blob: 25b3b1edc63a2a417e936b157c49a0cced717ac1 [file] [log] [blame]
Misha Brukmandaa4cb02004-03-01 17:47:27 +00001<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
Misha Brukman9d0919f2003-11-08 01:05:38 +00003<html>
4<head>
5 <title>LLVM Assembly Language Reference Manual</title>
Reid Spencer3921c742004-08-26 20:44:00 +00006 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
7 <meta name="author" content="Chris Lattner">
8 <meta name="description"
9 content="LLVM Assembly Language Reference Manual.">
Misha Brukman9d0919f2003-11-08 01:05:38 +000010 <link rel="stylesheet" href="llvm.css" type="text/css">
11</head>
Chris Lattnerd7923912004-05-23 21:06:01 +000012
Misha Brukman9d0919f2003-11-08 01:05:38 +000013<body>
Chris Lattnerd7923912004-05-23 21:06:01 +000014
Chris Lattner261efe92003-11-25 01:02:51 +000015<div class="doc_title"> LLVM Language Reference Manual </div>
Chris Lattner00950542001-06-06 20:29:01 +000016<ol>
Misha Brukman9d0919f2003-11-08 01:05:38 +000017 <li><a href="#abstract">Abstract</a></li>
18 <li><a href="#introduction">Introduction</a></li>
19 <li><a href="#identifiers">Identifiers</a></li>
Chris Lattnerfa730212004-12-09 16:11:40 +000020 <li><a href="#highlevel">High Level Structure</a>
21 <ol>
22 <li><a href="#modulestructure">Module Structure</a></li>
23 <li><a href="#globalvars">Global Variables</a></li>
24 <li><a href="#functionstructure">Function Structure</a></li>
25 </ol>
26 </li>
Chris Lattner00950542001-06-06 20:29:01 +000027 <li><a href="#typesystem">Type System</a>
28 <ol>
Chris Lattner261efe92003-11-25 01:02:51 +000029 <li><a href="#t_primitive">Primitive Types</a>
30 <ol>
Misha Brukman9d0919f2003-11-08 01:05:38 +000031 <li><a href="#t_classifications">Type Classifications</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000032 </ol>
33 </li>
Chris Lattner00950542001-06-06 20:29:01 +000034 <li><a href="#t_derived">Derived Types</a>
35 <ol>
Chris Lattner261efe92003-11-25 01:02:51 +000036 <li><a href="#t_array">Array Type</a></li>
Misha Brukman9d0919f2003-11-08 01:05:38 +000037 <li><a href="#t_function">Function Type</a></li>
38 <li><a href="#t_pointer">Pointer Type</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000039 <li><a href="#t_struct">Structure Type</a></li>
Chris Lattnera58561b2004-08-12 19:12:28 +000040 <li><a href="#t_packed">Packed Type</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000041 </ol>
42 </li>
43 </ol>
44 </li>
Chris Lattnerfa730212004-12-09 16:11:40 +000045 <li><a href="#constants">Constants</a>
Chris Lattner261efe92003-11-25 01:02:51 +000046 </li>
Chris Lattner00950542001-06-06 20:29:01 +000047 <li><a href="#instref">Instruction Reference</a>
48 <ol>
49 <li><a href="#terminators">Terminator Instructions</a>
50 <ol>
Chris Lattner261efe92003-11-25 01:02:51 +000051 <li><a href="#i_ret">'<tt>ret</tt>' Instruction</a></li>
52 <li><a href="#i_br">'<tt>br</tt>' Instruction</a></li>
Misha Brukman9d0919f2003-11-08 01:05:38 +000053 <li><a href="#i_switch">'<tt>switch</tt>' Instruction</a></li>
54 <li><a href="#i_invoke">'<tt>invoke</tt>' Instruction</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000055 <li><a href="#i_unwind">'<tt>unwind</tt>' Instruction</a></li>
Chris Lattner35eca582004-10-16 18:04:13 +000056 <li><a href="#i_unreachable">'<tt>unreachable</tt>' Instruction</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000057 </ol>
58 </li>
Chris Lattner00950542001-06-06 20:29:01 +000059 <li><a href="#binaryops">Binary Operations</a>
60 <ol>
Chris Lattner261efe92003-11-25 01:02:51 +000061 <li><a href="#i_add">'<tt>add</tt>' Instruction</a></li>
62 <li><a href="#i_sub">'<tt>sub</tt>' Instruction</a></li>
63 <li><a href="#i_mul">'<tt>mul</tt>' Instruction</a></li>
64 <li><a href="#i_div">'<tt>div</tt>' Instruction</a></li>
65 <li><a href="#i_rem">'<tt>rem</tt>' Instruction</a></li>
Misha Brukman9d0919f2003-11-08 01:05:38 +000066 <li><a href="#i_setcc">'<tt>set<i>cc</i></tt>' Instructions</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000067 </ol>
68 </li>
Chris Lattner00950542001-06-06 20:29:01 +000069 <li><a href="#bitwiseops">Bitwise Binary Operations</a>
70 <ol>
Misha Brukman9d0919f2003-11-08 01:05:38 +000071 <li><a href="#i_and">'<tt>and</tt>' Instruction</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000072 <li><a href="#i_or">'<tt>or</tt>' Instruction</a></li>
Misha Brukman9d0919f2003-11-08 01:05:38 +000073 <li><a href="#i_xor">'<tt>xor</tt>' Instruction</a></li>
74 <li><a href="#i_shl">'<tt>shl</tt>' Instruction</a></li>
75 <li><a href="#i_shr">'<tt>shr</tt>' Instruction</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000076 </ol>
77 </li>
Chris Lattner00950542001-06-06 20:29:01 +000078 <li><a href="#memoryops">Memory Access Operations</a>
79 <ol>
Chris Lattner261efe92003-11-25 01:02:51 +000080 <li><a href="#i_malloc">'<tt>malloc</tt>' Instruction</a></li>
81 <li><a href="#i_free">'<tt>free</tt>' Instruction</a></li>
82 <li><a href="#i_alloca">'<tt>alloca</tt>' Instruction</a></li>
83 <li><a href="#i_load">'<tt>load</tt>' Instruction</a></li>
84 <li><a href="#i_store">'<tt>store</tt>' Instruction</a></li>
85 <li><a href="#i_getelementptr">'<tt>getelementptr</tt>' Instruction</a></li>
86 </ol>
87 </li>
Chris Lattner00950542001-06-06 20:29:01 +000088 <li><a href="#otherops">Other Operations</a>
89 <ol>
Chris Lattner261efe92003-11-25 01:02:51 +000090 <li><a href="#i_phi">'<tt>phi</tt>' Instruction</a></li>
Misha Brukman9d0919f2003-11-08 01:05:38 +000091 <li><a href="#i_cast">'<tt>cast .. to</tt>' Instruction</a></li>
Chris Lattnercc37aae2004-03-12 05:50:16 +000092 <li><a href="#i_select">'<tt>select</tt>' Instruction</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000093 <li><a href="#i_call">'<tt>call</tt>' Instruction</a></li>
Misha Brukman9d0919f2003-11-08 01:05:38 +000094 <li><a href="#i_vanext">'<tt>vanext</tt>' Instruction</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000095 <li><a href="#i_vaarg">'<tt>vaarg</tt>' Instruction</a></li>
Chris Lattner00950542001-06-06 20:29:01 +000096 </ol>
Chris Lattner261efe92003-11-25 01:02:51 +000097 </li>
Chris Lattner00950542001-06-06 20:29:01 +000098 </ol>
Chris Lattner261efe92003-11-25 01:02:51 +000099 </li>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +0000100 <li><a href="#intrinsics">Intrinsic Functions</a>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +0000101 <ol>
Chris Lattner261efe92003-11-25 01:02:51 +0000102 <li><a href="#int_varargs">Variable Argument Handling Intrinsics</a>
103 <ol>
104 <li><a href="#i_va_start">'<tt>llvm.va_start</tt>' Intrinsic</a></li>
105 <li><a href="#i_va_end">'<tt>llvm.va_end</tt>' Intrinsic</a></li>
106 <li><a href="#i_va_copy">'<tt>llvm.va_copy</tt>' Intrinsic</a></li>
107 </ol>
108 </li>
Chris Lattnerd7923912004-05-23 21:06:01 +0000109 <li><a href="#int_gc">Accurate Garbage Collection Intrinsics</a>
110 <ol>
111 <li><a href="#i_gcroot">'<tt>llvm.gcroot</tt>' Intrinsic</a></li>
112 <li><a href="#i_gcread">'<tt>llvm.gcread</tt>' Intrinsic</a></li>
113 <li><a href="#i_gcwrite">'<tt>llvm.gcwrite</tt>' Intrinsic</a></li>
114 </ol>
115 </li>
Chris Lattner10610642004-02-14 04:08:35 +0000116 <li><a href="#int_codegen">Code Generator Intrinsics</a>
117 <ol>
118 <li><a href="#i_returnaddress">'<tt>llvm.returnaddress</tt>' Intrinsic</a></li>
119 <li><a href="#i_frameaddress">'<tt>llvm.frameaddress</tt>' Intrinsic</a></li>
John Criswell7123e272004-04-09 16:43:20 +0000120 </ol>
121 </li>
122 <li><a href="#int_os">Operating System Intrinsics</a>
123 <ol>
Chris Lattner32006282004-06-11 02:28:03 +0000124 <li><a href="#i_readport">'<tt>llvm.readport</tt>' Intrinsic</a></li>
125 <li><a href="#i_writeport">'<tt>llvm.writeport</tt>' Intrinsic</a></li>
John Criswell183402a2004-04-12 15:02:16 +0000126 <li><a href="#i_readio">'<tt>llvm.readio</tt>' Intrinsic</a></li>
127 <li><a href="#i_writeio">'<tt>llvm.writeio</tt>' Intrinsic</a></li>
Chris Lattner10610642004-02-14 04:08:35 +0000128 </ol>
Chris Lattner33aec9e2004-02-12 17:01:32 +0000129 <li><a href="#int_libc">Standard C Library Intrinsics</a>
130 <ol>
131 <li><a href="#i_memcpy">'<tt>llvm.memcpy</tt>' Intrinsic</a></li>
Chris Lattner0eb51b42004-02-12 18:10:10 +0000132 <li><a href="#i_memmove">'<tt>llvm.memmove</tt>' Intrinsic</a></li>
Chris Lattner10610642004-02-14 04:08:35 +0000133 <li><a href="#i_memset">'<tt>llvm.memset</tt>' Intrinsic</a></li>
Alkis Evlogimenos96853722004-06-12 19:19:14 +0000134 <li><a href="#i_isunordered">'<tt>llvm.isunordered</tt>' Intrinsic</a></li>
Chris Lattner33aec9e2004-02-12 17:01:32 +0000135 </ol>
136 </li>
Chris Lattnerd7923912004-05-23 21:06:01 +0000137 <li><a href="#int_debugger">Debugger intrinsics</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +0000138 </ol>
139 </li>
Chris Lattner00950542001-06-06 20:29:01 +0000140</ol>
Chris Lattnerd7923912004-05-23 21:06:01 +0000141
142<div class="doc_author">
143 <p>Written by <a href="mailto:sabre@nondot.org">Chris Lattner</a>
144 and <a href="mailto:vadve@cs.uiuc.edu">Vikram Adve</a></p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000145</div>
Chris Lattnerd7923912004-05-23 21:06:01 +0000146
Chris Lattner00950542001-06-06 20:29:01 +0000147<!-- *********************************************************************** -->
Chris Lattner261efe92003-11-25 01:02:51 +0000148<div class="doc_section"> <a name="abstract">Abstract </a></div>
149<!-- *********************************************************************** -->
Chris Lattnerd7923912004-05-23 21:06:01 +0000150
Misha Brukman9d0919f2003-11-08 01:05:38 +0000151<div class="doc_text">
Chris Lattner261efe92003-11-25 01:02:51 +0000152<p>This document is a reference manual for the LLVM assembly language.
153LLVM is an SSA based representation that provides type safety,
154low-level operations, flexibility, and the capability of representing
155'all' high-level languages cleanly. It is the common code
156representation used throughout all phases of the LLVM compilation
157strategy.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000158</div>
Chris Lattnerd7923912004-05-23 21:06:01 +0000159
Chris Lattner00950542001-06-06 20:29:01 +0000160<!-- *********************************************************************** -->
Chris Lattner261efe92003-11-25 01:02:51 +0000161<div class="doc_section"> <a name="introduction">Introduction</a> </div>
162<!-- *********************************************************************** -->
Chris Lattnerd7923912004-05-23 21:06:01 +0000163
Misha Brukman9d0919f2003-11-08 01:05:38 +0000164<div class="doc_text">
Chris Lattnerd7923912004-05-23 21:06:01 +0000165
Chris Lattner261efe92003-11-25 01:02:51 +0000166<p>The LLVM code representation is designed to be used in three
167different forms: as an in-memory compiler IR, as an on-disk bytecode
168representation (suitable for fast loading by a Just-In-Time compiler),
169and as a human readable assembly language representation. This allows
170LLVM to provide a powerful intermediate representation for efficient
171compiler transformations and analysis, while providing a natural means
172to debug and visualize the transformations. The three different forms
173of LLVM are all equivalent. This document describes the human readable
174representation and notation.</p>
Chris Lattnerd7923912004-05-23 21:06:01 +0000175
Chris Lattner261efe92003-11-25 01:02:51 +0000176<p>The LLVM representation aims to be a light-weight and low-level
177while being expressive, typed, and extensible at the same time. It
178aims to be a "universal IR" of sorts, by being at a low enough level
179that high-level ideas may be cleanly mapped to it (similar to how
180microprocessors are "universal IR's", allowing many source languages to
181be mapped to them). By providing type information, LLVM can be used as
182the target of optimizations: for example, through pointer analysis, it
183can be proven that a C automatic variable is never accessed outside of
184the current function... allowing it to be promoted to a simple SSA
185value instead of a memory location.</p>
Chris Lattnerd7923912004-05-23 21:06:01 +0000186
Misha Brukman9d0919f2003-11-08 01:05:38 +0000187</div>
Chris Lattnerd7923912004-05-23 21:06:01 +0000188
Chris Lattner00950542001-06-06 20:29:01 +0000189<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000190<div class="doc_subsubsection"> <a name="wellformed">Well-Formedness</a> </div>
Chris Lattnerd7923912004-05-23 21:06:01 +0000191
Misha Brukman9d0919f2003-11-08 01:05:38 +0000192<div class="doc_text">
Chris Lattnerd7923912004-05-23 21:06:01 +0000193
Chris Lattner261efe92003-11-25 01:02:51 +0000194<p>It is important to note that this document describes 'well formed'
195LLVM assembly language. There is a difference between what the parser
196accepts and what is considered 'well formed'. For example, the
197following instruction is syntactically okay, but not well formed:</p>
Chris Lattnerd7923912004-05-23 21:06:01 +0000198
199<pre>
200 %x = <a href="#i_add">add</a> int 1, %x
201</pre>
202
Chris Lattner261efe92003-11-25 01:02:51 +0000203<p>...because the definition of <tt>%x</tt> does not dominate all of
204its uses. The LLVM infrastructure provides a verification pass that may
205be used to verify that an LLVM module is well formed. This pass is
206automatically run by the parser after parsing input assembly, and by
207the optimizer before it outputs bytecode. The violations pointed out
208by the verifier pass indicate bugs in transformation passes or input to
209the parser.</p>
Chris Lattnerd7923912004-05-23 21:06:01 +0000210
Chris Lattner261efe92003-11-25 01:02:51 +0000211<!-- Describe the typesetting conventions here. --> </div>
Chris Lattnerd7923912004-05-23 21:06:01 +0000212
Chris Lattner00950542001-06-06 20:29:01 +0000213<!-- *********************************************************************** -->
Chris Lattner261efe92003-11-25 01:02:51 +0000214<div class="doc_section"> <a name="identifiers">Identifiers</a> </div>
Chris Lattner00950542001-06-06 20:29:01 +0000215<!-- *********************************************************************** -->
Chris Lattnerd7923912004-05-23 21:06:01 +0000216
Misha Brukman9d0919f2003-11-08 01:05:38 +0000217<div class="doc_text">
Chris Lattnerd7923912004-05-23 21:06:01 +0000218
Chris Lattner261efe92003-11-25 01:02:51 +0000219<p>LLVM uses three different forms of identifiers, for different
220purposes:</p>
Chris Lattnerd7923912004-05-23 21:06:01 +0000221
Chris Lattner00950542001-06-06 20:29:01 +0000222<ol>
Chris Lattner261efe92003-11-25 01:02:51 +0000223 <li>Numeric constants are represented as you would expect: 12, -3
John Criswell4457dc92004-04-09 16:48:45 +0000224123.421, etc. Floating point constants have an optional hexadecimal
Chris Lattner261efe92003-11-25 01:02:51 +0000225notation.</li>
226 <li>Named values are represented as a string of characters with a '%'
227prefix. For example, %foo, %DivisionByZero,
228%a.really.long.identifier. The actual regular expression used is '<tt>%[a-zA-Z$._][a-zA-Z$._0-9]*</tt>'.
229Identifiers which require other characters in their names can be
230surrounded with quotes. In this way, anything except a <tt>"</tt>
231character can be used in a name.</li>
232 <li>Unnamed values are represented as an unsigned numeric value with
233a '%' prefix. For example, %12, %2, %44.</li>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000234</ol>
John Criswell6794d922004-03-12 21:19:06 +0000235<p>LLVM requires that values start with a '%' sign for two reasons:
Chris Lattner261efe92003-11-25 01:02:51 +0000236Compilers don't need to worry about name clashes with reserved words,
237and the set of reserved words may be expanded in the future without
238penalty. Additionally, unnamed identifiers allow a compiler to quickly
239come up with a temporary variable without having to avoid symbol table
240conflicts.</p>
241<p>Reserved words in LLVM are very similar to reserved words in other
242languages. There are keywords for different opcodes ('<tt><a
243 href="#i_add">add</a></tt>', '<tt><a href="#i_cast">cast</a></tt>', '<tt><a
244 href="#i_ret">ret</a></tt>', etc...), for primitive type names ('<tt><a
245 href="#t_void">void</a></tt>', '<tt><a href="#t_uint">uint</a></tt>',
246etc...), and others. These reserved words cannot conflict with
247variable names, because none of them start with a '%' character.</p>
248<p>Here is an example of LLVM code to multiply the integer variable '<tt>%X</tt>'
249by 8:</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000250<p>The easy way:</p>
Chris Lattner261efe92003-11-25 01:02:51 +0000251<pre> %result = <a href="#i_mul">mul</a> uint %X, 8<br></pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000252<p>After strength reduction:</p>
Chris Lattner261efe92003-11-25 01:02:51 +0000253<pre> %result = <a href="#i_shl">shl</a> uint %X, ubyte 3<br></pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000254<p>And the hard way:</p>
Chris Lattner261efe92003-11-25 01:02:51 +0000255<pre> <a href="#i_add">add</a> uint %X, %X <i>; yields {uint}:%0</i>
256 <a
257 href="#i_add">add</a> uint %0, %0 <i>; yields {uint}:%1</i>
258 %result = <a
259 href="#i_add">add</a> uint %1, %1<br></pre>
260<p>This last way of multiplying <tt>%X</tt> by 8 illustrates several
261important lexical features of LLVM:</p>
Chris Lattner00950542001-06-06 20:29:01 +0000262<ol>
Chris Lattner261efe92003-11-25 01:02:51 +0000263 <li>Comments are delimited with a '<tt>;</tt>' and go until the end
264of line.</li>
265 <li>Unnamed temporaries are created when the result of a computation
266is not assigned to a named value.</li>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000267 <li>Unnamed temporaries are numbered sequentially</li>
268</ol>
Chris Lattner261efe92003-11-25 01:02:51 +0000269<p>...and it also show a convention that we follow in this document.
270When demonstrating instructions, we will follow an instruction with a
271comment that defines the type and name of value produced. Comments are
272shown in italic text.</p>
273<p>The one non-intuitive notation for constants is the optional
274hexidecimal form of floating point constants. For example, the form '<tt>double
Chris Lattner2b7d3202002-05-06 03:03:22 +00002750x432ff973cafa8000</tt>' is equivalent to (but harder to read than) '<tt>double
Chris Lattner261efe92003-11-25 01:02:51 +00002764.5e+15</tt>' which is also supported by the parser. The only time
277hexadecimal floating point constants are useful (and the only time that
278they are generated by the disassembler) is when an FP constant has to
279be emitted that is not representable as a decimal floating point number
280exactly. For example, NaN's, infinities, and other special cases are
281represented in their IEEE hexadecimal format so that assembly and
282disassembly do not cause any bits to change in the constants.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000283</div>
Chris Lattnerfa730212004-12-09 16:11:40 +0000284
285<!-- *********************************************************************** -->
286<div class="doc_section"> <a name="highlevel">High Level Structure</a> </div>
287<!-- *********************************************************************** -->
288
289<!-- ======================================================================= -->
290<div class="doc_subsection"> <a name="modulestructure">Module Structure</a>
291</div>
292
293<div class="doc_text">
294
295<p>LLVM programs are composed of "Module"s, each of which is a
296translation unit of the input programs. Each module consists of
297functions, global variables, and symbol table entries. Modules may be
298combined together with the LLVM linker, which merges function (and
299global variable) definitions, resolves forward declarations, and merges
300symbol table entries. Here is an example of the "hello world" module:</p>
301
302<pre><i>; Declare the string constant as a global constant...</i>
303<a href="#identifiers">%.LC0</a> = <a href="#linkage_internal">internal</a> <a
304 href="#globalvars">constant</a> <a href="#t_array">[13 x sbyte]</a> c"hello world\0A\00" <i>; [13 x sbyte]*</i>
305
306<i>; External declaration of the puts function</i>
307<a href="#functionstructure">declare</a> int %puts(sbyte*) <i>; int(sbyte*)* </i>
308
309<i>; Definition of main function</i>
310int %main() { <i>; int()* </i>
311 <i>; Convert [13x sbyte]* to sbyte *...</i>
312 %cast210 = <a
313 href="#i_getelementptr">getelementptr</a> [13 x sbyte]* %.LC0, long 0, long 0 <i>; sbyte*</i>
314
315 <i>; Call puts function to write out the string to stdout...</i>
316 <a
317 href="#i_call">call</a> int %puts(sbyte* %cast210) <i>; int</i>
318 <a
319 href="#i_ret">ret</a> int 0<br>}<br></pre>
320
321<p>This example is made up of a <a href="#globalvars">global variable</a>
322named "<tt>.LC0</tt>", an external declaration of the "<tt>puts</tt>"
323function, and a <a href="#functionstructure">function definition</a>
324for "<tt>main</tt>".</p>
325
326<a name="linkage"> In general, a module is made up of a list of global
327values, where both functions and global variables are global values.
328Global values are represented by a pointer to a memory location (in
329this case, a pointer to an array of char, and a pointer to a function),
330and have one of the following linkage types:</a>
331
332<p> </p>
333
334<dl>
335 <dt><tt><b><a name="linkage_internal">internal</a></b></tt> </dt>
336 <dd>Global values with internal linkage are only directly accessible
337by objects in the current module. In particular, linking code into a
338module with an internal global value may cause the internal to be
339renamed as necessary to avoid collisions. Because the symbol is
340internal to the module, all references can be updated. This
341corresponds to the notion of the '<tt>static</tt>' keyword in C, or the
342idea of "anonymous namespaces" in C++.
343 <p> </p>
344 </dd>
345 <dt><tt><b><a name="linkage_linkonce">linkonce</a></b></tt>: </dt>
346 <dd>"<tt>linkonce</tt>" linkage is similar to <tt>internal</tt>
347linkage, with the twist that linking together two modules defining the
348same <tt>linkonce</tt> globals will cause one of the globals to be
349discarded. This is typically used to implement inline functions.
350Unreferenced <tt>linkonce</tt> globals are allowed to be discarded.
351 <p> </p>
352 </dd>
353 <dt><tt><b><a name="linkage_weak">weak</a></b></tt>: </dt>
354 <dd>"<tt>weak</tt>" linkage is exactly the same as <tt>linkonce</tt>
355linkage, except that unreferenced <tt>weak</tt> globals may not be
356discarded. This is used to implement constructs in C such as "<tt>int
357X;</tt>" at global scope.
358 <p> </p>
359 </dd>
360 <dt><tt><b><a name="linkage_appending">appending</a></b></tt>: </dt>
361 <dd>"<tt>appending</tt>" linkage may only be applied to global
362variables of pointer to array type. When two global variables with
363appending linkage are linked together, the two global arrays are
364appended together. This is the LLVM, typesafe, equivalent of having
365the system linker append together "sections" with identical names when
366.o files are linked.
367 <p> </p>
368 </dd>
369 <dt><tt><b><a name="linkage_external">externally visible</a></b></tt>:</dt>
370 <dd>If none of the above identifiers are used, the global is
371externally visible, meaning that it participates in linkage and can be
372used to resolve external symbol references.
373 <p> </p>
374 </dd>
375</dl>
376
377<p> </p>
378
379<p><a name="linkage_external">For example, since the "<tt>.LC0</tt>"
380variable is defined to be internal, if another module defined a "<tt>.LC0</tt>"
381variable and was linked with this one, one of the two would be renamed,
382preventing a collision. Since "<tt>main</tt>" and "<tt>puts</tt>" are
383external (i.e., lacking any linkage declarations), they are accessible
384outside of the current module. It is illegal for a function <i>declaration</i>
385to have any linkage type other than "externally visible".</a></p>
386</div>
387
388<!-- ======================================================================= -->
389<div class="doc_subsection">
390 <a name="globalvars">Global Variables</a>
391</div>
392
393<div class="doc_text">
394
395<p>Global variables define regions of memory allocated at compilation
396time instead of run-time. Global variables may optionally be
397initialized. A variable may be defined as a global "constant", which
398indicates that the contents of the variable will never be modified
399(enabling better optimization, allowing the global data to be placed in the
400read-only section of an executable, etc).</p>
401
402<p>As SSA values, global variables define pointer values that are in
403scope (i.e. they dominate) all basic blocks in the program. Global
404variables always define a pointer to their "content" type because they
405describe a region of memory, and all memory objects in LLVM are
406accessed through pointers.</p>
407
408</div>
409
410
411<!-- ======================================================================= -->
412<div class="doc_subsection">
413 <a name="functionstructure">Functions</a>
414</div>
415
416<div class="doc_text">
417
418<p>LLVM function definitions are composed of a (possibly empty) argument list,
419an opening curly brace, a list of basic blocks, and a closing curly brace. LLVM
420function declarations are defined with the "<tt>declare</tt>" keyword, a
421function name, and a function signature.</p>
422
423<p>A function definition contains a list of basic blocks, forming the CFG for
424the function. Each basic block may optionally start with a label (giving the
425basic block a symbol table entry), contains a list of instructions, and ends
426with a <a href="#terminators">terminator</a> instruction (such as a branch or
427function return).</p>
428
429<p>The first basic block in program is special in two ways: it is immediately
430executed on entrance to the function, and it is not allowed to have predecessor
431basic blocks (i.e. there can not be any branches to the entry block of a
432function). Because the block can have no predecessors, it also cannot have any
433<a href="#i_phi">PHI nodes</a>.</p>
434
435<p>LLVM functions are identified by their name and type signature. Hence, two
436functions with the same name but different parameter lists or return values are
437considered different functions, and LLVM will resolves references to each
438appropriately.</p>
439
440</div>
441
442
443
Chris Lattner00950542001-06-06 20:29:01 +0000444<!-- *********************************************************************** -->
Chris Lattner261efe92003-11-25 01:02:51 +0000445<div class="doc_section"> <a name="typesystem">Type System</a> </div>
446<!-- *********************************************************************** -->
Chris Lattnerfa730212004-12-09 16:11:40 +0000447
Misha Brukman9d0919f2003-11-08 01:05:38 +0000448<div class="doc_text">
Chris Lattnerfa730212004-12-09 16:11:40 +0000449
Misha Brukman9d0919f2003-11-08 01:05:38 +0000450<p>The LLVM type system is one of the most important features of the
Chris Lattner261efe92003-11-25 01:02:51 +0000451intermediate representation. Being typed enables a number of
452optimizations to be performed on the IR directly, without having to do
453extra analyses on the side before the transformation. A strong type
454system makes it easier to read the generated code and enables novel
455analyses and transformations that are not feasible to perform on normal
456three address code representations.</p>
Chris Lattnerfa730212004-12-09 16:11:40 +0000457
458</div>
459
Chris Lattner00950542001-06-06 20:29:01 +0000460<!-- ======================================================================= -->
Chris Lattner261efe92003-11-25 01:02:51 +0000461<div class="doc_subsection"> <a name="t_primitive">Primitive Types</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000462<div class="doc_text">
John Criswell4457dc92004-04-09 16:48:45 +0000463<p>The primitive types are the fundamental building blocks of the LLVM
Chris Lattner261efe92003-11-25 01:02:51 +0000464system. The current set of primitive types are as follows:</p>
Misha Brukmandaa4cb02004-03-01 17:47:27 +0000465
Reid Spencerd3f876c2004-11-01 08:19:36 +0000466<table class="layout">
467 <tr class="layout">
468 <td class="left">
469 <table>
Chris Lattner261efe92003-11-25 01:02:51 +0000470 <tbody>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000471 <tr><th>Type</th><th>Description</th></tr>
472 <tr><td><tt>void</tt></td><td>No value</td></tr>
473 <tr><td><tt>ubyte</tt></td><td>Unsigned 8 bit value</td></tr>
474 <tr><td><tt>ushort</tt></td><td>Unsigned 16 bit value</td></tr>
475 <tr><td><tt>uint</tt></td><td>Unsigned 32 bit value</td></tr>
476 <tr><td><tt>ulong</tt></td><td>Unsigned 64 bit value</td></tr>
477 <tr><td><tt>float</tt></td><td>32 bit floating point value</td></tr>
478 <tr><td><tt>label</tt></td><td>Branch destination</td></tr>
Chris Lattner261efe92003-11-25 01:02:51 +0000479 </tbody>
480 </table>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000481 </td>
482 <td class="right">
483 <table>
Chris Lattner261efe92003-11-25 01:02:51 +0000484 <tbody>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000485 <tr><th>Type</th><th>Description</th></tr>
486 <tr><td><tt>bool</tt></td><td>True or False value</td></tr>
487 <tr><td><tt>sbyte</tt></td><td>Signed 8 bit value</td></tr>
488 <tr><td><tt>short</tt></td><td>Signed 16 bit value</td></tr>
489 <tr><td><tt>int</tt></td><td>Signed 32 bit value</td></tr>
490 <tr><td><tt>long</tt></td><td>Signed 64 bit value</td></tr>
491 <tr><td><tt>double</tt></td><td>64 bit floating point value</td></tr>
Chris Lattner261efe92003-11-25 01:02:51 +0000492 </tbody>
493 </table>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000494 </td>
495 </tr>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000496</table>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000497</div>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000498
Chris Lattner00950542001-06-06 20:29:01 +0000499<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000500<div class="doc_subsubsection"> <a name="t_classifications">Type
501Classifications</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000502<div class="doc_text">
Chris Lattner261efe92003-11-25 01:02:51 +0000503<p>These different primitive types fall into a few useful
504classifications:</p>
Misha Brukmandaa4cb02004-03-01 17:47:27 +0000505
506<table border="1" cellspacing="0" cellpadding="4">
Chris Lattner261efe92003-11-25 01:02:51 +0000507 <tbody>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000508 <tr><th>Classification</th><th>Types</th></tr>
Chris Lattner261efe92003-11-25 01:02:51 +0000509 <tr>
510 <td><a name="t_signed">signed</a></td>
511 <td><tt>sbyte, short, int, long, float, double</tt></td>
512 </tr>
513 <tr>
514 <td><a name="t_unsigned">unsigned</a></td>
515 <td><tt>ubyte, ushort, uint, ulong</tt></td>
516 </tr>
517 <tr>
518 <td><a name="t_integer">integer</a></td>
519 <td><tt>ubyte, sbyte, ushort, short, uint, int, ulong, long</tt></td>
520 </tr>
521 <tr>
522 <td><a name="t_integral">integral</a></td>
Misha Brukmanc24b7582004-08-12 20:16:08 +0000523 <td><tt>bool, ubyte, sbyte, ushort, short, uint, int, ulong, long</tt>
524 </td>
Chris Lattner261efe92003-11-25 01:02:51 +0000525 </tr>
526 <tr>
527 <td><a name="t_floating">floating point</a></td>
528 <td><tt>float, double</tt></td>
529 </tr>
530 <tr>
531 <td><a name="t_firstclass">first class</a></td>
Misha Brukmanc24b7582004-08-12 20:16:08 +0000532 <td><tt>bool, ubyte, sbyte, ushort, short, uint, int, ulong, long,<br>
533 float, double, <a href="#t_pointer">pointer</a>,
534 <a href="#t_packed">packed</a></tt></td>
Chris Lattner261efe92003-11-25 01:02:51 +0000535 </tr>
536 </tbody>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000537</table>
Misha Brukmandaa4cb02004-03-01 17:47:27 +0000538
Chris Lattner261efe92003-11-25 01:02:51 +0000539<p>The <a href="#t_firstclass">first class</a> types are perhaps the
540most important. Values of these types are the only ones which can be
541produced by instructions, passed as arguments, or used as operands to
542instructions. This means that all structures and arrays must be
543manipulated either by pointer or by component.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000544</div>
Chris Lattner00950542001-06-06 20:29:01 +0000545<!-- ======================================================================= -->
Chris Lattner261efe92003-11-25 01:02:51 +0000546<div class="doc_subsection"> <a name="t_derived">Derived Types</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000547<div class="doc_text">
Chris Lattner261efe92003-11-25 01:02:51 +0000548<p>The real power in LLVM comes from the derived types in the system.
549This is what allows a programmer to represent arrays, functions,
550pointers, and other useful types. Note that these derived types may be
551recursive: For example, it is possible to have a two dimensional array.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000552</div>
Chris Lattner00950542001-06-06 20:29:01 +0000553<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000554<div class="doc_subsubsection"> <a name="t_array">Array Type</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000555<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +0000556<h5>Overview:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000557<p>The array type is a very simple derived type that arranges elements
Chris Lattner261efe92003-11-25 01:02:51 +0000558sequentially in memory. The array type requires a size (number of
559elements) and an underlying data type.</p>
Chris Lattner7faa8832002-04-14 06:13:44 +0000560<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000561<pre> [&lt;# elements&gt; x &lt;elementtype&gt;]<br></pre>
562<p>The number of elements is a constant integer value, elementtype may
563be any type with a size.</p>
Chris Lattner7faa8832002-04-14 06:13:44 +0000564<h5>Examples:</h5>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000565<table class="layout">
566 <tr class="layout">
567 <td class="left">
568 <tt>[40 x int ]</tt><br/>
569 <tt>[41 x int ]</tt><br/>
570 <tt>[40 x uint]</tt><br/>
571 </td>
572 <td class="left">
573 Array of 40 integer values.<br/>
574 Array of 41 integer values.<br/>
575 Array of 40 unsigned integer values.<br/>
576 </td>
577 </tr>
Chris Lattner00950542001-06-06 20:29:01 +0000578</table>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000579<p>Here are some examples of multidimensional arrays:</p>
580<table class="layout">
581 <tr class="layout">
582 <td class="left">
583 <tt>[3 x [4 x int]]</tt><br/>
584 <tt>[12 x [10 x float]]</tt><br/>
585 <tt>[2 x [3 x [4 x uint]]]</tt><br/>
586 </td>
587 <td class="left">
588 3x4 array integer values.<br/>
589 12x10 array of single precision floating point values.<br/>
590 2x3x4 array of unsigned integer values.<br/>
591 </td>
592 </tr>
593</table>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000594</div>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000595
Chris Lattner00950542001-06-06 20:29:01 +0000596<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000597<div class="doc_subsubsection"> <a name="t_function">Function Type</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000598<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +0000599<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000600<p>The function type can be thought of as a function signature. It
601consists of a return type and a list of formal parameter types.
John Criswell009900b2003-11-25 21:45:46 +0000602Function types are usually used to build virtual function tables
Chris Lattner261efe92003-11-25 01:02:51 +0000603(which are structures of pointers to functions), for indirect function
604calls, and when defining a function.</p>
John Criswell009900b2003-11-25 21:45:46 +0000605<p>
606The return type of a function type cannot be an aggregate type.
607</p>
Chris Lattner00950542001-06-06 20:29:01 +0000608<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000609<pre> &lt;returntype&gt; (&lt;parameter list&gt;)<br></pre>
Misha Brukmanc24b7582004-08-12 20:16:08 +0000610<p>Where '<tt>&lt;parameter list&gt;</tt>' is a comma-separated list of type
611specifiers. Optionally, the parameter list may include a type <tt>...</tt>,
Chris Lattner27f71f22003-09-03 00:41:47 +0000612which indicates that the function takes a variable number of arguments.
613Variable argument functions can access their arguments with the <a
Chris Lattner261efe92003-11-25 01:02:51 +0000614 href="#int_varargs">variable argument handling intrinsic</a> functions.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000615<h5>Examples:</h5>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000616<table class="layout">
617 <tr class="layout">
618 <td class="left">
619 <tt>int (int)</tt> <br/>
620 <tt>float (int, int *) *</tt><br/>
621 <tt>int (sbyte *, ...)</tt><br/>
622 </td>
623 <td class="left">
624 function taking an <tt>int</tt>, returning an <tt>int</tt><br/>
625 <a href="#t_pointer">Pointer</a> to a function that takes an
Misha Brukmanc24b7582004-08-12 20:16:08 +0000626 <tt>int</tt> and a <a href="#t_pointer">pointer</a> to <tt>int</tt>,
Reid Spencerd3f876c2004-11-01 08:19:36 +0000627 returning <tt>float</tt>.<br/>
628 A vararg function that takes at least one <a href="#t_pointer">pointer</a>
629 to <tt>sbyte</tt> (signed char in C), which returns an integer. This is
630 the signature for <tt>printf</tt> in LLVM.<br/>
631 </td>
632 </tr>
Chris Lattner00950542001-06-06 20:29:01 +0000633</table>
Misha Brukmandaa4cb02004-03-01 17:47:27 +0000634
Misha Brukman9d0919f2003-11-08 01:05:38 +0000635</div>
Chris Lattner00950542001-06-06 20:29:01 +0000636<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000637<div class="doc_subsubsection"> <a name="t_struct">Structure Type</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000638<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +0000639<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000640<p>The structure type is used to represent a collection of data members
641together in memory. The packing of the field types is defined to match
642the ABI of the underlying processor. The elements of a structure may
643be any type that has a size.</p>
644<p>Structures are accessed using '<tt><a href="#i_load">load</a></tt>
645and '<tt><a href="#i_store">store</a></tt>' by getting a pointer to a
646field with the '<tt><a href="#i_getelementptr">getelementptr</a></tt>'
647instruction.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000648<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000649<pre> { &lt;type list&gt; }<br></pre>
Chris Lattner00950542001-06-06 20:29:01 +0000650<h5>Examples:</h5>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000651<table class="layout">
652 <tr class="layout">
653 <td class="left">
654 <tt>{ int, int, int }</tt><br/>
655 <tt>{ float, int (int) * }</tt><br/>
656 </td>
657 <td class="left">
658 a triple of three <tt>int</tt> values<br/>
659 A pair, where the first element is a <tt>float</tt> and the second element
660 is a <a href="#t_pointer">pointer</a> to a <a href="#t_function">function</a>
661 that takes an <tt>int</tt>, returning an <tt>int</tt>.<br/>
662 </td>
663 </tr>
Chris Lattner00950542001-06-06 20:29:01 +0000664</table>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000665</div>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000666
Chris Lattner00950542001-06-06 20:29:01 +0000667<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000668<div class="doc_subsubsection"> <a name="t_pointer">Pointer Type</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000669<div class="doc_text">
Chris Lattner7faa8832002-04-14 06:13:44 +0000670<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000671<p>As in many languages, the pointer type represents a pointer or
672reference to another object, which must live in memory.</p>
Chris Lattner7faa8832002-04-14 06:13:44 +0000673<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000674<pre> &lt;type&gt; *<br></pre>
Chris Lattner7faa8832002-04-14 06:13:44 +0000675<h5>Examples:</h5>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000676<table class="layout">
677 <tr class="layout">
678 <td class="left">
679 <tt>[4x int]*</tt><br/>
680 <tt>int (int *) *</tt><br/>
681 </td>
682 <td class="left">
683 A <a href="#t_pointer">pointer</a> to <a href="#t_array">array</a> of
684 four <tt>int</tt> values<br/>
685 A <a href="#t_pointer">pointer</a> to a <a
Misha Brukmanc24b7582004-08-12 20:16:08 +0000686 href="#t_function">function</a> that takes an <tt>int</tt>, returning an
Reid Spencerd3f876c2004-11-01 08:19:36 +0000687 <tt>int</tt>.<br/>
688 </td>
689 </tr>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000690</table>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000691</div>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000692
Chris Lattnera58561b2004-08-12 19:12:28 +0000693<!-- _______________________________________________________________________ -->
694<div class="doc_subsubsection"> <a name="t_packed">Packed Type</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000695<div class="doc_text">
Chris Lattnera58561b2004-08-12 19:12:28 +0000696<h5>Overview:</h5>
697<p>A packed type is a simple derived type that represents a vector
698of elements. Packed types are used when multiple primitive data
699are operated in parallel using a single instruction (SIMD).
700A packed type requires a size (number of
701elements) and an underlying primitive data type. Packed types are
702considered <a href="#t_firstclass">first class</a>.</p>
703<h5>Syntax:</h5>
704<pre> &lt; &lt;# elements&gt; x &lt;elementtype&gt; &gt;<br></pre>
705<p>The number of elements is a constant integer value, elementtype may
706be any integral or floating point type.</p>
707<h5>Examples:</h5>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000708<table class="layout">
709 <tr class="layout">
710 <td class="left">
711 <tt>&lt;4 x int&gt;</tt><br/>
712 <tt>&lt;8 x float&gt;</tt><br/>
713 <tt>&lt;2 x uint&gt;</tt><br/>
714 </td>
715 <td class="left">
716 Packed vector of 4 integer values.<br/>
717 Packed vector of 8 floating-point values.<br/>
718 Packed vector of 2 unsigned integer values.<br/>
719 </td>
720 </tr>
721</table>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000722</div>
723
Chris Lattner9ee5d222004-03-08 16:49:10 +0000724
Chris Lattner00950542001-06-06 20:29:01 +0000725<!-- *********************************************************************** -->
Chris Lattner261efe92003-11-25 01:02:51 +0000726<div class="doc_section"> <a name="instref">Instruction Reference</a> </div>
727<!-- *********************************************************************** -->
Misha Brukman9d0919f2003-11-08 01:05:38 +0000728<div class="doc_text">
Chris Lattner261efe92003-11-25 01:02:51 +0000729<p>The LLVM instruction set consists of several different
730classifications of instructions: <a href="#terminators">terminator
731instructions</a>, <a href="#binaryops">binary instructions</a>, <a
732 href="#memoryops">memory instructions</a>, and <a href="#otherops">other
733instructions</a>.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000734</div>
Chris Lattner00950542001-06-06 20:29:01 +0000735<!-- ======================================================================= -->
Chris Lattner261efe92003-11-25 01:02:51 +0000736<div class="doc_subsection"> <a name="terminators">Terminator
737Instructions</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000738<div class="doc_text">
Chris Lattner261efe92003-11-25 01:02:51 +0000739<p>As mentioned <a href="#functionstructure">previously</a>, every
740basic block in a program ends with a "Terminator" instruction, which
741indicates which block should be executed after the current block is
742finished. These terminator instructions typically yield a '<tt>void</tt>'
743value: they produce control flow, not values (the one exception being
744the '<a href="#i_invoke"><tt>invoke</tt></a>' instruction).</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000745<p>There are five different terminator instructions: the '<a
Chris Lattner261efe92003-11-25 01:02:51 +0000746 href="#i_ret"><tt>ret</tt></a>' instruction, the '<a href="#i_br"><tt>br</tt></a>'
747instruction, the '<a href="#i_switch"><tt>switch</tt></a>' instruction,
Chris Lattner35eca582004-10-16 18:04:13 +0000748the '<a href="#i_invoke"><tt>invoke</tt></a>' instruction, the '<a
749 href="#i_unwind"><tt>unwind</tt></a>' instruction, and the '<a
750 href="#i_unreachable"><tt>unreachable</tt></a>' instruction.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000751</div>
Chris Lattner00950542001-06-06 20:29:01 +0000752<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000753<div class="doc_subsubsection"> <a name="i_ret">'<tt>ret</tt>'
754Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000755<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +0000756<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000757<pre> ret &lt;type&gt; &lt;value&gt; <i>; Return a value from a non-void function</i>
Chris Lattner7faa8832002-04-14 06:13:44 +0000758 ret void <i>; Return from void function</i>
Chris Lattner00950542001-06-06 20:29:01 +0000759</pre>
Chris Lattner00950542001-06-06 20:29:01 +0000760<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000761<p>The '<tt>ret</tt>' instruction is used to return control flow (and a
762value) from a function, back to the caller.</p>
John Criswell4457dc92004-04-09 16:48:45 +0000763<p>There are two forms of the '<tt>ret</tt>' instruction: one that
Chris Lattner261efe92003-11-25 01:02:51 +0000764returns a value and then causes control flow, and one that just causes
765control flow to occur.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000766<h5>Arguments:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000767<p>The '<tt>ret</tt>' instruction may return any '<a
768 href="#t_firstclass">first class</a>' type. Notice that a function is
769not <a href="#wellformed">well formed</a> if there exists a '<tt>ret</tt>'
770instruction inside of the function that returns a value that does not
771match the return type of the function.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000772<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000773<p>When the '<tt>ret</tt>' instruction is executed, control flow
774returns back to the calling function's context. If the caller is a "<a
John Criswellfa081872004-06-25 15:16:57 +0000775 href="#i_call"><tt>call</tt></a>" instruction, execution continues at
Chris Lattner261efe92003-11-25 01:02:51 +0000776the instruction after the call. If the caller was an "<a
777 href="#i_invoke"><tt>invoke</tt></a>" instruction, execution continues
778at the beginning "normal" of the destination block. If the instruction
779returns a value, that value shall set the call or invoke instruction's
780return value.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000781<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000782<pre> ret int 5 <i>; Return an integer value of 5</i>
Chris Lattner7faa8832002-04-14 06:13:44 +0000783 ret void <i>; Return from a void function</i>
Chris Lattner00950542001-06-06 20:29:01 +0000784</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000785</div>
Chris Lattner00950542001-06-06 20:29:01 +0000786<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000787<div class="doc_subsubsection"> <a name="i_br">'<tt>br</tt>' Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000788<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +0000789<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000790<pre> br bool &lt;cond&gt;, label &lt;iftrue&gt;, label &lt;iffalse&gt;<br> br label &lt;dest&gt; <i>; Unconditional branch</i>
Chris Lattner00950542001-06-06 20:29:01 +0000791</pre>
Chris Lattner00950542001-06-06 20:29:01 +0000792<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000793<p>The '<tt>br</tt>' instruction is used to cause control flow to
794transfer to a different basic block in the current function. There are
795two forms of this instruction, corresponding to a conditional branch
796and an unconditional branch.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000797<h5>Arguments:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000798<p>The conditional branch form of the '<tt>br</tt>' instruction takes a
799single '<tt>bool</tt>' value and two '<tt>label</tt>' values. The
800unconditional form of the '<tt>br</tt>' instruction takes a single '<tt>label</tt>'
801value as a target.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000802<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000803<p>Upon execution of a conditional '<tt>br</tt>' instruction, the '<tt>bool</tt>'
804argument is evaluated. If the value is <tt>true</tt>, control flows
805to the '<tt>iftrue</tt>' <tt>label</tt> argument. If "cond" is <tt>false</tt>,
806control flows to the '<tt>iffalse</tt>' <tt>label</tt> argument.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000807<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000808<pre>Test:<br> %cond = <a href="#i_setcc">seteq</a> int %a, %b<br> br bool %cond, label %IfEqual, label %IfUnequal<br>IfEqual:<br> <a
809 href="#i_ret">ret</a> int 1<br>IfUnequal:<br> <a href="#i_ret">ret</a> int 0<br></pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000810</div>
Chris Lattner00950542001-06-06 20:29:01 +0000811<!-- _______________________________________________________________________ -->
Chris Lattnerc88c17b2004-02-24 04:54:45 +0000812<div class="doc_subsubsection">
813 <a name="i_switch">'<tt>switch</tt>' Instruction</a>
814</div>
815
Misha Brukman9d0919f2003-11-08 01:05:38 +0000816<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +0000817<h5>Syntax:</h5>
Chris Lattnerc88c17b2004-02-24 04:54:45 +0000818
819<pre>
820 switch &lt;intty&gt; &lt;value&gt;, label &lt;defaultdest&gt; [ &lt;intty&gt; &lt;val&gt;, label &lt;dest&gt; ... ]
821</pre>
822
Chris Lattner00950542001-06-06 20:29:01 +0000823<h5>Overview:</h5>
Chris Lattnerc88c17b2004-02-24 04:54:45 +0000824
825<p>The '<tt>switch</tt>' instruction is used to transfer control flow to one of
826several different places. It is a generalization of the '<tt>br</tt>'
Misha Brukman9d0919f2003-11-08 01:05:38 +0000827instruction, allowing a branch to occur to one of many possible
828destinations.</p>
Chris Lattnerc88c17b2004-02-24 04:54:45 +0000829
830
Chris Lattner00950542001-06-06 20:29:01 +0000831<h5>Arguments:</h5>
Chris Lattnerc88c17b2004-02-24 04:54:45 +0000832
833<p>The '<tt>switch</tt>' instruction uses three parameters: an integer
834comparison value '<tt>value</tt>', a default '<tt>label</tt>' destination, and
835an array of pairs of comparison value constants and '<tt>label</tt>'s. The
836table is not allowed to contain duplicate constant entries.</p>
837
Chris Lattner00950542001-06-06 20:29:01 +0000838<h5>Semantics:</h5>
Chris Lattnerc88c17b2004-02-24 04:54:45 +0000839
Chris Lattner261efe92003-11-25 01:02:51 +0000840<p>The <tt>switch</tt> instruction specifies a table of values and
841destinations. When the '<tt>switch</tt>' instruction is executed, this
John Criswell84114752004-06-25 16:05:06 +0000842table is searched for the given value. If the value is found, control flow is
843transfered to the corresponding destination; otherwise, control flow is
844transfered to the default destination.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000845
Chris Lattnerc88c17b2004-02-24 04:54:45 +0000846<h5>Implementation:</h5>
847
848<p>Depending on properties of the target machine and the particular
849<tt>switch</tt> instruction, this instruction may be code generated in different
John Criswell84114752004-06-25 16:05:06 +0000850ways. For example, it could be generated as a series of chained conditional
851branches or with a lookup table.</p>
Chris Lattnerc88c17b2004-02-24 04:54:45 +0000852
853<h5>Example:</h5>
854
855<pre>
856 <i>; Emulate a conditional br instruction</i>
857 %Val = <a href="#i_cast">cast</a> bool %value to int
858 switch int %Val, label %truedest [int 0, label %falsedest ]
859
860 <i>; Emulate an unconditional br instruction</i>
861 switch uint 0, label %dest [ ]
862
863 <i>; Implement a jump table:</i>
864 switch uint %val, label %otherwise [ uint 0, label %onzero
865 uint 1, label %onone
866 uint 2, label %ontwo ]
Chris Lattner00950542001-06-06 20:29:01 +0000867</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000868</div>
Chris Lattner00950542001-06-06 20:29:01 +0000869<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000870<div class="doc_subsubsection"> <a name="i_invoke">'<tt>invoke</tt>'
871Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000872<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +0000873<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000874<pre> &lt;result&gt; = invoke &lt;ptr to function ty&gt; %&lt;function ptr val&gt;(&lt;function args&gt;)<br> to label &lt;normal label&gt; except label &lt;exception label&gt;<br></pre>
Chris Lattner6536cfe2002-05-06 22:08:29 +0000875<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000876<p>The '<tt>invoke</tt>' instruction causes control to transfer to a
877specified function, with the possibility of control flow transfer to
878either the '<tt>normal</tt>' <tt>label</tt> label or the '<tt>exception</tt>'<tt>label</tt>.
879If the callee function returns with the "<tt><a href="#i_ret">ret</a></tt>"
880instruction, control flow will return to the "normal" label. If the
881callee (or any indirect callees) returns with the "<a href="#i_unwind"><tt>unwind</tt></a>"
882instruction, control is interrupted, and continued at the dynamically
883nearest "except" label.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000884<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000885<p>This instruction requires several arguments:</p>
Chris Lattner00950542001-06-06 20:29:01 +0000886<ol>
Chris Lattner261efe92003-11-25 01:02:51 +0000887 <li>'<tt>ptr to function ty</tt>': shall be the signature of the
888pointer to function value being invoked. In most cases, this is a
889direct function invocation, but indirect <tt>invoke</tt>s are just as
890possible, branching off an arbitrary pointer to function value. </li>
891 <li>'<tt>function ptr val</tt>': An LLVM value containing a pointer
892to a function to be invoked. </li>
893 <li>'<tt>function args</tt>': argument list whose types match the
894function signature argument types. If the function signature indicates
895the function accepts a variable number of arguments, the extra
896arguments can be specified. </li>
897 <li>'<tt>normal label</tt>': the label reached when the called
898function executes a '<tt><a href="#i_ret">ret</a></tt>' instruction. </li>
899 <li>'<tt>exception label</tt>': the label reached when a callee
900returns with the <a href="#i_unwind"><tt>unwind</tt></a> instruction. </li>
Chris Lattner00950542001-06-06 20:29:01 +0000901</ol>
Chris Lattner00950542001-06-06 20:29:01 +0000902<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000903<p>This instruction is designed to operate as a standard '<tt><a
Chris Lattner261efe92003-11-25 01:02:51 +0000904 href="#i_call">call</a></tt>' instruction in most regards. The
905primary difference is that it establishes an association with a label,
906which is used by the runtime library to unwind the stack.</p>
907<p>This instruction is used in languages with destructors to ensure
908that proper cleanup is performed in the case of either a <tt>longjmp</tt>
909or a thrown exception. Additionally, this is important for
910implementation of '<tt>catch</tt>' clauses in high-level languages that
911support them.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000912<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000913<pre> %retval = invoke int %Test(int 15)<br> to label %Continue<br> except label %TestCleanup <i>; {int}:retval set</i>
Chris Lattner00950542001-06-06 20:29:01 +0000914</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000915</div>
Chris Lattner35eca582004-10-16 18:04:13 +0000916
917
Chris Lattner27f71f22003-09-03 00:41:47 +0000918<!-- _______________________________________________________________________ -->
Chris Lattner35eca582004-10-16 18:04:13 +0000919
Chris Lattner261efe92003-11-25 01:02:51 +0000920<div class="doc_subsubsection"> <a name="i_unwind">'<tt>unwind</tt>'
921Instruction</a> </div>
Chris Lattner35eca582004-10-16 18:04:13 +0000922
Misha Brukman9d0919f2003-11-08 01:05:38 +0000923<div class="doc_text">
Chris Lattner35eca582004-10-16 18:04:13 +0000924
Chris Lattner27f71f22003-09-03 00:41:47 +0000925<h5>Syntax:</h5>
Chris Lattner35eca582004-10-16 18:04:13 +0000926<pre>
927 unwind
928</pre>
929
Chris Lattner27f71f22003-09-03 00:41:47 +0000930<h5>Overview:</h5>
Chris Lattner35eca582004-10-16 18:04:13 +0000931
932<p>The '<tt>unwind</tt>' instruction unwinds the stack, continuing control flow
933at the first callee in the dynamic call stack which used an <a
934href="#i_invoke"><tt>invoke</tt></a> instruction to perform the call. This is
935primarily used to implement exception handling.</p>
936
Chris Lattner27f71f22003-09-03 00:41:47 +0000937<h5>Semantics:</h5>
Chris Lattner35eca582004-10-16 18:04:13 +0000938
939<p>The '<tt>unwind</tt>' intrinsic causes execution of the current function to
940immediately halt. The dynamic call stack is then searched for the first <a
941href="#i_invoke"><tt>invoke</tt></a> instruction on the call stack. Once found,
942execution continues at the "exceptional" destination block specified by the
943<tt>invoke</tt> instruction. If there is no <tt>invoke</tt> instruction in the
944dynamic call chain, undefined behavior results.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000945</div>
Chris Lattner35eca582004-10-16 18:04:13 +0000946
947<!-- _______________________________________________________________________ -->
948
949<div class="doc_subsubsection"> <a name="i_unreachable">'<tt>unreachable</tt>'
950Instruction</a> </div>
951
952<div class="doc_text">
953
954<h5>Syntax:</h5>
955<pre>
956 unreachable
957</pre>
958
959<h5>Overview:</h5>
960
961<p>The '<tt>unreachable</tt>' instruction has no defined semantics. This
962instruction is used to inform the optimizer that a particular portion of the
963code is not reachable. This can be used to indicate that the code after a
964no-return function cannot be reached, and other facts.</p>
965
966<h5>Semantics:</h5>
967
968<p>The '<tt>unreachable</tt>' instruction has no defined semantics.</p>
969</div>
970
971
972
Chris Lattner00950542001-06-06 20:29:01 +0000973<!-- ======================================================================= -->
Chris Lattner261efe92003-11-25 01:02:51 +0000974<div class="doc_subsection"> <a name="binaryops">Binary Operations</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000975<div class="doc_text">
Chris Lattner261efe92003-11-25 01:02:51 +0000976<p>Binary operators are used to do most of the computation in a
977program. They require two operands, execute an operation on them, and
Chris Lattnera58561b2004-08-12 19:12:28 +0000978produce a single value. Although, that single value might represent
979multiple data, as is the case with the <a href="#t_packed">packed</a> data type.
980The result value of a binary operator is not
Chris Lattner261efe92003-11-25 01:02:51 +0000981necessarily the same type as its operands.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000982<p>There are several different binary operators:</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000983</div>
Chris Lattner00950542001-06-06 20:29:01 +0000984<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000985<div class="doc_subsubsection"> <a name="i_add">'<tt>add</tt>'
986Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000987<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +0000988<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000989<pre> &lt;result&gt; = add &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
Chris Lattner00950542001-06-06 20:29:01 +0000990</pre>
Chris Lattner00950542001-06-06 20:29:01 +0000991<h5>Overview:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000992<p>The '<tt>add</tt>' instruction returns the sum of its two operands.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000993<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000994<p>The two arguments to the '<tt>add</tt>' instruction must be either <a
Chris Lattnera58561b2004-08-12 19:12:28 +0000995 href="#t_integer">integer</a> or <a href="#t_floating">floating point</a> values.
996 This instruction can also take <a href="#t_packed">packed</a> versions of the values.
997Both arguments must have identical types.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000998<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000999<p>The value produced is the integer or floating point sum of the two
1000operands.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001001<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001002<pre> &lt;result&gt; = add int 4, %var <i>; yields {int}:result = 4 + %var</i>
Chris Lattner00950542001-06-06 20:29:01 +00001003</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001004</div>
Chris Lattner00950542001-06-06 20:29:01 +00001005<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001006<div class="doc_subsubsection"> <a name="i_sub">'<tt>sub</tt>'
1007Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001008<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001009<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001010<pre> &lt;result&gt; = sub &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
Chris Lattner00950542001-06-06 20:29:01 +00001011</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001012<h5>Overview:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001013<p>The '<tt>sub</tt>' instruction returns the difference of its two
1014operands.</p>
Chris Lattner261efe92003-11-25 01:02:51 +00001015<p>Note that the '<tt>sub</tt>' instruction is used to represent the '<tt>neg</tt>'
1016instruction present in most other intermediate representations.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001017<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001018<p>The two arguments to the '<tt>sub</tt>' instruction must be either <a
Chris Lattner261efe92003-11-25 01:02:51 +00001019 href="#t_integer">integer</a> or <a href="#t_floating">floating point</a>
Chris Lattnera58561b2004-08-12 19:12:28 +00001020values.
1021This instruction can also take <a href="#t_packed">packed</a> versions of the values.
1022Both arguments must have identical types.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001023<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001024<p>The value produced is the integer or floating point difference of
1025the two operands.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001026<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001027<pre> &lt;result&gt; = sub int 4, %var <i>; yields {int}:result = 4 - %var</i>
Chris Lattner00950542001-06-06 20:29:01 +00001028 &lt;result&gt; = sub int 0, %val <i>; yields {int}:result = -%var</i>
1029</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001030</div>
Chris Lattner00950542001-06-06 20:29:01 +00001031<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001032<div class="doc_subsubsection"> <a name="i_mul">'<tt>mul</tt>'
1033Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001034<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001035<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001036<pre> &lt;result&gt; = mul &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
Chris Lattner00950542001-06-06 20:29:01 +00001037</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001038<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001039<p>The '<tt>mul</tt>' instruction returns the product of its two
1040operands.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001041<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001042<p>The two arguments to the '<tt>mul</tt>' instruction must be either <a
Chris Lattner261efe92003-11-25 01:02:51 +00001043 href="#t_integer">integer</a> or <a href="#t_floating">floating point</a>
Chris Lattnera58561b2004-08-12 19:12:28 +00001044values.
1045This instruction can also take <a href="#t_packed">packed</a> versions of the values.
1046Both arguments must have identical types.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001047<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001048<p>The value produced is the integer or floating point product of the
Misha Brukman9d0919f2003-11-08 01:05:38 +00001049two operands.</p>
Chris Lattner261efe92003-11-25 01:02:51 +00001050<p>There is no signed vs unsigned multiplication. The appropriate
1051action is taken based on the type of the operand.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001052<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001053<pre> &lt;result&gt; = mul int 4, %var <i>; yields {int}:result = 4 * %var</i>
Chris Lattner00950542001-06-06 20:29:01 +00001054</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001055</div>
Chris Lattner00950542001-06-06 20:29:01 +00001056<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001057<div class="doc_subsubsection"> <a name="i_div">'<tt>div</tt>'
1058Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001059<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001060<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001061<pre> &lt;result&gt; = div &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
1062</pre>
1063<h5>Overview:</h5>
1064<p>The '<tt>div</tt>' instruction returns the quotient of its two
1065operands.</p>
1066<h5>Arguments:</h5>
1067<p>The two arguments to the '<tt>div</tt>' instruction must be either <a
1068 href="#t_integer">integer</a> or <a href="#t_floating">floating point</a>
Chris Lattnera58561b2004-08-12 19:12:28 +00001069values.
1070This instruction can also take <a href="#t_packed">packed</a> versions of the values.
1071Both arguments must have identical types.</p>
Chris Lattner261efe92003-11-25 01:02:51 +00001072<h5>Semantics:</h5>
1073<p>The value produced is the integer or floating point quotient of the
1074two operands.</p>
1075<h5>Example:</h5>
1076<pre> &lt;result&gt; = div int 4, %var <i>; yields {int}:result = 4 / %var</i>
1077</pre>
1078</div>
1079<!-- _______________________________________________________________________ -->
1080<div class="doc_subsubsection"> <a name="i_rem">'<tt>rem</tt>'
1081Instruction</a> </div>
1082<div class="doc_text">
1083<h5>Syntax:</h5>
1084<pre> &lt;result&gt; = rem &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
1085</pre>
1086<h5>Overview:</h5>
1087<p>The '<tt>rem</tt>' instruction returns the remainder from the
1088division of its two operands.</p>
1089<h5>Arguments:</h5>
1090<p>The two arguments to the '<tt>rem</tt>' instruction must be either <a
1091 href="#t_integer">integer</a> or <a href="#t_floating">floating point</a>
Chris Lattnera58561b2004-08-12 19:12:28 +00001092values.
1093This instruction can also take <a href="#t_packed">packed</a> versions of the values.
1094Both arguments must have identical types.</p>
Chris Lattner261efe92003-11-25 01:02:51 +00001095<h5>Semantics:</h5>
1096<p>This returns the <i>remainder</i> of a division (where the result
1097has the same sign as the divisor), not the <i>modulus</i> (where the
1098result has the same sign as the dividend) of a value. For more
1099information about the difference, see: <a
1100 href="http://mathforum.org/dr.math/problems/anne.4.28.99.html">The
1101Math Forum</a>.</p>
1102<h5>Example:</h5>
1103<pre> &lt;result&gt; = rem int 4, %var <i>; yields {int}:result = 4 % %var</i>
1104</pre>
1105</div>
1106<!-- _______________________________________________________________________ -->
1107<div class="doc_subsubsection"> <a name="i_setcc">'<tt>set<i>cc</i></tt>'
1108Instructions</a> </div>
1109<div class="doc_text">
1110<h5>Syntax:</h5>
1111<pre> &lt;result&gt; = seteq &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {bool}:result</i>
Chris Lattner00950542001-06-06 20:29:01 +00001112 &lt;result&gt; = setne &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {bool}:result</i>
1113 &lt;result&gt; = setlt &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {bool}:result</i>
1114 &lt;result&gt; = setgt &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {bool}:result</i>
1115 &lt;result&gt; = setle &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {bool}:result</i>
1116 &lt;result&gt; = setge &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {bool}:result</i>
1117</pre>
Chris Lattner261efe92003-11-25 01:02:51 +00001118<h5>Overview:</h5>
1119<p>The '<tt>set<i>cc</i></tt>' family of instructions returns a boolean
1120value based on a comparison of their two operands.</p>
1121<h5>Arguments:</h5>
1122<p>The two arguments to the '<tt>set<i>cc</i></tt>' instructions must
1123be of <a href="#t_firstclass">first class</a> type (it is not possible
1124to compare '<tt>label</tt>'s, '<tt>array</tt>'s, '<tt>structure</tt>'
1125or '<tt>void</tt>' values, etc...). Both arguments must have identical
1126types.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001127<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001128<p>The '<tt>seteq</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>'
1129value if both operands are equal.<br>
1130The '<tt>setne</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>'
1131value if both operands are unequal.<br>
1132The '<tt>setlt</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>'
1133value if the first operand is less than the second operand.<br>
1134The '<tt>setgt</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>'
1135value if the first operand is greater than the second operand.<br>
1136The '<tt>setle</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>'
1137value if the first operand is less than or equal to the second operand.<br>
1138The '<tt>setge</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>'
1139value if the first operand is greater than or equal to the second
1140operand.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001141<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001142<pre> &lt;result&gt; = seteq int 4, 5 <i>; yields {bool}:result = false</i>
Chris Lattner00950542001-06-06 20:29:01 +00001143 &lt;result&gt; = setne float 4, 5 <i>; yields {bool}:result = true</i>
1144 &lt;result&gt; = setlt uint 4, 5 <i>; yields {bool}:result = true</i>
1145 &lt;result&gt; = setgt sbyte 4, 5 <i>; yields {bool}:result = false</i>
1146 &lt;result&gt; = setle sbyte 4, 5 <i>; yields {bool}:result = true</i>
1147 &lt;result&gt; = setge sbyte 4, 5 <i>; yields {bool}:result = false</i>
1148</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001149</div>
Chris Lattner00950542001-06-06 20:29:01 +00001150<!-- ======================================================================= -->
Chris Lattner261efe92003-11-25 01:02:51 +00001151<div class="doc_subsection"> <a name="bitwiseops">Bitwise Binary
1152Operations</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001153<div class="doc_text">
Chris Lattner261efe92003-11-25 01:02:51 +00001154<p>Bitwise binary operators are used to do various forms of
1155bit-twiddling in a program. They are generally very efficient
1156instructions, and can commonly be strength reduced from other
1157instructions. They require two operands, execute an operation on them,
1158and produce a single value. The resulting value of the bitwise binary
1159operators is always the same type as its first operand.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001160</div>
Chris Lattner00950542001-06-06 20:29:01 +00001161<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001162<div class="doc_subsubsection"> <a name="i_and">'<tt>and</tt>'
1163Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001164<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001165<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001166<pre> &lt;result&gt; = and &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
Chris Lattner00950542001-06-06 20:29:01 +00001167</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001168<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001169<p>The '<tt>and</tt>' instruction returns the bitwise logical and of
1170its two operands.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001171<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001172<p>The two arguments to the '<tt>and</tt>' instruction must be <a
Chris Lattner261efe92003-11-25 01:02:51 +00001173 href="#t_integral">integral</a> values. Both arguments must have
1174identical types.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001175<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001176<p>The truth table used for the '<tt>and</tt>' instruction is:</p>
Chris Lattner261efe92003-11-25 01:02:51 +00001177<p> </p>
Misha Brukmandaa4cb02004-03-01 17:47:27 +00001178<div style="align: center">
Misha Brukman9d0919f2003-11-08 01:05:38 +00001179<table border="1" cellspacing="0" cellpadding="4">
Chris Lattner261efe92003-11-25 01:02:51 +00001180 <tbody>
1181 <tr>
1182 <td>In0</td>
1183 <td>In1</td>
1184 <td>Out</td>
1185 </tr>
1186 <tr>
1187 <td>0</td>
1188 <td>0</td>
1189 <td>0</td>
1190 </tr>
1191 <tr>
1192 <td>0</td>
1193 <td>1</td>
1194 <td>0</td>
1195 </tr>
1196 <tr>
1197 <td>1</td>
1198 <td>0</td>
1199 <td>0</td>
1200 </tr>
1201 <tr>
1202 <td>1</td>
1203 <td>1</td>
1204 <td>1</td>
1205 </tr>
1206 </tbody>
1207</table>
Misha Brukmandaa4cb02004-03-01 17:47:27 +00001208</div>
Chris Lattner00950542001-06-06 20:29:01 +00001209<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001210<pre> &lt;result&gt; = and int 4, %var <i>; yields {int}:result = 4 &amp; %var</i>
Chris Lattner00950542001-06-06 20:29:01 +00001211 &lt;result&gt; = and int 15, 40 <i>; yields {int}:result = 8</i>
1212 &lt;result&gt; = and int 4, 8 <i>; yields {int}:result = 0</i>
1213</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001214</div>
Chris Lattner00950542001-06-06 20:29:01 +00001215<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001216<div class="doc_subsubsection"> <a name="i_or">'<tt>or</tt>' Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001217<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001218<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001219<pre> &lt;result&gt; = or &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
Chris Lattner00950542001-06-06 20:29:01 +00001220</pre>
Chris Lattner261efe92003-11-25 01:02:51 +00001221<h5>Overview:</h5>
1222<p>The '<tt>or</tt>' instruction returns the bitwise logical inclusive
1223or of its two operands.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001224<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001225<p>The two arguments to the '<tt>or</tt>' instruction must be <a
Chris Lattner261efe92003-11-25 01:02:51 +00001226 href="#t_integral">integral</a> values. Both arguments must have
1227identical types.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001228<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001229<p>The truth table used for the '<tt>or</tt>' instruction is:</p>
Chris Lattner261efe92003-11-25 01:02:51 +00001230<p> </p>
Misha Brukmandaa4cb02004-03-01 17:47:27 +00001231<div style="align: center">
Chris Lattner261efe92003-11-25 01:02:51 +00001232<table border="1" cellspacing="0" cellpadding="4">
1233 <tbody>
1234 <tr>
1235 <td>In0</td>
1236 <td>In1</td>
1237 <td>Out</td>
1238 </tr>
1239 <tr>
1240 <td>0</td>
1241 <td>0</td>
1242 <td>0</td>
1243 </tr>
1244 <tr>
1245 <td>0</td>
1246 <td>1</td>
1247 <td>1</td>
1248 </tr>
1249 <tr>
1250 <td>1</td>
1251 <td>0</td>
1252 <td>1</td>
1253 </tr>
1254 <tr>
1255 <td>1</td>
1256 <td>1</td>
1257 <td>1</td>
1258 </tr>
1259 </tbody>
1260</table>
Misha Brukmandaa4cb02004-03-01 17:47:27 +00001261</div>
Chris Lattner00950542001-06-06 20:29:01 +00001262<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001263<pre> &lt;result&gt; = or int 4, %var <i>; yields {int}:result = 4 | %var</i>
Chris Lattner00950542001-06-06 20:29:01 +00001264 &lt;result&gt; = or int 15, 40 <i>; yields {int}:result = 47</i>
1265 &lt;result&gt; = or int 4, 8 <i>; yields {int}:result = 12</i>
1266</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001267</div>
Chris Lattner00950542001-06-06 20:29:01 +00001268<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001269<div class="doc_subsubsection"> <a name="i_xor">'<tt>xor</tt>'
1270Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001271<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001272<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001273<pre> &lt;result&gt; = xor &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
Chris Lattner00950542001-06-06 20:29:01 +00001274</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001275<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001276<p>The '<tt>xor</tt>' instruction returns the bitwise logical exclusive
1277or of its two operands. The <tt>xor</tt> is used to implement the
1278"one's complement" operation, which is the "~" operator in C.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001279<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001280<p>The two arguments to the '<tt>xor</tt>' instruction must be <a
Chris Lattner261efe92003-11-25 01:02:51 +00001281 href="#t_integral">integral</a> values. Both arguments must have
1282identical types.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001283<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001284<p>The truth table used for the '<tt>xor</tt>' instruction is:</p>
Chris Lattner261efe92003-11-25 01:02:51 +00001285<p> </p>
Misha Brukmandaa4cb02004-03-01 17:47:27 +00001286<div style="align: center">
Chris Lattner261efe92003-11-25 01:02:51 +00001287<table border="1" cellspacing="0" cellpadding="4">
1288 <tbody>
1289 <tr>
1290 <td>In0</td>
1291 <td>In1</td>
1292 <td>Out</td>
1293 </tr>
1294 <tr>
1295 <td>0</td>
1296 <td>0</td>
1297 <td>0</td>
1298 </tr>
1299 <tr>
1300 <td>0</td>
1301 <td>1</td>
1302 <td>1</td>
1303 </tr>
1304 <tr>
1305 <td>1</td>
1306 <td>0</td>
1307 <td>1</td>
1308 </tr>
1309 <tr>
1310 <td>1</td>
1311 <td>1</td>
1312 <td>0</td>
1313 </tr>
1314 </tbody>
1315</table>
Misha Brukmandaa4cb02004-03-01 17:47:27 +00001316</div>
Chris Lattner261efe92003-11-25 01:02:51 +00001317<p> </p>
Chris Lattner00950542001-06-06 20:29:01 +00001318<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001319<pre> &lt;result&gt; = xor int 4, %var <i>; yields {int}:result = 4 ^ %var</i>
Chris Lattner00950542001-06-06 20:29:01 +00001320 &lt;result&gt; = xor int 15, 40 <i>; yields {int}:result = 39</i>
1321 &lt;result&gt; = xor int 4, 8 <i>; yields {int}:result = 12</i>
Chris Lattner27f71f22003-09-03 00:41:47 +00001322 &lt;result&gt; = xor int %V, -1 <i>; yields {int}:result = ~%V</i>
Chris Lattner00950542001-06-06 20:29:01 +00001323</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001324</div>
Chris Lattner00950542001-06-06 20:29:01 +00001325<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001326<div class="doc_subsubsection"> <a name="i_shl">'<tt>shl</tt>'
1327Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001328<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001329<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001330<pre> &lt;result&gt; = shl &lt;ty&gt; &lt;var1&gt;, ubyte &lt;var2&gt; <i>; yields {ty}:result</i>
Chris Lattner00950542001-06-06 20:29:01 +00001331</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001332<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001333<p>The '<tt>shl</tt>' instruction returns the first operand shifted to
1334the left a specified number of bits.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001335<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001336<p>The first argument to the '<tt>shl</tt>' instruction must be an <a
Chris Lattner261efe92003-11-25 01:02:51 +00001337 href="#t_integer">integer</a> type. The second argument must be an '<tt>ubyte</tt>'
1338type.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001339<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001340<p>The value produced is <tt>var1</tt> * 2<sup><tt>var2</tt></sup>.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001341<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001342<pre> &lt;result&gt; = shl int 4, ubyte %var <i>; yields {int}:result = 4 &lt;&lt; %var</i>
Chris Lattner00950542001-06-06 20:29:01 +00001343 &lt;result&gt; = shl int 4, ubyte 2 <i>; yields {int}:result = 16</i>
1344 &lt;result&gt; = shl int 1, ubyte 10 <i>; yields {int}:result = 1024</i>
1345</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001346</div>
Chris Lattner00950542001-06-06 20:29:01 +00001347<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001348<div class="doc_subsubsection"> <a name="i_shr">'<tt>shr</tt>'
1349Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001350<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001351<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001352<pre> &lt;result&gt; = shr &lt;ty&gt; &lt;var1&gt;, ubyte &lt;var2&gt; <i>; yields {ty}:result</i>
Chris Lattner00950542001-06-06 20:29:01 +00001353</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001354<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001355<p>The '<tt>shr</tt>' instruction returns the first operand shifted to
1356the right a specified number of bits.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001357<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001358<p>The first argument to the '<tt>shr</tt>' instruction must be an <a
Chris Lattner261efe92003-11-25 01:02:51 +00001359 href="#t_integer">integer</a> type. The second argument must be an '<tt>ubyte</tt>'
1360type.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001361<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001362<p>If the first argument is a <a href="#t_signed">signed</a> type, the
1363most significant bit is duplicated in the newly free'd bit positions.
1364If the first argument is unsigned, zero bits shall fill the empty
1365positions.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001366<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001367<pre> &lt;result&gt; = shr int 4, ubyte %var <i>; yields {int}:result = 4 &gt;&gt; %var</i>
Chris Lattner8c6bb902003-06-18 21:30:51 +00001368 &lt;result&gt; = shr uint 4, ubyte 1 <i>; yields {uint}:result = 2</i>
Chris Lattner00950542001-06-06 20:29:01 +00001369 &lt;result&gt; = shr int 4, ubyte 2 <i>; yields {int}:result = 1</i>
Chris Lattner8c6bb902003-06-18 21:30:51 +00001370 &lt;result&gt; = shr sbyte 4, ubyte 3 <i>; yields {sbyte}:result = 0</i>
1371 &lt;result&gt; = shr sbyte -2, ubyte 1 <i>; yields {sbyte}:result = -1</i>
Chris Lattner00950542001-06-06 20:29:01 +00001372</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001373</div>
Chris Lattner00950542001-06-06 20:29:01 +00001374<!-- ======================================================================= -->
Chris Lattner261efe92003-11-25 01:02:51 +00001375<div class="doc_subsection"> <a name="memoryops">Memory Access
1376Operations</a></div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001377<div class="doc_text">
Chris Lattner261efe92003-11-25 01:02:51 +00001378<p>A key design point of an SSA-based representation is how it
1379represents memory. In LLVM, no memory locations are in SSA form, which
1380makes things very simple. This section describes how to read, write,
1381allocate and free memory in LLVM.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001382</div>
Chris Lattner00950542001-06-06 20:29:01 +00001383<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001384<div class="doc_subsubsection"> <a name="i_malloc">'<tt>malloc</tt>'
1385Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001386<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001387<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001388<pre> &lt;result&gt; = malloc &lt;type&gt;, uint &lt;NumElements&gt; <i>; yields {type*}:result</i>
Chris Lattner7faa8832002-04-14 06:13:44 +00001389 &lt;result&gt; = malloc &lt;type&gt; <i>; yields {type*}:result</i>
Chris Lattner00950542001-06-06 20:29:01 +00001390</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001391<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001392<p>The '<tt>malloc</tt>' instruction allocates memory from the system
1393heap and returns a pointer to it.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001394<h5>Arguments:</h5>
John Criswell6e4ca612004-02-24 16:13:56 +00001395<p>The '<tt>malloc</tt>' instruction allocates <tt>sizeof(&lt;type&gt;)*NumElements</tt>
1396bytes of memory from the operating system and returns a pointer of the
Chris Lattner261efe92003-11-25 01:02:51 +00001397appropriate type to the program. The second form of the instruction is
1398a shorter version of the first instruction that defaults to allocating
1399one element.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001400<p>'<tt>type</tt>' must be a sized type.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001401<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001402<p>Memory is allocated using the system "<tt>malloc</tt>" function, and
1403a pointer is returned.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001404<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001405<pre> %array = malloc [4 x ubyte ] <i>; yields {[%4 x ubyte]*}:array</i>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001406
Chris Lattner261efe92003-11-25 01:02:51 +00001407 %size = <a
1408 href="#i_add">add</a> uint 2, 2 <i>; yields {uint}:size = uint 4</i>
Chris Lattner7faa8832002-04-14 06:13:44 +00001409 %array1 = malloc ubyte, uint 4 <i>; yields {ubyte*}:array1</i>
1410 %array2 = malloc [12 x ubyte], uint %size <i>; yields {[12 x ubyte]*}:array2</i>
Chris Lattner00950542001-06-06 20:29:01 +00001411</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001412</div>
Chris Lattner00950542001-06-06 20:29:01 +00001413<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001414<div class="doc_subsubsection"> <a name="i_free">'<tt>free</tt>'
1415Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001416<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001417<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001418<pre> free &lt;type&gt; &lt;value&gt; <i>; yields {void}</i>
Chris Lattner00950542001-06-06 20:29:01 +00001419</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001420<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001421<p>The '<tt>free</tt>' instruction returns memory back to the unused
1422memory heap, to be reallocated in the future.</p>
1423<p> </p>
Chris Lattner00950542001-06-06 20:29:01 +00001424<h5>Arguments:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001425<p>'<tt>value</tt>' shall be a pointer value that points to a value
1426that was allocated with the '<tt><a href="#i_malloc">malloc</a></tt>'
1427instruction.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001428<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001429<p>Access to the memory pointed to by the pointer is not longer defined
1430after this instruction executes.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001431<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001432<pre> %array = <a href="#i_malloc">malloc</a> [4 x ubyte] <i>; yields {[4 x ubyte]*}:array</i>
Chris Lattner00950542001-06-06 20:29:01 +00001433 free [4 x ubyte]* %array
1434</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001435</div>
Chris Lattner00950542001-06-06 20:29:01 +00001436<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001437<div class="doc_subsubsection"> <a name="i_alloca">'<tt>alloca</tt>'
1438Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001439<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001440<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001441<pre> &lt;result&gt; = alloca &lt;type&gt;, uint &lt;NumElements&gt; <i>; yields {type*}:result</i>
Chris Lattner7faa8832002-04-14 06:13:44 +00001442 &lt;result&gt; = alloca &lt;type&gt; <i>; yields {type*}:result</i>
Chris Lattner00950542001-06-06 20:29:01 +00001443</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001444<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001445<p>The '<tt>alloca</tt>' instruction allocates memory on the current
1446stack frame of the procedure that is live until the current function
1447returns to its caller.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001448<h5>Arguments:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001449<p>The the '<tt>alloca</tt>' instruction allocates <tt>sizeof(&lt;type&gt;)*NumElements</tt>
1450bytes of memory on the runtime stack, returning a pointer of the
1451appropriate type to the program. The second form of the instruction is
1452a shorter version of the first that defaults to allocating one element.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001453<p>'<tt>type</tt>' may be any sized type.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001454<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001455<p>Memory is allocated, a pointer is returned. '<tt>alloca</tt>'d
1456memory is automatically released when the function returns. The '<tt>alloca</tt>'
1457instruction is commonly used to represent automatic variables that must
1458have an address available. When the function returns (either with the <tt><a
1459 href="#i_ret">ret</a></tt> or <tt><a href="#i_invoke">invoke</a></tt>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001460instructions), the memory is reclaimed.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001461<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001462<pre> %ptr = alloca int <i>; yields {int*}:ptr</i>
Chris Lattner7faa8832002-04-14 06:13:44 +00001463 %ptr = alloca int, uint 4 <i>; yields {int*}:ptr</i>
Chris Lattner00950542001-06-06 20:29:01 +00001464</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001465</div>
Chris Lattner00950542001-06-06 20:29:01 +00001466<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001467<div class="doc_subsubsection"> <a name="i_load">'<tt>load</tt>'
1468Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001469<div class="doc_text">
Chris Lattner2b7d3202002-05-06 03:03:22 +00001470<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001471<pre> &lt;result&gt; = load &lt;ty&gt;* &lt;pointer&gt;<br> &lt;result&gt; = volatile load &lt;ty&gt;* &lt;pointer&gt;<br></pre>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001472<h5>Overview:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001473<p>The '<tt>load</tt>' instruction is used to read from memory.</p>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001474<h5>Arguments:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001475<p>The argument to the '<tt>load</tt>' instruction specifies the memory
1476address to load from. The pointer must point to a <a
Chris Lattnere53e5082004-06-03 22:57:15 +00001477 href="#t_firstclass">first class</a> type. If the <tt>load</tt> is
Chris Lattner261efe92003-11-25 01:02:51 +00001478marked as <tt>volatile</tt> then the optimizer is not allowed to modify
1479the number or order of execution of this <tt>load</tt> with other
1480volatile <tt>load</tt> and <tt><a href="#i_store">store</a></tt>
1481instructions. </p>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001482<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001483<p>The location of memory pointed to is loaded.</p>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001484<h5>Examples:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001485<pre> %ptr = <a href="#i_alloca">alloca</a> int <i>; yields {int*}:ptr</i>
1486 <a
1487 href="#i_store">store</a> int 3, int* %ptr <i>; yields {void}</i>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001488 %val = load int* %ptr <i>; yields {int}:val = int 3</i>
1489</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001490</div>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001491<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001492<div class="doc_subsubsection"> <a name="i_store">'<tt>store</tt>'
1493Instruction</a> </div>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001494<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001495<pre> store &lt;ty&gt; &lt;value&gt;, &lt;ty&gt;* &lt;pointer&gt; <i>; yields {void}</i>
Chris Lattnerf0651072003-09-08 18:27:49 +00001496 volatile store &lt;ty&gt; &lt;value&gt;, &lt;ty&gt;* &lt;pointer&gt; <i>; yields {void}</i>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001497</pre>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001498<h5>Overview:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001499<p>The '<tt>store</tt>' instruction is used to write to memory.</p>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001500<h5>Arguments:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001501<p>There are two arguments to the '<tt>store</tt>' instruction: a value
1502to store and an address to store it into. The type of the '<tt>&lt;pointer&gt;</tt>'
1503operand must be a pointer to the type of the '<tt>&lt;value&gt;</tt>'
1504operand. If the <tt>store</tt> is marked as <tt>volatile</tt> then the
1505optimizer is not allowed to modify the number or order of execution of
1506this <tt>store</tt> with other volatile <tt>load</tt> and <tt><a
1507 href="#i_store">store</a></tt> instructions.</p>
1508<h5>Semantics:</h5>
1509<p>The contents of memory are updated to contain '<tt>&lt;value&gt;</tt>'
1510at the location specified by the '<tt>&lt;pointer&gt;</tt>' operand.</p>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001511<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001512<pre> %ptr = <a href="#i_alloca">alloca</a> int <i>; yields {int*}:ptr</i>
1513 <a
1514 href="#i_store">store</a> int 3, int* %ptr <i>; yields {void}</i>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001515 %val = load int* %ptr <i>; yields {int}:val = int 3</i>
1516</pre>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001517<!-- _______________________________________________________________________ -->
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001518<div class="doc_subsubsection">
1519 <a name="i_getelementptr">'<tt>getelementptr</tt>' Instruction</a>
1520</div>
1521
Misha Brukman9d0919f2003-11-08 01:05:38 +00001522<div class="doc_text">
Chris Lattner7faa8832002-04-14 06:13:44 +00001523<h5>Syntax:</h5>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001524<pre>
1525 &lt;result&gt; = getelementptr &lt;ty&gt;* &lt;ptrval&gt;{, &lt;ty&gt; &lt;idx&gt;}*
1526</pre>
1527
Chris Lattner7faa8832002-04-14 06:13:44 +00001528<h5>Overview:</h5>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001529
1530<p>
1531The '<tt>getelementptr</tt>' instruction is used to get the address of a
1532subelement of an aggregate data structure.</p>
1533
Chris Lattner7faa8832002-04-14 06:13:44 +00001534<h5>Arguments:</h5>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001535
1536<p>This instruction takes a list of integer constants that indicate what
1537elements of the aggregate object to index to. The actual types of the arguments
1538provided depend on the type of the first pointer argument. The
1539'<tt>getelementptr</tt>' instruction is used to index down through the type
1540levels of a structure. When indexing into a structure, only <tt>uint</tt>
1541integer constants are allowed. When indexing into an array or pointer
1542<tt>int</tt> and <tt>long</tt> indexes are allowed of any sign.</p>
1543
Chris Lattner261efe92003-11-25 01:02:51 +00001544<p>For example, let's consider a C code fragment and how it gets
1545compiled to LLVM:</p>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001546
1547<pre>
1548 struct RT {
1549 char A;
1550 int B[10][20];
1551 char C;
1552 };
1553 struct ST {
1554 int X;
1555 double Y;
1556 struct RT Z;
1557 };
1558
1559 int *foo(struct ST *s) {
1560 return &amp;s[1].Z.B[5][13];
1561 }
1562</pre>
1563
Misha Brukman9d0919f2003-11-08 01:05:38 +00001564<p>The LLVM code generated by the GCC frontend is:</p>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001565
1566<pre>
1567 %RT = type { sbyte, [10 x [20 x int]], sbyte }
1568 %ST = type { int, double, %RT }
1569
Brian Gaeke7283e7c2004-07-02 21:08:14 +00001570 implementation
1571
1572 int* %foo(%ST* %s) {
1573 entry:
1574 %reg = getelementptr %ST* %s, int 1, uint 2, uint 1, int 5, int 13
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001575 ret int* %reg
1576 }
1577</pre>
1578
Chris Lattner7faa8832002-04-14 06:13:44 +00001579<h5>Semantics:</h5>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001580
1581<p>The index types specified for the '<tt>getelementptr</tt>' instruction depend
Chris Lattnere53e5082004-06-03 22:57:15 +00001582on the pointer type that is being index into. <a href="#t_pointer">Pointer</a>
1583and <a href="#t_array">array</a> types require <tt>uint</tt>, <tt>int</tt>,
1584<tt>ulong</tt>, or <tt>long</tt> values, and <a href="#t_struct">structure</a>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001585types require <tt>uint</tt> <b>constants</b>.</p>
1586
Misha Brukman9d0919f2003-11-08 01:05:38 +00001587<p>In the example above, the first index is indexing into the '<tt>%ST*</tt>'
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001588type, which is a pointer, yielding a '<tt>%ST</tt>' = '<tt>{ int, double, %RT
1589}</tt>' type, a structure. The second index indexes into the third element of
1590the structure, yielding a '<tt>%RT</tt>' = '<tt>{ sbyte, [10 x [20 x int]],
1591sbyte }</tt>' type, another structure. The third index indexes into the second
1592element of the structure, yielding a '<tt>[10 x [20 x int]]</tt>' type, an
1593array. The two dimensions of the array are subscripted into, yielding an
1594'<tt>int</tt>' type. The '<tt>getelementptr</tt>' instruction return a pointer
1595to this element, thus computing a value of '<tt>int*</tt>' type.</p>
1596
Chris Lattner261efe92003-11-25 01:02:51 +00001597<p>Note that it is perfectly legal to index partially through a
1598structure, returning a pointer to an inner element. Because of this,
1599the LLVM code for the given testcase is equivalent to:</p>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001600
1601<pre>
1602 int* "foo"(%ST* %s) {
1603 %t1 = getelementptr %ST* %s, int 1 <i>; yields %ST*:%t1</i>
1604 %t2 = getelementptr %ST* %t1, int 0, uint 2 <i>; yields %RT*:%t2</i>
1605 %t3 = getelementptr %RT* %t2, int 0, uint 1 <i>; yields [10 x [20 x int]]*:%t3</i>
1606 %t4 = getelementptr [10 x [20 x int]]* %t3, int 0, int 5 <i>; yields [20 x int]*:%t4</i>
1607 %t5 = getelementptr [20 x int]* %t4, int 0, int 13 <i>; yields int*:%t5</i>
1608 ret int* %t5
1609 }
Chris Lattner6536cfe2002-05-06 22:08:29 +00001610</pre>
Chris Lattner7faa8832002-04-14 06:13:44 +00001611<h5>Example:</h5>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001612<pre>
1613 <i>; yields [12 x ubyte]*:aptr</i>
1614 %aptr = getelementptr {int, [12 x ubyte]}* %sptr, long 0, uint 1
1615</pre>
1616
1617</div>
Chris Lattner00950542001-06-06 20:29:01 +00001618<!-- ======================================================================= -->
Chris Lattner261efe92003-11-25 01:02:51 +00001619<div class="doc_subsection"> <a name="otherops">Other Operations</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001620<div class="doc_text">
John Criswell4457dc92004-04-09 16:48:45 +00001621<p>The instructions in this category are the "miscellaneous"
Chris Lattner261efe92003-11-25 01:02:51 +00001622instructions, which defy better classification.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001623</div>
Chris Lattner00950542001-06-06 20:29:01 +00001624<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001625<div class="doc_subsubsection"> <a name="i_phi">'<tt>phi</tt>'
1626Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001627<div class="doc_text">
Chris Lattner33ba0d92001-07-09 00:26:23 +00001628<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001629<pre> &lt;result&gt; = phi &lt;ty&gt; [ &lt;val0&gt;, &lt;label0&gt;], ...<br></pre>
Chris Lattner33ba0d92001-07-09 00:26:23 +00001630<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001631<p>The '<tt>phi</tt>' instruction is used to implement the &#966; node in
1632the SSA graph representing the function.</p>
Chris Lattner33ba0d92001-07-09 00:26:23 +00001633<h5>Arguments:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001634<p>The type of the incoming values are specified with the first type
1635field. After this, the '<tt>phi</tt>' instruction takes a list of pairs
1636as arguments, with one pair for each predecessor basic block of the
1637current block. Only values of <a href="#t_firstclass">first class</a>
1638type may be used as the value arguments to the PHI node. Only labels
1639may be used as the label arguments.</p>
1640<p>There must be no non-phi instructions between the start of a basic
1641block and the PHI instructions: i.e. PHI instructions must be first in
1642a basic block.</p>
Chris Lattner33ba0d92001-07-09 00:26:23 +00001643<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001644<p>At runtime, the '<tt>phi</tt>' instruction logically takes on the
1645value specified by the parameter, depending on which basic block we
1646came from in the last <a href="#terminators">terminator</a> instruction.</p>
Chris Lattner6536cfe2002-05-06 22:08:29 +00001647<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001648<pre>Loop: ; Infinite loop that counts from 0 on up...<br> %indvar = phi uint [ 0, %LoopHeader ], [ %nextindvar, %Loop ]<br> %nextindvar = add uint %indvar, 1<br> br label %Loop<br></pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001649</div>
Chris Lattnercc37aae2004-03-12 05:50:16 +00001650
Chris Lattner6536cfe2002-05-06 22:08:29 +00001651<!-- _______________________________________________________________________ -->
Chris Lattnercc37aae2004-03-12 05:50:16 +00001652<div class="doc_subsubsection">
1653 <a name="i_cast">'<tt>cast .. to</tt>' Instruction</a>
1654</div>
1655
Misha Brukman9d0919f2003-11-08 01:05:38 +00001656<div class="doc_text">
Chris Lattnercc37aae2004-03-12 05:50:16 +00001657
Chris Lattner6536cfe2002-05-06 22:08:29 +00001658<h5>Syntax:</h5>
Chris Lattnercc37aae2004-03-12 05:50:16 +00001659
1660<pre>
1661 &lt;result&gt; = cast &lt;ty&gt; &lt;value&gt; to &lt;ty2&gt; <i>; yields ty2</i>
Chris Lattner6536cfe2002-05-06 22:08:29 +00001662</pre>
Chris Lattnercc37aae2004-03-12 05:50:16 +00001663
Chris Lattner6536cfe2002-05-06 22:08:29 +00001664<h5>Overview:</h5>
Chris Lattnercc37aae2004-03-12 05:50:16 +00001665
1666<p>
1667The '<tt>cast</tt>' instruction is used as the primitive means to convert
1668integers to floating point, change data type sizes, and break type safety (by
1669casting pointers).
1670</p>
1671
1672
Chris Lattner6536cfe2002-05-06 22:08:29 +00001673<h5>Arguments:</h5>
Chris Lattnercc37aae2004-03-12 05:50:16 +00001674
1675<p>
1676The '<tt>cast</tt>' instruction takes a value to cast, which must be a first
1677class value, and a type to cast it to, which must also be a <a
1678href="#t_firstclass">first class</a> type.
1679</p>
1680
Chris Lattner6536cfe2002-05-06 22:08:29 +00001681<h5>Semantics:</h5>
Chris Lattnercc37aae2004-03-12 05:50:16 +00001682
1683<p>
1684This instruction follows the C rules for explicit casts when determining how the
1685data being cast must change to fit in its new container.
1686</p>
1687
1688<p>
1689When casting to bool, any value that would be considered true in the context of
1690a C '<tt>if</tt>' condition is converted to the boolean '<tt>true</tt>' values,
1691all else are '<tt>false</tt>'.
1692</p>
1693
1694<p>
1695When extending an integral value from a type of one signness to another (for
1696example '<tt>sbyte</tt>' to '<tt>ulong</tt>'), the value is sign-extended if the
1697<b>source</b> value is signed, and zero-extended if the source value is
1698unsigned. <tt>bool</tt> values are always zero extended into either zero or
1699one.
1700</p>
1701
Chris Lattner33ba0d92001-07-09 00:26:23 +00001702<h5>Example:</h5>
Chris Lattnercc37aae2004-03-12 05:50:16 +00001703
1704<pre>
1705 %X = cast int 257 to ubyte <i>; yields ubyte:1</i>
Chris Lattner7bae3952002-06-25 18:03:17 +00001706 %Y = cast int 123 to bool <i>; yields bool:true</i>
Chris Lattner33ba0d92001-07-09 00:26:23 +00001707</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001708</div>
Chris Lattnercc37aae2004-03-12 05:50:16 +00001709
1710<!-- _______________________________________________________________________ -->
1711<div class="doc_subsubsection">
1712 <a name="i_select">'<tt>select</tt>' Instruction</a>
1713</div>
1714
1715<div class="doc_text">
1716
1717<h5>Syntax:</h5>
1718
1719<pre>
1720 &lt;result&gt; = select bool &lt;cond&gt;, &lt;ty&gt; &lt;val1&gt;, &lt;ty&gt; &lt;val2&gt; <i>; yields ty</i>
1721</pre>
1722
1723<h5>Overview:</h5>
1724
1725<p>
1726The '<tt>select</tt>' instruction is used to choose one value based on a
1727condition, without branching.
1728</p>
1729
1730
1731<h5>Arguments:</h5>
1732
1733<p>
1734The '<tt>select</tt>' instruction requires a boolean value indicating the condition, and two values of the same <a href="#t_firstclass">first class</a> type.
1735</p>
1736
1737<h5>Semantics:</h5>
1738
1739<p>
1740If the boolean condition evaluates to true, the instruction returns the first
1741value argument, otherwise it returns the second value argument.
1742</p>
1743
1744<h5>Example:</h5>
1745
1746<pre>
1747 %X = select bool true, ubyte 17, ubyte 42 <i>; yields ubyte:17</i>
1748</pre>
1749</div>
1750
1751
1752
1753
1754
Chris Lattner33ba0d92001-07-09 00:26:23 +00001755<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001756<div class="doc_subsubsection"> <a name="i_call">'<tt>call</tt>'
1757Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001758<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001759<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001760<pre> &lt;result&gt; = call &lt;ty&gt;* &lt;fnptrval&gt;(&lt;param list&gt;)<br></pre>
Chris Lattner00950542001-06-06 20:29:01 +00001761<h5>Overview:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001762<p>The '<tt>call</tt>' instruction represents a simple function call.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001763<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001764<p>This instruction requires several arguments:</p>
Chris Lattner6536cfe2002-05-06 22:08:29 +00001765<ol>
Chris Lattner261efe92003-11-25 01:02:51 +00001766 <li>
1767 <p>'<tt>ty</tt>': shall be the signature of the pointer to function
1768value being invoked. The argument types must match the types implied
1769by this signature.</p>
1770 </li>
1771 <li>
1772 <p>'<tt>fnptrval</tt>': An LLVM value containing a pointer to a
1773function to be invoked. In most cases, this is a direct function
1774invocation, but indirect <tt>call</tt>s are just as possible,
1775calling an arbitrary pointer to function values.</p>
1776 </li>
1777 <li>
1778 <p>'<tt>function args</tt>': argument list whose types match the
1779function signature argument types. If the function signature
1780indicates the function accepts a variable number of arguments, the
1781extra arguments can be specified.</p>
1782 </li>
Chris Lattner6536cfe2002-05-06 22:08:29 +00001783</ol>
Chris Lattner00950542001-06-06 20:29:01 +00001784<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001785<p>The '<tt>call</tt>' instruction is used to cause control flow to
1786transfer to a specified function, with its incoming arguments bound to
1787the specified values. Upon a '<tt><a href="#i_ret">ret</a></tt>'
1788instruction in the called function, control flow continues with the
1789instruction after the function call, and the return value of the
1790function is bound to the result argument. This is a simpler case of
1791the <a href="#i_invoke">invoke</a> instruction.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001792<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001793<pre> %retval = call int %test(int %argc)<br> call int(sbyte*, ...) *%printf(sbyte* %msg, int 12, sbyte 42);<br></pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001794</div>
Chris Lattnere19d7a72004-09-27 21:51:25 +00001795
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001796<!-- _______________________________________________________________________ -->
Chris Lattnere19d7a72004-09-27 21:51:25 +00001797<div class="doc_subsubsection">
1798 <a name="i_vanext">'<tt>vanext</tt>' Instruction</a>
1799</div>
1800
Misha Brukman9d0919f2003-11-08 01:05:38 +00001801<div class="doc_text">
Chris Lattnere19d7a72004-09-27 21:51:25 +00001802
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001803<h5>Syntax:</h5>
Chris Lattnere19d7a72004-09-27 21:51:25 +00001804
1805<pre>
1806 &lt;resultarglist&gt; = vanext &lt;va_list&gt; &lt;arglist&gt;, &lt;argty&gt;
1807</pre>
1808
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001809<h5>Overview:</h5>
Chris Lattnere19d7a72004-09-27 21:51:25 +00001810
Chris Lattner261efe92003-11-25 01:02:51 +00001811<p>The '<tt>vanext</tt>' instruction is used to access arguments passed
1812through the "variable argument" area of a function call. It is used to
1813implement the <tt>va_arg</tt> macro in C.</p>
Chris Lattnere19d7a72004-09-27 21:51:25 +00001814
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001815<h5>Arguments:</h5>
Chris Lattnere19d7a72004-09-27 21:51:25 +00001816
1817<p>This instruction takes a <tt>va_list</tt> value and the type of the
1818argument. It returns another <tt>va_list</tt>. The actual type of
1819<tt>va_list</tt> may be defined differently for different targets. Most targets
1820use a <tt>va_list</tt> type of <tt>sbyte*</tt> or some other pointer type.</p>
1821
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001822<h5>Semantics:</h5>
Chris Lattnere19d7a72004-09-27 21:51:25 +00001823
1824<p>The '<tt>vanext</tt>' instruction advances the specified <tt>va_list</tt>
Chris Lattner261efe92003-11-25 01:02:51 +00001825past an argument of the specified type. In conjunction with the <a
1826 href="#i_vaarg"><tt>vaarg</tt></a> instruction, it is used to implement
1827the <tt>va_arg</tt> macro available in C. For more information, see
1828the variable argument handling <a href="#int_varargs">Intrinsic
1829Functions</a>.</p>
Chris Lattnere19d7a72004-09-27 21:51:25 +00001830
Chris Lattner261efe92003-11-25 01:02:51 +00001831<p>It is legal for this instruction to be called in a function which
1832does not take a variable number of arguments, for example, the <tt>vfprintf</tt>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001833function.</p>
Chris Lattnere19d7a72004-09-27 21:51:25 +00001834
Misha Brukman9d0919f2003-11-08 01:05:38 +00001835<p><tt>vanext</tt> is an LLVM instruction instead of an <a
Chris Lattnere19d7a72004-09-27 21:51:25 +00001836href="#intrinsics">intrinsic function</a> because it takes a type as an
1837argument. The type refers to the current argument in the <tt>va_list</tt>, it
1838tells the compiler how far on the stack it needs to advance to find the next
1839argument</p>
1840
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001841<h5>Example:</h5>
Chris Lattnere19d7a72004-09-27 21:51:25 +00001842
Chris Lattner261efe92003-11-25 01:02:51 +00001843<p>See the <a href="#int_varargs">variable argument processing</a>
1844section.</p>
Chris Lattnere19d7a72004-09-27 21:51:25 +00001845
Misha Brukman9d0919f2003-11-08 01:05:38 +00001846</div>
Chris Lattnere19d7a72004-09-27 21:51:25 +00001847
Chris Lattner8d1a81d2003-10-18 05:51:36 +00001848<!-- _______________________________________________________________________ -->
Chris Lattnere19d7a72004-09-27 21:51:25 +00001849<div class="doc_subsubsection">
1850 <a name="i_vaarg">'<tt>vaarg</tt>' Instruction</a>
1851</div>
1852
Misha Brukman9d0919f2003-11-08 01:05:38 +00001853<div class="doc_text">
Chris Lattnere19d7a72004-09-27 21:51:25 +00001854
Chris Lattner8d1a81d2003-10-18 05:51:36 +00001855<h5>Syntax:</h5>
Chris Lattnere19d7a72004-09-27 21:51:25 +00001856
1857<pre>
1858 &lt;resultval&gt; = vaarg &lt;va_list&gt; &lt;arglist&gt;, &lt;argty&gt;
1859</pre>
1860
Chris Lattner8d1a81d2003-10-18 05:51:36 +00001861<h5>Overview:</h5>
Chris Lattnere19d7a72004-09-27 21:51:25 +00001862
1863<p>The '<tt>vaarg</tt>' instruction is used to access arguments passed through
1864the "variable argument" area of a function call. It is used to implement the
1865<tt>va_arg</tt> macro in C.</p>
1866
Chris Lattner8d1a81d2003-10-18 05:51:36 +00001867<h5>Arguments:</h5>
Chris Lattnere19d7a72004-09-27 21:51:25 +00001868
1869<p>This instruction takes a <tt>va_list</tt> value and the type of the
1870argument. It returns a value of the specified argument type. Again, the actual
1871type of <tt>va_list</tt> is target specific.</p>
1872
Chris Lattner8d1a81d2003-10-18 05:51:36 +00001873<h5>Semantics:</h5>
Chris Lattnere19d7a72004-09-27 21:51:25 +00001874
1875<p>The '<tt>vaarg</tt>' instruction loads an argument of the specified type from
1876the specified <tt>va_list</tt>. In conjunction with the <a
1877href="#i_vanext"><tt>vanext</tt></a> instruction, it is used to implement the
1878<tt>va_arg</tt> macro available in C. For more information, see the variable
1879argument handling <a href="#int_varargs">Intrinsic Functions</a>.</p>
1880
1881<p>It is legal for this instruction to be called in a function which does not
1882take a variable number of arguments, for example, the <tt>vfprintf</tt>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001883function.</p>
Chris Lattnere19d7a72004-09-27 21:51:25 +00001884
Misha Brukman9d0919f2003-11-08 01:05:38 +00001885<p><tt>vaarg</tt> is an LLVM instruction instead of an <a
Chris Lattnere19d7a72004-09-27 21:51:25 +00001886href="#intrinsics">intrinsic function</a> because it takes an type as an
1887argument.</p>
1888
Chris Lattner8d1a81d2003-10-18 05:51:36 +00001889<h5>Example:</h5>
Chris Lattnere19d7a72004-09-27 21:51:25 +00001890
1891<p>See the <a href="#int_varargs">variable argument processing</a> section.</p>
1892
Misha Brukman9d0919f2003-11-08 01:05:38 +00001893</div>
Chris Lattner8ff75902004-01-06 05:31:32 +00001894
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001895<!-- *********************************************************************** -->
Chris Lattner261efe92003-11-25 01:02:51 +00001896<div class="doc_section"> <a name="intrinsics">Intrinsic Functions</a> </div>
1897<!-- *********************************************************************** -->
Chris Lattner8ff75902004-01-06 05:31:32 +00001898
Misha Brukman9d0919f2003-11-08 01:05:38 +00001899<div class="doc_text">
Chris Lattner33aec9e2004-02-12 17:01:32 +00001900
1901<p>LLVM supports the notion of an "intrinsic function". These functions have
1902well known names and semantics, and are required to follow certain
1903restrictions. Overall, these instructions represent an extension mechanism for
1904the LLVM language that does not require changing all of the transformations in
1905LLVM to add to the language (or the bytecode reader/writer, the parser,
1906etc...).</p>
1907
1908<p>Intrinsic function names must all start with an "<tt>llvm.</tt>" prefix, this
1909prefix is reserved in LLVM for intrinsic names, thus functions may not be named
1910this. Intrinsic functions must always be external functions: you cannot define
1911the body of intrinsic functions. Intrinsic functions may only be used in call
1912or invoke instructions: it is illegal to take the address of an intrinsic
1913function. Additionally, because intrinsic functions are part of the LLVM
1914language, it is required that they all be documented here if any are added.</p>
1915
1916
1917<p>
1918Adding an intrinsic to LLVM is straight-forward if it is possible to express the
1919concept in LLVM directly (ie, code generator support is not _required_). To do
1920this, extend the default implementation of the IntrinsicLowering class to handle
1921the intrinsic. Code generators use this class to lower intrinsics they do not
1922understand to raw LLVM instructions that they do.
1923</p>
1924
Misha Brukman9d0919f2003-11-08 01:05:38 +00001925</div>
Chris Lattner8ff75902004-01-06 05:31:32 +00001926
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001927<!-- ======================================================================= -->
Chris Lattner8ff75902004-01-06 05:31:32 +00001928<div class="doc_subsection">
1929 <a name="int_varargs">Variable Argument Handling Intrinsics</a>
1930</div>
1931
Misha Brukman9d0919f2003-11-08 01:05:38 +00001932<div class="doc_text">
Chris Lattnerd7923912004-05-23 21:06:01 +00001933
Misha Brukman9d0919f2003-11-08 01:05:38 +00001934<p>Variable argument support is defined in LLVM with the <a
Chris Lattner261efe92003-11-25 01:02:51 +00001935 href="#i_vanext"><tt>vanext</tt></a> instruction and these three
1936intrinsic functions. These functions are related to the similarly
1937named macros defined in the <tt>&lt;stdarg.h&gt;</tt> header file.</p>
Chris Lattnerd7923912004-05-23 21:06:01 +00001938
Chris Lattner261efe92003-11-25 01:02:51 +00001939<p>All of these functions operate on arguments that use a
1940target-specific value type "<tt>va_list</tt>". The LLVM assembly
1941language reference manual does not define what this type is, so all
1942transformations should be prepared to handle intrinsics with any type
1943used.</p>
Chris Lattnerd7923912004-05-23 21:06:01 +00001944
Misha Brukman9d0919f2003-11-08 01:05:38 +00001945<p>This example shows how the <a href="#i_vanext"><tt>vanext</tt></a>
Chris Lattner261efe92003-11-25 01:02:51 +00001946instruction and the variable argument handling intrinsic functions are
1947used.</p>
Chris Lattnerd7923912004-05-23 21:06:01 +00001948
Chris Lattner33aec9e2004-02-12 17:01:32 +00001949<pre>
1950int %test(int %X, ...) {
1951 ; Initialize variable argument processing
1952 %ap = call sbyte* %<a href="#i_va_start">llvm.va_start</a>()
1953
1954 ; Read a single integer argument
1955 %tmp = vaarg sbyte* %ap, int
1956
1957 ; Advance to the next argument
1958 %ap2 = vanext sbyte* %ap, int
1959
1960 ; Demonstrate usage of llvm.va_copy and llvm.va_end
1961 %aq = call sbyte* %<a href="#i_va_copy">llvm.va_copy</a>(sbyte* %ap2)
1962 call void %<a href="#i_va_end">llvm.va_end</a>(sbyte* %aq)
1963
1964 ; Stop processing of arguments.
1965 call void %<a href="#i_va_end">llvm.va_end</a>(sbyte* %ap2)
1966 ret int %tmp
1967}
1968</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001969</div>
Chris Lattner8ff75902004-01-06 05:31:32 +00001970
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001971<!-- _______________________________________________________________________ -->
Chris Lattner8ff75902004-01-06 05:31:32 +00001972<div class="doc_subsubsection">
1973 <a name="i_va_start">'<tt>llvm.va_start</tt>' Intrinsic</a>
1974</div>
1975
1976
Misha Brukman9d0919f2003-11-08 01:05:38 +00001977<div class="doc_text">
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001978<h5>Syntax:</h5>
Chris Lattnere19d7a72004-09-27 21:51:25 +00001979<pre> call &lt;va_list&gt; ()* %llvm.va_start()<br></pre>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001980<h5>Overview:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001981<p>The '<tt>llvm.va_start</tt>' intrinsic returns a new <tt>&lt;arglist&gt;</tt>
1982for subsequent use by the variable argument intrinsics.</p>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001983<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001984<p>The '<tt>llvm.va_start</tt>' intrinsic works just like the <tt>va_start</tt>
Chris Lattner261efe92003-11-25 01:02:51 +00001985macro available in C. In a target-dependent way, it initializes and
1986returns a <tt>va_list</tt> element, so that the next <tt>vaarg</tt>
1987will produce the first variable argument passed to the function. Unlike
1988the C <tt>va_start</tt> macro, this intrinsic does not need to know the
1989last argument of the function, the compiler can figure that out.</p>
1990<p>Note that this intrinsic function is only legal to be called from
1991within the body of a variable argument function.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001992</div>
Chris Lattner8ff75902004-01-06 05:31:32 +00001993
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001994<!-- _______________________________________________________________________ -->
Chris Lattner8ff75902004-01-06 05:31:32 +00001995<div class="doc_subsubsection">
1996 <a name="i_va_end">'<tt>llvm.va_end</tt>' Intrinsic</a>
1997</div>
1998
Misha Brukman9d0919f2003-11-08 01:05:38 +00001999<div class="doc_text">
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002000<h5>Syntax:</h5>
Chris Lattnere19d7a72004-09-27 21:51:25 +00002001<pre> call void (&lt;va_list&gt;)* %llvm.va_end(&lt;va_list&gt; &lt;arglist&gt;)<br></pre>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002002<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00002003<p>The '<tt>llvm.va_end</tt>' intrinsic destroys <tt>&lt;arglist&gt;</tt>
2004which has been initialized previously with <tt><a href="#i_va_start">llvm.va_start</a></tt>
2005or <tt><a href="#i_va_copy">llvm.va_copy</a></tt>.</p>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002006<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002007<p>The argument is a <tt>va_list</tt> to destroy.</p>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002008<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002009<p>The '<tt>llvm.va_end</tt>' intrinsic works just like the <tt>va_end</tt>
Chris Lattner261efe92003-11-25 01:02:51 +00002010macro available in C. In a target-dependent way, it destroys the <tt>va_list</tt>.
2011Calls to <a href="#i_va_start"><tt>llvm.va_start</tt></a> and <a
2012 href="#i_va_copy"><tt>llvm.va_copy</tt></a> must be matched exactly
2013with calls to <tt>llvm.va_end</tt>.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002014</div>
Chris Lattner8ff75902004-01-06 05:31:32 +00002015
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002016<!-- _______________________________________________________________________ -->
Chris Lattner8ff75902004-01-06 05:31:32 +00002017<div class="doc_subsubsection">
2018 <a name="i_va_copy">'<tt>llvm.va_copy</tt>' Intrinsic</a>
2019</div>
2020
Misha Brukman9d0919f2003-11-08 01:05:38 +00002021<div class="doc_text">
Chris Lattnerd7923912004-05-23 21:06:01 +00002022
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002023<h5>Syntax:</h5>
Chris Lattnerd7923912004-05-23 21:06:01 +00002024
2025<pre>
Chris Lattnere19d7a72004-09-27 21:51:25 +00002026 call &lt;va_list&gt; (&lt;va_list&gt;)* %llvm.va_copy(&lt;va_list&gt; &lt;destarglist&gt;)
Chris Lattnerd7923912004-05-23 21:06:01 +00002027</pre>
2028
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002029<h5>Overview:</h5>
Chris Lattnerd7923912004-05-23 21:06:01 +00002030
2031<p>The '<tt>llvm.va_copy</tt>' intrinsic copies the current argument position
2032from the source argument list to the destination argument list.</p>
2033
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002034<h5>Arguments:</h5>
Chris Lattnerd7923912004-05-23 21:06:01 +00002035
Misha Brukman9d0919f2003-11-08 01:05:38 +00002036<p>The argument is the <tt>va_list</tt> to copy.</p>
Chris Lattnerd7923912004-05-23 21:06:01 +00002037
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002038<h5>Semantics:</h5>
Chris Lattnerd7923912004-05-23 21:06:01 +00002039
Misha Brukman9d0919f2003-11-08 01:05:38 +00002040<p>The '<tt>llvm.va_copy</tt>' intrinsic works just like the <tt>va_copy</tt>
Chris Lattnerd7923912004-05-23 21:06:01 +00002041macro available in C. In a target-dependent way, it copies the source
2042<tt>va_list</tt> element into the returned list. This intrinsic is necessary
Chris Lattnerfcd37252004-06-21 22:52:48 +00002043because the <tt><a href="#i_va_start">llvm.va_start</a></tt> intrinsic may be
Chris Lattnerd7923912004-05-23 21:06:01 +00002044arbitrarily complex and require memory allocation, for example.</p>
2045
Misha Brukman9d0919f2003-11-08 01:05:38 +00002046</div>
Chris Lattner8ff75902004-01-06 05:31:32 +00002047
Chris Lattner33aec9e2004-02-12 17:01:32 +00002048<!-- ======================================================================= -->
2049<div class="doc_subsection">
Chris Lattnerd7923912004-05-23 21:06:01 +00002050 <a name="int_gc">Accurate Garbage Collection Intrinsics</a>
2051</div>
2052
2053<div class="doc_text">
2054
2055<p>
2056LLVM support for <a href="GarbageCollection.html">Accurate Garbage
2057Collection</a> requires the implementation and generation of these intrinsics.
2058These intrinsics allow identification of <a href="#i_gcroot">GC roots on the
2059stack</a>, as well as garbage collector implementations that require <a
2060href="#i_gcread">read</a> and <a href="#i_gcwrite">write</a> barriers.
2061Front-ends for type-safe garbage collected languages should generate these
2062intrinsics to make use of the LLVM garbage collectors. For more details, see <a
2063href="GarbageCollection.html">Accurate Garbage Collection with LLVM</a>.
2064</p>
2065</div>
2066
2067<!-- _______________________________________________________________________ -->
2068<div class="doc_subsubsection">
2069 <a name="i_gcroot">'<tt>llvm.gcroot</tt>' Intrinsic</a>
2070</div>
2071
2072<div class="doc_text">
2073
2074<h5>Syntax:</h5>
2075
2076<pre>
2077 call void (&lt;ty&gt;**, &lt;ty2&gt;*)* %llvm.gcroot(&lt;ty&gt;** %ptrloc, &lt;ty2&gt;* %metadata)
2078</pre>
2079
2080<h5>Overview:</h5>
2081
2082<p>The '<tt>llvm.gcroot</tt>' intrinsic declares the existance of a GC root to
2083the code generator, and allows some metadata to be associated with it.</p>
2084
2085<h5>Arguments:</h5>
2086
2087<p>The first argument specifies the address of a stack object that contains the
2088root pointer. The second pointer (which must be either a constant or a global
2089value address) contains the meta-data to be associated with the root.</p>
2090
2091<h5>Semantics:</h5>
2092
2093<p>At runtime, a call to this intrinsics stores a null pointer into the "ptrloc"
2094location. At compile-time, the code generator generates information to allow
2095the runtime to find the pointer at GC safe points.
2096</p>
2097
2098</div>
2099
2100
2101<!-- _______________________________________________________________________ -->
2102<div class="doc_subsubsection">
2103 <a name="i_gcread">'<tt>llvm.gcread</tt>' Intrinsic</a>
2104</div>
2105
2106<div class="doc_text">
2107
2108<h5>Syntax:</h5>
2109
2110<pre>
2111 call sbyte* (sbyte**)* %llvm.gcread(sbyte** %Ptr)
2112</pre>
2113
2114<h5>Overview:</h5>
2115
2116<p>The '<tt>llvm.gcread</tt>' intrinsic identifies reads of references from heap
2117locations, allowing garbage collector implementations that require read
2118barriers.</p>
2119
2120<h5>Arguments:</h5>
2121
2122<p>The argument is the address to read from, which should be an address
2123allocated from the garbage collector.</p>
2124
2125<h5>Semantics:</h5>
2126
2127<p>The '<tt>llvm.gcread</tt>' intrinsic has the same semantics as a load
2128instruction, but may be replaced with substantially more complex code by the
2129garbage collector runtime, as needed.</p>
2130
2131</div>
2132
2133
2134<!-- _______________________________________________________________________ -->
2135<div class="doc_subsubsection">
2136 <a name="i_gcwrite">'<tt>llvm.gcwrite</tt>' Intrinsic</a>
2137</div>
2138
2139<div class="doc_text">
2140
2141<h5>Syntax:</h5>
2142
2143<pre>
2144 call void (sbyte*, sbyte**)* %llvm.gcwrite(sbyte* %P1, sbyte** %P2)
2145</pre>
2146
2147<h5>Overview:</h5>
2148
2149<p>The '<tt>llvm.gcwrite</tt>' intrinsic identifies writes of references to heap
2150locations, allowing garbage collector implementations that require write
2151barriers (such as generational or reference counting collectors).</p>
2152
2153<h5>Arguments:</h5>
2154
2155<p>The first argument is the reference to store, and the second is the heap
2156location to store to.</p>
2157
2158<h5>Semantics:</h5>
2159
2160<p>The '<tt>llvm.gcwrite</tt>' intrinsic has the same semantics as a store
2161instruction, but may be replaced with substantially more complex code by the
2162garbage collector runtime, as needed.</p>
2163
2164</div>
2165
2166
2167
2168<!-- ======================================================================= -->
2169<div class="doc_subsection">
Chris Lattner10610642004-02-14 04:08:35 +00002170 <a name="int_codegen">Code Generator Intrinsics</a>
2171</div>
2172
2173<div class="doc_text">
2174<p>
2175These intrinsics are provided by LLVM to expose special features that may only
2176be implemented with code generator support.
2177</p>
2178
2179</div>
2180
2181<!-- _______________________________________________________________________ -->
2182<div class="doc_subsubsection">
2183 <a name="i_returnaddress">'<tt>llvm.returnaddress</tt>' Intrinsic</a>
2184</div>
2185
2186<div class="doc_text">
2187
2188<h5>Syntax:</h5>
2189<pre>
2190 call void* ()* %llvm.returnaddress(uint &lt;level&gt;)
2191</pre>
2192
2193<h5>Overview:</h5>
2194
2195<p>
2196The '<tt>llvm.returnaddress</tt>' intrinsic returns a target-specific value
2197indicating the return address of the current function or one of its callers.
2198</p>
2199
2200<h5>Arguments:</h5>
2201
2202<p>
2203The argument to this intrinsic indicates which function to return the address
2204for. Zero indicates the calling function, one indicates its caller, etc. The
2205argument is <b>required</b> to be a constant integer value.
2206</p>
2207
2208<h5>Semantics:</h5>
2209
2210<p>
2211The '<tt>llvm.returnaddress</tt>' intrinsic either returns a pointer indicating
2212the return address of the specified call frame, or zero if it cannot be
2213identified. The value returned by this intrinsic is likely to be incorrect or 0
2214for arguments other than zero, so it should only be used for debugging purposes.
2215</p>
2216
2217<p>
2218Note that calling this intrinsic does not prevent function inlining or other
2219aggressive transformations, so the value returned may not that of the obvious
2220source-language caller.
2221</p>
2222</div>
2223
2224
2225<!-- _______________________________________________________________________ -->
2226<div class="doc_subsubsection">
2227 <a name="i_frameaddress">'<tt>llvm.frameaddress</tt>' Intrinsic</a>
2228</div>
2229
2230<div class="doc_text">
2231
2232<h5>Syntax:</h5>
2233<pre>
2234 call void* ()* %llvm.frameaddress(uint &lt;level&gt;)
2235</pre>
2236
2237<h5>Overview:</h5>
2238
2239<p>
2240The '<tt>llvm.frameaddress</tt>' intrinsic returns the target-specific frame
2241pointer value for the specified stack frame.
2242</p>
2243
2244<h5>Arguments:</h5>
2245
2246<p>
2247The argument to this intrinsic indicates which function to return the frame
2248pointer for. Zero indicates the calling function, one indicates its caller,
2249etc. The argument is <b>required</b> to be a constant integer value.
2250</p>
2251
2252<h5>Semantics:</h5>
2253
2254<p>
2255The '<tt>llvm.frameaddress</tt>' intrinsic either returns a pointer indicating
2256the frame address of the specified call frame, or zero if it cannot be
2257identified. The value returned by this intrinsic is likely to be incorrect or 0
2258for arguments other than zero, so it should only be used for debugging purposes.
2259</p>
2260
2261<p>
2262Note that calling this intrinsic does not prevent function inlining or other
2263aggressive transformations, so the value returned may not that of the obvious
2264source-language caller.
2265</p>
2266</div>
2267
John Criswell7123e272004-04-09 16:43:20 +00002268<!-- ======================================================================= -->
2269<div class="doc_subsection">
2270 <a name="int_os">Operating System Intrinsics</a>
2271</div>
2272
2273<div class="doc_text">
2274<p>
2275These intrinsics are provided by LLVM to support the implementation of
2276operating system level code.
2277</p>
2278
2279</div>
John Criswell183402a2004-04-12 15:02:16 +00002280
John Criswellcfd3bac2004-04-09 15:23:37 +00002281<!-- _______________________________________________________________________ -->
2282<div class="doc_subsubsection">
2283 <a name="i_readport">'<tt>llvm.readport</tt>' Intrinsic</a>
2284</div>
2285
2286<div class="doc_text">
2287
2288<h5>Syntax:</h5>
2289<pre>
John Criswell7123e272004-04-09 16:43:20 +00002290 call &lt;integer type&gt; (&lt;integer type&gt;)* %llvm.readport (&lt;integer type&gt; &lt;address&gt;)
John Criswellcfd3bac2004-04-09 15:23:37 +00002291</pre>
2292
2293<h5>Overview:</h5>
2294
2295<p>
John Criswell7123e272004-04-09 16:43:20 +00002296The '<tt>llvm.readport</tt>' intrinsic reads data from the specified hardware
2297I/O port.
John Criswellcfd3bac2004-04-09 15:23:37 +00002298</p>
2299
2300<h5>Arguments:</h5>
2301
2302<p>
John Criswell7123e272004-04-09 16:43:20 +00002303The argument to this intrinsic indicates the hardware I/O address from which
2304to read the data. The address is in the hardware I/O address namespace (as
2305opposed to being a memory location for memory mapped I/O).
John Criswellcfd3bac2004-04-09 15:23:37 +00002306</p>
2307
2308<h5>Semantics:</h5>
2309
2310<p>
John Criswell7123e272004-04-09 16:43:20 +00002311The '<tt>llvm.readport</tt>' intrinsic reads data from the hardware I/O port
2312specified by <i>address</i> and returns the value. The address and return
2313value must be integers, but the size is dependent upon the platform upon which
2314the program is code generated. For example, on x86, the address must be an
2315unsigned 16 bit value, and the return value must be 8, 16, or 32 bits.
John Criswellcfd3bac2004-04-09 15:23:37 +00002316</p>
2317
2318</div>
2319
2320<!-- _______________________________________________________________________ -->
2321<div class="doc_subsubsection">
2322 <a name="i_writeport">'<tt>llvm.writeport</tt>' Intrinsic</a>
2323</div>
2324
2325<div class="doc_text">
2326
2327<h5>Syntax:</h5>
2328<pre>
John Criswell7123e272004-04-09 16:43:20 +00002329 call void (&lt;integer type&gt;, &lt;integer type&gt;)* %llvm.writeport (&lt;integer type&gt; &lt;value&gt;, &lt;integer type&gt; &lt;address&gt;)
John Criswellcfd3bac2004-04-09 15:23:37 +00002330</pre>
2331
2332<h5>Overview:</h5>
2333
2334<p>
John Criswell7123e272004-04-09 16:43:20 +00002335The '<tt>llvm.writeport</tt>' intrinsic writes data to the specified hardware
2336I/O port.
John Criswellcfd3bac2004-04-09 15:23:37 +00002337</p>
2338
2339<h5>Arguments:</h5>
2340
2341<p>
John Criswell96db6fc2004-04-12 16:33:19 +00002342The first argument is the value to write to the I/O port.
John Criswellcfd3bac2004-04-09 15:23:37 +00002343</p>
2344
2345<p>
John Criswell96db6fc2004-04-12 16:33:19 +00002346The second argument indicates the hardware I/O address to which data should be
2347written. The address is in the hardware I/O address namespace (as opposed to
2348being a memory location for memory mapped I/O).
John Criswellcfd3bac2004-04-09 15:23:37 +00002349</p>
2350
2351<h5>Semantics:</h5>
2352
2353<p>
2354The '<tt>llvm.writeport</tt>' intrinsic writes <i>value</i> to the I/O port
2355specified by <i>address</i>. The address and value must be integers, but the
2356size is dependent upon the platform upon which the program is code generated.
John Criswell7123e272004-04-09 16:43:20 +00002357For example, on x86, the address must be an unsigned 16 bit value, and the
2358value written must be 8, 16, or 32 bits in length.
John Criswellcfd3bac2004-04-09 15:23:37 +00002359</p>
2360
2361</div>
Chris Lattner10610642004-02-14 04:08:35 +00002362
John Criswell183402a2004-04-12 15:02:16 +00002363<!-- _______________________________________________________________________ -->
2364<div class="doc_subsubsection">
2365 <a name="i_readio">'<tt>llvm.readio</tt>' Intrinsic</a>
2366</div>
2367
2368<div class="doc_text">
2369
2370<h5>Syntax:</h5>
2371<pre>
John Criswell96db6fc2004-04-12 16:33:19 +00002372 call &lt;result&gt; (&lt;ty&gt;*)* %llvm.readio (&lt;ty&gt; * &lt;pointer&gt;)
John Criswell183402a2004-04-12 15:02:16 +00002373</pre>
2374
2375<h5>Overview:</h5>
2376
2377<p>
2378The '<tt>llvm.readio</tt>' intrinsic reads data from a memory mapped I/O
2379address.
2380</p>
2381
2382<h5>Arguments:</h5>
2383
2384<p>
John Criswell96db6fc2004-04-12 16:33:19 +00002385The argument to this intrinsic is a pointer indicating the memory address from
2386which to read the data. The data must be a
2387<a href="#t_firstclass">first class</a> type.
John Criswell183402a2004-04-12 15:02:16 +00002388</p>
2389
2390<h5>Semantics:</h5>
2391
2392<p>
2393The '<tt>llvm.readio</tt>' intrinsic reads data from a memory mapped I/O
John Criswell96db6fc2004-04-12 16:33:19 +00002394location specified by <i>pointer</i> and returns the value. The argument must
2395be a pointer, and the return value must be a
2396<a href="#t_firstclass">first class</a> type. However, certain architectures
2397may not support I/O on all first class types. For example, 32 bit processors
2398may only support I/O on data types that are 32 bits or less.
John Criswell183402a2004-04-12 15:02:16 +00002399</p>
2400
2401<p>
John Criswell96db6fc2004-04-12 16:33:19 +00002402This intrinsic enforces an in-order memory model for llvm.readio and
2403llvm.writeio calls on machines that use dynamic scheduling. Dynamically
2404scheduled processors may execute loads and stores out of order, re-ordering at
2405run time accesses to memory mapped I/O registers. Using these intrinsics
2406ensures that accesses to memory mapped I/O registers occur in program order.
John Criswell183402a2004-04-12 15:02:16 +00002407</p>
2408
2409</div>
2410
2411<!-- _______________________________________________________________________ -->
2412<div class="doc_subsubsection">
2413 <a name="i_writeio">'<tt>llvm.writeio</tt>' Intrinsic</a>
2414</div>
2415
2416<div class="doc_text">
2417
2418<h5>Syntax:</h5>
2419<pre>
John Criswell96db6fc2004-04-12 16:33:19 +00002420 call void (&lt;ty1&gt;, &lt;ty2&gt;*)* %llvm.writeio (&lt;ty1&gt; &lt;value&gt;, &lt;ty2&gt; * &lt;pointer&gt;)
John Criswell183402a2004-04-12 15:02:16 +00002421</pre>
2422
2423<h5>Overview:</h5>
2424
2425<p>
2426The '<tt>llvm.writeio</tt>' intrinsic writes data to the specified memory
2427mapped I/O address.
2428</p>
2429
2430<h5>Arguments:</h5>
2431
2432<p>
John Criswell96db6fc2004-04-12 16:33:19 +00002433The first argument is the value to write to the memory mapped I/O location.
2434The second argument is a pointer indicating the memory address to which the
2435data should be written.
John Criswell183402a2004-04-12 15:02:16 +00002436</p>
2437
2438<h5>Semantics:</h5>
2439
2440<p>
2441The '<tt>llvm.writeio</tt>' intrinsic writes <i>value</i> to the memory mapped
John Criswell96db6fc2004-04-12 16:33:19 +00002442I/O address specified by <i>pointer</i>. The value must be a
2443<a href="#t_firstclass">first class</a> type. However, certain architectures
2444may not support I/O on all first class types. For example, 32 bit processors
2445may only support I/O on data types that are 32 bits or less.
John Criswell183402a2004-04-12 15:02:16 +00002446</p>
2447
2448<p>
John Criswell96db6fc2004-04-12 16:33:19 +00002449This intrinsic enforces an in-order memory model for llvm.readio and
2450llvm.writeio calls on machines that use dynamic scheduling. Dynamically
2451scheduled processors may execute loads and stores out of order, re-ordering at
2452run time accesses to memory mapped I/O registers. Using these intrinsics
2453ensures that accesses to memory mapped I/O registers occur in program order.
John Criswell183402a2004-04-12 15:02:16 +00002454</p>
2455
2456</div>
2457
Chris Lattner10610642004-02-14 04:08:35 +00002458<!-- ======================================================================= -->
2459<div class="doc_subsection">
Chris Lattner33aec9e2004-02-12 17:01:32 +00002460 <a name="int_libc">Standard C Library Intrinsics</a>
2461</div>
2462
2463<div class="doc_text">
2464<p>
Chris Lattner10610642004-02-14 04:08:35 +00002465LLVM provides intrinsics for a few important standard C library functions.
2466These intrinsics allow source-language front-ends to pass information about the
2467alignment of the pointer arguments to the code generator, providing opportunity
2468for more efficient code generation.
Chris Lattner33aec9e2004-02-12 17:01:32 +00002469</p>
2470
2471</div>
2472
2473<!-- _______________________________________________________________________ -->
2474<div class="doc_subsubsection">
2475 <a name="i_memcpy">'<tt>llvm.memcpy</tt>' Intrinsic</a>
2476</div>
2477
2478<div class="doc_text">
2479
2480<h5>Syntax:</h5>
2481<pre>
2482 call void (sbyte*, sbyte*, uint, uint)* %llvm.memcpy(sbyte* &lt;dest&gt;, sbyte* &lt;src&gt;,
2483 uint &lt;len&gt;, uint &lt;align&gt;)
2484</pre>
2485
2486<h5>Overview:</h5>
2487
2488<p>
2489The '<tt>llvm.memcpy</tt>' intrinsic copies a block of memory from the source
2490location to the destination location.
2491</p>
2492
2493<p>
2494Note that, unlike the standard libc function, the <tt>llvm.memcpy</tt> intrinsic
2495does not return a value, and takes an extra alignment argument.
2496</p>
2497
2498<h5>Arguments:</h5>
2499
2500<p>
2501The first argument is a pointer to the destination, the second is a pointer to
2502the source. The third argument is an (arbitrarily sized) integer argument
2503specifying the number of bytes to copy, and the fourth argument is the alignment
2504of the source and destination locations.
2505</p>
2506
Chris Lattner3301ced2004-02-12 21:18:15 +00002507<p>
2508If the call to this intrinisic has an alignment value that is not 0 or 1, then
2509the caller guarantees that the size of the copy is a multiple of the alignment
2510and that both the source and destination pointers are aligned to that boundary.
2511</p>
2512
Chris Lattner33aec9e2004-02-12 17:01:32 +00002513<h5>Semantics:</h5>
2514
2515<p>
2516The '<tt>llvm.memcpy</tt>' intrinsic copies a block of memory from the source
2517location to the destination location, which are not allowed to overlap. It
2518copies "len" bytes of memory over. If the argument is known to be aligned to
2519some boundary, this can be specified as the fourth argument, otherwise it should
2520be set to 0 or 1.
2521</p>
2522</div>
2523
2524
Chris Lattner0eb51b42004-02-12 18:10:10 +00002525<!-- _______________________________________________________________________ -->
2526<div class="doc_subsubsection">
2527 <a name="i_memmove">'<tt>llvm.memmove</tt>' Intrinsic</a>
2528</div>
2529
2530<div class="doc_text">
2531
2532<h5>Syntax:</h5>
2533<pre>
2534 call void (sbyte*, sbyte*, uint, uint)* %llvm.memmove(sbyte* &lt;dest&gt;, sbyte* &lt;src&gt;,
2535 uint &lt;len&gt;, uint &lt;align&gt;)
2536</pre>
2537
2538<h5>Overview:</h5>
2539
2540<p>
2541The '<tt>llvm.memmove</tt>' intrinsic moves a block of memory from the source
2542location to the destination location. It is similar to the '<tt>llvm.memcpy</tt>'
2543intrinsic but allows the two memory locations to overlap.
2544</p>
2545
2546<p>
2547Note that, unlike the standard libc function, the <tt>llvm.memmove</tt> intrinsic
2548does not return a value, and takes an extra alignment argument.
2549</p>
2550
2551<h5>Arguments:</h5>
2552
2553<p>
2554The first argument is a pointer to the destination, the second is a pointer to
2555the source. The third argument is an (arbitrarily sized) integer argument
2556specifying the number of bytes to copy, and the fourth argument is the alignment
2557of the source and destination locations.
2558</p>
2559
Chris Lattner3301ced2004-02-12 21:18:15 +00002560<p>
2561If the call to this intrinisic has an alignment value that is not 0 or 1, then
2562the caller guarantees that the size of the copy is a multiple of the alignment
2563and that both the source and destination pointers are aligned to that boundary.
2564</p>
2565
Chris Lattner0eb51b42004-02-12 18:10:10 +00002566<h5>Semantics:</h5>
2567
2568<p>
2569The '<tt>llvm.memmove</tt>' intrinsic copies a block of memory from the source
2570location to the destination location, which may overlap. It
2571copies "len" bytes of memory over. If the argument is known to be aligned to
2572some boundary, this can be specified as the fourth argument, otherwise it should
2573be set to 0 or 1.
2574</p>
2575</div>
2576
Chris Lattner8ff75902004-01-06 05:31:32 +00002577
Chris Lattner10610642004-02-14 04:08:35 +00002578<!-- _______________________________________________________________________ -->
2579<div class="doc_subsubsection">
2580 <a name="i_memset">'<tt>llvm.memset</tt>' Intrinsic</a>
2581</div>
2582
2583<div class="doc_text">
2584
2585<h5>Syntax:</h5>
2586<pre>
2587 call void (sbyte*, ubyte, uint, uint)* %llvm.memset(sbyte* &lt;dest&gt;, ubyte &lt;val&gt;,
2588 uint &lt;len&gt;, uint &lt;align&gt;)
2589</pre>
2590
2591<h5>Overview:</h5>
2592
2593<p>
2594The '<tt>llvm.memset</tt>' intrinsic fills a block of memory with a particular
2595byte value.
2596</p>
2597
2598<p>
2599Note that, unlike the standard libc function, the <tt>llvm.memset</tt> intrinsic
2600does not return a value, and takes an extra alignment argument.
2601</p>
2602
2603<h5>Arguments:</h5>
2604
2605<p>
2606The first argument is a pointer to the destination to fill, the second is the
2607byte value to fill it with, the third argument is an (arbitrarily sized) integer
2608argument specifying the number of bytes to fill, and the fourth argument is the
2609known alignment of destination location.
2610</p>
2611
2612<p>
2613If the call to this intrinisic has an alignment value that is not 0 or 1, then
2614the caller guarantees that the size of the copy is a multiple of the alignment
2615and that the destination pointer is aligned to that boundary.
2616</p>
2617
2618<h5>Semantics:</h5>
2619
2620<p>
2621The '<tt>llvm.memset</tt>' intrinsic fills "len" bytes of memory starting at the
2622destination location. If the argument is known to be aligned to some boundary,
2623this can be specified as the fourth argument, otherwise it should be set to 0 or
26241.
2625</p>
2626</div>
2627
2628
Chris Lattner32006282004-06-11 02:28:03 +00002629<!-- _______________________________________________________________________ -->
2630<div class="doc_subsubsection">
Alkis Evlogimenos26bbe932004-06-13 01:16:15 +00002631 <a name="i_isunordered">'<tt>llvm.isunordered</tt>' Intrinsic</a>
2632</div>
2633
2634<div class="doc_text">
2635
2636<h5>Syntax:</h5>
2637<pre>
2638 call bool (&lt;float or double&gt;, &lt;float or double&gt;)* %llvm.isunordered(&lt;float or double&gt; Val1,
2639 &lt;float or double&gt; Val2)
2640</pre>
2641
2642<h5>Overview:</h5>
2643
2644<p>
2645The '<tt>llvm.isunordered</tt>' intrinsic returns true if either or both of the
2646specified floating point values is a NAN.
2647</p>
2648
2649<h5>Arguments:</h5>
2650
2651<p>
2652The arguments are floating point numbers of the same type.
2653</p>
2654
2655<h5>Semantics:</h5>
2656
2657<p>
2658If either or both of the arguments is a SNAN or QNAN, it returns true, otherwise
2659false.
2660</p>
2661</div>
2662
2663
Chris Lattner32006282004-06-11 02:28:03 +00002664
2665
Chris Lattner8ff75902004-01-06 05:31:32 +00002666<!-- ======================================================================= -->
2667<div class="doc_subsection">
2668 <a name="int_debugger">Debugger Intrinsics</a>
2669</div>
2670
2671<div class="doc_text">
2672<p>
2673The LLVM debugger intrinsics (which all start with <tt>llvm.dbg.</tt> prefix),
2674are described in the <a
2675href="SourceLevelDebugging.html#format_common_intrinsics">LLVM Source Level
2676Debugging</a> document.
2677</p>
2678</div>
2679
2680
Chris Lattner00950542001-06-06 20:29:01 +00002681<!-- *********************************************************************** -->
Chris Lattner00950542001-06-06 20:29:01 +00002682<hr>
Misha Brukmandaa4cb02004-03-01 17:47:27 +00002683<address>
2684 <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
2685 src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
2686 <a href="http://validator.w3.org/check/referer"><img
2687 src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /></a>
2688
2689 <a href="mailto:sabre@nondot.org">Chris Lattner</a><br>
2690 <a href="http://llvm.cs.uiuc.edu">The LLVM Compiler Infrastructure</a><br>
2691 Last modified: $Date$
2692</address>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002693</body>
2694</html>