Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1 | //===--- ModuleBuilder.cpp - Emit LLVM Code from ASTs ---------------------===// |
| 2 | // |
| 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 builds an AST and converts it to LLVM Code. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "clang/CodeGen/ModuleBuilder.h" |
| 15 | #include "CodeGenModule.h" |
| 16 | using namespace clang; |
| 17 | |
| 18 | |
| 19 | /// Init - Create an ModuleBuilder with the specified ASTContext. |
| 20 | clang::CodeGen::BuilderTy * |
| 21 | clang::CodeGen::Init(ASTContext &Context, llvm::Module &M) { |
| 22 | return new CodeGenModule(Context, M); |
| 23 | } |
| 24 | |
| 25 | void clang::CodeGen::Terminate(BuilderTy *B) { |
| 26 | delete static_cast<CodeGenModule*>(B); |
| 27 | } |
| 28 | |
| 29 | /// CodeGenFunction - Convert the AST node for a FunctionDecl into LLVM. |
| 30 | /// |
| 31 | void clang::CodeGen::CodeGenFunction(BuilderTy *B, FunctionDecl *D) { |
| 32 | static_cast<CodeGenModule*>(B)->EmitFunction(D); |
| 33 | } |
| 34 | |
Chris Lattner | 88a69ad | 2007-07-13 05:13:43 +0000 | [diff] [blame] | 35 | /// CodeGenGlobalVar - Emit the specified global variable to LLVM. |
| 36 | void clang::CodeGen::CodeGenGlobalVar(BuilderTy *Builder, FileVarDecl *D) { |
Chris Lattner | 32b266c | 2007-07-14 00:16:50 +0000 | [diff] [blame] | 37 | static_cast<CodeGenModule*>(Builder)->EmitGlobalVarDeclarator(D); |
Chris Lattner | 88a69ad | 2007-07-13 05:13:43 +0000 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 41 | /// PrintStats - Emit statistic information to stderr. |
| 42 | /// |
| 43 | void clang::CodeGen::PrintStats(BuilderTy *B) { |
| 44 | static_cast<CodeGenModule*>(B)->PrintStats(); |
| 45 | } |