|
8 | 8 |
|
9 | 9 | #include "llvm/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.h"
|
10 | 10 | #include "llvm/Analysis/TargetTransformInfo.h"
|
| 11 | +#include "llvm/SandboxIR/PassManager.h" |
11 | 12 | #include "llvm/SandboxIR/SandboxIR.h"
|
| 13 | +#include "llvm/Support/CommandLine.h" |
| 14 | +#include "llvm/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.h" |
12 | 15 |
|
13 | 16 | using namespace llvm;
|
14 | 17 |
|
15 | 18 | #define SV_NAME "sandbox-vectorizer"
|
16 | 19 | #define DEBUG_TYPE SV_NAME
|
17 | 20 |
|
| 21 | +cl::opt<bool> |
| 22 | + PrintPassPipeline("sbvec-print-pass-pipeline", cl::init(false), cl::Hidden, |
| 23 | + cl::desc("Prints the pass pipeline and returns.")); |
| 24 | + |
18 | 25 | PreservedAnalyses SandboxVectorizerPass::run(Function &F,
|
19 | 26 | FunctionAnalysisManager &AM) {
|
20 | 27 | TTI = &AM.getResult<TargetIRAnalysis>(F);
|
@@ -44,8 +51,22 @@ bool SandboxVectorizerPass::runImpl(Function &LLVMF) {
|
44 | 51 | sandboxir::Context Ctx(LLVMF.getContext());
|
45 | 52 | // Create SandboxIR for `LLVMF`.
|
46 | 53 | sandboxir::Function &F = *Ctx.createFunction(&LLVMF);
|
47 |
| - // TODO: Initialize SBVec Pass Manager |
48 |
| - (void)F; |
| 54 | + // Create the passes and register them with the PassRegistry. |
| 55 | + sandboxir::PassRegistry PR; |
| 56 | + auto &PM = static_cast<sandboxir::FunctionPassManager &>( |
| 57 | + PR.registerPass(std::make_unique<sandboxir::FunctionPassManager>("pm"))); |
| 58 | + auto &BottomUpVecPass = static_cast<sandboxir::FunctionPass &>( |
| 59 | + PR.registerPass(std::make_unique<sandboxir::BottomUpVec>())); |
| 60 | + |
| 61 | + // Create the default pass pipeline. |
| 62 | + PM.addPass(&BottomUpVecPass); |
| 63 | + |
| 64 | + if (PrintPassPipeline) { |
| 65 | + PM.printPipeline(outs()); |
| 66 | + return false; |
| 67 | + } |
49 | 68 |
|
50 |
| - return false; |
| 69 | + // Run the pass pipeline. |
| 70 | + bool Change = PM.runOnFunction(F); |
| 71 | + return Change; |
51 | 72 | }
|
0 commit comments