Step towards removing the hard coded behavior for this trait and to instead use common interface.
Differential Revision: https://reviews.llvm.org/D114208
include "mlir/IR/SymbolInterfaces.td"
include "mlir/Interfaces/CallInterfaces.td"
include "mlir/Interfaces/ControlFlowInterfaces.td"
+include "mlir/Interfaces/InferTypeOpInterface.td"
include "mlir/Interfaces/LoopLikeInterface.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
#define STANDALONE_OPS
include "Standalone/StandaloneDialect.td"
+include "mlir/Interfaces/InferTypeOpInterface.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
def Standalone_FooOp : Standalone_Op<"foo", [NoSideEffect,
include "mlir/Dialect/Arithmetic/IR/ArithmeticBase.td"
include "mlir/Interfaces/CastInterfaces.td"
+include "mlir/Interfaces/InferTypeOpInterface.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
include "mlir/Interfaces/VectorInterfaces.td"
include "mlir/IR/OpAsmInterface.td"
#define COMPLEX_OPS
include "mlir/Dialect/Complex/IR/ComplexBase.td"
+include "mlir/Interfaces/InferTypeOpInterface.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
class Complex_Op<string mnemonic, list<OpTrait> traits = []>
let arguments = (ins Complex<AnyFloat>:$lhs, Complex<AnyFloat>:$rhs);
let results = (outs I1:$result);
- let builders = [
- OpBuilder<(ins "Value":$lhs, "Value":$rhs), [{
- build($_builder, $_state, $_builder.getI1Type(), lhs, rhs);
- }]>];
let assemblyFormat = "$lhs `,` $rhs attr-dict `:` type($lhs)";
}
let arguments = (ins Complex<AnyFloat>:$lhs, Complex<AnyFloat>:$rhs);
let results = (outs I1:$result);
- let builders = [
- OpBuilder<(ins "Value":$lhs, "Value":$rhs), [{
- build($_builder, $_state, $_builder.getI1Type(), lhs, rhs);
- }]>];
let assemblyFormat = "$lhs `,` $rhs attr-dict `:` type($lhs)";
}
#include "mlir/IR/OpDefinition.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/IR/SymbolTable.h"
+#include "mlir/Interfaces/InferTypeOpInterface.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
namespace mlir {
include "mlir/Dialect/LLVMIR/LLVMOpBase.td"
include "mlir/IR/SymbolInterfaces.td"
include "mlir/Interfaces/DataLayoutInterfaces.td"
+include "mlir/Interfaces/InferTypeOpInterface.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
//===----------------------------------------------------------------------===//
#include "mlir/IR/TypeSupport.h"
#include "mlir/IR/Types.h"
#include "mlir/Interfaces/ControlFlowInterfaces.h"
+#include "mlir/Interfaces/InferTypeOpInterface.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/LLVMContext.h"
include "mlir/Dialect/LLVMIR/LLVMOpsInterfaces.td"
include "mlir/IR/SymbolInterfaces.td"
include "mlir/Interfaces/ControlFlowInterfaces.td"
+include "mlir/Interfaces/InferTypeOpInterface.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
def FMFnnan : BitEnumAttrCase<"nnan", 0x1>;
let arguments = (ins LLVM_ScalarOrVectorOf<I1>:$condition,
LLVM_Type:$trueValue, LLVM_Type:$falseValue);
let results = (outs LLVM_Type:$res);
- let builders = [
- OpBuilder<(ins "Value":$condition, "Value":$lhs, "Value":$rhs),
- [{
- build($_builder, $_state, lhs.getType(), condition, lhs, rhs);
- }]>];
let assemblyFormat = "operands attr-dict `:` type($condition) `,` type($res)";
}
def LLVM_FreezeOp : LLVM_Op<"freeze", [SameOperandsAndResultType]> {
#define MATH_OPS
include "mlir/Dialect/Math/IR/MathBase.td"
+include "mlir/Interfaces/InferTypeOpInterface.td"
include "mlir/Interfaces/VectorInterfaces.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
#define DIALECT_QUANT_QUANT_OPS_
include "mlir/Dialect/Quant/QuantOpsBase.td"
+include "mlir/Interfaces/InferTypeOpInterface.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
//===----------------------------------------------------------------------===//
#define MLIR_DIALECT_SPIRV_IR_ARITHMETIC_OPS
include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
+include "mlir/Interfaces/InferTypeOpInterface.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
class SPV_ArithmeticBinaryOp<string mnemonic, Type type,
SPV_SelectType:$result
);
- let builders = [
- OpBuilder<(ins "Value":$cond, "Value":$trueValue, "Value":$falseValue)>];
-
let assemblyFormat = [{
operands attr-dict `:` type($condition) `,` type($result)
}];
SPV_Bool:$result
);
- let builders = [OpBuilder<(ins "spirv::Scope")>];
-
let assemblyFormat = "$execution_scope attr-dict `:` type($result)";
}
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/Interfaces/ControlFlowInterfaces.h"
+#include "mlir/Interfaces/InferTypeOpInterface.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
#include "llvm/Support/PointerLikeTypeTraits.h"
include "mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.td"
include "mlir/Dialect/SparseTensor/IR/SparseTensorBase.td"
+include "mlir/Interfaces/InferTypeOpInterface.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
//===----------------------------------------------------------------------===//
#include "mlir/Interfaces/CallInterfaces.h"
#include "mlir/Interfaces/CastInterfaces.h"
#include "mlir/Interfaces/ControlFlowInterfaces.h"
+#include "mlir/Interfaces/InferTypeOpInterface.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
#include "mlir/Interfaces/VectorInterfaces.h"
include "mlir/Interfaces/CallInterfaces.td"
include "mlir/Interfaces/CastInterfaces.td"
include "mlir/Interfaces/ControlFlowInterfaces.td"
+include "mlir/Interfaces/InferTypeOpInterface.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
include "mlir/Interfaces/VectorInterfaces.td"
let results = (outs Index);
let verifier = ?;
- let builders = [
- OpBuilder<(ins "Value":$tensor), [{
- auto indexType = $_builder.getIndexType();
- build($_builder, $_state, indexType, tensor);
- }]>];
-
let hasFolder = 1;
let assemblyFormat = "$memrefOrTensor attr-dict `:` type($memrefOrTensor)";
}
AnyType:$false_value);
let results = (outs AnyType:$result);
- let builders = [
- OpBuilder<(ins "Value":$condition, "Value":$trueValue,
- "Value":$falseValue), [{
- $_state.addOperands({condition, trueValue, falseValue});
- $_state.addTypes(trueValue.getType());
- }]>];
-
let hasCanonicalizer = 1;
let hasFolder = 1;
}
#ifndef X86VECTOR_OPS
#define X86VECTOR_OPS
+include "mlir/Interfaces/InferTypeOpInterface.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
include "mlir/Dialect/LLVMIR/LLVMOpBase.td"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/IR/OpImplementation.h"
+#include "mlir/Interfaces/InferTypeOpInterface.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
#include "mlir/Dialect/X86Vector/X86VectorDialect.h.inc"
def SameOperandsShape : NativeOpTrait<"SameOperandsShape">;
// Op has same operand and result shape.
def SameOperandsAndResultShape : NativeOpTrait<"SameOperandsAndResultShape">;
-// Op has the same operand and result type.
-def SameOperandsAndResultType : NativeOpTrait<"SameOperandsAndResultType">;
// Op has the same element type (or type itself, if scalar) for all operands.
def SameOperandsElementType : NativeOpTrait<"SameOperandsElementType">;
// Op has the same operand and result element type (or type itself, if scalar).
];
}
+// Op has the same operand and result type.
+// TODO: Change from hard coded to utilizing type inference trait.
+def SameOperandsAndResultType : NativeOpTrait<"SameOperandsAndResultType">;
+
#endif // MLIR_INFERTYPEOPINTERFACE
MLIRCallInterfaces
MLIRControlFlowInterfaces
MLIRDataLayoutInterfaces
+ MLIRInferTypeOpInterface
MLIRIR
MLIRSideEffectInterfaces
MLIRSupport
// spv.GroupNonUniformElectOp
//===----------------------------------------------------------------------===//
-void spirv::GroupNonUniformElectOp::build(OpBuilder &builder,
- OperationState &state,
- spirv::Scope scope) {
- build(builder, state, builder.getI1Type(), scope);
-}
-
static LogicalResult verify(spirv::GroupNonUniformElectOp groupOp) {
spirv::Scope scope = groupOp.execution_scope();
if (scope != spirv::Scope::Workgroup && scope != spirv::Scope::Subgroup)
// spv.Select
//===----------------------------------------------------------------------===//
-void spirv::SelectOp::build(OpBuilder &builder, OperationState &state,
- Value cond, Value trueValue, Value falseValue) {
- build(builder, state, trueValue.getType(), cond, trueValue, falseValue);
-}
-
static LogicalResult verify(spirv::SelectOp op) {
if (auto conditionTy = op.condition().getType().dyn_cast<VectorType>()) {
auto resultVectorTy = op.result().getType().dyn_cast<VectorType>();
MLIRCallInterfaces
MLIRCastInterfaces
MLIRControlFlowInterfaces
+ MLIRInferTypeOpInterface
MLIRIR
MLIRSideEffectInterfaces
MLIRVectorInterfaces
#include "mlir/IR/Builders.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/IR/TypeUtilities.h"
+#include "mlir/Interfaces/InferTypeOpInterface.h"
using namespace mlir;
// -----
func @bit_field_insert_invalid_insert_type(%base: vector<3xi32>, %insert: vector<2xi32>, %offset: i32, %count: i16) -> vector<3xi32> {
- // expected-error @+1 {{all of {base, insert, result} have same type}}
+ // TODO: expand post change in verification order. This is currently only
+ // verifying that the type verification is failing but not the specific error
+ // message. In final state the error should refer to mismatch in base and
+ // insert.
+ // expected-error @+1 {{type}}
%0 = "spv.BitFieldInsert" (%base, %insert, %offset, %count) : (vector<3xi32>, vector<2xi32>, i32, i16) -> vector<3xi32>
spv.ReturnValue %0 : vector<3xi32>
}
// -----
func @bit_field_u_extract_invalid_result_type(%base: vector<3xi32>, %offset: i32, %count: i16) -> vector<4xi32> {
- // expected-error @+1 {{failed to verify that all of {base, result} have same type}}
+ // expected-error @+1 {{inferred type(s) 'vector<3xi32>' are incompatible with return type(s) of operation 'vector<4xi32>'}}
%0 = "spv.BitFieldUExtract" (%base, %offset, %count) : (vector<3xi32>, i32, i16) -> vector<4xi32>
spv.ReturnValue %0 : vector<4xi32>
}
func @select_op(%arg1: vector<4xi1>) -> () {
%0 = spv.Constant dense<[2.0, 3.0, 4.0]> : vector<3xf32>
%1 = spv.Constant dense<[5, 6, 7]> : vector<3xi32>
- // expected-error @+1 {{all of {true_value, false_value, result} have same type}}
+ // TODO: expand post change in verification order. This is currently only
+ // verifying that the type verification is failing but not the specific error
+ // message. In final state the error should refer to mismatch in true_value and
+ // false_value.
+ // expected-error @+1 {{type}}
%2 = "spv.Select"(%arg1, %1, %0) : (vector<4xi1>, vector<3xi32>, vector<3xf32>) -> vector<3xi32>
return
}
func @func_with_ops(i1, i32, i64) {
^bb0(%cond : i1, %t : i32, %f : i64):
- // expected-error@+1 {{all of {true_value, false_value, result} have same type}}
+ // TODO: expand post change in verification order. This is currently only
+ // verifying that the type verification is failing but not the specific error
+ // message. In final state the error should refer to mismatch in true_value and
+ // false_value.
+ // expected-error@+1 {{type}}
%r = "std.select"(%cond, %t, %f) : (i1, i32, i64) -> i32
}
srcs = ["include/mlir/Dialect/X86Vector/X86Vector.td"],
includes = ["include"],
deps = [
+ ":InferTypeOpInterfaceTdFiles",
":LLVMOpsTdFiles",
":SideEffectInterfacesTdFiles",
],
includes = ["include"],
deps = [
":IR",
+ ":InferTypeOpInterface",
":LLVMDialect",
":SideEffectInterfaces",
":X86VectorIncGen",
],
includes = ["include"],
deps = [
+ ":InferTypeOpInterfaceTdFiles",
":OpBaseTdFiles",
":SideEffectInterfacesTdFiles",
],
deps = [
":ArithmeticDialect",
":IR",
+ ":InferTypeOpInterface",
":SideEffectInterfaces",
":SparseTensorAttrDefsIncGen",
":SparseTensorOpsIncGen",
":CallInterfacesTdFiles",
":CastInterfacesTdFiles",
":ControlFlowInterfacesTdFiles",
+ ":InferTypeOpInterfaceTdFiles",
":OpBaseTdFiles",
":SideEffectInterfacesTdFiles",
":VectorInterfacesTdFiles",
":CommonFolders",
":ControlFlowInterfaces",
":IR",
+ ":InferTypeOpInterface",
":SideEffectInterfaces",
":StandardOpsIncGen",
":Support",
":ControlFlowInterfaces",
":DataLayoutInterfaces",
":IR",
+ ":InferTypeOpInterface",
":LLVMDialectAttributesIncGen",
":LLVMDialectInterfaceIncGen",
":LLVMOpsIncGen",
":GPUBaseIncGen",
":GPUOpsIncGen",
":IR",
+ ":InferTypeOpInterface",
":LLVMDialect",
":MemRefDialect",
":SideEffectInterfaces",
includes = ["include"],
deps = [
":ControlFlowInterfacesTdFiles",
+ ":InferTypeOpInterfaceTdFiles",
":OpBaseTdFiles",
":SideEffectInterfacesTdFiles",
],
deps = [
":CallInterfacesTdFiles",
":ControlFlowInterfacesTdFiles",
+ ":InferTypeOpInterfaceTdFiles",
":OpBaseTdFiles",
":SideEffectInterfacesTdFiles",
],
":CommonFolders",
":ControlFlowInterfaces",
":IR",
+ ":InferTypeOpInterface",
":Parser",
":Pass",
":SPIRVAttrUtilsGen",
],
includes = ["include"],
deps = [
+ ":InferTypeOpInterfaceTdFiles",
":OpBaseTdFiles",
":SideEffectInterfacesTdFiles",
],
],
includes = ["include"],
deps = [
+ ":InferTypeOpInterfaceTdFiles",
":OpBaseTdFiles",
":SideEffectInterfacesTdFiles",
],
includes = ["include"],
deps = [
":CastInterfacesTdFiles",
+ ":InferTypeOpInterfaceTdFiles",
":OpBaseTdFiles",
":SideEffectInterfacesTdFiles",
":VectorInterfacesTdFiles",
],
includes = ["include"],
deps = [
+ ":InferTypeOpInterfaceTdFiles",
":OpBaseTdFiles",
":SideEffectInterfacesTdFiles",
":VectorInterfacesTdFiles",