mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-04-29 22:50:53 +03:00
Merge branch 'master' into merge-2.067
This commit is contained in:
commit
1036edc266
5 changed files with 34 additions and 20 deletions
|
@ -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();
|
||||
|
||||
|
|
|
@ -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<std::string> &attrs)
|
||||
{
|
||||
|
@ -238,6 +239,7 @@ static void addMipsABI(const llvm::Triple &triple, std::vector<std::string> &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]);
|
||||
|
||||
|
|
|
@ -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<unsigned long long>(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<unsigned long long>(idx++));
|
||||
while(std::string::npos != (pos = insnt.find(needle)))
|
||||
insnt.replace(pos, needle.size(), buf);
|
||||
}
|
||||
|
|
|
@ -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<unsigned long long>(priority));
|
||||
arg1str = std::string(buf);
|
||||
return ident == Id::LDC_global_crt_ctor ? LLVMglobal_crt_ctor : LLVMglobal_crt_dtor;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue