diff mbox series

[1/3] target/nios2: Replace load_zero() by zero constant in DisasContext

Message ID 20211002233054.3575646-2-f4bug@amsat.org
State New
Headers show
Series target/nios2: Use tcg_constant_* | expand

Commit Message

Philippe Mathieu-Daudé Oct. 2, 2021, 11:30 p.m. UTC
Instead of using a temporary for $zero, keep a reference to the
constant pool.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/nios2/translate.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

Comments

Richard Henderson Oct. 3, 2021, 1:49 p.m. UTC | #1
On 10/2/21 7:30 PM, Philippe Mathieu-Daudé wrote:
> Instead of using a temporary for $zero, keep a reference to the
> constant pool.
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   target/nios2/translate.c | 17 ++---------------
>   1 file changed, 2 insertions(+), 15 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
diff mbox series

Patch

diff --git a/target/nios2/translate.c b/target/nios2/translate.c
index 08d7ac53983..c398c5320fb 100644
--- a/target/nios2/translate.c
+++ b/target/nios2/translate.c
@@ -122,20 +122,12 @@  static uint8_t get_opxcode(uint32_t code)
     return instr.opx;
 }
 
-static TCGv load_zero(DisasContext *dc)
-{
-    if (!dc->zero) {
-        dc->zero = tcg_const_i32(0);
-    }
-    return dc->zero;
-}
-
 static TCGv load_gpr(DisasContext *dc, uint8_t reg)
 {
     if (likely(reg != R_ZERO)) {
         return cpu_R[reg];
     } else {
-        return load_zero(dc);
+        return dc->zero;
     }
 }
 
@@ -752,6 +744,7 @@  static void nios2_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
     int page_insns;
 
     dc->mem_idx = cpu_mmu_index(env, false);
+    dc->zero = tcg_constant_i32(0);
 
     /* Bound the number of insns to execute to those left on the page.  */
     page_insns = -(dc->base.pc_first | TARGET_PAGE_MASK) / 4;
@@ -797,14 +790,8 @@  static void nios2_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
         return;
     }
 
-    dc->zero = NULL;
-
     instr = &i_type_instructions[op];
     instr->handler(dc, code, instr->flags);
-
-    if (dc->zero) {
-        tcg_temp_free(dc->zero);
-    }
 }
 
 static void nios2_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs)