All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Mackerras <paulus@ozlabs.org>
To: Balamuruhan S <bala24@linux.ibm.com>
Cc: naveen.n.rao@linux.vnet.ibm.com, linuxppc-dev@lists.ozlabs.org,
	sandipan@linux.ibm.com, ravi.bangoria@linux.ibm.com
Subject: Re: [PATCH 2/3] powerpc sstep: add support for divde[.] and divdeu[.] instructions
Date: Thu, 9 Jan 2020 09:23:14 +1100	[thread overview]
Message-ID: <20200108222314.GA11821@blackberry> (raw)
In-Reply-To: <20191210071904.31013-3-bala24@linux.ibm.com>

On Tue, Dec 10, 2019 at 12:49:03PM +0530, Balamuruhan S wrote:
> This patch adds emulation support for divde, divdeu instructions,
> 	* Divide Doubleword Extended (divde[.])
> 	* Divide Doubleword Extended Unsigned (divdeu[.])
> 
> Signed-off-by: Balamuruhan S <bala24@linux.ibm.com>
> ---
>  arch/powerpc/lib/sstep.c | 27 ++++++++++++++++++++++++++-
>  1 file changed, 26 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
> index c077acb983a1..4b4119729e59 100644
> --- a/arch/powerpc/lib/sstep.c
> +++ b/arch/powerpc/lib/sstep.c
> @@ -1736,7 +1736,32 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
>  			op->val = (int) regs->gpr[ra] /
>  				(int) regs->gpr[rb];
>  			goto arith_done;
> -
> +#ifdef __powerpc64__
> +		case 425:	/* divde[.] */
> +			if (instr & 1) {
> +				asm volatile(PPC_DIVDE_DOT(%0, %1, %2) :
> +					"=r" (op->val) : "r" (regs->gpr[ra]),
> +					"r" (regs->gpr[rb]));
> +				set_cr0(regs, op);

This seems unneccesarily complicated.  You take the trouble to do a
"divde." instruction rather than a "divde" instruction but then don't
use the CR0 setting that the instruction did, but instead go and work
out what happens to CR0 manually in set_cr0().  Also you don't tell
the compiler that CR0 has been modified, which could lead to problems.

This case could be done much more simply like this:



		case 425:	/* divde[.] */
			asm volatile(PPC_DIVDE(%0, %1, %2) :
				"=r" (op->val) : "r" (regs->gpr[ra]),
				"r" (regs->gpr[rb]));
			goto arith_done;

(note, goto arith_done rather than compute_done) and similarly for the
divdeu case.

Paul.

  reply	other threads:[~2020-01-08 22:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-10  7:19 [PATCH 0/3] Add support for divde[.] and divdeu[.] instruction emulation Balamuruhan S
2019-12-10  7:19 ` [PATCH 1/3] powerpc ppc-opcode: add divde, divde_dot, divdeu and divdeu_dot opcodes Balamuruhan S
2019-12-10  7:19 ` [PATCH 2/3] powerpc sstep: add support for divde[.] and divdeu[.] instructions Balamuruhan S
2020-01-08 22:23   ` Paul Mackerras [this message]
2020-01-10  9:44     ` Balamuruhan S
2019-12-10  7:19 ` [PATCH 3/3] powerpc test_emulate_step: add testcases " Balamuruhan S
2020-01-08 10:46 ` [PATCH 0/3] Add support for divde[.] and divdeu[.] instruction emulation Sandipan Das

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=20200108222314.GA11821@blackberry \
    --to=paulus@ozlabs.org \
    --cc=bala24@linux.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=naveen.n.rao@linux.vnet.ibm.com \
    --cc=ravi.bangoria@linux.ibm.com \
    --cc=sandipan@linux.ibm.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.