Disable a lot of dynarec sanity checks in release builds.
This commit is contained in:
parent
25fe224ea9
commit
6a09e9636c
4 changed files with 111 additions and 17 deletions
|
|
@ -69,8 +69,10 @@ static int dirty_list_size = 0;
|
|||
|
||||
static void block_free_list_add(codeblock_t *block)
|
||||
{
|
||||
#ifndef RELEASE_BUILD
|
||||
if (block->flags & CODEBLOCK_IN_DIRTY_LIST)
|
||||
fatal("block_free_list_add: block=%p in dirty list\n", block);
|
||||
#endif
|
||||
if (block_free_list)
|
||||
block->next = block_free_list;
|
||||
else
|
||||
|
|
@ -82,8 +84,10 @@ static void block_free_list_add(codeblock_t *block)
|
|||
|
||||
static void block_dirty_list_add(codeblock_t *block)
|
||||
{
|
||||
#ifndef RELEASE_BUILD
|
||||
if (block->flags & CODEBLOCK_IN_DIRTY_LIST)
|
||||
fatal("block_dirty_list_add: block=%p already in dirty list\n", block);
|
||||
#endif
|
||||
// pclog("block_dirty_list_add: block=%i size=%i %i head=%i tail=%i\n", get_block_nr(block), dirty_list_size, dirty_list_check_size(), block_dirty_list_head, block_dirty_list_tail);
|
||||
if (block_dirty_list_head != BLOCK_INVALID)
|
||||
{
|
||||
|
|
@ -108,12 +112,14 @@ static void block_dirty_list_add(codeblock_t *block)
|
|||
/*Evict oldest block to the free list*/
|
||||
codeblock_t *evict_block = &codeblock[block_dirty_list_tail];
|
||||
|
||||
#ifndef RELEASE_BUILD
|
||||
if (!(evict_block->flags & CODEBLOCK_IN_DIRTY_LIST))
|
||||
fatal("block_dirty_list_add: evict_block=%p %x %x not in dirty list\n", evict_block, evict_block->phys, evict_block->flags);
|
||||
if (!block_dirty_list_tail)
|
||||
fatal("block_dirty_list_add - !block_dirty_list_tail\n");
|
||||
if (evict_block->prev == BLOCK_INVALID)
|
||||
fatal("block_dirty_list_add - evict_block->prev == BLOCK_INVALID\n");
|
||||
#endif
|
||||
|
||||
block_dirty_list_tail = evict_block->prev;
|
||||
codeblock[evict_block->prev].next = BLOCK_INVALID;
|
||||
|
|
@ -132,8 +138,10 @@ static void block_dirty_list_remove(codeblock_t *block)
|
|||
codeblock_t *prev_block = &codeblock[block->prev];
|
||||
codeblock_t *next_block = &codeblock[block->next];
|
||||
|
||||
#ifndef RELEASE_BUILD
|
||||
if (!(block->flags & CODEBLOCK_IN_DIRTY_LIST))
|
||||
fatal("block_dirty_list_remove: block=%p not in dirty list\n", block);
|
||||
#endif
|
||||
|
||||
/*Is block head of list*/
|
||||
if (block->prev == BLOCK_INVALID)
|
||||
|
|
@ -148,8 +156,10 @@ static void block_dirty_list_remove(codeblock_t *block)
|
|||
next_block->prev = block->prev;
|
||||
|
||||
dirty_list_size--;
|
||||
#ifndef RELEASE_BUILD
|
||||
if (dirty_list_size < 0)
|
||||
fatal("remove - dirty_list_size < 0!\n");
|
||||
#endif
|
||||
block->flags &= ~CODEBLOCK_IN_DIRTY_LIST;
|
||||
// pclog(" block_dirty_list_remove: %p flags = %x\n", block, block->flags);
|
||||
}
|
||||
|
|
@ -180,9 +190,10 @@ static codeblock_t *block_free_list_get()
|
|||
/*Free list is empty, check the dirty list*/
|
||||
if (block_dirty_list_tail)
|
||||
{
|
||||
#ifndef RELEASE_BUILD
|
||||
if (dirty_list_size <= 0)
|
||||
fatal("get - dirty_list_size <= 0!\n");
|
||||
|
||||
#endif
|
||||
/*Reuse oldest block*/
|
||||
block = &codeblock[block_dirty_list_tail];
|
||||
|
||||
|
|
@ -310,9 +321,10 @@ static void add_to_block_list(codeblock_t *block)
|
|||
uint16_t block_nr = get_block_nr(block);
|
||||
//pclog("Add to block list %p %08x %llx %x\n", block, block->phys, block->page_mask2, block->flags);
|
||||
|
||||
#ifndef RELEASE_BUILD
|
||||
if (!block->page_mask)
|
||||
fatal("add_to_block_list - mask = 0 %llx %llx\n", block->page_mask,block->page_mask2);
|
||||
|
||||
#endif
|
||||
if (block_prev_nr)
|
||||
{
|
||||
block->next = block_prev_nr;
|
||||
|
|
@ -327,8 +339,10 @@ static void add_to_block_list(codeblock_t *block)
|
|||
|
||||
if (block->next)
|
||||
{
|
||||
#ifndef RELEASE_BUILD
|
||||
if (codeblock[block->next].pc == BLOCK_PC_INVALID)
|
||||
fatal("block->next->pc=BLOCK_PC_INVALID %p %p %x %x\n", (void *)&codeblock[block->next], (void *)codeblock, block_current, block_pos);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (block->page_mask2)
|
||||
|
|
@ -356,9 +370,10 @@ static void remove_from_block_list(codeblock_t *block, uint32_t pc)
|
|||
{
|
||||
if (!block->page_mask)
|
||||
return;
|
||||
#ifndef RELEASE_BUILD
|
||||
if (block->flags & CODEBLOCK_IN_DIRTY_LIST)
|
||||
fatal("remove_from_block_list: in dirty list\n");
|
||||
|
||||
#endif
|
||||
if (block->prev)
|
||||
{
|
||||
codeblock[block->prev].next = block->next;
|
||||
|
|
@ -376,8 +391,10 @@ static void remove_from_block_list(codeblock_t *block, uint32_t pc)
|
|||
|
||||
if (!(block->flags & CODEBLOCK_HAS_PAGE2))
|
||||
{
|
||||
#ifndef RELEASE_BUILD
|
||||
if (block->prev_2 || block->next_2)
|
||||
fatal("Invalid block_2 %x %p %08x\n", block->flags, block, block->phys);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
block->flags &= ~CODEBLOCK_HAS_PAGE2;
|
||||
|
|
@ -404,11 +421,12 @@ static void invalidate_block(codeblock_t *block)
|
|||
{
|
||||
uint32_t old_pc = block->pc;
|
||||
|
||||
#ifndef RELEASE_BUILD
|
||||
if (block->flags & CODEBLOCK_IN_DIRTY_LIST)
|
||||
fatal("invalidate_block: already in dirty list\n");
|
||||
if (block->pc == BLOCK_PC_INVALID)
|
||||
fatal("Invalidating deleted block\n");
|
||||
|
||||
#endif
|
||||
remove_from_block_list(block, old_pc);
|
||||
block_dirty_list_add(block);
|
||||
if (block->head_mem_block)
|
||||
|
|
@ -423,8 +441,10 @@ static void delete_block(codeblock_t *block)
|
|||
if (block == &codeblock[codeblock_hash[HASH(block->phys)]])
|
||||
codeblock_hash[HASH(block->phys)] = BLOCK_INVALID;
|
||||
|
||||
#ifndef RELEASE_BUILD
|
||||
if (block->pc == BLOCK_PC_INVALID)
|
||||
fatal("Deleting deleted block\n");
|
||||
#endif
|
||||
block->pc = BLOCK_PC_INVALID;
|
||||
|
||||
codeblock_tree_delete(block);
|
||||
|
|
@ -443,8 +463,10 @@ static void delete_dirty_block(codeblock_t *block)
|
|||
if (block == &codeblock[codeblock_hash[HASH(block->phys)]])
|
||||
codeblock_hash[HASH(block->phys)] = BLOCK_INVALID;
|
||||
|
||||
#ifndef RELEASE_BUILD
|
||||
if (block->pc == BLOCK_PC_INVALID)
|
||||
fatal("Deleting deleted block\n");
|
||||
#endif
|
||||
block->pc = BLOCK_PC_INVALID;
|
||||
|
||||
codeblock_tree_delete(block);
|
||||
|
|
@ -494,8 +516,10 @@ void codegen_check_flush(page_t *page, uint64_t mask, uint32_t phys_addr)
|
|||
invalidate_block(block);
|
||||
cpu_recomp_evicted++;
|
||||
}
|
||||
#ifndef RELEASE_BUILD
|
||||
if (block_nr == next_block)
|
||||
fatal("Broken 1\n");
|
||||
#endif
|
||||
block_nr = next_block;
|
||||
}
|
||||
|
||||
|
|
@ -512,8 +536,10 @@ void codegen_check_flush(page_t *page, uint64_t mask, uint32_t phys_addr)
|
|||
invalidate_block(block);
|
||||
cpu_recomp_evicted++;
|
||||
}
|
||||
#ifndef RELEASE_BUILD
|
||||
if (block_nr == next_block)
|
||||
fatal("Broken 2\n");
|
||||
#endif
|
||||
block_nr = next_block;
|
||||
}
|
||||
|
||||
|
|
@ -541,8 +567,10 @@ void codegen_block_init(uint32_t phys_addr)
|
|||
if (!page->block)
|
||||
mem_flush_write_page(phys_addr, cs+cpu_state.pc);
|
||||
block = block_free_list_get();
|
||||
#ifndef RELEASE_BUILD
|
||||
if (!block)
|
||||
fatal("codegen_block_init: block_free_list_get() returned NULL\n");
|
||||
#endif
|
||||
block_current = get_block_nr(block);
|
||||
|
||||
block_num = HASH(phys_addr);
|
||||
|
|
@ -582,10 +610,10 @@ void codegen_block_start_recompile(codeblock_t *block)
|
|||
|
||||
block_num = HASH(block->phys);
|
||||
block_current = get_block_nr(block);//block->pnt;
|
||||
|
||||
#ifndef RELEASE_BUILD
|
||||
if (block->pc != cs + cpu_state.pc || (block->flags & CODEBLOCK_WAS_RECOMPILED))
|
||||
fatal("Recompile to used block!\n");
|
||||
|
||||
#endif
|
||||
block->head_mem_block = codegen_allocator_allocate(NULL, block_current);
|
||||
block->data = codeblock_allocator_get_ptr(block->head_mem_block);
|
||||
|
||||
|
|
@ -695,6 +723,7 @@ void codegen_block_generate_end_mask_recompile()
|
|||
if (!pages[block->phys_2 >> 12].block_2)
|
||||
mem_flush_write_page(block->phys_2, codegen_endpc);
|
||||
|
||||
#ifndef RELEASE_BUILD
|
||||
if (!block->page_mask2)
|
||||
fatal("!page_mask2\n");
|
||||
if (block->next_2)
|
||||
|
|
@ -703,6 +732,7 @@ void codegen_block_generate_end_mask_recompile()
|
|||
if (codeblock[block->next_2].pc == BLOCK_PC_INVALID)
|
||||
fatal("block->next_2->pc=BLOCK_PC_INVALID %p\n", (void *)&codeblock[block->next_2]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -724,9 +754,10 @@ void codegen_block_generate_end_mask_mark()
|
|||
uint32_t end_pc;
|
||||
page_t *p;
|
||||
|
||||
#ifndef RELEASE_BUILD
|
||||
if (block->flags & CODEBLOCK_BYTE_MASK)
|
||||
fatal("codegen_block_generate_end_mask2() - BYTE_MASK\n");
|
||||
|
||||
#endif
|
||||
block->page_mask = 0;
|
||||
start_pc = (block->pc & 0xfff) & ~63;
|
||||
if ((block->pc ^ codegen_endpc) & ~0xfff)
|
||||
|
|
@ -771,7 +802,7 @@ void codegen_block_generate_end_mask_mark()
|
|||
|
||||
if (!pages[block->phys_2 >> 12].block_2)
|
||||
mem_flush_write_page(block->phys_2, codegen_endpc);
|
||||
|
||||
#ifndef RELEASE_BUILD
|
||||
if (!block->page_mask2)
|
||||
fatal("!page_mask2\n");
|
||||
if (block->next_2)
|
||||
|
|
@ -780,7 +811,7 @@ void codegen_block_generate_end_mask_mark()
|
|||
if (codeblock[block->next_2].pc == BLOCK_PC_INVALID)
|
||||
fatal("block->next_2->pc=BLOCK_PC_INVALID %p\n", (void *)&codeblock[block->next_2]);
|
||||
}
|
||||
|
||||
#endif
|
||||
block->dirty_mask2 = &page_2->dirty_mask;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -156,9 +156,10 @@ void codegen_ir_compile(ir_data_t *ir, codeblock_t *block)
|
|||
uop->dest_reg_a_real = codegen_reg_alloc_write_reg(block, uop->dest_reg_a);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef RELEASE_BUILD
|
||||
if (!uop_handlers[uop->type & UOP_MASK])
|
||||
fatal("!uop_handlers[uop->type & UOP_MASK] %08x\n", uop->type);
|
||||
#endif
|
||||
uop_handlers[uop->type & UOP_MASK](block, uop);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -271,8 +271,10 @@ static void codegen_reg_load(host_reg_set_t *reg_set, codeblock_t *block, int c,
|
|||
switch (ireg_data[IREG_GET_REG(ir_reg.reg)].native_size)
|
||||
{
|
||||
case REG_WORD:
|
||||
#ifndef RELEASE_BUILD
|
||||
if (ireg_data[IREG_GET_REG(ir_reg.reg)].type != REG_INTEGER)
|
||||
fatal("codegen_reg_load - REG_WORD !REG_INTEGER\n");
|
||||
#endif
|
||||
if ((uintptr_t)ireg_data[IREG_GET_REG(ir_reg.reg)].p < 256)
|
||||
codegen_direct_read_16_stack(block, reg_set->reg_list[c].reg, (intptr_t)ireg_data[IREG_GET_REG(ir_reg.reg)].p);
|
||||
else
|
||||
|
|
@ -280,8 +282,10 @@ static void codegen_reg_load(host_reg_set_t *reg_set, codeblock_t *block, int c,
|
|||
break;
|
||||
|
||||
case REG_DWORD:
|
||||
#ifndef RELEASE_BUILD
|
||||
if (ireg_data[IREG_GET_REG(ir_reg.reg)].type != REG_INTEGER)
|
||||
fatal("codegen_reg_load - REG_DWORD !REG_INTEGER\n");
|
||||
#endif
|
||||
if ((uintptr_t)ireg_data[IREG_GET_REG(ir_reg.reg)].p < 256)
|
||||
codegen_direct_read_32_stack(block, reg_set->reg_list[c].reg, (intptr_t)ireg_data[IREG_GET_REG(ir_reg.reg)].p);
|
||||
else
|
||||
|
|
@ -289,8 +293,10 @@ static void codegen_reg_load(host_reg_set_t *reg_set, codeblock_t *block, int c,
|
|||
break;
|
||||
|
||||
case REG_QWORD:
|
||||
#ifndef RELEASE_BUILD
|
||||
if (ireg_data[IREG_GET_REG(ir_reg.reg)].type != REG_FP)
|
||||
fatal("codegen_reg_load - REG_QWORD !REG_FP\n");
|
||||
#endif
|
||||
if ((uintptr_t)ireg_data[IREG_GET_REG(ir_reg.reg)].p < 256)
|
||||
codegen_direct_read_64_stack(block, reg_set->reg_list[c].reg, (intptr_t)ireg_data[IREG_GET_REG(ir_reg.reg)].p);
|
||||
else
|
||||
|
|
@ -298,8 +304,10 @@ static void codegen_reg_load(host_reg_set_t *reg_set, codeblock_t *block, int c,
|
|||
break;
|
||||
|
||||
case REG_POINTER:
|
||||
#ifndef RELEASE_BUILD
|
||||
if (ireg_data[IREG_GET_REG(ir_reg.reg)].type != REG_INTEGER)
|
||||
fatal("codegen_reg_load - REG_POINTER !REG_INTEGER\n");
|
||||
#endif
|
||||
if ((uintptr_t)ireg_data[IREG_GET_REG(ir_reg.reg)].p < 256)
|
||||
codegen_direct_read_pointer_stack(block, reg_set->reg_list[c].reg, (intptr_t)ireg_data[IREG_GET_REG(ir_reg.reg)].p);
|
||||
else
|
||||
|
|
@ -307,8 +315,10 @@ static void codegen_reg_load(host_reg_set_t *reg_set, codeblock_t *block, int c,
|
|||
break;
|
||||
|
||||
case REG_DOUBLE:
|
||||
#ifndef RELEASE_BUILD
|
||||
if (ireg_data[IREG_GET_REG(ir_reg.reg)].type != REG_FP)
|
||||
fatal("codegen_reg_load - REG_DOUBLE !REG_FP\n");
|
||||
#endif
|
||||
if ((uintptr_t)ireg_data[IREG_GET_REG(ir_reg.reg)].p < 256)
|
||||
codegen_direct_read_double_stack(block, reg_set->reg_list[c].reg, (intptr_t)ireg_data[IREG_GET_REG(ir_reg.reg)].p);
|
||||
else
|
||||
|
|
@ -316,8 +326,10 @@ static void codegen_reg_load(host_reg_set_t *reg_set, codeblock_t *block, int c,
|
|||
break;
|
||||
|
||||
case REG_FPU_ST_BYTE:
|
||||
#ifndef RELEASE_BUILD
|
||||
if (ireg_data[IREG_GET_REG(ir_reg.reg)].type != REG_INTEGER)
|
||||
fatal("codegen_reg_load - REG_FPU_ST_BYTE !REG_INTEGER\n");
|
||||
#endif
|
||||
if (block->flags & CODEBLOCK_STATIC_TOP)
|
||||
codegen_direct_read_8(block, reg_set->reg_list[c].reg, &cpu_state.tag[ir_reg.reg & 7]);
|
||||
else
|
||||
|
|
@ -325,8 +337,10 @@ static void codegen_reg_load(host_reg_set_t *reg_set, codeblock_t *block, int c,
|
|||
break;
|
||||
|
||||
case REG_FPU_ST_QWORD:
|
||||
#ifndef RELEASE_BUILD
|
||||
if (ireg_data[IREG_GET_REG(ir_reg.reg)].type != REG_FP)
|
||||
fatal("codegen_reg_load - REG_FPU_ST_QWORD !REG_FP\n");
|
||||
#endif
|
||||
if (block->flags & CODEBLOCK_STATIC_TOP)
|
||||
codegen_direct_read_64(block, reg_set->reg_list[c].reg, &cpu_state.MM[ir_reg.reg & 7]);
|
||||
else
|
||||
|
|
@ -334,8 +348,10 @@ static void codegen_reg_load(host_reg_set_t *reg_set, codeblock_t *block, int c,
|
|||
break;
|
||||
|
||||
case REG_FPU_ST_DOUBLE:
|
||||
#ifndef RELEASE_BUILD
|
||||
if (ireg_data[IREG_GET_REG(ir_reg.reg)].type != REG_FP)
|
||||
fatal("codegen_reg_load - REG_FPU_ST_DOUBLE !REG_FP\n");
|
||||
#endif
|
||||
if (block->flags & CODEBLOCK_STATIC_TOP)
|
||||
codegen_direct_read_double(block, reg_set->reg_list[c].reg, &cpu_state.ST[ir_reg.reg & 7]);
|
||||
else
|
||||
|
|
@ -363,24 +379,30 @@ static void codegen_reg_writeback(host_reg_set_t *reg_set, codeblock_t *block, i
|
|||
switch (ireg_data[ir_reg].native_size)
|
||||
{
|
||||
case REG_BYTE:
|
||||
#ifndef RELEASE_BUILD
|
||||
if (ireg_data[ir_reg].type != REG_INTEGER)
|
||||
fatal("codegen_reg_writeback - REG_BYTE !REG_INTEGER\n");
|
||||
if ((uintptr_t)p < 256)
|
||||
fatal("codegen_reg_writeback - REG_BYTE %p\n", p);
|
||||
#endif
|
||||
codegen_direct_write_8(block, p, reg_set->reg_list[c].reg);
|
||||
break;
|
||||
|
||||
case REG_WORD:
|
||||
#ifndef RELEASE_BUILD
|
||||
if (ireg_data[ir_reg].type != REG_INTEGER)
|
||||
fatal("codegen_reg_writeback - REG_WORD !REG_INTEGER\n");
|
||||
if ((uintptr_t)p < 256)
|
||||
fatal("codegen_reg_writeback - REG_WORD %p\n", p);
|
||||
#endif
|
||||
codegen_direct_write_16(block, p, reg_set->reg_list[c].reg);
|
||||
break;
|
||||
|
||||
case REG_DWORD:
|
||||
#ifndef RELEASE_BUILD
|
||||
if (ireg_data[ir_reg].type != REG_INTEGER)
|
||||
fatal("codegen_reg_writeback - REG_DWORD !REG_INTEGER\n");
|
||||
#endif
|
||||
if ((uintptr_t)p < 256)
|
||||
codegen_direct_write_32_stack(block, (intptr_t)p, reg_set->reg_list[c].reg);
|
||||
else
|
||||
|
|
@ -388,8 +410,10 @@ static void codegen_reg_writeback(host_reg_set_t *reg_set, codeblock_t *block, i
|
|||
break;
|
||||
|
||||
case REG_QWORD:
|
||||
#ifndef RELEASE_BUILD
|
||||
if (ireg_data[ir_reg].type != REG_FP)
|
||||
fatal("codegen_reg_writeback - REG_QWORD !REG_FP\n");
|
||||
#endif
|
||||
if ((uintptr_t)p < 256)
|
||||
codegen_direct_write_64_stack(block, (intptr_t)p, reg_set->reg_list[c].reg);
|
||||
else
|
||||
|
|
@ -397,16 +421,20 @@ static void codegen_reg_writeback(host_reg_set_t *reg_set, codeblock_t *block, i
|
|||
break;
|
||||
|
||||
case REG_POINTER:
|
||||
#ifndef RELEASE_BUILD
|
||||
if (ireg_data[ir_reg].type != REG_INTEGER)
|
||||
fatal("codegen_reg_writeback - REG_POINTER !REG_INTEGER\n");
|
||||
if ((uintptr_t)p < 256)
|
||||
fatal("codegen_reg_writeback - REG_POINTER %p\n", p);
|
||||
#endif
|
||||
codegen_direct_write_ptr(block, p, reg_set->reg_list[c].reg);
|
||||
break;
|
||||
|
||||
case REG_DOUBLE:
|
||||
#ifndef RELEASE_BUILD
|
||||
if (ireg_data[ir_reg].type != REG_FP)
|
||||
fatal("codegen_reg_writeback - REG_DOUBLE !REG_FP\n");
|
||||
#endif
|
||||
if ((uintptr_t)p < 256)
|
||||
codegen_direct_write_double_stack(block, (intptr_t)p, reg_set->reg_list[c].reg);
|
||||
else
|
||||
|
|
@ -414,8 +442,10 @@ static void codegen_reg_writeback(host_reg_set_t *reg_set, codeblock_t *block, i
|
|||
break;
|
||||
|
||||
case REG_FPU_ST_BYTE:
|
||||
#ifndef RELEASE_BUILD
|
||||
if (ireg_data[ir_reg].type != REG_INTEGER)
|
||||
fatal("codegen_reg_writeback - REG_FPU_ST_BYTE !REG_INTEGER\n");
|
||||
#endif
|
||||
if (block->flags & CODEBLOCK_STATIC_TOP)
|
||||
codegen_direct_write_8(block, &cpu_state.tag[reg_set->regs[c].reg & 7], reg_set->reg_list[c].reg);
|
||||
else
|
||||
|
|
@ -423,8 +453,10 @@ static void codegen_reg_writeback(host_reg_set_t *reg_set, codeblock_t *block, i
|
|||
break;
|
||||
|
||||
case REG_FPU_ST_QWORD:
|
||||
#ifndef RELEASE_BUILD
|
||||
if (ireg_data[ir_reg].type != REG_FP)
|
||||
fatal("codegen_reg_writeback - REG_FPU_ST_QWORD !REG_FP\n");
|
||||
#endif
|
||||
if (block->flags & CODEBLOCK_STATIC_TOP)
|
||||
codegen_direct_write_64(block, &cpu_state.MM[reg_set->regs[c].reg & 7], reg_set->reg_list[c].reg);
|
||||
else
|
||||
|
|
@ -432,8 +464,10 @@ static void codegen_reg_writeback(host_reg_set_t *reg_set, codeblock_t *block, i
|
|||
break;
|
||||
|
||||
case REG_FPU_ST_DOUBLE:
|
||||
#ifndef RELEASE_BUILD
|
||||
if (ireg_data[ir_reg].type != REG_FP)
|
||||
fatal("codegen_reg_writeback - REG_FPU_ST_DOUBLE !REG_FP\n");
|
||||
#endif
|
||||
if (block->flags & CODEBLOCK_STATIC_TOP)
|
||||
codegen_direct_write_double(block, &cpu_state.ST[reg_set->regs[c].reg & 7], reg_set->reg_list[c].reg);
|
||||
else
|
||||
|
|
@ -458,14 +492,18 @@ void codegen_reg_write_imm(codeblock_t *block, ir_reg_t ir_reg, uint32_t imm_dat
|
|||
switch (ireg_data[reg_idx].native_size)
|
||||
{
|
||||
case REG_BYTE:
|
||||
#ifndef RELEASE_BUILD
|
||||
if ((uintptr_t)p < 256)
|
||||
fatal("codegen_reg_write_imm - REG_BYTE %p\n", p);
|
||||
#endif
|
||||
codegen_direct_write_8_imm(block, p, imm_data);
|
||||
break;
|
||||
|
||||
case REG_WORD:
|
||||
#ifndef RELEASE_BUILD
|
||||
if ((uintptr_t)p < 256)
|
||||
fatal("codegen_reg_write_imm - REG_WORD %p\n", p);
|
||||
#endif
|
||||
codegen_direct_write_16_imm(block, p, imm_data);
|
||||
break;
|
||||
|
||||
|
|
@ -498,8 +536,10 @@ static void alloc_reg(ir_reg_t ir_reg)
|
|||
{
|
||||
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)
|
||||
fatal("alloc_reg - host_regs[c].version != ir_reg.version %i %p %p %i %i\n", c, reg_set, &host_reg_set, reg_set->regs[c].reg, ir_reg.reg);
|
||||
#endif
|
||||
reg_set->locked |= (1 << c);
|
||||
return;
|
||||
}
|
||||
|
|
@ -591,9 +631,10 @@ ir_host_reg_t codegen_reg_alloc_read_reg(codeblock_t *block, ir_reg_t ir_reg, in
|
|||
reg_version[IREG_GET_REG(reg_set->regs[c].reg)][reg_set->regs[c].version].refcount++;
|
||||
break;
|
||||
}
|
||||
|
||||
#ifndef RELEASE_BUILD
|
||||
if (!ir_reg_is_invalid(reg_set->regs[c]) && IREG_GET_REG(reg_set->regs[c].reg) == IREG_GET_REG(ir_reg.reg) && reg_version[IREG_GET_REG(reg_set->regs[c].reg)][reg_set->regs[c].version].refcount)
|
||||
fatal("codegen_reg_alloc_read_reg - version mismatch!\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (c == reg_set->nr_regs)
|
||||
|
|
@ -612,8 +653,10 @@ ir_host_reg_t codegen_reg_alloc_read_reg(codeblock_t *block, ir_reg_t ir_reg, in
|
|||
if (!(reg_set->locked & (1 << c)))
|
||||
break;
|
||||
}
|
||||
#ifndef RELEASE_BUILD
|
||||
if (c == reg_set->nr_regs)
|
||||
fatal("codegen_reg_alloc_read_reg - out of registers\n");
|
||||
#endif
|
||||
}
|
||||
if (reg_set->dirty[c])
|
||||
codegen_reg_writeback(reg_set, block, c, 1);
|
||||
|
|
@ -628,8 +671,10 @@ ir_host_reg_t codegen_reg_alloc_read_reg(codeblock_t *block, ir_reg_t ir_reg, in
|
|||
// pclog(" already loaded %i\n", c);
|
||||
|
||||
reg_version[IREG_GET_REG(reg_set->regs[c].reg)][reg_set->regs[c].version].refcount--;
|
||||
#ifndef RELEASE_BUILD
|
||||
if (reg_version[IREG_GET_REG(reg_set->regs[c].reg)][reg_set->regs[c].version].refcount == (uint8_t)-1)
|
||||
fatal("codegen_reg_alloc_read_reg - refcount < 0\n");
|
||||
#endif
|
||||
|
||||
if (host_reg_idx)
|
||||
*host_reg_idx = c;
|
||||
|
|
@ -653,11 +698,13 @@ ir_host_reg_t codegen_reg_alloc_write_reg(codeblock_t *block, ir_reg_t ir_reg)
|
|||
|
||||
codegen_reg_alloc_read_reg(block, parent_reg, &c);
|
||||
|
||||
#ifndef RELEASE_BUILD
|
||||
if (IREG_GET_REG(reg_set->regs[c].reg) != IREG_GET_REG(ir_reg.reg) || reg_set->regs[c].version > ir_reg.version-1)
|
||||
fatal("codegen_reg_alloc_write_reg sub_reg - doesn't match %i %02x.%i %02x.%i\n", c,
|
||||
reg_set->regs[c].reg,reg_set->regs[c].version,
|
||||
ir_reg.reg,ir_reg.version);
|
||||
|
||||
#endif
|
||||
|
||||
reg_set->regs[c].reg = ir_reg.reg;
|
||||
reg_set->regs[c].version = ir_reg.version;
|
||||
reg_set->dirty[c] = 1;
|
||||
|
|
@ -672,8 +719,10 @@ ir_host_reg_t codegen_reg_alloc_write_reg(codeblock_t *block, ir_reg_t ir_reg)
|
|||
{
|
||||
if (reg_set->regs[c].version <= ir_reg.version-1)
|
||||
{
|
||||
#ifndef RELEASE_BUILD
|
||||
if (reg_version[IREG_GET_REG(reg_set->regs[c].reg)][reg_set->regs[c].version].refcount != 0)
|
||||
fatal("codegen_reg_alloc_write_reg - previous version refcount != 0\n");
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -696,8 +745,10 @@ ir_host_reg_t codegen_reg_alloc_write_reg(codeblock_t *block, ir_reg_t ir_reg)
|
|||
if (!(reg_set->locked & (1 << c)))
|
||||
break;
|
||||
}
|
||||
#ifndef RELEASE_BUILD
|
||||
if (c == reg_set->nr_regs)
|
||||
fatal("codegen_reg_alloc_write_reg - out of registers\n");
|
||||
#endif
|
||||
if (reg_set->dirty[c])
|
||||
codegen_reg_writeback(reg_set, block, c, 1);
|
||||
}
|
||||
|
|
@ -723,8 +774,10 @@ int codegen_reg_is_loaded(ir_reg_t ir_reg)
|
|||
{
|
||||
if (reg_set->regs[c].version <= ir_reg.version-1)
|
||||
{
|
||||
#ifndef RELEASE_BUILD
|
||||
if (reg_version[IREG_GET_REG(reg_set->regs[c].reg)][reg_set->regs[c].version].refcount != 0)
|
||||
fatal("codegen_reg_alloc_write_reg - previous version refcount != 0\n");
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -746,9 +799,10 @@ void codegen_reg_rename(codeblock_t *block, ir_reg_t src, ir_reg_t dst)
|
|||
if (!ir_reg_is_invalid(reg_set->regs[c]) && IREG_GET_REG(reg_set->regs[c].reg) == IREG_GET_REG(src.reg) && reg_set->regs[c].version == src.version)
|
||||
break;
|
||||
}
|
||||
#ifndef RELEASE_BUILD
|
||||
if (c == reg_set->nr_regs)
|
||||
fatal("codegen_reg_rename: Can't find register to rename\n");
|
||||
|
||||
#endif
|
||||
target = c;
|
||||
if (reg_set->dirty[target])
|
||||
codegen_reg_writeback(reg_set, block, target, 0);
|
||||
|
|
|
|||
|
|
@ -325,17 +325,21 @@ static inline ir_reg_t codegen_reg_read(int reg)
|
|||
ir_reg_t ireg;
|
||||
reg_version_t *version;
|
||||
|
||||
#ifndef RELEASE_BUILD
|
||||
if (IREG_GET_REG(reg) == IREG_INVALID)
|
||||
fatal("codegen_reg_read - IREG_INVALID\n");
|
||||
|
||||
#endif
|
||||
ireg.reg = reg;
|
||||
ireg.version = reg_last_version[IREG_GET_REG(reg)];
|
||||
version = ®_version[IREG_GET_REG(ireg.reg)][ireg.version];
|
||||
version->flags = 0;
|
||||
version->refcount++;
|
||||
#ifndef RELEASE_BUILD
|
||||
if (!version->refcount)
|
||||
fatal("codegen_reg_read - refcount overflow\n");
|
||||
else if (version->refcount > REG_REFCOUNT_MAX)
|
||||
else
|
||||
#endif
|
||||
if (version->refcount > REG_REFCOUNT_MAX)
|
||||
CPU_BLOCK_END();
|
||||
if (version->refcount > max_version_refcount)
|
||||
max_version_refcount = version->refcount;
|
||||
|
|
@ -351,9 +355,10 @@ static inline ir_reg_t codegen_reg_write(int reg, int uop_nr)
|
|||
int last_version = reg_last_version[IREG_GET_REG(reg)];
|
||||
reg_version_t *version;
|
||||
|
||||
#ifndef RELEASE_BUILD
|
||||
if (IREG_GET_REG(reg) == IREG_INVALID)
|
||||
fatal("codegen_reg_write - IREG_INVALID\n");
|
||||
|
||||
#endif
|
||||
ireg.reg = reg;
|
||||
ireg.version = last_version + 1;
|
||||
|
||||
|
|
@ -365,9 +370,12 @@ static inline ir_reg_t codegen_reg_write(int reg, int uop_nr)
|
|||
}
|
||||
|
||||
reg_last_version[IREG_GET_REG(reg)]++;
|
||||
#ifndef RELEASE_BUILD
|
||||
if (!reg_last_version[IREG_GET_REG(reg)])
|
||||
fatal("codegen_reg_write - version overflow\n");
|
||||
else if (reg_last_version[IREG_GET_REG(reg)] > REG_VERSION_MAX)
|
||||
else
|
||||
#endif
|
||||
if (reg_last_version[IREG_GET_REG(reg)] > REG_VERSION_MAX)
|
||||
CPU_BLOCK_END();
|
||||
if (reg_last_version[IREG_GET_REG(reg)] > max_version_refcount)
|
||||
max_version_refcount = reg_last_version[IREG_GET_REG(reg)];
|
||||
|
|
|
|||
Loading…
Reference in a new issue