forked from OSchip/llvm-project
[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
This commit is contained in:
parent
c2f628e46c
commit
997f33cfee
|
@ -845,6 +845,16 @@ def BoolAttr : Attr<CPred<"$_self.isa<BoolAttr>()">, "bool attribute"> {
|
||||||
let constBuilderCall = "$_builder.getBoolAttr($0)";
|
let constBuilderCall = "$_builder.getBoolAttr($0)";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Index attribute.
|
||||||
|
def IndexAttr :
|
||||||
|
TypedAttrBase<
|
||||||
|
Index, "IntegerAttr",
|
||||||
|
And<[CPred<"$_self.isa<IntegerAttr>()">,
|
||||||
|
CPred<"$_self.cast<IntegerAttr>().getType().isa<IndexType>()">]>,
|
||||||
|
"index attribute"> {
|
||||||
|
let returnType = [{ APInt }];
|
||||||
|
}
|
||||||
|
|
||||||
// Base class for any integer (regardless of signedness semantics) attributes
|
// Base class for any integer (regardless of signedness semantics) attributes
|
||||||
// of fixed width.
|
// of fixed width.
|
||||||
class AnyIntegerAttrBase<AnyI attrValType, string descr> :
|
class AnyIntegerAttrBase<AnyI attrValType, string descr> :
|
||||||
|
|
|
@ -8,6 +8,8 @@ func @int_attrs_pass() {
|
||||||
"test.int_attrs"() {
|
"test.int_attrs"() {
|
||||||
// CHECK: any_i32_attr = 5 : ui32
|
// CHECK: any_i32_attr = 5 : ui32
|
||||||
any_i32_attr = 5 : ui32,
|
any_i32_attr = 5 : ui32,
|
||||||
|
// CHECK-SAME: index_attr = 8 : index
|
||||||
|
index_attr = 8 : index,
|
||||||
// CHECK-SAME: si32_attr = 7 : si32
|
// CHECK-SAME: si32_attr = 7 : si32
|
||||||
si32_attr = 7 : si32,
|
si32_attr = 7 : si32,
|
||||||
// CHECK-SAME: ui32_attr = 6 : ui32
|
// CHECK-SAME: ui32_attr = 6 : ui32
|
||||||
|
|
|
@ -199,6 +199,7 @@ def I64EnumAttrOp : TEST_Op<"i64_enum_attr"> {
|
||||||
def IntAttrOp : TEST_Op<"int_attrs"> {
|
def IntAttrOp : TEST_Op<"int_attrs"> {
|
||||||
let arguments = (ins
|
let arguments = (ins
|
||||||
AnyI32Attr:$any_i32_attr,
|
AnyI32Attr:$any_i32_attr,
|
||||||
|
IndexAttr:$index_attr,
|
||||||
UI32Attr:$ui32_attr,
|
UI32Attr:$ui32_attr,
|
||||||
SI32Attr:$si32_attr
|
SI32Attr:$si32_attr
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue