Removed redundant global.params.cpu field.

Now that we have global.params.targetTriple, the information
is only duplicated.
This commit is contained in:
David Nadlinger
2013-02-07 17:36:54 +01:00
parent bee0b9eba1
commit 5f3ba41574
13 changed files with 55 additions and 57 deletions
+4 -4
View File
@@ -69,13 +69,13 @@ struct UnknownTargetABI : TargetABI
TargetABI * TargetABI::getTarget()
{
switch(global.params.cpu)
switch (global.params.targetTriple.getArch())
{
case ARCHx86:
case llvm::Triple::x86:
return getX86TargetABI();
case ARCHx86_64:
case llvm::Triple::x86_64:
return getX86_64TargetABI();
case ARCHppc_64:
case llvm::Triple::ppc64:
return getPPC64TargetABI();
default:
Logger::cout() << "WARNING: Unknown ABI, guessing...\n";
+6 -4
View File
@@ -159,9 +159,11 @@ Statement *AsmStatement::semantic(Scope *sc)
#endif
bool err = false;
if ((global.params.cpu != ARCHx86) && (global.params.cpu != ARCHx86_64))
llvm::Triple const t = global.params.targetTriple;
if (!(t.getArch() == llvm::Triple::x86 || t.getArch() == llvm::Triple::x86_64))
{
error("inline asm is not supported for the \"%s\" architecture", global.params.targetTriple.getArchName().str().c_str());
error("inline asm is not supported for the \"%s\" architecture",
t.getArchName().str().c_str());
err = true;
}
if (!global.params.useInlineAsm)
@@ -185,9 +187,9 @@ Statement *AsmStatement::semantic(Scope *sc)
if (!asmparser)
{
if (global.params.cpu == ARCHx86)
if (t.getArch() == llvm::Triple::x86)
asmparser = new AsmParserx8632::AsmParser;
else if (global.params.cpu == ARCHx86_64)
else if (t.getArch() == llvm::Triple::x86_64)
asmparser = new AsmParserx8664::AsmParser;
}
+8 -2
View File
@@ -38,10 +38,16 @@ LLType* DtoComplexBaseType(Type* t)
case Tcomplex32: return LLType::getFloatTy(gIR->context());
case Tcomplex64: return LLType::getDoubleTy(gIR->context());
case Tcomplex80:
if ((global.params.cpu == ARCHx86) || (global.params.cpu == ARCHx86_64))
if ((global.params.targetTriple.getArch() == llvm::Triple::x86) ||
global.params.targetTriple.getArch() == llvm::Triple::x86_64)
{
return LLType::getX86_FP80Ty(gIR->context());
else if (global.params.cpu == ARCHppc || global.params.cpu == ARCHppc_64)
}
else if (global.params.targetTriple.getArch() == llvm::Triple::ppc ||
global.params.targetTriple.getArch() == llvm::Triple::ppc64)
{
return LLType::getPPC_FP128Ty(gIR->context());
}
else
return LLType::getDoubleTy(gIR->context());
}
+2 -2
View File
@@ -227,7 +227,7 @@ void emitABIReturnAsmStmt(IRAsmBlock* asmblock, Loc loc, FuncDeclaration* fdecl)
// It should be able to do this for a greater variety of types.
// x86
if (global.params.cpu == ARCHx86)
if (global.params.targetTriple.getArch() == llvm::Triple::x86)
{
LINK l = fdecl->linkage;
assert((l == LINKd || l == LINKc || l == LINKwindows) && "invalid linkage for asm implicit return");
@@ -301,7 +301,7 @@ void emitABIReturnAsmStmt(IRAsmBlock* asmblock, Loc loc, FuncDeclaration* fdecl)
}
// x86_64
else if (global.params.cpu == ARCHx86_64)
else if (global.params.targetTriple.getArch() == llvm::Triple::x86_64)
{
LINK l = fdecl->linkage;
/* TODO: Check if this works with extern(Windows), completely untested.
+11 -4
View File
@@ -65,15 +65,22 @@ llvm::CallingConv::ID DtoCallingConv(Loc loc, LINK l)
{
//TODO: StdCall is not a good base on Windows due to extra name mangling
// applied there
if (global.params.cpu == ARCHx86 || global.params.cpu == ARCHx86_64)
return (global.params.os != OSWindows) ? llvm::CallingConv::X86_StdCall : llvm::CallingConv::C;
if (global.params.targetTriple.getArch() == llvm::Triple::x86 ||
global.params.targetTriple.getArch() == llvm::Triple::x86_64)
{
return (global.params.os != OSWindows) ?
llvm::CallingConv::X86_StdCall : llvm::CallingConv::C;
}
else
return llvm::CallingConv::Fast;
}
// on the other hand, here, it's exactly what we want!!! TODO: right?
// On Windows 64bit, there is only one calling convention!
else if (l == LINKwindows)
return global.params.cpu == ARCHx86_64 ? llvm::CallingConv::C : llvm::CallingConv::X86_StdCall;
{
return (global.params.targetTriple.getArch() == llvm::Triple::x86_64) ?
llvm::CallingConv::C : llvm::CallingConv::X86_StdCall;
}
else if (l == LINKpascal)
return llvm::CallingConv::X86_StdCall;
else
@@ -92,7 +99,7 @@ DValue* DtoVaArg(Loc& loc, Type* type, Expression* valistArg)
if (DtoIsPassedByRef(type))
llt = getPtrToType(llt);
// issue a warning for broken va_arg instruction.
if (global.params.cpu != ARCHx86)
if (global.params.targetTriple.getArch() != llvm::Triple::x86)
warning(Loc(), "%s: va_arg for C variadic functions is probably broken for anything but x86", loc.toChars());
// done
return new DImValue(type, gIR->ir->CreateVAArg(expelem->getLVal(), llt, "tmp"));
+3 -2
View File
@@ -941,7 +941,7 @@ DValue* CallExp::toElem(IRState* p)
if (LLValue *argptr = gIR->func()->_argptr) {
DtoStore(DtoLoad(argptr), DtoBitCast(arg, getPtrToType(getVoidPtrType())));
return new DImValue(type, arg);
} else if (global.params.cpu == ARCHx86_64) {
} else if (global.params.targetTriple.getArch() == llvm::Triple::x86_64) {
LLValue *va_list = DtoAlloca(exp->type->nextOf());
DtoStore(va_list, arg);
va_list = DtoBitCast(va_list, getVoidPtrType());
@@ -954,7 +954,8 @@ DValue* CallExp::toElem(IRState* p)
}
}
#if DMDV2
else if (fndecl->llvmInternal == LLVMva_copy && global.params.cpu == ARCHx86_64) {
else if (fndecl->llvmInternal == LLVMva_copy &&
global.params.targetTriple.getArch() == llvm::Triple::x86_64) {
if (arguments->dim != 2) {
error("va_copy instruction expects 2 arguments");
return NULL;
+2 -2
View File
@@ -719,8 +719,8 @@ void TypeInfoStructDeclaration::llvmDefine()
// On x86_64, class TypeInfo_Struct contains 2 additional fields
// (m_arg1/m_arg2) which are used for the X86_64 System V ABI varargs
// implementation. They are not present on any other cpu/os.
assert((global.params.cpu != ARCHx86_64 && tscd->fields.dim == 11) ||
(global.params.cpu == ARCHx86_64 && tscd->fields.dim == 13));
assert((global.params.targetTriple.getArch() != llvm::Triple::x86_64 && tscd->fields.dim == 11) ||
(global.params.targetTriple.getArch() == llvm::Triple::x86_64 && tscd->fields.dim == 13));
//void function(void*) xdtor;
b.push_funcptr(sd->dtor);