diff --git a/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td index 30df3b739e5ca..2fcb199e65673 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td @@ -14,12 +14,13 @@ #define NVVMIR_OPS include "mlir/IR/EnumAttr.td" +include "mlir/Interfaces/ControlFlowInterfaces.td" +include "mlir/Interfaces/InferIntRangeInterface.td" +include "mlir/Interfaces/SideEffectInterfaces.td" include "mlir/Dialect/GPU/IR/CompilationAttrInterfaces.td" include "mlir/Dialect/LLVMIR/LLVMOpBase.td" include "mlir/Dialect/LLVMIR/NVVMRequiresSMTraits.td" -include "mlir/Interfaces/SideEffectInterfaces.td" include "mlir/Dialect/LLVMIR/BasicPtxBuilderInterface.td" -include "mlir/Interfaces/InferIntRangeInterface.td" include "mlir/Dialect/LLVMIR/LLVMTypes.td" def LLVM_PointerGeneric : LLVM_PointerInAddressSpace<0>; @@ -561,7 +562,7 @@ def NVVM_MBarrierTestWaitSharedOp : NVVM_Op<"mbarrier.test.wait.shared">, // NVVM synchronization op definitions //===----------------------------------------------------------------------===// -def NVVM_Barrier0Op : NVVM_Op<"barrier0"> { +def NVVM_Barrier0Op : NVVM_Op<"barrier0", [Convergent]> { let assemblyFormat = "attr-dict"; string llvmBuilder = [{ createIntrinsicCall( diff --git a/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h b/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h index d63800c12d132..750a9f86e49d7 100644 --- a/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h +++ b/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h @@ -337,8 +337,12 @@ struct ReturnLike : public TraitBase { return success(); } }; -} // namespace OpTrait +// The Operation may not be made control-dependent on any additional values. +// See https://llvm.org/docs/ConvergentOperations.html for more details. +template +struct Convergent : public TraitBase {}; +} // namespace OpTrait } // namespace mlir //===----------------------------------------------------------------------===// diff --git a/mlir/include/mlir/Interfaces/ControlFlowInterfaces.td b/mlir/include/mlir/Interfaces/ControlFlowInterfaces.td index b8d08cc553caa..6545d72aeb61a 100644 --- a/mlir/include/mlir/Interfaces/ControlFlowInterfaces.td +++ b/mlir/include/mlir/Interfaces/ControlFlowInterfaces.td @@ -511,4 +511,7 @@ def ReturnLike : TraitList<[ > ]>; +// Op is "convergent". +def Convergent : NativeOpTrait<"Convergent">; + #endif // MLIR_INTERFACES_CONTROLFLOWINTERFACES diff --git a/mlir/test/lib/Dialect/Test/TestOps.td b/mlir/test/lib/Dialect/Test/TestOps.td index 2eaad552a7a3a..ad14666a1a2cc 100644 --- a/mlir/test/lib/Dialect/Test/TestOps.td +++ b/mlir/test/lib/Dialect/Test/TestOps.td @@ -2113,6 +2113,11 @@ def TestTypeChangerOp : TEST_Op<"type_changer">, def TestValidOp : TEST_Op<"valid", [Terminator]>, Arguments<(ins Variadic)>; +def TestConvergentOp : TEST_Op<"convergent", [Convergent]> { + let arguments = (ins AnyType); + let results = (outs AnyType); +} + def TestMergeBlocksOp : TEST_Op<"merge_blocks"> { let summary = "merge_blocks operation"; let description = [{