diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-09-30 16:39:19 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-09-30 16:39:19 +0000 |
commit | c13c9e5a9d288eac494a38f0710d34446167f940 (patch) | |
tree | 9963870fcea50321766abe308393c6f996187897 /lib/LTO/LTOModule.cpp | |
parent | 4b5205d2a3e0df909f29de0bff8ea775ad21fe0f (diff) | |
download | external_llvm-c13c9e5a9d288eac494a38f0710d34446167f940.zip external_llvm-c13c9e5a9d288eac494a38f0710d34446167f940.tar.gz external_llvm-c13c9e5a9d288eac494a38f0710d34446167f940.tar.bz2 |
Move command line options to the users of libLTO. Fixes --enable-shared build.
Patch by Richard Sandiford.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191680 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/LTO/LTOModule.cpp')
-rw-r--r-- | lib/LTO/LTOModule.cpp | 146 |
1 files changed, 13 insertions, 133 deletions
diff --git a/lib/LTO/LTOModule.cpp b/lib/LTO/LTOModule.cpp index 1457f2f..fc8bf0c 100644 --- a/lib/LTO/LTOModule.cpp +++ b/lib/LTO/LTOModule.cpp @@ -40,108 +40,6 @@ #include "llvm/Target/TargetRegisterInfo.h" using namespace llvm; -static cl::opt<bool> -EnableFPMAD("enable-fp-mad", - cl::desc("Enable less precise MAD instructions to be generated"), - cl::init(false)); - -static cl::opt<bool> -DisableFPElim("disable-fp-elim", - cl::desc("Disable frame pointer elimination optimization"), - cl::init(false)); - -static cl::opt<bool> -EnableUnsafeFPMath("enable-unsafe-fp-math", - cl::desc("Enable optimizations that may decrease FP precision"), - cl::init(false)); - -static cl::opt<bool> -EnableNoInfsFPMath("enable-no-infs-fp-math", - cl::desc("Enable FP math optimizations that assume no +-Infs"), - cl::init(false)); - -static cl::opt<bool> -EnableNoNaNsFPMath("enable-no-nans-fp-math", - cl::desc("Enable FP math optimizations that assume no NaNs"), - cl::init(false)); - -static cl::opt<bool> -EnableHonorSignDependentRoundingFPMath("enable-sign-dependent-rounding-fp-math", - cl::Hidden, - cl::desc("Force codegen to assume rounding mode can change dynamically"), - cl::init(false)); - -static cl::opt<bool> -GenerateSoftFloatCalls("soft-float", - cl::desc("Generate software floating point library calls"), - cl::init(false)); - -static cl::opt<llvm::FloatABI::ABIType> -FloatABIForCalls("float-abi", - cl::desc("Choose float ABI type"), - cl::init(FloatABI::Default), - cl::values( - clEnumValN(FloatABI::Default, "default", - "Target default float ABI type"), - clEnumValN(FloatABI::Soft, "soft", - "Soft float ABI (implied by -soft-float)"), - clEnumValN(FloatABI::Hard, "hard", - "Hard float ABI (uses FP registers)"), - clEnumValEnd)); - -static cl::opt<llvm::FPOpFusion::FPOpFusionMode> -FuseFPOps("fp-contract", - cl::desc("Enable aggresive formation of fused FP ops"), - cl::init(FPOpFusion::Standard), - cl::values( - clEnumValN(FPOpFusion::Fast, "fast", - "Fuse FP ops whenever profitable"), - clEnumValN(FPOpFusion::Standard, "on", - "Only fuse 'blessed' FP ops."), - clEnumValN(FPOpFusion::Strict, "off", - "Only fuse FP ops when the result won't be effected."), - clEnumValEnd)); - -static cl::opt<bool> -DontPlaceZerosInBSS("nozero-initialized-in-bss", - cl::desc("Don't place zero-initialized symbols into bss section"), - cl::init(false)); - -static cl::opt<bool> -EnableGuaranteedTailCallOpt("tailcallopt", - cl::desc("Turn fastcc calls into tail calls by (potentially) changing ABI."), - cl::init(false)); - -static cl::opt<bool> -DisableTailCalls("disable-tail-calls", - cl::desc("Never emit tail calls"), - cl::init(false)); - -static cl::opt<unsigned> -OverrideStackAlignment("stack-alignment", - cl::desc("Override default stack alignment"), - cl::init(0)); - -static cl::opt<std::string> -TrapFuncName("trap-func", cl::Hidden, - cl::desc("Emit a call to trap function rather than a trap instruction"), - cl::init("")); - -static cl::opt<bool> -EnablePIE("enable-pie", - cl::desc("Assume the creation of a position independent executable."), - cl::init(false)); - -static cl::opt<bool> -SegmentedStacks("segmented-stacks", - cl::desc("Use segmented stacks if possible."), - cl::init(false)); - -static cl::opt<bool> -UseInitArray("use-init-array", - cl::desc("Use .init_array instead of .ctors."), - cl::init(false)); - LTOModule::LTOModule(llvm::Module *m, llvm::TargetMachine *t) : _module(m), _target(t), _context(_target->getMCAsmInfo(), _target->getRegisterInfo(), NULL), @@ -189,23 +87,26 @@ bool LTOModule::isTargetMatch(MemoryBuffer *buffer, const char *triplePrefix) { /// makeLTOModule - Create an LTOModule. N.B. These methods take ownership of /// the buffer. -LTOModule *LTOModule::makeLTOModule(const char *path, std::string &errMsg) { +LTOModule *LTOModule::makeLTOModule(const char *path, TargetOptions options, + std::string &errMsg) { OwningPtr<MemoryBuffer> buffer; if (error_code ec = MemoryBuffer::getFile(path, buffer)) { errMsg = ec.message(); return NULL; } - return makeLTOModule(buffer.take(), errMsg); + return makeLTOModule(buffer.take(), options, errMsg); } LTOModule *LTOModule::makeLTOModule(int fd, const char *path, - size_t size, std::string &errMsg) { - return makeLTOModule(fd, path, size, 0, errMsg); + size_t size, TargetOptions options, + std::string &errMsg) { + return makeLTOModule(fd, path, size, 0, options, errMsg); } LTOModule *LTOModule::makeLTOModule(int fd, const char *path, size_t map_size, off_t offset, + TargetOptions options, std::string &errMsg) { OwningPtr<MemoryBuffer> buffer; if (error_code ec = @@ -213,40 +114,20 @@ LTOModule *LTOModule::makeLTOModule(int fd, const char *path, errMsg = ec.message(); return NULL; } - return makeLTOModule(buffer.take(), errMsg); + return makeLTOModule(buffer.take(), options, errMsg); } LTOModule *LTOModule::makeLTOModule(const void *mem, size_t length, + TargetOptions options, std::string &errMsg) { OwningPtr<MemoryBuffer> buffer(makeBuffer(mem, length)); if (!buffer) return NULL; - return makeLTOModule(buffer.take(), errMsg); -} - -void LTOModule::getTargetOptions(TargetOptions &Options) { - Options.LessPreciseFPMADOption = EnableFPMAD; - Options.NoFramePointerElim = DisableFPElim; - Options.AllowFPOpFusion = FuseFPOps; - Options.UnsafeFPMath = EnableUnsafeFPMath; - Options.NoInfsFPMath = EnableNoInfsFPMath; - Options.NoNaNsFPMath = EnableNoNaNsFPMath; - Options.HonorSignDependentRoundingFPMathOption = - EnableHonorSignDependentRoundingFPMath; - Options.UseSoftFloat = GenerateSoftFloatCalls; - if (FloatABIForCalls != FloatABI::Default) - Options.FloatABIType = FloatABIForCalls; - Options.NoZerosInBSS = DontPlaceZerosInBSS; - Options.GuaranteedTailCallOpt = EnableGuaranteedTailCallOpt; - Options.DisableTailCalls = DisableTailCalls; - Options.StackAlignmentOverride = OverrideStackAlignment; - Options.TrapFuncName = TrapFuncName; - Options.PositionIndependentExecutable = EnablePIE; - Options.EnableSegmentedStacks = SegmentedStacks; - Options.UseInitArray = UseInitArray; + return makeLTOModule(buffer.take(), options, errMsg); } LTOModule *LTOModule::makeLTOModule(MemoryBuffer *buffer, + TargetOptions options, std::string &errMsg) { // parse bitcode buffer OwningPtr<Module> m(getLazyBitcodeModule(buffer, getGlobalContext(), @@ -278,10 +159,9 @@ LTOModule *LTOModule::makeLTOModule(MemoryBuffer *buffer, else if (Triple.getArch() == llvm::Triple::x86) CPU = "yonah"; } - TargetOptions Options; - getTargetOptions(Options); + TargetMachine *target = march->createTargetMachine(TripleStr, CPU, FeatureStr, - Options); + options); LTOModule *Ret = new LTOModule(m.take(), target); if (Ret->parseSymbols(errMsg)) { delete Ret; |