blob: fbebdcfcf573a8723591c5fb584ddc55fa4cc2d1 [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"
19
20namespace llvm {
21 class Module;
22 class Constant;
23 class Function;
24}
25
26namespace clang {
27 class ASTContext;
28 class FunctionDecl;
29 class Decl;
30 class FileVarDecl;
31
32namespace CodeGen {
33
34/// CodeGenModule - This class organizes the cross-module state that is used
35/// while generating LLVM code.
36class CodeGenModule {
37 ASTContext &Context;
38 llvm::Module &TheModule;
39 CodeGenTypes Types;
40
41 llvm::Function *MemCpyFn;
42 llvm::DenseMap<const Decl*, llvm::Constant*> GlobalDeclMap;
43public:
44 CodeGenModule(ASTContext &C, llvm::Module &M);
45
46 ASTContext &getContext() const { return Context; }
47 llvm::Module &getModule() const { return TheModule; }
48 CodeGenTypes &getTypes() { return Types; }
49
50 llvm::Constant *GetAddrOfGlobalDecl(const Decl *D);
51
52 llvm::Function *getMemCpyFn();
53
54 void EmitFunction(const FunctionDecl *FD);
55 void EmitGlobalVar(const FileVarDecl *D);
56 void EmitGlobalVarDeclarator(const FileVarDecl *D);
57
58 void PrintStats() {}
59};
60} // end namespace CodeGen
61} // end namespace clang
62
63#endif