[cfe-commits] r63553 - in /cfe/trunk/lib/CodeGen: CGCall.cpp CGExpr.cpp CGObjC.cpp CGObjCGNU.cpp CGObjCMac.cpp CodeGenFunction.cpp CodeGenFunction.h CodeGenModule.cpp CodeGenModule.h
Daniel Dunbar
daniel at zuster.org
Mon Feb 2 14:03:46 PST 2009
Author: ddunbar
Date: Mon Feb 2 16:03:45 2009
New Revision: 63553
URL: http://llvm.org/viewvc/llvm-project?rev=63553&view=rev
Log:
More ABI API cleanup.
- Lift CGFunctionInfo creation above ReturnTypeUsesSret and
EmitFunction{Epi,Pro}log.
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=63553&r1=63552&r2=63553&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Mon Feb 2 16:03:45 2009
@@ -935,8 +935,8 @@
/***/
-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 @@
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 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 @@
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 @@
}
}
-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 @@
// 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()));
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=63553&r1=63552&r2=63553&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Feb 2 16:03:45 2009
@@ -1102,5 +1102,5 @@
Args.push_back(std::make_pair(EmitAnyExprToTemp(*I),
I->getType()));
- return EmitCall(Callee, CGFunctionInfo(ResultType, Args), Args);
+ return EmitCall(CGFunctionInfo(ResultType, Args), Callee, Args);
}
Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=63553&r1=63552&r2=63553&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Mon Feb 2 16:03:45 2009
@@ -183,8 +183,8 @@
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 @@
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();
Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=63553&r1=63552&r2=63553&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Mon Feb 2 16:03:45 2009
@@ -311,7 +311,7 @@
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 @@
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
Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=63553&r1=63552&r2=63553&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Mon Feb 2 16:03:45 2009
@@ -810,7 +810,7 @@
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 @@
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,
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=63553&r1=63552&r2=63553&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Mon Feb 2 16:03:45 2009
@@ -125,7 +125,7 @@
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 @@
}
}
- 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.
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=63553&r1=63552&r2=63553&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Mon Feb 2 16:03:45 2009
@@ -70,6 +70,7 @@
// Holds the Decl for the current function or method
const Decl *CurFuncDecl;
+ const CGFunctionInfo *CurFnInfo;
QualType FnRetTy;
llvm::Function *CurFn;
@@ -219,13 +220,13 @@
/// 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 @@
/// 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);
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=63553&r1=63552&r2=63553&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Feb 2 16:03:45 2009
@@ -265,7 +265,7 @@
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()));
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=63553&r1=63552&r2=63553&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Mon Feb 2 16:03:45 2009
@@ -244,10 +244,10 @@
/// 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:
More information about the cfe-commits
mailing list