diff options
author | Stuart Hastings <stuart@apple.com> | 2011-04-25 23:48:12 +0000 |
---|---|---|
committer | Stuart Hastings <stuart@apple.com> | 2011-04-25 23:48:12 +0000 |
commit | df39fa2811933737974862ad376f140e4cdfeee1 (patch) | |
tree | ce709bae425e3c9cc59834716c607019b7e803d9 /lib/CodeGen/TargetInfo.cpp | |
parent | e2d0191afbe95f46abd21c3511a02a5a76106da4 (diff) |
Turn on byval parameters in Clang for ARM APCS. rdar://problem/7662569
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130176 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/TargetInfo.cpp')
-rw-r--r-- | lib/CodeGen/TargetInfo.cpp | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp index 0b244e8ba1..668970a6ad 100644 --- a/lib/CodeGen/TargetInfo.cpp +++ b/lib/CodeGen/TargetInfo.cpp @@ -2341,23 +2341,34 @@ ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty) const { // Otherwise, pass by coercing to a structure of the appropriate size. // - // FIXME: This is kind of nasty... but there isn't much choice because the ARM - // backend doesn't support byval. // FIXME: This doesn't handle alignment > 64 bits. const llvm::Type* ElemTy; unsigned SizeRegs; - if (getContext().getTypeAlign(Ty) > 32) { - ElemTy = llvm::Type::getInt64Ty(getVMContext()); - SizeRegs = (getContext().getTypeSize(Ty) + 63) / 64; - } else { + if (getContext().getTypeSize(Ty) <= 32) { ElemTy = llvm::Type::getInt32Ty(getVMContext()); SizeRegs = (getContext().getTypeSize(Ty) + 31) / 32; + llvm::SmallVector<const llvm::Type*, 8> LLVMFields; + LLVMFields.push_back(llvm::ArrayType::get(ElemTy, SizeRegs)); + const llvm::Type* STy = llvm::StructType::get(getVMContext(), LLVMFields, + true); + return ABIArgInfo::getDirect(STy); + } + + if (getABIKind() == ARMABIInfo::APCS) { + // Initial ARM ByVal support is APCS-only. + return ABIArgInfo::getIndirect(0, /*ByVal=*/true); + } else { + // FIXME: This is kind of nasty... but there isn't much choice + // because most of the ARM calling conventions don't yet support + // byval. + ElemTy = llvm::Type::getInt64Ty(getVMContext()); + SizeRegs = (getContext().getTypeSize(Ty) + 63) / 64; + llvm::SmallVector<const llvm::Type*, 8> LLVMFields; + LLVMFields.push_back(llvm::ArrayType::get(ElemTy, SizeRegs)); + const llvm::Type* STy = llvm::StructType::get(getVMContext(), LLVMFields, + true); + return ABIArgInfo::getDirect(STy); } - std::vector<const llvm::Type*> LLVMFields; - LLVMFields.push_back(llvm::ArrayType::get(ElemTy, SizeRegs)); - const llvm::Type* STy = llvm::StructType::get(getVMContext(), LLVMFields, - true); - return ABIArgInfo::getDirect(STy); } static bool isIntegerLikeType(QualType Ty, ASTContext &Context, |