diff --git a/mlir/examples/toy/Ch2/include/toy/Ops.td b/mlir/examples/toy/Ch2/include/toy/Ops.td index 6a3e77d06adb..e82302952e6f 100644 --- 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 index 01591a5eb69b..999ea86f03de 100644 --- 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 index ed2edc10e90f..537177bbd680 100644 --- 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 index b300aee147aa..3645141a0962 100644 --- 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 index c459fed11f8e..b70e14c2a7a2 100644 --- 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 index cddfd3674b6b..9db68fe7b98e 100644 --- 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 index 1b5780688bd5..da1bced4c989 100644 --- 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 index 95c2b4c3934f..674318431ff6 100644 --- 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 index 8632cb8cacc5..eda10d8c13b4 100644 --- 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 index d06b80292816..c702ed8d2fca 100644 --- 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 index c875d1cac7dd..a969fb8fe34e 100644 --- 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 index c13b02783635..b442d48e0e67 100644 --- 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 index c5919d5cbc80..90489299bafe 100644 --- 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 index 33dbcf1ae49f..1fa69fabfc95 100644 --- 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 index 52c73235e470..227ce33a26b4 100644 --- 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 index 227a48df2837..5605e1a784bf 100644 --- 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 index 4dfc439a3404..d89fcd722915 100644 --- 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 index 8025ad1e2bbc..d5bbedb9559d 100644 --- 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 index 4735c8ca3725..8f8073f6a1e6 100644 --- 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 index 6c52c0fbaaea..f800e349f9ac 100644 --- 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 index faf114ccd083..260e954371b1 100644 --- 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 index 26b332c4c451..a28c843c2023 100644 --- 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 index b78ecc3cd8fe..f9796817e38b 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td @@ -33,6 +33,7 @@ include "mlir/Dialect/SPIRV/SPIRVGroupOps.td" 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 index 89480664534f..b6affd876f54 100644 --- 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 index b1d02ed1314a..00e25363ec5b 100644 --- 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 index 331a43429039..ee7c1431429c 100644 --- 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 index f32b8df7a9c3..62b811ee6101 100644 --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -1555,10 +1555,6 @@ def FunctionLike : NativeOpTrait<"FunctionLike">; 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 index df18d63843fb..ebf3da628ebf 100644 --- a/mlir/include/mlir/Interfaces/SideEffects.td +++ b/mlir/include/mlir/Interfaces/SideEffects.td @@ -188,4 +188,13 @@ class MemWrite : 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 index 5471ab7b5eae..d9710ba03961 100644 --- a/mlir/test/lib/TestDialect/TestOps.td +++ b/mlir/test/lib/TestDialect/TestOps.td @@ -15,6 +15,7 @@ include "mlir/Interfaces/SideEffects.td" 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 index f07f99527ff8..2bad43dca074 100644 --- 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 index 98ce4baeafcd..26f41d478eff 100644 --- a/mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp +++ b/mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp @@ -225,7 +225,8 @@ static bool emitIntrinsic(const llvm::Record &record, llvm::raw_ostream &os) { 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) {