[cfe-commits] r128087 - in /cfe/trunk: include/clang/Driver/CC1Options.td include/clang/Frontend/CodeGenOptions.h lib/CodeGen/BackendUtil.cpp lib/Driver/Tools.cpp lib/Frontend/CompilerInvocation.cpp test/Driver/apple-kext-mkernel.c
Daniel Dunbar
daniel at zuster.org
Tue Mar 22 09:48:17 PDT 2011
Author: ddunbar
Date: Tue Mar 22 11:48:17 2011
New Revision: 128087
URL: http://llvm.org/viewvc/llvm-project?rev=128087&view=rev
Log:
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).
Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.h
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Driver/apple-kext-mkernel.c
Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=128087&r1=128086&r2=128087&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Tue Mar 22 11:48:17 2011
@@ -155,6 +155,8 @@
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">,
Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.h?rev=128087&r1=128086&r2=128087&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.h Tue Mar 22 11:48:17 2011
@@ -15,6 +15,7 @@
#define LLVM_CLANG_FRONTEND_CODEGENOPTIONS_H
#include <string>
+#include <vector>
namespace clang {
@@ -114,6 +115,9 @@
/// 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;
Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=128087&r1=128086&r2=128087&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Tue Mar 22 11:48:17 2011
@@ -248,6 +248,8 @@
}
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]));
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=128087&r1=128086&r2=128087&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Mar 22 11:48:17 2011
@@ -440,7 +440,7 @@
// 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 @@
// 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");
}
}
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=128087&r1=128086&r2=128087&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Mar 22 11:48:17 2011
@@ -207,6 +207,10 @@
}
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 @@
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);
Modified: cfe/trunk/test/Driver/apple-kext-mkernel.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/apple-kext-mkernel.c?rev=128087&r1=128086&r2=128087&view=diff
==============================================================================
--- cfe/trunk/test/Driver/apple-kext-mkernel.c (original)
+++ cfe/trunk/test/Driver/apple-kext-mkernel.c Tue Mar 22 11:48:17 2011
@@ -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"
More information about the cfe-commits
mailing list