public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Michael Ellerman <mpe@ellerman•id.au>
To: Sandipan Das <sandipan@linux•ibm.com>
Cc: paulus@samba•org, naveen.n.rao@linux•vnet.ibm.com,
	linuxppc-dev@lists•ozlabs.org, anton@samba•org,
	ravi.bangoria@linux•ibm.com
Subject: Re: [PATCH 1/6] powerpc sstep: Add maddhd, maddhdu, maddld instruction emulation
Date: Wed, 20 Feb 2019 11:51:52 +1100	[thread overview]
Message-ID: <871s438eon.fsf@concordia.ellerman.id.au> (raw)
In-Reply-To: <2962112510464de01b24f9e1014909fde3380d52.1535609090.git.sandipan@linux.ibm.com>

Sandipan Das <sandipan@linux•ibm.com> writes:

> This adds emulation support for the following integer instructions:
>   * Multiply-Add High Doubleword (maddhd)
>   * Multiply-Add High Doubleword Unsigned (maddhdu)
>   * Multiply-Add Low Doubleword (maddld)

This doesn't build with old binutils.

    {standard input}:2089: Error: Unrecognized opcode: `maddld'
    {standard input}:2104: Error: Unrecognized opcode: `maddhdu'
    {standard input}:1141: Error: Unrecognized opcode: `maddhd'


You'll need to add hand built versions, see ppc-opcode.h for examples.

cheers

> diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
> index d81568f783e5..b40ec18515bd 100644
> --- a/arch/powerpc/lib/sstep.c
> +++ b/arch/powerpc/lib/sstep.c
> @@ -1169,7 +1169,7 @@ static nokprobe_inline int trap_compare(long v1, long v2)
>  int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
>  		  unsigned int instr)
>  {
> -	unsigned int opcode, ra, rb, rd, spr, u;
> +	unsigned int opcode, ra, rb, rc, rd, spr, u;
>  	unsigned long int imm;
>  	unsigned long int val, val2;
>  	unsigned int mb, me, sh;
> @@ -1292,6 +1292,7 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
>  	rd = (instr >> 21) & 0x1f;
>  	ra = (instr >> 16) & 0x1f;
>  	rb = (instr >> 11) & 0x1f;
> +	rc = (instr >> 6) & 0x1f;
>  
>  	switch (opcode) {
>  #ifdef __powerpc64__
> @@ -1305,6 +1306,38 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
>  			goto trap;
>  		return 1;
>  
> +#ifdef __powerpc64__
> +	case 4:
> +		if (!cpu_has_feature(CPU_FTR_ARCH_300))
> +			return -1;
> +
> +		switch (instr & 0x3f) {
> +		case 48:	/* maddhd */
> +			asm("maddhd %0,%1,%2,%3" : "=r" (op->val) :
> +			    "r" (regs->gpr[ra]), "r" (regs->gpr[rb]),
> +			    "r" (regs->gpr[rc]));
> +			goto compute_done;
> +
> +		case 49:	/* maddhdu */
> +			asm("maddhdu %0,%1,%2,%3" : "=r" (op->val) :
> +			    "r" (regs->gpr[ra]), "r" (regs->gpr[rb]),
> +			    "r" (regs->gpr[rc]));
> +			goto compute_done;
> +
> +		case 51:	/* maddld */
> +			asm("maddld %0,%1,%2,%3" : "=r" (op->val) :
> +			    "r" (regs->gpr[ra]), "r" (regs->gpr[rb]),
> +			    "r" (regs->gpr[rc]));
> +			goto compute_done;
> +		}
> +
> +		/*
> +		 * There are other instructions from ISA 3.0 with the same
> +		 * primary opcode which do not have emulation support yet.
> +		 */
> +		return -1;
> +#endif
> +
>  	case 7:		/* mulli */
>  		op->val = regs->gpr[ra] * (short) instr;
>  		goto compute_done;
> -- 
> 2.14.4

  parent reply	other threads:[~2019-02-20  0:53 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-03 15:19 [PATCH 0/6] powerpc sstep: Extend instruction emulation support Sandipan Das
2018-09-03 15:19 ` [PATCH 1/6] powerpc sstep: Add maddhd, maddhdu, maddld instruction emulation Sandipan Das
2018-09-04 22:12   ` Segher Boessenkool
2018-09-05 11:30     ` Sandipan Das
2019-02-20  0:51   ` Michael Ellerman [this message]
2018-09-03 15:19 ` [PATCH 2/6] powerpc sstep: Add darn " Sandipan Das
2019-02-20  0:50   ` Michael Ellerman
2019-02-20  9:49     ` Sandipan Das
2018-09-03 15:19 ` [PATCH 3/6] powerpc sstep: Add cnttzw, cnttzd " Sandipan Das
2018-09-04 21:12   ` Segher Boessenkool
2018-09-05  6:36     ` Paul Mackerras
2018-09-03 15:19 ` [PATCH 4/6] powerpc sstep: Add extswsli " Sandipan Das
2018-09-03 15:19 ` [PATCH 5/6] powerpc sstep: Add modsw, moduw " Sandipan Das
2018-09-03 15:19 ` [PATCH 6/6] powerpc sstep: Add modsd, modud " Sandipan Das
2018-09-04 21:21   ` Segher Boessenkool
2018-09-05 11:53     ` 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=871s438eon.fsf@concordia.ellerman.id.au \
    --to=mpe@ellerman$(echo .)id.au \
    --cc=anton@samba$(echo .)org \
    --cc=linuxppc-dev@lists$(echo .)ozlabs.org \
    --cc=naveen.n.rao@linux$(echo .)vnet.ibm.com \
    --cc=paulus@samba$(echo .)org \
    --cc=ravi.bangoria@linux$(echo .)ibm.com \
    --cc=sandipan@linux$(echo .)ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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