Related articles |
---|
Switch statement code generation Pidgeot18@verizon.invalid (Joshua Cranmer) (2009-11-03) |
Re: Switch statement code generation gah@ugcs.caltech.edu (glen herrmannsfeldt) (2009-11-04) |
Re: Switch statement code generation kkylheku@gmail.com (Kaz Kylheku) (2009-11-04) |
Re: Switch statement code generation cr88192@hotmail.com (BGB / cr88192) (2009-11-04) |
Re: Switch statement code generation ian@airs.com (Ian Lance Taylor) (2009-11-03) |
Re: Switch statement code generation gah@ugcs.caltech.edu (glen herrmannsfeldt) (2009-11-04) |
Re: Switch statement code generation anton@mips.complang.tuwien.ac.at (2009-11-04) |
Re: Switch statement code generation Pidgeot18@verizon.invalid (Joshua Cranmer) (2009-11-04) |
Re: Switch statement code generation walter@bytecraft.com (Walter Banks) (2009-11-05) |
Re: Switch statement code generation bartc@freeuk.com (bartc) (2009-11-05) |
[10 later articles] |
From: | "BGB / cr88192" <cr88192@hotmail.com> |
Newsgroups: | comp.compilers |
Date: | Wed, 4 Nov 2009 00:13:39 -0700 |
Organization: | albasani.net |
References: | 09-11-002 09-11-003 |
Keywords: | code |
Posted-Date: | 05 Nov 2009 15:15:39 EST |
"glen herrmannsfeldt" <gah@ugcs.caltech.edu> wrote in message
> Joshua Cranmer <Pidgeot18@verizon.invalid> wrote:
>> I'm trying to put together a list of various methods to do code generate
>> for switch statements.
>
<snip>
> I believe that JVM also has a special instruction for this
> operation, as the above likely don't work there.
>
I think both the JVM and MSIL/CIL have special instructions for jump
tables...
>> [I think I've seen hashing into branch tables. -John]
>
> Sounds better than branching into hash tables.
>
> -- glen
> [On machines with condition codes, I've seen binary searches expanded
> into code with compare and branch instructions; after the comparison
> you can do a three way branch on less, equal, or greater. -John]
yeah...
in my compiler (on x86 and x64) I ended up using condition codes to
implement a trinary jump of this sort.
I had intended this for implementing slightly faster switches (errm...
because my compiler does not have jump tables... lame, I know, just never
got around to it...).
from what I remember, I do a binary lookup to handle switches.
then again, I am still not using my compiler as a "general purpose" C
compiler, and so there are still a few deficiencies I have never really
gotten around to fixing.
so many other things to work on, such as the x86 interpreter (now works ok,
and is ~170x slower than native, but still lacks a good deal in terms of API
bindings, me left thinking I may need some sort of IDL-like technology for
this, ...), ...
maybe just a whole lot of busywork, I don't know...
Return to the
comp.compilers page.
Search the
comp.compilers archives again.