Skip to content

Commit 997f33c

Browse files
ulysseBftynse
authored andcommitted
[MLIR] Add IndexAttr to primitive attributes kinds in tablegen.
Summary: OpBase.td defined attributes kind for all integer types expect index. This commit fixes that by adding an IndexAttr attribute kind. Differential Revision: https://reviews.llvm.org/D78195
1 parent c2f628e commit 997f33c

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

Diff for: mlir/include/mlir/IR/OpBase.td

+10
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,16 @@ def BoolAttr : Attr<CPred<"$_self.isa<BoolAttr>()">, "bool attribute"> {
845845
let constBuilderCall = "$_builder.getBoolAttr($0)";
846846
}
847847

848+
// Index attribute.
849+
def IndexAttr :
850+
TypedAttrBase<
851+
Index, "IntegerAttr",
852+
And<[CPred<"$_self.isa<IntegerAttr>()">,
853+
CPred<"$_self.cast<IntegerAttr>().getType().isa<IndexType>()">]>,
854+
"index attribute"> {
855+
let returnType = [{ APInt }];
856+
}
857+
848858
// Base class for any integer (regardless of signedness semantics) attributes
849859
// of fixed width.
850860
class AnyIntegerAttrBase<AnyI attrValType, string descr> :

Diff for: mlir/test/IR/attribute.mlir

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ func @int_attrs_pass() {
88
"test.int_attrs"() {
99
// CHECK: any_i32_attr = 5 : ui32
1010
any_i32_attr = 5 : ui32,
11+
// CHECK-SAME: index_attr = 8 : index
12+
index_attr = 8 : index,
1113
// CHECK-SAME: si32_attr = 7 : si32
1214
si32_attr = 7 : si32,
1315
// CHECK-SAME: ui32_attr = 6 : ui32

Diff for: mlir/test/lib/Dialect/Test/TestOps.td

+1
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ def I64EnumAttrOp : TEST_Op<"i64_enum_attr"> {
199199
def IntAttrOp : TEST_Op<"int_attrs"> {
200200
let arguments = (ins
201201
AnyI32Attr:$any_i32_attr,
202+
IndexAttr:$index_attr,
202203
UI32Attr:$ui32_attr,
203204
SI32Attr:$si32_attr
204205
);

0 commit comments

Comments
 (0)