diff options
author | Daniel Dunbar <daniel@zuster.org> | 2008-09-09 23:14:03 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2008-09-09 23:14:03 +0000 |
commit | 7c086516f3cc9fba2733b1919973206c6ba4b171 (patch) | |
tree | d6bf0f2be9e8b147829ae3209e81ec414c1b1304 /lib/CodeGen/CGObjC.cpp | |
parent | f99cb051665d2faab038ed855b2eff15d603796d (diff) |
Factor CodeGenFunction::StartFunction out of GenerateCode and
StartObjCMethod.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56030 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGObjC.cpp')
-rw-r--r-- | lib/CodeGen/CGObjC.cpp | 52 |
1 files changed, 11 insertions, 41 deletions
diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp index 70c1993887..a3da59410d 100644 --- a/lib/CodeGen/CGObjC.cpp +++ b/lib/CodeGen/CGObjC.cpp @@ -102,53 +102,23 @@ RValue CodeGenFunction::EmitObjCMessageExpr(const ObjCMessageExpr *E) { /// StartObjCMethod - Begin emission of an ObjCMethod. This generates /// the LLVM function and sets the other context used by /// CodeGenFunction. - -// FIXME: This should really be merged with GenerateCode. void CodeGenFunction::StartObjCMethod(const ObjCMethodDecl *OMD) { - CurFn = CGM.getObjCRuntime().GenerateMethod(OMD); + FunctionArgList Args; + llvm::Function *Fn = CGM.getObjCRuntime().GenerateMethod(OMD); - CGM.SetMethodAttributes(OMD, CurFn); - - llvm::BasicBlock *EntryBB = llvm::BasicBlock::Create("entry", CurFn); - - // Create a marker to make it easy to insert allocas into the entryblock - // later. Don't create this with the builder, because we don't want it - // folded. - llvm::Value *Undef = llvm::UndefValue::get(llvm::Type::Int32Ty); - AllocaInsertPt = new llvm::BitCastInst(Undef, llvm::Type::Int32Ty, "allocapt", - EntryBB); + CGM.SetMethodAttributes(OMD, Fn); - FnRetTy = OMD->getResultType(); - CurFuncDecl = OMD; + Args.push_back(std::make_pair(OMD->getSelfDecl(), + OMD->getSelfDecl()->getType())); + Args.push_back(std::make_pair(OMD->getCmdDecl(), + OMD->getCmdDecl()->getType())); - ReturnBlock = llvm::BasicBlock::Create("return", CurFn); - ReturnValue = 0; - if (!FnRetTy->isVoidType()) - ReturnValue = CreateTempAlloca(ConvertType(FnRetTy), "retval"); - - Builder.SetInsertPoint(EntryBB); - - // Emit allocs for param decls. Give the LLVM Argument nodes names. - llvm::Function::arg_iterator AI = CurFn->arg_begin(); - - // Name the struct return argument. - if (hasAggregateLLVMType(OMD->getResultType())) { - AI->setName("agg.result"); - ++AI; + for (unsigned i = 0, e = OMD->getNumParams(); i != e; ++i) { + ParmVarDecl *IPD = OMD->getParamDecl(i); + Args.push_back(std::make_pair(IPD, IPD->getType())); } - // Add implicit parameters to the decl map. - EmitParmDecl(*OMD->getSelfDecl(), AI); - ++AI; - - EmitParmDecl(*OMD->getCmdDecl(), AI); - ++AI; - - for (unsigned i = 0, e = OMD->getNumParams(); i != e; ++i, ++AI) { - assert(AI != CurFn->arg_end() && "Argument mismatch!"); - EmitParmDecl(*OMD->getParamDecl(i), AI); - } - assert(AI == CurFn->arg_end() && "Argument mismatch"); + StartFunction(OMD, OMD->getResultType(), Fn, Args); } /// Generate an Objective-C method. An Objective-C method is a C function with |