[Mlir-commits] [mlir] [mlir][OpenMP][NFC] clean up optional reduction region parsing (PR #105644)
Tom Eccles
llvmlistbot at llvm.org
Thu Aug 22 06:28:31 PDT 2024
https://github.com/tblah updated https://github.com/llvm/llvm-project/pull/105644
>From b21eb6f8d87550b3588159ee086a91c1b9547f6c Mon Sep 17 00:00:00 2001
From: Tom Eccles <tom.eccles at arm.com>
Date: Thu, 22 Aug 2024 11:36:11 +0000
Subject: [PATCH] [mlir][OpenMP][NFC] clean up optional reduction region
parsing
This can be handled in ODS instead of writing custom parsing/printing
code.
Thanks for the idea @skatrak
---
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | 6 +--
mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp | 46 -------------------
2 files changed, 3 insertions(+), 49 deletions(-)
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>()) {
More information about the Mlir-commits
mailing list