forward references in typedefs

Doug Gwyn gwyn at smoke.BRL.MIL
Wed Jul 26 04:10:36 AEST 1989


In article <686 at ftp.COM> wjr at ftp.UUCP (Bill Rust) writes:
>The only way to tell if a jump table is better than compare and jump is to
>see what the range of the switch variable is and how many values it
>actually assumes. This is very difficult to do in a one pass compiler.

I don't see that it's particularly hard to do.  The compiler generates
a preamble that branches to a postamble to be generated later (after the
entire switch has been seen), and for each case as it is encountered the
case value is stashed in a compiler internal table (only 257 labels need
be accommodated) and an entry point label output followed by the case code
then a jump to a second deferred label which will follow the postamble.
The postamble can be a jump table, or a sequence of comparisons (hopefully
ordered as a binary tree instead of linear), or any other algorithm the
compiler decided was best for the particular set of case labels.



More information about the Comp.lang.c mailing list