From 89b96876282a2216a4be21c47e9f08173287c195 Mon Sep 17 00:00:00 2001 From: Stefanos Kornilios Mitsis Poiitidis Date: Mon, 10 Aug 2015 04:57:00 +0200 Subject: [PATCH] shrec/x86: SIMPLELINK implementation for cross checking --- core/rec-x86/rec_x86_driver.cpp | 66 ++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/core/rec-x86/rec_x86_driver.cpp b/core/rec-x86/rec_x86_driver.cpp index 06e799bae..4d9f6d61b 100644 --- a/core/rec-x86/rec_x86_driver.cpp +++ b/core/rec-x86/rec_x86_driver.cpp @@ -438,7 +438,70 @@ u32 DynaRBI::Relink() x86e->x86_size=512; x86e->do_realloc=false; - if (BlockType==BET_StaticCall || BlockType==BET_DynamicCall) +//#define SIMPLELINK +#ifdef SIMPLELINK + switch (BlockType) { + + case BET_StaticJump: + case BET_StaticCall: + //next_pc = block->BranchBlock; + x86e->Emit(op_mov32, ECX, BranchBlock); + break; + + case BET_Cond_0: + case BET_Cond_1: + { + //next_pc = next_pc_value; + //if (*jdyn == 0) + //next_pc = branch_pc_value; + + x86e->Emit(op_mov32, ECX, NextBlock); + + u32* ptr = &sr.T; + if (has_jcond) + ptr = &Sh4cntx.jdyn; + + x86e->Emit(op_cmp32, ptr, BlockType & 1); + + x86_Label* lbl = x86e->CreateLabel(false, 8); + x86e->Emit(op_jne, lbl); + x86e->Emit(op_mov32, ECX, BranchBlock); + x86e->MarkLabel(lbl); + } + break; + + case BET_DynamicJump: + case BET_DynamicCall: + case BET_DynamicRet: + //next_pc = *jdyn; + x86e->Emit(op_mov32, ECX, &Sh4cntx.jdyn); + break; + + case BET_DynamicIntr: + case BET_StaticIntr: + if (BlockType == BET_StaticIntr) + { + x86e->Emit(op_mov32, &next_pc, NextBlock); + } + else + { + x86e->Emit(op_mov32, EAX, GetRegPtr(reg_pc_dyn)); + x86e->Emit(op_mov32, &next_pc, EAX); + } + x86e->Emit(op_call, x86_ptr_imm(UpdateINTC)); + + x86e->Emit(op_mov32, ECX, &next_pc); + + break; + + default: + die("Invalid block end type"); + } + + x86e->Emit(op_jmp, x86_ptr_imm(loop_no_update)); + +#else + if (BlockType == BET_StaticCall || BlockType == BET_DynamicCall) { //csc_push(this); } @@ -532,6 +595,7 @@ u32 DynaRBI::Relink() break; } +#endif