Frontend: Add a more explicit -backend-option flag for passing backend command

line options, instead of leveraging the blanket -mllvm option.
 - This allows using the frontend itself without requiring the backend have
   those options available (i.e., if the target wasn't built).

llvm-svn: 128087
This commit is contained in:
Daniel Dunbar 2011-03-22 16:48:17 +00:00
parent e14460ba37
commit 12100e2c7f
6 changed files with 18 additions and 5 deletions

View File

@ -155,6 +155,8 @@ def momit_leaf_frame_pointer : Flag<"-momit-leaf-frame-pointer">,
HelpText<"Omit frame pointer setup for leaf functions.">;
def msoft_float : Flag<"-msoft-float">,
HelpText<"Use software floating point">;
def backend_option : Separate<"-backend-option">,
HelpText<"Additional arguments to forward to LLVM backend (during code gen)">;
def mregparm : Separate<"-mregparm">,
HelpText<"Limit the number of registers available for integer arguments">;
def mrelax_all : Flag<"-mrelax-all">,

View File

@ -15,6 +15,7 @@
#define LLVM_CLANG_FRONTEND_CODEGENOPTIONS_H
#include <string>
#include <vector>
namespace clang {
@ -114,6 +115,9 @@ public:
/// The name of the relocation model to use.
std::string RelocationModel;
/// A list of command-line options to forward to the LLVM backend.
std::vector<std::string> BackendOptions;
/// The user specified number of registers to be used for integral arguments,
/// or 0 if unspecified.
unsigned NumRegisterParameters;

View File

@ -248,6 +248,8 @@ bool EmitAssemblyHelper::AddEmitPasses(BackendAction Action,
}
if (llvm::TimePassesIsEnabled)
BackendArgs.push_back("-time-passes");
for (unsigned i = 0, e = CodeGenOpts.BackendOptions.size(); i != e; ++i)
BackendArgs.push_back(CodeGenOpts.BackendOptions[i].c_str());
BackendArgs.push_back(0);
llvm::cl::ParseCommandLineOptions(BackendArgs.size() - 1,
const_cast<char **>(&BackendArgs[0]));

View File

@ -440,7 +440,7 @@ void Clang::AddARMTargetArgs(const ArgList &Args,
// Disable movt generation, if requested.
#ifdef DISABLE_ARM_DARWIN_USE_MOVT
CmdArgs.push_back("-mllvm");
CmdArgs.push_back("-backend-option");
CmdArgs.push_back("-arm-darwin-use-movt=0");
#endif
@ -607,10 +607,10 @@ void Clang::AddARMTargetArgs(const ArgList &Args,
// Kernel code has more strict alignment requirements.
if (KernelOrKext) {
CmdArgs.push_back("-mllvm");
CmdArgs.push_back("-backend-option");
CmdArgs.push_back("-arm-long-calls");
CmdArgs.push_back("-mllvm");
CmdArgs.push_back("-backend-option");
CmdArgs.push_back("-arm-strict-align");
}
}

View File

@ -207,6 +207,10 @@ static void CodeGenOptsToArgs(const CodeGenOptions &Opts,
}
if (!Opts.VerifyModule)
Res.push_back("-disable-llvm-verifier");
for (unsigned i = 0, e = Opts.BackendOptions.size(); i != e; ++i) {
Res.push_back("-backend-option");
Res.push_back(Opts.BackendOptions[i]);
}
}
static void DependencyOutputOptsToArgs(const DependencyOutputOptions &Opts,
@ -927,6 +931,7 @@ static void ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.NoInfsFPMath = Opts.NoNaNsFPMath = Args.hasArg(OPT_cl_finite_math_only)||
Args.hasArg(OPT_cl_fast_relaxed_math);
Opts.NoZeroInitializedInBSS = Args.hasArg(OPT_mno_zero_initialized_in_bss);
Opts.BackendOptions = Args.getAllArgValues(OPT_backend_option);
Opts.NumRegisterParameters = Args.getLastArgIntValue(OPT_mregparm, 0, Diags);
Opts.RelaxAll = Args.hasArg(OPT_mrelax_all);
Opts.OmitLeafFramePointer = Args.hasArg(OPT_momit_leaf_frame_pointer);

View File

@ -11,8 +11,8 @@
// RUN: -arch armv7 -mkernel -### -fsyntax-only %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-ARM < %t %s
// CHECK-ARM: "-mllvm" "-arm-long-calls"
// CHECK-ARM: "-mllvm" "-arm-strict-align"
// CHECK-ARM: "-backend-option" "-arm-long-calls"
// CHECK-ARM: "-backend-option" "-arm-strict-align"
// CHECK-ARM: "-fno-builtin"
// CHECK-ARM: "-fno-rtti"
// CHECK-ARM: "-fno-common"