more clang-formatting in codegen & codegen_new

This commit is contained in:
Jasmine Iwanek
2022-11-19 11:23:33 -05:00
parent d802ec3485
commit dd339ec191
3 changed files with 272 additions and 297 deletions

View File

@@ -32,8 +32,7 @@
#include "codegen_ops_stack.h" #include "codegen_ops_stack.h"
#include "codegen_ops_xchg.h" #include "codegen_ops_xchg.h"
RecompOpFn recomp_opcodes[512] = RecompOpFn recomp_opcodes[512] = {
{
// clang-format off // clang-format off
/*16-bit data*/ /*16-bit data*/
/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/
@@ -81,8 +80,7 @@ RecompOpFn recomp_opcodes[512] =
// clang-format on // clang-format on
}; };
RecompOpFn recomp_opcodes_0f[512] = RecompOpFn recomp_opcodes_0f[512] = {
{
// clang-format off // clang-format off
/*16-bit data*/ /*16-bit data*/
/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/
@@ -130,9 +128,7 @@ RecompOpFn recomp_opcodes_0f[512] =
// clang-format on // clang-format on
}; };
RecompOpFn recomp_opcodes_d8[512] = {
RecompOpFn recomp_opcodes_d8[512] =
{
// clang-format off // clang-format off
/*16-bit data*/ /*16-bit data*/
/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/
@@ -180,8 +176,7 @@ RecompOpFn recomp_opcodes_d8[512] =
// clang-format on // clang-format on
}; };
RecompOpFn recomp_opcodes_d9[512] = RecompOpFn recomp_opcodes_d9[512] = {
{
// clang-format off // clang-format off
/*16-bit data*/ /*16-bit data*/
/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/
@@ -229,8 +224,7 @@ RecompOpFn recomp_opcodes_d9[512] =
// clang-format on // clang-format on
}; };
RecompOpFn recomp_opcodes_da[512] = RecompOpFn recomp_opcodes_da[512] = {
{
// clang-format off // clang-format off
/*16-bit data*/ /*16-bit data*/
/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/
@@ -278,8 +272,7 @@ RecompOpFn recomp_opcodes_da[512] =
// clang-format on // clang-format on
}; };
RecompOpFn recomp_opcodes_db[512] = RecompOpFn recomp_opcodes_db[512] = {
{
// clang-format off // clang-format off
/*16-bit data*/ /*16-bit data*/
/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/
@@ -327,8 +320,7 @@ RecompOpFn recomp_opcodes_db[512] =
// clang-format on // clang-format on
}; };
RecompOpFn recomp_opcodes_dc[512] = RecompOpFn recomp_opcodes_dc[512] = {
{
// clang-format off // clang-format off
/*16-bit data*/ /*16-bit data*/
/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/
@@ -376,8 +368,7 @@ RecompOpFn recomp_opcodes_dc[512] =
// clang-format on // clang-format on
}; };
RecompOpFn recomp_opcodes_dd[512] = RecompOpFn recomp_opcodes_dd[512] = {
{
// clang-format off // clang-format off
/*16-bit data*/ /*16-bit data*/
/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/
@@ -425,8 +416,7 @@ RecompOpFn recomp_opcodes_dd[512] =
// clang-format on // clang-format on
}; };
RecompOpFn recomp_opcodes_de[512] = RecompOpFn recomp_opcodes_de[512] = {
{
// clang-format off // clang-format off
/*16-bit data*/ /*16-bit data*/
/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/
@@ -474,8 +464,7 @@ RecompOpFn recomp_opcodes_de[512] =
// clang-format on // clang-format on
}; };
RecompOpFn recomp_opcodes_df[512] = RecompOpFn recomp_opcodes_df[512] = {
{
// clang-format off // clang-format off
/*16-bit data*/ /*16-bit data*/
/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/
@@ -523,8 +512,7 @@ RecompOpFn recomp_opcodes_df[512] =
// clang-format on // clang-format on
}; };
RecompOpFn recomp_opcodes_REPE[512] = RecompOpFn recomp_opcodes_REPE[512] = {
{
// clang-format off // clang-format off
/*16-bit data*/ /*16-bit data*/
/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/
@@ -572,8 +560,7 @@ RecompOpFn recomp_opcodes_REPE[512] =
// clang-format on // clang-format on
}; };
RecompOpFn recomp_opcodes_REPNE[512] = RecompOpFn recomp_opcodes_REPNE[512] = {
{
// clang-format off // clang-format off
/*16-bit data*/ /*16-bit data*/
/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/

View File

@@ -1,4 +1,5 @@
static uint32_t ropJMP_r8(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) static uint32_t
ropJMP_r8(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
{ {
uint32_t offset = fetchdat & 0xff; uint32_t offset = fetchdat & 0xff;
@@ -10,7 +11,8 @@ static uint32_t ropJMP_r8(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin
return -1; return -1;
} }
static uint32_t ropJMP_r16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) static uint32_t
ropJMP_r16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
{ {
uint16_t offset = fetchdat & 0xffff; uint16_t offset = fetchdat & 0xffff;
@@ -19,7 +21,8 @@ static uint32_t ropJMP_r16(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, ui
return -1; return -1;
} }
static uint32_t ropJMP_r32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) static uint32_t
ropJMP_r32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
{ {
uint32_t offset = fastreadl(cs + op_pc); uint32_t offset = fastreadl(cs + op_pc);
@@ -28,21 +31,18 @@ static uint32_t ropJMP_r32(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, ui
return -1; return -1;
} }
static uint32_t
static uint32_t ropJCXZ(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) ropJCXZ(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
{ {
uint32_t offset = fetchdat & 0xff; uint32_t offset = fetchdat & 0xff;
if (offset & 0x80) if (offset & 0x80)
offset |= 0xffffff00; offset |= 0xffffff00;
if (op_32 & 0x200) if (op_32 & 0x200) {
{
int host_reg = LOAD_REG_L(REG_ECX); int host_reg = LOAD_REG_L(REG_ECX);
TEST_ZERO_JUMP_L(host_reg, op_pc + 1 + offset, 0); TEST_ZERO_JUMP_L(host_reg, op_pc + 1 + offset, 0);
} } else {
else
{
int host_reg = LOAD_REG_W(REG_CX); int host_reg = LOAD_REG_W(REG_CX);
TEST_ZERO_JUMP_W(host_reg, op_pc + 1 + offset, 0); TEST_ZERO_JUMP_W(host_reg, op_pc + 1 + offset, 0);
} }
@@ -50,22 +50,20 @@ static uint32_t ropJCXZ(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3
return op_pc + 1; return op_pc + 1;
} }
static uint32_t ropLOOP(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) static uint32_t
ropLOOP(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
{ {
uint32_t offset = fetchdat & 0xff; uint32_t offset = fetchdat & 0xff;
if (offset & 0x80) if (offset & 0x80)
offset |= 0xffffff00; offset |= 0xffffff00;
if (op_32 & 0x200) if (op_32 & 0x200) {
{
int host_reg = LOAD_REG_L(REG_ECX); int host_reg = LOAD_REG_L(REG_ECX);
SUB_HOST_REG_IMM(host_reg, 1); SUB_HOST_REG_IMM(host_reg, 1);
STORE_REG_L_RELEASE(host_reg); STORE_REG_L_RELEASE(host_reg);
TEST_NONZERO_JUMP_L(host_reg, op_pc + 1 + offset, 0); TEST_NONZERO_JUMP_L(host_reg, op_pc + 1 + offset, 0);
} } else {
else
{
int host_reg = LOAD_REG_W(REG_CX); int host_reg = LOAD_REG_W(REG_CX);
SUB_HOST_REG_IMM(host_reg, 1); SUB_HOST_REG_IMM(host_reg, 1);
STORE_REG_W_RELEASE(host_reg); STORE_REG_W_RELEASE(host_reg);
@@ -75,7 +73,8 @@ static uint32_t ropLOOP(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3
return op_pc + 1; return op_pc + 1;
} }
static void BRANCH_COND_B(int pc_offset, uint32_t op_pc, uint32_t offset, int not) static void
BRANCH_COND_B(int pc_offset, uint32_t op_pc, uint32_t offset, int not )
{ {
CALL_FUNC((uintptr_t) CF_SET); CALL_FUNC((uintptr_t) CF_SET);
if (not ) if (not )
@@ -84,12 +83,12 @@ static void BRANCH_COND_B(int pc_offset, uint32_t op_pc, uint32_t offset, int no
TEST_NONZERO_JUMP_L(0, op_pc + pc_offset + offset, timing_bt); TEST_NONZERO_JUMP_L(0, op_pc + pc_offset + offset, timing_bt);
} }
static void BRANCH_COND_E(int pc_offset, uint32_t op_pc, uint32_t offset, int not) static void
BRANCH_COND_E(int pc_offset, uint32_t op_pc, uint32_t offset, int not )
{ {
int host_reg; int host_reg;
switch (codegen_flags_changed ? cpu_state.flags_op : FLAGS_UNKNOWN) switch (codegen_flags_changed ? cpu_state.flags_op : FLAGS_UNKNOWN) {
{
case FLAGS_ZN8: case FLAGS_ZN8:
case FLAGS_ZN16: case FLAGS_ZN16:
case FLAGS_ZN32: case FLAGS_ZN32:
@@ -131,7 +130,8 @@ static void BRANCH_COND_E(int pc_offset, uint32_t op_pc, uint32_t offset, int no
} }
} }
static void BRANCH_COND_O(int pc_offset, uint32_t op_pc, uint32_t offset, int not) static void
BRANCH_COND_O(int pc_offset, uint32_t op_pc, uint32_t offset, int not )
{ {
CALL_FUNC((uintptr_t) VF_SET); CALL_FUNC((uintptr_t) VF_SET);
if (not ) if (not )
@@ -140,7 +140,8 @@ static void BRANCH_COND_O(int pc_offset, uint32_t op_pc, uint32_t offset, int no
TEST_NONZERO_JUMP_L(0, op_pc + pc_offset + offset, timing_bt); TEST_NONZERO_JUMP_L(0, op_pc + pc_offset + offset, timing_bt);
} }
static void BRANCH_COND_P(int pc_offset, uint32_t op_pc, uint32_t offset, int not) static void
BRANCH_COND_P(int pc_offset, uint32_t op_pc, uint32_t offset, int not )
{ {
CALL_FUNC((uintptr_t) PF_SET); CALL_FUNC((uintptr_t) PF_SET);
if (not ) if (not )
@@ -149,12 +150,12 @@ static void BRANCH_COND_P(int pc_offset, uint32_t op_pc, uint32_t offset, int no
TEST_NONZERO_JUMP_L(0, op_pc + pc_offset + offset, timing_bt); TEST_NONZERO_JUMP_L(0, op_pc + pc_offset + offset, timing_bt);
} }
static void BRANCH_COND_S(int pc_offset, uint32_t op_pc, uint32_t offset, int not) static void
BRANCH_COND_S(int pc_offset, uint32_t op_pc, uint32_t offset, int not )
{ {
int host_reg; int host_reg;
switch (codegen_flags_changed ? cpu_state.flags_op : FLAGS_UNKNOWN) switch (codegen_flags_changed ? cpu_state.flags_op : FLAGS_UNKNOWN) {
{
case FLAGS_ZN8: case FLAGS_ZN8:
case FLAGS_ADD8: case FLAGS_ADD8:
case FLAGS_SUB8: case FLAGS_SUB8:
@@ -213,7 +214,6 @@ static void BRANCH_COND_S(int pc_offset, uint32_t op_pc, uint32_t offset, int no
} }
} }
#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, \

View File

@@ -26,8 +26,7 @@
#include "codegen_ops_shift.h" #include "codegen_ops_shift.h"
#include "codegen_ops_stack.h" #include "codegen_ops_stack.h"
RecompOpFn recomp_opcodes[512] = RecompOpFn recomp_opcodes[512] = {
{
// clang-format off // clang-format off
/*16-bit data*/ /*16-bit data*/
/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/
@@ -75,9 +74,7 @@ RecompOpFn recomp_opcodes[512] =
// clang-format on // clang-format on
}; };
RecompOpFn recomp_opcodes_0f[512] = {
RecompOpFn recomp_opcodes_0f[512] =
{
// clang-format off // clang-format off
/*16-bit data*/ /*16-bit data*/
/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/
@@ -147,8 +144,7 @@ RecompOpFn recomp_opcodes_0f[512] =
// clang-format on // clang-format on
}; };
RecompOpFn recomp_opcodes_3DNOW[256] = RecompOpFn recomp_opcodes_3DNOW[256] = {
{
// clang-format off // clang-format off
#if defined __ARM_EABI__ || defined _ARM_ || defined _M_ARM || defined __aarch64__ || defined _M_ARM64 #if defined __ARM_EABI__ || defined _ARM_ || defined _M_ARM || defined __aarch64__ || defined _M_ARM64
0 0
@@ -177,8 +173,7 @@ RecompOpFn recomp_opcodes_3DNOW[256] =
// clang-format on // clang-format on
}; };
RecompOpFn recomp_opcodes_d8[512] = RecompOpFn recomp_opcodes_d8[512] = {
{
// clang-format off // clang-format off
/*16-bit data*/ /*16-bit data*/
/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/
@@ -226,8 +221,7 @@ RecompOpFn recomp_opcodes_d8[512] =
// clang-format on // clang-format on
}; };
RecompOpFn recomp_opcodes_d9[512] = RecompOpFn recomp_opcodes_d9[512] = {
{
// clang-format off // clang-format off
/*16-bit data*/ /*16-bit data*/
/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/
@@ -275,8 +269,7 @@ RecompOpFn recomp_opcodes_d9[512] =
// clang-format on // clang-format on
}; };
RecompOpFn recomp_opcodes_da[512] = RecompOpFn recomp_opcodes_da[512] = {
{
// clang-format off // clang-format off
/*16-bit data*/ /*16-bit data*/
/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/
@@ -324,8 +317,7 @@ RecompOpFn recomp_opcodes_da[512] =
// clang-format on // clang-format on
}; };
RecompOpFn recomp_opcodes_db[512] = RecompOpFn recomp_opcodes_db[512] = {
{
// clang-format off // clang-format off
/*16-bit data*/ /*16-bit data*/
/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/
@@ -373,8 +365,7 @@ RecompOpFn recomp_opcodes_db[512] =
// clang-format on // clang-format on
}; };
RecompOpFn recomp_opcodes_dc[512] = RecompOpFn recomp_opcodes_dc[512] = {
{
// clang-format off // clang-format off
/*16-bit data*/ /*16-bit data*/
/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/
@@ -422,8 +413,7 @@ RecompOpFn recomp_opcodes_dc[512] =
// clang-format on // clang-format on
}; };
RecompOpFn recomp_opcodes_dd[512] = RecompOpFn recomp_opcodes_dd[512] = {
{
// clang-format off // clang-format off
/*16-bit data*/ /*16-bit data*/
/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/
@@ -471,8 +461,7 @@ RecompOpFn recomp_opcodes_dd[512] =
// clang-format on // clang-format on
}; };
RecompOpFn recomp_opcodes_de[512] = RecompOpFn recomp_opcodes_de[512] = {
{
// clang-format off // clang-format off
/*16-bit data*/ /*16-bit data*/
/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/
@@ -520,8 +509,7 @@ RecompOpFn recomp_opcodes_de[512] =
// clang-format on // clang-format on
}; };
RecompOpFn recomp_opcodes_df[512] = RecompOpFn recomp_opcodes_df[512] = {
{
// clang-format off // clang-format off
/*16-bit data*/ /*16-bit data*/
/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/ /* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/