mirror of
https://github.com/86Box/86Box.git
synced 2026-02-22 09:35:32 -07:00
Even more sonarlint work
This commit is contained in:
@@ -31,9 +31,7 @@ static struct
|
||||
int
|
||||
codegen_get_instruction_uop(codeblock_t *block, uint32_t pc, int *first_instruction, int *TOP)
|
||||
{
|
||||
int c;
|
||||
|
||||
for (c = 0; c <= block->ins; c++) {
|
||||
for (uint8_t c = 0; c <= block->ins; c++) {
|
||||
if (codegen_instructions[c].pc == pc) {
|
||||
*first_instruction = c;
|
||||
*TOP = codegen_instructions[c].TOP;
|
||||
@@ -137,7 +135,9 @@ codegen_generate_ea_16_long(ir_data_t *ir, x86seg *op_ea_seg, uint32_t fetchdat,
|
||||
uop_MOV_IMM(ir, IREG_eaaddr, addr);
|
||||
(*op_pc) += 2;
|
||||
} else {
|
||||
int base_reg, index_reg, offset;
|
||||
int base_reg;
|
||||
int index_reg;
|
||||
int offset;
|
||||
|
||||
switch (cpu_rm & 7) {
|
||||
case 0:
|
||||
|
||||
@@ -212,7 +212,8 @@ codeblock_tree_delete(codeblock_t *block)
|
||||
return;
|
||||
} else {
|
||||
/*Difficult case - node has two children. Walk right child to find lowest node*/
|
||||
codeblock_t *lowest = &codeblock[block->right], *highest;
|
||||
codeblock_t *lowest = &codeblock[block->right];
|
||||
codeblock_t *highest;
|
||||
codeblock_t *old_parent;
|
||||
uint16_t lowest_nr;
|
||||
|
||||
|
||||
@@ -32,8 +32,6 @@ int codegen_allocator_usage = 0;
|
||||
void
|
||||
codegen_allocator_init(void)
|
||||
{
|
||||
int c;
|
||||
|
||||
#if defined WIN32 || defined _WIN32 || defined _WIN32
|
||||
mem_block_alloc = VirtualAlloc(NULL, MEM_BLOCK_NR * MEM_BLOCK_SIZE, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
||||
/* TODO: check deployment target: older Intel-based versions of macOS don't play
|
||||
@@ -44,7 +42,7 @@ codegen_allocator_init(void)
|
||||
mem_block_alloc = mmap(0, MEM_BLOCK_NR * MEM_BLOCK_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE, -1, 0);
|
||||
#endif
|
||||
|
||||
for (c = 0; c < MEM_BLOCK_NR; c++) {
|
||||
for (uint32_t c = 0; c < MEM_BLOCK_NR; c++) {
|
||||
mem_blocks[c].offset = c * MEM_BLOCK_SIZE;
|
||||
mem_blocks[c].code_block = BLOCK_INVALID;
|
||||
if (c < MEM_BLOCK_NR - 1)
|
||||
|
||||
@@ -1313,7 +1313,8 @@ static uint32_t imm_table[][2] = {
|
||||
uint32_t
|
||||
host_arm64_find_imm(uint32_t data)
|
||||
{
|
||||
int l = 0, r = IMM_NR - 1;
|
||||
int l = 0;
|
||||
int r = IMM_NR - 1;
|
||||
|
||||
while (l <= r) {
|
||||
int m = (l + r) >> 1;
|
||||
|
||||
@@ -263,7 +263,6 @@ void
|
||||
codegen_backend_init(void)
|
||||
{
|
||||
codeblock_t *block;
|
||||
int c;
|
||||
|
||||
codeblock = malloc(BLOCK_SIZE * sizeof(codeblock_t));
|
||||
codeblock_hash = malloc(HASH_SIZE * sizeof(codeblock_t *));
|
||||
@@ -271,7 +270,7 @@ codegen_backend_init(void)
|
||||
memset(codeblock, 0, BLOCK_SIZE * sizeof(codeblock_t));
|
||||
memset(codeblock_hash, 0, HASH_SIZE * sizeof(codeblock_t *));
|
||||
|
||||
for (c = 0; c < BLOCK_SIZE; c++)
|
||||
for (uint32_t c = 0; c < BLOCK_SIZE; c++)
|
||||
codeblock[c].pc = BLOCK_PC_INVALID;
|
||||
|
||||
block_current = 0;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -21,7 +21,8 @@
|
||||
|
||||
uint8_t *block_write_data = NULL;
|
||||
|
||||
int codegen_flat_ds, codegen_flat_ss;
|
||||
int codegen_flat_ds;
|
||||
int codegen_flat_ss;
|
||||
int mmx_ebx_ecx_loaded;
|
||||
int codegen_flags_changed = 0;
|
||||
int codegen_fpu_entered = 0;
|
||||
@@ -61,7 +62,8 @@ static void delete_dirty_block(codeblock_t *block);
|
||||
|
||||
The size of this list is limited to DIRTY_LIST_MAX_SIZE blocks. When this is
|
||||
exceeded the oldest entry will be moved to the free list.*/
|
||||
static uint16_t block_dirty_list_head, block_dirty_list_tail;
|
||||
static uint16_t block_dirty_list_head;
|
||||
static uint16_t block_dirty_list_tail;
|
||||
static int dirty_list_size = 0;
|
||||
#define DIRTY_LIST_MAX_SIZE 64
|
||||
|
||||
@@ -210,13 +212,11 @@ block_free_list_get(void)
|
||||
void
|
||||
codegen_init(void)
|
||||
{
|
||||
int c;
|
||||
|
||||
codegen_allocator_init();
|
||||
|
||||
codegen_backend_init();
|
||||
block_free_list = 0;
|
||||
for (c = 0; c < BLOCK_SIZE; c++)
|
||||
for (uint32_t c = 0; c < BLOCK_SIZE; c++)
|
||||
block_free_list_add(&codeblock[c]);
|
||||
block_dirty_list_head = block_dirty_list_tail = 0;
|
||||
dirty_list_size = 0;
|
||||
@@ -472,7 +472,6 @@ codegen_check_flush(page_t *page, uint64_t mask, uint32_t phys_addr)
|
||||
{
|
||||
uint16_t block_nr = page->block;
|
||||
int remove_from_evict_list = 0;
|
||||
int c;
|
||||
|
||||
while (block_nr) {
|
||||
codeblock_t *block = &codeblock[block_nr];
|
||||
@@ -509,7 +508,7 @@ codegen_check_flush(page_t *page, uint64_t mask, uint32_t phys_addr)
|
||||
page->code_present_mask &= ~page->dirty_mask;
|
||||
page->dirty_mask = 0;
|
||||
|
||||
for (c = 0; c < 64; c++) {
|
||||
for (uint8_t c = 0; c < 64; c++) {
|
||||
if (page->byte_code_present_mask[c] & page->byte_dirty_mask[c])
|
||||
remove_from_evict_list = 0;
|
||||
page->byte_code_present_mask[c] &= ~page->byte_dirty_mask[c];
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
extern int has_ea;
|
||||
static ir_data_t ir_block;
|
||||
|
||||
static int codegen_unroll_start, codegen_unroll_count;
|
||||
static int codegen_unroll_start;
|
||||
static int codegen_unroll_count;
|
||||
static int codegen_unroll_first_instruction;
|
||||
|
||||
ir_data_t *
|
||||
@@ -64,13 +65,12 @@ codegen_ir_compile(ir_data_t *ir, codeblock_t *block)
|
||||
int c;
|
||||
|
||||
if (codegen_unroll_count) {
|
||||
int unroll_count;
|
||||
int unroll_end;
|
||||
|
||||
codegen_set_loop_start(ir, codegen_unroll_first_instruction);
|
||||
unroll_end = ir->wr_pos;
|
||||
|
||||
for (unroll_count = 1; unroll_count < codegen_unroll_count; unroll_count++) {
|
||||
for (int unroll_count = 1; unroll_count < codegen_unroll_count; unroll_count++) {
|
||||
int offset = ir->wr_pos - codegen_unroll_start;
|
||||
// pclog("Unroll from %i to %i, offset %i - iteration %i\n", codegen_unroll_start, ir->wr_pos, offset, unroll_count);
|
||||
for (c = codegen_unroll_start; c < unroll_end; c++) {
|
||||
|
||||
@@ -264,7 +264,8 @@ ropJNE_common(codeblock_t *block, ir_data_t *ir, uint32_t dest_addr, uint32_t ne
|
||||
static int
|
||||
ropJBE_common(codeblock_t *block, ir_data_t *ir, uint32_t dest_addr, uint32_t next_pc)
|
||||
{
|
||||
int jump_uop, jump_uop2 = -1;
|
||||
int jump_uop;
|
||||
int jump_uop2 = -1;
|
||||
int do_unroll = ((CF_SET() || ZF_SET()) && codegen_can_unroll(block, ir, next_pc, dest_addr));
|
||||
|
||||
switch (codegen_flags_changed ? cpu_state.flags_op : FLAGS_UNKNOWN) {
|
||||
@@ -331,7 +332,8 @@ ropJBE_common(codeblock_t *block, ir_data_t *ir, uint32_t dest_addr, uint32_t ne
|
||||
static int
|
||||
ropJNBE_common(codeblock_t *block, ir_data_t *ir, uint32_t dest_addr, uint32_t next_pc)
|
||||
{
|
||||
int jump_uop, jump_uop2 = -1;
|
||||
int jump_uop;
|
||||
int jump_uop2 = -1;
|
||||
int do_unroll = ((!CF_SET() && !ZF_SET()) && codegen_can_unroll(block, ir, next_pc, dest_addr));
|
||||
|
||||
switch (codegen_flags_changed ? cpu_state.flags_op : FLAGS_UNKNOWN) {
|
||||
@@ -686,7 +688,8 @@ ropJNL_common(codeblock_t *block, ir_data_t *ir, uint32_t dest_addr, uint32_t ne
|
||||
static int
|
||||
ropJLE_common(codeblock_t *block, ir_data_t *ir, uint32_t dest_addr, uint32_t next_pc)
|
||||
{
|
||||
int jump_uop, jump_uop2 = -1;
|
||||
int jump_uop;
|
||||
int jump_uop2 = -1;
|
||||
int do_unroll = (((NF_SET() ? 1 : 0) != (VF_SET() ? 1 : 0) || ZF_SET()) && codegen_can_unroll(block, ir, next_pc, dest_addr));
|
||||
|
||||
switch (codegen_flags_changed ? cpu_state.flags_op : FLAGS_UNKNOWN) {
|
||||
@@ -748,7 +751,8 @@ ropJLE_common(codeblock_t *block, ir_data_t *ir, uint32_t dest_addr, uint32_t ne
|
||||
static int
|
||||
ropJNLE_common(codeblock_t *block, ir_data_t *ir, uint32_t dest_addr, uint32_t next_pc)
|
||||
{
|
||||
int jump_uop, jump_uop2 = -1;
|
||||
int jump_uop;
|
||||
int jump_uop2 = -1;
|
||||
int do_unroll = ((NF_SET() ? 1 : 0) == (VF_SET() ? 1 : 0) && !ZF_SET() && codegen_can_unroll(block, ir, next_pc, dest_addr));
|
||||
|
||||
switch (codegen_flags_changed ? cpu_state.flags_op : FLAGS_UNKNOWN) {
|
||||
@@ -928,7 +932,8 @@ ropLOOPE(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, u
|
||||
{
|
||||
uint32_t offset = (int32_t) (int8_t) fastreadb(cs + op_pc);
|
||||
uint32_t dest_addr = op_pc + 1 + offset;
|
||||
int jump_uop, jump_uop2;
|
||||
int jump_uop;
|
||||
int jump_uop2;
|
||||
|
||||
if (!(op_32 & 0x100))
|
||||
dest_addr &= 0xffff;
|
||||
@@ -960,7 +965,8 @@ ropLOOPNE(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat,
|
||||
{
|
||||
uint32_t offset = (int32_t) (int8_t) fastreadb(cs + op_pc);
|
||||
uint32_t dest_addr = op_pc + 1 + offset;
|
||||
int jump_uop, jump_uop2;
|
||||
int jump_uop;
|
||||
int jump_uop2;
|
||||
|
||||
if (!(op_32 & 0x100))
|
||||
dest_addr &= 0xffff;
|
||||
|
||||
@@ -269,7 +269,8 @@ uint32_t
|
||||
ropFF_16(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc)
|
||||
{
|
||||
x86seg *target_seg = NULL;
|
||||
int src_reg, sp_reg;
|
||||
int src_reg;
|
||||
int sp_reg;
|
||||
|
||||
if ((fetchdat & 0x38) != 0x00 && (fetchdat & 0x38) != 0x08 && (fetchdat & 0x38) != 0x10 && (fetchdat & 0x38) != 0x20 && (fetchdat & 0x38) != 0x28 && (fetchdat & 0x38) != 0x30)
|
||||
return 0;
|
||||
@@ -367,7 +368,8 @@ uint32_t
|
||||
ropFF_32(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc)
|
||||
{
|
||||
x86seg *target_seg = NULL;
|
||||
int src_reg, sp_reg;
|
||||
int src_reg;
|
||||
int sp_reg;
|
||||
|
||||
if ((fetchdat & 0x38) != 0x00 && (fetchdat & 0x38) != 0x08 && (fetchdat & 0x38) != 0x10 && (fetchdat & 0x38) != 0x20 && (fetchdat & 0x38) != 0x28 && (fetchdat & 0x38) != 0x30)
|
||||
return 0;
|
||||
|
||||
@@ -30,7 +30,8 @@ typedef struct host_reg_set_t {
|
||||
int nr_regs;
|
||||
} host_reg_set_t;
|
||||
|
||||
static host_reg_set_t host_reg_set, host_fp_reg_set;
|
||||
static host_reg_set_t host_reg_set;
|
||||
static host_reg_set_t host_fp_reg_set;
|
||||
|
||||
enum {
|
||||
REG_BYTE,
|
||||
@@ -182,9 +183,7 @@ struct
|
||||
void
|
||||
codegen_reg_mark_as_required(void)
|
||||
{
|
||||
int reg;
|
||||
|
||||
for (reg = 0; reg < IREG_COUNT; reg++) {
|
||||
for (uint8_t reg = 0; reg < IREG_COUNT; reg++) {
|
||||
int last_version = reg_last_version[reg];
|
||||
|
||||
if (last_version > 0 && ireg_data[reg].is_volatile == REG_PERMANENT)
|
||||
@@ -533,9 +532,8 @@ alloc_reg(ir_reg_t ir_reg)
|
||||
{
|
||||
host_reg_set_t *reg_set = get_reg_set(ir_reg);
|
||||
int nr_regs = (reg_set == &host_reg_set) ? CODEGEN_HOST_REGS : CODEGEN_HOST_FP_REGS;
|
||||
int c;
|
||||
|
||||
for (c = 0; c < nr_regs; c++) {
|
||||
for (int c = 0; c < nr_regs; c++) {
|
||||
if (IREG_GET_REG(reg_set->regs[c].reg) == IREG_GET_REG(ir_reg.reg)) {
|
||||
#ifndef RELEASE_BUILD
|
||||
if (reg_set->regs[c].version != ir_reg.version)
|
||||
@@ -552,9 +550,8 @@ alloc_dest_reg(ir_reg_t ir_reg, int dest_reference)
|
||||
{
|
||||
host_reg_set_t *reg_set = get_reg_set(ir_reg);
|
||||
int nr_regs = (reg_set == &host_reg_set) ? CODEGEN_HOST_REGS : CODEGEN_HOST_FP_REGS;
|
||||
int c;
|
||||
|
||||
for (c = 0; c < nr_regs; c++) {
|
||||
for (int c = 0; c < nr_regs; c++) {
|
||||
if (IREG_GET_REG(reg_set->regs[c].reg) == IREG_GET_REG(ir_reg.reg)) {
|
||||
if (reg_set->regs[c].version == ir_reg.version) {
|
||||
reg_set->locked |= (1 << c);
|
||||
@@ -737,10 +734,9 @@ int
|
||||
codegen_reg_is_loaded(ir_reg_t ir_reg)
|
||||
{
|
||||
host_reg_set_t *reg_set = get_reg_set(ir_reg);
|
||||
int c;
|
||||
|
||||
/*Search for previous version in host register*/
|
||||
for (c = 0; c < reg_set->nr_regs; c++) {
|
||||
for (int c = 0; c < reg_set->nr_regs; c++) {
|
||||
if (!ir_reg_is_invalid(reg_set->regs[c]) && IREG_GET_REG(reg_set->regs[c].reg) == IREG_GET_REG(ir_reg.reg)) {
|
||||
if (reg_set->regs[c].version <= ir_reg.version - 1) {
|
||||
# ifndef RELEASE_BUILD
|
||||
|
||||
Reference in New Issue
Block a user