@@ -22,6 +22,14 @@ cl::opt<bool>
22
22
PrintPassPipeline (" sbvec-print-pass-pipeline" , cl::init(false ), cl::Hidden,
23
23
cl::desc(" Prints the pass pipeline and returns." ));
24
24
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
+
25
33
PreservedAnalyses SandboxVectorizerPass::run (Function &F,
26
34
FunctionAnalysisManager &AM) {
27
35
TTI = &AM.getResult <TargetIRAnalysis>(F);
@@ -53,20 +61,26 @@ bool SandboxVectorizerPass::runImpl(Function &LLVMF) {
53
61
sandboxir::Function &F = *Ctx.createFunction (&LLVMF);
54
62
// Create the passes and register them with the PassRegistry.
55
63
sandboxir::PassRegistry PR;
56
- auto &PM = static_cast <sandboxir::FunctionPassManager &>(
57
- PR.registerPass (std::make_unique<sandboxir::FunctionPassManager>(" pm" )));
58
64
auto &BottomUpVecPass = static_cast <sandboxir::FunctionPass &>(
59
65
PR.registerPass (std::make_unique<sandboxir::BottomUpVec>()));
60
66
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
+ }
63
77
64
78
if (PrintPassPipeline) {
65
- PM. printPipeline (outs ());
79
+ PM-> printPipeline (outs ());
66
80
return false ;
67
81
}
68
82
69
83
// Run the pass pipeline.
70
- bool Change = PM. runOnFunction (F);
84
+ bool Change = PM-> runOnFunction (F);
71
85
return Change;
72
86
}
0 commit comments