[llvm-branch-commits] [mlir] [mlir][OpenMP][NFC] clean up optional reduction region parsing (PR #105644)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Aug 22 04:41:28 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
@llvm/pr-subscribers-mlir-openmp
Author: Tom Eccles (tblah)
<details>
<summary>Changes</summary>
This can be handled in ODS instead of writing custom parsing/printing code.
Thanks for the idea @<!-- -->skatrak
---
Full diff: https://github.com/llvm/llvm-project/pull/105644.diff
2 Files Affected:
- (modified) mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td (+3-3)
- (modified) mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp (-46)
``````````diff
diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
index 739b1f67be7cb2..5a7dae0b5f3074 100644
--- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -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() {
diff --git a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
index 273f49b8b12b67..eb4f9cb041841b 100644
--- a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
+++ b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
@@ -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>()) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/105644
More information about the llvm-branch-commits
mailing list