mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-01 23:50:43 +03:00
Do not use global.params.is<OS>
This PR replaces the few uses of global.params.is<OS> with global.params.targetTriple.isOS<OS>(). This avoids adding a new boolean for each supported OS. It also defines all xBSD-type OS as using the dso-registry.
This commit is contained in:
parent
04c6c48ee1
commit
d072bdf7b6
6 changed files with 25 additions and 10 deletions
|
@ -80,13 +80,15 @@ struct Param
|
||||||
#endif
|
#endif
|
||||||
bool is64bit; // generate 64 bit code
|
bool is64bit; // generate 64 bit code
|
||||||
bool isLP64; // generate code for LP64
|
bool isLP64; // generate code for LP64
|
||||||
|
#if !IN_LLVM
|
||||||
bool isLinux; // generate code for linux
|
bool isLinux; // generate code for linux
|
||||||
bool isOSX; // generate code for Mac OSX
|
bool isOSX; // generate code for Mac OSX
|
||||||
|
#endif
|
||||||
bool isWindows; // generate code for Windows
|
bool isWindows; // generate code for Windows
|
||||||
|
#if !IN_LLVM
|
||||||
bool isFreeBSD; // generate code for FreeBSD
|
bool isFreeBSD; // generate code for FreeBSD
|
||||||
bool isOpenBSD; // generate code for OpenBSD
|
bool isOpenBSD; // generate code for OpenBSD
|
||||||
bool isSolaris; // generate code for Solaris
|
bool isSolaris; // generate code for Solaris
|
||||||
#if !IN_LLVM
|
|
||||||
bool mscoff; // for Win32: write COFF object files instead of OMF
|
bool mscoff; // for Win32: write COFF object files instead of OMF
|
||||||
char useDeprecated; // 0: don't allow use of deprecated features
|
char useDeprecated; // 0: don't allow use of deprecated features
|
||||||
// 1: silently allow use of deprecated features
|
// 1: silently allow use of deprecated features
|
||||||
|
|
|
@ -212,7 +212,7 @@ void CodeGenerator::emit(Module *m) {
|
||||||
|
|
||||||
// On Linux, strongly define the excecutabe BSS bracketing symbols in
|
// On Linux, strongly define the excecutabe BSS bracketing symbols in
|
||||||
// the main module for druntime use (see rt.sections_linux).
|
// the main module for druntime use (see rt.sections_linux).
|
||||||
if (global.params.isLinux) {
|
if (global.params.targetTriple.isOSLinux()) {
|
||||||
emitSymbolAddrGlobal(ir_->module, "__bss_start", "_d_execBssBegAddr");
|
emitSymbolAddrGlobal(ir_->module, "__bss_start", "_d_execBssBegAddr");
|
||||||
emitSymbolAddrGlobal(ir_->module, "_end", "_d_execBssEndAddr");
|
emitSymbolAddrGlobal(ir_->module, "_end", "_d_execBssEndAddr");
|
||||||
}
|
}
|
||||||
|
|
|
@ -972,12 +972,7 @@ int main(int argc, char **argv) {
|
||||||
{
|
{
|
||||||
llvm::Triple triple = llvm::Triple(gTargetMachine->getTargetTriple());
|
llvm::Triple triple = llvm::Triple(gTargetMachine->getTargetTriple());
|
||||||
global.params.targetTriple = triple;
|
global.params.targetTriple = triple;
|
||||||
global.params.isLinux = triple.getOS() == llvm::Triple::Linux;
|
|
||||||
global.params.isOSX = triple.isMacOSX();
|
|
||||||
global.params.isWindows = triple.isOSWindows();
|
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.isLP64 = gDataLayout->getPointerSizeInBits() == 64;
|
||||||
global.params.is64bit = triple.isArch64Bit();
|
global.params.is64bit = triple.isArch64Bit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ struct X86TargetABI : TargetABI {
|
||||||
IntegerRewrite integerRewrite;
|
IntegerRewrite integerRewrite;
|
||||||
|
|
||||||
X86TargetABI()
|
X86TargetABI()
|
||||||
: isOSX(global.params.isOSX),
|
: isOSX(global.params.targetTriple.isMacOSX()),
|
||||||
isMSVC(global.params.targetTriple.isWindowsMSVCEnvironment()) {
|
isMSVC(global.params.targetTriple.isWindowsMSVCEnvironment()) {
|
||||||
using llvm::Triple;
|
using llvm::Triple;
|
||||||
auto os = global.params.targetTriple.getOS();
|
auto os = global.params.targetTriple.getOS();
|
||||||
|
|
|
@ -935,7 +935,16 @@ static void genModuleInfo(Module *m, bool emitFullModuleInfo) {
|
||||||
b.finalize(moduleInfoSym->getType()->getPointerElementType(), moduleInfoSym);
|
b.finalize(moduleInfoSym->getType()->getPointerElementType(), moduleInfoSym);
|
||||||
moduleInfoSym->setLinkage(llvm::GlobalValue::ExternalLinkage);
|
moduleInfoSym->setLinkage(llvm::GlobalValue::ExternalLinkage);
|
||||||
|
|
||||||
if (global.params.isLinux || global.params.isFreeBSD) {
|
if (global.params.targetTriple.isOSLinux() || global.params.targetTriple.isOSFreeBSD() ||
|
||||||
|
#if LDC_LLVM_VER > 305
|
||||||
|
global.params.targetTriple.isOSNetBSD() || global.params.targetTriple.isOSOpenBSD() ||
|
||||||
|
global.params.targetTriple.isOSDragonFly()
|
||||||
|
#else
|
||||||
|
global.params.targetTriple.getOS() == llvm::Triple::NetBSD ||
|
||||||
|
global.params.targetTriple.getOS() == llvm::Triple::OpenBSD ||
|
||||||
|
global.params.targetTriple.getOS() == llvm::Triple::DragonFly
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
if (emitFullModuleInfo) {
|
if (emitFullModuleInfo) {
|
||||||
build_dso_registry_calls(mangle(m), moduleInfoSym);
|
build_dso_registry_calls(mangle(m), moduleInfoSym);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -652,7 +652,16 @@ static void buildRuntimeModule() {
|
||||||
{objectTy});
|
{objectTy});
|
||||||
|
|
||||||
// void _d_dso_registry(CompilerDSOData* data)
|
// void _d_dso_registry(CompilerDSOData* data)
|
||||||
if (global.params.isLinux || global.params.isFreeBSD) {
|
if (global.params.targetTriple.isOSLinux() || global.params.targetTriple.isOSFreeBSD() ||
|
||||||
|
#if LDC_LLVM_VER > 305
|
||||||
|
global.params.targetTriple.isOSNetBSD() || global.params.targetTriple.isOSOpenBSD() ||
|
||||||
|
global.params.targetTriple.isOSDragonFly()
|
||||||
|
#else
|
||||||
|
global.params.targetTriple.getOS() == llvm::Triple::NetBSD ||
|
||||||
|
global.params.targetTriple.getOS() == llvm::Triple::OpenBSD ||
|
||||||
|
global.params.targetTriple.getOS() == llvm::Triple::DragonFly
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
llvm::StringRef fname("_d_dso_registry");
|
llvm::StringRef fname("_d_dso_registry");
|
||||||
|
|
||||||
LLType *LLvoidTy = LLType::getVoidTy(gIR->context());
|
LLType *LLvoidTy = LLType::getVoidTy(gIR->context());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue