jit clc/stc (F8/F9)

This commit is contained in:
Fabian 2020-12-31 19:14:32 -06:00
parent 1f1474680b
commit 51b09ade51
3 changed files with 20 additions and 12 deletions

View file

@ -389,8 +389,8 @@ const encodings = [
{ opcode: 0xF7, os: 1, e: 1, fixed_g: 6, custom: 1 },
{ opcode: 0xF7, os: 1, e: 1, fixed_g: 7, custom: 1 },
{ opcode: 0xF8, },
{ opcode: 0xF9, },
{ opcode: 0xF8, custom: 1 },
{ opcode: 0xF9, custom: 1 },
{ opcode: 0xFA, custom: 1, skip: 1 },
// STI: Note: Has special handling in jit in order to call handle_irqs safely
{ opcode: 0xFB, custom: 1, custom_sti: 1, skip: 1, },

View file

@ -1349,6 +1349,13 @@ pub fn gen_set_flags_changed(builder: &mut WasmBuilder, value: i32) {
builder.const_i32(value);
builder.store_aligned_i32(0);
}
pub fn gen_clear_flags_changed_bits(builder: &mut WasmBuilder, bits_to_clear: i32) {
builder.const_i32(global_pointers::flags_changed as i32);
gen_get_flags_changed(builder);
builder.const_i32(!bits_to_clear);
builder.and_i32();
builder.store_aligned_i32(0);
}
pub fn gen_set_flags_bits(builder: &mut WasmBuilder, bits_to_set: i32) {
builder.const_i32(global_pointers::flags as i32);

View file

@ -1252,11 +1252,7 @@ pub fn gen_bt(
builder.or_i32();
builder.store_aligned_i32(0);
builder.const_i32(global_pointers::flags_changed as i32);
codegen::gen_get_flags_changed(builder);
builder.const_i32(!1);
builder.and_i32();
builder.store_aligned_i32(0);
codegen::gen_clear_flags_changed_bits(builder, 1);
}
pub fn gen_bsf32(
@ -3384,6 +3380,15 @@ pub fn instr32_F7_7_reg_jit(ctx: &mut JitContext, r: u32) {
ctx.builder.block_end();
}
pub fn instr_F8_jit(ctx: &mut JitContext) {
codegen::gen_clear_flags_changed_bits(ctx.builder, 1);
codegen::gen_clear_flags_bits(ctx.builder, 1);
}
pub fn instr_F9_jit(ctx: &mut JitContext) {
codegen::gen_clear_flags_changed_bits(ctx.builder, 1);
codegen::gen_set_flags_bits(ctx.builder, 1);
}
pub fn instr_FA_jit(ctx: &mut JitContext) {
ctx.builder.call_fn0_ret("instr_FA_without_fault");
ctx.builder.eqz_i32();
@ -3696,11 +3701,7 @@ pub fn instr_9E_jit(ctx: &mut JitContext) {
ctx.builder.or_i32();
ctx.builder.store_aligned_i32(0);
ctx.builder.const_i32(global_pointers::flags_changed as i32);
codegen::gen_get_flags_changed(ctx.builder);
ctx.builder.const_i32(!0xFF);
ctx.builder.and_i32();
ctx.builder.store_aligned_i32(0);
codegen::gen_clear_flags_changed_bits(ctx.builder, 0xFF);
}
pub fn instr_9F_jit(ctx: &mut JitContext) {