]> granicus.if.org Git - clang/commitdiff
Tweak CGCall functions again:
authorDaniel Dunbar <daniel@zuster.org>
Wed, 10 Sep 2008 00:41:16 +0000 (00:41 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Wed, 10 Sep 2008 00:41:16 +0000 (00:41 +0000)
 - Realized these functions will eventually need access to more data,
   moved to CodeGenModule. Eventually they should probably live
   together in some other helper class.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56039 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGCall.cpp
lib/CodeGen/CGObjCMac.cpp
lib/CodeGen/CodeGenFunction.h
lib/CodeGen/CodeGenModule.cpp
lib/CodeGen/CodeGenModule.h

index 8f6bde412ba02fd856c671ac7d0d4bf62b9e50ff..168eaf37bdeb707de427ed19c6b16bd2b0e1dda8 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "CGCall.h"
 #include "CodeGenFunction.h"
+#include "CodeGenModule.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclObjC.h"
@@ -75,11 +76,11 @@ ArgTypeIterator CGCallInfo::argtypes_end() const {
 
 /***/
 
-bool CodeGenFunction::ReturnTypeUsesSret(QualType RetTy) {
-  return hasAggregateLLVMType(RetTy);
+bool CodeGenModule::ReturnTypeUsesSret(QualType RetTy) {
+  return CodeGenFunction::hasAggregateLLVMType(RetTy);
 }
 
-void CodeGenFunction::ConstructParamAttrList(const Decl *TargetDecl,
+void CodeGenModule::ConstructParamAttrList(const Decl *TargetDecl,
                                              ArgTypeIterator begin,
                                              ArgTypeIterator end,
                                              ParamAttrListType &PAL) {
@@ -94,7 +95,7 @@ void CodeGenFunction::ConstructParamAttrList(const Decl *TargetDecl,
 
   QualType ResTy = *begin;
   unsigned Index = 1;
-  if (CodeGenFunction::hasAggregateLLVMType(ResTy)) {
+  if (ReturnTypeUsesSret(ResTy)) {
     PAL.push_back(llvm::ParamAttrsWithIndex::get(Index, 
                                                  llvm::ParamAttr::StructRet));
     ++Index;
@@ -203,8 +204,9 @@ RValue CodeGenFunction::EmitCall(llvm::Value *Callee,
 
   // FIXME: Provide TargetDecl so nounwind, noreturn, etc, etc get set.
   CodeGen::ParamAttrListType ParamAttrList;
-  ConstructParamAttrList(0, CallInfo.argtypes_begin(), CallInfo.argtypes_end(),
-                         ParamAttrList);
+  CGM.ConstructParamAttrList(0, 
+                             CallInfo.argtypes_begin(), CallInfo.argtypes_end(),
+                             ParamAttrList);
   CI->setParamAttrs(llvm::PAListPtr::get(ParamAttrList.begin(), 
                                          ParamAttrList.size()));  
 
index ff7717dad33bffadb053c69ec143e1a8bf5ccc61..e3fcbdf11d6a65ba141335185a5c8bb77f768286 100644 (file)
@@ -531,7 +531,7 @@ CodeGen::RValue CGObjCMac::EmitMessageSend(CodeGen::CodeGenFunction &CGF,
 
   llvm::Value *Fn = 
     ObjCTypes.getMessageSendFn(IsSuper, 
-                               CGF.ReturnTypeUsesSret(ResultType),
+                               CGM.ReturnTypeUsesSret(ResultType),
                                CGM.getTypes().ConvertType(ResultType));
   return CGF.EmitCall(Fn, ResultType, ActualArgs);
 }
index ef7009c5aa5e007f76f9b97fad47e900c8e5306d..5054b56d212c09aa902858c03f25b3479a9950ef 100644 (file)
@@ -138,15 +138,6 @@ public:
                      const FunctionArgList &Args);
   void FinishFunction(SourceLocation EndLoc=SourceLocation());
 
-  /// ReturnTypeUsesSret - Return true iff the given type uses 'sret'
-  /// when used as a return type.
-  static bool ReturnTypeUsesSret(QualType RetTy);
-
-  static void ConstructParamAttrList(const Decl *TargetDecl,
-                                     const ArgTypeIterator begin,
-                                     const ArgTypeIterator end,
-                                     ParamAttrListType &PAL);
-
   /// 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.
index 9f7b97727612a83b159be18ebca39d2d44d75e41..e5acc505f5be390729bd0819f1d40e1843ca9785 100644 (file)
@@ -212,12 +212,12 @@ static void SetGlobalValueAttributes(const Decl *D,
   }
 }
 
-static void SetFunctionParamAttrs(const CGFunctionInfo &Info, llvm::Function *F) {
+void CodeGenModule::SetFunctionParamAttrs(const CGFunctionInfo &Info, 
+                                          llvm::Function *F) {
   ParamAttrListType ParamAttrList;
-  CodeGenFunction::ConstructParamAttrList(Info.getDecl(),
-                                          Info.argtypes_begin(), 
-                                          Info.argtypes_end(),
-                                          ParamAttrList);
+  ConstructParamAttrList(Info.getDecl(),
+                         Info.argtypes_begin(), Info.argtypes_end(),
+                         ParamAttrList);
 
   F->setParamAttrs(llvm::PAListPtr::get(ParamAttrList.begin(),
                                         ParamAttrList.size()));
index bcb464b66aedb07aeafd0e37ae1d708b08cde14f..4976e3474a699aa6967b611efd4f79e9b1b68752 100644 (file)
@@ -19,6 +19,8 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringMap.h"
 
+#include "CGCall.h"
+
 namespace llvm {
   class Module;
   class Constant;
@@ -215,6 +217,18 @@ public:
   void SetMethodAttributes(const ObjCMethodDecl *MD,
                            llvm::Function *F);
 
+  void SetFunctionParamAttrs(const CGFunctionInfo &Info, 
+                             llvm::Function *F);
+
+  /// ReturnTypeUsesSret - Return true iff the given type uses 'sret'
+  /// when used as a return type.
+  bool ReturnTypeUsesSret(QualType RetTy);
+
+  void ConstructParamAttrList(const Decl *TargetDecl,
+                              const ArgTypeIterator begin,
+                              const ArgTypeIterator end,
+                              ParamAttrListType &PAL);
+
 private:
   /// SetFunctionAttributesForDefinition - Set function attributes
   /// specific to a function definition.