diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-04-01 06:13:08 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-04-01 06:13:08 +0000 |
commit | cd76e673eb40779b526e3bbd60b51202572a1d6c (patch) | |
tree | 7d5737065ec1a417a6aa8acd0a202d251e1f8ee0 /clang/lib/CodeGen | |
parent | 034247130e04fa360da7a8395a882d123ffb08b5 (diff) | |
download | bcm5719-llvm-cd76e673eb40779b526e3bbd60b51202572a1d6c.tar.gz bcm5719-llvm-cd76e673eb40779b526e3bbd60b51202572a1d6c.zip |
x86-32 Darwin ABI: Handle direct return of vectors.
- Current return-arguments-32 status is: 8 out of 1000 failures (-7)
llvm-svn: 68192
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGCall.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 291e476f0bd..58e448949e7 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -278,6 +278,28 @@ ABIArgInfo X86_32ABIInfo::classifyReturnType(QualType RetTy, ASTContext &Context) const { if (RetTy->isVoidType()) { return ABIArgInfo::getIgnore(); + } else if (const VectorType *VT = RetTy->getAsVectorType()) { + // On Darwin, some vectors are returned in registers. + if (IsDarwin) { + uint64_t Size = Context.getTypeSize(RetTy); + + // 128-bit vectors are a special case; they are returned in + // registers and we need to make sure to pick a type the LLVM + // backend will like. + if (Size == 128) + return ABIArgInfo::getCoerce(llvm::VectorType::get(llvm::Type::Int64Ty, + 2)); + + // Always return in register if it fits in a general purpose + // register, or if it is 64 bits and has a single element. + if ((Size == 8 || Size == 16 || Size == 32) || + (Size == 64 && VT->getNumElements() == 1)) + return ABIArgInfo::getCoerce(llvm::IntegerType::get(Size)); + + return ABIArgInfo::getIndirect(0); + } + + return ABIArgInfo::getDirect(); } else if (CodeGenFunction::hasAggregateLLVMType(RetTy)) { // Outside of Darwin, structs and unions are always indirect. if (!IsDarwin && !RetTy->isAnyComplexType()) |