blob: 97d6a02f47f51ec243acab566644ab0634a7d6ed [file] [log] [blame]
Chris Lattner4b009652007-07-25 00:24:17 +00001//===--- CodeGenModule.h - Per-Module state for LLVM CodeGen --------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by Chris Lattner and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This is the internal per-translation-unit state used for llvm translation.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef CODEGEN_CODEGENMODULE_H
15#define CODEGEN_CODEGENMODULE_H
16
17#include "CodeGenTypes.h"
18#include "llvm/ADT/DenseMap.h"
Anders Carlsson36a04872007-08-21 00:21:21 +000019#include "llvm/ADT/StringMap.h"
Chris Lattner4b009652007-07-25 00:24:17 +000020
21namespace llvm {
22 class Module;
23 class Constant;
24 class Function;
25}
26
27namespace clang {
28 class ASTContext;
29 class FunctionDecl;
30 class Decl;
31 class FileVarDecl;
32
33namespace CodeGen {
34
35/// CodeGenModule - This class organizes the cross-module state that is used
36/// while generating LLVM code.
37class CodeGenModule {
38 ASTContext &Context;
39 llvm::Module &TheModule;
40 CodeGenTypes Types;
41
42 llvm::Function *MemCpyFn;
43 llvm::DenseMap<const Decl*, llvm::Constant*> GlobalDeclMap;
Anders Carlsson36a04872007-08-21 00:21:21 +000044
45 llvm::StringMap<llvm::Constant*> CFConstantStringMap;
46 llvm::Constant *CFConstantStringClassRef;
Chris Lattner4b009652007-07-25 00:24:17 +000047public:
48 CodeGenModule(ASTContext &C, llvm::Module &M);
49
50 ASTContext &getContext() const { return Context; }
51 llvm::Module &getModule() const { return TheModule; }
52 CodeGenTypes &getTypes() { return Types; }
53
54 llvm::Constant *GetAddrOfGlobalDecl(const Decl *D);
Anders Carlsson36a04872007-08-21 00:21:21 +000055 llvm::Constant *GetAddrOfConstantCFString(const std::string& str);
Chris Lattner4b009652007-07-25 00:24:17 +000056 llvm::Function *getMemCpyFn();
57
58 void EmitFunction(const FunctionDecl *FD);
59 void EmitGlobalVar(const FileVarDecl *D);
60 void EmitGlobalVarDeclarator(const FileVarDecl *D);
61
62 void PrintStats() {}
63};
64} // end namespace CodeGen
65} // end namespace clang
66
67#endif