Re: Switch statement code generation

"Ira Baxter" <idbaxter@semdesigns.com>
Sat, 14 Nov 2009 12:37:52 -0600

          From comp.compilers

Related articles
[10 earlier articles]
Re: Switch statement code generation nathan.mccauley@gmail.com (nathan.mccauley@gmail.com) (2009-11-07)
Re: Switch statement code generation DrDiettrich1@aol.com (Hans-Peter Diettrich) (2009-11-08)
Re: Switch statement code generation bear@sonic.net (Ray) (2009-11-09)
Re: Switch statement code generation DrDiettrich1@aol.com (Hans-Peter Diettrich) (2009-11-11)
Re: Switch statement code generation derek@knosof.co.uk (Derek M. Jones) (2009-11-11)
Re: Switch statement code generation anton@mips.complang.tuwien.ac.at (2009-11-11)
Re: Switch statement code generation idbaxter@semdesigns.com (Ira Baxter) (2009-11-14)
Re: Switch statement code generation cfc@shell01.TheWorld.com (Chris F Clark) (2009-11-15)
Re: Switch statement code generation pertti.kellomaki@tut.fi (Pertti Kellomaki) (2009-11-16)
Re: Switch statement code generation haberg_20080406@math.su.se (Hans Aberg) (2009-11-17)
| List of all articles for this month |

From: "Ira Baxter" <idbaxter@semdesigns.com>
Newsgroups: comp.compilers
Date: Sat, 14 Nov 2009 12:37:52 -0600
Organization: Compilers Central
Keywords: code
Posted-Date: 15 Nov 2009 17:48:05 EST

Ray" <bear@sonic.net> wrote in message news:09-11-031...
> nathan.mccauley@gmail.com wrote:
>
> > On Nov 5, 12:12 pm, Walter Banks <wal...@bytecraft.com> wrote:
> >> Joshua Cranmer wrote:
> >> > I'm trying to put together a list of various methods to do code
> >> > generate for switch statements. ...
> >
> > Has anyone seen tries used for the string-based switch statements?
>
> I think the winner for string switches is a string representation with
> a precomputed hash code, used in combination with a hashtable of
> jump addresses.


I'm surprised nobody mentioned perfect hashing. This is ideal
when the set of values is known in advance. No rehashing.


(I'll put this in my ToTry list for our parlanse compiler :)


-- IDB
[I gather that finding a perfect hash function that runs quickly is
not always easy, and that a slightly imperfect hash, e.g., into a
hash table with no collisions but a few empty slots can often be
a lot faster. -John]



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.