]> granicus.if.org Git - clang/commitdiff
Move more of the blocks code up and out.
authorMike Stump <mrs@apple.com>
Wed, 4 Mar 2009 18:47:42 +0000 (18:47 +0000)
committerMike Stump <mrs@apple.com>
Wed, 4 Mar 2009 18:47:42 +0000 (18:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66046 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGBlocks.cpp
lib/CodeGen/CGBlocks.h
lib/CodeGen/CodeGenModule.cpp
lib/CodeGen/CodeGenModule.h

index 8aabada259c37dda0d613af9134a32662b04690e..d877b171b9ebd63b95ea892ea5d01e719dc133a0 100644 (file)
@@ -501,7 +501,7 @@ llvm::Value *CodeGenFunction::GetAddrOfBlockDecl(const BlockDeclRefExpr *E) {
 }
 
 llvm::Constant *
-CodeGenModule::GetAddrOfGlobalBlock(const BlockExpr *BE, const char * n) {
+BlockModule::GetAddrOfGlobalBlock(const BlockExpr *BE, const char * n) {
   // Generate the block descriptor.
   const llvm::Type *UnsignedLongTy = Types.ConvertType(Context.UnsignedLongTy);
   const llvm::IntegerType *IntTy = cast<llvm::IntegerType>(
@@ -534,9 +534,9 @@ CodeGenModule::GetAddrOfGlobalBlock(const BlockExpr *BE, const char * n) {
   uint64_t subBlockSize, subBlockAlign;
   llvm::SmallVector<const Expr *, 8> subBlockDeclRefDecls;
   llvm::Function *Fn
-    = CodeGenFunction(*this).GenerateBlockFunction(BE, Info, subBlockSize,
-                                                   subBlockAlign,
-                                                   subBlockDeclRefDecls);
+    = CodeGenFunction(CGM).GenerateBlockFunction(BE, Info, subBlockSize,
+                                                 subBlockAlign,
+                                                 subBlockDeclRefDecls);
   assert(subBlockSize == BlockLiteralSize
          && "no imports allowed for global block");
 
index a55c578c0e117c1bc40380cae893e482aaaf747d..f58831423ef11552124369b7b4f140bf77e98227 100644 (file)
@@ -43,6 +43,7 @@ namespace llvm {
 namespace clang {
 
 namespace CodeGen {
+class CodeGenModule;
 
 class BlockBase {
 public:
@@ -59,11 +60,14 @@ public:
 class BlockModule : public BlockBase {
   ASTContext &Context;
   llvm::Module &TheModule;
+  const llvm::TargetData &TheTargetData;
   CodeGenTypes &Types;
+  CodeGenModule &CGM;
   
   ASTContext &getContext() const { return Context; }
   llvm::Module &getModule() const { return TheModule; }
   CodeGenTypes &getTypes() { return Types; }
+  const llvm::TargetData &getTargetData() const { return TheTargetData; }
 public:
   llvm::Constant *getNSConcreteGlobalBlock();
   llvm::Constant *getNSConcreteStackBlock();
@@ -73,6 +77,8 @@ public:
   const llvm::Type *getGenericBlockLiteralType();
   const llvm::Type *getGenericExtendedBlockLiteralType();
 
+  llvm::Constant *GetAddrOfGlobalBlock(const BlockExpr *BE, const char *);
+
   /// NSConcreteGlobalBlock - Cached reference to the class pointer for global
   /// blocks.
   llvm::Constant *NSConcreteGlobalBlock;
@@ -88,9 +94,11 @@ public:
     int GlobalUniqueCount;
   } Block;
 
-  BlockModule(ASTContext &C, llvm::Module &M, CodeGenTypes &T)
-    : Context(C), TheModule(M), Types(T), NSConcreteGlobalBlock(0),
-      NSConcreteStackBlock(0), BlockDescriptorType(0),
+  BlockModule(ASTContext &C, llvm::Module &M, const llvm::TargetData &TD,
+              CodeGenTypes &T, CodeGenModule &CodeGen)
+    : Context(C), TheModule(M), TheTargetData(TD), Types(T),
+      CGM(CodeGen),
+      NSConcreteGlobalBlock(0), NSConcreteStackBlock(0), BlockDescriptorType(0),
       GenericBlockLiteralType(0)  {
     Block.GlobalUniqueCount = 0;
   }
index c0dba74ad025a331f4e827e96df43450a1220bcb..422415c2e2432026dda7015ed70b5a5f463d966d 100644 (file)
@@ -34,7 +34,7 @@ using namespace CodeGen;
 CodeGenModule::CodeGenModule(ASTContext &C, const LangOptions &LO,
                              llvm::Module &M, const llvm::TargetData &TD,
                              Diagnostic &diags, bool GenerateDebugInfo)
-  : BlockModule(C, M, Types), Context(C), Features(LO), TheModule(M),
+  : BlockModule(C, M, TD, Types, *this), Context(C), Features(LO), TheModule(M),
     TheTargetData(TD), Diags(diags), Types(C, M, TD), Runtime(0),
     MemCpyFn(0), MemMoveFn(0), MemSetFn(0), CFConstantStringClassRef(0) {
 
index d20d22bc09f99b604c06be8c8111f6bcb03db661..a2b45a0b7495efa534d00a1e9718f7abc5dd08f5 100644 (file)
@@ -217,8 +217,6 @@ public:
   llvm::Constant *GetAddrOfConstantCString(const std::string &str,
                                            const char *GlobalName=0);
 
-  llvm::Constant *GetAddrOfGlobalBlock(const BlockExpr *BE, const char *);
-
   /// getBuiltinLibFunction - Given a builtin id for a function like
   /// "__builtin_fabsf", return a Function* for "fabsf".
   llvm::Value *getBuiltinLibFunction(unsigned BuiltinID);