Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 1 | //===--- ModuleBuilder.cpp - Emit LLVM Code from ASTs ---------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 959e5be | 2007-12-29 19:59:25 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 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. |
Chris Lattner | 07f44dc | 2007-11-13 18:16:41 +0000 | [diff] [blame] | 20 | clang::CodeGen::CodeGenModule * |
Chris Lattner | db6be56 | 2007-11-28 05:34:05 +0000 | [diff] [blame] | 21 | clang::CodeGen::Init(ASTContext &Context, const LangOptions &Features, |
Chris Lattner | 22595b8 | 2007-12-02 01:40:18 +0000 | [diff] [blame] | 22 | llvm::Module &M, const llvm::TargetData &TD, |
| 23 | Diagnostic &Diags) { |
| 24 | return new CodeGenModule(Context, Features, M, TD, Diags); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 25 | } |
| 26 | |
Chris Lattner | 07f44dc | 2007-11-13 18:16:41 +0000 | [diff] [blame] | 27 | void clang::CodeGen::Terminate(CodeGenModule *B) { |
| 28 | delete B; |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | /// CodeGenFunction - Convert the AST node for a FunctionDecl into LLVM. |
| 32 | /// |
Chris Lattner | 07f44dc | 2007-11-13 18:16:41 +0000 | [diff] [blame] | 33 | void clang::CodeGen::CodeGenFunction(CodeGenModule *B, FunctionDecl *D) { |
| 34 | B->EmitFunction(D); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | /// CodeGenGlobalVar - Emit the specified global variable to LLVM. |
Chris Lattner | 07f44dc | 2007-11-13 18:16:41 +0000 | [diff] [blame] | 38 | void clang::CodeGen::CodeGenGlobalVar(CodeGenModule *Builder, FileVarDecl *D) { |
| 39 | Builder->EmitGlobalVarDeclarator(D); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | |
| 43 | /// PrintStats - Emit statistic information to stderr. |
| 44 | /// |
Chris Lattner | 07f44dc | 2007-11-13 18:16:41 +0000 | [diff] [blame] | 45 | void clang::CodeGen::PrintStats(CodeGenModule *B) { |
| 46 | B->PrintStats(); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 47 | } |