diff --git a/clang/CodeGen/CodeGenFunction.cpp b/clang/CodeGen/CodeGenFunction.cpp new file mode 100644 index 000000000000..94146c016eef --- /dev/null +++ b/clang/CodeGen/CodeGenFunction.cpp @@ -0,0 +1,20 @@ +//===--- CodeGenFunction.cpp - Emit LLVM Code from ASTs for a Function ----===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by Chris Lattner and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This coordinates the per-function state used while generating code. +// +//===----------------------------------------------------------------------===// + +#include "CodeGenFunction.h" +#include "CodeGenModule.h" +#include "llvm/Support/LLVMBuilder.h" +using namespace llvm; +using namespace clang; +using namespace CodeGen; + diff --git a/clang/CodeGen/CodeGenFunction.h b/clang/CodeGen/CodeGenFunction.h new file mode 100644 index 000000000000..ebb3e797e136 --- /dev/null +++ b/clang/CodeGen/CodeGenFunction.h @@ -0,0 +1,38 @@ +//===--- CodeGenFunction.h - Per-Function state for LLVM CodeGen ----------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by Chris Lattner and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This is the internal per-function state used for llvm translation. +// +//===----------------------------------------------------------------------===// + +#ifndef CODEGEN_CODEGENFUNCTION_H +#define CODEGEN_CODEGENFUNCTION_H + +namespace llvm { + class Module; +namespace clang { + class ASTContext; + class FunctionDecl; + +namespace CodeGen { + class CodeGenModule; + +/// CodeGenFunction - This class organizes the per-function state that is used +/// while generating LLVM code. +class CodeGenFunction { + CodeGenModule &CGM; // Per-module state. +public: + CodeGenFunction(CodeGenModule &cgm) : CGM(cgm) {} + +}; +} // end namespace CodeGen +} // end namespace clang +} // end namespace llvm + +#endif diff --git a/clang/CodeGen/CodeGenModule.cpp b/clang/CodeGen/CodeGenModule.cpp new file mode 100644 index 000000000000..cbd679ae32c2 --- /dev/null +++ b/clang/CodeGen/CodeGenModule.cpp @@ -0,0 +1,24 @@ +//===--- CodeGenModule.cpp - Emit LLVM Code from ASTs for a Module --------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by Chris Lattner and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This coordinates the per-module state used while generating code. +// +//===----------------------------------------------------------------------===// + +#include "CodeGenModule.h" +#include "CodeGenFunction.h" +using namespace llvm; +using namespace clang; +using namespace CodeGen; + + +void CodeGenModule::EmitFunction(FunctionDecl *FD) { + CodeGenFunction CGF(*this); + +} diff --git a/clang/CodeGen/Builder.h b/clang/CodeGen/CodeGenModule.h similarity index 67% rename from clang/CodeGen/Builder.h rename to clang/CodeGen/CodeGenModule.h index 1e6b0c4ddcb2..c971d42705f6 100644 --- a/clang/CodeGen/Builder.h +++ b/clang/CodeGen/CodeGenModule.h @@ -1,4 +1,4 @@ -//===--- Builder.h - Internal interface for LLVM Builder ------------------===// +//===--- CodeGenModule.h - Per-Module state for LLVM CodeGen --------------===// // // The LLVM Compiler Infrastructure // @@ -11,8 +11,8 @@ // //===----------------------------------------------------------------------===// -#ifndef CODEGEN_BUILDER_H -#define CODEGEN_BUILDER_H +#ifndef CODEGEN_CODEGENMODULE_H +#define CODEGEN_CODEGENMODULE_H namespace llvm { class Module; @@ -22,16 +22,17 @@ namespace clang { namespace CodeGen { -class Builder { +/// CodeGenModule - This class organizes the cross-module state that is used +/// while generating LLVM code. +class CodeGenModule { ASTContext &Context; Module &TheModule; public: - Builder(ASTContext &C, Module &M) : Context(C), TheModule(M) {} + CodeGenModule(ASTContext &C, Module &M) : Context(C), TheModule(M) {} - void CodeGenFunction(FunctionDecl *FD) {} + void EmitFunction(FunctionDecl *FD); void PrintStats() {} - }; } // end namespace CodeGen } // end namespace clang diff --git a/clang/CodeGen/ModuleBuilder.cpp b/clang/CodeGen/ModuleBuilder.cpp index 309a35762a23..2de81721826d 100644 --- a/clang/CodeGen/ModuleBuilder.cpp +++ b/clang/CodeGen/ModuleBuilder.cpp @@ -12,7 +12,7 @@ //===----------------------------------------------------------------------===// #include "clang/CodeGen/ModuleBuilder.h" -#include "Builder.h" +#include "CodeGenModule.h" using namespace llvm; using namespace clang; @@ -20,21 +20,21 @@ using namespace clang; /// Init - Create an ModuleBuilder with the specified ASTContext. llvm::clang::CodeGen::BuilderTy * llvm::clang::CodeGen::Init(ASTContext &Context, Module &M) { - return new Builder(Context, M); + return new CodeGenModule(Context, M); } void llvm::clang::CodeGen::Terminate(BuilderTy *B) { - delete static_cast(B); + delete static_cast(B); } /// CodeGenFunction - Convert the AST node for a FunctionDecl into LLVM. /// void llvm::clang::CodeGen::CodeGenFunction(BuilderTy *B, FunctionDecl *D) { - static_cast(B)->CodeGenFunction(D); + static_cast(B)->EmitFunction(D); } /// PrintStats - Emit statistic information to stderr. /// void llvm::clang::CodeGen::PrintStats(BuilderTy *B) { - static_cast(B)->PrintStats(); + static_cast(B)->PrintStats(); } diff --git a/clang/clang.xcodeproj/project.pbxproj b/clang/clang.xcodeproj/project.pbxproj index f8b139602a36..fd0c89f86db2 100644 --- a/clang/clang.xcodeproj/project.pbxproj +++ b/clang/clang.xcodeproj/project.pbxproj @@ -56,9 +56,12 @@ DE75ED290B044DC90020CF81 /* ASTContext.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE75ED280B044DC90020CF81 /* ASTContext.h */; }; DE75EDF10B06880E0020CF81 /* Type.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE75EDF00B06880E0020CF81 /* Type.cpp */; }; DE927FFD0C055DE900231DA4 /* LLVMCodegen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE927FFC0C055DE900231DA4 /* LLVMCodegen.cpp */; }; - DE928B110C05658A00231DA4 /* Builder.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE928B100C05658A00231DA4 /* Builder.h */; }; DE928B130C05659200231DA4 /* ModuleBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE928B120C05659200231DA4 /* ModuleBuilder.cpp */; }; DE928B200C0565B000231DA4 /* ModuleBuilder.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE928B1F0C0565B000231DA4 /* ModuleBuilder.h */; }; + DE928B7D0C0A615100231DA4 /* CodeGenModule.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE928B7C0C0A615100231DA4 /* CodeGenModule.h */; }; + DE928B7F0C0A615600231DA4 /* CodeGenModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE928B7E0C0A615600231DA4 /* CodeGenModule.cpp */; }; + DE928B810C0A615B00231DA4 /* CodeGenFunction.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE928B800C0A615B00231DA4 /* CodeGenFunction.h */; }; + DE928B830C0A616000231DA4 /* CodeGenFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE928B820C0A616000231DA4 /* CodeGenFunction.cpp */; }; DEAEE98B0A5A2B970045101B /* MultipleIncludeOpt.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DEAEE98A0A5A2B970045101B /* MultipleIncludeOpt.h */; }; DEAEED4B0A5AF89A0045101B /* NOTES.txt in CopyFiles */ = {isa = PBXBuildFile; fileRef = DEAEED4A0A5AF89A0045101B /* NOTES.txt */; }; DEC8D9910A9433CD00353FCA /* Decl.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DEC8D9900A9433CD00353FCA /* Decl.h */; }; @@ -100,23 +103,6 @@ DED7D9E50A5257F6003AD0FB /* ScratchBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DED7D9E40A5257F6003AD0FB /* ScratchBuffer.cpp */; }; /* End PBXBuildFile section */ -/* Begin PBXBuildStyle section */ - 84FCE23B0C08F6EF00F0C622 /* Development */ = { - isa = PBXBuildStyle; - buildSettings = { - COPY_PHASE_STRIP = NO; - }; - name = Development; - }; - 84FCE23C0C08F6EF00F0C622 /* Deployment */ = { - isa = PBXBuildStyle; - buildSettings = { - COPY_PHASE_STRIP = YES; - }; - name = Deployment; - }; -/* End PBXBuildStyle section */ - /* Begin PBXCopyFilesBuildPhase section */ 8DD76F690486A84900D96B5E /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; @@ -168,8 +154,9 @@ 1A869A700BA2164C008DA07A /* LiteralSupport.h in CopyFiles */, DE67E7150C020EDF00F66BC5 /* Sema.h in CopyFiles */, DE67E7280C02109800F66BC5 /* ASTStreamer.h in CopyFiles */, - DE928B110C05658A00231DA4 /* Builder.h in CopyFiles */, DE928B200C0565B000231DA4 /* ModuleBuilder.h in CopyFiles */, + DE928B7D0C0A615100231DA4 /* CodeGenModule.h in CopyFiles */, + DE928B810C0A615B00231DA4 /* CodeGenFunction.h in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 1; }; @@ -226,9 +213,12 @@ DE75ED280B044DC90020CF81 /* ASTContext.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ASTContext.h; path = clang/AST/ASTContext.h; sourceTree = ""; }; DE75EDF00B06880E0020CF81 /* Type.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = Type.cpp; path = AST/Type.cpp; sourceTree = ""; }; DE927FFC0C055DE900231DA4 /* LLVMCodegen.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = LLVMCodegen.cpp; path = Driver/LLVMCodegen.cpp; sourceTree = ""; }; - DE928B100C05658A00231DA4 /* Builder.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Builder.h; path = CodeGen/Builder.h; sourceTree = ""; }; DE928B120C05659200231DA4 /* ModuleBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = ModuleBuilder.cpp; path = CodeGen/ModuleBuilder.cpp; sourceTree = ""; }; DE928B1F0C0565B000231DA4 /* ModuleBuilder.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ModuleBuilder.h; path = clang/CodeGen/ModuleBuilder.h; sourceTree = ""; }; + DE928B7C0C0A615100231DA4 /* CodeGenModule.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CodeGenModule.h; path = CodeGen/CodeGenModule.h; sourceTree = ""; }; + DE928B7E0C0A615600231DA4 /* CodeGenModule.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = CodeGenModule.cpp; path = CodeGen/CodeGenModule.cpp; sourceTree = ""; }; + DE928B800C0A615B00231DA4 /* CodeGenFunction.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CodeGenFunction.h; path = CodeGen/CodeGenFunction.h; sourceTree = ""; }; + DE928B820C0A616000231DA4 /* CodeGenFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = CodeGenFunction.cpp; path = CodeGen/CodeGenFunction.cpp; sourceTree = ""; }; DEAEE98A0A5A2B970045101B /* MultipleIncludeOpt.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MultipleIncludeOpt.h; sourceTree = ""; }; DEAEED4A0A5AF89A0045101B /* NOTES.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = NOTES.txt; sourceTree = ""; }; DEC8D9900A9433CD00353FCA /* Decl.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Decl.h; path = clang/AST/Decl.h; sourceTree = ""; }; @@ -376,7 +366,10 @@ DE927FCC0C0557CD00231DA4 /* CodeGen */ = { isa = PBXGroup; children = ( - DE928B100C05658A00231DA4 /* Builder.h */, + DE928B800C0A615B00231DA4 /* CodeGenFunction.h */, + DE928B820C0A616000231DA4 /* CodeGenFunction.cpp */, + DE928B7C0C0A615100231DA4 /* CodeGenModule.h */, + DE928B7E0C0A615600231DA4 /* CodeGenModule.cpp */, DE928B120C05659200231DA4 /* ModuleBuilder.cpp */, ); name = CodeGen; @@ -545,12 +538,6 @@ 08FB7793FE84155DC02AAC07 /* Project object */ = { isa = PBXProject; buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */; - buildSettings = { - }; - buildStyles = ( - 84FCE23B0C08F6EF00F0C622 /* Development */, - 84FCE23C0C08F6EF00F0C622 /* Deployment */, - ); hasScannedForEncodings = 1; mainGroup = 08FB7794FE84155DC02AAC07 /* clang */; projectDirPath = ""; @@ -610,6 +597,8 @@ DE06756C0C051CFE00EBBFD8 /* ParseExprCXX.cpp in Sources */, DE927FFD0C055DE900231DA4 /* LLVMCodegen.cpp in Sources */, DE928B130C05659200231DA4 /* ModuleBuilder.cpp in Sources */, + DE928B7F0C0A615600231DA4 /* CodeGenModule.cpp in Sources */, + DE928B830C0A616000231DA4 /* CodeGenFunction.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; };