blob: 49881c36d9405a3001a50c00545cb6166d5174e6 [file] [log] [blame]
Reid Spencer5f016e22007-07-11 17:01:13 +00001//===--- ModuleBuilder.cpp - Emit LLVM Code from ASTs ---------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner0bc735f2007-12-29 19:59:25 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Reid Spencer5f016e22007-07-11 17:01:13 +00007//
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"
16using namespace clang;
17
18
19/// Init - Create an ModuleBuilder with the specified ASTContext.
Chris Lattnera36c4862007-11-13 18:16:41 +000020clang::CodeGen::CodeGenModule *
Chris Lattner45e8cbd2007-11-28 05:34:05 +000021clang::CodeGen::Init(ASTContext &Context, const LangOptions &Features,
Chris Lattnerfb97b032007-12-02 01:40:18 +000022 llvm::Module &M, const llvm::TargetData &TD,
23 Diagnostic &Diags) {
24 return new CodeGenModule(Context, Features, M, TD, Diags);
Reid Spencer5f016e22007-07-11 17:01:13 +000025}
26
Chris Lattnera36c4862007-11-13 18:16:41 +000027void clang::CodeGen::Terminate(CodeGenModule *B) {
28 delete B;
Reid Spencer5f016e22007-07-11 17:01:13 +000029}
30
31/// CodeGenFunction - Convert the AST node for a FunctionDecl into LLVM.
32///
Chris Lattnera36c4862007-11-13 18:16:41 +000033void clang::CodeGen::CodeGenFunction(CodeGenModule *B, FunctionDecl *D) {
34 B->EmitFunction(D);
Reid Spencer5f016e22007-07-11 17:01:13 +000035}
36
Chris Lattner88a69ad2007-07-13 05:13:43 +000037/// CodeGenGlobalVar - Emit the specified global variable to LLVM.
Chris Lattnera36c4862007-11-13 18:16:41 +000038void clang::CodeGen::CodeGenGlobalVar(CodeGenModule *Builder, FileVarDecl *D) {
39 Builder->EmitGlobalVarDeclarator(D);
Chris Lattner88a69ad2007-07-13 05:13:43 +000040}
41
42
Reid Spencer5f016e22007-07-11 17:01:13 +000043/// PrintStats - Emit statistic information to stderr.
44///
Chris Lattnera36c4862007-11-13 18:16:41 +000045void clang::CodeGen::PrintStats(CodeGenModule *B) {
46 B->PrintStats();
Reid Spencer5f016e22007-07-11 17:01:13 +000047}