mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-30 08:49:04 -04:00

Transforms/Scalar/SCCP.cpp implemented both the Scalar and IPO SCCP, but this meant Transforms/Scalar including Transfroms/IPO headers, creating a circular dependency. (IPO depends on Scalar already) - so move the IPO SCCP shims out into IPO and the basic library implementation accessible from Scalar/SCCP.h to be used from the IPO/SCCP.cpp implementation. llvm-svn: 328250
59 lines
1.8 KiB
C++
59 lines
1.8 KiB
C++
#include "llvm/Transforms/IPO/SCCP.h"
|
|
#include "llvm/Analysis/TargetLibraryInfo.h"
|
|
#include "llvm/Transforms/IPO.h"
|
|
#include "llvm/Transforms/Scalar/SCCP.h"
|
|
|
|
using namespace llvm;
|
|
|
|
PreservedAnalyses IPSCCPPass::run(Module &M, ModuleAnalysisManager &AM) {
|
|
const DataLayout &DL = M.getDataLayout();
|
|
auto &TLI = AM.getResult<TargetLibraryAnalysis>(M);
|
|
if (!runIPSCCP(M, DL, &TLI))
|
|
return PreservedAnalyses::all();
|
|
return PreservedAnalyses::none();
|
|
}
|
|
|
|
namespace {
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
//
|
|
/// IPSCCP Class - This class implements interprocedural Sparse Conditional
|
|
/// Constant Propagation.
|
|
///
|
|
class IPSCCPLegacyPass : public ModulePass {
|
|
public:
|
|
static char ID;
|
|
|
|
IPSCCPLegacyPass() : ModulePass(ID) {
|
|
initializeIPSCCPLegacyPassPass(*PassRegistry::getPassRegistry());
|
|
}
|
|
|
|
bool runOnModule(Module &M) override {
|
|
if (skipModule(M))
|
|
return false;
|
|
const DataLayout &DL = M.getDataLayout();
|
|
const TargetLibraryInfo *TLI =
|
|
&getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
|
|
return runIPSCCP(M, DL, TLI);
|
|
}
|
|
|
|
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
|
AU.addRequired<TargetLibraryInfoWrapperPass>();
|
|
}
|
|
};
|
|
|
|
} // end anonymous namespace
|
|
|
|
char IPSCCPLegacyPass::ID = 0;
|
|
|
|
INITIALIZE_PASS_BEGIN(IPSCCPLegacyPass, "ipsccp",
|
|
"Interprocedural Sparse Conditional Constant Propagation",
|
|
false, false)
|
|
INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
|
|
INITIALIZE_PASS_END(IPSCCPLegacyPass, "ipsccp",
|
|
"Interprocedural Sparse Conditional Constant Propagation",
|
|
false, false)
|
|
|
|
// createIPSCCPPass - This is the public interface to this file.
|
|
ModulePass *llvm::createIPSCCPPass() { return new IPSCCPLegacyPass(); }
|