Move more of the blocks code up and out.

llvm-svn: 66046
This commit is contained in:
Mike Stump 2009-03-04 18:47:42 +00:00
parent d1b64be776
commit 6c39666a77
4 changed files with 16 additions and 10 deletions

View 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");

View 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;
}

View 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) {

View 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);