blob: 46eaeef7ba9e28b918df043fdfeb84ecb11d5d57 [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>
6 <link rel="stylesheet" href="llvm.css" type="text/css">
7</head>
Chris Lattnerd7923912004-05-23 21:06:01 +00008
Misha Brukman9d0919f2003-11-08 01:05:38 +00009<body>
Chris Lattnerd7923912004-05-23 21:06:01 +000010
Chris Lattner261efe92003-11-25 01:02:51 +000011<div class="doc_title"> LLVM Language Reference Manual </div>
Chris Lattner00950542001-06-06 20:29:01 +000012<ol>
Misha Brukman9d0919f2003-11-08 01:05:38 +000013 <li><a href="#abstract">Abstract</a></li>
14 <li><a href="#introduction">Introduction</a></li>
15 <li><a href="#identifiers">Identifiers</a></li>
Chris Lattner00950542001-06-06 20:29:01 +000016 <li><a href="#typesystem">Type System</a>
17 <ol>
Chris Lattner261efe92003-11-25 01:02:51 +000018 <li><a href="#t_primitive">Primitive Types</a>
19 <ol>
Misha Brukman9d0919f2003-11-08 01:05:38 +000020 <li><a href="#t_classifications">Type Classifications</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000021 </ol>
22 </li>
Chris Lattner00950542001-06-06 20:29:01 +000023 <li><a href="#t_derived">Derived Types</a>
24 <ol>
Chris Lattner261efe92003-11-25 01:02:51 +000025 <li><a href="#t_array">Array Type</a></li>
Misha Brukman9d0919f2003-11-08 01:05:38 +000026 <li><a href="#t_function">Function Type</a></li>
27 <li><a href="#t_pointer">Pointer Type</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000028 <li><a href="#t_struct">Structure Type</a></li>
Chris Lattnera58561b2004-08-12 19:12:28 +000029 <li><a href="#t_packed">Packed Type</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000030 </ol>
31 </li>
32 </ol>
33 </li>
Chris Lattner00950542001-06-06 20:29:01 +000034 <li><a href="#highlevel">High Level Structure</a>
35 <ol>
Misha Brukman9d0919f2003-11-08 01:05:38 +000036 <li><a href="#modulestructure">Module Structure</a></li>
37 <li><a href="#globalvars">Global Variables</a></li>
38 <li><a href="#functionstructure">Function Structure</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000039 </ol>
40 </li>
Chris Lattner00950542001-06-06 20:29:01 +000041 <li><a href="#instref">Instruction Reference</a>
42 <ol>
43 <li><a href="#terminators">Terminator Instructions</a>
44 <ol>
Chris Lattner261efe92003-11-25 01:02:51 +000045 <li><a href="#i_ret">'<tt>ret</tt>' Instruction</a></li>
46 <li><a href="#i_br">'<tt>br</tt>' Instruction</a></li>
Misha Brukman9d0919f2003-11-08 01:05:38 +000047 <li><a href="#i_switch">'<tt>switch</tt>' Instruction</a></li>
48 <li><a href="#i_invoke">'<tt>invoke</tt>' Instruction</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000049 <li><a href="#i_unwind">'<tt>unwind</tt>' Instruction</a></li>
50 </ol>
51 </li>
Chris Lattner00950542001-06-06 20:29:01 +000052 <li><a href="#binaryops">Binary Operations</a>
53 <ol>
Chris Lattner261efe92003-11-25 01:02:51 +000054 <li><a href="#i_add">'<tt>add</tt>' Instruction</a></li>
55 <li><a href="#i_sub">'<tt>sub</tt>' Instruction</a></li>
56 <li><a href="#i_mul">'<tt>mul</tt>' Instruction</a></li>
57 <li><a href="#i_div">'<tt>div</tt>' Instruction</a></li>
58 <li><a href="#i_rem">'<tt>rem</tt>' Instruction</a></li>
Misha Brukman9d0919f2003-11-08 01:05:38 +000059 <li><a href="#i_setcc">'<tt>set<i>cc</i></tt>' Instructions</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000060 </ol>
61 </li>
Chris Lattner00950542001-06-06 20:29:01 +000062 <li><a href="#bitwiseops">Bitwise Binary Operations</a>
63 <ol>
Misha Brukman9d0919f2003-11-08 01:05:38 +000064 <li><a href="#i_and">'<tt>and</tt>' Instruction</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000065 <li><a href="#i_or">'<tt>or</tt>' Instruction</a></li>
Misha Brukman9d0919f2003-11-08 01:05:38 +000066 <li><a href="#i_xor">'<tt>xor</tt>' Instruction</a></li>
67 <li><a href="#i_shl">'<tt>shl</tt>' Instruction</a></li>
68 <li><a href="#i_shr">'<tt>shr</tt>' Instruction</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000069 </ol>
70 </li>
Chris Lattner00950542001-06-06 20:29:01 +000071 <li><a href="#memoryops">Memory Access Operations</a>
72 <ol>
Chris Lattner261efe92003-11-25 01:02:51 +000073 <li><a href="#i_malloc">'<tt>malloc</tt>' Instruction</a></li>
74 <li><a href="#i_free">'<tt>free</tt>' Instruction</a></li>
75 <li><a href="#i_alloca">'<tt>alloca</tt>' Instruction</a></li>
76 <li><a href="#i_load">'<tt>load</tt>' Instruction</a></li>
77 <li><a href="#i_store">'<tt>store</tt>' Instruction</a></li>
78 <li><a href="#i_getelementptr">'<tt>getelementptr</tt>' Instruction</a></li>
79 </ol>
80 </li>
Chris Lattner00950542001-06-06 20:29:01 +000081 <li><a href="#otherops">Other Operations</a>
82 <ol>
Chris Lattner261efe92003-11-25 01:02:51 +000083 <li><a href="#i_phi">'<tt>phi</tt>' Instruction</a></li>
Misha Brukman9d0919f2003-11-08 01:05:38 +000084 <li><a href="#i_cast">'<tt>cast .. to</tt>' Instruction</a></li>
Chris Lattnercc37aae2004-03-12 05:50:16 +000085 <li><a href="#i_select">'<tt>select</tt>' Instruction</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000086 <li><a href="#i_call">'<tt>call</tt>' Instruction</a></li>
Misha Brukman9d0919f2003-11-08 01:05:38 +000087 <li><a href="#i_vanext">'<tt>vanext</tt>' Instruction</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000088 <li><a href="#i_vaarg">'<tt>vaarg</tt>' Instruction</a></li>
Chris Lattner00950542001-06-06 20:29:01 +000089 </ol>
Chris Lattner261efe92003-11-25 01:02:51 +000090 </li>
Chris Lattner00950542001-06-06 20:29:01 +000091 </ol>
Chris Lattner261efe92003-11-25 01:02:51 +000092 </li>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +000093 <li><a href="#intrinsics">Intrinsic Functions</a>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +000094 <ol>
Chris Lattner261efe92003-11-25 01:02:51 +000095 <li><a href="#int_varargs">Variable Argument Handling Intrinsics</a>
96 <ol>
97 <li><a href="#i_va_start">'<tt>llvm.va_start</tt>' Intrinsic</a></li>
98 <li><a href="#i_va_end">'<tt>llvm.va_end</tt>' Intrinsic</a></li>
99 <li><a href="#i_va_copy">'<tt>llvm.va_copy</tt>' Intrinsic</a></li>
100 </ol>
101 </li>
Chris Lattnerd7923912004-05-23 21:06:01 +0000102 <li><a href="#int_gc">Accurate Garbage Collection Intrinsics</a>
103 <ol>
104 <li><a href="#i_gcroot">'<tt>llvm.gcroot</tt>' Intrinsic</a></li>
105 <li><a href="#i_gcread">'<tt>llvm.gcread</tt>' Intrinsic</a></li>
106 <li><a href="#i_gcwrite">'<tt>llvm.gcwrite</tt>' Intrinsic</a></li>
107 </ol>
108 </li>
Chris Lattner10610642004-02-14 04:08:35 +0000109 <li><a href="#int_codegen">Code Generator Intrinsics</a>
110 <ol>
111 <li><a href="#i_returnaddress">'<tt>llvm.returnaddress</tt>' Intrinsic</a></li>
112 <li><a href="#i_frameaddress">'<tt>llvm.frameaddress</tt>' Intrinsic</a></li>
John Criswell7123e272004-04-09 16:43:20 +0000113 </ol>
114 </li>
115 <li><a href="#int_os">Operating System Intrinsics</a>
116 <ol>
Chris Lattner32006282004-06-11 02:28:03 +0000117 <li><a href="#i_readport">'<tt>llvm.readport</tt>' Intrinsic</a></li>
118 <li><a href="#i_writeport">'<tt>llvm.writeport</tt>' Intrinsic</a></li>
John Criswell183402a2004-04-12 15:02:16 +0000119 <li><a href="#i_readio">'<tt>llvm.readio</tt>' Intrinsic</a></li>
120 <li><a href="#i_writeio">'<tt>llvm.writeio</tt>' Intrinsic</a></li>
Chris Lattner10610642004-02-14 04:08:35 +0000121 </ol>
Chris Lattner33aec9e2004-02-12 17:01:32 +0000122 <li><a href="#int_libc">Standard C Library Intrinsics</a>
123 <ol>
124 <li><a href="#i_memcpy">'<tt>llvm.memcpy</tt>' Intrinsic</a></li>
Chris Lattner0eb51b42004-02-12 18:10:10 +0000125 <li><a href="#i_memmove">'<tt>llvm.memmove</tt>' Intrinsic</a></li>
Chris Lattner10610642004-02-14 04:08:35 +0000126 <li><a href="#i_memset">'<tt>llvm.memset</tt>' Intrinsic</a></li>
Alkis Evlogimenos96853722004-06-12 19:19:14 +0000127 <li><a href="#i_isunordered">'<tt>llvm.isunordered</tt>' Intrinsic</a></li>
Chris Lattner33aec9e2004-02-12 17:01:32 +0000128 </ol>
129 </li>
Chris Lattnerd7923912004-05-23 21:06:01 +0000130 <li><a href="#int_debugger">Debugger intrinsics</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +0000131 </ol>
132 </li>
Chris Lattner00950542001-06-06 20:29:01 +0000133</ol>
Chris Lattnerd7923912004-05-23 21:06:01 +0000134
135<div class="doc_author">
136 <p>Written by <a href="mailto:sabre@nondot.org">Chris Lattner</a>
137 and <a href="mailto:vadve@cs.uiuc.edu">Vikram Adve</a></p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000138</div>
Chris Lattnerd7923912004-05-23 21:06:01 +0000139
Chris Lattner00950542001-06-06 20:29:01 +0000140<!-- *********************************************************************** -->
Chris Lattner261efe92003-11-25 01:02:51 +0000141<div class="doc_section"> <a name="abstract">Abstract </a></div>
142<!-- *********************************************************************** -->
Chris Lattnerd7923912004-05-23 21:06:01 +0000143
Misha Brukman9d0919f2003-11-08 01:05:38 +0000144<div class="doc_text">
Chris Lattner261efe92003-11-25 01:02:51 +0000145<p>This document is a reference manual for the LLVM assembly language.
146LLVM is an SSA based representation that provides type safety,
147low-level operations, flexibility, and the capability of representing
148'all' high-level languages cleanly. It is the common code
149representation used throughout all phases of the LLVM compilation
150strategy.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000151</div>
Chris Lattnerd7923912004-05-23 21:06:01 +0000152
Chris Lattner00950542001-06-06 20:29:01 +0000153<!-- *********************************************************************** -->
Chris Lattner261efe92003-11-25 01:02:51 +0000154<div class="doc_section"> <a name="introduction">Introduction</a> </div>
155<!-- *********************************************************************** -->
Chris Lattnerd7923912004-05-23 21:06:01 +0000156
Misha Brukman9d0919f2003-11-08 01:05:38 +0000157<div class="doc_text">
Chris Lattnerd7923912004-05-23 21:06:01 +0000158
Chris Lattner261efe92003-11-25 01:02:51 +0000159<p>The LLVM code representation is designed to be used in three
160different forms: as an in-memory compiler IR, as an on-disk bytecode
161representation (suitable for fast loading by a Just-In-Time compiler),
162and as a human readable assembly language representation. This allows
163LLVM to provide a powerful intermediate representation for efficient
164compiler transformations and analysis, while providing a natural means
165to debug and visualize the transformations. The three different forms
166of LLVM are all equivalent. This document describes the human readable
167representation and notation.</p>
Chris Lattnerd7923912004-05-23 21:06:01 +0000168
Chris Lattner261efe92003-11-25 01:02:51 +0000169<p>The LLVM representation aims to be a light-weight and low-level
170while being expressive, typed, and extensible at the same time. It
171aims to be a "universal IR" of sorts, by being at a low enough level
172that high-level ideas may be cleanly mapped to it (similar to how
173microprocessors are "universal IR's", allowing many source languages to
174be mapped to them). By providing type information, LLVM can be used as
175the target of optimizations: for example, through pointer analysis, it
176can be proven that a C automatic variable is never accessed outside of
177the current function... allowing it to be promoted to a simple SSA
178value instead of a memory location.</p>
Chris Lattnerd7923912004-05-23 21:06:01 +0000179
Misha Brukman9d0919f2003-11-08 01:05:38 +0000180</div>
Chris Lattnerd7923912004-05-23 21:06:01 +0000181
Chris Lattner00950542001-06-06 20:29:01 +0000182<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000183<div class="doc_subsubsection"> <a name="wellformed">Well-Formedness</a> </div>
Chris Lattnerd7923912004-05-23 21:06:01 +0000184
Misha Brukman9d0919f2003-11-08 01:05:38 +0000185<div class="doc_text">
Chris Lattnerd7923912004-05-23 21:06:01 +0000186
Chris Lattner261efe92003-11-25 01:02:51 +0000187<p>It is important to note that this document describes 'well formed'
188LLVM assembly language. There is a difference between what the parser
189accepts and what is considered 'well formed'. For example, the
190following instruction is syntactically okay, but not well formed:</p>
Chris Lattnerd7923912004-05-23 21:06:01 +0000191
192<pre>
193 %x = <a href="#i_add">add</a> int 1, %x
194</pre>
195
Chris Lattner261efe92003-11-25 01:02:51 +0000196<p>...because the definition of <tt>%x</tt> does not dominate all of
197its uses. The LLVM infrastructure provides a verification pass that may
198be used to verify that an LLVM module is well formed. This pass is
199automatically run by the parser after parsing input assembly, and by
200the optimizer before it outputs bytecode. The violations pointed out
201by the verifier pass indicate bugs in transformation passes or input to
202the parser.</p>
Chris Lattnerd7923912004-05-23 21:06:01 +0000203
Chris Lattner261efe92003-11-25 01:02:51 +0000204<!-- Describe the typesetting conventions here. --> </div>
Chris Lattnerd7923912004-05-23 21:06:01 +0000205
Chris Lattner00950542001-06-06 20:29:01 +0000206<!-- *********************************************************************** -->
Chris Lattner261efe92003-11-25 01:02:51 +0000207<div class="doc_section"> <a name="identifiers">Identifiers</a> </div>
Chris Lattner00950542001-06-06 20:29:01 +0000208<!-- *********************************************************************** -->
Chris Lattnerd7923912004-05-23 21:06:01 +0000209
Misha Brukman9d0919f2003-11-08 01:05:38 +0000210<div class="doc_text">
Chris Lattnerd7923912004-05-23 21:06:01 +0000211
Chris Lattner261efe92003-11-25 01:02:51 +0000212<p>LLVM uses three different forms of identifiers, for different
213purposes:</p>
Chris Lattnerd7923912004-05-23 21:06:01 +0000214
Chris Lattner00950542001-06-06 20:29:01 +0000215<ol>
Chris Lattner261efe92003-11-25 01:02:51 +0000216 <li>Numeric constants are represented as you would expect: 12, -3
John Criswell4457dc92004-04-09 16:48:45 +0000217123.421, etc. Floating point constants have an optional hexadecimal
Chris Lattner261efe92003-11-25 01:02:51 +0000218notation.</li>
219 <li>Named values are represented as a string of characters with a '%'
220prefix. For example, %foo, %DivisionByZero,
221%a.really.long.identifier. The actual regular expression used is '<tt>%[a-zA-Z$._][a-zA-Z$._0-9]*</tt>'.
222Identifiers which require other characters in their names can be
223surrounded with quotes. In this way, anything except a <tt>"</tt>
224character can be used in a name.</li>
225 <li>Unnamed values are represented as an unsigned numeric value with
226a '%' prefix. For example, %12, %2, %44.</li>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000227</ol>
John Criswell6794d922004-03-12 21:19:06 +0000228<p>LLVM requires that values start with a '%' sign for two reasons:
Chris Lattner261efe92003-11-25 01:02:51 +0000229Compilers don't need to worry about name clashes with reserved words,
230and the set of reserved words may be expanded in the future without
231penalty. Additionally, unnamed identifiers allow a compiler to quickly
232come up with a temporary variable without having to avoid symbol table
233conflicts.</p>
234<p>Reserved words in LLVM are very similar to reserved words in other
235languages. There are keywords for different opcodes ('<tt><a
236 href="#i_add">add</a></tt>', '<tt><a href="#i_cast">cast</a></tt>', '<tt><a
237 href="#i_ret">ret</a></tt>', etc...), for primitive type names ('<tt><a
238 href="#t_void">void</a></tt>', '<tt><a href="#t_uint">uint</a></tt>',
239etc...), and others. These reserved words cannot conflict with
240variable names, because none of them start with a '%' character.</p>
241<p>Here is an example of LLVM code to multiply the integer variable '<tt>%X</tt>'
242by 8:</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000243<p>The easy way:</p>
Chris Lattner261efe92003-11-25 01:02:51 +0000244<pre> %result = <a href="#i_mul">mul</a> uint %X, 8<br></pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000245<p>After strength reduction:</p>
Chris Lattner261efe92003-11-25 01:02:51 +0000246<pre> %result = <a href="#i_shl">shl</a> uint %X, ubyte 3<br></pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000247<p>And the hard way:</p>
Chris Lattner261efe92003-11-25 01:02:51 +0000248<pre> <a href="#i_add">add</a> uint %X, %X <i>; yields {uint}:%0</i>
249 <a
250 href="#i_add">add</a> uint %0, %0 <i>; yields {uint}:%1</i>
251 %result = <a
252 href="#i_add">add</a> uint %1, %1<br></pre>
253<p>This last way of multiplying <tt>%X</tt> by 8 illustrates several
254important lexical features of LLVM:</p>
Chris Lattner00950542001-06-06 20:29:01 +0000255<ol>
Chris Lattner261efe92003-11-25 01:02:51 +0000256 <li>Comments are delimited with a '<tt>;</tt>' and go until the end
257of line.</li>
258 <li>Unnamed temporaries are created when the result of a computation
259is not assigned to a named value.</li>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000260 <li>Unnamed temporaries are numbered sequentially</li>
261</ol>
Chris Lattner261efe92003-11-25 01:02:51 +0000262<p>...and it also show a convention that we follow in this document.
263When demonstrating instructions, we will follow an instruction with a
264comment that defines the type and name of value produced. Comments are
265shown in italic text.</p>
266<p>The one non-intuitive notation for constants is the optional
267hexidecimal form of floating point constants. For example, the form '<tt>double
Chris Lattner2b7d3202002-05-06 03:03:22 +00002680x432ff973cafa8000</tt>' is equivalent to (but harder to read than) '<tt>double
Chris Lattner261efe92003-11-25 01:02:51 +00002694.5e+15</tt>' which is also supported by the parser. The only time
270hexadecimal floating point constants are useful (and the only time that
271they are generated by the disassembler) is when an FP constant has to
272be emitted that is not representable as a decimal floating point number
273exactly. For example, NaN's, infinities, and other special cases are
274represented in their IEEE hexadecimal format so that assembly and
275disassembly do not cause any bits to change in the constants.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000276</div>
Chris Lattner00950542001-06-06 20:29:01 +0000277<!-- *********************************************************************** -->
Chris Lattner261efe92003-11-25 01:02:51 +0000278<div class="doc_section"> <a name="typesystem">Type System</a> </div>
279<!-- *********************************************************************** -->
Misha Brukman9d0919f2003-11-08 01:05:38 +0000280<div class="doc_text">
Misha Brukman9d0919f2003-11-08 01:05:38 +0000281<p>The LLVM type system is one of the most important features of the
Chris Lattner261efe92003-11-25 01:02:51 +0000282intermediate representation. Being typed enables a number of
283optimizations to be performed on the IR directly, without having to do
284extra analyses on the side before the transformation. A strong type
285system makes it easier to read the generated code and enables novel
286analyses and transformations that are not feasible to perform on normal
287three address code representations.</p>
Chris Lattner7bae3952002-06-25 18:03:17 +0000288<!-- The written form for the type system was heavily influenced by the
289syntactic problems with types in the C language<sup><a
Chris Lattner261efe92003-11-25 01:02:51 +0000290href="#rw_stroustrup">1</a></sup>.<p> --> </div>
Chris Lattner00950542001-06-06 20:29:01 +0000291<!-- ======================================================================= -->
Chris Lattner261efe92003-11-25 01:02:51 +0000292<div class="doc_subsection"> <a name="t_primitive">Primitive Types</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000293<div class="doc_text">
John Criswell4457dc92004-04-09 16:48:45 +0000294<p>The primitive types are the fundamental building blocks of the LLVM
Chris Lattner261efe92003-11-25 01:02:51 +0000295system. The current set of primitive types are as follows:</p>
Misha Brukmandaa4cb02004-03-01 17:47:27 +0000296
297<table border="0" style="align: center">
Chris Lattner261efe92003-11-25 01:02:51 +0000298 <tbody>
299 <tr>
300 <td>
Misha Brukmandaa4cb02004-03-01 17:47:27 +0000301 <table border="1" cellspacing="0" cellpadding="4" style="align: center">
Chris Lattner261efe92003-11-25 01:02:51 +0000302 <tbody>
303 <tr>
304 <td><tt>void</tt></td>
305 <td>No value</td>
306 </tr>
307 <tr>
308 <td><tt>ubyte</tt></td>
309 <td>Unsigned 8 bit value</td>
310 </tr>
311 <tr>
312 <td><tt>ushort</tt></td>
313 <td>Unsigned 16 bit value</td>
314 </tr>
315 <tr>
316 <td><tt>uint</tt></td>
317 <td>Unsigned 32 bit value</td>
318 </tr>
319 <tr>
320 <td><tt>ulong</tt></td>
321 <td>Unsigned 64 bit value</td>
322 </tr>
323 <tr>
324 <td><tt>float</tt></td>
325 <td>32 bit floating point value</td>
326 </tr>
327 <tr>
328 <td><tt>label</tt></td>
329 <td>Branch destination</td>
330 </tr>
331 </tbody>
332 </table>
333 </td>
334 <td valign="top">
Misha Brukmandaa4cb02004-03-01 17:47:27 +0000335 <table border="1" cellspacing="0" cellpadding="4">
Chris Lattner261efe92003-11-25 01:02:51 +0000336 <tbody>
337 <tr>
338 <td><tt>bool</tt></td>
339 <td>True or False value</td>
340 </tr>
341 <tr>
342 <td><tt>sbyte</tt></td>
343 <td>Signed 8 bit value</td>
344 </tr>
345 <tr>
346 <td><tt>short</tt></td>
347 <td>Signed 16 bit value</td>
348 </tr>
349 <tr>
350 <td><tt>int</tt></td>
351 <td>Signed 32 bit value</td>
352 </tr>
353 <tr>
354 <td><tt>long</tt></td>
355 <td>Signed 64 bit value</td>
356 </tr>
357 <tr>
358 <td><tt>double</tt></td>
359 <td>64 bit floating point value</td>
360 </tr>
361 </tbody>
362 </table>
363 </td>
364 </tr>
365 </tbody>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000366</table>
Misha Brukmandaa4cb02004-03-01 17:47:27 +0000367
Misha Brukman9d0919f2003-11-08 01:05:38 +0000368</div>
Chris Lattner00950542001-06-06 20:29:01 +0000369<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000370<div class="doc_subsubsection"> <a name="t_classifications">Type
371Classifications</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000372<div class="doc_text">
Chris Lattner261efe92003-11-25 01:02:51 +0000373<p>These different primitive types fall into a few useful
374classifications:</p>
Misha Brukmandaa4cb02004-03-01 17:47:27 +0000375
376<table border="1" cellspacing="0" cellpadding="4">
Chris Lattner261efe92003-11-25 01:02:51 +0000377 <tbody>
378 <tr>
379 <td><a name="t_signed">signed</a></td>
380 <td><tt>sbyte, short, int, long, float, double</tt></td>
381 </tr>
382 <tr>
383 <td><a name="t_unsigned">unsigned</a></td>
384 <td><tt>ubyte, ushort, uint, ulong</tt></td>
385 </tr>
386 <tr>
387 <td><a name="t_integer">integer</a></td>
388 <td><tt>ubyte, sbyte, ushort, short, uint, int, ulong, long</tt></td>
389 </tr>
390 <tr>
391 <td><a name="t_integral">integral</a></td>
Misha Brukmanc24b7582004-08-12 20:16:08 +0000392 <td><tt>bool, ubyte, sbyte, ushort, short, uint, int, ulong, long</tt>
393 </td>
Chris Lattner261efe92003-11-25 01:02:51 +0000394 </tr>
395 <tr>
396 <td><a name="t_floating">floating point</a></td>
397 <td><tt>float, double</tt></td>
398 </tr>
399 <tr>
400 <td><a name="t_firstclass">first class</a></td>
Misha Brukmanc24b7582004-08-12 20:16:08 +0000401 <td><tt>bool, ubyte, sbyte, ushort, short, uint, int, ulong, long,<br>
402 float, double, <a href="#t_pointer">pointer</a>,
403 <a href="#t_packed">packed</a></tt></td>
Chris Lattner261efe92003-11-25 01:02:51 +0000404 </tr>
405 </tbody>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000406</table>
Misha Brukmandaa4cb02004-03-01 17:47:27 +0000407
Chris Lattner261efe92003-11-25 01:02:51 +0000408<p>The <a href="#t_firstclass">first class</a> types are perhaps the
409most important. Values of these types are the only ones which can be
410produced by instructions, passed as arguments, or used as operands to
411instructions. This means that all structures and arrays must be
412manipulated either by pointer or by component.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000413</div>
Chris Lattner00950542001-06-06 20:29:01 +0000414<!-- ======================================================================= -->
Chris Lattner261efe92003-11-25 01:02:51 +0000415<div class="doc_subsection"> <a name="t_derived">Derived Types</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000416<div class="doc_text">
Chris Lattner261efe92003-11-25 01:02:51 +0000417<p>The real power in LLVM comes from the derived types in the system.
418This is what allows a programmer to represent arrays, functions,
419pointers, and other useful types. Note that these derived types may be
420recursive: For example, it is possible to have a two dimensional array.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000421</div>
Chris Lattner00950542001-06-06 20:29:01 +0000422<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000423<div class="doc_subsubsection"> <a name="t_array">Array Type</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000424<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +0000425<h5>Overview:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000426<p>The array type is a very simple derived type that arranges elements
Chris Lattner261efe92003-11-25 01:02:51 +0000427sequentially in memory. The array type requires a size (number of
428elements) and an underlying data type.</p>
Chris Lattner7faa8832002-04-14 06:13:44 +0000429<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000430<pre> [&lt;# elements&gt; x &lt;elementtype&gt;]<br></pre>
431<p>The number of elements is a constant integer value, elementtype may
432be any type with a size.</p>
Chris Lattner7faa8832002-04-14 06:13:44 +0000433<h5>Examples:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000434<p> <tt>[40 x int ]</tt>: Array of 40 integer values.<br>
435<tt>[41 x int ]</tt>: Array of 41 integer values.<br>
436<tt>[40 x uint]</tt>: Array of 40 unsigned integer values.</p>
437<p> </p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000438<p>Here are some examples of multidimensional arrays:</p>
Misha Brukmandaa4cb02004-03-01 17:47:27 +0000439
Misha Brukman9d0919f2003-11-08 01:05:38 +0000440<table border="0" cellpadding="0" cellspacing="0">
Chris Lattner261efe92003-11-25 01:02:51 +0000441 <tbody>
442 <tr>
443 <td><tt>[3 x [4 x int]]</tt></td>
444 <td>: 3x4 array integer values.</td>
445 </tr>
446 <tr>
447 <td><tt>[12 x [10 x float]]</tt></td>
448 <td>: 12x10 array of single precision floating point values.</td>
449 </tr>
450 <tr>
451 <td><tt>[2 x [3 x [4 x uint]]]</tt></td>
452 <td>: 2x3x4 array of unsigned integer values.</td>
453 </tr>
454 </tbody>
Chris Lattner00950542001-06-06 20:29:01 +0000455</table>
Misha Brukmandaa4cb02004-03-01 17:47:27 +0000456
Misha Brukman9d0919f2003-11-08 01:05:38 +0000457</div>
Chris Lattner00950542001-06-06 20:29:01 +0000458<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000459<div class="doc_subsubsection"> <a name="t_function">Function Type</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000460<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +0000461<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000462<p>The function type can be thought of as a function signature. It
463consists of a return type and a list of formal parameter types.
John Criswell009900b2003-11-25 21:45:46 +0000464Function types are usually used to build virtual function tables
Chris Lattner261efe92003-11-25 01:02:51 +0000465(which are structures of pointers to functions), for indirect function
466calls, and when defining a function.</p>
John Criswell009900b2003-11-25 21:45:46 +0000467<p>
468The return type of a function type cannot be an aggregate type.
469</p>
Chris Lattner00950542001-06-06 20:29:01 +0000470<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000471<pre> &lt;returntype&gt; (&lt;parameter list&gt;)<br></pre>
Misha Brukmanc24b7582004-08-12 20:16:08 +0000472<p>Where '<tt>&lt;parameter list&gt;</tt>' is a comma-separated list of type
473specifiers. Optionally, the parameter list may include a type <tt>...</tt>,
Chris Lattner27f71f22003-09-03 00:41:47 +0000474which indicates that the function takes a variable number of arguments.
475Variable argument functions can access their arguments with the <a
Chris Lattner261efe92003-11-25 01:02:51 +0000476 href="#int_varargs">variable argument handling intrinsic</a> functions.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000477<h5>Examples:</h5>
Misha Brukmandaa4cb02004-03-01 17:47:27 +0000478
Misha Brukman9d0919f2003-11-08 01:05:38 +0000479<table border="0" cellpadding="0" cellspacing="0">
Chris Lattner261efe92003-11-25 01:02:51 +0000480 <tbody>
481 <tr>
482 <td><tt>int (int)</tt></td>
483 <td>: function taking an <tt>int</tt>, returning an <tt>int</tt></td>
484 </tr>
485 <tr>
486 <td><tt>float (int, int *) *</tt></td>
Misha Brukmanc24b7582004-08-12 20:16:08 +0000487 <td>: <a href="#t_pointer">Pointer</a> to a function that takes an
488 <tt>int</tt> and a <a href="#t_pointer">pointer</a> to <tt>int</tt>,
489 returning <tt>float</tt>.</td>
Chris Lattner261efe92003-11-25 01:02:51 +0000490 </tr>
491 <tr>
492 <td><tt>int (sbyte *, ...)</tt></td>
493 <td>: A vararg function that takes at least one <a
Misha Brukmanc24b7582004-08-12 20:16:08 +0000494 href="#t_pointer">pointer</a> to <tt>sbyte</tt> (signed char in C), which
495 returns an integer. This is the signature for <tt>printf</tt> in
496 LLVM.</td>
Chris Lattner261efe92003-11-25 01:02:51 +0000497 </tr>
498 </tbody>
Chris Lattner00950542001-06-06 20:29:01 +0000499</table>
Misha Brukmandaa4cb02004-03-01 17:47:27 +0000500
Misha Brukman9d0919f2003-11-08 01:05:38 +0000501</div>
Chris Lattner00950542001-06-06 20:29:01 +0000502<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000503<div class="doc_subsubsection"> <a name="t_struct">Structure Type</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000504<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +0000505<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000506<p>The structure type is used to represent a collection of data members
507together in memory. The packing of the field types is defined to match
508the ABI of the underlying processor. The elements of a structure may
509be any type that has a size.</p>
510<p>Structures are accessed using '<tt><a href="#i_load">load</a></tt>
511and '<tt><a href="#i_store">store</a></tt>' by getting a pointer to a
512field with the '<tt><a href="#i_getelementptr">getelementptr</a></tt>'
513instruction.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000514<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000515<pre> { &lt;type list&gt; }<br></pre>
Chris Lattner00950542001-06-06 20:29:01 +0000516<h5>Examples:</h5>
Misha Brukmandaa4cb02004-03-01 17:47:27 +0000517
Misha Brukman9d0919f2003-11-08 01:05:38 +0000518<table border="0" cellpadding="0" cellspacing="0">
Chris Lattner261efe92003-11-25 01:02:51 +0000519 <tbody>
520 <tr>
521 <td><tt>{ int, int, int }</tt></td>
522 <td>: a triple of three <tt>int</tt> values</td>
523 </tr>
524 <tr>
525 <td><tt>{ float, int (int) * }</tt></td>
Misha Brukmanc24b7582004-08-12 20:16:08 +0000526 <td>: A pair, where the first element is a <tt>float</tt> and the second
527 element is a <a href="#t_pointer">pointer</a> to a <a
528 href="#t_function">function</a> that takes an <tt>int</tt>, returning an
529 <tt>int</tt>.</td>
Chris Lattner261efe92003-11-25 01:02:51 +0000530 </tr>
531 </tbody>
Chris Lattner00950542001-06-06 20:29:01 +0000532</table>
Misha Brukmandaa4cb02004-03-01 17:47:27 +0000533
Misha Brukman9d0919f2003-11-08 01:05:38 +0000534</div>
Chris Lattner00950542001-06-06 20:29:01 +0000535<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000536<div class="doc_subsubsection"> <a name="t_pointer">Pointer Type</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000537<div class="doc_text">
Chris Lattner7faa8832002-04-14 06:13:44 +0000538<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000539<p>As in many languages, the pointer type represents a pointer or
540reference to another object, which must live in memory.</p>
Chris Lattner7faa8832002-04-14 06:13:44 +0000541<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000542<pre> &lt;type&gt; *<br></pre>
Chris Lattner7faa8832002-04-14 06:13:44 +0000543<h5>Examples:</h5>
Misha Brukmandaa4cb02004-03-01 17:47:27 +0000544
Misha Brukman9d0919f2003-11-08 01:05:38 +0000545<table border="0" cellpadding="0" cellspacing="0">
Chris Lattner261efe92003-11-25 01:02:51 +0000546 <tbody>
547 <tr>
548 <td><tt>[4x int]*</tt></td>
Misha Brukmanc24b7582004-08-12 20:16:08 +0000549 <td>: <a href="#t_pointer">pointer</a> to <a href="#t_array">array</a> of
550 four <tt>int</tt> values</td>
Chris Lattner261efe92003-11-25 01:02:51 +0000551 </tr>
552 <tr>
553 <td><tt>int (int *) *</tt></td>
554 <td>: A <a href="#t_pointer">pointer</a> to a <a
Misha Brukmanc24b7582004-08-12 20:16:08 +0000555 href="#t_function">function</a> that takes an <tt>int</tt>, returning an
556 <tt>int</tt>.</td>
Chris Lattner261efe92003-11-25 01:02:51 +0000557 </tr>
558 </tbody>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000559</table>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000560</div>
Chris Lattnera58561b2004-08-12 19:12:28 +0000561<!-- _______________________________________________________________________ -->
562<div class="doc_subsubsection"> <a name="t_packed">Packed Type</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000563<div class="doc_text">
Chris Lattnera58561b2004-08-12 19:12:28 +0000564<h5>Overview:</h5>
565<p>A packed type is a simple derived type that represents a vector
566of elements. Packed types are used when multiple primitive data
567are operated in parallel using a single instruction (SIMD).
568A packed type requires a size (number of
569elements) and an underlying primitive data type. Packed types are
570considered <a href="#t_firstclass">first class</a>.</p>
571<h5>Syntax:</h5>
572<pre> &lt; &lt;# elements&gt; x &lt;elementtype&gt; &gt;<br></pre>
573<p>The number of elements is a constant integer value, elementtype may
574be any integral or floating point type.</p>
575<h5>Examples:</h5>
576<p> <tt>&lt;4 x int&gt;</tt>: Packed vector of 4 integer values.<br>
577<tt>&lt;8 x float&gt;</tt>: Packed vector of 8 floating-point values.<br>
578<tt>&lt;2 x uint&gt;</tt>: Packed vector of 2 unsigned integer values.</p>
579<p> </p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000580</div>
581
Chris Lattnera58561b2004-08-12 19:12:28 +0000582<!-- *********************************************************************** -->
Chris Lattner261efe92003-11-25 01:02:51 +0000583<div class="doc_section"> <a name="highlevel">High Level Structure</a> </div>
Misha Brukmanc24b7582004-08-12 20:16:08 +0000584<!-- *********************************************************************** -->
585<!-- ======================================================================= -->
586<div class="doc_subsection"> <a name="modulestructure">Module Structure</a>
587</div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000588<div class="doc_text">
Chris Lattner261efe92003-11-25 01:02:51 +0000589<p>LLVM programs are composed of "Module"s, each of which is a
590translation unit of the input programs. Each module consists of
591functions, global variables, and symbol table entries. Modules may be
592combined together with the LLVM linker, which merges function (and
593global variable) definitions, resolves forward declarations, and merges
594symbol table entries. Here is an example of the "hello world" module:</p>
595<pre><i>; Declare the string constant as a global constant...</i>
596<a href="#identifiers">%.LC0</a> = <a href="#linkage_internal">internal</a> <a
597 href="#globalvars">constant</a> <a href="#t_array">[13 x sbyte]</a> c"hello world\0A\00" <i>; [13 x sbyte]*</i>
Chris Lattner2b7d3202002-05-06 03:03:22 +0000598
Chris Lattner27f71f22003-09-03 00:41:47 +0000599<i>; External declaration of the puts function</i>
600<a href="#functionstructure">declare</a> int %puts(sbyte*) <i>; int(sbyte*)* </i>
Chris Lattner2b7d3202002-05-06 03:03:22 +0000601
602<i>; Definition of main function</i>
Chris Lattner27f71f22003-09-03 00:41:47 +0000603int %main() { <i>; int()* </i>
Chris Lattner2b7d3202002-05-06 03:03:22 +0000604 <i>; Convert [13x sbyte]* to sbyte *...</i>
Chris Lattner261efe92003-11-25 01:02:51 +0000605 %cast210 = <a
606 href="#i_getelementptr">getelementptr</a> [13 x sbyte]* %.LC0, long 0, long 0 <i>; sbyte*</i>
Chris Lattner2b7d3202002-05-06 03:03:22 +0000607
608 <i>; Call puts function to write out the string to stdout...</i>
Chris Lattner261efe92003-11-25 01:02:51 +0000609 <a
610 href="#i_call">call</a> int %puts(sbyte* %cast210) <i>; int</i>
611 <a
612 href="#i_ret">ret</a> int 0<br>}<br></pre>
613<p>This example is made up of a <a href="#globalvars">global variable</a>
614named "<tt>.LC0</tt>", an external declaration of the "<tt>puts</tt>"
615function, and a <a href="#functionstructure">function definition</a>
616for "<tt>main</tt>".</p>
617<a name="linkage"> In general, a module is made up of a list of global
618values, where both functions and global variables are global values.
619Global values are represented by a pointer to a memory location (in
620this case, a pointer to an array of char, and a pointer to a function),
621and have one of the following linkage types:</a>
622<p> </p>
Chris Lattner27f71f22003-09-03 00:41:47 +0000623<dl>
Misha Brukmandaa4cb02004-03-01 17:47:27 +0000624 <dt><tt><b><a name="linkage_internal">internal</a></b></tt> </dt>
Chris Lattner261efe92003-11-25 01:02:51 +0000625 <dd>Global values with internal linkage are only directly accessible
626by objects in the current module. In particular, linking code into a
627module with an internal global value may cause the internal to be
628renamed as necessary to avoid collisions. Because the symbol is
629internal to the module, all references can be updated. This
630corresponds to the notion of the '<tt>static</tt>' keyword in C, or the
631idea of "anonymous namespaces" in C++.
632 <p> </p>
633 </dd>
Misha Brukmandaa4cb02004-03-01 17:47:27 +0000634 <dt><tt><b><a name="linkage_linkonce">linkonce</a></b></tt>: </dt>
Chris Lattner261efe92003-11-25 01:02:51 +0000635 <dd>"<tt>linkonce</tt>" linkage is similar to <tt>internal</tt>
636linkage, with the twist that linking together two modules defining the
637same <tt>linkonce</tt> globals will cause one of the globals to be
638discarded. This is typically used to implement inline functions.
639Unreferenced <tt>linkonce</tt> globals are allowed to be discarded.
640 <p> </p>
641 </dd>
Misha Brukmandaa4cb02004-03-01 17:47:27 +0000642 <dt><tt><b><a name="linkage_weak">weak</a></b></tt>: </dt>
Chris Lattner261efe92003-11-25 01:02:51 +0000643 <dd>"<tt>weak</tt>" linkage is exactly the same as <tt>linkonce</tt>
644linkage, except that unreferenced <tt>weak</tt> globals may not be
645discarded. This is used to implement constructs in C such as "<tt>int
646X;</tt>" at global scope.
647 <p> </p>
648 </dd>
Misha Brukmandaa4cb02004-03-01 17:47:27 +0000649 <dt><tt><b><a name="linkage_appending">appending</a></b></tt>: </dt>
Chris Lattner261efe92003-11-25 01:02:51 +0000650 <dd>"<tt>appending</tt>" linkage may only be applied to global
651variables of pointer to array type. When two global variables with
652appending linkage are linked together, the two global arrays are
653appended together. This is the LLVM, typesafe, equivalent of having
654the system linker append together "sections" with identical names when
655.o files are linked.
656 <p> </p>
657 </dd>
Misha Brukmandaa4cb02004-03-01 17:47:27 +0000658 <dt><tt><b><a name="linkage_external">externally visible</a></b></tt>:</dt>
Chris Lattner261efe92003-11-25 01:02:51 +0000659 <dd>If none of the above identifiers are used, the global is
660externally visible, meaning that it participates in linkage and can be
661used to resolve external symbol references.
662 <p> </p>
663 </dd>
Chris Lattner261efe92003-11-25 01:02:51 +0000664</dl>
665<p> </p>
666<p><a name="linkage_external">For example, since the "<tt>.LC0</tt>"
667variable is defined to be internal, if another module defined a "<tt>.LC0</tt>"
668variable and was linked with this one, one of the two would be renamed,
669preventing a collision. Since "<tt>main</tt>" and "<tt>puts</tt>" are
670external (i.e., lacking any linkage declarations), they are accessible
671outside of the current module. It is illegal for a function <i>declaration</i>
672to have any linkage type other than "externally visible".</a></p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000673</div>
Chris Lattner9ee5d222004-03-08 16:49:10 +0000674
Chris Lattner00950542001-06-06 20:29:01 +0000675<!-- ======================================================================= -->
Chris Lattner9ee5d222004-03-08 16:49:10 +0000676<div class="doc_subsection">
677 <a name="globalvars">Global Variables</a>
678</div>
679
Misha Brukman9d0919f2003-11-08 01:05:38 +0000680<div class="doc_text">
Chris Lattner9ee5d222004-03-08 16:49:10 +0000681
Chris Lattner261efe92003-11-25 01:02:51 +0000682<p>Global variables define regions of memory allocated at compilation
683time instead of run-time. Global variables may optionally be
684initialized. A variable may be defined as a global "constant", which
685indicates that the contents of the variable will never be modified
Chris Lattner9ee5d222004-03-08 16:49:10 +0000686(opening options for optimization).</p>
687
Chris Lattner261efe92003-11-25 01:02:51 +0000688<p>As SSA values, global variables define pointer values that are in
689scope (i.e. they dominate) for all basic blocks in the program. Global
690variables always define a pointer to their "content" type because they
691describe a region of memory, and all memory objects in LLVM are
692accessed through pointers.</p>
Chris Lattner9ee5d222004-03-08 16:49:10 +0000693
Misha Brukman9d0919f2003-11-08 01:05:38 +0000694</div>
Chris Lattner9ee5d222004-03-08 16:49:10 +0000695
696
Chris Lattner2b7d3202002-05-06 03:03:22 +0000697<!-- ======================================================================= -->
Chris Lattner9ee5d222004-03-08 16:49:10 +0000698<div class="doc_subsection">
699 <a name="functionstructure">Functions</a>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000700</div>
Chris Lattner9ee5d222004-03-08 16:49:10 +0000701
702<div class="doc_text">
703
704<p>LLVM function definitions are composed of a (possibly empty) argument list,
705an opening curly brace, a list of basic blocks, and a closing curly brace. LLVM
706function declarations are defined with the "<tt>declare</tt>" keyword, a
707function name, and a function signature.</p>
708
709<p>A function definition contains a list of basic blocks, forming the CFG for
710the function. Each basic block may optionally start with a label (giving the
711basic block a symbol table entry), contains a list of instructions, and ends
712with a <a href="#terminators">terminator</a> instruction (such as a branch or
713function return).</p>
714
715<p>The first basic block in program is special in two ways: it is immediately
716executed on entrance to the function, and it is not allowed to have predecessor
717basic blocks (i.e. there can not be any branches to the entry block of a
718function). Because the block can have no predecessors, it also cannot have any
719<a href="#i_phi">PHI nodes</a>.</p>
720
721<p>LLVM functions are identified by their name and type signature. Hence, two
722functions with the same name but different parameter lists or return values are
723considered different functions, and LLVM will resolves references to each
724appropriately.</p>
725
726</div>
727
728
Chris Lattner00950542001-06-06 20:29:01 +0000729<!-- *********************************************************************** -->
Chris Lattner261efe92003-11-25 01:02:51 +0000730<div class="doc_section"> <a name="instref">Instruction Reference</a> </div>
731<!-- *********************************************************************** -->
Misha Brukman9d0919f2003-11-08 01:05:38 +0000732<div class="doc_text">
Chris Lattner261efe92003-11-25 01:02:51 +0000733<p>The LLVM instruction set consists of several different
734classifications of instructions: <a href="#terminators">terminator
735instructions</a>, <a href="#binaryops">binary instructions</a>, <a
736 href="#memoryops">memory instructions</a>, and <a href="#otherops">other
737instructions</a>.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000738</div>
Chris Lattner00950542001-06-06 20:29:01 +0000739<!-- ======================================================================= -->
Chris Lattner261efe92003-11-25 01:02:51 +0000740<div class="doc_subsection"> <a name="terminators">Terminator
741Instructions</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000742<div class="doc_text">
Chris Lattner261efe92003-11-25 01:02:51 +0000743<p>As mentioned <a href="#functionstructure">previously</a>, every
744basic block in a program ends with a "Terminator" instruction, which
745indicates which block should be executed after the current block is
746finished. These terminator instructions typically yield a '<tt>void</tt>'
747value: they produce control flow, not values (the one exception being
748the '<a href="#i_invoke"><tt>invoke</tt></a>' instruction).</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000749<p>There are five different terminator instructions: the '<a
Chris Lattner261efe92003-11-25 01:02:51 +0000750 href="#i_ret"><tt>ret</tt></a>' instruction, the '<a href="#i_br"><tt>br</tt></a>'
751instruction, the '<a href="#i_switch"><tt>switch</tt></a>' instruction,
752the '<a href="#i_invoke"><tt>invoke</tt></a>' instruction, and the '<a
753 href="#i_unwind"><tt>unwind</tt></a>' instruction.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000754</div>
Chris Lattner00950542001-06-06 20:29:01 +0000755<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000756<div class="doc_subsubsection"> <a name="i_ret">'<tt>ret</tt>'
757Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000758<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +0000759<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000760<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 +0000761 ret void <i>; Return from void function</i>
Chris Lattner00950542001-06-06 20:29:01 +0000762</pre>
Chris Lattner00950542001-06-06 20:29:01 +0000763<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000764<p>The '<tt>ret</tt>' instruction is used to return control flow (and a
765value) from a function, back to the caller.</p>
John Criswell4457dc92004-04-09 16:48:45 +0000766<p>There are two forms of the '<tt>ret</tt>' instruction: one that
Chris Lattner261efe92003-11-25 01:02:51 +0000767returns a value and then causes control flow, and one that just causes
768control flow to occur.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000769<h5>Arguments:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000770<p>The '<tt>ret</tt>' instruction may return any '<a
771 href="#t_firstclass">first class</a>' type. Notice that a function is
772not <a href="#wellformed">well formed</a> if there exists a '<tt>ret</tt>'
773instruction inside of the function that returns a value that does not
774match the return type of the function.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000775<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000776<p>When the '<tt>ret</tt>' instruction is executed, control flow
777returns back to the calling function's context. If the caller is a "<a
John Criswellfa081872004-06-25 15:16:57 +0000778 href="#i_call"><tt>call</tt></a>" instruction, execution continues at
Chris Lattner261efe92003-11-25 01:02:51 +0000779the instruction after the call. If the caller was an "<a
780 href="#i_invoke"><tt>invoke</tt></a>" instruction, execution continues
781at the beginning "normal" of the destination block. If the instruction
782returns a value, that value shall set the call or invoke instruction's
783return value.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000784<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000785<pre> ret int 5 <i>; Return an integer value of 5</i>
Chris Lattner7faa8832002-04-14 06:13:44 +0000786 ret void <i>; Return from a void function</i>
Chris Lattner00950542001-06-06 20:29:01 +0000787</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000788</div>
Chris Lattner00950542001-06-06 20:29:01 +0000789<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000790<div class="doc_subsubsection"> <a name="i_br">'<tt>br</tt>' Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000791<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +0000792<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000793<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 +0000794</pre>
Chris Lattner00950542001-06-06 20:29:01 +0000795<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000796<p>The '<tt>br</tt>' instruction is used to cause control flow to
797transfer to a different basic block in the current function. There are
798two forms of this instruction, corresponding to a conditional branch
799and an unconditional branch.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000800<h5>Arguments:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000801<p>The conditional branch form of the '<tt>br</tt>' instruction takes a
802single '<tt>bool</tt>' value and two '<tt>label</tt>' values. The
803unconditional form of the '<tt>br</tt>' instruction takes a single '<tt>label</tt>'
804value as a target.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000805<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000806<p>Upon execution of a conditional '<tt>br</tt>' instruction, the '<tt>bool</tt>'
807argument is evaluated. If the value is <tt>true</tt>, control flows
808to the '<tt>iftrue</tt>' <tt>label</tt> argument. If "cond" is <tt>false</tt>,
809control flows to the '<tt>iffalse</tt>' <tt>label</tt> argument.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000810<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000811<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
812 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 +0000813</div>
Chris Lattner00950542001-06-06 20:29:01 +0000814<!-- _______________________________________________________________________ -->
Chris Lattnerc88c17b2004-02-24 04:54:45 +0000815<div class="doc_subsubsection">
816 <a name="i_switch">'<tt>switch</tt>' Instruction</a>
817</div>
818
Misha Brukman9d0919f2003-11-08 01:05:38 +0000819<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +0000820<h5>Syntax:</h5>
Chris Lattnerc88c17b2004-02-24 04:54:45 +0000821
822<pre>
823 switch &lt;intty&gt; &lt;value&gt;, label &lt;defaultdest&gt; [ &lt;intty&gt; &lt;val&gt;, label &lt;dest&gt; ... ]
824</pre>
825
Chris Lattner00950542001-06-06 20:29:01 +0000826<h5>Overview:</h5>
Chris Lattnerc88c17b2004-02-24 04:54:45 +0000827
828<p>The '<tt>switch</tt>' instruction is used to transfer control flow to one of
829several different places. It is a generalization of the '<tt>br</tt>'
Misha Brukman9d0919f2003-11-08 01:05:38 +0000830instruction, allowing a branch to occur to one of many possible
831destinations.</p>
Chris Lattnerc88c17b2004-02-24 04:54:45 +0000832
833
Chris Lattner00950542001-06-06 20:29:01 +0000834<h5>Arguments:</h5>
Chris Lattnerc88c17b2004-02-24 04:54:45 +0000835
836<p>The '<tt>switch</tt>' instruction uses three parameters: an integer
837comparison value '<tt>value</tt>', a default '<tt>label</tt>' destination, and
838an array of pairs of comparison value constants and '<tt>label</tt>'s. The
839table is not allowed to contain duplicate constant entries.</p>
840
Chris Lattner00950542001-06-06 20:29:01 +0000841<h5>Semantics:</h5>
Chris Lattnerc88c17b2004-02-24 04:54:45 +0000842
Chris Lattner261efe92003-11-25 01:02:51 +0000843<p>The <tt>switch</tt> instruction specifies a table of values and
844destinations. When the '<tt>switch</tt>' instruction is executed, this
John Criswell84114752004-06-25 16:05:06 +0000845table is searched for the given value. If the value is found, control flow is
846transfered to the corresponding destination; otherwise, control flow is
847transfered to the default destination.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000848
Chris Lattnerc88c17b2004-02-24 04:54:45 +0000849<h5>Implementation:</h5>
850
851<p>Depending on properties of the target machine and the particular
852<tt>switch</tt> instruction, this instruction may be code generated in different
John Criswell84114752004-06-25 16:05:06 +0000853ways. For example, it could be generated as a series of chained conditional
854branches or with a lookup table.</p>
Chris Lattnerc88c17b2004-02-24 04:54:45 +0000855
856<h5>Example:</h5>
857
858<pre>
859 <i>; Emulate a conditional br instruction</i>
860 %Val = <a href="#i_cast">cast</a> bool %value to int
861 switch int %Val, label %truedest [int 0, label %falsedest ]
862
863 <i>; Emulate an unconditional br instruction</i>
864 switch uint 0, label %dest [ ]
865
866 <i>; Implement a jump table:</i>
867 switch uint %val, label %otherwise [ uint 0, label %onzero
868 uint 1, label %onone
869 uint 2, label %ontwo ]
Chris Lattner00950542001-06-06 20:29:01 +0000870</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000871</div>
Chris Lattner00950542001-06-06 20:29:01 +0000872<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000873<div class="doc_subsubsection"> <a name="i_invoke">'<tt>invoke</tt>'
874Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000875<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +0000876<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000877<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 +0000878<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000879<p>The '<tt>invoke</tt>' instruction causes control to transfer to a
880specified function, with the possibility of control flow transfer to
881either the '<tt>normal</tt>' <tt>label</tt> label or the '<tt>exception</tt>'<tt>label</tt>.
882If the callee function returns with the "<tt><a href="#i_ret">ret</a></tt>"
883instruction, control flow will return to the "normal" label. If the
884callee (or any indirect callees) returns with the "<a href="#i_unwind"><tt>unwind</tt></a>"
885instruction, control is interrupted, and continued at the dynamically
886nearest "except" label.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000887<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000888<p>This instruction requires several arguments:</p>
Chris Lattner00950542001-06-06 20:29:01 +0000889<ol>
Chris Lattner261efe92003-11-25 01:02:51 +0000890 <li>'<tt>ptr to function ty</tt>': shall be the signature of the
891pointer to function value being invoked. In most cases, this is a
892direct function invocation, but indirect <tt>invoke</tt>s are just as
893possible, branching off an arbitrary pointer to function value. </li>
894 <li>'<tt>function ptr val</tt>': An LLVM value containing a pointer
895to a function to be invoked. </li>
896 <li>'<tt>function args</tt>': argument list whose types match the
897function signature argument types. If the function signature indicates
898the function accepts a variable number of arguments, the extra
899arguments can be specified. </li>
900 <li>'<tt>normal label</tt>': the label reached when the called
901function executes a '<tt><a href="#i_ret">ret</a></tt>' instruction. </li>
902 <li>'<tt>exception label</tt>': the label reached when a callee
903returns with the <a href="#i_unwind"><tt>unwind</tt></a> instruction. </li>
Chris Lattner00950542001-06-06 20:29:01 +0000904</ol>
Chris Lattner00950542001-06-06 20:29:01 +0000905<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000906<p>This instruction is designed to operate as a standard '<tt><a
Chris Lattner261efe92003-11-25 01:02:51 +0000907 href="#i_call">call</a></tt>' instruction in most regards. The
908primary difference is that it establishes an association with a label,
909which is used by the runtime library to unwind the stack.</p>
910<p>This instruction is used in languages with destructors to ensure
911that proper cleanup is performed in the case of either a <tt>longjmp</tt>
912or a thrown exception. Additionally, this is important for
913implementation of '<tt>catch</tt>' clauses in high-level languages that
914support them.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000915<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000916<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 +0000917</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000918</div>
Chris Lattner27f71f22003-09-03 00:41:47 +0000919<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000920<div class="doc_subsubsection"> <a name="i_unwind">'<tt>unwind</tt>'
921Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000922<div class="doc_text">
Chris Lattner27f71f22003-09-03 00:41:47 +0000923<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000924<pre> unwind<br></pre>
Chris Lattner27f71f22003-09-03 00:41:47 +0000925<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000926<p>The '<tt>unwind</tt>' instruction unwinds the stack, continuing
927control flow at the first callee in the dynamic call stack which used
928an <a href="#i_invoke"><tt>invoke</tt></a> instruction to perform the
929call. This is primarily used to implement exception handling.</p>
Chris Lattner27f71f22003-09-03 00:41:47 +0000930<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000931<p>The '<tt>unwind</tt>' intrinsic causes execution of the current
932function to immediately halt. The dynamic call stack is then searched
933for the first <a href="#i_invoke"><tt>invoke</tt></a> instruction on
934the call stack. Once found, execution continues at the "exceptional"
935destination block specified by the <tt>invoke</tt> instruction. If
936there is no <tt>invoke</tt> instruction in the dynamic call chain,
937undefined behavior results.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000938</div>
Chris Lattner00950542001-06-06 20:29:01 +0000939<!-- ======================================================================= -->
Chris Lattner261efe92003-11-25 01:02:51 +0000940<div class="doc_subsection"> <a name="binaryops">Binary Operations</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000941<div class="doc_text">
Chris Lattner261efe92003-11-25 01:02:51 +0000942<p>Binary operators are used to do most of the computation in a
943program. They require two operands, execute an operation on them, and
Chris Lattnera58561b2004-08-12 19:12:28 +0000944produce a single value. Although, that single value might represent
945multiple data, as is the case with the <a href="#t_packed">packed</a> data type.
946The result value of a binary operator is not
Chris Lattner261efe92003-11-25 01:02:51 +0000947necessarily the same type as its operands.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000948<p>There are several different binary operators:</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000949</div>
Chris Lattner00950542001-06-06 20:29:01 +0000950<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000951<div class="doc_subsubsection"> <a name="i_add">'<tt>add</tt>'
952Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000953<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +0000954<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000955<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 +0000956</pre>
Chris Lattner00950542001-06-06 20:29:01 +0000957<h5>Overview:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000958<p>The '<tt>add</tt>' instruction returns the sum of its two operands.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000959<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000960<p>The two arguments to the '<tt>add</tt>' instruction must be either <a
Chris Lattnera58561b2004-08-12 19:12:28 +0000961 href="#t_integer">integer</a> or <a href="#t_floating">floating point</a> values.
962 This instruction can also take <a href="#t_packed">packed</a> versions of the values.
963Both arguments must have identical types.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000964<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000965<p>The value produced is the integer or floating point sum of the two
966operands.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000967<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000968<pre> &lt;result&gt; = add int 4, %var <i>; yields {int}:result = 4 + %var</i>
Chris Lattner00950542001-06-06 20:29:01 +0000969</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000970</div>
Chris Lattner00950542001-06-06 20:29:01 +0000971<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000972<div class="doc_subsubsection"> <a name="i_sub">'<tt>sub</tt>'
973Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000974<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +0000975<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000976<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 +0000977</pre>
Chris Lattner00950542001-06-06 20:29:01 +0000978<h5>Overview:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000979<p>The '<tt>sub</tt>' instruction returns the difference of its two
980operands.</p>
Chris Lattner261efe92003-11-25 01:02:51 +0000981<p>Note that the '<tt>sub</tt>' instruction is used to represent the '<tt>neg</tt>'
982instruction present in most other intermediate representations.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000983<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000984<p>The two arguments to the '<tt>sub</tt>' instruction must be either <a
Chris Lattner261efe92003-11-25 01:02:51 +0000985 href="#t_integer">integer</a> or <a href="#t_floating">floating point</a>
Chris Lattnera58561b2004-08-12 19:12:28 +0000986values.
987This instruction can also take <a href="#t_packed">packed</a> versions of the values.
988Both arguments must have identical types.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000989<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000990<p>The value produced is the integer or floating point difference of
991the two operands.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000992<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000993<pre> &lt;result&gt; = sub int 4, %var <i>; yields {int}:result = 4 - %var</i>
Chris Lattner00950542001-06-06 20:29:01 +0000994 &lt;result&gt; = sub int 0, %val <i>; yields {int}:result = -%var</i>
995</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000996</div>
Chris Lattner00950542001-06-06 20:29:01 +0000997<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000998<div class="doc_subsubsection"> <a name="i_mul">'<tt>mul</tt>'
999Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001000<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001001<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001002<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 +00001003</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001004<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001005<p>The '<tt>mul</tt>' instruction returns the product of its two
1006operands.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001007<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001008<p>The two arguments to the '<tt>mul</tt>' instruction must be either <a
Chris Lattner261efe92003-11-25 01:02:51 +00001009 href="#t_integer">integer</a> or <a href="#t_floating">floating point</a>
Chris Lattnera58561b2004-08-12 19:12:28 +00001010values.
1011This instruction can also take <a href="#t_packed">packed</a> versions of the values.
1012Both arguments must have identical types.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001013<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001014<p>The value produced is the integer or floating point product of the
Misha Brukman9d0919f2003-11-08 01:05:38 +00001015two operands.</p>
Chris Lattner261efe92003-11-25 01:02:51 +00001016<p>There is no signed vs unsigned multiplication. The appropriate
1017action is taken based on the type of the operand.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001018<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001019<pre> &lt;result&gt; = mul int 4, %var <i>; yields {int}:result = 4 * %var</i>
Chris Lattner00950542001-06-06 20:29:01 +00001020</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001021</div>
Chris Lattner00950542001-06-06 20:29:01 +00001022<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001023<div class="doc_subsubsection"> <a name="i_div">'<tt>div</tt>'
1024Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001025<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001026<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001027<pre> &lt;result&gt; = div &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
1028</pre>
1029<h5>Overview:</h5>
1030<p>The '<tt>div</tt>' instruction returns the quotient of its two
1031operands.</p>
1032<h5>Arguments:</h5>
1033<p>The two arguments to the '<tt>div</tt>' instruction must be either <a
1034 href="#t_integer">integer</a> or <a href="#t_floating">floating point</a>
Chris Lattnera58561b2004-08-12 19:12:28 +00001035values.
1036This instruction can also take <a href="#t_packed">packed</a> versions of the values.
1037Both arguments must have identical types.</p>
Chris Lattner261efe92003-11-25 01:02:51 +00001038<h5>Semantics:</h5>
1039<p>The value produced is the integer or floating point quotient of the
1040two operands.</p>
1041<h5>Example:</h5>
1042<pre> &lt;result&gt; = div int 4, %var <i>; yields {int}:result = 4 / %var</i>
1043</pre>
1044</div>
1045<!-- _______________________________________________________________________ -->
1046<div class="doc_subsubsection"> <a name="i_rem">'<tt>rem</tt>'
1047Instruction</a> </div>
1048<div class="doc_text">
1049<h5>Syntax:</h5>
1050<pre> &lt;result&gt; = rem &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
1051</pre>
1052<h5>Overview:</h5>
1053<p>The '<tt>rem</tt>' instruction returns the remainder from the
1054division of its two operands.</p>
1055<h5>Arguments:</h5>
1056<p>The two arguments to the '<tt>rem</tt>' instruction must be either <a
1057 href="#t_integer">integer</a> or <a href="#t_floating">floating point</a>
Chris Lattnera58561b2004-08-12 19:12:28 +00001058values.
1059This instruction can also take <a href="#t_packed">packed</a> versions of the values.
1060Both arguments must have identical types.</p>
Chris Lattner261efe92003-11-25 01:02:51 +00001061<h5>Semantics:</h5>
1062<p>This returns the <i>remainder</i> of a division (where the result
1063has the same sign as the divisor), not the <i>modulus</i> (where the
1064result has the same sign as the dividend) of a value. For more
1065information about the difference, see: <a
1066 href="http://mathforum.org/dr.math/problems/anne.4.28.99.html">The
1067Math Forum</a>.</p>
1068<h5>Example:</h5>
1069<pre> &lt;result&gt; = rem int 4, %var <i>; yields {int}:result = 4 % %var</i>
1070</pre>
1071</div>
1072<!-- _______________________________________________________________________ -->
1073<div class="doc_subsubsection"> <a name="i_setcc">'<tt>set<i>cc</i></tt>'
1074Instructions</a> </div>
1075<div class="doc_text">
1076<h5>Syntax:</h5>
1077<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 +00001078 &lt;result&gt; = setne &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {bool}:result</i>
1079 &lt;result&gt; = setlt &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {bool}:result</i>
1080 &lt;result&gt; = setgt &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {bool}:result</i>
1081 &lt;result&gt; = setle &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {bool}:result</i>
1082 &lt;result&gt; = setge &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {bool}:result</i>
1083</pre>
Chris Lattner261efe92003-11-25 01:02:51 +00001084<h5>Overview:</h5>
1085<p>The '<tt>set<i>cc</i></tt>' family of instructions returns a boolean
1086value based on a comparison of their two operands.</p>
1087<h5>Arguments:</h5>
1088<p>The two arguments to the '<tt>set<i>cc</i></tt>' instructions must
1089be of <a href="#t_firstclass">first class</a> type (it is not possible
1090to compare '<tt>label</tt>'s, '<tt>array</tt>'s, '<tt>structure</tt>'
1091or '<tt>void</tt>' values, etc...). Both arguments must have identical
1092types.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001093<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001094<p>The '<tt>seteq</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>'
1095value if both operands are equal.<br>
1096The '<tt>setne</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>'
1097value if both operands are unequal.<br>
1098The '<tt>setlt</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>'
1099value if the first operand is less than the second operand.<br>
1100The '<tt>setgt</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>'
1101value if the first operand is greater than the second operand.<br>
1102The '<tt>setle</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>'
1103value if the first operand is less than or equal to the second operand.<br>
1104The '<tt>setge</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>'
1105value if the first operand is greater than or equal to the second
1106operand.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001107<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001108<pre> &lt;result&gt; = seteq int 4, 5 <i>; yields {bool}:result = false</i>
Chris Lattner00950542001-06-06 20:29:01 +00001109 &lt;result&gt; = setne float 4, 5 <i>; yields {bool}:result = true</i>
1110 &lt;result&gt; = setlt uint 4, 5 <i>; yields {bool}:result = true</i>
1111 &lt;result&gt; = setgt sbyte 4, 5 <i>; yields {bool}:result = false</i>
1112 &lt;result&gt; = setle sbyte 4, 5 <i>; yields {bool}:result = true</i>
1113 &lt;result&gt; = setge sbyte 4, 5 <i>; yields {bool}:result = false</i>
1114</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001115</div>
Chris Lattner00950542001-06-06 20:29:01 +00001116<!-- ======================================================================= -->
Chris Lattner261efe92003-11-25 01:02:51 +00001117<div class="doc_subsection"> <a name="bitwiseops">Bitwise Binary
1118Operations</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001119<div class="doc_text">
Chris Lattner261efe92003-11-25 01:02:51 +00001120<p>Bitwise binary operators are used to do various forms of
1121bit-twiddling in a program. They are generally very efficient
1122instructions, and can commonly be strength reduced from other
1123instructions. They require two operands, execute an operation on them,
1124and produce a single value. The resulting value of the bitwise binary
1125operators is always the same type as its first operand.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001126</div>
Chris Lattner00950542001-06-06 20:29:01 +00001127<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001128<div class="doc_subsubsection"> <a name="i_and">'<tt>and</tt>'
1129Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001130<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001131<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001132<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 +00001133</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001134<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001135<p>The '<tt>and</tt>' instruction returns the bitwise logical and of
1136its two operands.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001137<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001138<p>The two arguments to the '<tt>and</tt>' instruction must be <a
Chris Lattner261efe92003-11-25 01:02:51 +00001139 href="#t_integral">integral</a> values. Both arguments must have
1140identical types.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001141<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001142<p>The truth table used for the '<tt>and</tt>' instruction is:</p>
Chris Lattner261efe92003-11-25 01:02:51 +00001143<p> </p>
Misha Brukmandaa4cb02004-03-01 17:47:27 +00001144<div style="align: center">
Misha Brukman9d0919f2003-11-08 01:05:38 +00001145<table border="1" cellspacing="0" cellpadding="4">
Chris Lattner261efe92003-11-25 01:02:51 +00001146 <tbody>
1147 <tr>
1148 <td>In0</td>
1149 <td>In1</td>
1150 <td>Out</td>
1151 </tr>
1152 <tr>
1153 <td>0</td>
1154 <td>0</td>
1155 <td>0</td>
1156 </tr>
1157 <tr>
1158 <td>0</td>
1159 <td>1</td>
1160 <td>0</td>
1161 </tr>
1162 <tr>
1163 <td>1</td>
1164 <td>0</td>
1165 <td>0</td>
1166 </tr>
1167 <tr>
1168 <td>1</td>
1169 <td>1</td>
1170 <td>1</td>
1171 </tr>
1172 </tbody>
1173</table>
Misha Brukmandaa4cb02004-03-01 17:47:27 +00001174</div>
Chris Lattner00950542001-06-06 20:29:01 +00001175<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001176<pre> &lt;result&gt; = and int 4, %var <i>; yields {int}:result = 4 &amp; %var</i>
Chris Lattner00950542001-06-06 20:29:01 +00001177 &lt;result&gt; = and int 15, 40 <i>; yields {int}:result = 8</i>
1178 &lt;result&gt; = and int 4, 8 <i>; yields {int}:result = 0</i>
1179</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001180</div>
Chris Lattner00950542001-06-06 20:29:01 +00001181<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001182<div class="doc_subsubsection"> <a name="i_or">'<tt>or</tt>' Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001183<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001184<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001185<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 +00001186</pre>
Chris Lattner261efe92003-11-25 01:02:51 +00001187<h5>Overview:</h5>
1188<p>The '<tt>or</tt>' instruction returns the bitwise logical inclusive
1189or of its two operands.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001190<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001191<p>The two arguments to the '<tt>or</tt>' instruction must be <a
Chris Lattner261efe92003-11-25 01:02:51 +00001192 href="#t_integral">integral</a> values. Both arguments must have
1193identical types.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001194<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001195<p>The truth table used for the '<tt>or</tt>' instruction is:</p>
Chris Lattner261efe92003-11-25 01:02:51 +00001196<p> </p>
Misha Brukmandaa4cb02004-03-01 17:47:27 +00001197<div style="align: center">
Chris Lattner261efe92003-11-25 01:02:51 +00001198<table border="1" cellspacing="0" cellpadding="4">
1199 <tbody>
1200 <tr>
1201 <td>In0</td>
1202 <td>In1</td>
1203 <td>Out</td>
1204 </tr>
1205 <tr>
1206 <td>0</td>
1207 <td>0</td>
1208 <td>0</td>
1209 </tr>
1210 <tr>
1211 <td>0</td>
1212 <td>1</td>
1213 <td>1</td>
1214 </tr>
1215 <tr>
1216 <td>1</td>
1217 <td>0</td>
1218 <td>1</td>
1219 </tr>
1220 <tr>
1221 <td>1</td>
1222 <td>1</td>
1223 <td>1</td>
1224 </tr>
1225 </tbody>
1226</table>
Misha Brukmandaa4cb02004-03-01 17:47:27 +00001227</div>
Chris Lattner00950542001-06-06 20:29:01 +00001228<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001229<pre> &lt;result&gt; = or int 4, %var <i>; yields {int}:result = 4 | %var</i>
Chris Lattner00950542001-06-06 20:29:01 +00001230 &lt;result&gt; = or int 15, 40 <i>; yields {int}:result = 47</i>
1231 &lt;result&gt; = or int 4, 8 <i>; yields {int}:result = 12</i>
1232</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001233</div>
Chris Lattner00950542001-06-06 20:29:01 +00001234<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001235<div class="doc_subsubsection"> <a name="i_xor">'<tt>xor</tt>'
1236Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001237<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001238<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001239<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 +00001240</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001241<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001242<p>The '<tt>xor</tt>' instruction returns the bitwise logical exclusive
1243or of its two operands. The <tt>xor</tt> is used to implement the
1244"one's complement" operation, which is the "~" operator in C.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001245<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001246<p>The two arguments to the '<tt>xor</tt>' instruction must be <a
Chris Lattner261efe92003-11-25 01:02:51 +00001247 href="#t_integral">integral</a> values. Both arguments must have
1248identical types.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001249<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001250<p>The truth table used for the '<tt>xor</tt>' instruction is:</p>
Chris Lattner261efe92003-11-25 01:02:51 +00001251<p> </p>
Misha Brukmandaa4cb02004-03-01 17:47:27 +00001252<div style="align: center">
Chris Lattner261efe92003-11-25 01:02:51 +00001253<table border="1" cellspacing="0" cellpadding="4">
1254 <tbody>
1255 <tr>
1256 <td>In0</td>
1257 <td>In1</td>
1258 <td>Out</td>
1259 </tr>
1260 <tr>
1261 <td>0</td>
1262 <td>0</td>
1263 <td>0</td>
1264 </tr>
1265 <tr>
1266 <td>0</td>
1267 <td>1</td>
1268 <td>1</td>
1269 </tr>
1270 <tr>
1271 <td>1</td>
1272 <td>0</td>
1273 <td>1</td>
1274 </tr>
1275 <tr>
1276 <td>1</td>
1277 <td>1</td>
1278 <td>0</td>
1279 </tr>
1280 </tbody>
1281</table>
Misha Brukmandaa4cb02004-03-01 17:47:27 +00001282</div>
Chris Lattner261efe92003-11-25 01:02:51 +00001283<p> </p>
Chris Lattner00950542001-06-06 20:29:01 +00001284<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001285<pre> &lt;result&gt; = xor int 4, %var <i>; yields {int}:result = 4 ^ %var</i>
Chris Lattner00950542001-06-06 20:29:01 +00001286 &lt;result&gt; = xor int 15, 40 <i>; yields {int}:result = 39</i>
1287 &lt;result&gt; = xor int 4, 8 <i>; yields {int}:result = 12</i>
Chris Lattner27f71f22003-09-03 00:41:47 +00001288 &lt;result&gt; = xor int %V, -1 <i>; yields {int}:result = ~%V</i>
Chris Lattner00950542001-06-06 20:29:01 +00001289</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001290</div>
Chris Lattner00950542001-06-06 20:29:01 +00001291<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001292<div class="doc_subsubsection"> <a name="i_shl">'<tt>shl</tt>'
1293Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001294<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001295<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001296<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 +00001297</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001298<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001299<p>The '<tt>shl</tt>' instruction returns the first operand shifted to
1300the left a specified number of bits.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001301<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001302<p>The first argument to the '<tt>shl</tt>' instruction must be an <a
Chris Lattner261efe92003-11-25 01:02:51 +00001303 href="#t_integer">integer</a> type. The second argument must be an '<tt>ubyte</tt>'
1304type.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001305<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001306<p>The value produced is <tt>var1</tt> * 2<sup><tt>var2</tt></sup>.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001307<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001308<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 +00001309 &lt;result&gt; = shl int 4, ubyte 2 <i>; yields {int}:result = 16</i>
1310 &lt;result&gt; = shl int 1, ubyte 10 <i>; yields {int}:result = 1024</i>
1311</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001312</div>
Chris Lattner00950542001-06-06 20:29:01 +00001313<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001314<div class="doc_subsubsection"> <a name="i_shr">'<tt>shr</tt>'
1315Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001316<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001317<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001318<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 +00001319</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001320<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001321<p>The '<tt>shr</tt>' instruction returns the first operand shifted to
1322the right a specified number of bits.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001323<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001324<p>The first argument to the '<tt>shr</tt>' instruction must be an <a
Chris Lattner261efe92003-11-25 01:02:51 +00001325 href="#t_integer">integer</a> type. The second argument must be an '<tt>ubyte</tt>'
1326type.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001327<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001328<p>If the first argument is a <a href="#t_signed">signed</a> type, the
1329most significant bit is duplicated in the newly free'd bit positions.
1330If the first argument is unsigned, zero bits shall fill the empty
1331positions.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001332<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001333<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 +00001334 &lt;result&gt; = shr uint 4, ubyte 1 <i>; yields {uint}:result = 2</i>
Chris Lattner00950542001-06-06 20:29:01 +00001335 &lt;result&gt; = shr int 4, ubyte 2 <i>; yields {int}:result = 1</i>
Chris Lattner8c6bb902003-06-18 21:30:51 +00001336 &lt;result&gt; = shr sbyte 4, ubyte 3 <i>; yields {sbyte}:result = 0</i>
1337 &lt;result&gt; = shr sbyte -2, ubyte 1 <i>; yields {sbyte}:result = -1</i>
Chris Lattner00950542001-06-06 20:29:01 +00001338</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001339</div>
Chris Lattner00950542001-06-06 20:29:01 +00001340<!-- ======================================================================= -->
Chris Lattner261efe92003-11-25 01:02:51 +00001341<div class="doc_subsection"> <a name="memoryops">Memory Access
1342Operations</a></div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001343<div class="doc_text">
Chris Lattner261efe92003-11-25 01:02:51 +00001344<p>A key design point of an SSA-based representation is how it
1345represents memory. In LLVM, no memory locations are in SSA form, which
1346makes things very simple. This section describes how to read, write,
1347allocate and free memory in LLVM.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001348</div>
Chris Lattner00950542001-06-06 20:29:01 +00001349<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001350<div class="doc_subsubsection"> <a name="i_malloc">'<tt>malloc</tt>'
1351Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001352<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001353<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001354<pre> &lt;result&gt; = malloc &lt;type&gt;, uint &lt;NumElements&gt; <i>; yields {type*}:result</i>
Chris Lattner7faa8832002-04-14 06:13:44 +00001355 &lt;result&gt; = malloc &lt;type&gt; <i>; yields {type*}:result</i>
Chris Lattner00950542001-06-06 20:29:01 +00001356</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001357<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001358<p>The '<tt>malloc</tt>' instruction allocates memory from the system
1359heap and returns a pointer to it.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001360<h5>Arguments:</h5>
John Criswell6e4ca612004-02-24 16:13:56 +00001361<p>The '<tt>malloc</tt>' instruction allocates <tt>sizeof(&lt;type&gt;)*NumElements</tt>
1362bytes of memory from the operating system and returns a pointer of the
Chris Lattner261efe92003-11-25 01:02:51 +00001363appropriate type to the program. The second form of the instruction is
1364a shorter version of the first instruction that defaults to allocating
1365one element.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001366<p>'<tt>type</tt>' must be a sized type.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001367<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001368<p>Memory is allocated using the system "<tt>malloc</tt>" function, and
1369a pointer is returned.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001370<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001371<pre> %array = malloc [4 x ubyte ] <i>; yields {[%4 x ubyte]*}:array</i>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001372
Chris Lattner261efe92003-11-25 01:02:51 +00001373 %size = <a
1374 href="#i_add">add</a> uint 2, 2 <i>; yields {uint}:size = uint 4</i>
Chris Lattner7faa8832002-04-14 06:13:44 +00001375 %array1 = malloc ubyte, uint 4 <i>; yields {ubyte*}:array1</i>
1376 %array2 = malloc [12 x ubyte], uint %size <i>; yields {[12 x ubyte]*}:array2</i>
Chris Lattner00950542001-06-06 20:29:01 +00001377</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001378</div>
Chris Lattner00950542001-06-06 20:29:01 +00001379<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001380<div class="doc_subsubsection"> <a name="i_free">'<tt>free</tt>'
1381Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001382<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001383<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001384<pre> free &lt;type&gt; &lt;value&gt; <i>; yields {void}</i>
Chris Lattner00950542001-06-06 20:29:01 +00001385</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001386<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001387<p>The '<tt>free</tt>' instruction returns memory back to the unused
1388memory heap, to be reallocated in the future.</p>
1389<p> </p>
Chris Lattner00950542001-06-06 20:29:01 +00001390<h5>Arguments:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001391<p>'<tt>value</tt>' shall be a pointer value that points to a value
1392that was allocated with the '<tt><a href="#i_malloc">malloc</a></tt>'
1393instruction.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001394<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001395<p>Access to the memory pointed to by the pointer is not longer defined
1396after this instruction executes.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001397<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001398<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 +00001399 free [4 x ubyte]* %array
1400</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001401</div>
Chris Lattner00950542001-06-06 20:29:01 +00001402<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001403<div class="doc_subsubsection"> <a name="i_alloca">'<tt>alloca</tt>'
1404Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001405<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001406<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001407<pre> &lt;result&gt; = alloca &lt;type&gt;, uint &lt;NumElements&gt; <i>; yields {type*}:result</i>
Chris Lattner7faa8832002-04-14 06:13:44 +00001408 &lt;result&gt; = alloca &lt;type&gt; <i>; yields {type*}:result</i>
Chris Lattner00950542001-06-06 20:29:01 +00001409</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001410<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001411<p>The '<tt>alloca</tt>' instruction allocates memory on the current
1412stack frame of the procedure that is live until the current function
1413returns to its caller.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001414<h5>Arguments:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001415<p>The the '<tt>alloca</tt>' instruction allocates <tt>sizeof(&lt;type&gt;)*NumElements</tt>
1416bytes of memory on the runtime stack, returning a pointer of the
1417appropriate type to the program. The second form of the instruction is
1418a shorter version of the first that defaults to allocating one element.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001419<p>'<tt>type</tt>' may be any sized type.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001420<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001421<p>Memory is allocated, a pointer is returned. '<tt>alloca</tt>'d
1422memory is automatically released when the function returns. The '<tt>alloca</tt>'
1423instruction is commonly used to represent automatic variables that must
1424have an address available. When the function returns (either with the <tt><a
1425 href="#i_ret">ret</a></tt> or <tt><a href="#i_invoke">invoke</a></tt>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001426instructions), the memory is reclaimed.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001427<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001428<pre> %ptr = alloca int <i>; yields {int*}:ptr</i>
Chris Lattner7faa8832002-04-14 06:13:44 +00001429 %ptr = alloca int, uint 4 <i>; yields {int*}:ptr</i>
Chris Lattner00950542001-06-06 20:29:01 +00001430</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001431</div>
Chris Lattner00950542001-06-06 20:29:01 +00001432<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001433<div class="doc_subsubsection"> <a name="i_load">'<tt>load</tt>'
1434Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001435<div class="doc_text">
Chris Lattner2b7d3202002-05-06 03:03:22 +00001436<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001437<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 +00001438<h5>Overview:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001439<p>The '<tt>load</tt>' instruction is used to read from memory.</p>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001440<h5>Arguments:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001441<p>The argument to the '<tt>load</tt>' instruction specifies the memory
1442address to load from. The pointer must point to a <a
Chris Lattnere53e5082004-06-03 22:57:15 +00001443 href="#t_firstclass">first class</a> type. If the <tt>load</tt> is
Chris Lattner261efe92003-11-25 01:02:51 +00001444marked as <tt>volatile</tt> then the optimizer is not allowed to modify
1445the number or order of execution of this <tt>load</tt> with other
1446volatile <tt>load</tt> and <tt><a href="#i_store">store</a></tt>
1447instructions. </p>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001448<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001449<p>The location of memory pointed to is loaded.</p>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001450<h5>Examples:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001451<pre> %ptr = <a href="#i_alloca">alloca</a> int <i>; yields {int*}:ptr</i>
1452 <a
1453 href="#i_store">store</a> int 3, int* %ptr <i>; yields {void}</i>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001454 %val = load int* %ptr <i>; yields {int}:val = int 3</i>
1455</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001456</div>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001457<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001458<div class="doc_subsubsection"> <a name="i_store">'<tt>store</tt>'
1459Instruction</a> </div>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001460<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001461<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 +00001462 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 +00001463</pre>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001464<h5>Overview:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001465<p>The '<tt>store</tt>' instruction is used to write to memory.</p>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001466<h5>Arguments:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001467<p>There are two arguments to the '<tt>store</tt>' instruction: a value
1468to store and an address to store it into. The type of the '<tt>&lt;pointer&gt;</tt>'
1469operand must be a pointer to the type of the '<tt>&lt;value&gt;</tt>'
1470operand. If the <tt>store</tt> is marked as <tt>volatile</tt> then the
1471optimizer is not allowed to modify the number or order of execution of
1472this <tt>store</tt> with other volatile <tt>load</tt> and <tt><a
1473 href="#i_store">store</a></tt> instructions.</p>
1474<h5>Semantics:</h5>
1475<p>The contents of memory are updated to contain '<tt>&lt;value&gt;</tt>'
1476at the location specified by the '<tt>&lt;pointer&gt;</tt>' operand.</p>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001477<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001478<pre> %ptr = <a href="#i_alloca">alloca</a> int <i>; yields {int*}:ptr</i>
1479 <a
1480 href="#i_store">store</a> int 3, int* %ptr <i>; yields {void}</i>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001481 %val = load int* %ptr <i>; yields {int}:val = int 3</i>
1482</pre>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001483<!-- _______________________________________________________________________ -->
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001484<div class="doc_subsubsection">
1485 <a name="i_getelementptr">'<tt>getelementptr</tt>' Instruction</a>
1486</div>
1487
Misha Brukman9d0919f2003-11-08 01:05:38 +00001488<div class="doc_text">
Chris Lattner7faa8832002-04-14 06:13:44 +00001489<h5>Syntax:</h5>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001490<pre>
1491 &lt;result&gt; = getelementptr &lt;ty&gt;* &lt;ptrval&gt;{, &lt;ty&gt; &lt;idx&gt;}*
1492</pre>
1493
Chris Lattner7faa8832002-04-14 06:13:44 +00001494<h5>Overview:</h5>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001495
1496<p>
1497The '<tt>getelementptr</tt>' instruction is used to get the address of a
1498subelement of an aggregate data structure.</p>
1499
Chris Lattner7faa8832002-04-14 06:13:44 +00001500<h5>Arguments:</h5>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001501
1502<p>This instruction takes a list of integer constants that indicate what
1503elements of the aggregate object to index to. The actual types of the arguments
1504provided depend on the type of the first pointer argument. The
1505'<tt>getelementptr</tt>' instruction is used to index down through the type
1506levels of a structure. When indexing into a structure, only <tt>uint</tt>
1507integer constants are allowed. When indexing into an array or pointer
1508<tt>int</tt> and <tt>long</tt> indexes are allowed of any sign.</p>
1509
Chris Lattner261efe92003-11-25 01:02:51 +00001510<p>For example, let's consider a C code fragment and how it gets
1511compiled to LLVM:</p>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001512
1513<pre>
1514 struct RT {
1515 char A;
1516 int B[10][20];
1517 char C;
1518 };
1519 struct ST {
1520 int X;
1521 double Y;
1522 struct RT Z;
1523 };
1524
1525 int *foo(struct ST *s) {
1526 return &amp;s[1].Z.B[5][13];
1527 }
1528</pre>
1529
Misha Brukman9d0919f2003-11-08 01:05:38 +00001530<p>The LLVM code generated by the GCC frontend is:</p>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001531
1532<pre>
1533 %RT = type { sbyte, [10 x [20 x int]], sbyte }
1534 %ST = type { int, double, %RT }
1535
Brian Gaeke7283e7c2004-07-02 21:08:14 +00001536 implementation
1537
1538 int* %foo(%ST* %s) {
1539 entry:
1540 %reg = getelementptr %ST* %s, int 1, uint 2, uint 1, int 5, int 13
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001541 ret int* %reg
1542 }
1543</pre>
1544
Chris Lattner7faa8832002-04-14 06:13:44 +00001545<h5>Semantics:</h5>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001546
1547<p>The index types specified for the '<tt>getelementptr</tt>' instruction depend
Chris Lattnere53e5082004-06-03 22:57:15 +00001548on the pointer type that is being index into. <a href="#t_pointer">Pointer</a>
1549and <a href="#t_array">array</a> types require <tt>uint</tt>, <tt>int</tt>,
1550<tt>ulong</tt>, or <tt>long</tt> values, and <a href="#t_struct">structure</a>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001551types require <tt>uint</tt> <b>constants</b>.</p>
1552
Misha Brukman9d0919f2003-11-08 01:05:38 +00001553<p>In the example above, the first index is indexing into the '<tt>%ST*</tt>'
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001554type, which is a pointer, yielding a '<tt>%ST</tt>' = '<tt>{ int, double, %RT
1555}</tt>' type, a structure. The second index indexes into the third element of
1556the structure, yielding a '<tt>%RT</tt>' = '<tt>{ sbyte, [10 x [20 x int]],
1557sbyte }</tt>' type, another structure. The third index indexes into the second
1558element of the structure, yielding a '<tt>[10 x [20 x int]]</tt>' type, an
1559array. The two dimensions of the array are subscripted into, yielding an
1560'<tt>int</tt>' type. The '<tt>getelementptr</tt>' instruction return a pointer
1561to this element, thus computing a value of '<tt>int*</tt>' type.</p>
1562
Chris Lattner261efe92003-11-25 01:02:51 +00001563<p>Note that it is perfectly legal to index partially through a
1564structure, returning a pointer to an inner element. Because of this,
1565the LLVM code for the given testcase is equivalent to:</p>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001566
1567<pre>
1568 int* "foo"(%ST* %s) {
1569 %t1 = getelementptr %ST* %s, int 1 <i>; yields %ST*:%t1</i>
1570 %t2 = getelementptr %ST* %t1, int 0, uint 2 <i>; yields %RT*:%t2</i>
1571 %t3 = getelementptr %RT* %t2, int 0, uint 1 <i>; yields [10 x [20 x int]]*:%t3</i>
1572 %t4 = getelementptr [10 x [20 x int]]* %t3, int 0, int 5 <i>; yields [20 x int]*:%t4</i>
1573 %t5 = getelementptr [20 x int]* %t4, int 0, int 13 <i>; yields int*:%t5</i>
1574 ret int* %t5
1575 }
Chris Lattner6536cfe2002-05-06 22:08:29 +00001576</pre>
Chris Lattner7faa8832002-04-14 06:13:44 +00001577<h5>Example:</h5>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001578<pre>
1579 <i>; yields [12 x ubyte]*:aptr</i>
1580 %aptr = getelementptr {int, [12 x ubyte]}* %sptr, long 0, uint 1
1581</pre>
1582
1583</div>
Chris Lattner00950542001-06-06 20:29:01 +00001584<!-- ======================================================================= -->
Chris Lattner261efe92003-11-25 01:02:51 +00001585<div class="doc_subsection"> <a name="otherops">Other Operations</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001586<div class="doc_text">
John Criswell4457dc92004-04-09 16:48:45 +00001587<p>The instructions in this category are the "miscellaneous"
Chris Lattner261efe92003-11-25 01:02:51 +00001588instructions, which defy better classification.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001589</div>
Chris Lattner00950542001-06-06 20:29:01 +00001590<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001591<div class="doc_subsubsection"> <a name="i_phi">'<tt>phi</tt>'
1592Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001593<div class="doc_text">
Chris Lattner33ba0d92001-07-09 00:26:23 +00001594<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001595<pre> &lt;result&gt; = phi &lt;ty&gt; [ &lt;val0&gt;, &lt;label0&gt;], ...<br></pre>
Chris Lattner33ba0d92001-07-09 00:26:23 +00001596<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001597<p>The '<tt>phi</tt>' instruction is used to implement the &#966; node in
1598the SSA graph representing the function.</p>
Chris Lattner33ba0d92001-07-09 00:26:23 +00001599<h5>Arguments:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001600<p>The type of the incoming values are specified with the first type
1601field. After this, the '<tt>phi</tt>' instruction takes a list of pairs
1602as arguments, with one pair for each predecessor basic block of the
1603current block. Only values of <a href="#t_firstclass">first class</a>
1604type may be used as the value arguments to the PHI node. Only labels
1605may be used as the label arguments.</p>
1606<p>There must be no non-phi instructions between the start of a basic
1607block and the PHI instructions: i.e. PHI instructions must be first in
1608a basic block.</p>
Chris Lattner33ba0d92001-07-09 00:26:23 +00001609<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001610<p>At runtime, the '<tt>phi</tt>' instruction logically takes on the
1611value specified by the parameter, depending on which basic block we
1612came from in the last <a href="#terminators">terminator</a> instruction.</p>
Chris Lattner6536cfe2002-05-06 22:08:29 +00001613<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001614<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 +00001615</div>
Chris Lattnercc37aae2004-03-12 05:50:16 +00001616
Chris Lattner6536cfe2002-05-06 22:08:29 +00001617<!-- _______________________________________________________________________ -->
Chris Lattnercc37aae2004-03-12 05:50:16 +00001618<div class="doc_subsubsection">
1619 <a name="i_cast">'<tt>cast .. to</tt>' Instruction</a>
1620</div>
1621
Misha Brukman9d0919f2003-11-08 01:05:38 +00001622<div class="doc_text">
Chris Lattnercc37aae2004-03-12 05:50:16 +00001623
Chris Lattner6536cfe2002-05-06 22:08:29 +00001624<h5>Syntax:</h5>
Chris Lattnercc37aae2004-03-12 05:50:16 +00001625
1626<pre>
1627 &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 +00001628</pre>
Chris Lattnercc37aae2004-03-12 05:50:16 +00001629
Chris Lattner6536cfe2002-05-06 22:08:29 +00001630<h5>Overview:</h5>
Chris Lattnercc37aae2004-03-12 05:50:16 +00001631
1632<p>
1633The '<tt>cast</tt>' instruction is used as the primitive means to convert
1634integers to floating point, change data type sizes, and break type safety (by
1635casting pointers).
1636</p>
1637
1638
Chris Lattner6536cfe2002-05-06 22:08:29 +00001639<h5>Arguments:</h5>
Chris Lattnercc37aae2004-03-12 05:50:16 +00001640
1641<p>
1642The '<tt>cast</tt>' instruction takes a value to cast, which must be a first
1643class value, and a type to cast it to, which must also be a <a
1644href="#t_firstclass">first class</a> type.
1645</p>
1646
Chris Lattner6536cfe2002-05-06 22:08:29 +00001647<h5>Semantics:</h5>
Chris Lattnercc37aae2004-03-12 05:50:16 +00001648
1649<p>
1650This instruction follows the C rules for explicit casts when determining how the
1651data being cast must change to fit in its new container.
1652</p>
1653
1654<p>
1655When casting to bool, any value that would be considered true in the context of
1656a C '<tt>if</tt>' condition is converted to the boolean '<tt>true</tt>' values,
1657all else are '<tt>false</tt>'.
1658</p>
1659
1660<p>
1661When extending an integral value from a type of one signness to another (for
1662example '<tt>sbyte</tt>' to '<tt>ulong</tt>'), the value is sign-extended if the
1663<b>source</b> value is signed, and zero-extended if the source value is
1664unsigned. <tt>bool</tt> values are always zero extended into either zero or
1665one.
1666</p>
1667
Chris Lattner33ba0d92001-07-09 00:26:23 +00001668<h5>Example:</h5>
Chris Lattnercc37aae2004-03-12 05:50:16 +00001669
1670<pre>
1671 %X = cast int 257 to ubyte <i>; yields ubyte:1</i>
Chris Lattner7bae3952002-06-25 18:03:17 +00001672 %Y = cast int 123 to bool <i>; yields bool:true</i>
Chris Lattner33ba0d92001-07-09 00:26:23 +00001673</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001674</div>
Chris Lattnercc37aae2004-03-12 05:50:16 +00001675
1676<!-- _______________________________________________________________________ -->
1677<div class="doc_subsubsection">
1678 <a name="i_select">'<tt>select</tt>' Instruction</a>
1679</div>
1680
1681<div class="doc_text">
1682
1683<h5>Syntax:</h5>
1684
1685<pre>
1686 &lt;result&gt; = select bool &lt;cond&gt;, &lt;ty&gt; &lt;val1&gt;, &lt;ty&gt; &lt;val2&gt; <i>; yields ty</i>
1687</pre>
1688
1689<h5>Overview:</h5>
1690
1691<p>
1692The '<tt>select</tt>' instruction is used to choose one value based on a
1693condition, without branching.
1694</p>
1695
1696
1697<h5>Arguments:</h5>
1698
1699<p>
1700The '<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.
1701</p>
1702
1703<h5>Semantics:</h5>
1704
1705<p>
1706If the boolean condition evaluates to true, the instruction returns the first
1707value argument, otherwise it returns the second value argument.
1708</p>
1709
1710<h5>Example:</h5>
1711
1712<pre>
1713 %X = select bool true, ubyte 17, ubyte 42 <i>; yields ubyte:17</i>
1714</pre>
1715</div>
1716
1717
1718
1719
1720
Chris Lattner33ba0d92001-07-09 00:26:23 +00001721<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001722<div class="doc_subsubsection"> <a name="i_call">'<tt>call</tt>'
1723Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001724<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001725<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001726<pre> &lt;result&gt; = call &lt;ty&gt;* &lt;fnptrval&gt;(&lt;param list&gt;)<br></pre>
Chris Lattner00950542001-06-06 20:29:01 +00001727<h5>Overview:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001728<p>The '<tt>call</tt>' instruction represents a simple function call.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001729<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001730<p>This instruction requires several arguments:</p>
Chris Lattner6536cfe2002-05-06 22:08:29 +00001731<ol>
Chris Lattner261efe92003-11-25 01:02:51 +00001732 <li>
1733 <p>'<tt>ty</tt>': shall be the signature of the pointer to function
1734value being invoked. The argument types must match the types implied
1735by this signature.</p>
1736 </li>
1737 <li>
1738 <p>'<tt>fnptrval</tt>': An LLVM value containing a pointer to a
1739function to be invoked. In most cases, this is a direct function
1740invocation, but indirect <tt>call</tt>s are just as possible,
1741calling an arbitrary pointer to function values.</p>
1742 </li>
1743 <li>
1744 <p>'<tt>function args</tt>': argument list whose types match the
1745function signature argument types. If the function signature
1746indicates the function accepts a variable number of arguments, the
1747extra arguments can be specified.</p>
1748 </li>
Chris Lattner6536cfe2002-05-06 22:08:29 +00001749</ol>
Chris Lattner00950542001-06-06 20:29:01 +00001750<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001751<p>The '<tt>call</tt>' instruction is used to cause control flow to
1752transfer to a specified function, with its incoming arguments bound to
1753the specified values. Upon a '<tt><a href="#i_ret">ret</a></tt>'
1754instruction in the called function, control flow continues with the
1755instruction after the function call, and the return value of the
1756function is bound to the result argument. This is a simpler case of
1757the <a href="#i_invoke">invoke</a> instruction.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001758<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001759<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 +00001760</div>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001761<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001762<div class="doc_subsubsection"> <a name="i_vanext">'<tt>vanext</tt>'
1763Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001764<div class="doc_text">
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001765<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001766<pre> &lt;resultarglist&gt; = vanext &lt;va_list&gt; &lt;arglist&gt;, &lt;argty&gt;<br></pre>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001767<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001768<p>The '<tt>vanext</tt>' instruction is used to access arguments passed
1769through the "variable argument" area of a function call. It is used to
1770implement the <tt>va_arg</tt> macro in C.</p>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001771<h5>Arguments:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001772<p>This instruction takes a <tt>valist</tt> value and the type of the
1773argument. It returns another <tt>valist</tt>.</p>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001774<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001775<p>The '<tt>vanext</tt>' instruction advances the specified <tt>valist</tt>
1776past an argument of the specified type. In conjunction with the <a
1777 href="#i_vaarg"><tt>vaarg</tt></a> instruction, it is used to implement
1778the <tt>va_arg</tt> macro available in C. For more information, see
1779the variable argument handling <a href="#int_varargs">Intrinsic
1780Functions</a>.</p>
1781<p>It is legal for this instruction to be called in a function which
1782does not take a variable number of arguments, for example, the <tt>vfprintf</tt>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001783function.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001784<p><tt>vanext</tt> is an LLVM instruction instead of an <a
Chris Lattner261efe92003-11-25 01:02:51 +00001785 href="#intrinsics">intrinsic function</a> because it takes an type as
1786an argument.</p>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001787<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001788<p>See the <a href="#int_varargs">variable argument processing</a>
1789section.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001790</div>
Chris Lattner8d1a81d2003-10-18 05:51:36 +00001791<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001792<div class="doc_subsubsection"> <a name="i_vaarg">'<tt>vaarg</tt>'
1793Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001794<div class="doc_text">
Chris Lattner8d1a81d2003-10-18 05:51:36 +00001795<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001796<pre> &lt;resultval&gt; = vaarg &lt;va_list&gt; &lt;arglist&gt;, &lt;argty&gt;<br></pre>
Chris Lattner8d1a81d2003-10-18 05:51:36 +00001797<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001798<p>The '<tt>vaarg</tt>' instruction is used to access arguments passed
1799through the "variable argument" area of a function call. It is used to
1800implement the <tt>va_arg</tt> macro in C.</p>
Chris Lattner8d1a81d2003-10-18 05:51:36 +00001801<h5>Arguments:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001802<p>This instruction takes a <tt>valist</tt> value and the type of the
1803argument. It returns a value of the specified argument type.</p>
Chris Lattner8d1a81d2003-10-18 05:51:36 +00001804<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001805<p>The '<tt>vaarg</tt>' instruction loads an argument of the specified
1806type from the specified <tt>va_list</tt>. In conjunction with the <a
1807 href="#i_vanext"><tt>vanext</tt></a> instruction, it is used to
1808implement the <tt>va_arg</tt> macro available in C. For more
1809information, see the variable argument handling <a href="#int_varargs">Intrinsic
1810Functions</a>.</p>
1811<p>It is legal for this instruction to be called in a function which
1812does not take a variable number of arguments, for example, the <tt>vfprintf</tt>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001813function.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001814<p><tt>vaarg</tt> is an LLVM instruction instead of an <a
Chris Lattner261efe92003-11-25 01:02:51 +00001815 href="#intrinsics">intrinsic function</a> because it takes an type as
1816an argument.</p>
Chris Lattner8d1a81d2003-10-18 05:51:36 +00001817<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001818<p>See the <a href="#int_varargs">variable argument processing</a>
1819section.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001820</div>
Chris Lattner8ff75902004-01-06 05:31:32 +00001821
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001822<!-- *********************************************************************** -->
Chris Lattner261efe92003-11-25 01:02:51 +00001823<div class="doc_section"> <a name="intrinsics">Intrinsic Functions</a> </div>
1824<!-- *********************************************************************** -->
Chris Lattner8ff75902004-01-06 05:31:32 +00001825
Misha Brukman9d0919f2003-11-08 01:05:38 +00001826<div class="doc_text">
Chris Lattner33aec9e2004-02-12 17:01:32 +00001827
1828<p>LLVM supports the notion of an "intrinsic function". These functions have
1829well known names and semantics, and are required to follow certain
1830restrictions. Overall, these instructions represent an extension mechanism for
1831the LLVM language that does not require changing all of the transformations in
1832LLVM to add to the language (or the bytecode reader/writer, the parser,
1833etc...).</p>
1834
1835<p>Intrinsic function names must all start with an "<tt>llvm.</tt>" prefix, this
1836prefix is reserved in LLVM for intrinsic names, thus functions may not be named
1837this. Intrinsic functions must always be external functions: you cannot define
1838the body of intrinsic functions. Intrinsic functions may only be used in call
1839or invoke instructions: it is illegal to take the address of an intrinsic
1840function. Additionally, because intrinsic functions are part of the LLVM
1841language, it is required that they all be documented here if any are added.</p>
1842
1843
1844<p>
1845Adding an intrinsic to LLVM is straight-forward if it is possible to express the
1846concept in LLVM directly (ie, code generator support is not _required_). To do
1847this, extend the default implementation of the IntrinsicLowering class to handle
1848the intrinsic. Code generators use this class to lower intrinsics they do not
1849understand to raw LLVM instructions that they do.
1850</p>
1851
Misha Brukman9d0919f2003-11-08 01:05:38 +00001852</div>
Chris Lattner8ff75902004-01-06 05:31:32 +00001853
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001854<!-- ======================================================================= -->
Chris Lattner8ff75902004-01-06 05:31:32 +00001855<div class="doc_subsection">
1856 <a name="int_varargs">Variable Argument Handling Intrinsics</a>
1857</div>
1858
Misha Brukman9d0919f2003-11-08 01:05:38 +00001859<div class="doc_text">
Chris Lattnerd7923912004-05-23 21:06:01 +00001860
Misha Brukman9d0919f2003-11-08 01:05:38 +00001861<p>Variable argument support is defined in LLVM with the <a
Chris Lattner261efe92003-11-25 01:02:51 +00001862 href="#i_vanext"><tt>vanext</tt></a> instruction and these three
1863intrinsic functions. These functions are related to the similarly
1864named macros defined in the <tt>&lt;stdarg.h&gt;</tt> header file.</p>
Chris Lattnerd7923912004-05-23 21:06:01 +00001865
Chris Lattner261efe92003-11-25 01:02:51 +00001866<p>All of these functions operate on arguments that use a
1867target-specific value type "<tt>va_list</tt>". The LLVM assembly
1868language reference manual does not define what this type is, so all
1869transformations should be prepared to handle intrinsics with any type
1870used.</p>
Chris Lattnerd7923912004-05-23 21:06:01 +00001871
Misha Brukman9d0919f2003-11-08 01:05:38 +00001872<p>This example shows how the <a href="#i_vanext"><tt>vanext</tt></a>
Chris Lattner261efe92003-11-25 01:02:51 +00001873instruction and the variable argument handling intrinsic functions are
1874used.</p>
Chris Lattnerd7923912004-05-23 21:06:01 +00001875
Chris Lattner33aec9e2004-02-12 17:01:32 +00001876<pre>
1877int %test(int %X, ...) {
1878 ; Initialize variable argument processing
1879 %ap = call sbyte* %<a href="#i_va_start">llvm.va_start</a>()
1880
1881 ; Read a single integer argument
1882 %tmp = vaarg sbyte* %ap, int
1883
1884 ; Advance to the next argument
1885 %ap2 = vanext sbyte* %ap, int
1886
1887 ; Demonstrate usage of llvm.va_copy and llvm.va_end
1888 %aq = call sbyte* %<a href="#i_va_copy">llvm.va_copy</a>(sbyte* %ap2)
1889 call void %<a href="#i_va_end">llvm.va_end</a>(sbyte* %aq)
1890
1891 ; Stop processing of arguments.
1892 call void %<a href="#i_va_end">llvm.va_end</a>(sbyte* %ap2)
1893 ret int %tmp
1894}
1895</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001896</div>
Chris Lattner8ff75902004-01-06 05:31:32 +00001897
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001898<!-- _______________________________________________________________________ -->
Chris Lattner8ff75902004-01-06 05:31:32 +00001899<div class="doc_subsubsection">
1900 <a name="i_va_start">'<tt>llvm.va_start</tt>' Intrinsic</a>
1901</div>
1902
1903
Misha Brukman9d0919f2003-11-08 01:05:38 +00001904<div class="doc_text">
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001905<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001906<pre> call va_list ()* %llvm.va_start()<br></pre>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001907<h5>Overview:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001908<p>The '<tt>llvm.va_start</tt>' intrinsic returns a new <tt>&lt;arglist&gt;</tt>
1909for subsequent use by the variable argument intrinsics.</p>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001910<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001911<p>The '<tt>llvm.va_start</tt>' intrinsic works just like the <tt>va_start</tt>
Chris Lattner261efe92003-11-25 01:02:51 +00001912macro available in C. In a target-dependent way, it initializes and
1913returns a <tt>va_list</tt> element, so that the next <tt>vaarg</tt>
1914will produce the first variable argument passed to the function. Unlike
1915the C <tt>va_start</tt> macro, this intrinsic does not need to know the
1916last argument of the function, the compiler can figure that out.</p>
1917<p>Note that this intrinsic function is only legal to be called from
1918within the body of a variable argument function.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001919</div>
Chris Lattner8ff75902004-01-06 05:31:32 +00001920
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001921<!-- _______________________________________________________________________ -->
Chris Lattner8ff75902004-01-06 05:31:32 +00001922<div class="doc_subsubsection">
1923 <a name="i_va_end">'<tt>llvm.va_end</tt>' Intrinsic</a>
1924</div>
1925
Misha Brukman9d0919f2003-11-08 01:05:38 +00001926<div class="doc_text">
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001927<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001928<pre> call void (va_list)* %llvm.va_end(va_list &lt;arglist&gt;)<br></pre>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001929<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001930<p>The '<tt>llvm.va_end</tt>' intrinsic destroys <tt>&lt;arglist&gt;</tt>
1931which has been initialized previously with <tt><a href="#i_va_start">llvm.va_start</a></tt>
1932or <tt><a href="#i_va_copy">llvm.va_copy</a></tt>.</p>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001933<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001934<p>The argument is a <tt>va_list</tt> to destroy.</p>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001935<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001936<p>The '<tt>llvm.va_end</tt>' intrinsic works just like the <tt>va_end</tt>
Chris Lattner261efe92003-11-25 01:02:51 +00001937macro available in C. In a target-dependent way, it destroys the <tt>va_list</tt>.
1938Calls to <a href="#i_va_start"><tt>llvm.va_start</tt></a> and <a
1939 href="#i_va_copy"><tt>llvm.va_copy</tt></a> must be matched exactly
1940with calls to <tt>llvm.va_end</tt>.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001941</div>
Chris Lattner8ff75902004-01-06 05:31:32 +00001942
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001943<!-- _______________________________________________________________________ -->
Chris Lattner8ff75902004-01-06 05:31:32 +00001944<div class="doc_subsubsection">
1945 <a name="i_va_copy">'<tt>llvm.va_copy</tt>' Intrinsic</a>
1946</div>
1947
Misha Brukman9d0919f2003-11-08 01:05:38 +00001948<div class="doc_text">
Chris Lattnerd7923912004-05-23 21:06:01 +00001949
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001950<h5>Syntax:</h5>
Chris Lattnerd7923912004-05-23 21:06:01 +00001951
1952<pre>
1953 call va_list (va_list)* %llvm.va_copy(va_list &lt;destarglist&gt;)
1954</pre>
1955
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001956<h5>Overview:</h5>
Chris Lattnerd7923912004-05-23 21:06:01 +00001957
1958<p>The '<tt>llvm.va_copy</tt>' intrinsic copies the current argument position
1959from the source argument list to the destination argument list.</p>
1960
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001961<h5>Arguments:</h5>
Chris Lattnerd7923912004-05-23 21:06:01 +00001962
Misha Brukman9d0919f2003-11-08 01:05:38 +00001963<p>The argument is the <tt>va_list</tt> to copy.</p>
Chris Lattnerd7923912004-05-23 21:06:01 +00001964
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00001965<h5>Semantics:</h5>
Chris Lattnerd7923912004-05-23 21:06:01 +00001966
Misha Brukman9d0919f2003-11-08 01:05:38 +00001967<p>The '<tt>llvm.va_copy</tt>' intrinsic works just like the <tt>va_copy</tt>
Chris Lattnerd7923912004-05-23 21:06:01 +00001968macro available in C. In a target-dependent way, it copies the source
1969<tt>va_list</tt> element into the returned list. This intrinsic is necessary
Chris Lattnerfcd37252004-06-21 22:52:48 +00001970because the <tt><a href="#i_va_start">llvm.va_start</a></tt> intrinsic may be
Chris Lattnerd7923912004-05-23 21:06:01 +00001971arbitrarily complex and require memory allocation, for example.</p>
1972
Misha Brukman9d0919f2003-11-08 01:05:38 +00001973</div>
Chris Lattner8ff75902004-01-06 05:31:32 +00001974
Chris Lattner33aec9e2004-02-12 17:01:32 +00001975<!-- ======================================================================= -->
1976<div class="doc_subsection">
Chris Lattnerd7923912004-05-23 21:06:01 +00001977 <a name="int_gc">Accurate Garbage Collection Intrinsics</a>
1978</div>
1979
1980<div class="doc_text">
1981
1982<p>
1983LLVM support for <a href="GarbageCollection.html">Accurate Garbage
1984Collection</a> requires the implementation and generation of these intrinsics.
1985These intrinsics allow identification of <a href="#i_gcroot">GC roots on the
1986stack</a>, as well as garbage collector implementations that require <a
1987href="#i_gcread">read</a> and <a href="#i_gcwrite">write</a> barriers.
1988Front-ends for type-safe garbage collected languages should generate these
1989intrinsics to make use of the LLVM garbage collectors. For more details, see <a
1990href="GarbageCollection.html">Accurate Garbage Collection with LLVM</a>.
1991</p>
1992</div>
1993
1994<!-- _______________________________________________________________________ -->
1995<div class="doc_subsubsection">
1996 <a name="i_gcroot">'<tt>llvm.gcroot</tt>' Intrinsic</a>
1997</div>
1998
1999<div class="doc_text">
2000
2001<h5>Syntax:</h5>
2002
2003<pre>
2004 call void (&lt;ty&gt;**, &lt;ty2&gt;*)* %llvm.gcroot(&lt;ty&gt;** %ptrloc, &lt;ty2&gt;* %metadata)
2005</pre>
2006
2007<h5>Overview:</h5>
2008
2009<p>The '<tt>llvm.gcroot</tt>' intrinsic declares the existance of a GC root to
2010the code generator, and allows some metadata to be associated with it.</p>
2011
2012<h5>Arguments:</h5>
2013
2014<p>The first argument specifies the address of a stack object that contains the
2015root pointer. The second pointer (which must be either a constant or a global
2016value address) contains the meta-data to be associated with the root.</p>
2017
2018<h5>Semantics:</h5>
2019
2020<p>At runtime, a call to this intrinsics stores a null pointer into the "ptrloc"
2021location. At compile-time, the code generator generates information to allow
2022the runtime to find the pointer at GC safe points.
2023</p>
2024
2025</div>
2026
2027
2028<!-- _______________________________________________________________________ -->
2029<div class="doc_subsubsection">
2030 <a name="i_gcread">'<tt>llvm.gcread</tt>' Intrinsic</a>
2031</div>
2032
2033<div class="doc_text">
2034
2035<h5>Syntax:</h5>
2036
2037<pre>
2038 call sbyte* (sbyte**)* %llvm.gcread(sbyte** %Ptr)
2039</pre>
2040
2041<h5>Overview:</h5>
2042
2043<p>The '<tt>llvm.gcread</tt>' intrinsic identifies reads of references from heap
2044locations, allowing garbage collector implementations that require read
2045barriers.</p>
2046
2047<h5>Arguments:</h5>
2048
2049<p>The argument is the address to read from, which should be an address
2050allocated from the garbage collector.</p>
2051
2052<h5>Semantics:</h5>
2053
2054<p>The '<tt>llvm.gcread</tt>' intrinsic has the same semantics as a load
2055instruction, but may be replaced with substantially more complex code by the
2056garbage collector runtime, as needed.</p>
2057
2058</div>
2059
2060
2061<!-- _______________________________________________________________________ -->
2062<div class="doc_subsubsection">
2063 <a name="i_gcwrite">'<tt>llvm.gcwrite</tt>' Intrinsic</a>
2064</div>
2065
2066<div class="doc_text">
2067
2068<h5>Syntax:</h5>
2069
2070<pre>
2071 call void (sbyte*, sbyte**)* %llvm.gcwrite(sbyte* %P1, sbyte** %P2)
2072</pre>
2073
2074<h5>Overview:</h5>
2075
2076<p>The '<tt>llvm.gcwrite</tt>' intrinsic identifies writes of references to heap
2077locations, allowing garbage collector implementations that require write
2078barriers (such as generational or reference counting collectors).</p>
2079
2080<h5>Arguments:</h5>
2081
2082<p>The first argument is the reference to store, and the second is the heap
2083location to store to.</p>
2084
2085<h5>Semantics:</h5>
2086
2087<p>The '<tt>llvm.gcwrite</tt>' intrinsic has the same semantics as a store
2088instruction, but may be replaced with substantially more complex code by the
2089garbage collector runtime, as needed.</p>
2090
2091</div>
2092
2093
2094
2095<!-- ======================================================================= -->
2096<div class="doc_subsection">
Chris Lattner10610642004-02-14 04:08:35 +00002097 <a name="int_codegen">Code Generator Intrinsics</a>
2098</div>
2099
2100<div class="doc_text">
2101<p>
2102These intrinsics are provided by LLVM to expose special features that may only
2103be implemented with code generator support.
2104</p>
2105
2106</div>
2107
2108<!-- _______________________________________________________________________ -->
2109<div class="doc_subsubsection">
2110 <a name="i_returnaddress">'<tt>llvm.returnaddress</tt>' Intrinsic</a>
2111</div>
2112
2113<div class="doc_text">
2114
2115<h5>Syntax:</h5>
2116<pre>
2117 call void* ()* %llvm.returnaddress(uint &lt;level&gt;)
2118</pre>
2119
2120<h5>Overview:</h5>
2121
2122<p>
2123The '<tt>llvm.returnaddress</tt>' intrinsic returns a target-specific value
2124indicating the return address of the current function or one of its callers.
2125</p>
2126
2127<h5>Arguments:</h5>
2128
2129<p>
2130The argument to this intrinsic indicates which function to return the address
2131for. Zero indicates the calling function, one indicates its caller, etc. The
2132argument is <b>required</b> to be a constant integer value.
2133</p>
2134
2135<h5>Semantics:</h5>
2136
2137<p>
2138The '<tt>llvm.returnaddress</tt>' intrinsic either returns a pointer indicating
2139the return address of the specified call frame, or zero if it cannot be
2140identified. The value returned by this intrinsic is likely to be incorrect or 0
2141for arguments other than zero, so it should only be used for debugging purposes.
2142</p>
2143
2144<p>
2145Note that calling this intrinsic does not prevent function inlining or other
2146aggressive transformations, so the value returned may not that of the obvious
2147source-language caller.
2148</p>
2149</div>
2150
2151
2152<!-- _______________________________________________________________________ -->
2153<div class="doc_subsubsection">
2154 <a name="i_frameaddress">'<tt>llvm.frameaddress</tt>' Intrinsic</a>
2155</div>
2156
2157<div class="doc_text">
2158
2159<h5>Syntax:</h5>
2160<pre>
2161 call void* ()* %llvm.frameaddress(uint &lt;level&gt;)
2162</pre>
2163
2164<h5>Overview:</h5>
2165
2166<p>
2167The '<tt>llvm.frameaddress</tt>' intrinsic returns the target-specific frame
2168pointer value for the specified stack frame.
2169</p>
2170
2171<h5>Arguments:</h5>
2172
2173<p>
2174The argument to this intrinsic indicates which function to return the frame
2175pointer for. Zero indicates the calling function, one indicates its caller,
2176etc. The argument is <b>required</b> to be a constant integer value.
2177</p>
2178
2179<h5>Semantics:</h5>
2180
2181<p>
2182The '<tt>llvm.frameaddress</tt>' intrinsic either returns a pointer indicating
2183the frame address of the specified call frame, or zero if it cannot be
2184identified. The value returned by this intrinsic is likely to be incorrect or 0
2185for arguments other than zero, so it should only be used for debugging purposes.
2186</p>
2187
2188<p>
2189Note that calling this intrinsic does not prevent function inlining or other
2190aggressive transformations, so the value returned may not that of the obvious
2191source-language caller.
2192</p>
2193</div>
2194
John Criswell7123e272004-04-09 16:43:20 +00002195<!-- ======================================================================= -->
2196<div class="doc_subsection">
2197 <a name="int_os">Operating System Intrinsics</a>
2198</div>
2199
2200<div class="doc_text">
2201<p>
2202These intrinsics are provided by LLVM to support the implementation of
2203operating system level code.
2204</p>
2205
2206</div>
John Criswell183402a2004-04-12 15:02:16 +00002207
John Criswellcfd3bac2004-04-09 15:23:37 +00002208<!-- _______________________________________________________________________ -->
2209<div class="doc_subsubsection">
2210 <a name="i_readport">'<tt>llvm.readport</tt>' Intrinsic</a>
2211</div>
2212
2213<div class="doc_text">
2214
2215<h5>Syntax:</h5>
2216<pre>
John Criswell7123e272004-04-09 16:43:20 +00002217 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 +00002218</pre>
2219
2220<h5>Overview:</h5>
2221
2222<p>
John Criswell7123e272004-04-09 16:43:20 +00002223The '<tt>llvm.readport</tt>' intrinsic reads data from the specified hardware
2224I/O port.
John Criswellcfd3bac2004-04-09 15:23:37 +00002225</p>
2226
2227<h5>Arguments:</h5>
2228
2229<p>
John Criswell7123e272004-04-09 16:43:20 +00002230The argument to this intrinsic indicates the hardware I/O address from which
2231to read the data. The address is in the hardware I/O address namespace (as
2232opposed to being a memory location for memory mapped I/O).
John Criswellcfd3bac2004-04-09 15:23:37 +00002233</p>
2234
2235<h5>Semantics:</h5>
2236
2237<p>
John Criswell7123e272004-04-09 16:43:20 +00002238The '<tt>llvm.readport</tt>' intrinsic reads data from the hardware I/O port
2239specified by <i>address</i> and returns the value. The address and return
2240value must be integers, but the size is dependent upon the platform upon which
2241the program is code generated. For example, on x86, the address must be an
2242unsigned 16 bit value, and the return value must be 8, 16, or 32 bits.
John Criswellcfd3bac2004-04-09 15:23:37 +00002243</p>
2244
2245</div>
2246
2247<!-- _______________________________________________________________________ -->
2248<div class="doc_subsubsection">
2249 <a name="i_writeport">'<tt>llvm.writeport</tt>' Intrinsic</a>
2250</div>
2251
2252<div class="doc_text">
2253
2254<h5>Syntax:</h5>
2255<pre>
John Criswell7123e272004-04-09 16:43:20 +00002256 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 +00002257</pre>
2258
2259<h5>Overview:</h5>
2260
2261<p>
John Criswell7123e272004-04-09 16:43:20 +00002262The '<tt>llvm.writeport</tt>' intrinsic writes data to the specified hardware
2263I/O port.
John Criswellcfd3bac2004-04-09 15:23:37 +00002264</p>
2265
2266<h5>Arguments:</h5>
2267
2268<p>
John Criswell96db6fc2004-04-12 16:33:19 +00002269The first argument is the value to write to the I/O port.
John Criswellcfd3bac2004-04-09 15:23:37 +00002270</p>
2271
2272<p>
John Criswell96db6fc2004-04-12 16:33:19 +00002273The second argument indicates the hardware I/O address to which data should be
2274written. The address is in the hardware I/O address namespace (as opposed to
2275being a memory location for memory mapped I/O).
John Criswellcfd3bac2004-04-09 15:23:37 +00002276</p>
2277
2278<h5>Semantics:</h5>
2279
2280<p>
2281The '<tt>llvm.writeport</tt>' intrinsic writes <i>value</i> to the I/O port
2282specified by <i>address</i>. The address and value must be integers, but the
2283size is dependent upon the platform upon which the program is code generated.
John Criswell7123e272004-04-09 16:43:20 +00002284For example, on x86, the address must be an unsigned 16 bit value, and the
2285value written must be 8, 16, or 32 bits in length.
John Criswellcfd3bac2004-04-09 15:23:37 +00002286</p>
2287
2288</div>
Chris Lattner10610642004-02-14 04:08:35 +00002289
John Criswell183402a2004-04-12 15:02:16 +00002290<!-- _______________________________________________________________________ -->
2291<div class="doc_subsubsection">
2292 <a name="i_readio">'<tt>llvm.readio</tt>' Intrinsic</a>
2293</div>
2294
2295<div class="doc_text">
2296
2297<h5>Syntax:</h5>
2298<pre>
John Criswell96db6fc2004-04-12 16:33:19 +00002299 call &lt;result&gt; (&lt;ty&gt;*)* %llvm.readio (&lt;ty&gt; * &lt;pointer&gt;)
John Criswell183402a2004-04-12 15:02:16 +00002300</pre>
2301
2302<h5>Overview:</h5>
2303
2304<p>
2305The '<tt>llvm.readio</tt>' intrinsic reads data from a memory mapped I/O
2306address.
2307</p>
2308
2309<h5>Arguments:</h5>
2310
2311<p>
John Criswell96db6fc2004-04-12 16:33:19 +00002312The argument to this intrinsic is a pointer indicating the memory address from
2313which to read the data. The data must be a
2314<a href="#t_firstclass">first class</a> type.
John Criswell183402a2004-04-12 15:02:16 +00002315</p>
2316
2317<h5>Semantics:</h5>
2318
2319<p>
2320The '<tt>llvm.readio</tt>' intrinsic reads data from a memory mapped I/O
John Criswell96db6fc2004-04-12 16:33:19 +00002321location specified by <i>pointer</i> and returns the value. The argument must
2322be a pointer, and the return value must be a
2323<a href="#t_firstclass">first class</a> type. However, certain architectures
2324may not support I/O on all first class types. For example, 32 bit processors
2325may only support I/O on data types that are 32 bits or less.
John Criswell183402a2004-04-12 15:02:16 +00002326</p>
2327
2328<p>
John Criswell96db6fc2004-04-12 16:33:19 +00002329This intrinsic enforces an in-order memory model for llvm.readio and
2330llvm.writeio calls on machines that use dynamic scheduling. Dynamically
2331scheduled processors may execute loads and stores out of order, re-ordering at
2332run time accesses to memory mapped I/O registers. Using these intrinsics
2333ensures that accesses to memory mapped I/O registers occur in program order.
John Criswell183402a2004-04-12 15:02:16 +00002334</p>
2335
2336</div>
2337
2338<!-- _______________________________________________________________________ -->
2339<div class="doc_subsubsection">
2340 <a name="i_writeio">'<tt>llvm.writeio</tt>' Intrinsic</a>
2341</div>
2342
2343<div class="doc_text">
2344
2345<h5>Syntax:</h5>
2346<pre>
John Criswell96db6fc2004-04-12 16:33:19 +00002347 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 +00002348</pre>
2349
2350<h5>Overview:</h5>
2351
2352<p>
2353The '<tt>llvm.writeio</tt>' intrinsic writes data to the specified memory
2354mapped I/O address.
2355</p>
2356
2357<h5>Arguments:</h5>
2358
2359<p>
John Criswell96db6fc2004-04-12 16:33:19 +00002360The first argument is the value to write to the memory mapped I/O location.
2361The second argument is a pointer indicating the memory address to which the
2362data should be written.
John Criswell183402a2004-04-12 15:02:16 +00002363</p>
2364
2365<h5>Semantics:</h5>
2366
2367<p>
2368The '<tt>llvm.writeio</tt>' intrinsic writes <i>value</i> to the memory mapped
John Criswell96db6fc2004-04-12 16:33:19 +00002369I/O address specified by <i>pointer</i>. The value must be a
2370<a href="#t_firstclass">first class</a> type. However, certain architectures
2371may not support I/O on all first class types. For example, 32 bit processors
2372may only support I/O on data types that are 32 bits or less.
John Criswell183402a2004-04-12 15:02:16 +00002373</p>
2374
2375<p>
John Criswell96db6fc2004-04-12 16:33:19 +00002376This intrinsic enforces an in-order memory model for llvm.readio and
2377llvm.writeio calls on machines that use dynamic scheduling. Dynamically
2378scheduled processors may execute loads and stores out of order, re-ordering at
2379run time accesses to memory mapped I/O registers. Using these intrinsics
2380ensures that accesses to memory mapped I/O registers occur in program order.
John Criswell183402a2004-04-12 15:02:16 +00002381</p>
2382
2383</div>
2384
Chris Lattner10610642004-02-14 04:08:35 +00002385<!-- ======================================================================= -->
2386<div class="doc_subsection">
Chris Lattner33aec9e2004-02-12 17:01:32 +00002387 <a name="int_libc">Standard C Library Intrinsics</a>
2388</div>
2389
2390<div class="doc_text">
2391<p>
Chris Lattner10610642004-02-14 04:08:35 +00002392LLVM provides intrinsics for a few important standard C library functions.
2393These intrinsics allow source-language front-ends to pass information about the
2394alignment of the pointer arguments to the code generator, providing opportunity
2395for more efficient code generation.
Chris Lattner33aec9e2004-02-12 17:01:32 +00002396</p>
2397
2398</div>
2399
2400<!-- _______________________________________________________________________ -->
2401<div class="doc_subsubsection">
2402 <a name="i_memcpy">'<tt>llvm.memcpy</tt>' Intrinsic</a>
2403</div>
2404
2405<div class="doc_text">
2406
2407<h5>Syntax:</h5>
2408<pre>
2409 call void (sbyte*, sbyte*, uint, uint)* %llvm.memcpy(sbyte* &lt;dest&gt;, sbyte* &lt;src&gt;,
2410 uint &lt;len&gt;, uint &lt;align&gt;)
2411</pre>
2412
2413<h5>Overview:</h5>
2414
2415<p>
2416The '<tt>llvm.memcpy</tt>' intrinsic copies a block of memory from the source
2417location to the destination location.
2418</p>
2419
2420<p>
2421Note that, unlike the standard libc function, the <tt>llvm.memcpy</tt> intrinsic
2422does not return a value, and takes an extra alignment argument.
2423</p>
2424
2425<h5>Arguments:</h5>
2426
2427<p>
2428The first argument is a pointer to the destination, the second is a pointer to
2429the source. The third argument is an (arbitrarily sized) integer argument
2430specifying the number of bytes to copy, and the fourth argument is the alignment
2431of the source and destination locations.
2432</p>
2433
Chris Lattner3301ced2004-02-12 21:18:15 +00002434<p>
2435If the call to this intrinisic has an alignment value that is not 0 or 1, then
2436the caller guarantees that the size of the copy is a multiple of the alignment
2437and that both the source and destination pointers are aligned to that boundary.
2438</p>
2439
Chris Lattner33aec9e2004-02-12 17:01:32 +00002440<h5>Semantics:</h5>
2441
2442<p>
2443The '<tt>llvm.memcpy</tt>' intrinsic copies a block of memory from the source
2444location to the destination location, which are not allowed to overlap. It
2445copies "len" bytes of memory over. If the argument is known to be aligned to
2446some boundary, this can be specified as the fourth argument, otherwise it should
2447be set to 0 or 1.
2448</p>
2449</div>
2450
2451
Chris Lattner0eb51b42004-02-12 18:10:10 +00002452<!-- _______________________________________________________________________ -->
2453<div class="doc_subsubsection">
2454 <a name="i_memmove">'<tt>llvm.memmove</tt>' Intrinsic</a>
2455</div>
2456
2457<div class="doc_text">
2458
2459<h5>Syntax:</h5>
2460<pre>
2461 call void (sbyte*, sbyte*, uint, uint)* %llvm.memmove(sbyte* &lt;dest&gt;, sbyte* &lt;src&gt;,
2462 uint &lt;len&gt;, uint &lt;align&gt;)
2463</pre>
2464
2465<h5>Overview:</h5>
2466
2467<p>
2468The '<tt>llvm.memmove</tt>' intrinsic moves a block of memory from the source
2469location to the destination location. It is similar to the '<tt>llvm.memcpy</tt>'
2470intrinsic but allows the two memory locations to overlap.
2471</p>
2472
2473<p>
2474Note that, unlike the standard libc function, the <tt>llvm.memmove</tt> intrinsic
2475does not return a value, and takes an extra alignment argument.
2476</p>
2477
2478<h5>Arguments:</h5>
2479
2480<p>
2481The first argument is a pointer to the destination, the second is a pointer to
2482the source. The third argument is an (arbitrarily sized) integer argument
2483specifying the number of bytes to copy, and the fourth argument is the alignment
2484of the source and destination locations.
2485</p>
2486
Chris Lattner3301ced2004-02-12 21:18:15 +00002487<p>
2488If the call to this intrinisic has an alignment value that is not 0 or 1, then
2489the caller guarantees that the size of the copy is a multiple of the alignment
2490and that both the source and destination pointers are aligned to that boundary.
2491</p>
2492
Chris Lattner0eb51b42004-02-12 18:10:10 +00002493<h5>Semantics:</h5>
2494
2495<p>
2496The '<tt>llvm.memmove</tt>' intrinsic copies a block of memory from the source
2497location to the destination location, which may overlap. It
2498copies "len" bytes of memory over. If the argument is known to be aligned to
2499some boundary, this can be specified as the fourth argument, otherwise it should
2500be set to 0 or 1.
2501</p>
2502</div>
2503
Chris Lattner8ff75902004-01-06 05:31:32 +00002504
Chris Lattner10610642004-02-14 04:08:35 +00002505<!-- _______________________________________________________________________ -->
2506<div class="doc_subsubsection">
2507 <a name="i_memset">'<tt>llvm.memset</tt>' Intrinsic</a>
2508</div>
2509
2510<div class="doc_text">
2511
2512<h5>Syntax:</h5>
2513<pre>
2514 call void (sbyte*, ubyte, uint, uint)* %llvm.memset(sbyte* &lt;dest&gt;, ubyte &lt;val&gt;,
2515 uint &lt;len&gt;, uint &lt;align&gt;)
2516</pre>
2517
2518<h5>Overview:</h5>
2519
2520<p>
2521The '<tt>llvm.memset</tt>' intrinsic fills a block of memory with a particular
2522byte value.
2523</p>
2524
2525<p>
2526Note that, unlike the standard libc function, the <tt>llvm.memset</tt> intrinsic
2527does not return a value, and takes an extra alignment argument.
2528</p>
2529
2530<h5>Arguments:</h5>
2531
2532<p>
2533The first argument is a pointer to the destination to fill, the second is the
2534byte value to fill it with, the third argument is an (arbitrarily sized) integer
2535argument specifying the number of bytes to fill, and the fourth argument is the
2536known alignment of destination location.
2537</p>
2538
2539<p>
2540If the call to this intrinisic has an alignment value that is not 0 or 1, then
2541the caller guarantees that the size of the copy is a multiple of the alignment
2542and that the destination pointer is aligned to that boundary.
2543</p>
2544
2545<h5>Semantics:</h5>
2546
2547<p>
2548The '<tt>llvm.memset</tt>' intrinsic fills "len" bytes of memory starting at the
2549destination location. If the argument is known to be aligned to some boundary,
2550this can be specified as the fourth argument, otherwise it should be set to 0 or
25511.
2552</p>
2553</div>
2554
2555
Chris Lattner32006282004-06-11 02:28:03 +00002556<!-- _______________________________________________________________________ -->
2557<div class="doc_subsubsection">
Alkis Evlogimenos26bbe932004-06-13 01:16:15 +00002558 <a name="i_isunordered">'<tt>llvm.isunordered</tt>' Intrinsic</a>
2559</div>
2560
2561<div class="doc_text">
2562
2563<h5>Syntax:</h5>
2564<pre>
2565 call bool (&lt;float or double&gt;, &lt;float or double&gt;)* %llvm.isunordered(&lt;float or double&gt; Val1,
2566 &lt;float or double&gt; Val2)
2567</pre>
2568
2569<h5>Overview:</h5>
2570
2571<p>
2572The '<tt>llvm.isunordered</tt>' intrinsic returns true if either or both of the
2573specified floating point values is a NAN.
2574</p>
2575
2576<h5>Arguments:</h5>
2577
2578<p>
2579The arguments are floating point numbers of the same type.
2580</p>
2581
2582<h5>Semantics:</h5>
2583
2584<p>
2585If either or both of the arguments is a SNAN or QNAN, it returns true, otherwise
2586false.
2587</p>
2588</div>
2589
2590
Chris Lattner32006282004-06-11 02:28:03 +00002591
2592
Chris Lattner8ff75902004-01-06 05:31:32 +00002593<!-- ======================================================================= -->
2594<div class="doc_subsection">
2595 <a name="int_debugger">Debugger Intrinsics</a>
2596</div>
2597
2598<div class="doc_text">
2599<p>
2600The LLVM debugger intrinsics (which all start with <tt>llvm.dbg.</tt> prefix),
2601are described in the <a
2602href="SourceLevelDebugging.html#format_common_intrinsics">LLVM Source Level
2603Debugging</a> document.
2604</p>
2605</div>
2606
2607
Chris Lattner00950542001-06-06 20:29:01 +00002608<!-- *********************************************************************** -->
Chris Lattner00950542001-06-06 20:29:01 +00002609<hr>
Misha Brukmandaa4cb02004-03-01 17:47:27 +00002610<address>
2611 <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
2612 src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
2613 <a href="http://validator.w3.org/check/referer"><img
2614 src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /></a>
2615
2616 <a href="mailto:sabre@nondot.org">Chris Lattner</a><br>
2617 <a href="http://llvm.cs.uiuc.edu">The LLVM Compiler Infrastructure</a><br>
2618 Last modified: $Date$
2619</address>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002620</body>
2621</html>