Changeset 37696 in vbox for trunk/src/recompiler/tcg/i386/tcg-target.c
- Timestamp:
- Jun 29, 2011 7:02:40 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/recompiler/tcg/i386/tcg-target.c
r37689 r37696 364 364 }; 365 365 366 #if defined(VBOX) 367 /* Calc the size of the tcg_out_opc() result. */ 368 static inline unsigned char tcg_calc_opc_len(TCGContext *s, int opc, int r, int rm, int x) 369 { 370 unsigned char len = 1; 371 # if TCG_TARGET_REG_BITS == 64 372 unsigned rex; 373 rex = 0; 374 rex |= (opc & P_REXW) >> 8; /* REX.W */ 375 rex |= (r & 8) >> 1; /* REX.R */ 376 rex |= (x & 8) >> 2; /* REX.X */ 377 rex |= (rm & 8) >> 3; /* REX.B */ 378 rex |= opc & (r >= 4 ? P_REXB_R : 0); 379 rex |= opc & (rm >= 4 ? P_REXB_RM : 0); 380 if (rex) len++; 381 if (opc & P_ADDR32) len++; 382 # endif 383 if (opc & P_DATA16) len++; 384 if (opc & P_EXT) len++; 385 386 return len; 387 } 388 #endif 389 366 390 #if TCG_TARGET_REG_BITS == 64 367 391 static void tcg_out_opc(TCGContext *s, int opc, int r, int rm, int x) … … 439 463 /* Try for a rip-relative addressing mode. This has replaced 440 464 the 32-bit-mode absolute addressing encoding. */ 465 #ifdef VBOX 466 tcg_target_long pc = (tcg_target_long)s->code_ptr + tcg_calc_opc_len(s, opc, r, 0, 0) + 5; 467 #else 441 468 tcg_target_long pc = (tcg_target_long)s->code_ptr + 5 + ~rm; 469 #endif 442 470 tcg_target_long disp = offset - pc; 443 471 if (disp == (int32_t)disp) { … … 445 473 tcg_out8(s, (LOWREGMASK(r) << 3) | 5); 446 474 tcg_out32(s, disp); 475 #ifdef VBOX 476 Assert(pc == (tcg_target_long)s->code_ptr); 477 #endif 447 478 return; 448 479 } … … 960 991 static void tcg_out_branch(TCGContext *s, int call, tcg_target_long dest) 961 992 { 993 #ifdef VBOX 994 tcg_target_long disp = dest - (tcg_target_long)s->code_ptr 995 - tcg_calc_opc_len(s, call ? OPC_CALL_Jz : OPC_JMP_long, 0, 0, 0); 996 #else 962 997 tcg_target_long disp = dest - (tcg_target_long)s->code_ptr - 5; 998 #endif 963 999 964 1000 if (disp == (int32_t)disp) {
Note:
See TracChangeset
for help on using the changeset viewer.