Properly declare some classes and functions
[suif.git] / html / suif1_36.html
blob7223a9c689881c01204ce3f17600b51b49730f3f
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 - Array Instructions</TITLE>
7 <link href="suif1_37.html" rel=Next>
8 <link href="suif1_35.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_35.html">previous</A>, <A HREF="suif1_37.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="SEC36" HREF="suif1_toc.html#TOC36">Array Instructions</A></H2>
18 <P>
19 <A NAME="IDX218"></A>
20 <A NAME="IDX219"></A>
22 </P>
23 <P>
24 <A NAME="IDX220"></A>
25 Because many SUIF passes focus on analyzing and optimizing Fortran code,
26 a high-level representation of array references is crucial. SUIF
27 provides <CODE>array</CODE> instructions which retain all of the high-level
28 information in combination with other fields needed to generate code for
29 the address computations. The <CODE>in_array</CODE> class is used to hold
30 these array instructions.
32 </P>
33 <P>
34 <A NAME="IDX221"></A>
35 <A NAME="IDX222"></A>
36 <A NAME="IDX223"></A>
37 <A NAME="IDX224"></A>
38 <A NAME="IDX225"></A>
39 <A NAME="IDX226"></A>
40 Array instructions include a number of fields. First, a pointer to the
41 base of the array is specified in an operand field that can be accessed
42 with the <CODE>base_op</CODE> and <CODE>set_base_op</CODE> methods. If the array
43 elements are structures, a constant offset within the selected element
44 may be included. This optional integer offset can be accessed using the
45 <CODE>offset</CODE> and <CODE>set_offset</CODE> methods. The element size is needed
46 to generate low-level code for the array address calculation. The
47 <CODE>elem_size</CODE> method returns the element size in bits. The
48 <CODE>set_elem_size</CODE> method may be used to change the element size.
50 </P>
51 <P>
52 <A NAME="IDX227"></A>
53 <A NAME="IDX228"></A>
54 Because Fortran arrays do not always begin with index zero, an optional
55 operand, which is referenced using the <CODE>offset_op</CODE> and
56 <CODE>set_offset_op</CODE> methods, is provided to specify an offset. Since
57 there is a single offset operand, the offsets for all of the dimensions
58 must be combined into a single value. The arrays are stored in
59 row-major form, so the offset for the first dimension is multiplied by
60 the size of the remaining dimensions, etc. If the offset operand is
61 provided, it must have an integer type.
63 </P>
64 <P>
65 <A NAME="IDX229"></A>
66 <A NAME="IDX230"></A>
67 <A NAME="IDX231"></A>
68 <A NAME="IDX232"></A>
69 <A NAME="IDX233"></A>
70 <A NAME="IDX234"></A>
71 Array instructions can treat arrays of arrays as multidimensional
72 arrays, even though the type system does not support that directly.
73 Each array instruction includes a field to specify the number of
74 dimensions in the array. This field may be accessed with the
75 <CODE>dims</CODE> and <CODE>set_dims</CODE> methods. The indexes for the array
76 reference are stored in an array of source operands, one for each
77 dimension. These index operands can be accessed using the <CODE>index</CODE>
78 and <CODE>set_index</CODE> methods. The dimensions are numbered beginning
79 with zero. Similarly, the number of elements in each dimension are
80 stored in another array of source operands, which can be accessed with
81 the <CODE>bound</CODE> and <CODE>set_bound</CODE> methods.
83 </P>
84 <P>
85 <A NAME="IDX235"></A>
86 The result type of an array instruction must be a pointer. However, it
87 need not be a pointer to the element type. If the elements are
88 structures, the result type may be a pointer to one of the structure
89 fields. SUIF does not actually require that the result type match
90 anything within the array element type, although that is highly
91 recommended. The <CODE>elem_type</CODE> method can be used to determine the
92 actual type of the element being addressed.
94 </P>
95 <P>
96 The types of the array instruction operands must follow some
97 conventions. The index and bound operands must all have integer types.
98 The base operand must be a pointer to an array. If the array
99 instruction has multiple dimensions, the base must point to a nested
100 array (an array of arrays of arrays...) with the same depth as the
101 number of dimensions. For each dimension, if the bound operand is a
102 constant, it must match the number of elements specified in the
103 corresponding array type. (If the lower and upper bounds in the array
104 type are not both constant, then the bound operand may have any value.)
105 The bound operand for the first dimension is optional and may be null.
106 Finally, the element size must match the size of the elements in the
107 array type.
109 </P>
111 <P><HR><P>
112 <p>Go to the <A HREF="suif1_1.html">first</A>, <A HREF="suif1_35.html">previous</A>, <A HREF="suif1_37.html">next</A>, <A HREF="suif1_113.html">last</A> section, <A HREF="suif1_toc.html">table of contents</A>.
113 </BODY>
114 </HTML>