[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 44/68] target/nios2: Split out helpers for gen_i_cmpxx
From: |
Richard Henderson |
Subject: |
[PULL 44/68] target/nios2: Split out helpers for gen_i_cmpxx |
Date: |
Tue, 26 Apr 2022 11:18:43 -0700 |
Do as little work as possible within the macro.
Split out helper functions and pass in arguments instead.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/nios2/translate.c | 34 +++++++++++++++++++++++++++-------
1 file changed, 27 insertions(+), 7 deletions(-)
diff --git a/target/nios2/translate.c b/target/nios2/translate.c
index a3c63dbbbd..86978ba47a 100644
--- a/target/nios2/translate.c
+++ b/target/nios2/translate.c
@@ -71,6 +71,18 @@ typedef struct {
.a = extract32((code), 27, 5), \
}
+typedef target_ulong ImmFromIType(const InstrIType *);
+
+static target_ulong imm_unsigned(const InstrIType *i)
+{
+ return i->imm16.u;
+}
+
+static target_ulong imm_signed(const InstrIType *i)
+{
+ return i->imm16.s;
+}
+
/* R-Type instruction parsing */
typedef struct {
uint8_t op;
@@ -268,15 +280,23 @@ static void gen_bxx(DisasContext *dc, uint32_t code,
uint32_t flags)
}
/* Comparison instructions */
-#define gen_i_cmpxx(fname, op3) \
-static void (fname)(DisasContext *dc, uint32_t code, uint32_t flags) \
-{ \
- I_TYPE(instr, (code)); \
- tcg_gen_setcondi_tl(flags, cpu_R[instr.b], cpu_R[instr.a], (op3)); \
+static void do_i_cmpxx(DisasContext *dc, uint32_t insn,
+ TCGCond cond, ImmFromIType *imm)
+{
+ I_TYPE(instr, insn);
+
+ if (likely(instr.b != R_ZERO)) {
+ tcg_gen_setcondi_tl(cond, cpu_R[instr.b],
+ load_gpr(dc, instr.a), imm(&instr));
+ }
}
-gen_i_cmpxx(gen_cmpxxsi, instr.imm16.s)
-gen_i_cmpxx(gen_cmpxxui, instr.imm16.u)
+#define gen_i_cmpxx(fname, imm) \
+ static void (fname)(DisasContext *dc, uint32_t code, uint32_t flags) \
+ { do_i_cmpxx(dc, code, flags, imm); }
+
+gen_i_cmpxx(gen_cmpxxsi, imm_signed)
+gen_i_cmpxx(gen_cmpxxui, imm_unsigned)
/* Math/logic instructions */
#define gen_i_math_logic(fname, insn, resimm, op3) \
--
2.34.1
- [PULL 27/68] target/nios2: Use hw/registerfields.h for CR_TLBACC fields, (continued)
- [PULL 27/68] target/nios2: Use hw/registerfields.h for CR_TLBACC fields, Richard Henderson, 2022/04/26
- [PULL 30/68] target/nios2: Move R_FOO and CR_BAR into enumerations, Richard Henderson, 2022/04/26
- [PULL 33/68] target/nios2: Hoist CPU_LOG_INT logging, Richard Henderson, 2022/04/26
- [PULL 34/68] target/nios2: Handle EXCP_UNALIGN and EXCP_UNALIGND, Richard Henderson, 2022/04/26
- [PULL 35/68] target/nios2: Cleanup set of CR_EXCEPTION for do_interrupt, Richard Henderson, 2022/04/26
- [PULL 31/68] target/nios2: Create EXCP_SEMIHOST for semi-hosting, Richard Henderson, 2022/04/26
- [PULL 36/68] target/nios2: Clean up handling of tlbmisc in do_exception, Richard Henderson, 2022/04/26
- [PULL 40/68] target/nios2: Remove CPU_INTERRUPT_NMI, Richard Henderson, 2022/04/26
- [PULL 43/68] target/nios2: Split out named structs for [IRJ]_TYPE, Richard Henderson, 2022/04/26
- [PULL 46/68] target/nios2: Split out helpers for gen_r_math_logic, Richard Henderson, 2022/04/26
- [PULL 44/68] target/nios2: Split out helpers for gen_i_cmpxx,
Richard Henderson <=
- [PULL 49/68] target/nios2: Introduce dest_gpr, Richard Henderson, 2022/04/26
- [PULL 51/68] target/nios2: Enable unaligned traps for system mode, Richard Henderson, 2022/04/26
- [PULL 56/68] target/nios2: Implement Misaligned destination exception, Richard Henderson, 2022/04/26
- [PULL 53/68] target/nios2: Hoist set of is_jmp into gen_goto_tb, Richard Henderson, 2022/04/26
- [PULL 41/68] target/nios2: Support division error exception, Richard Henderson, 2022/04/26
- [PULL 42/68] target/nios2: Use tcg_constant_tl, Richard Henderson, 2022/04/26
- [PULL 54/68] target/nios2: Use gen_goto_tb for DISAS_TOO_MANY, Richard Henderson, 2022/04/26
- [PULL 64/68] hw/nios2: Introduce Nios2MachineState, Richard Henderson, 2022/04/26
- [PULL 45/68] target/nios2: Split out helpers for gen_i_math_logic, Richard Henderson, 2022/04/26
- [PULL 50/68] target/nios2: Drop CR_STATUS_EH from tb->flags, Richard Henderson, 2022/04/26