Pass the LLVM IR version of argument types down into computeInfo.

This is somewhat annoying to do this at this level, but it avoids
having ABIInfo know depend on CodeGenTypes for a hint.

Nothing is using this yet, so no functionality change.

llvm-svn: 107111
This commit is contained in:
Chris Lattner 2010-06-29 01:08:48 +00:00
parent 1e5da550e5
commit 1d7c9f7f4b
3 changed files with 38 additions and 10 deletions

View File

@ -136,7 +136,11 @@ namespace clang {
virtual void computeInfo(CodeGen::CGFunctionInfo &FI,
ASTContext &Ctx,
llvm::LLVMContext &VMContext) const = 0;
llvm::LLVMContext &VMContext,
// This is the preferred type for argument lowering
// which can be used to generate better IR.
const llvm::Type *const *PrefTypes = 0,
unsigned NumPrefTypes = 0) const = 0;
/// EmitVAArg - Emit the target dependent code to load a value of
/// \arg Ty from the va_list pointed to by \arg VAListAddr.

View File

@ -244,8 +244,16 @@ const CGFunctionInfo &CodeGenTypes::getFunctionInfo(CanQualType ResTy,
ArgTys);
FunctionInfos.InsertNode(FI, InsertPos);
// ABI lowering wants to know what our preferred type for the argument is in
// various situations, pass it in.
llvm::SmallVector<const llvm::Type *, 8> PreferredArgTypes;
for (llvm::SmallVectorImpl<CanQualType>::const_iterator
I = ArgTys.begin(), E = ArgTys.end(); I != E; ++I)
PreferredArgTypes.push_back(ConvertType(*I));
// Compute ABI information.
getABIInfo().computeInfo(*FI, getContext(), TheModule.getContext());
getABIInfo().computeInfo(*FI, getContext(), TheModule.getContext(),
PreferredArgTypes.data(), PreferredArgTypes.size());
return *FI;
}

View File

@ -280,7 +280,9 @@ class DefaultABIInfo : public ABIInfo {
llvm::LLVMContext &VMContext) const;
virtual void computeInfo(CGFunctionInfo &FI, ASTContext &Context,
llvm::LLVMContext &VMContext) const {
llvm::LLVMContext &VMContext,
const llvm::Type *const *PrefTypes,
unsigned NumPrefTypes) const {
FI.getReturnInfo() = classifyReturnType(FI.getReturnType(), Context,
VMContext);
for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end();
@ -347,7 +349,9 @@ public:
llvm::LLVMContext &VMContext) const;
virtual void computeInfo(CGFunctionInfo &FI, ASTContext &Context,
llvm::LLVMContext &VMContext) const {
llvm::LLVMContext &VMContext,
const llvm::Type *const *PrefTypes,
unsigned NumPrefTypes) const {
FI.getReturnInfo() = classifyReturnType(FI.getReturnType(), Context,
VMContext);
for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end();
@ -747,7 +751,9 @@ class X86_64ABIInfo : public ABIInfo {
public:
virtual void computeInfo(CGFunctionInfo &FI, ASTContext &Context,
llvm::LLVMContext &VMContext) const;
llvm::LLVMContext &VMContext,
const llvm::Type *const *PrefTypes,
unsigned NumPrefTypes) const;
virtual llvm::Value *EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
CodeGenFunction &CGF) const;
@ -1373,7 +1379,9 @@ ABIArgInfo X86_64ABIInfo::classifyArgumentType(QualType Ty, ASTContext &Context,
}
void X86_64ABIInfo::computeInfo(CGFunctionInfo &FI, ASTContext &Context,
llvm::LLVMContext &VMContext) const {
llvm::LLVMContext &VMContext,
const llvm::Type *const *PrefTypes,
unsigned NumPrefTypes) const {
FI.getReturnInfo() = classifyReturnType(FI.getReturnType(),
Context, VMContext);
@ -1635,7 +1643,9 @@ class PIC16ABIInfo : public ABIInfo {
llvm::LLVMContext &VMContext) const;
virtual void computeInfo(CGFunctionInfo &FI, ASTContext &Context,
llvm::LLVMContext &VMContext) const {
llvm::LLVMContext &VMContext,
const llvm::Type *const *PrefTypes,
unsigned NumPrefTypes) const {
FI.getReturnInfo() = classifyReturnType(FI.getReturnType(), Context,
VMContext);
for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end();
@ -1786,7 +1796,9 @@ private:
llvm::LLVMContext &VMContext) const;
virtual void computeInfo(CGFunctionInfo &FI, ASTContext &Context,
llvm::LLVMContext &VMContext) const;
llvm::LLVMContext &VMContext,
const llvm::Type *const *PrefTypes,
unsigned NumPrefTypes) const;
virtual llvm::Value *EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
CodeGenFunction &CGF) const;
@ -1805,7 +1817,9 @@ public:
}
void ARMABIInfo::computeInfo(CGFunctionInfo &FI, ASTContext &Context,
llvm::LLVMContext &VMContext) const {
llvm::LLVMContext &VMContext,
const llvm::Type *const *PrefTypes,
unsigned NumPrefTypes) const {
FI.getReturnInfo() = classifyReturnType(FI.getReturnType(), Context,
VMContext);
for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end();
@ -2088,7 +2102,9 @@ class SystemZABIInfo : public ABIInfo {
llvm::LLVMContext &VMContext) const;
virtual void computeInfo(CGFunctionInfo &FI, ASTContext &Context,
llvm::LLVMContext &VMContext) const {
llvm::LLVMContext &VMContext,
const llvm::Type *const *PrefTypes,
unsigned NumPrefTypes) const {
FI.getReturnInfo() = classifyReturnType(FI.getReturnType(),
Context, VMContext);
for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end();