diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -58,7 +58,7 @@ // 1. CPred: the primitive leaf predicate. // 2. Compound predicate: a predicate composed from child predicates using // predicate combiners ("conjunction", "disjunction", "negation" or -// "substitution"). +// "substitution") e.g. PredCombinerAnd. class Pred; // A logical predicate wrapping any C expression. @@ -81,7 +81,7 @@ // `CPred<"$_self.isa()">` (see the following sections for details). // Then for `F32:$attr`,`$_self` will be replaced by `$attr`. // For type constraints, it's a little bit special since we want the -// constraints on each type definition reads naturally and we want to attach +// constraints on each type definition to read naturally and we want to attach // type constraints directly to an operand/result, $_self will be replaced // by the operand/result's type. E.g., for `F32` in `F32:$operand`, its // `$_self` will be expanded as `getOperand(...).getType()`. @@ -363,12 +363,10 @@ AnyTypeOf), !interleave(widths, "/") # "-bit integer", "::mlir::IntegerType">; - -def AnyI1 : AnyI<1>; -def AnyI8 : AnyI<8>; -def AnyI16 : AnyI<16>; -def AnyI32 : AnyI<32>; -def AnyI64 : AnyI<64>; +// Define AnyI1, AnyI8, ... +foreach i = [1,8,16,32,64] in { + def AnyI#i : AnyI; +} // Any signless integer type irrespective of its width. def AnySignlessInteger : Type< @@ -387,11 +385,10 @@ AnyTypeOf), !interleave(widths, "/") # "-bit signless integer">; -def I1 : I<1>; -def I8 : I<8>; -def I16 : I<16>; -def I32 : I<32>; -def I64 : I<64>; +// Define I1, I8,I16 ... +foreach i = [1, 8, 16, 32, 64] in { + def I#i : I; +} // Any signed integer type irrespective of its width. def AnySignedInteger : Type< @@ -410,11 +407,9 @@ AnyTypeOf), !interleave(widths, "/") # "-bit signed integer">; -def SI1 : SI<1>; -def SI8 : SI<8>; -def SI16 : SI<16>; -def SI32 : SI<32>; -def SI64 : SI<64>; +foreach i = [1, 8, 16, 32, 64] in { + def SI#i : SI; +} // Any unsigned integer type irrespective of its width. def AnyUnsignedInteger : Type< @@ -433,11 +428,9 @@ AnyTypeOf), !interleave(widths, "/") # "-bit unsigned integer">; -def UI1 : UI<1>; -def UI8 : UI<8>; -def UI16 : UI<16>; -def UI32 : UI<32>; -def UI64 : UI<64>; +foreach i = [1, 8, 16, 32, 64] in { + def UI#i : UI; +} // Index type. def Index : Type()">, "index", @@ -466,11 +459,9 @@ AnyTypeOf), !interleave(widths, "/") # "-bit float">; -def F16 : F<16>; -def F32 : F<32>; -def F64 : F<64>; -def F80 : F<80>; -def F128 : F<128>; +foreach i = [16, 32, 64, 80, 128] in { + def F#i : F; +} def BF16 : Type, "bfloat16 type">, BuildableType<"$_builder.getBF16Type()">; @@ -698,11 +689,10 @@ def AnyStaticShapeTensor : StaticShapeTensorOf<[AnyType]>; -def I1Tensor : TensorOf<[I1]>; -def I8Tensor : TensorOf<[I8]>; -def I16Tensor : TensorOf<[I16]>; -def I32Tensor : TensorOf<[I32]>; -def I64Tensor : TensorOf<[I64]>; +// Define I1Tensor, I8Tensor, ... +foreach i = [1, 8, 16, 32, 64] in { + def I#i#Tensor : TensorOf<[!cast("I"#i)]>; +} def IndexTensor: TensorOf<[Index]>; def BF16Tensor : TensorOf<[BF16]>;