--- a/src/sh4/mmux86.c Mon Jan 26 07:26:24 2009 +0000 +++ b/src/sh4/mmux86.c Wed Mar 04 23:12:21 2009 +0000 @@ -22,19 +22,24 @@ #include "sh4/sh4mmio.h" #include "sh4/sh4trans.h" #include "sh4/mmu.h" -#include "sh4/x86op.h" +#include "xlat/x86/x86op.h" #if SIZEOF_VOID_P == 8 -#define ARG1 R_EDI -#define ARG2 R_ESI -#define DECODE() \ - MOV_imm64_r32((uintptr_t)addr_space, R_EAX); /* movq ptr, %rax */ \ - REXW(); OP(0x8B); OP(0x0C); OP(0xC8) /* movq [%rax + %rcx*8], %rcx */ +#define ARG1 REG_RDI +#define ARG2 REG_RSI +#define XLAT(addr_space, reg) \ + MOVQ_imm64_r64( (uintptr_t)addr_space, REG_RAX ); \ + MOVP_sib_rptr( 3, reg, REG_RAX, 0, reg ); +#define ADDP_imms_ptr(imm,p) \ + MOVQ_imm64_r64((uintptr_t)p, REG_EAX ); \ + ADDL_imms_r32disp(imm, REG_EAX, 0); #else -#define ARG1 R_EAX +#define ARG1 REG_EAX #define ARG2 R_EDX -#define DECODE() \ - MOV_r32disp32x4_r32( R_ECX, (uintptr_t)addr_space, R_ECX ); +#define XLAT(addr_space, reg) \ + MOVP_sib_rptr( 2, reg, -1, (uintptr_t)addr_space, reg ); +#define ADDP_imms_ptr(imm,p) \ + ADDL_imms_r32disp(imm, -1, (uintptr_t)p); #endif void mmu_utlb_init_vtable( struct utlb_entry *ent, struct utlb_page_entry *page, gboolean writable ) @@ -61,23 +66,18 @@ for( i=0; i<10; i+= inc, fn += inc, out += inc ) { *out = xlat_output; if( i != 9 ) { /* read_byte_for_write doesn't increment mmu_urc, everything else does */ -#if SIZEOF_VOID_P == 8 - MOV_imm64_r32((uintptr_t)&mmu_urc, R_EAX ); - OP(0x83); OP(0x00); OP(0x01); // ADD #1, [RAX] -#else - OP(0x83); MODRM_r32_disp32(0, (uintptr_t)&mmu_urc); OP(0x01); // ADD #1, mmu_urc -#endif + ADDP_imms_ptr(1, &mmu_urc); } - ADD_imm32_r32( ppn-vpn, ARG1 ); // 6 + ADDL_imms_r32( ppn-vpn, ARG1 ); // 6 if( ent->mask >= 0xFFFFF000 ) { // Maps to a single page, so jump directly there int rel = (*fn - xlat_output); - JMP_rel( rel ); // 5 + JMP_prerel( rel ); // 5 } else { - MOV_r32_r32( ARG1, R_ECX ); // 2 - SHR_imm8_r32( 12, R_ECX ); // 3 - DECODE(); // 14 - JMP_r32disp8(R_ECX, (((uintptr_t)out) - ((uintptr_t)&page->fn)) ); // 3 + MOVL_r32_r32( ARG1, REG_ECX ); // 2 + SHRL_imm_r32( 12, REG_ECX ); // 3 + XLAT(addr_space, REG_ECX); // 14 + JMP_r32disp(REG_ECX, (((uintptr_t)out) - ((uintptr_t)&page->fn)) ); // 3 } } @@ -95,15 +95,10 @@ memcpy( page, &p4_region_storequeue, sizeof(struct mem_region_fn) ); page->fn.prefetch = (mem_prefetch_fn_t)xlat_output; -#if SIZEOF_VOID_P == 8 - MOV_imm64_r32((uintptr_t)&mmu_urc, R_EAX ); - OP(0x83); OP(0x00); OP(0x01); // ADD #1, [RAX] -#else - OP(0x83); MODRM_r32_disp32(0, (uintptr_t)&mmu_urc); OP(0x01); // ADD #1, mmu_urc -#endif - ADD_imm32_r32( ppn-vpn, ARG1 ); + ADDP_imms_ptr(1, &mmu_urc); + ADDL_imms_r32( ppn-vpn, ARG1 ); int rel = ((uint8_t *)ccn_storequeue_prefetch_tlb) - xlat_output; - JMP_rel( rel ); + JMP_prerel( rel ); } void mmu_utlb_1k_init_vtable( struct utlb_1k_entry *entry ) @@ -114,31 +109,21 @@ for( i=0; i<9; i++, out++ ) { *out = xlat_output; - MOV_r32_r32( ARG1, R_ECX ); - SHR_imm8_r32( 10, R_ECX ); - AND_imm8s_r32( 0x3, R_ECX ); -#if SIZEOF_VOID_P == 8 - MOV_imm64_r32( (uintptr_t)&entry->subpages[0], R_EAX ); - REXW(); OP(0x8B); OP(0x0C); OP(0xC8); /* movq [%rax + %rcx*8], %rcx */ -#else - MOV_r32disp32x4_r32( R_ECX, ((uintptr_t)&entry->subpages[0]), R_ECX ); -#endif - JMP_r32disp8(R_ECX, (((uintptr_t)out) - ((uintptr_t)&entry->fn)) ); // 3 + MOVL_r32_r32( ARG1, REG_ECX ); + SHRL_imm_r32( 10, REG_ECX ); + ANDL_imms_r32( 0x3, REG_ECX ); + XLAT( (uintptr_t)&entry->subpages[0], REG_ECX ); + JMP_r32disp(REG_ECX, (((uintptr_t)out) - ((uintptr_t)&entry->fn)) ); // 3 } out = (uint8_t **)&entry->user_fn; for( i=0; i<9; i++, out++ ) { *out = xlat_output; - MOV_r32_r32( ARG1, R_ECX ); - SHR_imm8_r32( 10, R_ECX ); - AND_imm8s_r32( 0x3, R_ECX ); -#if SIZEOF_VOID_P == 8 - MOV_imm64_r32( (uintptr_t)&entry->user_subpages[0], R_EAX ); - REXW(); OP(0x8B); OP(0x0C); OP(0xC8); /* movq [%rax + %rcx*8], %rcx */ -#else - MOV_r32disp32x4_r32( R_ECX, ((uintptr_t)&entry->user_subpages[0]), R_ECX ); -#endif - JMP_r32disp8(R_ECX, (((uintptr_t)out) - ((uintptr_t)&entry->user_fn)) ); // 3 + MOVL_r32_r32( ARG1, REG_ECX ); + SHRL_imm_r32( 10, REG_ECX ); + ANDL_imms_r32( 0x3, REG_ECX ); + XLAT( (uintptr_t)&entry->user_subpages[0], REG_ECX ); + JMP_r32disp(REG_ECX, (((uintptr_t)out) - ((uintptr_t)&entry->user_fn)) ); // 3 } }