cbe: changes to get zig2.c compiling under msvc
- Add cpuid / getXCR0 functions for the cbe to use instead of asm blocks - Don't cast between 128 bit types during truncation - Fixup truncation to use functions for shifts / adds - Fixup float casts for undefined values - Add test for 128 bit integer truncation
This commit is contained in:
@@ -37,6 +37,20 @@ test "truncate to non-power-of-two integers" {
|
||||
try testTrunc(i32, i5, std.math.maxInt(i32), -1);
|
||||
}
|
||||
|
||||
test "truncate to non-power-of-two integers from 128-bit" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
try testTrunc(u128, u1, 0xffffffff_ffffffff_ffffffff_01010101, 0x01);
|
||||
try testTrunc(u128, u1, 0xffffffff_ffffffff_ffffffff_01010110, 0x00);
|
||||
try testTrunc(u128, u2, 0xffffffff_ffffffff_ffffffff_01010101, 0x01);
|
||||
try testTrunc(u128, u2, 0xffffffff_ffffffff_ffffffff_01010102, 0x02);
|
||||
try testTrunc(i128, i5, -4, -4);
|
||||
try testTrunc(i128, i5, 4, 4);
|
||||
try testTrunc(i128, i5, -28, 4);
|
||||
try testTrunc(i128, i5, 28, -4);
|
||||
try testTrunc(i128, i5, std.math.maxInt(i128), -1);
|
||||
}
|
||||
|
||||
fn testTrunc(comptime Big: type, comptime Little: type, big: Big, little: Little) !void {
|
||||
try expect(@truncate(Little, big) == little);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user