Add CodeGenOptions::{SoftFloat,FloatABI}, and update the all the (far too many) places to use this instead of using the backend -soft-float and -float-abi= options.

llvm-svn: 90127
This commit is contained in:
Daniel Dunbar 2009-11-30 08:42:00 +00:00
parent 91dea8252a
commit a74f8ff15c
7 changed files with 38 additions and 6 deletions

View File

@ -29,7 +29,7 @@ public:
OnlyAlwaysInlining // Only run the always inlining pass.
};
unsigned AsmVerbose : 1; /// -dA, -fverbose-asm
unsigned AsmVerbose : 1; /// -dA, -fverbose-asm.
unsigned DebugInfo : 1; /// Should generate deubg info (-g).
unsigned DisableFPElim : 1; /// Set when -fomit-frame-pointer is enabled.
unsigned DisableLLVMOpts : 1; /// Don't run any optimizations, for use in
@ -43,6 +43,7 @@ public:
unsigned NoZeroInitializedInBSS : 1; /// -fno-zero-initialized-in-bss
unsigned OptimizationLevel : 3; /// The -O[0-4] option specified.
unsigned OptimizeSize : 1; /// If -Os is specified.
unsigned SoftFloat : 1; /// -soft-float.
unsigned TimePasses : 1; /// Set when -ftime-report is enabled.
unsigned UnitAtATime : 1; /// Unused. For mirroring GCC optimization
/// selection.
@ -54,8 +55,12 @@ public:
/// The code model to use (-mcmodel).
std::string CodeModel;
/// Enable additional debugging information.
std::string DebugPass;
/// The ABI to use for passing floating point arguments.
std::string FloatABI;
/// The float precision limit to use, if non-empty.
std::string LimitFloatPrecision;
@ -84,6 +89,7 @@ public:
OptimizationLevel = 0;
OptimizeSize = 0;
UnrollLoops = 0;
SoftFloat = 0;
TimePasses = 0;
UnitAtATime = 1;
UnwindTables = 0;

View File

@ -117,10 +117,14 @@ def mdebug_pass : Separate<"-mdebug-pass">,
HelpText<"Enable additional debug output">;
def mdisable_fp_elim : Flag<"-mdisable-fp-elim">,
HelpText<"Disable frame pointer elimination optimization">;
def mfloat_abi : Flag<"-mfloat-abi">,
HelpText<"The float ABI to use">;
def mlimit_float_precision : Separate<"-mlimit-float-precision">,
HelpText<"Limit float precision to the given value">;
def mno_zero_initialized_in_bss : Flag<"-mno-zero-initialized-in-bss">,
HelpText<"Do not put zero initialized data in the BSS">;
def msoft_float : Separate<"-msoft-float">,
HelpText<"Use software floating point">;
def mrelocation_model : Separate<"-mrelocation-model">,
HelpText<"The relocation model to use">;
def munwind_tables : Flag<"-munwind-tables">,

View File

@ -184,8 +184,10 @@ static void ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
Opts.CodeModel = getLastArgValue(Args, OPT_mcode_model);
Opts.DebugPass = getLastArgValue(Args, OPT_mdebug_pass);
Opts.DisableFPElim = Args.hasArg(OPT_mdisable_fp_elim);
Opts.FloatABI = getLastArgValue(Args, OPT_mfloat_abi);
Opts.LimitFloatPrecision = getLastArgValue(Args, OPT_mlimit_float_precision);
Opts.NoZeroInitializedInBSS = Args.hasArg(OPT_mno_zero_initialized_in_bss);
Opts.SoftFloat = Args.hasArg(OPT_msoft_float);
Opts.UnwindTables = Args.hasArg(OPT_munwind_tables);
Opts.RelocationModel = getLastArgValue(Args, OPT_mrelocation_model, "pic");

View File

@ -418,15 +418,15 @@ void Clang::AddARMTargetArgs(const ArgList &Args,
// Floating point operations and argument passing are soft.
//
// FIXME: This changes CPP defines, we need -target-soft-float.
CmdArgs.push_back("-soft-float");
CmdArgs.push_back("-float-abi=soft");
CmdArgs.push_back("-msoft-float");
CmdArgs.push_back("-mfloat-abi=soft");
} else if (FloatABI == "softfp") {
// Floating point operations are hard, but argument passing is soft.
CmdArgs.push_back("-float-abi=soft");
CmdArgs.push_back("-mfloat-abi=soft");
} else {
// Floating point operations and argument passing are hard.
assert(FloatABI == "hard" && "Invalid float abi!");
CmdArgs.push_back("-float-abi=hard");
CmdArgs.push_back("-mfloat-abi=hard");
}
}

View File

@ -231,12 +231,18 @@ bool BackendConsumer::AddEmitPasses(std::string &Error) {
}
if (CodeGenOpts.DisableFPElim)
BackendArgs.push_back("-disable-fp-elim");
if (!CodeGenOpts.FloatABI.empty()) {
BackendArgs.push_back("-float-abi");
BackendArgs.push_back(CodeGenOpts.FloatABI.c_str());
}
if (!CodeGenOpts.LimitFloatPrecision.empty()) {
BackendArgs.push_back("-limit-float-precision");
BackendArgs.push_back(CodeGenOpts.LimitFloatPrecision.c_str());
}
if (CodeGenOpts.NoZeroInitializedInBSS)
BackendArgs.push_back("-nozero-initialized-in-bss");
if (CodeGenOpts.SoftFloat)
BackendArgs.push_back("-soft-float");
BackendArgs.push_back("-relocation-model");
BackendArgs.push_back(CodeGenOpts.RelocationModel.c_str());
if (llvm::TimePassesIsEnabled)

View File

@ -134,12 +134,18 @@ static void CodeGenOptsToArgs(const CodeGenOptions &Opts,
}
if (Opts.DisableFPElim)
Res.push_back("-mdisable-fp-elim");
if (!Opts.FloatABI.empty()) {
Res.push_back("-mfloat-abi");
Res.push_back(Opts.FloatABI);
}
if (!Opts.LimitFloatPrecision.empty()) {
Res.push_back("-mlimit-float-precision");
Res.push_back(Opts.LimitFloatPrecision);
}
if (Opts.NoZeroInitializedInBSS)
Res.push_back("-mno-zero-initialized-bss");
if (Opts.SoftFloat)
Res.push_back("-msoft-float");
if (Opts.UnwindTables)
Res.push_back("-munwind-tables");
if (Opts.RelocationModel != "pic") {

View File

@ -154,6 +154,9 @@ static llvm::cl::opt<bool>
MDisableFPElim("mdisable-fp-elim",
llvm::cl::desc("Disable frame pointer elimination optimization"));
static llvm::cl::opt<std::string>
MFloatABI("mfloat-abi", llvm::cl::desc("The float ABI to use"));
static llvm::cl::opt<std::string>
MLimitFloatPrecision("mlimit-float-precision",
llvm::cl::desc("Limit float precision to the given value"));
@ -162,6 +165,9 @@ static llvm::cl::opt<bool>
MNoZeroInitializedInBSS("mno-zero-initialized-in-bss",
llvm::cl::desc("Do not put zero initialized data in the BSS"));
static llvm::cl::opt<bool>
MSoftFloat("msoft-float", llvm::cl::desc("Use software floating point"));
static llvm::cl::opt<std::string>
MRelocationModel("mrelocation-model",
llvm::cl::desc("The relocation model to use"),
@ -821,10 +827,12 @@ void clang::InitializeCodeGenOptions(CodeGenOptions &Opts,
Opts.CodeModel = MCodeModel;
Opts.DebugPass = MDebugPass;
Opts.DisableFPElim = MDisableFPElim;
Opts.FloatABI = MFloatABI;
Opts.LimitFloatPrecision = MLimitFloatPrecision;
Opts.NoZeroInitializedInBSS = MNoZeroInitializedInBSS;
Opts.UnwindTables = MUnwindTables;
Opts.SoftFloat = MSoftFloat;
Opts.RelocationModel = MRelocationModel;
Opts.UnwindTables = MUnwindTables;
#ifdef NDEBUG
Opts.VerifyModule = 0;