From bee0b9eba10f13144a36e1c002e287dd967f13d7 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Thu, 7 Feb 2013 14:35:33 +0100 Subject: [PATCH 1/7] Remove global.params.isLE. --- dmd/mars.h | 1 - dmd2/mars.h | 1 - driver/main.cpp | 3 +-- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/dmd/mars.h b/dmd/mars.h index ae92eaeb..d4864c23 100644 --- a/dmd/mars.h +++ b/dmd/mars.h @@ -194,7 +194,6 @@ struct Param ARCH cpu; // target CPU OS os; // target OS bool is64bit; // generate 64 bit code - bool isLE; // generate little endian code bool useDeprecated; // allow use of deprecated features bool useAssert; // generate runtime code for assert()'s bool useInvariants; // generate class invariant checks diff --git a/dmd2/mars.h b/dmd2/mars.h index e4c5b80b..12721330 100644 --- a/dmd2/mars.h +++ b/dmd2/mars.h @@ -201,7 +201,6 @@ struct Param #endif char map; // generate linker .map file ARCH cpu; // target CPU - bool isLE; // generate little endian code bool is64bit; // generate 64 bit code #if IN_LLVM OS os; diff --git a/driver/main.cpp b/driver/main.cpp index 84a91b2d..cc3973c9 100644 --- a/driver/main.cpp +++ b/driver/main.cpp @@ -588,7 +588,6 @@ int main(int argc, char** argv) gDataLayout = target->getTargetData(); #endif - global.params.isLE = gDataLayout->isLittleEndian(); // Starting with LLVM 3.1 we could also use global.params.targetTriple.isArch64Bit(); global.params.is64bit = gDataLayout->getPointerSizeInBits(ADDRESS_SPACE) == 64; global.params.cpu = static_cast(global.params.targetTriple.getArch()); @@ -656,7 +655,7 @@ int main(int argc, char** argv) } // endianness - if (global.params.isLE) { + if (gDataLayout->isLittleEndian()) { VersionCondition::addPredefinedGlobalIdent("LittleEndian"); } else { From 5f3ba415740cac1d84c14d16ef3d76f461bc087d Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Thu, 7 Feb 2013 15:12:52 +0100 Subject: [PATCH 2/7] Removed redundant global.params.cpu field. Now that we have global.params.targetTriple, the information is only duplicated. --- dmd/mars.h | 15 ++------------- dmd/mtype.c | 9 ++++++--- dmd2/mars.h | 12 ------------ dmd2/mtype.c | 5 ++++- driver/main.cpp | 1 - gen/abi.cpp | 8 ++++---- gen/asmstmt.cpp | 10 ++++++---- gen/complex.cpp | 10 ++++++++-- gen/naked.cpp | 4 ++-- gen/tocall.cpp | 15 +++++++++++---- gen/toir.cpp | 5 +++-- gen/typinf.cpp | 4 ++-- ir/irtype.cpp | 14 +++++++------- 13 files changed, 55 insertions(+), 57 deletions(-) diff --git a/dmd/mars.h b/dmd/mars.h index d4864c23..bcaaef93 100644 --- a/dmd/mars.h +++ b/dmd/mars.h @@ -140,18 +140,7 @@ the target object file format: struct OutBuffer; -// LDC -enum ARCH -{ - ARCHinvalid = llvm::Triple::UnknownArch, - ARCHx86 = llvm::Triple::x86, - ARCHx86_64 = llvm::Triple::x86_64, - ARCHppc = llvm::Triple::ppc, - ARCHppc_64 = llvm::Triple::ppc64, - ARCHarm = llvm::Triple::arm, - ARCHthumb = llvm::Triple::thumb, -}; - +#if IN_LLVM enum OUTPUTFLAG { OUTPUTFLAGno, @@ -169,6 +158,7 @@ enum OS OSFreeBSD = llvm::Triple::FreeBSD, OSSolaris = llvm::Triple::Solaris, }; +#endif typedef unsigned char ubyte; @@ -191,7 +181,6 @@ struct Param #endif char vtls; // identify thread local variables // KN Start merge conflict - ARCH cpu; // target CPU OS os; // target OS bool is64bit; // generate 64 bit code bool useDeprecated; // allow use of deprecated features diff --git a/dmd/mtype.c b/dmd/mtype.c index 46bfcd52..5c0c246d 100644 --- a/dmd/mtype.c +++ b/dmd/mtype.c @@ -276,12 +276,12 @@ void Type::init() } // set real size and padding - if (global.params.cpu == ARCHx86) + if (global.params.targetTriple.getArch() == llvm::Triple::x86) { REALSIZE = 12; REALPAD = 2; } - else if (global.params.cpu == ARCHx86_64) + else if (global.params.targetTriple.getArch() == llvm::Triple::x86_64) { REALSIZE = 16; REALPAD = 6; @@ -1175,8 +1175,11 @@ unsigned TypeBasic::alignsize() #if IN_LLVM unsigned TypeBasic::memalign(unsigned salign) { - if (global.params.cpu == ARCHx86_64 && (ty == Tfloat80 || ty == Timaginary80)) + if (global.params.targetTriple.getArch() == llvm::Triple::x86_64 && + (ty == Tfloat80 || ty == Timaginary80)) + { return 16; + } return Type::memalign(salign); } #endif diff --git a/dmd2/mars.h b/dmd2/mars.h index 12721330..db17cb5c 100644 --- a/dmd2/mars.h +++ b/dmd2/mars.h @@ -147,17 +147,6 @@ typedef ArrayBase Identifiers; typedef ArrayBase Strings; #if IN_LLVM -enum ARCH -{ - ARCHinvalid = llvm::Triple::UnknownArch, - ARCHx86 = llvm::Triple::x86, - ARCHx86_64 = llvm::Triple::x86_64, - ARCHppc = llvm::Triple::ppc, - ARCHppc_64 = llvm::Triple::ppc64, - ARCHarm = llvm::Triple::arm, - ARCHthumb = llvm::Triple::thumb, -}; - enum OUTPUTFLAG { OUTPUTFLAGno, @@ -200,7 +189,6 @@ struct Param char optimize; // run optimizer #endif char map; // generate linker .map file - ARCH cpu; // target CPU bool is64bit; // generate 64 bit code #if IN_LLVM OS os; diff --git a/dmd2/mtype.c b/dmd2/mtype.c index 361c3ed1..6b8786f1 100644 --- a/dmd2/mtype.c +++ b/dmd2/mtype.c @@ -2923,8 +2923,11 @@ unsigned TypeBasic::alignsize() #if IN_LLVM unsigned TypeBasic::alignment() { - if (global.params.cpu == ARCHx86_64 && (ty == Tfloat80 || ty == Timaginary80)) + if (global.params.targetTriple.getArch() == llvm::Triple::x86_64 && + (ty == Tfloat80 || ty == Timaginary80)) + { return 16; + } return Type::alignment(); } #endif diff --git a/driver/main.cpp b/driver/main.cpp index cc3973c9..e5593b79 100644 --- a/driver/main.cpp +++ b/driver/main.cpp @@ -590,7 +590,6 @@ int main(int argc, char** argv) // Starting with LLVM 3.1 we could also use global.params.targetTriple.isArch64Bit(); global.params.is64bit = gDataLayout->getPointerSizeInBits(ADDRESS_SPACE) == 64; - global.params.cpu = static_cast(global.params.targetTriple.getArch()); global.params.os = static_cast(global.params.targetTriple.getOS()); switch (global.params.targetTriple.getArch()) diff --git a/gen/abi.cpp b/gen/abi.cpp index fb286bf2..346f9a35 100644 --- a/gen/abi.cpp +++ b/gen/abi.cpp @@ -69,13 +69,13 @@ struct UnknownTargetABI : TargetABI TargetABI * TargetABI::getTarget() { - switch(global.params.cpu) + switch (global.params.targetTriple.getArch()) { - case ARCHx86: + case llvm::Triple::x86: return getX86TargetABI(); - case ARCHx86_64: + case llvm::Triple::x86_64: return getX86_64TargetABI(); - case ARCHppc_64: + case llvm::Triple::ppc64: return getPPC64TargetABI(); default: Logger::cout() << "WARNING: Unknown ABI, guessing...\n"; diff --git a/gen/asmstmt.cpp b/gen/asmstmt.cpp index 2c020147..b8aff97b 100644 --- a/gen/asmstmt.cpp +++ b/gen/asmstmt.cpp @@ -159,9 +159,11 @@ Statement *AsmStatement::semantic(Scope *sc) #endif bool err = false; - if ((global.params.cpu != ARCHx86) && (global.params.cpu != ARCHx86_64)) + llvm::Triple const t = global.params.targetTriple; + if (!(t.getArch() == llvm::Triple::x86 || t.getArch() == llvm::Triple::x86_64)) { - error("inline asm is not supported for the \"%s\" architecture", global.params.targetTriple.getArchName().str().c_str()); + error("inline asm is not supported for the \"%s\" architecture", + t.getArchName().str().c_str()); err = true; } if (!global.params.useInlineAsm) @@ -185,9 +187,9 @@ Statement *AsmStatement::semantic(Scope *sc) if (!asmparser) { - if (global.params.cpu == ARCHx86) + if (t.getArch() == llvm::Triple::x86) asmparser = new AsmParserx8632::AsmParser; - else if (global.params.cpu == ARCHx86_64) + else if (t.getArch() == llvm::Triple::x86_64) asmparser = new AsmParserx8664::AsmParser; } diff --git a/gen/complex.cpp b/gen/complex.cpp index b7735579..e85d3e4b 100644 --- a/gen/complex.cpp +++ b/gen/complex.cpp @@ -38,10 +38,16 @@ LLType* DtoComplexBaseType(Type* t) case Tcomplex32: return LLType::getFloatTy(gIR->context()); case Tcomplex64: return LLType::getDoubleTy(gIR->context()); case Tcomplex80: - if ((global.params.cpu == ARCHx86) || (global.params.cpu == ARCHx86_64)) + if ((global.params.targetTriple.getArch() == llvm::Triple::x86) || + global.params.targetTriple.getArch() == llvm::Triple::x86_64) + { return LLType::getX86_FP80Ty(gIR->context()); - else if (global.params.cpu == ARCHppc || global.params.cpu == ARCHppc_64) + } + else if (global.params.targetTriple.getArch() == llvm::Triple::ppc || + global.params.targetTriple.getArch() == llvm::Triple::ppc64) + { return LLType::getPPC_FP128Ty(gIR->context()); + } else return LLType::getDoubleTy(gIR->context()); } diff --git a/gen/naked.cpp b/gen/naked.cpp index 24fac77b..6f13c25a 100644 --- a/gen/naked.cpp +++ b/gen/naked.cpp @@ -227,7 +227,7 @@ void emitABIReturnAsmStmt(IRAsmBlock* asmblock, Loc loc, FuncDeclaration* fdecl) // It should be able to do this for a greater variety of types. // x86 - if (global.params.cpu == ARCHx86) + if (global.params.targetTriple.getArch() == llvm::Triple::x86) { LINK l = fdecl->linkage; assert((l == LINKd || l == LINKc || l == LINKwindows) && "invalid linkage for asm implicit return"); @@ -301,7 +301,7 @@ void emitABIReturnAsmStmt(IRAsmBlock* asmblock, Loc loc, FuncDeclaration* fdecl) } // x86_64 - else if (global.params.cpu == ARCHx86_64) + else if (global.params.targetTriple.getArch() == llvm::Triple::x86_64) { LINK l = fdecl->linkage; /* TODO: Check if this works with extern(Windows), completely untested. diff --git a/gen/tocall.cpp b/gen/tocall.cpp index 6d99ddf7..d3f378fa 100644 --- a/gen/tocall.cpp +++ b/gen/tocall.cpp @@ -65,15 +65,22 @@ llvm::CallingConv::ID DtoCallingConv(Loc loc, LINK l) { //TODO: StdCall is not a good base on Windows due to extra name mangling // applied there - if (global.params.cpu == ARCHx86 || global.params.cpu == ARCHx86_64) - return (global.params.os != OSWindows) ? llvm::CallingConv::X86_StdCall : llvm::CallingConv::C; + if (global.params.targetTriple.getArch() == llvm::Triple::x86 || + global.params.targetTriple.getArch() == llvm::Triple::x86_64) + { + return (global.params.os != OSWindows) ? + llvm::CallingConv::X86_StdCall : llvm::CallingConv::C; + } else return llvm::CallingConv::Fast; } // on the other hand, here, it's exactly what we want!!! TODO: right? // On Windows 64bit, there is only one calling convention! else if (l == LINKwindows) - return global.params.cpu == ARCHx86_64 ? llvm::CallingConv::C : llvm::CallingConv::X86_StdCall; + { + return (global.params.targetTriple.getArch() == llvm::Triple::x86_64) ? + llvm::CallingConv::C : llvm::CallingConv::X86_StdCall; + } else if (l == LINKpascal) return llvm::CallingConv::X86_StdCall; else @@ -92,7 +99,7 @@ DValue* DtoVaArg(Loc& loc, Type* type, Expression* valistArg) if (DtoIsPassedByRef(type)) llt = getPtrToType(llt); // issue a warning for broken va_arg instruction. - if (global.params.cpu != ARCHx86) + if (global.params.targetTriple.getArch() != llvm::Triple::x86) warning(Loc(), "%s: va_arg for C variadic functions is probably broken for anything but x86", loc.toChars()); // done return new DImValue(type, gIR->ir->CreateVAArg(expelem->getLVal(), llt, "tmp")); diff --git a/gen/toir.cpp b/gen/toir.cpp index 99530748..9ce08d40 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -941,7 +941,7 @@ DValue* CallExp::toElem(IRState* p) if (LLValue *argptr = gIR->func()->_argptr) { DtoStore(DtoLoad(argptr), DtoBitCast(arg, getPtrToType(getVoidPtrType()))); return new DImValue(type, arg); - } else if (global.params.cpu == ARCHx86_64) { + } else if (global.params.targetTriple.getArch() == llvm::Triple::x86_64) { LLValue *va_list = DtoAlloca(exp->type->nextOf()); DtoStore(va_list, arg); va_list = DtoBitCast(va_list, getVoidPtrType()); @@ -954,7 +954,8 @@ DValue* CallExp::toElem(IRState* p) } } #if DMDV2 - else if (fndecl->llvmInternal == LLVMva_copy && global.params.cpu == ARCHx86_64) { + else if (fndecl->llvmInternal == LLVMva_copy && + global.params.targetTriple.getArch() == llvm::Triple::x86_64) { if (arguments->dim != 2) { error("va_copy instruction expects 2 arguments"); return NULL; diff --git a/gen/typinf.cpp b/gen/typinf.cpp index e5393058..784cd5ca 100644 --- a/gen/typinf.cpp +++ b/gen/typinf.cpp @@ -719,8 +719,8 @@ void TypeInfoStructDeclaration::llvmDefine() // On x86_64, class TypeInfo_Struct contains 2 additional fields // (m_arg1/m_arg2) which are used for the X86_64 System V ABI varargs // implementation. They are not present on any other cpu/os. - assert((global.params.cpu != ARCHx86_64 && tscd->fields.dim == 11) || - (global.params.cpu == ARCHx86_64 && tscd->fields.dim == 13)); + assert((global.params.targetTriple.getArch() != llvm::Triple::x86_64 && tscd->fields.dim == 11) || + (global.params.targetTriple.getArch() == llvm::Triple::x86_64 && tscd->fields.dim == 13)); //void function(void*) xdtor; b.push_funcptr(sd->dtor); diff --git a/ir/irtype.cpp b/ir/irtype.cpp index 743f0d65..c25f206e 100644 --- a/ir/irtype.cpp +++ b/ir/irtype.cpp @@ -68,6 +68,9 @@ llvm::Type * IrTypeBasic::basic2llvm(Type* t) LLType* t2; llvm::LLVMContext& ctx = llvm::getGlobalContext(); + llvm::Triple::ArchType const a = global.params.targetTriple.getArch(); + bool const anyX86 = (a == llvm::Triple::x86) || (a == llvm::Triple::x86_64); + bool const anyPPC = (a == llvm::Triple::ppc) || (a == llvm::Triple::ppc64); switch(t->ty) { @@ -110,10 +113,10 @@ llvm::Type * IrTypeBasic::basic2llvm(Type* t) case Tfloat80: case Timaginary80: // only x86 has 80bit float - if (global.params.cpu == ARCHx86 || global.params.cpu == ARCHx86_64) + if (anyX86) return llvm::Type::getX86_FP80Ty(ctx); // PPC has a special 128bit float - else if (global.params.cpu == ARCHppc || global.params.cpu == ARCHppc_64) + else if (anyPPC) return llvm::Type::getPPC_FP128Ty(ctx); // other platforms use 64bit reals else @@ -129,11 +132,8 @@ llvm::Type * IrTypeBasic::basic2llvm(Type* t) return getComplexType(ctx, t2); case Tcomplex80: - t2 = (global.params.cpu == ARCHx86 || global.params.cpu == ARCHx86_64) - ? llvm::Type::getX86_FP80Ty(ctx) - : (global.params.cpu == ARCHppc || global.params.cpu == ARCHppc_64) - ? llvm::Type::getPPC_FP128Ty(ctx) - : llvm::Type::getDoubleTy(ctx); + t2 = anyX86 ? llvm::Type::getX86_FP80Ty(ctx) + : (anyPPC ? llvm::Type::getPPC_FP128Ty(ctx) : llvm::Type::getDoubleTy(ctx)); return getComplexType(ctx, t2); case Tbool: From 4e02f41f3166e35a3dd9b0b10cee5d68f62454bf Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Thu, 7 Feb 2013 15:44:48 +0100 Subject: [PATCH 3/7] Factored out output name determination logic. --- driver/linker.cpp | 109 +++++++++++++++++++--------------------------- 1 file changed, 46 insertions(+), 63 deletions(-) diff --git a/driver/linker.cpp b/driver/linker.cpp index 0c8438a5..567dc8a4 100644 --- a/driver/linker.cpp +++ b/driver/linker.cpp @@ -120,6 +120,50 @@ static void CreateDirectoryOnDisk(llvm::StringRef fileName) ////////////////////////////////////////////////////////////////////////////// +static std::string getOutputName(bool const sharedLib) +{ + if (!sharedLib && global.params.exefile) + { + return global.params.exefile; + } + + if (sharedLib && global.params.objname) + { + return global.params.objname; + } + + // Output name is inferred. + std::string result; + + // try root module name + if (Module::rootModule) + result = Module::rootModule->toChars(); + else if (global.params.objfiles->dim) + result = FileName::removeExt(static_cast(global.params.objfiles->data[0])); + else + result = "a.out"; + + if (sharedLib) + { + std::string libExt = std::string(".") + global.dll_ext; + if (!endsWith(result, libExt)) + { + if (global.params.targetTriple.getOS() != llvm::Triple::Win32) + result = "lib" + result + libExt; + else + result.append(libExt); + } + } + else if (global.params.targetTriple.isOSWindows() && !endsWith(result, ".exe")) + { + result.append(".exe"); + } + + return result; +} + +////////////////////////////////////////////////////////////////////////////// + static llvm::sys::Path gExePath; int linkObjToBinaryGcc(bool sharedLib) @@ -147,38 +191,7 @@ int linkObjToBinaryGcc(bool sharedLib) } // output filename - std::string output; - if (!sharedLib && global.params.exefile) - { // explicit - output = global.params.exefile; - } - else if (sharedLib && global.params.objname) - { // explicit - output = global.params.objname; - } - else - { // inferred - // try root module name - if (Module::rootModule) - output = Module::rootModule->toChars(); - else if (global.params.objfiles->dim) - output = FileName::removeExt(static_cast(global.params.objfiles->data[0])); - else - output = "a.out"; - - if (sharedLib) { - std::string libExt = std::string(".") + global.dll_ext; - if (!endsWith(output, libExt)) - { - if (global.params.os != OSWindows) - output = "lib" + output + libExt; - else - output.append(libExt); - } - } else if (global.params.os == OSWindows && !endsWith(output, ".exe")) { - output.append(".exe"); - } - } + std::string output = getOutputName(sharedLib); if (sharedLib) args.push_back("-shared"); @@ -300,38 +313,8 @@ int linkObjToBinaryWin(bool sharedLib) args.push_back("/DLL"); // output filename - std::string output; - if (!sharedLib && global.params.exefile) - { // explicit - output = global.params.exefile; - } - else if (sharedLib && global.params.objname) - { // explicit - output = global.params.objname; - } - else - { // inferred - // try root module name - if (Module::rootModule) - output = Module::rootModule->toChars(); - else if (global.params.objfiles->dim) - output = FileName::removeExt(static_cast(global.params.objfiles->data[0])); - else - output = "a.out"; + std::string output = getOutputName(sharedLib); - if (sharedLib) { - std::string libExt = std::string(".") + global.dll_ext; - if (!endsWith(output, libExt)) - { - if (global.params.os != OSWindows) - output = "lib" + output + libExt; - else - output.append(libExt); - } - } else if (global.params.os == OSWindows && !endsWith(output, ".exe")) { - output.append(".exe"); - } - } args.push_back("/OUT:" + output); // object files From d4b391249d8dafc42ded358b5a53285c8697a6ac Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Thu, 7 Feb 2013 17:13:24 +0100 Subject: [PATCH 4/7] Removed redundant global.params.os field. I hope I have untangled the checks for "native" Windows (Triple::Win32) vs. Windows/MinGW/Cygwin (Triple::isOSWindows) correctly. MinGW needs some default libraries as well, has to be fixed later. --- dmd/mars.h | 1 - dmd/module.c | 6 ++++-- dmd/parse.c | 11 +++++++++-- dmd/statement.c | 4 ++-- dmd2/mars.h | 15 +-------------- dmd2/module.c | 3 ++- dmd2/parse.c | 13 ++++++++++--- dmd2/statement.c | 4 ++-- driver/linker.cpp | 16 +++++++--------- driver/main.cpp | 5 +---- gen/asm-x86.h | 12 ++++++++++-- gen/complex.cpp | 7 +++---- gen/naked.cpp | 18 ++++++++++++------ gen/tocall.cpp | 11 ++++++----- gen/tollvm.cpp | 4 ++-- 15 files changed, 71 insertions(+), 59 deletions(-) diff --git a/dmd/mars.h b/dmd/mars.h index bcaaef93..eb67e031 100644 --- a/dmd/mars.h +++ b/dmd/mars.h @@ -181,7 +181,6 @@ struct Param #endif char vtls; // identify thread local variables // KN Start merge conflict - OS os; // target OS bool is64bit; // generate 64 bit code bool useDeprecated; // allow use of deprecated features bool useAssert; // generate runtime code for assert()'s diff --git a/dmd/module.c b/dmd/module.c index 214f9864..50723083 100644 --- a/dmd/module.c +++ b/dmd/module.c @@ -168,6 +168,7 @@ Module::Module(char *filename, Identifier *ident, int doDocComment, int doHdrGen #endif } +#if IN_LLVM File* Module::buildFilePath(const char* forcename, const char* path, const char* ext) { const char *argobj; @@ -219,7 +220,6 @@ File* Module::buildFilePath(const char* forcename, const char* path, const char* return new File(FileName::forceExt(argobj, ext)); } -// LDC static void check_and_add_output_file(Module* NewMod, const std::string& str) { typedef std::map map_t; @@ -252,7 +252,8 @@ void Module::buildTargetFiles(bool singleObj) else if (global.params.output_s) objfile = Module::buildFilePath(global.params.objname, global.params.objdir, global.s_ext); else - objfile = Module::buildFilePath(global.params.objname, global.params.objdir, global.params.os == OSWindows ? global.obj_ext_alt : global.obj_ext); + objfile = Module::buildFilePath(global.params.objname, global.params.objdir, + global.params.targetTriple.isOSWindows() ? global.obj_ext_alt : global.obj_ext); } if(doDocComment && !docfile) docfile = Module::buildFilePath(global.params.docname, global.params.docdir, global.doc_ext); @@ -285,6 +286,7 @@ void Module::buildTargetFiles(bool singleObj) if (hdrfile) check_and_add_output_file(this, hdrfile->name->str); } +#endif void Module::deleteObjFile() { diff --git a/dmd/parse.c b/dmd/parse.c index 59c15af8..a16d0819 100644 --- a/dmd/parse.c +++ b/dmd/parse.c @@ -671,11 +671,18 @@ enum LINK Parser::parseLinkage() } else if (id == Id::System) { - // LDC we configure target at runtime - if (global.params.os == OSWindows) +#if IN_LLVM + if (global.params.targetTriple.isOSWindows()) link = LINKwindows; else link = LINKc; +#else +#if _WIN32 + link = LINKwindows; +#else + link = LINKc; +#endif +#endif } else { diff --git a/dmd/statement.c b/dmd/statement.c index ea268d15..7d412d45 100644 --- a/dmd/statement.c +++ b/dmd/statement.c @@ -47,9 +47,9 @@ int os_critsecsize() // Return sizeof(RTL_CRITICAL_SECTION) return global.params.is64bit ? 40 : 24; #else - if (global.params.os == OSWindows) + if (global.params.targetTriple.isOSWindows()) return global.params.is64bit ? 40 : 24; - else if (global.params.os == OSFreeBSD) + else if (global.params.targetTriple.getOS() == llvm::Triple::FreeBSD) return sizeof(size_t); else return sizeof(pthread_mutex_t); diff --git a/dmd2/mars.h b/dmd2/mars.h index db17cb5c..bce130fc 100644 --- a/dmd2/mars.h +++ b/dmd2/mars.h @@ -154,17 +154,6 @@ enum OUTPUTFLAG OUTPUTFLAGset // for -output }; -enum OS -{ - OSinvalid = llvm::Triple::UnknownOS, - OSLinux = llvm::Triple::Linux, - OSHaiku = llvm::Triple::Haiku, - OSWindows = llvm::Triple::Win32, - OSMacOSX = llvm::Triple::MacOSX, - OSFreeBSD = llvm::Triple::FreeBSD, - OSSolaris = llvm::Triple::Solaris, -}; - typedef unsigned char ubyte; #endif @@ -190,9 +179,7 @@ struct Param #endif char map; // generate linker .map file bool is64bit; // generate 64 bit code -#if IN_LLVM - OS os; -#else +#if !IN_LLVM char isLinux; // generate code for linux char isOSX; // generate code for Mac OSX char isWindows; // generate code for Windows diff --git a/dmd2/module.c b/dmd2/module.c index e013e274..a3068dce 100644 --- a/dmd2/module.c +++ b/dmd2/module.c @@ -357,7 +357,8 @@ void Module::buildTargetFiles(bool singleObj) if(!objfile) { if (global.params.output_o) - objfile = Module::buildFilePath(global.params.objname, global.params.objdir, global.params.os == OSWindows ? global.obj_ext_alt : global.obj_ext); + objfile = Module::buildFilePath(global.params.objname, global.params.objdir, + global.params.targetTriple.isOSWindows() ? global.obj_ext_alt : global.obj_ext); else if (global.params.output_bc) objfile = Module::buildFilePath(global.params.objname, global.params.objdir, global.bc_ext); else if (global.params.output_ll) diff --git a/dmd2/parse.c b/dmd2/parse.c index de5a3e08..ef36b455 100644 --- a/dmd2/parse.c +++ b/dmd2/parse.c @@ -980,11 +980,18 @@ enum LINK Parser::parseLinkage() } else if (id == Id::System) { - // LDC we configure target at runtime - if (global.params.os == OSWindows) +#if IN_LLVM + if (global.params.targetTriple.isOSWindows()) + link = LINKwindows; + else + link = LINKc; +#else +#if _WIN32 link = LINKwindows; - else +#else link = LINKc; +#endif +#endif } else { diff --git a/dmd2/statement.c b/dmd2/statement.c index df7b319f..6c80d7d8 100644 --- a/dmd2/statement.c +++ b/dmd2/statement.c @@ -44,9 +44,9 @@ int os_critsecsize() // Return sizeof(RTL_CRITICAL_SECTION) return global.params.is64bit ? 40 : 24; #else - if (global.params.os == OSWindows) + if (global.params.targetTriple.isOSWindows()) return global.params.is64bit ? 40 : 24; - else if (global.params.os == OSFreeBSD) + else if (global.params.targetTriple.getOS() == llvm::Triple::FreeBSD) return sizeof(size_t); else return sizeof(pthread_mutex_t); diff --git a/driver/linker.cpp b/driver/linker.cpp index 567dc8a4..26e9496e 100644 --- a/driver/linker.cpp +++ b/driver/linker.cpp @@ -220,32 +220,30 @@ int linkObjToBinaryGcc(bool sharedLib) // default libs bool addSoname = false; - switch(global.params.os) { - case OSLinux: + switch (global.params.targetTriple.getOS()) { + case llvm::Triple::Linux: addSoname = true; args.push_back("-lrt"); // fallthrough - case OSMacOSX: + case llvm::Triple::Darwin: + case llvm::Triple::MacOSX: args.push_back("-ldl"); // fallthrough - case OSFreeBSD: + case llvm::Triple::FreeBSD: addSoname = true; args.push_back("-lpthread"); args.push_back("-lm"); break; - case OSSolaris: + case llvm::Triple::Solaris: args.push_back("-lm"); args.push_back("-lumem"); // solaris TODO break; - case OSWindows: - // FIXME: I'd assume kernel32 etc - break; - default: // OS not yet handled, will probably lead to linker errors. + // FIXME: Win32, MinGW. break; } diff --git a/driver/main.cpp b/driver/main.cpp index e5593b79..f14ef747 100644 --- a/driver/main.cpp +++ b/driver/main.cpp @@ -590,7 +590,6 @@ int main(int argc, char** argv) // Starting with LLVM 3.1 we could also use global.params.targetTriple.isArch64Bit(); global.params.is64bit = gDataLayout->getPointerSizeInBits(ADDRESS_SPACE) == 64; - global.params.os = static_cast(global.params.targetTriple.getOS()); switch (global.params.targetTriple.getArch()) { @@ -681,7 +680,6 @@ int main(int argc, char** argv) VersionCondition::addPredefinedGlobalIdent(global.params.is64bit ? "Win64" : "Win32"); break; case llvm::Triple::MinGW32: - global.params.os = OSWindows; // FIXME: Check source for uses of MinGW32 VersionCondition::addPredefinedGlobalIdent("Windows"); VersionCondition::addPredefinedGlobalIdent(global.params.is64bit ? "Win64" : "Win32"); VersionCondition::addPredefinedGlobalIdent("mingw32"); // For backwards compatibility. @@ -701,7 +699,6 @@ int main(int argc, char** argv) VersionCondition::addPredefinedGlobalIdent("Posix"); break; case llvm::Triple::Darwin: - global.params.os = OSMacOSX; VersionCondition::addPredefinedGlobalIdent("OSX"); VersionCondition::addPredefinedGlobalIdent("darwin"); // For backwards compatibility. VersionCondition::addPredefinedGlobalIdent("Posix"); @@ -746,7 +743,7 @@ int main(int argc, char** argv) #undef XSTR #undef STR - if (global.params.os == OSWindows) { + if (global.params.targetTriple.isOSWindows()) { global.dll_ext = "dll"; global.lib_ext = "lib"; } else { diff --git a/gen/asm-x86.h b/gen/asm-x86.h index 6d8c396b..8d729fb8 100644 --- a/gen/asm-x86.h +++ b/gen/asm-x86.h @@ -1838,8 +1838,12 @@ namespace AsmParserx8664 } // osx needs an extra underscore - if ( global.params.os == OSMacOSX || global.params.os == OSWindows ) + if ( global.params.targetTriple.getOS() == llvm::Triple::MacOSX || + global.params.targetTriple.getOS() == llvm::Triple::Darwin || + global.params.targetTriple.isOSWindows() ) + { insnTemplate << "_"; + } // print out the mangle insnTemplate << vd->mangle(); @@ -2512,8 +2516,12 @@ namespace AsmParserx8664 use_star = false; // simply write out the mangle // on osx and windows, prepend extra _ - if ( global.params.os == OSMacOSX || global.params.os == OSWindows ) + if ( global.params.targetTriple.getOS() == llvm::Triple::MacOSX || + global.params.targetTriple.getOS() == llvm::Triple::Darwin || + global.params.targetTriple.isOSWindows() ) + { insnTemplate << "_"; + } insnTemplate << decl->mangle(); // addOperand2("${", ":c}", Arg_Pointer, e, asmcode); } diff --git a/gen/complex.cpp b/gen/complex.cpp index e85d3e4b..0f6d549d 100644 --- a/gen/complex.cpp +++ b/gen/complex.cpp @@ -38,13 +38,12 @@ LLType* DtoComplexBaseType(Type* t) case Tcomplex32: return LLType::getFloatTy(gIR->context()); case Tcomplex64: return LLType::getDoubleTy(gIR->context()); case Tcomplex80: - if ((global.params.targetTriple.getArch() == llvm::Triple::x86) || - global.params.targetTriple.getArch() == llvm::Triple::x86_64) + llvm::Triple::ArchType const a = global.params.targetTriple.getArch(); + if (a == llvm::Triple::x86 || a == llvm::Triple::x86_64) { return LLType::getX86_FP80Ty(gIR->context()); } - else if (global.params.targetTriple.getArch() == llvm::Triple::ppc || - global.params.targetTriple.getArch() == llvm::Triple::ppc64) + else if (a == llvm::Triple::ppc || a == llvm::Triple::ppc64) { return LLType::getPPC_FP128Ty(gIR->context()); } diff --git a/gen/naked.cpp b/gen/naked.cpp index 6f13c25a..c9e3baf6 100644 --- a/gen/naked.cpp +++ b/gen/naked.cpp @@ -127,9 +127,13 @@ void DtoDefineNakedFunction(FuncDeclaration* fd) const char* mangle = fd->mangle(); std::ostringstream tmpstr; + bool const isWin = global.params.targetTriple.isOSWindows(); + bool const isOSX = (global.params.targetTriple.getOS() == llvm::Triple::Darwin || + global.params.targetTriple.getOS() == llvm::Triple::MacOSX); + // osx is different // also mangling has an extra underscore prefixed - if (global.params.os == OSMacOSX) + if (isOSX) { std::string section = "text"; bool weak = false; @@ -159,10 +163,11 @@ void DtoDefineNakedFunction(FuncDeclaration* fd) { linkage = "weak"; tmpstr << "section\t.gnu.linkonce.t."; - if (global.params.os != OSWindows) + if (!isWin) { tmpstr << mangle << ",\"ax\",@progbits"; - } else + } + else { tmpstr << "_" << mangle << ",\"ax\""; } @@ -171,7 +176,7 @@ void DtoDefineNakedFunction(FuncDeclaration* fd) asmstr << "\t." << section << std::endl; asmstr << "\t.align\t16" << std::endl; - if (global.params.os == OSWindows) + if (isWin) { std::string def = "def"; std::string endef = "endef"; @@ -179,7 +184,8 @@ void DtoDefineNakedFunction(FuncDeclaration* fd) // hard code these two numbers for now since gas ignores .scl and llvm // is defaulting to .type 32 for everything I have seen asmstr << "\t.scl 2; .type 32;\t" << "." << endef << std::endl; - } else + } + else { asmstr << "\t." << linkage << "\t" << mangle << std::endl; asmstr << "\t.type\t" << mangle << ",@function" << std::endl; @@ -199,7 +205,7 @@ void DtoDefineNakedFunction(FuncDeclaration* fd) // emit size after body // llvm does this on linux, but not on osx or Win - if (global.params.os != OSMacOSX && global.params.os != OSWindows) + if (!(isWin || isOSX)) { asmstr << "\t.size\t" << mangle << ", .-" << mangle << std::endl << std::endl; } diff --git a/gen/tocall.cpp b/gen/tocall.cpp index d3f378fa..407517cb 100644 --- a/gen/tocall.cpp +++ b/gen/tocall.cpp @@ -59,17 +59,18 @@ TypeFunction* DtoTypeFunction(DValue* fnval) llvm::CallingConv::ID DtoCallingConv(Loc loc, LINK l) { + llvm::Triple::ArchType const arch = global.params.targetTriple.getArch(); + if (l == LINKc || l == LINKcpp || l == LINKintrinsic) return llvm::CallingConv::C; else if (l == LINKd || l == LINKdefault) { //TODO: StdCall is not a good base on Windows due to extra name mangling // applied there - if (global.params.targetTriple.getArch() == llvm::Triple::x86 || - global.params.targetTriple.getArch() == llvm::Triple::x86_64) + if (arch == llvm::Triple::x86 || arch == llvm::Triple::x86_64) { - return (global.params.os != OSWindows) ? - llvm::CallingConv::X86_StdCall : llvm::CallingConv::C; + return global.params.targetTriple.isOSWindows() ? + llvm::CallingConv::C : llvm::CallingConv::X86_StdCall; } else return llvm::CallingConv::Fast; @@ -78,7 +79,7 @@ llvm::CallingConv::ID DtoCallingConv(Loc loc, LINK l) // On Windows 64bit, there is only one calling convention! else if (l == LINKwindows) { - return (global.params.targetTriple.getArch() == llvm::Triple::x86_64) ? + return (arch == llvm::Triple::x86_64) ? llvm::CallingConv::C : llvm::CallingConv::X86_StdCall; } else if (l == LINKpascal) diff --git a/gen/tollvm.cpp b/gen/tollvm.cpp index 97593570..e301eebd 100644 --- a/gen/tollvm.cpp +++ b/gen/tollvm.cpp @@ -965,7 +965,7 @@ LLStructType* DtoMutexType() // The structures defined here must be the same as in druntime/src/rt/critical.c // Windows - if (global.params.os == OSWindows) + if (global.params.targetTriple.isOSWindows()) { llvm::Type *VoidPtrTy = llvm::Type::getInt8PtrTy(gIR->context()); llvm::Type *Int32Ty = llvm::Type::getInt32Ty(gIR->context()); @@ -993,7 +993,7 @@ LLStructType* DtoMutexType() } // FreeBSD - else if (global.params.os == OSFreeBSD) { + else if (global.params.targetTriple.getOS() == llvm::Triple::FreeBSD) { // Just a pointer return LLStructType::get(gIR->context(), DtoSize_t()); } From 6de735de31731a9393fe02d22d2527eb506789ca Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Thu, 7 Feb 2013 17:58:13 +0100 Subject: [PATCH 5/7] Small cleanup. --- driver/linker.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/driver/linker.cpp b/driver/linker.cpp index 26e9496e..07b62dc7 100644 --- a/driver/linker.cpp +++ b/driver/linker.cpp @@ -20,7 +20,6 @@ #include "mars.h" #include "module.h" -#define NO_COUT_LOGGER #include "gen/logger.h" #include "gen/optimizer.h" #include "gen/programs.h" @@ -39,7 +38,7 @@ llvm::cl::opt quiet("quiet", ////////////////////////////////////////////////////////////////////////////// -bool endsWith(const std::string &str, const std::string &end) +static bool endsWith(const std::string &str, const std::string &end) { return (str.length() >= end.length() && std::equal(end.rbegin(), end.rend(), str.rbegin())); } @@ -166,7 +165,7 @@ static std::string getOutputName(bool const sharedLib) static llvm::sys::Path gExePath; -int linkObjToBinaryGcc(bool sharedLib) +static int linkObjToBinaryGcc(bool sharedLib) { Logger::println("*** Linking executable ***"); @@ -275,7 +274,7 @@ int linkObjToBinaryGcc(bool sharedLib) ////////////////////////////////////////////////////////////////////////////// -int linkObjToBinaryWin(bool sharedLib) +static int linkObjToBinaryWin(bool sharedLib) { Logger::println("*** Linking executable ***"); From 561675376895cb2fa185a0372f6f767ae61a0f02 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Thu, 7 Feb 2013 17:59:09 +0100 Subject: [PATCH 6/7] Consistently use quotes for LLVM includes. --- dmd/declaration.h | 4 ++-- dmd2/declaration.h | 4 ++-- gen/functions.cpp | 2 +- ir/irtypeclass.h | 4 ++-- utils/gen_gccbuiltins.cpp | 12 ++++++------ 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/dmd/declaration.h b/dmd/declaration.h index 1bbef094..ba3a79a7 100644 --- a/dmd/declaration.h +++ b/dmd/declaration.h @@ -20,9 +20,9 @@ #include #include #if LDC_LLVM_VER >= 302 -#include +#include "llvm/DebugInfo.h" #else -#include +#include "llvm/Analysis/DebugInfo.h" #endif #endif diff --git a/dmd2/declaration.h b/dmd2/declaration.h index 30b9161c..ee488b2d 100644 --- a/dmd2/declaration.h +++ b/dmd2/declaration.h @@ -20,9 +20,9 @@ #include #include #if LDC_LLVM_VER >= 302 -#include +#include "llvm/DebugInfo.h" #else -#include +#include "llvm/Analysis/DebugInfo.h" #endif #endif diff --git a/gen/functions.cpp b/gen/functions.cpp index 549f2db3..96bad4fa 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -307,7 +307,7 @@ llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype, ////////////////////////////////////////////////////////////////////////////////////////// -#include +#include "llvm/Support/raw_ostream.h" #include "llvm/Support/SourceMgr.h" #include "llvm/Assembly/Parser.h" diff --git a/ir/irtypeclass.h b/ir/irtypeclass.h index 11b1371a..3a6adc77 100644 --- a/ir/irtypeclass.h +++ b/ir/irtypeclass.h @@ -16,9 +16,9 @@ #include "ir/irtypestruct.h" #if LDC_LLVM_VER >= 303 -#include +#include "llvm/IR/DerivedTypes.h" #else -#include +#include "llvm/DerivedTypes.h" #endif /// diff --git a/utils/gen_gccbuiltins.cpp b/utils/gen_gccbuiltins.cpp index 6cffcce3..5c095acb 100644 --- a/utils/gen_gccbuiltins.cpp +++ b/utils/gen_gccbuiltins.cpp @@ -21,14 +21,14 @@ #include #include -#include +#include "llvm/TableGen/Main.h" #if LDC_LLVM_VER < 302 -#include +#include "llvm/TableGen/TableGenAction.h" #endif -#include -#include -#include -#include +#include "llvm/TableGen/Record.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/PathV1.h" +#include "llvm/ADT/StringRef.h" using namespace std; using namespace llvm; From 0a96aea868cc269fbab920ebfb79666b673790a2 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Thu, 7 Feb 2013 19:36:29 +0100 Subject: [PATCH 7/7] Sort includes according to style guidelines: 1. Main include corresponding to .cpp file, if any. 2. DMD and LDC includes. 3. LLVM includes. 4. System includes. Also updated a few include guards to match the default format. --- driver/cl_options.cpp | 7 +-- driver/cl_options.h | 10 ++-- driver/configfile.cpp | 18 +++---- driver/configfile.h | 10 ++-- driver/ldmd.cpp | 8 ++-- driver/linker.cpp | 21 ++++---- driver/linker.h | 6 +-- driver/main.cpp | 70 +++++++++++++-------------- driver/toobj.cpp | 24 +++++----- driver/toobj.h | 8 +++- gen/aa.cpp | 20 ++++---- gen/aa.h | 11 ++++- gen/abi-generic.h | 9 ++-- gen/abi-ppc64.cpp | 9 ++-- gen/abi-ppc64.h | 8 ++-- gen/abi-x86-64.cpp | 19 ++++---- gen/abi-x86-64.h | 8 ++-- gen/abi-x86.cpp | 10 ++-- gen/abi-x86.h | 7 ++- gen/abi.cpp | 21 ++++---- gen/abi.h | 4 +- gen/arrays.cpp | 22 ++++----- gen/arrays.h | 14 ++++-- gen/binops.cpp | 10 ++-- gen/cl_helpers.cpp | 8 ++-- gen/cl_helpers.h | 7 ++- gen/classes.cpp | 12 ++--- gen/classes.h | 18 ++++--- gen/complex.cpp | 14 +++--- gen/complex.h | 26 +++++++--- gen/declarations.cpp | 11 ++--- gen/dvalue.cpp | 16 ++----- gen/dvalue.h | 2 +- gen/functions.cpp | 46 +++++++++--------- gen/functions.h | 8 ++-- gen/irstate.cpp | 15 +++--- gen/irstate.h | 12 ++--- gen/llvm.h | 6 +-- gen/llvmcompat.cpp | 2 +- gen/llvmhelpers.cpp | 42 ++++++++-------- gen/llvmhelpers.h | 7 ++- gen/logger.cpp | 8 ++-- gen/logger.h | 4 +- gen/module.cpp | 72 +++++++++++++--------------- gen/naked.cpp | 21 ++++---- gen/nested.cpp | 6 +-- gen/optimizer.cpp | 7 +-- gen/passes/SimplifyDRuntimeCalls.cpp | 1 - gen/pragma.cpp | 8 ++-- gen/pragma.h | 6 +-- gen/programs.cpp | 6 +-- gen/rttibuilder.cpp | 7 +-- gen/rttibuilder.h | 21 ++++---- gen/runtime.cpp | 32 ++++++------- gen/runtime.h | 6 +-- gen/statements.cpp | 48 +++++++++---------- gen/structs.cpp | 26 +++++----- gen/structs.h | 32 +++++++++---- gen/tocall.cpp | 17 +++---- gen/todebug.cpp | 25 +++++----- gen/todebug.h | 2 +- gen/toir.cpp | 44 ++++++++--------- gen/tollvm.cpp | 27 +++++------ gen/tollvm.h | 7 ++- gen/typeinf.h | 1 + gen/typinf.cpp | 40 +++++++--------- gen/utils.h | 4 +- gen/warnings.cpp | 5 +- gen/warnings.h | 9 ++-- ir/ir.h | 5 +- ir/irdsymbol.cpp | 3 +- ir/irfunction.cpp | 1 - ir/irfunction.h | 5 +- ir/irfuncty.cpp | 4 +- ir/irlandingpad.cpp | 8 ++-- ir/irlandingpad.h | 3 +- ir/irmodule.cpp | 2 +- ir/irstruct.cpp | 10 ++-- ir/irstruct.h | 3 +- utils/gen_gccbuiltins.cpp | 22 ++++----- 80 files changed, 550 insertions(+), 614 deletions(-) diff --git a/driver/cl_options.cpp b/driver/cl_options.cpp index c10e34c3..dda40e86 100644 --- a/driver/cl_options.cpp +++ b/driver/cl_options.cpp @@ -9,7 +9,8 @@ #include "driver/cl_options.h" #include "gen/cl_helpers.h" - +#include "gen/logger.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Target/TargetMachine.h" #if LDC_LLVM_VER >= 303 #include "llvm/IR/DataLayout.h" @@ -19,10 +20,6 @@ #include "llvm/Target/TargetData.h" #endif -#include "gen/logger.h" - -#include "llvm/Support/CommandLine.h" - namespace opts { // Positional options first, in order: diff --git a/driver/cl_options.h b/driver/cl_options.h index ca9b657f..605b21e3 100644 --- a/driver/cl_options.h +++ b/driver/cl_options.h @@ -12,17 +12,15 @@ // //===----------------------------------------------------------------------===// -#ifndef LDC_CL_OPTIONS_H -#define LDC_CL_OPTIONS_H +#ifndef LDC_DRIVER_CL_OPTIONS_H +#define LDC_DRIVER_CL_OPTIONS_H #include "mars.h" - +#include "llvm/Support/CodeGen.h" +#include "llvm/Support/CommandLine.h" #include #include -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/CodeGen.h" - namespace opts { namespace cl = llvm::cl; diff --git a/driver/configfile.cpp b/driver/configfile.cpp index 1af2f525..af3431f0 100644 --- a/driver/configfile.cpp +++ b/driver/configfile.cpp @@ -7,19 +7,15 @@ // //===----------------------------------------------------------------------===// -#include -#include -#include -#include - +#include "driver/configfile.h" +#include "mars.h" +#include "libconfig.h++" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" - -#include "libconfig.h++" - -#include "driver/configfile.h" - -#include "mars.h" +#include +#include +#include +#include namespace sys = llvm::sys; diff --git a/driver/configfile.h b/driver/configfile.h index 9465a877..391e9f8c 100644 --- a/driver/configfile.h +++ b/driver/configfile.h @@ -11,11 +11,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LDC_CONF_CONFIGFILE_H -#define LDC_CONF_CONFIGFILE_H +#ifndef LDC_DRIVER_CONFIGFILE_H +#define LDC_DRIVER_CONFIGFILE_H -#include #include +#include + +namespace llvm { namespace sys { class Path; } } namespace libconfig { @@ -48,4 +50,4 @@ private: s_vector switches; }; -#endif // LDC_CONF_CONFIGFILE_H +#endif // LDC_DRIVER_CONFIGFILE_H diff --git a/driver/ldmd.cpp b/driver/ldmd.cpp index 495aa17b..498d1032 100644 --- a/driver/ldmd.cpp +++ b/driver/ldmd.cpp @@ -48,6 +48,10 @@ # error "Please define LDC_EXE_NAME to the name of the LDC executable to use." #endif +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/Program.h" +#include "llvm/Support/SystemUtils.h" +#include "llvm/Support/raw_ostream.h" #include #include #include @@ -56,10 +60,6 @@ #include #include #include -#include "llvm/Support/FileSystem.h" -#include "llvm/Support/Program.h" -#include "llvm/Support/SystemUtils.h" -#include "llvm/Support/raw_ostream.h" #ifdef HAVE_SC_ARG_MAX # include diff --git a/driver/linker.cpp b/driver/linker.cpp index 07b62dc7..31351fc1 100644 --- a/driver/linker.cpp +++ b/driver/linker.cpp @@ -7,26 +7,23 @@ // //===----------------------------------------------------------------------===// +#include "driver/linker.h" +#include "mars.h" +#include "module.h" +#include "root.h" +#include "driver/cl_options.h" #include "gen/llvm.h" -#include "llvm/Linker.h" +#include "gen/logger.h" +#include "gen/optimizer.h" +#include "gen/programs.h" #include "llvm/ADT/Triple.h" +#include "llvm/Linker.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Program.h" #if _WIN32 #include "llvm/Support/SystemUtils.h" #endif -#include "root.h" -#include "mars.h" -#include "module.h" - -#include "gen/logger.h" -#include "gen/optimizer.h" -#include "gen/programs.h" - -#include "driver/linker.h" -#include "driver/cl_options.h" - ////////////////////////////////////////////////////////////////////////////// // Is this useful? diff --git a/driver/linker.h b/driver/linker.h index d5220224..404c3ddc 100644 --- a/driver/linker.h +++ b/driver/linker.h @@ -12,8 +12,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LDC_GEN_LINKER_H -#define LDC_GEN_LINKER_H +#ifndef LDC_DRIVER_LINKER_H +#define LDC_DRIVER_LINKER_H #include "llvm/Support/CommandLine.h" #include @@ -55,4 +55,4 @@ void deleteExecutable(); */ int runExecutable(); -#endif // LDC_GEN_LINKER_H +#endif // LDC_DRIVER_LINKER_H diff --git a/driver/main.cpp b/driver/main.cpp index f14ef747..babbac54 100644 --- a/driver/main.cpp +++ b/driver/main.cpp @@ -7,9 +7,33 @@ // //===----------------------------------------------------------------------===// -#include "gen/llvmcompat.h" +#include "id.h" +#include "json.h" +#include "mars.h" +#include "module.h" +#include "mtype.h" +#include "rmem.h" +#include "root.h" +#include "driver/cl_options.h" +#include "driver/configfile.h" +#include "driver/linker.h" +#include "driver/toobj.h" +#include "gen/cl_helpers.h" +#include "gen/irstate.h" +#include "gen/linkage.h" #include "gen/llvm.h" +#include "gen/llvmcompat.h" +#include "gen/logger.h" +#include "gen/metadata.h" +#include "gen/optimizer.h" +#include "gen/passes/Passes.h" #include "llvm/Linker.h" +#include "llvm/MC/SubtargetFeature.h" +#include "llvm/Support/Host.h" +#include "llvm/Support/TargetRegistry.h" +#include "llvm/Support/TargetSelect.h" +#include "llvm/Target/TargetMachine.h" +#include "llvm/Target/TargetOptions.h" #if LDC_LLVM_VER >= 303 #include "llvm/LinkAllIR.h" #include "llvm/IR/LLVMContext.h" @@ -17,54 +41,26 @@ #include "llvm/LinkAllVMCore.h" #include "llvm/LLVMContext.h" #endif -#include "llvm/Target/TargetMachine.h" -#include "llvm/Target/TargetOptions.h" -#include "llvm/Support/TargetSelect.h" -#include "llvm/Support/TargetRegistry.h" -#include "llvm/Support/Host.h" -#include "llvm/MC/SubtargetFeature.h" - -#include -#include #include #include - -#include "rmem.h" -#include "root.h" +#include +#include +#if POSIX +#include +#elif _WIN32 +#include +#endif // stricmp #if __GNUC__ && !_WIN32 #include "gnuc.h" #endif -#include "mars.h" -#include "module.h" -#include "mtype.h" -#include "id.h" +// Needs Type already declared. #include "cond.h" -#include "json.h" -#include "gen/logger.h" -#include "gen/linkage.h" -#include "gen/irstate.h" -#include "gen/optimizer.h" -#include "gen/metadata.h" -#include "gen/passes/Passes.h" - -#include "driver/linker.h" -#include "driver/cl_options.h" -#include "gen/cl_helpers.h" using namespace opts; -#include "driver/configfile.h" -#include "driver/toobj.h" - -#if POSIX -#include -#elif _WIN32 -#include -#endif - extern void getenv_setargv(const char *envvar, int *pargc, char** *pargv); extern void backend_init(); extern void backend_term(); diff --git a/driver/toobj.cpp b/driver/toobj.cpp index d19df8d5..2b455c04 100644 --- a/driver/toobj.cpp +++ b/driver/toobj.cpp @@ -7,26 +7,24 @@ // //===----------------------------------------------------------------------===// -#include -#include - +#include "driver/toobj.h" +#include "gen/irstate.h" +#include "gen/logger.h" +#include "gen/optimizer.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Bitcode/ReaderWriter.h" +#include "llvm/PassManager.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/FormattedStream.h" +#include "llvm/Support/Program.h" +#include "llvm/Target/TargetMachine.h" #if LDC_LLVM_VER >= 303 #include "llvm/IR/Module.h" #else #include "llvm/Module.h" #endif -#include "llvm/PassManager.h" -#include "llvm/Support/Program.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/FormattedStream.h" -#include "llvm/Target/TargetMachine.h" - -#include "gen/irstate.h" -#include "gen/logger.h" -#include "gen/optimizer.h" - +#include +#include // fwd decl void emit_file(llvm::TargetMachine &Target, llvm::Module& m, llvm::raw_fd_ostream& Out, diff --git a/driver/toobj.h b/driver/toobj.h index bae370d8..03b9ddb8 100644 --- a/driver/toobj.h +++ b/driver/toobj.h @@ -11,8 +11,12 @@ // //===----------------------------------------------------------------------===// -#ifndef LDC_GEN_TOOBJ_H -#define LDC_GEN_TOOBJ_H +#ifndef LDC_DRIVER_TOOBJ_H +#define LDC_DRIVER_TOOBJ_H + +#include + +namespace llvm { class Module; } void writeModule(llvm::Module* m, std::string filename); diff --git a/gen/aa.cpp b/gen/aa.cpp index bc4d6927..a88b108e 100644 --- a/gen/aa.cpp +++ b/gen/aa.cpp @@ -7,20 +7,18 @@ // //===----------------------------------------------------------------------===// -#include "gen/llvm.h" - -#include "mtype.h" -#include "module.h" -#include "declaration.h" -#include "aggregate.h" - #include "gen/aa.h" -#include "gen/runtime.h" -#include "gen/tollvm.h" +#include "aggregate.h" +#include "declaration.h" +#include "module.h" +#include "mtype.h" +#include "gen/dvalue.h" +#include "gen/irstate.h" +#include "gen/llvm.h" #include "gen/llvmhelpers.h" #include "gen/logger.h" -#include "gen/irstate.h" -#include "gen/dvalue.h" +#include "gen/runtime.h" +#include "gen/tollvm.h" #include "ir/irmodule.h" #if DMDV2 diff --git a/gen/aa.h b/gen/aa.h index 0154f302..c0d5929c 100644 --- a/gen/aa.h +++ b/gen/aa.h @@ -11,13 +11,20 @@ // //===----------------------------------------------------------------------===// - #ifndef LDC_GEN_AA_H #define LDC_GEN_AA_H +#include "lexer.h" + +enum TOK; +struct DValue; +struct Loc; +struct Type; +namespace llvm { class Value; } + DValue* DtoAAIndex(Loc& loc, Type* type, DValue* aa, DValue* key, bool lvalue); DValue* DtoAAIn(Loc& loc, Type* type, DValue* aa, DValue* key); DValue* DtoAARemove(Loc& loc, DValue* aa, DValue* key); -LLValue* DtoAAEquals(Loc& loc, TOK op, DValue* l, DValue* r); +llvm::Value* DtoAAEquals(Loc& loc, TOK op, DValue* l, DValue* r); #endif // LDC_GEN_AA_H diff --git a/gen/abi-generic.h b/gen/abi-generic.h index b77fca44..995594c3 100644 --- a/gen/abi-generic.h +++ b/gen/abi-generic.h @@ -11,12 +11,15 @@ // //===----------------------------------------------------------------------===// -#ifndef LDC_GEN_ABI_GENERIC -#define LDC_GEN_ABI_GENERIC +#ifndef LDC_GEN_ABI_GENERIC_H +#define LDC_GEN_ABI_GENERIC_H +#include "gen/abi.h" +#include "gen/irstate.h" #include "gen/llvmhelpers.h" -#include "gen/tollvm.h" +#include "gen/logger.h" #include "gen/structs.h" +#include "gen/tollvm.h" /// Removes padding fields for (non-union-containing!) structs struct RemoveStructPadding : ABIRewrite { diff --git a/gen/abi-ppc64.cpp b/gen/abi-ppc64.cpp index 16e641fa..9d0fbc61 100644 --- a/gen/abi-ppc64.cpp +++ b/gen/abi-ppc64.cpp @@ -12,11 +12,12 @@ // //===----------------------------------------------------------------------===// +#include "gen/abi-ppc64.h" #include "gen/abi.h" -#include "gen/irstate.h" -#include "gen/tollvm.h" -#include "gen/llvmhelpers.h" #include "gen/dvalue.h" +#include "gen/irstate.h" +#include "gen/llvmhelpers.h" +#include "gen/tollvm.h" struct PPC64TargetABI : TargetABI { @@ -56,4 +57,4 @@ struct PPC64TargetABI : TargetABI { TargetABI* getPPC64TargetABI() { return new PPC64TargetABI(); -} \ No newline at end of file +} diff --git a/gen/abi-ppc64.h b/gen/abi-ppc64.h index de4e989a..367701af 100644 --- a/gen/abi-ppc64.h +++ b/gen/abi-ppc64.h @@ -11,13 +11,11 @@ // //===----------------------------------------------------------------------===// -#ifndef __LDC_GEN_ABI_PPC64_H__ -#define __LDC_GEN_ABI_PPC64_H__ - -#include "gen/abi.h" +#ifndef LDC_GEN_ABI_PPC64_H +#define LDC_GEN_ABI_PPC64_H +struct TargetABI; TargetABI* getPPC64TargetABI(); - #endif diff --git a/gen/abi-x86-64.cpp b/gen/abi-x86-64.cpp index fb11b248..4e902b64 100644 --- a/gen/abi-x86-64.cpp +++ b/gen/abi-x86-64.cpp @@ -43,21 +43,20 @@ // //===----------------------------------------------------------------------===// -#include "mtype.h" -#include "declaration.h" +#include "gen/abi-x86-64.h" #include "aggregate.h" - +#include "declaration.h" +#include "mtype.h" +#include "gen/abi-generic.h" +#include "gen/abi-x86-64.h" +#include "gen/abi.h" +#include "gen/dvalue.h" #include "gen/irstate.h" #include "gen/llvm.h" -#include "gen/tollvm.h" -#include "gen/logger.h" -#include "gen/dvalue.h" #include "gen/llvmhelpers.h" -#include "gen/abi.h" -#include "gen/abi-x86-64.h" -#include "gen/abi-generic.h" +#include "gen/logger.h" +#include "gen/tollvm.h" #include "ir/irfunction.h" - #include #include #include diff --git a/gen/abi-x86-64.h b/gen/abi-x86-64.h index 8ce2376a..fc4a10b9 100644 --- a/gen/abi-x86-64.h +++ b/gen/abi-x86-64.h @@ -11,13 +11,11 @@ // //===----------------------------------------------------------------------===// -#ifndef __LDC_GEN_ABI_X86_64_H__ -#define __LDC_GEN_ABI_X86_64_H__ - -#include "gen/abi.h" +#ifndef LDC_GEN_ABI_X86_64_H +#define LDC_GEN_ABI_X86_64_H +struct TargetABI; TargetABI* getX86_64TargetABI(); - #endif diff --git a/gen/abi-x86.cpp b/gen/abi-x86.cpp index 8f7c02d3..59edcfa5 100644 --- a/gen/abi-x86.cpp +++ b/gen/abi-x86.cpp @@ -8,16 +8,14 @@ //===----------------------------------------------------------------------===// #include "gen/llvm.h" - #include "mars.h" - +#include "gen/abi-generic.h" +#include "gen/abi.h" +#include "gen/dvalue.h" #include "gen/irstate.h" #include "gen/llvmhelpers.h" -#include "gen/tollvm.h" -#include "gen/abi.h" #include "gen/logger.h" -#include "gen/dvalue.h" -#include "gen/abi-generic.h" +#include "gen/tollvm.h" #include "ir/irfunction.h" #include "ir/irfuncty.h" diff --git a/gen/abi-x86.h b/gen/abi-x86.h index 70638e04..bd3312e3 100644 --- a/gen/abi-x86.h +++ b/gen/abi-x86.h @@ -11,11 +11,10 @@ // //===----------------------------------------------------------------------===// -#ifndef __LDC_GEN_ABI_X86_H__ -#define __LDC_GEN_ABI_X86_H__ - -#include "gen/abi.h" +#ifndef LDC_GEN_ABI_X86_H +#define LDC_GEN_ABI_X86_H +struct TargetABI; TargetABI* getX86TargetABI(); #endif diff --git a/gen/abi.cpp b/gen/abi.cpp index 346f9a35..9ec247a3 100644 --- a/gen/abi.cpp +++ b/gen/abi.cpp @@ -7,24 +7,21 @@ // //===----------------------------------------------------------------------===// -#include "gen/llvm.h" - -#include - -#include "mars.h" - -#include "gen/irstate.h" -#include "gen/llvmhelpers.h" -#include "gen/tollvm.h" #include "gen/abi.h" -#include "gen/logger.h" -#include "gen/dvalue.h" +#include "mars.h" #include "gen/abi-generic.h" #include "gen/abi-ppc64.h" -#include "gen/abi-x86.h" #include "gen/abi-x86-64.h" +#include "gen/abi-x86.h" +#include "gen/dvalue.h" +#include "gen/irstate.h" +#include "gen/llvm.h" +#include "gen/llvmhelpers.h" +#include "gen/logger.h" +#include "gen/tollvm.h" #include "ir/irfunction.h" #include "ir/irfuncty.h" +#include ////////////////////////////////////////////////////////////////////////////// diff --git a/gen/abi.h b/gen/abi.h index da15be9e..ee482054 100644 --- a/gen/abi.h +++ b/gen/abi.h @@ -14,8 +14,8 @@ // //===----------------------------------------------------------------------===// -#ifndef __LDC_GEN_ABI_H__ -#define __LDC_GEN_ABI_H__ +#ifndef LDC_GEN_ABI_H +#define LDC_GEN_ABI_H #include diff --git a/gen/arrays.cpp b/gen/arrays.cpp index 30a38f3f..609b5683 100644 --- a/gen/arrays.cpp +++ b/gen/arrays.cpp @@ -7,22 +7,20 @@ // //===----------------------------------------------------------------------===// -#include "gen/llvm.h" - -#include "mtype.h" -#include "module.h" -#include "dsymbol.h" +#include "gen/arrays.h" #include "aggregate.h" #include "declaration.h" +#include "dsymbol.h" #include "init.h" - -#include "gen/irstate.h" -#include "gen/tollvm.h" -#include "gen/llvmhelpers.h" -#include "gen/arrays.h" -#include "gen/runtime.h" -#include "gen/logger.h" +#include "module.h" +#include "mtype.h" #include "gen/dvalue.h" +#include "gen/irstate.h" +#include "gen/llvm.h" +#include "gen/llvmhelpers.h" +#include "gen/logger.h" +#include "gen/runtime.h" +#include "gen/tollvm.h" #include "ir/irmodule.h" #include "ir/irtypestruct.h" diff --git a/gen/arrays.h b/gen/arrays.h index 4d2d18a3..d32ac898 100644 --- a/gen/arrays.h +++ b/gen/arrays.h @@ -11,12 +11,18 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVMC_GEN_ARRAYS_H -#define LLVMC_GEN_ARRAYS_H +#ifndef LDC_GEN_ARRAYS_H +#define LDC_GEN_ARRAYS_H + +#include "lexer.h" +#include "gen/llvm.h" struct ArrayInitializer; - struct DSliceValue; +struct DValue; +struct Expression; +struct Loc; +struct Type; llvm::StructType* DtoArrayType(Type* arrayTy); llvm::StructType* DtoArrayType(LLType* elemTy); @@ -69,4 +75,4 @@ DValue* DtoCastArray(Loc& loc, DValue* val, Type* to); // generates an array bounds check void DtoArrayBoundsCheck(Loc& loc, DValue* arr, DValue* index, DValue* lowerBound = 0); -#endif // LLVMC_GEN_ARRAYS_H +#endif // LDC_GEN_ARRAYS_H diff --git a/gen/binops.cpp b/gen/binops.cpp index d4eeeb15..bcf32c76 100644 --- a/gen/binops.cpp +++ b/gen/binops.cpp @@ -8,15 +8,13 @@ //===----------------------------------------------------------------------===// #include "gen/llvm.h" - #include "declaration.h" - -#include "gen/irstate.h" -#include "gen/tollvm.h" -#include "gen/dvalue.h" -#include "gen/logger.h" #include "gen/complex.h" +#include "gen/dvalue.h" +#include "gen/irstate.h" #include "gen/llvmhelpers.h" +#include "gen/logger.h" +#include "gen/tollvm.h" ////////////////////////////////////////////////////////////////////////////// diff --git a/gen/cl_helpers.cpp b/gen/cl_helpers.cpp index dcfe59dc..1fba45a3 100644 --- a/gen/cl_helpers.cpp +++ b/gen/cl_helpers.cpp @@ -8,15 +8,13 @@ //===----------------------------------------------------------------------===// #include "gen/cl_helpers.h" - #include "mars.h" -#include "root.h" #include "rmem.h" - -#include // isupper, tolower +#include "root.h" #include -#include +#include // isupper, tolower #include +#include namespace opts { diff --git a/gen/cl_helpers.h b/gen/cl_helpers.h index 06bd195d..3870119c 100644 --- a/gen/cl_helpers.h +++ b/gen/cl_helpers.h @@ -12,13 +12,12 @@ // //===----------------------------------------------------------------------===// -#ifndef LDC_CL_HELPERS_H -#define LDC_CL_HELPERS_H - -#include +#ifndef LDC_GEN_CL_HELPERS_H +#define LDC_GEN_CL_HELPERS_H #include "llvm/Support/CommandLine.h" #include "llvm/Support/Compiler.h" +#include template struct ArrayBase; typedef ArrayBase Strings; diff --git a/gen/classes.cpp b/gen/classes.cpp index d7374797..cf3535d9 100644 --- a/gen/classes.cpp +++ b/gen/classes.cpp @@ -8,18 +8,15 @@ //===----------------------------------------------------------------------===// #include "gen/llvm.h" - -#include "mtype.h" #include "aggregate.h" -#include "init.h" #include "declaration.h" - -#include "gen/dvalue.h" -#include "gen/irstate.h" - +#include "init.h" +#include "mtype.h" #include "gen/arrays.h" #include "gen/classes.h" +#include "gen/dvalue.h" #include "gen/functions.h" +#include "gen/irstate.h" #include "gen/llvmhelpers.h" #include "gen/logger.h" #include "gen/nested.h" @@ -28,7 +25,6 @@ #include "gen/structs.h" #include "gen/tollvm.h" #include "gen/utils.h" - #include "ir/irstruct.h" #include "ir/irtypeclass.h" diff --git a/gen/classes.h b/gen/classes.h index 27be1b99..a451443e 100644 --- a/gen/classes.h +++ b/gen/classes.h @@ -17,6 +17,12 @@ #include "gen/structs.h" +struct ClassDeclaration; +struct CtorDeclaration; +struct FuncDeclaration; +struct NewExp; +struct TypeClass; + /// Resolves the llvm type for a class declaration void DtoResolveClass(ClassDeclaration* cd); @@ -31,12 +37,12 @@ void DtoDefineClass(ClassDeclaration* cd); /// Builds the initializer of cd's ClassInfo. /// FIXME: this should be put into IrStruct and eventually IrClass. -LLConstant* DtoDefineClassInfo(ClassDeclaration* cd); +llvm::Constant* DtoDefineClassInfo(ClassDeclaration* cd); DValue* DtoNewClass(Loc loc, TypeClass* type, NewExp* newexp); -void DtoInitClass(TypeClass* tc, LLValue* dst); -DValue* DtoCallClassCtor(TypeClass* type, CtorDeclaration* ctor, Array* arguments, LLValue* mem); -void DtoFinalizeClass(LLValue* inst); +void DtoInitClass(TypeClass* tc, llvm::Value* dst); +DValue* DtoCallClassCtor(TypeClass* type, CtorDeclaration* ctor, Array* arguments, llvm::Value* mem); +void DtoFinalizeClass(llvm::Value* inst); DValue* DtoCastClass(DValue* val, Type* to); DValue* DtoDynamicCastObject(DValue* val, Type* to); @@ -44,8 +50,8 @@ DValue* DtoDynamicCastObject(DValue* val, Type* to); DValue* DtoCastInterfaceToObject(DValue* val, Type* to); DValue* DtoDynamicCastInterface(DValue* val, Type* to); -LLValue* DtoIndexClass(LLValue* src, ClassDeclaration* sd, VarDeclaration* vd); +llvm::Value* DtoIndexClass(llvm::Value* src, ClassDeclaration* sd, VarDeclaration* vd); -LLValue* DtoVirtualFunctionPointer(DValue* inst, FuncDeclaration* fdecl, char* name); +llvm::Value* DtoVirtualFunctionPointer(DValue* inst, FuncDeclaration* fdecl, char* name); #endif diff --git a/gen/complex.cpp b/gen/complex.cpp index 0f6d549d..f8875945 100644 --- a/gen/complex.cpp +++ b/gen/complex.cpp @@ -7,17 +7,15 @@ // //===----------------------------------------------------------------------===// -#include "gen/llvm.h" - -#include "mtype.h" -#include "declaration.h" - #include "gen/complex.h" -#include "gen/tollvm.h" -#include "gen/llvmhelpers.h" -#include "gen/irstate.h" +#include "declaration.h" +#include "mtype.h" #include "gen/dvalue.h" +#include "gen/irstate.h" +#include "gen/llvm.h" +#include "gen/llvmhelpers.h" #include "gen/logger.h" +#include "gen/tollvm.h" ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/gen/complex.h b/gen/complex.h index 046d8c66..4e1eaf1e 100644 --- a/gen/complex.h +++ b/gen/complex.h @@ -14,19 +14,33 @@ #ifndef LDC_GEN_COMPLEX_H #define LDC_GEN_COMPLEX_H +#include "lexer.h" +#include "longdouble.h" + +struct DValue; +struct Loc; +struct Type; +namespace llvm +{ + class Constant; + class StructType; + class Type; + class Value; +} + llvm::StructType* DtoComplexType(Type* t); -LLType* DtoComplexBaseType(Type* t); +llvm::Type* DtoComplexBaseType(Type* t); -LLConstant* DtoConstComplex(Type* t, longdouble re, longdouble im); +llvm::Constant* DtoConstComplex(Type* t, longdouble re, longdouble im); -LLConstant* DtoComplexShuffleMask(unsigned a, unsigned b); +llvm::Constant* DtoComplexShuffleMask(unsigned a, unsigned b); DValue* DtoComplex(Loc& loc, Type* to, DValue* val); -void DtoComplexSet(LLValue* c, LLValue* re, LLValue* im); +void DtoComplexSet(llvm::Value* c, llvm::Value* re, llvm::Value* im); void DtoGetComplexParts(Loc& loc, Type* to, DValue* c, DValue*& re, DValue*& im); -void DtoGetComplexParts(Loc& loc, Type* to, DValue* c, LLValue*& re, LLValue*& im); +void DtoGetComplexParts(Loc& loc, Type* to, DValue* c, llvm::Value*& re, llvm::Value*& im); DValue* DtoComplexAdd(Loc& loc, Type* type, DValue* lhs, DValue* rhs); DValue* DtoComplexSub(Loc& loc, Type* type, DValue* lhs, DValue* rhs); @@ -35,7 +49,7 @@ DValue* DtoComplexDiv(Loc& loc, Type* type, DValue* lhs, DValue* rhs); DValue* DtoComplexRem(Loc& loc, Type* type, DValue* lhs, DValue* rhs); DValue* DtoComplexNeg(Loc& loc, Type* type, DValue* val); -LLValue* DtoComplexEquals(Loc& loc, TOK op, DValue* lhs, DValue* rhs); +llvm::Value* DtoComplexEquals(Loc& loc, TOK op, DValue* lhs, DValue* rhs); DValue* DtoCastComplex(Loc& loc, DValue* val, Type* to); diff --git a/gen/declarations.cpp b/gen/declarations.cpp index 88b62a40..9de7b982 100644 --- a/gen/declarations.cpp +++ b/gen/declarations.cpp @@ -7,26 +7,23 @@ // //===----------------------------------------------------------------------===// -#include "gen/llvm.h" - #include "aggregate.h" #include "declaration.h" #include "enum.h" #include "id.h" +#include "init.h" #include "rmem.h" #include "template.h" -#include "init.h" - #include "gen/irstate.h" -#include "gen/tollvm.h" +#include "gen/llvm.h" #include "gen/llvmhelpers.h" #include "gen/logger.h" #include "gen/todebug.h" - +#include "gen/tollvm.h" #include "ir/ir.h" -#include "ir/irvar.h" #include "ir/irtype.h" #include "ir/irtypestruct.h" +#include "ir/irvar.h" /* ================================================================== */ diff --git a/gen/dvalue.cpp b/gen/dvalue.cpp index 9da16448..160bb4ce 100644 --- a/gen/dvalue.cpp +++ b/gen/dvalue.cpp @@ -7,16 +7,13 @@ // //===----------------------------------------------------------------------===// -#include "gen/llvm.h" - -#include "gen/tollvm.h" -#include "gen/irstate.h" -#include "gen/logger.h" #include "gen/dvalue.h" -#include "gen/llvmhelpers.h" - #include "declaration.h" - +#include "gen/irstate.h" +#include "gen/llvm.h" +#include "gen/llvmhelpers.h" +#include "gen/logger.h" +#include "gen/tollvm.h" ///////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////// @@ -95,6 +92,3 @@ LLValue* DConstValue::getRVal() assert(c); return c; } - -///////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/gen/dvalue.h b/gen/dvalue.h index 1e91bc82..03856249 100644 --- a/gen/dvalue.h +++ b/gen/dvalue.h @@ -17,8 +17,8 @@ #ifndef LDC_GEN_DVALUE_H #define LDC_GEN_DVALUE_H -#include #include "root.h" +#include struct Type; struct Dsymbol; diff --git a/gen/functions.cpp b/gen/functions.cpp index 96bad4fa..7bac905e 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -7,36 +7,34 @@ // //===----------------------------------------------------------------------===// +#include "gen/functions.h" +#include "aggregate.h" +#include "declaration.h" +#include "id.h" +#include "init.h" +#include "module.h" +#include "mtype.h" +#include "statement.h" +#include "template.h" +#include "gen/abi.h" +#include "gen/arrays.h" +#include "gen/classes.h" +#include "gen/dvalue.h" +#include "gen/irstate.h" #include "gen/llvm.h" -#include "llvm/Support/CFG.h" +#include "gen/llvmhelpers.h" +#include "gen/logger.h" +#include "gen/nested.h" +#include "gen/pragma.h" +#include "gen/runtime.h" +#include "gen/todebug.h" +#include "gen/tollvm.h" #if LDC_LLVM_VER >= 303 #include "llvm/IR/Intrinsics.h" #else #include "llvm/Intrinsics.h" #endif - -#include "mtype.h" -#include "aggregate.h" -#include "init.h" -#include "declaration.h" -#include "template.h" -#include "module.h" -#include "statement.h" -#include "id.h" - -#include "gen/irstate.h" -#include "gen/tollvm.h" -#include "gen/llvmhelpers.h" -#include "gen/runtime.h" -#include "gen/arrays.h" -#include "gen/logger.h" -#include "gen/functions.h" -#include "gen/todebug.h" -#include "gen/classes.h" -#include "gen/dvalue.h" -#include "gen/abi.h" -#include "gen/nested.h" -#include "gen/pragma.h" +#include "llvm/Support/CFG.h" #include #if LDC_LLVM_VER < 302 diff --git a/gen/functions.h b/gen/functions.h index 0be3a73c..f2a2c403 100644 --- a/gen/functions.h +++ b/gen/functions.h @@ -16,13 +16,15 @@ #include "mars.h" +struct DValue; +struct Expression; struct FuncDeclaration; -struct Type; - struct IRAsmBlock; - +struct Parameter; +struct Type; namespace llvm { + class FunctionType; class Value; } diff --git a/gen/irstate.cpp b/gen/irstate.cpp index 20748c9d..b81c9e1b 100644 --- a/gen/irstate.cpp +++ b/gen/irstate.cpp @@ -7,16 +7,13 @@ // //===----------------------------------------------------------------------===// -#include - -#include "gen/llvm.h" - -#include "mtype.h" -#include "declaration.h" -#include "statement.h" - #include "gen/irstate.h" -#include "tollvm.h" +#include "declaration.h" +#include "mtype.h" +#include "statement.h" +#include "gen/llvm.h" +#include "gen/tollvm.h" +#include IRState* gIR = 0; llvm::TargetMachine* gTargetMachine = 0; diff --git a/gen/irstate.h b/gen/irstate.h index cde25f24..9aa17124 100644 --- a/gen/irstate.h +++ b/gen/irstate.h @@ -15,17 +15,15 @@ #ifndef LDC_GEN_IRSTATE_H #define LDC_GEN_IRSTATE_H -#include -#include -#include -#include - -#include "root.h" #include "aggregate.h" - +#include "root.h" #include "ir/irfunction.h" #include "ir/irstruct.h" #include "ir/irvar.h" +#include +#include +#include +#include #if LDC_LLVM_VER >= 302 #include "llvm/DIBuilder.h" diff --git a/gen/llvm.h b/gen/llvm.h index f0b207f8..5db2fded 100644 --- a/gen/llvm.h +++ b/gen/llvm.h @@ -15,8 +15,8 @@ // //===----------------------------------------------------------------------===// -#ifndef GEN_LLVM_H -#define GEN_LLVM_H +#ifndef LDC_GEN_LLVM_H +#define LDC_GEN_LLVM_H #if LDC_LLVM_VER >= 303 #include "llvm/IR/Type.h" @@ -94,4 +94,4 @@ using llvm::IRBuilder; using llvm::APFloat; using llvm::APInt; -#endif // GEN_LLVM_H +#endif // LDC_GEN_LLVM_H diff --git a/gen/llvmcompat.cpp b/gen/llvmcompat.cpp index cb441463..17e0045c 100644 --- a/gen/llvmcompat.cpp +++ b/gen/llvmcompat.cpp @@ -8,8 +8,8 @@ //===----------------------------------------------------------------------===// #include "gen/llvmcompat.h" -#include "llvm/Config/llvm-config.h" #include "llvm/ADT/Triple.h" +#include "llvm/Config/llvm-config.h" #if LDC_LLVM_VER >= 303 #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Function.h" diff --git a/gen/llvmhelpers.cpp b/gen/llvmhelpers.cpp index 8c2e0dbd..a5e0df49 100644 --- a/gen/llvmhelpers.cpp +++ b/gen/llvmhelpers.cpp @@ -8,36 +8,32 @@ //===----------------------------------------------------------------------===// #include "gen/llvmhelpers.h" -#include "gen/llvm.h" - -#include "mars.h" -#include "init.h" -#include "id.h" #include "expression.h" -#include "template.h" +#include "id.h" +#include "init.h" +#include "mars.h" #include "module.h" - +#include "template.h" +#include "gen/arrays.h" +#include "gen/classes.h" +#include "gen/complex.h" +#include "gen/dvalue.h" +#include "gen/functions.h" +#include "gen/irstate.h" +#include "gen/llvm.h" +#include "gen/llvmcompat.h" +#include "gen/logger.h" +#include "gen/nested.h" +#include "gen/runtime.h" +#include "gen/todebug.h" +#include "gen/tollvm.h" +#include "gen/typeinf.h" +#include "ir/irmodule.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/Target/TargetMachine.h" #if LDC_LLVM_VER >= 301 #include "llvm/Transforms/Utils/ModuleUtils.h" #endif - -#include "gen/tollvm.h" -#include "gen/irstate.h" -#include "gen/runtime.h" -#include "gen/logger.h" -#include "gen/arrays.h" -#include "gen/dvalue.h" -#include "gen/complex.h" -#include "gen/classes.h" -#include "gen/functions.h" -#include "gen/typeinf.h" -#include "gen/todebug.h" -#include "gen/nested.h" -#include "ir/irmodule.h" -#include "gen/llvmcompat.h" - #include /****************************************************************************************/ diff --git a/gen/llvmhelpers.h b/gen/llvmhelpers.h index 7689e411..a3399c44 100644 --- a/gen/llvmhelpers.h +++ b/gen/llvmhelpers.h @@ -16,11 +16,10 @@ #ifndef LDC_GEN_LLVMHELPERS_H #define LDC_GEN_LLVMHELPERS_H -#include "gen/llvm.h" -#include "gen/dvalue.h" - -#include "statement.h" #include "mtype.h" +#include "statement.h" +#include "gen/dvalue.h" +#include "gen/llvm.h" // this is used for tracking try-finally, synchronized and volatile scopes struct EnclosingHandler diff --git a/gen/logger.cpp b/gen/logger.cpp index a16e94cf..aeeab3f2 100644 --- a/gen/logger.cpp +++ b/gen/logger.cpp @@ -7,17 +7,15 @@ // //===----------------------------------------------------------------------===// +#include "mars.h" +#include "llvm/Support/CommandLine.h" #include #include #include #include #include -#include #include - -#include "mars.h" - -#include "llvm/Support/CommandLine.h" +#include #if LDC_LLVM_VER >= 303 #include "llvm/IR/GlobalValue.h" diff --git a/gen/logger.h b/gen/logger.h index 52c12a43..e9683505 100644 --- a/gen/logger.h +++ b/gen/logger.h @@ -12,8 +12,8 @@ // //===----------------------------------------------------------------------===// -#ifndef _llvmd_gen_logger_h_ -#define _llvmd_gen_logger_h_ +#ifndef LDC_GEN_LOGGER_H +#define LDC_GEN_LOGGER_H #include diff --git a/gen/module.cpp b/gen/module.cpp index c458101d..671217bb 100644 --- a/gen/module.cpp +++ b/gen/module.cpp @@ -7,7 +7,41 @@ // //===----------------------------------------------------------------------===// +#include "aggregate.h" +#include "attrib.h" +#include "declaration.h" +#include "enum.h" +#include "id.h" +#include "import.h" +#include "init.h" +#include "mars.h" +#include "module.h" +#include "mtype.h" +#include "scope.h" +#include "statement.h" +#include "template.h" +#include "gen/abi.h" +#include "gen/arrays.h" +#include "gen/classes.h" +#include "gen/functions.h" +#include "gen/irstate.h" #include "gen/llvm.h" +#include "gen/llvmhelpers.h" +#include "gen/logger.h" +#include "gen/optimizer.h" +#include "gen/programs.h" +#include "gen/rttibuilder.h" +#include "gen/runtime.h" +#include "gen/structs.h" +#include "gen/todebug.h" +#include "gen/tollvm.h" +#include "ir/irdsymbol.h" +#include "ir/irmodule.h" +#include "ir/irtype.h" +#if !MODULEINFO_IS_STRUCT +#include "ir/irtypeclass.h" +#endif +#include "ir/irvar.h" #include "llvm/Analysis/Verifier.h" #include "llvm/LinkAllPasses.h" #if LDC_LLVM_VER >= 303 @@ -22,44 +56,6 @@ #endif #endif -#include "mars.h" -#include "module.h" -#include "mtype.h" -#include "declaration.h" -#include "statement.h" -#include "enum.h" -#include "aggregate.h" -#include "init.h" -#include "attrib.h" -#include "id.h" -#include "import.h" -#include "template.h" -#include "scope.h" - -#include "gen/abi.h" -#include "gen/arrays.h" -#include "gen/classes.h" -#include "gen/functions.h" -#include "gen/irstate.h" -#include "gen/llvmhelpers.h" -#include "gen/logger.h" -#include "gen/programs.h" -#include "gen/rttibuilder.h" -#include "gen/runtime.h" -#include "gen/structs.h" -#include "gen/todebug.h" -#include "gen/tollvm.h" -#include "gen/optimizer.h" - -#include "ir/irdsymbol.h" -#include "ir/irmodule.h" -#include "ir/irtype.h" -#include "ir/irvar.h" - -#if !MODULEINFO_IS_STRUCT -#include "ir/irtypeclass.h" -#endif - #if DMDV2 #define NEW_MODULEINFO_LAYOUT 1 #endif diff --git a/gen/naked.cpp b/gen/naked.cpp index c9e3baf6..63cce793 100644 --- a/gen/naked.cpp +++ b/gen/naked.cpp @@ -7,26 +7,23 @@ // //===----------------------------------------------------------------------===// +#include "expression.h" +#include "declaration.h" +#include "statement.h" +#include "template.h" +#include "gen/dvalue.h" +#include "gen/irstate.h" #include "gen/llvm.h" +#include "gen/llvmhelpers.h" +#include "gen/logger.h" +#include "gen/tollvm.h" #if LDC_LLVM_VER >= 303 #include "llvm/IR/InlineAsm.h" #else #include "llvm/InlineAsm.h" #endif - -#include "expression.h" -#include "statement.h" -#include "declaration.h" -#include "template.h" - #include -#include "gen/logger.h" -#include "gen/irstate.h" -#include "gen/llvmhelpers.h" -#include "gen/tollvm.h" -#include "gen/dvalue.h" - ////////////////////////////////////////////////////////////////////////////////////////// void Statement::toNakedIR(IRState *p) diff --git a/gen/nested.cpp b/gen/nested.cpp index 4166c6b6..e32e6447 100644 --- a/gen/nested.cpp +++ b/gen/nested.cpp @@ -8,15 +8,13 @@ //===----------------------------------------------------------------------===// #include "gen/nested.h" - #include "gen/dvalue.h" +#include "gen/functions.h" #include "gen/irstate.h" #include "gen/llvmhelpers.h" #include "gen/logger.h" -#include "gen/tollvm.h" -#include "gen/functions.h" #include "gen/todebug.h" - +#include "gen/tollvm.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/Support/CommandLine.h" namespace cl = llvm::cl; diff --git a/gen/optimizer.cpp b/gen/optimizer.cpp index 4f5ac5f4..fe01ff49 100644 --- a/gen/optimizer.cpp +++ b/gen/optimizer.cpp @@ -8,13 +8,12 @@ //===----------------------------------------------------------------------===// #include "gen/optimizer.h" +#include "mars.h" // error() #include "gen/cl_helpers.h" #include "gen/logger.h" - #include "gen/passes/Passes.h" - -#include "llvm/PassManager.h" #include "llvm/LinkAllPasses.h" +#include "llvm/PassManager.h" #if LDC_LLVM_VER >= 303 #include "llvm/IR/Module.h" #include "llvm/IR/DataLayout.h" @@ -35,8 +34,6 @@ #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/IPO/PassManagerBuilder.h" -#include "mars.h" // error() - using namespace llvm; // Allow the user to specify specific optimizations to run. diff --git a/gen/passes/SimplifyDRuntimeCalls.cpp b/gen/passes/SimplifyDRuntimeCalls.cpp index eeacab26..6747c377 100644 --- a/gen/passes/SimplifyDRuntimeCalls.cpp +++ b/gen/passes/SimplifyDRuntimeCalls.cpp @@ -17,7 +17,6 @@ #define DEBUG_TYPE "simplify-drtcalls" #include "Passes.h" - #include "llvm/Pass.h" #if LDC_LLVM_VER >= 303 #include "llvm/IR/Function.h" diff --git a/gen/pragma.cpp b/gen/pragma.cpp index 89b22ec5..85f293a5 100644 --- a/gen/pragma.cpp +++ b/gen/pragma.cpp @@ -9,11 +9,11 @@ #include "pragma.h" #include "attrib.h" -#include "id.h" -#include "expression.h" -#include "scope.h" -#include "module.h" #include "declaration.h" +#include "expression.h" +#include "id.h" +#include "module.h" +#include "scope.h" #include "template.h" #include "llvm/Support/CommandLine.h" diff --git a/gen/pragma.h b/gen/pragma.h index 6da5dc65..2763bd0b 100644 --- a/gen/pragma.h +++ b/gen/pragma.h @@ -11,8 +11,8 @@ // //===----------------------------------------------------------------------===// -#ifndef PRAGMA_H -#define PRAGMA_H +#ifndef LDC_GEN_PRAGMA_H +#define LDC_GEN_PRAGMA_H #include @@ -51,4 +51,4 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str); void DtoCheckPragma(PragmaDeclaration *decl, Dsymbol *sym, Pragma llvm_internal, const std::string &arg1str); -#endif // PRAGMA_H +#endif // LDC_GEN_PRAGMA_H diff --git a/gen/programs.cpp b/gen/programs.cpp index b36d2c8b..a4df987d 100644 --- a/gen/programs.cpp +++ b/gen/programs.cpp @@ -8,13 +8,11 @@ //===----------------------------------------------------------------------===// #include "gen/programs.h" - +#include "mars.h" // fatal() +#include "root.h" // error(char*) #include "llvm/Support/CommandLine.h" #include "llvm/Support/Program.h" -#include "root.h" // error(char*) -#include "mars.h" // fatal() - using namespace llvm; static cl::opt gcc("gcc", diff --git a/gen/rttibuilder.cpp b/gen/rttibuilder.cpp index 0aede9ff..7e327645 100644 --- a/gen/rttibuilder.cpp +++ b/gen/rttibuilder.cpp @@ -7,18 +7,15 @@ // //===----------------------------------------------------------------------===// -#include "gen/llvm.h" - +#include "gen/rttibuilder.h" #include "aggregate.h" #include "mtype.h" - #include "gen/arrays.h" #include "gen/irstate.h" #include "gen/linkage.h" +#include "gen/llvm.h" #include "gen/llvmhelpers.h" -#include "gen/rttibuilder.h" #include "gen/tollvm.h" - #include "ir/irstruct.h" RTTIBuilder::RTTIBuilder(AggregateDeclaration* base_class) diff --git a/gen/rttibuilder.h b/gen/rttibuilder.h index 5d7eeeb1..a539bb45 100644 --- a/gen/rttibuilder.h +++ b/gen/rttibuilder.h @@ -12,22 +12,25 @@ // //===----------------------------------------------------------------------===// -#ifndef __LDC_GEN_RTTIBUILDER_H__ -#define __LDC_GEN_RTTIBUILDER_H__ +#ifndef LDC_GEN_RTTIBUILDER_H +#define LDC_GEN_RTTIBUILDER_H +#include "llvm/ADT/SmallVector.h" #if LDC_LLVM_VER >= 303 #include "llvm/IR/Constant.h" #else #include "llvm/Constant.h" #endif -#include "llvm/ADT/SmallVector.h" -struct ClassDeclaration; struct AggregateDeclaration; -struct TypeClass; -struct Type; - +struct ClassDeclaration; +struct Dsymbol; +struct FuncDeclaration; +struct IrGlobal; struct IrStruct; +struct Type; +struct TypeClass; +namespace llvm { class StructType; } struct RTTIBuilder { @@ -75,10 +78,10 @@ struct RTTIBuilder /// Creates the initializer constant and assigns it to the global. void finalize(IrGlobal* tid); - void finalize(LLType* type, LLValue* value); + void finalize(llvm::Type* type, llvm::Value* value); /// Creates the initializer constant and assigns it to the global. - llvm::Constant* get_constant(LLStructType *initType); + llvm::Constant* get_constant(llvm::StructType* initType); }; #endif diff --git a/gen/runtime.cpp b/gen/runtime.cpp index df3a8758..3c63aa16 100644 --- a/gen/runtime.cpp +++ b/gen/runtime.cpp @@ -7,7 +7,22 @@ // //===----------------------------------------------------------------------===// +#include "gen/runtime.h" +#include "aggregate.h" +#include "dsymbol.h" +#include "lexer.h" +#include "mars.h" +#include "module.h" +#include "mtype.h" +#include "root.h" +#include "gen/irstate.h" #include "gen/llvm.h" +#include "gen/logger.h" +#include "gen/tollvm.h" +#include "ir/irtype.h" +#include "llvm/Bitcode/ReaderWriter.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/MemoryBuffer.h" #if LDC_LLVM_VER >= 303 #include "llvm/IR/Module.h" #include "llvm/IR/Attributes.h" @@ -15,23 +30,6 @@ #include "llvm/Module.h" #include "llvm/Attributes.h" #endif -#include "llvm/Bitcode/ReaderWriter.h" -#include "llvm/Support/MemoryBuffer.h" -#include "llvm/Support/CommandLine.h" - -#include "root.h" -#include "mars.h" -#include "lexer.h" -#include "dsymbol.h" -#include "mtype.h" -#include "aggregate.h" -#include "module.h" - -#include "gen/runtime.h" -#include "gen/logger.h" -#include "gen/tollvm.h" -#include "gen/irstate.h" -#include "ir/irtype.h" #if LDC_LLVM_VER < 302 using namespace llvm::Attribute; diff --git a/gen/runtime.h b/gen/runtime.h index db494059..05e62c09 100644 --- a/gen/runtime.h +++ b/gen/runtime.h @@ -11,8 +11,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LDC_GEN_RUNTIME_H_ -#define LDC_GEN_RUNTIME_H_ +#ifndef LDC_GEN_RUNTIME_H +#define LDC_GEN_RUNTIME_H namespace llvm { @@ -40,4 +40,4 @@ llvm::GlobalVariable* LLVM_D_GetRuntimeGlobal(llvm::Module* target, const char* #define _adCmp "_adCmp2" #endif -#endif // LDC_GEN_RUNTIME_H_ +#endif // LDC_GEN_RUNTIME_H diff --git a/gen/statements.cpp b/gen/statements.cpp index 8c6fbeee..09fcefc3 100644 --- a/gen/statements.cpp +++ b/gen/statements.cpp @@ -7,39 +7,37 @@ // //===----------------------------------------------------------------------===// - -#include -#include -#include - +#include "init.h" +#include "mars.h" +#include "module.h" +#include "mtype.h" +#include "port.h" +#include "gen/abi.h" +#include "gen/arrays.h" +#include "gen/dvalue.h" +#include "gen/irstate.h" #include "gen/llvm.h" +#include "gen/llvmhelpers.h" +#include "gen/logger.h" +#include "gen/runtime.h" +#include "gen/todebug.h" +#include "gen/tollvm.h" +#include "ir/irfunction.h" +#include "ir/irlandingpad.h" +#include "ir/irmodule.h" +#include "llvm/Support/CFG.h" #if LDC_LLVM_VER >= 303 #include "llvm/IR/InlineAsm.h" #else #include "llvm/InlineAsm.h" #endif -#include "llvm/Support/CFG.h" +#include +#include +#include -#include "mars.h" -#include "init.h" -#include "mtype.h" +// Need to include this after the other DMD includes because of missing +// dependencies. #include "hdrgen.h" -#include "port.h" -#include "module.h" - -#include "gen/irstate.h" -#include "gen/logger.h" -#include "gen/tollvm.h" -#include "gen/llvmhelpers.h" -#include "gen/runtime.h" -#include "gen/arrays.h" -#include "gen/todebug.h" -#include "gen/dvalue.h" -#include "gen/abi.h" - -#include "ir/irfunction.h" -#include "ir/irmodule.h" -#include "ir/irlandingpad.h" ////////////////////////////////////////////////////////////////////////////// diff --git a/gen/structs.cpp b/gen/structs.cpp index 44ec0dd1..d428f113 100644 --- a/gen/structs.cpp +++ b/gen/structs.cpp @@ -7,29 +7,25 @@ // //===----------------------------------------------------------------------===// -#include - -#include "gen/llvm.h" -#include "llvm/ADT/DenseMap.h" -#include "llvm/Support/ManagedStatic.h" - -#include "mtype.h" #include "aggregate.h" -#include "init.h" #include "declaration.h" - -#include "gen/irstate.h" -#include "gen/tollvm.h" -#include "gen/llvmhelpers.h" +#include "init.h" +#include "mtype.h" #include "gen/arrays.h" -#include "gen/logger.h" -#include "gen/structs.h" #include "gen/dvalue.h" #include "gen/functions.h" +#include "gen/irstate.h" +#include "gen/llvm.h" +#include "gen/llvmhelpers.h" +#include "gen/logger.h" +#include "gen/structs.h" +#include "gen/tollvm.h" #include "gen/utils.h" - #include "ir/irstruct.h" #include "ir/irtypestruct.h" +#include "llvm/ADT/DenseMap.h" +#include "llvm/Support/ManagedStatic.h" +#include ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/gen/structs.h b/gen/structs.h index f0a77913..165a3d46 100644 --- a/gen/structs.h +++ b/gen/structs.h @@ -11,10 +11,23 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVMD_GEN_STRUCTS_H -#define LLVMD_GEN_STRUCTS_H +#ifndef LDC_GEN_STRUCTS_H +#define LDC_GEN_STRUCTS_H +#include "lexer.h" +#include + +struct DValue; +struct StructDeclaration; struct StructInitializer; +struct Type; +struct VarDeclaration; +namespace llvm +{ + class Constant; + class Type; + class Value; +} /** * Sets up codegen metadata and emits global data (.init, etc.), if needed. @@ -24,31 +37,30 @@ struct StructInitializer; void DtoResolveStruct(StructDeclaration* sd); /// Build constant struct initializer. -LLConstant* DtoConstStructInitializer(StructInitializer* si); +llvm::Constant* DtoConstStructInitializer(StructInitializer* si); /// Build values for a struct literal. std::vector DtoStructLiteralValues(const StructDeclaration* sd, - const std::vector& inits, - bool isConst = false); + const std::vector& inits, bool isConst = false); /// Returns a boolean=true if the two structs are equal. -LLValue* DtoStructEquals(TOK op, DValue* lhs, DValue* rhs); +llvm::Value* DtoStructEquals(TOK op, DValue* lhs, DValue* rhs); /// index a struct one level -LLValue* DtoIndexStruct(LLValue* src, StructDeclaration* sd, VarDeclaration* vd); +llvm::Value* DtoIndexStruct(llvm::Value* src, StructDeclaration* sd, VarDeclaration* vd); /// Return the type returned by DtoUnpaddedStruct called on a value of the /// specified type. /// Union types will get expanded into a struct, with a type for each member. -LLType* DtoUnpaddedStructType(Type* dty); +llvm::Type* DtoUnpaddedStructType(Type* dty); /// Return the struct value represented by v without the padding fields. /// Unions will be expanded, with a value for each member. /// Note: v must be a pointer to a struct, but the return value will be a /// first-class struct value. -LLValue* DtoUnpaddedStruct(Type* dty, LLValue* v); +llvm::Value* DtoUnpaddedStruct(Type* dty, llvm::Value* v); /// Undo the transformation performed by DtoUnpaddedStruct, writing to lval. -void DtoPaddedStruct(Type* dty, LLValue* v, LLValue* lval); +void DtoPaddedStruct(Type* dty, llvm::Value* v, llvm::Value* lval); #endif diff --git a/gen/tocall.cpp b/gen/tocall.cpp index 407517cb..23233ef9 100644 --- a/gen/tocall.cpp +++ b/gen/tocall.cpp @@ -7,21 +7,18 @@ // //===----------------------------------------------------------------------===// -#include "gen/llvm.h" - -#include "mtype.h" #include "declaration.h" #include "id.h" - -#include "gen/tollvm.h" -#include "gen/llvmhelpers.h" -#include "gen/irstate.h" +#include "mtype.h" +#include "gen/abi.h" #include "gen/dvalue.h" #include "gen/functions.h" -#include "gen/abi.h" -#include "gen/nested.h" - +#include "gen/irstate.h" +#include "gen/llvm.h" +#include "gen/llvmhelpers.h" #include "gen/logger.h" +#include "gen/nested.h" +#include "gen/tollvm.h" ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/gen/todebug.cpp b/gen/todebug.cpp index 6e0e80f2..e6605432 100644 --- a/gen/todebug.cpp +++ b/gen/todebug.cpp @@ -7,26 +7,23 @@ // //===----------------------------------------------------------------------===// +#include "gen/todebug.h" +#include "declaration.h" +#include "mars.h" +#include "module.h" +#include "gen/irstate.h" +#include "gen/linkage.h" #include "gen/llvm.h" +#include "gen/llvmhelpers.h" +#include "gen/logger.h" +#include "gen/tollvm.h" +#include "gen/utils.h" +#include "ir/irmodule.h" #include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/Support/Dwarf.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" -#include "declaration.h" -#include "module.h" -#include "mars.h" - -#include "gen/todebug.h" -#include "gen/irstate.h" -#include "gen/tollvm.h" -#include "gen/logger.h" -#include "gen/llvmhelpers.h" -#include "gen/linkage.h" -#include "gen/utils.h" - -#include "ir/irmodule.h" - using namespace llvm::dwarf; ////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/gen/todebug.h b/gen/todebug.h index 0e572bae..94468aaa 100644 --- a/gen/todebug.h +++ b/gen/todebug.h @@ -14,8 +14,8 @@ #ifndef LDC_GEN_TODEBUG_H #define LDC_GEN_TODEBUG_H -#include "gen/tollvm.h" #include "gen/irstate.h" +#include "gen/tollvm.h" void RegisterDwarfSymbols(llvm::Module* mod); diff --git a/gen/toir.cpp b/gen/toir.cpp index 9ce08d40..016f5ad2 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -7,44 +7,40 @@ // //===----------------------------------------------------------------------===// -#include -#include -#include - -#include "gen/llvm.h" -#include "llvm/Support/CommandLine.h" - #include "attrib.h" +#include "enum.h" +#include "hdrgen.h" +#include "id.h" #include "init.h" #include "mtype.h" -#include "template.h" -#include "hdrgen.h" #include "port.h" #include "rmem.h" -#include "id.h" -#include "enum.h" - -#include "gen/irstate.h" -#include "gen/logger.h" -#include "gen/tollvm.h" -#include "gen/llvmhelpers.h" -#include "gen/runtime.h" +#include "template.h" +#include "gen/aa.h" #include "gen/arrays.h" -#include "gen/structs.h" #include "gen/classes.h" -#include "gen/typeinf.h" #include "gen/complex.h" #include "gen/dvalue.h" -#include "gen/aa.h" #include "gen/functions.h" -#include "gen/todebug.h" +#include "gen/irstate.h" +#include "gen/llvm.h" +#include "gen/llvmhelpers.h" +#include "gen/logger.h" #include "gen/nested.h" -#include "gen/utils.h" -#include "gen/warnings.h" #include "gen/optimizer.h" #include "gen/pragma.h" - +#include "gen/runtime.h" +#include "gen/structs.h" +#include "gen/todebug.h" +#include "gen/tollvm.h" +#include "gen/typeinf.h" +#include "gen/utils.h" +#include "gen/warnings.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/ManagedStatic.h" +#include +#include +#include llvm::cl::opt checkPrintf("check-printf-calls", llvm::cl::desc("Validate printf call format strings against arguments"), diff --git a/gen/tollvm.cpp b/gen/tollvm.cpp index e301eebd..85347fb9 100644 --- a/gen/tollvm.cpp +++ b/gen/tollvm.cpp @@ -7,30 +7,27 @@ // //===----------------------------------------------------------------------===// -#include "gen/llvm.h" - -#include "dsymbol.h" +#include "gen/tollvm.h" #include "aggregate.h" #include "declaration.h" -#include "init.h" +#include "dsymbol.h" #include "id.h" +#include "init.h" #include "module.h" - -#include "gen/tollvm.h" -#include "gen/irstate.h" -#include "gen/logger.h" -#include "gen/runtime.h" #include "gen/arrays.h" +#include "gen/classes.h" +#include "gen/complex.h" #include "gen/dvalue.h" #include "gen/functions.h" -#include "gen/structs.h" -#include "gen/classes.h" -#include "gen/typeinf.h" -#include "gen/complex.h" -#include "gen/llvmhelpers.h" +#include "gen/irstate.h" #include "gen/linkage.h" +#include "gen/llvm.h" +#include "gen/llvmhelpers.h" +#include "gen/logger.h" #include "gen/pragma.h" - +#include "gen/runtime.h" +#include "gen/structs.h" +#include "gen/typeinf.h" #include "ir/irtype.h" #include "ir/irtypeclass.h" #include "ir/irtypefunction.h" diff --git a/gen/tollvm.h b/gen/tollvm.h index 3b0ef8a9..4f473e45 100644 --- a/gen/tollvm.h +++ b/gen/tollvm.h @@ -16,12 +16,11 @@ #ifndef LDC_GEN_TOLLVM_H #define LDC_GEN_TOLLVM_H -#include "gen/llvm.h" -#include "lexer.h" -#include "mtype.h" #include "attrib.h" #include "declaration.h" - +#include "lexer.h" +#include "mtype.h" +#include "gen/llvm.h" #include "gen/structs.h" // D->LLVM type handling stuff diff --git a/gen/typeinf.h b/gen/typeinf.h index fe993a78..7a77ad5b 100644 --- a/gen/typeinf.h +++ b/gen/typeinf.h @@ -15,6 +15,7 @@ #ifndef LDC_GEN_TYPEINF_H #define LDC_GEN_TYPEINF_H +struct TypeInfoDeclaration; void DtoResolveTypeInfo(TypeInfoDeclaration* tid); void DtoDeclareTypeInfo(TypeInfoDeclaration* tid); void DtoConstInitTypeInfo(TypeInfoDeclaration* tid); diff --git a/gen/typinf.cpp b/gen/typinf.cpp index 784cd5ca..404c450d 100644 --- a/gen/typinf.cpp +++ b/gen/typinf.cpp @@ -20,39 +20,35 @@ // Copyright (c) 2007 by Tomas Lindquist Olsen // tomas at famolsen dk -#include -#include - -#include "gen/llvm.h" - +#include "aggregate.h" +#include "attrib.h" +#include "declaration.h" +#include "enum.h" +#include "expression.h" +#include "id.h" +#include "import.h" +#include "init.h" #include "mars.h" #include "module.h" #include "mtype.h" #include "scope.h" -#include "init.h" -#include "expression.h" -#include "attrib.h" -#include "declaration.h" #include "template.h" -#include "id.h" -#include "enum.h" -#include "import.h" -#include "aggregate.h" - -#include "gen/irstate.h" -#include "gen/logger.h" -#include "gen/runtime.h" -#include "gen/tollvm.h" -#include "gen/llvmhelpers.h" #include "gen/arrays.h" -#include "gen/structs.h" #include "gen/classes.h" +#include "gen/irstate.h" #include "gen/linkage.h" +#include "gen/llvm.h" +#include "gen/llvmhelpers.h" +#include "gen/logger.h" #include "gen/metadata.h" #include "gen/rttibuilder.h" - -#include "ir/irvar.h" +#include "gen/runtime.h" +#include "gen/structs.h" +#include "gen/tollvm.h" #include "ir/irtype.h" +#include "ir/irvar.h" +#include +#include #include /******************************************* diff --git a/gen/utils.h b/gen/utils.h index 8d7c1e6e..b2c57b24 100644 --- a/gen/utils.h +++ b/gen/utils.h @@ -11,8 +11,8 @@ // //===----------------------------------------------------------------------===// -#ifndef __LDC_GEN_UTILS_H__ -#define __LDC_GEN_UTILS_H__ +#ifndef LDC_GEN_UTILS_H +#define LDC_GEN_UTILS_H #include "root.h" diff --git a/gen/warnings.cpp b/gen/warnings.cpp index f3b59846..93268115 100644 --- a/gen/warnings.cpp +++ b/gen/warnings.cpp @@ -7,11 +7,8 @@ // //===----------------------------------------------------------------------===// -#include "mars.h" -#include "mtype.h" -#include "expression.h" - #include "gen/warnings.h" +#include "mtype.h" void warnInvalidPrintfCall(Loc loc, Expression* arguments, size_t nargs) { diff --git a/gen/warnings.h b/gen/warnings.h index 7367c6d2..f08c21b4 100644 --- a/gen/warnings.h +++ b/gen/warnings.h @@ -11,9 +11,12 @@ // //===----------------------------------------------------------------------===// -#ifndef __LDC_GEN_WARNINGS_H__ -#define __LDC_GEN_WARNINGS_H__ +#ifndef LDC_GEN_WARNINGS_H +#define LDC_GEN_WARNINGS_H + +#include "expression.h" +#include "mars.h" void warnInvalidPrintfCall(Loc loc, Expression* arguments, size_t nargs); -#endif // __LDC_GEN_WARNINGS_H__ +#endif // LDC_GEN_WARNINGS_H diff --git a/ir/ir.h b/ir/ir.h index dbca3572..ecf28dc7 100644 --- a/ir/ir.h +++ b/ir/ir.h @@ -16,10 +16,9 @@ #ifndef LDC_IR_IR_H #define LDC_IR_IR_H -#include - -#include "ir/irforw.h" #include "root.h" +#include "ir/irforw.h" +#include struct IRState; struct IrFunction; diff --git a/ir/irdsymbol.cpp b/ir/irdsymbol.cpp index 598001b9..290cfcbc 100644 --- a/ir/irdsymbol.cpp +++ b/ir/irdsymbol.cpp @@ -8,12 +8,11 @@ //===----------------------------------------------------------------------===// #include "gen/llvm.h" +#include "gen/logger.h" #include "ir/ir.h" #include "ir/irdsymbol.h" #include "ir/irvar.h" -#include "gen/logger.h" - std::set IrDsymbol::list; void IrDsymbol::resetAll() diff --git a/ir/irfunction.cpp b/ir/irfunction.cpp index 2f825850..cc49a65e 100644 --- a/ir/irfunction.cpp +++ b/ir/irfunction.cpp @@ -10,7 +10,6 @@ #include "gen/llvm.h" #include "gen/tollvm.h" #include "ir/irfunction.h" - #include FuncGen::FuncGen() diff --git a/ir/irfunction.h b/ir/irfunction.h index 0e4ef450..fcc1082d 100644 --- a/ir/irfunction.h +++ b/ir/irfunction.h @@ -19,10 +19,9 @@ #include "gen/llvm.h" #include "ir/ir.h" #include "ir/irlandingpad.h" - -#include -#include #include +#include +#include struct Statement; struct EnclosingHandler; diff --git a/ir/irfuncty.cpp b/ir/irfuncty.cpp index 05ed7d97..be66f086 100644 --- a/ir/irfuncty.cpp +++ b/ir/irfuncty.cpp @@ -8,13 +8,11 @@ //===----------------------------------------------------------------------===// #include "ir/irfuncty.h" - #include "mtype.h" - #include "gen/abi.h" #include "gen/dvalue.h" -#include "gen/logger.h" #include "gen/llvm.h" +#include "gen/logger.h" #include "gen/tollvm.h" #if LDC_LLVM_VER >= 303 diff --git a/ir/irlandingpad.cpp b/ir/irlandingpad.cpp index 900ff773..8f4c25ca 100644 --- a/ir/irlandingpad.cpp +++ b/ir/irlandingpad.cpp @@ -8,13 +8,13 @@ //===----------------------------------------------------------------------===// #include "gen/llvm.h" -#include "gen/tollvm.h" -#include "gen/irstate.h" -#include "gen/runtime.h" -#include "gen/logger.h" #include "gen/classes.h" +#include "gen/irstate.h" #include "gen/llvmhelpers.h" +#include "gen/logger.h" +#include "gen/runtime.h" #include "gen/todebug.h" +#include "gen/tollvm.h" #include "ir/irlandingpad.h" IRLandingPadInfo::IRLandingPadInfo(Catch* catchstmt_, llvm::BasicBlock* end_) : diff --git a/ir/irlandingpad.h b/ir/irlandingpad.h index e3789882..904a5cff 100644 --- a/ir/irlandingpad.h +++ b/ir/irlandingpad.h @@ -15,9 +15,8 @@ #ifndef LDC_IR_IRLANDINGPADINFO_H #define LDC_IR_IRLANDINGPADINFO_H -#include "ir/ir.h" #include "statement.h" - +#include "ir/ir.h" #include #include diff --git a/ir/irmodule.cpp b/ir/irmodule.cpp index 80d32a66..eab29ff8 100644 --- a/ir/irmodule.cpp +++ b/ir/irmodule.cpp @@ -8,8 +8,8 @@ //===----------------------------------------------------------------------===// #include "gen/llvm.h" -#include "gen/tollvm.h" #include "gen/irstate.h" +#include "gen/tollvm.h" #include "ir/irmodule.h" IrModule::IrModule(Module* module, const char* srcfilename) diff --git a/ir/irstruct.cpp b/ir/irstruct.cpp index 046e41b2..db7410e3 100644 --- a/ir/irstruct.cpp +++ b/ir/irstruct.cpp @@ -8,21 +8,17 @@ //===----------------------------------------------------------------------===// #include "gen/llvm.h" - -#include "mtype.h" #include "aggregate.h" #include "declaration.h" #include "init.h" - +#include "mtype.h" #include "gen/irstate.h" -#include "gen/tollvm.h" -#include "gen/logger.h" #include "gen/llvmhelpers.h" +#include "gen/logger.h" +#include "gen/tollvm.h" #include "gen/utils.h" - #include "ir/irstruct.h" #include "ir/irtypeclass.h" - #include ////////////////////////////////////////////////////////////////////////////// diff --git a/ir/irstruct.h b/ir/irstruct.h index 535f8807..28c8f01d 100644 --- a/ir/irstruct.h +++ b/ir/irstruct.h @@ -16,9 +16,8 @@ #define LDC_IR_IRSTRUCT_H #include "ir/ir.h" - -#include #include +#include // DMD forward declarations struct StructInitializer; diff --git a/utils/gen_gccbuiltins.cpp b/utils/gen_gccbuiltins.cpp index 5c095acb..de309440 100644 --- a/utils/gen_gccbuiltins.cpp +++ b/utils/gen_gccbuiltins.cpp @@ -13,22 +13,20 @@ // //===----------------------------------------------------------------------===// -#include -#include -#include - -#include -#include -#include - #include "llvm/TableGen/Main.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/PathV1.h" +#include "llvm/TableGen/Record.h" #if LDC_LLVM_VER < 302 #include "llvm/TableGen/TableGenAction.h" #endif -#include "llvm/TableGen/Record.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/PathV1.h" -#include "llvm/ADT/StringRef.h" +#include +#include +#include +#include +#include +#include using namespace std; using namespace llvm;