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.

But my primary question is about how to generate a jump at the end of
You could have a look at the rs6000 patterns (in rs6000.md)
"*return_and_restore_gpregs_<mode>_r11" and the function that creates
such patterns, "rs6000_emit_savres_rtx" in (rs6000.c).  This does a whole
bunch more than you need, but maybe you'll get the idea.  Some points:

- The pattern should describe all it does (restore what regs, etc.), not
   just the jump;
- You should set a JUMP_LABEL (to ret_rtx) on the jump, and it should _be_
   a jump_insn;
- You want a separate pattern in the machine description for this.

HTH,


Segher

OK, so i386 doesn't have a generic "any_parallel_operand" predicate and I assume I might be shot if I tried to add one, so (just focusing on the epilogue for now) I've added one called for "restore_multiple_and_return" that snoops through the vector and verifies that it's what is expected. 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)

This is the actual asm of the stub:

__msabi_restore_odd:
    pop    %rsi
    movaps (%rsp),%xmm6
    movaps 0x10(%rsp),%xmm7
    movaps 0x20(%rsp),%xmm8
    movaps 0x30(%rsp),%xmm9
    movaps 0x40(%rsp),%xmm10
    movaps 0x50(%rsp),%xmm11
    movaps 0x60(%rsp),%xmm12
    movaps 0x70(%rsp),%xmm13
    movaps 0x80(%rsp),%xmm14
    movaps 0x90(%rsp),%xmm15
    add    $0xa0,%rsp
    pop    %rdi
    ret

Thanks again for all your help!

Daniel

Reply via email to