diff options
Diffstat (limited to 'clang/CodeGen')
| -rw-r--r-- | clang/CodeGen/CodeGenFunction.cpp | 20 | ||||
| -rw-r--r-- | clang/CodeGen/CodeGenFunction.h | 38 | ||||
| -rw-r--r-- | clang/CodeGen/CodeGenModule.cpp | 24 | ||||
| -rw-r--r-- | clang/CodeGen/CodeGenModule.h (renamed from clang/CodeGen/Builder.h) | 15 | ||||
| -rw-r--r-- | clang/CodeGen/ModuleBuilder.cpp | 10 |
5 files changed, 95 insertions, 12 deletions
diff --git a/clang/CodeGen/CodeGenFunction.cpp b/clang/CodeGen/CodeGenFunction.cpp new file mode 100644 index 00000000000..94146c016ee --- /dev/null +++ b/clang/CodeGen/CodeGenFunction.cpp @@ -0,0 +1,20 @@ +//===--- CodeGenFunction.cpp - Emit LLVM Code from ASTs for a Function ----===// +// +// 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 coordinates the per-function state used while generating code. +// +//===----------------------------------------------------------------------===// + +#include "CodeGenFunction.h" +#include "CodeGenModule.h" +#include "llvm/Support/LLVMBuilder.h" +using namespace llvm; +using namespace clang; +using namespace CodeGen; + diff --git a/clang/CodeGen/CodeGenFunction.h b/clang/CodeGen/CodeGenFunction.h new file mode 100644 index 00000000000..ebb3e797e13 --- /dev/null +++ b/clang/CodeGen/CodeGenFunction.h @@ -0,0 +1,38 @@ +//===--- CodeGenFunction.h - Per-Function state for LLVM CodeGen ----------===// +// +// 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-function state used for llvm translation. +// +//===----------------------------------------------------------------------===// + +#ifndef CODEGEN_CODEGENFUNCTION_H +#define CODEGEN_CODEGENFUNCTION_H + +namespace llvm { + class Module; +namespace clang { + class ASTContext; + class FunctionDecl; + +namespace CodeGen { + class CodeGenModule; + +/// CodeGenFunction - This class organizes the per-function state that is used +/// while generating LLVM code. +class CodeGenFunction { + CodeGenModule &CGM; // Per-module state. +public: + CodeGenFunction(CodeGenModule &cgm) : CGM(cgm) {} + +}; +} // end namespace CodeGen +} // end namespace clang +} // end namespace llvm + +#endif diff --git a/clang/CodeGen/CodeGenModule.cpp b/clang/CodeGen/CodeGenModule.cpp new file mode 100644 index 00000000000..cbd679ae32c --- /dev/null +++ b/clang/CodeGen/CodeGenModule.cpp @@ -0,0 +1,24 @@ +//===--- CodeGenModule.cpp - Emit LLVM Code from ASTs for a Module --------===// +// +// 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 coordinates the per-module state used while generating code. +// +//===----------------------------------------------------------------------===// + +#include "CodeGenModule.h" +#include "CodeGenFunction.h" +using namespace llvm; +using namespace clang; +using namespace CodeGen; + + +void CodeGenModule::EmitFunction(FunctionDecl *FD) { + CodeGenFunction CGF(*this); + +} diff --git a/clang/CodeGen/Builder.h b/clang/CodeGen/CodeGenModule.h index 1e6b0c4ddcb..c971d42705f 100644 --- a/clang/CodeGen/Builder.h +++ b/clang/CodeGen/CodeGenModule.h @@ -1,4 +1,4 @@ -//===--- Builder.h - Internal interface for LLVM Builder ------------------===// +//===--- CodeGenModule.h - Per-Module state for LLVM CodeGen --------------===// // // The LLVM Compiler Infrastructure // @@ -11,8 +11,8 @@ // //===----------------------------------------------------------------------===// -#ifndef CODEGEN_BUILDER_H -#define CODEGEN_BUILDER_H +#ifndef CODEGEN_CODEGENMODULE_H +#define CODEGEN_CODEGENMODULE_H namespace llvm { class Module; @@ -22,16 +22,17 @@ namespace clang { namespace CodeGen { -class Builder { +/// CodeGenModule - This class organizes the cross-module state that is used +/// while generating LLVM code. +class CodeGenModule { ASTContext &Context; Module &TheModule; public: - Builder(ASTContext &C, Module &M) : Context(C), TheModule(M) {} + CodeGenModule(ASTContext &C, Module &M) : Context(C), TheModule(M) {} - void CodeGenFunction(FunctionDecl *FD) {} + void EmitFunction(FunctionDecl *FD); void PrintStats() {} - }; } // end namespace CodeGen } // end namespace clang diff --git a/clang/CodeGen/ModuleBuilder.cpp b/clang/CodeGen/ModuleBuilder.cpp index 309a35762a2..2de81721826 100644 --- a/clang/CodeGen/ModuleBuilder.cpp +++ b/clang/CodeGen/ModuleBuilder.cpp @@ -12,7 +12,7 @@ //===----------------------------------------------------------------------===// #include "clang/CodeGen/ModuleBuilder.h" -#include "Builder.h" +#include "CodeGenModule.h" using namespace llvm; using namespace clang; @@ -20,21 +20,21 @@ using namespace clang; /// Init - Create an ModuleBuilder with the specified ASTContext. llvm::clang::CodeGen::BuilderTy * llvm::clang::CodeGen::Init(ASTContext &Context, Module &M) { - return new Builder(Context, M); + return new CodeGenModule(Context, M); } void llvm::clang::CodeGen::Terminate(BuilderTy *B) { - delete static_cast<Builder*>(B); + delete static_cast<CodeGenModule*>(B); } /// CodeGenFunction - Convert the AST node for a FunctionDecl into LLVM. /// void llvm::clang::CodeGen::CodeGenFunction(BuilderTy *B, FunctionDecl *D) { - static_cast<Builder*>(B)->CodeGenFunction(D); + static_cast<CodeGenModule*>(B)->EmitFunction(D); } /// PrintStats - Emit statistic information to stderr. /// void llvm::clang::CodeGen::PrintStats(BuilderTy *B) { - static_cast<Builder*>(B)->PrintStats(); + static_cast<CodeGenModule*>(B)->PrintStats(); } |

