// FIXME: This is just a temporary option, for testing purposes.
unsigned NoBitFieldTypeAlign : 1;
+ unsigned MRTD : 1; // -mrtd calling convention
+
private:
// We declare multibit enums as unsigned because MSVC insists on making enums
// signed. Set/Query these values using accessors.
FastRelaxedMath = 0;
DefaultFPContract = 0;
NoBitFieldTypeAlign = 0;
+ MRTD = 0;
}
GCMode getGCMode() const { return (GCMode) GC; }
HelpText<"Limit the number of registers available for integer arguments">;
def mrelax_all : Flag<"-mrelax-all">,
HelpText<"Relax all machine instructions">;
+def mrtd: Flag<"-mrtd">,
+ HelpText<"Make StdCall calling convention the default">;
def mrelocation_model : Separate<"-mrelocation-model">,
HelpText<"The relocation model to use">;
def munwind_tables : Flag<"-munwind-tables">,
def mno_pascal_strings : Flag<"-mno-pascal-strings">, Group<m_Group>;
def mno_red_zone : Flag<"-mno-red-zone">, Group<m_Group>;
def mno_relax_all : Flag<"-mno-relax-all">, Group<m_Group>;
+def mno_rtd: Flag<"-mno-rtd">, Group<m_Group>;
def mno_soft_float : Flag<"-mno-soft-float">, Group<m_Group>;
def mno_sse2 : Flag<"-mno-sse2">, Group<m_x86_Features_Group>;
def mno_sse3 : Flag<"-mno-sse3">, Group<m_x86_Features_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 mrtd: Flag<"-mrtd">, Group<m_Group>;
def msoft_float : Flag<"-msoft-float">, Group<m_Group>;
def msse2 : Flag<"-msse2">, Group<m_x86_Features_Group>;
def msse3 : Flag<"-msse3">, Group<m_x86_Features_Group>;
QualType
ASTContext::getFunctionNoProtoType(QualType ResultTy,
const FunctionType::ExtInfo &Info) const {
- const CallingConv CallConv = Info.getCC();
+ const CallingConv DefaultCC = Info.getCC();
+ const CallingConv CallConv = (LangOpts.MRTD && DefaultCC == CC_Default) ?
+ CC_X86StdCall : DefaultCC;
// Unique functions, to guarantee there is only one function of a particular
// structure.
llvm::FoldingSetNodeID ID;
assert(NewIP == 0 && "Shouldn't be in the map!"); (void)NewIP;
}
+ FunctionProtoType::ExtInfo newInfo = Info.withCallingConv(CallConv);
FunctionNoProtoType *New = new (*this, TypeAlignment)
- FunctionNoProtoType(ResultTy, Canonical, Info);
+ FunctionNoProtoType(ResultTy, Canonical, newInfo);
Types.push_back(New);
FunctionNoProtoTypes.InsertNode(New, InsertPos);
return QualType(New, 0);
if (!ArgArray[i].isCanonicalAsParam())
isCanonical = false;
- const CallingConv CallConv = EPI.ExtInfo.getCC();
+ const CallingConv DefaultCC = EPI.ExtInfo.getCC();
+ const CallingConv CallConv = (LangOpts.MRTD && DefaultCC == CC_Default) ?
+ CC_X86StdCall : DefaultCC;
// If this type isn't canonical, get the canonical version of it.
// The exception spec is not part of the canonical type.
NumArgs * sizeof(QualType) +
EPI.NumExceptions * sizeof(QualType);
FunctionProtoType *FTP = (FunctionProtoType*) Allocate(Size, TypeAlignment);
- new (FTP) FunctionProtoType(ResultTy, ArgArray, NumArgs, Canonical, EPI);
+ FunctionProtoType::ExtProtoInfo newEPI = EPI;
+ newEPI.ExtInfo = EPI.ExtInfo.withCallingConv(CallConv);
+ new (FTP) FunctionProtoType(ResultTy, ArgArray, NumArgs, Canonical, newEPI);
Types.push_back(FTP);
FunctionProtoTypes.InsertNode(FTP, InsertPos);
return QualType(FTP, 0);
CmdArgs.push_back(A->getValue(Args));
}
+ if (Args.hasFlag(options::OPT_mrtd, options::OPT_mno_rtd, false))
+ CmdArgs.push_back("-mrtd");
+
// FIXME: Set --enable-unsafe-fp-math.
if (Args.hasFlag(options::OPT_fno_omit_frame_pointer,
options::OPT_fomit_frame_pointer))
Opts.SinglePrecisionConstants = Args.hasArg(OPT_cl_single_precision_constant);
Opts.FastRelaxedMath = Args.hasArg(OPT_cl_fast_relaxed_math);
Opts.OptimizeSize = 0;
+ Opts.MRTD = Args.hasArg(OPT_mrtd);
// FIXME: Eliminate this dependency.
unsigned Opt = getOptimizationLevel(Args, IK, Diags);
PARSE_LANGOPT(DefaultFPContract);
PARSE_LANGOPT(ElideConstructors);
PARSE_LANGOPT(SpellChecking);
+ PARSE_LANGOPT(MRTD);
#undef PARSE_LANGOPT
return Listener->ReadLanguageOptions(LangOpts);
Record.push_back(LangOpts.DefaultFPContract);
Record.push_back(LangOpts.ElideConstructors);
Record.push_back(LangOpts.SpellChecking);
+ Record.push_back(LangOpts.MRTD);
Stream.EmitRecord(LANGUAGE_OPTIONS, Record);
}
--- /dev/null
+// RUN: %clang_cc1 -mrtd -triple i386-unknown-freebsd9.0 -emit-llvm -o - %s | FileCheck %s
+
+void baz(int arg);
+
+// CHECK: define x86_stdcallcc void @foo(i32 %arg) nounwind
+void foo(int arg) {
+// CHECK: %call = call x86_stdcallcc i32 (...)* @bar(i32 %tmp)
+ bar(arg);
+// CHECK: call x86_stdcallcc void @baz(i32 %tmp1)
+ baz(arg);
+}
+
+// CHECK: declare x86_stdcallcc i32 @bar(...)
+
+// CHECK: declare x86_stdcallcc void @baz(i32)