* [Qemu-devel] [PATCH 1/3] target-unicore32: remove cpu_halted()
@ 2011-04-12 22:31 Aurelien Jarno
2011-04-12 22:31 ` [Qemu-devel] [PATCH 2/3] target-unicore32: move FPU helpers to op_helper.c Aurelien Jarno
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Aurelien Jarno @ 2011-04-12 22:31 UTC (permalink / raw)
To: qemu-devel; +Cc: Guan Xuetao, Aurelien Jarno
cpu_halted() has been removed on all targets in commit
eda48c344f35e5bd511dea3e8be56fb08c19b399. Also remove it on unicore32.
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
target-unicore32/exec.h | 15 ---------------
1 files changed, 0 insertions(+), 15 deletions(-)
diff --git a/target-unicore32/exec.h b/target-unicore32/exec.h
index 4ab55f4..498df23 100644
--- a/target-unicore32/exec.h
+++ b/target-unicore32/exec.h
@@ -32,19 +32,4 @@ static inline int cpu_has_work(CPUState *env)
(CPU_INTERRUPT_HARD | CPU_INTERRUPT_EXITTB);
}
-static inline int cpu_halted(CPUState *env)
-{
- if (!env->halted) {
- return 0;
- }
- /* An interrupt wakes the CPU even if the I and R ASR bits are
- set. We use EXITTB to silently wake CPU without causing an
- actual interrupt. */
- if (cpu_has_work(env)) {
- env->halted = 0;
- return 0;
- }
- return EXCP_HALTED;
-}
-
#endif /* __UC32_EXEC_H__ */
--
1.7.2.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH 2/3] target-unicore32: move FPU helpers to op_helper.c
2011-04-12 22:31 [Qemu-devel] [PATCH 1/3] target-unicore32: remove cpu_halted() Aurelien Jarno
@ 2011-04-12 22:31 ` Aurelien Jarno
2011-04-12 22:31 ` [Qemu-devel] [PATCH 3/3] target-unicore32: mark a few helpers const + pure Aurelien Jarno
2011-04-13 5:42 ` [Qemu-devel] [PATCH 1/3] target-unicore32: remove cpu_halted() Guan Xuetao
2 siblings, 0 replies; 5+ messages in thread
From: Aurelien Jarno @ 2011-04-12 22:31 UTC (permalink / raw)
To: qemu-devel; +Cc: Guan Xuetao, Aurelien Jarno
This patch moves FPU helpers to op_helper.c, which has direct access to
the env pointer. This means one less argument to pass, so a gain in
speed.
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
target-unicore32/helper.c | 329 ------------------------------------------
target-unicore32/helper.h | 36 +++---
target-unicore32/op_helper.c | 329 ++++++++++++++++++++++++++++++++++++++++++
target-unicore32/translate.c | 28 ++--
4 files changed, 361 insertions(+), 361 deletions(-)
diff --git a/target-unicore32/helper.c b/target-unicore32/helper.c
index 483aeae..9b0aae2 100644
--- a/target-unicore32/helper.c
+++ b/target-unicore32/helper.c
@@ -156,332 +156,3 @@ uint32_t HELPER(get_r29_banked)(CPUState *env, uint32_t mode)
return 0;
}
-/* UniCore-F64 support. We follow the convention used for F64 instrunctions:
- Single precition routines have a "s" suffix, double precision a
- "d" suffix. */
-
-/* Convert host exception flags to f64 form. */
-static inline int ucf64_exceptbits_from_host(int host_bits)
-{
- int target_bits = 0;
-
- if (host_bits & float_flag_invalid) {
- target_bits |= UCF64_FPSCR_FLAG_INVALID;
- }
- if (host_bits & float_flag_divbyzero) {
- target_bits |= UCF64_FPSCR_FLAG_DIVZERO;
- }
- if (host_bits & float_flag_overflow) {
- target_bits |= UCF64_FPSCR_FLAG_OVERFLOW;
- }
- if (host_bits & float_flag_underflow) {
- target_bits |= UCF64_FPSCR_FLAG_UNDERFLOW;
- }
- if (host_bits & float_flag_inexact) {
- target_bits |= UCF64_FPSCR_FLAG_INEXACT;
- }
- return target_bits;
-}
-
-uint32_t HELPER(ucf64_get_fpscr)(CPUState *env)
-{
- int i;
- uint32_t fpscr;
-
- fpscr = (env->ucf64.xregs[UC32_UCF64_FPSCR] & UCF64_FPSCR_MASK);
- i = get_float_exception_flags(&env->ucf64.fp_status);
- fpscr |= ucf64_exceptbits_from_host(i);
- return fpscr;
-}
-
-/* Convert ucf64 exception flags to target form. */
-static inline int ucf64_exceptbits_to_host(int target_bits)
-{
- int host_bits = 0;
-
- if (target_bits & UCF64_FPSCR_FLAG_INVALID) {
- host_bits |= float_flag_invalid;
- }
- if (target_bits & UCF64_FPSCR_FLAG_DIVZERO) {
- host_bits |= float_flag_divbyzero;
- }
- if (target_bits & UCF64_FPSCR_FLAG_OVERFLOW) {
- host_bits |= float_flag_overflow;
- }
- if (target_bits & UCF64_FPSCR_FLAG_UNDERFLOW) {
- host_bits |= float_flag_underflow;
- }
- if (target_bits & UCF64_FPSCR_FLAG_INEXACT) {
- host_bits |= float_flag_inexact;
- }
- return host_bits;
-}
-
-void HELPER(ucf64_set_fpscr)(CPUState *env, uint32_t val)
-{
- int i;
- uint32_t changed;
-
- changed = env->ucf64.xregs[UC32_UCF64_FPSCR];
- env->ucf64.xregs[UC32_UCF64_FPSCR] = (val & UCF64_FPSCR_MASK);
-
- changed ^= val;
- if (changed & (UCF64_FPSCR_RND_MASK)) {
- i = UCF64_FPSCR_RND(val);
- switch (i) {
- case 0:
- i = float_round_nearest_even;
- break;
- case 1:
- i = float_round_to_zero;
- break;
- case 2:
- i = float_round_up;
- break;
- case 3:
- i = float_round_down;
- break;
- default: /* 100 and 101 not implement */
- cpu_abort(env, "Unsupported UniCore-F64 round mode");
- }
- set_float_rounding_mode(i, &env->ucf64.fp_status);
- }
-
- i = ucf64_exceptbits_to_host(UCF64_FPSCR_TRAPEN(val));
- set_float_exception_flags(i, &env->ucf64.fp_status);
-}
-
-float32 HELPER(ucf64_adds)(float32 a, float32 b, CPUState *env)
-{
- return float32_add(a, b, &env->ucf64.fp_status);
-}
-
-float64 HELPER(ucf64_addd)(float64 a, float64 b, CPUState *env)
-{
- return float64_add(a, b, &env->ucf64.fp_status);
-}
-
-float32 HELPER(ucf64_subs)(float32 a, float32 b, CPUState *env)
-{
- return float32_sub(a, b, &env->ucf64.fp_status);
-}
-
-float64 HELPER(ucf64_subd)(float64 a, float64 b, CPUState *env)
-{
- return float64_sub(a, b, &env->ucf64.fp_status);
-}
-
-float32 HELPER(ucf64_muls)(float32 a, float32 b, CPUState *env)
-{
- return float32_mul(a, b, &env->ucf64.fp_status);
-}
-
-float64 HELPER(ucf64_muld)(float64 a, float64 b, CPUState *env)
-{
- return float64_mul(a, b, &env->ucf64.fp_status);
-}
-
-float32 HELPER(ucf64_divs)(float32 a, float32 b, CPUState *env)
-{
- return float32_div(a, b, &env->ucf64.fp_status);
-}
-
-float64 HELPER(ucf64_divd)(float64 a, float64 b, CPUState *env)
-{
- return float64_div(a, b, &env->ucf64.fp_status);
-}
-
-float32 HELPER(ucf64_negs)(float32 a)
-{
- return float32_chs(a);
-}
-
-float64 HELPER(ucf64_negd)(float64 a)
-{
- return float64_chs(a);
-}
-
-float32 HELPER(ucf64_abss)(float32 a)
-{
- return float32_abs(a);
-}
-
-float64 HELPER(ucf64_absd)(float64 a)
-{
- return float64_abs(a);
-}
-
-/* XXX: check quiet/signaling case */
-void HELPER(ucf64_cmps)(float32 a, float32 b, uint32_t c, CPUState *env)
-{
- int flag;
- flag = float32_compare_quiet(a, b, &env->ucf64.fp_status);
- env->CF = 0;
- switch (c & 0x7) {
- case 0: /* F */
- break;
- case 1: /* UN */
- if (flag == 2) {
- env->CF = 1;
- }
- break;
- case 2: /* EQ */
- if (flag == 0) {
- env->CF = 1;
- }
- break;
- case 3: /* UEQ */
- if ((flag == 0) || (flag == 2)) {
- env->CF = 1;
- }
- break;
- case 4: /* OLT */
- if (flag == -1) {
- env->CF = 1;
- }
- break;
- case 5: /* ULT */
- if ((flag == -1) || (flag == 2)) {
- env->CF = 1;
- }
- break;
- case 6: /* OLE */
- if ((flag == -1) || (flag == 0)) {
- env->CF = 1;
- }
- break;
- case 7: /* ULE */
- if (flag != 1) {
- env->CF = 1;
- }
- break;
- }
- env->ucf64.xregs[UC32_UCF64_FPSCR] = (env->CF << 29)
- | (env->ucf64.xregs[UC32_UCF64_FPSCR] & 0x0fffffff);
-}
-
-void HELPER(ucf64_cmpd)(float64 a, float64 b, uint32_t c, CPUState *env)
-{
- int flag;
- flag = float64_compare_quiet(a, b, &env->ucf64.fp_status);
- env->CF = 0;
- switch (c & 0x7) {
- case 0: /* F */
- break;
- case 1: /* UN */
- if (flag == 2) {
- env->CF = 1;
- }
- break;
- case 2: /* EQ */
- if (flag == 0) {
- env->CF = 1;
- }
- break;
- case 3: /* UEQ */
- if ((flag == 0) || (flag == 2)) {
- env->CF = 1;
- }
- break;
- case 4: /* OLT */
- if (flag == -1) {
- env->CF = 1;
- }
- break;
- case 5: /* ULT */
- if ((flag == -1) || (flag == 2)) {
- env->CF = 1;
- }
- break;
- case 6: /* OLE */
- if ((flag == -1) || (flag == 0)) {
- env->CF = 1;
- }
- break;
- case 7: /* ULE */
- if (flag != 1) {
- env->CF = 1;
- }
- break;
- }
- env->ucf64.xregs[UC32_UCF64_FPSCR] = (env->CF << 29)
- | (env->ucf64.xregs[UC32_UCF64_FPSCR] & 0x0fffffff);
-}
-
-/* Helper routines to perform bitwise copies between float and int. */
-static inline float32 ucf64_itos(uint32_t i)
-{
- union {
- uint32_t i;
- float32 s;
- } v;
-
- v.i = i;
- return v.s;
-}
-
-static inline uint32_t ucf64_stoi(float32 s)
-{
- union {
- uint32_t i;
- float32 s;
- } v;
-
- v.s = s;
- return v.i;
-}
-
-static inline float64 ucf64_itod(uint64_t i)
-{
- union {
- uint64_t i;
- float64 d;
- } v;
-
- v.i = i;
- return v.d;
-}
-
-static inline uint64_t ucf64_dtoi(float64 d)
-{
- union {
- uint64_t i;
- float64 d;
- } v;
-
- v.d = d;
- return v.i;
-}
-
-/* Integer to float conversion. */
-float32 HELPER(ucf64_si2sf)(float32 x, CPUState *env)
-{
- return int32_to_float32(ucf64_stoi(x), &env->ucf64.fp_status);
-}
-
-float64 HELPER(ucf64_si2df)(float32 x, CPUState *env)
-{
- return int32_to_float64(ucf64_stoi(x), &env->ucf64.fp_status);
-}
-
-/* Float to integer conversion. */
-float32 HELPER(ucf64_sf2si)(float32 x, CPUState *env)
-{
- return ucf64_itos(float32_to_int32(x, &env->ucf64.fp_status));
-}
-
-float32 HELPER(ucf64_df2si)(float64 x, CPUState *env)
-{
- return ucf64_itos(float64_to_int32(x, &env->ucf64.fp_status));
-}
-
-/* floating point conversion */
-float64 HELPER(ucf64_sf2df)(float32 x, CPUState *env)
-{
- return float32_to_float64(x, &env->ucf64.fp_status);
-}
-
-float32 HELPER(ucf64_df2sf)(float64 x, CPUState *env)
-{
- return float64_to_float32(x, &env->ucf64.fp_status);
-}
diff --git a/target-unicore32/helper.h b/target-unicore32/helper.h
index 615de2a..1e45302 100644
--- a/target-unicore32/helper.h
+++ b/target-unicore32/helper.h
@@ -40,31 +40,31 @@ DEF_HELPER_2(ror_cc, i32, i32, i32)
DEF_HELPER_2(get_r29_banked, i32, env, i32)
DEF_HELPER_3(set_r29_banked, void, env, i32, i32)
-DEF_HELPER_1(ucf64_get_fpscr, i32, env)
-DEF_HELPER_2(ucf64_set_fpscr, void, env, i32)
+DEF_HELPER_0(ucf64_get_fpscr, i32)
+DEF_HELPER_1(ucf64_set_fpscr, void, i32)
-DEF_HELPER_3(ucf64_adds, f32, f32, f32, env)
-DEF_HELPER_3(ucf64_addd, f64, f64, f64, env)
-DEF_HELPER_3(ucf64_subs, f32, f32, f32, env)
-DEF_HELPER_3(ucf64_subd, f64, f64, f64, env)
-DEF_HELPER_3(ucf64_muls, f32, f32, f32, env)
-DEF_HELPER_3(ucf64_muld, f64, f64, f64, env)
-DEF_HELPER_3(ucf64_divs, f32, f32, f32, env)
-DEF_HELPER_3(ucf64_divd, f64, f64, f64, env)
+DEF_HELPER_2(ucf64_adds, f32, f32, f32)
+DEF_HELPER_2(ucf64_addd, f64, f64, f64)
+DEF_HELPER_2(ucf64_subs, f32, f32, f32)
+DEF_HELPER_2(ucf64_subd, f64, f64, f64)
+DEF_HELPER_2(ucf64_muls, f32, f32, f32)
+DEF_HELPER_2(ucf64_muld, f64, f64, f64)
+DEF_HELPER_2(ucf64_divs, f32, f32, f32)
+DEF_HELPER_2(ucf64_divd, f64, f64, f64)
DEF_HELPER_1(ucf64_negs, f32, f32)
DEF_HELPER_1(ucf64_negd, f64, f64)
DEF_HELPER_1(ucf64_abss, f32, f32)
DEF_HELPER_1(ucf64_absd, f64, f64)
-DEF_HELPER_4(ucf64_cmps, void, f32, f32, i32, env)
-DEF_HELPER_4(ucf64_cmpd, void, f64, f64, i32, env)
+DEF_HELPER_3(ucf64_cmps, void, f32, f32, i32)
+DEF_HELPER_3(ucf64_cmpd, void, f64, f64, i32)
-DEF_HELPER_2(ucf64_sf2df, f64, f32, env)
-DEF_HELPER_2(ucf64_df2sf, f32, f64, env)
+DEF_HELPER_1(ucf64_sf2df, f64, f32)
+DEF_HELPER_1(ucf64_df2sf, f32, f64)
-DEF_HELPER_2(ucf64_si2sf, f32, f32, env)
-DEF_HELPER_2(ucf64_si2df, f64, f32, env)
+DEF_HELPER_1(ucf64_si2sf, f32, f32)
+DEF_HELPER_1(ucf64_si2df, f64, f32)
-DEF_HELPER_2(ucf64_sf2si, f32, f32, env)
-DEF_HELPER_2(ucf64_df2si, f32, f64, env)
+DEF_HELPER_1(ucf64_sf2si, f32, f32)
+DEF_HELPER_1(ucf64_df2si, f32, f64)
#include "def-helper.h"
diff --git a/target-unicore32/op_helper.c b/target-unicore32/op_helper.c
index 31e4b11..722523a 100644
--- a/target-unicore32/op_helper.c
+++ b/target-unicore32/op_helper.c
@@ -246,3 +246,332 @@ uint32_t HELPER(ror_cc)(uint32_t x, uint32_t i)
return ((uint32_t)x >> shift) | (x << (32 - shift));
}
}
+
+/* UniCore-F64 support. We follow the convention used for F64 instrunctions:
+ Single precition routines have a "s" suffix, double precision a
+ "d" suffix. */
+
+/* Convert host exception flags to f64 form. */
+static inline int ucf64_exceptbits_from_host(int host_bits)
+{
+ int target_bits = 0;
+
+ if (host_bits & float_flag_invalid) {
+ target_bits |= UCF64_FPSCR_FLAG_INVALID;
+ }
+ if (host_bits & float_flag_divbyzero) {
+ target_bits |= UCF64_FPSCR_FLAG_DIVZERO;
+ }
+ if (host_bits & float_flag_overflow) {
+ target_bits |= UCF64_FPSCR_FLAG_OVERFLOW;
+ }
+ if (host_bits & float_flag_underflow) {
+ target_bits |= UCF64_FPSCR_FLAG_UNDERFLOW;
+ }
+ if (host_bits & float_flag_inexact) {
+ target_bits |= UCF64_FPSCR_FLAG_INEXACT;
+ }
+ return target_bits;
+}
+
+uint32_t HELPER(ucf64_get_fpscr)(void)
+{
+ int i;
+ uint32_t fpscr;
+
+ fpscr = (env->ucf64.xregs[UC32_UCF64_FPSCR] & UCF64_FPSCR_MASK);
+ i = get_float_exception_flags(&env->ucf64.fp_status);
+ fpscr |= ucf64_exceptbits_from_host(i);
+ return fpscr;
+}
+
+/* Convert ucf64 exception flags to target form. */
+static inline int ucf64_exceptbits_to_host(int target_bits)
+{
+ int host_bits = 0;
+
+ if (target_bits & UCF64_FPSCR_FLAG_INVALID) {
+ host_bits |= float_flag_invalid;
+ }
+ if (target_bits & UCF64_FPSCR_FLAG_DIVZERO) {
+ host_bits |= float_flag_divbyzero;
+ }
+ if (target_bits & UCF64_FPSCR_FLAG_OVERFLOW) {
+ host_bits |= float_flag_overflow;
+ }
+ if (target_bits & UCF64_FPSCR_FLAG_UNDERFLOW) {
+ host_bits |= float_flag_underflow;
+ }
+ if (target_bits & UCF64_FPSCR_FLAG_INEXACT) {
+ host_bits |= float_flag_inexact;
+ }
+ return host_bits;
+}
+
+void HELPER(ucf64_set_fpscr)(uint32_t val)
+{
+ int i;
+ uint32_t changed;
+
+ changed = env->ucf64.xregs[UC32_UCF64_FPSCR];
+ env->ucf64.xregs[UC32_UCF64_FPSCR] = (val & UCF64_FPSCR_MASK);
+
+ changed ^= val;
+ if (changed & (UCF64_FPSCR_RND_MASK)) {
+ i = UCF64_FPSCR_RND(val);
+ switch (i) {
+ case 0:
+ i = float_round_nearest_even;
+ break;
+ case 1:
+ i = float_round_to_zero;
+ break;
+ case 2:
+ i = float_round_up;
+ break;
+ case 3:
+ i = float_round_down;
+ break;
+ default: /* 100 and 101 not implement */
+ cpu_abort(env, "Unsupported UniCore-F64 round mode");
+ }
+ set_float_rounding_mode(i, &env->ucf64.fp_status);
+ }
+
+ i = ucf64_exceptbits_to_host(UCF64_FPSCR_TRAPEN(val));
+ set_float_exception_flags(i, &env->ucf64.fp_status);
+}
+
+float32 HELPER(ucf64_adds)(float32 a, float32 b)
+{
+ return float32_add(a, b, &env->ucf64.fp_status);
+}
+
+float64 HELPER(ucf64_addd)(float64 a, float64 b)
+{
+ return float64_add(a, b, &env->ucf64.fp_status);
+}
+
+float32 HELPER(ucf64_subs)(float32 a, float32 b)
+{
+ return float32_sub(a, b, &env->ucf64.fp_status);
+}
+
+float64 HELPER(ucf64_subd)(float64 a, float64 b)
+{
+ return float64_sub(a, b, &env->ucf64.fp_status);
+}
+
+float32 HELPER(ucf64_muls)(float32 a, float32 b)
+{
+ return float32_mul(a, b, &env->ucf64.fp_status);
+}
+
+float64 HELPER(ucf64_muld)(float64 a, float64 b)
+{
+ return float64_mul(a, b, &env->ucf64.fp_status);
+}
+
+float32 HELPER(ucf64_divs)(float32 a, float32 b)
+{
+ return float32_div(a, b, &env->ucf64.fp_status);
+}
+
+float64 HELPER(ucf64_divd)(float64 a, float64 b)
+{
+ return float64_div(a, b, &env->ucf64.fp_status);
+}
+
+float32 HELPER(ucf64_negs)(float32 a)
+{
+ return float32_chs(a);
+}
+
+float64 HELPER(ucf64_negd)(float64 a)
+{
+ return float64_chs(a);
+}
+
+float32 HELPER(ucf64_abss)(float32 a)
+{
+ return float32_abs(a);
+}
+
+float64 HELPER(ucf64_absd)(float64 a)
+{
+ return float64_abs(a);
+}
+
+/* XXX: check quiet/signaling case */
+void HELPER(ucf64_cmps)(float32 a, float32 b, uint32_t c)
+{
+ int flag;
+ flag = float32_compare_quiet(a, b, &env->ucf64.fp_status);
+ env->CF = 0;
+ switch (c & 0x7) {
+ case 0: /* F */
+ break;
+ case 1: /* UN */
+ if (flag == 2) {
+ env->CF = 1;
+ }
+ break;
+ case 2: /* EQ */
+ if (flag == 0) {
+ env->CF = 1;
+ }
+ break;
+ case 3: /* UEQ */
+ if ((flag == 0) || (flag == 2)) {
+ env->CF = 1;
+ }
+ break;
+ case 4: /* OLT */
+ if (flag == -1) {
+ env->CF = 1;
+ }
+ break;
+ case 5: /* ULT */
+ if ((flag == -1) || (flag == 2)) {
+ env->CF = 1;
+ }
+ break;
+ case 6: /* OLE */
+ if ((flag == -1) || (flag == 0)) {
+ env->CF = 1;
+ }
+ break;
+ case 7: /* ULE */
+ if (flag != 1) {
+ env->CF = 1;
+ }
+ break;
+ }
+ env->ucf64.xregs[UC32_UCF64_FPSCR] = (env->CF << 29)
+ | (env->ucf64.xregs[UC32_UCF64_FPSCR] & 0x0fffffff);
+}
+
+void HELPER(ucf64_cmpd)(float64 a, float64 b, uint32_t c)
+{
+ int flag;
+ flag = float64_compare_quiet(a, b, &env->ucf64.fp_status);
+ env->CF = 0;
+ switch (c & 0x7) {
+ case 0: /* F */
+ break;
+ case 1: /* UN */
+ if (flag == 2) {
+ env->CF = 1;
+ }
+ break;
+ case 2: /* EQ */
+ if (flag == 0) {
+ env->CF = 1;
+ }
+ break;
+ case 3: /* UEQ */
+ if ((flag == 0) || (flag == 2)) {
+ env->CF = 1;
+ }
+ break;
+ case 4: /* OLT */
+ if (flag == -1) {
+ env->CF = 1;
+ }
+ break;
+ case 5: /* ULT */
+ if ((flag == -1) || (flag == 2)) {
+ env->CF = 1;
+ }
+ break;
+ case 6: /* OLE */
+ if ((flag == -1) || (flag == 0)) {
+ env->CF = 1;
+ }
+ break;
+ case 7: /* ULE */
+ if (flag != 1) {
+ env->CF = 1;
+ }
+ break;
+ }
+ env->ucf64.xregs[UC32_UCF64_FPSCR] = (env->CF << 29)
+ | (env->ucf64.xregs[UC32_UCF64_FPSCR] & 0x0fffffff);
+}
+/* Helper routines to perform bitwise copies between float and int. */
+static inline float32 ucf64_itos(uint32_t i)
+{
+ union {
+ uint32_t i;
+ float32 s;
+ } v;
+
+ v.i = i;
+ return v.s;
+}
+
+static inline uint32_t ucf64_stoi(float32 s)
+{
+ union {
+ uint32_t i;
+ float32 s;
+ } v;
+
+ v.s = s;
+ return v.i;
+}
+
+static inline float64 ucf64_itod(uint64_t i)
+{
+ union {
+ uint64_t i;
+ float64 d;
+ } v;
+
+ v.i = i;
+ return v.d;
+}
+
+static inline uint64_t ucf64_dtoi(float64 d)
+{
+ union {
+ uint64_t i;
+ float64 d;
+ } v;
+
+ v.d = d;
+ return v.i;
+}
+
+/* Integer to float conversion. */
+float32 HELPER(ucf64_si2sf)(float32 x)
+{
+ return int32_to_float32(ucf64_stoi(x), &env->ucf64.fp_status);
+}
+
+float64 HELPER(ucf64_si2df)(float32 x)
+{
+ return int32_to_float64(ucf64_stoi(x), &env->ucf64.fp_status);
+}
+
+/* Float to integer conversion. */
+float32 HELPER(ucf64_sf2si)(float32 x)
+{
+ return ucf64_itos(float32_to_int32(x, &env->ucf64.fp_status));
+}
+
+float32 HELPER(ucf64_df2si)(float64 x)
+{
+ return ucf64_itos(float64_to_int32(x, &env->ucf64.fp_status));
+}
+
+/* floating point conversion */
+float64 HELPER(ucf64_sf2df)(float32 x)
+{
+ return float32_to_float64(x, &env->ucf64.fp_status);
+}
+
+float32 HELPER(ucf64_df2sf)(float64 x)
+{
+ return float64_to_float32(x, &env->ucf64.fp_status);
+}
diff --git a/target-unicore32/translate.c b/target-unicore32/translate.c
index a6ba991..281b494 100644
--- a/target-unicore32/translate.c
+++ b/target-unicore32/translate.c
@@ -790,12 +790,12 @@ static void do_ucf64_trans(CPUState *env, DisasContext *s, uint32_t insn)
if (UCOP_SET(24)) {
/* CFF */
tmp = new_tmp();
- gen_helper_ucf64_get_fpscr(tmp, cpu_env);
+ gen_helper_ucf64_get_fpscr(tmp);
store_reg(s, UCOP_REG_D, tmp);
} else {
/* CTF */
tmp = load_reg(s, UCOP_REG_D);
- gen_helper_ucf64_set_fpscr(cpu_env, tmp);
+ gen_helper_ucf64_set_fpscr(tmp);
dead_tmp(tmp);
gen_lookup_tb(s);
}
@@ -829,11 +829,11 @@ static void do_ucf64_trans(CPUState *env, DisasContext *s, uint32_t insn)
if (UCOP_SET(26)) {
tcg_gen_ld_i64(cpu_F0d, cpu_env, ucf64_reg_offset(UCOP_REG_N));
tcg_gen_ld_i64(cpu_F1d, cpu_env, ucf64_reg_offset(UCOP_REG_M));
- gen_helper_ucf64_cmpd(cpu_F0d, cpu_F1d, tmp, cpu_env);
+ gen_helper_ucf64_cmpd(cpu_F0d, cpu_F1d, tmp);
} else {
tcg_gen_ld_i32(cpu_F0s, cpu_env, ucf64_reg_offset(UCOP_REG_N));
tcg_gen_ld_i32(cpu_F1s, cpu_env, ucf64_reg_offset(UCOP_REG_M));
- gen_helper_ucf64_cmps(cpu_F0s, cpu_F1s, tmp, cpu_env);
+ gen_helper_ucf64_cmps(cpu_F0s, cpu_F1s, tmp);
}
dead_tmp(tmp);
return;
@@ -855,12 +855,12 @@ static void do_ucf64_fcvt(CPUState *env, DisasContext *s, uint32_t insn)
switch (UCOP_UCF64_FMT) {
case 1 /* d */:
tcg_gen_ld_i64(cpu_F0d, cpu_env, ucf64_reg_offset(UCOP_REG_M));
- gen_helper_ucf64_df2sf(cpu_F0s, cpu_F0d, cpu_env);
+ gen_helper_ucf64_df2sf(cpu_F0s, cpu_F0d);
tcg_gen_st_i32(cpu_F0s, cpu_env, ucf64_reg_offset(UCOP_REG_D));
break;
case 2 /* w */:
tcg_gen_ld_i32(cpu_F0s, cpu_env, ucf64_reg_offset(UCOP_REG_M));
- gen_helper_ucf64_si2sf(cpu_F0s, cpu_F0s, cpu_env);
+ gen_helper_ucf64_si2sf(cpu_F0s, cpu_F0s);
tcg_gen_st_i32(cpu_F0s, cpu_env, ucf64_reg_offset(UCOP_REG_D));
break;
default /* s */:
@@ -872,12 +872,12 @@ static void do_ucf64_fcvt(CPUState *env, DisasContext *s, uint32_t insn)
switch (UCOP_UCF64_FMT) {
case 0 /* s */:
tcg_gen_ld_i32(cpu_F0s, cpu_env, ucf64_reg_offset(UCOP_REG_M));
- gen_helper_ucf64_sf2df(cpu_F0d, cpu_F0s, cpu_env);
+ gen_helper_ucf64_sf2df(cpu_F0d, cpu_F0s);
tcg_gen_st_i64(cpu_F0d, cpu_env, ucf64_reg_offset(UCOP_REG_D));
break;
case 2 /* w */:
tcg_gen_ld_i32(cpu_F0s, cpu_env, ucf64_reg_offset(UCOP_REG_M));
- gen_helper_ucf64_si2df(cpu_F0d, cpu_F0s, cpu_env);
+ gen_helper_ucf64_si2df(cpu_F0d, cpu_F0s);
tcg_gen_st_i64(cpu_F0d, cpu_env, ucf64_reg_offset(UCOP_REG_D));
break;
default /* d */:
@@ -889,12 +889,12 @@ static void do_ucf64_fcvt(CPUState *env, DisasContext *s, uint32_t insn)
switch (UCOP_UCF64_FMT) {
case 0 /* s */:
tcg_gen_ld_i32(cpu_F0s, cpu_env, ucf64_reg_offset(UCOP_REG_M));
- gen_helper_ucf64_sf2si(cpu_F0s, cpu_F0s, cpu_env);
+ gen_helper_ucf64_sf2si(cpu_F0s, cpu_F0s);
tcg_gen_st_i32(cpu_F0s, cpu_env, ucf64_reg_offset(UCOP_REG_D));
break;
case 1 /* d */:
tcg_gen_ld_i64(cpu_F0d, cpu_env, ucf64_reg_offset(UCOP_REG_M));
- gen_helper_ucf64_df2si(cpu_F0s, cpu_F0d, cpu_env);
+ gen_helper_ucf64_df2si(cpu_F0s, cpu_F0d);
tcg_gen_st_i32(cpu_F0s, cpu_env, ucf64_reg_offset(UCOP_REG_D));
break;
default /* w */:
@@ -921,11 +921,11 @@ static void do_ucf64_fcmp(CPUState *env, DisasContext *s, uint32_t insn)
if (UCOP_SET(24)) {
tcg_gen_ld_i64(cpu_F0d, cpu_env, ucf64_reg_offset(UCOP_REG_N));
tcg_gen_ld_i64(cpu_F1d, cpu_env, ucf64_reg_offset(UCOP_REG_M));
- /* gen_helper_ucf64_cmpd(cpu_F0d, cpu_F1d, cpu_env); */
+ /* gen_helper_ucf64_cmpd(cpu_F0d, cpu_F1d); */
} else {
tcg_gen_ld_i32(cpu_F0s, cpu_env, ucf64_reg_offset(UCOP_REG_N));
tcg_gen_ld_i32(cpu_F1s, cpu_env, ucf64_reg_offset(UCOP_REG_M));
- /* gen_helper_ucf64_cmps(cpu_F0s, cpu_F1s, cpu_env); */
+ /* gen_helper_ucf64_cmps(cpu_F0s, cpu_F1s); */
}
}
@@ -965,7 +965,7 @@ static void do_ucf64_fcmp(CPUState *env, DisasContext *s, uint32_t insn)
tcg_gen_ld_i32(cpu_F1s, cpu_env, \
ucf64_reg_offset(UCOP_REG_M)); \
gen_helper_ucf64_##name##s(cpu_F0s, \
- cpu_F0s, cpu_F1s, cpu_env); \
+ cpu_F0s, cpu_F1s); \
tcg_gen_st_i32(cpu_F0s, cpu_env, \
ucf64_reg_offset(UCOP_REG_D)); \
break; \
@@ -975,7 +975,7 @@ static void do_ucf64_fcmp(CPUState *env, DisasContext *s, uint32_t insn)
tcg_gen_ld_i64(cpu_F1d, cpu_env, \
ucf64_reg_offset(UCOP_REG_M)); \
gen_helper_ucf64_##name##d(cpu_F0d, \
- cpu_F0d, cpu_F1d, cpu_env); \
+ cpu_F0d, cpu_F1d); \
tcg_gen_st_i64(cpu_F0d, cpu_env, \
ucf64_reg_offset(UCOP_REG_D)); \
break; \
--
1.7.2.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH 3/3] target-unicore32: mark a few helpers const + pure
2011-04-12 22:31 [Qemu-devel] [PATCH 1/3] target-unicore32: remove cpu_halted() Aurelien Jarno
2011-04-12 22:31 ` [Qemu-devel] [PATCH 2/3] target-unicore32: move FPU helpers to op_helper.c Aurelien Jarno
@ 2011-04-12 22:31 ` Aurelien Jarno
2011-04-13 6:03 ` Guan Xuetao
2011-04-13 5:42 ` [Qemu-devel] [PATCH 1/3] target-unicore32: remove cpu_halted() Guan Xuetao
2 siblings, 1 reply; 5+ messages in thread
From: Aurelien Jarno @ 2011-04-12 22:31 UTC (permalink / raw)
To: qemu-devel; +Cc: Guan Xuetao, Aurelien Jarno
Helpers that do not trigger exceptions and do only access to the arguments
can be declared as const + pure.
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
target-unicore32/helper.h | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/target-unicore32/helper.h b/target-unicore32/helper.h
index 1e45302..4f8b5d7 100644
--- a/target-unicore32/helper.h
+++ b/target-unicore32/helper.h
@@ -29,9 +29,9 @@ DEF_HELPER_2(adc_cc, i32, i32, i32)
DEF_HELPER_2(sub_cc, i32, i32, i32)
DEF_HELPER_2(sbc_cc, i32, i32, i32)
-DEF_HELPER_2(shl, i32, i32, i32)
-DEF_HELPER_2(shr, i32, i32, i32)
-DEF_HELPER_2(sar, i32, i32, i32)
+DEF_HELPER_FLAGS_2(shl, TCG_CALL_CONST | TCG_CALL_PURE, i32, i32, i32)
+DEF_HELPER_FLAGS_2(shr, TCG_CALL_CONST | TCG_CALL_PURE, i32, i32, i32)
+DEF_HELPER_FLAGS_2(sar, TCG_CALL_CONST | TCG_CALL_PURE, i32, i32, i32)
DEF_HELPER_2(shl_cc, i32, i32, i32)
DEF_HELPER_2(shr_cc, i32, i32, i32)
DEF_HELPER_2(sar_cc, i32, i32, i32)
@@ -51,10 +51,10 @@ DEF_HELPER_2(ucf64_muls, f32, f32, f32)
DEF_HELPER_2(ucf64_muld, f64, f64, f64)
DEF_HELPER_2(ucf64_divs, f32, f32, f32)
DEF_HELPER_2(ucf64_divd, f64, f64, f64)
-DEF_HELPER_1(ucf64_negs, f32, f32)
-DEF_HELPER_1(ucf64_negd, f64, f64)
-DEF_HELPER_1(ucf64_abss, f32, f32)
-DEF_HELPER_1(ucf64_absd, f64, f64)
+DEF_HELPER_FLAGS_1(ucf64_negs, TCG_CALL_CONST | TCG_CALL_PURE, f32, f32)
+DEF_HELPER_FLAGS_1(ucf64_negd, TCG_CALL_CONST | TCG_CALL_PURE, f64, f64)
+DEF_HELPER_FLAGS_1(ucf64_abss, TCG_CALL_CONST | TCG_CALL_PURE, f32, f32)
+DEF_HELPER_FLAGS_1(ucf64_absd, TCG_CALL_CONST | TCG_CALL_PURE, f64, f64)
DEF_HELPER_3(ucf64_cmps, void, f32, f32, i32)
DEF_HELPER_3(ucf64_cmpd, void, f64, f64, i32)
--
1.7.2.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] target-unicore32: remove cpu_halted()
2011-04-12 22:31 [Qemu-devel] [PATCH 1/3] target-unicore32: remove cpu_halted() Aurelien Jarno
2011-04-12 22:31 ` [Qemu-devel] [PATCH 2/3] target-unicore32: move FPU helpers to op_helper.c Aurelien Jarno
2011-04-12 22:31 ` [Qemu-devel] [PATCH 3/3] target-unicore32: mark a few helpers const + pure Aurelien Jarno
@ 2011-04-13 5:42 ` Guan Xuetao
2 siblings, 0 replies; 5+ messages in thread
From: Guan Xuetao @ 2011-04-13 5:42 UTC (permalink / raw)
To: 'Aurelien Jarno', qemu-devel
Applied.
Thanks.
Guan Xuetao
> -----Original Message-----
> From: Aurelien Jarno [mailto:aurelien@aurel32.net]
> Sent: Wednesday, April 13, 2011 6:31 AM
> To: qemu-devel@nongnu.org
> Cc: Aurelien Jarno; Guan Xuetao
> Subject: [PATCH 1/3] target-unicore32: remove cpu_halted()
>
> cpu_halted() has been removed on all targets in commit
> eda48c344f35e5bd511dea3e8be56fb08c19b399. Also remove it on unicore32.
>
> Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> ---
> target-unicore32/exec.h | 15 ---------------
> 1 files changed, 0 insertions(+), 15 deletions(-)
>
> diff --git a/target-unicore32/exec.h b/target-unicore32/exec.h
> index 4ab55f4..498df23 100644
> --- a/target-unicore32/exec.h
> +++ b/target-unicore32/exec.h
> @@ -32,19 +32,4 @@ static inline int cpu_has_work(CPUState *env)
> (CPU_INTERRUPT_HARD | CPU_INTERRUPT_EXITTB);
> }
>
> -static inline int cpu_halted(CPUState *env)
> -{
> - if (!env->halted) {
> - return 0;
> - }
> - /* An interrupt wakes the CPU even if the I and R ASR bits are
> - set. We use EXITTB to silently wake CPU without causing an
> - actual interrupt. */
> - if (cpu_has_work(env)) {
> - env->halted = 0;
> - return 0;
> - }
> - return EXCP_HALTED;
> -}
> -
> #endif /* __UC32_EXEC_H__ */
> --
> 1.7.2.3
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] target-unicore32: mark a few helpers const + pure
2011-04-12 22:31 ` [Qemu-devel] [PATCH 3/3] target-unicore32: mark a few helpers const + pure Aurelien Jarno
@ 2011-04-13 6:03 ` Guan Xuetao
0 siblings, 0 replies; 5+ messages in thread
From: Guan Xuetao @ 2011-04-13 6:03 UTC (permalink / raw)
To: 'Aurelien Jarno', qemu-devel
Applied, thanks.
Tested-and-Acked-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Guan
> -----Original Message-----
> From: Aurelien Jarno [mailto:aurelien@aurel32.net]
> Sent: Wednesday, April 13, 2011 6:31 AM
> To: qemu-devel@nongnu.org
> Cc: Aurelien Jarno; Guan Xuetao
> Subject: [PATCH 3/3] target-unicore32: mark a few helpers const + pure
>
> Helpers that do not trigger exceptions and do only access to the arguments
> can be declared as const + pure.
>
> Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> ---
> target-unicore32/helper.h | 14 +++++++-------
> 1 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/target-unicore32/helper.h b/target-unicore32/helper.h
> index 1e45302..4f8b5d7 100644
> --- a/target-unicore32/helper.h
> +++ b/target-unicore32/helper.h
> @@ -29,9 +29,9 @@ DEF_HELPER_2(adc_cc, i32, i32, i32)
> DEF_HELPER_2(sub_cc, i32, i32, i32)
> DEF_HELPER_2(sbc_cc, i32, i32, i32)
>
> -DEF_HELPER_2(shl, i32, i32, i32)
> -DEF_HELPER_2(shr, i32, i32, i32)
> -DEF_HELPER_2(sar, i32, i32, i32)
> +DEF_HELPER_FLAGS_2(shl, TCG_CALL_CONST | TCG_CALL_PURE, i32, i32, i32)
> +DEF_HELPER_FLAGS_2(shr, TCG_CALL_CONST | TCG_CALL_PURE, i32, i32, i32)
> +DEF_HELPER_FLAGS_2(sar, TCG_CALL_CONST | TCG_CALL_PURE, i32, i32, i32)
> DEF_HELPER_2(shl_cc, i32, i32, i32)
> DEF_HELPER_2(shr_cc, i32, i32, i32)
> DEF_HELPER_2(sar_cc, i32, i32, i32)
> @@ -51,10 +51,10 @@ DEF_HELPER_2(ucf64_muls, f32, f32, f32)
> DEF_HELPER_2(ucf64_muld, f64, f64, f64)
> DEF_HELPER_2(ucf64_divs, f32, f32, f32)
> DEF_HELPER_2(ucf64_divd, f64, f64, f64)
> -DEF_HELPER_1(ucf64_negs, f32, f32)
> -DEF_HELPER_1(ucf64_negd, f64, f64)
> -DEF_HELPER_1(ucf64_abss, f32, f32)
> -DEF_HELPER_1(ucf64_absd, f64, f64)
> +DEF_HELPER_FLAGS_1(ucf64_negs, TCG_CALL_CONST | TCG_CALL_PURE, f32, f32)
> +DEF_HELPER_FLAGS_1(ucf64_negd, TCG_CALL_CONST | TCG_CALL_PURE, f64, f64)
> +DEF_HELPER_FLAGS_1(ucf64_abss, TCG_CALL_CONST | TCG_CALL_PURE, f32, f32)
> +DEF_HELPER_FLAGS_1(ucf64_absd, TCG_CALL_CONST | TCG_CALL_PURE, f64, f64)
> DEF_HELPER_3(ucf64_cmps, void, f32, f32, i32)
> DEF_HELPER_3(ucf64_cmpd, void, f64, f64, i32)
>
> --
> 1.7.2.3
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-04-13 6:05 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-12 22:31 [Qemu-devel] [PATCH 1/3] target-unicore32: remove cpu_halted() Aurelien Jarno
2011-04-12 22:31 ` [Qemu-devel] [PATCH 2/3] target-unicore32: move FPU helpers to op_helper.c Aurelien Jarno
2011-04-12 22:31 ` [Qemu-devel] [PATCH 3/3] target-unicore32: mark a few helpers const + pure Aurelien Jarno
2011-04-13 6:03 ` Guan Xuetao
2011-04-13 5:42 ` [Qemu-devel] [PATCH 1/3] target-unicore32: remove cpu_halted() Guan Xuetao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).