blob: 8e40483bd57cd3574608d3849d76fa594faab8f4 [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 Lattner23b7eb62007-06-15 23:05:46 +000023}
24
Chris Lattnerf97fe382007-05-24 06:29:05 +000025namespace clang {
26 class ASTContext;
27 class FunctionDecl;
Chris Lattner2052bc82007-06-16 00:12:05 +000028 class Decl;
Chris Lattnerf97fe382007-05-24 06:29:05 +000029
30namespace CodeGen {
31
Chris Lattnerbed31442007-05-28 01:07:47 +000032/// CodeGenModule - This class organizes the cross-module state that is used
33/// while generating LLVM code.
34class CodeGenModule {
Chris Lattnerf97fe382007-05-24 06:29:05 +000035 ASTContext &Context;
Chris Lattner23b7eb62007-06-15 23:05:46 +000036 llvm::Module &TheModule;
Chris Lattner2ccb73b2007-06-16 00:16:26 +000037 CodeGenTypes Types;
38
Chris Lattnerb6984c42007-06-20 04:44:43 +000039 llvm::DenseMap<const Decl*, llvm::Constant*> GlobalDeclMap;
Chris Lattnerf97fe382007-05-24 06:29:05 +000040public:
Chris Lattner2ccb73b2007-06-16 00:16:26 +000041 CodeGenModule(ASTContext &C, llvm::Module &M);
Chris Lattnerf97fe382007-05-24 06:29:05 +000042
Chris Lattnerd1af2d22007-05-29 23:17:50 +000043 ASTContext &getContext() const { return Context; }
Chris Lattner23b7eb62007-06-15 23:05:46 +000044 llvm::Module &getModule() const { return TheModule; }
Chris Lattner2ccb73b2007-06-16 00:16:26 +000045 CodeGenTypes &getTypes() { return Types; }
Chris Lattnerd1af2d22007-05-29 23:17:50 +000046
Chris Lattnerb6984c42007-06-20 04:44:43 +000047 llvm::Constant *GetAddrOfGlobalDecl(const Decl *D);
48
Chris Lattnerbed31442007-05-28 01:07:47 +000049 void EmitFunction(FunctionDecl *FD);
Chris Lattnerf97fe382007-05-24 06:29:05 +000050
51 void PrintStats() {}
Chris Lattnerf97fe382007-05-24 06:29:05 +000052};
53} // end namespace CodeGen
54} // end namespace clang
Chris Lattnerf97fe382007-05-24 06:29:05 +000055
56#endif