diff options
author | Mike Stump <mrs@apple.com> | 2009-02-21 20:00:35 +0000 |
---|---|---|
committer | Mike Stump <mrs@apple.com> | 2009-02-21 20:00:35 +0000 |
commit | 4e7a1f7682d94811bd41fca8aefccc38f686db23 (patch) | |
tree | 781baa224e97254f4e097ab80c0175aca139a7a2 /lib/CodeGen/CodeGenFunction.h | |
parent | 8dfb0c57ddb700b163afa89e3ab160f1de26753d (diff) |
Add CodeGen support for the helper for BlockDeclRefExprs. The easier
stuff is mostly done. Move BlockHasCopyDispose up.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65242 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.h')
-rw-r--r-- | lib/CodeGen/CodeGenFunction.h | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index 7072be8f60..2de696d664 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -88,9 +88,6 @@ public: const llvm::Type *LLVMIntTy; uint32_t LLVMPointerWidth; - llvm::Constant *BuildBlockLiteralTmp(const BlockExpr *); - llvm::Constant *BuildDescriptorBlockDecl(); - public: /// ObjCEHValueStack - Stack of Objective-C exception values, used for /// rethrows. @@ -250,6 +247,13 @@ public: void GenerateObjCSetter(ObjCImplementationDecl *IMP, const ObjCPropertyImplDecl *PID); + //===--------------------------------------------------------------------===// + // Block Bits + //===--------------------------------------------------------------------===// + + llvm::Constant *BuildBlockLiteralTmp(const BlockExpr *); + llvm::Constant *BuildDescriptorBlockDecl(uint64_t Size); + /// BlockInfo - Information to generate a block literal. struct BlockInfo { /// BlockLiteralTy - The type of the block literal. @@ -263,7 +267,35 @@ public: }; llvm::Function *GenerateBlockFunction(const BlockExpr *Expr, - const BlockInfo& Info); + const BlockInfo& Info, + uint64_t &Size); + + ImplicitParamDecl *BlockStructDecl; + + ImplicitParamDecl *getBlockStructDecl() { return BlockStructDecl; } + + llvm::Value *LoadBlockStruct(); + + /// BlockHasCopyDispose - True iff the block uses copy/dispose. + bool BlockHasCopyDispose; + + uint64_t BlockOffset; + /// getBlockOffset - Offset for next allocated variable use in a BlockExpr. + uint64_t getBlockOffset(uint64_t Size, uint64_t Align) { + assert (((Align >> 3) > 0) && "alignment must be 1 byte or more"); + assert (((Align & 7) == 0) + && "alignment must be on at least byte boundaries"); + // Ensure proper alignment, even if it means we have to have a gap + if (BlockOffset % (Align >> 3)) { + BlockOffset += (Align >> 3) - (BlockOffset % (Align >> 3)); + assert ((BlockOffset % (Align >> 3)) == 0 + && "alignment calculation is wrong"); + } + + BlockOffset += Size; + return BlockOffset-Size; + } + std::map<Decl*, uint64_t> BlockDecls; void GenerateCode(const FunctionDecl *FD, llvm::Function *Fn); |