2007-05-28 01:07:47 +00:00
|
|
|
//===--- CodeGenModule.h - Per-Module state for LLVM CodeGen --------------===//
|
2007-05-24 06:29:05 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by Chris Lattner and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This is the internal per-translation-unit state used for llvm translation.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2007-05-28 01:07:47 +00:00
|
|
|
#ifndef CODEGEN_CODEGENMODULE_H
|
|
|
|
#define CODEGEN_CODEGENMODULE_H
|
2007-05-24 06:29:05 +00:00
|
|
|
|
2007-06-16 00:16:26 +00:00
|
|
|
#include "CodeGenTypes.h"
|
2007-06-20 04:44:43 +00:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
2007-08-21 00:21:21 +00:00
|
|
|
#include "llvm/ADT/StringMap.h"
|
2007-06-16 00:16:26 +00:00
|
|
|
|
2007-05-24 06:29:05 +00:00
|
|
|
namespace llvm {
|
|
|
|
class Module;
|
2007-06-16 00:12:05 +00:00
|
|
|
class Constant;
|
2007-06-22 18:48:09 +00:00
|
|
|
class Function;
|
2007-10-30 21:27:20 +00:00
|
|
|
class GlobalVariable;
|
2007-10-31 20:01:01 +00:00
|
|
|
class TargetData;
|
2007-06-15 23:05:46 +00:00
|
|
|
}
|
|
|
|
|
2007-05-24 06:29:05 +00:00
|
|
|
namespace clang {
|
|
|
|
class ASTContext;
|
|
|
|
class FunctionDecl;
|
2007-06-16 00:12:05 +00:00
|
|
|
class Decl;
|
2007-12-02 00:11:25 +00:00
|
|
|
class Expr;
|
2007-09-13 21:41:19 +00:00
|
|
|
class ValueDecl;
|
2007-07-13 05:13:43 +00:00
|
|
|
class FileVarDecl;
|
2007-11-28 05:34:05 +00:00
|
|
|
struct LangOptions;
|
2007-12-02 01:40:18 +00:00
|
|
|
class Diagnostic;
|
2007-05-24 06:29:05 +00:00
|
|
|
|
|
|
|
namespace CodeGen {
|
|
|
|
|
2007-05-28 01:07:47 +00:00
|
|
|
/// CodeGenModule - This class organizes the cross-module state that is used
|
|
|
|
/// while generating LLVM code.
|
|
|
|
class CodeGenModule {
|
2007-05-24 06:29:05 +00:00
|
|
|
ASTContext &Context;
|
2007-11-28 05:34:05 +00:00
|
|
|
const LangOptions &Features;
|
2007-06-15 23:05:46 +00:00
|
|
|
llvm::Module &TheModule;
|
2007-10-31 20:01:01 +00:00
|
|
|
const llvm::TargetData &TheTargetData;
|
2007-12-02 01:40:18 +00:00
|
|
|
Diagnostic &Diags;
|
2007-06-16 00:16:26 +00:00
|
|
|
CodeGenTypes Types;
|
|
|
|
|
2007-06-22 18:48:09 +00:00
|
|
|
llvm::Function *MemCpyFn;
|
2007-06-20 04:44:43 +00:00
|
|
|
llvm::DenseMap<const Decl*, llvm::Constant*> GlobalDeclMap;
|
2007-11-28 05:34:05 +00:00
|
|
|
|
2007-08-21 00:21:21 +00:00
|
|
|
llvm::StringMap<llvm::Constant*> CFConstantStringMap;
|
2007-11-28 05:34:05 +00:00
|
|
|
llvm::StringMap<llvm::Constant*> ConstantStringMap;
|
2007-08-21 00:21:21 +00:00
|
|
|
llvm::Constant *CFConstantStringClassRef;
|
2007-08-31 04:31:45 +00:00
|
|
|
|
|
|
|
std::vector<llvm::Function *> BuiltinFunctions;
|
2007-05-24 06:29:05 +00:00
|
|
|
public:
|
2007-11-28 05:34:05 +00:00
|
|
|
CodeGenModule(ASTContext &C, const LangOptions &Features, llvm::Module &M,
|
2007-12-02 01:40:18 +00:00
|
|
|
const llvm::TargetData &TD, Diagnostic &Diags);
|
2007-05-24 06:29:05 +00:00
|
|
|
|
2007-05-29 23:17:50 +00:00
|
|
|
ASTContext &getContext() const { return Context; }
|
2007-11-28 05:34:05 +00:00
|
|
|
const LangOptions &getLangOptions() const { return Features; }
|
2007-06-15 23:05:46 +00:00
|
|
|
llvm::Module &getModule() const { return TheModule; }
|
2007-06-16 00:16:26 +00:00
|
|
|
CodeGenTypes &getTypes() { return Types; }
|
2007-12-02 01:40:18 +00:00
|
|
|
Diagnostic &getDiags() const { return Diags; }
|
2007-05-29 23:17:50 +00:00
|
|
|
|
2007-12-02 07:09:19 +00:00
|
|
|
llvm::Constant *GetAddrOfFunctionDecl(const FunctionDecl *D,
|
|
|
|
bool isDefinition);
|
|
|
|
llvm::Constant *GetAddrOfFileVarDecl(const FileVarDecl *D,
|
|
|
|
bool isDefinition);
|
2007-08-31 04:31:45 +00:00
|
|
|
|
2007-12-02 06:27:33 +00:00
|
|
|
|
2007-08-31 04:31:45 +00:00
|
|
|
/// getBuiltinLibFunction - Given a builtin id for a function like
|
|
|
|
/// "__builtin_fabsf", return a Function* for "fabsf".
|
|
|
|
///
|
|
|
|
llvm::Function *getBuiltinLibFunction(unsigned BuiltinID);
|
2007-08-21 00:21:21 +00:00
|
|
|
llvm::Constant *GetAddrOfConstantCFString(const std::string& str);
|
2007-11-28 05:34:05 +00:00
|
|
|
llvm::Constant *GetAddrOfConstantString(const std::string& str);
|
2007-06-22 18:48:09 +00:00
|
|
|
llvm::Function *getMemCpyFn();
|
|
|
|
|
2007-08-31 04:31:45 +00:00
|
|
|
|
2007-07-13 05:13:43 +00:00
|
|
|
void EmitFunction(const FunctionDecl *FD);
|
|
|
|
void EmitGlobalVar(const FileVarDecl *D);
|
2007-07-14 00:16:50 +00:00
|
|
|
void EmitGlobalVarDeclarator(const FileVarDecl *D);
|
2007-12-02 00:11:25 +00:00
|
|
|
llvm::Constant *EmitGlobalInit(const Expr *Expression);
|
2007-05-24 06:29:05 +00:00
|
|
|
|
|
|
|
void PrintStats() {}
|
2007-12-02 07:09:19 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
/// ReplaceMapValuesWith - This is a really slow and bad function that
|
|
|
|
/// searches for any entries in GlobalDeclMap that point to OldVal, changing
|
|
|
|
/// them to point to NewVal. This is badbadbad, FIXME!
|
|
|
|
void ReplaceMapValuesWith(llvm::Constant *OldVal, llvm::Constant *NewVal);
|
|
|
|
|
2007-05-24 06:29:05 +00:00
|
|
|
};
|
|
|
|
} // end namespace CodeGen
|
|
|
|
} // end namespace clang
|
|
|
|
|
|
|
|
#endif
|