diff --git a/driver/main.cpp b/driver/main.cpp index 5026e6d539..303e7aeac8 100644 --- a/driver/main.cpp +++ b/driver/main.cpp @@ -544,6 +544,16 @@ static void initializePasses() { /// Register the MIPS ABI. static void registerMipsABI() { +#if LDC_LLVM_VER >= 307 + // FIXME: EABI? + auto dl = gTargetMachine->getDataLayout(); + if (dl->getPointerSizeInBits() == 64) + VersionCondition::addPredefinedGlobalIdent("MIPS_N64"); + else if (dl->getLargestLegalIntTypeSize() == 64) + VersionCondition::addPredefinedGlobalIdent("MIPS_N32"); + else + VersionCondition::addPredefinedGlobalIdent("MIPS_O32"); +#else llvm::StringRef features = gTargetMachine->getTargetFeatureString(); if (features.find("+o32") != std::string::npos) VersionCondition::addPredefinedGlobalIdent("MIPS_O32"); @@ -553,6 +563,7 @@ static void registerMipsABI() VersionCondition::addPredefinedGlobalIdent("MIPS_N64"); if (features.find("+eabi") != std::string::npos) VersionCondition::addPredefinedGlobalIdent("MIPS_EABI"); +#endif } /// Register the float ABI. @@ -562,7 +573,7 @@ static void registerPredefinedFloatABI(const char *soft, const char *hard, const // Use target floating point unit instead of s/w float routines #if LDC_LLVM_VER >= 307 // FIXME: This is a semantic change! - bool useFPU = gTargetMachine->Options.FloatABIType = llvm::FloatABI::Hard; + bool useFPU = gTargetMachine->Options.FloatABIType == llvm::FloatABI::Hard; #else bool useFPU = !gTargetMachine->Options.UseSoftFloat; #endif @@ -687,7 +698,7 @@ static void registerPredefinedTargetVersions() { } // a generic 64bit version - if (global.params.is64bit) { + if (global.params.isLP64) { VersionCondition::addPredefinedGlobalIdent("D_LP64"); } @@ -1025,20 +1036,6 @@ int main(int argc, char **argv) bitness, mFloatABI, mRelocModel, mCodeModel, codeGenOptLevel(), global.params.symdebug || disableFpElim, disableLinkerStripDead); - { - llvm::Triple triple = llvm::Triple(gTargetMachine->getTargetTriple()); - global.params.targetTriple = triple; - global.params.isLinux = triple.getOS() == llvm::Triple::Linux; - global.params.isOSX = triple.isMacOSX(); - global.params.isWindows = triple.isOSWindows(); - global.params.isFreeBSD = triple.getOS() == llvm::Triple::FreeBSD; - global.params.isOpenBSD = triple.getOS() == llvm::Triple::OpenBSD; - global.params.isSolaris = triple.getOS() == llvm::Triple::Solaris; - // FIXME: Correctly handle the x32 ABI (AMD64 ILP32) here. - global.params.isLP64 = triple.isArch64Bit(); - global.params.is64bit = triple.isArch64Bit(); - } - #if LDC_LLVM_VER >= 307 gDataLayout = gTargetMachine->getDataLayout(); #elif LDC_LLVM_VER >= 306 @@ -1049,6 +1046,19 @@ int main(int argc, char **argv) gDataLayout = gTargetMachine->getTargetData(); #endif + { + llvm::Triple triple = llvm::Triple(gTargetMachine->getTargetTriple()); + global.params.targetTriple = triple; + global.params.isLinux = triple.getOS() == llvm::Triple::Linux; + global.params.isOSX = triple.isMacOSX(); + global.params.isWindows = triple.isOSWindows(); + global.params.isFreeBSD = triple.getOS() == llvm::Triple::FreeBSD; + global.params.isOpenBSD = triple.getOS() == llvm::Triple::OpenBSD; + global.params.isSolaris = triple.getOS() == llvm::Triple::Solaris; + global.params.isLP64 = gDataLayout->getPointerSizeInBits() == 64; + global.params.is64bit = triple.isArch64Bit(); + } + // allocate the target abi gABI = TargetABI::getTarget(); diff --git a/driver/targetmachine.cpp b/driver/targetmachine.cpp index 81b0f654e9..d12bbc32d5 100644 --- a/driver/targetmachine.cpp +++ b/driver/targetmachine.cpp @@ -199,6 +199,7 @@ static FloatABI::Type getARMFloatABI(const llvm::Triple &triple, } } +#if LDC_LLVM_VER < 307 /// Sanitizes the MIPS ABI in the feature string. static void addMipsABI(const llvm::Triple &triple, std::vector &attrs) { @@ -238,6 +239,7 @@ static void addMipsABI(const llvm::Triple &triple, std::vector &att if (bits != defaultABI) attrs.push_back(is64Bit ? "-n64" : "-o32"); } +#endif /// Looks up a target based on an arch name and a target triple. /// @@ -362,11 +364,13 @@ llvm::TargetMachine* createTargetMachine( #endif } } +#if LDC_LLVM_VER < 307 if (triple.getArch() == llvm::Triple::mips || triple.getArch() == llvm::Triple::mipsel || triple.getArch() == llvm::Triple::mips64 || triple.getArch() == llvm::Triple::mips64el) addMipsABI(triple, attrs); +#endif for (unsigned i = 0; i < attrs.size(); ++i) features.AddFeature(attrs[i]); diff --git a/gen/asmstmt.cpp b/gen/asmstmt.cpp index 0f3f9f1cdd..453de3b6ab 100644 --- a/gen/asmstmt.cpp +++ b/gen/asmstmt.cpp @@ -446,7 +446,7 @@ static void remap_outargs(std::string& insnt, size_t nargs, size_t idx) needle = prefix + digits[i] + suffix; size_t pos = insnt.find(needle); if(std::string::npos != pos) - sprintf(buf, "%lu", idx++); + sprintf(buf, "%llu", static_cast(idx++)); while(std::string::npos != (pos = insnt.find(needle))) insnt.replace(pos, needle.size(), buf); } @@ -471,7 +471,7 @@ static void remap_inargs(std::string& insnt, size_t nargs, size_t idx) needle = prefix + digits[i] + suffix; size_t pos = insnt.find(needle); if(std::string::npos != pos) - sprintf(buf, "%lu", idx++); + sprintf(buf, "%llu", static_cast(idx++)); while(std::string::npos != (pos = insnt.find(needle))) insnt.replace(pos, needle.size(), buf); } diff --git a/gen/pragma.cpp b/gen/pragma.cpp index 709ad4768d..14fc97d114 100644 --- a/gen/pragma.cpp +++ b/gen/pragma.cpp @@ -118,7 +118,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str) else priority = 65535; char buf[8]; - sprintf(buf, "%lu", priority); + sprintf(buf, "%llu", static_cast(priority)); arg1str = std::string(buf); return ident == Id::LDC_global_crt_ctor ? LLVMglobal_crt_ctor : LLVMglobal_crt_dtor; } diff --git a/gen/tollvm.cpp b/gen/tollvm.cpp index ce9c547a24..8411732e02 100644 --- a/gen/tollvm.cpp +++ b/gen/tollvm.cpp @@ -300,7 +300,7 @@ LLIntegerType* DtoSize_t() // the type of size_t does not change once set static LLIntegerType* t = NULL; if (t == NULL) - t = (global.params.is64bit) ? LLType::getInt64Ty(gIR->context()) : LLType::getInt32Ty(gIR->context()); + t = (global.params.isLP64) ? LLType::getInt64Ty(gIR->context()) : LLType::getInt32Ty(gIR->context()); return t; }