[cfe-commits] r64452 - in /cfe/trunk/lib/CodeGen: CGBlocks.cpp CodeGenModule.cpp CodeGenModule.h
Mike Stump
mrs at apple.com
Fri Feb 13 07:25:37 PST 2009
Author: mrs
Date: Fri Feb 13 09:25:34 2009
New Revision: 64452
URL: http://llvm.org/viewvc/llvm-project?rev=64452&view=rev
Log:
Move GenericBlockLiteralType into CGM.
Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=64452&r1=64451&r2=64452&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Fri Feb 13 09:25:34 2009
@@ -47,34 +47,35 @@
return BlockDescriptorType;
}
-static const llvm::Type *getGenericBlockLiteralType(CodeGenModule &CGM) {
- static const llvm::Type *Ty = 0;
-
- if (!Ty) {
- const llvm::Type *Int8PtrTy =
- llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
+const llvm::Type *
+CodeGenModule::getGenericBlockLiteralType() {
+ if (GenericBlockLiteralType)
+ return GenericBlockLiteralType;
+
+ const llvm::Type *Int8PtrTy =
+ llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
- const llvm::Type *BlockDescPtrTy =
- llvm::PointerType::getUnqual(CGM.getBlockDescriptorType());
+ const llvm::Type *BlockDescPtrTy =
+ llvm::PointerType::getUnqual(getBlockDescriptorType());
- // struct __block_literal_generic {
- // void *isa;
- // int flags;
- // int reserved;
- // void (*invoke)(void *);
- // struct __block_descriptor *descriptor;
- // };
- Ty = llvm::StructType::get(Int8PtrTy,
- llvm::Type::Int32Ty,
- llvm::Type::Int32Ty,
- Int8PtrTy,
- BlockDescPtrTy,
- NULL);
+ // struct __block_literal_generic {
+ // void *isa;
+ // int flags;
+ // int reserved;
+ // void (*invoke)(void *);
+ // struct __block_descriptor *descriptor;
+ // };
+ GenericBlockLiteralType = llvm::StructType::get(Int8PtrTy,
+ llvm::Type::Int32Ty,
+ llvm::Type::Int32Ty,
+ Int8PtrTy,
+ BlockDescPtrTy,
+ NULL);
- CGM.getModule().addTypeName("struct.__block_literal_generic", Ty);
- }
+ getModule().addTypeName("struct.__block_literal_generic",
+ GenericBlockLiteralType);
- return Ty;
+ return GenericBlockLiteralType;
}
/// getBlockFunctionType - Given a BlockPointerType, will return the
@@ -103,7 +104,7 @@
// Get a pointer to the generic block literal.
const llvm::Type *BlockLiteralTy =
- llvm::PointerType::getUnqual(getGenericBlockLiteralType(CGM));
+ llvm::PointerType::getUnqual(CGM.getGenericBlockLiteralType());
// Bitcast the callee to a block literal.
llvm::Value *BlockLiteral =
@@ -164,7 +165,7 @@
// Block literal size. For global blocks we just use the size of the generic
// block literal struct.
uint64_t BlockLiteralSize =
- TheTargetData.getTypeStoreSizeInBits(getGenericBlockLiteralType(*this)) / 8;
+ TheTargetData.getTypeStoreSizeInBits(getGenericBlockLiteralType()) / 8;
DescriptorFields[1] = llvm::ConstantInt::get(UnsignedLongTy,BlockLiteralSize);
llvm::Constant *DescriptorStruct =
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=64452&r1=64451&r2=64452&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Feb 13 09:25:34 2009
@@ -37,7 +37,7 @@
: Context(C), Features(LO), TheModule(M), TheTargetData(TD), Diags(diags),
Types(C, M, TD), Runtime(0), MemCpyFn(0), MemMoveFn(0), MemSetFn(0),
CFConstantStringClassRef(0), NSConcreteGlobalBlock(0),
- BlockDescriptorType(0) {
+ BlockDescriptorType(0), GenericBlockLiteralType(0) {
if (Features.ObjC1) {
if (Features.NeXTRuntime) {
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=64452&r1=64451&r2=64452&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Fri Feb 13 09:25:34 2009
@@ -128,6 +128,7 @@
llvm::Constant *NSConcreteGlobalBlock;
const llvm::Type *BlockDescriptorType;
+ const llvm::Type * GenericBlockLiteralType;
std::vector<llvm::Function *> BuiltinFunctions;
public:
@@ -142,6 +143,8 @@
const llvm::Type *getBlockDescriptorType();
+ const llvm::Type *getGenericBlockLiteralType();
+
/// getObjCRuntime() - Return a reference to the configured
/// Objective-C runtime.
CGObjCRuntime &getObjCRuntime() {
More information about the cfe-commits
mailing list