Split cmp operations that aren't 32/64 bit for arm (#6484)
This commit is contained in:
parent
cbd82f5250
commit
efc7766244
Notes:
git
2022-10-04 05:57:56 +09:00
Merged-By: maximecb <maximecb@ruby-lang.org>
@ -234,6 +234,20 @@ impl Assembler
|
|||||||
(opnd0, opnd1)
|
(opnd0, opnd1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn split_less_than_32_cmp(asm: &mut Assembler, opnd0: Opnd) -> Opnd {
|
||||||
|
match opnd0 {
|
||||||
|
Opnd::Reg(_) | Opnd::InsnOut { .. } => {
|
||||||
|
match opnd0.rm_num_bits() {
|
||||||
|
8 => asm.and(opnd0.with_num_bits(64).unwrap(), Opnd::UImm(0xff)),
|
||||||
|
16 => asm.and(opnd0.with_num_bits(64).unwrap(), Opnd::UImm(0xffff)),
|
||||||
|
32 | 64 => opnd0,
|
||||||
|
bits => unreachable!("Invalid number of bits. {}", bits)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => opnd0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let mut asm_local = Assembler::new_with_label_names(std::mem::take(&mut self.label_names));
|
let mut asm_local = Assembler::new_with_label_names(std::mem::take(&mut self.label_names));
|
||||||
let asm = &mut asm_local;
|
let asm = &mut asm_local;
|
||||||
let mut iterator = self.into_draining_iter();
|
let mut iterator = self.into_draining_iter();
|
||||||
@ -316,6 +330,7 @@ impl Assembler
|
|||||||
},
|
},
|
||||||
Insn::Cmp { left, right } => {
|
Insn::Cmp { left, right } => {
|
||||||
let opnd0 = split_load_operand(asm, left);
|
let opnd0 = split_load_operand(asm, left);
|
||||||
|
let opnd0 = split_less_than_32_cmp(asm, opnd0);
|
||||||
let opnd1 = split_shifted_immediate(asm, right);
|
let opnd1 = split_shifted_immediate(asm, right);
|
||||||
asm.cmp(opnd0, opnd1);
|
asm.cmp(opnd0, opnd1);
|
||||||
},
|
},
|
||||||
|
@ -341,3 +341,12 @@ fn test_lookback_iterator() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_cmp_8_bit() {
|
||||||
|
let (mut asm, mut cb) = setup_asm();
|
||||||
|
let reg = Assembler::get_alloc_regs()[0];
|
||||||
|
asm.cmp(Opnd::Reg(reg).with_num_bits(8).unwrap(), Opnd::UImm(RUBY_SYMBOL_FLAG as u64));
|
||||||
|
|
||||||
|
asm.compile_with_num_regs(&mut cb, 1);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user