Re: Help needed: Code generation for CASE/SWITCH statements

David L Moore <dlmoore@ix.netcom.com>
5 Dec 1997 01:12:22 -0500

          From comp.compilers

Related articles
Re: Help needed: Code generation for CASE/SWITCH statements johnmce@world.std.com (1997-12-05)
Re: Help needed: Code generation for CASE/SWITCH statements srw@pspf47.ih.lucent.com (1997-12-05)
Re: Help needed: Code generation for CASE/SWITCH statements dwight@pentasoft.com (1997-12-05)
Re: Help needed: Code generation for CASE/SWITCH statements preston@cs.rice.edu (1997-12-05)
Re: Help needed: Code generation for CASE/SWITCH statements dlmoore@ix.netcom.com (David L Moore) (1997-12-05)
Re: Help needed: Code generation for CASE/SWITCH statements drh@microsoft.com (Dave Hanson) (1997-12-05)
Re: Help needed: Code generation for CASE/SWITCH statements wilson@marker.cs.utah.edu (Wilson C Hsieh) (1997-12-05)
Re: Help needed: Code generation for CASE/SWITCH statements conway@mundook.cs.mu.OZ.AU (1997-12-05)
Re: Help needed: Code generation for CASE/SWITCH statements gclind01@spd.louisville.edu (1997-12-07)
Re: Help needed: Code generation for CASE/SWITCH statements wi534@victoria.tc.ca (William A. Barath) (1997-12-07)
Re: Help needed: Code generation for CASE/SWITCH statements sethml@ugcs.caltech.edu (1997-12-07)
[9 later articles]
| List of all articles for this month |
From: David L Moore <dlmoore@ix.netcom.com>
Newsgroups: comp.compilers,comp.lang.c.moderated
Date: 5 Dec 1997 01:12:22 -0500
Organization: Netcom
References: <clcm-19971204-0012@plethora.net>
Keywords: code

Jakob wrote:




> [How to implement a case jump table]


A common technique is to divide the table up into compact segments on
which you will use an indexed jump and then select the appropriate
table with if statements. These can be arranged as a binary tree to
minimize the number of comparisons needed. If you have profile info,
you may be able to do better, but otherwise this is a pretty good
approach.


Control Data's Fortran compiler had a nice trick in it which should
not be lost to posterity. The inbuilt assembler contained a large
sparse indexed table for opcode recognition. The code for the
assembler was inserted into the empty space in the table. This worked
because the compiler would never spit out bad opcodes.


The table management was all done with pseudo-code (macros) at assembly
time!
--


Post a followup to this message

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