1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Split cmp operations that aren't 32/64 bit for arm (#6484)

This commit is contained in:
Jimmy Miller 2022-10-03 16:57:27 -04:00 committed by GitHub
parent cbd82f5250
commit efc7766244
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: git 2022-10-04 05:57:56 +09:00
Merged-By: maximecb <maximecb@ruby-lang.org>
2 changed files with 24 additions and 0 deletions

View file

@ -234,6 +234,20 @@ impl Assembler
(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 asm = &mut asm_local;
let mut iterator = self.into_draining_iter();
@ -316,6 +330,7 @@ impl Assembler
},
Insn::Cmp { left, right } => {
let opnd0 = split_load_operand(asm, left);
let opnd0 = split_less_than_32_cmp(asm, opnd0);
let opnd1 = split_shifted_immediate(asm, right);
asm.cmp(opnd0, opnd1);
},

View file

@ -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);
}