public inbox for sid@sourceware.org
 help / color / mirror / Atom feed
From: Dave Brolley <brolley@redhat.com>
To: Nick Clifton <nickc@redhat.com>
Cc: cgen@sourceware.org, sid@sourceware.org, dj@redhat.com
Subject: Re: RFA: XStormy16: Fix implementation of MOVF instruction
Date: Mon, 01 Nov 2010 15:48:00 -0000	[thread overview]
Message-ID: <4CCEE146.4050908@redhat.com> (raw)
In-Reply-To: <m3vd4mpri0.fsf@redhat.com>

  Hi Nick,

I don't know that this port has a maintainer for CGEN/SID. However, I 
think that testing against a specific test case which exhibits the bug 
and running the SID testsuite for --target=xstormy16-elf should be 
sufficient. I see that there is no test case for this insn in
sid/component/testsuite/sidcomp.cgen-cpu.xstormy16, so please add one 
before running the test suite.

Dave

On 10/28/2010 05:59 AM, Nick Clifton wrote:
> Hi Guys,
>
>    The patch below fixes the emulation of the XStormy16's MOVF
>    instruction.  There were two problems - firstly when memory addresses
>    were being aligned they were also being truncated to 16-bits.  (The
>    MOVF instruction allows access to a 32-bit address space).  Secondly
>    the pre-decrement and post-increment addressing modes were not
>    propagating the carry into the base register.
>
>    Tested by running lots of different xstormy16 programs under SID.
>
>    OK to apply ?
>
> Cheers
>    Nick Clifton
>
> cgen/ChangeLog
> 2010-10-28  Nick Clifton<nickc@redhat.com>
>
> 	* cpu/xstormy16.cpu (alignfix-mem-far): New macro.  Like
>          alignfix-mem, but works with 32-bit addresses.
>          (set-alignfix-mem-far): New macro.  Like set-alignfix-mem but
>          works with 32-bit addresses.
>          (movfgrgri, movfgrgripostinc, movfgrgripredec, movfgrgrii,
>          movfgrgriipostinc, movfgrgriipredec): Use alignfix-mem-far.
>          (movfgrigr, movfgripostincgr, movfgripredecgr): Use
>          set-alignfix-mem-far.
> 	(movfgrgriipostinc, movfgriipostincgr): Propagate addition to
>          source register into base register.
> 	(movfgrgriipredec, movfgriipredecgr): Propagate subtraction from
>          source register into base register.
>
> sid/component/cgen-cpu/xstormy16/ChangeLog
> 2010-10-28  Nick Clifton<nickc@redhat.com>
>
> 	* xstormy16-sem.cxx: Regenerate.
>
> Index: cgen/cpu/xstormy16.cpu
> ===================================================================
> RCS file: /cvs/src/src/cgen/cpu/xstormy16.cpu,v
> retrieving revision 1.15
> diff -u -3 -p -r1.15 xstormy16.cpu
> --- cgen/cpu/xstormy16.cpu	1 Jun 2010 22:06:50 -0000	1.15
> +++ cgen/cpu/xstormy16.cpu	28 Oct 2010 09:44:15 -0000
> @@ -524,6 +524,12 @@
>   (define-pmacro (set-alignfix-mem where what)
>     (set (mem HI (and where #xFFFE)) what))
>
> +(define-pmacro (alignfix-mem-far where)
> +  (mem HI (and where #xFFFFFFFE)))
> +
> +(define-pmacro (set-alignfix-mem-far where what)
> +  (set (mem HI (and where #xFFFFFFFE)) what))
> +
>   (dni movlmemimm
>        "Move immediate to low memory"
>        ()
> @@ -824,7 +830,7 @@
>        ("movf$ws2 $Rdm,($Rs)")
>        (+ OP1_7 OP2A_4 ws2 Rs OP4M_0 Rdm)
>        (if ws2
> -	 (set-psw Rdm (index-of Rdm) (alignfix-mem (or (sll SI R8 16) Rs)) ws2)
> +	 (set-psw Rdm (index-of Rdm) (alignfix-mem-far (or (sll SI R8 16) Rs)) ws2)
>   	 (set-psw Rdm (index-of Rdm) (and #xFF (mem QI (or (sll SI R8 16) Rs))) ws2))
>        ()
>   )
> @@ -836,7 +842,7 @@
>        (+ OP1_6 OP2A_4 ws2 Rs OP4M_0 Rdm)
>        (sequence ()
>   	       (if ws2
> -		   (set-psw Rdm (index-of Rdm) (alignfix-mem (join SI HI R8 Rs)) ws2)
> +		   (set-psw Rdm (index-of Rdm) (alignfix-mem-far (join SI HI R8 Rs)) ws2)
>   		   (set-psw Rdm (index-of Rdm) (and #xFF (mem QI (join SI HI R8 Rs))) ws2))
>   	       (set Rs (add Rs (add ws2 1))))
>        ()
> @@ -850,7 +856,7 @@
>        (sequence ()
>   	       (set Rs (sub Rs (add ws2 1)))
>   	       (if ws2
> -		   (set-psw Rdm (index-of Rdm) (alignfix-mem (join SI HI R8 Rs)) ws2)
> +		   (set-psw Rdm (index-of Rdm) (alignfix-mem-far (join SI HI R8 Rs)) ws2)
>   		   (set-psw Rdm (index-of Rdm) (and #xFF (mem QI (join SI HI R8 Rs))) ws2)))
>        ()
>   )
> @@ -862,7 +868,7 @@
>        (+ OP1_7 OP2A_6 ws2 Rs OP4M_0 Rdm)
>        (sequence ()
>   	       (if ws2
> -		   (set-alignfix-mem (join SI HI R8 Rs) Rdm)
> +		   (set-alignfix-mem-far (join SI HI R8 Rs) Rdm)
>   		   (set (mem QI (join SI HI R8 Rs)) Rdm))
>   	       (set-psw-nowrite (index-of Rdm) Rdm ws2))
>        ()
> @@ -875,7 +881,7 @@
>        (+ OP1_6 OP2A_6 ws2 Rs OP4M_0 Rdm)
>        (sequence ()
>   	       (if ws2
> -		   (set-alignfix-mem (join SI HI R8 Rs) Rdm)
> +		   (set-alignfix-mem-far (join SI HI R8 Rs) Rdm)
>   		   (set (mem QI (join SI HI R8 Rs)) Rdm))
>   	       (set-psw-nowrite (index-of Rdm) Rdm ws2)
>   	       (set Rs (add Rs (add ws2 1))))
> @@ -891,7 +897,7 @@
>   	       (set-psw-nowrite (index-of Rdm) Rdm ws2)
>   	       (set Rs (sub Rs (add ws2 1)))
>   	       (if ws2
> -		   (set-alignfix-mem (join SI HI R8 Rs) Rdm)
> +		   (set-alignfix-mem-far (join SI HI R8 Rs) Rdm)
>   		   (set (mem QI (join SI HI R8 Rs)) Rdm)))
>        ()
>   )
> @@ -902,7 +908,7 @@
>        ("movf$ws2 $Rdm,($Rb,$Rs,$imm12)")
>        (+ OP1_7 OP2A_4 ws2 Rs OP4M_1 Rdm OP5A_0 Rb imm12)
>        (if ws2
> -	 (set-psw Rdm (index-of Rdm) (alignfix-mem (add (join SI HI Rb Rs) imm12)) ws2)
> +	 (set-psw Rdm (index-of Rdm) (alignfix-mem-far (add (join SI HI Rb Rs) imm12)) ws2)
>   	 (set-psw Rdm (index-of Rdm) (and #xFF (mem QI (add (join SI HI Rb Rs) imm12))) ws2))
>        ()
>   )
> @@ -914,9 +920,13 @@
>        (+ OP1_6 OP2A_4 ws2 Rs OP4M_1 Rdm OP5A_0 Rb imm12)
>        (sequence ()
>   	       (if ws2
> -		   (set-psw Rdm (index-of Rdm) (alignfix-mem (add (join SI HI Rb Rs) imm12)) ws2)
> +		   (set-psw Rdm (index-of Rdm) (alignfix-mem-far (add (join SI HI Rb Rs) imm12)) ws2)
>   		   (set-psw Rdm (index-of Rdm) (and #xFF (mem QI (add (join SI HI Rb Rs) imm12))) ws2))
> -	       (set Rs (add Rs (add ws2 1))))
> +	       (set Rs (add Rs (add ws2 1)))
> +	       ; Note - despite the XStormy16 ISA documentation the
> +	       ; addition *is* propogated into the base register.
> +	       (if (eq Rs 0) (set Rb (add Rb 1)))
> +	       )
>        ()
>   )
>
> @@ -926,9 +936,12 @@
>        ("movf$ws2 $Rdm,($Rb,--$Rs,$imm12)")
>        (+ OP1_6 OP2A_C ws2 Rs OP4M_1 Rdm OP5A_0 Rb imm12)
>        (sequence ()
> +	       ; Note - despite the XStormy16 ISA documentation the
> +	       ; subtraction *is* propogated into the base register.
> +	       (if (eq Rs 0) (set Rb (sub Rb 1)))
>   	       (set Rs (sub Rs (add ws2 1)))
>   	       (if ws2
> -		   (set-psw Rdm (index-of Rdm) (alignfix-mem (add (join SI HI Rb Rs) imm12)) ws2)
> +		   (set-psw Rdm (index-of Rdm) (alignfix-mem-far (add (join SI HI Rb Rs) imm12)) ws2)
>   		   (set-psw Rdm (index-of Rdm) (and #xFF (mem QI (add (join SI HI Rb Rs) imm12))) ws2)))
>        ()
>   )
> @@ -958,7 +971,11 @@
>   		   (set (mem HI (and (add (join SI HI Rb Rs) imm12) #xFFFFFFFE)) Rdm)
>   		   (set (mem QI (add (join SI HI Rb Rs) imm12)) Rdm))
>   	       (set-psw-nowrite (index-of Rdm) Rdm ws2)
> -	       (set Rs (add Rs (add ws2 1))))
> +	       (set Rs (add Rs (add ws2 1)))
> +	       ; Note - despite the XStormy16 ISA documentation the
> +	       ; addition *is* propogated into the base register.
> +	       (if (eq Rs 0) (set Rb (add Rb 1)))
> +	       )
>        ()
>   )
>
> @@ -968,6 +985,9 @@
>        ("movf$ws2 ($Rb,--$Rs,$imm12),$Rdm")
>        (+ OP1_6 OP2A_E ws2 Rs OP4M_1 Rdm OP5A_0 Rb imm12)
>        (sequence ()
> +	       ; Note - despite the XStormy16 ISA documentation the
> +	       ; subtraction *is* propogated into the base register.
> +	       (if (eq Rs 0) (set Rb (sub Rb 1)))
>   	       (set Rs (sub Rs (add ws2 1)))
>   	       (set-psw-nowrite (index-of Rdm) Rdm ws2)
>   	       (if ws2

  reply	other threads:[~2010-11-01 15:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-28  9:59 Nick Clifton
2010-11-01 15:48 ` Dave Brolley [this message]
2010-11-02 16:18   ` Nick Clifton
2010-11-02 16:30     ` Dave Brolley

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=4CCEE146.4050908@redhat.com \
    --to=brolley@redhat.com \
    --cc=cgen@sourceware.org \
    --cc=dj@redhat.com \
    --cc=nickc@redhat.com \
    --cc=sid@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).