[PATCH/RFA] Register prefix changes for VAX ELF

John David Anglin dave@hiauly1.hia.nrc.ca
Sat Jun 22 20:54:00 GMT 2002


Hmmm.

> Actually, something like:
> 
>          movab function,r3               /* get function address */
>          movl ap,r0                      /* save argument pointer */
>          addl2 $offset,4(ap)             /* adjust first argument */
>          movl 4(fp),r1                   /* save CALLS/CALLG flag */
>          insv $16,$12,function,r1        /* insert new saveregmask */
>          bicb2 $0x20,7(fp)               /* make ret not pop arguments */
>          movl 16(fp),r2                  /* save return address */
>          movab 1f, 16(fp)                /* return to our thunk */
>          ret                             /* restore the stack */
> 1:      pushr function                  /* push saved registers */
>          pushl r2                        /* push saved return pc */
>          pushl fp                        /* push old frame pointer */
>          pushl ap                        /* push old argument pointer */
>          pushl r1                        /* push new saved registers, etal */
>          pushl $0                        /* push a 0; call frame is now 
> complete */
>          movl r0,ap                      /* restore from saved argument 
> pointer */
>          movl sp,fp                      /* set fp to bottom of call frame */
>          jmp function+2                  /* and transfer to the function */
> 
> Basically, it forces a return, manufactuers a call frame, and then jumps
> to the thunk.  And the stack will be as if it was called directly.  Note
> that this will not work under VMS since R2/R3 are preserved registers unless
> when we emit this we can force r2,r3 to saved.

Maybe we can save a couple of registers.  We don't currently use callg so can
r1 be free'd up?  Or, if we want to support callg, can a second jump sequence
be used for it?  After the saved pc is pushed, we can use it if necessary
to build the new saved registers et al.  It might also be possible to determine
the calls/callg flag from the return pc and just use a single sequence.  I
don't see where r3 is used.  So, it looks as if the above can be modified
to just use r0 and r1.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)



More information about the Gcc-patches mailing list