From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KET3s-0004o6-D5 for qemu-devel@nongnu.org; Thu, 03 Jul 2008 13:57:40 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KET3r-0004nG-Lc for qemu-devel@nongnu.org; Thu, 03 Jul 2008 13:57:39 -0400 Received: from [199.232.76.173] (port=40107 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KET3r-0004n9-BS for qemu-devel@nongnu.org; Thu, 03 Jul 2008 13:57:39 -0400 Received: from savannah.gnu.org ([199.232.41.3]:47512 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KET3q-0007Do-UJ for qemu-devel@nongnu.org; Thu, 03 Jul 2008 13:57:39 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1KET3p-0007fo-KP for qemu-devel@nongnu.org; Thu, 03 Jul 2008 17:57:37 +0000 Received: from ths by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1KET3p-0007fc-6v for qemu-devel@nongnu.org; Thu, 03 Jul 2008 17:57:37 +0000 MIME-Version: 1.0 Errors-To: ths Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Thiemo Seufer Message-Id: Date: Thu, 03 Jul 2008 17:57:37 +0000 Subject: [Qemu-devel] [4840] Convert remaining __builtin_expect to likely/unlikely, by Jan Kiszka . Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 4840 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4840 Author: ths Date: 2008-07-03 17:57:36 +0000 (Thu, 03 Jul 2008) Log Message: ----------- Convert remaining __builtin_expect to likely/unlikely, by Jan Kiszka. Modified Paths: -------------- trunk/cpu-exec.c trunk/exec-all.h trunk/softmmu_header.h trunk/target-arm/op_helper.c trunk/target-arm/translate.c trunk/target-cris/op_helper.c trunk/target-cris/translate.c trunk/target-m68k/op_helper.c trunk/target-m68k/translate.c Modified: trunk/cpu-exec.c =================================================================== --- trunk/cpu-exec.c 2008-07-03 16:40:06 UTC (rev 4839) +++ trunk/cpu-exec.c 2008-07-03 17:57:36 UTC (rev 4840) @@ -224,8 +224,8 @@ #error unsupported CPU #endif tb = env->tb_jmp_cache[tb_jmp_cache_hash_func(pc)]; - if (__builtin_expect(!tb || tb->pc != pc || tb->cs_base != cs_base || - tb->flags != flags, 0)) { + if (unlikely(!tb || tb->pc != pc || tb->cs_base != cs_base || + tb->flags != flags)) { tb = tb_find_slow(pc, cs_base, flags); } return tb; @@ -360,7 +360,7 @@ next_tb = 0; /* force lookup of first TB */ for(;;) { interrupt_request = env->interrupt_request; - if (__builtin_expect(interrupt_request, 0) && + if (unlikely(interrupt_request) && likely(!(env->singlestep_enabled & SSTEP_NOIRQ))) { if (interrupt_request & CPU_INTERRUPT_DEBUG) { env->interrupt_request &= ~CPU_INTERRUPT_DEBUG; Modified: trunk/exec-all.h =================================================================== --- trunk/exec-all.h 2008-07-03 16:40:06 UTC (rev 4839) +++ trunk/exec-all.h 2008-07-03 17:57:36 UTC (rev 4840) @@ -357,8 +357,8 @@ page_index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); mmu_idx = cpu_mmu_index(env1); - if (__builtin_expect(env1->tlb_table[mmu_idx][page_index].addr_code != - (addr & TARGET_PAGE_MASK), 0)) { + if (unlikely(env1->tlb_table[mmu_idx][page_index].addr_code != + (addr & TARGET_PAGE_MASK))) { ldub_code(addr); } pd = env1->tlb_table[mmu_idx][page_index].addr_code & ~TARGET_PAGE_MASK; Modified: trunk/softmmu_header.h =================================================================== --- trunk/softmmu_header.h 2008-07-03 16:40:06 UTC (rev 4839) +++ trunk/softmmu_header.h 2008-07-03 17:57:36 UTC (rev 4840) @@ -231,8 +231,8 @@ addr = ptr; page_index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); mmu_idx = CPU_MMU_INDEX; - if (__builtin_expect(env->tlb_table[mmu_idx][page_index].ADDR_READ != - (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))), 0)) { + if (unlikely(env->tlb_table[mmu_idx][page_index].ADDR_READ != + (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) { res = glue(glue(__ld, SUFFIX), MMUSUFFIX)(addr, mmu_idx); } else { physaddr = addr + env->tlb_table[mmu_idx][page_index].addend; @@ -252,8 +252,8 @@ addr = ptr; page_index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); mmu_idx = CPU_MMU_INDEX; - if (__builtin_expect(env->tlb_table[mmu_idx][page_index].ADDR_READ != - (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))), 0)) { + if (unlikely(env->tlb_table[mmu_idx][page_index].ADDR_READ != + (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) { res = (DATA_STYPE)glue(glue(__ld, SUFFIX), MMUSUFFIX)(addr, mmu_idx); } else { physaddr = addr + env->tlb_table[mmu_idx][page_index].addend; @@ -277,8 +277,8 @@ addr = ptr; page_index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); mmu_idx = CPU_MMU_INDEX; - if (__builtin_expect(env->tlb_table[mmu_idx][page_index].addr_write != - (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))), 0)) { + if (unlikely(env->tlb_table[mmu_idx][page_index].addr_write != + (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) { glue(glue(__st, SUFFIX), MMUSUFFIX)(addr, v, mmu_idx); } else { physaddr = addr + env->tlb_table[mmu_idx][page_index].addend; Modified: trunk/target-arm/op_helper.c =================================================================== --- trunk/target-arm/op_helper.c 2008-07-03 16:40:06 UTC (rev 4839) +++ trunk/target-arm/op_helper.c 2008-07-03 17:57:36 UTC (rev 4840) @@ -97,7 +97,7 @@ saved_env = env; env = cpu_single_env; ret = cpu_arm_handle_mmu_fault(env, addr, is_write, mmu_idx, 1); - if (__builtin_expect(ret, 0)) { + if (unlikely(ret)) { if (retaddr) { /* now we have a real cpu fault */ pc = (unsigned long)retaddr; Modified: trunk/target-arm/translate.c =================================================================== --- trunk/target-arm/translate.c 2008-07-03 16:40:06 UTC (rev 4839) +++ trunk/target-arm/translate.c 2008-07-03 17:57:36 UTC (rev 4840) @@ -3393,7 +3393,7 @@ static inline void gen_jmp (DisasContext *s, uint32_t dest) { - if (__builtin_expect(s->singlestep_enabled, 0)) { + if (unlikely(s->singlestep_enabled)) { /* An indirect jump so that we still trigger the debug exception. */ if (s->thumb) dest |= 1; @@ -8703,7 +8703,7 @@ /* At this stage dc->condjmp will only be set when the skipped instruction was a conditional branch or trap, and the PC has already been written. */ - if (__builtin_expect(env->singlestep_enabled, 0)) { + if (unlikely(env->singlestep_enabled)) { /* Make sure the pc is updated, and raise a debug exception. */ if (dc->condjmp) { gen_set_condexec(dc); Modified: trunk/target-cris/op_helper.c =================================================================== --- trunk/target-cris/op_helper.c 2008-07-03 16:40:06 UTC (rev 4839) +++ trunk/target-cris/op_helper.c 2008-07-03 17:57:36 UTC (rev 4840) @@ -61,7 +61,7 @@ D(fprintf(logfile, "%s pc=%x tpc=%x ra=%x\n", __func__, env->pc, env->debug1, retaddr)); ret = cpu_cris_handle_mmu_fault(env, addr, is_write, mmu_idx, 1); - if (__builtin_expect(ret, 0)) { + if (unlikely(ret)) { if (retaddr) { /* now we have a real cpu fault */ pc = (unsigned long)retaddr; Modified: trunk/target-cris/translate.c =================================================================== --- trunk/target-cris/translate.c 2008-07-03 16:40:06 UTC (rev 4839) +++ trunk/target-cris/translate.c 2008-07-03 17:57:36 UTC (rev 4840) @@ -3191,7 +3191,7 @@ cris_evaluate_flags (dc); - if (__builtin_expect(env->singlestep_enabled, 0)) { + if (unlikely(env->singlestep_enabled)) { tcg_gen_movi_tl(env_pc, npc); t_gen_raise_exception(EXCP_DEBUG); } else { Modified: trunk/target-m68k/op_helper.c =================================================================== --- trunk/target-m68k/op_helper.c 2008-07-03 16:40:06 UTC (rev 4839) +++ trunk/target-m68k/op_helper.c 2008-07-03 17:57:36 UTC (rev 4840) @@ -61,7 +61,7 @@ saved_env = env; env = cpu_single_env; ret = cpu_m68k_handle_mmu_fault(env, addr, is_write, mmu_idx, 1); - if (__builtin_expect(ret, 0)) { + if (unlikely(ret)) { if (retaddr) { /* now we have a real cpu fault */ pc = (unsigned long)retaddr; Modified: trunk/target-m68k/translate.c =================================================================== --- trunk/target-m68k/translate.c 2008-07-03 16:40:06 UTC (rev 4839) +++ trunk/target-m68k/translate.c 2008-07-03 17:57:36 UTC (rev 4840) @@ -873,7 +873,7 @@ TranslationBlock *tb; tb = s->tb; - if (__builtin_expect (s->singlestep_enabled, 0)) { + if (unlikely(s->singlestep_enabled)) { gen_exception(s, dest, EXCP_DEBUG); } else if ((tb->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK) || (s->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK)) { @@ -2991,7 +2991,7 @@ if (tb->cflags & CF_LAST_IO) gen_io_end(); - if (__builtin_expect(env->singlestep_enabled, 0)) { + if (unlikely(env->singlestep_enabled)) { /* Make sure the pc is updated, and raise a debug exception. */ if (!dc->is_jmp) { gen_flush_cc_op(dc);