[cfe-commits] r130312 - /cfe/trunk/lib/CodeGen/TargetInfo.cpp
Frits van Bommel
fvbommel at gmail.com
Thu Apr 28 02:12:23 PDT 2011
On Wed, Apr 27, 2011 at 7:24 PM, Stuart Hastings <stuart at apple.com> wrote:
> // 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().getTypeSizeInChars(Ty) <= CharUnits::fromQuantity(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);
First of all, a SmallVector<[something], 8> is overkill when you only
ever push_back() a single item. However, since StructType::get()
accepts an ArrayRef<>, you can even just use a single "const
llvm::Type *LLVMField" variable and pass that to StructType::get()
instead of LLVMFields, making it entirely redundant.
> + 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);
Same here.
More information about the cfe-commits
mailing list