Another problem with PIC port, too many reloads for insn

Robert Baruch autophile@gmail.com
Sat Jan 22 17:38:00 GMT 2005


Hi all,

No, not Position Independent Code... this is the PIC microcontroller
port I'm working on. The one that requires that all moves (and all
adds except increments) go through the W register.

I have changed GO_IF_LEGITIMATE_ADDRESS to accept only these
expressions for valid addresses:

FSR -- the only register which can be used as an indirect pointer
post_inc(FSR)
constant

I specifically left out reg+offset because I want to force gcc to
compute that first, then put the result in FSR.

The problem happens with this insn: set ( subreg ( pseudo-260, 0 ),
const_int ( 0 ) ).

The pseudo gets replaced with mem ( plus ( FP, 104 ) ) where FP is the
register where I'm holding the frame pointer.

find_reloads for the insn computes five reloads:

(gdb) p rld[0]
$32 = {
  in = 0x0, 
  out = 0x0, 
  class = W_REG, 
  inmode = QImode, 
  outmode = VOIDmode, 
  mode = QImode, 
  nregs = 1, 
  inc = 0, 
  in_reg = 0x0, 
  out_reg = 0x0, 
  regno = -1, 
  reg_rtx = 0x0, 
  opnum = 0, 
  secondary_in_reload = -1, 
  secondary_out_reload = -1, 
  secondary_in_icode = CODE_FOR_nothing, 
  secondary_out_icode = CODE_FOR_nothing, 
  when_needed = RELOAD_FOR_OPADDR_ADDR, 
  optional = 0, 
  nocombine = 1, 
  secondary_p = 1, 
  nongroup = 0
}
(gdb) p rld[1]
$33 = {
  in = 0x446f90, 
      (plus:QI (reg/f:QI 49 R20/FP)
        (const_int 104 [0x68]))
  out = 0x0, 
  class = GENERAL_REGS, 
  inmode = QImode, 
  outmode = VOIDmode, 
  mode = QImode, 
  nregs = 1, 
  inc = 0, 
  in_reg = 0x446fa8, 
  out_reg = 0x0, 
  regno = -1, 
  reg_rtx = 0x0, 
  opnum = 0, 
  secondary_in_reload = 0, 
  secondary_out_reload = -1, 
  secondary_in_icode = CODE_FOR_nothing, 
  secondary_out_icode = CODE_FOR_nothing, 
  when_needed = RELOAD_FOR_OPADDR_ADDR, 
  optional = 0, 
  nocombine = 1, 
  secondary_p = 0, 
  nongroup = 0
}
(gdb) p rld[2]
$34 = {
  in = 0x0, 
  out = 0x0, 
  class = W_REG, 
  inmode = VOIDmode, 
  outmode = QImode, 
  mode = QImode, 
  nregs = 1, 
  inc = 0, 
  in_reg = 0x0, 
  out_reg = 0x0, 
  regno = -1, 
  reg_rtx = 0x0, 
  opnum = 0, 
  secondary_in_reload = -1, 
  secondary_out_reload = -1, 
  secondary_in_icode = CODE_FOR_nothing, 
  secondary_out_icode = CODE_FOR_nothing, 
  when_needed = RELOAD_FOR_OPERAND_ADDRESS, 
  optional = 1, 
  nocombine = 1, 
  secondary_p = 1, 
  nongroup = 0
}
(gdb) p rld[3]
$35 = {
  in = 0x0, 
  out = 0x446f9c, 
      (mem:QI (plus:QI (reg/f:QI 49 R20/FP)
              (const_int 104 [0x68])) [6 __x0+0 S4 A8])
  class = NO_REGS, 
  inmode = VOIDmode, 
  outmode = QImode, 
  mode = QImode, 
  nregs = 1, 
  inc = 0, 
  in_reg = 0x0, 
  out_reg = 0x43c534, 
  regno = -1, 
  reg_rtx = 0x0, 
  opnum = 0, 
  secondary_in_reload = -1, 
  secondary_out_reload = 2, 
  secondary_in_icode = CODE_FOR_nothing, 
  secondary_out_icode = CODE_FOR_nothing, 
  when_needed = RELOAD_FOR_OUTPUT, 
  optional = 1, 
  nocombine = 0, 
  secondary_p = 0, 
  nongroup = 0
}
(gdb) p rld[4]
$36 = {
  in = 0x40e37210, 
      (const_int 0 [0x0])
  out = 0x0, 
  class = W_REG, 
  inmode = QImode, 
  outmode = VOIDmode, 
  mode = QImode, 
  nregs = 1, 
  inc = 0, 
  in_reg = 0x40e37210, 
  out_reg = 0x0, 
  regno = -1, 
  reg_rtx = 0x0, 
  opnum = 1, 
  secondary_in_reload = -1, 
  secondary_out_reload = -1, 
  secondary_in_icode = CODE_FOR_nothing, 
  secondary_out_icode = CODE_FOR_nothing, 
  when_needed = RELOAD_FOR_INPUT, 
  optional = 0, 
  nocombine = 0, 
  secondary_p = 0, 
  nongroup = 0
}


Later on, in find_reload_regs for this instruction, the reload order
is determined to be 0, 4, 1, 2, 3. Reload 0 snags the W register, and
of course reload 4 fails and causes GCC to abort, complaining that it
cannot find a spill register because the W register required for
reload 4 is already used.

I need some advice on what I should be doing to help GCC resolve this
insn. I'm including my current port so you can look at it and laugh :)

Thanks for any help!

--Rob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pic-20050122.tgz
Type: application/x-gzip
Size: 10561 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20050122/f19e7599/attachment.bin>


More information about the Gcc mailing list