public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* movsi on a 16 bit machine
@ 2009-07-20 13:33 Florent Defay
  2009-07-20 18:37 ` Ian Lance Taylor
  0 siblings, 1 reply; 3+ messages in thread
From: Florent Defay @ 2009-07-20 13:33 UTC (permalink / raw)
  To: gcc-help

Hello,

I am working on a new port for a 16-bit machine.

I have trouble with movsi.

As the machine is 16-bit, movsi cannot be done in one shot. So I split
it into two movhi:

(define_insn_and_split "movsi"
  [(set (match_operand:SI 0 "nonimmediate_operand" "=r,m")
        (match_operand:SI 1 "general_operand" "rim,r"))]
  ""
  "#"
  "reload_completed"
 [(set (match_dup 2)
       (match_dup 3))
  (set (match_dup 4)
       (match_dup 5))]
  {
    operands[2] = simplify_gen_subreg(HImode,operands[0],SImode,0);
    operands[4] = simplify_gen_subreg(HImode,operands[0],SImode,2);
    operands[3] = simplify_gen_subreg(HImode,operands[1],SImode,0);
    operands[5] = simplify_gen_subreg(HImode,operands[1],SImode,2);
  }
)

But there is a problem (rare) when the following case is encountered:

move 4(R0),R0
move 6(R0),R1

Here, the operands considered are:
operand0: R0:R1  (16 bits + 16 bits)
operand1: 4(R0):6(R0)  (16 bits + 16 bits)

this should be moving operand1 into operand0 but operand1 is addressed
by R0 and R0 is modified at first line, so second line is false.

I would like to modify the implementation to fix it but I do not know how.
Please help.

Regards,

Florent.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: movsi on a 16 bit machine
  2009-07-20 13:33 movsi on a 16 bit machine Florent Defay
@ 2009-07-20 18:37 ` Ian Lance Taylor
  2009-07-24  9:16   ` Florent Defay
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Lance Taylor @ 2009-07-20 18:37 UTC (permalink / raw)
  To: Florent Defay; +Cc: gcc-help

Florent Defay <spira.inhabitant@gmail.com> writes:

> I have trouble with movsi.
>
> As the machine is 16-bit, movsi cannot be done in one shot. So I split
> it into two movhi:
>
> (define_insn_and_split "movsi"
>   [(set (match_operand:SI 0 "nonimmediate_operand" "=r,m")
>         (match_operand:SI 1 "general_operand" "rim,r"))]
>   ""
>   "#"
>   "reload_completed"
>  [(set (match_dup 2)
>        (match_dup 3))
>   (set (match_dup 4)
>        (match_dup 5))]
>   {
>     operands[2] = simplify_gen_subreg(HImode,operands[0],SImode,0);
>     operands[4] = simplify_gen_subreg(HImode,operands[0],SImode,2);
>     operands[3] = simplify_gen_subreg(HImode,operands[1],SImode,0);
>     operands[5] = simplify_gen_subreg(HImode,operands[1],SImode,2);
>   }
> )
>
> But there is a problem (rare) when the following case is encountered:
>
> move 4(R0),R0
> move 6(R0),R1
>
> Here, the operands considered are:
> operand0: R0:R1  (16 bits + 16 bits)
> operand1: 4(R0):6(R0)  (16 bits + 16 bits)
>
> this should be moving operand1 into operand0 but operand1 is addressed
> by R0 and R0 is modified at first line, so second line is false.

You need to make your split a little more complicated so that when the
registers overlap, it generates
    move 6(R0),R1
    move 4(R0),R0
A define_insn_and_split is permitted to generate the actual instructions
to use followed by DONE, just as in define_expand.

Ian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: movsi on a 16 bit machine
  2009-07-20 18:37 ` Ian Lance Taylor
@ 2009-07-24  9:16   ` Florent Defay
  0 siblings, 0 replies; 3+ messages in thread
From: Florent Defay @ 2009-07-24  9:16 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help

>
> You need to make your split a little more complicated so that when the
> registers overlap, it generates
>    move 6(R0),R1
>    move 4(R0),R0
> A define_insn_and_split is permitted to generate the actual instructions
> to use followed by DONE, just as in define_expand.
>

Alright. I did it. It works.

Thank you.


Florent

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-07-24  9:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-20 13:33 movsi on a 16 bit machine Florent Defay
2009-07-20 18:37 ` Ian Lance Taylor
2009-07-24  9:16   ` Florent Defay

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).