Skip to content

Commit b1f11b6

Browse files
[mlir][IR] Add SingleBlock trait to ModuleOp/GPUModuleOp
The region is already declared as `SizedRegion<1>`, but this will add an additional `getBlock()` convenience function to `ModuleOp`.
1 parent 82e594a commit b1f11b6

File tree

5 files changed

+7
-9
lines changed

5 files changed

+7
-9
lines changed

flang/lib/Lower/OpenMP/DataSharingProcessor.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,7 @@ void DataSharingProcessor::doPrivatize(const semantics::Symbol *sym,
478478
return existingPrivatizer;
479479

480480
mlir::OpBuilder::InsertionGuard guard(firOpBuilder);
481-
firOpBuilder.setInsertionPoint(&moduleOp.getBodyRegion().front(),
482-
moduleOp.getBodyRegion().front().begin());
481+
firOpBuilder.setInsertionPointToStart(moduleOp.getBody());
483482
auto result = firOpBuilder.create<mlir::omp::PrivateClauseOp>(
484483
symLoc, uniquePrivatizerName, symType,
485484
isFirstPrivate ? mlir::omp::DataSharingClauseType::FirstPrivate

mlir/include/mlir/Dialect/GPU/IR/GPUOps.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1380,7 +1380,8 @@ def GPU_BarrierOp : GPU_Op<"barrier"> {
13801380

13811381
def GPU_GPUModuleOp : GPU_Op<"module", [
13821382
DataLayoutOpInterface, HasDefaultDLTIDataLayout, IsolatedFromAbove,
1383-
NoRegionArguments, SymbolTable, Symbol] # GraphRegionNoTerminator.traits> {
1383+
NoRegionArguments, SymbolTable, Symbol]
1384+
# GraphRegionNoTerminator.traits> {
13841385
let summary = "A top level compilation unit containing code to be run on a GPU.";
13851386
let description = [{
13861387
GPU module contains code that is intended to be run on a GPU. A host device

mlir/lib/Conversion/BufferizationToMemRef/BufferizationToMemRef.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ struct BufferizationToMemRefPass
134134

135135
bufferization::DeallocHelperMap deallocHelperFuncMap;
136136
if (auto module = dyn_cast<ModuleOp>(getOperation())) {
137-
OpBuilder builder =
138-
OpBuilder::atBlockBegin(&module.getBodyRegion().front());
137+
OpBuilder builder = OpBuilder::atBlockBegin(module.getBody());
139138

140139
// Build dealloc helper function if there are deallocs.
141140
getOperation()->walk([&](bufferization::DeallocOp deallocOp) {

mlir/lib/Dialect/Bufferization/Transforms/LowerDeallocations.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,7 @@ struct LowerDeallocationsPass
391391

392392
bufferization::DeallocHelperMap deallocHelperFuncMap;
393393
if (auto module = dyn_cast<ModuleOp>(getOperation())) {
394-
OpBuilder builder =
395-
OpBuilder::atBlockBegin(&module.getBodyRegion().front());
394+
OpBuilder builder = OpBuilder::atBlockBegin(module.getBody());
396395

397396
// Build dealloc helper function if there are deallocs.
398397
getOperation()->walk([&](bufferization::DeallocOp deallocOp) {

mlir/lib/Dialect/SparseTensor/Transforms/SparseGPUCodegen.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static gpu::GPUModuleOp genGPUModule(OpBuilder &builder, ModuleOp topModule) {
5858
for (auto op : topModule.getBodyRegion().getOps<gpu::GPUModuleOp>())
5959
return op; // existing
6060
markAsGPUContainer(topModule);
61-
builder.setInsertionPointToStart(&topModule.getBodyRegion().front());
61+
builder.setInsertionPointToStart(topModule.getBody());
6262
return builder.create<gpu::GPUModuleOp>(topModule->getLoc(),
6363
"sparse_kernels");
6464
}
@@ -75,7 +75,7 @@ static gpu::GPUFuncOp genGPUFunc(OpBuilder &builder, gpu::GPUModuleOp gpuModule,
7575
("kernel" + Twine(kernelNumber++)).toStringRef(kernelName);
7676
} while (gpuModule.lookupSymbol(kernelName));
7777
// Then we insert a new kernel with given arguments into the module.
78-
builder.setInsertionPointToStart(&gpuModule.getBodyRegion().front());
78+
builder.setInsertionPointToStart(gpuModule.getBody());
7979
SmallVector<Type> argsTp;
8080
for (auto arg : args)
8181
argsTp.push_back(arg.getType());

0 commit comments

Comments
 (0)