blob: 0bfbef8bb1f633b57a84c7a82795b2c1a74d7f10 [file] [log] [blame]
Chris Lattner00950542001-06-06 20:29:01 +00001<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html><head><title>llvm Assembly Language Reference Manual</title></head>
3<body bgcolor=white>
4
5<table width="100%" bgcolor="#330077" border=0 cellpadding=4 cellspacing=0>
6<tr><td>&nbsp; <font size=+5 color="#EEEEFF" face="Georgia,Palatino,Times,Roman"><b>llvm Assembly Language Reference Manual</b></font></td>
7</tr></table>
8
9<ol>
10 <li><a href="#abstract">Abstract</a>
11 <li><a href="#introduction">Introduction</a>
12 <li><a href="#identifiers">Identifiers</a>
13 <li><a href="#typesystem">Type System</a>
14 <ol>
15 <li><a href="#t_primitive">Primitive Types</a>
16 <ol>
17 <li><a href="#t_classifications">Type Classifications</a>
18 </ol>
19 <li><a href="#t_derived">Derived Types</a>
20 <ol>
21 <li><a href="#t_array" >Array Type</a>
Chris Lattner7faa8832002-04-14 06:13:44 +000022 <li><a href="#t_function">Function Type</a>
Chris Lattner00950542001-06-06 20:29:01 +000023 <li><a href="#t_pointer">Pointer Type</a>
24 <li><a href="#t_struct" >Structure Type</a>
Chris Lattner690d99b2002-08-29 18:33:48 +000025 <!-- <li><a href="#t_packed" >Packed Type</a> -->
Chris Lattner00950542001-06-06 20:29:01 +000026 </ol>
27 </ol>
28 <li><a href="#highlevel">High Level Structure</a>
29 <ol>
30 <li><a href="#modulestructure">Module Structure</a>
Chris Lattner2b7d3202002-05-06 03:03:22 +000031 <li><a href="#globalvars">Global Variables</a>
Chris Lattner7faa8832002-04-14 06:13:44 +000032 <li><a href="#functionstructure">Function Structure</a>
Chris Lattner00950542001-06-06 20:29:01 +000033 </ol>
34 <li><a href="#instref">Instruction Reference</a>
35 <ol>
36 <li><a href="#terminators">Terminator Instructions</a>
37 <ol>
Chris Lattner7faa8832002-04-14 06:13:44 +000038 <li><a href="#i_ret" >'<tt>ret</tt>' Instruction</a>
39 <li><a href="#i_br" >'<tt>br</tt>' Instruction</a>
40 <li><a href="#i_switch">'<tt>switch</tt>' Instruction</a>
41 <li><a href="#i_invoke">'<tt>invoke</tt>' Instruction</a>
Chris Lattner00950542001-06-06 20:29:01 +000042 </ol>
Chris Lattner00950542001-06-06 20:29:01 +000043 <li><a href="#binaryops">Binary Operations</a>
44 <ol>
45 <li><a href="#i_add" >'<tt>add</tt>' Instruction</a>
46 <li><a href="#i_sub" >'<tt>sub</tt>' Instruction</a>
47 <li><a href="#i_mul" >'<tt>mul</tt>' Instruction</a>
48 <li><a href="#i_div" >'<tt>div</tt>' Instruction</a>
49 <li><a href="#i_rem" >'<tt>rem</tt>' Instruction</a>
50 <li><a href="#i_setcc">'<tt>set<i>cc</i></tt>' Instructions</a>
51 </ol>
52 <li><a href="#bitwiseops">Bitwise Binary Operations</a>
53 <ol>
54 <li><a href="#i_and">'<tt>and</tt>' Instruction</a>
55 <li><a href="#i_or" >'<tt>or</tt>' Instruction</a>
56 <li><a href="#i_xor">'<tt>xor</tt>' Instruction</a>
57 <li><a href="#i_shl">'<tt>shl</tt>' Instruction</a>
58 <li><a href="#i_shr">'<tt>shr</tt>' Instruction</a>
59 </ol>
60 <li><a href="#memoryops">Memory Access Operations</a>
61 <ol>
62 <li><a href="#i_malloc" >'<tt>malloc</tt>' Instruction</a>
63 <li><a href="#i_free" >'<tt>free</tt>' Instruction</a>
64 <li><a href="#i_alloca" >'<tt>alloca</tt>' Instruction</a>
65 <li><a href="#i_load" >'<tt>load</tt>' Instruction</a>
66 <li><a href="#i_store" >'<tt>store</tt>' Instruction</a>
Chris Lattner2b7d3202002-05-06 03:03:22 +000067 <li><a href="#i_getelementptr">'<tt>getelementptr</tt>' Instruction</a>
Chris Lattner00950542001-06-06 20:29:01 +000068 </ol>
69 <li><a href="#otherops">Other Operations</a>
70 <ol>
Chris Lattner6536cfe2002-05-06 22:08:29 +000071 <li><a href="#i_phi" >'<tt>phi</tt>' Instruction</a>
Chris Lattner33ba0d92001-07-09 00:26:23 +000072 <li><a href="#i_cast">'<tt>cast .. to</tt>' Instruction</a>
Chris Lattner00950542001-06-06 20:29:01 +000073 <li><a href="#i_call" >'<tt>call</tt>' Instruction</a>
Chris Lattner00950542001-06-06 20:29:01 +000074 </ol>
Chris Lattner00950542001-06-06 20:29:01 +000075 </ol>
Chris Lattner6536cfe2002-05-06 22:08:29 +000076<!--
Chris Lattner00950542001-06-06 20:29:01 +000077 <li><a href="#related">Related Work</a>
Chris Lattner6536cfe2002-05-06 22:08:29 +000078-->
Chris Lattner00950542001-06-06 20:29:01 +000079</ol>
80
81
82<!-- *********************************************************************** -->
Chris Lattner2b7d3202002-05-06 03:03:22 +000083<p><table width="100%" bgcolor="#330077" border=0 cellpadding=4 cellspacing=0>
84<tr><td align=center><font color="#EEEEFF" size=+2 face="Georgia,Palatino"><b>
Chris Lattner00950542001-06-06 20:29:01 +000085<a name="abstract">Abstract
86</b></font></td></tr></table><ul>
87<!-- *********************************************************************** -->
88
89<blockquote>
Chris Lattner7bae3952002-06-25 18:03:17 +000090 This document is a reference manual for the LLVM assembly language. LLVM is
91 an SSA based representation that provides type safety, low level operations,
92 flexibility, and the capability of representing 'all' high level languages
93 cleanly. It is the common code representation used throughout all phases of
94 the LLVM compilation strategy.
Chris Lattner00950542001-06-06 20:29:01 +000095</blockquote>
96
97
98
99
100<!-- *********************************************************************** -->
Chris Lattner2b7d3202002-05-06 03:03:22 +0000101</ul><table width="100%" bgcolor="#330077" border=0 cellpadding=4 cellspacing=0>
102<tr><td align=center><font color="#EEEEFF" size=+2 face="Georgia,Palatino"><b>
Chris Lattner00950542001-06-06 20:29:01 +0000103<a name="introduction">Introduction
104</b></font></td></tr></table><ul>
105<!-- *********************************************************************** -->
106
Chris Lattner7faa8832002-04-14 06:13:44 +0000107The LLVM code representation is designed to be used in three different forms: as
108an in-memory compiler IR, as an on-disk bytecode representation, suitable for
109fast loading by a dynamic compiler, and as a human readable assembly language
110representation. This allows LLVM to provide a powerful intermediate
111representation for efficient compiler transformations and analysis, while
112providing a natural means to debug and visualize the transformations. The three
113different forms of LLVM are all equivalent. This document describes the human
114readable representation and notation.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000115
Chris Lattner7faa8832002-04-14 06:13:44 +0000116The LLVM representation aims to be a light weight and low level while being
Chris Lattnerb7c6c2a2002-06-25 20:20:08 +0000117expressive, typed, and extensible at the same time. It aims to be a "universal
118IR" of sorts, by being at a low enough level that high level ideas may be
119cleanly mapped to it (similar to how microprocessors are "universal IR's",
120allowing many source languages to be mapped to them). By providing type
121information, LLVM can be used as the target of optimizations: for example,
122through pointer analysis, it can be proven that a C automatic variable is never
123accessed outside of the current function... allowing it to be promoted to a
124simple SSA value instead of a memory location.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000125
126<!-- _______________________________________________________________________ -->
127</ul><a name="wellformed"><h4><hr size=0>Well Formedness</h4><ul>
128
Chris Lattner7faa8832002-04-14 06:13:44 +0000129It is important to note that this document describes 'well formed' llvm assembly
130language. There is a difference between what the parser accepts and what is
131considered 'well formed'. For example, the following instruction is
132syntactically okay, but not well formed:<p>
Chris Lattner00950542001-06-06 20:29:01 +0000133
134<pre>
135 %x = <a href="#i_add">add</a> int 1, %x
136</pre>
137
Chris Lattner7bae3952002-06-25 18:03:17 +0000138...because the definition of %x does not dominate all of its uses. The LLVM
139infrastructure provides a verification pass that may be used to verify that an
140LLVM module is well formed. This pass is automatically run by the parser after
Chris Lattner2b7d3202002-05-06 03:03:22 +0000141parsing input assembly, and by the optimizer before it outputs bytecode. The
Chris Lattner7faa8832002-04-14 06:13:44 +0000142violations pointed out by the verifier pass indicate bugs in transformation
Chris Lattner2b7d3202002-05-06 03:03:22 +0000143passes or input to the parser.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000144
Chris Lattner7bae3952002-06-25 18:03:17 +0000145<!-- Describe the typesetting conventions here. -->
Chris Lattner00950542001-06-06 20:29:01 +0000146
147
148<!-- *********************************************************************** -->
Chris Lattner2b7d3202002-05-06 03:03:22 +0000149</ul><table width="100%" bgcolor="#330077" border=0 cellpadding=4 cellspacing=0>
150<tr><td align=center><font color="#EEEEFF" size=+2 face="Georgia,Palatino"><b>
Chris Lattner00950542001-06-06 20:29:01 +0000151<a name="identifiers">Identifiers
152</b></font></td></tr></table><ul>
153<!-- *********************************************************************** -->
154
155LLVM uses three different forms of identifiers, for different purposes:<p>
156
157<ol>
Chris Lattner2b7d3202002-05-06 03:03:22 +0000158<li>Numeric constants are represented as you would expect: 12, -3 123.421, etc. Floating point constants have an optional hexidecimal notation.
Chris Lattner00950542001-06-06 20:29:01 +0000159<li>Named values are represented as a string of characters with a '%' prefix. For example, %foo, %DivisionByZero, %a.really.long.identifier. The actual regular expression used is '<tt>%[a-zA-Z$._][a-zA-Z$._0-9]*</tt>'.
160<li>Unnamed values are represented as an unsigned numeric value with a '%' prefix. For example, %12, %2, %44.
161</ol><p>
162
Chris Lattner7faa8832002-04-14 06:13:44 +0000163LLVM requires the values start with a '%' sign for two reasons: Compilers don't
164need to worry about name clashes with reserved words, and the set of reserved
165words may be expanded in the future without penalty. Additionally, unnamed
166identifiers allow a compiler to quickly come up with a temporary variable
167without having to avoid symbol table conflicts.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000168
Chris Lattner7faa8832002-04-14 06:13:44 +0000169Reserved words in LLVM are very similar to reserved words in other languages.
170There are keywords for different opcodes ('<tt><a href="#i_add">add</a></tt>',
171'<tt><a href="#i_cast">cast</a></tt>', '<tt><a href="#i_ret">ret</a></tt>',
172etc...), for primitive type names ('<tt><a href="#t_void">void</a></tt>',
173'<tt><a href="#t_uint">uint</a></tt>', etc...), and others. These reserved
174words cannot conflict with variable names, because none of them start with a '%'
175character.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000176
Chris Lattner7faa8832002-04-14 06:13:44 +0000177Here is an example of LLVM code to multiply the integer variable '<tt>%X</tt>'
178by 8:<p>
Chris Lattner00950542001-06-06 20:29:01 +0000179
180The easy way:
181<pre>
Chris Lattner2b7d3202002-05-06 03:03:22 +0000182 %result = <a href="#i_mul">mul</a> uint %X, 8
Chris Lattner00950542001-06-06 20:29:01 +0000183</pre>
184
185After strength reduction:
186<pre>
Chris Lattner2b7d3202002-05-06 03:03:22 +0000187 %result = <a href="#i_shl">shl</a> uint %X, ubyte 3
Chris Lattner00950542001-06-06 20:29:01 +0000188</pre>
189
190And the hard way:
191<pre>
Chris Lattner7bae3952002-06-25 18:03:17 +0000192 <a href="#i_add">add</a> uint %X, %X <i>; yields {uint}:%0</i>
193 <a href="#i_add">add</a> uint %0, %0 <i>; yields {uint}:%1</i>
Chris Lattner2b7d3202002-05-06 03:03:22 +0000194 %result = <a href="#i_add">add</a> uint %1, %1
Chris Lattner00950542001-06-06 20:29:01 +0000195</pre>
196
197This last way of multiplying <tt>%X</tt> by 8 illustrates several important lexical features of LLVM:<p>
198
199<ol>
200<li>Comments are delimited with a '<tt>;</tt>' and go until the end of line.
Chris Lattner7faa8832002-04-14 06:13:44 +0000201<li>Unnamed temporaries are created when the result of a computation is not
202 assigned to a named value.
Chris Lattner00950542001-06-06 20:29:01 +0000203<li>Unnamed temporaries are numbered sequentially
204</ol><p>
205
Chris Lattner7faa8832002-04-14 06:13:44 +0000206...and it also show a convention that we follow in this document. When
207demonstrating instructions, we will follow an instruction with a comment that
208defines the type and name of value produced. Comments are shown in italic
209text.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000210
Chris Lattner2b7d3202002-05-06 03:03:22 +0000211The one unintuitive notation for constants is the optional hexidecimal form of
212floating point constants. For example, the form '<tt>double
2130x432ff973cafa8000</tt>' is equivalent to (but harder to read than) '<tt>double
2144.5e+15</tt>' which is also supported by the parser. The only time hexadecimal
215floating point constants are useful (and the only time that they are generated
216by the disassembler) is when an FP constant has to be emitted that is not
217representable as a decimal floating point number exactly. For example, NaN's,
218infinities, and other special cases are represented in their IEEE hexadecimal
219format so that assembly and disassembly do not cause any bits to change in the
220constants.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000221
222
223<!-- *********************************************************************** -->
Chris Lattner2b7d3202002-05-06 03:03:22 +0000224</ul><table width="100%" bgcolor="#330077" border=0 cellpadding=4 cellspacing=0>
225<tr><td align=center><font color="#EEEEFF" size=+2 face="Georgia,Palatino"><b>
Chris Lattner00950542001-06-06 20:29:01 +0000226<a name="typesystem">Type System
227</b></font></td></tr></table><ul>
228<!-- *********************************************************************** -->
229
Chris Lattner2b7d3202002-05-06 03:03:22 +0000230The LLVM type system is one of the most important features of the intermediate
Chris Lattnerb7c6c2a2002-06-25 20:20:08 +0000231representation. Being typed enables a number of optimizations to be performed
232on the IR directly, without having to do extra analyses on the side before the
233transformation. A strong type system makes it easier to read the generated code
234and enables novel analyses and transformations that are not feasible to perform
235on normal three address code representations.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000236
Chris Lattner7bae3952002-06-25 18:03:17 +0000237<!-- The written form for the type system was heavily influenced by the
238syntactic problems with types in the C language<sup><a
239href="#rw_stroustrup">1</a></sup>.<p> -->
Chris Lattner00950542001-06-06 20:29:01 +0000240
241
242
243<!-- ======================================================================= -->
Chris Lattner2b7d3202002-05-06 03:03:22 +0000244</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0>
245<tr><td>&nbsp;</td><td width="100%">&nbsp; <font color="#EEEEFF" face="Georgia,Palatino"><b>
Chris Lattner00950542001-06-06 20:29:01 +0000246<a name="t_primitive">Primitive Types
247</b></font></td></tr></table><ul>
248
Chris Lattner7faa8832002-04-14 06:13:44 +0000249The primitive types are the fundemental building blocks of the LLVM system. The
250current set of primitive types are as follows:<p>
Chris Lattner00950542001-06-06 20:29:01 +0000251
252<table border=0 align=center><tr><td>
253
254<table border=1 cellspacing=0 cellpadding=4 align=center>
255<tr><td><tt>void</tt></td> <td>No value</td></tr>
256<tr><td><tt>ubyte</tt></td> <td>Unsigned 8 bit value</td></tr>
257<tr><td><tt>ushort</tt></td><td>Unsigned 16 bit value</td></tr>
258<tr><td><tt>uint</tt></td> <td>Unsigned 32 bit value</td></tr>
259<tr><td><tt>ulong</tt></td> <td>Unsigned 64 bit value</td></tr>
260<tr><td><tt>float</tt></td> <td>32 bit floating point value</td></tr>
261<tr><td><tt>label</tt></td> <td>Branch destination</td></tr>
262</table>
263
Chris Lattner7faa8832002-04-14 06:13:44 +0000264</td><td valign=top>
Chris Lattner00950542001-06-06 20:29:01 +0000265
266<table border=1 cellspacing=0 cellpadding=4 align=center>
267<tr><td><tt>bool</tt></td> <td>True or False value</td></tr>
268<tr><td><tt>sbyte</tt></td> <td>Signed 8 bit value</td></tr>
269<tr><td><tt>short</tt></td> <td>Signed 16 bit value</td></tr>
270<tr><td><tt>int</tt></td> <td>Signed 32 bit value</td></tr>
271<tr><td><tt>long</tt></td> <td>Signed 64 bit value</td></tr>
272<tr><td><tt>double</tt></td><td>64 bit floating point value</td></tr>
Chris Lattner00950542001-06-06 20:29:01 +0000273</table>
274
275</td></tr></table><p>
276
277
278
279<!-- _______________________________________________________________________ -->
280</ul><a name="t_classifications"><h4><hr size=0>Type Classifications</h4><ul>
281
282These different primitive types fall into a few useful classifications:<p>
283
284<table border=1 cellspacing=0 cellpadding=4 align=center>
285<tr><td><a name="t_signed">signed</td> <td><tt>sbyte, short, int, long, float, double</tt></td></tr>
286<tr><td><a name="t_unsigned">unsigned</td><td><tt>ubyte, ushort, uint, ulong</tt></td></tr>
287<tr><td><a name="t_integral">integral</td><td><tt>ubyte, sbyte, ushort, short, uint, int, ulong, long</tt></td></tr>
288<tr><td><a name="t_floating">floating point</td><td><tt>float, double</tt></td></tr>
Chris Lattner2b7d3202002-05-06 03:03:22 +0000289<tr><td><a name="t_firstclass">first class</td><td><tt>bool, ubyte, sbyte, ushort, short,<br> uint, int, ulong, long, float, double, <a href="#t_pointer">pointer</a></tt></td></tr>
Chris Lattner00950542001-06-06 20:29:01 +0000290</table><p>
291
292
293
294
295
296<!-- ======================================================================= -->
297</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0><tr><td>&nbsp;</td><td width="100%">&nbsp; <font color="#EEEEFF" face="Georgia,Palatino"><b>
298<a name="t_derived">Derived Types
299</b></font></td></tr></table><ul>
300
Chris Lattner7faa8832002-04-14 06:13:44 +0000301The real power in LLVM comes from the derived types in the system. This is what
302allows a programmer to represent arrays, functions, pointers, and other useful
303types. Note that these derived types may be recursive: For example, it is
304possible to have a two dimensional array.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000305
306
307
308<!-- _______________________________________________________________________ -->
309</ul><a name="t_array"><h4><hr size=0>Array Type</h4><ul>
310
311<h5>Overview:</h5>
312
Chris Lattner7faa8832002-04-14 06:13:44 +0000313The array type is a very simple derived type that arranges elements sequentially
314in memory. The array type requires a size (number of elements) and an
315underlying data type.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000316
Chris Lattner7faa8832002-04-14 06:13:44 +0000317<h5>Syntax:</h5>
318<pre>
319 [&lt;# elements&gt; x &lt;elementtype&gt;]
320</pre>
Chris Lattner00950542001-06-06 20:29:01 +0000321
Chris Lattner2b7d3202002-05-06 03:03:22 +0000322The number of elements is a constant integer value, elementtype may be any type
Chris Lattner7faa8832002-04-14 06:13:44 +0000323with a size.<p>
324
325<h5>Examples:</h5>
326<ul>
Chris Lattner00950542001-06-06 20:29:01 +0000327 <tt>[40 x int ]</tt>: Array of 40 integer values.<br>
328 <tt>[41 x int ]</tt>: Array of 41 integer values.<br>
329 <tt>[40 x uint]</tt>: Array of 40 unsigned integer values.<p>
Chris Lattner7faa8832002-04-14 06:13:44 +0000330</ul>
Chris Lattner00950542001-06-06 20:29:01 +0000331
332Here are some examples of multidimensional arrays:<p>
333<ul>
334<table border=0 cellpadding=0 cellspacing=0>
335<tr><td><tt>[3 x [4 x int]]</tt></td><td>: 3x4 array integer values.</td></tr>
Chris Lattner7faa8832002-04-14 06:13:44 +0000336<tr><td><tt>[12 x [10 x float]]</tt></td><td>: 2x10 array of single precision floating point values.</td></tr>
Chris Lattner00950542001-06-06 20:29:01 +0000337<tr><td><tt>[2 x [3 x [4 x uint]]]</tt></td><td>: 2x3x4 array of unsigned integer values.</td></tr>
338</table>
339</ul>
340
341
Chris Lattner00950542001-06-06 20:29:01 +0000342<!-- _______________________________________________________________________ -->
Chris Lattner7faa8832002-04-14 06:13:44 +0000343</ul><a name="t_function"><h4><hr size=0>Function Type</h4><ul>
Chris Lattner00950542001-06-06 20:29:01 +0000344
345<h5>Overview:</h5>
346
Chris Lattner7faa8832002-04-14 06:13:44 +0000347The function type can be thought of as a function signature. It consists of a
348return type and a list of formal parameter types. Function types are usually
349used when to build virtual function tables (which are structures of pointers to
350functions), for indirect function calls, and when defining a function.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000351
352<h5>Syntax:</h5>
353<pre>
354 &lt;returntype&gt; (&lt;parameter list&gt;)
355</pre>
356
Chris Lattner7faa8832002-04-14 06:13:44 +0000357Where '<tt>&lt;parameter list&gt;</tt>' is a comma seperated list of type
358specifiers. Optionally, the parameter list may include a type <tt>...</tt>,
359which indicates that the function takes a variable number of arguments. Note
360that there currently is no way to define a function in LLVM that takes a
361variable number of arguments, but it is possible to <b>call</b> a function that
362is vararg.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000363
364<h5>Examples:</h5>
365<ul>
366<table border=0 cellpadding=0 cellspacing=0>
Chris Lattner7faa8832002-04-14 06:13:44 +0000367
368<tr><td><tt>int (int)</tt></td><td>: function taking an <tt>int</tt>, returning
369an <tt>int</tt></td></tr>
370
371<tr><td><tt>float (int, int *) *</tt></td><td>: <a href="#t_pointer">Pointer</a>
372to a function that takes an <tt>int</tt> and a <a href="#t_pointer">pointer</a>
373to <tt>int</tt>, returning <tt>float</tt>.</td></tr>
374
375<tr><td><tt>int (sbyte *, ...)</tt></td><td>: A vararg function that takes at
376least one <a href="#t_pointer">pointer</a> to <tt>sbyte</tt> (signed char in C),
377which returns an integer. This is the signature for <tt>printf</tt> in
378LLVM.</td></tr>
379
Chris Lattner00950542001-06-06 20:29:01 +0000380</table>
381</ul>
382
383
384
385<!-- _______________________________________________________________________ -->
386</ul><a name="t_struct"><h4><hr size=0>Structure Type</h4><ul>
387
388<h5>Overview:</h5>
389
Chris Lattner2b7d3202002-05-06 03:03:22 +0000390The structure type is used to represent a collection of data members together in
Chris Lattner7bae3952002-06-25 18:03:17 +0000391memory. The packing of the field types is defined to match the ABI of the
392underlying processor. The elements of a structure may be any type that has a
393size.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000394
Chris Lattner2b7d3202002-05-06 03:03:22 +0000395Structures are accessed using '<tt><a href="#i_load">load</a></tt> and '<tt><a
396href="#i_store">store</a></tt>' by getting a pointer to a field with the '<tt><a
397href="#i_getelementptr">getelementptr</a></tt>' instruction.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000398
399<h5>Syntax:</h5>
400<pre>
401 { &lt;type list&gt; }
402</pre>
403
404
405<h5>Examples:</h5>
406<table border=0 cellpadding=0 cellspacing=0>
Chris Lattner7faa8832002-04-14 06:13:44 +0000407
408<tr><td><tt>{ int, int, int }</tt></td><td>: a triple of three <tt>int</tt>
409values</td></tr>
410
Chris Lattner7bae3952002-06-25 18:03:17 +0000411<tr><td><tt>{ float, int (int) * }</tt></td><td>: A pair, where the first
Chris Lattner7faa8832002-04-14 06:13:44 +0000412element is a <tt>float</tt> and the second element is a <a
413href="#t_pointer">pointer</a> to a <a href="t_function">function</a> that takes
414an <tt>int</tt>, returning an <tt>int</tt>.</td></tr>
415
Chris Lattner00950542001-06-06 20:29:01 +0000416</table>
417
418
419<!-- _______________________________________________________________________ -->
420</ul><a name="t_pointer"><h4><hr size=0>Pointer Type</h4><ul>
421
Chris Lattner7faa8832002-04-14 06:13:44 +0000422<h5>Overview:</h5>
423
424As in many languages, the pointer type represents a pointer or reference to
425another object, which must live in memory.<p>
426
427<h5>Syntax:</h5>
428<pre>
429 &lt;type&gt; *
430</pre>
431
432<h5>Examples:</h5>
433
434<table border=0 cellpadding=0 cellspacing=0>
435
436<tr><td><tt>[4x int]*</tt></td><td>: <a href="#t_pointer">pointer</a> to <a
437href="#t_array">array</a> of four <tt>int</tt> values</td></tr>
438
439<tr><td><tt>int (int *) *</tt></td><td>: A <a href="#t_pointer">pointer</a> to a
440<a href="t_function">function</a> that takes an <tt>int</tt>, returning an
441<tt>int</tt>.</td></tr>
442
443</table>
444<p>
445
Chris Lattner00950542001-06-06 20:29:01 +0000446
447<!-- _______________________________________________________________________ -->
Chris Lattner7faa8832002-04-14 06:13:44 +0000448<!--
Chris Lattner00950542001-06-06 20:29:01 +0000449</ul><a name="t_packed"><h4><hr size=0>Packed Type</h4><ul>
450
451Mention/decide that packed types work with saturation or not. Maybe have a packed+saturated type in addition to just a packed type.<p>
452
453Packed types should be 'nonsaturated' because standard data types are not saturated. Maybe have a saturated packed type?<p>
454
Chris Lattner7faa8832002-04-14 06:13:44 +0000455-->
456
Chris Lattner00950542001-06-06 20:29:01 +0000457
458<!-- *********************************************************************** -->
Chris Lattner2b7d3202002-05-06 03:03:22 +0000459</ul><table width="100%" bgcolor="#330077" border=0 cellpadding=4 cellspacing=0>
460<tr><td align=center><font color="#EEEEFF" size=+2 face="Georgia,Palatino"><b>
Chris Lattner00950542001-06-06 20:29:01 +0000461<a name="highlevel">High Level Structure
462</b></font></td></tr></table><ul>
463<!-- *********************************************************************** -->
464
465
466<!-- ======================================================================= -->
Chris Lattner2b7d3202002-05-06 03:03:22 +0000467</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0>
468<tr><td>&nbsp;</td><td width="100%">&nbsp; <font color="#EEEEFF" face="Georgia,Palatino"><b>
Chris Lattner00950542001-06-06 20:29:01 +0000469<a name="modulestructure">Module Structure
470</b></font></td></tr></table><ul>
471
Chris Lattner2b7d3202002-05-06 03:03:22 +0000472LLVM programs are composed of "Module"s, each of which is a translation unit of
473the input programs. Each module consists of functions, global variables, and
474symbol table entries. Modules may be combined together with the LLVM linker,
475which merges function (and global variable) definitions, resolves forward
476declarations, and merges symbol table entries. Here is an example of the "hello world" module:<p>
Chris Lattner00950542001-06-06 20:29:01 +0000477
Chris Lattner2b7d3202002-05-06 03:03:22 +0000478<pre>
479<i>; Declare the string constant as a global constant...</i>
480<a href="#identifiers">%.LC0</a> = <a href="#linkage_decl">internal</a> <a href="#globalvars">constant</a> <a href="#t_array">[13 x sbyte]</a> c"hello world\0A\00" <i>; [13 x sbyte]*</i>
481
482<i>; Forward declaration of puts</i>
483<a href="#functionstructure">declare</a> int "puts"(sbyte*) <i>; int(sbyte*)* </i>
484
485<i>; Definition of main function</i>
486int "main"() { <i>; int()* </i>
487 <i>; Convert [13x sbyte]* to sbyte *...</i>
488 %cast210 = <a href="#i_getelementptr">getelementptr</a> [13 x sbyte]* %.LC0, uint 0, uint 0 <i>; sbyte*</i>
489
490 <i>; Call puts function to write out the string to stdout...</i>
491 <a href="#i_call">call</a> int %puts(sbyte* %cast210) <i>; int</i>
492 <a href="#i_ret">ret</a> int 0
493}
494</pre>
495
496This example is made up of a <a href="#globalvars">global variable</a> named
497"<tt>.LC0</tt>", an external declaration of the "<tt>puts</tt>" function, and a
498<a href="#functionstructure">function definition</a> for "<tt>main</tt>".<p>
499
500<a name="linkage_decl">
501In general, a module is made up of a list of global values, where both functions
502and global variables are global values. Global values are represented by a
503pointer to a memory location (in this case, a pointer to an array of char, and a
504pointer to a function), and can be either "internal" or externally accessible
Chris Lattner7bae3952002-06-25 18:03:17 +0000505(which corresponds to the static keyword in C, when used at global scope).<p>
Chris Lattner2b7d3202002-05-06 03:03:22 +0000506
507For example, since the "<tt>.LC0</tt>" variable is defined to be internal, if
508another module defined a "<tt>.LC0</tt>" variable and was linked with this one,
509one of the two would be renamed, preventing a collision. Since "<tt>main</tt>"
Chris Lattner7bae3952002-06-25 18:03:17 +0000510and "<tt>puts</tt>" are external (i.e., lacking "<tt>internal</tt>"
511declarations), they are accessible outside of the current module. It is illegal
512for a function declaration to be "<tt>internal</tt>".<p>
Chris Lattner00950542001-06-06 20:29:01 +0000513
514
515<!-- ======================================================================= -->
Chris Lattner2b7d3202002-05-06 03:03:22 +0000516</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0>
517<tr><td>&nbsp;</td><td width="100%">&nbsp; <font color="#EEEEFF" face="Georgia,Palatino"><b>
518<a name="globalvars">Global Variables
519</b></font></td></tr></table><ul>
520
521Global variables define regions of memory allocated at compilation time instead
Chris Lattner7bae3952002-06-25 18:03:17 +0000522of run-time. Global variables may optionally be initialized. A variable may
523be defined as a global "constant", which indicates that the contents of the
Chris Lattner2b7d3202002-05-06 03:03:22 +0000524variable will never be modified (opening options for optimization). Constants
525must always have an initial value.<p>
526
Chris Lattner7bae3952002-06-25 18:03:17 +0000527As SSA values, global variables define pointer values that are in scope
528(i.e. they dominate) for all basic blocks in the program. Global variables
529always define a pointer to their "content" type because they describe a region
530of memory, and all memory objects in LLVM are accessed through pointers.<p>
Chris Lattner2b7d3202002-05-06 03:03:22 +0000531
532
533
534<!-- ======================================================================= -->
535</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0>
536<tr><td>&nbsp;</td><td width="100%">&nbsp; <font color="#EEEEFF" face="Georgia,Palatino"><b>
Chris Lattner7faa8832002-04-14 06:13:44 +0000537<a name="functionstructure">Function Structure
Chris Lattner00950542001-06-06 20:29:01 +0000538</b></font></td></tr></table><ul>
539
Chris Lattner2b7d3202002-05-06 03:03:22 +0000540LLVM functions definitions are composed of a (possibly empty) argument list, an
541opening curly brace, a list of basic blocks, and a closing curly brace. LLVM
542function declarations are defined with the "<tt>declare</tt>" keyword, a
543function name and a function signature.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000544
Chris Lattner2b7d3202002-05-06 03:03:22 +0000545A function definition contains a list of basic blocks, forming the CFG for the
546function. Each basic block may optionally start with a label (giving the basic
547block a symbol table entry), contains a list of instructions, and ends with a <a
548href="#terminators">terminator</a> instruction (such as a branch or function
549return).<p>
550
551The first basic block in program is special in two ways: it is immediately
552executed on entrance to the function, and it is not allowed to have predecessor
553basic blocks (i.e. there can not be any branches to the entry block of a
554function).<p>
Chris Lattner00950542001-06-06 20:29:01 +0000555
556
557<!-- *********************************************************************** -->
Chris Lattner2b7d3202002-05-06 03:03:22 +0000558</ul><table width="100%" bgcolor="#330077" border=0 cellpadding=4 cellspacing=0>
559<tr><td align=center><font color="#EEEEFF" size=+2 face="Georgia,Palatino"><b>
Chris Lattner00950542001-06-06 20:29:01 +0000560<a name="instref">Instruction Reference
561</b></font></td></tr></table><ul>
562<!-- *********************************************************************** -->
563
Chris Lattner2b7d3202002-05-06 03:03:22 +0000564The LLVM instruction set consists of several different classifications of
Chris Lattnere489aa52002-08-14 17:55:59 +0000565instructions: <a href="#terminators">terminator instructions</a>, <a
566href="#binaryops">binary instructions</a>, <a href="#memoryops">memory
567instructions</a>, and <a href="#otherops">other instructions</a>.<p>
Chris Lattner2b7d3202002-05-06 03:03:22 +0000568
Chris Lattner00950542001-06-06 20:29:01 +0000569
570<!-- ======================================================================= -->
Chris Lattner2b7d3202002-05-06 03:03:22 +0000571</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0>
572<tr><td>&nbsp;</td><td width="100%">&nbsp; <font color="#EEEEFF" face="Georgia,Palatino"><b>
Chris Lattner00950542001-06-06 20:29:01 +0000573<a name="terminators">Terminator Instructions
574</b></font></td></tr></table><ul>
575
Chris Lattner2b7d3202002-05-06 03:03:22 +0000576As mentioned <a href="#functionstructure">previously</a>, every basic block in a
Chris Lattner7bae3952002-06-25 18:03:17 +0000577program ends with a "Terminator" instruction, which indicates which block should
578be executed after the current block is finished. These terminator instructions
579typically yield a '<tt>void</tt>' value: they produce control flow, not values
580(the one exception being the '<a href="#i_invoke"><tt>invoke</tt></a>'
581instruction).<p>
Chris Lattner00950542001-06-06 20:29:01 +0000582
Chris Lattner7faa8832002-04-14 06:13:44 +0000583There are four different terminator instructions: the '<a
584href="#i_ret"><tt>ret</tt></a>' instruction, the '<a
585href="#i_br"><tt>br</tt></a>' instruction, the '<a
586href="#i_switch"><tt>switch</tt></a>' instruction, and the '<a
587href="#i_invoke"><tt>invoke</tt></a>' instruction.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000588
589
590<!-- _______________________________________________________________________ -->
591</ul><a name="i_ret"><h4><hr size=0>'<tt>ret</tt>' Instruction</h4><ul>
592
593<h5>Syntax:</h5>
594<pre>
Chris Lattner7faa8832002-04-14 06:13:44 +0000595 ret &lt;type&gt; &lt;value&gt; <i>; Return a value from a non-void function</i>
596 ret void <i>; Return from void function</i>
Chris Lattner00950542001-06-06 20:29:01 +0000597</pre>
598
599<h5>Overview:</h5>
Chris Lattner00950542001-06-06 20:29:01 +0000600
Chris Lattner2b7d3202002-05-06 03:03:22 +0000601The '<tt>ret</tt>' instruction is used to return control flow (and a value) from
602a function, back to the caller.<p>
Chris Lattner7faa8832002-04-14 06:13:44 +0000603
604There are two forms of the '<tt>ret</tt>' instructruction: one that returns a
605value and then causes control flow, and one that just causes control flow to
606occur.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000607
608<h5>Arguments:</h5>
Chris Lattner7faa8832002-04-14 06:13:44 +0000609
610The '<tt>ret</tt>' instruction may return any '<a href="#t_firstclass">first
611class</a>' type. Notice that a function is not <a href="#wellformed">well
612formed</a> if there exists a '<tt>ret</tt>' instruction inside of the function
613that returns a value that does not match the return type of the function.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000614
615<h5>Semantics:</h5>
Chris Lattner7faa8832002-04-14 06:13:44 +0000616
617When the '<tt>ret</tt>' instruction is executed, control flow returns back to
618the calling function's context. If the instruction returns a value, that value
619shall be propogated into the calling function's data space.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000620
621<h5>Example:</h5>
622<pre>
623 ret int 5 <i>; Return an integer value of 5</i>
Chris Lattner7faa8832002-04-14 06:13:44 +0000624 ret void <i>; Return from a void function</i>
Chris Lattner00950542001-06-06 20:29:01 +0000625</pre>
626
627
628<!-- _______________________________________________________________________ -->
629</ul><a name="i_br"><h4><hr size=0>'<tt>br</tt>' Instruction</h4><ul>
630
631<h5>Syntax:</h5>
632<pre>
633 br bool &lt;cond&gt;, label &lt;iftrue&gt;, label &lt;iffalse&gt;
634 br label &lt;dest&gt; <i>; Unconditional branch</i>
635</pre>
636
637<h5>Overview:</h5>
Chris Lattner7faa8832002-04-14 06:13:44 +0000638
639The '<tt>br</tt>' instruction is used to cause control flow to transfer to a
640different basic block in the current function. There are two forms of this
641instruction, corresponding to a conditional branch and an unconditional
642branch.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000643
644<h5>Arguments:</h5>
645
Chris Lattner7faa8832002-04-14 06:13:44 +0000646The conditional branch form of the '<tt>br</tt>' instruction takes a single
647'<tt>bool</tt>' value and two '<tt>label</tt>' values. The unconditional form
648of the '<tt>br</tt>' instruction takes a single '<tt>label</tt>' value as a
649target.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000650
651<h5>Semantics:</h5>
652
Chris Lattner7faa8832002-04-14 06:13:44 +0000653Upon execution of a conditional '<tt>br</tt>' instruction, the '<tt>bool</tt>'
654argument is evaluated. If the value is <tt>true</tt>, control flows to the
655'<tt>iftrue</tt>' '<tt>label</tt>' argument. If "cond" is <tt>false</tt>,
656control flows to the '<tt>iffalse</tt>' '<tt>label</tt>' argument.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000657
658<h5>Example:</h5>
659<pre>
660Test:
661 %cond = <a href="#i_setcc">seteq</a> int %a, %b
662 br bool %cond, label %IfEqual, label %IfUnequal
663IfEqual:
Chris Lattner2b7d3202002-05-06 03:03:22 +0000664 <a href="#i_ret">ret</a> int 1
Chris Lattner00950542001-06-06 20:29:01 +0000665IfUnequal:
Chris Lattner2b7d3202002-05-06 03:03:22 +0000666 <a href="#i_ret">ret</a> int 0
Chris Lattner00950542001-06-06 20:29:01 +0000667</pre>
668
669
670<!-- _______________________________________________________________________ -->
671</ul><a name="i_switch"><h4><hr size=0>'<tt>switch</tt>' Instruction</h4><ul>
672
673<h5>Syntax:</h5>
674<pre>
675 <i>; Definitions for lookup indirect branch</i>
676 %switchtype = type [&lt;anysize&gt; x { uint, label }]
677
678 <i>; Lookup indirect branch</i>
679 switch uint &lt;value&gt;, label &lt;defaultdest&gt;, %switchtype &lt;switchtable&gt;
680
681 <i>; Indexed indirect branch</i>
682 switch uint &lt;idxvalue&gt;, label &lt;defaultdest&gt;, [&lt;anysize&gt; x label] &lt;desttable&gt;
683</pre>
684
685<h5>Overview:</h5>
Chris Lattner00950542001-06-06 20:29:01 +0000686
Chris Lattner7faa8832002-04-14 06:13:44 +0000687The '<tt>switch</tt>' instruction is used to transfer control flow to one of
688several different places. It is a generalization of the '<tt>br</tt>'
689instruction, allowing a branch to occur to one of many possible destinations.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000690
Chris Lattner7faa8832002-04-14 06:13:44 +0000691The '<tt>switch</tt>' statement supports two different styles of indirect
692branching: lookup branching and indexed branching. Lookup branching is
693generally useful if the values to switch on are spread far appart, where index
694branching is useful if the values to switch on are generally dense.<p>
695
696The two different forms of the '<tt>switch</tt>' statement are simple hints to
Chris Lattner2b7d3202002-05-06 03:03:22 +0000697the underlying implementation. For example, the compiler may choose to
698implement a small indirect branch table as a series of predicated comparisons:
699if it is faster for the target architecture.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000700
701<h5>Arguments:</h5>
Chris Lattner00950542001-06-06 20:29:01 +0000702
Chris Lattner7faa8832002-04-14 06:13:44 +0000703The lookup form of the '<tt>switch</tt>' instruction uses three parameters: a
704'<tt>uint</tt>' comparison value '<tt>value</tt>', a default '<tt>label</tt>'
705destination, and an array of pairs of comparison value constants and
706'<tt>label</tt>'s. The sized array must be a constant value.<p>
707
708The indexed form of the '<tt>switch</tt>' instruction uses three parameters: an
709'<tt>uint</tt>' index value, a default '<tt>label</tt>' and a sized array of
710'<tt>label</tt>'s. The '<tt>dests</tt>' array must be a constant array.
Chris Lattner00950542001-06-06 20:29:01 +0000711
712<h5>Semantics:</h5>
713
Chris Lattner7faa8832002-04-14 06:13:44 +0000714The lookup style switch statement specifies a table of values and destinations.
715When the '<tt>switch</tt>' instruction is executed, this table is searched for
716the given value. If the value is found, the corresponding destination is
717branched to. <p>
Chris Lattner00950542001-06-06 20:29:01 +0000718
Chris Lattner7faa8832002-04-14 06:13:44 +0000719The index branch form simply looks up a label element directly in a table and
720branches to it.<p>
721
722In either case, the compiler knows the static size of the array, because it is
723provided as part of the constant values type.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000724
725<h5>Example:</h5>
726<pre>
727 <i>; Emulate a conditional br instruction</i>
728 %Val = <a href="#i_cast">cast</a> bool %value to uint
729 switch uint %Val, label %truedest, [1 x label] [label %falsedest ]
730
731 <i>; Emulate an unconditional br instruction</i>
732 switch uint 0, label %dest, [ 0 x label] [ ]
733
Chris Lattner2b7d3202002-05-06 03:03:22 +0000734 <i>; Implement a jump table:</i>
Chris Lattner00950542001-06-06 20:29:01 +0000735 switch uint %val, label %otherwise, [3 x label] [ label %onzero,
736 label %onone,
737 label %ontwo ]
738
739</pre>
740
741
742
743<!-- _______________________________________________________________________ -->
Chris Lattner7faa8832002-04-14 06:13:44 +0000744</ul><a name="i_invoke"><h4><hr size=0>'<tt>invoke</tt>' Instruction</h4><ul>
Chris Lattner00950542001-06-06 20:29:01 +0000745
746<h5>Syntax:</h5>
747<pre>
Chris Lattner7faa8832002-04-14 06:13:44 +0000748 &lt;result&gt; = invoke &lt;ptr to function ty&gt; %&lt;function ptr val&gt;(&lt;function args&gt;)
749 to label &lt;normal label&gt; except label &lt;exception label&gt;
Chris Lattner00950542001-06-06 20:29:01 +0000750</pre>
751
Chris Lattner6536cfe2002-05-06 22:08:29 +0000752<h5>Overview:</h5>
753
754The '<tt>invoke</tt>' instruction is used to cause control flow to transfer to a
755specified function, with the possibility of control flow transfer to either the
756'<tt>normal label</tt>' label or the '<tt>exception label</tt>'. The '<tt><a
757href="#i_call">call</a></tt>' instruction is closely related, but guarantees
758that control flow either never returns from the called function, or that it
Chris Lattner7bae3952002-06-25 18:03:17 +0000759returns to the instruction following the '<tt><a href="#i_call">call</a></tt>'
Chris Lattner6536cfe2002-05-06 22:08:29 +0000760instruction.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000761
762<h5>Arguments:</h5>
763
764This instruction requires several arguments:<p>
765<ol>
Chris Lattner7faa8832002-04-14 06:13:44 +0000766
767<li>'<tt>ptr to function ty</tt>': shall be the signature of the pointer to
Chris Lattner2b7d3202002-05-06 03:03:22 +0000768function value being invoked. In most cases, this is a direct function
Chris Lattner7faa8832002-04-14 06:13:44 +0000769invocation, but indirect <tt>invoke</tt>'s are just as possible, branching off
770an arbitrary pointer to function value.<p>
771
772<li>'<tt>function ptr val</tt>': An LLVM value containing a pointer to a
773function to be invoked.
774
775<li>'<tt>function args</tt>': argument list whose types match the function
Chris Lattner6536cfe2002-05-06 22:08:29 +0000776signature argument types. If the function signature indicates the function
777accepts a variable number of arguments, the extra arguments can be specified.
Chris Lattner7faa8832002-04-14 06:13:44 +0000778
779<li>'<tt>normal label</tt>': the label reached when the called function executes
780a '<tt><a href="#i_ret">ret</a></tt>' instruction.
781
782<li>'<tt>exception label</tt>': the label reached when an exception is thrown.
Chris Lattner00950542001-06-06 20:29:01 +0000783</ol>
784
785<h5>Semantics:</h5>
786
Chris Lattner2b7d3202002-05-06 03:03:22 +0000787This instruction is designed to operate as a standard '<tt><a
788href="#i_call">call</a></tt>' instruction in most regards. The primary
789difference is that it associates a label with the function invocation that may
790be accessed via the runtime library provided by the execution environment. This
791instruction is used in languages with destructors to ensure that proper cleanup
792is performed in the case of either a <tt>longjmp</tt> or a thrown exception.
793Additionally, this is important for implementation of '<tt>catch</tt>' clauses
794in high-level languages that support them.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000795
Chris Lattner7bae3952002-06-25 18:03:17 +0000796<!-- For a more comprehensive explanation of how this instruction is used, look in the llvm/docs/2001-05-18-ExceptionHandling.txt document.<p> -->
Chris Lattner00950542001-06-06 20:29:01 +0000797
798<h5>Example:</h5>
799<pre>
Chris Lattner7faa8832002-04-14 06:13:44 +0000800 %retval = invoke int %Test(int 15)
801 to label %Continue except label %TestCleanup <i>; {int}:retval set</i>
Chris Lattner00950542001-06-06 20:29:01 +0000802</pre>
803
804
805
806<!-- ======================================================================= -->
Chris Lattner00950542001-06-06 20:29:01 +0000807</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0><tr><td>&nbsp;</td><td width="100%">&nbsp; <font color="#EEEEFF" face="Georgia,Palatino"><b>
808<a name="binaryops">Binary Operations
809</b></font></td></tr></table><ul>
810
Chris Lattner7faa8832002-04-14 06:13:44 +0000811Binary operators are used to do most of the computation in a program. They
812require two operands, execute an operation on them, and produce a single value.
813The result value of a binary operator is not neccesarily the same type as its
814operands.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000815
816There are several different binary operators:<p>
817
818
819<!-- _______________________________________________________________________ -->
820</ul><a name="i_add"><h4><hr size=0>'<tt>add</tt>' Instruction</h4><ul>
821
822<h5>Syntax:</h5>
823<pre>
824 &lt;result&gt; = add &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
825</pre>
826
827<h5>Overview:</h5>
828The '<tt>add</tt>' instruction returns the sum of its two operands.<p>
829
830<h5>Arguments:</h5>
831The two arguments to the '<tt>add</tt>' instruction must be either <a href="#t_integral">integral</a> or <a href="#t_floating">floating point</a> values. Both arguments must have identical types.<p>
832
833<h5>Semantics:</h5>
Chris Lattner7bae3952002-06-25 18:03:17 +0000834
835The value produced is the integral or floating point sum of the two operands.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000836
837<h5>Example:</h5>
838<pre>
839 &lt;result&gt; = add int 4, %var <i>; yields {int}:result = 4 + %var</i>
840</pre>
841
842
843<!-- _______________________________________________________________________ -->
844</ul><a name="i_sub"><h4><hr size=0>'<tt>sub</tt>' Instruction</h4><ul>
845
846<h5>Syntax:</h5>
847<pre>
848 &lt;result&gt; = sub &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
849</pre>
850
851<h5>Overview:</h5>
Chris Lattner7faa8832002-04-14 06:13:44 +0000852
Chris Lattner00950542001-06-06 20:29:01 +0000853The '<tt>sub</tt>' instruction returns the difference of its two operands.<p>
854
Chris Lattner7faa8832002-04-14 06:13:44 +0000855Note that the '<tt>sub</tt>' instruction is used to represent the '<tt>neg</tt>'
856instruction present in most other intermediate representations.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000857
858<h5>Arguments:</h5>
Chris Lattner7faa8832002-04-14 06:13:44 +0000859
860The two arguments to the '<tt>sub</tt>' instruction must be either <a
861href="#t_integral">integral</a> or <a href="#t_floating">floating point</a>
862values. Both arguments must have identical types.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000863
864<h5>Semantics:</h5>
Chris Lattner7bae3952002-06-25 18:03:17 +0000865
866The value produced is the integral or floating point difference of the two
867operands.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000868
869<h5>Example:</h5>
870<pre>
871 &lt;result&gt; = sub int 4, %var <i>; yields {int}:result = 4 - %var</i>
872 &lt;result&gt; = sub int 0, %val <i>; yields {int}:result = -%var</i>
873</pre>
874
875<!-- _______________________________________________________________________ -->
876</ul><a name="i_mul"><h4><hr size=0>'<tt>mul</tt>' Instruction</h4><ul>
877
878<h5>Syntax:</h5>
879<pre>
880 &lt;result&gt; = mul &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
881</pre>
882
883<h5>Overview:</h5>
884The '<tt>mul</tt>' instruction returns the product of its two operands.<p>
885
886<h5>Arguments:</h5>
887The two arguments to the '<tt>mul</tt>' instruction must be either <a href="#t_integral">integral</a> or <a href="#t_floating">floating point</a> values. Both arguments must have identical types.<p>
888
889<h5>Semantics:</h5>
Chris Lattner7bae3952002-06-25 18:03:17 +0000890
891The value produced is the integral or floating point product of the two
892operands.<p>
Chris Lattner7faa8832002-04-14 06:13:44 +0000893
894There is no signed vs unsigned multiplication. The appropriate action is taken
895based on the type of the operand. <p>
Chris Lattner00950542001-06-06 20:29:01 +0000896
897
898<h5>Example:</h5>
899<pre>
900 &lt;result&gt; = mul int 4, %var <i>; yields {int}:result = 4 * %var</i>
901</pre>
902
903
904<!-- _______________________________________________________________________ -->
905</ul><a name="i_div"><h4><hr size=0>'<tt>div</tt>' Instruction</h4><ul>
906
907<h5>Syntax:</h5>
908<pre>
909 &lt;result&gt; = div &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
910</pre>
911
912<h5>Overview:</h5>
Chris Lattner7faa8832002-04-14 06:13:44 +0000913
Chris Lattner00950542001-06-06 20:29:01 +0000914The '<tt>div</tt>' instruction returns the quotient of its two operands.<p>
915
916<h5>Arguments:</h5>
Chris Lattner7faa8832002-04-14 06:13:44 +0000917
918The two arguments to the '<tt>div</tt>' instruction must be either <a
919href="#t_integral">integral</a> or <a href="#t_floating">floating point</a>
920values. Both arguments must have identical types.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000921
922<h5>Semantics:</h5>
Chris Lattner7bae3952002-06-25 18:03:17 +0000923
924The value produced is the integral or floating point quotient of the two
925operands.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000926
927<h5>Example:</h5>
928<pre>
929 &lt;result&gt; = div int 4, %var <i>; yields {int}:result = 4 / %var</i>
930</pre>
931
932
933<!-- _______________________________________________________________________ -->
934</ul><a name="i_rem"><h4><hr size=0>'<tt>rem</tt>' Instruction</h4><ul>
935
936<h5>Syntax:</h5>
937<pre>
938 &lt;result&gt; = rem &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
939</pre>
940
941<h5>Overview:</h5>
942The '<tt>rem</tt>' instruction returns the remainder from the division of its two operands.<p>
943
944<h5>Arguments:</h5>
945The two arguments to the '<tt>rem</tt>' instruction must be either <a href="#t_integral">integral</a> or <a href="#t_floating">floating point</a> values. Both arguments must have identical types.<p>
946
947<h5>Semantics:</h5>
Chris Lattner6536cfe2002-05-06 22:08:29 +0000948
949This returns the <i>remainder</i> of a division (where the result has the same
950sign as the divisor), not the <i>modulus</i> (where the result has the same sign
951as the dividend) of a value. For more information about the difference, see: <a
952href="http://mathforum.org/dr.math/problems/anne.4.28.99.html">The Math
953Forum</a>.<p>
954
Chris Lattner00950542001-06-06 20:29:01 +0000955<h5>Example:</h5>
956<pre>
957 &lt;result&gt; = rem int 4, %var <i>; yields {int}:result = 4 % %var</i>
958</pre>
959
960
961<!-- _______________________________________________________________________ -->
962</ul><a name="i_setcc"><h4><hr size=0>'<tt>set<i>cc</i></tt>' Instructions</h4><ul>
963
964<h5>Syntax:</h5>
965<pre>
966 &lt;result&gt; = seteq &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {bool}:result</i>
967 &lt;result&gt; = setne &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {bool}:result</i>
968 &lt;result&gt; = setlt &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {bool}:result</i>
969 &lt;result&gt; = setgt &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {bool}:result</i>
970 &lt;result&gt; = setle &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {bool}:result</i>
971 &lt;result&gt; = setge &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {bool}:result</i>
972</pre>
973
Chris Lattner6536cfe2002-05-06 22:08:29 +0000974<h5>Overview:</h5> The '<tt>set<i>cc</i></tt>' family of instructions returns a
975boolean value based on a comparison of their two operands.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000976
Chris Lattner7faa8832002-04-14 06:13:44 +0000977<h5>Arguments:</h5> The two arguments to the '<tt>set<i>cc</i></tt>'
978instructions must be of <a href="#t_firstclass">first class</a> or <a
979href="#t_pointer">pointer</a> type (it is not possible to compare
980'<tt>label</tt>'s, '<tt>array</tt>'s, '<tt>structure</tt>' or '<tt>void</tt>'
Chris Lattner6536cfe2002-05-06 22:08:29 +0000981values, etc...). Both arguments must have identical types.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000982
Chris Lattner6536cfe2002-05-06 22:08:29 +0000983The '<tt>setlt</tt>', '<tt>setgt</tt>', '<tt>setle</tt>', and '<tt>setge</tt>'
984instructions do not operate on '<tt>bool</tt>' typed arguments.<p>
Chris Lattner00950542001-06-06 20:29:01 +0000985
986<h5>Semantics:</h5>
Chris Lattner6536cfe2002-05-06 22:08:29 +0000987
988The '<tt>seteq</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>' value if
989both operands are equal.<br>
990
991The '<tt>setne</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>' value if
992both operands are unequal.<br>
993
994The '<tt>setlt</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>' value if
995the first operand is less than the second operand.<br>
996
997The '<tt>setgt</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>' value if
998the first operand is greater than the second operand.<br>
999
1000The '<tt>setle</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>' value if
1001the first operand is less than or equal to the second operand.<br>
1002
1003The '<tt>setge</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>' value if
1004the first operand is greater than or equal to the second operand.<p>
Chris Lattner00950542001-06-06 20:29:01 +00001005
1006<h5>Example:</h5>
1007<pre>
1008 &lt;result&gt; = seteq int 4, 5 <i>; yields {bool}:result = false</i>
1009 &lt;result&gt; = setne float 4, 5 <i>; yields {bool}:result = true</i>
1010 &lt;result&gt; = setlt uint 4, 5 <i>; yields {bool}:result = true</i>
1011 &lt;result&gt; = setgt sbyte 4, 5 <i>; yields {bool}:result = false</i>
1012 &lt;result&gt; = setle sbyte 4, 5 <i>; yields {bool}:result = true</i>
1013 &lt;result&gt; = setge sbyte 4, 5 <i>; yields {bool}:result = false</i>
1014</pre>
1015
1016
1017
1018<!-- ======================================================================= -->
Chris Lattner2b7d3202002-05-06 03:03:22 +00001019</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0>
1020<tr><td>&nbsp;</td><td width="100%">&nbsp; <font color="#EEEEFF" face="Georgia,Palatino"><b>
Chris Lattner00950542001-06-06 20:29:01 +00001021<a name="bitwiseops">Bitwise Binary Operations
1022</b></font></td></tr></table><ul>
1023
Chris Lattner2b7d3202002-05-06 03:03:22 +00001024Bitwise binary operators are used to do various forms of bit-twiddling in a
1025program. They are generally very efficient instructions, and can commonly be
1026strength reduced from other instructions. They require two operands, execute an
1027operation on them, and produce a single value. The resulting value of the
1028bitwise binary operators is always the same type as its first operand.<p>
Chris Lattner00950542001-06-06 20:29:01 +00001029
1030<!-- _______________________________________________________________________ -->
1031</ul><a name="i_and"><h4><hr size=0>'<tt>and</tt>' Instruction</h4><ul>
1032
1033<h5>Syntax:</h5>
1034<pre>
1035 &lt;result&gt; = and &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
1036</pre>
1037
1038<h5>Overview:</h5>
1039The '<tt>and</tt>' instruction returns the bitwise logical and of its two operands.<p>
1040
1041<h5>Arguments:</h5>
Chris Lattner6536cfe2002-05-06 22:08:29 +00001042
1043The two arguments to the '<tt>and</tt>' instruction must be either <a
1044href="#t_integral">integral</a> or <tt>bool</tt> values. Both arguments must
1045have identical types.<p>
Chris Lattner00950542001-06-06 20:29:01 +00001046
1047
1048<h5>Semantics:</h5>
Chris Lattner7bae3952002-06-25 18:03:17 +00001049
1050The truth table used for the '<tt>and</tt>' instruction is:<p>
1051
Chris Lattnerc98cbbc2002-06-25 18:06:50 +00001052<center><table border=1 cellspacing=0 cellpadding=4>
Chris Lattner7bae3952002-06-25 18:03:17 +00001053<tr><td>In0</td> <td>In1</td> <td>Out</td></tr>
1054<tr><td>0</td> <td>0</td> <td>0</td></tr>
1055<tr><td>0</td> <td>1</td> <td>0</td></tr>
1056<tr><td>1</td> <td>0</td> <td>0</td></tr>
1057<tr><td>1</td> <td>1</td> <td>1</td></tr>
1058</table></center><p>
Chris Lattner00950542001-06-06 20:29:01 +00001059
1060
1061<h5>Example:</h5>
1062<pre>
1063 &lt;result&gt; = and int 4, %var <i>; yields {int}:result = 4 & %var</i>
1064 &lt;result&gt; = and int 15, 40 <i>; yields {int}:result = 8</i>
1065 &lt;result&gt; = and int 4, 8 <i>; yields {int}:result = 0</i>
1066</pre>
1067
1068
1069
1070<!-- _______________________________________________________________________ -->
1071</ul><a name="i_or"><h4><hr size=0>'<tt>or</tt>' Instruction</h4><ul>
1072
1073<h5>Syntax:</h5>
1074<pre>
1075 &lt;result&gt; = or &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
1076</pre>
1077
Chris Lattner7faa8832002-04-14 06:13:44 +00001078<h5>Overview:</h5> The '<tt>or</tt>' instruction returns the bitwise logical
1079inclusive or of its two operands.<p>
Chris Lattner00950542001-06-06 20:29:01 +00001080
1081<h5>Arguments:</h5>
Chris Lattner7faa8832002-04-14 06:13:44 +00001082
1083The two arguments to the '<tt>or</tt>' instruction must be either <a
Chris Lattner6536cfe2002-05-06 22:08:29 +00001084href="#t_integral">integral</a> or <tt>bool</tt> values. Both arguments must
1085have identical types.<p>
Chris Lattner00950542001-06-06 20:29:01 +00001086
1087
1088<h5>Semantics:</h5>
Chris Lattner7bae3952002-06-25 18:03:17 +00001089
1090The truth table used for the '<tt>or</tt>' instruction is:<p>
1091
Chris Lattnerc98cbbc2002-06-25 18:06:50 +00001092<center><table border=1 cellspacing=0 cellpadding=4>
Chris Lattner7bae3952002-06-25 18:03:17 +00001093<tr><td>In0</td> <td>In1</td> <td>Out</td></tr>
1094<tr><td>0</td> <td>0</td> <td>0</td></tr>
1095<tr><td>0</td> <td>1</td> <td>1</td></tr>
1096<tr><td>1</td> <td>0</td> <td>1</td></tr>
1097<tr><td>1</td> <td>1</td> <td>1</td></tr>
1098</table></center><p>
Chris Lattner00950542001-06-06 20:29:01 +00001099
1100
1101<h5>Example:</h5>
1102<pre>
1103 &lt;result&gt; = or int 4, %var <i>; yields {int}:result = 4 | %var</i>
1104 &lt;result&gt; = or int 15, 40 <i>; yields {int}:result = 47</i>
1105 &lt;result&gt; = or int 4, 8 <i>; yields {int}:result = 12</i>
1106</pre>
1107
1108
1109<!-- _______________________________________________________________________ -->
1110</ul><a name="i_xor"><h4><hr size=0>'<tt>xor</tt>' Instruction</h4><ul>
1111
1112<h5>Syntax:</h5>
1113<pre>
1114 &lt;result&gt; = xor &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
1115</pre>
1116
1117<h5>Overview:</h5>
Chris Lattner7faa8832002-04-14 06:13:44 +00001118
1119The '<tt>xor</tt>' instruction returns the bitwise logical exclusive or of its
1120two operands.<p>
Chris Lattner00950542001-06-06 20:29:01 +00001121
1122<h5>Arguments:</h5>
Chris Lattner7faa8832002-04-14 06:13:44 +00001123
1124The two arguments to the '<tt>xor</tt>' instruction must be either <a
Chris Lattner6536cfe2002-05-06 22:08:29 +00001125href="#t_integral">integral</a> or <tt>bool</tt> values. Both arguments must
1126have identical types.<p>
Chris Lattner00950542001-06-06 20:29:01 +00001127
1128
1129<h5>Semantics:</h5>
Chris Lattner7bae3952002-06-25 18:03:17 +00001130
1131The truth table used for the '<tt>xor</tt>' instruction is:<p>
1132
Chris Lattnerc98cbbc2002-06-25 18:06:50 +00001133<center><table border=1 cellspacing=0 cellpadding=4>
Chris Lattner7bae3952002-06-25 18:03:17 +00001134<tr><td>In0</td> <td>In1</td> <td>Out</td></tr>
1135<tr><td>0</td> <td>0</td> <td>0</td></tr>
1136<tr><td>0</td> <td>1</td> <td>1</td></tr>
1137<tr><td>1</td> <td>0</td> <td>1</td></tr>
1138<tr><td>1</td> <td>1</td> <td>0</td></tr>
1139</table></center><p>
Chris Lattner00950542001-06-06 20:29:01 +00001140
1141
1142<h5>Example:</h5>
1143<pre>
1144 &lt;result&gt; = xor int 4, %var <i>; yields {int}:result = 4 ^ %var</i>
1145 &lt;result&gt; = xor int 15, 40 <i>; yields {int}:result = 39</i>
1146 &lt;result&gt; = xor int 4, 8 <i>; yields {int}:result = 12</i>
1147</pre>
1148
1149
1150<!-- _______________________________________________________________________ -->
1151</ul><a name="i_shl"><h4><hr size=0>'<tt>shl</tt>' Instruction</h4><ul>
1152
1153<h5>Syntax:</h5>
1154<pre>
1155 &lt;result&gt; = shl &lt;ty&gt; &lt;var1&gt;, ubyte &lt;var2&gt; <i>; yields {ty}:result</i>
1156</pre>
1157
1158<h5>Overview:</h5>
Chris Lattner7faa8832002-04-14 06:13:44 +00001159
1160The '<tt>shl</tt>' instruction returns the first operand shifted to the left a
1161specified number of bits.
Chris Lattner00950542001-06-06 20:29:01 +00001162
1163<h5>Arguments:</h5>
Chris Lattner7faa8832002-04-14 06:13:44 +00001164
1165The first argument to the '<tt>shl</tt>' instruction must be an <a
1166href="#t_integral">integral</a> type. The second argument must be an
1167'<tt>ubyte</tt>' type.<p>
Chris Lattner00950542001-06-06 20:29:01 +00001168
1169<h5>Semantics:</h5>
Chris Lattner7bae3952002-06-25 18:03:17 +00001170
1171The value produced is <tt>var1</tt> * 2<sup><tt>var2</tt></sup>.<p>
Chris Lattner00950542001-06-06 20:29:01 +00001172
1173
1174<h5>Example:</h5>
1175<pre>
1176 &lt;result&gt; = shl int 4, ubyte %var <i>; yields {int}:result = 4 << %var</i>
1177 &lt;result&gt; = shl int 4, ubyte 2 <i>; yields {int}:result = 16</i>
1178 &lt;result&gt; = shl int 1, ubyte 10 <i>; yields {int}:result = 1024</i>
1179</pre>
1180
1181
1182<!-- _______________________________________________________________________ -->
1183</ul><a name="i_shr"><h4><hr size=0>'<tt>shr</tt>' Instruction</h4><ul>
1184
1185
1186<h5>Syntax:</h5>
1187<pre>
1188 &lt;result&gt; = shr &lt;ty&gt; &lt;var1&gt;, ubyte &lt;var2&gt; <i>; yields {ty}:result</i>
1189</pre>
1190
1191<h5>Overview:</h5>
1192The '<tt>shr</tt>' instruction returns the first operand shifted to the right a specified number of bits.
1193
1194<h5>Arguments:</h5>
1195The first argument to the '<tt>shr</tt>' instruction must be an <a href="#t_integral">integral</a> type. The second argument must be an '<tt>ubyte</tt>' type.<p>
1196
1197<h5>Semantics:</h5>
Chris Lattner7bae3952002-06-25 18:03:17 +00001198
1199If the first argument is a <a href="#t_signed">signed</a> type, the most
1200significant bit is duplicated in the newly free'd bit positions. If the first
1201argument is unsigned, zero bits shall fill the empty positions.<p>
Chris Lattner00950542001-06-06 20:29:01 +00001202
1203<h5>Example:</h5>
1204<pre>
1205 &lt;result&gt; = shr int 4, ubyte %var <i>; yields {int}:result = 4 >> %var</i>
1206 &lt;result&gt; = shr int 4, ubyte 1 <i>; yields {int}:result = 2</i>
1207 &lt;result&gt; = shr int 4, ubyte 2 <i>; yields {int}:result = 1</i>
1208 &lt;result&gt; = shr int 4, ubyte 3 <i>; yields {int}:result = 0</i>
1209</pre>
1210
1211
1212
1213
1214
1215<!-- ======================================================================= -->
Chris Lattner2b7d3202002-05-06 03:03:22 +00001216</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0>
1217<tr><td>&nbsp;</td><td width="100%">&nbsp; <font color="#EEEEFF" face="Georgia,Palatino"><b>
Chris Lattner00950542001-06-06 20:29:01 +00001218<a name="memoryops">Memory Access Operations
1219</b></font></td></tr></table><ul>
1220
Chris Lattner6536cfe2002-05-06 22:08:29 +00001221Accessing memory in SSA form is, well, sticky at best. This section describes how to read, write, allocate and free memory in LLVM.<p>
Chris Lattner00950542001-06-06 20:29:01 +00001222
1223
1224<!-- _______________________________________________________________________ -->
1225</ul><a name="i_malloc"><h4><hr size=0>'<tt>malloc</tt>' Instruction</h4><ul>
1226
1227<h5>Syntax:</h5>
1228<pre>
Chris Lattner7faa8832002-04-14 06:13:44 +00001229 &lt;result&gt; = malloc &lt;type&gt;, uint &lt;NumElements&gt; <i>; yields {type*}:result</i>
1230 &lt;result&gt; = malloc &lt;type&gt; <i>; yields {type*}:result</i>
Chris Lattner00950542001-06-06 20:29:01 +00001231</pre>
1232
1233<h5>Overview:</h5>
1234The '<tt>malloc</tt>' instruction allocates memory from the system heap and returns a pointer to it.<p>
1235
1236<h5>Arguments:</h5>
1237
Chris Lattner7faa8832002-04-14 06:13:44 +00001238The the '<tt>malloc</tt>' instruction allocates
1239<tt>sizeof(&lt;type&gt;)*NumElements</tt> bytes of memory from the operating
1240system, and returns a pointer of the appropriate type to the program. The
1241second form of the instruction is a shorter version of the first instruction
1242that defaults to allocating one element.<p>
Chris Lattner00950542001-06-06 20:29:01 +00001243
Chris Lattner7faa8832002-04-14 06:13:44 +00001244'<tt>type</tt>' must be a sized type<p>
Chris Lattner00950542001-06-06 20:29:01 +00001245
1246<h5>Semantics:</h5>
1247Memory is allocated, a pointer is returned.<p>
1248
1249<h5>Example:</h5>
1250<pre>
1251 %array = malloc [4 x ubyte ] <i>; yields {[%4 x ubyte]*}:array</i>
1252
1253 %size = <a href="#i_add">add</a> uint 2, 2 <i>; yields {uint}:size = uint 4</i>
Chris Lattner7faa8832002-04-14 06:13:44 +00001254 %array1 = malloc ubyte, uint 4 <i>; yields {ubyte*}:array1</i>
1255 %array2 = malloc [12 x ubyte], uint %size <i>; yields {[12 x ubyte]*}:array2</i>
Chris Lattner00950542001-06-06 20:29:01 +00001256</pre>
1257
1258
1259<!-- _______________________________________________________________________ -->
1260</ul><a name="i_free"><h4><hr size=0>'<tt>free</tt>' Instruction</h4><ul>
1261
1262<h5>Syntax:</h5>
1263<pre>
1264 free &lt;type&gt; &lt;value&gt; <i>; yields {void}</i>
1265</pre>
1266
1267
1268<h5>Overview:</h5>
1269The '<tt>free</tt>' instruction returns memory back to the unused memory heap, to be reallocated in the future.<p>
1270
1271
1272<h5>Arguments:</h5>
1273
Chris Lattner6536cfe2002-05-06 22:08:29 +00001274'<tt>value</tt>' shall be a pointer value that points to a value that was
1275allocated with the '<tt><a href="#i_malloc">malloc</a></tt>' instruction.<p>
Chris Lattner00950542001-06-06 20:29:01 +00001276
1277
1278<h5>Semantics:</h5>
Chris Lattner00950542001-06-06 20:29:01 +00001279
Chris Lattner6536cfe2002-05-06 22:08:29 +00001280Access to the memory pointed to by the pointer is not longer defined after this instruction executes.<p>
Chris Lattner00950542001-06-06 20:29:01 +00001281
1282<h5>Example:</h5>
1283<pre>
1284 %array = <a href="#i_malloc">malloc</a> [4 x ubyte] <i>; yields {[4 x ubyte]*}:array</i>
1285 free [4 x ubyte]* %array
1286</pre>
1287
1288
1289<!-- _______________________________________________________________________ -->
1290</ul><a name="i_alloca"><h4><hr size=0>'<tt>alloca</tt>' Instruction</h4><ul>
1291
1292<h5>Syntax:</h5>
1293<pre>
Chris Lattner7faa8832002-04-14 06:13:44 +00001294 &lt;result&gt; = alloca &lt;type&gt;, uint &lt;NumElements&gt; <i>; yields {type*}:result</i>
1295 &lt;result&gt; = alloca &lt;type&gt; <i>; yields {type*}:result</i>
Chris Lattner00950542001-06-06 20:29:01 +00001296</pre>
1297
1298<h5>Overview:</h5>
1299
Chris Lattner7faa8832002-04-14 06:13:44 +00001300The '<tt>alloca</tt>' instruction allocates memory on the current stack frame of
1301the procedure that is live until the current function returns to its caller.<p>
Chris Lattner00950542001-06-06 20:29:01 +00001302
1303<h5>Arguments:</h5>
Chris Lattner00950542001-06-06 20:29:01 +00001304
Chris Lattner7faa8832002-04-14 06:13:44 +00001305The the '<tt>alloca</tt>' instruction allocates
1306<tt>sizeof(&lt;type&gt;)*NumElements</tt> bytes of memory on the runtime stack,
1307returning a pointer of the appropriate type to the program. The second form of
1308the instruction is a shorter version of the first that defaults to allocating
1309one element.<p>
Chris Lattner00950542001-06-06 20:29:01 +00001310
Chris Lattner7faa8832002-04-14 06:13:44 +00001311'<tt>type</tt>' may be any sized type.<p>
Chris Lattner00950542001-06-06 20:29:01 +00001312
1313<h5>Semantics:</h5>
Chris Lattner7faa8832002-04-14 06:13:44 +00001314
1315Memory is allocated, a pointer is returned. '<tt>alloca</tt>'d memory is
1316automatically released when the function returns. The '<tt>alloca</tt>'
1317instruction is commonly used to represent automatic variables that must have an
1318address available, as well as spilled variables.<p>
Chris Lattner00950542001-06-06 20:29:01 +00001319
1320<h5>Example:</h5>
1321<pre>
1322 %ptr = alloca int <i>; yields {int*}:ptr</i>
Chris Lattner7faa8832002-04-14 06:13:44 +00001323 %ptr = alloca int, uint 4 <i>; yields {int*}:ptr</i>
Chris Lattner00950542001-06-06 20:29:01 +00001324</pre>
1325
1326
1327<!-- _______________________________________________________________________ -->
Chris Lattner2b7d3202002-05-06 03:03:22 +00001328</ul><a name="i_load"><h4><hr size=0>'<tt>load</tt>' Instruction</h4><ul>
1329
1330<h5>Syntax:</h5>
1331<pre>
1332 &lt;result&gt; = load &lt;ty&gt;* &lt;pointer&gt;
1333</pre>
1334
1335<h5>Overview:</h5>
1336The '<tt>load</tt>' instruction is used to read from memory.<p>
1337
1338<h5>Arguments:</h5>
1339
1340The argument to the '<tt>load</tt>' instruction specifies the memory address to load from. The pointer must point to a <a href="t_firstclass">first class</a> type.<p>
1341
1342<h5>Semantics:</h5>
1343
1344The location of memory pointed to is loaded.
1345
1346<h5>Examples:</h5>
1347<pre>
1348 %ptr = <a href="#i_alloca">alloca</a> int <i>; yields {int*}:ptr</i>
1349 <a href="#i_store">store</a> int 3, int* %ptr <i>; yields {void}</i>
1350 %val = load int* %ptr <i>; yields {int}:val = int 3</i>
1351</pre>
1352
1353
1354
1355
1356<!-- _______________________________________________________________________ -->
1357</ul><a name="i_store"><h4><hr size=0>'<tt>store</tt>' Instruction</h4><ul>
1358
1359<h5>Syntax:</h5>
1360<pre>
1361 store &lt;ty&gt; &lt;value&gt;, &lt;ty&gt;* &lt;pointer&gt; <i>; yields {void}</i>
1362</pre>
1363
1364<h5>Overview:</h5>
1365The '<tt>store</tt>' instruction is used to write to memory.<p>
1366
1367<h5>Arguments:</h5>
1368
1369There are two arguments to the '<tt>store</tt>' instruction: a value to store
1370and an address to store it into. The type of the '<tt>&lt;pointer&gt;</tt>'
1371operand must be a pointer to the type of the '<tt>&lt;value&gt;</tt>'
1372operand.<p>
1373
1374<h5>Semantics:</h5> The contents of memory are updated to contain
1375'<tt>&lt;value&gt;</tt>' at the location specified by the
1376'<tt>&lt;pointer&gt;</tt>' operand.<p>
1377
1378<h5>Example:</h5>
1379<pre>
1380 %ptr = <a href="#i_alloca">alloca</a> int <i>; yields {int*}:ptr</i>
1381 <a href="#i_store">store</a> int 3, int* %ptr <i>; yields {void}</i>
1382 %val = load int* %ptr <i>; yields {int}:val = int 3</i>
1383</pre>
1384
1385
1386
1387
1388<!-- _______________________________________________________________________ -->
Chris Lattner7faa8832002-04-14 06:13:44 +00001389</ul><a name="i_getelementptr"><h4><hr size=0>'<tt>getelementptr</tt>' Instruction</h4><ul>
1390
1391<h5>Syntax:</h5>
1392<pre>
1393 &lt;result&gt; = getelementptr &lt;ty&gt;* &lt;ptrval&gt;{, uint &lt;aidx&gt;|, ubyte &lt;sidx&gt;}*
1394</pre>
1395
1396<h5>Overview:</h5>
1397
1398The '<tt>getelementptr</tt>' instruction is used to get the address of a
Chris Lattner6536cfe2002-05-06 22:08:29 +00001399subelement of an aggregate data structure.<p>
Chris Lattner7faa8832002-04-14 06:13:44 +00001400
1401<h5>Arguments:</h5>
1402
1403This instruction takes a list of <tt>uint</tt> values and <tt>ubyte</tt>
1404constants that indicate what form of addressing to perform. The actual types of
1405the arguments provided depend on the type of the first pointer argument. The
1406'<tt>getelementptr</tt>' instruction is used to index down through the type
1407levels of a structure.<p>
1408
Chris Lattner6536cfe2002-05-06 22:08:29 +00001409For example, lets consider a C code fragment and how it gets compiled to
1410LLVM:<p>
1411
1412<pre>
1413struct RT {
1414 char A;
1415 int B[10][20];
1416 char C;
1417};
1418struct ST {
1419 int X;
1420 double Y;
1421 struct RT Z;
1422};
1423
1424int *foo(struct ST *s) {
1425 return &amp;s[1].Z.B[5][13];
1426}
1427</pre>
1428
1429The LLVM code generated by the GCC frontend is:
1430
1431<pre>
1432%RT = type { sbyte, [10 x [20 x int]], sbyte }
1433%ST = type { int, double, %RT }
1434
1435int* "foo"(%ST* %s) {
1436 %reg = getelementptr %ST* %s, uint 1, ubyte 2, ubyte 1, uint 5, uint 13
1437 ret int* %reg
1438}
1439</pre>
Chris Lattner7faa8832002-04-14 06:13:44 +00001440
1441<h5>Semantics:</h5>
1442
Chris Lattner6536cfe2002-05-06 22:08:29 +00001443The index types specified for the '<tt>getelementptr</tt>' instruction depend on
1444the pointer type that is being index into. <a href="t_pointer">Pointer</a> and
1445<a href="t_array">array</a> types require '<tt>uint</tt>' values, and <a
1446href="t_struct">structure</a> types require '<tt>ubyte</tt>'
1447<b>constants</b>.<p>
1448
1449In the example above, the first index is indexing into the '<tt>%ST*</tt>' type,
1450which is a pointer, yielding a '<tt>%ST</tt>' = '<tt>{ int, double, %RT }</tt>'
1451type, a structure. The second index indexes into the third element of the
1452structure, yielding a '<tt>%RT</tt>' = '<tt>{ sbyte, [10 x [20 x int]], sbyte
1453}</tt>' type, another structure. The third index indexes into the second
1454element of the structure, yielding a '<tt>[10 x [20 x int]]</tt>' type, an
1455array. The two dimensions of the array are subscripted into, yielding an
1456'<tt>int</tt>' type. The '<tt>getelementptr</tt>' instruction return a pointer
1457to this element, thus yielding a '<tt>int*</tt>' type.<p>
1458
1459Note that it is perfectly legal to index partially through a structure,
1460returning a pointer to an inner element. Because of this, the LLVM code for the
1461given testcase is equivalent to:<p>
1462
1463<pre>
1464int* "foo"(%ST* %s) {
1465 %t1 = getelementptr %ST* %s , uint 1 <i>; yields %ST*:%t1</i>
1466 %t2 = getelementptr %ST* %t1, uint 0, ubyte 2 <i>; yields %RT*:%t2</i>
1467 %t3 = getelementptr %RT* %t2, uint 0, ubyte 1 <i>; yields [10 x [20 x int]]*:%t3</i>
1468 %t4 = getelementptr [10 x [20 x int]]* %t3, uint 0, uint 5 <i>; yields [20 x int]*:%t4</i>
1469 %t5 = getelementptr [20 x int]* %t4, uint 0, uint 13 <i>; yields int*:%t5</i>
1470 ret int* %t5
1471}
1472</pre>
1473
1474
Chris Lattner7faa8832002-04-14 06:13:44 +00001475
1476<h5>Example:</h5>
1477<pre>
Chris Lattnerf31860b2002-08-19 21:14:38 +00001478 <i>; yields [12 x ubyte]*:aptr</i>
Chris Lattner6536cfe2002-05-06 22:08:29 +00001479 %aptr = getelementptr {int, [12 x ubyte]}* %sptr, uint 0, ubyte 1
Chris Lattner7faa8832002-04-14 06:13:44 +00001480</pre>
1481
1482
1483
Chris Lattner00950542001-06-06 20:29:01 +00001484<!-- ======================================================================= -->
Chris Lattner2b7d3202002-05-06 03:03:22 +00001485</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0>
1486<tr><td>&nbsp;</td><td width="100%">&nbsp; <font color="#EEEEFF" face="Georgia,Palatino"><b>
Chris Lattner00950542001-06-06 20:29:01 +00001487<a name="otherops">Other Operations
1488</b></font></td></tr></table><ul>
1489
1490The instructions in this catagory are the "miscellaneous" functions, that defy better classification.<p>
1491
1492
1493<!-- _______________________________________________________________________ -->
Chris Lattner6536cfe2002-05-06 22:08:29 +00001494</ul><a name="i_phi"><h4><hr size=0>'<tt>phi</tt>' Instruction</h4><ul>
Chris Lattner33ba0d92001-07-09 00:26:23 +00001495
1496<h5>Syntax:</h5>
1497<pre>
Chris Lattner6536cfe2002-05-06 22:08:29 +00001498 &lt;result&gt; = phi &lt;ty&gt; [ &lt;val0&gt;, &lt;label0&gt;], ...
Chris Lattner33ba0d92001-07-09 00:26:23 +00001499</pre>
1500
1501<h5>Overview:</h5>
1502
Chris Lattner6536cfe2002-05-06 22:08:29 +00001503The '<tt>phi</tt>' instruction is used to implement the &phi; node in the SSA
1504graph representing the function.<p>
Chris Lattner33ba0d92001-07-09 00:26:23 +00001505
1506<h5>Arguments:</h5>
1507
Chris Lattner6536cfe2002-05-06 22:08:29 +00001508The type of the incoming values are specified with the first type field. After
1509this, the '<tt>phi</tt>' instruction takes a list of pairs as arguments, with
1510one pair for each predecessor basic block of the current block.<p>
1511
1512There must be no non-phi instructions between the start of a basic block and the
1513PHI instructions: i.e. PHI instructions must be first in a basic block.<p>
Chris Lattner33ba0d92001-07-09 00:26:23 +00001514
1515<h5>Semantics:</h5>
1516
Chris Lattner6536cfe2002-05-06 22:08:29 +00001517At runtime, the '<tt>phi</tt>' instruction logically takes on the value
1518specified by the parameter, depending on which basic block we came from in the
1519last <a href="#terminators">terminator</a> instruction.<p>
1520
1521<h5>Example:</h5>
1522
1523<pre>
1524Loop: ; Infinite loop that counts from 0 on up...
1525 %indvar = phi uint [ 0, %LoopHeader ], [ %nextindvar, %Loop ]
1526 %nextindvar = add uint %indvar, 1
1527 br label %Loop
1528</pre>
1529
1530
1531<!-- _______________________________________________________________________ -->
1532</ul><a name="i_cast"><h4><hr size=0>'<tt>cast .. to</tt>' Instruction</h4><ul>
1533
1534<h5>Syntax:</h5>
1535<pre>
1536 &lt;result&gt; = cast &lt;ty&gt; &lt;value&gt; to &lt;ty2&gt; <i>; yields ty2</i>
1537</pre>
1538
1539<h5>Overview:</h5>
1540
1541The '<tt>cast</tt>' instruction is used as the primitive means to convert
1542integers to floating point, change data type sizes, and break type safety (by
1543casting pointers).<p>
1544
1545<h5>Arguments:</h5>
1546
Chris Lattner7bae3952002-06-25 18:03:17 +00001547The '<tt>cast</tt>' instruction takes a value to cast, which must be a first
Chris Lattner6536cfe2002-05-06 22:08:29 +00001548class value, and a type to cast it to, which must also be a first class type.<p>
1549
1550<h5>Semantics:</h5>
1551
1552This instruction follows the C rules for explicit casts when determining how the
1553data being cast must change to fit in its new container.<p>
1554
Chris Lattner7bae3952002-06-25 18:03:17 +00001555When casting to bool, any value that would be considered true in the context of
1556a C '<tt>if</tt>' condition is converted to the boolean '<tt>true</tt>' values,
1557all else are '<tt>false</tt>'.<p>
Chris Lattner33ba0d92001-07-09 00:26:23 +00001558
Chris Lattnerf8856bc2002-08-13 20:52:09 +00001559When extending an integral value from a type of one signness to another (for
1560example '<tt>sbyte</tt>' to '<tt>ulong</tt>'), the value is sign-extended if the
1561<b>source</b> value is signed, and zero-extended if the source value is
Chris Lattner2b4dcbb2002-08-15 19:36:05 +00001562unsigned. <tt>bool</tt> values are always zero extended into either zero or
1563one.<p>
Chris Lattnerf8856bc2002-08-13 20:52:09 +00001564
Chris Lattner33ba0d92001-07-09 00:26:23 +00001565<h5>Example:</h5>
1566<pre>
Chris Lattner6536cfe2002-05-06 22:08:29 +00001567 %X = cast int 257 to ubyte <i>; yields ubyte:1</i>
Chris Lattner7bae3952002-06-25 18:03:17 +00001568 %Y = cast int 123 to bool <i>; yields bool:true</i>
Chris Lattner33ba0d92001-07-09 00:26:23 +00001569</pre>
1570
1571
1572
1573<!-- _______________________________________________________________________ -->
Chris Lattner00950542001-06-06 20:29:01 +00001574</ul><a name="i_call"><h4><hr size=0>'<tt>call</tt>' Instruction</h4><ul>
1575
1576<h5>Syntax:</h5>
1577<pre>
Chris Lattner6536cfe2002-05-06 22:08:29 +00001578 &lt;result&gt; = call &lt;ty&gt;* &lt;fnptrval&gt;(&lt;param list&gt;)
Chris Lattner00950542001-06-06 20:29:01 +00001579</pre>
1580
1581<h5>Overview:</h5>
1582
Chris Lattner6536cfe2002-05-06 22:08:29 +00001583The '<tt>call</tt>' instruction represents a simple function call.<p>
Chris Lattner00950542001-06-06 20:29:01 +00001584
1585<h5>Arguments:</h5>
1586
Chris Lattner6536cfe2002-05-06 22:08:29 +00001587This instruction requires several arguments:<p>
1588<ol>
1589
1590<li>'<tt>ty</tt>': shall be the signature of the pointer to function value being
1591invoked. The argument types must match the types implied by this signature.<p>
1592
1593<li>'<tt>fnptrval</tt>': An LLVM value containing a pointer to a function to be
1594invoked. In most cases, this is a direct function invocation, but indirect
1595<tt>call</tt>'s are just as possible, calling an arbitrary pointer to function
1596values.<p>
1597
1598<li>'<tt>function args</tt>': argument list whose types match the function
1599signature argument types. If the function signature indicates the function
1600accepts a variable number of arguments, the extra arguments can be specified.
1601</ol>
Chris Lattner00950542001-06-06 20:29:01 +00001602
1603<h5>Semantics:</h5>
1604
Chris Lattner6536cfe2002-05-06 22:08:29 +00001605The '<tt>call</tt>' instruction is used to cause control flow to transfer to a
1606specified function, with its incoming arguments bound to the specified values.
1607Upon a '<tt><a href="#i_ret">ret</a></tt>' instruction in the called function,
1608control flow continues with the instruction after the function call, and the
1609return value of the function is bound to the result argument. This is a simpler
1610case of the <a href="#i_invoke">invoke</a> instruction.<p>
Chris Lattner00950542001-06-06 20:29:01 +00001611
1612<h5>Example:</h5>
1613<pre>
1614 %retval = call int %test(int %argc)
Chris Lattner6536cfe2002-05-06 22:08:29 +00001615 call int(sbyte*, ...) *%printf(sbyte* %msg, int 12, sbyte 42);
1616
Chris Lattner00950542001-06-06 20:29:01 +00001617</pre>
1618
Chris Lattner6536cfe2002-05-06 22:08:29 +00001619<!--
Chris Lattner00950542001-06-06 20:29:01 +00001620
Chris Lattner6536cfe2002-05-06 22:08:29 +00001621<!x- *********************************************************************** -x>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001622</ul><table width="100%" bgcolor="#330077" border=0 cellpadding=4 cellspacing=0>
1623<tr><td align=center><font color="#EEEEFF" size=+2 face="Georgia,Palatino"><b>
Chris Lattner00950542001-06-06 20:29:01 +00001624<a name="related">Related Work
1625</b></font></td></tr></table><ul>
Chris Lattner6536cfe2002-05-06 22:08:29 +00001626<!x- *********************************************************************** -x>
Chris Lattner00950542001-06-06 20:29:01 +00001627
1628
1629Codesigned virtual machines.<p>
1630
1631<dl>
1632<a name="rw_safetsa">
1633<dt>SafeTSA
1634<DD>Description here<p>
1635
1636<a name="rw_java">
1637<dt><a href="http://www.javasoft.com">Java</a>
1638<DD>Desciption here<p>
1639
1640<a name="rw_net">
1641<dt><a href="http://www.microsoft.com/net">Microsoft .net</a>
1642<DD>Desciption here<p>
1643
1644<a name="rw_gccrtl">
1645<dt><a href="http://www.math.umn.edu/systems_guide/gcc-2.95.1/gcc_15.html">GNU RTL Intermediate Representation</a>
1646<DD>Desciption here<p>
1647
1648<a name="rw_ia64">
1649<dt><a href="http://developer.intel.com/design/ia-64/index.htm">IA64 Architecture &amp; Instruction Set</a>
1650<DD>Desciption here<p>
1651
1652<a name="rw_mmix">
1653<dt><a href="http://www-cs-faculty.stanford.edu/~knuth/mmix-news.html">MMIX Instruction Set</a>
1654<DD>Desciption here<p>
1655
1656<a name="rw_stroustrup">
1657<dt><a href="http://www.research.att.com/~bs/devXinterview.html">"Interview With Bjarne Stroustrup"</a>
1658<DD>This interview influenced the design and thought process behind LLVM in several ways, most notably the way that derived types are written in text format. See the question that starts with "you defined the C declarator syntax as an experiment that failed".<p>
1659</dl>
1660
Chris Lattner6536cfe2002-05-06 22:08:29 +00001661<!x- _______________________________________________________________________ -x>
Chris Lattner00950542001-06-06 20:29:01 +00001662</ul><a name="rw_vectorization"><h3><hr size=0>Vectorized Architectures</h3><ul>
1663
1664<dl>
1665<a name="rw_intel_simd">
1666<dt>Intel MMX, MMX2, SSE, SSE2
1667<DD>Description here<p>
1668
1669<a name="rw_amd_simd">
1670<dt><a href="http://www.nondot.org/~sabre/os/H1ChipFeatures/3DNow!TechnologyManual.pdf">AMD 3Dnow!, 3Dnow! 2</a>
1671<DD>Desciption here<p>
1672
1673<a name="rw_sun_simd">
1674<dt><a href="http://www.nondot.org/~sabre/os/H1ChipFeatures/VISInstructionSetUsersManual.pdf">Sun VIS ISA</a>
1675<DD>Desciption here<p>
1676
Chris Lattner6536cfe2002-05-06 22:08:29 +00001677<a name="rw_powerpc_simd">
1678<dt>PowerPC Altivec
1679<DD>Desciption here<p>
Chris Lattner00950542001-06-06 20:29:01 +00001680
1681</dl>
1682
1683more...
1684
Chris Lattner6536cfe2002-05-06 22:08:29 +00001685-->
1686
1687
Chris Lattner00950542001-06-06 20:29:01 +00001688<!-- *********************************************************************** -->
1689</ul>
1690<!-- *********************************************************************** -->
1691
1692
1693<hr>
1694<font size=-1>
1695<address><a href="mailto:sabre@nondot.org">Chris Lattner</a></address>
1696<!-- Created: Tue Jan 23 15:19:28 CST 2001 -->
1697<!-- hhmts start -->
Chris Lattnerf31860b2002-08-19 21:14:38 +00001698Last modified: Mon Aug 19 15:52:29 CDT 2002
Chris Lattner00950542001-06-06 20:29:01 +00001699<!-- hhmts end -->
1700</font>
1701</body></html>