add $(EXEEXT) to executable targets during installation for MinGW
[suif.git] / html / suif1_30.html
blob95e69c9113f67e950b8e77598e63663605336a9b
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 - Operands</TITLE>
7 <link href="suif1_31.html" rel=Next>
8 <link href="suif1_29.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_29.html">previous</A>, <A HREF="suif1_31.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="SEC30" HREF="suif1_toc.html#TOC30">Operands</A></H2>
18 <P>
19 <A NAME="IDX163"></A>
21 </P>
22 <P>
23 <A NAME="IDX164"></A>
24 Most SUIF instructions have operands that are represented by objects of
25 the <CODE>operand</CODE> class, which is implemented in the files
26 <TT>`operand.h'</TT> and <CODE>operand.cc</CODE>. An operand may have three
27 different kinds of values:
29 </P>
31 <UL>
32 <LI>
34 <A NAME="IDX165"></A>
35 It may be a null operand. The <CODE>is_null</CODE> method tests for this
36 case. Null operands occur when an operand field in an instruction is
37 unused.
39 <LI>
41 <A NAME="IDX166"></A>
42 <A NAME="IDX167"></A>
43 <A NAME="IDX168"></A>
44 An operand may refer directly to the symbol for a variable. The
45 <CODE>is_symbol</CODE> method tests for this case. The <CODE>symbol</CODE> and
46 <CODE>set_symbol</CODE> methods access the symbol field. A variable in a
47 source operand indicates that the contents of the variable are used. In
48 a destination operand, a variable is assigned the result of the
49 instruction.
51 <LI>
53 <A NAME="IDX169"></A>
54 <A NAME="IDX170"></A>
55 <A NAME="IDX171"></A>
56 An operand may also point to another instruction. The <CODE>is_instr</CODE>
57 method tests for this, and the <CODE>instr</CODE> and <CODE>set_instr</CODE> methods
58 access the pointer field. This is used to implement expression trees
59 and, in low-SUIF, to refer to the results of other instructions in a
60 flat list. An instruction pointer in a source operand means that the
61 result of that instruction is used as the operand. Conversely, an
62 instruction pointer in a destination operand indicates that the result
63 value is used by that instruction.
64 </UL>
66 <P>
67 <A NAME="IDX172"></A>
68 The <CODE>is_expr</CODE> method is very similar to <CODE>is_instr</CODE>. Besides
69 checking if the operand holds an instruction pointer, it also tests if
70 that instruction is a subexpression that is not contained in a separate
71 <CODE>tree_instr</CODE> node (i.e. it's not in a flat list). This method
72 should not be used for destination operands.
74 </P>
75 <P>
76 Before changing a source operand from an instruction pointer to some
77 other value, the instruction must be removed. The <CODE>remove</CODE> method
78 checks if the operand is an instruction, and if so, calls the
79 instruction's <CODE>remove</CODE> method. See section <A HREF="suif1_28.html#SEC28">Source Operands</A>.
81 </P>
82 <P>
83 <A NAME="IDX173"></A>
84 <A NAME="IDX174"></A>
85 The operand class includes several methods to simplify common
86 operations. One frequently needs to know the type of a particular
87 operand. This can be determined from the variable's type or the
88 instruction's result type, but checking for these different kinds of
89 operands and then extracting the type is cumbersome. Instead, you can
90 use the <CODE>type</CODE> method which performs this operation for you. It
91 returns the SUIF <CODE>void</CODE> type for null operands. Another common
92 operation is testing an operand to see if it contains an integer
93 constant from a load constant instruction. The <CODE>is_const_int</CODE>
94 method checks if this is the case, and if so, it also returns the value
95 of the constant.
97 </P>
98 <P>
99 <A NAME="IDX175"></A>
100 <A NAME="IDX176"></A>
101 Operands have two different methods for printing themselves out to a
102 file as text. The <CODE>print</CODE> method is used by the library when
103 printing instructions. Because source and destination operands are
104 handled differently, <CODE>print</CODE> requires that you specify the
105 instruction that contains the operand so that it can determine how the
106 operand is being used. However, when debugging a program, you may not
107 know which instruction contains an operand. If you do know that it is
108 used as a source operand, you can use the <CODE>print_source</CODE> method to
109 print it without specifying the instruction.
111 </P>
113 <P><HR><P>
114 <p>Go to the <A HREF="suif1_1.html">first</A>, <A HREF="suif1_29.html">previous</A>, <A HREF="suif1_31.html">next</A>, <A HREF="suif1_113.html">last</A> section, <A HREF="suif1_toc.html">table of contents</A>.
115 </BODY>
116 </HTML>