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 | // |
Chris Lattner | 0bc735f | 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. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +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 | c6fdc34 | 2008-01-12 07:05:38 +0000 | [diff] [blame] | 16 | #include "clang/AST/Decl.h" |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 17 | using namespace clang; |
| 18 | |
| 19 | |
| 20 | /// Init - Create an ModuleBuilder with the specified ASTContext. |
Chris Lattner | a36c486 | 2007-11-13 18:16:41 +0000 | [diff] [blame] | 21 | clang::CodeGen::CodeGenModule * |
Chris Lattner | 45e8cbd | 2007-11-28 05:34:05 +0000 | [diff] [blame] | 22 | clang::CodeGen::Init(ASTContext &Context, const LangOptions &Features, |
Chris Lattner | fb97b03 | 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); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 26 | } |
| 27 | |
Chris Lattner | a36c486 | 2007-11-13 18:16:41 +0000 | [diff] [blame] | 28 | void clang::CodeGen::Terminate(CodeGenModule *B) { |
| 29 | delete B; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | /// CodeGenFunction - Convert the AST node for a FunctionDecl into LLVM. |
| 33 | /// |
Chris Lattner | a36c486 | 2007-11-13 18:16:41 +0000 | [diff] [blame] | 34 | void clang::CodeGen::CodeGenFunction(CodeGenModule *B, FunctionDecl *D) { |
| 35 | B->EmitFunction(D); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 36 | } |
| 37 | |
Chris Lattner | c6fdc34 | 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 | 88a69ad | 2007-07-13 05:13:43 +0000 | [diff] [blame] | 48 | /// CodeGenGlobalVar - Emit the specified global variable to LLVM. |
Chris Lattner | a36c486 | 2007-11-13 18:16:41 +0000 | [diff] [blame] | 49 | void clang::CodeGen::CodeGenGlobalVar(CodeGenModule *Builder, FileVarDecl *D) { |
| 50 | Builder->EmitGlobalVarDeclarator(D); |
Chris Lattner | 88a69ad | 2007-07-13 05:13:43 +0000 | [diff] [blame] | 51 | } |
| 52 | |
Chris Lattner | d86e6bc | 2008-02-05 08:06:13 +0000 | [diff] [blame] | 53 | /// CodeGenTypeDecl - Compile a type. |
| 54 | void clang::CodeGen::CodeGenTypeDecl(CodeGenModule *Builder, TypeDecl *D) { |
| 55 | Builder->EmitType(D); |
| 56 | } |
| 57 | |
Chris Lattner | 88a69ad | 2007-07-13 05:13:43 +0000 | [diff] [blame] | 58 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 59 | /// PrintStats - Emit statistic information to stderr. |
| 60 | /// |
Chris Lattner | a36c486 | 2007-11-13 18:16:41 +0000 | [diff] [blame] | 61 | void clang::CodeGen::PrintStats(CodeGenModule *B) { |
| 62 | B->PrintStats(); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 63 | } |