mirror of
https://github.com/intel/llvm.git
synced 2026-01-22 23:49:22 +08:00
[mlir][OpenMP][NFC] clean up optional reduction region parsing (#105644)
This can be handled in ODS instead of writing custom parsing/printing code. Thanks for the idea @skatrak
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -1883,52 +1883,6 @@ LogicalResult DistributeOp::verify() {
|
||||
// DeclareReductionOp
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
static ParseResult parseOptionalReductionRegion(OpAsmParser &parser,
|
||||
Region ®ion,
|
||||
StringRef keyword) {
|
||||
if (parser.parseOptionalKeyword(keyword))
|
||||
return success();
|
||||
return parser.parseRegion(region);
|
||||
}
|
||||
|
||||
static void printOptionalReductionRegion(OpAsmPrinter &printer, Region ®ion,
|
||||
StringRef keyword) {
|
||||
if (region.empty())
|
||||
return;
|
||||
printer << keyword << " ";
|
||||
printer.printRegion(region);
|
||||
}
|
||||
|
||||
static ParseResult parseAllocReductionRegion(OpAsmParser &parser,
|
||||
Region ®ion) {
|
||||
return parseOptionalReductionRegion(parser, region, "alloc");
|
||||
}
|
||||
|
||||
static void printAllocReductionRegion(OpAsmPrinter &printer,
|
||||
DeclareReductionOp op, Region ®ion) {
|
||||
printOptionalReductionRegion(printer, region, "alloc");
|
||||
}
|
||||
|
||||
static ParseResult parseAtomicReductionRegion(OpAsmParser &parser,
|
||||
Region ®ion) {
|
||||
return parseOptionalReductionRegion(parser, region, "atomic");
|
||||
}
|
||||
|
||||
static void printAtomicReductionRegion(OpAsmPrinter &printer,
|
||||
DeclareReductionOp op, Region ®ion) {
|
||||
printOptionalReductionRegion(printer, region, "atomic");
|
||||
}
|
||||
|
||||
static ParseResult parseCleanupReductionRegion(OpAsmParser &parser,
|
||||
Region ®ion) {
|
||||
return parseOptionalReductionRegion(parser, region, "cleanup");
|
||||
}
|
||||
|
||||
static void printCleanupReductionRegion(OpAsmPrinter &printer,
|
||||
DeclareReductionOp op, Region ®ion) {
|
||||
printOptionalReductionRegion(printer, region, "cleanup");
|
||||
}
|
||||
|
||||
LogicalResult DeclareReductionOp::verifyRegions() {
|
||||
if (!getAllocRegion().empty()) {
|
||||
for (YieldOp yieldOp : getAllocRegion().getOps<YieldOp>()) {
|
||||
|
||||
Reference in New Issue
Block a user