On 2 March 2013 12:24, Anthony Green <gr...@moxielogic.com> 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

Reply via email to