summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/TargetInfo.cpp
diff options
context:
space:
mode:
authorMichael Kuperstein <michael.m.kuperstein@intel.com>2015-10-25 08:18:20 +0000
committerMichael Kuperstein <michael.m.kuperstein@intel.com>2015-10-25 08:18:20 +0000
commit6890188ea35079f183a739ae3dfb3b8a0f391c12 (patch)
tree7f5308112edce234e3f9ca9a8e7ecfd58d9d48c1 /clang/lib/CodeGen/TargetInfo.cpp
parenteaa16005af8f47597f3e8d5ed75f5e8fcd0c8bc5 (diff)
downloadbcm5719-llvm-6890188ea35079f183a739ae3dfb3b8a0f391c12.tar.gz
bcm5719-llvm-6890188ea35079f183a739ae3dfb3b8a0f391c12.zip
[X86] Mark inregs correctly for MCU psABI
The MCU psABI calling convention is somewhat, but not quite, like -mregparm 3. In particular, the rules involving structs are different. Differential Revision: http://reviews.llvm.org/D13978 llvm-svn: 251224
Diffstat (limited to 'clang/lib/CodeGen/TargetInfo.cpp')
-rw-r--r--clang/lib/CodeGen/TargetInfo.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index f76fad16cc2..d7cb7ee67ff 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -799,6 +799,7 @@ class X86_32ABIInfo : public ABIInfo {
bool IsRetSmallStructInRegABI;
bool IsWin32StructABI;
bool IsSoftFloatABI;
+ bool IsMCUABI;
unsigned DefaultNumRegisterParameters;
static bool isRegisterSize(unsigned Size) {
@@ -853,6 +854,7 @@ public:
IsRetSmallStructInRegABI(RetSmallStructInRegABI),
IsWin32StructABI(Win32StructABI),
IsSoftFloatABI(SoftFloatABI),
+ IsMCUABI(CGT.getTarget().getTriple().isEnvironmentIAMCU()),
DefaultNumRegisterParameters(NumRegisterParameters) {}
};
@@ -986,7 +988,7 @@ void X86_32TargetCodeGenInfo::addReturnRegisterOutputs(
}
/// shouldReturnTypeInRegister - Determine if the given type should be
-/// returned in a register (for the Darwin ABI).
+/// returned in a register (for the Darwin and MCU ABI).
bool X86_32ABIInfo::shouldReturnTypeInRegister(QualType Ty,
ASTContext &Context) const {
uint64_t Size = Context.getTypeSize(Ty);
@@ -1226,9 +1228,18 @@ bool X86_32ABIInfo::shouldUseInReg(QualType Ty, CCState &State,
if (SizeInRegs == 0)
return false;
- if (SizeInRegs > State.FreeRegs) {
- State.FreeRegs = 0;
- return false;
+ if (!IsMCUABI) {
+ if (SizeInRegs > State.FreeRegs) {
+ State.FreeRegs = 0;
+ return false;
+ }
+ } else {
+ // The MCU psABI allows passing parameters in-reg even if there are
+ // earlier parameters that are passed on the stack. Also,
+ // it does not allow passing >8-byte structs in-register,
+ // even if there are 3 free registers available.
+ if (SizeInRegs > State.FreeRegs || SizeInRegs > 2)
+ return false;
}
State.FreeRegs -= SizeInRegs;
@@ -1372,6 +1383,8 @@ void X86_32ABIInfo::computeInfo(CGFunctionInfo &FI) const {
State.FreeSSERegs = 6;
} else if (FI.getHasRegParm())
State.FreeRegs = FI.getRegParm();
+ else if (IsMCUABI)
+ State.FreeRegs = 3;
else
State.FreeRegs = DefaultNumRegisterParameters;
@@ -1520,7 +1533,7 @@ bool X86_32TargetCodeGenInfo::isStructReturnInRegABI(
return true;
}
- if (Triple.isOSDarwin())
+ if (Triple.isOSDarwin() || Triple.isEnvironmentIAMCU())
return true;
switch (Triple.getOS()) {
OpenPOWER on IntegriCloud