More linting in src/codegen

This commit is contained in:
Jasmine Iwanek
2023-08-22 13:33:49 -04:00
parent 66854089c0
commit c4bb670901
14 changed files with 694 additions and 613 deletions

View File

@@ -33,6 +33,8 @@ int codegen_in_recompile;
void void
codegen_set_rounding_mode(int mode) codegen_set_rounding_mode(int mode)
{ {
/* cpu_state.new_npxc = (cpu_state.old_npxc & ~0xc00) | (cpu_state.npxc & 0xc00); */ #if 0
cpu_state.new_npxc = (cpu_state.old_npxc & ~0xc00) | (cpu_state.npxc & 0xc00);
#endif
cpu_state.new_npxc = (cpu_state.old_npxc & ~0xc00) | (mode << 10); cpu_state.new_npxc = (cpu_state.old_npxc & ~0xc00) | (mode << 10);
} }

View File

@@ -74,19 +74,25 @@
*/ */
typedef struct codeblock_t { typedef struct codeblock_t {
uint64_t page_mask, page_mask2; uint64_t page_mask;
uint64_t *dirty_mask, *dirty_mask2; uint64_t page_mask2;
uint64_t *dirty_mask;
uint64_t *dirty_mask2;
uint64_t cmp; uint64_t cmp;
/*Previous and next pointers, for the codeblock list associated with /*Previous and next pointers, for the codeblock list associated with
each physical page. Two sets of pointers, as a codeblock can be each physical page. Two sets of pointers, as a codeblock can be
present in two pages.*/ present in two pages.*/
struct codeblock_t *prev, *next; struct codeblock_t *prev;
struct codeblock_t *prev_2, *next_2; struct codeblock_t *next;
struct codeblock_t *prev_2;
struct codeblock_t *next_2;
/*Pointers for codeblock tree, used to search for blocks when hash lookup /*Pointers for codeblock tree, used to search for blocks when hash lookup
fails.*/ fails.*/
struct codeblock_t *parent, *left, *right; struct codeblock_t *parent;
struct codeblock_t *left;
struct codeblock_t *right;
int pnt; int pnt;
int ins; int ins;

View File

@@ -5,6 +5,7 @@
#include <86box/86box.h> #include <86box/86box.h>
#include <86box/mem.h> #include <86box/mem.h>
#include <86box/plat_unused.h>
#include "cpu.h" #include "cpu.h"
#include "x86.h" #include "x86.h"
#include "x86_ops.h" #include "x86_ops.h"

View File

@@ -8,7 +8,9 @@ ropINC_rw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, cod
host_reg = LOAD_REG_W(opcode & 7); host_reg = LOAD_REG_W(opcode & 7);
STORE_HOST_REG_ADDR_WL((uintptr_t) &cpu_state.flags_op1, host_reg); STORE_HOST_REG_ADDR_WL((uintptr_t) &cpu_state.flags_op1, host_reg);
// ADD_HOST_REG_IMM_W(host_reg, 1); #if 0
ADD_HOST_REG_IMM_W(host_reg, 1);
#endif
INC_HOST_REG_W(host_reg); INC_HOST_REG_W(host_reg);
STORE_IMM_ADDR_L((uintptr_t) &cpu_state.flags_op2, 1); STORE_IMM_ADDR_L((uintptr_t) &cpu_state.flags_op2, 1);
STORE_IMM_ADDR_L((uintptr_t) &cpu_state.flags_op, FLAGS_INC16); STORE_IMM_ADDR_L((uintptr_t) &cpu_state.flags_op, FLAGS_INC16);
@@ -29,7 +31,9 @@ ropINC_rl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, cod
host_reg = LOAD_REG_L(opcode & 7); host_reg = LOAD_REG_L(opcode & 7);
STORE_HOST_REG_ADDR((uintptr_t) &cpu_state.flags_op1, host_reg); STORE_HOST_REG_ADDR((uintptr_t) &cpu_state.flags_op1, host_reg);
// ADD_HOST_REG_IMM(host_reg, 1); #if 0
ADD_HOST_REG_IMM(host_reg, 1);
#endif
INC_HOST_REG(host_reg); INC_HOST_REG(host_reg);
STORE_IMM_ADDR_L((uintptr_t) &cpu_state.flags_op2, 1); STORE_IMM_ADDR_L((uintptr_t) &cpu_state.flags_op2, 1);
STORE_IMM_ADDR_L((uintptr_t) &cpu_state.flags_op, FLAGS_INC32); STORE_IMM_ADDR_L((uintptr_t) &cpu_state.flags_op, FLAGS_INC32);
@@ -50,7 +54,9 @@ ropDEC_rw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, cod
host_reg = LOAD_REG_W(opcode & 7); host_reg = LOAD_REG_W(opcode & 7);
STORE_HOST_REG_ADDR_WL((uintptr_t) &cpu_state.flags_op1, host_reg); STORE_HOST_REG_ADDR_WL((uintptr_t) &cpu_state.flags_op1, host_reg);
// SUB_HOST_REG_IMM_W(host_reg, 1); #if 0
SUB_HOST_REG_IMM_W(host_reg, 1);
#endif
DEC_HOST_REG_W(host_reg); DEC_HOST_REG_W(host_reg);
STORE_IMM_ADDR_L((uintptr_t) &cpu_state.flags_op2, 1); STORE_IMM_ADDR_L((uintptr_t) &cpu_state.flags_op2, 1);
STORE_IMM_ADDR_L((uintptr_t) &cpu_state.flags_op, FLAGS_DEC16); STORE_IMM_ADDR_L((uintptr_t) &cpu_state.flags_op, FLAGS_DEC16);
@@ -71,7 +77,9 @@ ropDEC_rl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, cod
host_reg = LOAD_REG_L(opcode & 7); host_reg = LOAD_REG_L(opcode & 7);
STORE_HOST_REG_ADDR((uintptr_t) &cpu_state.flags_op1, host_reg); STORE_HOST_REG_ADDR((uintptr_t) &cpu_state.flags_op1, host_reg);
// SUB_HOST_REG_IMM(host_reg, 1); #if 0
SUB_HOST_REG_IMM(host_reg, 1);
#endif
DEC_HOST_REG(host_reg); DEC_HOST_REG(host_reg);
STORE_IMM_ADDR_L((uintptr_t) &cpu_state.flags_op2, 1); STORE_IMM_ADDR_L((uintptr_t) &cpu_state.flags_op2, 1);
STORE_IMM_ADDR_L((uintptr_t) &cpu_state.flags_op, FLAGS_DEC32); STORE_IMM_ADDR_L((uintptr_t) &cpu_state.flags_op, FLAGS_DEC32);
@@ -84,9 +92,11 @@ ropDEC_rl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, cod
} }
#define ROP_ARITH_RMW(name, op, writeback) \ #define ROP_ARITH_RMW(name, op, writeback) \
static uint32_t rop##name##_b_rmw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \ static uint32_t \
rop##name##_b_rmw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \
{ \ { \
int src_reg, dst_reg; \ int src_reg; \
int dst_reg; \
x86seg *target_seg; \ x86seg *target_seg; \
\ \
if ((fetchdat & 0xc0) == 0xc0) { \ if ((fetchdat & 0xc0) == 0xc0) { \
@@ -118,9 +128,11 @@ ropDEC_rl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, cod
codegen_flags_changed = 1; \ codegen_flags_changed = 1; \
return op_pc + 1; \ return op_pc + 1; \
} \ } \
static uint32_t rop##name##_w_rmw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \ static uint32_t \
rop##name##_w_rmw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \
{ \ { \
int src_reg, dst_reg; \ int src_reg; \
int dst_reg; \
x86seg *target_seg; \ x86seg *target_seg; \
\ \
if ((fetchdat & 0xc0) == 0xc0) { \ if ((fetchdat & 0xc0) == 0xc0) { \
@@ -152,9 +164,11 @@ ropDEC_rl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, cod
codegen_flags_changed = 1; \ codegen_flags_changed = 1; \
return op_pc + 1; \ return op_pc + 1; \
} \ } \
static uint32_t rop##name##_l_rmw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \ static uint32_t \
rop##name##_l_rmw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \
{ \ { \
int src_reg, dst_reg; \ int src_reg; \
int dst_reg; \
x86seg *target_seg; \ x86seg *target_seg; \
\ \
if ((fetchdat & 0xc0) == 0xc0) { \ if ((fetchdat & 0xc0) == 0xc0) { \
@@ -188,9 +202,11 @@ ropDEC_rl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, cod
} }
#define ROP_ARITH_RM(name, op, writeback) \ #define ROP_ARITH_RM(name, op, writeback) \
static uint32_t rop##name##_b_rm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \ static uint32_t \
rop##name##_b_rm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \
{ \ { \
int src_reg, dst_reg; \ int src_reg; \
int dst_reg; \
\ \
if ((fetchdat & 0xc0) == 0xc0) { \ if ((fetchdat & 0xc0) == 0xc0) { \
src_reg = LOAD_REG_B(fetchdat & 7); \ src_reg = LOAD_REG_B(fetchdat & 7); \
@@ -216,9 +232,11 @@ ropDEC_rl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, cod
codegen_flags_changed = 1; \ codegen_flags_changed = 1; \
return op_pc + 1; \ return op_pc + 1; \
} \ } \
static uint32_t rop##name##_w_rm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \ static uint32_t \
rop##name##_w_rm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \
{ \ { \
int src_reg, dst_reg; \ int src_reg; \
int dst_reg; \
\ \
if ((fetchdat & 0xc0) == 0xc0) { \ if ((fetchdat & 0xc0) == 0xc0) { \
src_reg = LOAD_REG_W(fetchdat & 7); \ src_reg = LOAD_REG_W(fetchdat & 7); \
@@ -244,9 +262,11 @@ ropDEC_rl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, cod
codegen_flags_changed = 1; \ codegen_flags_changed = 1; \
return op_pc + 1; \ return op_pc + 1; \
} \ } \
static uint32_t rop##name##_l_rm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \ static uint32_t \
rop##name##_l_rm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \
{ \ { \
int src_reg, dst_reg; \ int src_reg; \
int dst_reg; \
\ \
if ((fetchdat & 0xc0) == 0xc0) { \ if ((fetchdat & 0xc0) == 0xc0) { \
src_reg = LOAD_REG_L(fetchdat & 7); \ src_reg = LOAD_REG_L(fetchdat & 7); \

View File

@@ -195,7 +195,8 @@ ropFSTPd(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, code
} }
#define ropFarith(name, size, load, op) \ #define ropFarith(name, size, load, op) \
static uint32_t ropF##name##size(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \ static uint32_t \
ropF##name##size(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \
{ \ { \
x86seg *target_seg; \ x86seg *target_seg; \
\ \
@@ -239,7 +240,8 @@ ropFarith(SUB, il, MEM_LOAD_ADDR_EA_L, FP_OP_IL);
ropFarith(SUBR, il, MEM_LOAD_ADDR_EA_L, FP_OP_IL); ropFarith(SUBR, il, MEM_LOAD_ADDR_EA_L, FP_OP_IL);
#define ropFcompare(name, size, load, op) \ #define ropFcompare(name, size, load, op) \
static uint32_t ropF##name##size(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \ static uint32_t \
ropF##name##size(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \
{ \ { \
x86seg *target_seg; \ x86seg *target_seg; \
\ \
@@ -270,7 +272,9 @@ ropFcompare(COM, d, MEM_LOAD_ADDR_EA_Q, FP_COMPARE_D);
ropFcompare(COM, iw, MEM_LOAD_ADDR_EA_W, FP_COMPARE_IW); ropFcompare(COM, iw, MEM_LOAD_ADDR_EA_W, FP_COMPARE_IW);
ropFcompare(COM, il, MEM_LOAD_ADDR_EA_L, FP_COMPARE_IL); ropFcompare(COM, il, MEM_LOAD_ADDR_EA_L, FP_COMPARE_IL);
/*static uint32_t ropFADDs(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) #if 0
static uint32_t
ropFADDs(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
{ {
x86seg *target_seg; x86seg *target_seg;
@@ -287,7 +291,8 @@ ropFcompare(COM, il, MEM_LOAD_ADDR_EA_L, FP_COMPARE_IL);
return op_pc + 1; return op_pc + 1;
} }
static uint32_t ropFDIVs(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) static uint32_t
ropFDIVs(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
{ {
x86seg *target_seg; x86seg *target_seg;
@@ -304,7 +309,8 @@ static uint32_t ropFDIVs(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint
return op_pc + 1; return op_pc + 1;
} }
static uint32_t ropFMULs(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) static uint32_t
ropFMULs(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
{ {
x86seg *target_seg; x86seg *target_seg;
@@ -321,7 +327,8 @@ static uint32_t ropFMULs(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint
return op_pc + 1; return op_pc + 1;
} }
static uint32_t ropFSUBs(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) static uint32_t
ropFSUBs(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
{ {
x86seg *target_seg; x86seg *target_seg;
@@ -337,7 +344,8 @@ static uint32_t ropFSUBs(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint
FP_OP_S(FPU_SUB); FP_OP_S(FPU_SUB);
return op_pc + 1; return op_pc + 1;
}*/ }
#endif
static uint32_t static uint32_t
ropFADD(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) ropFADD(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
@@ -659,7 +667,8 @@ ropFCHS(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeb
} }
#define opFLDimm(name, v) \ #define opFLDimm(name, v) \
static uint32_t ropFLD##name(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \ static uint32_t \
ropFLD##name(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \
{ \ { \
static double fp_imm = v; \ static double fp_imm = v; \
\ \
@@ -678,7 +687,8 @@ opFLDimm(EG2, 0.3010299956639812);
opFLDimm(Z, 0.0) opFLDimm(Z, 0.0)
// clang-format on // clang-format on
static uint32_t ropFLDLN2(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) static uint32_t
ropFLDLN2(UNUSED(uint8_t opcode), uint32_t fetchdat, UNUSED(uint32_t op_32), uint32_t op_pc, UNUSED(codeblock_t *block))
{ {
FP_ENTER(); FP_ENTER();
FP_LOAD_IMM_Q(0x3fe62e42fefa39f0ULL); FP_LOAD_IMM_Q(0x3fe62e42fefa39f0ULL);

View File

@@ -215,7 +215,8 @@ BRANCH_COND_S(int pc_offset, uint32_t op_pc, uint32_t offset, int not )
} }
#define ropBRANCH(name, func, not ) \ #define ropBRANCH(name, func, not ) \
static uint32_t rop##name(uint8_t opcode, uint32_t fetchdat, \ static uint32_t \
rop##name(uint8_t opcode, uint32_t fetchdat, \
uint32_t op_32, uint32_t op_pc, \ uint32_t op_32, uint32_t op_pc, \
codeblock_t *block) \ codeblock_t *block) \
{ \ { \
@@ -228,7 +229,8 @@ BRANCH_COND_S(int pc_offset, uint32_t op_pc, uint32_t offset, int not )
\ \
return op_pc + 1; \ return op_pc + 1; \
} \ } \
static uint32_t rop##name##_w(uint8_t opcode, \ static uint32_t \
rop##name##_w(uint8_t opcode, \
uint32_t fetchdat, uint32_t op_32, \ uint32_t fetchdat, uint32_t op_32, \
uint32_t op_pc, codeblock_t *block) \ uint32_t op_pc, codeblock_t *block) \
{ \ { \
@@ -241,7 +243,8 @@ BRANCH_COND_S(int pc_offset, uint32_t op_pc, uint32_t offset, int not )
\ \
return op_pc + 2; \ return op_pc + 2; \
} \ } \
static uint32_t rop##name##_l(uint8_t opcode, \ static uint32_t \
rop##name##_l(uint8_t opcode, \
uint32_t fetchdat, uint32_t op_32, \ uint32_t fetchdat, uint32_t op_32, \
uint32_t op_pc, codeblock_t *block) \ uint32_t op_pc, codeblock_t *block) \
{ \ { \

View File

@@ -1,7 +1,9 @@
#define ROP_LOGIC(name, op, writeback) \ #define ROP_LOGIC(name, op, writeback) \
static uint32_t rop##name##_b_rmw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \ static uint32_t \
rop##name##_b_rmw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \
{ \ { \
int src_reg, dst_reg; \ int src_reg; \
int dst_reg; \
x86seg *target_seg; \ x86seg *target_seg; \
\ \
if ((fetchdat & 0xc0) == 0xc0) { \ if ((fetchdat & 0xc0) == 0xc0) { \
@@ -30,9 +32,11 @@
\ \
return op_pc + 1; \ return op_pc + 1; \
} \ } \
static uint32_t rop##name##_w_rmw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \ static uint32_t \
rop##name##_w_rmw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \
{ \ { \
int src_reg, dst_reg; \ int src_reg; \
int dst_reg; \
x86seg *target_seg; \ x86seg *target_seg; \
\ \
if ((fetchdat & 0xc0) == 0xc0) { \ if ((fetchdat & 0xc0) == 0xc0) { \
@@ -61,9 +65,11 @@
\ \
return op_pc + 1; \ return op_pc + 1; \
} \ } \
static uint32_t rop##name##_l_rmw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \ static uint32_t \
rop##name##_l_rmw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \
{ \ { \
int src_reg, dst_reg; \ int src_reg; \
int dst_reg; \
x86seg *target_seg; \ x86seg *target_seg; \
\ \
if ((fetchdat & 0xc0) == 0xc0) { \ if ((fetchdat & 0xc0) == 0xc0) { \
@@ -92,9 +98,11 @@
\ \
return op_pc + 1; \ return op_pc + 1; \
} \ } \
static uint32_t rop##name##_b_rm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \ static uint32_t \
rop##name##_b_rm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \
{ \ { \
int src_reg, dst_reg; \ int src_reg; \
int dst_reg; \
\ \
if ((fetchdat & 0xc0) == 0xc0) { \ if ((fetchdat & 0xc0) == 0xc0) { \
src_reg = LOAD_REG_B(fetchdat & 7); \ src_reg = LOAD_REG_B(fetchdat & 7); \
@@ -117,9 +125,11 @@
\ \
return op_pc + 1; \ return op_pc + 1; \
} \ } \
static uint32_t rop##name##_w_rm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \ static uint32_t \
rop##name##_w_rm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \
{ \ { \
int src_reg, dst_reg; \ int src_reg; \
int dst_reg; \
\ \
if ((fetchdat & 0xc0) == 0xc0) { \ if ((fetchdat & 0xc0) == 0xc0) { \
src_reg = LOAD_REG_W(fetchdat & 7); \ src_reg = LOAD_REG_W(fetchdat & 7); \
@@ -142,9 +152,11 @@
\ \
return op_pc + 1; \ return op_pc + 1; \
} \ } \
static uint32_t rop##name##_l_rm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \ static uint32_t \
rop##name##_l_rm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \
{ \ { \
int src_reg, dst_reg; \ int src_reg; \
int dst_reg; \
\ \
if ((fetchdat & 0xc0) == 0xc0) { \ if ((fetchdat & 0xc0) == 0xc0) { \
src_reg = LOAD_REG_L(fetchdat & 7); \ src_reg = LOAD_REG_L(fetchdat & 7); \

View File

@@ -96,10 +96,13 @@ ropMOVD_mm_l(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc,
} }
#define MMX_OP(name, func) \ #define MMX_OP(name, func) \
static uint32_t name(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \ static uint32_t \
name(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \
{ \ { \
int src_reg1, src_reg2; \ int src_reg1; \
int xmm_src, xmm_dst; \ int src_reg2; \
int xmm_src; \
int xmm_dst; \
\ \
MMX_ENTER(); \ MMX_ENTER(); \
\ \

View File

@@ -225,7 +225,8 @@ ropLEAVE_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, c
} }
#define ROP_PUSH_SEG(seg) \ #define ROP_PUSH_SEG(seg) \
static uint32_t ropPUSH_##seg##_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \ static uint32_t \
ropPUSH_##seg##_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \
{ \ { \
int host_reg; \ int host_reg; \
\ \
@@ -237,7 +238,8 @@ ropLEAVE_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, c
\ \
return op_pc; \ return op_pc; \
} \ } \
static uint32_t ropPUSH_##seg##_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \ static uint32_t \
ropPUSH_##seg##_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \
{ \ { \
int host_reg; \ int host_reg; \
\ \
@@ -258,7 +260,8 @@ ROP_PUSH_SEG(GS)
ROP_PUSH_SEG(SS) ROP_PUSH_SEG(SS)
#define ROP_POP_SEG(seg, rseg) \ #define ROP_POP_SEG(seg, rseg) \
static uint32_t ropPOP_##seg##_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \ static uint32_t \
ropPOP_##seg##_16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \
{ \ { \
STORE_IMM_ADDR_L((uintptr_t) &cpu_state.oldpc, op_old_pc); \ STORE_IMM_ADDR_L((uintptr_t) &cpu_state.oldpc, op_old_pc); \
LOAD_STACK_TO_EA(0); \ LOAD_STACK_TO_EA(0); \
@@ -268,7 +271,8 @@ ROP_PUSH_SEG(SS)
\ \
return op_pc; \ return op_pc; \
} \ } \
static uint32_t ropPOP_##seg##_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \ static uint32_t \
ropPOP_##seg##_32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \
{ \ { \
STORE_IMM_ADDR_L((uintptr_t) &cpu_state.oldpc, op_old_pc); \ STORE_IMM_ADDR_L((uintptr_t) &cpu_state.oldpc, op_old_pc); \
LOAD_STACK_TO_EA(0); \ LOAD_STACK_TO_EA(0); \

View File

@@ -219,8 +219,9 @@ CALL_FUNC(uintptr_t func)
} }
static __inline void static __inline void
RELEASE_REG(int host_reg) RELEASE_REG(UNUSED(int host_reg))
{ {
//
} }
static __inline int static __inline int
@@ -3949,7 +3950,8 @@ FP_LOAD_REG_D(int reg, int *host_reg1, int *host_reg2)
static __inline int64_t static __inline int64_t
x87_fround16_64(double b) x87_fround16_64(double b)
{ {
int16_t a, c; int16_t a;
int16_t c;
switch ((cpu_state.npxc >> 10) & 3) { switch ((cpu_state.npxc >> 10) & 3) {
case 0: /*Nearest*/ case 0: /*Nearest*/
@@ -3974,7 +3976,8 @@ x87_fround16_64(double b)
static __inline int64_t static __inline int64_t
x87_fround32_64(double b) x87_fround32_64(double b)
{ {
int32_t a, c; int32_t a;
int32_t c;
switch ((cpu_state.npxc >> 10) & 3) { switch ((cpu_state.npxc >> 10) & 3) {
case 0: /*Nearest*/ case 0: /*Nearest*/
@@ -3999,7 +4002,8 @@ x87_fround32_64(double b)
static __inline int64_t static __inline int64_t
x87_fround(double b) x87_fround(double b)
{ {
int64_t a, c; int64_t a;
int64_t c;
switch ((cpu_state.npxc >> 10) & 3) { switch ((cpu_state.npxc >> 10) & 3) {
case 0: /*Nearest*/ case 0: /*Nearest*/
@@ -4550,8 +4554,9 @@ FP_COMPARE_IL(void)
} }
static __inline void static __inline void
UPDATE_NPXC(int reg) UPDATE_NPXC(UNUSED(int reg))
{ {
//
} }
static __inline void static __inline void
@@ -4776,7 +4781,8 @@ STORE_MMX_Q_MMX(int guest_reg, int host_reg)
} }
#define MMX_x86_OP(name, opcode) \ #define MMX_x86_OP(name, opcode) \
static __inline void MMX_##name(int dst_reg, int src_reg) \ static __inline void \
MMX_##name(int dst_reg, int src_reg) \
{ \ { \
addbyte(0x66); /*op dst_reg, src_reg*/ \ addbyte(0x66); /*op dst_reg, src_reg*/ \
addbyte(0x0f); \ addbyte(0x0f); \
@@ -5014,7 +5020,9 @@ LOAD_EA(void)
static __inline void static __inline void
MEM_CHECK_WRITE(x86seg *seg) MEM_CHECK_WRITE(x86seg *seg)
{ {
uint8_t *jump1, *jump2, *jump3 = NULL; uint8_t *jump1 = NULL;
uint8_t *jump2 = NULL;
uint8_t *jump3 = NULL;
CHECK_SEG_WRITE(seg); CHECK_SEG_WRITE(seg);
@@ -5115,7 +5123,10 @@ MEM_CHECK_WRITE(x86seg *seg)
static __inline void static __inline void
MEM_CHECK_WRITE_W(x86seg *seg) MEM_CHECK_WRITE_W(x86seg *seg)
{ {
uint8_t *jump1, *jump2, *jump3, *jump4 = NULL; uint8_t *jump1 = NULL;
uint8_t *jump2 = NULL;
uint8_t *jump3 = NULL;
uint8_t *jump4 = NULL;
int jump_pos; int jump_pos;
CHECK_SEG_WRITE(seg); CHECK_SEG_WRITE(seg);
@@ -5248,7 +5259,10 @@ MEM_CHECK_WRITE_W(x86seg *seg)
static __inline void static __inline void
MEM_CHECK_WRITE_L(x86seg *seg) MEM_CHECK_WRITE_L(x86seg *seg)
{ {
uint8_t *jump1, *jump2, *jump3, *jump4 = NULL; uint8_t *jump1 = NULL;
uint8_t *jump2 = NULL;
uint8_t *jump3 = NULL;
uint8_t *jump4 = NULL;
int jump_pos; int jump_pos;
CHECK_SEG_WRITE(seg); CHECK_SEG_WRITE(seg);

View File

@@ -3620,7 +3620,8 @@ STORE_MMX_Q_MMX(int guest_reg, int host_reg)
} }
#define MMX_x86_OP(name, opcode) \ #define MMX_x86_OP(name, opcode) \
static __inline void MMX_##name(int dst_reg, int src_reg) \ static \
__inline void MMX_##name(int dst_reg, int src_reg) \
{ \ { \
addbyte(0x66); /*op dst_reg, src_reg*/ \ addbyte(0x66); /*op dst_reg, src_reg*/ \
addbyte(0x0f); \ addbyte(0x0f); \
@@ -3628,6 +3629,7 @@ STORE_MMX_Q_MMX(int guest_reg, int host_reg)
addbyte(0xc0 | (dst_reg << 3) | src_reg); \ addbyte(0xc0 | (dst_reg << 3) | src_reg); \
} }
// clang-format off
MMX_x86_OP(AND, 0xdb) MMX_x86_OP(AND, 0xdb)
MMX_x86_OP(ANDN, 0xdf) MMX_x86_OP(ANDN, 0xdf)
MMX_x86_OP(OR, 0xeb) MMX_x86_OP(OR, 0xeb)
@@ -3672,6 +3674,7 @@ MMX_x86_OP(PSLLQ, 0xf3);
MMX_x86_OP(PMULLW, 0xd5); MMX_x86_OP(PMULLW, 0xd5);
MMX_x86_OP(PMULHW, 0xe5); MMX_x86_OP(PMULHW, 0xe5);
MMX_x86_OP(PMADDWD, 0xf5); MMX_x86_OP(PMADDWD, 0xf5);
// clang-format on
static __inline void static __inline void
MMX_PACKSSWB(int dst_reg, int src_reg) MMX_PACKSSWB(int dst_reg, int src_reg)

View File

@@ -1,5 +1,6 @@
#define OP_XCHG_AX_(reg) \ #define OP_XCHG_AX_(reg) \
static uint32_t ropXCHG_AX_##reg(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \ static uint32_t \
ropXCHG_AX_##reg(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \
{ \ { \
int ax_reg, host_reg, temp_reg; \ int ax_reg, host_reg, temp_reg; \
\ \
@@ -21,7 +22,8 @@ OP_XCHG_AX_(SP)
OP_XCHG_AX_(BP) OP_XCHG_AX_(BP)
#define OP_XCHG_EAX_(reg) \ #define OP_XCHG_EAX_(reg) \
static uint32_t ropXCHG_EAX_##reg(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \ static uint32_t \
ropXCHG_EAX_##reg(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \
{ \ { \
int eax_reg, host_reg, temp_reg; \ int eax_reg, host_reg, temp_reg; \
\ \

View File

@@ -15,6 +15,7 @@
# include "x86seg.h" # include "x86seg.h"
# include "x87.h" # include "x87.h"
# include <86box/mem.h> # include <86box/mem.h>
# include <86box/plat_unused.h>
# include "386_common.h" # include "386_common.h"
@@ -31,7 +32,8 @@
# include <windows.h> # include <windows.h>
# endif # endif
int codegen_flat_ds, codegen_flat_ss; int codegen_flat_ds;
int codegen_flat_ss;
int codegen_flags_changed = 0; int codegen_flags_changed = 0;
int codegen_fpu_entered = 0; int codegen_fpu_entered = 0;
int codegen_fpu_loaded_iq[8]; int codegen_fpu_loaded_iq[8];
@@ -65,8 +67,6 @@ static int last_ssegs;
void void
codegen_init(void) codegen_init(void)
{ {
int c;
# if _WIN64 # if _WIN64
codeblock = VirtualAlloc(NULL, BLOCK_SIZE * sizeof(codeblock_t), MEM_COMMIT, PAGE_EXECUTE_READWRITE); codeblock = VirtualAlloc(NULL, BLOCK_SIZE * sizeof(codeblock_t), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
# elif defined(__unix__) || defined(__APPLE__) || defined(__HAIKU__) # elif defined(__unix__) || defined(__APPLE__) || defined(__HAIKU__)
@@ -79,26 +79,25 @@ codegen_init(void)
memset(codeblock, 0, BLOCK_SIZE * sizeof(codeblock_t)); memset(codeblock, 0, BLOCK_SIZE * sizeof(codeblock_t));
memset(codeblock_hash, 0, HASH_SIZE * sizeof(codeblock_t *)); memset(codeblock_hash, 0, HASH_SIZE * sizeof(codeblock_t *));
for (c = 0; c < BLOCK_SIZE; c++) for (int c = 0; c < BLOCK_SIZE; c++)
codeblock[c].valid = 0; codeblock[c].valid = 0;
} }
void void
codegen_reset(void) codegen_reset(void)
{ {
int c;
memset(codeblock, 0, BLOCK_SIZE * sizeof(codeblock_t)); memset(codeblock, 0, BLOCK_SIZE * sizeof(codeblock_t));
memset(codeblock_hash, 0, HASH_SIZE * sizeof(codeblock_t *)); memset(codeblock_hash, 0, HASH_SIZE * sizeof(codeblock_t *));
mem_reset_page_blocks(); mem_reset_page_blocks();
for (c = 0; c < BLOCK_SIZE; c++) for (int c = 0; c < BLOCK_SIZE; c++)
codeblock[c].valid = 0; codeblock[c].valid = 0;
} }
void void
dump_block(void) dump_block(void)
{ {
//
} }
static void static void
@@ -536,6 +535,7 @@ int opcode_0f_modrm[256] = {
void void
codegen_debug(void) codegen_debug(void)
{ {
//
} }
static x86seg * static x86seg *

View File

@@ -1679,6 +1679,7 @@ int opcode_0f_modrm[256] = {
void void
codegen_debug(void) codegen_debug(void)
{ {
//
} }
static x86seg * static x86seg *