blob: fbebdcfcf573a8723591c5fb584ddc55fa4cc2d1 [file] [log] [blame]
Reid Spencer5f016e22007-07-11 17:01:13 +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;
Chris Lattner88a69ad2007-07-13 05:13:43 +000030 class FileVarDecl;
Reid Spencer5f016e22007-07-11 17:01:13 +000031
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
Chris Lattner88a69ad2007-07-13 05:13:43 +000054 void EmitFunction(const FunctionDecl *FD);
55 void EmitGlobalVar(const FileVarDecl *D);
Chris Lattner32b266c2007-07-14 00:16:50 +000056 void EmitGlobalVarDeclarator(const FileVarDecl *D);
Reid Spencer5f016e22007-07-11 17:01:13 +000057
58 void PrintStats() {}
59};
60} // end namespace CodeGen
61} // end namespace clang
62
63#endif