mirror of
https://github.com/copy/v86.git
synced 2025-12-31 04:23:15 +00:00
Codegen for fpu instructions (DC group)
This commit is contained in:
parent
f797ce10c9
commit
21caefbffd
3 changed files with 80 additions and 8 deletions
|
|
@ -309,14 +309,14 @@ const encodings = [
|
|||
{ opcode: 0xDB, e: 1, fixed_g: 6, custom: 0, is_fpu: 1, task_switch_test: 1, },
|
||||
{ opcode: 0xDB, e: 1, fixed_g: 7, custom: 0, is_fpu: 1, task_switch_test: 1, },
|
||||
|
||||
{ opcode: 0xDC, e: 1, fixed_g: 0, custom: 0, is_fpu: 1, task_switch_test: 1, },
|
||||
{ opcode: 0xDC, e: 1, fixed_g: 1, custom: 0, is_fpu: 1, task_switch_test: 1, },
|
||||
{ opcode: 0xDC, e: 1, fixed_g: 2, custom: 0, is_fpu: 1, task_switch_test: 1, },
|
||||
{ opcode: 0xDC, e: 1, fixed_g: 3, custom: 0, is_fpu: 1, task_switch_test: 1, },
|
||||
{ opcode: 0xDC, e: 1, fixed_g: 4, custom: 0, is_fpu: 1, task_switch_test: 1, },
|
||||
{ opcode: 0xDC, e: 1, fixed_g: 5, custom: 0, is_fpu: 1, task_switch_test: 1, },
|
||||
{ opcode: 0xDC, e: 1, fixed_g: 6, custom: 0, is_fpu: 1, task_switch_test: 1, },
|
||||
{ opcode: 0xDC, e: 1, fixed_g: 7, custom: 0, is_fpu: 1, task_switch_test: 1, },
|
||||
{ opcode: 0xDC, e: 1, fixed_g: 0, custom: 1, is_fpu: 1, task_switch_test: 1, },
|
||||
{ opcode: 0xDC, e: 1, fixed_g: 1, custom: 1, is_fpu: 1, task_switch_test: 1, },
|
||||
{ opcode: 0xDC, e: 1, fixed_g: 2, custom: 1, is_fpu: 1, task_switch_test: 1, },
|
||||
{ opcode: 0xDC, e: 1, fixed_g: 3, custom: 1, is_fpu: 1, task_switch_test: 1, },
|
||||
{ opcode: 0xDC, e: 1, fixed_g: 4, custom: 1, is_fpu: 1, task_switch_test: 1, },
|
||||
{ opcode: 0xDC, e: 1, fixed_g: 5, custom: 1, is_fpu: 1, task_switch_test: 1, },
|
||||
{ opcode: 0xDC, e: 1, fixed_g: 6, custom: 1, is_fpu: 1, task_switch_test: 1, },
|
||||
{ opcode: 0xDC, e: 1, fixed_g: 7, custom: 1, is_fpu: 1, task_switch_test: 1, },
|
||||
|
||||
{ opcode: 0xDD, e: 1, fixed_g: 0, custom: 0, is_fpu: 1, task_switch_test: 1, },
|
||||
{ opcode: 0xDD, e: 1, fixed_g: 1, custom: 0, is_fpu: 1, task_switch_test: 1, only_reg: 1, }, // XXX: Test should fail
|
||||
|
|
|
|||
|
|
@ -1029,6 +1029,11 @@ pub fn gen_fpu_load_m32(ctx: &mut JitContext) {
|
|||
ctx.builder.instruction_body.promote_f32_to_f64();
|
||||
}
|
||||
|
||||
pub fn gen_fpu_load_m64(ctx: &mut JitContext) {
|
||||
gen_safe_read64(ctx);
|
||||
ctx.builder.instruction_body.reinterpret_i64_as_f64();
|
||||
}
|
||||
|
||||
pub fn gen_profiler_stat_increment(builder: &mut WasmBuilder, stat: profiler::stat) {
|
||||
let addr = unsafe { profiler::stat_array.as_mut_ptr().offset(stat as isize) } as u32;
|
||||
gen_increment_variable(builder, addr, 1)
|
||||
|
|
|
|||
|
|
@ -1917,6 +1917,73 @@ pub fn instr_D8_7_reg_jit(ctx: &mut JitContext, r: u32) {
|
|||
instr_group_D8_reg_jit(ctx, r, "fpu_fdivr")
|
||||
}
|
||||
|
||||
fn instr_group_DC_mem_jit(ctx: &mut JitContext, modrm_byte: u8, op: &str) {
|
||||
ctx.builder.instruction_body.const_i32(0);
|
||||
codegen::gen_modrm_resolve(ctx, modrm_byte);
|
||||
codegen::gen_fpu_load_m64(ctx);
|
||||
codegen::gen_call_fn2_i32_f64(ctx.builder, op)
|
||||
}
|
||||
fn instr_group_DC_reg_jit(ctx: &mut JitContext, r: u32, op: &str) {
|
||||
ctx.builder.instruction_body.const_i32(r as i32);
|
||||
codegen::gen_fpu_get_sti(ctx, r);
|
||||
codegen::gen_call_fn2_i32_f64(ctx.builder, op)
|
||||
}
|
||||
|
||||
pub fn instr_DC_0_mem_jit(ctx: &mut JitContext, modrm_byte: u8) {
|
||||
instr_group_DC_mem_jit(ctx, modrm_byte, "fpu_fadd")
|
||||
}
|
||||
pub fn instr_DC_0_reg_jit(ctx: &mut JitContext, r: u32) {
|
||||
instr_group_DC_reg_jit(ctx, r, "fpu_fadd")
|
||||
}
|
||||
pub fn instr_DC_1_mem_jit(ctx: &mut JitContext, modrm_byte: u8) {
|
||||
instr_group_DC_mem_jit(ctx, modrm_byte, "fpu_fmul")
|
||||
}
|
||||
pub fn instr_DC_1_reg_jit(ctx: &mut JitContext, r: u32) {
|
||||
instr_group_DC_reg_jit(ctx, r, "fpu_fmul")
|
||||
}
|
||||
pub fn instr_DC_2_mem_jit(ctx: &mut JitContext, modrm_byte: u8) {
|
||||
codegen::gen_modrm_resolve(ctx, modrm_byte);
|
||||
codegen::gen_fpu_load_m64(ctx);
|
||||
codegen::gen_call_fn1_f64(ctx.builder, "fpu_fcom")
|
||||
}
|
||||
pub fn instr_DC_2_reg_jit(ctx: &mut JitContext, r: u32) {
|
||||
codegen::gen_fpu_get_sti(ctx, r);
|
||||
codegen::gen_call_fn1_f64(ctx.builder, "fpu_fcom")
|
||||
}
|
||||
pub fn instr_DC_3_mem_jit(ctx: &mut JitContext, modrm_byte: u8) {
|
||||
codegen::gen_modrm_resolve(ctx, modrm_byte);
|
||||
codegen::gen_fpu_load_m64(ctx);
|
||||
codegen::gen_call_fn1_f64(ctx.builder, "fpu_fcomp")
|
||||
}
|
||||
pub fn instr_DC_3_reg_jit(ctx: &mut JitContext, r: u32) {
|
||||
codegen::gen_fpu_get_sti(ctx, r);
|
||||
codegen::gen_call_fn1_f64(ctx.builder, "fpu_fcomp")
|
||||
}
|
||||
pub fn instr_DC_4_mem_jit(ctx: &mut JitContext, modrm_byte: u8) {
|
||||
instr_group_DC_mem_jit(ctx, modrm_byte, "fpu_fsub")
|
||||
}
|
||||
pub fn instr_DC_4_reg_jit(ctx: &mut JitContext, r: u32) {
|
||||
instr_group_DC_reg_jit(ctx, r, "fpu_fsub")
|
||||
}
|
||||
pub fn instr_DC_5_mem_jit(ctx: &mut JitContext, modrm_byte: u8) {
|
||||
instr_group_DC_mem_jit(ctx, modrm_byte, "fpu_fsubr")
|
||||
}
|
||||
pub fn instr_DC_5_reg_jit(ctx: &mut JitContext, r: u32) {
|
||||
instr_group_DC_reg_jit(ctx, r, "fpu_fsubr")
|
||||
}
|
||||
pub fn instr_DC_6_mem_jit(ctx: &mut JitContext, modrm_byte: u8) {
|
||||
instr_group_DC_mem_jit(ctx, modrm_byte, "fpu_fdiv")
|
||||
}
|
||||
pub fn instr_DC_6_reg_jit(ctx: &mut JitContext, r: u32) {
|
||||
instr_group_DC_reg_jit(ctx, r, "fpu_fdiv")
|
||||
}
|
||||
pub fn instr_DC_7_mem_jit(ctx: &mut JitContext, modrm_byte: u8) {
|
||||
instr_group_DC_mem_jit(ctx, modrm_byte, "fpu_fdivr")
|
||||
}
|
||||
pub fn instr_DC_7_reg_jit(ctx: &mut JitContext, r: u32) {
|
||||
instr_group_DC_reg_jit(ctx, r, "fpu_fdivr")
|
||||
}
|
||||
|
||||
pub fn instr16_EB_jit(ctx: &mut JitContext, imm8: u32) {
|
||||
codegen::gen_jmp_rel16(ctx.builder, imm8 as u16);
|
||||
// dbg_assert(is_asize_32() || get_real_eip() < 0x10000);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue