blob: 9d2874984ad467b7967a19e73d7382f26b281585 [file] [log] [blame]
Chris Lattnerf97fe382007-05-24 06:29:05 +00001//===--- 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"
Chris Lattnerbed31442007-05-28 01:07:47 +000015#include "CodeGenModule.h"
Chris Lattnerf97fe382007-05-24 06:29:05 +000016using namespace clang;
17
18
19/// Init - Create an ModuleBuilder with the specified ASTContext.
Chris Lattner034b49d2007-11-13 18:16:41 +000020clang::CodeGen::CodeGenModule *
Chris Lattnerfb300092007-11-28 05:34:05 +000021clang::CodeGen::Init(ASTContext &Context, const LangOptions &Features,
Chris Lattnerc8dbe1e2007-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);
Chris Lattnerf97fe382007-05-24 06:29:05 +000025}
26
Chris Lattner034b49d2007-11-13 18:16:41 +000027void clang::CodeGen::Terminate(CodeGenModule *B) {
28 delete B;
Chris Lattnerf97fe382007-05-24 06:29:05 +000029}
30
31/// CodeGenFunction - Convert the AST node for a FunctionDecl into LLVM.
32///
Chris Lattner034b49d2007-11-13 18:16:41 +000033void clang::CodeGen::CodeGenFunction(CodeGenModule *B, FunctionDecl *D) {
34 B->EmitFunction(D);
Chris Lattnerf97fe382007-05-24 06:29:05 +000035}
36
Chris Lattnerd14bfa92007-07-13 05:13:43 +000037/// CodeGenGlobalVar - Emit the specified global variable to LLVM.
Chris Lattner034b49d2007-11-13 18:16:41 +000038void clang::CodeGen::CodeGenGlobalVar(CodeGenModule *Builder, FileVarDecl *D) {
39 Builder->EmitGlobalVarDeclarator(D);
Chris Lattnerd14bfa92007-07-13 05:13:43 +000040}
41
42
Chris Lattnerf97fe382007-05-24 06:29:05 +000043/// PrintStats - Emit statistic information to stderr.
44///
Chris Lattner034b49d2007-11-13 18:16:41 +000045void clang::CodeGen::PrintStats(CodeGenModule *B) {
46 B->PrintStats();
Chris Lattnerf97fe382007-05-24 06:29:05 +000047}