diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td --- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td +++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td @@ -109,7 +109,7 @@ // i %0, %1 : i32 class IntArithmeticOp traits = []> : ArithmeticOp, - Arguments<(ins SignlessIntegerLike:$lhs, SignlessIntegerLike:$rhs)>; + Arguments<(ins IntegerLike:$lhs, IntegerLike:$rhs)>; // Base class for standard arithmetic binary operations on floats, vectors and // tensors thereof. This operation has two operands and returns one result, 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 @@ -678,6 +678,14 @@ TensorOf<[I1]>.predicate]>, "bool-like">; +// Type constraint for integer-like types: integers, indices, vectors of +// integers, tensors of integers. +def IntegerLike : TypeConstraint.predicate, + TensorOf<[AnyInteger]>.predicate]>, + "integer-like">; + // Type constraint for signless-integer-like types: signless integers, indices, // vectors of signless integers, tensors of signless integers. def SignlessIntegerLike : TypeConstraint, %arg1: f32, %arg2: i32, %arg3: index, %arg4: i64, %arg5: f16) { -func @standard_instrs(tensor<4x4x?xf32>, f32, i32, index, i64, f16) { -^bb42(%t: tensor<4x4x?xf32>, %f: f32, %i: i32, %idx : index, %j: i64, %half: f16): +// CHECK-LABEL: func @standard_instrs(%arg0: tensor<4x4x?xf32>, %arg1: f32, %arg2: i32, %arg3: index, %arg4: i64, %arg5: f16, %arg6: si32, %arg7: ui32) { +func @standard_instrs(tensor<4x4x?xf32>, f32, i32, index, i64, f16, si32, ui32) { +^bb42(%t: tensor<4x4x?xf32>, %f: f32, %i: i32, %idx : index, %j: i64, %half: f16, %si: si32, %ui: ui32): // CHECK: %0 = dim %arg0, 2 : tensor<4x4x?xf32> %a = "std.dim"(%t){index = 2} : (tensor<4x4x?xf32>) -> index @@ -515,6 +515,18 @@ // CHECK: %{{[0-9]+}} = rsqrt %arg1 : f32 %145 = rsqrt %f : f32 + // CHECK: %{{[0-9]+}} = addi %arg6, %arg6 : si32 + %146 = "std.addi"(%si, %si) : (si32,si32) -> si32 + + // CHECK: %{{[0-9]+}} = addi %{{[0-9]+}}, %{{[0-9]+}} : si32 + %147 = addi %146, %146 : si32 + + // CHECK: %{{[0-9]+}} = addi %arg7, %arg7 : ui32 + %148 = "std.addi"(%ui, %ui) : (ui32,ui32) -> ui32 + + // CHECK: %{{[0-9]+}} = addi %{{[0-9]+}}, %{{[0-9]+}} : ui32 + %149 = addi %148, %148 : ui32 + return } diff --git a/mlir/test/IR/invalid-ops.mlir b/mlir/test/IR/invalid-ops.mlir --- a/mlir/test/IR/invalid-ops.mlir +++ b/mlir/test/IR/invalid-ops.mlir @@ -186,7 +186,7 @@ func @func_with_ops(f32) { ^bb0(%a : f32): - // expected-error@+1 {{'std.addi' op operand #0 must be signless-integer-like}} + // expected-error@+1 {{'std.addi' op operand #0 must be integer-like}} %sf = addi %a, %a : f32 }