Update rustfmt
This commit is contained in:
parent
ca2409b024
commit
75dbbbc55a
|
@ -3,3 +3,7 @@ match_block_trailing_comma = true
|
||||||
fn_single_line = true
|
fn_single_line = true
|
||||||
imports_indent = "Block"
|
imports_indent = "Block"
|
||||||
control_brace_style = "ClosingNextLine"
|
control_brace_style = "ClosingNextLine"
|
||||||
|
single_line_if_else_max_width = 92
|
||||||
|
ignore = [
|
||||||
|
"src/rust/gen"
|
||||||
|
]
|
||||||
|
|
|
@ -19,10 +19,10 @@ extern "C" {
|
||||||
|
|
||||||
use cpu2::fpu::fpu_set_tag_word;
|
use cpu2::fpu::fpu_set_tag_word;
|
||||||
use cpu2::global_pointers::*;
|
use cpu2::global_pointers::*;
|
||||||
pub use cpu2::imports::{mem16, mem32s, mem8};
|
pub use cpu2::imports::{mem8, mem16, mem32s};
|
||||||
use cpu2::memory::{
|
use cpu2::memory::{
|
||||||
in_mapped_range, read128, read16, read32s, read64s, read8, read_aligned16, read_aligned32,
|
in_mapped_range, read8, read16, read32s, read64s, read128, read_aligned16, read_aligned32,
|
||||||
write128, write16, write32, write64, write8, write_aligned32,
|
write8, write16, write32, write64, write128, write_aligned32,
|
||||||
};
|
};
|
||||||
use cpu2::misc_instr::{
|
use cpu2::misc_instr::{
|
||||||
adjust_stack_reg, get_stack_pointer, getaf, getcf, getof, getpf, getsf, getzf, pop16, pop32s,
|
adjust_stack_reg, get_stack_pointer, getaf, getcf, getof, getpf, getsf, getzf, pop16, pop32s,
|
||||||
|
@ -335,12 +335,7 @@ impl SegmentDescriptor {
|
||||||
pub fn dpl(&self) -> u8 { (self.access_byte() >> 5) & 3 }
|
pub fn dpl(&self) -> u8 { (self.access_byte() >> 5) & 3 }
|
||||||
pub fn is_32(&self) -> bool { self.flags() & 4 == 4 }
|
pub fn is_32(&self) -> bool { self.flags() & 4 == 4 }
|
||||||
pub fn effective_limit(&self) -> u32 {
|
pub fn effective_limit(&self) -> u32 {
|
||||||
if self.flags() & 8 == 8 {
|
if self.flags() & 8 == 8 { self.limit() << 12 | 0xFFF } else { self.limit() }
|
||||||
self.limit() << 12 | 0xFFF
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
self.limit()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -822,12 +817,7 @@ pub unsafe fn call_interrupt_vector(
|
||||||
let old_ss = *sreg.offset(SS as isize) as i32;
|
let old_ss = *sreg.offset(SS as isize) as i32;
|
||||||
|
|
||||||
let error_code_space = if error_code.is_some() { 1 } else { 0 };
|
let error_code_space = if error_code.is_some() { 1 } else { 0 };
|
||||||
let vm86_space = if (old_flags & FLAG_VM) == FLAG_VM {
|
let vm86_space = if (old_flags & FLAG_VM) == FLAG_VM { 4 } else { 0 };
|
||||||
4
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
0
|
|
||||||
};
|
|
||||||
let bytes_per_arg = if descriptor.is_32() { 4 } else { 2 };
|
let bytes_per_arg = if descriptor.is_32() { 4 } else { 2 };
|
||||||
|
|
||||||
let stack_space = bytes_per_arg * (5 + error_code_space + vm86_space);
|
let stack_space = bytes_per_arg * (5 + error_code_space + vm86_space);
|
||||||
|
@ -1120,12 +1110,7 @@ pub unsafe fn do_page_walk(addr: i32, for_writing: bool, user: bool) -> Result<i
|
||||||
|
|
||||||
let new_page_dir_entry = page_dir_entry
|
let new_page_dir_entry = page_dir_entry
|
||||||
| PAGE_TABLE_ACCESSED_MASK
|
| PAGE_TABLE_ACCESSED_MASK
|
||||||
| if for_writing {
|
| if for_writing { PAGE_TABLE_DIRTY_MASK } else { 0 };
|
||||||
PAGE_TABLE_DIRTY_MASK
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
0
|
|
||||||
};
|
|
||||||
|
|
||||||
if page_dir_entry != new_page_dir_entry {
|
if page_dir_entry != new_page_dir_entry {
|
||||||
write_aligned32(page_dir_addr as u32, new_page_dir_entry);
|
write_aligned32(page_dir_addr as u32, new_page_dir_entry);
|
||||||
|
@ -1177,12 +1162,7 @@ pub unsafe fn do_page_walk(addr: i32, for_writing: bool, user: bool) -> Result<i
|
||||||
}
|
}
|
||||||
let new_page_table_entry = page_table_entry
|
let new_page_table_entry = page_table_entry
|
||||||
| PAGE_TABLE_ACCESSED_MASK
|
| PAGE_TABLE_ACCESSED_MASK
|
||||||
| if for_writing {
|
| if for_writing { PAGE_TABLE_DIRTY_MASK } else { 0 };
|
||||||
PAGE_TABLE_DIRTY_MASK
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
0
|
|
||||||
};
|
|
||||||
if page_table_entry != new_page_table_entry {
|
if page_table_entry != new_page_table_entry {
|
||||||
write_aligned32(page_table_addr as u32, new_page_table_entry);
|
write_aligned32(page_table_addr as u32, new_page_table_entry);
|
||||||
}
|
}
|
||||||
|
@ -1224,18 +1204,8 @@ pub unsafe fn do_page_walk(addr: i32, for_writing: bool, user: bool) -> Result<i
|
||||||
let info_bits = TLB_VALID
|
let info_bits = TLB_VALID
|
||||||
| if can_write { 0 } else { TLB_READONLY }
|
| if can_write { 0 } else { TLB_READONLY }
|
||||||
| if allow_user { 0 } else { TLB_NO_USER }
|
| if allow_user { 0 } else { TLB_NO_USER }
|
||||||
| if is_in_mapped_range {
|
| if is_in_mapped_range { TLB_IN_MAPPED_RANGE } else { 0 }
|
||||||
TLB_IN_MAPPED_RANGE
|
| if global && 0 != *cr.offset(4) & CR4_PGE { TLB_GLOBAL } else { 0 }
|
||||||
}
|
|
||||||
else {
|
|
||||||
0
|
|
||||||
}
|
|
||||||
| if global && 0 != *cr.offset(4) & CR4_PGE {
|
|
||||||
TLB_GLOBAL
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
0
|
|
||||||
}
|
|
||||||
| if has_code { TLB_HAS_CODE } else { 0 };
|
| if has_code { TLB_HAS_CODE } else { 0 };
|
||||||
dbg_assert!((high ^ page << 12) & 0xFFF == 0);
|
dbg_assert!((high ^ page << 12) & 0xFFF == 0);
|
||||||
*tlb_data.offset(page as isize) = high ^ page << 12 | info_bits;
|
*tlb_data.offset(page as isize) = high ^ page << 12 | info_bits;
|
||||||
|
@ -1420,12 +1390,8 @@ pub unsafe fn tlb_set_has_code(physical_page: Page, has_code: bool) {
|
||||||
if 0 != entry {
|
if 0 != entry {
|
||||||
let tlb_physical_page = entry as u32 >> 12 ^ page as u32;
|
let tlb_physical_page = entry as u32 >> 12 ^ page as u32;
|
||||||
if physical_page == tlb_physical_page {
|
if physical_page == tlb_physical_page {
|
||||||
*tlb_data.offset(page as isize) = if has_code {
|
*tlb_data.offset(page as isize) =
|
||||||
entry | TLB_HAS_CODE
|
if has_code { entry | TLB_HAS_CODE } else { entry & !TLB_HAS_CODE }
|
||||||
}
|
|
||||||
else {
|
|
||||||
entry & !TLB_HAS_CODE
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1764,12 +1730,7 @@ pub unsafe fn test_privileges_for_io(port: i32, size: i32) -> bool {
|
||||||
translate_address_system_read(tsr_offset + iomap_base + (port >> 3)),
|
translate_address_system_read(tsr_offset + iomap_base + (port >> 3)),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
let port_info = if mask & 0xFF00 != 0 {
|
let port_info = if mask & 0xFF00 != 0 { read16(addr) } else { read8(addr) };
|
||||||
read16(addr)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
read8(addr)
|
|
||||||
};
|
|
||||||
|
|
||||||
dbg_assert!(addr & 0xFFF < 0xFFF);
|
dbg_assert!(addr & 0xFFF < 0xFFF);
|
||||||
|
|
||||||
|
@ -1841,12 +1802,7 @@ pub unsafe fn get_seg_prefix_ds(offset: i32) -> i32 { return get_seg_prefix(DS)
|
||||||
pub unsafe fn get_seg_prefix_ss(offset: i32) -> i32 { return get_seg_prefix(SS) + offset; }
|
pub unsafe fn get_seg_prefix_ss(offset: i32) -> i32 { return get_seg_prefix(SS) + offset; }
|
||||||
|
|
||||||
pub unsafe fn modrm_resolve(modrm_byte: i32) -> OrPageFault<i32> {
|
pub unsafe fn modrm_resolve(modrm_byte: i32) -> OrPageFault<i32> {
|
||||||
if is_asize_32() {
|
if is_asize_32() { resolve_modrm32(modrm_byte) } else { resolve_modrm16(modrm_byte) }
|
||||||
resolve_modrm32(modrm_byte)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
resolve_modrm16(modrm_byte)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn run_instruction(opcode: i32) { ::gen::interpreter::run(opcode as u32) }
|
pub unsafe fn run_instruction(opcode: i32) { ::gen::interpreter::run(opcode as u32) }
|
||||||
|
@ -2789,12 +2745,7 @@ pub unsafe fn task_switch_test_mmx_jit() {
|
||||||
|
|
||||||
pub unsafe fn read_moffs() -> OrPageFault<i32> {
|
pub unsafe fn read_moffs() -> OrPageFault<i32> {
|
||||||
// read 2 or 4 byte from ip, depending on address size attribute
|
// read 2 or 4 byte from ip, depending on address size attribute
|
||||||
if is_asize_32() {
|
if is_asize_32() { read_imm32s() } else { read_imm16() }
|
||||||
read_imm32s()
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
read_imm16()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|
|
@ -519,12 +519,8 @@ pub unsafe fn fpu_fprem(ieee: bool) {
|
||||||
let exp1 = st1.log2();
|
let exp1 = st1.log2();
|
||||||
let d = (exp0 - exp1).abs();
|
let d = (exp0 - exp1).abs();
|
||||||
if !intel_compatibility || d < 64.0 {
|
if !intel_compatibility || d < 64.0 {
|
||||||
let fprem_quotient = convert_f64_to_i32(if ieee {
|
let fprem_quotient =
|
||||||
round(st0 / st1)
|
convert_f64_to_i32(if ieee { round(st0 / st1) } else { trunc(st0 / st1) });
|
||||||
}
|
|
||||||
else {
|
|
||||||
trunc(st0 / st1)
|
|
||||||
});
|
|
||||||
fpu_write_st(*fpu_stack_ptr as i32, fmod(st0, st1));
|
fpu_write_st(*fpu_stack_ptr as i32, fmod(st0, st1));
|
||||||
*fpu_status_word &= !(FPU_C0 | FPU_C1 | FPU_C3);
|
*fpu_status_word &= !(FPU_C0 | FPU_C1 | FPU_C3);
|
||||||
if 0 != fprem_quotient & 1 {
|
if 0 != fprem_quotient & 1 {
|
||||||
|
@ -541,12 +537,7 @@ pub unsafe fn fpu_fprem(ieee: bool) {
|
||||||
else {
|
else {
|
||||||
let n = 32.0;
|
let n = 32.0;
|
||||||
let fprem_quotient = convert_f64_to_i32(
|
let fprem_quotient = convert_f64_to_i32(
|
||||||
if ieee {
|
if ieee { round(st0 / st1) } else { trunc(st0 / st1) } / pow(2.0, d - n),
|
||||||
round(st0 / st1)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
trunc(st0 / st1)
|
|
||||||
} / pow(2.0, d - n),
|
|
||||||
);
|
);
|
||||||
fpu_write_st(
|
fpu_write_st(
|
||||||
*fpu_stack_ptr as i32,
|
*fpu_stack_ptr as i32,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#![allow(non_upper_case_globals)]
|
#![allow(non_upper_case_globals)]
|
||||||
|
|
||||||
use cpu2::cpu::{reg128, reg64};
|
use cpu2::cpu::{reg64, reg128};
|
||||||
|
|
||||||
pub const reg8: *mut u8 = 64 as *mut u8;
|
pub const reg8: *mut u8 = 64 as *mut u8;
|
||||||
pub const reg16: *mut u16 = 64 as *mut u16;
|
pub const reg16: *mut u16 = 64 as *mut u16;
|
||||||
|
|
|
@ -2784,12 +2784,7 @@ pub unsafe fn instr_F9() {
|
||||||
pub unsafe fn instr_FA_without_fault() -> bool {
|
pub unsafe fn instr_FA_without_fault() -> bool {
|
||||||
// cli
|
// cli
|
||||||
if !*protected_mode
|
if !*protected_mode
|
||||||
|| if 0 != *flags & FLAG_VM {
|
|| if 0 != *flags & FLAG_VM { getiopl() == 3 } else { getiopl() >= *cpl as i32 }
|
||||||
getiopl() == 3
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
getiopl() >= *cpl as i32
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
*flags &= !FLAG_INTERRUPT;
|
*flags &= !FLAG_INTERRUPT;
|
||||||
return true;
|
return true;
|
||||||
|
@ -2822,12 +2817,7 @@ pub unsafe fn instr_FB() {
|
||||||
// sti
|
// sti
|
||||||
let old_if = *flags & FLAG_INTERRUPT;
|
let old_if = *flags & FLAG_INTERRUPT;
|
||||||
if !*protected_mode
|
if !*protected_mode
|
||||||
|| if 0 != *flags & FLAG_VM {
|
|| if 0 != *flags & FLAG_VM { getiopl() == 3 } else { getiopl() >= *cpl as i32 }
|
||||||
getiopl() == 3
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
getiopl() >= *cpl as i32
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
*flags |= FLAG_INTERRUPT;
|
*flags |= FLAG_INTERRUPT;
|
||||||
if old_if == 0 {
|
if old_if == 0 {
|
||||||
|
|
|
@ -29,8 +29,8 @@ extern "C" {
|
||||||
|
|
||||||
use cpu2::arith::{
|
use cpu2::arith::{
|
||||||
bsf16, bsf32, bsr16, bsr32, bt_mem, bt_reg, btc_mem, btc_reg, btr_mem, btr_reg, bts_mem,
|
bsf16, bsf32, bsr16, bsr32, bt_mem, bt_reg, btc_mem, btc_reg, btr_mem, btr_reg, bts_mem,
|
||||||
bts_reg, cmpxchg16, cmpxchg32, cmpxchg8, popcnt, shld16, shld32, shrd16, shrd32, xadd16,
|
bts_reg, cmpxchg8, cmpxchg16, cmpxchg32, popcnt, shld16, shld32, shrd16, shrd32, xadd8, xadd16,
|
||||||
xadd32, xadd8,
|
xadd32,
|
||||||
};
|
};
|
||||||
use cpu2::arith::{
|
use cpu2::arith::{
|
||||||
imul_reg16, imul_reg32, saturate_sd_to_sb, saturate_sd_to_sw, saturate_sd_to_ub,
|
imul_reg16, imul_reg32, saturate_sd_to_sb, saturate_sd_to_sw, saturate_sd_to_ub,
|
||||||
|
@ -1932,30 +1932,10 @@ pub unsafe fn instr_660F64_mem(addr: i32, r: i32) {
|
||||||
pub unsafe fn instr_0F65(source: reg64, r: i32) {
|
pub unsafe fn instr_0F65(source: reg64, r: i32) {
|
||||||
// pcmpgtw mm, mm/m64
|
// pcmpgtw mm, mm/m64
|
||||||
let destination = read_mmx64s(r);
|
let destination = read_mmx64s(r);
|
||||||
let word0 = if destination.i16_0[0] as i32 > source.i16_0[0] as i32 {
|
let word0 = if destination.i16_0[0] as i32 > source.i16_0[0] as i32 { 0xFFFF } else { 0 };
|
||||||
0xFFFF
|
let word1 = if destination.i16_0[1] as i32 > source.i16_0[1] as i32 { 0xFFFF } else { 0 };
|
||||||
}
|
let word2 = if destination.i16_0[2] as i32 > source.i16_0[2] as i32 { 0xFFFF } else { 0 };
|
||||||
else {
|
let word3 = if destination.i16_0[3] as i32 > source.i16_0[3] as i32 { 0xFFFF } else { 0 };
|
||||||
0
|
|
||||||
};
|
|
||||||
let word1 = if destination.i16_0[1] as i32 > source.i16_0[1] as i32 {
|
|
||||||
0xFFFF
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
0
|
|
||||||
};
|
|
||||||
let word2 = if destination.i16_0[2] as i32 > source.i16_0[2] as i32 {
|
|
||||||
0xFFFF
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
0
|
|
||||||
};
|
|
||||||
let word3 = if destination.i16_0[3] as i32 > source.i16_0[3] as i32 {
|
|
||||||
0xFFFF
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
0
|
|
||||||
};
|
|
||||||
let low = word0 | word1 << 16;
|
let low = word0 | word1 << 16;
|
||||||
let high = word2 | word3 << 16;
|
let high = word2 | word3 << 16;
|
||||||
write_mmx64(r, low, high);
|
write_mmx64(r, low, high);
|
||||||
|
@ -1996,18 +1976,8 @@ pub unsafe fn instr_660F65_mem(addr: i32, r: i32) {
|
||||||
pub unsafe fn instr_0F66(source: reg64, r: i32) {
|
pub unsafe fn instr_0F66(source: reg64, r: i32) {
|
||||||
// pcmpgtd mm, mm/m64
|
// pcmpgtd mm, mm/m64
|
||||||
let destination = read_mmx64s(r);
|
let destination = read_mmx64s(r);
|
||||||
let low = if destination.i32_0[0] > source.i32_0[0] {
|
let low = if destination.i32_0[0] > source.i32_0[0] { -1 } else { 0 };
|
||||||
-1
|
let high = if destination.i32_0[1] > source.i32_0[1] { -1 } else { 0 };
|
||||||
}
|
|
||||||
else {
|
|
||||||
0
|
|
||||||
};
|
|
||||||
let high = if destination.i32_0[1] > source.i32_0[1] {
|
|
||||||
-1
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
0
|
|
||||||
};
|
|
||||||
write_mmx64(r, low, high);
|
write_mmx64(r, low, high);
|
||||||
transition_fpu_to_mmx();
|
transition_fpu_to_mmx();
|
||||||
}
|
}
|
||||||
|
@ -2024,30 +1994,10 @@ pub unsafe fn instr_660F66(source: reg128, r: i32) {
|
||||||
let destination = read_xmm128s(r);
|
let destination = read_xmm128s(r);
|
||||||
write_xmm128(
|
write_xmm128(
|
||||||
r,
|
r,
|
||||||
if destination.i32_0[0] > source.i32_0[0] {
|
if destination.i32_0[0] > source.i32_0[0] { -1 } else { 0 },
|
||||||
-1
|
if destination.i32_0[1] > source.i32_0[1] { -1 } else { 0 },
|
||||||
}
|
if destination.i32_0[2] > source.i32_0[2] { -1 } else { 0 },
|
||||||
else {
|
if destination.i32_0[3] > source.i32_0[3] { -1 } else { 0 },
|
||||||
0
|
|
||||||
},
|
|
||||||
if destination.i32_0[1] > source.i32_0[1] {
|
|
||||||
-1
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
0
|
|
||||||
},
|
|
||||||
if destination.i32_0[2] > source.i32_0[2] {
|
|
||||||
-1
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
0
|
|
||||||
},
|
|
||||||
if destination.i32_0[3] > source.i32_0[3] {
|
|
||||||
-1
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
0
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
@ -2663,30 +2613,10 @@ pub unsafe fn instr_660F74_mem(addr: i32, r: i32) {
|
||||||
pub unsafe fn instr_0F75(source: reg64, r: i32) {
|
pub unsafe fn instr_0F75(source: reg64, r: i32) {
|
||||||
// pcmpeqw mm, mm/m64
|
// pcmpeqw mm, mm/m64
|
||||||
let destination = read_mmx64s(r);
|
let destination = read_mmx64s(r);
|
||||||
let word0 = if destination.u16_0[0] as i32 == source.u16_0[0] as i32 {
|
let word0 = if destination.u16_0[0] as i32 == source.u16_0[0] as i32 { 0xFFFF } else { 0 };
|
||||||
0xFFFF
|
let word1 = if destination.u16_0[1] as i32 == source.u16_0[1] as i32 { 0xFFFF } else { 0 };
|
||||||
}
|
let word2 = if destination.u16_0[2] as i32 == source.u16_0[2] as i32 { 0xFFFF } else { 0 };
|
||||||
else {
|
let word3 = if destination.u16_0[3] as i32 == source.u16_0[3] as i32 { 0xFFFF } else { 0 };
|
||||||
0
|
|
||||||
};
|
|
||||||
let word1 = if destination.u16_0[1] as i32 == source.u16_0[1] as i32 {
|
|
||||||
0xFFFF
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
0
|
|
||||||
};
|
|
||||||
let word2 = if destination.u16_0[2] as i32 == source.u16_0[2] as i32 {
|
|
||||||
0xFFFF
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
0
|
|
||||||
};
|
|
||||||
let word3 = if destination.u16_0[3] as i32 == source.u16_0[3] as i32 {
|
|
||||||
0xFFFF
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
0
|
|
||||||
};
|
|
||||||
let low = word0 | word1 << 16;
|
let low = word0 | word1 << 16;
|
||||||
let high = word2 | word3 << 16;
|
let high = word2 | word3 << 16;
|
||||||
write_mmx64(r, low, high);
|
write_mmx64(r, low, high);
|
||||||
|
@ -2725,18 +2655,8 @@ pub unsafe fn instr_660F75_mem(addr: i32, r: i32) {
|
||||||
pub unsafe fn instr_0F76(source: reg64, r: i32) {
|
pub unsafe fn instr_0F76(source: reg64, r: i32) {
|
||||||
// pcmpeqd mm, mm/m64
|
// pcmpeqd mm, mm/m64
|
||||||
let destination = read_mmx64s(r);
|
let destination = read_mmx64s(r);
|
||||||
let low = if destination.u32_0[0] == source.u32_0[0] {
|
let low = if destination.u32_0[0] == source.u32_0[0] { -1 } else { 0 };
|
||||||
-1
|
let high = if destination.u32_0[1] == source.u32_0[1] { -1 } else { 0 };
|
||||||
}
|
|
||||||
else {
|
|
||||||
0
|
|
||||||
};
|
|
||||||
let high = if destination.u32_0[1] == source.u32_0[1] {
|
|
||||||
-1
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
0
|
|
||||||
};
|
|
||||||
write_mmx64(r, low, high);
|
write_mmx64(r, low, high);
|
||||||
transition_fpu_to_mmx();
|
transition_fpu_to_mmx();
|
||||||
}
|
}
|
||||||
|
@ -2753,30 +2673,10 @@ pub unsafe fn instr_660F76(source: reg128, r: i32) {
|
||||||
let destination = read_xmm128s(r);
|
let destination = read_xmm128s(r);
|
||||||
write_xmm128(
|
write_xmm128(
|
||||||
r,
|
r,
|
||||||
if source.u32_0[0] == destination.u32_0[0] {
|
if source.u32_0[0] == destination.u32_0[0] { -1 } else { 0 },
|
||||||
-1
|
if source.u32_0[1] == destination.u32_0[1] { -1 } else { 0 },
|
||||||
}
|
if source.u32_0[2] == destination.u32_0[2] { -1 } else { 0 },
|
||||||
else {
|
if source.u32_0[3] == destination.u32_0[3] { -1 } else { 0 },
|
||||||
0
|
|
||||||
},
|
|
||||||
if source.u32_0[1] == destination.u32_0[1] {
|
|
||||||
-1
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
0
|
|
||||||
},
|
|
||||||
if source.u32_0[2] == destination.u32_0[2] {
|
|
||||||
-1
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
0
|
|
||||||
},
|
|
||||||
if source.u32_0[3] == destination.u32_0[3] {
|
|
||||||
-1
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
0
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
@ -6186,18 +6086,10 @@ pub unsafe fn instr_660FC2(source: reg128, r: i32, imm8: i32) {
|
||||||
let destination = read_xmm128s(r);
|
let destination = read_xmm128s(r);
|
||||||
let result = reg128 {
|
let result = reg128 {
|
||||||
i64_0: [
|
i64_0: [
|
||||||
(if sse_comparison(imm8, destination.f64_0[0], source.f64_0[0]) {
|
(if sse_comparison(imm8, destination.f64_0[0], source.f64_0[0]) { -1 } else { 0 })
|
||||||
-1
|
as i64,
|
||||||
}
|
(if sse_comparison(imm8, destination.f64_0[1], source.f64_0[1]) { -1 } else { 0 })
|
||||||
else {
|
as i64,
|
||||||
0
|
|
||||||
}) as i64,
|
|
||||||
(if sse_comparison(imm8, destination.f64_0[1], source.f64_0[1]) {
|
|
||||||
-1
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
0
|
|
||||||
}) as i64,
|
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
write_xmm_reg128(r, result);
|
write_xmm_reg128(r, result);
|
||||||
|
@ -6216,12 +6108,8 @@ pub unsafe fn instr_F20FC2(source: reg64, r: i32, imm8: i32) {
|
||||||
let destination = read_xmm64s(r);
|
let destination = read_xmm64s(r);
|
||||||
let result = reg64 {
|
let result = reg64 {
|
||||||
i64_0: [
|
i64_0: [
|
||||||
(if sse_comparison(imm8, destination.f64_0[0], source.f64_0[0]) {
|
(if sse_comparison(imm8, destination.f64_0[0], source.f64_0[0]) { -1 } else { 0 })
|
||||||
-1
|
as i64,
|
||||||
}
|
|
||||||
else {
|
|
||||||
0
|
|
||||||
}) as i64,
|
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
write_xmm64(r, result);
|
write_xmm64(r, result);
|
||||||
|
@ -6238,12 +6126,7 @@ pub unsafe fn instr_F20FC2_mem(addr: i32, r: i32, imm: i32) {
|
||||||
pub unsafe fn instr_F30FC2(source: f32, r: i32, imm8: i32) {
|
pub unsafe fn instr_F30FC2(source: f32, r: i32, imm8: i32) {
|
||||||
// cmpss xmm, xmm/m32
|
// cmpss xmm, xmm/m32
|
||||||
let destination = read_xmm_f32(r);
|
let destination = read_xmm_f32(r);
|
||||||
let result = if sse_comparison(imm8, destination as f64, source as f64) {
|
let result = if sse_comparison(imm8, destination as f64, source as f64) { -1 } else { 0 };
|
||||||
-1
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
0
|
|
||||||
};
|
|
||||||
write_xmm32(r, result);
|
write_xmm32(r, result);
|
||||||
}
|
}
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|
|
@ -186,12 +186,7 @@ pub unsafe fn push16_ss32_mem(addr: i32) -> OrPageFault<()> { push16_ss32(safe_r
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe fn push16(imm16: i32) -> OrPageFault<()> {
|
pub unsafe fn push16(imm16: i32) -> OrPageFault<()> {
|
||||||
if *stack_size_32 {
|
if *stack_size_32 { push16_ss32(imm16) } else { push16_ss16(imm16) }
|
||||||
push16_ss32(imm16)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
push16_ss16(imm16)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
@ -216,21 +211,11 @@ pub unsafe fn push32_ss32_mem(addr: i32) -> OrPageFault<()> { push32_ss32(safe_r
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe fn push32(imm32: i32) -> OrPageFault<()> {
|
pub unsafe fn push32(imm32: i32) -> OrPageFault<()> {
|
||||||
if *stack_size_32 {
|
if *stack_size_32 { push32_ss32(imm32) } else { push32_ss16(imm32) }
|
||||||
push32_ss32(imm32)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
push32_ss16(imm32)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe fn pop16() -> OrPageFault<i32> {
|
pub unsafe fn pop16() -> OrPageFault<i32> {
|
||||||
if *stack_size_32 {
|
if *stack_size_32 { pop16_ss32() } else { pop16_ss16() }
|
||||||
pop16_ss32()
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
pop16_ss16()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe fn pop16_ss16() -> OrPageFault<i32> {
|
pub unsafe fn pop16_ss16() -> OrPageFault<i32> {
|
||||||
|
@ -248,12 +233,7 @@ pub unsafe fn pop16_ss32() -> OrPageFault<i32> {
|
||||||
}
|
}
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe fn pop32s() -> OrPageFault<i32> {
|
pub unsafe fn pop32s() -> OrPageFault<i32> {
|
||||||
if *stack_size_32 {
|
if *stack_size_32 { pop32s_ss32() } else { pop32s_ss16() }
|
||||||
pop32s_ss32()
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
pop32s_ss16()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe fn pop32s_ss16() -> OrPageFault<i32> {
|
pub unsafe fn pop32s_ss16() -> OrPageFault<i32> {
|
||||||
|
|
|
@ -97,13 +97,7 @@ pub unsafe fn resolve_modrm32_(modrm_byte: i32) -> OrPageFault<i32> {
|
||||||
resolve_sib(false)?
|
resolve_sib(false)?
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
resolve_sib(true)?
|
resolve_sib(true)? + if modrm_byte < 128 { read_imm8s()? } else { read_imm32s()? }
|
||||||
+ if modrm_byte < 128 {
|
|
||||||
read_imm8s()?
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
read_imm32s()?
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if r as i32 == 5 {
|
else if r as i32 == 5 {
|
||||||
|
@ -113,12 +107,7 @@ pub unsafe fn resolve_modrm32_(modrm_byte: i32) -> OrPageFault<i32> {
|
||||||
else {
|
else {
|
||||||
get_seg_prefix_ss(
|
get_seg_prefix_ss(
|
||||||
*reg32.offset(EBP as isize)
|
*reg32.offset(EBP as isize)
|
||||||
+ if modrm_byte < 128 {
|
+ if modrm_byte < 128 { read_imm8s()? } else { read_imm32s()? },
|
||||||
read_imm8s()?
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
read_imm32s()?
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,12 +117,7 @@ pub unsafe fn resolve_modrm32_(modrm_byte: i32) -> OrPageFault<i32> {
|
||||||
else {
|
else {
|
||||||
get_seg_prefix_ds(
|
get_seg_prefix_ds(
|
||||||
*reg32.offset(r as isize)
|
*reg32.offset(r as isize)
|
||||||
+ if modrm_byte < 128 {
|
+ if modrm_byte < 128 { read_imm8s()? } else { read_imm32s()? },
|
||||||
read_imm8s()?
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
read_imm32s()?
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,12 +25,7 @@ impl CpuContext {
|
||||||
}
|
}
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub fn advance_moffs(&mut self) {
|
pub fn advance_moffs(&mut self) {
|
||||||
if self.asize_32() {
|
if self.asize_32() { self.advance32() } else { self.advance16() }
|
||||||
self.advance32()
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
self.advance16()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_imm8(&mut self) -> u8 {
|
pub fn read_imm8(&mut self) -> u8 {
|
||||||
|
@ -54,12 +49,7 @@ impl CpuContext {
|
||||||
v
|
v
|
||||||
}
|
}
|
||||||
pub fn read_moffs(&mut self) -> u32 {
|
pub fn read_moffs(&mut self) -> u32 {
|
||||||
if self.asize_32() {
|
if self.asize_32() { self.read_imm32() } else { self.read_imm16() as u32 }
|
||||||
self.read_imm32()
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
self.read_imm16() as u32
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cpl3(&self) -> bool { self.state_flags.cpl3() }
|
pub fn cpl3(&self) -> bool { self.state_flags.cpl3() }
|
||||||
|
|
|
@ -136,12 +136,7 @@ mod jit_cache_array {
|
||||||
|
|
||||||
pub fn get_page_index(page: Page) -> Option<u32> {
|
pub fn get_page_index(page: Page) -> Option<u32> {
|
||||||
let index = unsafe { *page_first_entry.offset(page.to_u32() as isize) };
|
let index = unsafe { *page_first_entry.offset(page.to_u32() as isize) };
|
||||||
if index == NO_NEXT_ENTRY {
|
if index == NO_NEXT_ENTRY { None } else { Some(index) }
|
||||||
None
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Some(index)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_page_index(page: Page, index: Option<u32>) {
|
pub fn set_page_index(page: Page, index: Option<u32>) {
|
||||||
|
@ -154,7 +149,11 @@ mod jit_cache_array {
|
||||||
unsafe { &mut *jit_cache_array.offset(i as isize) }
|
unsafe { &mut *jit_cache_array.offset(i as isize) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set(i: u32, entry: Entry) { unsafe { *jit_cache_array.offset(i as isize) = entry }; }
|
fn set(i: u32, entry: Entry) {
|
||||||
|
unsafe {
|
||||||
|
*jit_cache_array.offset(i as isize) = entry
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
pub fn insert(index: u32, mut entry: Entry) {
|
pub fn insert(index: u32, mut entry: Entry) {
|
||||||
let page = Page::page_of(entry.start_addr);
|
let page = Page::page_of(entry.start_addr);
|
||||||
|
@ -1264,8 +1263,14 @@ fn jit_generate_basic_block(ctx: &mut JitContext, block: &BasicBlock) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if was_block_boundary || is_near_end_of_page(end_addr) || end_addr > stop_addr {
|
if was_block_boundary || is_near_end_of_page(end_addr) || end_addr > stop_addr {
|
||||||
dbg_log!("Overlapping basic blocks start={:x} expected_end={:x} end={:x} was_block_boundary={} near_end_of_page={}",
|
dbg_log!(
|
||||||
start_addr, stop_addr, end_addr, was_block_boundary, is_near_end_of_page(end_addr));
|
"Overlapping basic blocks start={:x} expected_end={:x} end={:x} was_block_boundary={} near_end_of_page={}",
|
||||||
|
start_addr,
|
||||||
|
stop_addr,
|
||||||
|
end_addr,
|
||||||
|
was_block_boundary,
|
||||||
|
is_near_end_of_page(end_addr)
|
||||||
|
);
|
||||||
dbg_assert!(false);
|
dbg_assert!(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1510,12 +1515,8 @@ pub fn check_missed_entry_points(phys_address: u32, state_flags: CachedStateFlag
|
||||||
let last_jump_type = unsafe { ::cpu2::cpu::debug_last_jump.name() };
|
let last_jump_type = unsafe { ::cpu2::cpu::debug_last_jump.name() };
|
||||||
let last_jump_addr =
|
let last_jump_addr =
|
||||||
unsafe { ::cpu2::cpu::debug_last_jump.phys_address() }.unwrap_or(0);
|
unsafe { ::cpu2::cpu::debug_last_jump.phys_address() }.unwrap_or(0);
|
||||||
let last_jump_opcode = if last_jump_addr != 0 {
|
let last_jump_opcode =
|
||||||
cpu::read32(last_jump_addr)
|
if last_jump_addr != 0 { cpu::read32(last_jump_addr) } else { 0 };
|
||||||
}
|
|
||||||
else {
|
|
||||||
0
|
|
||||||
};
|
|
||||||
|
|
||||||
let opcode = cpu::read32(phys_address);
|
let opcode = cpu::read32(phys_address);
|
||||||
dbg_log!(
|
dbg_log!(
|
||||||
|
|
|
@ -10,12 +10,7 @@ use regs::{EAX, EBP, EBX, ECX, EDI, EDX, ESI, ESP};
|
||||||
use wasmgen::wasm_util::WasmBuf;
|
use wasmgen::wasm_util::WasmBuf;
|
||||||
|
|
||||||
pub fn skip(ctx: &mut CpuContext, modrm_byte: u8) {
|
pub fn skip(ctx: &mut CpuContext, modrm_byte: u8) {
|
||||||
if ctx.asize_32() {
|
if ctx.asize_32() { skip32(ctx, modrm_byte) } else { skip16(ctx, modrm_byte) }
|
||||||
skip32(ctx, modrm_byte)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
skip16(ctx, modrm_byte)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn skip16(ctx: &mut CpuContext, modrm_byte: u8) {
|
fn skip16(ctx: &mut CpuContext, modrm_byte: u8) {
|
||||||
|
@ -70,12 +65,7 @@ fn skip32(ctx: &mut CpuContext, modrm_byte: u8) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn gen(ctx: &mut JitContext, modrm_byte: u8) {
|
pub fn gen(ctx: &mut JitContext, modrm_byte: u8) {
|
||||||
if ctx.cpu.asize_32() {
|
if ctx.cpu.asize_32() { gen32(ctx, modrm_byte) } else { gen16(ctx, modrm_byte) }
|
||||||
gen32(ctx, modrm_byte)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
gen16(ctx, modrm_byte)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Imm16 {
|
enum Imm16 {
|
||||||
|
@ -348,12 +338,7 @@ fn can_optimize_get_seg(ctx: &mut JitContext, segment: u32) -> bool {
|
||||||
|
|
||||||
pub fn jit_add_seg_offset(ctx: &mut JitContext, default_segment: u32) {
|
pub fn jit_add_seg_offset(ctx: &mut JitContext, default_segment: u32) {
|
||||||
let prefix = ctx.cpu.prefixes & PREFIX_MASK_SEGMENT;
|
let prefix = ctx.cpu.prefixes & PREFIX_MASK_SEGMENT;
|
||||||
let seg = if prefix != 0 {
|
let seg = if prefix != 0 { prefix - 1 } else { default_segment };
|
||||||
prefix - 1
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
default_segment
|
|
||||||
};
|
|
||||||
|
|
||||||
if can_optimize_get_seg(ctx, seg) || prefix == SEG_PREFIX_ZERO {
|
if can_optimize_get_seg(ctx, seg) || prefix == SEG_PREFIX_ZERO {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use util::{SafeToU16, SafeToU8};
|
use util::{SafeToU8, SafeToU16};
|
||||||
use wasmgen::wasm_opcodes as op;
|
use wasmgen::wasm_opcodes as op;
|
||||||
use wasmgen::wasm_util::WasmBuf;
|
use wasmgen::wasm_util::WasmBuf;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue