diff options
author | Daniel Dunbar <daniel@zuster.org> | 2008-09-10 04:01:49 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2008-09-10 04:01:49 +0000 |
commit | 45c25ba11cbf8c9a461def5b03f6ee9481e06769 (patch) | |
tree | 2be394b3b5a29a887130e782ffc0fcac8a1f48cd /lib/CodeGen/CodeGenTypes.cpp | |
parent | 2c8e0f32b9c33686be23c70add0b97490903de9f (diff) |
Move FunctionType conversion into CGCall.cpp:
- Added CodeGenTypes::GetFunctionType, taking a CGFunctionInfo.
- Updated Obj-C runtimes to use this instead of rolling the
llvm::FunctionType by hand.
- Killed CodeGenTypes::{ConvertReturnType, DecodeArgumentTypes}.
Add ABIArgInfo class to encapsulate ABI decision of how to lower types
to LLVM.
- Will move to target sometime soon.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56047 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenTypes.cpp')
-rw-r--r-- | lib/CodeGen/CodeGenTypes.cpp | 53 |
1 files changed, 5 insertions, 48 deletions
diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp index c91f801873..c156f7f7a9 100644 --- a/lib/CodeGen/CodeGenTypes.cpp +++ b/lib/CodeGen/CodeGenTypes.cpp @@ -20,6 +20,8 @@ #include "llvm/Module.h" #include "llvm/Target/TargetData.h" +#include "CGCall.h" + using namespace clang; using namespace CodeGen; @@ -167,13 +169,6 @@ void CodeGenTypes::CollectObjCIvarTypes(ObjCInterfaceDecl *ObjCClass, } } -const llvm::Type *CodeGenTypes::ConvertReturnType(QualType T) { - if (T->isVoidType()) - return llvm::Type::VoidTy; // Result of function uses llvm void. - else - return ConvertType(T); -} - static const llvm::Type* getTypeForFormat(const llvm::fltSemantics &format) { if (&format == &llvm::APFloat::IEEEsingle) return llvm::Type::FloatTy; @@ -273,35 +268,9 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) { VT.getNumElements()); } case Type::FunctionNoProto: - case Type::FunctionProto: { - const FunctionType &FP = cast<FunctionType>(Ty); - const llvm::Type *ResultType; - - if (FP.getResultType()->isVoidType()) - ResultType = llvm::Type::VoidTy; // Result of function uses llvm void. - else - ResultType = ConvertTypeRecursive(FP.getResultType()); - - // FIXME: Convert argument types. - bool isVarArg; - std::vector<const llvm::Type*> ArgTys; - - // Struct return passes the struct byref. - if (!ResultType->isSingleValueType() && ResultType != llvm::Type::VoidTy) { - ArgTys.push_back(llvm::PointerType::get(ResultType, - FP.getResultType().getAddressSpace())); - ResultType = llvm::Type::VoidTy; - } - - if (const FunctionTypeProto *FTP = dyn_cast<FunctionTypeProto>(&FP)) { - DecodeArgumentTypes(*FTP, ArgTys); - isVarArg = FTP->isVariadic(); - } else { - isVarArg = true; - } - - return llvm::FunctionType::get(ResultType, ArgTys, isVarArg); - } + return GetFunctionType(CGFunctionInfo(cast<FunctionTypeNoProto>(&Ty))); + case Type::FunctionProto: + return GetFunctionType(CGFunctionInfo(cast<FunctionTypeProto>(&Ty))); case Type::ASQual: return @@ -364,18 +333,6 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) { return llvm::OpaqueType::get(); } -void CodeGenTypes::DecodeArgumentTypes(const FunctionTypeProto &FTP, - std::vector<const llvm::Type*> &ArgTys) { - for (unsigned i = 0, e = FTP.getNumArgs(); i != e; ++i) { - const llvm::Type *Ty = ConvertTypeRecursive(FTP.getArgType(i)); - if (Ty->isSingleValueType()) - ArgTys.push_back(Ty); - else - // byval arguments are always on the stack, which is addr space #0. - ArgTys.push_back(llvm::PointerType::getUnqual(Ty)); - } -} - /// ConvertTagDeclType - Lay out a tagged decl type like struct or union or /// enum. const llvm::Type *CodeGenTypes::ConvertTagDeclType(const TagDecl *TD) { |