switch statement generation

dgaudet@undergrad.math.uwaterloo.ca (Dean Gaudet)
Thu, 7 Apr 1994 16:19:21 GMT

          From comp.compilers

Related articles
switch statement generation dgaudet@undergrad.math.uwaterloo.ca (1994-04-06)
Re: switch statement generation mps@dent.uchicago.edu (1994-04-07)
switch statement generation dgaudet@undergrad.math.uwaterloo.ca (1994-04-07)
Re: switch statement generation henry@zoo.toronto.edu (1994-04-10)
Re: switch statement generation ch+@cs.cmu.edu (1994-04-11)
Re: switch statement generation ok@cs.rmit.oz.au (1994-04-13)
Re: switch statement generation ltd@netcom.com (1994-04-14)
Re: switch statement generation chase@Think.COM (1994-04-15)
| List of all articles for this month |

Newsgroups: comp.compilers
From: dgaudet@undergrad.math.uwaterloo.ca (Dean Gaudet)
Keywords: C, optimize, available, comment
Organization: University of Waterloo
Date: Thu, 7 Apr 1994 16:19:21 GMT

I received several interested replies for my binary search technique,
so I decided to package it up and post it.


I wrote it 3 or 4 years ago, before the advent of 64 bits. Chances are
it's broken on 64-bit machines. It generates microsoft 386 assembly
(blech). It probably requires some massaging to compile. The README
however contains an example that hopefully illustrates the technique,
which is the important thing anyhow.


Looking back in my files I also notice two other switch techniques I was
fooling with:


- one based on Patricia, using a bunch of 386 tricks to get the most
        out of each comparison
- one that attempts to deal with bit clusters in the case values,
        i.e. consider the two masks


all_on = a bit is 1 here iff it is 1 in all cases
all_off = a bit is 1 here iff it is 0 in all cases


        if( ( x & (all_on | all_off) ) == all_on ) then
all the important information about x is in the bits
~(all_on | all_off)
and we shift these around to form a jump table index


        I did this to deal with switch statements for cases that were all
        divisible by a power of 2, for example.


I've included those files in the package as well.


I would really appreciate it if you contact me, or post, any further
developments on any of these techniques.


Dean
[It's in the compiler archives as iecc.com:pub/file/switch.shar.gz or mail
"send switch.shar" to compilers-server@iecc.com. -John]
--


Post a followup to this message

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