diff options
author | Mike Stump <mrs@apple.com> | 2009-02-28 09:07:16 +0000 |
---|---|---|
committer | Mike Stump <mrs@apple.com> | 2009-02-28 09:07:16 +0000 |
commit | a99038c0757a836c6faeeddaa5dfd249b32f6e9e (patch) | |
tree | 86ec44cc788dc21f42c1edebf26e0311bad1602b /lib/CodeGen/CGExprScalar.cpp | |
parent | 709fa15defbc0208b33707b3da3a628df5a9b7b9 (diff) |
First cut CodeGen support for __block variables.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65688 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprScalar.cpp')
-rw-r--r-- | lib/CodeGen/CGExprScalar.cpp | 35 |
1 files changed, 3 insertions, 32 deletions
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index c65c0816e2..0b8cc535bf 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -224,7 +224,7 @@ public: Value *VisitStmtExpr(const StmtExpr *E); - Value *VisitBlockDeclRefExpr(BlockDeclRefExpr *E); + Value *VisitBlockDeclRefExpr(const BlockDeclRefExpr *E); // Unary Operators. Value *VisitPrePostIncDec(const UnaryOperator *E, bool isInc, bool isPre); @@ -601,37 +601,8 @@ Value *ScalarExprEmitter::VisitStmtExpr(const StmtExpr *E) { !E->getType()->isVoidType()).getScalarVal(); } -Value *ScalarExprEmitter::VisitBlockDeclRefExpr(BlockDeclRefExpr *E) { - if (E->isByRef()) { - // FIXME: Add codegen for __block variables. - return VisitExpr(E); - } - - // FIXME: ensure we don't need copy/dispose. - uint64_t &offset = CGF.BlockDecls[E->getDecl()]; - - const llvm::Type *Ty; - Ty = CGF.CGM.getTypes().ConvertType(E->getDecl()->getType()); - - // See if we have already allocated an offset for this variable. - if (offset == 0) { - // if not, allocate one now. - offset = CGF.getBlockOffset(E->getDecl()); - } - - llvm::Value *BlockLiteral = CGF.LoadBlockStruct(); - llvm::Value *V = Builder.CreateGEP(BlockLiteral, - llvm::ConstantInt::get(llvm::Type::Int64Ty, - offset), - "tmp"); - Ty = llvm::PointerType::get(Ty, 0); - if (E->isByRef()) - Ty = llvm::PointerType::get(Ty, 0); - V = Builder.CreateBitCast(V, Ty); - V = Builder.CreateLoad(V, false, "tmp"); - if (E->isByRef()) - V = Builder.CreateLoad(V, false, "tmp"); - return V; +Value *ScalarExprEmitter::VisitBlockDeclRefExpr(const BlockDeclRefExpr *E) { + return Builder.CreateLoad(CGF.GetAddrOfBlockDecl(E), false, "tmp"); } //===----------------------------------------------------------------------===// |