Get rid of temporary context methods

This commit is contained in:
Maxime Chevalier-Boisvert 2022-06-15 16:30:40 -04:00 коммит произвёл Takashi Kokubun
Родитель 40ac79ada8
Коммит b8fc9909bf
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 6FFC433B12EE23DD
3 изменённых файлов: 11 добавлений и 37 удалений

Просмотреть файл

@ -725,29 +725,3 @@ def_push_2_opnd_no_out!(cmp, Op::Cmp);
def_push_2_opnd_no_out!(test, Op::Test);
def_push_0_opnd_no_out!(breakpoint, Op::Breakpoint);
def_push_2_opnd_no_out!(incr_counter, Op::IncrCounter);
// NOTE: these methods are temporary and will likely move
// to context.rs later
// They are just wrappers to convert from X86Opnd into the IR Opnd type
impl Context
{
pub fn ir_sp_opnd(&mut self, idx: isize) -> Opnd {
self.sp_opnd(idx).into()
}
pub fn ir_stack_opnd(&mut self, idx: i32) -> Opnd {
self.stack_opnd(idx).into()
}
pub fn ir_stack_pop(&mut self, n: usize) -> Opnd {
self.stack_pop(n).into()
}
pub fn ir_stack_push(&mut self, val_type: Type) -> Opnd {
self.stack_push(val_type).into()
}
pub fn ir_stack_push_mapping(&mut self, (mapping, temp_type): (TempMapping, Type)) -> Opnd {
self.stack_push_mapping((mapping, temp_type)).into()
}
}

Просмотреть файл

@ -12,10 +12,10 @@ fn gen_dup(
ctx: &mut Context,
asm: &mut Assembler,
) {
let dup_val = ctx.ir_stack_pop(0);
let dup_val = ctx.stack_pop(0);
let (mapping, tmp_type) = ctx.get_opnd_mapping(StackOpnd(0));
let loc0 = ctx.ir_stack_push_mapping((mapping, tmp_type));
let loc0 = ctx.stack_push_mapping((mapping, tmp_type));
asm.mov(loc0, dup_val);
}

Просмотреть файл

@ -277,7 +277,7 @@ fn jit_save_pc(jit: &JITState, asm: &mut Assembler) {
/// which could invalidate memory operands
fn gen_save_sp(jit: &JITState, asm: &mut Assembler, ctx: &mut Context) {
if ctx.get_sp_offset() != 0 {
let stack_pointer = ctx.ir_sp_opnd(0);
let stack_pointer = ctx.sp_opnd(0);
let sp_addr = asm.lea(stack_pointer);
asm.mov(SP, sp_addr);
let cfp_sp_opnd = Opnd::mem(64, CFP, RUBY_OFFSET_CFP_SP);
@ -897,10 +897,10 @@ fn gen_dup(
_ocb: &mut OutlinedCb,
) -> CodegenStatus {
let dup_val = ctx.ir_stack_pop(0);
let dup_val = ctx.stack_pop(0);
let (mapping, tmp_type) = ctx.get_opnd_mapping(StackOpnd(0));
let loc0 = ctx.ir_stack_push_mapping((mapping, tmp_type));
let loc0 = ctx.stack_push_mapping((mapping, tmp_type));
asm.mov(loc0, dup_val);
KeepCompiling
@ -924,16 +924,16 @@ fn gen_dupn(
return CantCompile;
}
let opnd1: Opnd = ctx.ir_stack_opnd(1);
let opnd0: Opnd = ctx.ir_stack_opnd(0);
let opnd1: Opnd = ctx.stack_opnd(1);
let opnd0: Opnd = ctx.stack_opnd(0);
let mapping1 = ctx.get_opnd_mapping(StackOpnd(1));
let mapping0 = ctx.get_opnd_mapping(StackOpnd(0));
let dst1: Opnd = ctx.ir_stack_push_mapping(mapping1);
let dst1: Opnd = ctx.stack_push_mapping(mapping1);
asm.mov(dst1, opnd1);
let dst0: Opnd = ctx.ir_stack_push_mapping(mapping0);
let dst0: Opnd = ctx.stack_push_mapping(mapping0);
asm.mov(dst0, opnd0);
KeepCompiling
@ -957,8 +957,8 @@ fn stack_swap(
offset0: u16,
offset1: u16,
) {
let stack0_mem = ctx.ir_stack_opnd(offset0 as i32);
let stack1_mem = ctx.ir_stack_opnd(offset1 as i32);
let stack0_mem = ctx.stack_opnd(offset0 as i32);
let stack1_mem = ctx.stack_opnd(offset1 as i32);
let mapping0 = ctx.get_opnd_mapping(StackOpnd(offset0));
let mapping1 = ctx.get_opnd_mapping(StackOpnd(offset1));