[cfe-commits] r125201 - in /cfe/trunk: include/clang/Driver/CC1Options.td include/clang/Driver/Options.td include/clang/Frontend/CodeGenOptions.h lib/CodeGen/CGCall.cpp lib/Driver/Tools.cpp lib/Frontend/CompilerInvocation.cpp test/CodeGen/regparm-flag.c
Daniel Dunbar
daniel at zuster.org
Wed Feb 9 09:54:19 PST 2011
Author: ddunbar
Date: Wed Feb 9 11:54:19 2011
New Revision: 125201
URL: http://llvm.org/viewvc/llvm-project?rev=125201&view=rev
Log:
Driver/Frontend: Wire up -mregparm=.
Added:
cfe/trunk/test/CodeGen/regparm-flag.c
Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.h
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=125201&r1=125200&r2=125201&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Wed Feb 9 11:54:19 2011
@@ -177,6 +177,8 @@
HelpText<"Omit frame pointer setup for leaf functions.">;
def msoft_float : Flag<"-msoft-float">,
HelpText<"Use software floating point">;
+def mregparm : Separate<"-mregparm">,
+ HelpText<"Limit the number of registers available for integer arguments">;
def mrelax_all : Flag<"-mrelax-all">,
HelpText<"Relax all machine instructions">;
def mrelocation_model : Separate<"-mrelocation-model">,
Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=125201&r1=125200&r2=125201&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Feb 9 11:54:19 2011
@@ -505,6 +505,7 @@
def momit_leaf_frame_pointer : Flag<"-momit-leaf-frame-pointer">, Group<f_Group>;
def mpascal_strings : Flag<"-mpascal-strings">, Group<m_Group>;
def mred_zone : Flag<"-mred-zone">, Group<m_Group>;
+def mregparm_EQ : Joined<"-mregparm=">, Group<m_Group>;
def mrelax_all : Flag<"-mrelax-all">, Group<m_Group>;
def msoft_float : Flag<"-msoft-float">, Group<m_Group>;
def msse2 : Flag<"-msse2">, Group<m_x86_Features_Group>;
Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.h?rev=125201&r1=125200&r2=125201&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.h Wed Feb 9 11:54:19 2011
@@ -111,6 +111,10 @@
/// The name of the relocation model to use.
std::string RelocationModel;
+ /// The user specified number of registers to be used for integral arguments,
+ /// or 0 if unspecified.
+ unsigned NumRegisterParameters;
+
public:
CodeGenOptions() {
AsmVerbose = 0;
@@ -134,6 +138,7 @@
NoInfsFPMath = 0;
NoNaNsFPMath = 0;
NoZeroInitializedInBSS = 0;
+ NumRegisterParameters = 0;
ObjCDispatchMethod = Legacy;
OmitLeafFramePointer = 0;
OptimizationLevel = 0;
Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=125201&r1=125200&r2=125201&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Wed Feb 9 11:54:19 2011
@@ -755,10 +755,10 @@
if (RetAttrs)
PAL.push_back(llvm::AttributeWithIndex::get(0, RetAttrs));
- // FIXME: we need to honor command line settings also.
- // FIXME: RegParm should be reduced in case of nested functions and/or global
- // register variable.
+ // FIXME: RegParm should be reduced in case of global register variable.
signed RegParm = FI.getRegParm();
+ if (!RegParm)
+ RegParm = CodeGenOpts.NumRegisterParameters;
unsigned PointerWidth = getContext().Target.getPointerWidth(0);
for (CGFunctionInfo::const_arg_iterator it = FI.arg_begin(),
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=125201&r1=125200&r2=125201&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Feb 9 11:54:19 2011
@@ -1012,6 +1012,11 @@
// LLVM Code Generator Options.
+ if (Arg *A = Args.getLastArg(options::OPT_mregparm_EQ)) {
+ CmdArgs.push_back("-mregparm");
+ CmdArgs.push_back(A->getValue(Args));
+ }
+
// FIXME: Set --enable-unsafe-fp-math.
if (Args.hasFlag(options::OPT_fno_omit_frame_pointer,
options::OPT_fomit_frame_pointer))
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=125201&r1=125200&r2=125201&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Feb 9 11:54:19 2011
@@ -202,6 +202,10 @@
Res.push_back("-fobjc-dispatch-method=non-legacy");
break;
}
+ if (Opts.NumRegisterParameters) {
+ Res.push_back("-mregparm");
+ Res.push_back(llvm::utostr(Opts.NumRegisterParameters));
+ }
if (Opts.RelaxAll)
Res.push_back("-mrelax-all");
if (Opts.SoftFloat)
@@ -928,6 +932,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.NumRegisterParameters = Args.getLastArgIntValue(OPT_mregparm, 0, Diags);
Opts.RelaxAll = Args.hasArg(OPT_mrelax_all);
Opts.OmitLeafFramePointer = Args.hasArg(OPT_momit_leaf_frame_pointer);
Opts.SoftFloat = Args.hasArg(OPT_msoft_float);
Added: cfe/trunk/test/CodeGen/regparm-flag.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/regparm-flag.c?rev=125201&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/regparm-flag.c (added)
+++ cfe/trunk/test/CodeGen/regparm-flag.c Wed Feb 9 11:54:19 2011
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -mregparm 4 %s -emit-llvm -o %t
+// RUN: FileCheck < %t %s
+
+void f1(int a, int b, int c, int d,
+ int e, int f, int g, int h);
+
+void f0() {
+// CHECK: call void @f1(i32 inreg 1, i32 inreg 2, i32 inreg 3, i32 inreg 4,
+// CHECK: i32 5, i32 6, i32 7, i32 8)
+ f1(1, 2, 3, 4, 5, 6, 7, 8);
+}
+
+// CHECK: declare void @f1(i32 inreg, i32 inreg, i32 inreg, i32 inreg,
+// CHECK: i32, i32, i32, i32)
+
More information about the cfe-commits
mailing list