@@ -128,10 +128,11 @@ pub(crate) fn codegen_int_binop<'tcx>(
128
128
let rhs = in_rhs. load_scalar ( fx) ;
129
129
130
130
let b = fx. bcx . ins ( ) ;
131
+ // FIXME trap on overflow for the Unchecked versions
131
132
let val = match bin_op {
132
- BinOp :: Add => b. iadd ( lhs, rhs) ,
133
- BinOp :: Sub => b. isub ( lhs, rhs) ,
134
- BinOp :: Mul => b. imul ( lhs, rhs) ,
133
+ BinOp :: Add | BinOp :: AddUnchecked => b. iadd ( lhs, rhs) ,
134
+ BinOp :: Sub | BinOp :: SubUnchecked => b. isub ( lhs, rhs) ,
135
+ BinOp :: Mul | BinOp :: MulUnchecked => b. imul ( lhs, rhs) ,
135
136
BinOp :: Div => {
136
137
if signed {
137
138
b. sdiv ( lhs, rhs)
@@ -149,16 +150,19 @@ pub(crate) fn codegen_int_binop<'tcx>(
149
150
BinOp :: BitXor => b. bxor ( lhs, rhs) ,
150
151
BinOp :: BitAnd => b. band ( lhs, rhs) ,
151
152
BinOp :: BitOr => b. bor ( lhs, rhs) ,
152
- BinOp :: Shl => b. ishl ( lhs, rhs) ,
153
- BinOp :: Shr => {
153
+ BinOp :: Shl | BinOp :: ShlUnchecked => b. ishl ( lhs, rhs) ,
154
+ BinOp :: Shr | BinOp :: ShrUnchecked => {
154
155
if signed {
155
156
b. sshr ( lhs, rhs)
156
157
} else {
157
158
b. ushr ( lhs, rhs)
158
159
}
159
160
}
161
+ BinOp :: Offset => unreachable ! ( "Offset is not an integer operation" ) ,
160
162
// Compare binops handles by `codegen_binop`.
161
- _ => unreachable ! ( "{:?}({:?}, {:?})" , bin_op, in_lhs. layout( ) . ty, in_rhs. layout( ) . ty) ,
163
+ BinOp :: Eq | BinOp :: Ne | BinOp :: Lt | BinOp :: Le | BinOp :: Gt | BinOp :: Ge => {
164
+ unreachable ! ( "{:?}({:?}, {:?})" , bin_op, in_lhs. layout( ) . ty, in_rhs. layout( ) . ty) ;
165
+ }
162
166
} ;
163
167
164
168
CValue :: by_val ( val, in_lhs. layout ( ) )
0 commit comments