[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 38/76] target/microblaze: Implement cmp and cmpu inline
From: |
Richard Henderson |
Subject: |
[PATCH v2 38/76] target/microblaze: Implement cmp and cmpu inline |
Date: |
Fri, 28 Aug 2020 07:18:51 -0700 |
These are simple enough operations; we do not need to
call an out-of-line helper.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/microblaze/helper.h | 2 --
target/microblaze/op_helper.c | 20 --------------------
target/microblaze/translate.c | 24 ++++++++++++++++++++++--
3 files changed, 22 insertions(+), 24 deletions(-)
diff --git a/target/microblaze/helper.h b/target/microblaze/helper.h
index 988abf7661..6f7f96421f 100644
--- a/target/microblaze/helper.h
+++ b/target/microblaze/helper.h
@@ -1,6 +1,4 @@
DEF_HELPER_FLAGS_2(raise_exception, TCG_CALL_NO_WG, noreturn, env, i32)
-DEF_HELPER_2(cmp, i32, i32, i32)
-DEF_HELPER_2(cmpu, i32, i32, i32)
DEF_HELPER_3(divs, i32, env, i32, i32)
DEF_HELPER_3(divu, i32, env, i32, i32)
diff --git a/target/microblaze/op_helper.c b/target/microblaze/op_helper.c
index 9bb6a2ad76..f976d112eb 100644
--- a/target/microblaze/op_helper.c
+++ b/target/microblaze/op_helper.c
@@ -69,26 +69,6 @@ void helper_raise_exception(CPUMBState *env, uint32_t index)
cpu_loop_exit(cs);
}
-uint32_t helper_cmp(uint32_t a, uint32_t b)
-{
- uint32_t t;
-
- t = b + ~a + 1;
- if ((b & 0x80000000) ^ (a & 0x80000000))
- t = (t & 0x7fffffff) | (b & 0x80000000);
- return t;
-}
-
-uint32_t helper_cmpu(uint32_t a, uint32_t b)
-{
- uint32_t t;
-
- t = b + ~a + 1;
- if ((b & 0x80000000) ^ (a & 0x80000000))
- t = (t & 0x7fffffff) | (a & 0x80000000);
- return t;
-}
-
static inline int div_prepare(CPUMBState *env, uint32_t a, uint32_t b)
{
MicroBlazeCPU *cpu = env_archcpu(env);
diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c
index 0e7d24ddca..8da477457d 100644
--- a/target/microblaze/translate.c
+++ b/target/microblaze/translate.c
@@ -327,8 +327,28 @@ DO_TYPEBV(addic, true, gen_addc)
DO_TYPEBI(addik, false, tcg_gen_addi_i32)
DO_TYPEBV(addikc, true, gen_addkc)
-DO_TYPEA(cmp, false, gen_helper_cmp)
-DO_TYPEA(cmpu, false, gen_helper_cmpu)
+static void gen_cmp(TCGv_i32 out, TCGv_i32 ina, TCGv_i32 inb)
+{
+ TCGv_i32 lt = tcg_temp_new_i32();
+
+ tcg_gen_setcond_i32(TCG_COND_LT, lt, inb, ina);
+ tcg_gen_sub_i32(out, inb, ina);
+ tcg_gen_deposit_i32(out, out, lt, 31, 1);
+ tcg_temp_free_i32(lt);
+}
+
+static void gen_cmpu(TCGv_i32 out, TCGv_i32 ina, TCGv_i32 inb)
+{
+ TCGv_i32 lt = tcg_temp_new_i32();
+
+ tcg_gen_setcond_i32(TCG_COND_LTU, lt, inb, ina);
+ tcg_gen_sub_i32(out, inb, ina);
+ tcg_gen_deposit_i32(out, out, lt, 31, 1);
+ tcg_temp_free_i32(lt);
+}
+
+DO_TYPEA(cmp, false, gen_cmp)
+DO_TYPEA(cmpu, false, gen_cmpu)
/* No input carry, but output carry. */
static void gen_rsub(TCGv_i32 out, TCGv_i32 ina, TCGv_i32 inb)
--
2.25.1
- [PATCH v2 25/76] target/microblaze: Split out MSR[C] to its own variable, (continued)
- [PATCH v2 25/76] target/microblaze: Split out MSR[C] to its own variable, Richard Henderson, 2020/08/28
- [PATCH v2 27/76] target/microblaze: Check singlestep_enabled in gen_goto_tb, Richard Henderson, 2020/08/28
- [PATCH v2 29/76] target/microblaze: Convert to translator_loop, Richard Henderson, 2020/08/28
- [PATCH v2 30/76] target/microblaze: Remove SIM_COMPAT, Richard Henderson, 2020/08/28
- [PATCH v2 28/76] target/microblaze: Convert to DisasContextBase, Richard Henderson, 2020/08/28
- [PATCH v2 31/76] target/microblaze: Remove DISAS_GNU, Richard Henderson, 2020/08/28
- [PATCH v2 33/76] target/microblaze: Remove LOG_DIS, Richard Henderson, 2020/08/28
- [PATCH v2 32/76] target/microblaze: Remove empty D macros, Richard Henderson, 2020/08/28
- [PATCH v2 35/76] target/microblaze: Add decodetree infrastructure, Richard Henderson, 2020/08/28
- [PATCH v2 37/76] target/microblaze: Convert dec_sub to decodetree, Richard Henderson, 2020/08/28
- [PATCH v2 38/76] target/microblaze: Implement cmp and cmpu inline,
Richard Henderson <=
- [PATCH v2 36/76] target/microblaze: Convert dec_add to decodetree, Richard Henderson, 2020/08/28
- [PATCH v2 34/76] target/microblaze: Ensure imm constant is always available, Richard Henderson, 2020/08/28
- [PATCH v2 39/76] target/microblaze: Convert dec_pattern to decodetree, Richard Henderson, 2020/08/28
- [PATCH v2 40/76] target/microblaze: Convert dec_and, dec_or, dec_xor to decodetree, Richard Henderson, 2020/08/28
- [PATCH v2 42/76] target/microblaze: Convert dec_div to decodetree, Richard Henderson, 2020/08/28
- [PATCH v2 41/76] target/microblaze: Convert dec_mul to decodetree, Richard Henderson, 2020/08/28
- [PATCH v2 45/76] target/microblaze: Convert dec_barrel to decodetree, Richard Henderson, 2020/08/28
- [PATCH v2 43/76] target/microblaze: Unwind properly when raising divide-by-zero, Richard Henderson, 2020/08/28
- [PATCH v2 44/76] target/microblaze: Convert dec_bit to decodetree, Richard Henderson, 2020/08/28
- [PATCH v2 46/76] target/microblaze: Convert dec_imm to decodetree, Richard Henderson, 2020/08/28