blob: 16b13d1c4dd8010c42d55f89c783e29069f86420 [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 Lattner23b7eb62007-06-15 23:05:46 +000020clang::CodeGen::BuilderTy *
21clang::CodeGen::Init(ASTContext &Context, llvm::Module &M) {
Chris Lattnerbed31442007-05-28 01:07:47 +000022 return new CodeGenModule(Context, M);
Chris Lattnerf97fe382007-05-24 06:29:05 +000023}
24
Chris Lattner23b7eb62007-06-15 23:05:46 +000025void clang::CodeGen::Terminate(BuilderTy *B) {
Chris Lattnerbed31442007-05-28 01:07:47 +000026 delete static_cast<CodeGenModule*>(B);
Chris Lattnerf97fe382007-05-24 06:29:05 +000027}
28
29/// CodeGenFunction - Convert the AST node for a FunctionDecl into LLVM.
30///
Chris Lattner23b7eb62007-06-15 23:05:46 +000031void clang::CodeGen::CodeGenFunction(BuilderTy *B, FunctionDecl *D) {
Chris Lattnerbed31442007-05-28 01:07:47 +000032 static_cast<CodeGenModule*>(B)->EmitFunction(D);
Chris Lattnerf97fe382007-05-24 06:29:05 +000033}
34
35/// PrintStats - Emit statistic information to stderr.
36///
Chris Lattner23b7eb62007-06-15 23:05:46 +000037void clang::CodeGen::PrintStats(BuilderTy *B) {
Chris Lattnerbed31442007-05-28 01:07:47 +000038 static_cast<CodeGenModule*>(B)->PrintStats();
Chris Lattnerf97fe382007-05-24 06:29:05 +000039}