summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.h
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2008-07-29 23:18:29 +0000
committerDaniel Dunbar <daniel@zuster.org>2008-07-29 23:18:29 +0000
commit9c426524f8c1e0cd3fb1b05ceefb903629a4cda8 (patch)
treead75ea6eec15c8e9d0a6bee3b32c0c14ad7beea5 /clang/lib/CodeGen/CodeGenModule.h
parent6b1cc46fee3cb5f5c3140f68036346eef0079100 (diff)
downloadbcm5719-llvm-9c426524f8c1e0cd3fb1b05ceefb903629a4cda8.tar.gz
bcm5719-llvm-9c426524f8c1e0cd3fb1b05ceefb903629a4cda8.zip
Rework codegen emission of globals
- No (intended) functionality change. - Primary purpose is to clearly separate (lazy) construction of globals that are a forward declaration or tentative definition from those that are the final definition. - Lazy construction is now encapsulated in GetAddrOf{Function,GlobalVar} while final definitions are constructed in EmitGlobal{Function,Var}Definition. - External interface for dealing with globals is now limited to EmitGlobal and GetAddrOf{Function,GlobalVar}. - Also updated helper functions dealing with statics, annotations, and ctors to be private. llvm-svn: 54179
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.h')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.h51
1 files changed, 34 insertions, 17 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h
index 86094972427..57363cddee0 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -1,4 +1,4 @@
-//===--- CodeGenModule.h - Per-Module state for LLVM CodeGen --------------===//
+//===--- CodeGenModule.h - Per-Module state for LLVM CodeGen ----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -40,6 +40,7 @@ namespace clang {
class Expr;
class Stmt;
class NamedDecl;
+ class ValueDecl;
class VarDecl;
struct LangOptions;
class Diagnostic;
@@ -66,7 +67,13 @@ class CodeGenModule {
llvm::Function *MemMoveFn;
llvm::Function *MemSetFn;
llvm::DenseMap<const Decl*, llvm::Constant*> GlobalDeclMap;
- std::vector<const NamedDecl*> StaticDecls;
+
+ /// List of static global for which code generation is delayed. When
+ /// the translation unit has been fully processed we will lazily
+ /// emit definitions for only the decls that were actually used.
+ /// This should contain only Function and Var decls, and only those
+ /// which actually define something.
+ std::vector<const ValueDecl*> StaticDecls;
std::vector<llvm::Constant*> GlobalCtors;
std::vector<llvm::Constant*> Annotations;
@@ -90,11 +97,14 @@ public:
CodeGenTypes &getTypes() { return Types; }
Diagnostic &getDiags() const { return Diags; }
const llvm::TargetData &getTargetData() const { return TheTargetData; }
-
- llvm::Constant *GetAddrOfFunctionDecl(const FunctionDecl *D,
- bool isDefinition);
- llvm::Constant *GetAddrOfGlobalVar(const VarDecl *D, bool isDefinition);
-
+
+ /// GetAddrOfGlobalVar - Return the llvm::Constant for the address
+ /// of the given global variable.
+ llvm::Constant *GetAddrOfGlobalVar(const VarDecl *D);
+
+ /// GetAddrOfFunction - Return the llvm::Constant for the address
+ /// of the given function.
+ llvm::Constant *GetAddrOfFunction(const FunctionDecl *D);
/// getBuiltinLibFunction - Given a builtin id for a function like
/// "__builtin_fabsf", return a Function* for "fabsf".
@@ -111,21 +121,18 @@ public:
llvm::Function *getIntrinsic(unsigned IID, const llvm::Type **Tys = 0,
unsigned NumTys = 0);
- void AddGlobalCtor(llvm::Function * Ctor);
- void EmitGlobalCtors(void);
- void AddAnnotation(llvm::Constant *C) { Annotations.push_back(C); }
- void EmitAnnotations(void);
- void EmitStatics(void);
-
void EmitObjCMethod(const ObjCMethodDecl *OMD);
void EmitObjCCategoryImpl(const ObjCCategoryImplDecl *OCD);
void EmitObjCClassImplementation(const ObjCImplementationDecl *OID);
void EmitObjCProtocolImplementation(const ObjCProtocolDecl *PD);
- void EmitFunction(const FunctionDecl *FD);
- void EmitGlobalVar(const VarDecl *D);
- void EmitGlobalVarInit(const VarDecl *D);
+
+ /// EmitGlobal - Emit code for a singal global function or var
+ /// decl. Forward declarations are emitted lazily.
+ void EmitGlobal(const ValueDecl *D);
+
+ void AddAnnotation(llvm::Constant *C) { Annotations.push_back(C); }
+
void UpdateCompletedType(const TagDecl *D);
- llvm::Constant *EmitGlobalInit(const Expr *E);
llvm::Constant *EmitConstantExpr(const Expr *E, CodeGenFunction *CGF = 0);
llvm::Constant *EmitAnnotateAttr(llvm::GlobalValue *GV,
const AnnotateAttr *AA, unsigned LineNo);
@@ -157,6 +164,16 @@ private:
void SetGlobalValueAttributes(const FunctionDecl *FD,
llvm::GlobalValue *GV);
+ void EmitGlobalDefinition(const ValueDecl *D);
+ llvm::GlobalValue *EmitForwardFunctionDefinition(const FunctionDecl *D);
+ void EmitGlobalFunctionDefinition(const FunctionDecl *D);
+ void EmitGlobalVarDefinition(const VarDecl *D);
+
+ void AddGlobalCtor(llvm::Function * Ctor);
+ void EmitGlobalCtors(void);
+ void EmitAnnotations(void);
+ void EmitStatics(void);
+
};
} // end namespace CodeGen
} // end namespace clang
OpenPOWER on IntegriCloud