@@ -21,6 +21,7 @@ include "mlir/Dialect/GPU/IR/GPUDeviceMappingAttr.td"
2121include "mlir/Dialect/GPU/IR/ParallelLoopMapperAttr.td"
2222include "mlir/IR/CommonTypeConstraints.td"
2323include "mlir/IR/EnumAttr.td"
24+ include "mlir/IR/RegionKindInterface.td"
2425include "mlir/IR/SymbolInterfaces.td"
2526include "mlir/Interfaces/ControlFlowInterfaces.td"
2627include "mlir/Interfaces/DataLayoutInterfaces.td"
@@ -1347,10 +1348,7 @@ def GPU_BarrierOp : GPU_Op<"barrier"> {
13471348
13481349def GPU_GPUModuleOp : GPU_Op<"module", [
13491350 DataLayoutOpInterface, HasDefaultDLTIDataLayout, IsolatedFromAbove,
1350- SymbolTable, Symbol, SingleBlockImplicitTerminator<"ModuleEndOp">
1351- ]>, Arguments<(ins SymbolNameAttr:$sym_name,
1352- OptionalAttr<GPUNonEmptyTargetArrayAttr>:$targets,
1353- OptionalAttr<OffloadingTranslationAttr>:$offloadingHandler)> {
1351+ NoRegionArguments, SymbolTable, Symbol] # GraphRegionNoTerminator.traits> {
13541352 let summary = "A top level compilation unit containing code to be run on a GPU.";
13551353 let description = [{
13561354 GPU module contains code that is intended to be run on a GPU. A host device
@@ -1379,15 +1377,13 @@ def GPU_GPUModuleOp : GPU_Op<"module", [
13791377 gpu.module @symbol_name {
13801378 gpu.func {}
13811379 ...
1382- gpu.module_end
13831380 }
13841381 // Module with offloading handler and target attributes.
13851382 gpu.module @symbol_name2 <#gpu.select_object<1>> [
13861383 #nvvm.target,
13871384 #rocdl.target<chip = "gfx90a">] {
13881385 gpu.func {}
13891386 ...
1390- gpu.module_end
13911387 }
13921388 ```
13931389 }];
@@ -1399,8 +1395,18 @@ def GPU_GPUModuleOp : GPU_Op<"module", [
13991395 "ArrayRef<Attribute>":$targets,
14001396 CArg<"Attribute", "{}">:$handler)>
14011397 ];
1398+
1399+ let arguments = (ins
1400+ SymbolNameAttr:$sym_name,
1401+ OptionalAttr<GPUNonEmptyTargetArrayAttr>:$targets,
1402+ OptionalAttr<OffloadingTranslationAttr>:$offloadingHandler);
14021403 let regions = (region SizedRegion<1>:$bodyRegion);
1403- let hasCustomAssemblyFormat = 1;
1404+ let assemblyFormat = [{
1405+ $sym_name
1406+ (`<` $offloadingHandler^ `>`)?
1407+ ($targets^)?
1408+ attr-dict-with-keyword $bodyRegion
1409+ }];
14041410
14051411 // We need to ensure the block inside the region is properly terminated;
14061412 // the auto-generated builders do not guarantee that.
@@ -1415,17 +1421,6 @@ def GPU_GPUModuleOp : GPU_Op<"module", [
14151421 }];
14161422}
14171423
1418- def GPU_ModuleEndOp : GPU_Op<"module_end", [
1419- Terminator, HasParent<"GPUModuleOp">
1420- ]> {
1421- let summary = "A pseudo op that marks the end of a gpu.module.";
1422- let description = [{
1423- This op terminates the only block inside the only region of a `gpu.module`.
1424- }];
1425-
1426- let assemblyFormat = "attr-dict";
1427- }
1428-
14291424def GPU_BinaryOp : GPU_Op<"binary", [Symbol]>, Arguments<(ins
14301425 SymbolNameAttr:$sym_name,
14311426 OptionalAttr<OffloadingTranslationAttr>:$offloadingHandler,
0 commit comments