[llvm] [SandboxVectorizer] Use sbvec-passes flag to create a pipeline of Region passes after BottomUpVec. (PR #111223)
Jorge Gorbe Moya via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 7 14:57:27 PDT 2024
================
@@ -10,10 +10,69 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/SandboxIR/Function.h"
#include "llvm/SandboxIR/Instruction.h"
-
-using namespace llvm::sandboxir;
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Transforms/Vectorize/SandboxVectorizer/Passes/NullPass.h"
namespace llvm::sandboxir {
+
+static cl::opt<bool>
+ PrintPassPipeline("sbvec-print-pass-pipeline", cl::init(false), cl::Hidden,
+ cl::desc("Prints the pass pipeline and returns."));
+
+/// A magic string for the default pass pipeline.
+static const char *DefaultPipelineMagicStr = "*";
+
+static cl::opt<std::string> UserDefinedPassPipeline(
+ "sbvec-passes", cl::init(DefaultPipelineMagicStr), cl::Hidden,
+ cl::desc("Comma-separated list of vectorizer passes. If not set "
+ "we run the predefined pipeline."));
+
+static void registerAllRegionPasses(sandboxir::PassRegistry &PR) {
+ PR.registerPass(std::make_unique<sandboxir::NullPass>());
+}
+
+/// Adds to `RPM` a sequence of passes described by `Pipeline` from the `PR`
+/// pass registry.
+static void parseAndCreatePassPipeline(RegionPassManager &RPM, PassRegistry &PR,
----------------
slackito wrote:
It could be a member of RPM. The moral equivalent of this function for `FunctionPassManager` is currently a member function of `PassRegistry`:
```
class PassRegistry {
...
FunctionPassManager &parseAndCreatePassPipeline(StringRef Pipeline);
};
```
If we change `PassRegistry::parseAndCreatePassPipeline` to get the pass manager as an argument rather than creating it inside the function, I think we could easily make it generic to avoid duplicating the pipeline parsing code:
```
class PassRegistry {
...
template <typename PassManagerType>
void parseAndCreatePassPipeline(PassManagerType &PM, StringRef Pipeline);
};
```
What do you think?
https://github.com/llvm/llvm-project/pull/111223
More information about the llvm-commits
mailing list