@@ -8,7 +8,6 @@ pub fn maybe_codegen<'a, 'tcx>(
8
8
checked : bool ,
9
9
lhs : CValue < ' tcx > ,
10
10
rhs : CValue < ' tcx > ,
11
- out_ty : Ty < ' tcx > ,
12
11
) -> Option < CValue < ' tcx > > {
13
12
if lhs. layout ( ) . ty != fx. tcx . types . u128 && lhs. layout ( ) . ty != fx. tcx . types . i128 {
14
13
return None ;
@@ -26,13 +25,15 @@ pub fn maybe_codegen<'a, 'tcx>(
26
25
}
27
26
BinOp :: Add | BinOp :: Sub if !checked => return None ,
28
27
BinOp :: Add => {
28
+ let out_ty = fx. tcx . mk_tup ( [ lhs. layout ( ) . ty , fx. tcx . types . bool ] . iter ( ) ) ;
29
29
return Some ( if is_signed {
30
30
fx. easy_call ( "__rust_i128_addo" , & [ lhs, rhs] , out_ty)
31
31
} else {
32
32
fx. easy_call ( "__rust_u128_addo" , & [ lhs, rhs] , out_ty)
33
33
} )
34
34
}
35
35
BinOp :: Sub => {
36
+ let out_ty = fx. tcx . mk_tup ( [ lhs. layout ( ) . ty , fx. tcx . types . bool ] . iter ( ) ) ;
36
37
return Some ( if is_signed {
37
38
fx. easy_call ( "__rust_i128_subo" , & [ lhs, rhs] , out_ty)
38
39
} else {
@@ -42,6 +43,7 @@ pub fn maybe_codegen<'a, 'tcx>(
42
43
BinOp :: Offset => unreachable ! ( "offset should only be used on pointers, not 128bit ints" ) ,
43
44
BinOp :: Mul => {
44
45
let res = if checked {
46
+ let out_ty = fx. tcx . mk_tup ( [ lhs. layout ( ) . ty , fx. tcx . types . bool ] . iter ( ) ) ;
45
47
if is_signed {
46
48
fx. easy_call ( "__rust_i128_mulo" , & [ lhs, rhs] , out_ty)
47
49
} else {
@@ -91,18 +93,7 @@ pub fn maybe_codegen<'a, 'tcx>(
91
93
// } else {
92
94
// msb_cc
93
95
// }
94
- let cc = match ( bin_op, is_signed) {
95
- ( BinOp :: Ge , false ) => IntCC :: UnsignedGreaterThanOrEqual ,
96
- ( BinOp :: Gt , false ) => IntCC :: UnsignedGreaterThan ,
97
- ( BinOp :: Lt , false ) => IntCC :: UnsignedLessThan ,
98
- ( BinOp :: Le , false ) => IntCC :: UnsignedLessThanOrEqual ,
99
-
100
- ( BinOp :: Ge , true ) => IntCC :: SignedGreaterThanOrEqual ,
101
- ( BinOp :: Gt , true ) => IntCC :: SignedGreaterThan ,
102
- ( BinOp :: Lt , true ) => IntCC :: SignedLessThan ,
103
- ( BinOp :: Le , true ) => IntCC :: SignedLessThanOrEqual ,
104
- _ => unreachable ! ( ) ,
105
- } ;
96
+ let cc = crate :: num:: bin_op_to_intcc ( bin_op, is_signed) . unwrap ( ) ;
106
97
107
98
let msb_eq = fx. bcx . ins ( ) . icmp ( IntCC :: Equal , lhs_msb, rhs_msb) ;
108
99
let lsb_cc = fx. bcx . ins ( ) . icmp ( cc, lhs_lsb, rhs_lsb) ;
@@ -160,6 +151,7 @@ pub fn maybe_codegen<'a, 'tcx>(
160
151
} ;
161
152
if let Some ( val) = val {
162
153
if let Some ( is_overflow) = is_overflow {
154
+ let out_ty = fx. tcx . mk_tup ( [ lhs. layout ( ) . ty , fx. tcx . types . bool ] . iter ( ) ) ;
163
155
let val = val. load_scalar ( fx) ;
164
156
return Some ( CValue :: by_val_pair ( val, is_overflow, fx. layout_of ( out_ty) ) )
165
157
} else {
@@ -186,6 +178,7 @@ pub fn maybe_codegen<'a, 'tcx>(
186
178
( _, _) => unreachable ! ( ) ,
187
179
} ;
188
180
if let Some ( is_overflow) = is_overflow {
181
+ let out_ty = fx. tcx . mk_tup ( [ lhs. layout ( ) . ty , fx. tcx . types . bool ] . iter ( ) ) ;
189
182
let val = val. load_scalar ( fx) ;
190
183
Some ( CValue :: by_val_pair ( val, is_overflow, fx. layout_of ( out_ty) ) )
191
184
} else {
0 commit comments