diff --git a/mlir/examples/toy/Ch2/include/toy/Ops.td b/mlir/examples/toy/Ch2/include/toy/Ops.td --- a/mlir/examples/toy/Ch2/include/toy/Ops.td +++ b/mlir/examples/toy/Ch2/include/toy/Ops.td @@ -14,6 +14,7 @@ #define TOY_OPS include "mlir/IR/OpBase.td" +include "mlir/Interfaces/SideEffects.td" // Provide a definition of the 'toy' dialect in the ODS framework so that we // can define our operations. diff --git a/mlir/examples/toy/Ch3/include/toy/Ops.td b/mlir/examples/toy/Ch3/include/toy/Ops.td --- a/mlir/examples/toy/Ch3/include/toy/Ops.td +++ b/mlir/examples/toy/Ch3/include/toy/Ops.td @@ -13,7 +13,7 @@ #ifndef TOY_OPS #define TOY_OPS -include "mlir/IR/OpBase.td" +include "mlir/Interfaces/SideEffects.td" // Provide a definition of the 'toy' dialect in the ODS framework so that we // can define our operations. diff --git a/mlir/examples/toy/Ch4/include/toy/Ops.td b/mlir/examples/toy/Ch4/include/toy/Ops.td --- a/mlir/examples/toy/Ch4/include/toy/Ops.td +++ b/mlir/examples/toy/Ch4/include/toy/Ops.td @@ -14,6 +14,7 @@ #define TOY_OPS include "mlir/Interfaces/CallInterfaces.td" +include "mlir/Interfaces/SideEffects.td" include "toy/ShapeInferenceInterface.td" // Provide a definition of the 'toy' dialect in the ODS framework so that we diff --git a/mlir/examples/toy/Ch5/include/toy/Ops.td b/mlir/examples/toy/Ch5/include/toy/Ops.td --- a/mlir/examples/toy/Ch5/include/toy/Ops.td +++ b/mlir/examples/toy/Ch5/include/toy/Ops.td @@ -14,6 +14,7 @@ #define TOY_OPS include "mlir/Interfaces/CallInterfaces.td" +include "mlir/Interfaces/SideEffects.td" include "toy/ShapeInferenceInterface.td" // Provide a definition of the 'toy' dialect in the ODS framework so that we diff --git a/mlir/examples/toy/Ch6/include/toy/Ops.td b/mlir/examples/toy/Ch6/include/toy/Ops.td --- a/mlir/examples/toy/Ch6/include/toy/Ops.td +++ b/mlir/examples/toy/Ch6/include/toy/Ops.td @@ -14,6 +14,7 @@ #define TOY_OPS include "mlir/Interfaces/CallInterfaces.td" +include "mlir/Interfaces/SideEffects.td" include "toy/ShapeInferenceInterface.td" // Provide a definition of the 'toy' dialect in the ODS framework so that we diff --git a/mlir/examples/toy/Ch7/include/toy/Ops.td b/mlir/examples/toy/Ch7/include/toy/Ops.td --- a/mlir/examples/toy/Ch7/include/toy/Ops.td +++ b/mlir/examples/toy/Ch7/include/toy/Ops.td @@ -14,6 +14,7 @@ #define TOY_OPS include "mlir/Interfaces/CallInterfaces.td" +include "mlir/Interfaces/SideEffects.td" include "toy/ShapeInferenceInterface.td" // Provide a definition of the 'toy' dialect in the ODS framework so that we diff --git a/mlir/include/mlir/Dialect/AffineOps/AffineOps.td b/mlir/include/mlir/Dialect/AffineOps/AffineOps.td --- a/mlir/include/mlir/Dialect/AffineOps/AffineOps.td +++ b/mlir/include/mlir/Dialect/AffineOps/AffineOps.td @@ -14,7 +14,7 @@ #define AFFINE_OPS include "mlir/Dialect/AffineOps/AffineOpsBase.td" -include "mlir/IR/OpBase.td" +include "mlir/Interfaces/SideEffects.td" include "mlir/Transforms/LoopLikeInterface.td" def Affine_Dialect : Dialect { diff --git a/mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.td b/mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.td --- a/mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.td +++ b/mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.td @@ -16,6 +16,7 @@ include "mlir/IR/OpBase.td" include "mlir/Dialect/QuantOps/QuantPredicates.td" +include "mlir/Interfaces/SideEffects.td" def fxpmath_Dialect : Dialect { let name = "fxpmath"; diff --git a/mlir/include/mlir/Dialect/GPU/GPUOps.td b/mlir/include/mlir/Dialect/GPU/GPUOps.td --- a/mlir/include/mlir/Dialect/GPU/GPUOps.td +++ b/mlir/include/mlir/Dialect/GPU/GPUOps.td @@ -13,8 +13,8 @@ #ifndef GPU_OPS #define GPU_OPS -include "mlir/IR/OpBase.td" include "mlir/Dialect/LLVMIR/LLVMOpBase.td" +include "mlir/Interfaces/SideEffects.td" // Type constraint accepting standard integers, indices and wrapped LLVM integer // types. diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td @@ -15,6 +15,7 @@ include "mlir/Dialect/LLVMIR/LLVMOpBase.td" include "mlir/Interfaces/ControlFlowInterfaces.td" +include "mlir/Interfaces/SideEffects.td" class LLVM_Builder { string llvmBuilder = builder; diff --git a/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td --- a/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td @@ -14,6 +14,7 @@ #define NVVMIR_OPS include "mlir/Dialect/LLVMIR/LLVMOpBase.td" +include "mlir/Interfaces/SideEffects.td" //===----------------------------------------------------------------------===// // NVVM dialect definitions diff --git a/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td b/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td --- a/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td @@ -14,6 +14,7 @@ #define ROCDLIR_OPS include "mlir/Dialect/LLVMIR/LLVMOpBase.td" +include "mlir/Interfaces/SideEffects.td" //===----------------------------------------------------------------------===// // ROCDL dialect definitions diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td @@ -15,6 +15,7 @@ include "mlir/Dialect/AffineOps/AffineOpsBase.td" include "mlir/Dialect/Linalg/IR/LinalgBase.td" +include "mlir/Interfaces/SideEffects.td" // Base class for Linalg dialect ops that do not correspond to library calls. class Linalg_Op traits = []> : diff --git a/mlir/include/mlir/Dialect/LoopOps/LoopOps.td b/mlir/include/mlir/Dialect/LoopOps/LoopOps.td --- a/mlir/include/mlir/Dialect/LoopOps/LoopOps.td +++ b/mlir/include/mlir/Dialect/LoopOps/LoopOps.td @@ -13,7 +13,7 @@ #ifndef LOOP_OPS #define LOOP_OPS -include "mlir/IR/OpBase.td" +include "mlir/Interfaces/SideEffects.td" include "mlir/Transforms/LoopLikeInterface.td" def Loop_Dialect : Dialect { diff --git a/mlir/include/mlir/Dialect/QuantOps/QuantOps.td b/mlir/include/mlir/Dialect/QuantOps/QuantOps.td --- a/mlir/include/mlir/Dialect/QuantOps/QuantOps.td +++ b/mlir/include/mlir/Dialect/QuantOps/QuantOps.td @@ -15,6 +15,7 @@ include "mlir/IR/OpBase.td" include "mlir/Dialect/QuantOps/QuantPredicates.td" +include "mlir/Interfaces/SideEffects.td" def quant_Dialect : Dialect { let name = "quant"; diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVArithmeticOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVArithmeticOps.td --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVArithmeticOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVArithmeticOps.td @@ -15,6 +15,7 @@ #define SPIRV_ARITHMETIC_OPS include "mlir/Dialect/SPIRV/SPIRVBase.td" +include "mlir/Interfaces/SideEffects.td" class SPV_ArithmeticBinaryOp traits = []> : diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVBitOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVBitOps.td --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVBitOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVBitOps.td @@ -15,6 +15,7 @@ #define SPIRV_BIT_OPS include "mlir/Dialect/SPIRV/SPIRVBase.td" +include "mlir/Interfaces/SideEffects.td" class SPV_BitBinaryOp traits = []> : // All the operands type used in bit instructions are SPV_Integer. diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVCastOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVCastOps.td --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVCastOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVCastOps.td @@ -15,6 +15,7 @@ #define SPIRV_CAST_OPS include "mlir/Dialect/SPIRV/SPIRVBase.td" +include "mlir/Interfaces/SideEffects.td" class SPV_CastOp traits = []> : diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td @@ -15,6 +15,7 @@ #define SPIRV_COMPOSITE_OPS include "mlir/Dialect/SPIRV/SPIRVBase.td" +include "mlir/Interfaces/SideEffects.td" // ----- diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td @@ -17,6 +17,7 @@ include "mlir/Dialect/SPIRV/SPIRVBase.td" include "mlir/Interfaces/CallInterfaces.td" include "mlir/Interfaces/ControlFlowInterfaces.td" +include "mlir/Interfaces/SideEffects.td" // ----- diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td @@ -14,6 +14,7 @@ #define SPIRV_GLSL_OPS include "mlir/Dialect/SPIRV/SPIRVBase.td" +include "mlir/Interfaces/SideEffects.td" //===----------------------------------------------------------------------===// // SPIR-V GLSL 4.50 opcode specification. diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td @@ -15,6 +15,7 @@ #define SPIRV_LOGICAL_OPS include "mlir/Dialect/SPIRV/SPIRVBase.td" +include "mlir/Interfaces/SideEffects.td" class SPV_LogicalBinaryOp traits = []> : diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td @@ -33,6 +33,7 @@ include "mlir/Dialect/SPIRV/SPIRVLogicalOps.td" include "mlir/Dialect/SPIRV/SPIRVNonUniformOps.td" include "mlir/Dialect/SPIRV/SPIRVStructureOps.td" +include "mlir/Interfaces/SideEffects.td" // ----- diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVStructureOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVStructureOps.td --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVStructureOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVStructureOps.td @@ -15,8 +15,9 @@ #ifndef SPIRV_STRUCTURE_OPS #define SPIRV_STRUCTURE_OPS -include "mlir/Interfaces/CallInterfaces.td" include "mlir/Dialect/SPIRV/SPIRVBase.td" +include "mlir/Interfaces/CallInterfaces.td" +include "mlir/Interfaces/SideEffects.td" // ----- 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 @@ -13,9 +13,9 @@ #ifndef STANDARD_OPS #define STANDARD_OPS +include "mlir/IR/OpAsmInterface.td" include "mlir/Interfaces/CallInterfaces.td" include "mlir/Interfaces/ControlFlowInterfaces.td" -include "mlir/IR/OpAsmInterface.td" include "mlir/Interfaces/SideEffects.td" def Std_Dialect : Dialect { diff --git a/mlir/include/mlir/Dialect/VectorOps/VectorOps.td b/mlir/include/mlir/Dialect/VectorOps/VectorOps.td --- a/mlir/include/mlir/Dialect/VectorOps/VectorOps.td +++ b/mlir/include/mlir/Dialect/VectorOps/VectorOps.td @@ -13,8 +13,8 @@ #ifndef VECTOR_OPS #define VECTOR_OPS -include "mlir/IR/OpBase.td" include "mlir/Dialect/AffineOps/AffineOpsBase.td" +include "mlir/Interfaces/SideEffects.td" def Vector_Dialect : Dialect { let name = "vector"; 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 @@ -1555,10 +1555,6 @@ def IsolatedFromAbove : NativeOpTrait<"IsIsolatedFromAbove">; // Op results are float or vectors/tensors thereof. def ResultsAreFloatLike : NativeOpTrait<"ResultsAreFloatLike">; -// Op has no side effect. -def NoSideEffect : NativeOpTrait<"HasNoSideEffect">; -// Op has recursively computed side effects. -def RecursiveSideEffects : NativeOpTrait<"HasRecursiveSideEffects">; // Op has the same operand type. def SameTypeOperands : NativeOpTrait<"SameTypeOperands">; // Op has same shape for all operands. diff --git a/mlir/include/mlir/Interfaces/SideEffects.td b/mlir/include/mlir/Interfaces/SideEffects.td --- a/mlir/include/mlir/Interfaces/SideEffects.td +++ b/mlir/include/mlir/Interfaces/SideEffects.td @@ -188,4 +188,13 @@ : MemoryEffect<"MemoryEffects::Write", resourceName>; def MemWrite : MemWrite<"">; +//===----------------------------------------------------------------------===// +// Effect Traits +//===----------------------------------------------------------------------===// + +// Op has no side effect. +def NoSideEffect : NativeOpTrait<"HasNoSideEffect">; +// Op has recursively computed side effects. +def RecursiveSideEffects : NativeOpTrait<"HasRecursiveSideEffects">; + #endif // MLIR_INTERFACES_SIDEEFFECTS diff --git a/mlir/test/lib/TestDialect/TestOps.td b/mlir/test/lib/TestDialect/TestOps.td --- a/mlir/test/lib/TestDialect/TestOps.td +++ b/mlir/test/lib/TestDialect/TestOps.td @@ -15,6 +15,7 @@ include "mlir/Interfaces/CallInterfaces.td" include "mlir/Interfaces/ControlFlowInterfaces.td" include "mlir/Interfaces/InferTypeOpInterface.td" +include "mlir/Interfaces/SideEffects.td" def TEST_Dialect : Dialect { let name = "test"; diff --git a/mlir/test/mlir-tblgen/op-decl.td b/mlir/test/mlir-tblgen/op-decl.td --- a/mlir/test/mlir-tblgen/op-decl.td +++ b/mlir/test/mlir-tblgen/op-decl.td @@ -1,6 +1,7 @@ // RUN: mlir-tblgen -gen-op-decls -I %S/../../include %s | FileCheck --dump-input-on-failure %s include "mlir/IR/OpBase.td" +include "mlir/Interfaces/SideEffects.td" def Test_Dialect : Dialect { let name = "test"; diff --git a/mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp b/mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp --- a/mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp +++ b/mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp @@ -225,7 +225,8 @@ static bool emitIntrinsics(const llvm::RecordKeeper &records, llvm::raw_ostream &os) { llvm::emitSourceFileHeader("Operations for LLVM intrinsics", os); - os << "include \"mlir/Dialect/LLVMIR/LLVMOpBase.td\"\n\n"; + os << "include \"mlir/Dialect/LLVMIR/LLVMOpBase.td\"\n"; + os << "include \"mlir/Interfaces/SideEffects.td\"\n\n"; auto defs = records.getAllDerivedDefinitions("Intrinsic"); for (const llvm::Record *r : defs) {