summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/TargetInfo.cpp
diff options
context:
space:
mode:
authorTim Northover <tnorthover@apple.com>2014-11-07 22:30:50 +0000
committerTim Northover <tnorthover@apple.com>2014-11-07 22:30:50 +0000
commit5a1558ec31903371b0843382ce313749be0d13a4 (patch)
treec7e6a6f852d5da0aba5360dd2216bd7fa9a1e007 /clang/lib/CodeGen/TargetInfo.cpp
parentedf99a92c00193fb72f3e94f4440b9f86789cca4 (diff)
downloadbcm5719-llvm-5a1558ec31903371b0843382ce313749be0d13a4.tar.gz
bcm5719-llvm-5a1558ec31903371b0843382ce313749be0d13a4.zip
ARM ABI: simplify decisions on whether args can be expanded.
Homogeneous aggregates on AAPCS_VFP ARM need to be passed *without* being flattened (e.g. [2 x float] rather than "float, float") for various weird ABI reasons. However, this isn't the case for anything else; further, we know at the ABIArgInfo::getDirect callsites whether this flattening is allowed. So, we can get more unified ARM code, with a simpler Clang, by just using that knowledge directly. llvm-svn: 221559
Diffstat (limited to 'clang/lib/CodeGen/TargetInfo.cpp')
-rw-r--r--clang/lib/CodeGen/TargetInfo.cpp56
1 files changed, 21 insertions, 35 deletions
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index c51a48646f4..870e392807b 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -4546,9 +4546,6 @@ void ARMABIInfo::computeInfo(CGFunctionInfo &FI) const {
// unallocated are marked as unavailable.
resetAllocatedRegs();
- const bool isAAPCS_VFP =
- getABIKind() == ARMABIInfo::AAPCS_VFP && !FI.isVariadic();
-
if (getCXXABI().classifyReturnType(FI)) {
if (FI.getReturnInfo().isIndirect())
markAllocatedGPRs(1, 1);
@@ -4578,11 +4575,11 @@ void ARMABIInfo::computeInfo(CGFunctionInfo &FI) const {
llvm::Type *PaddingTy = llvm::ArrayType::get(
llvm::Type::getInt32Ty(getVMContext()), NumGPRs - PreAllocationGPRs);
if (I.info.canHaveCoerceToType()) {
- I.info = ABIArgInfo::getDirect(I.info.getCoerceToType() /* type */, 0 /* offset */,
- PaddingTy, !isAAPCS_VFP);
+ I.info = ABIArgInfo::getDirect(I.info.getCoerceToType() /* type */,
+ 0 /* offset */, PaddingTy, true);
} else {
I.info = ABIArgInfo::getDirect(nullptr /* type */, 0 /* offset */,
- PaddingTy, !isAAPCS_VFP);
+ PaddingTy, true);
}
}
}
@@ -4693,9 +4690,7 @@ ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty, bool isVariadic,
// with a Base Type of a single- or double-precision floating-point type,
// 64-bit containerized vectors or 128-bit containerized vectors with one
// to four Elements.
-
- const bool isAAPCS_VFP =
- getABIKind() == ARMABIInfo::AAPCS_VFP && !isVariadic;
+ bool IsEffectivelyAAPCS_VFP = getABIKind() == AAPCS_VFP && !isVariadic;
// Handle illegal vector types here.
if (isIllegalVectorType(Ty)) {
@@ -4704,7 +4699,7 @@ ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty, bool isVariadic,
llvm::Type *ResType =
llvm::Type::getInt32Ty(getVMContext());
markAllocatedGPRs(1, 1);
- return ABIArgInfo::getDirect(ResType, 0, nullptr, !isAAPCS_VFP);
+ return ABIArgInfo::getDirect(ResType);
}
if (Size == 64) {
llvm::Type *ResType = llvm::VectorType::get(
@@ -4715,7 +4710,7 @@ ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty, bool isVariadic,
markAllocatedVFPs(2, 2);
IsCPRC = true;
}
- return ABIArgInfo::getDirect(ResType, 0, nullptr, !isAAPCS_VFP);
+ return ABIArgInfo::getDirect(ResType);
}
if (Size == 128) {
llvm::Type *ResType = llvm::VectorType::get(
@@ -4726,7 +4721,7 @@ ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty, bool isVariadic,
markAllocatedVFPs(4, 4);
IsCPRC = true;
}
- return ABIArgInfo::getDirect(ResType, 0, nullptr, !isAAPCS_VFP);
+ return ABIArgInfo::getDirect(ResType);
}
markAllocatedGPRs(1, 1);
return ABIArgInfo::getIndirect(0, /*ByVal=*/false);
@@ -4765,9 +4760,8 @@ ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty, bool isVariadic,
unsigned Size = getContext().getTypeSize(Ty);
if (!IsCPRC)
markAllocatedGPRs(Size > 32 ? 2 : 1, (Size + 31) / 32);
- return (Ty->isPromotableIntegerType()
- ? ABIArgInfo::getExtend()
- : ABIArgInfo::getDirect(nullptr, 0, nullptr, !isAAPCS_VFP));
+ return (Ty->isPromotableIntegerType() ? ABIArgInfo::getExtend()
+ : ABIArgInfo::getDirect());
}
if (CGCXXABI::RecordArgABI RAA = getRecordArgABI(Ty, getCXXABI())) {
@@ -4779,7 +4773,7 @@ ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty, bool isVariadic,
if (isEmptyRecord(getContext(), Ty, true))
return ABIArgInfo::getIgnore();
- if (isAAPCS_VFP) {
+ if (IsEffectivelyAAPCS_VFP) {
// Homogeneous Aggregates need to be expanded when we can fit the aggregate
// into VFP registers.
const Type *Base = nullptr;
@@ -4800,7 +4794,7 @@ ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty, bool isVariadic,
markAllocatedVFPs(2, Members * 2);
}
IsCPRC = true;
- return ABIArgInfo::getDirect(nullptr, 0, nullptr, !isAAPCS_VFP);
+ return ABIArgInfo::getDirect(nullptr, 0, nullptr, false);
}
}
@@ -4838,9 +4832,7 @@ ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty, bool isVariadic,
markAllocatedGPRs(2, SizeRegs * 2);
}
- llvm::Type *STy =
- llvm::StructType::get(llvm::ArrayType::get(ElemTy, SizeRegs), NULL);
- return ABIArgInfo::getDirect(STy, 0, nullptr, !isAAPCS_VFP);
+ return ABIArgInfo::getDirect(llvm::ArrayType::get(ElemTy, SizeRegs));
}
static bool isIntegerLikeType(QualType Ty, ASTContext &Context,
@@ -4930,8 +4922,7 @@ static bool isIntegerLikeType(QualType Ty, ASTContext &Context,
ABIArgInfo ARMABIInfo::classifyReturnType(QualType RetTy,
bool isVariadic) const {
- const bool isAAPCS_VFP =
- getABIKind() == ARMABIInfo::AAPCS_VFP && !isVariadic;
+ bool IsEffectivelyAAPCS_VFP = getABIKind() == AAPCS_VFP && !isVariadic;
if (RetTy->isVoidType())
return ABIArgInfo::getIgnore();
@@ -4947,9 +4938,8 @@ ABIArgInfo ARMABIInfo::classifyReturnType(QualType RetTy,
if (const EnumType *EnumTy = RetTy->getAs<EnumType>())
RetTy = EnumTy->getDecl()->getIntegerType();
- return (RetTy->isPromotableIntegerType()
- ? ABIArgInfo::getExtend()
- : ABIArgInfo::getDirect(nullptr, 0, nullptr, !isAAPCS_VFP));
+ return RetTy->isPromotableIntegerType() ? ABIArgInfo::getExtend()
+ : ABIArgInfo::getDirect();
}
// Are we following APCS?
@@ -4987,13 +4977,13 @@ ABIArgInfo ARMABIInfo::classifyReturnType(QualType RetTy,
return ABIArgInfo::getIgnore();
// Check for homogeneous aggregates with AAPCS-VFP.
- if (getABIKind() == AAPCS_VFP && !isVariadic) {
+ if (IsEffectivelyAAPCS_VFP) {
const Type *Base = nullptr;
uint64_t Members;
if (isHomogeneousAggregate(RetTy, Base, Members)) {
assert(Base && "Base class should be set for homogeneous aggregate");
// Homogeneous Aggregates are returned directly.
- return ABIArgInfo::getDirect(nullptr, 0, nullptr, !isAAPCS_VFP);
+ return ABIArgInfo::getDirect(nullptr, 0, nullptr, false);
}
}
@@ -5003,18 +4993,14 @@ ABIArgInfo ARMABIInfo::classifyReturnType(QualType RetTy,
if (Size <= 32) {
if (getDataLayout().isBigEndian())
// Return in 32 bit integer integer type (as if loaded by LDR, AAPCS 5.4)
- return ABIArgInfo::getDirect(llvm::Type::getInt32Ty(getVMContext()), 0,
- nullptr, !isAAPCS_VFP);
+ return ABIArgInfo::getDirect(llvm::Type::getInt32Ty(getVMContext()));
// Return in the smallest viable integer type.
if (Size <= 8)
- return ABIArgInfo::getDirect(llvm::Type::getInt8Ty(getVMContext()), 0,
- nullptr, !isAAPCS_VFP);
+ return ABIArgInfo::getDirect(llvm::Type::getInt8Ty(getVMContext()));
if (Size <= 16)
- return ABIArgInfo::getDirect(llvm::Type::getInt16Ty(getVMContext()), 0,
- nullptr, !isAAPCS_VFP);
- return ABIArgInfo::getDirect(llvm::Type::getInt32Ty(getVMContext()), 0,
- nullptr, !isAAPCS_VFP);
+ return ABIArgInfo::getDirect(llvm::Type::getInt16Ty(getVMContext()));
+ return ABIArgInfo::getDirect(llvm::Type::getInt32Ty(getVMContext()));
}
markAllocatedGPRs(1, 1);
OpenPOWER on IntegriCloud