|
36 | 36 | #include "llvm/IR/Module.h" |
37 | 37 | #include "llvm/IR/Type.h" |
38 | 38 | #include "llvm/IR/Value.h" |
| 39 | +#include "llvm/InitializePasses.h" |
39 | 40 | #include "llvm/Support/Casting.h" |
40 | 41 | #include "llvm/Support/CommandLine.h" |
41 | 42 | #include "llvm/Transforms/Utils/Local.h" |
@@ -339,9 +340,25 @@ class ScalarizerVisitor : public InstVisitor<ScalarizerVisitor, bool> { |
339 | 340 | const bool ScalarizeLoadStore; |
340 | 341 | const unsigned ScalarizeMinBits; |
341 | 342 | }; |
342 | | - |
343 | 343 | } // end anonymous namespace |
344 | 344 |
|
| 345 | +ScalarizerLegacyPass::ScalarizerLegacyPass() : FunctionPass(ID) { |
| 346 | + Options.ScalarizeVariableInsertExtract = true; |
| 347 | + Options.ScalarizeLoadStore = true; |
| 348 | +} |
| 349 | + |
| 350 | +void ScalarizerLegacyPass::getAnalysisUsage(AnalysisUsage& AU) const { |
| 351 | + AU.addRequired<DominatorTreeWrapperPass>(); |
| 352 | + AU.addPreserved<DominatorTreeWrapperPass>(); |
| 353 | +} |
| 354 | + |
| 355 | +char ScalarizerLegacyPass::ID = 0; |
| 356 | +INITIALIZE_PASS_BEGIN(ScalarizerLegacyPass, "scalarizer", |
| 357 | + "Scalarize vector operations", false, false) |
| 358 | +INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) |
| 359 | +INITIALIZE_PASS_END(ScalarizerLegacyPass, "scalarizer", |
| 360 | + "Scalarize vector operations", false, false) |
| 361 | + |
345 | 362 | Scatterer::Scatterer(BasicBlock *bb, BasicBlock::iterator bbi, Value *v, |
346 | 363 | const VectorSplit &VS, ValueVector *cachePtr) |
347 | 364 | : BB(bb), BBI(bbi), V(v), VS(VS), CachePtr(cachePtr) { |
@@ -414,6 +431,19 @@ Value *Scatterer::operator[](unsigned Frag) { |
414 | 431 | return CV[Frag]; |
415 | 432 | } |
416 | 433 |
|
| 434 | +bool ScalarizerLegacyPass::runOnFunction(Function &F) { |
| 435 | + if (skipFunction(F)) |
| 436 | + return false; |
| 437 | + |
| 438 | + DominatorTree *DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree(); |
| 439 | + ScalarizerVisitor Impl(DT, Options); |
| 440 | + return Impl.visit(F); |
| 441 | +} |
| 442 | + |
| 443 | +FunctionPass *llvm::createScalarizerPass() { |
| 444 | + return new ScalarizerLegacyPass(); |
| 445 | +} |
| 446 | + |
417 | 447 | bool ScalarizerVisitor::visit(Function &F) { |
418 | 448 | assert(Gathered.empty() && Scattered.empty()); |
419 | 449 |
|
|
0 commit comments