aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGObjCMac.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2008-09-10 04:01:49 +0000
committerDaniel Dunbar <daniel@zuster.org>2008-09-10 04:01:49 +0000
commit45c25ba11cbf8c9a461def5b03f6ee9481e06769 (patch)
tree2be394b3b5a29a887130e782ffc0fcac8a1f48cd /lib/CodeGen/CGObjCMac.cpp
parent2c8e0f32b9c33686be23c70add0b97490903de9f (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/CGObjCMac.cpp')
-rw-r--r--lib/CodeGen/CGObjCMac.cpp54
1 files changed, 3 insertions, 51 deletions
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index e3fcbdf11d..d63004f212 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -1344,66 +1344,18 @@ llvm::Constant *CGObjCMac::EmitMethodList(const std::string &Name,
}
llvm::Function *CGObjCMac::GenerateMethod(const ObjCMethodDecl *OMD) {
- const llvm::Type *ReturnTy =
- CGM.getTypes().ConvertReturnType(OMD->getResultType());
- const llvm::Type *SelfTy =
- CGM.getTypes().ConvertType(OMD->getSelfDecl()->getType());
-
- std::vector<const llvm::Type*> ArgTys;
- ArgTys.reserve(1 + 2 + OMD->param_size());
-
- // FIXME: This is not something we should have to be dealing with
- // here.
- bool useStructRet =
- CodeGen::CodeGenFunction::hasAggregateLLVMType(OMD->getResultType());
- if (useStructRet) {
- ArgTys.push_back(llvm::PointerType::getUnqual(ReturnTy));
- ReturnTy = llvm::Type::VoidTy;
- }
-
- // Implicit arguments
- ArgTys.push_back(SelfTy);
- ArgTys.push_back(ObjCTypes.SelectorPtrTy);
-
- for (ObjCMethodDecl::param_const_iterator
- i = OMD->param_begin(), e = OMD->param_end();
- i != e; ++i) {
- const llvm::Type *Ty = CGM.getTypes().ConvertType((*i)->getType());
- if (Ty->isSingleValueType()) {
- ArgTys.push_back(Ty);
- } else {
- ArgTys.push_back(llvm::PointerType::getUnqual(Ty));
- }
- }
-
std::string Name;
GetNameForMethod(OMD, Name);
+ const llvm::FunctionType *MethodTy =
+ CGM.getTypes().GetFunctionType(CGFunctionInfo(OMD, CGM.getContext()));
llvm::Function *Method =
- llvm::Function::Create(llvm::FunctionType::get(ReturnTy,
- ArgTys,
- OMD->isVariadic()),
+ llvm::Function::Create(MethodTy,
llvm::GlobalValue::InternalLinkage,
Name,
&CGM.getModule());
MethodDefinitions.insert(std::make_pair(OMD, Method));
- unsigned Offset = 3; // Return plus self and selector implicit args.
- if (useStructRet) {
- Method->addParamAttr(1, llvm::ParamAttr::StructRet);
- ++Offset;
- }
-
- // FIXME: This is horrible, we need to be reusing the machinery in
- // CodeGenModule.cpp (SetFunctionAttributes).
- for (ObjCMethodDecl::param_const_iterator
- i = OMD->param_begin(), e = OMD->param_end();
- i != e; ++i, ++Offset) {
- const llvm::Type *Ty = CGM.getTypes().ConvertType((*i)->getType());
- if (!Ty->isSingleValueType())
- Method->addParamAttr(Offset, llvm::ParamAttr::ByVal);
- }
-
return Method;
}