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 * |
Devang Patel | f767e21 | 2007-10-31 00:59:29 +0000 | [diff] [blame^] | 21 | clang::CodeGen::Init(ASTContext &Context, llvm::Module &M, |
| 22 | const llvm::TargetData &TD) { |
| 23 | return new CodeGenModule(Context, M, TD); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 24 | } |
| 25 | |
| 26 | void clang::CodeGen::Terminate(BuilderTy *B) { |
| 27 | delete static_cast<CodeGenModule*>(B); |
| 28 | } |
| 29 | |
| 30 | /// CodeGenFunction - Convert the AST node for a FunctionDecl into LLVM. |
| 31 | /// |
| 32 | void clang::CodeGen::CodeGenFunction(BuilderTy *B, FunctionDecl *D) { |
| 33 | static_cast<CodeGenModule*>(B)->EmitFunction(D); |
| 34 | } |
| 35 | |
Chris Lattner | 88a69ad | 2007-07-13 05:13:43 +0000 | [diff] [blame] | 36 | /// CodeGenGlobalVar - Emit the specified global variable to LLVM. |
| 37 | void clang::CodeGen::CodeGenGlobalVar(BuilderTy *Builder, FileVarDecl *D) { |
Chris Lattner | 32b266c | 2007-07-14 00:16:50 +0000 | [diff] [blame] | 38 | static_cast<CodeGenModule*>(Builder)->EmitGlobalVarDeclarator(D); |
Chris Lattner | 88a69ad | 2007-07-13 05:13:43 +0000 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 42 | /// PrintStats - Emit statistic information to stderr. |
| 43 | /// |
| 44 | void clang::CodeGen::PrintStats(BuilderTy *B) { |
| 45 | static_cast<CodeGenModule*>(B)->PrintStats(); |
| 46 | } |