summaryrefslogtreecommitdiff
path: root/yjit/src/asm/arm64/arg
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2022-07-21 16:25:21 -0400
committerTakashi Kokubun <takashikkbn@gmail.com>2022-08-29 08:47:03 -0700
commit70e117d512636465d8dc2094b22dd6535602050a (patch)
tree4912439409afef39a7a5bc04288f68cfae476920 /yjit/src/asm/arm64/arg
parente9a2effd74a3c1a40bd82e75ac24e8570ba57364 (diff)
Fixes (https://github.com/Shopify/ruby/pull/336)
* Fix bitmask encoding to u32 * Fix splitting for Op::And to account for bitmask immediate
Diffstat (limited to 'yjit/src/asm/arm64/arg')
-rw-r--r--yjit/src/asm/arm64/arg/bitmask_imm.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/yjit/src/asm/arm64/arg/bitmask_imm.rs b/yjit/src/asm/arm64/arg/bitmask_imm.rs
index 847b735eaa..220a7d697e 100644
--- a/yjit/src/asm/arm64/arg/bitmask_imm.rs
+++ b/yjit/src/asm/arm64/arg/bitmask_imm.rs
@@ -136,7 +136,7 @@ impl From<BitmaskImmediate> for u32 {
fn from(bitmask: BitmaskImmediate) -> Self {
0
| (((bitmask.n as u32) & 1) << 12)
- | (bitmask.immr << 6) as u32
+ | ((bitmask.immr as u32) << 6)
| bitmask.imms as u32
}
}
@@ -153,6 +153,13 @@ mod tests {
}
#[test]
+ fn test_negative() {
+ let bitmask: BitmaskImmediate = (-9_i64 as u64).try_into().unwrap();
+ let encoded: u32 = bitmask.into();
+ assert_eq!(7998, encoded);
+ }
+
+ #[test]
fn test_size_2_minimum() {
let bitmask = BitmaskImmediate::try_from(0x5555555555555555);
assert!(matches!(bitmask, Ok(BitmaskImmediate { n: 0, immr: 0b000000, imms: 0b111100 })));