mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-03 08:30:47 +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.
|
/// Register the MIPS ABI.
|
||||||
static void registerMipsABI()
|
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();
|
llvm::StringRef features = gTargetMachine->getTargetFeatureString();
|
||||||
if (features.find("+o32") != std::string::npos)
|
if (features.find("+o32") != std::string::npos)
|
||||||
VersionCondition::addPredefinedGlobalIdent("MIPS_O32");
|
VersionCondition::addPredefinedGlobalIdent("MIPS_O32");
|
||||||
|
@ -553,6 +563,7 @@ static void registerMipsABI()
|
||||||
VersionCondition::addPredefinedGlobalIdent("MIPS_N64");
|
VersionCondition::addPredefinedGlobalIdent("MIPS_N64");
|
||||||
if (features.find("+eabi") != std::string::npos)
|
if (features.find("+eabi") != std::string::npos)
|
||||||
VersionCondition::addPredefinedGlobalIdent("MIPS_EABI");
|
VersionCondition::addPredefinedGlobalIdent("MIPS_EABI");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Register the float ABI.
|
/// 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
|
// Use target floating point unit instead of s/w float routines
|
||||||
#if LDC_LLVM_VER >= 307
|
#if LDC_LLVM_VER >= 307
|
||||||
// FIXME: This is a semantic change!
|
// FIXME: This is a semantic change!
|
||||||
bool useFPU = gTargetMachine->Options.FloatABIType = llvm::FloatABI::Hard;
|
bool useFPU = gTargetMachine->Options.FloatABIType == llvm::FloatABI::Hard;
|
||||||
#else
|
#else
|
||||||
bool useFPU = !gTargetMachine->Options.UseSoftFloat;
|
bool useFPU = !gTargetMachine->Options.UseSoftFloat;
|
||||||
#endif
|
#endif
|
||||||
|
@ -687,7 +698,7 @@ static void registerPredefinedTargetVersions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// a generic 64bit version
|
// a generic 64bit version
|
||||||
if (global.params.is64bit) {
|
if (global.params.isLP64) {
|
||||||
VersionCondition::addPredefinedGlobalIdent("D_LP64");
|
VersionCondition::addPredefinedGlobalIdent("D_LP64");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1025,20 +1036,6 @@ int main(int argc, char **argv)
|
||||||
bitness, mFloatABI, mRelocModel, mCodeModel, codeGenOptLevel(),
|
bitness, mFloatABI, mRelocModel, mCodeModel, codeGenOptLevel(),
|
||||||
global.params.symdebug || disableFpElim, disableLinkerStripDead);
|
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
|
#if LDC_LLVM_VER >= 307
|
||||||
gDataLayout = gTargetMachine->getDataLayout();
|
gDataLayout = gTargetMachine->getDataLayout();
|
||||||
#elif LDC_LLVM_VER >= 306
|
#elif LDC_LLVM_VER >= 306
|
||||||
|
@ -1049,6 +1046,19 @@ int main(int argc, char **argv)
|
||||||
gDataLayout = gTargetMachine->getTargetData();
|
gDataLayout = gTargetMachine->getTargetData();
|
||||||
#endif
|
#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
|
// allocate the target abi
|
||||||
gABI = TargetABI::getTarget();
|
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.
|
/// Sanitizes the MIPS ABI in the feature string.
|
||||||
static void addMipsABI(const llvm::Triple &triple, std::vector<std::string> &attrs)
|
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)
|
if (bits != defaultABI)
|
||||||
attrs.push_back(is64Bit ? "-n64" : "-o32");
|
attrs.push_back(is64Bit ? "-n64" : "-o32");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/// Looks up a target based on an arch name and a target triple.
|
/// Looks up a target based on an arch name and a target triple.
|
||||||
///
|
///
|
||||||
|
@ -362,11 +364,13 @@ llvm::TargetMachine* createTargetMachine(
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if LDC_LLVM_VER < 307
|
||||||
if (triple.getArch() == llvm::Triple::mips ||
|
if (triple.getArch() == llvm::Triple::mips ||
|
||||||
triple.getArch() == llvm::Triple::mipsel ||
|
triple.getArch() == llvm::Triple::mipsel ||
|
||||||
triple.getArch() == llvm::Triple::mips64 ||
|
triple.getArch() == llvm::Triple::mips64 ||
|
||||||
triple.getArch() == llvm::Triple::mips64el)
|
triple.getArch() == llvm::Triple::mips64el)
|
||||||
addMipsABI(triple, attrs);
|
addMipsABI(triple, attrs);
|
||||||
|
#endif
|
||||||
for (unsigned i = 0; i < attrs.size(); ++i)
|
for (unsigned i = 0; i < attrs.size(); ++i)
|
||||||
features.AddFeature(attrs[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;
|
needle = prefix + digits[i] + suffix;
|
||||||
size_t pos = insnt.find(needle);
|
size_t pos = insnt.find(needle);
|
||||||
if(std::string::npos != pos)
|
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)))
|
while(std::string::npos != (pos = insnt.find(needle)))
|
||||||
insnt.replace(pos, needle.size(), buf);
|
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;
|
needle = prefix + digits[i] + suffix;
|
||||||
size_t pos = insnt.find(needle);
|
size_t pos = insnt.find(needle);
|
||||||
if(std::string::npos != pos)
|
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)))
|
while(std::string::npos != (pos = insnt.find(needle)))
|
||||||
insnt.replace(pos, needle.size(), buf);
|
insnt.replace(pos, needle.size(), buf);
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str)
|
||||||
else
|
else
|
||||||
priority = 65535;
|
priority = 65535;
|
||||||
char buf[8];
|
char buf[8];
|
||||||
sprintf(buf, "%lu", priority);
|
sprintf(buf, "%llu", static_cast<unsigned long long>(priority));
|
||||||
arg1str = std::string(buf);
|
arg1str = std::string(buf);
|
||||||
return ident == Id::LDC_global_crt_ctor ? LLVMglobal_crt_ctor : LLVMglobal_crt_dtor;
|
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
|
// the type of size_t does not change once set
|
||||||
static LLIntegerType* t = NULL;
|
static LLIntegerType* t = NULL;
|
||||||
if (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;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue