Fix build breakage
[oota-llvm.git] / docs / LangRef.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2                       "http://www.w3.org/TR/html4/strict.dtd">
3 <html>
4 <head>
5   <title>LLVM Assembly Language Reference Manual</title>
6   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
7   <meta name="author" content="Chris Lattner">
8   <meta name="description" 
9   content="LLVM Assembly Language Reference Manual.">
10   <link rel="stylesheet" href="llvm.css" type="text/css">
11 </head>
12
13 <body>
14
15 <div class="doc_title"> LLVM Language Reference Manual </div>
16 <ol>
17   <li><a href="#abstract">Abstract</a></li>
18   <li><a href="#introduction">Introduction</a></li>
19   <li><a href="#identifiers">Identifiers</a></li>
20   <li><a href="#highlevel">High Level Structure</a>
21     <ol>
22       <li><a href="#modulestructure">Module Structure</a></li>
23       <li><a href="#linkage">Linkage Types</a></li>
24       <li><a href="#callingconv">Calling Conventions</a></li>
25       <li><a href="#globalvars">Global Variables</a></li>
26       <li><a href="#functionstructure">Functions</a></li>
27       <li><a href="#aliasstructure">Aliases</a>
28       <li><a href="#paramattrs">Parameter Attributes</a></li>
29       <li><a href="#gc">Garbage Collector Names</a></li>
30       <li><a href="#moduleasm">Module-Level Inline Assembly</a></li>
31       <li><a href="#datalayout">Data Layout</a></li>
32     </ol>
33   </li>
34   <li><a href="#typesystem">Type System</a>
35     <ol>
36       <li><a href="#t_classifications">Type Classifications</a></li>
37       <li><a href="#t_primitive">Primitive Types</a>    
38         <ol>
39           <li><a href="#t_floating">Floating Point Types</a></li>
40           <li><a href="#t_void">Void Type</a></li>
41           <li><a href="#t_label">Label Type</a></li>
42         </ol>
43       </li>
44       <li><a href="#t_derived">Derived Types</a>
45         <ol>
46           <li><a href="#t_integer">Integer Type</a></li>
47           <li><a href="#t_array">Array Type</a></li>
48           <li><a href="#t_function">Function Type</a></li>
49           <li><a href="#t_pointer">Pointer Type</a></li>
50           <li><a href="#t_struct">Structure Type</a></li>
51           <li><a href="#t_pstruct">Packed Structure Type</a></li>
52           <li><a href="#t_vector">Vector Type</a></li>
53           <li><a href="#t_opaque">Opaque Type</a></li>
54         </ol>
55       </li>
56     </ol>
57   </li>
58   <li><a href="#constants">Constants</a>
59     <ol>
60       <li><a href="#simpleconstants">Simple Constants</a>
61       <li><a href="#aggregateconstants">Aggregate Constants</a>
62       <li><a href="#globalconstants">Global Variable and Function Addresses</a>
63       <li><a href="#undefvalues">Undefined Values</a>
64       <li><a href="#constantexprs">Constant Expressions</a>
65     </ol>
66   </li>
67   <li><a href="#othervalues">Other Values</a>
68     <ol>
69       <li><a href="#inlineasm">Inline Assembler Expressions</a>
70     </ol>
71   </li>
72   <li><a href="#instref">Instruction Reference</a>
73     <ol>
74       <li><a href="#terminators">Terminator Instructions</a>
75         <ol>
76           <li><a href="#i_ret">'<tt>ret</tt>' Instruction</a></li>
77           <li><a href="#i_br">'<tt>br</tt>' Instruction</a></li>
78           <li><a href="#i_switch">'<tt>switch</tt>' Instruction</a></li>
79           <li><a href="#i_invoke">'<tt>invoke</tt>' Instruction</a></li>
80           <li><a href="#i_unwind">'<tt>unwind</tt>'  Instruction</a></li>
81           <li><a href="#i_unreachable">'<tt>unreachable</tt>' Instruction</a></li>
82         </ol>
83       </li>
84       <li><a href="#binaryops">Binary Operations</a>
85         <ol>
86           <li><a href="#i_add">'<tt>add</tt>' Instruction</a></li>
87           <li><a href="#i_sub">'<tt>sub</tt>' Instruction</a></li>
88           <li><a href="#i_mul">'<tt>mul</tt>' Instruction</a></li>
89           <li><a href="#i_udiv">'<tt>udiv</tt>' Instruction</a></li>
90           <li><a href="#i_sdiv">'<tt>sdiv</tt>' Instruction</a></li>
91           <li><a href="#i_fdiv">'<tt>fdiv</tt>' Instruction</a></li>
92           <li><a href="#i_urem">'<tt>urem</tt>' Instruction</a></li>
93           <li><a href="#i_srem">'<tt>srem</tt>' Instruction</a></li>
94           <li><a href="#i_frem">'<tt>frem</tt>' Instruction</a></li>
95         </ol>
96       </li>
97       <li><a href="#bitwiseops">Bitwise Binary Operations</a>
98         <ol>
99           <li><a href="#i_shl">'<tt>shl</tt>' Instruction</a></li>
100           <li><a href="#i_lshr">'<tt>lshr</tt>' Instruction</a></li>
101           <li><a href="#i_ashr">'<tt>ashr</tt>' Instruction</a></li>
102           <li><a href="#i_and">'<tt>and</tt>' Instruction</a></li>
103           <li><a href="#i_or">'<tt>or</tt>'  Instruction</a></li>
104           <li><a href="#i_xor">'<tt>xor</tt>' Instruction</a></li>
105         </ol>
106       </li>
107       <li><a href="#vectorops">Vector Operations</a>
108         <ol>
109           <li><a href="#i_extractelement">'<tt>extractelement</tt>' Instruction</a></li>
110           <li><a href="#i_insertelement">'<tt>insertelement</tt>' Instruction</a></li>
111           <li><a href="#i_shufflevector">'<tt>shufflevector</tt>' Instruction</a></li>
112         </ol>
113       </li>
114       <li><a href="#memoryops">Memory Access and Addressing Operations</a>
115         <ol>
116           <li><a href="#i_malloc">'<tt>malloc</tt>'   Instruction</a></li>
117           <li><a href="#i_free">'<tt>free</tt>'     Instruction</a></li>
118           <li><a href="#i_alloca">'<tt>alloca</tt>'   Instruction</a></li>
119          <li><a href="#i_load">'<tt>load</tt>'     Instruction</a></li>
120          <li><a href="#i_store">'<tt>store</tt>'    Instruction</a></li>
121          <li><a href="#i_getelementptr">'<tt>getelementptr</tt>' Instruction</a></li>
122         </ol>
123       </li>
124       <li><a href="#convertops">Conversion Operations</a>
125         <ol>
126           <li><a href="#i_trunc">'<tt>trunc .. to</tt>' Instruction</a></li>
127           <li><a href="#i_zext">'<tt>zext .. to</tt>' Instruction</a></li>
128           <li><a href="#i_sext">'<tt>sext .. to</tt>' Instruction</a></li>
129           <li><a href="#i_fptrunc">'<tt>fptrunc .. to</tt>' Instruction</a></li>
130           <li><a href="#i_fpext">'<tt>fpext .. to</tt>' Instruction</a></li>
131           <li><a href="#i_fptoui">'<tt>fptoui .. to</tt>' Instruction</a></li>
132           <li><a href="#i_fptosi">'<tt>fptosi .. to</tt>' Instruction</a></li>
133           <li><a href="#i_uitofp">'<tt>uitofp .. to</tt>' Instruction</a></li>
134           <li><a href="#i_sitofp">'<tt>sitofp .. to</tt>' Instruction</a></li>
135           <li><a href="#i_ptrtoint">'<tt>ptrtoint .. to</tt>' Instruction</a></li>
136           <li><a href="#i_inttoptr">'<tt>inttoptr .. to</tt>' Instruction</a></li>
137           <li><a href="#i_bitcast">'<tt>bitcast .. to</tt>' Instruction</a></li>
138         </ol>
139       <li><a href="#otherops">Other Operations</a>
140         <ol>
141           <li><a href="#i_icmp">'<tt>icmp</tt>' Instruction</a></li>
142           <li><a href="#i_fcmp">'<tt>fcmp</tt>' Instruction</a></li>
143           <li><a href="#i_vicmp">'<tt>vicmp</tt>' Instruction</a></li>
144           <li><a href="#i_vfcmp">'<tt>vfcmp</tt>' Instruction</a></li>
145           <li><a href="#i_phi">'<tt>phi</tt>'   Instruction</a></li>
146           <li><a href="#i_select">'<tt>select</tt>' Instruction</a></li>
147           <li><a href="#i_call">'<tt>call</tt>'  Instruction</a></li>
148           <li><a href="#i_va_arg">'<tt>va_arg</tt>'  Instruction</a></li>
149           <li><a href="#i_getresult">'<tt>getresult</tt>'  Instruction</a></li>
150         </ol>
151       </li>
152     </ol>
153   </li>
154   <li><a href="#intrinsics">Intrinsic Functions</a>
155     <ol>
156       <li><a href="#int_varargs">Variable Argument Handling Intrinsics</a>
157         <ol>
158           <li><a href="#int_va_start">'<tt>llvm.va_start</tt>' Intrinsic</a></li>
159           <li><a href="#int_va_end">'<tt>llvm.va_end</tt>'   Intrinsic</a></li>
160           <li><a href="#int_va_copy">'<tt>llvm.va_copy</tt>'  Intrinsic</a></li>
161         </ol>
162       </li>
163       <li><a href="#int_gc">Accurate Garbage Collection Intrinsics</a>
164         <ol>
165           <li><a href="#int_gcroot">'<tt>llvm.gcroot</tt>' Intrinsic</a></li>
166           <li><a href="#int_gcread">'<tt>llvm.gcread</tt>' Intrinsic</a></li>
167           <li><a href="#int_gcwrite">'<tt>llvm.gcwrite</tt>' Intrinsic</a></li>
168         </ol>
169       </li>
170       <li><a href="#int_codegen">Code Generator Intrinsics</a>
171         <ol>
172           <li><a href="#int_returnaddress">'<tt>llvm.returnaddress</tt>' Intrinsic</a></li>
173           <li><a href="#int_frameaddress">'<tt>llvm.frameaddress</tt>'   Intrinsic</a></li>
174           <li><a href="#int_stacksave">'<tt>llvm.stacksave</tt>' Intrinsic</a></li>
175           <li><a href="#int_stackrestore">'<tt>llvm.stackrestore</tt>' Intrinsic</a></li>
176           <li><a href="#int_prefetch">'<tt>llvm.prefetch</tt>' Intrinsic</a></li>
177           <li><a href="#int_pcmarker">'<tt>llvm.pcmarker</tt>' Intrinsic</a></li>
178           <li><a href="#int_readcyclecounter"><tt>llvm.readcyclecounter</tt>' Intrinsic</a></li>
179         </ol>
180       </li>
181       <li><a href="#int_libc">Standard C Library Intrinsics</a>
182         <ol>
183           <li><a href="#int_memcpy">'<tt>llvm.memcpy.*</tt>' Intrinsic</a></li>
184           <li><a href="#int_memmove">'<tt>llvm.memmove.*</tt>' Intrinsic</a></li>
185           <li><a href="#int_memset">'<tt>llvm.memset.*</tt>' Intrinsic</a></li>
186           <li><a href="#int_sqrt">'<tt>llvm.sqrt.*</tt>' Intrinsic</a></li>
187           <li><a href="#int_powi">'<tt>llvm.powi.*</tt>' Intrinsic</a></li>
188           <li><a href="#int_sin">'<tt>llvm.sin.*</tt>' Intrinsic</a></li>
189           <li><a href="#int_cos">'<tt>llvm.cos.*</tt>' Intrinsic</a></li>
190           <li><a href="#int_pow">'<tt>llvm.pow.*</tt>' Intrinsic</a></li>
191         </ol>
192       </li>
193       <li><a href="#int_manip">Bit Manipulation Intrinsics</a>
194         <ol>
195           <li><a href="#int_bswap">'<tt>llvm.bswap.*</tt>' Intrinsics</a></li>
196           <li><a href="#int_ctpop">'<tt>llvm.ctpop.*</tt>' Intrinsic </a></li>
197           <li><a href="#int_ctlz">'<tt>llvm.ctlz.*</tt>' Intrinsic </a></li>
198           <li><a href="#int_cttz">'<tt>llvm.cttz.*</tt>' Intrinsic </a></li>
199           <li><a href="#int_part_select">'<tt>llvm.part.select.*</tt>' Intrinsic </a></li>
200           <li><a href="#int_part_set">'<tt>llvm.part.set.*</tt>' Intrinsic </a></li>
201         </ol>
202       </li>
203       <li><a href="#int_debugger">Debugger intrinsics</a></li>
204       <li><a href="#int_eh">Exception Handling intrinsics</a></li>
205       <li><a href="#int_trampoline">Trampoline Intrinsic</a>
206         <ol>
207           <li><a href="#int_it">'<tt>llvm.init.trampoline</tt>' Intrinsic</a></li>
208         </ol>
209       </li>
210           <li><a href="#int_atomics">Atomic intrinsics</a>
211             <ol>
212               <li><a href="#int_memory_barrier"><tt>llvm.memory_barrier</tt></a></li>
213               <li><a href="#int_atomic_lcs"><tt>llvm.atomic.lcs</tt></a></li>
214               <li><a href="#int_atomic_las"><tt>llvm.atomic.las</tt></a></li>
215               <li><a href="#int_atomic_swap"><tt>llvm.atomic.swap</tt></a></li>
216             </ol>
217           </li>
218       <li><a href="#int_general">General intrinsics</a>
219         <ol>
220           <li><a href="#int_var_annotation">
221             <tt>llvm.var.annotation</tt>' Intrinsic</a></li>
222           <li><a href="#int_annotation">
223             <tt>llvm.annotation.*</tt>' Intrinsic</a></li>
224           <li><a href="#int_trap">
225             <tt>llvm.trap</tt>' Intrinsic</a></li>
226         </ol>
227       </li>
228     </ol>
229   </li>
230 </ol>
231
232 <div class="doc_author">
233   <p>Written by <a href="mailto:sabre@nondot.org">Chris Lattner</a>
234             and <a href="mailto:vadve@cs.uiuc.edu">Vikram Adve</a></p>
235 </div>
236
237 <!-- *********************************************************************** -->
238 <div class="doc_section"> <a name="abstract">Abstract </a></div>
239 <!-- *********************************************************************** -->
240
241 <div class="doc_text">
242 <p>This document is a reference manual for the LLVM assembly language. 
243 LLVM is an SSA based representation that provides type safety,
244 low-level operations, flexibility, and the capability of representing
245 'all' high-level languages cleanly.  It is the common code
246 representation used throughout all phases of the LLVM compilation
247 strategy.</p>
248 </div>
249
250 <!-- *********************************************************************** -->
251 <div class="doc_section"> <a name="introduction">Introduction</a> </div>
252 <!-- *********************************************************************** -->
253
254 <div class="doc_text">
255
256 <p>The LLVM code representation is designed to be used in three
257 different forms: as an in-memory compiler IR, as an on-disk bitcode
258 representation (suitable for fast loading by a Just-In-Time compiler),
259 and as a human readable assembly language representation.  This allows
260 LLVM to provide a powerful intermediate representation for efficient
261 compiler transformations and analysis, while providing a natural means
262 to debug and visualize the transformations.  The three different forms
263 of LLVM are all equivalent.  This document describes the human readable
264 representation and notation.</p>
265
266 <p>The LLVM representation aims to be light-weight and low-level
267 while being expressive, typed, and extensible at the same time.  It
268 aims to be a "universal IR" of sorts, by being at a low enough level
269 that high-level ideas may be cleanly mapped to it (similar to how
270 microprocessors are "universal IR's", allowing many source languages to
271 be mapped to them).  By providing type information, LLVM can be used as
272 the target of optimizations: for example, through pointer analysis, it
273 can be proven that a C automatic variable is never accessed outside of
274 the current function... allowing it to be promoted to a simple SSA
275 value instead of a memory location.</p>
276
277 </div>
278
279 <!-- _______________________________________________________________________ -->
280 <div class="doc_subsubsection"> <a name="wellformed">Well-Formedness</a> </div>
281
282 <div class="doc_text">
283
284 <p>It is important to note that this document describes 'well formed'
285 LLVM assembly language.  There is a difference between what the parser
286 accepts and what is considered 'well formed'.  For example, the
287 following instruction is syntactically okay, but not well formed:</p>
288
289 <div class="doc_code">
290 <pre>
291 %x = <a href="#i_add">add</a> i32 1, %x
292 </pre>
293 </div>
294
295 <p>...because the definition of <tt>%x</tt> does not dominate all of
296 its uses. The LLVM infrastructure provides a verification pass that may
297 be used to verify that an LLVM module is well formed.  This pass is
298 automatically run by the parser after parsing input assembly and by
299 the optimizer before it outputs bitcode.  The violations pointed out
300 by the verifier pass indicate bugs in transformation passes or input to
301 the parser.</p>
302 </div>
303
304 <!-- Describe the typesetting conventions here. -->
305
306 <!-- *********************************************************************** -->
307 <div class="doc_section"> <a name="identifiers">Identifiers</a> </div>
308 <!-- *********************************************************************** -->
309
310 <div class="doc_text">
311
312   <p>LLVM identifiers come in two basic types: global and local. Global
313   identifiers (functions, global variables) begin with the @ character. Local
314   identifiers (register names, types) begin with the % character. Additionally,
315   there are three different formats for identifiers, for different purposes:
316
317 <ol>
318   <li>Named values are represented as a string of characters with their prefix.
319   For example, %foo, @DivisionByZero, %a.really.long.identifier.  The actual
320   regular expression used is '<tt>[%@][a-zA-Z$._][a-zA-Z$._0-9]*</tt>'.
321   Identifiers which require other characters in their names can be surrounded
322   with quotes.  In this way, anything except a <tt>&quot;</tt> character can 
323   be used in a named value.</li>
324
325   <li>Unnamed values are represented as an unsigned numeric value with their
326   prefix.  For example, %12, @2, %44.</li>
327
328   <li>Constants, which are described in a <a href="#constants">section about
329   constants</a>, below.</li>
330 </ol>
331
332 <p>LLVM requires that values start with a prefix for two reasons: Compilers
333 don't need to worry about name clashes with reserved words, and the set of
334 reserved words may be expanded in the future without penalty.  Additionally,
335 unnamed identifiers allow a compiler to quickly come up with a temporary
336 variable without having to avoid symbol table conflicts.</p>
337
338 <p>Reserved words in LLVM are very similar to reserved words in other
339 languages. There are keywords for different opcodes 
340 ('<tt><a href="#i_add">add</a></tt>', 
341  '<tt><a href="#i_bitcast">bitcast</a></tt>', 
342  '<tt><a href="#i_ret">ret</a></tt>', etc...), for primitive type names ('<tt><a
343 href="#t_void">void</a></tt>', '<tt><a href="#t_primitive">i32</a></tt>', etc...),
344 and others.  These reserved words cannot conflict with variable names, because
345 none of them start with a prefix character ('%' or '@').</p>
346
347 <p>Here is an example of LLVM code to multiply the integer variable
348 '<tt>%X</tt>' by 8:</p>
349
350 <p>The easy way:</p>
351
352 <div class="doc_code">
353 <pre>
354 %result = <a href="#i_mul">mul</a> i32 %X, 8
355 </pre>
356 </div>
357
358 <p>After strength reduction:</p>
359
360 <div class="doc_code">
361 <pre>
362 %result = <a href="#i_shl">shl</a> i32 %X, i8 3
363 </pre>
364 </div>
365
366 <p>And the hard way:</p>
367
368 <div class="doc_code">
369 <pre>
370 <a href="#i_add">add</a> i32 %X, %X           <i>; yields {i32}:%0</i>
371 <a href="#i_add">add</a> i32 %0, %0           <i>; yields {i32}:%1</i>
372 %result = <a href="#i_add">add</a> i32 %1, %1
373 </pre>
374 </div>
375
376 <p>This last way of multiplying <tt>%X</tt> by 8 illustrates several
377 important lexical features of LLVM:</p>
378
379 <ol>
380
381   <li>Comments are delimited with a '<tt>;</tt>' and go until the end of
382   line.</li>
383
384   <li>Unnamed temporaries are created when the result of a computation is not
385   assigned to a named value.</li>
386
387   <li>Unnamed temporaries are numbered sequentially</li>
388
389 </ol>
390
391 <p>...and it also shows a convention that we follow in this document.  When
392 demonstrating instructions, we will follow an instruction with a comment that
393 defines the type and name of value produced.  Comments are shown in italic
394 text.</p>
395
396 </div>
397
398 <!-- *********************************************************************** -->
399 <div class="doc_section"> <a name="highlevel">High Level Structure</a> </div>
400 <!-- *********************************************************************** -->
401
402 <!-- ======================================================================= -->
403 <div class="doc_subsection"> <a name="modulestructure">Module Structure</a>
404 </div>
405
406 <div class="doc_text">
407
408 <p>LLVM programs are composed of "Module"s, each of which is a
409 translation unit of the input programs.  Each module consists of
410 functions, global variables, and symbol table entries.  Modules may be
411 combined together with the LLVM linker, which merges function (and
412 global variable) definitions, resolves forward declarations, and merges
413 symbol table entries. Here is an example of the "hello world" module:</p>
414
415 <div class="doc_code">
416 <pre><i>; Declare the string constant as a global constant...</i>
417 <a href="#identifiers">@.LC0</a> = <a href="#linkage_internal">internal</a> <a
418  href="#globalvars">constant</a> <a href="#t_array">[13 x i8]</a> c"hello world\0A\00"          <i>; [13 x i8]*</i>
419
420 <i>; External declaration of the puts function</i>
421 <a href="#functionstructure">declare</a> i32 @puts(i8 *)                                            <i>; i32(i8 *)* </i>
422
423 <i>; Definition of main function</i>
424 define i32 @main() {                                                 <i>; i32()* </i>
425         <i>; Convert [13x i8 ]* to i8  *...</i>
426         %cast210 = <a
427  href="#i_getelementptr">getelementptr</a> [13 x i8 ]* @.LC0, i64 0, i64 0 <i>; i8 *</i>
428
429         <i>; Call puts function to write out the string to stdout...</i>
430         <a
431  href="#i_call">call</a> i32 @puts(i8 * %cast210)                              <i>; i32</i>
432         <a
433  href="#i_ret">ret</a> i32 0<br>}<br>
434 </pre>
435 </div>
436
437 <p>This example is made up of a <a href="#globalvars">global variable</a>
438 named "<tt>.LC0</tt>", an external declaration of the "<tt>puts</tt>"
439 function, and a <a href="#functionstructure">function definition</a>
440 for "<tt>main</tt>".</p>
441
442 <p>In general, a module is made up of a list of global values,
443 where both functions and global variables are global values.  Global values are
444 represented by a pointer to a memory location (in this case, a pointer to an
445 array of char, and a pointer to a function), and have one of the following <a
446 href="#linkage">linkage types</a>.</p>
447
448 </div>
449
450 <!-- ======================================================================= -->
451 <div class="doc_subsection">
452   <a name="linkage">Linkage Types</a>
453 </div>
454
455 <div class="doc_text">
456
457 <p>
458 All Global Variables and Functions have one of the following types of linkage:
459 </p>
460
461 <dl>
462
463   <dt><tt><b><a name="linkage_internal">internal</a></b></tt> </dt>
464
465   <dd>Global values with internal linkage are only directly accessible by
466   objects in the current module.  In particular, linking code into a module with
467   an internal global value may cause the internal to be renamed as necessary to
468   avoid collisions.  Because the symbol is internal to the module, all
469   references can be updated.  This corresponds to the notion of the
470   '<tt>static</tt>' keyword in C.
471   </dd>
472
473   <dt><tt><b><a name="linkage_linkonce">linkonce</a></b></tt>: </dt>
474
475   <dd>Globals with "<tt>linkonce</tt>" linkage are merged with other globals of
476   the same name when linkage occurs.  This is typically used to implement 
477   inline functions, templates, or other code which must be generated in each 
478   translation unit that uses it.  Unreferenced <tt>linkonce</tt> globals are 
479   allowed to be discarded.
480   </dd>
481
482   <dt><tt><b><a name="linkage_weak">weak</a></b></tt>: </dt>
483
484   <dd>"<tt>weak</tt>" linkage is exactly the same as <tt>linkonce</tt> linkage,
485   except that unreferenced <tt>weak</tt> globals may not be discarded.  This is
486   used for globals that may be emitted in multiple translation units, but that
487   are not guaranteed to be emitted into every translation unit that uses them.
488   One example of this are common globals in C, such as "<tt>int X;</tt>" at 
489   global scope.
490   </dd>
491
492   <dt><tt><b><a name="linkage_appending">appending</a></b></tt>: </dt>
493
494   <dd>"<tt>appending</tt>" linkage may only be applied to global variables of
495   pointer to array type.  When two global variables with appending linkage are
496   linked together, the two global arrays are appended together.  This is the
497   LLVM, typesafe, equivalent of having the system linker append together
498   "sections" with identical names when .o files are linked.
499   </dd>
500
501   <dt><tt><b><a name="linkage_externweak">extern_weak</a></b></tt>: </dt>
502   <dd>The semantics of this linkage follow the ELF model: the symbol is weak
503     until linked, if not linked, the symbol becomes null instead of being an
504     undefined reference.
505   </dd>
506
507   <dt><tt><b><a name="linkage_external">externally visible</a></b></tt>:</dt>
508
509   <dd>If none of the above identifiers are used, the global is externally
510   visible, meaning that it participates in linkage and can be used to resolve
511   external symbol references.
512   </dd>
513 </dl>
514
515   <p>
516   The next two types of linkage are targeted for Microsoft Windows platform
517   only. They are designed to support importing (exporting) symbols from (to)
518   DLLs.
519   </p>
520
521   <dl>
522   <dt><tt><b><a name="linkage_dllimport">dllimport</a></b></tt>: </dt>
523
524   <dd>"<tt>dllimport</tt>" linkage causes the compiler to reference a function
525     or variable via a global pointer to a pointer that is set up by the DLL
526     exporting the symbol. On Microsoft Windows targets, the pointer name is
527     formed by combining <code>_imp__</code> and the function or variable name.
528   </dd>
529
530   <dt><tt><b><a name="linkage_dllexport">dllexport</a></b></tt>: </dt>
531
532   <dd>"<tt>dllexport</tt>" linkage causes the compiler to provide a global
533     pointer to a pointer in a DLL, so that it can be referenced with the
534     <tt>dllimport</tt> attribute. On Microsoft Windows targets, the pointer
535     name is formed by combining <code>_imp__</code> and the function or variable
536     name.
537   </dd>
538
539 </dl>
540
541 <p><a name="linkage_external"></a>For example, since the "<tt>.LC0</tt>"
542 variable is defined to be internal, if another module defined a "<tt>.LC0</tt>"
543 variable and was linked with this one, one of the two would be renamed,
544 preventing a collision.  Since "<tt>main</tt>" and "<tt>puts</tt>" are
545 external (i.e., lacking any linkage declarations), they are accessible
546 outside of the current module.</p>
547 <p>It is illegal for a function <i>declaration</i>
548 to have any linkage type other than "externally visible", <tt>dllimport</tt>,
549 or <tt>extern_weak</tt>.</p>
550 <p>Aliases can have only <tt>external</tt>, <tt>internal</tt> and <tt>weak</tt>
551 linkages.
552 </div>
553
554 <!-- ======================================================================= -->
555 <div class="doc_subsection">
556   <a name="callingconv">Calling Conventions</a>
557 </div>
558
559 <div class="doc_text">
560
561 <p>LLVM <a href="#functionstructure">functions</a>, <a href="#i_call">calls</a>
562 and <a href="#i_invoke">invokes</a> can all have an optional calling convention
563 specified for the call.  The calling convention of any pair of dynamic
564 caller/callee must match, or the behavior of the program is undefined.  The
565 following calling conventions are supported by LLVM, and more may be added in
566 the future:</p>
567
568 <dl>
569   <dt><b>"<tt>ccc</tt>" - The C calling convention</b>:</dt>
570
571   <dd>This calling convention (the default if no other calling convention is
572   specified) matches the target C calling conventions.  This calling convention
573   supports varargs function calls and tolerates some mismatch in the declared
574   prototype and implemented declaration of the function (as does normal C). 
575   </dd>
576
577   <dt><b>"<tt>fastcc</tt>" - The fast calling convention</b>:</dt>
578
579   <dd>This calling convention attempts to make calls as fast as possible
580   (e.g. by passing things in registers).  This calling convention allows the
581   target to use whatever tricks it wants to produce fast code for the target,
582   without having to conform to an externally specified ABI.  Implementations of
583   this convention should allow arbitrary tail call optimization to be supported.
584   This calling convention does not support varargs and requires the prototype of
585   all callees to exactly match the prototype of the function definition.
586   </dd>
587
588   <dt><b>"<tt>coldcc</tt>" - The cold calling convention</b>:</dt>
589
590   <dd>This calling convention attempts to make code in the caller as efficient
591   as possible under the assumption that the call is not commonly executed.  As
592   such, these calls often preserve all registers so that the call does not break
593   any live ranges in the caller side.  This calling convention does not support
594   varargs and requires the prototype of all callees to exactly match the
595   prototype of the function definition.
596   </dd>
597
598   <dt><b>"<tt>cc &lt;<em>n</em>&gt;</tt>" - Numbered convention</b>:</dt>
599
600   <dd>Any calling convention may be specified by number, allowing
601   target-specific calling conventions to be used.  Target specific calling
602   conventions start at 64.
603   </dd>
604 </dl>
605
606 <p>More calling conventions can be added/defined on an as-needed basis, to
607 support pascal conventions or any other well-known target-independent
608 convention.</p>
609
610 </div>
611
612 <!-- ======================================================================= -->
613 <div class="doc_subsection">
614   <a name="visibility">Visibility Styles</a>
615 </div>
616
617 <div class="doc_text">
618
619 <p>
620 All Global Variables and Functions have one of the following visibility styles:
621 </p>
622
623 <dl>
624   <dt><b>"<tt>default</tt>" - Default style</b>:</dt>
625
626   <dd>On ELF, default visibility means that the declaration is visible to other
627     modules and, in shared libraries, means that the declared entity may be
628     overridden. On Darwin, default visibility means that the declaration is
629     visible to other modules. Default visibility corresponds to "external
630     linkage" in the language.
631   </dd>
632
633   <dt><b>"<tt>hidden</tt>" - Hidden style</b>:</dt>
634
635   <dd>Two declarations of an object with hidden visibility refer to the same
636     object if they are in the same shared object. Usually, hidden visibility
637     indicates that the symbol will not be placed into the dynamic symbol table,
638     so no other module (executable or shared library) can reference it
639     directly.
640   </dd>
641
642   <dt><b>"<tt>protected</tt>" - Protected style</b>:</dt>
643
644   <dd>On ELF, protected visibility indicates that the symbol will be placed in
645   the dynamic symbol table, but that references within the defining module will
646   bind to the local symbol. That is, the symbol cannot be overridden by another
647   module.
648   </dd>
649 </dl>
650
651 </div>
652
653 <!-- ======================================================================= -->
654 <div class="doc_subsection">
655   <a name="globalvars">Global Variables</a>
656 </div>
657
658 <div class="doc_text">
659
660 <p>Global variables define regions of memory allocated at compilation time
661 instead of run-time.  Global variables may optionally be initialized, may have
662 an explicit section to be placed in, and may have an optional explicit alignment
663 specified.  A variable may be defined as "thread_local", which means that it
664 will not be shared by threads (each thread will have a separated copy of the
665 variable).  A variable may be defined as a global "constant," which indicates
666 that the contents of the variable will <b>never</b> be modified (enabling better
667 optimization, allowing the global data to be placed in the read-only section of
668 an executable, etc).  Note that variables that need runtime initialization
669 cannot be marked "constant" as there is a store to the variable.</p>
670
671 <p>
672 LLVM explicitly allows <em>declarations</em> of global variables to be marked
673 constant, even if the final definition of the global is not.  This capability
674 can be used to enable slightly better optimization of the program, but requires
675 the language definition to guarantee that optimizations based on the
676 'constantness' are valid for the translation units that do not include the
677 definition.
678 </p>
679
680 <p>As SSA values, global variables define pointer values that are in
681 scope (i.e. they dominate) all basic blocks in the program.  Global
682 variables always define a pointer to their "content" type because they
683 describe a region of memory, and all memory objects in LLVM are
684 accessed through pointers.</p>
685
686 <p>A global variable may be declared to reside in a target-specifc numbered 
687 address space. For targets that support them, address spaces may affect how
688 optimizations are performed and/or what target instructions are used to access 
689 the variable. The default address space is zero. The address space qualifier 
690 must precede any other attributes.</p>
691
692 <p>LLVM allows an explicit section to be specified for globals.  If the target
693 supports it, it will emit globals to the section specified.</p>
694
695 <p>An explicit alignment may be specified for a global.  If not present, or if
696 the alignment is set to zero, the alignment of the global is set by the target
697 to whatever it feels convenient.  If an explicit alignment is specified, the 
698 global is forced to have at least that much alignment.  All alignments must be
699 a power of 2.</p>
700
701 <p>For example, the following defines a global in a numbered address space with 
702 an initializer, section, and alignment:</p>
703
704 <div class="doc_code">
705 <pre>
706 @G = constant float 1.0 addrspace(5), section "foo", align 4
707 </pre>
708 </div>
709
710 </div>
711
712
713 <!-- ======================================================================= -->
714 <div class="doc_subsection">
715   <a name="functionstructure">Functions</a>
716 </div>
717
718 <div class="doc_text">
719
720 <p>LLVM function definitions consist of the "<tt>define</tt>" keyord, 
721 an optional <a href="#linkage">linkage type</a>, an optional 
722 <a href="#visibility">visibility style</a>, an optional 
723 <a href="#callingconv">calling convention</a>, a return type, an optional
724 <a href="#paramattrs">parameter attribute</a> for the return type, a function 
725 name, a (possibly empty) argument list (each with optional 
726 <a href="#paramattrs">parameter attributes</a>), an optional section, an
727 optional alignment, an optional <a href="#gc">garbage collector name</a>, an
728 opening curly brace, a list of basic blocks, and a closing curly brace.
729
730 LLVM function declarations consist of the "<tt>declare</tt>" keyword, an
731 optional <a href="#linkage">linkage type</a>, an optional
732 <a href="#visibility">visibility style</a>, an optional 
733 <a href="#callingconv">calling convention</a>, a return type, an optional
734 <a href="#paramattrs">parameter attribute</a> for the return type, a function 
735 name, a possibly empty list of arguments, an optional alignment, and an optional
736 <a href="#gc">garbage collector name</a>.</p>
737
738 <p>A function definition contains a list of basic blocks, forming the CFG for
739 the function.  Each basic block may optionally start with a label (giving the
740 basic block a symbol table entry), contains a list of instructions, and ends
741 with a <a href="#terminators">terminator</a> instruction (such as a branch or
742 function return).</p>
743
744 <p>The first basic block in a function is special in two ways: it is immediately
745 executed on entrance to the function, and it is not allowed to have predecessor
746 basic blocks (i.e. there can not be any branches to the entry block of a
747 function).  Because the block can have no predecessors, it also cannot have any
748 <a href="#i_phi">PHI nodes</a>.</p>
749
750 <p>LLVM allows an explicit section to be specified for functions.  If the target
751 supports it, it will emit functions to the section specified.</p>
752
753 <p>An explicit alignment may be specified for a function.  If not present, or if
754 the alignment is set to zero, the alignment of the function is set by the target
755 to whatever it feels convenient.  If an explicit alignment is specified, the
756 function is forced to have at least that much alignment.  All alignments must be
757 a power of 2.</p>
758
759 </div>
760
761
762 <!-- ======================================================================= -->
763 <div class="doc_subsection">
764   <a name="aliasstructure">Aliases</a>
765 </div>
766 <div class="doc_text">
767   <p>Aliases act as "second name" for the aliasee value (which can be either
768   function, global variable, another alias or bitcast of global value). Aliases
769   may have an optional <a href="#linkage">linkage type</a>, and an
770   optional <a href="#visibility">visibility style</a>.</p>
771
772   <h5>Syntax:</h5>
773
774 <div class="doc_code">
775 <pre>
776 @&lt;Name&gt; = [Linkage] [Visibility] alias &lt;AliaseeTy&gt; @&lt;Aliasee&gt;
777 </pre>
778 </div>
779
780 </div>
781
782
783
784 <!-- ======================================================================= -->
785 <div class="doc_subsection"><a name="paramattrs">Parameter Attributes</a></div>
786 <div class="doc_text">
787   <p>The return type and each parameter of a function type may have a set of
788   <i>parameter attributes</i> associated with them. Parameter attributes are
789   used to communicate additional information about the result or parameters of
790   a function. Parameter attributes are considered to be part of the function,
791   not of the function type, so functions with different parameter attributes
792   can have the same function type.</p>
793
794   <p>Parameter attributes are simple keywords that follow the type specified. If
795   multiple parameter attributes are needed, they are space separated. For 
796   example:</p>
797
798 <div class="doc_code">
799 <pre>
800 declare i32 @printf(i8* noalias , ...) nounwind
801 declare i32 @atoi(i8*) nounwind readonly
802 </pre>
803 </div>
804
805   <p>Note that any attributes for the function result (<tt>nounwind</tt>,
806   <tt>readonly</tt>) come immediately after the argument list.</p>
807
808   <p>Currently, only the following parameter attributes are defined:</p>
809   <dl>
810     <dt><tt>zeroext</tt></dt>
811     <dd>This indicates that the parameter should be zero extended just before
812     a call to this function.</dd>
813
814     <dt><tt>signext</tt></dt>
815     <dd>This indicates that the parameter should be sign extended just before
816     a call to this function.</dd>
817
818     <dt><tt>inreg</tt></dt>
819     <dd>This indicates that the parameter should be placed in register (if
820     possible) during assembling function call. Support for this attribute is
821     target-specific</dd>
822
823     <dt><tt>byval</tt></dt>
824     <dd>This indicates that the pointer parameter should really be passed by
825     value to the function.  The attribute implies that a hidden copy of the
826     pointee is made between the caller and the callee, so the callee is unable
827     to modify the value in the callee.  This attribute is only valid on llvm
828     pointer arguments.  It is generally used to pass structs and arrays by
829     value, but is also valid on scalars (even though this is silly).</dd>
830
831     <dt><tt>sret</tt></dt>
832     <dd>This indicates that the pointer parameter specifies the address of a
833     structure that is the return value of the function in the source program.
834     Loads and stores to the structure are assumed not to trap.
835     May only be applied to the first parameter.</dd>
836
837     <dt><tt>noalias</tt></dt>
838     <dd>This indicates that the parameter does not alias any global or any other
839     parameter.  The caller is responsible for ensuring that this is the case,
840     usually by placing the value in a stack allocation.</dd>
841
842     <dt><tt>noreturn</tt></dt>
843     <dd>This function attribute indicates that the function never returns. This
844     indicates to LLVM that every call to this function should be treated as if
845     an <tt>unreachable</tt> instruction immediately followed the call.</dd> 
846
847     <dt><tt>nounwind</tt></dt>
848     <dd>This function attribute indicates that no exceptions unwind out of the
849     function.  Usually this is because the function makes no use of exceptions,
850     but it may also be that the function catches any exceptions thrown when
851     executing it.</dd>
852
853     <dt><tt>nest</tt></dt>
854     <dd>This indicates that the parameter can be excised using the
855     <a href="#int_trampoline">trampoline intrinsics</a>.</dd>
856     <dt><tt>readonly</tt></dt>
857     <dd>This function attribute indicates that the function has no side-effects
858     except for producing a return value or throwing an exception.  The value
859     returned must only depend on the function arguments and/or global variables.
860     It may use values obtained by dereferencing pointers.</dd>
861     <dt><tt>readnone</tt></dt>
862     <dd>A <tt>readnone</tt> function has the same restrictions as a <tt>readonly</tt>
863     function, but in addition it is not allowed to dereference any pointer arguments
864     or global variables.
865   </dl>
866
867 </div>
868
869 <!-- ======================================================================= -->
870 <div class="doc_subsection">
871   <a name="gc">Garbage Collector Names</a>
872 </div>
873
874 <div class="doc_text">
875 <p>Each function may specify a garbage collector name, which is simply a
876 string.</p>
877
878 <div class="doc_code"><pre
879 >define void @f() gc "name" { ...</pre></div>
880
881 <p>The compiler declares the supported values of <i>name</i>. Specifying a
882 collector which will cause the compiler to alter its output in order to support
883 the named garbage collection algorithm.</p>
884 </div>
885
886 <!-- ======================================================================= -->
887 <div class="doc_subsection">
888   <a name="moduleasm">Module-Level Inline Assembly</a>
889 </div>
890
891 <div class="doc_text">
892 <p>
893 Modules may contain "module-level inline asm" blocks, which corresponds to the
894 GCC "file scope inline asm" blocks.  These blocks are internally concatenated by
895 LLVM and treated as a single unit, but may be separated in the .ll file if
896 desired.  The syntax is very simple:
897 </p>
898
899 <div class="doc_code">
900 <pre>
901 module asm "inline asm code goes here"
902 module asm "more can go here"
903 </pre>
904 </div>
905
906 <p>The strings can contain any character by escaping non-printable characters.
907    The escape sequence used is simply "\xx" where "xx" is the two digit hex code
908    for the number.
909 </p>
910
911 <p>
912   The inline asm code is simply printed to the machine code .s file when
913   assembly code is generated.
914 </p>
915 </div>
916
917 <!-- ======================================================================= -->
918 <div class="doc_subsection">
919   <a name="datalayout">Data Layout</a>
920 </div>
921
922 <div class="doc_text">
923 <p>A module may specify a target specific data layout string that specifies how
924 data is to be laid out in memory. The syntax for the data layout is simply:</p>
925 <pre>    target datalayout = "<i>layout specification</i>"</pre>
926 <p>The <i>layout specification</i> consists of a list of specifications 
927 separated by the minus sign character ('-').  Each specification starts with a 
928 letter and may include other information after the letter to define some 
929 aspect of the data layout.  The specifications accepted are as follows: </p>
930 <dl>
931   <dt><tt>E</tt></dt>
932   <dd>Specifies that the target lays out data in big-endian form. That is, the
933   bits with the most significance have the lowest address location.</dd>
934   <dt><tt>e</tt></dt>
935   <dd>Specifies that hte target lays out data in little-endian form. That is,
936   the bits with the least significance have the lowest address location.</dd>
937   <dt><tt>p:<i>size</i>:<i>abi</i>:<i>pref</i></tt></dt>
938   <dd>This specifies the <i>size</i> of a pointer and its <i>abi</i> and 
939   <i>preferred</i> alignments. All sizes are in bits. Specifying the <i>pref</i>
940   alignment is optional. If omitted, the preceding <tt>:</tt> should be omitted
941   too.</dd>
942   <dt><tt>i<i>size</i>:<i>abi</i>:<i>pref</i></tt></dt>
943   <dd>This specifies the alignment for an integer type of a given bit
944   <i>size</i>. The value of <i>size</i> must be in the range [1,2^23).</dd>
945   <dt><tt>v<i>size</i>:<i>abi</i>:<i>pref</i></tt></dt>
946   <dd>This specifies the alignment for a vector type of a given bit 
947   <i>size</i>.</dd>
948   <dt><tt>f<i>size</i>:<i>abi</i>:<i>pref</i></tt></dt>
949   <dd>This specifies the alignment for a floating point type of a given bit 
950   <i>size</i>. The value of <i>size</i> must be either 32 (float) or 64
951   (double).</dd>
952   <dt><tt>a<i>size</i>:<i>abi</i>:<i>pref</i></tt></dt>
953   <dd>This specifies the alignment for an aggregate type of a given bit
954   <i>size</i>.</dd>
955 </dl>
956 <p>When constructing the data layout for a given target, LLVM starts with a
957 default set of specifications which are then (possibly) overriden by the
958 specifications in the <tt>datalayout</tt> keyword. The default specifications
959 are given in this list:</p>
960 <ul>
961   <li><tt>E</tt> - big endian</li>
962   <li><tt>p:32:64:64</tt> - 32-bit pointers with 64-bit alignment</li>
963   <li><tt>i1:8:8</tt> - i1 is 8-bit (byte) aligned</li>
964   <li><tt>i8:8:8</tt> - i8 is 8-bit (byte) aligned</li>
965   <li><tt>i16:16:16</tt> - i16 is 16-bit aligned</li>
966   <li><tt>i32:32:32</tt> - i32 is 32-bit aligned</li>
967   <li><tt>i64:32:64</tt> - i64 has abi alignment of 32-bits but preferred
968   alignment of 64-bits</li>
969   <li><tt>f32:32:32</tt> - float is 32-bit aligned</li>
970   <li><tt>f64:64:64</tt> - double is 64-bit aligned</li>
971   <li><tt>v64:64:64</tt> - 64-bit vector is 64-bit aligned</li>
972   <li><tt>v128:128:128</tt> - 128-bit vector is 128-bit aligned</li>
973   <li><tt>a0:0:1</tt> - aggregates are 8-bit aligned</li>
974 </ul>
975 <p>When llvm is determining the alignment for a given type, it uses the 
976 following rules:
977 <ol>
978   <li>If the type sought is an exact match for one of the specifications, that
979   specification is used.</li>
980   <li>If no match is found, and the type sought is an integer type, then the
981   smallest integer type that is larger than the bitwidth of the sought type is
982   used. If none of the specifications are larger than the bitwidth then the the
983   largest integer type is used. For example, given the default specifications
984   above, the i7 type will use the alignment of i8 (next largest) while both
985   i65 and i256 will use the alignment of i64 (largest specified).</li>
986   <li>If no match is found, and the type sought is a vector type, then the
987   largest vector type that is smaller than the sought vector type will be used
988   as a fall back.  This happens because <128 x double> can be implemented in 
989   terms of 64 <2 x double>, for example.</li>
990 </ol>
991 </div>
992
993 <!-- *********************************************************************** -->
994 <div class="doc_section"> <a name="typesystem">Type System</a> </div>
995 <!-- *********************************************************************** -->
996
997 <div class="doc_text">
998
999 <p>The LLVM type system is one of the most important features of the
1000 intermediate representation.  Being typed enables a number of
1001 optimizations to be performed on the IR directly, without having to do
1002 extra analyses on the side before the transformation.  A strong type
1003 system makes it easier to read the generated code and enables novel
1004 analyses and transformations that are not feasible to perform on normal
1005 three address code representations.</p>
1006
1007 </div>
1008
1009 <!-- ======================================================================= -->
1010 <div class="doc_subsection"> <a name="t_classifications">Type
1011 Classifications</a> </div>
1012 <div class="doc_text">
1013 <p>The types fall into a few useful
1014 classifications:</p>
1015
1016 <table border="1" cellspacing="0" cellpadding="4">
1017   <tbody>
1018     <tr><th>Classification</th><th>Types</th></tr>
1019     <tr>
1020       <td><a href="#t_integer">integer</a></td>
1021       <td><tt>i1, i2, i3, ... i8, ... i16, ... i32, ... i64, ... </tt></td>
1022     </tr>
1023     <tr>
1024       <td><a href="#t_floating">floating point</a></td>
1025       <td><tt>float, double, x86_fp80, fp128, ppc_fp128</tt></td>
1026     </tr>
1027     <tr>
1028       <td><a name="t_firstclass">first class</a></td>
1029       <td><a href="#t_integer">integer</a>,
1030           <a href="#t_floating">floating point</a>,
1031           <a href="#t_pointer">pointer</a>,
1032           <a href="#t_vector">vector</a>
1033       </td>
1034     </tr>
1035     <tr>
1036       <td><a href="#t_primitive">primitive</a></td>
1037       <td><a href="#t_label">label</a>,
1038           <a href="#t_void">void</a>,
1039           <a href="#t_integer">integer</a>,
1040           <a href="#t_floating">floating point</a>.</td>
1041     </tr>
1042     <tr>
1043       <td><a href="#t_derived">derived</a></td>
1044       <td><a href="#t_integer">integer</a>,
1045           <a href="#t_array">array</a>,
1046           <a href="#t_function">function</a>,
1047           <a href="#t_pointer">pointer</a>,
1048           <a href="#t_struct">structure</a>,
1049           <a href="#t_pstruct">packed structure</a>,
1050           <a href="#t_vector">vector</a>,
1051           <a href="#t_opaque">opaque</a>.
1052     </tr>
1053   </tbody>
1054 </table>
1055
1056 <p>The <a href="#t_firstclass">first class</a> types are perhaps the
1057 most important.  Values of these types are the only ones which can be
1058 produced by instructions, passed as arguments, or used as operands to
1059 instructions.  This means that all structures and arrays must be
1060 manipulated either by pointer or by component.</p>
1061 </div>
1062
1063 <!-- ======================================================================= -->
1064 <div class="doc_subsection"> <a name="t_primitive">Primitive Types</a> </div>
1065
1066 <div class="doc_text">
1067 <p>The primitive types are the fundamental building blocks of the LLVM
1068 system.</p>
1069
1070 </div>
1071
1072 <!-- _______________________________________________________________________ -->
1073 <div class="doc_subsubsection"> <a name="t_floating">Floating Point Types</a> </div>
1074
1075 <div class="doc_text">
1076       <table>
1077         <tbody>
1078           <tr><th>Type</th><th>Description</th></tr>
1079           <tr><td><tt>float</tt></td><td>32-bit floating point value</td></tr>
1080           <tr><td><tt>double</tt></td><td>64-bit floating point value</td></tr>
1081           <tr><td><tt>fp128</tt></td><td>128-bit floating point value (112-bit mantissa)</td></tr>
1082           <tr><td><tt>x86_fp80</tt></td><td>80-bit floating point value (X87)</td></tr>
1083           <tr><td><tt>ppc_fp128</tt></td><td>128-bit floating point value (two 64-bits)</td></tr>
1084         </tbody>
1085       </table>
1086 </div>
1087
1088 <!-- _______________________________________________________________________ -->
1089 <div class="doc_subsubsection"> <a name="t_void">Void Type</a> </div>
1090
1091 <div class="doc_text">
1092 <h5>Overview:</h5>
1093 <p>The void type does not represent any value and has no size.</p>
1094
1095 <h5>Syntax:</h5>
1096
1097 <pre>
1098   void
1099 </pre>
1100 </div>
1101
1102 <!-- _______________________________________________________________________ -->
1103 <div class="doc_subsubsection"> <a name="t_label">Label Type</a> </div>
1104
1105 <div class="doc_text">
1106 <h5>Overview:</h5>
1107 <p>The label type represents code labels.</p>
1108
1109 <h5>Syntax:</h5>
1110
1111 <pre>
1112   label
1113 </pre>
1114 </div>
1115
1116
1117 <!-- ======================================================================= -->
1118 <div class="doc_subsection"> <a name="t_derived">Derived Types</a> </div>
1119
1120 <div class="doc_text">
1121
1122 <p>The real power in LLVM comes from the derived types in the system. 
1123 This is what allows a programmer to represent arrays, functions,
1124 pointers, and other useful types.  Note that these derived types may be
1125 recursive: For example, it is possible to have a two dimensional array.</p>
1126
1127 </div>
1128
1129 <!-- _______________________________________________________________________ -->
1130 <div class="doc_subsubsection"> <a name="t_integer">Integer Type</a> </div>
1131
1132 <div class="doc_text">
1133
1134 <h5>Overview:</h5>
1135 <p>The integer type is a very simple derived type that simply specifies an
1136 arbitrary bit width for the integer type desired. Any bit width from 1 bit to
1137 2^23-1 (about 8 million) can be specified.</p>
1138
1139 <h5>Syntax:</h5>
1140
1141 <pre>
1142   iN
1143 </pre>
1144
1145 <p>The number of bits the integer will occupy is specified by the <tt>N</tt>
1146 value.</p>
1147
1148 <h5>Examples:</h5>
1149 <table class="layout">
1150   <tbody>
1151   <tr>
1152     <td><tt>i1</tt></td>
1153     <td>a single-bit integer.</td>
1154   </tr><tr>
1155     <td><tt>i32</tt></td>
1156     <td>a 32-bit integer.</td>
1157   </tr><tr>
1158     <td><tt>i1942652</tt></td>
1159     <td>a really big integer of over 1 million bits.</td>
1160   </tr>
1161   </tbody>
1162 </table>
1163 </div>
1164
1165 <!-- _______________________________________________________________________ -->
1166 <div class="doc_subsubsection"> <a name="t_array">Array Type</a> </div>
1167
1168 <div class="doc_text">
1169
1170 <h5>Overview:</h5>
1171
1172 <p>The array type is a very simple derived type that arranges elements
1173 sequentially in memory.  The array type requires a size (number of
1174 elements) and an underlying data type.</p>
1175
1176 <h5>Syntax:</h5>
1177
1178 <pre>
1179   [&lt;# elements&gt; x &lt;elementtype&gt;]
1180 </pre>
1181
1182 <p>The number of elements is a constant integer value; elementtype may
1183 be any type with a size.</p>
1184
1185 <h5>Examples:</h5>
1186 <table class="layout">
1187   <tr class="layout">
1188     <td class="left"><tt>[40 x i32]</tt></td>
1189     <td class="left">Array of 40 32-bit integer values.</td>
1190   </tr>
1191   <tr class="layout">
1192     <td class="left"><tt>[41 x i32]</tt></td>
1193     <td class="left">Array of 41 32-bit integer values.</td>
1194   </tr>
1195   <tr class="layout">
1196     <td class="left"><tt>[4 x i8]</tt></td>
1197     <td class="left">Array of 4 8-bit integer values.</td>
1198   </tr>
1199 </table>
1200 <p>Here are some examples of multidimensional arrays:</p>
1201 <table class="layout">
1202   <tr class="layout">
1203     <td class="left"><tt>[3 x [4 x i32]]</tt></td>
1204     <td class="left">3x4 array of 32-bit integer values.</td>
1205   </tr>
1206   <tr class="layout">
1207     <td class="left"><tt>[12 x [10 x float]]</tt></td>
1208     <td class="left">12x10 array of single precision floating point values.</td>
1209   </tr>
1210   <tr class="layout">
1211     <td class="left"><tt>[2 x [3 x [4 x i16]]]</tt></td>
1212     <td class="left">2x3x4 array of 16-bit integer  values.</td>
1213   </tr>
1214 </table>
1215
1216 <p>Note that 'variable sized arrays' can be implemented in LLVM with a zero 
1217 length array.  Normally, accesses past the end of an array are undefined in
1218 LLVM (e.g. it is illegal to access the 5th element of a 3 element array).
1219 As a special case, however, zero length arrays are recognized to be variable
1220 length.  This allows implementation of 'pascal style arrays' with the  LLVM
1221 type "{ i32, [0 x float]}", for example.</p>
1222
1223 </div>
1224
1225 <!-- _______________________________________________________________________ -->
1226 <div class="doc_subsubsection"> <a name="t_function">Function Type</a> </div>
1227 <div class="doc_text">
1228
1229 <h5>Overview:</h5>
1230
1231 <p>The function type can be thought of as a function signature.  It
1232 consists of a return type and a list of formal parameter types. The
1233 return type of a function type is a scalar type, a void type, or a struct type. 
1234 If the return type is a struct type then all struct elements must be of first 
1235 class types, and the struct must have at least one element.</p>
1236
1237 <h5>Syntax:</h5>
1238
1239 <pre>
1240   &lt;returntype list&gt; (&lt;parameter list&gt;)
1241 </pre>
1242
1243 <p>...where '<tt>&lt;parameter list&gt;</tt>' is a comma-separated list of type
1244 specifiers.  Optionally, the parameter list may include a type <tt>...</tt>,
1245 which indicates that the function takes a variable number of arguments.
1246 Variable argument functions can access their arguments with the <a
1247  href="#int_varargs">variable argument handling intrinsic</a> functions.
1248 '<tt>&lt;returntype list&gt;</tt>' is a comma-separated list of
1249 <a href="#t_firstclass">first class</a> type specifiers.</p>
1250
1251 <h5>Examples:</h5>
1252 <table class="layout">
1253   <tr class="layout">
1254     <td class="left"><tt>i32 (i32)</tt></td>
1255     <td class="left">function taking an <tt>i32</tt>, returning an <tt>i32</tt>
1256     </td>
1257   </tr><tr class="layout">
1258     <td class="left"><tt>float&nbsp;(i16&nbsp;signext,&nbsp;i32&nbsp;*)&nbsp;*
1259     </tt></td>
1260     <td class="left"><a href="#t_pointer">Pointer</a> to a function that takes 
1261       an <tt>i16</tt> that should be sign extended and a 
1262       <a href="#t_pointer">pointer</a> to <tt>i32</tt>, returning 
1263       <tt>float</tt>.
1264     </td>
1265   </tr><tr class="layout">
1266     <td class="left"><tt>i32 (i8*, ...)</tt></td>
1267     <td class="left">A vararg function that takes at least one 
1268       <a href="#t_pointer">pointer</a> to <tt>i8 </tt> (char in C), 
1269       which returns an integer.  This is the signature for <tt>printf</tt> in 
1270       LLVM.
1271     </td>
1272   </tr><tr class="layout">
1273     <td class="left"><tt>{i32, i32} (i32)</tt></td>
1274     <td class="left">A function taking an <tt>i32></tt>, returning two 
1275         <tt> i32 </tt> values as an aggregate of type <tt>{ i32, i32 }</tt>
1276     </td>
1277   </tr>
1278 </table>
1279
1280 </div>
1281 <!-- _______________________________________________________________________ -->
1282 <div class="doc_subsubsection"> <a name="t_struct">Structure Type</a> </div>
1283 <div class="doc_text">
1284 <h5>Overview:</h5>
1285 <p>The structure type is used to represent a collection of data members
1286 together in memory.  The packing of the field types is defined to match
1287 the ABI of the underlying processor.  The elements of a structure may
1288 be any type that has a size.</p>
1289 <p>Structures are accessed using '<tt><a href="#i_load">load</a></tt>
1290 and '<tt><a href="#i_store">store</a></tt>' by getting a pointer to a
1291 field with the '<tt><a href="#i_getelementptr">getelementptr</a></tt>'
1292 instruction.</p>
1293 <h5>Syntax:</h5>
1294 <pre>  { &lt;type list&gt; }<br></pre>
1295 <h5>Examples:</h5>
1296 <table class="layout">
1297   <tr class="layout">
1298     <td class="left"><tt>{ i32, i32, i32 }</tt></td>
1299     <td class="left">A triple of three <tt>i32</tt> values</td>
1300   </tr><tr class="layout">
1301     <td class="left"><tt>{&nbsp;float,&nbsp;i32&nbsp;(i32)&nbsp;*&nbsp;}</tt></td>
1302     <td class="left">A pair, where the first element is a <tt>float</tt> and the
1303       second element is a <a href="#t_pointer">pointer</a> to a
1304       <a href="#t_function">function</a> that takes an <tt>i32</tt>, returning
1305       an <tt>i32</tt>.</td>
1306   </tr>
1307 </table>
1308 </div>
1309
1310 <!-- _______________________________________________________________________ -->
1311 <div class="doc_subsubsection"> <a name="t_pstruct">Packed Structure Type</a>
1312 </div>
1313 <div class="doc_text">
1314 <h5>Overview:</h5>
1315 <p>The packed structure type is used to represent a collection of data members
1316 together in memory.  There is no padding between fields.  Further, the alignment
1317 of a packed structure is 1 byte.  The elements of a packed structure may
1318 be any type that has a size.</p>
1319 <p>Structures are accessed using '<tt><a href="#i_load">load</a></tt>
1320 and '<tt><a href="#i_store">store</a></tt>' by getting a pointer to a
1321 field with the '<tt><a href="#i_getelementptr">getelementptr</a></tt>'
1322 instruction.</p>
1323 <h5>Syntax:</h5>
1324 <pre>  &lt; { &lt;type list&gt; } &gt; <br></pre>
1325 <h5>Examples:</h5>
1326 <table class="layout">
1327   <tr class="layout">
1328     <td class="left"><tt>&lt; { i32, i32, i32 } &gt;</tt></td>
1329     <td class="left">A triple of three <tt>i32</tt> values</td>
1330   </tr><tr class="layout">
1331   <td class="left"><tt>&lt; { float, i32 (i32)* } &gt;</tt></td>
1332     <td class="left">A pair, where the first element is a <tt>float</tt> and the
1333       second element is a <a href="#t_pointer">pointer</a> to a
1334       <a href="#t_function">function</a> that takes an <tt>i32</tt>, returning
1335       an <tt>i32</tt>.</td>
1336   </tr>
1337 </table>
1338 </div>
1339
1340 <!-- _______________________________________________________________________ -->
1341 <div class="doc_subsubsection"> <a name="t_pointer">Pointer Type</a> </div>
1342 <div class="doc_text">
1343 <h5>Overview:</h5>
1344 <p>As in many languages, the pointer type represents a pointer or
1345 reference to another object, which must live in memory. Pointer types may have 
1346 an optional address space attribute defining the target-specific numbered 
1347 address space where the pointed-to object resides. The default address space is 
1348 zero.</p>
1349 <h5>Syntax:</h5>
1350 <pre>  &lt;type&gt; *<br></pre>
1351 <h5>Examples:</h5>
1352 <table class="layout">
1353   <tr class="layout">
1354     <td class="left"><tt>[4x i32]*</tt></td>
1355     <td class="left">A <a href="#t_pointer">pointer</a> to <a
1356                     href="#t_array">array</a> of four <tt>i32</tt> values.</td>
1357   </tr>
1358   <tr class="layout">
1359     <td class="left"><tt>i32 (i32 *) *</tt></td>
1360     <td class="left"> A <a href="#t_pointer">pointer</a> to a <a
1361       href="#t_function">function</a> that takes an <tt>i32*</tt>, returning an
1362       <tt>i32</tt>.</td>
1363   </tr>
1364   <tr class="layout">
1365     <td class="left"><tt>i32 addrspace(5)*</tt></td>
1366     <td class="left">A <a href="#t_pointer">pointer</a> to an <tt>i32</tt> value
1367      that resides in address space #5.</td>
1368   </tr>
1369 </table>
1370 </div>
1371
1372 <!-- _______________________________________________________________________ -->
1373 <div class="doc_subsubsection"> <a name="t_vector">Vector Type</a> </div>
1374 <div class="doc_text">
1375
1376 <h5>Overview:</h5>
1377
1378 <p>A vector type is a simple derived type that represents a vector
1379 of elements.  Vector types are used when multiple primitive data 
1380 are operated in parallel using a single instruction (SIMD). 
1381 A vector type requires a size (number of
1382 elements) and an underlying primitive data type.  Vectors must have a power
1383 of two length (1, 2, 4, 8, 16 ...).  Vector types are
1384 considered <a href="#t_firstclass">first class</a>.</p>
1385
1386 <h5>Syntax:</h5>
1387
1388 <pre>
1389   &lt; &lt;# elements&gt; x &lt;elementtype&gt; &gt;
1390 </pre>
1391
1392 <p>The number of elements is a constant integer value; elementtype may
1393 be any integer or floating point type.</p>
1394
1395 <h5>Examples:</h5>
1396
1397 <table class="layout">
1398   <tr class="layout">
1399     <td class="left"><tt>&lt;4 x i32&gt;</tt></td>
1400     <td class="left">Vector of 4 32-bit integer values.</td>
1401   </tr>
1402   <tr class="layout">
1403     <td class="left"><tt>&lt;8 x float&gt;</tt></td>
1404     <td class="left">Vector of 8 32-bit floating-point values.</td>
1405   </tr>
1406   <tr class="layout">
1407     <td class="left"><tt>&lt;2 x i64&gt;</tt></td>
1408     <td class="left">Vector of 2 64-bit integer values.</td>
1409   </tr>
1410 </table>
1411 </div>
1412
1413 <!-- _______________________________________________________________________ -->
1414 <div class="doc_subsubsection"> <a name="t_opaque">Opaque Type</a> </div>
1415 <div class="doc_text">
1416
1417 <h5>Overview:</h5>
1418
1419 <p>Opaque types are used to represent unknown types in the system.  This
1420 corresponds (for example) to the C notion of a forward declared structure type.
1421 In LLVM, opaque types can eventually be resolved to any type (not just a
1422 structure type).</p>
1423
1424 <h5>Syntax:</h5>
1425
1426 <pre>
1427   opaque
1428 </pre>
1429
1430 <h5>Examples:</h5>
1431
1432 <table class="layout">
1433   <tr class="layout">
1434     <td class="left"><tt>opaque</tt></td>
1435     <td class="left">An opaque type.</td>
1436   </tr>
1437 </table>
1438 </div>
1439
1440
1441 <!-- *********************************************************************** -->
1442 <div class="doc_section"> <a name="constants">Constants</a> </div>
1443 <!-- *********************************************************************** -->
1444
1445 <div class="doc_text">
1446
1447 <p>LLVM has several different basic types of constants.  This section describes
1448 them all and their syntax.</p>
1449
1450 </div>
1451
1452 <!-- ======================================================================= -->
1453 <div class="doc_subsection"><a name="simpleconstants">Simple Constants</a></div>
1454
1455 <div class="doc_text">
1456
1457 <dl>
1458   <dt><b>Boolean constants</b></dt>
1459
1460   <dd>The two strings '<tt>true</tt>' and '<tt>false</tt>' are both valid
1461   constants of the <tt><a href="#t_primitive">i1</a></tt> type.
1462   </dd>
1463
1464   <dt><b>Integer constants</b></dt>
1465
1466   <dd>Standard integers (such as '4') are constants of the <a
1467   href="#t_integer">integer</a> type.  Negative numbers may be used with 
1468   integer types.
1469   </dd>
1470
1471   <dt><b>Floating point constants</b></dt>
1472
1473   <dd>Floating point constants use standard decimal notation (e.g. 123.421),
1474   exponential notation (e.g. 1.23421e+2), or a more precise hexadecimal
1475   notation (see below).  The assembler requires the exact decimal value of
1476   a floating-point constant.  For example, the assembler accepts 1.25 but
1477   rejects 1.3 because 1.3 is a repeating decimal in binary.  Floating point
1478   constants must have a <a href="#t_floating">floating point</a> type. </dd>
1479
1480   <dt><b>Null pointer constants</b></dt>
1481
1482   <dd>The identifier '<tt>null</tt>' is recognized as a null pointer constant
1483   and must be of <a href="#t_pointer">pointer type</a>.</dd>
1484
1485 </dl>
1486
1487 <p>The one non-intuitive notation for constants is the optional hexadecimal form
1488 of floating point constants.  For example, the form '<tt>double
1489 0x432ff973cafa8000</tt>' is equivalent to (but harder to read than) '<tt>double
1490 4.5e+15</tt>'.  The only time hexadecimal floating point constants are required
1491 (and the only time that they are generated by the disassembler) is when a 
1492 floating point constant must be emitted but it cannot be represented as a 
1493 decimal floating point number.  For example, NaN's, infinities, and other 
1494 special values are represented in their IEEE hexadecimal format so that 
1495 assembly and disassembly do not cause any bits to change in the constants.</p>
1496
1497 </div>
1498
1499 <!-- ======================================================================= -->
1500 <div class="doc_subsection"><a name="aggregateconstants">Aggregate Constants</a>
1501 </div>
1502
1503 <div class="doc_text">
1504 <p>Aggregate constants arise from aggregation of simple constants
1505 and smaller aggregate constants.</p>
1506
1507 <dl>
1508   <dt><b>Structure constants</b></dt>
1509
1510   <dd>Structure constants are represented with notation similar to structure
1511   type definitions (a comma separated list of elements, surrounded by braces
1512   (<tt>{}</tt>)).  For example: "<tt>{ i32 4, float 17.0, i32* @G }</tt>",
1513   where "<tt>@G</tt>" is declared as "<tt>@G = external global i32</tt>".  Structure constants
1514   must have <a href="#t_struct">structure type</a>, and the number and
1515   types of elements must match those specified by the type.
1516   </dd>
1517
1518   <dt><b>Array constants</b></dt>
1519
1520   <dd>Array constants are represented with notation similar to array type
1521   definitions (a comma separated list of elements, surrounded by square brackets
1522   (<tt>[]</tt>)).  For example: "<tt>[ i32 42, i32 11, i32 74 ]</tt>".  Array
1523   constants must have <a href="#t_array">array type</a>, and the number and
1524   types of elements must match those specified by the type.
1525   </dd>
1526
1527   <dt><b>Vector constants</b></dt>
1528
1529   <dd>Vector constants are represented with notation similar to vector type
1530   definitions (a comma separated list of elements, surrounded by
1531   less-than/greater-than's (<tt>&lt;&gt;</tt>)).  For example: "<tt>&lt; i32 42,
1532   i32 11, i32 74, i32 100 &gt;</tt>".  Vector constants must have <a
1533   href="#t_vector">vector type</a>, and the number and types of elements must
1534   match those specified by the type.
1535   </dd>
1536
1537   <dt><b>Zero initialization</b></dt>
1538
1539   <dd>The string '<tt>zeroinitializer</tt>' can be used to zero initialize a
1540   value to zero of <em>any</em> type, including scalar and aggregate types.
1541   This is often used to avoid having to print large zero initializers (e.g. for
1542   large arrays) and is always exactly equivalent to using explicit zero
1543   initializers.
1544   </dd>
1545 </dl>
1546
1547 </div>
1548
1549 <!-- ======================================================================= -->
1550 <div class="doc_subsection">
1551   <a name="globalconstants">Global Variable and Function Addresses</a>
1552 </div>
1553
1554 <div class="doc_text">
1555
1556 <p>The addresses of <a href="#globalvars">global variables</a> and <a
1557 href="#functionstructure">functions</a> are always implicitly valid (link-time)
1558 constants.  These constants are explicitly referenced when the <a
1559 href="#identifiers">identifier for the global</a> is used and always have <a
1560 href="#t_pointer">pointer</a> type. For example, the following is a legal LLVM
1561 file:</p>
1562
1563 <div class="doc_code">
1564 <pre>
1565 @X = global i32 17
1566 @Y = global i32 42
1567 @Z = global [2 x i32*] [ i32* @X, i32* @Y ]
1568 </pre>
1569 </div>
1570
1571 </div>
1572
1573 <!-- ======================================================================= -->
1574 <div class="doc_subsection"><a name="undefvalues">Undefined Values</a></div>
1575 <div class="doc_text">
1576   <p>The string '<tt>undef</tt>' is recognized as a type-less constant that has 
1577   no specific value.  Undefined values may be of any type and be used anywhere 
1578   a constant is permitted.</p>
1579
1580   <p>Undefined values indicate to the compiler that the program is well defined
1581   no matter what value is used, giving the compiler more freedom to optimize.
1582   </p>
1583 </div>
1584
1585 <!-- ======================================================================= -->
1586 <div class="doc_subsection"><a name="constantexprs">Constant Expressions</a>
1587 </div>
1588
1589 <div class="doc_text">
1590
1591 <p>Constant expressions are used to allow expressions involving other constants
1592 to be used as constants.  Constant expressions may be of any <a
1593 href="#t_firstclass">first class</a> type and may involve any LLVM operation
1594 that does not have side effects (e.g. load and call are not supported).  The
1595 following is the syntax for constant expressions:</p>
1596
1597 <dl>
1598   <dt><b><tt>trunc ( CST to TYPE )</tt></b></dt>
1599   <dd>Truncate a constant to another type. The bit size of CST must be larger 
1600   than the bit size of TYPE. Both types must be integers.</dd>
1601
1602   <dt><b><tt>zext ( CST to TYPE )</tt></b></dt>
1603   <dd>Zero extend a constant to another type. The bit size of CST must be 
1604   smaller or equal to the bit size of TYPE.  Both types must be integers.</dd>
1605
1606   <dt><b><tt>sext ( CST to TYPE )</tt></b></dt>
1607   <dd>Sign extend a constant to another type. The bit size of CST must be 
1608   smaller or equal to the bit size of TYPE.  Both types must be integers.</dd>
1609
1610   <dt><b><tt>fptrunc ( CST to TYPE )</tt></b></dt>
1611   <dd>Truncate a floating point constant to another floating point type. The 
1612   size of CST must be larger than the size of TYPE. Both types must be 
1613   floating point.</dd>
1614
1615   <dt><b><tt>fpext ( CST to TYPE )</tt></b></dt>
1616   <dd>Floating point extend a constant to another type. The size of CST must be 
1617   smaller or equal to the size of TYPE. Both types must be floating point.</dd>
1618
1619   <dt><b><tt>fptoui ( CST to TYPE )</tt></b></dt>
1620   <dd>Convert a floating point constant to the corresponding unsigned integer
1621   constant. TYPE must be a scalar or vector integer type. CST must be of scalar
1622   or vector floating point type. Both CST and TYPE must be scalars, or vectors
1623   of the same number of elements. If the  value won't fit in the integer type,
1624   the results are undefined.</dd>
1625
1626   <dt><b><tt>fptosi ( CST to TYPE )</tt></b></dt>
1627   <dd>Convert a floating point constant to the corresponding signed integer
1628   constant.  TYPE must be a scalar or vector integer type. CST must be of scalar
1629   or vector floating point type. Both CST and TYPE must be scalars, or vectors
1630   of the same number of elements. If the  value won't fit in the integer type,
1631   the results are undefined.</dd>
1632
1633   <dt><b><tt>uitofp ( CST to TYPE )</tt></b></dt>
1634   <dd>Convert an unsigned integer constant to the corresponding floating point
1635   constant. TYPE must be a scalar or vector floating point type. CST must be of
1636   scalar or vector integer type. Both CST and TYPE must be scalars, or vectors
1637   of the same number of elements. If the value won't fit in the floating point 
1638   type, the results are undefined.</dd>
1639
1640   <dt><b><tt>sitofp ( CST to TYPE )</tt></b></dt>
1641   <dd>Convert a signed integer constant to the corresponding floating point
1642   constant. TYPE must be a scalar or vector floating point type. CST must be of
1643   scalar or vector integer type. Both CST and TYPE must be scalars, or vectors
1644   of the same number of elements. If the value won't fit in the floating point 
1645   type, the results are undefined.</dd>
1646
1647   <dt><b><tt>ptrtoint ( CST to TYPE )</tt></b></dt>
1648   <dd>Convert a pointer typed constant to the corresponding integer constant
1649   TYPE must be an integer type. CST must be of pointer type. The CST value is
1650   zero extended, truncated, or unchanged to make it fit in TYPE.</dd>
1651
1652   <dt><b><tt>inttoptr ( CST to TYPE )</tt></b></dt>
1653   <dd>Convert a integer constant to a pointer constant.  TYPE must be a
1654   pointer type.  CST must be of integer type. The CST value is zero extended, 
1655   truncated, or unchanged to make it fit in a pointer size. This one is 
1656   <i>really</i> dangerous!</dd>
1657
1658   <dt><b><tt>bitcast ( CST to TYPE )</tt></b></dt>
1659   <dd>Convert a constant, CST, to another TYPE. The size of CST and TYPE must be
1660   identical (same number of bits). The conversion is done as if the CST value
1661   was stored to memory and read back as TYPE. In other words, no bits change 
1662   with this operator, just the type.  This can be used for conversion of
1663   vector types to any other type, as long as they have the same bit width. For
1664   pointers it is only valid to cast to another pointer type.
1665   </dd>
1666
1667   <dt><b><tt>getelementptr ( CSTPTR, IDX0, IDX1, ... )</tt></b></dt>
1668
1669   <dd>Perform the <a href="#i_getelementptr">getelementptr operation</a> on
1670   constants.  As with the <a href="#i_getelementptr">getelementptr</a>
1671   instruction, the index list may have zero or more indexes, which are required
1672   to make sense for the type of "CSTPTR".</dd>
1673
1674   <dt><b><tt>select ( COND, VAL1, VAL2 )</tt></b></dt>
1675
1676   <dd>Perform the <a href="#i_select">select operation</a> on
1677   constants.</dd>
1678
1679   <dt><b><tt>icmp COND ( VAL1, VAL2 )</tt></b></dt>
1680   <dd>Performs the <a href="#i_icmp">icmp operation</a> on constants.</dd>
1681
1682   <dt><b><tt>fcmp COND ( VAL1, VAL2 )</tt></b></dt>
1683   <dd>Performs the <a href="#i_fcmp">fcmp operation</a> on constants.</dd>
1684
1685   <dt><b><tt>vicmp COND ( VAL1, VAL2 )</tt></b></dt>
1686   <dd>Performs the <a href="#i_vicmp">vicmp operation</a> on constants.</dd>
1687
1688   <dt><b><tt>vfcmp COND ( VAL1, VAL2 )</tt></b></dt>
1689   <dd>Performs the <a href="#i_vfcmp">vfcmp operation</a> on constants.</dd>
1690
1691   <dt><b><tt>extractelement ( VAL, IDX )</tt></b></dt>
1692
1693   <dd>Perform the <a href="#i_extractelement">extractelement
1694   operation</a> on constants.
1695
1696   <dt><b><tt>insertelement ( VAL, ELT, IDX )</tt></b></dt>
1697
1698   <dd>Perform the <a href="#i_insertelement">insertelement
1699     operation</a> on constants.</dd>
1700
1701
1702   <dt><b><tt>shufflevector ( VEC1, VEC2, IDXMASK )</tt></b></dt>
1703
1704   <dd>Perform the <a href="#i_shufflevector">shufflevector
1705     operation</a> on constants.</dd>
1706
1707   <dt><b><tt>OPCODE ( LHS, RHS )</tt></b></dt>
1708
1709   <dd>Perform the specified operation of the LHS and RHS constants. OPCODE may 
1710   be any of the <a href="#binaryops">binary</a> or <a href="#bitwiseops">bitwise
1711   binary</a> operations.  The constraints on operands are the same as those for
1712   the corresponding instruction (e.g. no bitwise operations on floating point
1713   values are allowed).</dd>
1714 </dl>
1715 </div>
1716
1717 <!-- *********************************************************************** -->
1718 <div class="doc_section"> <a name="othervalues">Other Values</a> </div>
1719 <!-- *********************************************************************** -->
1720
1721 <!-- ======================================================================= -->
1722 <div class="doc_subsection">
1723 <a name="inlineasm">Inline Assembler Expressions</a>
1724 </div>
1725
1726 <div class="doc_text">
1727
1728 <p>
1729 LLVM supports inline assembler expressions (as opposed to <a href="#moduleasm">
1730 Module-Level Inline Assembly</a>) through the use of a special value.  This
1731 value represents the inline assembler as a string (containing the instructions
1732 to emit), a list of operand constraints (stored as a string), and a flag that 
1733 indicates whether or not the inline asm expression has side effects.  An example
1734 inline assembler expression is:
1735 </p>
1736
1737 <div class="doc_code">
1738 <pre>
1739 i32 (i32) asm "bswap $0", "=r,r"
1740 </pre>
1741 </div>
1742
1743 <p>
1744 Inline assembler expressions may <b>only</b> be used as the callee operand of
1745 a <a href="#i_call"><tt>call</tt> instruction</a>.  Thus, typically we have:
1746 </p>
1747
1748 <div class="doc_code">
1749 <pre>
1750 %X = call i32 asm "<a href="#int_bswap">bswap</a> $0", "=r,r"(i32 %Y)
1751 </pre>
1752 </div>
1753
1754 <p>
1755 Inline asms with side effects not visible in the constraint list must be marked
1756 as having side effects.  This is done through the use of the
1757 '<tt>sideeffect</tt>' keyword, like so:
1758 </p>
1759
1760 <div class="doc_code">
1761 <pre>
1762 call void asm sideeffect "eieio", ""()
1763 </pre>
1764 </div>
1765
1766 <p>TODO: The format of the asm and constraints string still need to be
1767 documented here.  Constraints on what can be done (e.g. duplication, moving, etc
1768 need to be documented).
1769 </p>
1770
1771 </div>
1772
1773 <!-- *********************************************************************** -->
1774 <div class="doc_section"> <a name="instref">Instruction Reference</a> </div>
1775 <!-- *********************************************************************** -->
1776
1777 <div class="doc_text">
1778
1779 <p>The LLVM instruction set consists of several different
1780 classifications of instructions: <a href="#terminators">terminator
1781 instructions</a>, <a href="#binaryops">binary instructions</a>,
1782 <a href="#bitwiseops">bitwise binary instructions</a>, <a
1783  href="#memoryops">memory instructions</a>, and <a href="#otherops">other
1784 instructions</a>.</p>
1785
1786 </div>
1787
1788 <!-- ======================================================================= -->
1789 <div class="doc_subsection"> <a name="terminators">Terminator
1790 Instructions</a> </div>
1791
1792 <div class="doc_text">
1793
1794 <p>As mentioned <a href="#functionstructure">previously</a>, every
1795 basic block in a program ends with a "Terminator" instruction, which
1796 indicates which block should be executed after the current block is
1797 finished. These terminator instructions typically yield a '<tt>void</tt>'
1798 value: they produce control flow, not values (the one exception being
1799 the '<a href="#i_invoke"><tt>invoke</tt></a>' instruction).</p>
1800 <p>There are six different terminator instructions: the '<a
1801  href="#i_ret"><tt>ret</tt></a>' instruction, the '<a href="#i_br"><tt>br</tt></a>'
1802 instruction, the '<a href="#i_switch"><tt>switch</tt></a>' instruction,
1803 the '<a href="#i_invoke"><tt>invoke</tt></a>' instruction, the '<a
1804  href="#i_unwind"><tt>unwind</tt></a>' instruction, and the '<a
1805  href="#i_unreachable"><tt>unreachable</tt></a>' instruction.</p>
1806
1807 </div>
1808
1809 <!-- _______________________________________________________________________ -->
1810 <div class="doc_subsubsection"> <a name="i_ret">'<tt>ret</tt>'
1811 Instruction</a> </div>
1812 <div class="doc_text">
1813 <h5>Syntax:</h5>
1814 <pre>  ret &lt;type&gt; &lt;value&gt;       <i>; Return a value from a non-void function</i>
1815   ret void                 <i>; Return from void function</i>
1816   ret &lt;type&gt; &lt;value&gt;, &lt;type&gt; &lt;value&gt;  <i>; Return two values from a non-void function </i>
1817 </pre>
1818
1819 <h5>Overview:</h5>
1820
1821 <p>The '<tt>ret</tt>' instruction is used to return control flow (and a
1822 value) from a function back to the caller.</p>
1823 <p>There are two forms of the '<tt>ret</tt>' instruction: one that
1824 returns value(s) and then causes control flow, and one that just causes
1825 control flow to occur.</p>
1826
1827 <h5>Arguments:</h5>
1828
1829 <p>The '<tt>ret</tt>' instruction may return zero, one or multiple values. 
1830 The type of each return value must be a '<a href="#t_firstclass">first 
1831 class</a>' type.  Note that a function is not <a href="#wellformed">well 
1832 formed</a> if there exists a '<tt>ret</tt>' instruction inside of the 
1833 function that returns values that do not match the return type of the 
1834 function.</p>
1835
1836 <h5>Semantics:</h5>
1837
1838 <p>When the '<tt>ret</tt>' instruction is executed, control flow
1839 returns back to the calling function's context.  If the caller is a "<a
1840  href="#i_call"><tt>call</tt></a>" instruction, execution continues at
1841 the instruction after the call.  If the caller was an "<a
1842  href="#i_invoke"><tt>invoke</tt></a>" instruction, execution continues
1843 at the beginning of the "normal" destination block.  If the instruction
1844 returns a value, that value shall set the call or invoke instruction's
1845 return value. If the instruction returns multiple values then these 
1846 values can only be accessed through a '<a href="#i_getresult"><tt>getresult</tt>
1847 </a>' instruction.</p>
1848
1849 <h5>Example:</h5>
1850
1851 <pre>
1852   ret i32 5                       <i>; Return an integer value of 5</i>
1853   ret void                        <i>; Return from a void function</i>
1854   ret i32 4, i8 2                 <i>; Return two values 4 and 2 </i> 
1855 </pre>
1856 </div>
1857 <!-- _______________________________________________________________________ -->
1858 <div class="doc_subsubsection"> <a name="i_br">'<tt>br</tt>' Instruction</a> </div>
1859 <div class="doc_text">
1860 <h5>Syntax:</h5>
1861 <pre>  br i1 &lt;cond&gt;, label &lt;iftrue&gt;, label &lt;iffalse&gt;<br>  br label &lt;dest&gt;          <i>; Unconditional branch</i>
1862 </pre>
1863 <h5>Overview:</h5>
1864 <p>The '<tt>br</tt>' instruction is used to cause control flow to
1865 transfer to a different basic block in the current function.  There are
1866 two forms of this instruction, corresponding to a conditional branch
1867 and an unconditional branch.</p>
1868 <h5>Arguments:</h5>
1869 <p>The conditional branch form of the '<tt>br</tt>' instruction takes a
1870 single '<tt>i1</tt>' value and two '<tt>label</tt>' values.  The
1871 unconditional form of the '<tt>br</tt>' instruction takes a single 
1872 '<tt>label</tt>' value as a target.</p>
1873 <h5>Semantics:</h5>
1874 <p>Upon execution of a conditional '<tt>br</tt>' instruction, the '<tt>i1</tt>'
1875 argument is evaluated.  If the value is <tt>true</tt>, control flows
1876 to the '<tt>iftrue</tt>' <tt>label</tt> argument.  If "cond" is <tt>false</tt>,
1877 control flows to the '<tt>iffalse</tt>' <tt>label</tt> argument.</p>
1878 <h5>Example:</h5>
1879 <pre>Test:<br>  %cond = <a href="#i_icmp">icmp</a> eq, i32 %a, %b<br>  br i1 %cond, label %IfEqual, label %IfUnequal<br>IfEqual:<br>  <a
1880  href="#i_ret">ret</a> i32 1<br>IfUnequal:<br>  <a href="#i_ret">ret</a> i32 0<br></pre>
1881 </div>
1882 <!-- _______________________________________________________________________ -->
1883 <div class="doc_subsubsection">
1884    <a name="i_switch">'<tt>switch</tt>' Instruction</a>
1885 </div>
1886
1887 <div class="doc_text">
1888 <h5>Syntax:</h5>
1889
1890 <pre>
1891   switch &lt;intty&gt; &lt;value&gt;, label &lt;defaultdest&gt; [ &lt;intty&gt; &lt;val&gt;, label &lt;dest&gt; ... ]
1892 </pre>
1893
1894 <h5>Overview:</h5>
1895
1896 <p>The '<tt>switch</tt>' instruction is used to transfer control flow to one of
1897 several different places.  It is a generalization of the '<tt>br</tt>'
1898 instruction, allowing a branch to occur to one of many possible
1899 destinations.</p>
1900
1901
1902 <h5>Arguments:</h5>
1903
1904 <p>The '<tt>switch</tt>' instruction uses three parameters: an integer
1905 comparison value '<tt>value</tt>', a default '<tt>label</tt>' destination, and
1906 an array of pairs of comparison value constants and '<tt>label</tt>'s.  The
1907 table is not allowed to contain duplicate constant entries.</p>
1908
1909 <h5>Semantics:</h5>
1910
1911 <p>The <tt>switch</tt> instruction specifies a table of values and
1912 destinations. When the '<tt>switch</tt>' instruction is executed, this
1913 table is searched for the given value.  If the value is found, control flow is
1914 transfered to the corresponding destination; otherwise, control flow is
1915 transfered to the default destination.</p>
1916
1917 <h5>Implementation:</h5>
1918
1919 <p>Depending on properties of the target machine and the particular
1920 <tt>switch</tt> instruction, this instruction may be code generated in different
1921 ways.  For example, it could be generated as a series of chained conditional
1922 branches or with a lookup table.</p>
1923
1924 <h5>Example:</h5>
1925
1926 <pre>
1927  <i>; Emulate a conditional br instruction</i>
1928  %Val = <a href="#i_zext">zext</a> i1 %value to i32
1929  switch i32 %Val, label %truedest [i32 0, label %falsedest ]
1930
1931  <i>; Emulate an unconditional br instruction</i>
1932  switch i32 0, label %dest [ ]
1933
1934  <i>; Implement a jump table:</i>
1935  switch i32 %val, label %otherwise [ i32 0, label %onzero 
1936                                       i32 1, label %onone 
1937                                       i32 2, label %ontwo ]
1938 </pre>
1939 </div>
1940
1941 <!-- _______________________________________________________________________ -->
1942 <div class="doc_subsubsection">
1943   <a name="i_invoke">'<tt>invoke</tt>' Instruction</a>
1944 </div>
1945
1946 <div class="doc_text">
1947
1948 <h5>Syntax:</h5>
1949
1950 <pre>
1951   &lt;result&gt; = invoke [<a href="#callingconv">cconv</a>] &lt;ptr to function ty&gt; &lt;function ptr val&gt;(&lt;function args&gt;) 
1952                 to label &lt;normal label&gt; unwind label &lt;exception label&gt;
1953 </pre>
1954
1955 <h5>Overview:</h5>
1956
1957 <p>The '<tt>invoke</tt>' instruction causes control to transfer to a specified
1958 function, with the possibility of control flow transfer to either the
1959 '<tt>normal</tt>' label or the
1960 '<tt>exception</tt>' label.  If the callee function returns with the
1961 "<tt><a href="#i_ret">ret</a></tt>" instruction, control flow will return to the
1962 "normal" label.  If the callee (or any indirect callees) returns with the "<a
1963 href="#i_unwind"><tt>unwind</tt></a>" instruction, control is interrupted and
1964 continued at the dynamically nearest "exception" label. If the callee function 
1965 returns multiple values then individual return values are only accessible through 
1966 a '<tt><a href="#i_getresult">getresult</a></tt>' instruction.</p>
1967
1968 <h5>Arguments:</h5>
1969
1970 <p>This instruction requires several arguments:</p>
1971
1972 <ol>
1973   <li>
1974     The optional "cconv" marker indicates which <a href="#callingconv">calling
1975     convention</a> the call should use.  If none is specified, the call defaults
1976     to using C calling conventions.
1977   </li>
1978   <li>'<tt>ptr to function ty</tt>': shall be the signature of the pointer to
1979   function value being invoked.  In most cases, this is a direct function
1980   invocation, but indirect <tt>invoke</tt>s are just as possible, branching off
1981   an arbitrary pointer to function value.
1982   </li>
1983
1984   <li>'<tt>function ptr val</tt>': An LLVM value containing a pointer to a
1985   function to be invoked. </li>
1986
1987   <li>'<tt>function args</tt>': argument list whose types match the function
1988   signature argument types.  If the function signature indicates the function
1989   accepts a variable number of arguments, the extra arguments can be
1990   specified. </li>
1991
1992   <li>'<tt>normal label</tt>': the label reached when the called function
1993   executes a '<tt><a href="#i_ret">ret</a></tt>' instruction. </li>
1994
1995   <li>'<tt>exception label</tt>': the label reached when a callee returns with
1996   the <a href="#i_unwind"><tt>unwind</tt></a> instruction. </li>
1997
1998 </ol>
1999
2000 <h5>Semantics:</h5>
2001
2002 <p>This instruction is designed to operate as a standard '<tt><a
2003 href="#i_call">call</a></tt>' instruction in most regards.  The primary
2004 difference is that it establishes an association with a label, which is used by
2005 the runtime library to unwind the stack.</p>
2006
2007 <p>This instruction is used in languages with destructors to ensure that proper
2008 cleanup is performed in the case of either a <tt>longjmp</tt> or a thrown
2009 exception.  Additionally, this is important for implementation of
2010 '<tt>catch</tt>' clauses in high-level languages that support them.</p>
2011
2012 <h5>Example:</h5>
2013 <pre>
2014   %retval = invoke i32 @Test(i32 15) to label %Continue
2015               unwind label %TestCleanup              <i>; {i32}:retval set</i>
2016   %retval = invoke <a href="#callingconv">coldcc</a> i32 %Testfnptr(i32 15) to label %Continue
2017               unwind label %TestCleanup              <i>; {i32}:retval set</i>
2018 </pre>
2019 </div>
2020
2021
2022 <!-- _______________________________________________________________________ -->
2023
2024 <div class="doc_subsubsection"> <a name="i_unwind">'<tt>unwind</tt>'
2025 Instruction</a> </div>
2026
2027 <div class="doc_text">
2028
2029 <h5>Syntax:</h5>
2030 <pre>
2031   unwind
2032 </pre>
2033
2034 <h5>Overview:</h5>
2035
2036 <p>The '<tt>unwind</tt>' instruction unwinds the stack, continuing control flow
2037 at the first callee in the dynamic call stack which used an <a
2038 href="#i_invoke"><tt>invoke</tt></a> instruction to perform the call.  This is
2039 primarily used to implement exception handling.</p>
2040
2041 <h5>Semantics:</h5>
2042
2043 <p>The '<tt>unwind</tt>' instruction causes execution of the current function to
2044 immediately halt.  The dynamic call stack is then searched for the first <a
2045 href="#i_invoke"><tt>invoke</tt></a> instruction on the call stack.  Once found,
2046 execution continues at the "exceptional" destination block specified by the
2047 <tt>invoke</tt> instruction.  If there is no <tt>invoke</tt> instruction in the
2048 dynamic call chain, undefined behavior results.</p>
2049 </div>
2050
2051 <!-- _______________________________________________________________________ -->
2052
2053 <div class="doc_subsubsection"> <a name="i_unreachable">'<tt>unreachable</tt>'
2054 Instruction</a> </div>
2055
2056 <div class="doc_text">
2057
2058 <h5>Syntax:</h5>
2059 <pre>
2060   unreachable
2061 </pre>
2062
2063 <h5>Overview:</h5>
2064
2065 <p>The '<tt>unreachable</tt>' instruction has no defined semantics.  This
2066 instruction is used to inform the optimizer that a particular portion of the
2067 code is not reachable.  This can be used to indicate that the code after a
2068 no-return function cannot be reached, and other facts.</p>
2069
2070 <h5>Semantics:</h5>
2071
2072 <p>The '<tt>unreachable</tt>' instruction has no defined semantics.</p>
2073 </div>
2074
2075
2076
2077 <!-- ======================================================================= -->
2078 <div class="doc_subsection"> <a name="binaryops">Binary Operations</a> </div>
2079 <div class="doc_text">
2080 <p>Binary operators are used to do most of the computation in a
2081 program.  They require two operands of the same type, execute an operation on them, and
2082 produce a single value.  The operands might represent 
2083 multiple data, as is the case with the <a href="#t_vector">vector</a> data type. 
2084 The result value has the same type as its operands.</p>
2085 <p>There are several different binary operators:</p>
2086 </div>
2087 <!-- _______________________________________________________________________ -->
2088 <div class="doc_subsubsection"> <a name="i_add">'<tt>add</tt>'
2089 Instruction</a> </div>
2090 <div class="doc_text">
2091 <h5>Syntax:</h5>
2092 <pre>  &lt;result&gt; = add &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt;   <i>; yields {ty}:result</i>
2093 </pre>
2094 <h5>Overview:</h5>
2095 <p>The '<tt>add</tt>' instruction returns the sum of its two operands.</p>
2096 <h5>Arguments:</h5>
2097 <p>The two arguments to the '<tt>add</tt>' instruction must be either <a
2098  href="#t_integer">integer</a> or <a href="#t_floating">floating point</a> values.
2099  This instruction can also take <a href="#t_vector">vector</a> versions of the values.
2100 Both arguments must have identical types.</p>
2101 <h5>Semantics:</h5>
2102 <p>The value produced is the integer or floating point sum of the two
2103 operands.</p>
2104 <p>If an integer sum has unsigned overflow, the result returned is the
2105 mathematical result modulo 2<sup>n</sup>, where n is the bit width of
2106 the result.</p>
2107 <p>Because LLVM integers use a two's complement representation, this
2108 instruction is appropriate for both signed and unsigned integers.</p>
2109 <h5>Example:</h5>
2110 <pre>  &lt;result&gt; = add i32 4, %var          <i>; yields {i32}:result = 4 + %var</i>
2111 </pre>
2112 </div>
2113 <!-- _______________________________________________________________________ -->
2114 <div class="doc_subsubsection"> <a name="i_sub">'<tt>sub</tt>'
2115 Instruction</a> </div>
2116 <div class="doc_text">
2117 <h5>Syntax:</h5>
2118 <pre>  &lt;result&gt; = sub &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt;   <i>; yields {ty}:result</i>
2119 </pre>
2120 <h5>Overview:</h5>
2121 <p>The '<tt>sub</tt>' instruction returns the difference of its two
2122 operands.</p>
2123 <p>Note that the '<tt>sub</tt>' instruction is used to represent the '<tt>neg</tt>'
2124 instruction present in most other intermediate representations.</p>
2125 <h5>Arguments:</h5>
2126 <p>The two arguments to the '<tt>sub</tt>' instruction must be either <a
2127  href="#t_integer">integer</a> or <a href="#t_floating">floating point</a>
2128 values. 
2129 This instruction can also take <a href="#t_vector">vector</a> versions of the values.
2130 Both arguments must have identical types.</p>
2131 <h5>Semantics:</h5>
2132 <p>The value produced is the integer or floating point difference of
2133 the two operands.</p>
2134 <p>If an integer difference has unsigned overflow, the result returned is the
2135 mathematical result modulo 2<sup>n</sup>, where n is the bit width of
2136 the result.</p>
2137 <p>Because LLVM integers use a two's complement representation, this
2138 instruction is appropriate for both signed and unsigned integers.</p>
2139 <h5>Example:</h5>
2140 <pre>
2141   &lt;result&gt; = sub i32 4, %var          <i>; yields {i32}:result = 4 - %var</i>
2142   &lt;result&gt; = sub i32 0, %val          <i>; yields {i32}:result = -%var</i>
2143 </pre>
2144 </div>
2145 <!-- _______________________________________________________________________ -->
2146 <div class="doc_subsubsection"> <a name="i_mul">'<tt>mul</tt>'
2147 Instruction</a> </div>
2148 <div class="doc_text">
2149 <h5>Syntax:</h5>
2150 <pre>  &lt;result&gt; = mul &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt;   <i>; yields {ty}:result</i>
2151 </pre>
2152 <h5>Overview:</h5>
2153 <p>The  '<tt>mul</tt>' instruction returns the product of its two
2154 operands.</p>
2155 <h5>Arguments:</h5>
2156 <p>The two arguments to the '<tt>mul</tt>' instruction must be either <a
2157  href="#t_integer">integer</a> or <a href="#t_floating">floating point</a>
2158 values. 
2159 This instruction can also take <a href="#t_vector">vector</a> versions of the values.
2160 Both arguments must have identical types.</p>
2161 <h5>Semantics:</h5>
2162 <p>The value produced is the integer or floating point product of the
2163 two operands.</p>
2164 <p>If the result of an integer multiplication has unsigned overflow,
2165 the result returned is the mathematical result modulo 
2166 2<sup>n</sup>, where n is the bit width of the result.</p>
2167 <p>Because LLVM integers use a two's complement representation, and the
2168 result is the same width as the operands, this instruction returns the
2169 correct result for both signed and unsigned integers.  If a full product
2170 (e.g. <tt>i32</tt>x<tt>i32</tt>-><tt>i64</tt>) is needed, the operands
2171 should be sign-extended or zero-extended as appropriate to the
2172 width of the full product.</p>
2173 <h5>Example:</h5>
2174 <pre>  &lt;result&gt; = mul i32 4, %var          <i>; yields {i32}:result = 4 * %var</i>
2175 </pre>
2176 </div>
2177 <!-- _______________________________________________________________________ -->
2178 <div class="doc_subsubsection"> <a name="i_udiv">'<tt>udiv</tt>' Instruction
2179 </a></div>
2180 <div class="doc_text">
2181 <h5>Syntax:</h5>
2182 <pre>  &lt;result&gt; = udiv &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt;   <i>; yields {ty}:result</i>
2183 </pre>
2184 <h5>Overview:</h5>
2185 <p>The '<tt>udiv</tt>' instruction returns the quotient of its two
2186 operands.</p>
2187 <h5>Arguments:</h5>
2188 <p>The two arguments to the '<tt>udiv</tt>' instruction must be 
2189 <a href="#t_integer">integer</a> values. Both arguments must have identical 
2190 types. This instruction can also take <a href="#t_vector">vector</a> versions 
2191 of the values in which case the elements must be integers.</p>
2192 <h5>Semantics:</h5>
2193 <p>The value produced is the unsigned integer quotient of the two operands.</p>
2194 <p>Note that unsigned integer division and signed integer division are distinct
2195 operations; for signed integer division, use '<tt>sdiv</tt>'.</p>
2196 <p>Division by zero leads to undefined behavior.</p>
2197 <h5>Example:</h5>
2198 <pre>  &lt;result&gt; = udiv i32 4, %var          <i>; yields {i32}:result = 4 / %var</i>
2199 </pre>
2200 </div>
2201 <!-- _______________________________________________________________________ -->
2202 <div class="doc_subsubsection"> <a name="i_sdiv">'<tt>sdiv</tt>' Instruction
2203 </a> </div>
2204 <div class="doc_text">
2205 <h5>Syntax:</h5>
2206 <pre>  &lt;result&gt; = sdiv &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt;   <i>; yields {ty}:result</i>
2207 </pre>
2208 <h5>Overview:</h5>
2209 <p>The '<tt>sdiv</tt>' instruction returns the quotient of its two
2210 operands.</p>
2211 <h5>Arguments:</h5>
2212 <p>The two arguments to the '<tt>sdiv</tt>' instruction must be
2213 <a href="#t_integer">integer</a> values.  Both arguments must have identical 
2214 types. This instruction can also take <a href="#t_vector">vector</a> versions 
2215 of the values in which case the elements must be integers.</p>
2216 <h5>Semantics:</h5>
2217 <p>The value produced is the signed integer quotient of the two operands rounded towards zero.</p>
2218 <p>Note that signed integer division and unsigned integer division are distinct
2219 operations; for unsigned integer division, use '<tt>udiv</tt>'.</p>
2220 <p>Division by zero leads to undefined behavior. Overflow also leads to
2221 undefined behavior; this is a rare case, but can occur, for example,
2222 by doing a 32-bit division of -2147483648 by -1.</p>
2223 <h5>Example:</h5>
2224 <pre>  &lt;result&gt; = sdiv i32 4, %var          <i>; yields {i32}:result = 4 / %var</i>
2225 </pre>
2226 </div>
2227 <!-- _______________________________________________________________________ -->
2228 <div class="doc_subsubsection"> <a name="i_fdiv">'<tt>fdiv</tt>'
2229 Instruction</a> </div>
2230 <div class="doc_text">
2231 <h5>Syntax:</h5>
2232 <pre>  &lt;result&gt; = fdiv &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt;   <i>; yields {ty}:result</i>
2233 </pre>
2234 <h5>Overview:</h5>
2235 <p>The '<tt>fdiv</tt>' instruction returns the quotient of its two
2236 operands.</p>
2237 <h5>Arguments:</h5>
2238 <p>The two arguments to the '<tt>fdiv</tt>' instruction must be
2239 <a href="#t_floating">floating point</a> values.  Both arguments must have
2240 identical types.  This instruction can also take <a href="#t_vector">vector</a>
2241 versions of floating point values.</p>
2242 <h5>Semantics:</h5>
2243 <p>The value produced is the floating point quotient of the two operands.</p>
2244 <h5>Example:</h5>
2245 <pre>  &lt;result&gt; = fdiv float 4.0, %var          <i>; yields {float}:result = 4.0 / %var</i>
2246 </pre>
2247 </div>
2248 <!-- _______________________________________________________________________ -->
2249 <div class="doc_subsubsection"> <a name="i_urem">'<tt>urem</tt>' Instruction</a>
2250 </div>
2251 <div class="doc_text">
2252 <h5>Syntax:</h5>
2253 <pre>  &lt;result&gt; = urem &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt;   <i>; yields {ty}:result</i>
2254 </pre>
2255 <h5>Overview:</h5>
2256 <p>The '<tt>urem</tt>' instruction returns the remainder from the
2257 unsigned division of its two arguments.</p>
2258 <h5>Arguments:</h5>
2259 <p>The two arguments to the '<tt>urem</tt>' instruction must be
2260 <a href="#t_integer">integer</a> values. Both arguments must have identical
2261 types. This instruction can also take <a href="#t_vector">vector</a> versions 
2262 of the values in which case the elements must be integers.</p>
2263 <h5>Semantics:</h5>
2264 <p>This instruction returns the unsigned integer <i>remainder</i> of a division.
2265 This instruction always performs an unsigned division to get the remainder.</p>
2266 <p>Note that unsigned integer remainder and signed integer remainder are
2267 distinct operations; for signed integer remainder, use '<tt>srem</tt>'.</p>
2268 <p>Taking the remainder of a division by zero leads to undefined behavior.</p>
2269 <h5>Example:</h5>
2270 <pre>  &lt;result&gt; = urem i32 4, %var          <i>; yields {i32}:result = 4 % %var</i>
2271 </pre>
2272
2273 </div>
2274 <!-- _______________________________________________________________________ -->
2275 <div class="doc_subsubsection"> <a name="i_srem">'<tt>srem</tt>'
2276 Instruction</a> </div>
2277 <div class="doc_text">
2278 <h5>Syntax:</h5>
2279 <pre>  &lt;result&gt; = srem &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt;   <i>; yields {ty}:result</i>
2280 </pre>
2281 <h5>Overview:</h5>
2282 <p>The '<tt>srem</tt>' instruction returns the remainder from the
2283 signed division of its two operands. This instruction can also take
2284 <a href="#t_vector">vector</a> versions of the values in which case
2285 the elements must be integers.</p>
2286
2287 <h5>Arguments:</h5>
2288 <p>The two arguments to the '<tt>srem</tt>' instruction must be 
2289 <a href="#t_integer">integer</a> values.  Both arguments must have identical 
2290 types.</p>
2291 <h5>Semantics:</h5>
2292 <p>This instruction returns the <i>remainder</i> of a division (where the result
2293 has the same sign as the dividend, <tt>var1</tt>), not the <i>modulo</i> 
2294 operator (where the result has the same sign as the divisor, <tt>var2</tt>) of 
2295 a value.  For more information about the difference, see <a
2296  href="http://mathforum.org/dr.math/problems/anne.4.28.99.html">The
2297 Math Forum</a>. For a table of how this is implemented in various languages,
2298 please see <a href="http://en.wikipedia.org/wiki/Modulo_operation">
2299 Wikipedia: modulo operation</a>.</p>
2300 <p>Note that signed integer remainder and unsigned integer remainder are
2301 distinct operations; for unsigned integer remainder, use '<tt>urem</tt>'.</p>
2302 <p>Taking the remainder of a division by zero leads to undefined behavior.
2303 Overflow also leads to undefined behavior; this is a rare case, but can occur,
2304 for example, by taking the remainder of a 32-bit division of -2147483648 by -1.
2305 (The remainder doesn't actually overflow, but this rule lets srem be 
2306 implemented using instructions that return both the result of the division
2307 and the remainder.)</p>
2308 <h5>Example:</h5>
2309 <pre>  &lt;result&gt; = srem i32 4, %var          <i>; yields {i32}:result = 4 % %var</i>
2310 </pre>
2311
2312 </div>
2313 <!-- _______________________________________________________________________ -->
2314 <div class="doc_subsubsection"> <a name="i_frem">'<tt>frem</tt>'
2315 Instruction</a> </div>
2316 <div class="doc_text">
2317 <h5>Syntax:</h5>
2318 <pre>  &lt;result&gt; = frem &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt;   <i>; yields {ty}:result</i>
2319 </pre>
2320 <h5>Overview:</h5>
2321 <p>The '<tt>frem</tt>' instruction returns the remainder from the
2322 division of its two operands.</p>
2323 <h5>Arguments:</h5>
2324 <p>The two arguments to the '<tt>frem</tt>' instruction must be
2325 <a href="#t_floating">floating point</a> values.  Both arguments must have 
2326 identical types.  This instruction can also take <a href="#t_vector">vector</a>
2327 versions of floating point values.</p>
2328 <h5>Semantics:</h5>
2329 <p>This instruction returns the <i>remainder</i> of a division.
2330 The remainder has the same sign as the dividend.</p>
2331 <h5>Example:</h5>
2332 <pre>  &lt;result&gt; = frem float 4.0, %var          <i>; yields {float}:result = 4.0 % %var</i>
2333 </pre>
2334 </div>
2335
2336 <!-- ======================================================================= -->
2337 <div class="doc_subsection"> <a name="bitwiseops">Bitwise Binary
2338 Operations</a> </div>
2339 <div class="doc_text">
2340 <p>Bitwise binary operators are used to do various forms of
2341 bit-twiddling in a program.  They are generally very efficient
2342 instructions and can commonly be strength reduced from other
2343 instructions.  They require two operands of the same type, execute an operation on them,
2344 and produce a single value.  The resulting value is the same type as its operands.</p>
2345 </div>
2346
2347 <!-- _______________________________________________________________________ -->
2348 <div class="doc_subsubsection"> <a name="i_shl">'<tt>shl</tt>'
2349 Instruction</a> </div>
2350 <div class="doc_text">
2351 <h5>Syntax:</h5>
2352 <pre>  &lt;result&gt; = shl &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt;   <i>; yields {ty}:result</i>
2353 </pre>
2354
2355 <h5>Overview:</h5>
2356
2357 <p>The '<tt>shl</tt>' instruction returns the first operand shifted to
2358 the left a specified number of bits.</p>
2359
2360 <h5>Arguments:</h5>
2361
2362 <p>Both arguments to the '<tt>shl</tt>' instruction must be the same <a
2363  href="#t_integer">integer</a> type.  '<tt>var2</tt>' is treated as an
2364 unsigned value.</p>
2365  
2366 <h5>Semantics:</h5>
2367
2368 <p>The value produced is <tt>var1</tt> * 2<sup><tt>var2</tt></sup> mod 2<sup>n</sup>,
2369 where n is the width of the result.  If <tt>var2</tt> is (statically or dynamically) negative or
2370 equal to or larger than the number of bits in <tt>var1</tt>, the result is undefined.</p>
2371
2372 <h5>Example:</h5><pre>
2373   &lt;result&gt; = shl i32 4, %var   <i>; yields {i32}: 4 &lt;&lt; %var</i>
2374   &lt;result&gt; = shl i32 4, 2      <i>; yields {i32}: 16</i>
2375   &lt;result&gt; = shl i32 1, 10     <i>; yields {i32}: 1024</i>
2376   &lt;result&gt; = shl i32 1, 32     <i>; undefined</i>
2377 </pre>
2378 </div>
2379 <!-- _______________________________________________________________________ -->
2380 <div class="doc_subsubsection"> <a name="i_lshr">'<tt>lshr</tt>'
2381 Instruction</a> </div>
2382 <div class="doc_text">
2383 <h5>Syntax:</h5>
2384 <pre>  &lt;result&gt; = lshr &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt;   <i>; yields {ty}:result</i>
2385 </pre>
2386
2387 <h5>Overview:</h5>
2388 <p>The '<tt>lshr</tt>' instruction (logical shift right) returns the first 
2389 operand shifted to the right a specified number of bits with zero fill.</p>
2390
2391 <h5>Arguments:</h5>
2392 <p>Both arguments to the '<tt>lshr</tt>' instruction must be the same 
2393 <a href="#t_integer">integer</a> type.  '<tt>var2</tt>' is treated as an
2394 unsigned value.</p>
2395
2396 <h5>Semantics:</h5>
2397
2398 <p>This instruction always performs a logical shift right operation. The most
2399 significant bits of the result will be filled with zero bits after the 
2400 shift.  If <tt>var2</tt> is (statically or dynamically) equal to or larger than
2401 the number of bits in <tt>var1</tt>, the result is undefined.</p>
2402
2403 <h5>Example:</h5>
2404 <pre>
2405   &lt;result&gt; = lshr i32 4, 1   <i>; yields {i32}:result = 2</i>
2406   &lt;result&gt; = lshr i32 4, 2   <i>; yields {i32}:result = 1</i>
2407   &lt;result&gt; = lshr i8  4, 3   <i>; yields {i8}:result = 0</i>
2408   &lt;result&gt; = lshr i8 -2, 1   <i>; yields {i8}:result = 0x7FFFFFFF </i>
2409   &lt;result&gt; = lshr i32 1, 32  <i>; undefined</i>
2410 </pre>
2411 </div>
2412
2413 <!-- _______________________________________________________________________ -->
2414 <div class="doc_subsubsection"> <a name="i_ashr">'<tt>ashr</tt>'
2415 Instruction</a> </div>
2416 <div class="doc_text">
2417
2418 <h5>Syntax:</h5>
2419 <pre>  &lt;result&gt; = ashr &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt;   <i>; yields {ty}:result</i>
2420 </pre>
2421
2422 <h5>Overview:</h5>
2423 <p>The '<tt>ashr</tt>' instruction (arithmetic shift right) returns the first 
2424 operand shifted to the right a specified number of bits with sign extension.</p>
2425
2426 <h5>Arguments:</h5>
2427 <p>Both arguments to the '<tt>ashr</tt>' instruction must be the same 
2428 <a href="#t_integer">integer</a> type.  '<tt>var2</tt>' is treated as an
2429 unsigned value.</p>
2430
2431 <h5>Semantics:</h5>
2432 <p>This instruction always performs an arithmetic shift right operation, 
2433 The most significant bits of the result will be filled with the sign bit 
2434 of <tt>var1</tt>.  If <tt>var2</tt> is (statically or dynamically) equal to or
2435 larger than the number of bits in <tt>var1</tt>, the result is undefined.
2436 </p>
2437
2438 <h5>Example:</h5>
2439 <pre>
2440   &lt;result&gt; = ashr i32 4, 1   <i>; yields {i32}:result = 2</i>
2441   &lt;result&gt; = ashr i32 4, 2   <i>; yields {i32}:result = 1</i>
2442   &lt;result&gt; = ashr i8  4, 3   <i>; yields {i8}:result = 0</i>
2443   &lt;result&gt; = ashr i8 -2, 1   <i>; yields {i8}:result = -1</i>
2444   &lt;result&gt; = ashr i32 1, 32  <i>; undefined</i>
2445 </pre>
2446 </div>
2447
2448 <!-- _______________________________________________________________________ -->
2449 <div class="doc_subsubsection"> <a name="i_and">'<tt>and</tt>'
2450 Instruction</a> </div>
2451 <div class="doc_text">
2452 <h5>Syntax:</h5>
2453 <pre>  &lt;result&gt; = and &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt;   <i>; yields {ty}:result</i>
2454 </pre>
2455 <h5>Overview:</h5>
2456 <p>The '<tt>and</tt>' instruction returns the bitwise logical and of
2457 its two operands.</p>
2458 <h5>Arguments:</h5>
2459 <p>The two arguments to the '<tt>and</tt>' instruction must be <a
2460  href="#t_integer">integer</a> values.  Both arguments must have
2461 identical types.</p>
2462 <h5>Semantics:</h5>
2463 <p>The truth table used for the '<tt>and</tt>' instruction is:</p>
2464 <p> </p>
2465 <div style="align: center">
2466 <table border="1" cellspacing="0" cellpadding="4">
2467   <tbody>
2468     <tr>
2469       <td>In0</td>
2470       <td>In1</td>
2471       <td>Out</td>
2472     </tr>
2473     <tr>
2474       <td>0</td>
2475       <td>0</td>
2476       <td>0</td>
2477     </tr>
2478     <tr>
2479       <td>0</td>
2480       <td>1</td>
2481       <td>0</td>
2482     </tr>
2483     <tr>
2484       <td>1</td>
2485       <td>0</td>
2486       <td>0</td>
2487     </tr>
2488     <tr>
2489       <td>1</td>
2490       <td>1</td>
2491       <td>1</td>
2492     </tr>
2493   </tbody>
2494 </table>
2495 </div>
2496 <h5>Example:</h5>
2497 <pre>  &lt;result&gt; = and i32 4, %var         <i>; yields {i32}:result = 4 &amp; %var</i>
2498   &lt;result&gt; = and i32 15, 40          <i>; yields {i32}:result = 8</i>
2499   &lt;result&gt; = and i32 4, 8            <i>; yields {i32}:result = 0</i>
2500 </pre>
2501 </div>
2502 <!-- _______________________________________________________________________ -->
2503 <div class="doc_subsubsection"> <a name="i_or">'<tt>or</tt>' Instruction</a> </div>
2504 <div class="doc_text">
2505 <h5>Syntax:</h5>
2506 <pre>  &lt;result&gt; = or &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt;   <i>; yields {ty}:result</i>
2507 </pre>
2508 <h5>Overview:</h5>
2509 <p>The '<tt>or</tt>' instruction returns the bitwise logical inclusive
2510 or of its two operands.</p>
2511 <h5>Arguments:</h5>
2512 <p>The two arguments to the '<tt>or</tt>' instruction must be <a
2513  href="#t_integer">integer</a> values.  Both arguments must have
2514 identical types.</p>
2515 <h5>Semantics:</h5>
2516 <p>The truth table used for the '<tt>or</tt>' instruction is:</p>
2517 <p> </p>
2518 <div style="align: center">
2519 <table border="1" cellspacing="0" cellpadding="4">
2520   <tbody>
2521     <tr>
2522       <td>In0</td>
2523       <td>In1</td>
2524       <td>Out</td>
2525     </tr>
2526     <tr>
2527       <td>0</td>
2528       <td>0</td>
2529       <td>0</td>
2530     </tr>
2531     <tr>
2532       <td>0</td>
2533       <td>1</td>
2534       <td>1</td>
2535     </tr>
2536     <tr>
2537       <td>1</td>
2538       <td>0</td>
2539       <td>1</td>
2540     </tr>
2541     <tr>
2542       <td>1</td>
2543       <td>1</td>
2544       <td>1</td>
2545     </tr>
2546   </tbody>
2547 </table>
2548 </div>
2549 <h5>Example:</h5>
2550 <pre>  &lt;result&gt; = or i32 4, %var         <i>; yields {i32}:result = 4 | %var</i>
2551   &lt;result&gt; = or i32 15, 40          <i>; yields {i32}:result = 47</i>
2552   &lt;result&gt; = or i32 4, 8            <i>; yields {i32}:result = 12</i>
2553 </pre>
2554 </div>
2555 <!-- _______________________________________________________________________ -->
2556 <div class="doc_subsubsection"> <a name="i_xor">'<tt>xor</tt>'
2557 Instruction</a> </div>
2558 <div class="doc_text">
2559 <h5>Syntax:</h5>
2560 <pre>  &lt;result&gt; = xor &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt;   <i>; yields {ty}:result</i>
2561 </pre>
2562 <h5>Overview:</h5>
2563 <p>The '<tt>xor</tt>' instruction returns the bitwise logical exclusive
2564 or of its two operands.  The <tt>xor</tt> is used to implement the
2565 "one's complement" operation, which is the "~" operator in C.</p>
2566 <h5>Arguments:</h5>
2567 <p>The two arguments to the '<tt>xor</tt>' instruction must be <a
2568  href="#t_integer">integer</a> values.  Both arguments must have
2569 identical types.</p>
2570 <h5>Semantics:</h5>
2571 <p>The truth table used for the '<tt>xor</tt>' instruction is:</p>
2572 <p> </p>
2573 <div style="align: center">
2574 <table border="1" cellspacing="0" cellpadding="4">
2575   <tbody>
2576     <tr>
2577       <td>In0</td>
2578       <td>In1</td>
2579       <td>Out</td>
2580     </tr>
2581     <tr>
2582       <td>0</td>
2583       <td>0</td>
2584       <td>0</td>
2585     </tr>
2586     <tr>
2587       <td>0</td>
2588       <td>1</td>
2589       <td>1</td>
2590     </tr>
2591     <tr>
2592       <td>1</td>
2593       <td>0</td>
2594       <td>1</td>
2595     </tr>
2596     <tr>
2597       <td>1</td>
2598       <td>1</td>
2599       <td>0</td>
2600     </tr>
2601   </tbody>
2602 </table>
2603 </div>
2604 <p> </p>
2605 <h5>Example:</h5>
2606 <pre>  &lt;result&gt; = xor i32 4, %var         <i>; yields {i32}:result = 4 ^ %var</i>
2607   &lt;result&gt; = xor i32 15, 40          <i>; yields {i32}:result = 39</i>
2608   &lt;result&gt; = xor i32 4, 8            <i>; yields {i32}:result = 12</i>
2609   &lt;result&gt; = xor i32 %V, -1          <i>; yields {i32}:result = ~%V</i>
2610 </pre>
2611 </div>
2612
2613 <!-- ======================================================================= -->
2614 <div class="doc_subsection"> 
2615   <a name="vectorops">Vector Operations</a>
2616 </div>
2617
2618 <div class="doc_text">
2619
2620 <p>LLVM supports several instructions to represent vector operations in a
2621 target-independent manner.  These instructions cover the element-access and
2622 vector-specific operations needed to process vectors effectively.  While LLVM
2623 does directly support these vector operations, many sophisticated algorithms
2624 will want to use target-specific intrinsics to take full advantage of a specific
2625 target.</p>
2626
2627 </div>
2628
2629 <!-- _______________________________________________________________________ -->
2630 <div class="doc_subsubsection">
2631    <a name="i_extractelement">'<tt>extractelement</tt>' Instruction</a>
2632 </div>
2633
2634 <div class="doc_text">
2635
2636 <h5>Syntax:</h5>
2637
2638 <pre>
2639   &lt;result&gt; = extractelement &lt;n x &lt;ty&gt;&gt; &lt;val&gt;, i32 &lt;idx&gt;    <i>; yields &lt;ty&gt;</i>
2640 </pre>
2641
2642 <h5>Overview:</h5>
2643
2644 <p>
2645 The '<tt>extractelement</tt>' instruction extracts a single scalar
2646 element from a vector at a specified index.
2647 </p>
2648
2649
2650 <h5>Arguments:</h5>
2651
2652 <p>
2653 The first operand of an '<tt>extractelement</tt>' instruction is a
2654 value of <a href="#t_vector">vector</a> type.  The second operand is
2655 an index indicating the position from which to extract the element.
2656 The index may be a variable.</p>
2657
2658 <h5>Semantics:</h5>
2659
2660 <p>
2661 The result is a scalar of the same type as the element type of
2662 <tt>val</tt>.  Its value is the value at position <tt>idx</tt> of
2663 <tt>val</tt>.  If <tt>idx</tt> exceeds the length of <tt>val</tt>, the
2664 results are undefined.
2665 </p>
2666
2667 <h5>Example:</h5>
2668
2669 <pre>
2670   %result = extractelement &lt;4 x i32&gt; %vec, i32 0    <i>; yields i32</i>
2671 </pre>
2672 </div>
2673
2674
2675 <!-- _______________________________________________________________________ -->
2676 <div class="doc_subsubsection">
2677    <a name="i_insertelement">'<tt>insertelement</tt>' Instruction</a>
2678 </div>
2679
2680 <div class="doc_text">
2681
2682 <h5>Syntax:</h5>
2683
2684 <pre>
2685   &lt;result&gt; = insertelement &lt;n x &lt;ty&gt;&gt; &lt;val&gt;, &lt;ty&gt; &lt;elt&gt, i32 &lt;idx&gt;    <i>; yields &lt;n x &lt;ty&gt;&gt;</i>
2686 </pre>
2687
2688 <h5>Overview:</h5>
2689
2690 <p>
2691 The '<tt>insertelement</tt>' instruction inserts a scalar
2692 element into a vector at a specified index.
2693 </p>
2694
2695
2696 <h5>Arguments:</h5>
2697
2698 <p>
2699 The first operand of an '<tt>insertelement</tt>' instruction is a
2700 value of <a href="#t_vector">vector</a> type.  The second operand is a
2701 scalar value whose type must equal the element type of the first
2702 operand.  The third operand is an index indicating the position at
2703 which to insert the value.  The index may be a variable.</p>
2704
2705 <h5>Semantics:</h5>
2706
2707 <p>
2708 The result is a vector of the same type as <tt>val</tt>.  Its
2709 element values are those of <tt>val</tt> except at position
2710 <tt>idx</tt>, where it gets the value <tt>elt</tt>.  If <tt>idx</tt>
2711 exceeds the length of <tt>val</tt>, the results are undefined.
2712 </p>
2713
2714 <h5>Example:</h5>
2715
2716 <pre>
2717   %result = insertelement &lt;4 x i32&gt; %vec, i32 1, i32 0    <i>; yields &lt;4 x i32&gt;</i>
2718 </pre>
2719 </div>
2720
2721 <!-- _______________________________________________________________________ -->
2722 <div class="doc_subsubsection">
2723    <a name="i_shufflevector">'<tt>shufflevector</tt>' Instruction</a>
2724 </div>
2725
2726 <div class="doc_text">
2727
2728 <h5>Syntax:</h5>
2729
2730 <pre>
2731   &lt;result&gt; = shufflevector &lt;n x &lt;ty&gt;&gt; &lt;v1&gt;, &lt;n x &lt;ty&gt;&gt; &lt;v2&gt;, &lt;n x i32&gt; &lt;mask&gt;    <i>; yields &lt;n x &lt;ty&gt;&gt;</i>
2732 </pre>
2733
2734 <h5>Overview:</h5>
2735
2736 <p>
2737 The '<tt>shufflevector</tt>' instruction constructs a permutation of elements
2738 from two input vectors, returning a vector of the same type.
2739 </p>
2740
2741 <h5>Arguments:</h5>
2742
2743 <p>
2744 The first two operands of a '<tt>shufflevector</tt>' instruction are vectors
2745 with types that match each other and types that match the result of the
2746 instruction.  The third argument is a shuffle mask, which has the same number
2747 of elements as the other vector type, but whose element type is always 'i32'.
2748 </p>
2749
2750 <p>
2751 The shuffle mask operand is required to be a constant vector with either
2752 constant integer or undef values.
2753 </p>
2754
2755 <h5>Semantics:</h5>
2756
2757 <p>
2758 The elements of the two input vectors are numbered from left to right across
2759 both of the vectors.  The shuffle mask operand specifies, for each element of
2760 the result vector, which element of the two input registers the result element
2761 gets.  The element selector may be undef (meaning "don't care") and the second
2762 operand may be undef if performing a shuffle from only one vector.
2763 </p>
2764
2765 <h5>Example:</h5>
2766
2767 <pre>
2768   %result = shufflevector &lt;4 x i32&gt; %v1, &lt;4 x i32&gt; %v2, 
2769                           &lt;4 x i32&gt; &lt;i32 0, i32 4, i32 1, i32 5&gt;  <i>; yields &lt;4 x i32&gt;</i>
2770   %result = shufflevector &lt;4 x i32&gt; %v1, &lt;4 x i32&gt; undef, 
2771                           &lt;4 x i32&gt; &lt;i32 0, i32 1, i32 2, i32 3&gt;  <i>; yields &lt;4 x i32&gt;</i> - Identity shuffle.
2772 </pre>
2773 </div>
2774
2775
2776 <!-- ======================================================================= -->
2777 <div class="doc_subsection"> 
2778   <a name="memoryops">Memory Access and Addressing Operations</a>
2779 </div>
2780
2781 <div class="doc_text">
2782
2783 <p>A key design point of an SSA-based representation is how it
2784 represents memory.  In LLVM, no memory locations are in SSA form, which
2785 makes things very simple.  This section describes how to read, write,
2786 allocate, and free memory in LLVM.</p>
2787
2788 </div>
2789
2790 <!-- _______________________________________________________________________ -->
2791 <div class="doc_subsubsection">
2792   <a name="i_malloc">'<tt>malloc</tt>' Instruction</a>
2793 </div>
2794
2795 <div class="doc_text">
2796
2797 <h5>Syntax:</h5>
2798
2799 <pre>
2800   &lt;result&gt; = malloc &lt;type&gt;[, i32 &lt;NumElements&gt;][, align &lt;alignment&gt;]     <i>; yields {type*}:result</i>
2801 </pre>
2802
2803 <h5>Overview:</h5>
2804
2805 <p>The '<tt>malloc</tt>' instruction allocates memory from the system
2806 heap and returns a pointer to it. The object is always allocated in the generic 
2807 address space (address space zero).</p>
2808
2809 <h5>Arguments:</h5>
2810
2811 <p>The '<tt>malloc</tt>' instruction allocates
2812 <tt>sizeof(&lt;type&gt;)*NumElements</tt>
2813 bytes of memory from the operating system and returns a pointer of the
2814 appropriate type to the program.  If "NumElements" is specified, it is the
2815 number of elements allocated, otherwise "NumElements" is defaulted to be one.
2816 If a constant alignment is specified, the value result of the allocation is guaranteed to
2817 be aligned to at least that boundary.  If not specified, or if zero, the target can
2818 choose to align the allocation on any convenient boundary.</p>
2819
2820 <p>'<tt>type</tt>' must be a sized type.</p>
2821
2822 <h5>Semantics:</h5>
2823
2824 <p>Memory is allocated using the system "<tt>malloc</tt>" function, and
2825 a pointer is returned.  The result of a zero byte allocattion is undefined.  The
2826 result is null if there is insufficient memory available.</p>
2827
2828 <h5>Example:</h5>
2829
2830 <pre>
2831   %array  = malloc [4 x i8 ]                    <i>; yields {[%4 x i8]*}:array</i>
2832
2833   %size   = <a href="#i_add">add</a> i32 2, 2                        <i>; yields {i32}:size = i32 4</i>
2834   %array1 = malloc i8, i32 4                    <i>; yields {i8*}:array1</i>
2835   %array2 = malloc [12 x i8], i32 %size         <i>; yields {[12 x i8]*}:array2</i>
2836   %array3 = malloc i32, i32 4, align 1024       <i>; yields {i32*}:array3</i>
2837   %array4 = malloc i32, align 1024              <i>; yields {i32*}:array4</i>
2838 </pre>
2839 </div>
2840
2841 <!-- _______________________________________________________________________ -->
2842 <div class="doc_subsubsection">
2843   <a name="i_free">'<tt>free</tt>' Instruction</a>
2844 </div>
2845
2846 <div class="doc_text">
2847
2848 <h5>Syntax:</h5>
2849
2850 <pre>
2851   free &lt;type&gt; &lt;value&gt;                              <i>; yields {void}</i>
2852 </pre>
2853
2854 <h5>Overview:</h5>
2855
2856 <p>The '<tt>free</tt>' instruction returns memory back to the unused
2857 memory heap to be reallocated in the future.</p>
2858
2859 <h5>Arguments:</h5>
2860
2861 <p>'<tt>value</tt>' shall be a pointer value that points to a value
2862 that was allocated with the '<tt><a href="#i_malloc">malloc</a></tt>'
2863 instruction.</p>
2864
2865 <h5>Semantics:</h5>
2866
2867 <p>Access to the memory pointed to by the pointer is no longer defined
2868 after this instruction executes.  If the pointer is null, the operation
2869 is a noop.</p>
2870
2871 <h5>Example:</h5>
2872
2873 <pre>
2874   %array  = <a href="#i_malloc">malloc</a> [4 x i8]                    <i>; yields {[4 x i8]*}:array</i>
2875             free   [4 x i8]* %array
2876 </pre>
2877 </div>
2878
2879 <!-- _______________________________________________________________________ -->
2880 <div class="doc_subsubsection">
2881   <a name="i_alloca">'<tt>alloca</tt>' Instruction</a>
2882 </div>
2883
2884 <div class="doc_text">
2885
2886 <h5>Syntax:</h5>
2887
2888 <pre>
2889   &lt;result&gt; = alloca &lt;type&gt;[, i32 &lt;NumElements&gt;][, align &lt;alignment&gt;]     <i>; yields {type*}:result</i>
2890 </pre>
2891
2892 <h5>Overview:</h5>
2893
2894 <p>The '<tt>alloca</tt>' instruction allocates memory on the stack frame of the
2895 currently executing function, to be automatically released when this function
2896 returns to its caller. The object is always allocated in the generic address 
2897 space (address space zero).</p>
2898
2899 <h5>Arguments:</h5>
2900
2901 <p>The '<tt>alloca</tt>' instruction allocates <tt>sizeof(&lt;type&gt;)*NumElements</tt>
2902 bytes of memory on the runtime stack, returning a pointer of the
2903 appropriate type to the program.  If "NumElements" is specified, it is the
2904 number of elements allocated, otherwise "NumElements" is defaulted to be one.
2905 If a constant alignment is specified, the value result of the allocation is guaranteed
2906 to be aligned to at least that boundary.  If not specified, or if zero, the target
2907 can choose to align the allocation on any convenient boundary.</p>
2908
2909 <p>'<tt>type</tt>' may be any sized type.</p>
2910
2911 <h5>Semantics:</h5>
2912
2913 <p>Memory is allocated; a pointer is returned.  The operation is undefiend if
2914 there is insufficient stack space for the allocation.  '<tt>alloca</tt>'d
2915 memory is automatically released when the function returns.  The '<tt>alloca</tt>'
2916 instruction is commonly used to represent automatic variables that must
2917 have an address available.  When the function returns (either with the <tt><a
2918  href="#i_ret">ret</a></tt> or <tt><a href="#i_unwind">unwind</a></tt>
2919 instructions), the memory is reclaimed.  Allocating zero bytes
2920 is legal, but the result is undefined.</p>
2921
2922 <h5>Example:</h5>
2923
2924 <pre>
2925   %ptr = alloca i32                              <i>; yields {i32*}:ptr</i>
2926   %ptr = alloca i32, i32 4                       <i>; yields {i32*}:ptr</i>
2927   %ptr = alloca i32, i32 4, align 1024           <i>; yields {i32*}:ptr</i>
2928   %ptr = alloca i32, align 1024                  <i>; yields {i32*}:ptr</i>
2929 </pre>
2930 </div>
2931
2932 <!-- _______________________________________________________________________ -->
2933 <div class="doc_subsubsection"> <a name="i_load">'<tt>load</tt>'
2934 Instruction</a> </div>
2935 <div class="doc_text">
2936 <h5>Syntax:</h5>
2937 <pre>  &lt;result&gt; = load &lt;ty&gt;* &lt;pointer&gt;[, align &lt;alignment&gt;]<br>  &lt;result&gt; = volatile load &lt;ty&gt;* &lt;pointer&gt;[, align &lt;alignment&gt;]<br></pre>
2938 <h5>Overview:</h5>
2939 <p>The '<tt>load</tt>' instruction is used to read from memory.</p>
2940 <h5>Arguments:</h5>
2941 <p>The argument to the '<tt>load</tt>' instruction specifies the memory
2942 address from which to load.  The pointer must point to a <a
2943  href="#t_firstclass">first class</a> type.  If the <tt>load</tt> is
2944 marked as <tt>volatile</tt>, then the optimizer is not allowed to modify
2945 the number or order of execution of this <tt>load</tt> with other
2946 volatile <tt>load</tt> and <tt><a href="#i_store">store</a></tt>
2947 instructions. </p>
2948 <p>
2949 The optional constant "align" argument specifies the alignment of the operation
2950 (that is, the alignment of the memory address). A value of 0 or an
2951 omitted "align" argument means that the operation has the preferential
2952 alignment for the target. It is the responsibility of the code emitter
2953 to ensure that the alignment information is correct. Overestimating
2954 the alignment results in an undefined behavior. Underestimating the
2955 alignment may produce less efficient code. An alignment of 1 is always
2956 safe.
2957 </p>
2958 <h5>Semantics:</h5>
2959 <p>The location of memory pointed to is loaded.</p>
2960 <h5>Examples:</h5>
2961 <pre>  %ptr = <a href="#i_alloca">alloca</a> i32                               <i>; yields {i32*}:ptr</i>
2962   <a
2963  href="#i_store">store</a> i32 3, i32* %ptr                          <i>; yields {void}</i>
2964   %val = load i32* %ptr                           <i>; yields {i32}:val = i32 3</i>
2965 </pre>
2966 </div>
2967 <!-- _______________________________________________________________________ -->
2968 <div class="doc_subsubsection"> <a name="i_store">'<tt>store</tt>'
2969 Instruction</a> </div>
2970 <div class="doc_text">
2971 <h5>Syntax:</h5>
2972 <pre>  store &lt;ty&gt; &lt;value&gt;, &lt;ty&gt;* &lt;pointer&gt;[, align &lt;alignment&gt;]                   <i>; yields {void}</i>
2973   volatile store &lt;ty&gt; &lt;value&gt;, &lt;ty&gt;* &lt;pointer&gt;[, align &lt;alignment&gt;]          <i>; yields {void}</i>
2974 </pre>
2975 <h5>Overview:</h5>
2976 <p>The '<tt>store</tt>' instruction is used to write to memory.</p>
2977 <h5>Arguments:</h5>
2978 <p>There are two arguments to the '<tt>store</tt>' instruction: a value
2979 to store and an address at which to store it.  The type of the '<tt>&lt;pointer&gt;</tt>'
2980 operand must be a pointer to the <a href="#t_firstclass">first class</a> type
2981 of the '<tt>&lt;value&gt;</tt>'
2982 operand. If the <tt>store</tt> is marked as <tt>volatile</tt>, then the
2983 optimizer is not allowed to modify the number or order of execution of
2984 this <tt>store</tt> with other volatile <tt>load</tt> and <tt><a
2985  href="#i_store">store</a></tt> instructions.</p>
2986 <p>
2987 The optional constant "align" argument specifies the alignment of the operation
2988 (that is, the alignment of the memory address). A value of 0 or an
2989 omitted "align" argument means that the operation has the preferential
2990 alignment for the target. It is the responsibility of the code emitter
2991 to ensure that the alignment information is correct. Overestimating
2992 the alignment results in an undefined behavior. Underestimating the
2993 alignment may produce less efficient code. An alignment of 1 is always
2994 safe.
2995 </p>
2996 <h5>Semantics:</h5>
2997 <p>The contents of memory are updated to contain '<tt>&lt;value&gt;</tt>'
2998 at the location specified by the '<tt>&lt;pointer&gt;</tt>' operand.</p>
2999 <h5>Example:</h5>
3000 <pre>  %ptr = <a href="#i_alloca">alloca</a> i32                               <i>; yields {i32*}:ptr</i>
3001   store i32 3, i32* %ptr                          <i>; yields {void}</i>
3002   %val = <a href="#i_load">load</a> i32* %ptr                           <i>; yields {i32}:val = i32 3</i>
3003 </pre>
3004 </div>
3005
3006 <!-- _______________________________________________________________________ -->
3007 <div class="doc_subsubsection">
3008    <a name="i_getelementptr">'<tt>getelementptr</tt>' Instruction</a>
3009 </div>
3010
3011 <div class="doc_text">
3012 <h5>Syntax:</h5>
3013 <pre>
3014   &lt;result&gt; = getelementptr &lt;ty&gt;* &lt;ptrval&gt;{, &lt;ty&gt; &lt;idx&gt;}*
3015 </pre>
3016
3017 <h5>Overview:</h5>
3018
3019 <p>
3020 The '<tt>getelementptr</tt>' instruction is used to get the address of a
3021 subelement of an aggregate data structure.</p>
3022
3023 <h5>Arguments:</h5>
3024
3025 <p>This instruction takes a list of integer operands that indicate what
3026 elements of the aggregate object to index to.  The actual types of the arguments
3027 provided depend on the type of the first pointer argument.  The
3028 '<tt>getelementptr</tt>' instruction is used to index down through the type
3029 levels of a structure or to a specific index in an array.  When indexing into a
3030 structure, only <tt>i32</tt> integer constants are allowed.  When indexing 
3031 into an array or pointer, only integers of 32 or 64 bits are allowed; 32-bit 
3032 values will be sign extended to 64-bits if required.</p>
3033
3034 <p>For example, let's consider a C code fragment and how it gets
3035 compiled to LLVM:</p>
3036
3037 <div class="doc_code">
3038 <pre>
3039 struct RT {
3040   char A;
3041   int B[10][20];
3042   char C;
3043 };
3044 struct ST {
3045   int X;
3046   double Y;
3047   struct RT Z;
3048 };
3049
3050 int *foo(struct ST *s) {
3051   return &amp;s[1].Z.B[5][13];
3052 }
3053 </pre>
3054 </div>
3055
3056 <p>The LLVM code generated by the GCC frontend is:</p>
3057
3058 <div class="doc_code">
3059 <pre>
3060 %RT = type { i8 , [10 x [20 x i32]], i8  }
3061 %ST = type { i32, double, %RT }
3062
3063 define i32* %foo(%ST* %s) {
3064 entry:
3065   %reg = getelementptr %ST* %s, i32 1, i32 2, i32 1, i32 5, i32 13
3066   ret i32* %reg
3067 }
3068 </pre>
3069 </div>
3070
3071 <h5>Semantics:</h5>
3072
3073 <p>The index types specified for the '<tt>getelementptr</tt>' instruction depend
3074 on the pointer type that is being indexed into. <a href="#t_pointer">Pointer</a>
3075 and <a href="#t_array">array</a> types can use a 32-bit or 64-bit
3076 <a href="#t_integer">integer</a> type but the value will always be sign extended
3077 to 64-bits.  <a href="#t_struct">Structure</a> and <a href="#t_pstruct">packed
3078 structure</a> types require <tt>i32</tt> <b>constants</b>.</p>
3079
3080 <p>In the example above, the first index is indexing into the '<tt>%ST*</tt>'
3081 type, which is a pointer, yielding a '<tt>%ST</tt>' = '<tt>{ i32, double, %RT
3082 }</tt>' type, a structure.  The second index indexes into the third element of
3083 the structure, yielding a '<tt>%RT</tt>' = '<tt>{ i8 , [10 x [20 x i32]],
3084 i8  }</tt>' type, another structure.  The third index indexes into the second
3085 element of the structure, yielding a '<tt>[10 x [20 x i32]]</tt>' type, an
3086 array.  The two dimensions of the array are subscripted into, yielding an
3087 '<tt>i32</tt>' type.  The '<tt>getelementptr</tt>' instruction returns a pointer
3088 to this element, thus computing a value of '<tt>i32*</tt>' type.</p>
3089
3090 <p>Note that it is perfectly legal to index partially through a
3091 structure, returning a pointer to an inner element.  Because of this,
3092 the LLVM code for the given testcase is equivalent to:</p>
3093
3094 <pre>
3095   define i32* %foo(%ST* %s) {
3096     %t1 = getelementptr %ST* %s, i32 1                        <i>; yields %ST*:%t1</i>
3097     %t2 = getelementptr %ST* %t1, i32 0, i32 2                <i>; yields %RT*:%t2</i>
3098     %t3 = getelementptr %RT* %t2, i32 0, i32 1                <i>; yields [10 x [20 x i32]]*:%t3</i>
3099     %t4 = getelementptr [10 x [20 x i32]]* %t3, i32 0, i32 5  <i>; yields [20 x i32]*:%t4</i>
3100     %t5 = getelementptr [20 x i32]* %t4, i32 0, i32 13        <i>; yields i32*:%t5</i>
3101     ret i32* %t5
3102   }
3103 </pre>
3104
3105 <p>Note that it is undefined to access an array out of bounds: array and 
3106 pointer indexes must always be within the defined bounds of the array type.
3107 The one exception for this rule is zero length arrays.  These arrays are
3108 defined to be accessible as variable length arrays, which requires access
3109 beyond the zero'th element.</p>
3110
3111 <p>The getelementptr instruction is often confusing.  For some more insight
3112 into how it works, see <a href="GetElementPtr.html">the getelementptr 
3113 FAQ</a>.</p>
3114
3115 <h5>Example:</h5>
3116
3117 <pre>
3118     <i>; yields [12 x i8]*:aptr</i>
3119     %aptr = getelementptr {i32, [12 x i8]}* %sptr, i64 0, i32 1
3120 </pre>
3121 </div>
3122
3123 <!-- ======================================================================= -->
3124 <div class="doc_subsection"> <a name="convertops">Conversion Operations</a>
3125 </div>
3126 <div class="doc_text">
3127 <p>The instructions in this category are the conversion instructions (casting)
3128 which all take a single operand and a type. They perform various bit conversions
3129 on the operand.</p>
3130 </div>
3131
3132 <!-- _______________________________________________________________________ -->
3133 <div class="doc_subsubsection">
3134    <a name="i_trunc">'<tt>trunc .. to</tt>' Instruction</a>
3135 </div>
3136 <div class="doc_text">
3137
3138 <h5>Syntax:</h5>
3139 <pre>
3140   &lt;result&gt; = trunc &lt;ty&gt; &lt;value&gt; to &lt;ty2&gt;             <i>; yields ty2</i>
3141 </pre>
3142
3143 <h5>Overview:</h5>
3144 <p>
3145 The '<tt>trunc</tt>' instruction truncates its operand to the type <tt>ty2</tt>.
3146 </p>
3147
3148 <h5>Arguments:</h5>
3149 <p>
3150 The '<tt>trunc</tt>' instruction takes a <tt>value</tt> to trunc, which must 
3151 be an <a href="#t_integer">integer</a> type, and a type that specifies the size 
3152 and type of the result, which must be an <a href="#t_integer">integer</a> 
3153 type. The bit size of <tt>value</tt> must be larger than the bit size of 
3154 <tt>ty2</tt>. Equal sized types are not allowed.</p>
3155
3156 <h5>Semantics:</h5>
3157 <p>
3158 The '<tt>trunc</tt>' instruction truncates the high order bits in <tt>value</tt>
3159 and converts the remaining bits to <tt>ty2</tt>. Since the source size must be
3160 larger than the destination size, <tt>trunc</tt> cannot be a <i>no-op cast</i>.
3161 It will always truncate bits.</p>
3162
3163 <h5>Example:</h5>
3164 <pre>
3165   %X = trunc i32 257 to i8              <i>; yields i8:1</i>
3166   %Y = trunc i32 123 to i1              <i>; yields i1:true</i>
3167   %Y = trunc i32 122 to i1              <i>; yields i1:false</i>
3168 </pre>
3169 </div>
3170
3171 <!-- _______________________________________________________________________ -->
3172 <div class="doc_subsubsection">
3173    <a name="i_zext">'<tt>zext .. to</tt>' Instruction</a>
3174 </div>
3175 <div class="doc_text">
3176
3177 <h5>Syntax:</h5>
3178 <pre>
3179   &lt;result&gt; = zext &lt;ty&gt; &lt;value&gt; to &lt;ty2&gt;             <i>; yields ty2</i>
3180 </pre>
3181
3182 <h5>Overview:</h5>
3183 <p>The '<tt>zext</tt>' instruction zero extends its operand to type 
3184 <tt>ty2</tt>.</p>
3185
3186
3187 <h5>Arguments:</h5>
3188 <p>The '<tt>zext</tt>' instruction takes a value to cast, which must be of 
3189 <a href="#t_integer">integer</a> type, and a type to cast it to, which must
3190 also be of <a href="#t_integer">integer</a> type. The bit size of the
3191 <tt>value</tt> must be smaller than the bit size of the destination type, 
3192 <tt>ty2</tt>.</p>
3193
3194 <h5>Semantics:</h5>
3195 <p>The <tt>zext</tt> fills the high order bits of the <tt>value</tt> with zero
3196 bits until it reaches the size of the destination type, <tt>ty2</tt>.</p>
3197
3198 <p>When zero extending from i1, the result will always be either 0 or 1.</p>
3199
3200 <h5>Example:</h5>
3201 <pre>
3202   %X = zext i32 257 to i64              <i>; yields i64:257</i>
3203   %Y = zext i1 true to i32              <i>; yields i32:1</i>
3204 </pre>
3205 </div>
3206
3207 <!-- _______________________________________________________________________ -->
3208 <div class="doc_subsubsection">
3209    <a name="i_sext">'<tt>sext .. to</tt>' Instruction</a>
3210 </div>
3211 <div class="doc_text">
3212
3213 <h5>Syntax:</h5>
3214 <pre>
3215   &lt;result&gt; = sext &lt;ty&gt; &lt;value&gt; to &lt;ty2&gt;             <i>; yields ty2</i>
3216 </pre>
3217
3218 <h5>Overview:</h5>
3219 <p>The '<tt>sext</tt>' sign extends <tt>value</tt> to the type <tt>ty2</tt>.</p>
3220
3221 <h5>Arguments:</h5>
3222 <p>
3223 The '<tt>sext</tt>' instruction takes a value to cast, which must be of 
3224 <a href="#t_integer">integer</a> type, and a type to cast it to, which must
3225 also be of <a href="#t_integer">integer</a> type.  The bit size of the
3226 <tt>value</tt> must be smaller than the bit size of the destination type, 
3227 <tt>ty2</tt>.</p>
3228
3229 <h5>Semantics:</h5>
3230 <p>
3231 The '<tt>sext</tt>' instruction performs a sign extension by copying the sign
3232 bit (highest order bit) of the <tt>value</tt> until it reaches the bit size of
3233 the type <tt>ty2</tt>.</p>
3234
3235 <p>When sign extending from i1, the extension always results in -1 or 0.</p>
3236
3237 <h5>Example:</h5>
3238 <pre>
3239   %X = sext i8  -1 to i16              <i>; yields i16   :65535</i>
3240   %Y = sext i1 true to i32             <i>; yields i32:-1</i>
3241 </pre>
3242 </div>
3243
3244 <!-- _______________________________________________________________________ -->
3245 <div class="doc_subsubsection">
3246    <a name="i_fptrunc">'<tt>fptrunc .. to</tt>' Instruction</a>
3247 </div>
3248
3249 <div class="doc_text">
3250
3251 <h5>Syntax:</h5>
3252
3253 <pre>
3254   &lt;result&gt; = fptrunc &lt;ty&gt; &lt;value&gt; to &lt;ty2&gt;             <i>; yields ty2</i>
3255 </pre>
3256
3257 <h5>Overview:</h5>
3258 <p>The '<tt>fptrunc</tt>' instruction truncates <tt>value</tt> to type
3259 <tt>ty2</tt>.</p>
3260
3261
3262 <h5>Arguments:</h5>
3263 <p>The '<tt>fptrunc</tt>' instruction takes a <a href="#t_floating">floating
3264   point</a> value to cast and a <a href="#t_floating">floating point</a> type to
3265 cast it to. The size of <tt>value</tt> must be larger than the size of
3266 <tt>ty2</tt>. This implies that <tt>fptrunc</tt> cannot be used to make a 
3267 <i>no-op cast</i>.</p>
3268
3269 <h5>Semantics:</h5>
3270 <p> The '<tt>fptrunc</tt>' instruction truncates a <tt>value</tt> from a larger
3271 <a href="#t_floating">floating point</a> type to a smaller 
3272 <a href="#t_floating">floating point</a> type.  If the value cannot fit within 
3273 the destination type, <tt>ty2</tt>, then the results are undefined.</p>
3274
3275 <h5>Example:</h5>
3276 <pre>
3277   %X = fptrunc double 123.0 to float         <i>; yields float:123.0</i>
3278   %Y = fptrunc double 1.0E+300 to float      <i>; yields undefined</i>
3279 </pre>
3280 </div>
3281
3282 <!-- _______________________________________________________________________ -->
3283 <div class="doc_subsubsection">
3284    <a name="i_fpext">'<tt>fpext .. to</tt>' Instruction</a>
3285 </div>
3286 <div class="doc_text">
3287
3288 <h5>Syntax:</h5>
3289 <pre>
3290   &lt;result&gt; = fpext &lt;ty&gt; &lt;value&gt; to &lt;ty2&gt;             <i>; yields ty2</i>
3291 </pre>
3292
3293 <h5>Overview:</h5>
3294 <p>The '<tt>fpext</tt>' extends a floating point <tt>value</tt> to a larger
3295 floating point value.</p>
3296
3297 <h5>Arguments:</h5>
3298 <p>The '<tt>fpext</tt>' instruction takes a 
3299 <a href="#t_floating">floating point</a> <tt>value</tt> to cast, 
3300 and a <a href="#t_floating">floating point</a> type to cast it to. The source
3301 type must be smaller than the destination type.</p>
3302
3303 <h5>Semantics:</h5>
3304 <p>The '<tt>fpext</tt>' instruction extends the <tt>value</tt> from a smaller
3305 <a href="#t_floating">floating point</a> type to a larger 
3306 <a href="#t_floating">floating point</a> type. The <tt>fpext</tt> cannot be 
3307 used to make a <i>no-op cast</i> because it always changes bits. Use 
3308 <tt>bitcast</tt> to make a <i>no-op cast</i> for a floating point cast.</p>
3309
3310 <h5>Example:</h5>
3311 <pre>
3312   %X = fpext float 3.1415 to double        <i>; yields double:3.1415</i>
3313   %Y = fpext float 1.0 to float            <i>; yields float:1.0 (no-op)</i>
3314 </pre>
3315 </div>
3316
3317 <!-- _______________________________________________________________________ -->
3318 <div class="doc_subsubsection">
3319    <a name="i_fptoui">'<tt>fptoui .. to</tt>' Instruction</a>
3320 </div>
3321 <div class="doc_text">
3322
3323 <h5>Syntax:</h5>
3324 <pre>
3325   &lt;result&gt; = fptoui &lt;ty&gt; &lt;value&gt; to &lt;ty2&gt;             <i>; yields ty2</i>
3326 </pre>
3327
3328 <h5>Overview:</h5>
3329 <p>The '<tt>fptoui</tt>' converts a floating point <tt>value</tt> to its
3330 unsigned integer equivalent of type <tt>ty2</tt>.
3331 </p>
3332
3333 <h5>Arguments:</h5>
3334 <p>The '<tt>fptoui</tt>' instruction takes a value to cast, which must be a 
3335 scalar or vector <a href="#t_floating">floating point</a> value, and a type 
3336 to cast it to <tt>ty2</tt>, which must be an <a href="#t_integer">integer</a> 
3337 type. If <tt>ty</tt> is a vector floating point type, <tt>ty2</tt> must be a
3338 vector integer type with the same number of elements as <tt>ty</tt></p>
3339
3340 <h5>Semantics:</h5>
3341 <p> The '<tt>fptoui</tt>' instruction converts its 
3342 <a href="#t_floating">floating point</a> operand into the nearest (rounding
3343 towards zero) unsigned integer value. If the value cannot fit in <tt>ty2</tt>,
3344 the results are undefined.</p>
3345
3346 <h5>Example:</h5>
3347 <pre>
3348   %X = fptoui double 123.0 to i32      <i>; yields i32:123</i>
3349   %Y = fptoui float 1.0E+300 to i1     <i>; yields undefined:1</i>
3350   %X = fptoui float 1.04E+17 to i8     <i>; yields undefined:1</i>
3351 </pre>
3352 </div>
3353
3354 <!-- _______________________________________________________________________ -->
3355 <div class="doc_subsubsection">
3356    <a name="i_fptosi">'<tt>fptosi .. to</tt>' Instruction</a>
3357 </div>
3358 <div class="doc_text">
3359
3360 <h5>Syntax:</h5>
3361 <pre>
3362   &lt;result&gt; = fptosi &lt;ty&gt; &lt;value&gt; to &lt;ty2&gt;             <i>; yields ty2</i>
3363 </pre>
3364
3365 <h5>Overview:</h5>
3366 <p>The '<tt>fptosi</tt>' instruction converts 
3367 <a href="#t_floating">floating point</a> <tt>value</tt> to type <tt>ty2</tt>.
3368 </p>
3369
3370 <h5>Arguments:</h5>
3371 <p> The '<tt>fptosi</tt>' instruction takes a value to cast, which must be a 
3372 scalar or vector <a href="#t_floating">floating point</a> value, and a type 
3373 to cast it to <tt>ty2</tt>, which must be an <a href="#t_integer">integer</a> 
3374 type. If <tt>ty</tt> is a vector floating point type, <tt>ty2</tt> must be a
3375 vector integer type with the same number of elements as <tt>ty</tt></p>
3376
3377 <h5>Semantics:</h5>
3378 <p>The '<tt>fptosi</tt>' instruction converts its 
3379 <a href="#t_floating">floating point</a> operand into the nearest (rounding
3380 towards zero) signed integer value. If the value cannot fit in <tt>ty2</tt>,
3381 the results are undefined.</p>
3382
3383 <h5>Example:</h5>
3384 <pre>
3385   %X = fptosi double -123.0 to i32      <i>; yields i32:-123</i>
3386   %Y = fptosi float 1.0E-247 to i1      <i>; yields undefined:1</i>
3387   %X = fptosi float 1.04E+17 to i8      <i>; yields undefined:1</i>
3388 </pre>
3389 </div>
3390
3391 <!-- _______________________________________________________________________ -->
3392 <div class="doc_subsubsection">
3393    <a name="i_uitofp">'<tt>uitofp .. to</tt>' Instruction</a>
3394 </div>
3395 <div class="doc_text">
3396
3397 <h5>Syntax:</h5>
3398 <pre>
3399   &lt;result&gt; = uitofp &lt;ty&gt; &lt;value&gt; to &lt;ty2&gt;             <i>; yields ty2</i>
3400 </pre>
3401
3402 <h5>Overview:</h5>
3403 <p>The '<tt>uitofp</tt>' instruction regards <tt>value</tt> as an unsigned
3404 integer and converts that value to the <tt>ty2</tt> type.</p>
3405
3406 <h5>Arguments:</h5>
3407 <p>The '<tt>uitofp</tt>' instruction takes a value to cast, which must be a
3408 scalar or vector <a href="#t_integer">integer</a> value, and a type to cast it
3409 to <tt>ty2</tt>, which must be an <a href="#t_floating">floating point</a> 
3410 type. If <tt>ty</tt> is a vector integer type, <tt>ty2</tt> must be a vector
3411 floating point type with the same number of elements as <tt>ty</tt></p>
3412
3413 <h5>Semantics:</h5>
3414 <p>The '<tt>uitofp</tt>' instruction interprets its operand as an unsigned
3415 integer quantity and converts it to the corresponding floating point value. If
3416 the value cannot fit in the floating point value, the results are undefined.</p>
3417
3418 <h5>Example:</h5>
3419 <pre>
3420   %X = uitofp i32 257 to float         <i>; yields float:257.0</i>
3421   %Y = uitofp i8  -1 to double         <i>; yields double:255.0</i>
3422 </pre>
3423 </div>
3424
3425 <!-- _______________________________________________________________________ -->
3426 <div class="doc_subsubsection">
3427    <a name="i_sitofp">'<tt>sitofp .. to</tt>' Instruction</a>
3428 </div>
3429 <div class="doc_text">
3430
3431 <h5>Syntax:</h5>
3432 <pre>
3433   &lt;result&gt; = sitofp &lt;ty&gt; &lt;value&gt; to &lt;ty2&gt;             <i>; yields ty2</i>
3434 </pre>
3435
3436 <h5>Overview:</h5>
3437 <p>The '<tt>sitofp</tt>' instruction regards <tt>value</tt> as a signed
3438 integer and converts that value to the <tt>ty2</tt> type.</p>
3439
3440 <h5>Arguments:</h5>
3441 <p>The '<tt>sitofp</tt>' instruction takes a value to cast, which must be a
3442 scalar or vector <a href="#t_integer">integer</a> value, and a type to cast it
3443 to <tt>ty2</tt>, which must be an <a href="#t_floating">floating point</a> 
3444 type. If <tt>ty</tt> is a vector integer type, <tt>ty2</tt> must be a vector
3445 floating point type with the same number of elements as <tt>ty</tt></p>
3446
3447 <h5>Semantics:</h5>
3448 <p>The '<tt>sitofp</tt>' instruction interprets its operand as a signed
3449 integer quantity and converts it to the corresponding floating point value. If
3450 the value cannot fit in the floating point value, the results are undefined.</p>
3451
3452 <h5>Example:</h5>
3453 <pre>
3454   %X = sitofp i32 257 to float         <i>; yields float:257.0</i>
3455   %Y = sitofp i8  -1 to double         <i>; yields double:-1.0</i>
3456 </pre>
3457 </div>
3458
3459 <!-- _______________________________________________________________________ -->
3460 <div class="doc_subsubsection">
3461    <a name="i_ptrtoint">'<tt>ptrtoint .. to</tt>' Instruction</a>
3462 </div>
3463 <div class="doc_text">
3464
3465 <h5>Syntax:</h5>
3466 <pre>
3467   &lt;result&gt; = ptrtoint &lt;ty&gt; &lt;value&gt; to &lt;ty2&gt;             <i>; yields ty2</i>
3468 </pre>
3469
3470 <h5>Overview:</h5>
3471 <p>The '<tt>ptrtoint</tt>' instruction converts the pointer <tt>value</tt> to 
3472 the integer type <tt>ty2</tt>.</p>
3473
3474 <h5>Arguments:</h5>
3475 <p>The '<tt>ptrtoint</tt>' instruction takes a <tt>value</tt> to cast, which 
3476 must be a <a href="#t_pointer">pointer</a> value, and a type to cast it to
3477 <tt>ty2</tt>, which must be an <a href="#t_integer">integer</a> type. 
3478
3479 <h5>Semantics:</h5>
3480 <p>The '<tt>ptrtoint</tt>' instruction converts <tt>value</tt> to integer type
3481 <tt>ty2</tt> by interpreting the pointer value as an integer and either 
3482 truncating or zero extending that value to the size of the integer type. If
3483 <tt>value</tt> is smaller than <tt>ty2</tt> then a zero extension is done. If
3484 <tt>value</tt> is larger than <tt>ty2</tt> then a truncation is done. If they
3485 are the same size, then nothing is done (<i>no-op cast</i>) other than a type
3486 change.</p>
3487
3488 <h5>Example:</h5>
3489 <pre>
3490   %X = ptrtoint i32* %X to i8           <i>; yields truncation on 32-bit architecture</i>
3491   %Y = ptrtoint i32* %x to i64          <i>; yields zero extension on 32-bit architecture</i>
3492 </pre>
3493 </div>
3494
3495 <!-- _______________________________________________________________________ -->
3496 <div class="doc_subsubsection">
3497    <a name="i_inttoptr">'<tt>inttoptr .. to</tt>' Instruction</a>
3498 </div>
3499 <div class="doc_text">
3500
3501 <h5>Syntax:</h5>
3502 <pre>
3503   &lt;result&gt; = inttoptr &lt;ty&gt; &lt;value&gt; to &lt;ty2&gt;             <i>; yields ty2</i>
3504 </pre>
3505
3506 <h5>Overview:</h5>
3507 <p>The '<tt>inttoptr</tt>' instruction converts an integer <tt>value</tt> to 
3508 a pointer type, <tt>ty2</tt>.</p>
3509
3510 <h5>Arguments:</h5>
3511 <p>The '<tt>inttoptr</tt>' instruction takes an <a href="#t_integer">integer</a>
3512 value to cast, and a type to cast it to, which must be a 
3513 <a href="#t_pointer">pointer</a> type.
3514
3515 <h5>Semantics:</h5>
3516 <p>The '<tt>inttoptr</tt>' instruction converts <tt>value</tt> to type
3517 <tt>ty2</tt> by applying either a zero extension or a truncation depending on
3518 the size of the integer <tt>value</tt>. If <tt>value</tt> is larger than the
3519 size of a pointer then a truncation is done. If <tt>value</tt> is smaller than
3520 the size of a pointer then a zero extension is done. If they are the same size,
3521 nothing is done (<i>no-op cast</i>).</p>
3522
3523 <h5>Example:</h5>
3524 <pre>
3525   %X = inttoptr i32 255 to i32*          <i>; yields zero extension on 64-bit architecture</i>
3526   %X = inttoptr i32 255 to i32*          <i>; yields no-op on 32-bit architecture</i>
3527   %Y = inttoptr i64 0 to i32*            <i>; yields truncation on 32-bit architecture</i>
3528 </pre>
3529 </div>
3530
3531 <!-- _______________________________________________________________________ -->
3532 <div class="doc_subsubsection">
3533    <a name="i_bitcast">'<tt>bitcast .. to</tt>' Instruction</a>
3534 </div>
3535 <div class="doc_text">
3536
3537 <h5>Syntax:</h5>
3538 <pre>
3539   &lt;result&gt; = bitcast &lt;ty&gt; &lt;value&gt; to &lt;ty2&gt;             <i>; yields ty2</i>
3540 </pre>
3541
3542 <h5>Overview:</h5>
3543 <p>The '<tt>bitcast</tt>' instruction converts <tt>value</tt> to type
3544 <tt>ty2</tt> without changing any bits.</p>
3545
3546 <h5>Arguments:</h5>
3547 <p>The '<tt>bitcast</tt>' instruction takes a value to cast, which must be 
3548 a first class value, and a type to cast it to, which must also be a <a
3549   href="#t_firstclass">first class</a> type. The bit sizes of <tt>value</tt>
3550 and the destination type, <tt>ty2</tt>, must be identical. If the source
3551 type is a pointer, the destination type must also be a pointer.</p>
3552
3553 <h5>Semantics:</h5>
3554 <p>The '<tt>bitcast</tt>' instruction converts <tt>value</tt> to type
3555 <tt>ty2</tt>. It is always a <i>no-op cast</i> because no bits change with 
3556 this conversion.  The conversion is done as if the <tt>value</tt> had been 
3557 stored to memory and read back as type <tt>ty2</tt>. Pointer types may only be
3558 converted to other pointer types with this instruction. To convert pointers to 
3559 other types, use the <a href="#i_inttoptr">inttoptr</a> or 
3560 <a href="#i_ptrtoint">ptrtoint</a> instructions first.</p>
3561
3562 <h5>Example:</h5>
3563 <pre>
3564   %X = bitcast i8 255 to i8              <i>; yields i8 :-1</i>
3565   %Y = bitcast i32* %x to sint*          <i>; yields sint*:%x</i>
3566   %Z = bitcast <2xint> %V to i64;        <i>; yields i64: %V</i>   
3567 </pre>
3568 </div>
3569
3570 <!-- ======================================================================= -->
3571 <div class="doc_subsection"> <a name="otherops">Other Operations</a> </div>
3572 <div class="doc_text">
3573 <p>The instructions in this category are the "miscellaneous"
3574 instructions, which defy better classification.</p>
3575 </div>
3576
3577 <!-- _______________________________________________________________________ -->
3578 <div class="doc_subsubsection"><a name="i_icmp">'<tt>icmp</tt>' Instruction</a>
3579 </div>
3580 <div class="doc_text">
3581 <h5>Syntax:</h5>
3582 <pre>  &lt;result&gt; = icmp &lt;cond&gt; &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt;   <i>; yields {i1}:result</i>
3583 </pre>
3584 <h5>Overview:</h5>
3585 <p>The '<tt>icmp</tt>' instruction returns a boolean value based on comparison
3586 of its two integer or pointer operands.</p>
3587 <h5>Arguments:</h5>
3588 <p>The '<tt>icmp</tt>' instruction takes three operands. The first operand is
3589 the condition code indicating the kind of comparison to perform. It is not
3590 a value, just a keyword. The possible condition code are:
3591 <ol>
3592   <li><tt>eq</tt>: equal</li>
3593   <li><tt>ne</tt>: not equal </li>
3594   <li><tt>ugt</tt>: unsigned greater than</li>
3595   <li><tt>uge</tt>: unsigned greater or equal</li>
3596   <li><tt>ult</tt>: unsigned less than</li>
3597   <li><tt>ule</tt>: unsigned less or equal</li>
3598   <li><tt>sgt</tt>: signed greater than</li>
3599   <li><tt>sge</tt>: signed greater or equal</li>
3600   <li><tt>slt</tt>: signed less than</li>
3601   <li><tt>sle</tt>: signed less or equal</li>
3602 </ol>
3603 <p>The remaining two arguments must be <a href="#t_integer">integer</a> or
3604 <a href="#t_pointer">pointer</a> typed. They must also be identical types.</p>
3605 <h5>Semantics:</h5>
3606 <p>The '<tt>icmp</tt>' compares <tt>var1</tt> and <tt>var2</tt> according to 
3607 the condition code given as <tt>cond</tt>. The comparison performed always
3608 yields a <a href="#t_primitive">i1</a> result, as follows: 
3609 <ol>
3610   <li><tt>eq</tt>: yields <tt>true</tt> if the operands are equal, 
3611   <tt>false</tt> otherwise. No sign interpretation is necessary or performed.
3612   </li>
3613   <li><tt>ne</tt>: yields <tt>true</tt> if the operands are unequal, 
3614   <tt>false</tt> otherwise. No sign interpretation is necessary or performed.
3615   <li><tt>ugt</tt>: interprets the operands as unsigned values and yields
3616   <tt>true</tt> if <tt>var1</tt> is greater than <tt>var2</tt>.</li>
3617   <li><tt>uge</tt>: interprets the operands as unsigned values and yields
3618   <tt>true</tt> if <tt>var1</tt> is greater than or equal to <tt>var2</tt>.</li>
3619   <li><tt>ult</tt>: interprets the operands as unsigned values and yields
3620   <tt>true</tt> if <tt>var1</tt> is less than <tt>var2</tt>.</li>
3621   <li><tt>ule</tt>: interprets the operands as unsigned values and yields
3622   <tt>true</tt> if <tt>var1</tt> is less than or equal to <tt>var2</tt>.</li>
3623   <li><tt>sgt</tt>: interprets the operands as signed values and yields
3624   <tt>true</tt> if <tt>var1</tt> is greater than <tt>var2</tt>.</li>
3625   <li><tt>sge</tt>: interprets the operands as signed values and yields
3626   <tt>true</tt> if <tt>var1</tt> is greater than or equal to <tt>var2</tt>.</li>
3627   <li><tt>slt</tt>: interprets the operands as signed values and yields
3628   <tt>true</tt> if <tt>var1</tt> is less than <tt>var2</tt>.</li>
3629   <li><tt>sle</tt>: interprets the operands as signed values and yields
3630   <tt>true</tt> if <tt>var1</tt> is less than or equal to <tt>var2</tt>.</li>
3631 </ol>
3632 <p>If the operands are <a href="#t_pointer">pointer</a> typed, the pointer
3633 values are compared as if they were integers.</p>
3634
3635 <h5>Example:</h5>
3636 <pre>  &lt;result&gt; = icmp eq i32 4, 5          <i>; yields: result=false</i>
3637   &lt;result&gt; = icmp ne float* %X, %X     <i>; yields: result=false</i>
3638   &lt;result&gt; = icmp ult i16  4, 5        <i>; yields: result=true</i>
3639   &lt;result&gt; = icmp sgt i16  4, 5        <i>; yields: result=false</i>
3640   &lt;result&gt; = icmp ule i16 -4, 5        <i>; yields: result=false</i>
3641   &lt;result&gt; = icmp sge i16  4, 5        <i>; yields: result=false</i>
3642 </pre>
3643 </div>
3644
3645 <!-- _______________________________________________________________________ -->
3646 <div class="doc_subsubsection"><a name="i_fcmp">'<tt>fcmp</tt>' Instruction</a>
3647 </div>
3648 <div class="doc_text">
3649 <h5>Syntax:</h5>
3650 <pre>  &lt;result&gt; = fcmp &lt;cond&gt; &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt;     <i>; yields {i1}:result</i>
3651 </pre>
3652 <h5>Overview:</h5>
3653 <p>The '<tt>fcmp</tt>' instruction returns a boolean value based on comparison
3654 of its floating point operands.</p>
3655 <h5>Arguments:</h5>
3656 <p>The '<tt>fcmp</tt>' instruction takes three operands. The first operand is
3657 the condition code indicating the kind of comparison to perform. It is not
3658 a value, just a keyword. The possible condition code are:
3659 <ol>
3660   <li><tt>false</tt>: no comparison, always returns false</li>
3661   <li><tt>oeq</tt>: ordered and equal</li>
3662   <li><tt>ogt</tt>: ordered and greater than </li>
3663   <li><tt>oge</tt>: ordered and greater than or equal</li>
3664   <li><tt>olt</tt>: ordered and less than </li>
3665   <li><tt>ole</tt>: ordered and less than or equal</li>
3666   <li><tt>one</tt>: ordered and not equal</li>
3667   <li><tt>ord</tt>: ordered (no nans)</li>
3668   <li><tt>ueq</tt>: unordered or equal</li>
3669   <li><tt>ugt</tt>: unordered or greater than </li>
3670   <li><tt>uge</tt>: unordered or greater than or equal</li>
3671   <li><tt>ult</tt>: unordered or less than </li>
3672   <li><tt>ule</tt>: unordered or less than or equal</li>
3673   <li><tt>une</tt>: unordered or not equal</li>
3674   <li><tt>uno</tt>: unordered (either nans)</li>
3675   <li><tt>true</tt>: no comparison, always returns true</li>
3676 </ol>
3677 <p><i>Ordered</i> means that neither operand is a QNAN while
3678 <i>unordered</i> means that either operand may be a QNAN.</p>
3679 <p>The <tt>val1</tt> and <tt>val2</tt> arguments must be
3680 <a href="#t_floating">floating point</a> typed.  They must have identical 
3681 types.</p>
3682 <h5>Semantics:</h5>
3683 <p>The '<tt>fcmp</tt>' instruction compares <tt>var1</tt> and <tt>var2</tt>
3684 according to the condition code given as <tt>cond</tt>. The comparison performed 
3685 always yields a <a href="#t_primitive">i1</a> result, as follows: 
3686 <ol>
3687   <li><tt>false</tt>: always yields <tt>false</tt>, regardless of operands.</li>
3688   <li><tt>oeq</tt>: yields <tt>true</tt> if both operands are not a QNAN and 
3689   <tt>var1</tt> is equal to <tt>var2</tt>.</li>
3690   <li><tt>ogt</tt>: yields <tt>true</tt> if both operands are not a QNAN and
3691   <tt>var1</tt> is greather than <tt>var2</tt>.</li>
3692   <li><tt>oge</tt>: yields <tt>true</tt> if both operands are not a QNAN and 
3693   <tt>var1</tt> is greater than or equal to <tt>var2</tt>.</li>
3694   <li><tt>olt</tt>: yields <tt>true</tt> if both operands are not a QNAN and 
3695   <tt>var1</tt> is less than <tt>var2</tt>.</li>
3696   <li><tt>ole</tt>: yields <tt>true</tt> if both operands are not a QNAN and 
3697   <tt>var1</tt> is less than or equal to <tt>var2</tt>.</li>
3698   <li><tt>one</tt>: yields <tt>true</tt> if both operands are not a QNAN and 
3699   <tt>var1</tt> is not equal to <tt>var2</tt>.</li>
3700   <li><tt>ord</tt>: yields <tt>true</tt> if both operands are not a QNAN.</li>
3701   <li><tt>ueq</tt>: yields <tt>true</tt> if either operand is a QNAN or 
3702   <tt>var1</tt> is equal to <tt>var2</tt>.</li>
3703   <li><tt>ugt</tt>: yields <tt>true</tt> if either operand is a QNAN or 
3704   <tt>var1</tt> is greater than <tt>var2</tt>.</li>
3705   <li><tt>uge</tt>: yields <tt>true</tt> if either operand is a QNAN or 
3706   <tt>var1</tt> is greater than or equal to <tt>var2</tt>.</li>
3707   <li><tt>ult</tt>: yields <tt>true</tt> if either operand is a QNAN or 
3708   <tt>var1</tt> is less than <tt>var2</tt>.</li>
3709   <li><tt>ule</tt>: yields <tt>true</tt> if either operand is a QNAN or 
3710   <tt>var1</tt> is less than or equal to <tt>var2</tt>.</li>
3711   <li><tt>une</tt>: yields <tt>true</tt> if either operand is a QNAN or 
3712   <tt>var1</tt> is not equal to <tt>var2</tt>.</li>
3713   <li><tt>uno</tt>: yields <tt>true</tt> if either operand is a QNAN.</li>
3714   <li><tt>true</tt>: always yields <tt>true</tt>, regardless of operands.</li>
3715 </ol>
3716
3717 <h5>Example:</h5>
3718 <pre>  &lt;result&gt; = fcmp oeq float 4.0, 5.0    <i>; yields: result=false</i>
3719   &lt;result&gt; = icmp one float 4.0, 5.0    <i>; yields: result=true</i>
3720   &lt;result&gt; = icmp olt float 4.0, 5.0    <i>; yields: result=true</i>
3721   &lt;result&gt; = icmp ueq double 1.0, 2.0   <i>; yields: result=false</i>
3722 </pre>
3723 </div>
3724
3725 <!-- _______________________________________________________________________ -->
3726 <div class="doc_subsubsection">
3727   <a name="i_vicmp">'<tt>vicmp</tt>' Instruction</a>
3728 </div>
3729 <div class="doc_text">
3730 <h5>Syntax:</h5>
3731 <pre>  &lt;result&gt; = vicmp &lt;cond&gt; &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt;   <i>; yields {ty}:result</i>
3732 </pre>
3733 <h5>Overview:</h5>
3734 <p>The '<tt>vicmp</tt>' instruction returns an integer vector value based on
3735 element-wise comparison of its two integer vector operands.</p>
3736 <h5>Arguments:</h5>
3737 <p>The '<tt>vicmp</tt>' instruction takes three operands. The first operand is
3738 the condition code indicating the kind of comparison to perform. It is not
3739 a value, just a keyword. The possible condition code are:
3740 <ol>
3741   <li><tt>eq</tt>: equal</li>
3742   <li><tt>ne</tt>: not equal </li>
3743   <li><tt>ugt</tt>: unsigned greater than</li>
3744   <li><tt>uge</tt>: unsigned greater or equal</li>
3745   <li><tt>ult</tt>: unsigned less than</li>
3746   <li><tt>ule</tt>: unsigned less or equal</li>
3747   <li><tt>sgt</tt>: signed greater than</li>
3748   <li><tt>sge</tt>: signed greater or equal</li>
3749   <li><tt>slt</tt>: signed less than</li>
3750   <li><tt>sle</tt>: signed less or equal</li>
3751 </ol>
3752 <p>The remaining two arguments must be <a href="#t_vector">vector</a> of 
3753 <a href="#t_integer">integer</a> typed. They must also be identical types.</p>
3754 <h5>Semantics:</h5>
3755 <p>The '<tt>vicmp</tt>' instruction compares <tt>var1</tt> and <tt>var2</tt>
3756 according to the condition code given as <tt>cond</tt>. The comparison yields a 
3757 <a href="#t_vector">vector</a> of <a href="#t_integer">integer</a> result, of
3758 identical type as the values being compared.  The most significant bit in each
3759 element is 1 if the element-wise comparison evaluates to true, and is 0
3760 otherwise.  All other bits of the result are undefined.  The condition codes
3761 are evaluated identically to the <a href="#i_icmp">'<tt>icmp</tt>'
3762 instruction</a>.
3763
3764 <h5>Example:</h5>
3765 <pre>
3766   &lt;result&gt; = vicmp eq <2 x i32> < i32 4, i32 0 >, < i32 5, i32 0 >   <i>; yields: result=<2 x i32> < i32 0, i32 -1 ></i>
3767   &lt;result&gt; = vicmp ult <2 x i8> < i8 1, i8 2 >, < i8 2, i8 2>        <i>; yields: result=<2 x i8> < i8 -1, i8 0 ></i>
3768 </pre>
3769 </div>
3770
3771 <!-- _______________________________________________________________________ -->
3772 <div class="doc_subsubsection">
3773   <a name="i_vfcmp">'<tt>vfcmp</tt>' Instruction</a>
3774 </div>
3775 <div class="doc_text">
3776 <h5>Syntax:</h5>
3777 <pre>  &lt;result&gt; = vfcmp &lt;cond&gt; &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt;</pre>
3778 <h5>Overview:</h5>
3779 <p>The '<tt>vfcmp</tt>' instruction returns an integer vector value based on
3780 element-wise comparison of its two floating point vector operands.  The output
3781 elements have the same width as the input elements.</p>
3782 <h5>Arguments:</h5>
3783 <p>The '<tt>vfcmp</tt>' instruction takes three operands. The first operand is
3784 the condition code indicating the kind of comparison to perform. It is not
3785 a value, just a keyword. The possible condition code are:
3786 <ol>
3787   <li><tt>false</tt>: no comparison, always returns false</li>
3788   <li><tt>oeq</tt>: ordered and equal</li>
3789   <li><tt>ogt</tt>: ordered and greater than </li>
3790   <li><tt>oge</tt>: ordered and greater than or equal</li>
3791   <li><tt>olt</tt>: ordered and less than </li>
3792   <li><tt>ole</tt>: ordered and less than or equal</li>
3793   <li><tt>one</tt>: ordered and not equal</li>
3794   <li><tt>ord</tt>: ordered (no nans)</li>
3795   <li><tt>ueq</tt>: unordered or equal</li>
3796   <li><tt>ugt</tt>: unordered or greater than </li>
3797   <li><tt>uge</tt>: unordered or greater than or equal</li>
3798   <li><tt>ult</tt>: unordered or less than </li>
3799   <li><tt>ule</tt>: unordered or less than or equal</li>
3800   <li><tt>une</tt>: unordered or not equal</li>
3801   <li><tt>uno</tt>: unordered (either nans)</li>
3802   <li><tt>true</tt>: no comparison, always returns true</li>
3803 </ol>
3804 <p>The remaining two arguments must be <a href="#t_vector">vector</a> of 
3805 <a href="#t_floating">floating point</a> typed. They must also be identical
3806 types.</p>
3807 <h5>Semantics:</h5>
3808 <p>The '<tt>vfcmp</tt>' instruction compares <tt>var1</tt> and <tt>var2</tt>
3809 according to  the condition code given as <tt>cond</tt>. The comparison yields a 
3810 <a href="#t_vector">vector</a> of <a href="#t_integer">integer</a> result, with
3811 an identical number of elements as the values being compared, and each element
3812 having identical with to the width of the floating point elements. The most 
3813 significant bit in each element is 1 if the element-wise comparison evaluates to
3814 true, and is 0 otherwise.  All other bits of the result are undefined.  The
3815 condition codes are evaluated identically to the 
3816 <a href="#i_fcmp">'<tt>fcmp</tt>' instruction</a>.
3817
3818 <h5>Example:</h5>
3819 <pre>
3820   &lt;result&gt; = vfcmp oeq <2 x float> < float 4, float 0 >, < float 5, float 0 >       <i>; yields: result=<2 x i32> < i32 0, i32 -1 ></i>
3821   &lt;result&gt; = vfcmp ult <2 x double> < double 1, double 2 >, < double 2, double 2>   <i>; yields: result=<2 x i64> < i64 -1, i64 0 ></i>
3822 </pre>
3823 </div>
3824
3825 <!-- _______________________________________________________________________ -->
3826 <div class="doc_subsubsection"> <a name="i_phi">'<tt>phi</tt>'
3827 Instruction</a> </div>
3828 <div class="doc_text">
3829 <h5>Syntax:</h5>
3830 <pre>  &lt;result&gt; = phi &lt;ty&gt; [ &lt;val0&gt;, &lt;label0&gt;], ...<br></pre>
3831 <h5>Overview:</h5>
3832 <p>The '<tt>phi</tt>' instruction is used to implement the &#966; node in
3833 the SSA graph representing the function.</p>
3834 <h5>Arguments:</h5>
3835 <p>The type of the incoming values is specified with the first type
3836 field. After this, the '<tt>phi</tt>' instruction takes a list of pairs
3837 as arguments, with one pair for each predecessor basic block of the
3838 current block.  Only values of <a href="#t_firstclass">first class</a>
3839 type may be used as the value arguments to the PHI node.  Only labels
3840 may be used as the label arguments.</p>
3841 <p>There must be no non-phi instructions between the start of a basic
3842 block and the PHI instructions: i.e. PHI instructions must be first in
3843 a basic block.</p>
3844 <h5>Semantics:</h5>
3845 <p>At runtime, the '<tt>phi</tt>' instruction logically takes on the value
3846 specified by the pair corresponding to the predecessor basic block that executed
3847 just prior to the current block.</p>
3848 <h5>Example:</h5>
3849 <pre>Loop:       ; Infinite loop that counts from 0 on up...<br>  %indvar = phi i32 [ 0, %LoopHeader ], [ %nextindvar, %Loop ]<br>  %nextindvar = add i32 %indvar, 1<br>  br label %Loop<br></pre>
3850 </div>
3851
3852 <!-- _______________________________________________________________________ -->
3853 <div class="doc_subsubsection">
3854    <a name="i_select">'<tt>select</tt>' Instruction</a>
3855 </div>
3856
3857 <div class="doc_text">
3858
3859 <h5>Syntax:</h5>
3860
3861 <pre>
3862   &lt;result&gt; = select i1 &lt;cond&gt;, &lt;ty&gt; &lt;val1&gt;, &lt;ty&gt; &lt;val2&gt;             <i>; yields ty</i>
3863 </pre>
3864
3865 <h5>Overview:</h5>
3866
3867 <p>
3868 The '<tt>select</tt>' instruction is used to choose one value based on a
3869 condition, without branching.
3870 </p>
3871
3872
3873 <h5>Arguments:</h5>
3874
3875 <p>
3876 The '<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.
3877 </p>
3878
3879 <h5>Semantics:</h5>
3880
3881 <p>
3882 If the boolean condition evaluates to true, the instruction returns the first
3883 value argument; otherwise, it returns the second value argument.
3884 </p>
3885
3886 <h5>Example:</h5>
3887
3888 <pre>
3889   %X = select i1 true, i8 17, i8 42          <i>; yields i8:17</i>
3890 </pre>
3891 </div>
3892
3893
3894 <!-- _______________________________________________________________________ -->
3895 <div class="doc_subsubsection">
3896   <a name="i_call">'<tt>call</tt>' Instruction</a>
3897 </div>
3898
3899 <div class="doc_text">
3900
3901 <h5>Syntax:</h5>
3902 <pre>
3903   &lt;result&gt; = [tail] call [<a href="#callingconv">cconv</a>] &lt;ty&gt; [&lt;fnty&gt;*] &lt;fnptrval&gt;(&lt;param list&gt;)
3904 </pre>
3905
3906 <h5>Overview:</h5>
3907
3908 <p>The '<tt>call</tt>' instruction represents a simple function call.</p>
3909
3910 <h5>Arguments:</h5>
3911
3912 <p>This instruction requires several arguments:</p>
3913
3914 <ol>
3915   <li>
3916     <p>The optional "tail" marker indicates whether the callee function accesses
3917     any allocas or varargs in the caller.  If the "tail" marker is present, the
3918     function call is eligible for tail call optimization.  Note that calls may
3919     be marked "tail" even if they do not occur before a <a
3920     href="#i_ret"><tt>ret</tt></a> instruction.
3921   </li>
3922   <li>
3923     <p>The optional "cconv" marker indicates which <a href="#callingconv">calling
3924     convention</a> the call should use.  If none is specified, the call defaults
3925     to using C calling conventions.
3926   </li>
3927   <li>
3928     <p>'<tt>ty</tt>': the type of the call instruction itself which is also
3929     the type of the return value.  Functions that return no value are marked
3930     <tt><a href="#t_void">void</a></tt>.</p>
3931   </li>
3932   <li>
3933     <p>'<tt>fnty</tt>': shall be the signature of the pointer to function
3934     value being invoked.  The argument types must match the types implied by
3935     this signature.  This type can be omitted if the function is not varargs
3936     and if the function type does not return a pointer to a function.</p>
3937   </li>
3938   <li>
3939     <p>'<tt>fnptrval</tt>': An LLVM value containing a pointer to a function to
3940     be invoked. In most cases, this is a direct function invocation, but
3941     indirect <tt>call</tt>s are just as possible, calling an arbitrary pointer
3942     to function value.</p>
3943   </li>
3944   <li>
3945     <p>'<tt>function args</tt>': argument list whose types match the
3946     function signature argument types. All arguments must be of 
3947     <a href="#t_firstclass">first class</a> type. If the function signature 
3948     indicates the function accepts a variable number of arguments, the extra 
3949     arguments can be specified.</p>
3950   </li>
3951 </ol>
3952
3953 <h5>Semantics:</h5>
3954
3955 <p>The '<tt>call</tt>' instruction is used to cause control flow to
3956 transfer to a specified function, with its incoming arguments bound to
3957 the specified values. Upon a '<tt><a href="#i_ret">ret</a></tt>'
3958 instruction in the called function, control flow continues with the
3959 instruction after the function call, and the return value of the
3960 function is bound to the result argument.  If the callee returns multiple 
3961 values then the return values of the function are only accessible through 
3962 the '<tt><a href="#i_getresult">getresult</a></tt>' instruction.</p>
3963
3964 <h5>Example:</h5>
3965
3966 <pre>
3967   %retval = call i32 @test(i32 %argc)
3968   call i32 (i8 *, ...)* @printf(i8 * %msg, i32 12, i8 42)      <i>; yields i32</i>
3969   %X = tail call i32 @foo()                                    <i>; yields i32</i>
3970   %Y = tail call <a href="#callingconv">fastcc</a> i32 @foo()  <i>; yields i32</i>
3971   call void %foo(i8 97 signext)
3972
3973   %struct.A = type { i32, i8 }
3974   %r = call %struct.A @foo()                     <i>; yields { 32, i8 }</i>
3975   %gr = getresult %struct.A %r, 0                <i>; yields i32</i>
3976   %gr1 = getresult %struct.A %r, 1               <i>; yields i8</i>
3977 </pre>
3978
3979 </div>
3980
3981 <!-- _______________________________________________________________________ -->
3982 <div class="doc_subsubsection">
3983   <a name="i_va_arg">'<tt>va_arg</tt>' Instruction</a>
3984 </div>
3985
3986 <div class="doc_text">
3987
3988 <h5>Syntax:</h5>
3989
3990 <pre>
3991   &lt;resultval&gt; = va_arg &lt;va_list*&gt; &lt;arglist&gt;, &lt;argty&gt;
3992 </pre>
3993
3994 <h5>Overview:</h5>
3995
3996 <p>The '<tt>va_arg</tt>' instruction is used to access arguments passed through
3997 the "variable argument" area of a function call.  It is used to implement the
3998 <tt>va_arg</tt> macro in C.</p>
3999
4000 <h5>Arguments:</h5>
4001
4002 <p>This instruction takes a <tt>va_list*</tt> value and the type of
4003 the argument. It returns a value of the specified argument type and
4004 increments the <tt>va_list</tt> to point to the next argument.  The
4005 actual type of <tt>va_list</tt> is target specific.</p>
4006
4007 <h5>Semantics:</h5>
4008
4009 <p>The '<tt>va_arg</tt>' instruction loads an argument of the specified
4010 type from the specified <tt>va_list</tt> and causes the
4011 <tt>va_list</tt> to point to the next argument.  For more information,
4012 see the variable argument handling <a href="#int_varargs">Intrinsic
4013 Functions</a>.</p>
4014
4015 <p>It is legal for this instruction to be called in a function which does not
4016 take a variable number of arguments, for example, the <tt>vfprintf</tt>
4017 function.</p>
4018
4019 <p><tt>va_arg</tt> is an LLVM instruction instead of an <a
4020 href="#intrinsics">intrinsic function</a> because it takes a type as an
4021 argument.</p>
4022
4023 <h5>Example:</h5>
4024
4025 <p>See the <a href="#int_varargs">variable argument processing</a> section.</p>
4026
4027 </div>
4028
4029 <!-- _______________________________________________________________________ -->
4030 <div class="doc_subsubsection">
4031   <a name="i_getresult">'<tt>getresult</tt>' Instruction</a>
4032 </div>
4033
4034 <div class="doc_text">
4035
4036 <h5>Syntax:</h5>
4037 <pre>
4038   &lt;resultval&gt; = getresult &lt;type&gt; &lt;retval&gt;, &lt;index&gt;
4039 </pre>
4040
4041 <h5>Overview:</h5>
4042
4043 <p> The '<tt>getresult</tt>' instruction is used to extract individual values
4044 from a '<tt><a href="#i_call">call</a></tt>' 
4045 or '<tt><a href="#i_invoke">invoke</a></tt>' instruction that returns multiple
4046 results.</p>
4047
4048 <h5>Arguments:</h5>
4049
4050 <p>The '<tt>getresult</tt>' instruction takes a call or invoke value as its 
4051 first argument, or an undef value.  The value must have <a 
4052 href="#t_struct">structure type</a>.  The second argument is a constant 
4053 unsigned index value which must be in range for the number of values returned 
4054 by the call.</p>
4055
4056 <h5>Semantics:</h5>
4057
4058 <p>The '<tt>getresult</tt>' instruction extracts the element identified by
4059 '<tt>index</tt>' from the aggregate value.</p>
4060
4061 <h5>Example:</h5>
4062
4063 <pre>
4064   %struct.A = type { i32, i8 }
4065
4066   %r = call %struct.A @foo()
4067   %gr = getresult %struct.A %r, 0    <i>; yields i32:%gr</i>
4068   %gr1 = getresult %struct.A %r, 1   <i>; yields i8:%gr1</i>
4069   add i32 %gr, 42
4070   add i8 %gr1, 41
4071 </pre>
4072
4073 </div>
4074
4075 <!-- *********************************************************************** -->
4076 <div class="doc_section"> <a name="intrinsics">Intrinsic Functions</a> </div>
4077 <!-- *********************************************************************** -->
4078
4079 <div class="doc_text">
4080
4081 <p>LLVM supports the notion of an "intrinsic function".  These functions have
4082 well known names and semantics and are required to follow certain restrictions.
4083 Overall, these intrinsics represent an extension mechanism for the LLVM 
4084 language that does not require changing all of the transformations in LLVM when 
4085 adding to the language (or the bitcode reader/writer, the parser, etc...).</p>
4086
4087 <p>Intrinsic function names must all start with an "<tt>llvm.</tt>" prefix. This
4088 prefix is reserved in LLVM for intrinsic names; thus, function names may not
4089 begin with this prefix.  Intrinsic functions must always be external functions:
4090 you cannot define the body of intrinsic functions.  Intrinsic functions may
4091 only be used in call or invoke instructions: it is illegal to take the address
4092 of an intrinsic function.  Additionally, because intrinsic functions are part
4093 of the LLVM language, it is required if any are added that they be documented
4094 here.</p>
4095
4096 <p>Some intrinsic functions can be overloaded, i.e., the intrinsic represents 
4097 a family of functions that perform the same operation but on different data 
4098 types. Because LLVM can represent over 8 million different integer types, 
4099 overloading is used commonly to allow an intrinsic function to operate on any 
4100 integer type. One or more of the argument types or the result type can be 
4101 overloaded to accept any integer type. Argument types may also be defined as 
4102 exactly matching a previous argument's type or the result type. This allows an 
4103 intrinsic function which accepts multiple arguments, but needs all of them to 
4104 be of the same type, to only be overloaded with respect to a single argument or 
4105 the result.</p>
4106
4107 <p>Overloaded intrinsics will have the names of its overloaded argument types 
4108 encoded into its function name, each preceded by a period. Only those types 
4109 which are overloaded result in a name suffix. Arguments whose type is matched 
4110 against another type do not. For example, the <tt>llvm.ctpop</tt> function can 
4111 take an integer of any width and returns an integer of exactly the same integer 
4112 width. This leads to a family of functions such as
4113 <tt>i8 @llvm.ctpop.i8(i8 %val)</tt> and <tt>i29 @llvm.ctpop.i29(i29 %val)</tt>.
4114 Only one type, the return type, is overloaded, and only one type suffix is 
4115 required. Because the argument's type is matched against the return type, it 
4116 does not require its own name suffix.</p>
4117
4118 <p>To learn how to add an intrinsic function, please see the 
4119 <a href="ExtendingLLVM.html">Extending LLVM Guide</a>.
4120 </p>
4121
4122 </div>
4123
4124 <!-- ======================================================================= -->
4125 <div class="doc_subsection">
4126   <a name="int_varargs">Variable Argument Handling Intrinsics</a>
4127 </div>
4128
4129 <div class="doc_text">
4130
4131 <p>Variable argument support is defined in LLVM with the <a
4132  href="#i_va_arg"><tt>va_arg</tt></a> instruction and these three
4133 intrinsic functions.  These functions are related to the similarly
4134 named macros defined in the <tt>&lt;stdarg.h&gt;</tt> header file.</p>
4135
4136 <p>All of these functions operate on arguments that use a
4137 target-specific value type "<tt>va_list</tt>".  The LLVM assembly
4138 language reference manual does not define what this type is, so all
4139 transformations should be prepared to handle these functions regardless of
4140 the type used.</p>
4141
4142 <p>This example shows how the <a href="#i_va_arg"><tt>va_arg</tt></a>
4143 instruction and the variable argument handling intrinsic functions are
4144 used.</p>
4145
4146 <div class="doc_code">
4147 <pre>
4148 define i32 @test(i32 %X, ...) {
4149   ; Initialize variable argument processing
4150   %ap = alloca i8*
4151   %ap2 = bitcast i8** %ap to i8*
4152   call void @llvm.va_start(i8* %ap2)
4153
4154   ; Read a single integer argument
4155   %tmp = va_arg i8** %ap, i32
4156
4157   ; Demonstrate usage of llvm.va_copy and llvm.va_end
4158   %aq = alloca i8*
4159   %aq2 = bitcast i8** %aq to i8*
4160   call void @llvm.va_copy(i8* %aq2, i8* %ap2)
4161   call void @llvm.va_end(i8* %aq2)
4162
4163   ; Stop processing of arguments.
4164   call void @llvm.va_end(i8* %ap2)
4165   ret i32 %tmp
4166 }
4167
4168 declare void @llvm.va_start(i8*)
4169 declare void @llvm.va_copy(i8*, i8*)
4170 declare void @llvm.va_end(i8*)
4171 </pre>
4172 </div>
4173
4174 </div>
4175
4176 <!-- _______________________________________________________________________ -->
4177 <div class="doc_subsubsection">
4178   <a name="int_va_start">'<tt>llvm.va_start</tt>' Intrinsic</a>
4179 </div>
4180
4181
4182 <div class="doc_text">
4183 <h5>Syntax:</h5>
4184 <pre>  declare void %llvm.va_start(i8* &lt;arglist&gt;)<br></pre>
4185 <h5>Overview:</h5>
4186 <P>The '<tt>llvm.va_start</tt>' intrinsic initializes
4187 <tt>*&lt;arglist&gt;</tt> for subsequent use by <tt><a
4188 href="#i_va_arg">va_arg</a></tt>.</p>
4189
4190 <h5>Arguments:</h5>
4191
4192 <P>The argument is a pointer to a <tt>va_list</tt> element to initialize.</p>
4193
4194 <h5>Semantics:</h5>
4195
4196 <P>The '<tt>llvm.va_start</tt>' intrinsic works just like the <tt>va_start</tt>
4197 macro available in C.  In a target-dependent way, it initializes the
4198 <tt>va_list</tt> element to which the argument points, so that the next call to
4199 <tt>va_arg</tt> will produce the first variable argument passed to the function.
4200 Unlike the C <tt>va_start</tt> macro, this intrinsic does not need to know the
4201 last argument of the function as the compiler can figure that out.</p>
4202
4203 </div>
4204
4205 <!-- _______________________________________________________________________ -->
4206 <div class="doc_subsubsection">
4207  <a name="int_va_end">'<tt>llvm.va_end</tt>' Intrinsic</a>
4208 </div>
4209
4210 <div class="doc_text">
4211 <h5>Syntax:</h5>
4212 <pre>  declare void @llvm.va_end(i8* &lt;arglist&gt;)<br></pre>
4213 <h5>Overview:</h5>
4214
4215 <p>The '<tt>llvm.va_end</tt>' intrinsic destroys <tt>*&lt;arglist&gt;</tt>,
4216 which has been initialized previously with <tt><a href="#int_va_start">llvm.va_start</a></tt>
4217 or <tt><a href="#i_va_copy">llvm.va_copy</a></tt>.</p>
4218
4219 <h5>Arguments:</h5>
4220
4221 <p>The argument is a pointer to a <tt>va_list</tt> to destroy.</p>
4222
4223 <h5>Semantics:</h5>
4224
4225 <p>The '<tt>llvm.va_end</tt>' intrinsic works just like the <tt>va_end</tt>
4226 macro available in C.  In a target-dependent way, it destroys the
4227 <tt>va_list</tt> element to which the argument points.  Calls to <a
4228 href="#int_va_start"><tt>llvm.va_start</tt></a> and <a href="#int_va_copy">
4229 <tt>llvm.va_copy</tt></a> must be matched exactly with calls to
4230 <tt>llvm.va_end</tt>.</p>
4231
4232 </div>
4233
4234 <!-- _______________________________________________________________________ -->
4235 <div class="doc_subsubsection">
4236   <a name="int_va_copy">'<tt>llvm.va_copy</tt>' Intrinsic</a>
4237 </div>
4238
4239 <div class="doc_text">
4240
4241 <h5>Syntax:</h5>
4242
4243 <pre>
4244   declare void @llvm.va_copy(i8* &lt;destarglist&gt;, i8* &lt;srcarglist&gt;)
4245 </pre>
4246
4247 <h5>Overview:</h5>
4248
4249 <p>The '<tt>llvm.va_copy</tt>' intrinsic copies the current argument position
4250 from the source argument list to the destination argument list.</p>
4251
4252 <h5>Arguments:</h5>
4253
4254 <p>The first argument is a pointer to a <tt>va_list</tt> element to initialize.
4255 The second argument is a pointer to a <tt>va_list</tt> element to copy from.</p>
4256
4257
4258 <h5>Semantics:</h5>
4259
4260 <p>The '<tt>llvm.va_copy</tt>' intrinsic works just like the <tt>va_copy</tt>
4261 macro available in C.  In a target-dependent way, it copies the source
4262 <tt>va_list</tt> element into the destination <tt>va_list</tt> element.  This
4263 intrinsic is necessary because the <tt><a href="#int_va_start">
4264 llvm.va_start</a></tt> intrinsic may be arbitrarily complex and require, for
4265 example, memory allocation.</p>
4266
4267 </div>
4268
4269 <!-- ======================================================================= -->
4270 <div class="doc_subsection">
4271   <a name="int_gc">Accurate Garbage Collection Intrinsics</a>
4272 </div>
4273
4274 <div class="doc_text">
4275
4276 <p>
4277 LLVM support for <a href="GarbageCollection.html">Accurate Garbage
4278 Collection</a> requires the implementation and generation of these intrinsics.
4279 These intrinsics allow identification of <a href="#int_gcroot">GC roots on the
4280 stack</a>, as well as garbage collector implementations that require <a
4281 href="#int_gcread">read</a> and <a href="#int_gcwrite">write</a> barriers.
4282 Front-ends for type-safe garbage collected languages should generate these
4283 intrinsics to make use of the LLVM garbage collectors.  For more details, see <a
4284 href="GarbageCollection.html">Accurate Garbage Collection with LLVM</a>.
4285 </p>
4286
4287 <p>The garbage collection intrinsics only operate on objects in the generic 
4288         address space (address space zero).</p>
4289
4290 </div>
4291
4292 <!-- _______________________________________________________________________ -->
4293 <div class="doc_subsubsection">
4294   <a name="int_gcroot">'<tt>llvm.gcroot</tt>' Intrinsic</a>
4295 </div>
4296
4297 <div class="doc_text">
4298
4299 <h5>Syntax:</h5>
4300
4301 <pre>
4302   declare void @llvm.gcroot(i8** %ptrloc, i8* %metadata)
4303 </pre>
4304
4305 <h5>Overview:</h5>
4306
4307 <p>The '<tt>llvm.gcroot</tt>' intrinsic declares the existence of a GC root to
4308 the code generator, and allows some metadata to be associated with it.</p>
4309
4310 <h5>Arguments:</h5>
4311
4312 <p>The first argument specifies the address of a stack object that contains the
4313 root pointer.  The second pointer (which must be either a constant or a global
4314 value address) contains the meta-data to be associated with the root.</p>
4315
4316 <h5>Semantics:</h5>
4317
4318 <p>At runtime, a call to this intrinsic stores a null pointer into the "ptrloc"
4319 location.  At compile-time, the code generator generates information to allow
4320 the runtime to find the pointer at GC safe points. The '<tt>llvm.gcroot</tt>'
4321 intrinsic may only be used in a function which <a href="#gc">specifies a GC
4322 algorithm</a>.</p>
4323
4324 </div>
4325
4326
4327 <!-- _______________________________________________________________________ -->
4328 <div class="doc_subsubsection">
4329   <a name="int_gcread">'<tt>llvm.gcread</tt>' Intrinsic</a>
4330 </div>
4331
4332 <div class="doc_text">
4333
4334 <h5>Syntax:</h5>
4335
4336 <pre>
4337   declare i8* @llvm.gcread(i8* %ObjPtr, i8** %Ptr)
4338 </pre>
4339
4340 <h5>Overview:</h5>
4341
4342 <p>The '<tt>llvm.gcread</tt>' intrinsic identifies reads of references from heap
4343 locations, allowing garbage collector implementations that require read
4344 barriers.</p>
4345
4346 <h5>Arguments:</h5>
4347
4348 <p>The second argument is the address to read from, which should be an address
4349 allocated from the garbage collector.  The first object is a pointer to the 
4350 start of the referenced object, if needed by the language runtime (otherwise
4351 null).</p>
4352
4353 <h5>Semantics:</h5>
4354
4355 <p>The '<tt>llvm.gcread</tt>' intrinsic has the same semantics as a load
4356 instruction, but may be replaced with substantially more complex code by the
4357 garbage collector runtime, as needed. The '<tt>llvm.gcread</tt>' intrinsic
4358 may only be used in a function which <a href="#gc">specifies a GC
4359 algorithm</a>.</p>
4360
4361 </div>
4362
4363
4364 <!-- _______________________________________________________________________ -->
4365 <div class="doc_subsubsection">
4366   <a name="int_gcwrite">'<tt>llvm.gcwrite</tt>' Intrinsic</a>
4367 </div>
4368
4369 <div class="doc_text">
4370
4371 <h5>Syntax:</h5>
4372
4373 <pre>
4374   declare void @llvm.gcwrite(i8* %P1, i8* %Obj, i8** %P2)
4375 </pre>
4376
4377 <h5>Overview:</h5>
4378
4379 <p>The '<tt>llvm.gcwrite</tt>' intrinsic identifies writes of references to heap
4380 locations, allowing garbage collector implementations that require write
4381 barriers (such as generational or reference counting collectors).</p>
4382
4383 <h5>Arguments:</h5>
4384
4385 <p>The first argument is the reference to store, the second is the start of the
4386 object to store it to, and the third is the address of the field of Obj to 
4387 store to.  If the runtime does not require a pointer to the object, Obj may be
4388 null.</p>
4389
4390 <h5>Semantics:</h5>
4391
4392 <p>The '<tt>llvm.gcwrite</tt>' intrinsic has the same semantics as a store
4393 instruction, but may be replaced with substantially more complex code by the
4394 garbage collector runtime, as needed. The '<tt>llvm.gcwrite</tt>' intrinsic
4395 may only be used in a function which <a href="#gc">specifies a GC
4396 algorithm</a>.</p>
4397
4398 </div>
4399
4400
4401
4402 <!-- ======================================================================= -->
4403 <div class="doc_subsection">
4404   <a name="int_codegen">Code Generator Intrinsics</a>
4405 </div>
4406
4407 <div class="doc_text">
4408 <p>
4409 These intrinsics are provided by LLVM to expose special features that may only
4410 be implemented with code generator support.
4411 </p>
4412
4413 </div>
4414
4415 <!-- _______________________________________________________________________ -->
4416 <div class="doc_subsubsection">
4417   <a name="int_returnaddress">'<tt>llvm.returnaddress</tt>' Intrinsic</a>
4418 </div>
4419
4420 <div class="doc_text">
4421
4422 <h5>Syntax:</h5>
4423 <pre>
4424   declare i8  *@llvm.returnaddress(i32 &lt;level&gt;)
4425 </pre>
4426
4427 <h5>Overview:</h5>
4428
4429 <p>
4430 The '<tt>llvm.returnaddress</tt>' intrinsic attempts to compute a 
4431 target-specific value indicating the return address of the current function 
4432 or one of its callers.
4433 </p>
4434
4435 <h5>Arguments:</h5>
4436
4437 <p>
4438 The argument to this intrinsic indicates which function to return the address
4439 for.  Zero indicates the calling function, one indicates its caller, etc.  The
4440 argument is <b>required</b> to be a constant integer value.
4441 </p>
4442
4443 <h5>Semantics:</h5>
4444
4445 <p>
4446 The '<tt>llvm.returnaddress</tt>' intrinsic either returns a pointer indicating
4447 the return address of the specified call frame, or zero if it cannot be
4448 identified.  The value returned by this intrinsic is likely to be incorrect or 0
4449 for arguments other than zero, so it should only be used for debugging purposes.
4450 </p>
4451
4452 <p>
4453 Note that calling this intrinsic does not prevent function inlining or other
4454 aggressive transformations, so the value returned may not be that of the obvious
4455 source-language caller.
4456 </p>
4457 </div>
4458
4459
4460 <!-- _______________________________________________________________________ -->
4461 <div class="doc_subsubsection">
4462   <a name="int_frameaddress">'<tt>llvm.frameaddress</tt>' Intrinsic</a>
4463 </div>
4464
4465 <div class="doc_text">
4466
4467 <h5>Syntax:</h5>
4468 <pre>
4469   declare i8 *@llvm.frameaddress(i32 &lt;level&gt;)
4470 </pre>
4471
4472 <h5>Overview:</h5>
4473
4474 <p>
4475 The '<tt>llvm.frameaddress</tt>' intrinsic attempts to return the 
4476 target-specific frame pointer value for the specified stack frame.
4477 </p>
4478
4479 <h5>Arguments:</h5>
4480
4481 <p>
4482 The argument to this intrinsic indicates which function to return the frame
4483 pointer for.  Zero indicates the calling function, one indicates its caller,
4484 etc.  The argument is <b>required</b> to be a constant integer value.
4485 </p>
4486
4487 <h5>Semantics:</h5>
4488
4489 <p>
4490 The '<tt>llvm.frameaddress</tt>' intrinsic either returns a pointer indicating
4491 the frame address of the specified call frame, or zero if it cannot be
4492 identified.  The value returned by this intrinsic is likely to be incorrect or 0
4493 for arguments other than zero, so it should only be used for debugging purposes.
4494 </p>
4495
4496 <p>
4497 Note that calling this intrinsic does not prevent function inlining or other
4498 aggressive transformations, so the value returned may not be that of the obvious
4499 source-language caller.
4500 </p>
4501 </div>
4502
4503 <!-- _______________________________________________________________________ -->
4504 <div class="doc_subsubsection">
4505   <a name="int_stacksave">'<tt>llvm.stacksave</tt>' Intrinsic</a>
4506 </div>
4507
4508 <div class="doc_text">
4509
4510 <h5>Syntax:</h5>
4511 <pre>
4512   declare i8 *@llvm.stacksave()
4513 </pre>
4514
4515 <h5>Overview:</h5>
4516
4517 <p>
4518 The '<tt>llvm.stacksave</tt>' intrinsic is used to remember the current state of
4519 the function stack, for use with <a href="#int_stackrestore">
4520 <tt>llvm.stackrestore</tt></a>.  This is useful for implementing language
4521 features like scoped automatic variable sized arrays in C99.
4522 </p>
4523
4524 <h5>Semantics:</h5>
4525
4526 <p>
4527 This intrinsic returns a opaque pointer value that can be passed to <a
4528 href="#int_stackrestore"><tt>llvm.stackrestore</tt></a>.  When an
4529 <tt>llvm.stackrestore</tt> intrinsic is executed with a value saved from 
4530 <tt>llvm.stacksave</tt>, it effectively restores the state of the stack to the
4531 state it was in when the <tt>llvm.stacksave</tt> intrinsic executed.  In
4532 practice, this pops any <a href="#i_alloca">alloca</a> blocks from the stack
4533 that were allocated after the <tt>llvm.stacksave</tt> was executed.
4534 </p>
4535
4536 </div>
4537
4538 <!-- _______________________________________________________________________ -->
4539 <div class="doc_subsubsection">
4540   <a name="int_stackrestore">'<tt>llvm.stackrestore</tt>' Intrinsic</a>
4541 </div>
4542
4543 <div class="doc_text">
4544
4545 <h5>Syntax:</h5>
4546 <pre>
4547   declare void @llvm.stackrestore(i8 * %ptr)
4548 </pre>
4549
4550 <h5>Overview:</h5>
4551
4552 <p>
4553 The '<tt>llvm.stackrestore</tt>' intrinsic is used to restore the state of
4554 the function stack to the state it was in when the corresponding <a
4555 href="#int_stacksave"><tt>llvm.stacksave</tt></a> intrinsic executed.  This is
4556 useful for implementing language features like scoped automatic variable sized
4557 arrays in C99.
4558 </p>
4559
4560 <h5>Semantics:</h5>
4561
4562 <p>
4563 See the description for <a href="#int_stacksave"><tt>llvm.stacksave</tt></a>.
4564 </p>
4565
4566 </div>
4567
4568
4569 <!-- _______________________________________________________________________ -->
4570 <div class="doc_subsubsection">
4571   <a name="int_prefetch">'<tt>llvm.prefetch</tt>' Intrinsic</a>
4572 </div>
4573
4574 <div class="doc_text">
4575
4576 <h5>Syntax:</h5>
4577 <pre>
4578   declare void @llvm.prefetch(i8* &lt;address&gt;, i32 &lt;rw&gt;, i32 &lt;locality&gt;)
4579 </pre>
4580
4581 <h5>Overview:</h5>
4582
4583
4584 <p>
4585 The '<tt>llvm.prefetch</tt>' intrinsic is a hint to the code generator to insert
4586 a prefetch instruction if supported; otherwise, it is a noop.  Prefetches have
4587 no
4588 effect on the behavior of the program but can change its performance
4589 characteristics.
4590 </p>
4591
4592 <h5>Arguments:</h5>
4593
4594 <p>
4595 <tt>address</tt> is the address to be prefetched, <tt>rw</tt> is the specifier
4596 determining if the fetch should be for a read (0) or write (1), and
4597 <tt>locality</tt> is a temporal locality specifier ranging from (0) - no
4598 locality, to (3) - extremely local keep in cache.  The <tt>rw</tt> and
4599 <tt>locality</tt> arguments must be constant integers.
4600 </p>
4601
4602 <h5>Semantics:</h5>
4603
4604 <p>
4605 This intrinsic does not modify the behavior of the program.  In particular,
4606 prefetches cannot trap and do not produce a value.  On targets that support this
4607 intrinsic, the prefetch can provide hints to the processor cache for better
4608 performance.
4609 </p>
4610
4611 </div>
4612
4613 <!-- _______________________________________________________________________ -->
4614 <div class="doc_subsubsection">
4615   <a name="int_pcmarker">'<tt>llvm.pcmarker</tt>' Intrinsic</a>
4616 </div>
4617
4618 <div class="doc_text">
4619
4620 <h5>Syntax:</h5>
4621 <pre>
4622   declare void @llvm.pcmarker(i32 &lt;id&gt;)
4623 </pre>
4624
4625 <h5>Overview:</h5>
4626
4627
4628 <p>
4629 The '<tt>llvm.pcmarker</tt>' intrinsic is a method to export a Program Counter
4630 (PC) in a region of 
4631 code to simulators and other tools.  The method is target specific, but it is 
4632 expected that the marker will use exported symbols to transmit the PC of the marker.
4633 The marker makes no guarantees that it will remain with any specific instruction 
4634 after optimizations.  It is possible that the presence of a marker will inhibit 
4635 optimizations.  The intended use is to be inserted after optimizations to allow
4636 correlations of simulation runs.
4637 </p>
4638
4639 <h5>Arguments:</h5>
4640
4641 <p>
4642 <tt>id</tt> is a numerical id identifying the marker.
4643 </p>
4644
4645 <h5>Semantics:</h5>
4646
4647 <p>
4648 This intrinsic does not modify the behavior of the program.  Backends that do not 
4649 support this intrinisic may ignore it.
4650 </p>
4651
4652 </div>
4653
4654 <!-- _______________________________________________________________________ -->
4655 <div class="doc_subsubsection">
4656   <a name="int_readcyclecounter">'<tt>llvm.readcyclecounter</tt>' Intrinsic</a>
4657 </div>
4658
4659 <div class="doc_text">
4660
4661 <h5>Syntax:</h5>
4662 <pre>
4663   declare i64 @llvm.readcyclecounter( )
4664 </pre>
4665
4666 <h5>Overview:</h5>
4667
4668
4669 <p>
4670 The '<tt>llvm.readcyclecounter</tt>' intrinsic provides access to the cycle 
4671 counter register (or similar low latency, high accuracy clocks) on those targets
4672 that support it.  On X86, it should map to RDTSC.  On Alpha, it should map to RPCC.
4673 As the backing counters overflow quickly (on the order of 9 seconds on alpha), this
4674 should only be used for small timings.  
4675 </p>
4676
4677 <h5>Semantics:</h5>
4678
4679 <p>
4680 When directly supported, reading the cycle counter should not modify any memory.  
4681 Implementations are allowed to either return a application specific value or a
4682 system wide value.  On backends without support, this is lowered to a constant 0.
4683 </p>
4684
4685 </div>
4686
4687 <!-- ======================================================================= -->
4688 <div class="doc_subsection">
4689   <a name="int_libc">Standard C Library Intrinsics</a>
4690 </div>
4691
4692 <div class="doc_text">
4693 <p>
4694 LLVM provides intrinsics for a few important standard C library functions.
4695 These intrinsics allow source-language front-ends to pass information about the
4696 alignment of the pointer arguments to the code generator, providing opportunity
4697 for more efficient code generation.
4698 </p>
4699
4700 </div>
4701
4702 <!-- _______________________________________________________________________ -->
4703 <div class="doc_subsubsection">
4704   <a name="int_memcpy">'<tt>llvm.memcpy</tt>' Intrinsic</a>
4705 </div>
4706
4707 <div class="doc_text">
4708
4709 <h5>Syntax:</h5>
4710 <pre>
4711   declare void @llvm.memcpy.i32(i8 * &lt;dest&gt;, i8 * &lt;src&gt;,
4712                                 i32 &lt;len&gt;, i32 &lt;align&gt;)
4713   declare void @llvm.memcpy.i64(i8 * &lt;dest&gt;, i8 * &lt;src&gt;,
4714                                 i64 &lt;len&gt;, i32 &lt;align&gt;)
4715 </pre>
4716
4717 <h5>Overview:</h5>
4718
4719 <p>
4720 The '<tt>llvm.memcpy.*</tt>' intrinsics copy a block of memory from the source
4721 location to the destination location.
4722 </p>
4723
4724 <p>
4725 Note that, unlike the standard libc function, the <tt>llvm.memcpy.*</tt> 
4726 intrinsics do not return a value, and takes an extra alignment argument.
4727 </p>
4728
4729 <h5>Arguments:</h5>
4730
4731 <p>
4732 The first argument is a pointer to the destination, the second is a pointer to
4733 the source.  The third argument is an integer argument
4734 specifying the number of bytes to copy, and the fourth argument is the alignment
4735 of the source and destination locations.
4736 </p>
4737
4738 <p>
4739 If the call to this intrinisic has an alignment value that is not 0 or 1, then
4740 the caller guarantees that both the source and destination pointers are aligned
4741 to that boundary.
4742 </p>
4743
4744 <h5>Semantics:</h5>
4745
4746 <p>
4747 The '<tt>llvm.memcpy.*</tt>' intrinsics copy a block of memory from the source
4748 location to the destination location, which are not allowed to overlap.  It
4749 copies "len" bytes of memory over.  If the argument is known to be aligned to
4750 some boundary, this can be specified as the fourth argument, otherwise it should
4751 be set to 0 or 1.
4752 </p>
4753 </div>
4754
4755
4756 <!-- _______________________________________________________________________ -->
4757 <div class="doc_subsubsection">
4758   <a name="int_memmove">'<tt>llvm.memmove</tt>' Intrinsic</a>
4759 </div>
4760
4761 <div class="doc_text">
4762
4763 <h5>Syntax:</h5>
4764 <pre>
4765   declare void @llvm.memmove.i32(i8 * &lt;dest&gt;, i8 * &lt;src&gt;,
4766                                  i32 &lt;len&gt;, i32 &lt;align&gt;)
4767   declare void @llvm.memmove.i64(i8 * &lt;dest&gt;, i8 * &lt;src&gt;,
4768                                  i64 &lt;len&gt;, i32 &lt;align&gt;)
4769 </pre>
4770
4771 <h5>Overview:</h5>
4772
4773 <p>
4774 The '<tt>llvm.memmove.*</tt>' intrinsics move a block of memory from the source
4775 location to the destination location. It is similar to the
4776 '<tt>llvm.memcpy</tt>' intrinsic but allows the two memory locations to overlap.
4777 </p>
4778
4779 <p>
4780 Note that, unlike the standard libc function, the <tt>llvm.memmove.*</tt> 
4781 intrinsics do not return a value, and takes an extra alignment argument.
4782 </p>
4783
4784 <h5>Arguments:</h5>
4785
4786 <p>
4787 The first argument is a pointer to the destination, the second is a pointer to
4788 the source.  The third argument is an integer argument
4789 specifying the number of bytes to copy, and the fourth argument is the alignment
4790 of the source and destination locations.
4791 </p>
4792
4793 <p>
4794 If the call to this intrinisic has an alignment value that is not 0 or 1, then
4795 the caller guarantees that the source and destination pointers are aligned to
4796 that boundary.
4797 </p>
4798
4799 <h5>Semantics:</h5>
4800
4801 <p>
4802 The '<tt>llvm.memmove.*</tt>' intrinsics copy a block of memory from the source
4803 location to the destination location, which may overlap.  It
4804 copies "len" bytes of memory over.  If the argument is known to be aligned to
4805 some boundary, this can be specified as the fourth argument, otherwise it should
4806 be set to 0 or 1.
4807 </p>
4808 </div>
4809
4810
4811 <!-- _______________________________________________________________________ -->
4812 <div class="doc_subsubsection">
4813   <a name="int_memset">'<tt>llvm.memset.*</tt>' Intrinsics</a>
4814 </div>
4815
4816 <div class="doc_text">
4817
4818 <h5>Syntax:</h5>
4819 <pre>
4820   declare void @llvm.memset.i32(i8 * &lt;dest&gt;, i8 &lt;val&gt;,
4821                                 i32 &lt;len&gt;, i32 &lt;align&gt;)
4822   declare void @llvm.memset.i64(i8 * &lt;dest&gt;, i8 &lt;val&gt;,
4823                                 i64 &lt;len&gt;, i32 &lt;align&gt;)
4824 </pre>
4825
4826 <h5>Overview:</h5>
4827
4828 <p>
4829 The '<tt>llvm.memset.*</tt>' intrinsics fill a block of memory with a particular
4830 byte value.
4831 </p>
4832
4833 <p>
4834 Note that, unlike the standard libc function, the <tt>llvm.memset</tt> intrinsic
4835 does not return a value, and takes an extra alignment argument.
4836 </p>
4837
4838 <h5>Arguments:</h5>
4839
4840 <p>
4841 The first argument is a pointer to the destination to fill, the second is the
4842 byte value to fill it with, the third argument is an integer
4843 argument specifying the number of bytes to fill, and the fourth argument is the
4844 known alignment of destination location.
4845 </p>
4846
4847 <p>
4848 If the call to this intrinisic has an alignment value that is not 0 or 1, then
4849 the caller guarantees that the destination pointer is aligned to that boundary.
4850 </p>
4851
4852 <h5>Semantics:</h5>
4853
4854 <p>
4855 The '<tt>llvm.memset.*</tt>' intrinsics fill "len" bytes of memory starting at
4856 the
4857 destination location.  If the argument is known to be aligned to some boundary,
4858 this can be specified as the fourth argument, otherwise it should be set to 0 or
4859 1.
4860 </p>
4861 </div>
4862
4863
4864 <!-- _______________________________________________________________________ -->
4865 <div class="doc_subsubsection">
4866   <a name="int_sqrt">'<tt>llvm.sqrt.*</tt>' Intrinsic</a>
4867 </div>
4868
4869 <div class="doc_text">
4870
4871 <h5>Syntax:</h5>
4872 <p>This is an overloaded intrinsic. You can use <tt>llvm.sqrt</tt> on any 
4873 floating point or vector of floating point type. Not all targets support all
4874 types however.
4875 <pre>
4876   declare float     @llvm.sqrt.f32(float %Val)
4877   declare double    @llvm.sqrt.f64(double %Val)
4878   declare x86_fp80  @llvm.sqrt.f80(x86_fp80 %Val)
4879   declare fp128     @llvm.sqrt.f128(fp128 %Val)
4880   declare ppc_fp128 @llvm.sqrt.ppcf128(ppc_fp128 %Val)
4881 </pre>
4882
4883 <h5>Overview:</h5>
4884
4885 <p>
4886 The '<tt>llvm.sqrt</tt>' intrinsics return the sqrt of the specified operand,
4887 returning the same value as the libm '<tt>sqrt</tt>' functions would.  Unlike
4888 <tt>sqrt</tt> in libm, however, <tt>llvm.sqrt</tt> has undefined behavior for
4889 negative numbers other than -0.0 (which allows for better optimization, because
4890 there is no need to worry about errno being set).  <tt>llvm.sqrt(-0.0)</tt> is
4891 defined to return -0.0 like IEEE sqrt.
4892 </p>
4893
4894 <h5>Arguments:</h5>
4895
4896 <p>
4897 The argument and return value are floating point numbers of the same type.
4898 </p>
4899
4900 <h5>Semantics:</h5>
4901
4902 <p>
4903 This function returns the sqrt of the specified operand if it is a nonnegative
4904 floating point number.
4905 </p>
4906 </div>
4907
4908 <!-- _______________________________________________________________________ -->
4909 <div class="doc_subsubsection">
4910   <a name="int_powi">'<tt>llvm.powi.*</tt>' Intrinsic</a>
4911 </div>
4912
4913 <div class="doc_text">
4914
4915 <h5>Syntax:</h5>
4916 <p>This is an overloaded intrinsic. You can use <tt>llvm.powi</tt> on any 
4917 floating point or vector of floating point type. Not all targets support all
4918 types however.
4919 <pre>
4920   declare float     @llvm.powi.f32(float  %Val, i32 %power)
4921   declare double    @llvm.powi.f64(double %Val, i32 %power)
4922   declare x86_fp80  @llvm.powi.f80(x86_fp80  %Val, i32 %power)
4923   declare fp128     @llvm.powi.f128(fp128 %Val, i32 %power)
4924   declare ppc_fp128 @llvm.powi.ppcf128(ppc_fp128  %Val, i32 %power)
4925 </pre>
4926
4927 <h5>Overview:</h5>
4928
4929 <p>
4930 The '<tt>llvm.powi.*</tt>' intrinsics return the first operand raised to the
4931 specified (positive or negative) power.  The order of evaluation of
4932 multiplications is not defined.  When a vector of floating point type is
4933 used, the second argument remains a scalar integer value.
4934 </p>
4935
4936 <h5>Arguments:</h5>
4937
4938 <p>
4939 The second argument is an integer power, and the first is a value to raise to
4940 that power.
4941 </p>
4942
4943 <h5>Semantics:</h5>
4944
4945 <p>
4946 This function returns the first value raised to the second power with an
4947 unspecified sequence of rounding operations.</p>
4948 </div>
4949
4950 <!-- _______________________________________________________________________ -->
4951 <div class="doc_subsubsection">
4952   <a name="int_sin">'<tt>llvm.sin.*</tt>' Intrinsic</a>
4953 </div>
4954
4955 <div class="doc_text">
4956
4957 <h5>Syntax:</h5>
4958 <p>This is an overloaded intrinsic. You can use <tt>llvm.sin</tt> on any 
4959 floating point or vector of floating point type. Not all targets support all
4960 types however.
4961 <pre>
4962   declare float     @llvm.sin.f32(float  %Val)
4963   declare double    @llvm.sin.f64(double %Val)
4964   declare x86_fp80  @llvm.sin.f80(x86_fp80  %Val)
4965   declare fp128     @llvm.sin.f128(fp128 %Val)
4966   declare ppc_fp128 @llvm.sin.ppcf128(ppc_fp128  %Val)
4967 </pre>
4968
4969 <h5>Overview:</h5>
4970
4971 <p>
4972 The '<tt>llvm.sin.*</tt>' intrinsics return the sine of the operand.
4973 </p>
4974
4975 <h5>Arguments:</h5>
4976
4977 <p>
4978 The argument and return value are floating point numbers of the same type.
4979 </p>
4980
4981 <h5>Semantics:</h5>
4982
4983 <p>
4984 This function returns the sine of the specified operand, returning the
4985 same values as the libm <tt>sin</tt> functions would, and handles error
4986 conditions in the same way.</p>
4987 </div>
4988
4989 <!-- _______________________________________________________________________ -->
4990 <div class="doc_subsubsection">
4991   <a name="int_cos">'<tt>llvm.cos.*</tt>' Intrinsic</a>
4992 </div>
4993
4994 <div class="doc_text">
4995
4996 <h5>Syntax:</h5>
4997 <p>This is an overloaded intrinsic. You can use <tt>llvm.cos</tt> on any 
4998 floating point or vector of floating point type. Not all targets support all
4999 types however.
5000 <pre>
5001   declare float     @llvm.cos.f32(float  %Val)
5002   declare double    @llvm.cos.f64(double %Val)
5003   declare x86_fp80  @llvm.cos.f80(x86_fp80  %Val)
5004   declare fp128     @llvm.cos.f128(fp128 %Val)
5005   declare ppc_fp128 @llvm.cos.ppcf128(ppc_fp128  %Val)
5006 </pre>
5007
5008 <h5>Overview:</h5>
5009
5010 <p>
5011 The '<tt>llvm.cos.*</tt>' intrinsics return the cosine of the operand.
5012 </p>
5013
5014 <h5>Arguments:</h5>
5015
5016 <p>
5017 The argument and return value are floating point numbers of the same type.
5018 </p>
5019
5020 <h5>Semantics:</h5>
5021
5022 <p>
5023 This function returns the cosine of the specified operand, returning the
5024 same values as the libm <tt>cos</tt> functions would, and handles error
5025 conditions in the same way.</p>
5026 </div>
5027
5028 <!-- _______________________________________________________________________ -->
5029 <div class="doc_subsubsection">
5030   <a name="int_pow">'<tt>llvm.pow.*</tt>' Intrinsic</a>
5031 </div>
5032
5033 <div class="doc_text">
5034
5035 <h5>Syntax:</h5>
5036 <p>This is an overloaded intrinsic. You can use <tt>llvm.pow</tt> on any 
5037 floating point or vector of floating point type. Not all targets support all
5038 types however.
5039 <pre>
5040   declare float     @llvm.pow.f32(float  %Val, float %Power)
5041   declare double    @llvm.pow.f64(double %Val, double %Power)
5042   declare x86_fp80  @llvm.pow.f80(x86_fp80  %Val, x86_fp80 %Power)
5043   declare fp128     @llvm.pow.f128(fp128 %Val, fp128 %Power)
5044   declare ppc_fp128 @llvm.pow.ppcf128(ppc_fp128  %Val, ppc_fp128 Power)
5045 </pre>
5046
5047 <h5>Overview:</h5>
5048
5049 <p>
5050 The '<tt>llvm.pow.*</tt>' intrinsics return the first operand raised to the
5051 specified (positive or negative) power.
5052 </p>
5053
5054 <h5>Arguments:</h5>
5055
5056 <p>
5057 The second argument is a floating point power, and the first is a value to
5058 raise to that power.
5059 </p>
5060
5061 <h5>Semantics:</h5>
5062
5063 <p>
5064 This function returns the first value raised to the second power,
5065 returning the
5066 same values as the libm <tt>pow</tt> functions would, and handles error
5067 conditions in the same way.</p>
5068 </div>
5069
5070
5071 <!-- ======================================================================= -->
5072 <div class="doc_subsection">
5073   <a name="int_manip">Bit Manipulation Intrinsics</a>
5074 </div>
5075
5076 <div class="doc_text">
5077 <p>
5078 LLVM provides intrinsics for a few important bit manipulation operations.
5079 These allow efficient code generation for some algorithms.
5080 </p>
5081
5082 </div>
5083
5084 <!-- _______________________________________________________________________ -->
5085 <div class="doc_subsubsection">
5086   <a name="int_bswap">'<tt>llvm.bswap.*</tt>' Intrinsics</a>
5087 </div>
5088
5089 <div class="doc_text">
5090
5091 <h5>Syntax:</h5>
5092 <p>This is an overloaded intrinsic function. You can use bswap on any integer
5093 type that is an even number of bytes (i.e. BitWidth % 16 == 0).
5094 <pre>
5095   declare i16 @llvm.bswap.i16(i16 &lt;id&gt;)
5096   declare i32 @llvm.bswap.i32(i32 &lt;id&gt;)
5097   declare i64 @llvm.bswap.i64(i64 &lt;id&gt;)
5098 </pre>
5099
5100 <h5>Overview:</h5>
5101
5102 <p>
5103 The '<tt>llvm.bswap</tt>' family of intrinsics is used to byte swap integer 
5104 values with an even number of bytes (positive multiple of 16 bits).  These are 
5105 useful for performing operations on data that is not in the target's native 
5106 byte order.
5107 </p>
5108
5109 <h5>Semantics:</h5>
5110
5111 <p>
5112 The <tt>llvm.bswap.i16</tt> intrinsic returns an i16 value that has the high 
5113 and low byte of the input i16 swapped.  Similarly, the <tt>llvm.bswap.i32</tt> 
5114 intrinsic returns an i32 value that has the four bytes of the input i32 
5115 swapped, so that if the input bytes are numbered 0, 1, 2, 3 then the returned 
5116 i32 will have its bytes in 3, 2, 1, 0 order.  The <tt>llvm.bswap.i48</tt>, 
5117 <tt>llvm.bswap.i64</tt> and other intrinsics extend this concept to
5118 additional even-byte lengths (6 bytes, 8 bytes and more, respectively).
5119 </p>
5120
5121 </div>
5122
5123 <!-- _______________________________________________________________________ -->
5124 <div class="doc_subsubsection">
5125   <a name="int_ctpop">'<tt>llvm.ctpop.*</tt>' Intrinsic</a>
5126 </div>
5127
5128 <div class="doc_text">
5129
5130 <h5>Syntax:</h5>
5131 <p>This is an overloaded intrinsic. You can use llvm.ctpop on any integer bit
5132 width. Not all targets support all bit widths however.
5133 <pre>
5134   declare i8 @llvm.ctpop.i8 (i8  &lt;src&gt;)
5135   declare i16 @llvm.ctpop.i16(i16 &lt;src&gt;)
5136   declare i32 @llvm.ctpop.i32(i32 &lt;src&gt;)
5137   declare i64 @llvm.ctpop.i64(i64 &lt;src&gt;)
5138   declare i256 @llvm.ctpop.i256(i256 &lt;src&gt;)
5139 </pre>
5140
5141 <h5>Overview:</h5>
5142
5143 <p>
5144 The '<tt>llvm.ctpop</tt>' family of intrinsics counts the number of bits set in a 
5145 value.
5146 </p>
5147
5148 <h5>Arguments:</h5>
5149
5150 <p>
5151 The only argument is the value to be counted.  The argument may be of any
5152 integer type.  The return type must match the argument type.
5153 </p>
5154
5155 <h5>Semantics:</h5>
5156
5157 <p>
5158 The '<tt>llvm.ctpop</tt>' intrinsic counts the 1's in a variable.
5159 </p>
5160 </div>
5161
5162 <!-- _______________________________________________________________________ -->
5163 <div class="doc_subsubsection">
5164   <a name="int_ctlz">'<tt>llvm.ctlz.*</tt>' Intrinsic</a>
5165 </div>
5166
5167 <div class="doc_text">
5168
5169 <h5>Syntax:</h5>
5170 <p>This is an overloaded intrinsic. You can use <tt>llvm.ctlz</tt> on any 
5171 integer bit width. Not all targets support all bit widths however.
5172 <pre>
5173   declare i8 @llvm.ctlz.i8 (i8  &lt;src&gt;)
5174   declare i16 @llvm.ctlz.i16(i16 &lt;src&gt;)
5175   declare i32 @llvm.ctlz.i32(i32 &lt;src&gt;)
5176   declare i64 @llvm.ctlz.i64(i64 &lt;src&gt;)
5177   declare i256 @llvm.ctlz.i256(i256 &lt;src&gt;)
5178 </pre>
5179
5180 <h5>Overview:</h5>
5181
5182 <p>
5183 The '<tt>llvm.ctlz</tt>' family of intrinsic functions counts the number of 
5184 leading zeros in a variable.
5185 </p>
5186
5187 <h5>Arguments:</h5>
5188
5189 <p>
5190 The only argument is the value to be counted.  The argument may be of any
5191 integer type. The return type must match the argument type.
5192 </p>
5193
5194 <h5>Semantics:</h5>
5195
5196 <p>
5197 The '<tt>llvm.ctlz</tt>' intrinsic counts the leading (most significant) zeros
5198 in a variable.  If the src == 0 then the result is the size in bits of the type
5199 of src. For example, <tt>llvm.ctlz(i32 2) = 30</tt>.
5200 </p>
5201 </div>
5202
5203
5204
5205 <!-- _______________________________________________________________________ -->
5206 <div class="doc_subsubsection">
5207   <a name="int_cttz">'<tt>llvm.cttz.*</tt>' Intrinsic</a>
5208 </div>
5209
5210 <div class="doc_text">
5211
5212 <h5>Syntax:</h5>
5213 <p>This is an overloaded intrinsic. You can use <tt>llvm.cttz</tt> on any 
5214 integer bit width. Not all targets support all bit widths however.
5215 <pre>
5216   declare i8 @llvm.cttz.i8 (i8  &lt;src&gt;)
5217   declare i16 @llvm.cttz.i16(i16 &lt;src&gt;)
5218   declare i32 @llvm.cttz.i32(i32 &lt;src&gt;)
5219   declare i64 @llvm.cttz.i64(i64 &lt;src&gt;)
5220   declare i256 @llvm.cttz.i256(i256 &lt;src&gt;)
5221 </pre>
5222
5223 <h5>Overview:</h5>
5224
5225 <p>
5226 The '<tt>llvm.cttz</tt>' family of intrinsic functions counts the number of 
5227 trailing zeros.
5228 </p>
5229
5230 <h5>Arguments:</h5>
5231
5232 <p>
5233 The only argument is the value to be counted.  The argument may be of any
5234 integer type.  The return type must match the argument type.
5235 </p>
5236
5237 <h5>Semantics:</h5>
5238
5239 <p>
5240 The '<tt>llvm.cttz</tt>' intrinsic counts the trailing (least significant) zeros
5241 in a variable.  If the src == 0 then the result is the size in bits of the type
5242 of src.  For example, <tt>llvm.cttz(2) = 1</tt>.
5243 </p>
5244 </div>
5245
5246 <!-- _______________________________________________________________________ -->
5247 <div class="doc_subsubsection">
5248   <a name="int_part_select">'<tt>llvm.part.select.*</tt>' Intrinsic</a>
5249 </div>
5250
5251 <div class="doc_text">
5252
5253 <h5>Syntax:</h5>
5254 <p>This is an overloaded intrinsic. You can use <tt>llvm.part.select</tt> 
5255 on any integer bit width.
5256 <pre>
5257   declare i17 @llvm.part.select.i17 (i17 %val, i32 %loBit, i32 %hiBit)
5258   declare i29 @llvm.part.select.i29 (i29 %val, i32 %loBit, i32 %hiBit)
5259 </pre>
5260
5261 <h5>Overview:</h5>
5262 <p>The '<tt>llvm.part.select</tt>' family of intrinsic functions selects a
5263 range of bits from an integer value and returns them in the same bit width as
5264 the original value.</p>
5265
5266 <h5>Arguments:</h5>
5267 <p>The first argument, <tt>%val</tt> and the result may be integer types of 
5268 any bit width but they must have the same bit width. The second and third 
5269 arguments must be <tt>i32</tt> type since they specify only a bit index.</p>
5270
5271 <h5>Semantics:</h5>
5272 <p>The operation of the '<tt>llvm.part.select</tt>' intrinsic has two modes
5273 of operation: forwards and reverse. If <tt>%loBit</tt> is greater than
5274 <tt>%hiBits</tt> then the intrinsic operates in reverse mode. Otherwise it
5275 operates in forward mode.</p>
5276 <p>In forward mode, this intrinsic is the equivalent of shifting <tt>%val</tt>
5277 right by <tt>%loBit</tt> bits and then ANDing it with a mask with
5278 only the <tt>%hiBit - %loBit</tt> bits set, as follows:</p>
5279 <ol>
5280   <li>The <tt>%val</tt> is shifted right (LSHR) by the number of bits specified
5281   by <tt>%loBits</tt>. This normalizes the value to the low order bits.</li>
5282   <li>The <tt>%loBits</tt> value is subtracted from the <tt>%hiBits</tt> value
5283   to determine the number of bits to retain.</li>
5284   <li>A mask of the retained bits is created by shifting a -1 value.</li>
5285   <li>The mask is ANDed with <tt>%val</tt> to produce the result.
5286 </ol>
5287 <p>In reverse mode, a similar computation is made except that the bits are
5288 returned in the reverse order. So, for example, if <tt>X</tt> has the value
5289 <tt>i16 0x0ACF (101011001111)</tt> and we apply 
5290 <tt>part.select(i16 X, 8, 3)</tt> to it, we get back the value 
5291 <tt>i16 0x0026 (000000100110)</tt>.</p>
5292 </div>
5293
5294 <div class="doc_subsubsection">
5295   <a name="int_part_set">'<tt>llvm.part.set.*</tt>' Intrinsic</a>
5296 </div>
5297
5298 <div class="doc_text">
5299
5300 <h5>Syntax:</h5>
5301 <p>This is an overloaded intrinsic. You can use <tt>llvm.part.set</tt> 
5302 on any integer bit width.
5303 <pre>
5304   declare i17 @llvm.part.set.i17.i9 (i17 %val, i9 %repl, i32 %lo, i32 %hi)
5305   declare i29 @llvm.part.set.i29.i9 (i29 %val, i9 %repl, i32 %lo, i32 %hi)
5306 </pre>
5307
5308 <h5>Overview:</h5>
5309 <p>The '<tt>llvm.part.set</tt>' family of intrinsic functions replaces a range
5310 of bits in an integer value with another integer value. It returns the integer
5311 with the replaced bits.</p>
5312
5313 <h5>Arguments:</h5>
5314 <p>The first argument, <tt>%val</tt> and the result may be integer types of 
5315 any bit width but they must have the same bit width. <tt>%val</tt> is the value
5316 whose bits will be replaced.  The second argument, <tt>%repl</tt> may be an
5317 integer of any bit width. The third and fourth arguments must be <tt>i32</tt> 
5318 type since they specify only a bit index.</p>
5319
5320 <h5>Semantics:</h5>
5321 <p>The operation of the '<tt>llvm.part.set</tt>' intrinsic has two modes
5322 of operation: forwards and reverse. If <tt>%lo</tt> is greater than
5323 <tt>%hi</tt> then the intrinsic operates in reverse mode. Otherwise it
5324 operates in forward mode.</p>
5325 <p>For both modes, the <tt>%repl</tt> value is prepared for use by either
5326 truncating it down to the size of the replacement area or zero extending it 
5327 up to that size.</p>
5328 <p>In forward mode, the bits between <tt>%lo</tt> and <tt>%hi</tt> (inclusive)
5329 are replaced with corresponding bits from <tt>%repl</tt>. That is the 0th bit
5330 in <tt>%repl</tt> replaces the <tt>%lo</tt>th bit in <tt>%val</tt> and etc. up
5331 to the <tt>%hi</tt>th bit. 
5332 <p>In reverse mode, a similar computation is made except that the bits are
5333 reversed.  That is, the <tt>0</tt>th bit in <tt>%repl</tt> replaces the 
5334 <tt>%hi</tt> bit in <tt>%val</tt> and etc. down to the <tt>%lo</tt>th bit.
5335 <h5>Examples:</h5>
5336 <pre>
5337   llvm.part.set(0xFFFF, 0, 4, 7) -&gt; 0xFF0F
5338   llvm.part.set(0xFFFF, 0, 7, 4) -&gt; 0xFF0F
5339   llvm.part.set(0xFFFF, 1, 7, 4) -&gt; 0xFF8F
5340   llvm.part.set(0xFFFF, F, 8, 3) -&gt; 0xFFE7
5341   llvm.part.set(0xFFFF, 0, 3, 8) -&gt; 0xFE07
5342 </pre>
5343 </div>
5344
5345 <!-- ======================================================================= -->
5346 <div class="doc_subsection">
5347   <a name="int_debugger">Debugger Intrinsics</a>
5348 </div>
5349
5350 <div class="doc_text">
5351 <p>
5352 The LLVM debugger intrinsics (which all start with <tt>llvm.dbg.</tt> prefix),
5353 are described in the <a
5354 href="SourceLevelDebugging.html#format_common_intrinsics">LLVM Source Level
5355 Debugging</a> document.
5356 </p>
5357 </div>
5358
5359
5360 <!-- ======================================================================= -->
5361 <div class="doc_subsection">
5362   <a name="int_eh">Exception Handling Intrinsics</a>
5363 </div>
5364
5365 <div class="doc_text">
5366 <p> The LLVM exception handling intrinsics (which all start with
5367 <tt>llvm.eh.</tt> prefix), are described in the <a
5368 href="ExceptionHandling.html#format_common_intrinsics">LLVM Exception
5369 Handling</a> document. </p>
5370 </div>
5371
5372 <!-- ======================================================================= -->
5373 <div class="doc_subsection">
5374   <a name="int_trampoline">Trampoline Intrinsic</a>
5375 </div>
5376
5377 <div class="doc_text">
5378 <p>
5379   This intrinsic makes it possible to excise one parameter, marked with
5380   the <tt>nest</tt> attribute, from a function.  The result is a callable
5381   function pointer lacking the nest parameter - the caller does not need
5382   to provide a value for it.  Instead, the value to use is stored in
5383   advance in a "trampoline", a block of memory usually allocated
5384   on the stack, which also contains code to splice the nest value into the
5385   argument list.  This is used to implement the GCC nested function address
5386   extension.
5387 </p>
5388 <p>
5389   For example, if the function is
5390   <tt>i32 f(i8* nest  %c, i32 %x, i32 %y)</tt> then the resulting function
5391   pointer has signature <tt>i32 (i32, i32)*</tt>.  It can be created as follows:</p>
5392 <pre>
5393   %tramp = alloca [10 x i8], align 4 ; size and alignment only correct for X86
5394   %tramp1 = getelementptr [10 x i8]* %tramp, i32 0, i32 0
5395   %p = call i8* @llvm.init.trampoline( i8* %tramp1, i8* bitcast (i32 (i8* nest , i32, i32)* @f to i8*), i8* %nval )
5396   %fp = bitcast i8* %p to i32 (i32, i32)*
5397 </pre>
5398   <p>The call <tt>%val = call i32 %fp( i32 %x, i32 %y )</tt> is then equivalent
5399   to <tt>%val = call i32 %f( i8* %nval, i32 %x, i32 %y )</tt>.</p>
5400 </div>
5401
5402 <!-- _______________________________________________________________________ -->
5403 <div class="doc_subsubsection">
5404   <a name="int_it">'<tt>llvm.init.trampoline</tt>' Intrinsic</a>
5405 </div>
5406 <div class="doc_text">
5407 <h5>Syntax:</h5>
5408 <pre>
5409 declare i8* @llvm.init.trampoline(i8* &lt;tramp&gt;, i8* &lt;func&gt;, i8* &lt;nval&gt;)
5410 </pre>
5411 <h5>Overview:</h5>
5412 <p>
5413   This fills the memory pointed to by <tt>tramp</tt> with code
5414   and returns a function pointer suitable for executing it.
5415 </p>
5416 <h5>Arguments:</h5>
5417 <p>
5418   The <tt>llvm.init.trampoline</tt> intrinsic takes three arguments, all
5419   pointers.  The <tt>tramp</tt> argument must point to a sufficiently large
5420   and sufficiently aligned block of memory; this memory is written to by the
5421   intrinsic.  Note that the size and the alignment are target-specific - LLVM
5422   currently provides no portable way of determining them, so a front-end that
5423   generates this intrinsic needs to have some target-specific knowledge.
5424   The <tt>func</tt> argument must hold a function bitcast to an <tt>i8*</tt>.
5425 </p>
5426 <h5>Semantics:</h5>
5427 <p>
5428   The block of memory pointed to by <tt>tramp</tt> is filled with target
5429   dependent code, turning it into a function.  A pointer to this function is
5430   returned, but needs to be bitcast to an
5431   <a href="#int_trampoline">appropriate function pointer type</a>
5432   before being called.  The new function's signature is the same as that of
5433   <tt>func</tt> with any arguments marked with the <tt>nest</tt> attribute
5434   removed.  At most one such <tt>nest</tt> argument is allowed, and it must be
5435   of pointer type.  Calling the new function is equivalent to calling
5436   <tt>func</tt> with the same argument list, but with <tt>nval</tt> used for the
5437   missing <tt>nest</tt> argument.  If, after calling
5438   <tt>llvm.init.trampoline</tt>, the memory pointed to by <tt>tramp</tt> is
5439   modified, then the effect of any later call to the returned function pointer is
5440   undefined.
5441 </p>
5442 </div>
5443
5444 <!-- ======================================================================= -->
5445 <div class="doc_subsection">
5446   <a name="int_atomics">Atomic Operations and Synchronization Intrinsics</a>
5447 </div>
5448
5449 <div class="doc_text">
5450 <p>
5451   These intrinsic functions expand the "universal IR" of LLVM to represent 
5452   hardware constructs for atomic operations and memory synchronization.  This 
5453   provides an interface to the hardware, not an interface to the programmer. It 
5454   is aimed at a low enough level to allow any programming models or APIs which 
5455   need atomic behaviors to map cleanly onto it. It is also modeled primarily on 
5456   hardware behavior. Just as hardware provides a "universal IR" for source 
5457   languages, it also provides a starting point for developing a "universal" 
5458   atomic operation and synchronization IR.
5459 </p>
5460 <p>
5461   These do <em>not</em> form an API such as high-level threading libraries, 
5462   software transaction memory systems, atomic primitives, and intrinsic 
5463   functions as found in BSD, GNU libc, atomic_ops, APR, and other system and 
5464   application libraries.  The hardware interface provided by LLVM should allow 
5465   a clean implementation of all of these APIs and parallel programming models. 
5466   No one model or paradigm should be selected above others unless the hardware 
5467   itself ubiquitously does so.
5468
5469 </p>
5470 </div>
5471
5472 <!-- _______________________________________________________________________ -->
5473 <div class="doc_subsubsection">
5474   <a name="int_memory_barrier">'<tt>llvm.memory.barrier</tt>' Intrinsic</a>
5475 </div>
5476 <div class="doc_text">
5477 <h5>Syntax:</h5>
5478 <pre>
5479 declare void @llvm.memory.barrier( i1 &lt;ll&gt;, i1 &lt;ls&gt;, i1 &lt;sl&gt;, i1 &lt;ss&gt;, 
5480 i1 &lt;device&gt; )
5481
5482 </pre>
5483 <h5>Overview:</h5>
5484 <p>
5485   The <tt>llvm.memory.barrier</tt> intrinsic guarantees ordering between 
5486   specific pairs of memory access types.
5487 </p>
5488 <h5>Arguments:</h5>
5489 <p>
5490   The <tt>llvm.memory.barrier</tt> intrinsic requires five boolean arguments. 
5491   The first four arguments enables a specific barrier as listed below.  The fith
5492   argument specifies that the barrier applies to io or device or uncached memory.
5493
5494 </p>
5495   <ul>
5496     <li><tt>ll</tt>: load-load barrier</li>
5497     <li><tt>ls</tt>: load-store barrier</li>
5498     <li><tt>sl</tt>: store-load barrier</li>
5499     <li><tt>ss</tt>: store-store barrier</li>
5500     <li><tt>device</tt>: barrier applies to device and uncached memory also.
5501   </ul>
5502 <h5>Semantics:</h5>
5503 <p>
5504   This intrinsic causes the system to enforce some ordering constraints upon 
5505   the loads and stores of the program. This barrier does not indicate 
5506   <em>when</em> any events will occur, it only enforces an <em>order</em> in 
5507   which they occur. For any of the specified pairs of load and store operations 
5508   (f.ex.  load-load, or store-load), all of the first operations preceding the 
5509   barrier will complete before any of the second operations succeeding the 
5510   barrier begin. Specifically the semantics for each pairing is as follows:
5511 </p>
5512   <ul>
5513     <li><tt>ll</tt>: All loads before the barrier must complete before any load 
5514     after the barrier begins.</li>
5515
5516     <li><tt>ls</tt>: All loads before the barrier must complete before any 
5517     store after the barrier begins.</li>
5518     <li><tt>ss</tt>: All stores before the barrier must complete before any 
5519     store after the barrier begins.</li>
5520     <li><tt>sl</tt>: All stores before the barrier must complete before any 
5521     load after the barrier begins.</li>
5522   </ul>
5523 <p>
5524   These semantics are applied with a logical "and" behavior when more than  one 
5525   is enabled in a single memory barrier intrinsic.  
5526 </p>
5527 <p>
5528   Backends may implement stronger barriers than those requested when they do not
5529   support as fine grained a barrier as requested.  Some architectures do not
5530   need all types of barriers and on such architectures, these become noops.
5531 </p>
5532 <h5>Example:</h5>
5533 <pre>
5534 %ptr      = malloc i32
5535             store i32 4, %ptr
5536
5537 %result1  = load i32* %ptr      <i>; yields {i32}:result1 = 4</i>
5538             call void @llvm.memory.barrier( i1 false, i1 true, i1 false, i1 false )
5539                                 <i>; guarantee the above finishes</i>
5540             store i32 8, %ptr   <i>; before this begins</i>
5541 </pre>
5542 </div>
5543
5544 <!-- _______________________________________________________________________ -->
5545 <div class="doc_subsubsection">
5546   <a name="int_atomic_lcs">'<tt>llvm.atomic.lcs.*</tt>' Intrinsic</a>
5547 </div>
5548 <div class="doc_text">
5549 <h5>Syntax:</h5>
5550 <p>
5551   This is an overloaded intrinsic. You can use <tt>llvm.atomic.lcs</tt> on any 
5552   integer bit width. Not all targets support all bit widths however.</p>
5553
5554 <pre>
5555 declare i8 @llvm.atomic.lcs.i8( i8* &lt;ptr&gt;, i8 &lt;cmp&gt;, i8 &lt;val&gt; )
5556 declare i16 @llvm.atomic.lcs.i16( i16* &lt;ptr&gt;, i16 &lt;cmp&gt;, i16 &lt;val&gt; )
5557 declare i32 @llvm.atomic.lcs.i32( i32* &lt;ptr&gt;, i32 &lt;cmp&gt;, i32 &lt;val&gt; )
5558 declare i64 @llvm.atomic.lcs.i64( i64* &lt;ptr&gt;, i64 &lt;cmp&gt;, i64 &lt;val&gt; )
5559
5560 </pre>
5561 <h5>Overview:</h5>
5562 <p>
5563   This loads a value in memory and compares it to a given value. If they are 
5564   equal, it stores a new value into the memory.
5565 </p>
5566 <h5>Arguments:</h5>
5567 <p>
5568   The <tt>llvm.atomic.lcs</tt> intrinsic takes three arguments. The result as 
5569   well as both <tt>cmp</tt> and <tt>val</tt> must be integer values with the 
5570   same bit width. The <tt>ptr</tt> argument must be a pointer to a value of 
5571   this integer type. While any bit width integer may be used, targets may only 
5572   lower representations they support in hardware.
5573
5574 </p>
5575 <h5>Semantics:</h5>
5576 <p>
5577   This entire intrinsic must be executed atomically. It first loads the value 
5578   in memory pointed to by <tt>ptr</tt> and compares it with the value 
5579   <tt>cmp</tt>. If they are equal, <tt>val</tt> is stored into the memory. The 
5580   loaded value is yielded in all cases. This provides the equivalent of an 
5581   atomic compare-and-swap operation within the SSA framework.
5582 </p>
5583 <h5>Examples:</h5>
5584
5585 <pre>
5586 %ptr      = malloc i32
5587             store i32 4, %ptr
5588
5589 %val1     = add i32 4, 4
5590 %result1  = call i32 @llvm.atomic.lcs.i32( i32* %ptr, i32 4, %val1 )
5591                                           <i>; yields {i32}:result1 = 4</i>
5592 %stored1  = icmp eq i32 %result1, 4       <i>; yields {i1}:stored1 = true</i>
5593 %memval1  = load i32* %ptr                <i>; yields {i32}:memval1 = 8</i>
5594
5595 %val2     = add i32 1, 1
5596 %result2  = call i32 @llvm.atomic.lcs.i32( i32* %ptr, i32 5, %val2 )
5597                                           <i>; yields {i32}:result2 = 8</i>
5598 %stored2  = icmp eq i32 %result2, 5       <i>; yields {i1}:stored2 = false</i>
5599
5600 %memval2  = load i32* %ptr                <i>; yields {i32}:memval2 = 8</i>
5601 </pre>
5602 </div>
5603
5604 <!-- _______________________________________________________________________ -->
5605 <div class="doc_subsubsection">
5606   <a name="int_atomic_swap">'<tt>llvm.atomic.swap.*</tt>' Intrinsic</a>
5607 </div>
5608 <div class="doc_text">
5609 <h5>Syntax:</h5>
5610
5611 <p>
5612   This is an overloaded intrinsic. You can use <tt>llvm.atomic.swap</tt> on any 
5613   integer bit width. Not all targets support all bit widths however.</p>
5614 <pre>
5615 declare i8 @llvm.atomic.swap.i8( i8* &lt;ptr&gt;, i8 &lt;val&gt; )
5616 declare i16 @llvm.atomic.swap.i16( i16* &lt;ptr&gt;, i16 &lt;val&gt; )
5617 declare i32 @llvm.atomic.swap.i32( i32* &lt;ptr&gt;, i32 &lt;val&gt; )
5618 declare i64 @llvm.atomic.swap.i64( i64* &lt;ptr&gt;, i64 &lt;val&gt; )
5619
5620 </pre>
5621 <h5>Overview:</h5>
5622 <p>
5623   This intrinsic loads the value stored in memory at <tt>ptr</tt> and yields 
5624   the value from memory. It then stores the value in <tt>val</tt> in the memory 
5625   at <tt>ptr</tt>.
5626 </p>
5627 <h5>Arguments:</h5>
5628
5629 <p>
5630   The <tt>llvm.atomic.ls</tt> intrinsic takes two arguments. Both the 
5631   <tt>val</tt> argument and the result must be integers of the same bit width. 
5632   The first argument, <tt>ptr</tt>, must be a pointer to a value of this 
5633   integer type. The targets may only lower integer representations they 
5634   support.
5635 </p>
5636 <h5>Semantics:</h5>
5637 <p>
5638   This intrinsic loads the value pointed to by <tt>ptr</tt>, yields it, and 
5639   stores <tt>val</tt> back into <tt>ptr</tt> atomically. This provides the 
5640   equivalent of an atomic swap operation within the SSA framework.
5641
5642 </p>
5643 <h5>Examples:</h5>
5644 <pre>
5645 %ptr      = malloc i32
5646             store i32 4, %ptr
5647
5648 %val1     = add i32 4, 4
5649 %result1  = call i32 @llvm.atomic.swap.i32( i32* %ptr, i32 %val1 )
5650                                         <i>; yields {i32}:result1 = 4</i>
5651 %stored1  = icmp eq i32 %result1, 4     <i>; yields {i1}:stored1 = true</i>
5652 %memval1  = load i32* %ptr              <i>; yields {i32}:memval1 = 8</i>
5653
5654 %val2     = add i32 1, 1
5655 %result2  = call i32 @llvm.atomic.swap.i32( i32* %ptr, i32 %val2 )
5656                                         <i>; yields {i32}:result2 = 8</i>
5657
5658 %stored2  = icmp eq i32 %result2, 8     <i>; yields {i1}:stored2 = true</i>
5659 %memval2  = load i32* %ptr              <i>; yields {i32}:memval2 = 2</i>
5660 </pre>
5661 </div>
5662
5663 <!-- _______________________________________________________________________ -->
5664 <div class="doc_subsubsection">
5665   <a name="int_atomic_las">'<tt>llvm.atomic.las.*</tt>' Intrinsic</a>
5666
5667 </div>
5668 <div class="doc_text">
5669 <h5>Syntax:</h5>
5670 <p>
5671   This is an overloaded intrinsic. You can use <tt>llvm.atomic.las</tt> on any 
5672   integer bit width. Not all targets support all bit widths however.</p>
5673 <pre>
5674 declare i8 @llvm.atomic.las.i8.( i8* &lt;ptr&gt;, i8 &lt;delta&gt; )
5675 declare i16 @llvm.atomic.las.i16.( i16* &lt;ptr&gt;, i16 &lt;delta&gt; )
5676 declare i32 @llvm.atomic.las.i32.( i32* &lt;ptr&gt;, i32 &lt;delta&gt; )
5677 declare i64 @llvm.atomic.las.i64.( i64* &lt;ptr&gt;, i64 &lt;delta&gt; )
5678
5679 </pre>
5680 <h5>Overview:</h5>
5681 <p>
5682   This intrinsic adds <tt>delta</tt> to the value stored in memory at 
5683   <tt>ptr</tt>. It yields the original value at <tt>ptr</tt>.
5684 </p>
5685 <h5>Arguments:</h5>
5686 <p>
5687
5688   The intrinsic takes two arguments, the first a pointer to an integer value 
5689   and the second an integer value. The result is also an integer value. These 
5690   integer types can have any bit width, but they must all have the same bit 
5691   width. The targets may only lower integer representations they support.
5692 </p>
5693 <h5>Semantics:</h5>
5694 <p>
5695   This intrinsic does a series of operations atomically. It first loads the 
5696   value stored at <tt>ptr</tt>. It then adds <tt>delta</tt>, stores the result 
5697   to <tt>ptr</tt>. It yields the original value stored at <tt>ptr</tt>.
5698 </p>
5699
5700 <h5>Examples:</h5>
5701 <pre>
5702 %ptr      = malloc i32
5703         store i32 4, %ptr
5704 %result1  = call i32 @llvm.atomic.las.i32( i32* %ptr, i32 4 )
5705                                 <i>; yields {i32}:result1 = 4</i>
5706 %result2  = call i32 @llvm.atomic.las.i32( i32* %ptr, i32 2 )
5707                                 <i>; yields {i32}:result2 = 8</i>
5708 %result3  = call i32 @llvm.atomic.las.i32( i32* %ptr, i32 5 )
5709                                 <i>; yields {i32}:result3 = 10</i>
5710 %memval   = load i32* %ptr      <i>; yields {i32}:memval1 = 15</i>
5711 </pre>
5712 </div>
5713
5714
5715 <!-- ======================================================================= -->
5716 <div class="doc_subsection">
5717   <a name="int_general">General Intrinsics</a>
5718 </div>
5719
5720 <div class="doc_text">
5721 <p> This class of intrinsics is designed to be generic and has
5722 no specific purpose. </p>
5723 </div>
5724
5725 <!-- _______________________________________________________________________ -->
5726 <div class="doc_subsubsection">
5727   <a name="int_var_annotation">'<tt>llvm.var.annotation</tt>' Intrinsic</a>
5728 </div>
5729
5730 <div class="doc_text">
5731
5732 <h5>Syntax:</h5>
5733 <pre>
5734   declare void @llvm.var.annotation(i8* &lt;val&gt;, i8* &lt;str&gt;, i8* &lt;str&gt;, i32  &lt;int&gt; )
5735 </pre>
5736
5737 <h5>Overview:</h5>
5738
5739 <p>
5740 The '<tt>llvm.var.annotation</tt>' intrinsic
5741 </p>
5742
5743 <h5>Arguments:</h5>
5744
5745 <p>
5746 The first argument is a pointer to a value, the second is a pointer to a 
5747 global string, the third is a pointer to a global string which is the source 
5748 file name, and the last argument is the line number.
5749 </p>
5750
5751 <h5>Semantics:</h5>
5752
5753 <p>
5754 This intrinsic allows annotation of local variables with arbitrary strings.
5755 This can be useful for special purpose optimizations that want to look for these
5756 annotations.  These have no other defined use, they are ignored by code
5757 generation and optimization.
5758 </p>
5759 </div>
5760
5761 <!-- _______________________________________________________________________ -->
5762 <div class="doc_subsubsection">
5763   <a name="int_annotation">'<tt>llvm.annotation.*</tt>' Intrinsic</a>
5764 </div>
5765
5766 <div class="doc_text">
5767
5768 <h5>Syntax:</h5>
5769 <p>This is an overloaded intrinsic. You can use '<tt>llvm.annotation</tt>' on 
5770 any integer bit width. 
5771 </p>
5772 <pre>
5773   declare i8 @llvm.annotation.i8(i8 &lt;val&gt;, i8* &lt;str&gt;, i8* &lt;str&gt;, i32  &lt;int&gt; )
5774   declare i16 @llvm.annotation.i16(i16 &lt;val&gt;, i8* &lt;str&gt;, i8* &lt;str&gt;, i32  &lt;int&gt; )
5775   declare i32 @llvm.annotation.i32(i32 &lt;val&gt;, i8* &lt;str&gt;, i8* &lt;str&gt;, i32  &lt;int&gt; )
5776   declare i64 @llvm.annotation.i64(i64 &lt;val&gt;, i8* &lt;str&gt;, i8* &lt;str&gt;, i32  &lt;int&gt; )
5777   declare i256 @llvm.annotation.i256(i256 &lt;val&gt;, i8* &lt;str&gt;, i8* &lt;str&gt;, i32  &lt;int&gt; )
5778 </pre>
5779
5780 <h5>Overview:</h5>
5781
5782 <p>
5783 The '<tt>llvm.annotation</tt>' intrinsic.
5784 </p>
5785
5786 <h5>Arguments:</h5>
5787
5788 <p>
5789 The first argument is an integer value (result of some expression), 
5790 the second is a pointer to a global string, the third is a pointer to a global 
5791 string which is the source file name, and the last argument is the line number.
5792 It returns the value of the first argument.
5793 </p>
5794
5795 <h5>Semantics:</h5>
5796
5797 <p>
5798 This intrinsic allows annotations to be put on arbitrary expressions
5799 with arbitrary strings.  This can be useful for special purpose optimizations 
5800 that want to look for these annotations.  These have no other defined use, they 
5801 are ignored by code generation and optimization.
5802 </div>
5803
5804 <!-- _______________________________________________________________________ -->
5805 <div class="doc_subsubsection">
5806   <a name="int_trap">'<tt>llvm.trap</tt>' Intrinsic</a>
5807 </div>
5808
5809 <div class="doc_text">
5810
5811 <h5>Syntax:</h5>
5812 <pre>
5813   declare void @llvm.trap()
5814 </pre>
5815
5816 <h5>Overview:</h5>
5817
5818 <p>
5819 The '<tt>llvm.trap</tt>' intrinsic
5820 </p>
5821
5822 <h5>Arguments:</h5>
5823
5824 <p>
5825 None
5826 </p>
5827
5828 <h5>Semantics:</h5>
5829
5830 <p>
5831 This intrinsics is lowered to the target dependent trap instruction. If the
5832 target does not have a trap instruction, this intrinsic will be lowered to the
5833 call of the abort() function.
5834 </p>
5835 </div>
5836
5837 <!-- *********************************************************************** -->
5838 <hr>
5839 <address>
5840   <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
5841   src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
5842   <a href="http://validator.w3.org/check/referer"><img
5843   src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
5844
5845   <a href="mailto:sabre@nondot.org">Chris Lattner</a><br>
5846   <a href="http://llvm.org">The LLVM Compiler Infrastructure</a><br>
5847   Last modified: $Date$
5848 </address>
5849
5850 </body>
5851 </html>