authorgravatar for marc@tiehu.isMarc Tiehuis <marc@tiehu.is> 2018-06-30 19:57:17+12:00
committergravatar for marc@tiehu.isMarc Tiehuis <marc@tiehu.is> 2018-06-30 21:58:59+12:00
log814a34f263cbfeabbf7a898b3b70fa781baaccac
tree7a0c74c058b5c3113183ef0966b2f6387b826128
parent53fef94b9fb2b04d208a0671aa58e90f93f412cf

compiler_rt: Add floattitf/floattidf/floattisf


7 files changed, 451 insertions(+), 0 deletions(-)

std/special/compiler_rt/floattidf.zig created+69
...@@ -0,0 +1,69 @@
1const builtin = @import("builtin");
2const is_test = builtin.is_test;
3
4const DBL_MANT_DIG = 53;
5
6pub extern fn __floattidf(arg: i128) f64 {
7 @setRuntimeSafety(is_test);
8
9 if (arg == 0)
10 return 0.0;
11
12 var ai = arg;
13 const N: u32 = 128;
14 const si = ai >> @intCast(u7, (N - 1));
15 ai = ((ai ^ si) -% si);
16 var a = @bitCast(u128, ai);
17
18 const sd = @bitCast(i32, N - @clz(a)); // number of significant digits
19 var e: i32 = sd - 1; // exponent
20 if (sd > DBL_MANT_DIG) {
21 // start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx
22 // finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR
23 // 12345678901234567890123456
24 // 1 = msb 1 bit
25 // P = bit DBL_MANT_DIG-1 bits to the right of 1
26 // Q = bit DBL_MANT_DIG bits to the right of 1
27 // R = "or" of all bits to the right of Q
28 switch (sd) {
29 DBL_MANT_DIG + 1 => {
30 a <<= 1;
31 },
32 DBL_MANT_DIG + 2 => {},
33 else => {
34 const shift1_amt = @intCast(i32, sd - (DBL_MANT_DIG + 2));
35 const shift1_amt_u7 = @intCast(u7, shift1_amt);
36
37 const shift2_amt = @intCast(i32, N + (DBL_MANT_DIG + 2)) - sd;
38 const shift2_amt_u7 = @intCast(u7, shift2_amt);
39
40 a = (a >> shift1_amt_u7) | @boolToInt((a & (@intCast(u128, @maxValue(u128)) >> shift2_amt_u7)) != 0);
41 },
42 }
43 // finish
44 a |= @boolToInt((a & 4) != 0); // Or P into R
45 a +%= 1; // round - this step may add a significant bit
46 a >>= 2; // dump Q and R
47 // a is now rounded to DBL_MANT_DIG or DBL_MANT_DIG+1 bits
48 if ((a & (u128(1) << DBL_MANT_DIG)) != 0) {
49 a >>= 1;
50 e +%= 1;
51 }
52 // a is now rounded to DBL_MANT_DIG bits
53 } else {
54 a <<= @intCast(u7, DBL_MANT_DIG - sd);
55 // a is now rounded to DBL_MANT_DIG bits
56 }
57
58 const s = @bitCast(u128, arg) >> (128 - 32);
59 const high: u64 = (@intCast(u64, s) & 0x80000000) | // sign
60 (@intCast(u32, (e + 1023)) << 20) | // exponent
61 (@truncate(u32, a >> 32) & 0x000fffff); // mantissa-high
62 const low: u64 = @truncate(u32, a); // mantissa-low
63
64 return @bitCast(f64, low | (high << 32));
65}
66
67test "import floattidf" {
68 _ = @import("floattidf_test.zig");
69}
std/special/compiler_rt/floattidf_test.zig created+84
...@@ -0,0 +1,84 @@
1const __floattidf = @import("floattidf.zig").__floattidf;
2const assert = @import("std").debug.assert;
3
4fn test__floattidf(a: i128, expected: f64) void {
5 const x = __floattidf(a);
6 assert(x == expected);
7}
8
9test "floattidf" {
10 test__floattidf(0, 0.0);
11
12 test__floattidf(1, 1.0);
13 test__floattidf(2, 2.0);
14 test__floattidf(20, 20.0);
15 test__floattidf(-1, -1.0);
16 test__floattidf(-2, -2.0);
17 test__floattidf(-20, -20.0);
18
19 test__floattidf(0x7FFFFF8000000000, 0x1.FFFFFEp+62);
20 test__floattidf(0x7FFFFFFFFFFFF800, 0x1.FFFFFFFFFFFFEp+62);
21 test__floattidf(0x7FFFFF0000000000, 0x1.FFFFFCp+62);
22 test__floattidf(0x7FFFFFFFFFFFF000, 0x1.FFFFFFFFFFFFCp+62);
23
24 test__floattidf(make_ti(0x8000008000000000, 0), -0x1.FFFFFEp+126);
25 test__floattidf(make_ti(0x8000000000000800, 0), -0x1.FFFFFFFFFFFFEp+126);
26 test__floattidf(make_ti(0x8000010000000000, 0), -0x1.FFFFFCp+126);
27 test__floattidf(make_ti(0x8000000000001000, 0), -0x1.FFFFFFFFFFFFCp+126);
28
29 test__floattidf(make_ti(0x8000000000000000, 0), -0x1.000000p+127);
30 test__floattidf(make_ti(0x8000000000000001, 0), -0x1.000000p+127);
31
32 test__floattidf(0x0007FB72E8000000, 0x1.FEDCBAp+50);
33
34 test__floattidf(0x0007FB72EA000000, 0x1.FEDCBA8p+50);
35 test__floattidf(0x0007FB72EB000000, 0x1.FEDCBACp+50);
36 test__floattidf(0x0007FB72EBFFFFFF, 0x1.FEDCBAFFFFFFCp+50);
37 test__floattidf(0x0007FB72EC000000, 0x1.FEDCBBp+50);
38 test__floattidf(0x0007FB72E8000001, 0x1.FEDCBA0000004p+50);
39
40 test__floattidf(0x0007FB72E6000000, 0x1.FEDCB98p+50);
41 test__floattidf(0x0007FB72E7000000, 0x1.FEDCB9Cp+50);
42 test__floattidf(0x0007FB72E7FFFFFF, 0x1.FEDCB9FFFFFFCp+50);
43 test__floattidf(0x0007FB72E4000001, 0x1.FEDCB90000004p+50);
44 test__floattidf(0x0007FB72E4000000, 0x1.FEDCB9p+50);
45
46 test__floattidf(0x023479FD0E092DC0, 0x1.1A3CFE870496Ep+57);
47 test__floattidf(0x023479FD0E092DA1, 0x1.1A3CFE870496Dp+57);
48 test__floattidf(0x023479FD0E092DB0, 0x1.1A3CFE870496Ep+57);
49 test__floattidf(0x023479FD0E092DB8, 0x1.1A3CFE870496Ep+57);
50 test__floattidf(0x023479FD0E092DB6, 0x1.1A3CFE870496Ep+57);
51 test__floattidf(0x023479FD0E092DBF, 0x1.1A3CFE870496Ep+57);
52 test__floattidf(0x023479FD0E092DC1, 0x1.1A3CFE870496Ep+57);
53 test__floattidf(0x023479FD0E092DC7, 0x1.1A3CFE870496Ep+57);
54 test__floattidf(0x023479FD0E092DC8, 0x1.1A3CFE870496Ep+57);
55 test__floattidf(0x023479FD0E092DCF, 0x1.1A3CFE870496Ep+57);
56 test__floattidf(0x023479FD0E092DD0, 0x1.1A3CFE870496Ep+57);
57 test__floattidf(0x023479FD0E092DD1, 0x1.1A3CFE870496Fp+57);
58 test__floattidf(0x023479FD0E092DD8, 0x1.1A3CFE870496Fp+57);
59 test__floattidf(0x023479FD0E092DDF, 0x1.1A3CFE870496Fp+57);
60 test__floattidf(0x023479FD0E092DE0, 0x1.1A3CFE870496Fp+57);
61
62 test__floattidf(make_ti(0x023479FD0E092DC0, 0), 0x1.1A3CFE870496Ep+121);
63 test__floattidf(make_ti(0x023479FD0E092DA1, 1), 0x1.1A3CFE870496Dp+121);
64 test__floattidf(make_ti(0x023479FD0E092DB0, 2), 0x1.1A3CFE870496Ep+121);
65 test__floattidf(make_ti(0x023479FD0E092DB8, 3), 0x1.1A3CFE870496Ep+121);
66 test__floattidf(make_ti(0x023479FD0E092DB6, 4), 0x1.1A3CFE870496Ep+121);
67 test__floattidf(make_ti(0x023479FD0E092DBF, 5), 0x1.1A3CFE870496Ep+121);
68 test__floattidf(make_ti(0x023479FD0E092DC1, 6), 0x1.1A3CFE870496Ep+121);
69 test__floattidf(make_ti(0x023479FD0E092DC7, 7), 0x1.1A3CFE870496Ep+121);
70 test__floattidf(make_ti(0x023479FD0E092DC8, 8), 0x1.1A3CFE870496Ep+121);
71 test__floattidf(make_ti(0x023479FD0E092DCF, 9), 0x1.1A3CFE870496Ep+121);
72 test__floattidf(make_ti(0x023479FD0E092DD0, 0), 0x1.1A3CFE870496Ep+121);
73 test__floattidf(make_ti(0x023479FD0E092DD1, 11), 0x1.1A3CFE870496Fp+121);
74 test__floattidf(make_ti(0x023479FD0E092DD8, 12), 0x1.1A3CFE870496Fp+121);
75 test__floattidf(make_ti(0x023479FD0E092DDF, 13), 0x1.1A3CFE870496Fp+121);
76 test__floattidf(make_ti(0x023479FD0E092DE0, 14), 0x1.1A3CFE870496Fp+121);
77}
78
79fn make_ti(high: u64, low: u64) i128 {
80 var result: u128 = high;
81 result <<= 64;
82 result |= low;
83 return @bitCast(i128, result);
84}
std/special/compiler_rt/floattisf.zig created+69
...@@ -0,0 +1,69 @@
1const builtin = @import("builtin");
2const is_test = builtin.is_test;
3
4const FLT_MANT_DIG = 24;
5
6pub extern fn __floattisf(arg: i128) f32 {
7 @setRuntimeSafety(is_test);
8
9 if (arg == 0)
10 return 0.0;
11
12 var ai = arg;
13 const N: u32 = 128;
14 const si = ai >> @intCast(u7, (N - 1));
15 ai = ((ai ^ si) -% si);
16 var a = @bitCast(u128, ai);
17
18 const sd = @bitCast(i32, N - @clz(a)); // number of significant digits
19 var e: i32 = sd - 1; // exponent
20
21 if (sd > FLT_MANT_DIG) {
22 // start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx
23 // finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR
24 // 12345678901234567890123456
25 // 1 = msb 1 bit
26 // P = bit FLT_MANT_DIG-1 bits to the right of 1
27 // Q = bit FLT_MANT_DIG bits to the right of 1
28 // R = "or" of all bits to the right of Q
29 switch (sd) {
30 FLT_MANT_DIG + 1 => {
31 a <<= 1;
32 },
33 FLT_MANT_DIG + 2 => {},
34 else => {
35 const shift1_amt = @intCast(i32, sd - (FLT_MANT_DIG + 2));
36 const shift1_amt_u7 = @intCast(u7, shift1_amt);
37
38 const shift2_amt = @intCast(i32, N + (FLT_MANT_DIG + 2)) - sd;
39 const shift2_amt_u7 = @intCast(u7, shift2_amt);
40
41 a = (a >> shift1_amt_u7) | @boolToInt((a & (@intCast(u128, @maxValue(u128)) >> shift2_amt_u7)) != 0);
42 },
43 }
44 // finish
45 a |= @boolToInt((a & 4) != 0); // Or P into R
46 a +%= 1; // round - this step may add a significant bit
47 a >>= 2; // dump Q and R
48 // a is now rounded to FLT_MANT_DIG or FLT_MANT_DIG+1 bits
49 if ((a & (u128(1) << FLT_MANT_DIG)) != 0) {
50 a >>= 1;
51 e +%= 1;
52 }
53 // a is now rounded to FLT_MANT_DIG bits
54 } else {
55 a <<= @intCast(u7, FLT_MANT_DIG - sd);
56 // a is now rounded to FLT_MANT_DIG bits
57 }
58
59 const s = @bitCast(u128, arg) >> (128 - 32);
60 const r = (@intCast(u32, s) & 0x80000000) | // sign
61 (@intCast(u32, (e + 127)) << 23) | // exponent
62 (@truncate(u32, a) & 0x007fffff); // mantissa-high
63
64 return @bitCast(f32, r);
65}
66
67test "import floattisf" {
68 _ = @import("floattisf_test.zig");
69}
std/special/compiler_rt/floattisf_test.zig created+60
...@@ -0,0 +1,60 @@
1const __floattisf = @import("floattisf.zig").__floattisf;
2const assert = @import("std").debug.assert;
3
4fn test__floattisf(a: i128, expected: f32) void {
5 const x = __floattisf(a);
6 assert(x == expected);
7}
8
9test "floattisf" {
10 test__floattisf(0, 0.0);
11
12 test__floattisf(1, 1.0);
13 test__floattisf(2, 2.0);
14 test__floattisf(-1, -1.0);
15 test__floattisf(-2, -2.0);
16
17 test__floattisf(0x7FFFFF8000000000, 0x1.FFFFFEp+62);
18 test__floattisf(0x7FFFFF0000000000, 0x1.FFFFFCp+62);
19
20 test__floattisf(make_ti(0xFFFFFFFFFFFFFFFF, 0x8000008000000000), -0x1.FFFFFEp+62);
21 test__floattisf(make_ti(0xFFFFFFFFFFFFFFFF, 0x8000010000000000), -0x1.FFFFFCp+62);
22
23 test__floattisf(make_ti(0xFFFFFFFFFFFFFFFF, 0x8000000000000000), -0x1.000000p+63);
24 test__floattisf(make_ti(0xFFFFFFFFFFFFFFFF, 0x8000000000000001), -0x1.000000p+63);
25
26 test__floattisf(0x0007FB72E8000000, 0x1.FEDCBAp+50);
27
28 test__floattisf(0x0007FB72EA000000, 0x1.FEDCBAp+50);
29 test__floattisf(0x0007FB72EB000000, 0x1.FEDCBAp+50);
30 test__floattisf(0x0007FB72EBFFFFFF, 0x1.FEDCBAp+50);
31 test__floattisf(0x0007FB72EC000000, 0x1.FEDCBCp+50);
32 test__floattisf(0x0007FB72E8000001, 0x1.FEDCBAp+50);
33
34 test__floattisf(0x0007FB72E6000000, 0x1.FEDCBAp+50);
35 test__floattisf(0x0007FB72E7000000, 0x1.FEDCBAp+50);
36 test__floattisf(0x0007FB72E7FFFFFF, 0x1.FEDCBAp+50);
37 test__floattisf(0x0007FB72E4000001, 0x1.FEDCBAp+50);
38 test__floattisf(0x0007FB72E4000000, 0x1.FEDCB8p+50);
39
40 test__floattisf(make_ti(0x0007FB72E8000000, 0), 0x1.FEDCBAp+114);
41
42 test__floattisf(make_ti(0x0007FB72EA000000, 0), 0x1.FEDCBAp+114);
43 test__floattisf(make_ti(0x0007FB72EB000000, 0), 0x1.FEDCBAp+114);
44 test__floattisf(make_ti(0x0007FB72EBFFFFFF, 0), 0x1.FEDCBAp+114);
45 test__floattisf(make_ti(0x0007FB72EC000000, 0), 0x1.FEDCBCp+114);
46 test__floattisf(make_ti(0x0007FB72E8000001, 0), 0x1.FEDCBAp+114);
47
48 test__floattisf(make_ti(0x0007FB72E6000000, 0), 0x1.FEDCBAp+114);
49 test__floattisf(make_ti(0x0007FB72E7000000, 0), 0x1.FEDCBAp+114);
50 test__floattisf(make_ti(0x0007FB72E7FFFFFF, 0), 0x1.FEDCBAp+114);
51 test__floattisf(make_ti(0x0007FB72E4000001, 0), 0x1.FEDCBAp+114);
52 test__floattisf(make_ti(0x0007FB72E4000000, 0), 0x1.FEDCB8p+114);
53}
54
55fn make_ti(high: u64, low: u64) i128 {
56 var result: u128 = high;
57 result <<= 64;
58 result |= low;
59 return @bitCast(i128, result);
60}
std/special/compiler_rt/floattitf.zig created+69
...@@ -0,0 +1,69 @@
1const builtin = @import("builtin");
2const is_test = builtin.is_test;
3
4const LDBL_MANT_DIG = 113;
5
6pub extern fn __floattitf(arg: i128) f128 {
7 @setRuntimeSafety(is_test);
8
9 if (arg == 0)
10 return 0.0;
11
12 var ai = arg;
13 const N: u32 = 128;
14 const si = ai >> @intCast(u7, (N - 1));
15 ai = ((ai ^ si) -% si);
16 var a = @bitCast(u128, ai);
17
18 const sd = @bitCast(i32, N - @clz(a)); // number of significant digits
19 var e: i32 = sd - 1; // exponent
20 if (sd > LDBL_MANT_DIG) {
21 // start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx
22 // finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR
23 // 12345678901234567890123456
24 // 1 = msb 1 bit
25 // P = bit LDBL_MANT_DIG-1 bits to the right of 1
26 // Q = bit LDBL_MANT_DIG bits to the right of 1
27 // R = "or" of all bits to the right of Q
28 switch (sd) {
29 LDBL_MANT_DIG + 1 => {
30 a <<= 1;
31 },
32 LDBL_MANT_DIG + 2 => {},
33 else => {
34 const shift1_amt = @intCast(i32, sd - (LDBL_MANT_DIG + 2));
35 const shift1_amt_u7 = @intCast(u7, shift1_amt);
36
37 const shift2_amt = @intCast(i32, N + (LDBL_MANT_DIG + 2)) - sd;
38 const shift2_amt_u7 = @intCast(u7, shift2_amt);
39
40 a = (a >> shift1_amt_u7) | @boolToInt((a & (@intCast(u128, @maxValue(u128)) >> shift2_amt_u7)) != 0);
41 },
42 }
43 // finish
44 a |= @boolToInt((a & 4) != 0); // Or P into R
45 a +%= 1; // round - this step may add a significant bit
46 a >>= 2; // dump Q and R
47 // a is now rounded to LDBL_MANT_DIG or LDBL_MANT_DIG+1 bits
48 if ((a & (u128(1) << LDBL_MANT_DIG)) != 0) {
49 a >>= 1;
50 e +%= 1;
51 }
52 // a is now rounded to LDBL_MANT_DIG bits
53 } else {
54 a <<= @intCast(u7, LDBL_MANT_DIG - sd);
55 // a is now rounded to LDBL_MANT_DIG bits
56 }
57
58 const s = @bitCast(u128, arg) >> (128 - 64);
59 const high: u128 = (@intCast(u64, s) & 0x8000000000000000) | // sign
60 (@intCast(u64, (e + 16383)) << 48) | // exponent
61 (@truncate(u64, a >> 64) & 0x0000ffffffffffff); // mantissa-high
62 const low = @truncate(u64, a); // mantissa-low
63
64 return @bitCast(f128, low | (high << 64));
65}
66
67test "import floattitf" {
68 _ = @import("floattitf_test.zig");
69}
std/special/compiler_rt/floattitf_test.zig created+96
...@@ -0,0 +1,96 @@
1const __floattitf = @import("floattitf.zig").__floattitf;
2const assert = @import("std").debug.assert;
3
4fn test__floattitf(a: i128, expected: f128) void {
5 const x = __floattitf(a);
6 assert(x == expected);
7}
8
9test "floattitf" {
10 test__floattitf(0, 0.0);
11
12 test__floattitf(1, 1.0);
13 test__floattitf(2, 2.0);
14 test__floattitf(20, 20.0);
15 test__floattitf(-1, -1.0);
16 test__floattitf(-2, -2.0);
17 test__floattitf(-20, -20.0);
18
19 test__floattitf(0x7FFFFF8000000000, 0x1.FFFFFEp+62);
20 test__floattitf(0x7FFFFFFFFFFFF800, 0x1.FFFFFFFFFFFFEp+62);
21 test__floattitf(0x7FFFFF0000000000, 0x1.FFFFFCp+62);
22 test__floattitf(0x7FFFFFFFFFFFF000, 0x1.FFFFFFFFFFFFCp+62);
23
24 test__floattitf(make_ti(0x8000008000000000, 0), -0x1.FFFFFEp+126);
25 test__floattitf(make_ti(0x8000000000000800, 0), -0x1.FFFFFFFFFFFFEp+126);
26 test__floattitf(make_ti(0x8000010000000000, 0), -0x1.FFFFFCp+126);
27 test__floattitf(make_ti(0x8000000000001000, 0), -0x1.FFFFFFFFFFFFCp+126);
28
29 test__floattitf(make_ti(0x8000000000000000, 0), -0x1.000000p+127);
30 test__floattitf(make_ti(0x8000000000000001, 0), -0x1.FFFFFFFFFFFFFFFCp+126);
31
32 test__floattitf(0x0007FB72E8000000, 0x1.FEDCBAp+50);
33
34 test__floattitf(0x0007FB72EA000000, 0x1.FEDCBA8p+50);
35 test__floattitf(0x0007FB72EB000000, 0x1.FEDCBACp+50);
36 test__floattitf(0x0007FB72EBFFFFFF, 0x1.FEDCBAFFFFFFCp+50);
37 test__floattitf(0x0007FB72EC000000, 0x1.FEDCBBp+50);
38 test__floattitf(0x0007FB72E8000001, 0x1.FEDCBA0000004p+50);
39
40 test__floattitf(0x0007FB72E6000000, 0x1.FEDCB98p+50);
41 test__floattitf(0x0007FB72E7000000, 0x1.FEDCB9Cp+50);
42 test__floattitf(0x0007FB72E7FFFFFF, 0x1.FEDCB9FFFFFFCp+50);
43 test__floattitf(0x0007FB72E4000001, 0x1.FEDCB90000004p+50);
44 test__floattitf(0x0007FB72E4000000, 0x1.FEDCB9p+50);
45
46 test__floattitf(0x023479FD0E092DC0, 0x1.1A3CFE870496Ep+57);
47 test__floattitf(0x023479FD0E092DA1, 0x1.1A3CFE870496D08p+57);
48 test__floattitf(0x023479FD0E092DB0, 0x1.1A3CFE870496D8p+57);
49 test__floattitf(0x023479FD0E092DB8, 0x1.1A3CFE870496DCp+57);
50 test__floattitf(0x023479FD0E092DB6, 0x1.1A3CFE870496DBp+57);
51 test__floattitf(0x023479FD0E092DBF, 0x1.1A3CFE870496DF8p+57);
52 test__floattitf(0x023479FD0E092DC1, 0x1.1A3CFE870496E08p+57);
53 test__floattitf(0x023479FD0E092DC7, 0x1.1A3CFE870496E38p+57);
54 test__floattitf(0x023479FD0E092DC8, 0x1.1A3CFE870496E4p+57);
55 test__floattitf(0x023479FD0E092DCF, 0x1.1A3CFE870496E78p+57);
56 test__floattitf(0x023479FD0E092DD0, 0x1.1A3CFE870496E8p+57);
57 test__floattitf(0x023479FD0E092DD1, 0x1.1A3CFE870496E88p+57);
58 test__floattitf(0x023479FD0E092DD8, 0x1.1A3CFE870496ECp+57);
59 test__floattitf(0x023479FD0E092DDF, 0x1.1A3CFE870496EF8p+57);
60 test__floattitf(0x023479FD0E092DE0, 0x1.1A3CFE870496Fp+57);
61
62 test__floattitf(make_ti(0x023479FD0E092DC0, 0), 0x1.1A3CFE870496Ep+121);
63 test__floattitf(make_ti(0x023479FD0E092DA1, 1), 0x1.1A3CFE870496D08p+121);
64 test__floattitf(make_ti(0x023479FD0E092DB0, 2), 0x1.1A3CFE870496D8p+121);
65 test__floattitf(make_ti(0x023479FD0E092DB8, 3), 0x1.1A3CFE870496DCp+121);
66 test__floattitf(make_ti(0x023479FD0E092DB6, 4), 0x1.1A3CFE870496DBp+121);
67 test__floattitf(make_ti(0x023479FD0E092DBF, 5), 0x1.1A3CFE870496DF8p+121);
68 test__floattitf(make_ti(0x023479FD0E092DC1, 6), 0x1.1A3CFE870496E08p+121);
69 test__floattitf(make_ti(0x023479FD0E092DC7, 7), 0x1.1A3CFE870496E38p+121);
70 test__floattitf(make_ti(0x023479FD0E092DC8, 8), 0x1.1A3CFE870496E4p+121);
71 test__floattitf(make_ti(0x023479FD0E092DCF, 9), 0x1.1A3CFE870496E78p+121);
72 test__floattitf(make_ti(0x023479FD0E092DD0, 0), 0x1.1A3CFE870496E8p+121);
73 test__floattitf(make_ti(0x023479FD0E092DD1, 11), 0x1.1A3CFE870496E88p+121);
74 test__floattitf(make_ti(0x023479FD0E092DD8, 12), 0x1.1A3CFE870496ECp+121);
75 test__floattitf(make_ti(0x023479FD0E092DDF, 13), 0x1.1A3CFE870496EF8p+121);
76 test__floattitf(make_ti(0x023479FD0E092DE0, 14), 0x1.1A3CFE870496Fp+121);
77
78 test__floattitf(make_ti(0, 0xFFFFFFFFFFFFFFFF), 0x1.FFFFFFFFFFFFFFFEp+63);
79
80 test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC2801), 0x1.23456789ABCDEF0123456789ABC3p+124);
81 test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC3000), 0x1.23456789ABCDEF0123456789ABC3p+124);
82 test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC37FF), 0x1.23456789ABCDEF0123456789ABC3p+124);
83 test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC3800), 0x1.23456789ABCDEF0123456789ABC4p+124);
84 test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC4000), 0x1.23456789ABCDEF0123456789ABC4p+124);
85 test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC47FF), 0x1.23456789ABCDEF0123456789ABC4p+124);
86 test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC4800), 0x1.23456789ABCDEF0123456789ABC4p+124);
87 test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC4801), 0x1.23456789ABCDEF0123456789ABC5p+124);
88 test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC57FF), 0x1.23456789ABCDEF0123456789ABC5p+124);
89}
90
91fn make_ti(high: u64, low: u64) i128 {
92 var result: u128 = high;
93 result <<= 64;
94 result |= low;
95 return @bitCast(i128, result);
96}
std/special/compiler_rt/index.zig+4
...@@ -21,6 +21,10 @@ comptime {...@@ -21,6 +21,10 @@ comptime {
2121
22 @export("__unordtf2", @import("comparetf2.zig").__unordtf2, linkage);22 @export("__unordtf2", @import("comparetf2.zig").__unordtf2, linkage);
2323
24 @export("__floattitf", @import("floattitf.zig").__floattitf, linkage);
25 @export("__floattidf", @import("floattidf.zig").__floattidf, linkage);
26 @export("__floattisf", @import("floattisf.zig").__floattisf, linkage);
27
24 @export("__floatunditf", @import("floatunditf.zig").__floatunditf, linkage);28 @export("__floatunditf", @import("floatunditf.zig").__floatunditf, linkage);
25 @export("__floatunsitf", @import("floatunsitf.zig").__floatunsitf, linkage);29 @export("__floatunsitf", @import("floatunsitf.zig").__floatunsitf, linkage);
2630