[cfe-commits] r108481 - in /cfe/trunk/lib/CodeGen: CGBlocks.cpp CGBlocks.h CodeGenModule.cpp CodeGenModule.h
Daniel Dunbar
daniel at zuster.org
Thu Jul 15 17:00:15 PDT 2010
Author: ddunbar
Date: Thu Jul 15 19:00:15 2010
New Revision: 108481
URL: http://llvm.org/viewvc/llvm-project?rev=108481&view=rev
Log:
IRgen: Move blocks runtime interfaces to CodeGenModule.
Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGBlocks.h
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=108481&r1=108480&r2=108481&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Thu Jul 15 19:00:15 2010
@@ -111,20 +111,6 @@
return C;
}
-llvm::Constant *BlockModule::getNSConcreteGlobalBlock() {
- if (NSConcreteGlobalBlock == 0)
- NSConcreteGlobalBlock = CGM.CreateRuntimeVariable(PtrToInt8Ty,
- "_NSConcreteGlobalBlock");
- return NSConcreteGlobalBlock;
-}
-
-llvm::Constant *BlockModule::getNSConcreteStackBlock() {
- if (NSConcreteStackBlock == 0)
- NSConcreteStackBlock = CGM.CreateRuntimeVariable(PtrToInt8Ty,
- "_NSConcreteStackBlock");
- return NSConcreteStackBlock;
-}
-
static void CollectBlockDeclRefInfo(const Stmt *S, CGBlockInfo &Info) {
for (Stmt::const_child_iterator I = S->child_begin(), E = S->child_end();
I != E; ++I)
@@ -700,7 +686,7 @@
&& "no imports allowed for global block");
// isa
- LiteralFields[0] = getNSConcreteGlobalBlock();
+ LiteralFields[0] = CGM.getNSConcreteGlobalBlock();
// Flags
LiteralFields[1] =
@@ -1012,7 +998,7 @@
Dstv = Builder.CreateBitCast(Dstv, PtrToInt8Ty);
llvm::Value *N = llvm::ConstantInt::get(CGF.Int32Ty, flag);
- llvm::Value *F = getBlockObjectAssign();
+ llvm::Value *F = CGM.getBlockObjectAssign();
Builder.CreateCall3(F, Dstv, Srcv, N);
}
}
@@ -1164,7 +1150,7 @@
flag |= BLOCK_BYREF_CALLER;
llvm::Value *N = llvm::ConstantInt::get(CGF.Int32Ty, flag);
- llvm::Value *F = getBlockObjectAssign();
+ llvm::Value *F = CGM.getBlockObjectAssign();
Builder.CreateCall3(F, DstObj, SrcObj, N);
CGF.FinishFunction();
@@ -1259,37 +1245,8 @@
return Entry=CodeGenFunction(CGM).GeneratebyrefDestroyHelperFunction(T, Flag);
}
-llvm::Value *BlockFunction::getBlockObjectDispose() {
- if (CGM.BlockObjectDispose == 0) {
- const llvm::FunctionType *FTy;
- std::vector<const llvm::Type*> ArgTys;
- const llvm::Type *ResultType = llvm::Type::getVoidTy(VMContext);
- ArgTys.push_back(PtrToInt8Ty);
- ArgTys.push_back(CGF.Int32Ty);
- FTy = llvm::FunctionType::get(ResultType, ArgTys, false);
- CGM.BlockObjectDispose
- = CGM.CreateRuntimeFunction(FTy, "_Block_object_dispose");
- }
- return CGM.BlockObjectDispose;
-}
-
-llvm::Value *BlockFunction::getBlockObjectAssign() {
- if (CGM.BlockObjectAssign == 0) {
- const llvm::FunctionType *FTy;
- std::vector<const llvm::Type*> ArgTys;
- const llvm::Type *ResultType = llvm::Type::getVoidTy(VMContext);
- ArgTys.push_back(PtrToInt8Ty);
- ArgTys.push_back(PtrToInt8Ty);
- ArgTys.push_back(CGF.Int32Ty);
- FTy = llvm::FunctionType::get(ResultType, ArgTys, false);
- CGM.BlockObjectAssign
- = CGM.CreateRuntimeFunction(FTy, "_Block_object_assign");
- }
- return CGM.BlockObjectAssign;
-}
-
void BlockFunction::BuildBlockRelease(llvm::Value *V, int flag) {
- llvm::Value *F = getBlockObjectDispose();
+ llvm::Value *F = CGM.getBlockObjectDispose();
llvm::Value *N;
V = Builder.CreateBitCast(V, PtrToInt8Ty);
N = llvm::ConstantInt::get(CGF.Int32Ty, flag);
Modified: cfe/trunk/lib/CodeGen/CGBlocks.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.h?rev=108481&r1=108480&r2=108481&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBlocks.h (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.h Thu Jul 15 19:00:15 2010
@@ -73,8 +73,6 @@
CodeGenTypes &getTypes() { return Types; }
const llvm::TargetData &getTargetData() const { return TheTargetData; }
public:
- llvm::Constant *getNSConcreteGlobalBlock();
- llvm::Constant *getNSConcreteStackBlock();
int getGlobalUniqueCount() { return ++Block.GlobalUniqueCount; }
const llvm::Type *getBlockDescriptorType();
@@ -82,14 +80,6 @@
llvm::Constant *GetAddrOfGlobalBlock(const BlockExpr *BE, const char *);
- /// NSConcreteGlobalBlock - Cached reference to the class pointer for global
- /// blocks.
- llvm::Constant *NSConcreteGlobalBlock;
-
- /// NSConcreteStackBlock - Cached reference to the class poinnter for stack
- /// blocks.
- llvm::Constant *NSConcreteStackBlock;
-
const llvm::Type *BlockDescriptorType;
const llvm::Type *GenericBlockLiteralType;
@@ -97,8 +87,6 @@
int GlobalUniqueCount;
} Block;
- llvm::Value *BlockObjectAssign;
- llvm::Value *BlockObjectDispose;
const llvm::PointerType *PtrToInt8Ty;
std::map<uint64_t, llvm::Constant *> AssignCache;
@@ -108,9 +96,7 @@
CodeGenTypes &T, CodeGenModule &CodeGen)
: Context(C), TheModule(M), TheTargetData(TD), Types(T),
CGM(CodeGen), VMContext(M.getContext()),
- NSConcreteGlobalBlock(0), NSConcreteStackBlock(0), BlockDescriptorType(0),
- GenericBlockLiteralType(0),
- BlockObjectAssign(0), BlockObjectDispose(0) {
+ BlockDescriptorType(0), GenericBlockLiteralType(0) {
Block.GlobalUniqueCount = 0;
PtrToInt8Ty = llvm::Type::getInt8PtrTy(M.getContext());
}
@@ -207,8 +193,6 @@
llvm::Constant *BuildbyrefDestroyHelper(const llvm::Type *T, int flag,
unsigned Align);
- llvm::Value *getBlockObjectAssign();
- llvm::Value *getBlockObjectDispose();
void BuildBlockRelease(llvm::Value *DeclPtr, int flag = BLOCK_FIELD_IS_BYREF);
bool BlockRequiresCopying(QualType Ty)
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=108481&r1=108480&r2=108481&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Jul 15 19:00:15 2010
@@ -50,9 +50,10 @@
TheTargetData(TD), TheTargetCodeGenInfo(0), Diags(diags),
Types(C, M, TD, getTargetCodeGenInfo().getABIInfo()),
VTables(*this), Runtime(0), ABI(0),
- CFConstantStringClassRef(0),
- NSConstantStringClassRef(0),
- VMContext(M.getContext()) {
+ CFConstantStringClassRef(0), NSConstantStringClassRef(0),
+ VMContext(M.getContext()),
+ NSConcreteGlobalBlock(0), NSConcreteStackBlock(0),
+ BlockObjectAssign(0), BlockObjectDispose(0){
if (!Features.ObjC1)
Runtime = 0;
@@ -2132,3 +2133,54 @@
}
}
}
+
+///@name Custom Runtime Function Interfaces
+///@{
+//
+// FIXME: These can be eliminated once we can have clients just get the required
+// AST nodes from the builtin tables.
+
+llvm::Constant *CodeGenModule::getBlockObjectDispose() {
+ if (BlockObjectDispose)
+ return BlockObjectDispose;
+
+ const llvm::FunctionType *FTy;
+ std::vector<const llvm::Type*> ArgTys;
+ const llvm::Type *ResultType = llvm::Type::getVoidTy(VMContext);
+ ArgTys.push_back(PtrToInt8Ty);
+ ArgTys.push_back(llvm::Type::getInt32Ty(VMContext));
+ FTy = llvm::FunctionType::get(ResultType, ArgTys, false);
+ return BlockObjectDispose =
+ CreateRuntimeFunction(FTy, "_Block_object_dispose");
+}
+
+llvm::Constant *CodeGenModule::getBlockObjectAssign() {
+ if (BlockObjectAssign)
+ return BlockObjectAssign;
+
+ const llvm::FunctionType *FTy;
+ std::vector<const llvm::Type*> ArgTys;
+ const llvm::Type *ResultType = llvm::Type::getVoidTy(VMContext);
+ ArgTys.push_back(PtrToInt8Ty);
+ ArgTys.push_back(PtrToInt8Ty);
+ ArgTys.push_back(llvm::Type::getInt32Ty(VMContext));
+ FTy = llvm::FunctionType::get(ResultType, ArgTys, false);
+ return BlockObjectAssign =
+ CreateRuntimeFunction(FTy, "_Block_object_assign");
+}
+
+llvm::Constant *CodeGenModule::getNSConcreteGlobalBlock() {
+ if (NSConcreteGlobalBlock)
+ return NSConcreteGlobalBlock;
+ return NSConcreteGlobalBlock = CreateRuntimeVariable(
+ PtrToInt8Ty, "_NSConcreteGlobalBlock");
+}
+
+llvm::Constant *CodeGenModule::getNSConcreteStackBlock() {
+ if (NSConcreteStackBlock)
+ return NSConcreteStackBlock;
+ return NSConcreteStackBlock = CreateRuntimeVariable(
+ PtrToInt8Ty, "_NSConcreteStackBlock");
+}
+
+///@}
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=108481&r1=108480&r2=108481&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Thu Jul 15 19:00:15 2010
@@ -193,6 +193,16 @@
void createCXXABI();
llvm::LLVMContext &VMContext;
+
+ /// @name Cache for Blocks Runtime Globals
+ /// @{
+
+ llvm::Constant *NSConcreteGlobalBlock;
+ llvm::Constant *NSConcreteStackBlock;
+ llvm::Constant *BlockObjectAssign;
+ llvm::Constant *BlockObjectDispose;
+
+ /// @}
public:
CodeGenModule(ASTContext &C, const CodeGenOptions &CodeGenOpts,
llvm::Module &M, const llvm::TargetData &TD, Diagnostic &Diags);
@@ -398,6 +408,16 @@
llvm::Constant *CreateRuntimeVariable(const llvm::Type *Ty,
llvm::StringRef Name);
+ ///@name Custom Blocks Runtime Interfaces
+ ///@{
+
+ llvm::Constant *getNSConcreteGlobalBlock();
+ llvm::Constant *getNSConcreteStackBlock();
+ llvm::Constant *getBlockObjectAssign();
+ llvm::Constant *getBlockObjectDispose();
+
+ ///@}
+
void UpdateCompletedType(const TagDecl *TD) {
// Make sure that this type is translated.
Types.UpdateCompletedType(TD);
More information about the cfe-commits
mailing list