Skip to content

[mlir][OpenMP][NFC] clean up optional reduction region parsing #105644

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -1576,11 +1576,11 @@ def DeclareReductionOp : OpenMP_Op<"declare_reduction", [IsolatedFromAbove,
AnyRegion:$cleanupRegion);

let assemblyFormat = "$sym_name `:` $type attr-dict-with-keyword "
"custom<AllocReductionRegion>($allocRegion) "
"( `alloc` $allocRegion^ )? "
"`init` $initializerRegion "
"`combiner` $reductionRegion "
"custom<AtomicReductionRegion>($atomicReductionRegion) "
"custom<CleanupReductionRegion>($cleanupRegion)";
"( `atomic` $atomicReductionRegion^ )? "
"( `cleanup` $cleanupRegion^ )? ";

let extraClassDeclaration = [{
PointerLikeType getAccumulatorType() {
Expand Down
46 changes: 0 additions & 46 deletions mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1883,52 +1883,6 @@ LogicalResult DistributeOp::verify() {
// DeclareReductionOp
//===----------------------------------------------------------------------===//

static ParseResult parseOptionalReductionRegion(OpAsmParser &parser,
Region &region,
StringRef keyword) {
if (parser.parseOptionalKeyword(keyword))
return success();
return parser.parseRegion(region);
}

static void printOptionalReductionRegion(OpAsmPrinter &printer, Region &region,
StringRef keyword) {
if (region.empty())
return;
printer << keyword << " ";
printer.printRegion(region);
}

static ParseResult parseAllocReductionRegion(OpAsmParser &parser,
Region &region) {
return parseOptionalReductionRegion(parser, region, "alloc");
}

static void printAllocReductionRegion(OpAsmPrinter &printer,
DeclareReductionOp op, Region &region) {
printOptionalReductionRegion(printer, region, "alloc");
}

static ParseResult parseAtomicReductionRegion(OpAsmParser &parser,
Region &region) {
return parseOptionalReductionRegion(parser, region, "atomic");
}

static void printAtomicReductionRegion(OpAsmPrinter &printer,
DeclareReductionOp op, Region &region) {
printOptionalReductionRegion(printer, region, "atomic");
}

static ParseResult parseCleanupReductionRegion(OpAsmParser &parser,
Region &region) {
return parseOptionalReductionRegion(parser, region, "cleanup");
}

static void printCleanupReductionRegion(OpAsmPrinter &printer,
DeclareReductionOp op, Region &region) {
printOptionalReductionRegion(printer, region, "cleanup");
}

LogicalResult DeclareReductionOp::verifyRegions() {
if (!getAllocRegion().empty()) {
for (YieldOp yieldOp : getAllocRegion().getOps<YieldOp>()) {
Expand Down
Loading