summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>2022-06-14 16:32:54 -0400
committerTakashi Kokubun <takashikkbn@gmail.com>2022-08-29 08:46:56 -0700
commite743e3bf20a38d44888383393823b8776c2d1e90 (patch)
treead999e82c9b0513b4027abebeaabf0f8779e2e2b
parent4dbc1e1d825b4a50e3847de788da0ab6a8d860ae (diff)
Remove unused code, add backend asm test
-rw-r--r--yjit/src/backend/ir.rs56
1 files changed, 23 insertions, 33 deletions
diff --git a/yjit/src/backend/ir.rs b/yjit/src/backend/ir.rs
index 86e590e846..1fca3a5b87 100644
--- a/yjit/src/backend/ir.rs
+++ b/yjit/src/backend/ir.rs
@@ -153,7 +153,7 @@ impl Opnd
disp: disp,
})
},
- _ => unreachable!()
+ _ => unreachable!("memory operand with non-register base")
}
}
@@ -169,42 +169,22 @@ impl From<usize> for Opnd {
}
}
-impl From<VALUE> for Opnd {
- fn from(value: VALUE) -> Self {
- let VALUE(uimm) = value;
- Opnd::UImm(uimm as u64)
+impl From<u64> for Opnd {
+ fn from(value: u64) -> Self {
+ Opnd::UImm(value.try_into().unwrap())
}
}
-/// NOTE: this is useful during the port but can probably be removed once
-/// Context returns ir::Opnd instead of X86Opnd
-///
-/// Method to convert from an X86Opnd to an IR Opnd
-impl From<X86Opnd> for Opnd {
- fn from(opnd: X86Opnd) -> Self {
- match opnd {
- X86Opnd::None => Opnd::None,
- X86Opnd::UImm(X86UImm{ value, .. }) => Opnd::UImm(value),
- X86Opnd::Imm(X86Imm{ value, .. }) => Opnd::Imm(value),
-
- // General-purpose register
- X86Opnd::Reg(reg) => {
- Opnd::Reg(reg)
- }
-
- // Memory operand with displacement
- X86Opnd::Mem(X86Mem{ num_bits, base_reg_no, disp, idx_reg_no: None, scale_exp: 0 }) => {
- let base_reg = Reg { num_bits: 64, reg_no: base_reg_no, reg_type: RegType::GP };
-
- Opnd::Mem(Mem {
- base_reg: base_reg,
- disp,
- num_bits
- })
- }
+impl From<i32> for Opnd {
+ fn from(value: i32) -> Self {
+ Opnd::Imm(value.try_into().unwrap())
+ }
+}
- _ => panic!("unsupported x86 operand type")
- }
+impl From<VALUE> for Opnd {
+ fn from(value: VALUE) -> Self {
+ let VALUE(uimm) = value;
+ Opnd::UImm(uimm as u64)
}
}
@@ -874,6 +854,16 @@ mod tests {
asm.compile_with_regs(&mut cb, regs);
}
+ // 64-bit values can't be written directly to memory,
+ // need to be split into one or more register movs first
+ #[test]
+ fn test_store_u64()
+ {
+ let (mut asm, mut cb, regs) = setup_asm(1);
+ asm.store(Opnd::mem(64, SP, 0), u64::MAX.into());
+ asm.compile_with_regs(&mut cb, regs);
+ }
+
#[test]
fn test_c_call()
{