From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 12/26] target-alpha: Tidy up arithmetic exceptions.
Date: Mon, 23 May 2011 13:28:32 -0700 [thread overview]
Message-ID: <1306182526-12081-13-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1306182526-12081-1-git-send-email-rth@twiddle.net>
Introduce and use arith_excp, filling in the trap_arg[01] IPRs.
Signed-off-by: Richard Henderson <rth@twiddle.net>
---
target-alpha/op_helper.c | 34 +++++++++++++++++++++-------------
1 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/target-alpha/op_helper.c b/target-alpha/op_helper.c
index 73e5805..672940e 100644
--- a/target-alpha/op_helper.c
+++ b/target-alpha/op_helper.c
@@ -32,6 +32,15 @@ void QEMU_NORETURN helper_excp (int excp, int error)
cpu_loop_exit();
}
+static void QEMU_NORETURN arith_excp(int exc, uint64_t mask)
+{
+ env->exception_index = EXCP_ARITH;
+ env->error_code = 0;
+ env->trap_arg0 = exc;
+ env->trap_arg1 = mask;
+ cpu_loop_exit();
+}
+
uint64_t helper_load_pcc (void)
{
/* ??? This isn't a timer for which we have any rate info. */
@@ -53,7 +62,7 @@ uint64_t helper_addqv (uint64_t op1, uint64_t op2)
uint64_t tmp = op1;
op1 += op2;
if (unlikely((tmp ^ op2 ^ (-1ULL)) & (tmp ^ op1) & (1ULL << 63))) {
- helper_excp(EXCP_ARITH, EXC_M_IOV);
+ arith_excp(EXC_M_IOV, 0);
}
return op1;
}
@@ -63,7 +72,7 @@ uint64_t helper_addlv (uint64_t op1, uint64_t op2)
uint64_t tmp = op1;
op1 = (uint32_t)(op1 + op2);
if (unlikely((tmp ^ op2 ^ (-1UL)) & (tmp ^ op1) & (1UL << 31))) {
- helper_excp(EXCP_ARITH, EXC_M_IOV);
+ arith_excp(EXC_M_IOV, 0);
}
return op1;
}
@@ -73,7 +82,7 @@ uint64_t helper_subqv (uint64_t op1, uint64_t op2)
uint64_t res;
res = op1 - op2;
if (unlikely((op1 ^ op2) & (res ^ op1) & (1ULL << 63))) {
- helper_excp(EXCP_ARITH, EXC_M_IOV);
+ arith_excp(EXC_M_IOV, 0);
}
return res;
}
@@ -83,7 +92,7 @@ uint64_t helper_sublv (uint64_t op1, uint64_t op2)
uint32_t res;
res = op1 - op2;
if (unlikely((op1 ^ op2) & (res ^ op1) & (1UL << 31))) {
- helper_excp(EXCP_ARITH, EXC_M_IOV);
+ arith_excp(EXC_M_IOV, 0);
}
return res;
}
@@ -93,7 +102,7 @@ uint64_t helper_mullv (uint64_t op1, uint64_t op2)
int64_t res = (int64_t)op1 * (int64_t)op2;
if (unlikely((int32_t)res != res)) {
- helper_excp(EXCP_ARITH, EXC_M_IOV);
+ arith_excp(EXC_M_IOV, 0);
}
return (int64_t)((int32_t)res);
}
@@ -105,7 +114,7 @@ uint64_t helper_mulqv (uint64_t op1, uint64_t op2)
muls64(&tl, &th, op1, op2);
/* If th != 0 && th != -1, then we had an overflow */
if (unlikely((th + 1) > 1)) {
- helper_excp(EXCP_ARITH, EXC_M_IOV);
+ arith_excp(EXC_M_IOV, 0);
}
return tl;
}
@@ -373,8 +382,6 @@ void helper_fp_exc_raise(uint32_t exc, uint32_t regno)
if (exc) {
uint32_t hw_exc = 0;
- env->trap_arg1 = 1ull << regno;
-
if (exc & float_flag_invalid) {
hw_exc |= EXC_M_INV;
}
@@ -390,7 +397,8 @@ void helper_fp_exc_raise(uint32_t exc, uint32_t regno)
if (exc & float_flag_inexact) {
hw_exc |= EXC_M_INE;
}
- helper_excp(EXCP_ARITH, hw_exc);
+
+ arith_excp(hw_exc, 1ull << regno);
}
}
@@ -420,7 +428,7 @@ uint64_t helper_ieee_input(uint64_t val)
if (env->fpcr_dnz) {
val &= 1ull << 63;
} else {
- helper_excp(EXCP_ARITH, EXC_M_UNF);
+ arith_excp(EXC_M_UNF, 0);
}
}
} else if (exp == 0x7ff) {
@@ -428,7 +436,7 @@ uint64_t helper_ieee_input(uint64_t val)
/* ??? I'm not sure these exception bit flags are correct. I do
know that the Linux kernel, at least, doesn't rely on them and
just emulates the insn to figure out what exception to use. */
- helper_excp(EXCP_ARITH, frac ? EXC_M_INV : EXC_M_FOV);
+ arith_excp(frac ? EXC_M_INV : EXC_M_FOV, 0);
}
return val;
}
@@ -445,12 +453,12 @@ uint64_t helper_ieee_input_cmp(uint64_t val)
if (env->fpcr_dnz) {
val &= 1ull << 63;
} else {
- helper_excp(EXCP_ARITH, EXC_M_UNF);
+ arith_excp(EXC_M_UNF, 0);
}
}
} else if (exp == 0x7ff && frac) {
/* NaN. */
- helper_excp(EXCP_ARITH, EXC_M_INV);
+ arith_excp(EXC_M_INV, 0);
}
return val;
}
--
1.7.4.4
next prev parent reply other threads:[~2011-05-23 20:29 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-23 20:28 [Qemu-devel] [PULL 00/26] Alpha system emulation, v5 Richard Henderson
2011-05-23 20:28 ` [Qemu-devel] [PATCH 01/26] target-alpha: Claim ownership Richard Henderson
2011-05-23 20:28 ` [Qemu-devel] [PATCH 02/26] target-alpha: Disassemble EV6 PALcode instructions Richard Henderson
2011-05-23 20:28 ` [Qemu-devel] [PATCH 03/26] target-alpha: Single-step properly across branches Richard Henderson
2011-05-23 20:28 ` [Qemu-devel] [PATCH 04/26] target-alpha: Remove partial support for palcode emulation Richard Henderson
2011-05-23 20:28 ` [Qemu-devel] [PATCH 05/26] target-alpha: Fix translation of PALmode memory insns Richard Henderson
2011-05-23 20:28 ` [Qemu-devel] [PATCH 06/26] target-alpha: Fix system store_conditional Richard Henderson
2011-05-23 20:28 ` [Qemu-devel] [PATCH 07/26] target-alpha: Cleanup MMU modes Richard Henderson
2011-05-23 20:28 ` [Qemu-devel] [PATCH 08/26] target-alpha: Merge HW_REI and HW_RET implementations Richard Henderson
2011-05-23 20:28 ` [Qemu-devel] [PATCH 09/26] target-alpha: Rationalize internal processor registers Richard Henderson
2011-05-23 20:28 ` [Qemu-devel] [PATCH 10/26] target-alpha: Enable the alpha-softmmu target Richard Henderson
2011-05-23 20:28 ` [Qemu-devel] [PATCH 11/26] target-alpha: Tidy exception constants Richard Henderson
2011-05-23 20:28 ` Richard Henderson [this message]
2011-05-23 20:28 ` [Qemu-devel] [PATCH 13/26] target-alpha: Use do_restore_state for arithmetic exceptions Richard Henderson
2011-05-23 20:28 ` [Qemu-devel] [PATCH 14/26] target-alpha: Add various symbolic constants Richard Henderson
2011-05-23 20:28 ` [Qemu-devel] [PATCH 15/26] target-alpha: Use kernel mmu_idx for pal_mode Richard Henderson
2011-05-23 20:28 ` [Qemu-devel] [PATCH 16/26] target-alpha: Add IPRs to be used by the emulation PALcode Richard Henderson
2011-05-23 20:28 ` [Qemu-devel] [PATCH 17/26] target-alpha: Implement do_interrupt for system mode Richard Henderson
2011-05-23 20:28 ` [Qemu-devel] [PATCH 18/26] target-alpha: Swap shadow registers moving to/from PALmode Richard Henderson
2011-05-23 20:28 ` [Qemu-devel] [PATCH 19/26] target-alpha: All ISA checks to use TB->FLAGS Richard Henderson
2011-05-23 20:28 ` [Qemu-devel] [PATCH 20/26] target-alpha: Disable interrupts properly Richard Henderson
2011-05-23 20:28 ` [Qemu-devel] [PATCH 21/26] target-alpha: Implement more CALL_PAL values inline Richard Henderson
2011-05-23 20:28 ` [Qemu-devel] [PATCH 22/26] target-alpha: Implement cpu_alpha_handle_mmu_fault for system mode Richard Henderson
2011-05-23 20:28 ` [Qemu-devel] [PATCH 23/26] target-alpha: Remap PIO space for 43-bit KSEG for EV6 Richard Henderson
2011-05-23 20:28 ` [Qemu-devel] [PATCH 24/26] target-alpha: Trap for unassigned and unaligned addresses Richard Henderson
2011-05-23 20:28 ` [Qemu-devel] [PATCH 25/26] target-alpha: Use a fixed frequency for the RPCC in system mode Richard Henderson
2011-05-23 20:28 ` [Qemu-devel] [PATCH 26/26] target-alpha: Implement TLB flush primitives Richard Henderson
2011-05-27 19:55 ` [Qemu-devel] [PULL 00/26] Alpha system emulation, v5 Richard Henderson
2011-06-02 14:56 ` Richard Henderson
2011-06-08 19:10 ` Richard Henderson
2011-06-10 20:32 ` Edgar E. Iglesias
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1306182526-12081-13-git-send-email-rth@twiddle.net \
--to=rth@twiddle.net \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).