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
// of fixed width.
class AnyIntegerAttrBase<AnyI attrValType, string descr> :
"test.int_attrs"() {
// CHECK: 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
si32_attr = 7 : si32,
// CHECK-SAME: ui32_attr = 6 : ui32
"test.int_attrs"() {
// CHECK: any_i32_attr = 5 : si32
any_i32_attr = 5 : si32,
+ index_attr = 8 : index,
si32_attr = 7 : si32,
ui32_attr = 6 : ui32
} : () -> ()
"test.int_attrs"() {
// CHECK: any_i32_attr = 5 : i32
any_i32_attr = 5 : i32,
+ index_attr = 8 : index,
si32_attr = 7 : si32,
ui32_attr = 6 : ui32
} : () -> ()
// expected-error @+1 {{'si32_attr' failed to satisfy constraint: 32-bit signed integer attribute}}
"test.int_attrs"() {
any_i32_attr = 5 : i32,
+ index_attr = 8 : index,
si32_attr = 7 : ui32,
ui32_attr = 6 : ui32
} : () -> ()
// expected-error @+1 {{'ui32_attr' failed to satisfy constraint: 32-bit unsigned integer attribute}}
"test.int_attrs"() {
any_i32_attr = 5 : i32,
+ index_attr = 8 : index,
si32_attr = 7 : si32,
ui32_attr = 6 : si32
} : () -> ()