Partial support for integer divisions in access vectors
[suif.git] / html / suif1_56.html
blob859e9d533b140896380a1bca8bb8a518e66ce80d
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 - Variable Features</TITLE>
7 <link href="suif1_57.html" rel=Next>
8 <link href="suif1_55.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_55.html">previous</A>, <A HREF="suif1_57.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 <H3><A NAME="SEC56" HREF="suif1_toc.html#TOC56">Basic Features of Variables</A></H3>
19 <P>
20 <A NAME="IDX373"></A>
21 <A NAME="IDX374"></A>
22 The type of a variable can be accessed via the <CODE>type</CODE> and
23 <CODE>set_type</CODE> methods. The type must be visible in the scope where
24 the variable is defined. Since the type specifies the amount of storage
25 occupied by the variable, the size of the type must not be zero. This
26 means that function types, void types, incomplete structure and union
27 types, and array types with unknown bounds cannot be used for variables
28 <A NAME="DOCF4" HREF="suif1_foot.html#FOOT4">(4)</A>. Pointers to those types are acceptable, of course.
29 Sub-variables may have any type so long as the size of that type and
30 the sub-variable's offset allow it to remain within the parent
31 variable.
33 </P>
34 <P>
35 <A NAME="IDX375"></A>
36 <A NAME="IDX376"></A>
37 <A NAME="IDX377"></A>
38 <A NAME="IDX378"></A>
39 <A NAME="IDX379"></A>
40 Variable symbols may also be allocated to machine registers. A flag is
41 used to indicate variables that are contained in registers; the
42 <CODE>is_reg</CODE> method returns the value of this flag and the
43 <CODE>set_reg</CODE> and <CODE>reset_reg</CODE> methods change its value. The
44 <CODE>reg_num</CODE> annotation can be attached to a register variable to
45 specify the corresponding machine register number (see section <A HREF="suif1_78.html#SEC78">Miscellaneous Annotations</A>). Variables cannot be registers if they have variable
46 definitions. Whether a sub-variable is a register or not is slaved to
47 this property in its parent.
49 </P>
50 <P>
51 <A NAME="IDX380"></A>
52 <A NAME="IDX381"></A>
53 Symbols for variables that are not allocated on the stack must have
54 separate variable definitions (see section <A HREF="suif1_58.html#SEC58">Variable Definitions</A>) or else
55 they are merely declarations of external symbols. The
56 <CODE>has_var_def</CODE> method checks if a variable symbol has a separate
57 definition, and the <CODE>definition</CODE> method returns a pointer to the
58 definition. It is an error to call <CODE>definition</CODE> for a variable
59 that does not have a definition, so be sure to check first.
60 Sub-variables are never allowed to have their own definitions.
62 </P>
63 <P>
64 <A NAME="IDX382"></A>
65 <A NAME="IDX383"></A>
66 The <CODE>var_sym</CODE> class includes several methods to check various
67 attributes and flags for variables. The <CODE>is_auto</CODE> method checks if
68 a variable is in the automatic storage class, i.e. if it will be
69 allocated on the stack. Global variables and static local variables
70 (those with variable definitions) are not automatic and <CODE>is_auto</CODE>
71 returns <CODE>FALSE</CODE> for them; other variables are automatic. The
72 <CODE>is_static</CODE> method is the opposite of <CODE>is_auto</CODE>, except that
73 register variables are not considered to be static.
75 </P>
76 <P>
77 <A NAME="IDX384"></A>
78 <A NAME="IDX385"></A>
79 <A NAME="IDX386"></A>
80 The formal parameters of a procedure are represented by variables that
81 have a special flag set. The <CODE>is_param</CODE> method returns the value
82 of this flag, and the <CODE>set_param</CODE> and <CODE>reset_param</CODE> methods
83 change its value. Identifying the formals with flags does not allow
84 their order to be specified, so the procedure symbol table maintains a
85 list of the formals (see section <A HREF="suif1_44.html#SEC44">Procedure Symbol Tables</A>). All of the
86 variables for which <CODE>is_param</CODE> returns <CODE>TRUE</CODE> should be on the
87 list of parameters, and conversely, all variables on the parameter list
88 should have the flag set. Sub-variables are not allowed to be
89 parameters; sub-variables of parameters are allowed, but these are not
90 considered parameters themselves.
92 </P>
93 <P>
94 <A NAME="IDX387"></A>
95 <A NAME="IDX388"></A>
96 <A NAME="IDX389"></A>
97 Because many compiler optimizations are only applicable to variables
98 that are not aliased, it is important to identify such variables. Each
99 variable symbol includes a flag to indicate whether the variable has its
100 address taken, and thus whether it could be aliased. The
101 <CODE>is_addr_taken</CODE> method returns the value of this flag. The
102 front-end should set these flags, but they may also need to be updated
103 as the code is transformed. The <CODE>set_addr_taken</CODE> and
104 <CODE>reset_addr_taken</CODE> methods can be used to change the flag for a
105 particular variable symbol. For sub-variables, this property is
106 slaved to this property in the parent variable.
108 </P>
110 <A NAME="IDX390"></A>
111 Besides requiring that variables not be aliased, most optimizations also
112 do not apply to aggregate data structures. The <CODE>is_scalar</CODE> method
113 checks the type of a variable symbol and returns <CODE>TRUE</CODE> if it is
114 not an aggregate type. Arrays, structures, and unions are considered to
115 be aggregates.
117 </P>
119 <A NAME="IDX391"></A>
120 In general, most optimizations target scalar variables that are
121 guaranteed not to be aliased. Since it is difficult to guarantee that
122 global variables with external linkage are not addressed, those
123 variables may be aliased even if their flags indicate that they are not
124 addressed. Rather than checking these conditions separately, the
125 library provides one method to check them all. The <CODE>is_spilled</CODE>
126 method returns <CODE>TRUE</CODE> for variables that are static, addressed, or
127 aggregates. Variables that are not spilled can then be targeted for
128 optimization.
130 </P>
132 <P><HR><P>
133 <p>Go to the <A HREF="suif1_1.html">first</A>, <A HREF="suif1_55.html">previous</A>, <A HREF="suif1_57.html">next</A>, <A HREF="suif1_113.html">last</A> section, <A HREF="suif1_toc.html">table of contents</A>.
134 </BODY>
135 </HTML>