diff options
author | John McCall <rjmccall@apple.com> | 2012-02-17 03:33:10 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2012-02-17 03:33:10 +0000 |
commit | de5d3c717684f3821b8db58037bc7140acf134aa (patch) | |
tree | 1da3f29eb82c1e2cd61af4f0ccd0e23ca2809793 /lib/CodeGen/TargetInfo.cpp | |
parent | a345edb668380691fc92d4e4aa0a5ffec366ca6a (diff) |
Whether an argument is required (in contrast with being an
optional argument passed through the variadic ellipsis)
potentially affects how we need to lower it. Propagate
this information down to the various getFunctionInfo(...)
overloads on CodeGenTypes. Furthermore, rename those
overloads to clarify their distinct purposes, and make
sure we're calling the right one in the right place.
This has a nice side-effect of making it easier to construct
a function type, since the 'variadic' bit is no longer
separable.
This shouldn't really change anything for our existing
platforms, with one minor exception --- we should now call
variadic ObjC methods with the ... in the "right place"
(see the test case), which I guess matters for anyone
running GNUStep on MIPS. Mostly it's just a substantial
clean-up.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150788 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/TargetInfo.cpp')
-rw-r--r-- | lib/CodeGen/TargetInfo.cpp | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp index cae8f5fb1a..2ee662c1e7 100644 --- a/lib/CodeGen/TargetInfo.cpp +++ b/lib/CodeGen/TargetInfo.cpp @@ -98,8 +98,8 @@ unsigned TargetCodeGenInfo::getSizeOfUnwindException() const { return 32; } -bool TargetCodeGenInfo::isNoProtoCallVariadic( - const CodeGen::CGFunctionInfo &) const { +bool TargetCodeGenInfo::isNoProtoCallVariadic(const CallArgList &args, + const FunctionNoProtoType *fnType) const { // The following conventions are known to require this to be false: // x86_stdcall // MIPS @@ -935,6 +935,17 @@ public: X86_64ABIInfo(CodeGen::CodeGenTypes &CGT, bool hasavx) : ABIInfo(CGT), HasAVX(hasavx) {} + bool isPassedUsingAVXType(QualType type) const { + unsigned neededInt, neededSSE; + ABIArgInfo info = classifyArgumentType(type, neededInt, neededSSE); + if (info.isDirect()) { + llvm::Type *ty = info.getCoerceToType(); + if (llvm::VectorType *vectorTy = dyn_cast_or_null<llvm::VectorType>(ty)) + return (vectorTy->getBitWidth() > 128); + } + return false; + } + virtual void computeInfo(CGFunctionInfo &FI) const; virtual llvm::Value *EmitVAArg(llvm::Value *VAListAddr, QualType Ty, @@ -960,6 +971,10 @@ public: X86_64TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT, bool HasAVX) : TargetCodeGenInfo(new X86_64ABIInfo(CGT, HasAVX)) {} + const X86_64ABIInfo &getABIInfo() const { + return static_cast<const X86_64ABIInfo&>(TargetCodeGenInfo::getABIInfo()); + } + int getDwarfEHStackPointer(CodeGen::CodeGenModule &CGM) const { return 7; } @@ -980,33 +995,29 @@ public: return X86AdjustInlineAsmType(CGF, Constraint, Ty); } - bool isNoProtoCallVariadic(const CodeGen::CGFunctionInfo &FI) const { + bool isNoProtoCallVariadic(const CallArgList &args, + const FunctionNoProtoType *fnType) const { // The default CC on x86-64 sets %al to the number of SSA // registers used, and GCC sets this when calling an unprototyped // function, so we override the default behavior. However, don't do // that when AVX types are involved: the ABI explicitly states it is // undefined, and it doesn't work in practice because of how the ABI // defines varargs anyway. - if (FI.getCallingConvention() == llvm::CallingConv::C) { + if (fnType->getCallConv() == CC_Default || fnType->getCallConv() == CC_C) { bool HasAVXType = false; - for (CGFunctionInfo::const_arg_iterator it = FI.arg_begin(), - ie = FI.arg_end(); - it != ie; ++it) { - if (it->info.isDirect()) { - llvm::Type *Ty = it->info.getCoerceToType(); - if (llvm::VectorType *VTy = dyn_cast_or_null<llvm::VectorType>(Ty)) { - if (VTy->getBitWidth() > 128) { - HasAVXType = true; - break; - } - } + for (CallArgList::const_iterator + it = args.begin(), ie = args.end(); it != ie; ++it) { + if (getABIInfo().isPassedUsingAVXType(it->Ty)) { + HasAVXType = true; + break; } } + if (!HasAVXType) return true; } - return TargetCodeGenInfo::isNoProtoCallVariadic(FI); + return TargetCodeGenInfo::isNoProtoCallVariadic(args, fnType); } }; |