Properly declare some classes and functions
[suif.git] / html / suif1_100.html
blob540300cdcda92c3f07fd497673eb32601c5555cf
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 - Immeds</TITLE>
7 <link href="suif1_101.html" rel=Next>
8 <link href="suif1_99.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_99.html">previous</A>, <A HREF="suif1_101.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="SEC100" HREF="suif1_toc.html#TOC100">Immediate Values</A></H2>
18 <P>
19 <A NAME="IDX695"></A>
21 </P>
22 <P>
23 <A NAME="IDX696"></A>
24 An immediate value may be an integer constant, string constant,
25 floating-point constant, SUIF type, symbolic address, expression
26 operand, or instruction, or it can be undefined. It can be used as
27 the source of an <CODE>ldc</CODE> (load constant) instruction (see section <A HREF="suif1_34.html#SEC34">Load Constant Instructions</A>) or as an element of an annotation
28 (see section <A HREF="suif1_69.html#SEC69">Annotations</A>). Only integers, floating-point values, and
29 symbolic addresses may be used in <CODE>ldc</CODE> instructions, while any
30 kind of immediate value may appear in an annotation. Immediate values
31 are implemented by the <CODE>immed</CODE> class defined in the files
32 <TT>`immed.h'</TT> and <TT>`immed.cc'</TT>.
34 </P>
35 <P>
36 <A NAME="IDX697"></A>
37 The kind of value in an <CODE>immed</CODE> is identified by the <CODE>kind</CODE>
38 method. This returns a member of the <CODE>immed_kinds</CODE> enumerated
39 type. The members of this enumeration are:
41 </P>
42 <DL COMPACT>
44 <DT><CODE>im_int</CODE>
45 <DD>
46 <A NAME="IDX698"></A>
47 <A NAME="IDX699"></A>
48 Integer. The <CODE>is_integer</CODE> method tests for this kind of immediate
49 and the <CODE>integer</CODE> method returns the integer value.
51 <DT><CODE>im_string</CODE>
52 <DD>
53 <A NAME="IDX700"></A>
54 <A NAME="IDX701"></A>
55 Character string. The string is automatically entered in the lexicon
56 (see section <A HREF="suif1_102.html#SEC102">Lexicon</A>) when the <CODE>immed</CODE> is created. The
57 <CODE>is_string</CODE> method checks if an <CODE>immed</CODE> is a string, and the
58 <CODE>string</CODE> method returns a pointer to the string.
60 <DT><CODE>im_float</CODE>
61 <DD>
62 <A NAME="IDX702"></A>
63 <A NAME="IDX703"></A>
64 Floating-point value. The SUIF library stores all floating-point values
65 using the <CODE>double</CODE> type, so the precision is limited by the
66 precision for the <CODE>double</CODE> type. The <CODE>is_flt</CODE> method checks
67 for this kind of immediate, and the <CODE>flt</CODE> method returns the value.
69 <DT><CODE>im_symbol</CODE>
70 <DD>
71 <A NAME="IDX704"></A>
72 <A NAME="IDX705"></A>
73 <A NAME="IDX706"></A>
74 <A NAME="IDX707"></A>
75 Symbolic address. See section <A HREF="suif1_101.html#SEC101">Symbolic Addresses</A>. The <CODE>is_symbol</CODE>
76 method checks if an <CODE>immed</CODE> is a symbolic address. The <CODE>addr</CODE>
77 method returns the entire <CODE>sym_addr</CODE> object, but the <CODE>symbol</CODE>
78 and <CODE>offset</CODE> methods are also available to retrieve the symbol
79 pointer and integer offset separately.
81 <DT><CODE>im_type</CODE>
82 <DD>
83 <A NAME="IDX708"></A>
84 <A NAME="IDX709"></A>
85 SUIF type. The <CODE>is_type</CODE> method checks for this kind of immediate,
86 and the <CODE>type</CODE> method returns a pointer to the SUIF type node.
88 <DT><CODE>im_op</CODE>
89 <DD>
90 <A NAME="IDX710"></A>
91 <A NAME="IDX711"></A>
92 Expression operand. The immed is considered to "own" the entire
93 expression tree when it's in an annotation, so the same expression
94 shouldn't be used in another annotation or as the source for an
95 instruction; instead a copy should be made with the <CODE>clone</CODE>
96 method. The <CODE>is_op</CODE> method checks for this kind of immediate,
97 and the <CODE>op</CODE> method returns the expression.
99 <DT><CODE>im_instr</CODE>
100 <DD>
101 <A NAME="IDX712"></A>
102 <A NAME="IDX713"></A>
103 SUIF instruction. The immed is considered to "own" the instruction
104 and its expression trees when it's in an annotation, so the same
105 instruction shouldn't be used in another annotation or in a
106 <CODE>tree_node</CODE> or expression; instead a copy should be made with the
107 <CODE>clone</CODE> method. The <CODE>is_instr</CODE> method checks for this kind
108 of immediate, and the <CODE>instr</CODE> method returns the instruction.
110 <DT><CODE>im_undef</CODE>
111 <DD>
112 <A NAME="IDX714"></A>
113 Undefined value. This is included to signal errors by marking an
114 immediate as undefined. The <CODE>is_error</CODE> method also checks for this
115 condition.
116 </DL>
119 Since an immediate value is small, there are no methods to change the
120 value of an <CODE>immed</CODE>. Instead a variety of constructors are
121 provided to make it easy to create new immediate values. That is, you
122 can initialize different kinds of immediates by providing arguments of
123 various types to constructors.
125 </P>
127 <A NAME="IDX715"></A>
128 <A NAME="IDX716"></A>
129 The <CODE>immed</CODE> class provides two print methods, <CODE>print</CODE> and
130 <CODE>rawprint</CODE>. The difference between them is that the latter doesn't
131 escape <SAMP>`"'</SAMP> and <SAMP>`\'</SAMP> when printing strings.
133 </P>
135 <P><HR><P>
136 <p>Go to the <A HREF="suif1_1.html">first</A>, <A HREF="suif1_99.html">previous</A>, <A HREF="suif1_101.html">next</A>, <A HREF="suif1_113.html">last</A> section, <A HREF="suif1_toc.html">table of contents</A>.
137 </BODY>
138 </HTML>