Update for change to LLVM TargetMachine API in r145714.

llvm-svn: 145715
This commit is contained in:
Nick Lewycky 2011-12-02 22:17:00 +00:00
parent 50f02cb21b
commit 432add5b8f
1 changed files with 37 additions and 34 deletions

View File

@ -43,7 +43,7 @@ namespace {
class EmitAssemblyHelper {
DiagnosticsEngine &Diags;
const CodeGenOptions &CodeGenOpts;
const TargetOptions &TargetOpts;
const clang::TargetOptions &TargetOpts;
const LangOptions &LangOpts;
Module *TheModule;
@ -87,7 +87,8 @@ private:
public:
EmitAssemblyHelper(DiagnosticsEngine &_Diags,
const CodeGenOptions &CGOpts, const TargetOptions &TOpts,
const CodeGenOptions &CGOpts,
const clang::TargetOptions &TOpts,
const LangOptions &LOpts,
Module *M)
: Diags(_Diags), CodeGenOpts(CGOpts), TargetOpts(TOpts), LangOpts(LOpts),
@ -218,35 +219,6 @@ bool EmitAssemblyHelper::AddEmitPasses(BackendAction Action,
// being gross, this is also totally broken if we ever care about
// concurrency.
// Set frame pointer elimination mode.
if (!CodeGenOpts.DisableFPElim) {
llvm::NoFramePointerElim = false;
llvm::NoFramePointerElimNonLeaf = false;
} else if (CodeGenOpts.OmitLeafFramePointer) {
llvm::NoFramePointerElim = false;
llvm::NoFramePointerElimNonLeaf = true;
} else {
llvm::NoFramePointerElim = true;
llvm::NoFramePointerElimNonLeaf = true;
}
// Set float ABI type.
if (CodeGenOpts.FloatABI == "soft" || CodeGenOpts.FloatABI == "softfp")
llvm::FloatABIType = llvm::FloatABI::Soft;
else if (CodeGenOpts.FloatABI == "hard")
llvm::FloatABIType = llvm::FloatABI::Hard;
else {
assert(CodeGenOpts.FloatABI.empty() && "Invalid float abi!");
llvm::FloatABIType = llvm::FloatABI::Default;
}
llvm::LessPreciseFPMADOption = CodeGenOpts.LessPreciseFPMAD;
llvm::NoInfsFPMath = CodeGenOpts.NoInfsFPMath;
llvm::NoNaNsFPMath = CodeGenOpts.NoNaNsFPMath;
NoZerosInBSS = CodeGenOpts.NoZeroInitializedInBSS;
llvm::UnsafeFPMath = CodeGenOpts.UnsafeFPMath;
llvm::UseSoftFloat = CodeGenOpts.SoftFloat;
TargetMachine::setAsmVerbosityDefault(CodeGenOpts.AsmVerbose);
TargetMachine::setFunctionSections(CodeGenOpts.FunctionSections);
@ -315,9 +287,40 @@ bool EmitAssemblyHelper::AddEmitPasses(BackendAction Action,
case 3: OptLevel = CodeGenOpt::Aggressive; break;
}
llvm::TargetOptions Options;
// Set frame pointer elimination mode.
if (!CodeGenOpts.DisableFPElim) {
Options.NoFramePointerElim = false;
Options.NoFramePointerElimNonLeaf = false;
} else if (CodeGenOpts.OmitLeafFramePointer) {
Options.NoFramePointerElim = false;
Options.NoFramePointerElimNonLeaf = true;
} else {
Options.NoFramePointerElim = true;
Options.NoFramePointerElimNonLeaf = true;
}
// Set float ABI type.
if (CodeGenOpts.FloatABI == "soft" || CodeGenOpts.FloatABI == "softfp")
Options.FloatABIType = llvm::FloatABI::Soft;
else if (CodeGenOpts.FloatABI == "hard")
Options.FloatABIType = llvm::FloatABI::Hard;
else {
assert(CodeGenOpts.FloatABI.empty() && "Invalid float abi!");
Options.FloatABIType = llvm::FloatABI::Default;
}
Options.LessPreciseFPMADOption = CodeGenOpts.LessPreciseFPMAD;
Options.NoInfsFPMath = CodeGenOpts.NoInfsFPMath;
Options.NoNaNsFPMath = CodeGenOpts.NoNaNsFPMath;
Options.NoZerosInBSS = CodeGenOpts.NoZeroInitializedInBSS;
Options.UnsafeFPMath = CodeGenOpts.UnsafeFPMath;
Options.UseSoftFloat = CodeGenOpts.SoftFloat;
TargetMachine *TM = TheTarget->createTargetMachine(Triple, TargetOpts.CPU,
FeaturesStr, RM, CM,
OptLevel);
FeaturesStr, Options,
RM, CM, OptLevel);
if (CodeGenOpts.RelaxAll)
TM->setMCRelaxAll(true);
@ -412,7 +415,7 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction Action, raw_ostream *OS) {
void clang::EmitBackendOutput(DiagnosticsEngine &Diags,
const CodeGenOptions &CGOpts,
const TargetOptions &TOpts,
const clang::TargetOptions &TOpts,
const LangOptions &LOpts,
Module *M,
BackendAction Action, raw_ostream *OS) {