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" |
Chris Lattner | 806a5f5 | 2008-01-12 07:05:38 +0000 | [diff] [blame^] | 16 | #include "clang/AST/Decl.h" |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 17 | using namespace clang; |
| 18 | |
| 19 | |
| 20 | /// Init - Create an ModuleBuilder with the specified ASTContext. |
Chris Lattner | 07f44dc | 2007-11-13 18:16:41 +0000 | [diff] [blame] | 21 | clang::CodeGen::CodeGenModule * |
Chris Lattner | db6be56 | 2007-11-28 05:34:05 +0000 | [diff] [blame] | 22 | clang::CodeGen::Init(ASTContext &Context, const LangOptions &Features, |
Chris Lattner | 22595b8 | 2007-12-02 01:40:18 +0000 | [diff] [blame] | 23 | llvm::Module &M, const llvm::TargetData &TD, |
| 24 | Diagnostic &Diags) { |
| 25 | return new CodeGenModule(Context, Features, M, TD, Diags); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 26 | } |
| 27 | |
Chris Lattner | 07f44dc | 2007-11-13 18:16:41 +0000 | [diff] [blame] | 28 | void clang::CodeGen::Terminate(CodeGenModule *B) { |
| 29 | delete B; |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | /// CodeGenFunction - Convert the AST node for a FunctionDecl into LLVM. |
| 33 | /// |
Chris Lattner | 07f44dc | 2007-11-13 18:16:41 +0000 | [diff] [blame] | 34 | void clang::CodeGen::CodeGenFunction(CodeGenModule *B, FunctionDecl *D) { |
| 35 | B->EmitFunction(D); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 36 | } |
| 37 | |
Chris Lattner | 806a5f5 | 2008-01-12 07:05:38 +0000 | [diff] [blame^] | 38 | /// CodeGenLinkageSpec - Emit the specified linkage space to LLVM. |
| 39 | void clang::CodeGen::CodeGenLinkageSpec(CodeGenModule *Builder, |
| 40 | LinkageSpecDecl *LS) { |
| 41 | if (LS->getLanguage() == LinkageSpecDecl::lang_cxx) |
| 42 | Builder->WarnUnsupported(LS, "linkage spec"); |
| 43 | |
| 44 | // FIXME: implement C++ linkage, C linkage works mostly by C |
| 45 | // language reuse already. |
| 46 | } |
| 47 | |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 48 | /// CodeGenGlobalVar - Emit the specified global variable to LLVM. |
Chris Lattner | 07f44dc | 2007-11-13 18:16:41 +0000 | [diff] [blame] | 49 | void clang::CodeGen::CodeGenGlobalVar(CodeGenModule *Builder, FileVarDecl *D) { |
| 50 | Builder->EmitGlobalVarDeclarator(D); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | |
| 54 | /// PrintStats - Emit statistic information to stderr. |
| 55 | /// |
Chris Lattner | 07f44dc | 2007-11-13 18:16:41 +0000 | [diff] [blame] | 56 | void clang::CodeGen::PrintStats(CodeGenModule *B) { |
| 57 | B->PrintStats(); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 58 | } |