qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: Anthony Green <green@moxielogic.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v8 1/4] Add moxie target code
Date: Tue, 05 Mar 2013 07:38:37 -0800	[thread overview]
Message-ID: <5136117D.7050206@twiddle.net> (raw)
In-Reply-To: <1362400146-24782-2-git-send-email-green@moxielogic.com>

On 03/04/2013 04:29 AM, Anthony Green wrote:
> +void tlb_fill(CPUMoxieState *env, target_ulong addr, int is_write, int mmu_idx,
> +              uintptr_t retaddr)
> +{
> +    int ret;
> +
> +    ret = cpu_moxie_handle_mmu_fault(env, addr, is_write, mmu_idx);
> +    if (unlikely(ret)) {
> +        if (retaddr) {
> +            cpu_restore_state(env, retaddr);
> +        }
> +    }
> +    cpu_loop_exit(env);
> +}
> +
> +void helper_raise_exception(CPUMoxieState *env, uint32_t pc, int ex)
> +{
> +    env->exception_index = ex;
> +    /* Stash the exception type.  */
> +    env->sregs[2] = ex;
> +    /* Stash the address where the exception occurred.  */
> +    env->sregs[5] = pc;
> +    /* Jump the the exception handline routine.  */
> +    env->pc = env->sregs[1];
> +    cpu_loop_exit(env);
> +}

To be fixed later: The cpu_restore_state trick is not exclusive to memory
operations.  Any kind of runtime exception can use it.  Which means...

> +
> +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);
> +        return 0;
> +    }

You need not store to or pass cpu_pc into the division routines.

> +DEF_HELPER_4(div, i32, env, i32, i32, i32)
> +DEF_HELPER_4(udiv, i32, env, i32, i32, i32)

Should use HELPER_FLAGS_4 with TCG_CALL_NO_WG, indicating that the function
does not write to tcg global registers.  (It does read them, via the exception
path.)


r~

  reply	other threads:[~2013-03-05 15:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-04 12:29 [Qemu-devel] [PATCH v8 0/4] Moxie CPU port Anthony Green
2013-03-04 12:29 ` [Qemu-devel] [PATCH v8 1/4] Add moxie target code Anthony Green
2013-03-05 15:38   ` Richard Henderson [this message]
2013-03-04 12:29 ` [Qemu-devel] [PATCH v8 2/4] Add moxie disassembler Anthony Green
2013-03-04 12:29 ` [Qemu-devel] [PATCH v8 3/4] Add sample moxie system Anthony Green
2013-03-04 12:29 ` [Qemu-devel] [PATCH v8 4/4] Add top level changes for moxie Anthony Green
2013-03-07 23:51 ` [Qemu-devel] [PATCH v8 0/4] Moxie CPU port Anthony Green

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=5136117D.7050206@twiddle.net \
    --to=rth@twiddle.net \
    --cc=green@moxielogic.com \
    --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).