[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 01/16] target/mips: Extract gen_base_index_addr() helper
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v3 01/16] target/mips: Extract gen_base_index_addr() helper |
Date: |
Tue, 26 Nov 2024 14:59:47 +0100 |
Factor out gen_base_index_addr() which is used twice
but we'll use it more.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20241111222936.59869-2-philmd@linaro.org>
---
target/mips/tcg/translate.h | 1 +
target/mips/tcg/translate.c | 27 +++++++++++++--------------
2 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/target/mips/tcg/translate.h b/target/mips/tcg/translate.h
index 1bf153d1838..ed69ba15e58 100644
--- a/target/mips/tcg/translate.h
+++ b/target/mips/tcg/translate.h
@@ -153,6 +153,7 @@ void check_cp1_registers(DisasContext *ctx, int regs);
void check_cop1x(DisasContext *ctx);
void gen_base_offset_addr(DisasContext *ctx, TCGv addr, int base, int offset);
+void gen_base_index_addr(DisasContext *ctx, TCGv addr, int base, int index);
void gen_move_low32(TCGv ret, TCGv_i64 arg);
void gen_move_high32(TCGv ret, TCGv_i64 arg);
void gen_load_gpr(TCGv t, int reg);
diff --git a/target/mips/tcg/translate.c b/target/mips/tcg/translate.c
index de7045874dd..7152f5418e1 100644
--- a/target/mips/tcg/translate.c
+++ b/target/mips/tcg/translate.c
@@ -1956,6 +1956,17 @@ void gen_base_offset_addr(DisasContext *ctx, TCGv addr,
int base, int offset)
}
}
+void gen_base_index_addr(DisasContext *ctx, TCGv addr, int base, int index)
+{
+ if (base == 0) {
+ gen_load_gpr(addr, index);
+ } else if (index == 0) {
+ gen_load_gpr(addr, base);
+ } else {
+ gen_op_addr_add(ctx, addr, cpu_gpr[base], cpu_gpr[index]);
+ }
+}
+
static target_ulong pc_relative_pc(DisasContext *ctx)
{
target_ulong pc = ctx->base.pc_next;
@@ -10545,13 +10556,7 @@ static void gen_flt3_ldst(DisasContext *ctx, uint32_t
opc,
{
TCGv t0 = tcg_temp_new();
- if (base == 0) {
- gen_load_gpr(t0, index);
- } else if (index == 0) {
- gen_load_gpr(t0, base);
- } else {
- gen_op_addr_add(ctx, t0, cpu_gpr[base], cpu_gpr[index]);
- }
+ gen_base_index_addr(ctx, t0, base, index);
/*
* Don't do NOP if destination is zero: we must perform the actual
* memory access.
@@ -11333,13 +11338,7 @@ static void gen_mips_lx(DisasContext *ctx, uint32_t
opc,
}
t0 = tcg_temp_new();
- if (base == 0) {
- gen_load_gpr(t0, offset);
- } else if (offset == 0) {
- gen_load_gpr(t0, base);
- } else {
- gen_op_addr_add(ctx, t0, cpu_gpr[base], cpu_gpr[offset]);
- }
+ gen_base_index_addr(ctx, t0, base, offset);
switch (opc) {
case OPC_LBUX:
--
2.45.2
- [PATCH v3 00/16] target/mips: Convert nanoMIPS LSA opcode to decodetree, Philippe Mathieu-Daudé, 2024/11/26
- [PATCH v3 02/16] target/mips: Extract generic gen_lx() helper, Philippe Mathieu-Daudé, 2024/11/26
- [PATCH v3 01/16] target/mips: Extract gen_base_index_addr() helper,
Philippe Mathieu-Daudé <=
- [PATCH v3 03/16] target/mips: Convert Octeon LX instructions to decodetree, Philippe Mathieu-Daudé, 2024/11/26
- [PATCH v3 05/16] target/mips: Have gen_[d]lsa() callers add 1 to shift amount argument, Philippe Mathieu-Daudé, 2024/11/26
- [PATCH v3 04/16] target/mips: Call translator_ld() in translate_insn() callees, Philippe Mathieu-Daudé, 2024/11/26
- [PATCH v3 06/16] target/mips: Decode LSA shift amount using decodetree function, Philippe Mathieu-Daudé, 2024/11/26
- [PATCH v3 07/16] target/mips: Introduce decode tree bindings for MIPS16e ASE, Philippe Mathieu-Daudé, 2024/11/26
- [PATCH v3 08/16] target/mips: Introduce decode tree bindings for microMIPS ISA, Philippe Mathieu-Daudé, 2024/11/26
- [PATCH v3 09/16] scripts/decodetree: Add support for 48-bit instructions, Philippe Mathieu-Daudé, 2024/11/26