Move LLVM backend options to explicit clang-cc / clang -cc1 options, which we then manually pass to the command line library; eventually the latter grossness should be fixed by a real API when creating the target machine.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90063 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Driver/CC1Options.cpp b/lib/Driver/CC1Options.cpp
index d4a8b3f..b9c4277 100644
--- a/lib/Driver/CC1Options.cpp
+++ b/lib/Driver/CC1Options.cpp
@@ -173,6 +173,15 @@
Opts.SimplifyLibCalls = 1;
Opts.UnrollLoops = (Opts.OptimizationLevel > 1 && !Opts.OptimizeSize);
+ Opts.AsmVerbose = Args.hasArg(OPT_masm_verbose);
+ Opts.CodeModel = getLastArgValue(Args, OPT_mcode_model);
+ Opts.DebugPass = getLastArgValue(Args, OPT_mdebug_pass);
+ Opts.DisableFPElim = Args.hasArg(OPT_mdisable_fp_elim);
+ Opts.LimitFloatPrecision = getLastArgValue(Args, OPT_mlimit_float_precision);
+ Opts.NoZeroInitializedInBSS = Args.hasArg(OPT_mno_zero_initialized_in_bss);
+ Opts.UnwindTables = Args.hasArg(OPT_munwind_tables);
+ Opts.RelocationModel = getLastArgValue(Args, OPT_mrelocation_model, "pic");
+
Opts.MainFileName = getLastArgValue(Args, OPT_main_file_name);
// FIXME: Implement!
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index c79b093..ed4d391 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -700,8 +700,10 @@
else
Model = getToolChain().GetDefaultRelocationModel();
}
- CmdArgs.push_back("-relocation-model");
- CmdArgs.push_back(Model);
+ if (llvm::StringRef(Model) != "pic") {
+ CmdArgs.push_back("-mrelocation-model");
+ CmdArgs.push_back(Model);
+ }
// Infer the __PIC__ value.
//
@@ -711,27 +713,30 @@
CmdArgs.push_back("-pic-level");
CmdArgs.push_back(Args.hasArg(options::OPT_fPIC) ? "2" : "1");
}
-
- if (Args.hasArg(options::OPT_ftime_report))
- CmdArgs.push_back("-time-passes");
- // FIXME: Set --enable-unsafe-fp-math.
- if (Args.hasFlag(options::OPT_fno_omit_frame_pointer,
- options::OPT_fomit_frame_pointer))
- CmdArgs.push_back("-disable-fp-elim");
- if (!Args.hasFlag(options::OPT_fzero_initialized_in_bss,
- options::OPT_fno_zero_initialized_in_bss,
- true))
- CmdArgs.push_back("-nozero-initialized-in-bss");
- if (Args.hasArg(options::OPT_dA) || Args.hasArg(options::OPT_fverbose_asm))
- CmdArgs.push_back("-asm-verbose");
- if (Args.hasArg(options::OPT_fdebug_pass_structure))
- CmdArgs.push_back("-debug-pass=Structure");
- if (Args.hasArg(options::OPT_fdebug_pass_arguments))
- CmdArgs.push_back("-debug-pass=Arguments");
if (!Args.hasFlag(options::OPT_fmerge_all_constants,
options::OPT_fno_merge_all_constants))
CmdArgs.push_back("-no-merge-all-constants");
+ // LLVM Code Generator Options.
+
+ // FIXME: Set --enable-unsafe-fp-math.
+ if (Args.hasFlag(options::OPT_fno_omit_frame_pointer,
+ options::OPT_fomit_frame_pointer))
+ CmdArgs.push_back("-mdisable-fp-elim");
+ if (!Args.hasFlag(options::OPT_fzero_initialized_in_bss,
+ options::OPT_fno_zero_initialized_in_bss))
+ CmdArgs.push_back("-mno-zero-initialized-in-bss");
+ if (Args.hasArg(options::OPT_dA) || Args.hasArg(options::OPT_fverbose_asm))
+ CmdArgs.push_back("-masm-verbose");
+ if (Args.hasArg(options::OPT_fdebug_pass_structure)) {
+ CmdArgs.push_back("-mdebug-pass");
+ CmdArgs.push_back("Structure");
+ }
+ if (Args.hasArg(options::OPT_fdebug_pass_arguments)) {
+ CmdArgs.push_back("-mdebug-pass");
+ CmdArgs.push_back("Arguments");
+ }
+
// This is a coarse approximation of what llvm-gcc actually does, both
// -fasynchronous-unwind-tables and -fnon-call-exceptions interact in more
// complicated ways.
@@ -742,15 +747,18 @@
!Args.hasArg(options::OPT_mkernel));
if (Args.hasFlag(options::OPT_funwind_tables, options::OPT_fno_unwind_tables,
AsynchronousUnwindTables))
- CmdArgs.push_back("-unwind-tables=1");
- else
- CmdArgs.push_back("-unwind-tables=0");
+ CmdArgs.push_back("-munwind-tables");
+
+ if (Arg *A = Args.getLastArg(options::OPT_flimited_precision_EQ)) {
+ CmdArgs.push_back("-mlimit-float-precision");
+ CmdArgs.push_back(A->getValue(Args));
+ }
// FIXME: Handle -mtune=.
(void) Args.hasArg(options::OPT_mtune_EQ);
if (Arg *A = Args.getLastArg(options::OPT_mcmodel_EQ)) {
- CmdArgs.push_back("-code-model");
+ CmdArgs.push_back("-mcode-model");
CmdArgs.push_back(A->getValue(Args));
}
@@ -776,11 +784,6 @@
getToolChain().IsMathErrnoDefault()))
CmdArgs.push_back("-fno-math-errno");
- if (Arg *A = Args.getLastArg(options::OPT_flimited_precision_EQ)) {
- CmdArgs.push_back("-limit-float-precision");
- CmdArgs.push_back(A->getValue(Args));
- }
-
Arg *Unsupported;
if ((Unsupported = Args.getLastArg(options::OPT_MG)) ||
(Unsupported = Args.getLastArg(options::OPT_MQ)) ||