Skip to content

Commit 0bae745

Browse files
committed
Auto merge of #46290 - scottmcm:i128-from-compiler-builtins, r=nagisa
Update compiler-builtins and use it in the 128-bit lowering MIR test This picks up the lang item implementations from rust-lang/compiler-builtins#210 cc #45676 @est31 @nagisa
2 parents 7e25139 + c0654ce commit 0bae745

File tree

3 files changed

+43
-94
lines changed

3 files changed

+43
-94
lines changed

src/test/mir-opt/lower_128bit_debug_test.rs

+21-47
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,14 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// asmjs can't even pass i128 as arguments or return values, so ignore it.
12+
// this will hopefully be fixed by the LLVM 5 upgrade (#43370)
13+
// ignore-asmjs
14+
// ignore-emscripten
15+
1116
// compile-flags: -Z lower_128bit_ops -C debug_assertions=yes
1217

1318
#![feature(i128_type)]
14-
#![feature(lang_items)]
15-
16-
#[lang="i128_div"]
17-
fn i128_div(_x: i128, _y: i128) -> i128 { 3 }
18-
#[lang="u128_div"]
19-
fn u128_div(_x: u128, _y: u128) -> u128 { 4 }
20-
#[lang="i128_rem"]
21-
fn i128_rem(_x: i128, _y: i128) -> i128 { 5 }
22-
#[lang="u128_rem"]
23-
fn u128_rem(_x: u128, _y: u128) -> u128 { 6 }
24-
25-
#[lang="i128_addo"]
26-
fn i128_addo(_x: i128, _y: i128) -> (i128, bool) { (0, false) }
27-
#[lang="u128_addo"]
28-
fn u128_addo(_x: u128, _y: u128) -> (u128, bool) { (1, false) }
29-
#[lang="i128_subo"]
30-
fn i128_subo(_x: i128, _y: i128) -> (i128, bool) { (2, false) }
31-
#[lang="u128_subo"]
32-
fn u128_subo(_x: u128, _y: u128) -> (u128, bool) { (3, false) }
33-
#[lang="i128_mulo"]
34-
fn i128_mulo(_x: i128, _y: i128) -> (i128, bool) { (4, false) }
35-
#[lang="u128_mulo"]
36-
fn u128_mulo(_x: u128, _y: u128) -> (u128, bool) { (5, false) }
37-
#[lang="i128_shlo"]
38-
fn i128_shlo(_x: i128, _y: u128) -> (i128, bool) { (6, false) }
39-
#[lang="u128_shlo"]
40-
fn u128_shlo(_x: u128, _y: u128) -> (u128, bool) { (6, false) }
41-
#[lang="i128_shro"]
42-
fn i128_shro(_x: i128, _y: u128) -> (i128, bool) { (7, false) }
43-
#[lang="u128_shro"]
44-
fn u128_shro(_x: u128, _y: u128) -> (u128, bool) { (8, false) }
4519

4620
fn test_signed(mut x: i128) -> i128 {
4721
x += 1;
@@ -66,31 +40,31 @@ fn test_unsigned(mut x: u128) -> u128 {
6640
}
6741

6842
fn main() {
69-
test_signed(-200);
70-
test_unsigned(200);
43+
assert_eq!(test_signed(-222), -1);
44+
assert_eq!(test_unsigned(200), 2);
7145
}
7246

7347
// END RUST SOURCE
7448

7549
// START rustc.test_signed.Lower128Bit.after.mir
76-
// _2 = const i128_addo(_1, const 1i128) -> bb10;
50+
// _2 = const compiler_builtins::int::addsub::rust_i128_addo(_1, const 1i128) -> bb10;
7751
// ...
7852
// _1 = move (_2.0: i128);
79-
// _3 = const i128_subo(_1, const 2i128) -> bb11;
53+
// _3 = const compiler_builtins::int::addsub::rust_i128_subo(_1, const 2i128) -> bb11;
8054
// ...
8155
// _1 = move (_3.0: i128);
82-
// _4 = const i128_mulo(_1, const 3i128) -> bb12;
56+
// _4 = const compiler_builtins::int::mul::rust_i128_mulo(_1, const 3i128) -> bb12;
8357
// ...
8458
// _1 = move (_4.0: i128);
8559
// ...
86-
// _1 = const i128_div(_1, const 4i128) -> bb13;
60+
// _1 = const compiler_builtins::int::sdiv::rust_i128_div(_1, const 4i128) -> bb13;
8761
// ...
88-
// _1 = const i128_rem(_1, const 5i128) -> bb15;
62+
// _1 = const compiler_builtins::int::sdiv::rust_i128_rem(_1, const 5i128) -> bb15;
8963
// ...
9064
// _1 = move (_13.0: i128);
9165
// ...
9266
// _17 = const 7i32 as u128 (Misc);
93-
// _14 = const i128_shro(_1, move _17) -> bb16;
67+
// _14 = const compiler_builtins::int::shift::rust_i128_shro(_1, move _17) -> bb16;
9468
// ...
9569
// _1 = move (_14.0: i128);
9670
// ...
@@ -103,30 +77,30 @@ fn main() {
10377
// assert(!move (_13.1: bool), "attempt to shift left with overflow") -> bb8;
10478
// ...
10579
// _16 = const 6i32 as u128 (Misc);
106-
// _13 = const i128_shlo(_1, move _16) -> bb14;
80+
// _13 = const compiler_builtins::int::shift::rust_i128_shlo(_1, move _16) -> bb14;
10781
// ...
10882
// assert(!move (_14.1: bool), "attempt to shift right with overflow") -> bb9;
10983
// END rustc.test_signed.Lower128Bit.after.mir
11084

11185
// START rustc.test_unsigned.Lower128Bit.after.mir
112-
// _2 = const u128_addo(_1, const 1u128) -> bb8;
86+
// _2 = const compiler_builtins::int::addsub::rust_u128_addo(_1, const 1u128) -> bb8;
11387
// ...
11488
// _1 = move (_2.0: u128);
115-
// _3 = const u128_subo(_1, const 2u128) -> bb9;
89+
// _3 = const compiler_builtins::int::addsub::rust_u128_subo(_1, const 2u128) -> bb9;
11690
// ...
11791
// _1 = move (_3.0: u128);
118-
// _4 = const u128_mulo(_1, const 3u128) -> bb10;
92+
// _4 = const compiler_builtins::int::mul::rust_u128_mulo(_1, const 3u128) -> bb10;
11993
// ...
12094
// _1 = move (_4.0: u128);
12195
// ...
122-
// _1 = const u128_div(_1, const 4u128) -> bb11;
96+
// _1 = const compiler_builtins::int::udiv::rust_u128_div(_1, const 4u128) -> bb11;
12397
// ...
124-
// _1 = const u128_rem(_1, const 5u128) -> bb13;
98+
// _1 = const compiler_builtins::int::udiv::rust_u128_rem(_1, const 5u128) -> bb13;
12599
// ...
126100
// _1 = move (_7.0: u128);
127101
// ...
128102
// _11 = const 7i32 as u128 (Misc);
129-
// _8 = const u128_shro(_1, move _11) -> bb14;
103+
// _8 = const compiler_builtins::int::shift::rust_u128_shro(_1, move _11) -> bb14;
130104
// ...
131105
// _1 = move (_8.0: u128);
132106
// ...
@@ -139,7 +113,7 @@ fn main() {
139113
// assert(!move (_7.1: bool), "attempt to shift left with overflow") -> bb6;
140114
// ...
141115
// _10 = const 6i32 as u128 (Misc);
142-
// _7 = const u128_shlo(_1, move _10) -> bb12;
116+
// _7 = const compiler_builtins::int::shift::rust_u128_shlo(_1, move _10) -> bb12;
143117
// ...
144118
// assert(!move (_8.1: bool), "attempt to shift right with overflow") -> bb7;
145119
// END rustc.test_unsigned.Lower128Bit.after.mir

src/test/mir-opt/lower_128bit_test.rs

+21-46
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,14 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// asmjs can't even pass i128 as arguments or return values, so ignore it.
12+
// this will hopefully be fixed by the LLVM 5 upgrade (#43370)
13+
// ignore-asmjs
14+
// ignore-emscripten
15+
1116
// compile-flags: -Z lower_128bit_ops -C debug_assertions=no
1217

1318
#![feature(i128_type)]
14-
#![feature(lang_items)]
15-
16-
#[lang="i128_add"]
17-
fn i128_add(_x: i128, _y: i128) -> i128 { 0 }
18-
#[lang="u128_add"]
19-
fn u128_add(_x: u128, _y: u128) -> u128 { 0 }
20-
#[lang="i128_sub"]
21-
fn i128_sub(_x: i128, _y: i128) -> i128 { 1 }
22-
#[lang="u128_sub"]
23-
fn u128_sub(_x: u128, _y: u128) -> u128 { 1 }
24-
#[lang="i128_mul"]
25-
fn i128_mul(_x: i128, _y: i128) -> i128 { 2 }
26-
#[lang="u128_mul"]
27-
fn u128_mul(_x: u128, _y: u128) -> u128 { 2 }
28-
#[lang="i128_div"]
29-
fn i128_div(_x: i128, _y: i128) -> i128 { 3 }
30-
#[lang="u128_div"]
31-
fn u128_div(_x: u128, _y: u128) -> u128 { 4 }
32-
#[lang="i128_rem"]
33-
fn i128_rem(_x: i128, _y: i128) -> i128 { 5 }
34-
#[lang="u128_rem"]
35-
fn u128_rem(_x: u128, _y: u128) -> u128 { 6 }
36-
#[lang="i128_shl"]
37-
fn i128_shl(_x: i128, _y: u32) -> i128 { 7 }
38-
#[lang="u128_shl"]
39-
fn u128_shl(_x: u128, _y: u32) -> u128 { 7 }
40-
#[lang="i128_shr"]
41-
fn i128_shr(_x: i128, _y: u32) -> i128 { 8 }
42-
#[lang="u128_shr"]
43-
fn u128_shr(_x: u128, _y: u32) -> u128 { 9 }
4419

4520
fn test_signed(mut x: i128) -> i128 {
4621
x += 1;
@@ -65,44 +40,44 @@ fn test_unsigned(mut x: u128) -> u128 {
6540
}
6641

6742
fn main() {
68-
test_signed(-200);
69-
test_unsigned(200);
43+
assert_eq!(test_signed(-222), -1);
44+
assert_eq!(test_unsigned(200), 2);
7045
}
7146

7247
// END RUST SOURCE
7348

7449
// START rustc.test_signed.Lower128Bit.after.mir
75-
// _1 = const i128_add(_1, const 1i128) -> bb7;
50+
// _1 = const compiler_builtins::int::addsub::rust_i128_add(_1, const 1i128) -> bb7;
7651
// ...
77-
// _1 = const i128_div(_1, const 4i128) -> bb8;
52+
// _1 = const compiler_builtins::int::sdiv::rust_i128_div(_1, const 4i128) -> bb8;
7853
// ...
79-
// _1 = const i128_rem(_1, const 5i128) -> bb11;
54+
// _1 = const compiler_builtins::int::sdiv::rust_i128_rem(_1, const 5i128) -> bb11;
8055
// ...
81-
// _1 = const i128_mul(_1, const 3i128) -> bb5;
56+
// _1 = const compiler_builtins::int::mul::rust_i128_mul(_1, const 3i128) -> bb5;
8257
// ...
83-
// _1 = const i128_sub(_1, const 2i128) -> bb6;
58+
// _1 = const compiler_builtins::int::addsub::rust_i128_sub(_1, const 2i128) -> bb6;
8459
// ...
8560
// _11 = const 7i32 as u32 (Misc);
86-
// _1 = const i128_shr(_1, move _11) -> bb9;
61+
// _1 = const compiler_builtins::int::shift::rust_i128_shr(_1, move _11) -> bb9;
8762
// ...
8863
// _12 = const 6i32 as u32 (Misc);
89-
// _1 = const i128_shl(_1, move _12) -> bb10;
64+
// _1 = const compiler_builtins::int::shift::rust_i128_shl(_1, move _12) -> bb10;
9065
// END rustc.test_signed.Lower128Bit.after.mir
9166

9267
// START rustc.test_unsigned.Lower128Bit.after.mir
93-
// _1 = const u128_add(_1, const 1u128) -> bb5;
68+
// _1 = const compiler_builtins::int::addsub::rust_u128_add(_1, const 1u128) -> bb5;
9469
// ...
95-
// _1 = const u128_div(_1, const 4u128) -> bb6;
70+
// _1 = const compiler_builtins::int::udiv::rust_u128_div(_1, const 4u128) -> bb6;
9671
// ...
97-
// _1 = const u128_rem(_1, const 5u128) -> bb9;
72+
// _1 = const compiler_builtins::int::udiv::rust_u128_rem(_1, const 5u128) -> bb9;
9873
// ...
99-
// _1 = const u128_mul(_1, const 3u128) -> bb3;
74+
// _1 = const compiler_builtins::int::mul::rust_u128_mul(_1, const 3u128) -> bb3;
10075
// ...
101-
// _1 = const u128_sub(_1, const 2u128) -> bb4;
76+
// _1 = const compiler_builtins::int::addsub::rust_u128_sub(_1, const 2u128) -> bb4;
10277
// ...
10378
// _5 = const 7i32 as u32 (Misc);
104-
// _1 = const u128_shr(_1, move _5) -> bb7;
79+
// _1 = const compiler_builtins::int::shift::rust_u128_shr(_1, move _5) -> bb7;
10580
// ...
10681
// _6 = const 6i32 as u32 (Misc);
107-
// _1 = const u128_shl(_1, move _6) -> bb8;
82+
// _1 = const compiler_builtins::int::shift::rust_u128_shl(_1, move _6) -> bb8;
10883
// END rustc.test_unsigned.Lower128Bit.after.mir

0 commit comments

Comments
 (0)