diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-02-02 22:03:45 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-02-02 22:03:45 +0000 |
commit | 88b5396b0897f28d22ae3debf4a0d97b33b6c362 (patch) | |
tree | 7838b5a53781e11e09273dad5fdd044b44174b9d | |
parent | d671c5a61605ab864768cbbb4feb9cd652609083 (diff) |
More ABI API cleanup.
- Lift CGFunctionInfo creation above ReturnTypeUsesSret and
EmitFunction{Epi,Pro}log.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63553 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/CGCall.cpp | 25 | ||||
-rw-r--r-- | lib/CodeGen/CGExpr.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/CGObjC.cpp | 6 | ||||
-rw-r--r-- | lib/CodeGen/CGObjCGNU.cpp | 4 | ||||
-rw-r--r-- | lib/CodeGen/CGObjCMac.cpp | 4 | ||||
-rw-r--r-- | lib/CodeGen/CodeGenFunction.cpp | 6 | ||||
-rw-r--r-- | lib/CodeGen/CodeGenFunction.h | 11 | ||||
-rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/CodeGenModule.h | 6 |
9 files changed, 34 insertions, 32 deletions
diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp index a592ace68a..c7b2a5dc89 100644 --- a/lib/CodeGen/CGCall.cpp +++ b/lib/CodeGen/CGCall.cpp @@ -935,8 +935,8 @@ static void CreateCoercedStore(llvm::Value *Src, /***/ -bool CodeGenModule::ReturnTypeUsesSret(QualType RetTy) { - return getABIReturnInfo(RetTy, getTypes()).isStructRet(); +bool CodeGenModule::ReturnTypeUsesSret(const CGFunctionInfo &FI) { + return getABIReturnInfo(FI.getReturnType(), getTypes()).isStructRet(); } const llvm::FunctionType * @@ -1008,8 +1008,8 @@ CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI, bool IsVariadic) { return llvm::FunctionType::get(ResultType, ArgTys, IsVariadic); } -void CodeGenModule::ConstructAttributeList(const Decl *TargetDecl, - const CGFunctionInfo &Info, +void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &Info, + const Decl *TargetDecl, AttributeListType &PAL) { unsigned FuncAttrs = 0; unsigned RetAttrs = 0; @@ -1107,16 +1107,14 @@ void CodeGenModule::ConstructAttributeList(const Decl *TargetDecl, } -void CodeGenFunction::EmitFunctionProlog(llvm::Function *Fn, - QualType RetTy, +void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI, + llvm::Function *Fn, const FunctionArgList &Args) { - CGFunctionInfo FnInfo(RetTy, Args); - // Emit allocs for param decls. Give the LLVM Argument nodes names. llvm::Function::arg_iterator AI = Fn->arg_begin(); // Name the struct return argument. - if (CGM.ReturnTypeUsesSret(RetTy)) { + if (CGM.ReturnTypeUsesSret(FI)) { AI->setName("agg.result"); ++AI; } @@ -1173,12 +1171,13 @@ void CodeGenFunction::EmitFunctionProlog(llvm::Function *Fn, assert(AI == Fn->arg_end() && "Argument mismatch!"); } -void CodeGenFunction::EmitFunctionEpilog(QualType RetTy, +void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI, llvm::Value *ReturnValue) { llvm::Value *RV = 0; // Functions with no result always return void. if (ReturnValue) { + QualType RetTy = FI.getReturnType(); ABIArgInfo RetAI = getABIReturnInfo(RetTy, CGM.getTypes()); switch (RetAI.getKind()) { @@ -1220,8 +1219,8 @@ void CodeGenFunction::EmitFunctionEpilog(QualType RetTy, } } -RValue CodeGenFunction::EmitCall(llvm::Value *Callee, - const CGFunctionInfo &CallInfo, +RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, + llvm::Value *Callee, const CallArgList &CallArgs) { llvm::SmallVector<llvm::Value*, 16> Args; @@ -1282,7 +1281,7 @@ RValue CodeGenFunction::EmitCall(llvm::Value *Callee, // FIXME: Provide TargetDecl so nounwind, noreturn, etc, etc get set. CodeGen::AttributeListType AttributeList; - CGM.ConstructAttributeList(0, CallInfo, AttributeList); + CGM.ConstructAttributeList(CallInfo, 0, AttributeList); CI->setAttributes(llvm::AttrListPtr::get(AttributeList.begin(), AttributeList.size())); diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 0e13a8ddcd..5ed215164b 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -1102,5 +1102,5 @@ RValue CodeGenFunction::EmitCallExpr(llvm::Value *Callee, QualType CalleeType, Args.push_back(std::make_pair(EmitAnyExprToTemp(*I), I->getType())); - return EmitCall(Callee, CGFunctionInfo(ResultType, Args), Args); + return EmitCall(CGFunctionInfo(ResultType, Args), Callee, Args); } diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp index 0c0b2510e9..cf37886e6d 100644 --- a/lib/CodeGen/CGObjC.cpp +++ b/lib/CodeGen/CGObjC.cpp @@ -183,8 +183,8 @@ void CodeGenFunction::GenerateObjCGetter(ObjCImplementationDecl *IMP, Args.push_back(std::make_pair(RValue::get(CmdVal), Cmd->getType())); Args.push_back(std::make_pair(RValue::get(Offset), getContext().LongTy)); Args.push_back(std::make_pair(RValue::get(True), getContext().BoolTy)); - RValue RV = EmitCall(GetPropertyFn, CGFunctionInfo(PD->getType(), Args), - Args); + RValue RV = EmitCall(CGFunctionInfo(PD->getType(), Args), + GetPropertyFn, Args); // We need to fix the type here. Ivars with copy & retain are // always objects so we don't need to worry about complex or // aggregates. @@ -268,7 +268,7 @@ void CodeGenFunction::GenerateObjCSetter(ObjCImplementationDecl *IMP, getContext().BoolTy)); Args.push_back(std::make_pair(RValue::get(IsCopy ? True : False), getContext().BoolTy)); - EmitCall(SetPropertyFn, CGFunctionInfo(PD->getType(), Args), Args); + EmitCall(CGFunctionInfo(PD->getType(), Args), SetPropertyFn, Args); } else { SourceLocation Loc = PD->getLocation(); ValueDecl *Self = OMD->getSelfDecl(); diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp index 6eca3f1271..e6ae6f36b4 100644 --- a/lib/CodeGen/CGObjCGNU.cpp +++ b/lib/CodeGen/CGObjCGNU.cpp @@ -311,7 +311,7 @@ CGObjCGNU::GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF, ActualArgs.push_back(std::make_pair(RValue::get(cmd), CGF.getContext().getObjCSelType())); ActualArgs.insert(ActualArgs.end(), CallArgs.begin(), CallArgs.end()); - return CGF.EmitCall(imp, CGFunctionInfo(ResultType, ActualArgs), ActualArgs); + return CGF.EmitCall(CGFunctionInfo(ResultType, ActualArgs), imp, ActualArgs); } /// Generate code for a message send expression. @@ -358,7 +358,7 @@ CGObjCGNU::GenerateMessageSend(CodeGen::CodeGenFunction &CGF, ActualArgs.push_back(std::make_pair(RValue::get(cmd), CGF.getContext().getObjCSelType())); ActualArgs.insert(ActualArgs.end(), CallArgs.begin(), CallArgs.end()); - return CGF.EmitCall(imp, CGFunctionInfo(ResultType, ActualArgs), ActualArgs); + return CGF.EmitCall(CGFunctionInfo(ResultType, ActualArgs), imp, ActualArgs); } /// Generates a MethodList. Used in construction of a objc_class and diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index 6bc03fe085..d8e873b845 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -810,7 +810,7 @@ CodeGen::RValue CGObjCMac::EmitMessageSend(CodeGen::CodeGenFunction &CGF, const llvm::FunctionType *FTy = CGM.getTypes().GetFunctionType(FnInfo, false); llvm::Constant *Fn; - if (CGM.ReturnTypeUsesSret(ResultType)) { + if (CGM.ReturnTypeUsesSret(FnInfo)) { Fn = ObjCTypes.getSendStretFn(IsSuper); } else if (ResultType->isFloatingType()) { // FIXME: Sadly, this is wrong. This actually depends on the @@ -820,7 +820,7 @@ CodeGen::RValue CGObjCMac::EmitMessageSend(CodeGen::CodeGenFunction &CGF, Fn = ObjCTypes.getSendFn(IsSuper); } Fn = llvm::ConstantExpr::getBitCast(Fn, llvm::PointerType::getUnqual(FTy)); - return CGF.EmitCall(Fn, FnInfo, ActualArgs); + return CGF.EmitCall(FnInfo, Fn, ActualArgs); } llvm::Value *CGObjCMac::GenerateProtocolRef(CGBuilderTy &Builder, diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index 5d34f65fc1..fe28b3aecc 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -125,7 +125,7 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) { DI->EmitRegionEnd(CurFn, Builder); } - EmitFunctionEpilog(FnRetTy, ReturnValue); + EmitFunctionEpilog(*CurFnInfo, ReturnValue); // Remove the AllocaInsertPt instruction, which is just a convenience for us. AllocaInsertPt->eraseFromParent(); @@ -171,7 +171,9 @@ void CodeGenFunction::StartFunction(const Decl *D, QualType RetTy, } } - EmitFunctionProlog(CurFn, FnRetTy, Args); + // FIXME: Leaked. + CurFnInfo = new CGFunctionInfo(FnRetTy, Args); + EmitFunctionProlog(*CurFnInfo, CurFn, Args); // If any of the arguments have a variably modified type, make sure to // emit the type size. diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index 1bacff2480..9033a65be2 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -70,6 +70,7 @@ public: // Holds the Decl for the current function or method const Decl *CurFuncDecl; + const CGFunctionInfo *CurFnInfo; QualType FnRetTy; llvm::Function *CurFn; @@ -219,13 +220,13 @@ public: /// EmitFunctionProlog - Emit the target specific LLVM code to load /// the arguments for the given function. This is also responsible /// for naming the LLVM function arguments. - void EmitFunctionProlog(llvm::Function *Fn, QualType RetTy, + void EmitFunctionProlog(const CGFunctionInfo &FI, + llvm::Function *Fn, const FunctionArgList &Args); /// EmitFunctionEpilog - Emit the target specific LLVM code to /// return the given temporary. - void EmitFunctionEpilog(QualType RetTy, - llvm::Value *ReturnValue); + void EmitFunctionEpilog(const CGFunctionInfo &FI, llvm::Value *ReturnValue); const llvm::Type *ConvertType(QualType T); @@ -543,8 +544,8 @@ public: /// given result type, and using the given argument list which /// specifies both the LLVM arguments and the types they were /// derived from. - RValue EmitCall(llvm::Value *Callee, - const CGFunctionInfo &FnInfo, + RValue EmitCall(const CGFunctionInfo &FnInfo, + llvm::Value *Callee, const CallArgList &Args); RValue EmitCallExpr(const CallExpr *E); diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index bdb99d6439..d02812ac5d 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -265,7 +265,7 @@ void CodeGenModule::SetFunctionAttributes(const Decl *D, const CGFunctionInfo &Info, llvm::Function *F) { AttributeListType AttributeList; - ConstructAttributeList(D, Info, AttributeList); + ConstructAttributeList(Info, D, AttributeList); F->setAttributes(llvm::AttrListPtr::get(AttributeList.begin(), AttributeList.size())); diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h index 724ca28b88..bedefcaa3f 100644 --- a/lib/CodeGen/CodeGenModule.h +++ b/lib/CodeGen/CodeGenModule.h @@ -244,10 +244,10 @@ public: /// ReturnTypeUsesSret - Return true iff the given type uses 'sret' /// when used as a return type. - bool ReturnTypeUsesSret(QualType RetTy); + bool ReturnTypeUsesSret(const CGFunctionInfo &FI); - void ConstructAttributeList(const Decl *TargetDecl, - const CGFunctionInfo &Info, + void ConstructAttributeList(const CGFunctionInfo &Info, + const Decl *TargetDecl, AttributeListType &PAL); private: |