Re: Switch statement code generation

anton@mips.complang.tuwien.ac.at (Anton Ertl)
Wed, 04 Nov 2009 10:51:34 GMT

          From comp.compilers

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)
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)
[7 later articles]
| List of all articles for this month |

From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.compilers
Date: Wed, 04 Nov 2009 10:51:34 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
References: 09-11-002
Keywords: code, bibliography
Posted-Date: 05 Nov 2009 15:17:30 EST

Joshua Cranmer <Pidgeot18@verizon.invalid> writes:
>I'm trying to put together a list of various methods to do code generate
>for switch statements.
...
>Are there any other methods worth mentioning?


Hash-table-based jump tables.


IIRC the following paper discusses these methods:


@Article{journals/spe/KannanP94,
    title = "Short Communication: Correction to 'Producing Good
Code for the case Statement'",
    author = "Sampath Kannan and Todd A. Proebsting",
    journal = "Softw, Pract. Exper",
    year = "1994",
    number = "2",
    volume = "24",
    bibdate = "2003-11-25",
    bibsource = "DBLP,
http://dblp.uni-trier.de/db/journals/spe/spe24.html#KannanP94",
    pages = "233",
}


and this refers to:


@Article{bernstein:85a,
    author = "R. L. Bernstein",
    title = "Producing good code for the case statement",
    journal = "Software -- Practice \& Experience",
    volume = "15",
    number = "10",
    pages = "1021--1024",
    month = oct,
    year = "1985",
}


These days, with the varying amounts of branch prediction hardware,
the best way probably depends on the hardware (which branch predictors
are implemented in the hardware?) and on the run-time characteristics
of the program (how effective are the branch predictors on this
particular usage pattern).


- anton
--
M. Anton Ertl
anton@mips.complang.tuwien.ac.at
http://www.complang.tuwien.ac.at/anton/



Post a followup to this message

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