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.
This commit is contained in:
David Nadlinger
2013-02-07 17:13:24 +01:00
parent 4e02f41f31
commit d4b391249d
15 changed files with 71 additions and 59 deletions

View File

@@ -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);
}

View File

@@ -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());
}

View File

@@ -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;
}

View File

@@ -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)

View File

@@ -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());
}