[LLVMdev] jump table ?

Simon Burton simon at arrowtheory.com
Thu Jun 29 01:43:17 PDT 2006


On Wed, 28 Jun 2006 11:53:56 -0500 (CDT)
Chris Lattner <sabre at nondot.org> wrote:

> On Wed, 28 Jun 2006, Simon Burton wrote:
> > Is it possible to take the address
> > of a basic block ?
> 
> Nope.
> 
> > I'd like to put a whole bunch of these
> > addresses into an array, and then select
> > one to branch to. Eg. like a switch statement.
> > (i'm thinking also of GCC's computed goto's)
> 
> llvm-gcc supports gcc's computed goto's.  You can see what code it 
> generates.

Yes: a bunch of switch statements.

> 
> > I'm finding the code generated by an llvm switch
> > is a big bunch of compares and jump instructions,
> > which i'm not sure is the most efficent way of
> > doing this.
> 
> LLVM does support switch table emission, but only in certain modes.  I 
> think it's only supported in non-pic codegen mode.  Patches to improve 
> this would be welcome :)

I am not sure what "non-pic codegen mode" is.
PIC is relocatable code ? ie. object files ?
So if i'm using the JIT then it will generate a switch table ?
How can i test this, since
i've been examining the native assembly output (is this 'pic' mode?) of llc.

I guess I can compare the speed of a big switch construct with
a nest of branch statements and see if it's any faster.

Simon.


> 
> -Chris
> 
> -- 
> http://nondot.org/sabre/
> http://llvm.org/
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev



More information about the llvm-dev mailing list