[flang-commits] [flang] [flang][Transforms][NFC] Remove boilerplate from vscale range pass (PR #94598)
via flang-commits
flang-commits at lists.llvm.org
Thu Jun 6 02:46:10 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-fir-hlfir
Author: Tom Eccles (tblah)
<details>
<summary>Changes</summary>
Use tablegen to generate the pass constructor.
This pass is supposed to add function attributes so it does not need to operate on other top level operations.
---
Full diff: https://github.com/llvm/llvm-project/pull/94598.diff
4 Files Affected:
- (modified) flang/include/flang/Optimizer/Transforms/Passes.h (+1)
- (modified) flang/include/flang/Optimizer/Transforms/Passes.td (-1)
- (modified) flang/include/flang/Tools/CLOptions.inc (+1-1)
- (modified) flang/lib/Optimizer/Transforms/VScaleAttr.cpp (-12)
``````````diff
diff --git a/flang/include/flang/Optimizer/Transforms/Passes.h b/flang/include/flang/Optimizer/Transforms/Passes.h
index 2d43f4d4c55b6..4e978e6c9cdec 100644
--- a/flang/include/flang/Optimizer/Transforms/Passes.h
+++ b/flang/include/flang/Optimizer/Transforms/Passes.h
@@ -54,6 +54,7 @@ namespace fir {
#define GEN_PASS_DECL_OMPMAPINFOFINALIZATIONPASS
#define GEN_PASS_DECL_OMPMARKDECLARETARGETPASS
#define GEN_PASS_DECL_OMPFUNCTIONFILTERING
+#define GEN_PASS_DECL_VSCALEATTR
#include "flang/Optimizer/Transforms/Passes.h.inc"
std::unique_ptr<mlir::Pass> createAffineDemotionPass();
diff --git a/flang/include/flang/Optimizer/Transforms/Passes.td b/flang/include/flang/Optimizer/Transforms/Passes.td
index cac590a8da003..4e281e2846c56 100644
--- a/flang/include/flang/Optimizer/Transforms/Passes.td
+++ b/flang/include/flang/Optimizer/Transforms/Passes.td
@@ -359,7 +359,6 @@ def VScaleAttr : Pass<"vscale-attr", "mlir::func::FuncOp"> {
"std::pair<unsigned, unsigned>", /*default=*/"std::pair<unsigned, unsigned>{}",
"vector scale range">,
];
- let constructor = "::fir::createVScaleAttrPass()";
}
def FunctionAttr : Pass<"function-attr", "mlir::func::FuncOp"> {
diff --git a/flang/include/flang/Tools/CLOptions.inc b/flang/include/flang/Tools/CLOptions.inc
index d0399d65f5655..528c51d8c1c44 100644
--- a/flang/include/flang/Tools/CLOptions.inc
+++ b/flang/include/flang/Tools/CLOptions.inc
@@ -369,7 +369,7 @@ inline void createDefaultFIRCodeGenPassPipeline(mlir::PassManager &pm,
fir::createDebugPasses(pm, config.DebugInfo, config.OptLevel, inputFilename);
if (config.VScaleMin != 0)
- pm.addPass(fir::createVScaleAttrPass({config.VScaleMin, config.VScaleMax}));
+ pm.addPass(fir::createVScaleAttr({{config.VScaleMin, config.VScaleMax}}));
// Add function attributes
fir::FunctionAttrTypes functionAttrs;
diff --git a/flang/lib/Optimizer/Transforms/VScaleAttr.cpp b/flang/lib/Optimizer/Transforms/VScaleAttr.cpp
index 601a937de37be..d311167c58b4d 100644
--- a/flang/lib/Optimizer/Transforms/VScaleAttr.cpp
+++ b/flang/lib/Optimizer/Transforms/VScaleAttr.cpp
@@ -38,7 +38,6 @@
#include <algorithm>
namespace fir {
-#define GEN_PASS_DECL_VSCALEATTR
#define GEN_PASS_DEF_VSCALEATTR
#include "flang/Optimizer/Transforms/Passes.h.inc"
} // namespace fir
@@ -77,14 +76,3 @@ void VScaleAttrPass::runOnOperation() {
LLVM_DEBUG(llvm::dbgs() << "=== End " DEBUG_TYPE " ===\n");
}
-
-std::unique_ptr<mlir::Pass>
-fir::createVScaleAttrPass(std::pair<unsigned, unsigned> vscaleAttr) {
- VScaleAttrOptions opts;
- opts.vscaleRange = vscaleAttr;
- return std::make_unique<VScaleAttrPass>(opts);
-}
-
-std::unique_ptr<mlir::Pass> fir::createVScaleAttrPass() {
- return std::make_unique<VScaleAttrPass>();
-}
``````````
</details>
https://github.com/llvm/llvm-project/pull/94598
More information about the flang-commits
mailing list