mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 09:58:32 +00:00
Fix simarm64 bugs on Windows.
This fixes build errors and crashes when building simarm64 on Windows: 1. __int128 is not supported by Visual Studio. Use Multiply128 instead on Windows. 2. UL is 32-bit - replace with ULL when doing 64-bit math. R=zra@google.com Review-Url: https://codereview.chromium.org/2628043006 .
This commit is contained in:
parent
6f9dcaff9d
commit
050d2e3df9
|
@ -181,7 +181,7 @@ static int CountLeadingZeros(uint64_t value, int width) {
|
|||
|
||||
static int CountOneBits(uint64_t value, int width) {
|
||||
// Mask out unused bits to ensure that they are not counted.
|
||||
value &= (0xffffffffffffffffUL >> (64 - width));
|
||||
value &= (0xffffffffffffffffULL >> (64 - width));
|
||||
|
||||
value = ((value >> 1) & 0x5555555555555555) + (value & 0x5555555555555555);
|
||||
value = ((value >> 2) & 0x3333333333333333) + (value & 0x3333333333333333);
|
||||
|
@ -282,7 +282,7 @@ bool Operand::IsImmLogical(uint64_t value, uint8_t width, Operand* imm_op) {
|
|||
// 5. If the most-significant half of the bitwise value is equal to the
|
||||
// least-significant half, return to step 2 using the least-significant
|
||||
// half of the value.
|
||||
uint64_t mask = (1UL << (width >> 1)) - 1;
|
||||
uint64_t mask = (1ULL << (width >> 1)) - 1;
|
||||
if ((value & mask) == ((value >> (width >> 1)) & mask)) {
|
||||
width >>= 1;
|
||||
set_bits >>= 1;
|
||||
|
|
|
@ -810,7 +810,7 @@ static inline uint64_t RotateRight(uint64_t value,
|
|||
uint8_t width) {
|
||||
ASSERT(width <= 64);
|
||||
rotate &= 63;
|
||||
return ((value & ((1UL << rotate) - 1UL)) << (width - rotate)) |
|
||||
return ((value & ((1ULL << rotate) - 1ULL)) << (width - rotate)) |
|
||||
(value >> rotate);
|
||||
}
|
||||
|
||||
|
@ -820,7 +820,7 @@ static inline uint64_t RepeatBitsAcrossReg(uint8_t reg_size,
|
|||
ASSERT((width == 2) || (width == 4) || (width == 8) || (width == 16) ||
|
||||
(width == 32));
|
||||
ASSERT((reg_size == kWRegSizeInBits) || (reg_size == kXRegSizeInBits));
|
||||
uint64_t result = value & ((1UL << width) - 1UL);
|
||||
uint64_t result = value & ((1ULL << width) - 1ULL);
|
||||
for (unsigned i = width; i < reg_size; i *= 2) {
|
||||
result |= (result << i);
|
||||
}
|
||||
|
@ -1087,7 +1087,7 @@ class Instr {
|
|||
if (imm_s == 0x3F) {
|
||||
return 0;
|
||||
}
|
||||
uint64_t bits = (1UL << (imm_s + 1)) - 1;
|
||||
uint64_t bits = (1ULL << (imm_s + 1)) - 1;
|
||||
return RotateRight(bits, imm_r, 64);
|
||||
} else {
|
||||
if ((imm_s >> 1) == 0x1F) {
|
||||
|
@ -1099,7 +1099,7 @@ class Instr {
|
|||
if ((imm_s & mask) == mask) {
|
||||
return 0;
|
||||
}
|
||||
uint64_t bits = (1UL << ((imm_s & mask) + 1)) - 1;
|
||||
uint64_t bits = (1ULL << ((imm_s & mask) + 1)) - 1;
|
||||
return RepeatBitsAcrossReg(
|
||||
reg_size, RotateRight(bits, imm_r & mask, width), width);
|
||||
}
|
||||
|
|
|
@ -2656,18 +2656,30 @@ void Simulator::DecodeMiscDP3Source(Instr* instr) {
|
|||
// Format(instr, "smulh 'rd, 'rn, 'rm");
|
||||
const int64_t rn_val = get_register(rn, R31IsZR);
|
||||
const int64_t rm_val = get_register(rm, R31IsZR);
|
||||
#if defined(TARGET_OS_WINDOWS)
|
||||
// Visual Studio does not support __int128.
|
||||
int64_t alu_out;
|
||||
Multiply128(rn_val, rm_val, &alu_out);
|
||||
#else
|
||||
const __int128 res =
|
||||
static_cast<__int128>(rn_val) * static_cast<__int128>(rm_val);
|
||||
const int64_t alu_out = static_cast<int64_t>(res >> 64);
|
||||
#endif // TARGET_OS_WINDOWS
|
||||
set_register(instr, rd, alu_out, R31IsZR);
|
||||
} else if ((instr->Bits(29, 2) == 0) && (instr->Bits(21, 3) == 6) &&
|
||||
(instr->Bit(15) == 0)) {
|
||||
// Format(instr, "umulh 'rd, 'rn, 'rm");
|
||||
const uint64_t rn_val = get_register(rn, R31IsZR);
|
||||
const uint64_t rm_val = get_register(rm, R31IsZR);
|
||||
#if defined(TARGET_OS_WINDOWS)
|
||||
// Visual Studio does not support __int128.
|
||||
int64_t alu_out;
|
||||
Multiply128(rn_val, rm_val, &alu_out);
|
||||
#else
|
||||
const __int128 res =
|
||||
static_cast<__int128>(rn_val) * static_cast<__int128>(rm_val);
|
||||
const int64_t alu_out = static_cast<int64_t>(res >> 64);
|
||||
#endif // TARGET_OS_WINDOWS
|
||||
set_register(instr, rd, alu_out, R31IsZR);
|
||||
} else if ((instr->Bits(29, 3) == 4) && (instr->Bits(21, 3) == 5) &&
|
||||
(instr->Bit(15) == 0)) {
|
||||
|
|
Loading…
Reference in a new issue