-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MLIR] Split arith dialect from the std dialect
Create the Arithmetic dialect that contains basic integer and floating point arithmetic operations. Ops that did not meet this criterion were moved to the Math dialect. First of two atomic patches to remove integer and floating point operations from the standard dialect. Ops will be removed from the standard dialect in a subsequent patch. Reviewed By: ftynse, silvas Differential Revision: https://reviews.llvm.org/D110200
- Loading branch information
Showing
14 changed files
with
2,355 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_subdirectory(IR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
//===- Arithmetic.h - Arithmetic dialect --------------------------*- C++-*-==// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
#ifndef MLIR_DIALECT_ARITHMETIC_IR_ARITHMETIC_H_ | ||
#define MLIR_DIALECT_ARITHMETIC_IR_ARITHMETIC_H_ | ||
|
||
#include "mlir/IR/Dialect.h" | ||
#include "mlir/IR/OpDefinition.h" | ||
#include "mlir/Interfaces/CastInterfaces.h" | ||
#include "mlir/Interfaces/SideEffectInterfaces.h" | ||
#include "mlir/Interfaces/VectorInterfaces.h" | ||
|
||
//===----------------------------------------------------------------------===// | ||
// ArithmeticDialect | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "mlir/Dialect/Arithmetic/IR/ArithmeticOpsDialect.h.inc" | ||
|
||
//===----------------------------------------------------------------------===// | ||
// Arithmetic Dialect Enum Attributes | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "mlir/Dialect/Arithmetic/IR/ArithmeticOpsEnums.h.inc" | ||
|
||
//===----------------------------------------------------------------------===// | ||
// Arithmetic Dialect Operations | ||
//===----------------------------------------------------------------------===// | ||
|
||
#define GET_OP_CLASSES | ||
#include "mlir/Dialect/Arithmetic/IR/ArithmeticOps.h.inc" | ||
|
||
//===----------------------------------------------------------------------===// | ||
// Utility Functions | ||
//===----------------------------------------------------------------------===// | ||
|
||
namespace mlir { | ||
namespace arith { | ||
|
||
/// Compute `lhs` `pred` `rhs`, where `pred` is one of the known integer | ||
/// comparison predicates. | ||
bool applyCmpPredicate(arith::CmpIPredicate predicate, const APInt &lhs, | ||
const APInt &rhs); | ||
|
||
/// Compute `lhs` `pred` `rhs`, where `pred` is one of the known floating point | ||
/// comparison predicates. | ||
bool applyCmpPredicate(arith::CmpFPredicate predicate, const APFloat &lhs, | ||
const APFloat &rhs); | ||
|
||
} // end namespace arith | ||
} // end namespace mlir | ||
|
||
#endif // MLIR_DIALECT_ARITHMETIC_IR_ARITHMETIC_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
//===- ArithmeticBase.td - Base defs for arith dialect ------*- tablegen -*-==// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef ARITHMETIC_BASE | ||
#define ARITHMETIC_BASE | ||
|
||
include "mlir/IR/OpBase.td" | ||
|
||
def Arithmetic_Dialect : Dialect { | ||
let name = "arith"; | ||
let cppNamespace = "::mlir::arith"; | ||
let description = [{ | ||
The arithmetic dialect is intended to hold basic integer and floating point | ||
mathematical operations. This includes unary, binary, and ternary arithmetic | ||
ops, bitwise and shift ops, cast ops, and compare ops. Operations in this | ||
dialect also accept vectors and tensors of integers or floats. | ||
}]; | ||
} | ||
|
||
// The predicate indicates the type of the comparison to perform: | ||
// (un)orderedness, (in)equality and less/greater than (or equal to) as | ||
// well as predicates that are always true or false. | ||
def Arith_CmpFPredicateAttr : I64EnumAttr< | ||
"CmpFPredicate", "", | ||
[ | ||
I64EnumAttrCase<"AlwaysFalse", 0, "false">, | ||
I64EnumAttrCase<"OEQ", 1, "oeq">, | ||
I64EnumAttrCase<"OGT", 2, "ogt">, | ||
I64EnumAttrCase<"OGE", 3, "oge">, | ||
I64EnumAttrCase<"OLT", 4, "olt">, | ||
I64EnumAttrCase<"OLE", 5, "ole">, | ||
I64EnumAttrCase<"ONE", 6, "one">, | ||
I64EnumAttrCase<"ORD", 7, "ord">, | ||
I64EnumAttrCase<"UEQ", 8, "ueq">, | ||
I64EnumAttrCase<"UGT", 9, "ugt">, | ||
I64EnumAttrCase<"UGE", 10, "uge">, | ||
I64EnumAttrCase<"ULT", 11, "ult">, | ||
I64EnumAttrCase<"ULE", 12, "ule">, | ||
I64EnumAttrCase<"UNE", 13, "une">, | ||
I64EnumAttrCase<"UNO", 14, "uno">, | ||
I64EnumAttrCase<"AlwaysTrue", 15, "true">, | ||
]> { | ||
let cppNamespace = "::mlir::arith"; | ||
} | ||
|
||
def Arith_CmpIPredicateAttr : I64EnumAttr< | ||
"CmpIPredicate", "", | ||
[ | ||
I64EnumAttrCase<"eq", 0>, | ||
I64EnumAttrCase<"ne", 1>, | ||
I64EnumAttrCase<"slt", 2>, | ||
I64EnumAttrCase<"sle", 3>, | ||
I64EnumAttrCase<"sgt", 4>, | ||
I64EnumAttrCase<"sge", 5>, | ||
I64EnumAttrCase<"ult", 6>, | ||
I64EnumAttrCase<"ule", 7>, | ||
I64EnumAttrCase<"ugt", 8>, | ||
I64EnumAttrCase<"uge", 9>, | ||
]> { | ||
let cppNamespace = "::mlir::arith"; | ||
} | ||
|
||
#endif // ARITHMETIC_BASE |
Oops, something went wrong.