[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 38/77] target/microblaze: Implement cmp and cmpu inline
From: |
Richard Henderson |
Subject: |
[PATCH 38/77] target/microblaze: Implement cmp and cmpu inline |
Date: |
Tue, 25 Aug 2020 13:59:11 -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 98050f64b7..ce91645f05 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 29/77] target/microblaze: Convert to translator_loop, (continued)
- [PATCH 29/77] target/microblaze: Convert to translator_loop, Richard Henderson, 2020/08/25
- [PATCH 32/77] target/microblaze: Remove empty D macros, Richard Henderson, 2020/08/25
- [PATCH 25/77] target/microblaze: Split out MSR[C] to its own variable, Richard Henderson, 2020/08/25
- [PATCH 33/77] target/microblaze: Remove LOG_DIS, Richard Henderson, 2020/08/25
- [PATCH 36/77] target/microblaze: Convert dec_add to decodetree, Richard Henderson, 2020/08/25
- [PATCH 37/77] target/microblaze: Convert dec_sub to decodetree, Richard Henderson, 2020/08/25
- [PATCH 28/77] target/microblaze: Convert to DisasContextBase, Richard Henderson, 2020/08/25
- [PATCH 31/77] target/microblaze: Remove DISAS_GNU, Richard Henderson, 2020/08/25
- [PATCH 34/77] target/microblaze: Ensure imm constant is always available, Richard Henderson, 2020/08/25
- [PATCH 35/77] target/microblaze: Add decodetree infrastructure, Richard Henderson, 2020/08/25
- [PATCH 38/77] target/microblaze: Implement cmp and cmpu inline,
Richard Henderson <=
- [PATCH 39/77] target/microblaze: Convert dec_pattern to decodetree, Richard Henderson, 2020/08/25
- [PATCH 42/77] target/microblaze: Convert dec_div to decodetree, Richard Henderson, 2020/08/25
- [PATCH 40/77] target/microblaze: Convert dec_and, dec_or, dec_xor to decodetree, Richard Henderson, 2020/08/25
- [PATCH 43/77] target/microblaze: Unwind properly when raising divide-by-zero, Richard Henderson, 2020/08/25
- [PATCH 41/77] target/microblaze: Convert dec_mul to decodetree, Richard Henderson, 2020/08/25
- [PATCH 44/77] target/microblaze: Convert dec_bit to decodetree, Richard Henderson, 2020/08/25
- [PATCH 45/77] target/microblaze: Convert dec_barrel to decodetree, Richard Henderson, 2020/08/25
- [PATCH 47/77] target/microblaze: Convert dec_fpu to decodetree, Richard Henderson, 2020/08/25
- [PATCH 46/77] target/microblaze: Convert dec_imm to decodetree, Richard Henderson, 2020/08/25
- [PATCH 48/77] target/microblaze: Fix cpu unwind for fpu exceptions, Richard Henderson, 2020/08/25