blob: 885fb97a9f55ec6757f223288bac3bce460f36df [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 Lattnerf97fe382007-05-24 06:29:05 +000030
31namespace CodeGen {
32
Chris Lattnerbed31442007-05-28 01:07:47 +000033/// CodeGenModule - This class organizes the cross-module state that is used
34/// while generating LLVM code.
35class CodeGenModule {
Chris Lattnerf97fe382007-05-24 06:29:05 +000036 ASTContext &Context;
Chris Lattner23b7eb62007-06-15 23:05:46 +000037 llvm::Module &TheModule;
Chris Lattner2ccb73b2007-06-16 00:16:26 +000038 CodeGenTypes Types;
39
Chris Lattner09153c02007-06-22 18:48:09 +000040 llvm::Function *MemCpyFn;
Chris Lattnerb6984c42007-06-20 04:44:43 +000041 llvm::DenseMap<const Decl*, llvm::Constant*> GlobalDeclMap;
Chris Lattnerf97fe382007-05-24 06:29:05 +000042public:
Chris Lattner2ccb73b2007-06-16 00:16:26 +000043 CodeGenModule(ASTContext &C, llvm::Module &M);
Chris Lattnerf97fe382007-05-24 06:29:05 +000044
Chris Lattnerd1af2d22007-05-29 23:17:50 +000045 ASTContext &getContext() const { return Context; }
Chris Lattner23b7eb62007-06-15 23:05:46 +000046 llvm::Module &getModule() const { return TheModule; }
Chris Lattner2ccb73b2007-06-16 00:16:26 +000047 CodeGenTypes &getTypes() { return Types; }
Chris Lattnerd1af2d22007-05-29 23:17:50 +000048
Chris Lattnerb6984c42007-06-20 04:44:43 +000049 llvm::Constant *GetAddrOfGlobalDecl(const Decl *D);
50
Chris Lattner09153c02007-06-22 18:48:09 +000051 llvm::Function *getMemCpyFn();
52
Chris Lattnerbed31442007-05-28 01:07:47 +000053 void EmitFunction(FunctionDecl *FD);
Chris Lattnerf97fe382007-05-24 06:29:05 +000054
55 void PrintStats() {}
Chris Lattnerf97fe382007-05-24 06:29:05 +000056};
57} // end namespace CodeGen
58} // end namespace clang
Chris Lattnerf97fe382007-05-24 06:29:05 +000059
60#endif