blob: fbebdcfcf573a8723591c5fb584ddc55fa4cc2d1 [file] [log] [blame]
Chris Lattnerbed31442007-05-28 01:07:47 +00001//===--- CodeGenModule.h - Per-Module state for LLVM CodeGen --------------===//
Chris Lattnerf97fe382007-05-24 06:29:05 +00002//
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
Chris Lattnerbed31442007-05-28 01:07:47 +000014#ifndef CODEGEN_CODEGENMODULE_H
15#define CODEGEN_CODEGENMODULE_H
Chris Lattnerf97fe382007-05-24 06:29:05 +000016
Chris Lattner2ccb73b2007-06-16 00:16:26 +000017#include "CodeGenTypes.h"
Chris Lattnerb6984c42007-06-20 04:44:43 +000018#include "llvm/ADT/DenseMap.h"
Chris Lattner2ccb73b2007-06-16 00:16:26 +000019
Chris Lattnerf97fe382007-05-24 06:29:05 +000020namespace llvm {
21 class Module;
Chris Lattner2052bc82007-06-16 00:12:05 +000022 class Constant;
Chris Lattner09153c02007-06-22 18:48:09 +000023 class Function;
Chris Lattner23b7eb62007-06-15 23:05:46 +000024}
25
Chris Lattnerf97fe382007-05-24 06:29:05 +000026namespace clang {
27 class ASTContext;
28 class FunctionDecl;
Chris Lattner2052bc82007-06-16 00:12:05 +000029 class Decl;
Chris Lattnerd14bfa92007-07-13 05:13:43 +000030 class FileVarDecl;
Chris Lattnerf97fe382007-05-24 06:29:05 +000031
32namespace CodeGen {
33
Chris Lattnerbed31442007-05-28 01:07:47 +000034/// CodeGenModule - This class organizes the cross-module state that is used
35/// while generating LLVM code.
36class CodeGenModule {
Chris Lattnerf97fe382007-05-24 06:29:05 +000037 ASTContext &Context;
Chris Lattner23b7eb62007-06-15 23:05:46 +000038 llvm::Module &TheModule;
Chris Lattner2ccb73b2007-06-16 00:16:26 +000039 CodeGenTypes Types;
40
Chris Lattner09153c02007-06-22 18:48:09 +000041 llvm::Function *MemCpyFn;
Chris Lattnerb6984c42007-06-20 04:44:43 +000042 llvm::DenseMap<const Decl*, llvm::Constant*> GlobalDeclMap;
Chris Lattnerf97fe382007-05-24 06:29:05 +000043public:
Chris Lattner2ccb73b2007-06-16 00:16:26 +000044 CodeGenModule(ASTContext &C, llvm::Module &M);
Chris Lattnerf97fe382007-05-24 06:29:05 +000045
Chris Lattnerd1af2d22007-05-29 23:17:50 +000046 ASTContext &getContext() const { return Context; }
Chris Lattner23b7eb62007-06-15 23:05:46 +000047 llvm::Module &getModule() const { return TheModule; }
Chris Lattner2ccb73b2007-06-16 00:16:26 +000048 CodeGenTypes &getTypes() { return Types; }
Chris Lattnerd1af2d22007-05-29 23:17:50 +000049
Chris Lattnerb6984c42007-06-20 04:44:43 +000050 llvm::Constant *GetAddrOfGlobalDecl(const Decl *D);
51
Chris Lattner09153c02007-06-22 18:48:09 +000052 llvm::Function *getMemCpyFn();
53
Chris Lattnerd14bfa92007-07-13 05:13:43 +000054 void EmitFunction(const FunctionDecl *FD);
55 void EmitGlobalVar(const FileVarDecl *D);
Chris Lattner6ee31f52007-07-14 00:16:50 +000056 void EmitGlobalVarDeclarator(const FileVarDecl *D);
Chris Lattnerf97fe382007-05-24 06:29:05 +000057
58 void PrintStats() {}
Chris Lattnerf97fe382007-05-24 06:29:05 +000059};
60} // end namespace CodeGen
61} // end namespace clang
Chris Lattnerf97fe382007-05-24 06:29:05 +000062
63#endif