public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* How to recognize registers after reload ?.
@ 2020-10-22  8:02 Henri Cloetens
  2020-10-22 21:30 ` Jeff Law
  0 siblings, 1 reply; 10+ messages in thread
From: Henri Cloetens @ 2020-10-22  8:02 UTC (permalink / raw)
  To: gcc-help

Hello all,

I have an issue with my custom compiler back-end after reload.

1. The machine has move-instructions that can do following:
    a. From register file to (register indirect offset) or to register file.
    b. From (register indirect offset), register file, immediate to 
register file

2. I have now 3 patterns to emit moves in the .md-file:

     1. movesi_internal_fromreg (from register file to memory or 
register file)
     2. movesi_internal_toreg (from memory , immediate, register file to 
register file)
     3. movesi : define_expand. It has C-code that analyses the operands 
and selects 1,2 or both.

Motivation for the split was problems with the "combine" step. Suppose 
following code:
     *a = 10.
     Even if my front_end (define_expand) splits this in
     r100 = 10
    *r101 = r100
    the combine step, if these is only one movesi_internal, willl group 
it again, to then find out
    there is no instruction pattern.

Now, it being split, it goes wrong during reload. The issue is, that the 
code of the define_expand is wrong.
I there uses the tests (GET_CODE(operands[0,1]) == REG), and this is not 
correct any more. I mean,
this evaluated true also for a register that the reload step knows needs 
to end up in memory.
Question :
   - What tests are there to find out an operand is intended to be a 
pseudo in memory, and not a register ?.
   - What is a register, especially during reload ?.
     The issue is the movesi_internal_fromreg:

(define_insn "movsi_internal_fromreg"
   [(set (match_operand:SI 0 "memoryIndirect_or_reg" "r,MemInd,r"
           (match_operand:SI 1 "gpc_reg_operand" "r,r,           MemInd"))]
""
..

Please note the MemInd qualifier on the second line, at the end.
   - When I add this, the reload goes fine.
   - Without it, it gets in an endless loop. The backend is called with 
the "from" operand
      actually a pseudo on the stack, and this is incorrectly recognized 
as a register.
   - In my opinion, it needs to be solved by changing the 
"define_expand" for "movsi", so that it
     recognizes the variable on the stack, and calls the other 
instruction : "movsi_internal_toreg".
     Only I dont know how to recognize the stackvar.

Best Regards,

Henri.


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

end of thread, other threads:[~2020-10-23 11:37 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-22  8:02 How to recognize registers after reload ? Henri Cloetens
2020-10-22 21:30 ` Jeff Law
2020-10-22 22:24   ` Segher Boessenkool
2020-10-22 23:47     ` Jeff Law
2020-10-23  7:28       ` Henri Cloetens
2020-10-23  7:35         ` AW: " Stefan Franke
2020-10-23  7:56           ` Henri Cloetens
2020-10-23 10:20           ` Segher Boessenkool
2020-10-23 11:38             ` Henri Cloetens
2020-10-23 10:02         ` Segher Boessenkool

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