[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v6 1/4] Add moxie target code
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH v6 1/4] Add moxie target code |
Date: |
Sat, 2 Mar 2013 13:45:18 +0000 |
On 2 March 2013 12:24, Anthony Green <address@hidden> wrote:
> +uint32_t helper_div(CPUMoxieState *env, uint32_t pc, uint32_t a, uint32_t b)
> +{
> + if (unlikely(b == 0)) {
> + helper_raise_exception(env, pc, MOXIE_EX_DIV0);
This never returns, so the following 'return' is unreachable.
> + return 0;
> + }
> + return (int32_t)a / (int32_t)b;
> +}
You need to handle MININT / -1 too, because MININT idiv -1 is
undefined behaviour in C, and we mustn't allow the guest to
cause us to do that. (Does the Moxie architecture spec specify
the result here or does it say it's an unknown value, or does
it cause an exception, or is it genuinely unpredictable?)
Do you have a coherent rationale for what code you are putting
into op_helper.c and what into helper.c? (In most of QEMU's
existing targets the split is purely for historical reasons
since these files used to be compiled differently.)
-- PMM