Skip to content

Commit

Permalink
Revert "[target.d] refactor 64bit logic (#16669)" (#16815)
Browse files Browse the repository at this point in the history
This reverts commit a271bd1.
  • Loading branch information
WalterBright authored Aug 29, 2024
1 parent 0176845 commit 80a4a56
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 21 deletions.
15 changes: 7 additions & 8 deletions compiler/src/dmd/dmsc.d
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,15 @@ void backend_init(const ref Param params, const ref DMDparams driverParams, cons
{
//printf("backend_init()\n");
exefmt_t exfmt;
const is64 = target.isLP64;
switch (target.os)
{
case Target.OS.Windows: exfmt = is64 ? EX_WIN64 : EX_WIN32; break;
case Target.OS.linux: exfmt = is64 ? EX_LINUX64 : EX_LINUX; break;
case Target.OS.OSX: exfmt = is64 ? EX_OSX64 : EX_OSX; break;
case Target.OS.FreeBSD: exfmt = is64 ? EX_FREEBSD64 : EX_FREEBSD; break;
case Target.OS.OpenBSD: exfmt = is64 ? EX_OPENBSD64 : EX_OPENBSD; break;
case Target.OS.Solaris: exfmt = is64 ? EX_SOLARIS64 : EX_SOLARIS; break;
case Target.OS.DragonFlyBSD: assert(is64); exfmt = EX_DRAGONFLYBSD64; break;
case Target.OS.Windows: exfmt = target.isX86_64 ? EX_WIN64 : EX_WIN32; break;
case Target.OS.linux: exfmt = target.isX86_64 ? EX_LINUX64 : EX_LINUX; break;
case Target.OS.OSX: exfmt = target.isX86_64 ? EX_OSX64 : EX_OSX; break;
case Target.OS.FreeBSD: exfmt = target.isX86_64 ? EX_FREEBSD64 : EX_FREEBSD; break;
case Target.OS.OpenBSD: exfmt = target.isX86_64 ? EX_OPENBSD64 : EX_OPENBSD; break;
case Target.OS.Solaris: exfmt = target.isX86_64 ? EX_SOLARIS64 : EX_SOLARIS; break;
case Target.OS.DragonFlyBSD: exfmt = EX_DRAGONFLYBSD64; break;
default: assert(0);
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dmd/glue.d
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ public void FuncDeclaration_toObjFile(FuncDeclaration fd, bool multiobj)
if (fd.v_argptr)
{
// Declare va_argsave
if (target.isLP64 &&
if (target.isX86_64 &&
target.os & Target.OS.Posix)
{
type *t = type_struct_class("__va_argsave_t", 16, 8 * 6 + 8 * 16 + 8 * 3 + 8, null, null, false, false, true, false);
Expand Down
22 changes: 11 additions & 11 deletions compiler/src/dmd/target.d
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ extern (C++) struct Target
}
else
assert(0);
if (isLP64)
if (isX86_64)
{
if (os & (Target.OS.linux | Target.OS.FreeBSD | Target.OS.OpenBSD | Target.OS.DragonFlyBSD | Target.OS.Solaris))
{
Expand Down Expand Up @@ -605,7 +605,7 @@ extern (C++) struct Target
{
const size = type.alignsize();

if ((isLP64 || os == Target.OS.OSX) && (size == 16 || size == 32))
if ((isX86_64 || os == Target.OS.OSX) && (size == 16 || size == 32))
return size;

return (8 < size) ? 8 : size;
Expand All @@ -630,7 +630,7 @@ extern (C++) struct Target
}
else if (os & Target.OS.Posix)
{
if (isLP64)
if (isX86_64)
{
import dmd.identifier : Identifier;
import dmd.mtype : TypeIdentifier;
Expand Down Expand Up @@ -957,7 +957,7 @@ extern (C++) struct Target
{
import dmd.argtypes_x86 : toArgTypes_x86;
import dmd.argtypes_sysv_x64 : toArgTypes_sysv_x64;
if (isLP64)
if (isX86_64)
{
// no argTypes for Win64 yet
return isPOSIX ? toArgTypes_sysv_x64(t) : null;
Expand Down Expand Up @@ -1005,7 +1005,7 @@ extern (C++) struct Target
const sz = tn.size();
Type tns = tn;

if (os == Target.OS.Windows && isLP64)
if (os == Target.OS.Windows && isX86_64)
{
// https://msdn.microsoft.com/en-us/library/7572ztz4%28v=vs.100%29.aspx
if (tns.ty == TY.Tcomplex32)
Expand Down Expand Up @@ -1039,7 +1039,7 @@ extern (C++) struct Target
return true;
}
}
else if (isLP64 && isPOSIX)
else if (isX86_64 && isPOSIX)
{
TypeTuple tt = toArgTypes_sysv_x64(tn);
if (!tt)
Expand Down Expand Up @@ -1114,7 +1114,7 @@ extern (C++) struct Target
return false; // return small structs in regs
// (not 3 byte structs!)
case 16:
if (os & Target.OS.Posix && isLP64)
if (os & Target.OS.Posix && isX86_64)
return false;
break;

Expand Down Expand Up @@ -1163,7 +1163,7 @@ extern (C++) struct Target
extern (C++) bool preferPassByRef(Type t)
{
const size = t.size();
if (isLP64)
if (isX86_64)
{
if (os == Target.OS.Windows)
{
Expand Down Expand Up @@ -1405,14 +1405,14 @@ struct TargetC
longsize = 4;
else
assert(0);
if (target.isLP64)
if (target.isX86_64)
{
if (os & (Target.OS.linux | Target.OS.FreeBSD | Target.OS.OpenBSD | Target.OS.DragonFlyBSD | Target.OS.Solaris))
longsize = 8;
else if (os == Target.OS.OSX)
longsize = 8;
}
if (target.isLP64 && os == Target.OS.Windows)
if (target.isX86_64 && os == Target.OS.Windows)
long_doublesize = 8;
else
long_doublesize = target.realsize;
Expand Down Expand Up @@ -1626,7 +1626,7 @@ struct TargetObjC

extern (D) void initialize(ref const Param params, ref const Target target) @safe
{
if (target.os == Target.OS.OSX && target.isLP64)
if (target.os == Target.OS.OSX && target.isX86_64)
supported = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dmd/todt.d
Original file line number Diff line number Diff line change
Expand Up @@ -1417,7 +1417,7 @@ private extern (C++) class TypeInfoDtVisitor : Visitor
override void visit(TypeInfoStructDeclaration d)
{
//printf("TypeInfoStructDeclaration.toDt() '%s'\n", d.toChars());
if (target.isLP64)
if (target.isX86_64)
verifyStructSize(Type.typeinfostruct, 17 * target.ptrsize);
else
verifyStructSize(Type.typeinfostruct, 15 * target.ptrsize);
Expand Down

0 comments on commit 80a4a56

Please sign in to comment.