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
>
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>.
17 <H2><A NAME=
"SEC37" HREF=
"suif1_toc.html#TOC37">Multi-way Branch Instructions
</A></H2>
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
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
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.
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>.