snoot: immed_and_type_for_C_intconst: properly parse "0"
[suif.git] / html / suif1_37.html
blob31498b4e85e34fc23892f2d834e16e4945ccd968
1 <HTML>
2 <HEAD>
3 <!-- This HTML file has been created by texi2html 1.54
4 from suif1.texi on 28 April 1999 -->
6 <TITLE>The SUIF Version 1 Library - Multi-way Branch Instructions</TITLE>
7 <link href="suif1_38.html" rel=Next>
8 <link href="suif1_36.html" rel=Previous>
9 <link href="suif1_toc.html" rel=ToC>
11 </HEAD>
12 <BODY>
13 <p>Go to the <A HREF="suif1_1.html">first</A>, <A HREF="suif1_36.html">previous</A>, <A HREF="suif1_38.html">next</A>, <A HREF="suif1_113.html">last</A> section, <A HREF="suif1_toc.html">table of contents</A>.
14 <P><HR><P>
17 <H2><A NAME="SEC37" HREF="suif1_toc.html#TOC37">Multi-way Branch Instructions</A></H2>
18 <P>
19 <A NAME="IDX236"></A>
20 <A NAME="IDX237"></A>
22 </P>
23 <P>
24 <A NAME="IDX238"></A>
25 Fortran computed <CODE>goto</CODE> statements and C <CODE>switch</CODE> statements
26 are represented in SUIF by multi-way branch (<CODE>mbr</CODE>) instructions.
27 These are easier to analyze than the equivalent series of conditional
28 branches, and they can easily be used to generate efficient jump table
29 code. The <CODE>in_mbr</CODE> class holds these multi-way branch
30 instructions.
32 </P>
33 <P>
34 <A NAME="IDX239"></A>
35 <A NAME="IDX240"></A>
36 <A NAME="IDX241"></A>
37 <A NAME="IDX242"></A>
38 The <CODE>in_mbr</CODE> class contains a field with a pointer to an array of
39 label symbols. The <CODE>num_labs</CODE> method returns the number of labels
40 in the array. The size of the array can be changed at any time using
41 the <CODE>set_num_labs</CODE> method; if necessary the array will be
42 reallocated. A particular element within the array can be accessed
43 using the <CODE>label</CODE> and <CODE>set_label</CODE> methods. You must specify
44 the array index, and, as usual, the elements are numbered beginning with
45 zero.
47 </P>
48 <P>
49 <A NAME="IDX243"></A>
50 <A NAME="IDX244"></A>
51 <A NAME="IDX245"></A>
52 <A NAME="IDX246"></A>
53 <A NAME="IDX247"></A>
54 <A NAME="IDX248"></A>
55 A multi-way branch instruction transfers control to one of the target
56 labels depending on the value in the source operand. This operand must
57 have an integer type. It can be accessed using the <CODE>src_op</CODE> and
58 <CODE>set_src</CODE> methods. The value of the source operand is combined
59 with an integer offset to determine the target label. The offset can be
60 accessed with the <CODE>lower</CODE> and <CODE>set_lower</CODE> methods. The offset
61 is subtracted from the value in the source operand and the result is
62 used to index into the array of target labels. If the index is within
63 the range of the array, the instruction branches to the label at that
64 position in the array; otherwise, it branches to the default target
65 label. The <CODE>default_lab</CODE> and <CODE>set_default_lab</CODE> methods access
66 this default label field. The destination operand of a multi-way branch
67 is unused and trying to set it will cause an error. The result type
68 should always be the SUIF <CODE>void</CODE> type.
70 </P>
72 <P><HR><P>
73 <p>Go to the <A HREF="suif1_1.html">first</A>, <A HREF="suif1_36.html">previous</A>, <A HREF="suif1_38.html">next</A>, <A HREF="suif1_113.html">last</A> section, <A HREF="suif1_toc.html">table of contents</A>.
74 </BODY>
75 </HTML>