Helper macros to annotate likely branch directions. Colateral effect: this

also fixes build with GCC 4.1 (ppc-dyngen-ops.cpp) since the branches are
re-ordered in a way there is now only one exit-point in op_jump_next_A0().
This commit is contained in:
gbeauche 2006-04-01 21:41:19 +00:00
parent db76383246
commit b288f6278e
2 changed files with 17 additions and 2 deletions

View File

@ -166,6 +166,21 @@ typedef int64 intptr;
#error "Unsupported size of pointer"
#endif
/**
* Helper macros to annotate likely branch directions
**/
#if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
#define likely(x) __builtin_expect((x),1)
#define unlikely(x) __builtin_expect((x),0)
#endif
#ifndef likely
#define likely(x) (x)
#endif
#ifndef unlikely
#define unlikely(x) (x)
#endif
/**
* Helper functions to byteswap data
**/

View File

@ -1246,10 +1246,10 @@ void OPPROTO op_dcbz_T0(void)
void OPPROTO op_jump_next_A0(void)
{
// Make sure there is no pending interrupt request
if (powerpc_dyngen_helper::spcflags().empty()) {
if (likely(powerpc_dyngen_helper::spcflags().empty())) {
powerpc_block_info *bi = (powerpc_block_info *)reg_A0;
uint32 pc = powerpc_dyngen_helper::get_pc();
if (bi->pc == pc || (bi = powerpc_dyngen_helper::find_block(pc)) != NULL)
if (likely(bi->pc == pc) || likely((bi = powerpc_dyngen_helper::find_block(pc)) != NULL))
goto *(bi->entry_point);
}
dyngen_barrier();