1
Fork 0

interpret: simplify handling of shifts by no longer trying to handle signed and unsigned shift amounts in the same branch

This commit is contained in:
Ralf Jung 2023-11-12 12:16:41 +01:00
parent a04d56b36d
commit 31493c70fa
7 changed files with 86 additions and 58 deletions

View file

@ -1404,18 +1404,18 @@ pub enum BinOp {
BitOr,
/// The `<<` operator (shift left)
///
/// The offset is truncated to the size of the first operand before shifting.
/// The offset is truncated to the size of the first operand and made unsigned before shifting.
Shl,
/// Like `Shl`, but is UB if the RHS >= LHS::BITS
/// Like `Shl`, but is UB if the RHS >= LHS::BITS or RHS < 0
ShlUnchecked,
/// The `>>` operator (shift right)
///
/// The offset is truncated to the size of the first operand before shifting.
/// The offset is truncated to the size of the first operand and made unsigned before shifting.
///
/// This is an arithmetic shift if the LHS is signed
/// and a logical shift if the LHS is unsigned.
Shr,
/// Like `Shl`, but is UB if the RHS >= LHS::BITS
/// Like `Shl`, but is UB if the RHS >= LHS::BITS or RHS < 0
ShrUnchecked,
/// The `==` operator (equality)
Eq,