This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: A question about fold_rtx when it attempts to fold PC


On Wed, 2005-01-26 at 11:29 -0500, Kazu Hirata wrote:
> Hi John,
> 
> > It's not true to say that a dispatch table is something that a table
> > jump insn references but does not jump to.  There are some implementations
> > of the dispatch table on the PA which contain code that's jumped to.
> 
> Err, do you mean we jump to a dispatch table itself on PA?  A dispatch
> table is a collection of addresses, not something to interpret as
> executable code.  I am afraid I am missing something here.  Or do you
> mean PA has some executable code between a label and a dispatch table?
Dispatch tables on the PA are implemented with the indexed branch.

The indexed branch basically does something like

pc = pc + (index << 3) + 4

Each entry in the jump table is itself a branch plus a delay slot
(thus the shift left 3 rather than a shift left 2). 

So the code looks something like

... normalize index ...

    blr,n <index>
    nop			/* Delay slot of BLR */

    bl,n <target0>	/* Jump to the code for the lowest case value */
    nop			/* Delay slot */

    bl,n <target1>	/* Jump to the code for the next case value */
    nop			/* Delay slot */

And so on.


This was actually the recommended way to implement switch tables on the
PA, err, a decade ago.

For the most part GCC doesn't know that the jump table is real code;
we don't expose that tidbit until reorg in an attempt to fill all
those annoying delay slots with something useful.

[ Basically most of GCC treats the jump table as a blob of data
  which gets inserted into the text segment.  ]

Jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]