[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc
Subject:    Re: How do you emit RTL for a jump to a mem/symbol instead of an asm label?
From:       Segher Boessenkool <segher () kernel ! crashing ! org>
Date:       2016-08-27 1:42:57
Message-ID: 20160827014257.GB20847 () gate ! crashing ! org
[Download RAW message or body]

On Wed, Aug 24, 2016 at 02:47:41AM -0500, Daniel Santos wrote:
> On 08/21/2016 05:59 PM, Segher Boessenkool wrote:
> >On Sun, Aug 21, 2016 at 02:04:49PM -0500, Daniel Santos wrote:
> >>Thanks for the response! Perhaps an UNSPEC insn is needed here because I
> >>have work to do on other passes too. For example, when the debug info is
> >>created, it's giving the wrong location (on the stack) for where some
> >>registers were saved.
> >Don't worry about this until you have the basics working.  It is fiddly
> >work but not really hard.

You have the basics working now, right?  ;-)

> Then I've added a pattern for it 
> and it's matching on the below RTL and emitting the jump I want! :) My 
> question now is can you see anything that I'm missing or doing wrong in 
> this? I'm telling what registers I'm restoring, where they are read from 
> and what changes I'm making to the stack pointer.
> 
> (jump_insn 27 26 28 2 (parallel [
>             (simple_return)
>             (use (symbol_ref:DI ("__msabi_restore_odd")))
>             (set (reg:DI 4 si)
>                 (mem/c:DI (plus:DI (reg/f:DI 7 sp)
>                         (const_int 0 [0])) [2  S8 A8]))
>             (set (reg:V4SF 27 xmm6)
>                 (mem/c:V4SF (plus:DI (reg/f:DI 7 sp)
>                         (const_int 8 [0x8])) [2  S16 A8]))
>             (set (reg:V4SF 28 xmm7)
>                 (mem/c:V4SF (plus:DI (reg/f:DI 7 sp)
>                         (const_int 24 [0x18])) [2  S16 A8]))
>             (set (reg:V4SF 45 xmm8)
>                 (mem/c:V4SF (plus:DI (reg/f:DI 7 sp)
>                         (const_int 40 [0x28])) [2  S16 A8]))
>             (set (reg:V4SF 46 xmm9)
>                 (mem/c:V4SF (plus:DI (reg/f:DI 7 sp)
>                         (const_int 56 [0x38])) [2  S16 A8]))
>             (set (reg:V4SF 47 xmm10)
>                 (mem/c:V4SF (plus:DI (reg/f:DI 7 sp)
>                         (const_int 72 [0x48])) [2  S16 A8]))
>             (set (reg:V4SF 48 xmm11)
>                 (mem/c:V4SF (plus:DI (reg/f:DI 7 sp)
>                         (const_int 88 [0x58])) [2  S16 A8]))
>             (set (reg:V4SF 49 xmm12)
>                 (mem/c:V4SF (plus:DI (reg/f:DI 7 sp)
>                         (const_int 104 [0x68])) [2  S16 A8]))
>             (set (reg:V4SF 50 xmm13)
>                 (mem/c:V4SF (plus:DI (reg/f:DI 7 sp)
>                         (const_int 120 [0x78])) [2  S16 A8]))
>             (set (reg:V4SF 51 xmm14)
>                 (mem/c:V4SF (plus:DI (reg/f:DI 7 sp)
>                         (const_int 136 [0x88])) [2  S16 A8]))
>             (set (reg:V4SF 52 xmm15)
>                 (mem/c:V4SF (plus:DI (reg/f:DI 7 sp)
>                         (const_int 152 [0x98])) [2  S16 A8]))
>             (set (reg:DI 5 di)
>                 (mem/c:DI (plus:DI (reg/f:DI 7 sp)
>                         (const_int 168 [0xa8])) [2  S8 A8]))
>             (set (reg/f:DI 7 sp)
>                 (plus:DI (reg/f:DI 7 sp)
>                     (const_int 176 [0xb0])))
>         ]) ../a.c:9 -1
>      (expr_list:REG_CFA_ADJUST_CFA (set (reg/f:DI 7 sp)
>             (plus:DI (reg/f:DI 7 sp)
>                 (const_int 176 [0xb0])))
>         (nil))
>  -> simple_return)

You now need to add REG_CFA_RESTORE notes for the registers you restore
from stack, as well.  The REG_CFA_ADJUST_CFA note is done automatically
it seems, but the REG_CFA_RESTORE need to be done by hand.

You also should check if the prologue has the correct notes; usually
you don't need more than just setting RTX_FRAME_RELATED_P on the relevant
insns (and arms of the parallel).  That flag shows up as "/f" in the RTL
dumps.


Segher
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic