[PATCH] D77907: [mlir][Pass] Add a new `Pass::getArgument` hook
River Riddle via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 10 23:09:57 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7824768b2e78: [mlir][Pass] Add a new `Pass::getArgument` hook (authored by rriddle).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D77907/new/
https://reviews.llvm.org/D77907
Files:
mlir/include/mlir/Pass/Pass.h
mlir/lib/Pass/Pass.cpp
mlir/tools/mlir-tblgen/PassGen.cpp
Index: mlir/tools/mlir-tblgen/PassGen.cpp
===================================================================
--- mlir/tools/mlir-tblgen/PassGen.cpp
+++ mlir/tools/mlir-tblgen/PassGen.cpp
@@ -42,10 +42,10 @@
{0}Base(const {0}Base &) : {1}(PassID::getID<DerivedT>()) {{}
/// Returns the command-line argument attached to this pass.
- static llvm::StringRef getPassArgument() { return "{2}"; }
+ llvm::StringRef getArgument() const override { return "{2}"; }
/// Returns the derived pass name.
- llvm::StringRef getName() override { return "{0}"; }
+ llvm::StringRef getName() const override { return "{0}"; }
/// Support isa/dyn_cast functionality for the derived pass class.
static bool classof(const ::mlir::Pass *pass) {{
Index: mlir/lib/Pass/Pass.cpp
===================================================================
--- mlir/lib/Pass/Pass.cpp
+++ mlir/lib/Pass/Pass.cpp
@@ -59,11 +59,14 @@
});
return;
}
- // Otherwise, print the pass argument followed by its options.
- if (const PassInfo *info = lookupPassInfo())
- os << info->getPassArgument();
+ // Otherwise, print the pass argument followed by its options. If the pass
+ // doesn't have an argument, print the name of the pass to give some indicator
+ // of what pass was run.
+ StringRef argument = getArgument();
+ if (!argument.empty())
+ os << argument;
else
- os << getName();
+ os << "unknown<" << getName() << ">";
passOptions.print(os);
}
Index: mlir/include/mlir/Pass/Pass.h
===================================================================
--- mlir/include/mlir/Pass/Pass.h
+++ mlir/include/mlir/Pass/Pass.h
@@ -55,7 +55,15 @@
const PassInfo *lookupPassInfo() const { return lookupPassInfo(getPassID()); }
/// Returns the derived pass name.
- virtual StringRef getName() = 0;
+ virtual StringRef getName() const = 0;
+
+ /// Returns the command line argument used when registering this pass. Return
+ /// an empty string if one does not exist.
+ virtual StringRef getArgument() const {
+ if (const PassInfo *passInfo = lookupPassInfo())
+ return passInfo->getPassArgument();
+ return "";
+ }
/// Returns the name of the operation that this pass operates on, or None if
/// this is a generic OperationPass.
@@ -332,12 +340,7 @@
PassWrapper() : BaseT(PassID::getID<PassT>()) {}
/// Returns the derived pass name.
- StringRef getName() override {
- StringRef name = llvm::getTypeName<PassT>();
- if (!name.consume_front("mlir::"))
- name.consume_front("(anonymous namespace)::");
- return name;
- }
+ StringRef getName() const override { return llvm::getTypeName<PassT>(); }
/// A clone method to create a copy of this pass.
std::unique_ptr<Pass> clonePass() const override {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77907.256746.patch
Type: text/x-patch
Size: 2780 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200411/56848339/attachment.bin>
More information about the llvm-commits
mailing list