2007-05-24 06:29:05 +00:00
|
|
|
//===--- ModuleBuilder.cpp - Emit LLVM Code from ASTs ---------------------===//
|
|
|
|
|
//
|
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
|
//
|
2007-12-29 19:59:25 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-05-24 06:29:05 +00:00
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
//
|
|
|
|
|
// This builds an AST and converts it to LLVM Code.
|
|
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
#include "clang/CodeGen/ModuleBuilder.h"
|
2007-05-28 01:07:47 +00:00
|
|
|
#include "CodeGenModule.h"
|
2008-01-12 07:05:38 +00:00
|
|
|
#include "clang/AST/Decl.h"
|
2007-05-24 06:29:05 +00:00
|
|
|
using namespace clang;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Init - Create an ModuleBuilder with the specified ASTContext.
|
2007-11-13 18:16:41 +00:00
|
|
|
clang::CodeGen::CodeGenModule *
|
2007-11-28 05:34:05 +00:00
|
|
|
clang::CodeGen::Init(ASTContext &Context, const LangOptions &Features,
|
2007-12-02 01:40:18 +00:00
|
|
|
llvm::Module &M, const llvm::TargetData &TD,
|
|
|
|
|
Diagnostic &Diags) {
|
|
|
|
|
return new CodeGenModule(Context, Features, M, TD, Diags);
|
2007-05-24 06:29:05 +00:00
|
|
|
}
|
|
|
|
|
|
2007-11-13 18:16:41 +00:00
|
|
|
void clang::CodeGen::Terminate(CodeGenModule *B) {
|
|
|
|
|
delete B;
|
2007-05-24 06:29:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// CodeGenFunction - Convert the AST node for a FunctionDecl into LLVM.
|
|
|
|
|
///
|
2007-11-13 18:16:41 +00:00
|
|
|
void clang::CodeGen::CodeGenFunction(CodeGenModule *B, FunctionDecl *D) {
|
|
|
|
|
B->EmitFunction(D);
|
2007-05-24 06:29:05 +00:00
|
|
|
}
|
|
|
|
|
|
2008-01-12 07:05:38 +00:00
|
|
|
/// CodeGenLinkageSpec - Emit the specified linkage space to LLVM.
|
|
|
|
|
void clang::CodeGen::CodeGenLinkageSpec(CodeGenModule *Builder,
|
|
|
|
|
LinkageSpecDecl *LS) {
|
|
|
|
|
if (LS->getLanguage() == LinkageSpecDecl::lang_cxx)
|
|
|
|
|
Builder->WarnUnsupported(LS, "linkage spec");
|
|
|
|
|
|
|
|
|
|
// FIXME: implement C++ linkage, C linkage works mostly by C
|
|
|
|
|
// language reuse already.
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-13 05:13:43 +00:00
|
|
|
/// CodeGenGlobalVar - Emit the specified global variable to LLVM.
|
2007-11-13 18:16:41 +00:00
|
|
|
void clang::CodeGen::CodeGenGlobalVar(CodeGenModule *Builder, FileVarDecl *D) {
|
|
|
|
|
Builder->EmitGlobalVarDeclarator(D);
|
2007-07-13 05:13:43 +00:00
|
|
|
}
|
|
|
|
|
|
2008-02-05 08:06:13 +00:00
|
|
|
/// CodeGenTypeDecl - Compile a type.
|
|
|
|
|
void clang::CodeGen::CodeGenTypeDecl(CodeGenModule *Builder, TypeDecl *D) {
|
|
|
|
|
Builder->EmitType(D);
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-13 05:13:43 +00:00
|
|
|
|
2007-05-24 06:29:05 +00:00
|
|
|
/// PrintStats - Emit statistic information to stderr.
|
|
|
|
|
///
|
2007-11-13 18:16:41 +00:00
|
|
|
void clang::CodeGen::PrintStats(CodeGenModule *B) {
|
|
|
|
|
B->PrintStats();
|
2007-05-24 06:29:05 +00:00
|
|
|
}
|