Skip to content

Commit

Permalink
make X86 a positive affirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed May 30, 2024
1 parent 1dae282 commit 41eb76a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
5 changes: 4 additions & 1 deletion compiler/src/dmd/frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -7542,6 +7542,7 @@ struct Target final
_d_dynamicArray< const char > architectureName;
CPU cpu;
bool isX86_64;
bool isX86;
bool isLP64;
_d_dynamicArray< const char > obj_ext;
_d_dynamicArray< const char > lib_ext;
Expand Down Expand Up @@ -7613,6 +7614,7 @@ struct Target final
objc(),
architectureName(),
isX86_64(),
isX86(),
isLP64(),
obj_ext(),
lib_ext(),
Expand All @@ -7625,7 +7627,7 @@ struct Target final
params()
{
}
Target(OS os, uint8_t osMajor = 0u, uint8_t ptrsize = 0u, uint8_t realsize = 0u, uint8_t realpad = 0u, uint8_t realalignsize = 0u, uint8_t classinfosize = 0u, uint64_t maxStaticDataSize = 0LLU, TargetC c = TargetC(), TargetCPP cpp = TargetCPP(), TargetObjC objc = TargetObjC(), _d_dynamicArray< const char > architectureName = {}, CPU cpu = (CPU)0u, bool isX86_64 = false, bool isLP64 = false, _d_dynamicArray< const char > obj_ext = {}, _d_dynamicArray< const char > lib_ext = {}, _d_dynamicArray< const char > dll_ext = {}, bool run_noext = false, FPTypeProperties<float > FloatProperties = FPTypeProperties<float >(), FPTypeProperties<double > DoubleProperties = FPTypeProperties<double >(), FPTypeProperties<_d_real > RealProperties = FPTypeProperties<_d_real >(), Type* tvalist = nullptr, const Param* params = nullptr) :
Target(OS os, uint8_t osMajor = 0u, uint8_t ptrsize = 0u, uint8_t realsize = 0u, uint8_t realpad = 0u, uint8_t realalignsize = 0u, uint8_t classinfosize = 0u, uint64_t maxStaticDataSize = 0LLU, TargetC c = TargetC(), TargetCPP cpp = TargetCPP(), TargetObjC objc = TargetObjC(), _d_dynamicArray< const char > architectureName = {}, CPU cpu = (CPU)0u, bool isX86_64 = false, bool isX86 = false, bool isLP64 = false, _d_dynamicArray< const char > obj_ext = {}, _d_dynamicArray< const char > lib_ext = {}, _d_dynamicArray< const char > dll_ext = {}, bool run_noext = false, FPTypeProperties<float > FloatProperties = FPTypeProperties<float >(), FPTypeProperties<double > DoubleProperties = FPTypeProperties<double >(), FPTypeProperties<_d_real > RealProperties = FPTypeProperties<_d_real >(), Type* tvalist = nullptr, const Param* params = nullptr) :
os(os),
osMajor(osMajor),
ptrsize(ptrsize),
Expand All @@ -7640,6 +7642,7 @@ struct Target final
architectureName(architectureName),
cpu(cpu),
isX86_64(isX86_64),
isX86(isX86),
isLP64(isLP64),
obj_ext(obj_ext),
lib_ext(lib_ext),
Expand Down
3 changes: 3 additions & 0 deletions compiler/src/dmd/mars.d
Original file line number Diff line number Diff line change
Expand Up @@ -883,14 +883,17 @@ bool parseCommandLine(const ref Strings arguments, const size_t argc, ref Param
}
else if (arg == "-m32") // https://dlang.org/dmd.html#switch-m32
{
target.isX86 = true;
target.isX86_64 = false;
}
else if (arg == "-m64") // https://dlang.org/dmd.html#switch-m64
{
target.isX86 = false;
target.isX86_64 = true;
}
else if (arg == "-m32mscoff") // https://dlang.org/dmd.html#switch-m32mscoff
{
target.isX86 = true;
target.isX86_64 = false;
}
else if (startsWith(p + 1, "mscrtlib="))
Expand Down
12 changes: 10 additions & 2 deletions compiler/src/dmd/target.d
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ extern (C++) struct Target
const(char)[] architectureName;
CPU cpu; // CPU instruction set to target
bool isX86_64; // generate 64 bit code for x86_64; true by default for 64 bit dmd
bool isX86 = true; // generate 32 bit Intel x86 code
bool isLP64; // pointers are 64 bits

// Environmental
Expand Down Expand Up @@ -403,6 +404,7 @@ extern (C++) struct Target
extern (C++) void _init(ref const Param params)
{
// isX86_64 and cpu are initialized in parseCommandLine
assert(isX86 != isX86_64);

this.params = &params;

Expand Down Expand Up @@ -1329,7 +1331,13 @@ extern (C++) struct Target
*/
extern (D) uint stackAlign() @safe
{
return isXmmSupported() ? 16 : (isX86_64 ? 8 : 4);
assert(isX86_64 != isX86);
uint sz = isXmmSupported() ? 16 :
isX86_64 ? 8 :
isX86 ? 4 : 0;
assert(sz);
return sz;
// return isXmmSupported() ? 16 : (isX86_64 ? 8 : 4);
}
}

Expand Down Expand Up @@ -1482,7 +1490,7 @@ struct TargetCPP
else
assert(0);
// C++ and D ABI incompatible on all (?) x86 32-bit platforms
wrapDtorInExternD = !target.isX86_64;
wrapDtorInExternD = target.isX86;
}

/**
Expand Down
1 change: 1 addition & 0 deletions compiler/src/dmd/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ struct Target
DString architectureName; // name of the platform architecture (e.g. X86_64)
CPU cpu; // CPU instruction set to target
d_bool isX86_64; // generate 64 bit code for x86_64; true by default for 64 bit dmd
d_bool isX86; // generate 32 bit Intel x86 code
d_bool isLP64; // pointers are 64 bits

// Environmental
Expand Down

0 comments on commit 41eb76a

Please sign in to comment.