@@ -22,6 +22,14 @@ cl::opt<bool>
2222 PrintPassPipeline (" sbvec-print-pass-pipeline" , cl::init(false ), cl::Hidden,
2323 cl::desc(" Prints the pass pipeline and returns." ));
2424
25+ // / A magic string for the default pass pipeline.
26+ const char *DefaultPipelineMagicStr = " *" ;
27+
28+ cl::opt<std::string> UserDefinedPassPipeline (
29+ " sbvec-passes" , cl::init(DefaultPipelineMagicStr), cl::Hidden,
30+ cl::desc(" Comma-separated list of vectorizer passes. If not set "
31+ " we run the predefined pipeline." ));
32+
2533PreservedAnalyses SandboxVectorizerPass::run (Function &F,
2634 FunctionAnalysisManager &AM) {
2735 TTI = &AM.getResult <TargetIRAnalysis>(F);
@@ -53,20 +61,26 @@ bool SandboxVectorizerPass::runImpl(Function &LLVMF) {
5361 sandboxir::Function &F = *Ctx.createFunction (&LLVMF);
5462 // Create the passes and register them with the PassRegistry.
5563 sandboxir::PassRegistry PR;
56- auto &PM = static_cast <sandboxir::FunctionPassManager &>(
57- PR.registerPass (std::make_unique<sandboxir::FunctionPassManager>(" pm" )));
5864 auto &BottomUpVecPass = static_cast <sandboxir::FunctionPass &>(
5965 PR.registerPass (std::make_unique<sandboxir::BottomUpVec>()));
6066
61- // Create the default pass pipeline.
62- PM.addPass (&BottomUpVecPass);
67+ sandboxir::FunctionPassManager *PM = nullptr ;
68+ if (UserDefinedPassPipeline == DefaultPipelineMagicStr) {
69+ // Create the default pass pipeline.
70+ PM = &static_cast <sandboxir::FunctionPassManager &>(PR.registerPass (
71+ std::make_unique<sandboxir::FunctionPassManager>(" pm" )));
72+ PM->addPass (&BottomUpVecPass);
73+ } else {
74+ // Create the user-defined pipeline.
75+ PM = &PR.parseAndCreatePassPipeline (UserDefinedPassPipeline);
76+ }
6377
6478 if (PrintPassPipeline) {
65- PM. printPipeline (outs ());
79+ PM-> printPipeline (outs ());
6680 return false ;
6781 }
6882
6983 // Run the pass pipeline.
70- bool Change = PM. runOnFunction (F);
84+ bool Change = PM-> runOnFunction (F);
7185 return Change;
7286}
0 commit comments