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