blob: fff5b3fbfff2e045a27222512df018774adf4146 [file] [log] [blame]
Chris Lattner4b009652007-07-25 00:24:17 +00001//===--- ModuleBuilder.cpp - Emit LLVM Code from ASTs ---------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner959e5be2007-12-29 19:59:25 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Chris Lattner4b009652007-07-25 00:24:17 +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"
Chris Lattner806a5f52008-01-12 07:05:38 +000016#include "clang/AST/Decl.h"
Chris Lattner4b009652007-07-25 00:24:17 +000017using namespace clang;
18
19
20/// Init - Create an ModuleBuilder with the specified ASTContext.
Chris Lattner07f44dc2007-11-13 18:16:41 +000021clang::CodeGen::CodeGenModule *
Chris Lattnerdb6be562007-11-28 05:34:05 +000022clang::CodeGen::Init(ASTContext &Context, const LangOptions &Features,
Chris Lattner22595b82007-12-02 01:40:18 +000023 llvm::Module &M, const llvm::TargetData &TD,
24 Diagnostic &Diags) {
25 return new CodeGenModule(Context, Features, M, TD, Diags);
Chris Lattner4b009652007-07-25 00:24:17 +000026}
27
Chris Lattner07f44dc2007-11-13 18:16:41 +000028void clang::CodeGen::Terminate(CodeGenModule *B) {
29 delete B;
Chris Lattner4b009652007-07-25 00:24:17 +000030}
31
32/// CodeGenFunction - Convert the AST node for a FunctionDecl into LLVM.
33///
Chris Lattner07f44dc2007-11-13 18:16:41 +000034void clang::CodeGen::CodeGenFunction(CodeGenModule *B, FunctionDecl *D) {
35 B->EmitFunction(D);
Chris Lattner4b009652007-07-25 00:24:17 +000036}
37
Chris Lattner806a5f52008-01-12 07:05:38 +000038/// CodeGenLinkageSpec - Emit the specified linkage space to LLVM.
39void 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 Lattner4b009652007-07-25 00:24:17 +000048/// CodeGenGlobalVar - Emit the specified global variable to LLVM.
Chris Lattner07f44dc2007-11-13 18:16:41 +000049void clang::CodeGen::CodeGenGlobalVar(CodeGenModule *Builder, FileVarDecl *D) {
50 Builder->EmitGlobalVarDeclarator(D);
Chris Lattner4b009652007-07-25 00:24:17 +000051}
52
53
54/// PrintStats - Emit statistic information to stderr.
55///
Chris Lattner07f44dc2007-11-13 18:16:41 +000056void clang::CodeGen::PrintStats(CodeGenModule *B) {
57 B->PrintStats();
Chris Lattner4b009652007-07-25 00:24:17 +000058}