blob: f313aed782bcf1a3cf6e3ef0d11308105851aa48 [file] [log] [blame]
Misha Brukmandaa4cb02004-03-01 17:47:27 +00001<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
Misha Brukman9d0919f2003-11-08 01:05:38 +00003<html>
4<head>
5 <title>LLVM Assembly Language Reference Manual</title>
Reid Spencer3921c742004-08-26 20:44:00 +00006 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
7 <meta name="author" content="Chris Lattner">
8 <meta name="description"
9 content="LLVM Assembly Language Reference Manual.">
Misha Brukman9d0919f2003-11-08 01:05:38 +000010 <link rel="stylesheet" href="llvm.css" type="text/css">
11</head>
Chris Lattnerd7923912004-05-23 21:06:01 +000012
Misha Brukman9d0919f2003-11-08 01:05:38 +000013<body>
Chris Lattnerd7923912004-05-23 21:06:01 +000014
Chris Lattner261efe92003-11-25 01:02:51 +000015<div class="doc_title"> LLVM Language Reference Manual </div>
Chris Lattner00950542001-06-06 20:29:01 +000016<ol>
Misha Brukman9d0919f2003-11-08 01:05:38 +000017 <li><a href="#abstract">Abstract</a></li>
18 <li><a href="#introduction">Introduction</a></li>
19 <li><a href="#identifiers">Identifiers</a></li>
Chris Lattnerfa730212004-12-09 16:11:40 +000020 <li><a href="#highlevel">High Level Structure</a>
21 <ol>
22 <li><a href="#modulestructure">Module Structure</a></li>
Chris Lattnere5d947b2004-12-09 16:36:40 +000023 <li><a href="#linkage">Linkage Types</a></li>
Chris Lattnerfa730212004-12-09 16:11:40 +000024 <li><a href="#globalvars">Global Variables</a></li>
25 <li><a href="#functionstructure">Function Structure</a></li>
26 </ol>
27 </li>
Chris Lattner00950542001-06-06 20:29:01 +000028 <li><a href="#typesystem">Type System</a>
29 <ol>
Chris Lattner261efe92003-11-25 01:02:51 +000030 <li><a href="#t_primitive">Primitive Types</a>
31 <ol>
Misha Brukman9d0919f2003-11-08 01:05:38 +000032 <li><a href="#t_classifications">Type Classifications</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000033 </ol>
34 </li>
Chris Lattner00950542001-06-06 20:29:01 +000035 <li><a href="#t_derived">Derived Types</a>
36 <ol>
Chris Lattner261efe92003-11-25 01:02:51 +000037 <li><a href="#t_array">Array Type</a></li>
Misha Brukman9d0919f2003-11-08 01:05:38 +000038 <li><a href="#t_function">Function Type</a></li>
39 <li><a href="#t_pointer">Pointer Type</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000040 <li><a href="#t_struct">Structure Type</a></li>
Chris Lattnera58561b2004-08-12 19:12:28 +000041 <li><a href="#t_packed">Packed Type</a></li>
Chris Lattner69c11bb2005-04-25 17:34:15 +000042 <li><a href="#t_opaque">Opaque Type</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000043 </ol>
44 </li>
45 </ol>
46 </li>
Chris Lattnerfa730212004-12-09 16:11:40 +000047 <li><a href="#constants">Constants</a>
Chris Lattnerc3f59762004-12-09 17:30:23 +000048 <ol>
49 <li><a href="#simpleconstants">Simple Constants</a>
50 <li><a href="#aggregateconstants">Aggregate Constants</a>
51 <li><a href="#globalconstants">Global Variable and Function Addresses</a>
52 <li><a href="#undefvalues">Undefined Values</a>
53 <li><a href="#constantexprs">Constant Expressions</a>
54 </ol>
Chris Lattner261efe92003-11-25 01:02:51 +000055 </li>
Chris Lattner00950542001-06-06 20:29:01 +000056 <li><a href="#instref">Instruction Reference</a>
57 <ol>
58 <li><a href="#terminators">Terminator Instructions</a>
59 <ol>
Chris Lattner261efe92003-11-25 01:02:51 +000060 <li><a href="#i_ret">'<tt>ret</tt>' Instruction</a></li>
61 <li><a href="#i_br">'<tt>br</tt>' Instruction</a></li>
Misha Brukman9d0919f2003-11-08 01:05:38 +000062 <li><a href="#i_switch">'<tt>switch</tt>' Instruction</a></li>
63 <li><a href="#i_invoke">'<tt>invoke</tt>' Instruction</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000064 <li><a href="#i_unwind">'<tt>unwind</tt>' Instruction</a></li>
Chris Lattner35eca582004-10-16 18:04:13 +000065 <li><a href="#i_unreachable">'<tt>unreachable</tt>' Instruction</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000066 </ol>
67 </li>
Chris Lattner00950542001-06-06 20:29:01 +000068 <li><a href="#binaryops">Binary Operations</a>
69 <ol>
Chris Lattner261efe92003-11-25 01:02:51 +000070 <li><a href="#i_add">'<tt>add</tt>' Instruction</a></li>
71 <li><a href="#i_sub">'<tt>sub</tt>' Instruction</a></li>
72 <li><a href="#i_mul">'<tt>mul</tt>' Instruction</a></li>
73 <li><a href="#i_div">'<tt>div</tt>' Instruction</a></li>
74 <li><a href="#i_rem">'<tt>rem</tt>' Instruction</a></li>
Misha Brukman9d0919f2003-11-08 01:05:38 +000075 <li><a href="#i_setcc">'<tt>set<i>cc</i></tt>' Instructions</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000076 </ol>
77 </li>
Chris Lattner00950542001-06-06 20:29:01 +000078 <li><a href="#bitwiseops">Bitwise Binary Operations</a>
79 <ol>
Misha Brukman9d0919f2003-11-08 01:05:38 +000080 <li><a href="#i_and">'<tt>and</tt>' Instruction</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000081 <li><a href="#i_or">'<tt>or</tt>' Instruction</a></li>
Misha Brukman9d0919f2003-11-08 01:05:38 +000082 <li><a href="#i_xor">'<tt>xor</tt>' Instruction</a></li>
83 <li><a href="#i_shl">'<tt>shl</tt>' Instruction</a></li>
84 <li><a href="#i_shr">'<tt>shr</tt>' Instruction</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000085 </ol>
86 </li>
Chris Lattner00950542001-06-06 20:29:01 +000087 <li><a href="#memoryops">Memory Access Operations</a>
88 <ol>
Chris Lattner261efe92003-11-25 01:02:51 +000089 <li><a href="#i_malloc">'<tt>malloc</tt>' Instruction</a></li>
90 <li><a href="#i_free">'<tt>free</tt>' Instruction</a></li>
91 <li><a href="#i_alloca">'<tt>alloca</tt>' Instruction</a></li>
92 <li><a href="#i_load">'<tt>load</tt>' Instruction</a></li>
93 <li><a href="#i_store">'<tt>store</tt>' Instruction</a></li>
94 <li><a href="#i_getelementptr">'<tt>getelementptr</tt>' Instruction</a></li>
95 </ol>
96 </li>
Chris Lattner00950542001-06-06 20:29:01 +000097 <li><a href="#otherops">Other Operations</a>
98 <ol>
Chris Lattner261efe92003-11-25 01:02:51 +000099 <li><a href="#i_phi">'<tt>phi</tt>' Instruction</a></li>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000100 <li><a href="#i_cast">'<tt>cast .. to</tt>' Instruction</a></li>
Chris Lattnercc37aae2004-03-12 05:50:16 +0000101 <li><a href="#i_select">'<tt>select</tt>' Instruction</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +0000102 <li><a href="#i_call">'<tt>call</tt>' Instruction</a></li>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000103 <li><a href="#i_vanext">'<tt>vanext</tt>' Instruction</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +0000104 <li><a href="#i_vaarg">'<tt>vaarg</tt>' Instruction</a></li>
Chris Lattner00950542001-06-06 20:29:01 +0000105 </ol>
Chris Lattner261efe92003-11-25 01:02:51 +0000106 </li>
Chris Lattner00950542001-06-06 20:29:01 +0000107 </ol>
Chris Lattner261efe92003-11-25 01:02:51 +0000108 </li>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +0000109 <li><a href="#intrinsics">Intrinsic Functions</a>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +0000110 <ol>
Chris Lattner261efe92003-11-25 01:02:51 +0000111 <li><a href="#int_varargs">Variable Argument Handling Intrinsics</a>
112 <ol>
113 <li><a href="#i_va_start">'<tt>llvm.va_start</tt>' Intrinsic</a></li>
114 <li><a href="#i_va_end">'<tt>llvm.va_end</tt>' Intrinsic</a></li>
115 <li><a href="#i_va_copy">'<tt>llvm.va_copy</tt>' Intrinsic</a></li>
116 </ol>
117 </li>
Chris Lattnerd7923912004-05-23 21:06:01 +0000118 <li><a href="#int_gc">Accurate Garbage Collection Intrinsics</a>
119 <ol>
120 <li><a href="#i_gcroot">'<tt>llvm.gcroot</tt>' Intrinsic</a></li>
121 <li><a href="#i_gcread">'<tt>llvm.gcread</tt>' Intrinsic</a></li>
122 <li><a href="#i_gcwrite">'<tt>llvm.gcwrite</tt>' Intrinsic</a></li>
123 </ol>
124 </li>
Chris Lattner10610642004-02-14 04:08:35 +0000125 <li><a href="#int_codegen">Code Generator Intrinsics</a>
126 <ol>
127 <li><a href="#i_returnaddress">'<tt>llvm.returnaddress</tt>' Intrinsic</a></li>
128 <li><a href="#i_frameaddress">'<tt>llvm.frameaddress</tt>' Intrinsic</a></li>
Chris Lattner9a9d7ac2005-02-28 19:24:19 +0000129 <li><a href="#i_prefetch">'<tt>llvm.prefetch</tt>' Intrinsic</a></li>
Andrew Lenharth7f4ec3b2005-03-28 20:05:49 +0000130 <li><a href="#i_pcmarker">'<tt>llvm.pcmarker</tt>' Intrinsic</a></li>
John Criswell7123e272004-04-09 16:43:20 +0000131 </ol>
132 </li>
133 <li><a href="#int_os">Operating System Intrinsics</a>
134 <ol>
Chris Lattner32006282004-06-11 02:28:03 +0000135 <li><a href="#i_readport">'<tt>llvm.readport</tt>' Intrinsic</a></li>
136 <li><a href="#i_writeport">'<tt>llvm.writeport</tt>' Intrinsic</a></li>
John Criswell183402a2004-04-12 15:02:16 +0000137 <li><a href="#i_readio">'<tt>llvm.readio</tt>' Intrinsic</a></li>
138 <li><a href="#i_writeio">'<tt>llvm.writeio</tt>' Intrinsic</a></li>
Chris Lattner10610642004-02-14 04:08:35 +0000139 </ol>
Chris Lattner33aec9e2004-02-12 17:01:32 +0000140 <li><a href="#int_libc">Standard C Library Intrinsics</a>
141 <ol>
142 <li><a href="#i_memcpy">'<tt>llvm.memcpy</tt>' Intrinsic</a></li>
Chris Lattner0eb51b42004-02-12 18:10:10 +0000143 <li><a href="#i_memmove">'<tt>llvm.memmove</tt>' Intrinsic</a></li>
Chris Lattner10610642004-02-14 04:08:35 +0000144 <li><a href="#i_memset">'<tt>llvm.memset</tt>' Intrinsic</a></li>
Alkis Evlogimenos96853722004-06-12 19:19:14 +0000145 <li><a href="#i_isunordered">'<tt>llvm.isunordered</tt>' Intrinsic</a></li>
Chris Lattner33aec9e2004-02-12 17:01:32 +0000146 </ol>
147 </li>
Andrew Lenharthec370fd2005-05-03 18:01:48 +0000148 <li><a href="#int_count">Bit counting Intrinsics</a>
149 <ol>
150 <li><a href="#int_ctpop">'<tt>llvm.ctpop</tt>' Intrinsic </a></li>
151 <li><a href="#int_cttz">'<tt>llvm.cttz</tt>' Intrinsic </a></li>
152 <li><a href="#int_ctlz">'<tt>llvm.ctlz</tt>' Intrinsic </a></li>
153 </ol>
154 </li>
Chris Lattnerd7923912004-05-23 21:06:01 +0000155 <li><a href="#int_debugger">Debugger intrinsics</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +0000156 </ol>
157 </li>
Chris Lattner00950542001-06-06 20:29:01 +0000158</ol>
Chris Lattnerd7923912004-05-23 21:06:01 +0000159
160<div class="doc_author">
161 <p>Written by <a href="mailto:sabre@nondot.org">Chris Lattner</a>
162 and <a href="mailto:vadve@cs.uiuc.edu">Vikram Adve</a></p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000163</div>
Chris Lattnerd7923912004-05-23 21:06:01 +0000164
Chris Lattner00950542001-06-06 20:29:01 +0000165<!-- *********************************************************************** -->
Chris Lattner261efe92003-11-25 01:02:51 +0000166<div class="doc_section"> <a name="abstract">Abstract </a></div>
167<!-- *********************************************************************** -->
Chris Lattnerd7923912004-05-23 21:06:01 +0000168
Misha Brukman9d0919f2003-11-08 01:05:38 +0000169<div class="doc_text">
Chris Lattner261efe92003-11-25 01:02:51 +0000170<p>This document is a reference manual for the LLVM assembly language.
171LLVM is an SSA based representation that provides type safety,
172low-level operations, flexibility, and the capability of representing
173'all' high-level languages cleanly. It is the common code
174representation used throughout all phases of the LLVM compilation
175strategy.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000176</div>
Chris Lattnerd7923912004-05-23 21:06:01 +0000177
Chris Lattner00950542001-06-06 20:29:01 +0000178<!-- *********************************************************************** -->
Chris Lattner261efe92003-11-25 01:02:51 +0000179<div class="doc_section"> <a name="introduction">Introduction</a> </div>
180<!-- *********************************************************************** -->
Chris Lattnerd7923912004-05-23 21:06:01 +0000181
Misha Brukman9d0919f2003-11-08 01:05:38 +0000182<div class="doc_text">
Chris Lattnerd7923912004-05-23 21:06:01 +0000183
Chris Lattner261efe92003-11-25 01:02:51 +0000184<p>The LLVM code representation is designed to be used in three
185different forms: as an in-memory compiler IR, as an on-disk bytecode
186representation (suitable for fast loading by a Just-In-Time compiler),
187and as a human readable assembly language representation. This allows
188LLVM to provide a powerful intermediate representation for efficient
189compiler transformations and analysis, while providing a natural means
190to debug and visualize the transformations. The three different forms
191of LLVM are all equivalent. This document describes the human readable
192representation and notation.</p>
Chris Lattnerd7923912004-05-23 21:06:01 +0000193
Chris Lattner261efe92003-11-25 01:02:51 +0000194<p>The LLVM representation aims to be a light-weight and low-level
195while being expressive, typed, and extensible at the same time. It
196aims to be a "universal IR" of sorts, by being at a low enough level
197that high-level ideas may be cleanly mapped to it (similar to how
198microprocessors are "universal IR's", allowing many source languages to
199be mapped to them). By providing type information, LLVM can be used as
200the target of optimizations: for example, through pointer analysis, it
201can be proven that a C automatic variable is never accessed outside of
202the current function... allowing it to be promoted to a simple SSA
203value instead of a memory location.</p>
Chris Lattnerd7923912004-05-23 21:06:01 +0000204
Misha Brukman9d0919f2003-11-08 01:05:38 +0000205</div>
Chris Lattnerd7923912004-05-23 21:06:01 +0000206
Chris Lattner00950542001-06-06 20:29:01 +0000207<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000208<div class="doc_subsubsection"> <a name="wellformed">Well-Formedness</a> </div>
Chris Lattnerd7923912004-05-23 21:06:01 +0000209
Misha Brukman9d0919f2003-11-08 01:05:38 +0000210<div class="doc_text">
Chris Lattnerd7923912004-05-23 21:06:01 +0000211
Chris Lattner261efe92003-11-25 01:02:51 +0000212<p>It is important to note that this document describes 'well formed'
213LLVM assembly language. There is a difference between what the parser
214accepts and what is considered 'well formed'. For example, the
215following instruction is syntactically okay, but not well formed:</p>
Chris Lattnerd7923912004-05-23 21:06:01 +0000216
217<pre>
218 %x = <a href="#i_add">add</a> int 1, %x
219</pre>
220
Chris Lattner261efe92003-11-25 01:02:51 +0000221<p>...because the definition of <tt>%x</tt> does not dominate all of
222its uses. The LLVM infrastructure provides a verification pass that may
223be used to verify that an LLVM module is well formed. This pass is
224automatically run by the parser after parsing input assembly, and by
225the optimizer before it outputs bytecode. The violations pointed out
226by the verifier pass indicate bugs in transformation passes or input to
227the parser.</p>
Chris Lattnerd7923912004-05-23 21:06:01 +0000228
Chris Lattner261efe92003-11-25 01:02:51 +0000229<!-- Describe the typesetting conventions here. --> </div>
Chris Lattnerd7923912004-05-23 21:06:01 +0000230
Chris Lattner00950542001-06-06 20:29:01 +0000231<!-- *********************************************************************** -->
Chris Lattner261efe92003-11-25 01:02:51 +0000232<div class="doc_section"> <a name="identifiers">Identifiers</a> </div>
Chris Lattner00950542001-06-06 20:29:01 +0000233<!-- *********************************************************************** -->
Chris Lattnerd7923912004-05-23 21:06:01 +0000234
Misha Brukman9d0919f2003-11-08 01:05:38 +0000235<div class="doc_text">
Chris Lattnerd7923912004-05-23 21:06:01 +0000236
Chris Lattner261efe92003-11-25 01:02:51 +0000237<p>LLVM uses three different forms of identifiers, for different
238purposes:</p>
Chris Lattnerd7923912004-05-23 21:06:01 +0000239
Chris Lattner00950542001-06-06 20:29:01 +0000240<ol>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000241 <li>Named values are represented as a string of characters with a '%' prefix.
242 For example, %foo, %DivisionByZero, %a.really.long.identifier. The actual
243 regular expression used is '<tt>%[a-zA-Z$._][a-zA-Z$._0-9]*</tt>'.
244 Identifiers which require other characters in their names can be surrounded
245 with quotes. In this way, anything except a <tt>"</tt> character can be used
246 in a name.</li>
247
248 <li>Unnamed values are represented as an unsigned numeric value with a '%'
249 prefix. For example, %12, %2, %44.</li>
250
Reid Spencercc16dc32004-12-09 18:02:53 +0000251 <li>Constants, which are described in a <a href="#constants">section about
252 constants</a>, below.</li>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000253</ol>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000254
255<p>LLVM requires that values start with a '%' sign for two reasons: Compilers
256don't need to worry about name clashes with reserved words, and the set of
257reserved words may be expanded in the future without penalty. Additionally,
258unnamed identifiers allow a compiler to quickly come up with a temporary
259variable without having to avoid symbol table conflicts.</p>
260
Chris Lattner261efe92003-11-25 01:02:51 +0000261<p>Reserved words in LLVM are very similar to reserved words in other
262languages. There are keywords for different opcodes ('<tt><a
Chris Lattnere5d947b2004-12-09 16:36:40 +0000263href="#i_add">add</a></tt>', '<tt><a href="#i_cast">cast</a></tt>', '<tt><a
264href="#i_ret">ret</a></tt>', etc...), for primitive type names ('<tt><a
265href="#t_void">void</a></tt>', '<tt><a href="#t_uint">uint</a></tt>', etc...),
266and others. These reserved words cannot conflict with variable names, because
267none of them start with a '%' character.</p>
268
269<p>Here is an example of LLVM code to multiply the integer variable
270'<tt>%X</tt>' by 8:</p>
271
Misha Brukman9d0919f2003-11-08 01:05:38 +0000272<p>The easy way:</p>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000273
274<pre>
275 %result = <a href="#i_mul">mul</a> uint %X, 8
276</pre>
277
Misha Brukman9d0919f2003-11-08 01:05:38 +0000278<p>After strength reduction:</p>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000279
280<pre>
281 %result = <a href="#i_shl">shl</a> uint %X, ubyte 3
282</pre>
283
Misha Brukman9d0919f2003-11-08 01:05:38 +0000284<p>And the hard way:</p>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000285
286<pre>
287 <a href="#i_add">add</a> uint %X, %X <i>; yields {uint}:%0</i>
288 <a href="#i_add">add</a> uint %0, %0 <i>; yields {uint}:%1</i>
289 %result = <a href="#i_add">add</a> uint %1, %1
290</pre>
291
Chris Lattner261efe92003-11-25 01:02:51 +0000292<p>This last way of multiplying <tt>%X</tt> by 8 illustrates several
293important lexical features of LLVM:</p>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000294
Chris Lattner00950542001-06-06 20:29:01 +0000295<ol>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000296
297 <li>Comments are delimited with a '<tt>;</tt>' and go until the end of
298 line.</li>
299
300 <li>Unnamed temporaries are created when the result of a computation is not
301 assigned to a named value.</li>
302
Misha Brukman9d0919f2003-11-08 01:05:38 +0000303 <li>Unnamed temporaries are numbered sequentially</li>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000304
Misha Brukman9d0919f2003-11-08 01:05:38 +0000305</ol>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000306
307<p>...and it also show a convention that we follow in this document. When
308demonstrating instructions, we will follow an instruction with a comment that
309defines the type and name of value produced. Comments are shown in italic
310text.</p>
311
Misha Brukman9d0919f2003-11-08 01:05:38 +0000312</div>
Chris Lattnerfa730212004-12-09 16:11:40 +0000313
314<!-- *********************************************************************** -->
315<div class="doc_section"> <a name="highlevel">High Level Structure</a> </div>
316<!-- *********************************************************************** -->
317
318<!-- ======================================================================= -->
319<div class="doc_subsection"> <a name="modulestructure">Module Structure</a>
320</div>
321
322<div class="doc_text">
323
324<p>LLVM programs are composed of "Module"s, each of which is a
325translation unit of the input programs. Each module consists of
326functions, global variables, and symbol table entries. Modules may be
327combined together with the LLVM linker, which merges function (and
328global variable) definitions, resolves forward declarations, and merges
329symbol table entries. Here is an example of the "hello world" module:</p>
330
331<pre><i>; Declare the string constant as a global constant...</i>
332<a href="#identifiers">%.LC0</a> = <a href="#linkage_internal">internal</a> <a
333 href="#globalvars">constant</a> <a href="#t_array">[13 x sbyte]</a> c"hello world\0A\00" <i>; [13 x sbyte]*</i>
334
335<i>; External declaration of the puts function</i>
336<a href="#functionstructure">declare</a> int %puts(sbyte*) <i>; int(sbyte*)* </i>
337
338<i>; Definition of main function</i>
339int %main() { <i>; int()* </i>
340 <i>; Convert [13x sbyte]* to sbyte *...</i>
341 %cast210 = <a
342 href="#i_getelementptr">getelementptr</a> [13 x sbyte]* %.LC0, long 0, long 0 <i>; sbyte*</i>
343
344 <i>; Call puts function to write out the string to stdout...</i>
345 <a
346 href="#i_call">call</a> int %puts(sbyte* %cast210) <i>; int</i>
347 <a
348 href="#i_ret">ret</a> int 0<br>}<br></pre>
349
350<p>This example is made up of a <a href="#globalvars">global variable</a>
351named "<tt>.LC0</tt>", an external declaration of the "<tt>puts</tt>"
352function, and a <a href="#functionstructure">function definition</a>
353for "<tt>main</tt>".</p>
354
Chris Lattnere5d947b2004-12-09 16:36:40 +0000355<p>In general, a module is made up of a list of global values,
356where both functions and global variables are global values. Global values are
357represented by a pointer to a memory location (in this case, a pointer to an
358array of char, and a pointer to a function), and have one of the following <a
359href="#linkage">linkage types</a>.</p>
Chris Lattnerfa730212004-12-09 16:11:40 +0000360
Chris Lattnere5d947b2004-12-09 16:36:40 +0000361</div>
362
363<!-- ======================================================================= -->
364<div class="doc_subsection">
365 <a name="linkage">Linkage Types</a>
366</div>
367
368<div class="doc_text">
369
370<p>
371All Global Variables and Functions have one of the following types of linkage:
372</p>
Chris Lattnerfa730212004-12-09 16:11:40 +0000373
374<dl>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000375
Chris Lattnerfa730212004-12-09 16:11:40 +0000376 <dt><tt><b><a name="linkage_internal">internal</a></b></tt> </dt>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000377
378 <dd>Global values with internal linkage are only directly accessible by
379 objects in the current module. In particular, linking code into a module with
380 an internal global value may cause the internal to be renamed as necessary to
381 avoid collisions. Because the symbol is internal to the module, all
382 references can be updated. This corresponds to the notion of the
383 '<tt>static</tt>' keyword in C, or the idea of "anonymous namespaces" in C++.
Chris Lattnerfa730212004-12-09 16:11:40 +0000384 </dd>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000385
Chris Lattnerfa730212004-12-09 16:11:40 +0000386 <dt><tt><b><a name="linkage_linkonce">linkonce</a></b></tt>: </dt>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000387
388 <dd>"<tt>linkonce</tt>" linkage is similar to <tt>internal</tt> linkage, with
389 the twist that linking together two modules defining the same
390 <tt>linkonce</tt> globals will cause one of the globals to be discarded. This
391 is typically used to implement inline functions. Unreferenced
392 <tt>linkonce</tt> globals are allowed to be discarded.
Chris Lattnerfa730212004-12-09 16:11:40 +0000393 </dd>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000394
Chris Lattnerfa730212004-12-09 16:11:40 +0000395 <dt><tt><b><a name="linkage_weak">weak</a></b></tt>: </dt>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000396
397 <dd>"<tt>weak</tt>" linkage is exactly the same as <tt>linkonce</tt> linkage,
398 except that unreferenced <tt>weak</tt> globals may not be discarded. This is
399 used to implement constructs in C such as "<tt>int X;</tt>" at global scope.
Chris Lattnerfa730212004-12-09 16:11:40 +0000400 </dd>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000401
Chris Lattnerfa730212004-12-09 16:11:40 +0000402 <dt><tt><b><a name="linkage_appending">appending</a></b></tt>: </dt>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000403
404 <dd>"<tt>appending</tt>" linkage may only be applied to global variables of
405 pointer to array type. When two global variables with appending linkage are
406 linked together, the two global arrays are appended together. This is the
407 LLVM, typesafe, equivalent of having the system linker append together
408 "sections" with identical names when .o files are linked.
Chris Lattnerfa730212004-12-09 16:11:40 +0000409 </dd>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000410
Chris Lattnerfa730212004-12-09 16:11:40 +0000411 <dt><tt><b><a name="linkage_external">externally visible</a></b></tt>:</dt>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000412
413 <dd>If none of the above identifiers are used, the global is externally
414 visible, meaning that it participates in linkage and can be used to resolve
415 external symbol references.
Chris Lattnerfa730212004-12-09 16:11:40 +0000416 </dd>
417</dl>
418
Chris Lattnerfa730212004-12-09 16:11:40 +0000419<p><a name="linkage_external">For example, since the "<tt>.LC0</tt>"
420variable is defined to be internal, if another module defined a "<tt>.LC0</tt>"
421variable and was linked with this one, one of the two would be renamed,
422preventing a collision. Since "<tt>main</tt>" and "<tt>puts</tt>" are
423external (i.e., lacking any linkage declarations), they are accessible
424outside of the current module. It is illegal for a function <i>declaration</i>
425to have any linkage type other than "externally visible".</a></p>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000426
Chris Lattnerfa730212004-12-09 16:11:40 +0000427</div>
428
429<!-- ======================================================================= -->
430<div class="doc_subsection">
431 <a name="globalvars">Global Variables</a>
432</div>
433
434<div class="doc_text">
435
Chris Lattner3689a342005-02-12 19:30:21 +0000436<p>Global variables define regions of memory allocated at compilation time
437instead of run-time. Global variables may optionally be initialized. A
438variable may be defined as a global "constant", which indicates that the
439contents of the variable will <b>never</b> be modified (enabling better
440optimization, allowing the global data to be placed in the read-only section of
441an executable, etc). Note that variables that need runtime initialization
442cannot be marked "constant", as there is a store to the variable.</p>
443
444<p>
445LLVM explicitly allows <em>declarations</em> of global variables to be marked
446constant, even if the final definition of the global is not. This capability
447can be used to enable slightly better optimization of the program, but requires
448the language definition to guarantee that optimizations based on the
449'constantness' are valid for the translation units that do not include the
450definition.
451</p>
Chris Lattnerfa730212004-12-09 16:11:40 +0000452
453<p>As SSA values, global variables define pointer values that are in
454scope (i.e. they dominate) all basic blocks in the program. Global
455variables always define a pointer to their "content" type because they
456describe a region of memory, and all memory objects in LLVM are
457accessed through pointers.</p>
458
459</div>
460
461
462<!-- ======================================================================= -->
463<div class="doc_subsection">
464 <a name="functionstructure">Functions</a>
465</div>
466
467<div class="doc_text">
468
469<p>LLVM function definitions are composed of a (possibly empty) argument list,
470an opening curly brace, a list of basic blocks, and a closing curly brace. LLVM
471function declarations are defined with the "<tt>declare</tt>" keyword, a
472function name, and a function signature.</p>
473
474<p>A function definition contains a list of basic blocks, forming the CFG for
475the function. Each basic block may optionally start with a label (giving the
476basic block a symbol table entry), contains a list of instructions, and ends
477with a <a href="#terminators">terminator</a> instruction (such as a branch or
478function return).</p>
479
480<p>The first basic block in program is special in two ways: it is immediately
481executed on entrance to the function, and it is not allowed to have predecessor
482basic blocks (i.e. there can not be any branches to the entry block of a
483function). Because the block can have no predecessors, it also cannot have any
484<a href="#i_phi">PHI nodes</a>.</p>
485
486<p>LLVM functions are identified by their name and type signature. Hence, two
487functions with the same name but different parameter lists or return values are
Chris Lattnerd4f6b172005-03-07 22:13:59 +0000488considered different functions, and LLVM will resolve references to each
Chris Lattnerfa730212004-12-09 16:11:40 +0000489appropriately.</p>
490
491</div>
492
493
494
Chris Lattner00950542001-06-06 20:29:01 +0000495<!-- *********************************************************************** -->
Chris Lattner261efe92003-11-25 01:02:51 +0000496<div class="doc_section"> <a name="typesystem">Type System</a> </div>
497<!-- *********************************************************************** -->
Chris Lattnerfa730212004-12-09 16:11:40 +0000498
Misha Brukman9d0919f2003-11-08 01:05:38 +0000499<div class="doc_text">
Chris Lattnerfa730212004-12-09 16:11:40 +0000500
Misha Brukman9d0919f2003-11-08 01:05:38 +0000501<p>The LLVM type system is one of the most important features of the
Chris Lattner261efe92003-11-25 01:02:51 +0000502intermediate representation. Being typed enables a number of
503optimizations to be performed on the IR directly, without having to do
504extra analyses on the side before the transformation. A strong type
505system makes it easier to read the generated code and enables novel
506analyses and transformations that are not feasible to perform on normal
507three address code representations.</p>
Chris Lattnerfa730212004-12-09 16:11:40 +0000508
509</div>
510
Chris Lattner00950542001-06-06 20:29:01 +0000511<!-- ======================================================================= -->
Chris Lattner261efe92003-11-25 01:02:51 +0000512<div class="doc_subsection"> <a name="t_primitive">Primitive Types</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000513<div class="doc_text">
John Criswell4457dc92004-04-09 16:48:45 +0000514<p>The primitive types are the fundamental building blocks of the LLVM
Chris Lattnerd4f6b172005-03-07 22:13:59 +0000515system. The current set of primitive types is as follows:</p>
Misha Brukmandaa4cb02004-03-01 17:47:27 +0000516
Reid Spencerd3f876c2004-11-01 08:19:36 +0000517<table class="layout">
518 <tr class="layout">
519 <td class="left">
520 <table>
Chris Lattner261efe92003-11-25 01:02:51 +0000521 <tbody>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000522 <tr><th>Type</th><th>Description</th></tr>
523 <tr><td><tt>void</tt></td><td>No value</td></tr>
Misha Brukmancfa87bc2005-04-22 18:02:52 +0000524 <tr><td><tt>ubyte</tt></td><td>Unsigned 8-bit value</td></tr>
525 <tr><td><tt>ushort</tt></td><td>Unsigned 16-bit value</td></tr>
526 <tr><td><tt>uint</tt></td><td>Unsigned 32-bit value</td></tr>
527 <tr><td><tt>ulong</tt></td><td>Unsigned 64-bit value</td></tr>
528 <tr><td><tt>float</tt></td><td>32-bit floating point value</td></tr>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000529 <tr><td><tt>label</tt></td><td>Branch destination</td></tr>
Chris Lattner261efe92003-11-25 01:02:51 +0000530 </tbody>
531 </table>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000532 </td>
533 <td class="right">
534 <table>
Chris Lattner261efe92003-11-25 01:02:51 +0000535 <tbody>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000536 <tr><th>Type</th><th>Description</th></tr>
537 <tr><td><tt>bool</tt></td><td>True or False value</td></tr>
Misha Brukmancfa87bc2005-04-22 18:02:52 +0000538 <tr><td><tt>sbyte</tt></td><td>Signed 8-bit value</td></tr>
539 <tr><td><tt>short</tt></td><td>Signed 16-bit value</td></tr>
540 <tr><td><tt>int</tt></td><td>Signed 32-bit value</td></tr>
541 <tr><td><tt>long</tt></td><td>Signed 64-bit value</td></tr>
542 <tr><td><tt>double</tt></td><td>64-bit floating point value</td></tr>
Chris Lattner261efe92003-11-25 01:02:51 +0000543 </tbody>
544 </table>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000545 </td>
546 </tr>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000547</table>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000548</div>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000549
Chris Lattner00950542001-06-06 20:29:01 +0000550<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000551<div class="doc_subsubsection"> <a name="t_classifications">Type
552Classifications</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000553<div class="doc_text">
Chris Lattner261efe92003-11-25 01:02:51 +0000554<p>These different primitive types fall into a few useful
555classifications:</p>
Misha Brukmandaa4cb02004-03-01 17:47:27 +0000556
557<table border="1" cellspacing="0" cellpadding="4">
Chris Lattner261efe92003-11-25 01:02:51 +0000558 <tbody>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000559 <tr><th>Classification</th><th>Types</th></tr>
Chris Lattner261efe92003-11-25 01:02:51 +0000560 <tr>
561 <td><a name="t_signed">signed</a></td>
562 <td><tt>sbyte, short, int, long, float, double</tt></td>
563 </tr>
564 <tr>
565 <td><a name="t_unsigned">unsigned</a></td>
566 <td><tt>ubyte, ushort, uint, ulong</tt></td>
567 </tr>
568 <tr>
569 <td><a name="t_integer">integer</a></td>
570 <td><tt>ubyte, sbyte, ushort, short, uint, int, ulong, long</tt></td>
571 </tr>
572 <tr>
573 <td><a name="t_integral">integral</a></td>
Misha Brukmanc24b7582004-08-12 20:16:08 +0000574 <td><tt>bool, ubyte, sbyte, ushort, short, uint, int, ulong, long</tt>
575 </td>
Chris Lattner261efe92003-11-25 01:02:51 +0000576 </tr>
577 <tr>
578 <td><a name="t_floating">floating point</a></td>
579 <td><tt>float, double</tt></td>
580 </tr>
581 <tr>
582 <td><a name="t_firstclass">first class</a></td>
Misha Brukmanc24b7582004-08-12 20:16:08 +0000583 <td><tt>bool, ubyte, sbyte, ushort, short, uint, int, ulong, long,<br>
584 float, double, <a href="#t_pointer">pointer</a>,
585 <a href="#t_packed">packed</a></tt></td>
Chris Lattner261efe92003-11-25 01:02:51 +0000586 </tr>
587 </tbody>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000588</table>
Misha Brukmandaa4cb02004-03-01 17:47:27 +0000589
Chris Lattner261efe92003-11-25 01:02:51 +0000590<p>The <a href="#t_firstclass">first class</a> types are perhaps the
591most important. Values of these types are the only ones which can be
592produced by instructions, passed as arguments, or used as operands to
593instructions. This means that all structures and arrays must be
594manipulated either by pointer or by component.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000595</div>
Chris Lattnerc3f59762004-12-09 17:30:23 +0000596
Chris Lattner00950542001-06-06 20:29:01 +0000597<!-- ======================================================================= -->
Chris Lattner261efe92003-11-25 01:02:51 +0000598<div class="doc_subsection"> <a name="t_derived">Derived Types</a> </div>
Chris Lattnerc3f59762004-12-09 17:30:23 +0000599
Misha Brukman9d0919f2003-11-08 01:05:38 +0000600<div class="doc_text">
Chris Lattnerc3f59762004-12-09 17:30:23 +0000601
Chris Lattner261efe92003-11-25 01:02:51 +0000602<p>The real power in LLVM comes from the derived types in the system.
603This is what allows a programmer to represent arrays, functions,
604pointers, and other useful types. Note that these derived types may be
605recursive: For example, it is possible to have a two dimensional array.</p>
Chris Lattnerc3f59762004-12-09 17:30:23 +0000606
Misha Brukman9d0919f2003-11-08 01:05:38 +0000607</div>
Chris Lattnerc3f59762004-12-09 17:30:23 +0000608
Chris Lattner00950542001-06-06 20:29:01 +0000609<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000610<div class="doc_subsubsection"> <a name="t_array">Array Type</a> </div>
Chris Lattnerc3f59762004-12-09 17:30:23 +0000611
Misha Brukman9d0919f2003-11-08 01:05:38 +0000612<div class="doc_text">
Chris Lattnerc3f59762004-12-09 17:30:23 +0000613
Chris Lattner00950542001-06-06 20:29:01 +0000614<h5>Overview:</h5>
Chris Lattnerc3f59762004-12-09 17:30:23 +0000615
Misha Brukman9d0919f2003-11-08 01:05:38 +0000616<p>The array type is a very simple derived type that arranges elements
Chris Lattner261efe92003-11-25 01:02:51 +0000617sequentially in memory. The array type requires a size (number of
618elements) and an underlying data type.</p>
Chris Lattnerc3f59762004-12-09 17:30:23 +0000619
Chris Lattner7faa8832002-04-14 06:13:44 +0000620<h5>Syntax:</h5>
Chris Lattnerc3f59762004-12-09 17:30:23 +0000621
622<pre>
623 [&lt;# elements&gt; x &lt;elementtype&gt;]
624</pre>
625
Chris Lattner261efe92003-11-25 01:02:51 +0000626<p>The number of elements is a constant integer value, elementtype may
627be any type with a size.</p>
Chris Lattnerc3f59762004-12-09 17:30:23 +0000628
Chris Lattner7faa8832002-04-14 06:13:44 +0000629<h5>Examples:</h5>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000630<table class="layout">
631 <tr class="layout">
632 <td class="left">
633 <tt>[40 x int ]</tt><br/>
634 <tt>[41 x int ]</tt><br/>
635 <tt>[40 x uint]</tt><br/>
636 </td>
637 <td class="left">
638 Array of 40 integer values.<br/>
639 Array of 41 integer values.<br/>
640 Array of 40 unsigned integer values.<br/>
641 </td>
642 </tr>
Chris Lattner00950542001-06-06 20:29:01 +0000643</table>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000644<p>Here are some examples of multidimensional arrays:</p>
645<table class="layout">
646 <tr class="layout">
647 <td class="left">
648 <tt>[3 x [4 x int]]</tt><br/>
649 <tt>[12 x [10 x float]]</tt><br/>
650 <tt>[2 x [3 x [4 x uint]]]</tt><br/>
651 </td>
652 <td class="left">
653 3x4 array integer values.<br/>
654 12x10 array of single precision floating point values.<br/>
655 2x3x4 array of unsigned integer values.<br/>
656 </td>
657 </tr>
658</table>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000659</div>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000660
Chris Lattner00950542001-06-06 20:29:01 +0000661<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000662<div class="doc_subsubsection"> <a name="t_function">Function Type</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000663<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +0000664<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000665<p>The function type can be thought of as a function signature. It
666consists of a return type and a list of formal parameter types.
John Criswell009900b2003-11-25 21:45:46 +0000667Function types are usually used to build virtual function tables
Chris Lattner261efe92003-11-25 01:02:51 +0000668(which are structures of pointers to functions), for indirect function
669calls, and when defining a function.</p>
John Criswell009900b2003-11-25 21:45:46 +0000670<p>
671The return type of a function type cannot be an aggregate type.
672</p>
Chris Lattner00950542001-06-06 20:29:01 +0000673<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000674<pre> &lt;returntype&gt; (&lt;parameter list&gt;)<br></pre>
Misha Brukmanc24b7582004-08-12 20:16:08 +0000675<p>Where '<tt>&lt;parameter list&gt;</tt>' is a comma-separated list of type
676specifiers. Optionally, the parameter list may include a type <tt>...</tt>,
Chris Lattner27f71f22003-09-03 00:41:47 +0000677which indicates that the function takes a variable number of arguments.
678Variable argument functions can access their arguments with the <a
Chris Lattner261efe92003-11-25 01:02:51 +0000679 href="#int_varargs">variable argument handling intrinsic</a> functions.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000680<h5>Examples:</h5>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000681<table class="layout">
682 <tr class="layout">
683 <td class="left">
684 <tt>int (int)</tt> <br/>
685 <tt>float (int, int *) *</tt><br/>
686 <tt>int (sbyte *, ...)</tt><br/>
687 </td>
688 <td class="left">
689 function taking an <tt>int</tt>, returning an <tt>int</tt><br/>
690 <a href="#t_pointer">Pointer</a> to a function that takes an
Misha Brukmanc24b7582004-08-12 20:16:08 +0000691 <tt>int</tt> and a <a href="#t_pointer">pointer</a> to <tt>int</tt>,
Reid Spencerd3f876c2004-11-01 08:19:36 +0000692 returning <tt>float</tt>.<br/>
693 A vararg function that takes at least one <a href="#t_pointer">pointer</a>
694 to <tt>sbyte</tt> (signed char in C), which returns an integer. This is
695 the signature for <tt>printf</tt> in LLVM.<br/>
696 </td>
697 </tr>
Chris Lattner00950542001-06-06 20:29:01 +0000698</table>
Misha Brukmandaa4cb02004-03-01 17:47:27 +0000699
Misha Brukman9d0919f2003-11-08 01:05:38 +0000700</div>
Chris Lattner00950542001-06-06 20:29:01 +0000701<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000702<div class="doc_subsubsection"> <a name="t_struct">Structure Type</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000703<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +0000704<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000705<p>The structure type is used to represent a collection of data members
706together in memory. The packing of the field types is defined to match
707the ABI of the underlying processor. The elements of a structure may
708be any type that has a size.</p>
709<p>Structures are accessed using '<tt><a href="#i_load">load</a></tt>
710and '<tt><a href="#i_store">store</a></tt>' by getting a pointer to a
711field with the '<tt><a href="#i_getelementptr">getelementptr</a></tt>'
712instruction.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000713<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000714<pre> { &lt;type list&gt; }<br></pre>
Chris Lattner00950542001-06-06 20:29:01 +0000715<h5>Examples:</h5>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000716<table class="layout">
717 <tr class="layout">
718 <td class="left">
719 <tt>{ int, int, int }</tt><br/>
720 <tt>{ float, int (int) * }</tt><br/>
721 </td>
722 <td class="left">
723 a triple of three <tt>int</tt> values<br/>
724 A pair, where the first element is a <tt>float</tt> and the second element
725 is a <a href="#t_pointer">pointer</a> to a <a href="#t_function">function</a>
726 that takes an <tt>int</tt>, returning an <tt>int</tt>.<br/>
727 </td>
728 </tr>
Chris Lattner00950542001-06-06 20:29:01 +0000729</table>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000730</div>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000731
Chris Lattner00950542001-06-06 20:29:01 +0000732<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000733<div class="doc_subsubsection"> <a name="t_pointer">Pointer Type</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000734<div class="doc_text">
Chris Lattner7faa8832002-04-14 06:13:44 +0000735<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000736<p>As in many languages, the pointer type represents a pointer or
737reference to another object, which must live in memory.</p>
Chris Lattner7faa8832002-04-14 06:13:44 +0000738<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000739<pre> &lt;type&gt; *<br></pre>
Chris Lattner7faa8832002-04-14 06:13:44 +0000740<h5>Examples:</h5>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000741<table class="layout">
742 <tr class="layout">
743 <td class="left">
744 <tt>[4x int]*</tt><br/>
745 <tt>int (int *) *</tt><br/>
746 </td>
747 <td class="left">
748 A <a href="#t_pointer">pointer</a> to <a href="#t_array">array</a> of
749 four <tt>int</tt> values<br/>
750 A <a href="#t_pointer">pointer</a> to a <a
Chris Lattnera977c482005-02-19 02:22:14 +0000751 href="#t_function">function</a> that takes an <tt>int*</tt>, returning an
Reid Spencerd3f876c2004-11-01 08:19:36 +0000752 <tt>int</tt>.<br/>
753 </td>
754 </tr>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000755</table>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000756</div>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000757
Chris Lattnera58561b2004-08-12 19:12:28 +0000758<!-- _______________________________________________________________________ -->
759<div class="doc_subsubsection"> <a name="t_packed">Packed Type</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000760<div class="doc_text">
Chris Lattner69c11bb2005-04-25 17:34:15 +0000761
Chris Lattnera58561b2004-08-12 19:12:28 +0000762<h5>Overview:</h5>
Chris Lattner69c11bb2005-04-25 17:34:15 +0000763
Chris Lattnera58561b2004-08-12 19:12:28 +0000764<p>A packed type is a simple derived type that represents a vector
765of elements. Packed types are used when multiple primitive data
766are operated in parallel using a single instruction (SIMD).
767A packed type requires a size (number of
768elements) and an underlying primitive data type. Packed types are
769considered <a href="#t_firstclass">first class</a>.</p>
Chris Lattner69c11bb2005-04-25 17:34:15 +0000770
Chris Lattnera58561b2004-08-12 19:12:28 +0000771<h5>Syntax:</h5>
Chris Lattner69c11bb2005-04-25 17:34:15 +0000772
773<pre>
774 &lt; &lt;# elements&gt; x &lt;elementtype&gt; &gt;
775</pre>
776
Chris Lattnera58561b2004-08-12 19:12:28 +0000777<p>The number of elements is a constant integer value, elementtype may
778be any integral or floating point type.</p>
Chris Lattner69c11bb2005-04-25 17:34:15 +0000779
Chris Lattnera58561b2004-08-12 19:12:28 +0000780<h5>Examples:</h5>
Chris Lattner69c11bb2005-04-25 17:34:15 +0000781
Reid Spencerd3f876c2004-11-01 08:19:36 +0000782<table class="layout">
783 <tr class="layout">
784 <td class="left">
785 <tt>&lt;4 x int&gt;</tt><br/>
786 <tt>&lt;8 x float&gt;</tt><br/>
787 <tt>&lt;2 x uint&gt;</tt><br/>
788 </td>
789 <td class="left">
790 Packed vector of 4 integer values.<br/>
791 Packed vector of 8 floating-point values.<br/>
792 Packed vector of 2 unsigned integer values.<br/>
793 </td>
794 </tr>
795</table>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000796</div>
797
Chris Lattner69c11bb2005-04-25 17:34:15 +0000798<!-- _______________________________________________________________________ -->
799<div class="doc_subsubsection"> <a name="t_opaque">Opaque Type</a> </div>
800<div class="doc_text">
801
802<h5>Overview:</h5>
803
804<p>Opaque types are used to represent unknown types in the system. This
805corresponds (for example) to the C notion of a foward declared structure type.
806In LLVM, opaque types can eventually be resolved to any type (not just a
807structure type).</p>
808
809<h5>Syntax:</h5>
810
811<pre>
812 opaque
813</pre>
814
815<h5>Examples:</h5>
816
817<table class="layout">
818 <tr class="layout">
819 <td class="left">
820 <tt>opaque</tt>
821 </td>
822 <td class="left">
823 An opaque type.<br/>
824 </td>
825 </tr>
826</table>
827</div>
828
829
Chris Lattnerc3f59762004-12-09 17:30:23 +0000830<!-- *********************************************************************** -->
831<div class="doc_section"> <a name="constants">Constants</a> </div>
832<!-- *********************************************************************** -->
833
834<div class="doc_text">
835
836<p>LLVM has several different basic types of constants. This section describes
837them all and their syntax.</p>
838
839</div>
840
841<!-- ======================================================================= -->
Reid Spencercc16dc32004-12-09 18:02:53 +0000842<div class="doc_subsection"><a name="simpleconstants">Simple Constants</a></div>
Chris Lattnerc3f59762004-12-09 17:30:23 +0000843
844<div class="doc_text">
845
846<dl>
847 <dt><b>Boolean constants</b></dt>
848
849 <dd>The two strings '<tt>true</tt>' and '<tt>false</tt>' are both valid
850 constants of the <tt><a href="#t_primitive">bool</a></tt> type.
851 </dd>
852
853 <dt><b>Integer constants</b></dt>
854
Reid Spencercc16dc32004-12-09 18:02:53 +0000855 <dd>Standard integers (such as '4') are constants of the <a
Chris Lattnerc3f59762004-12-09 17:30:23 +0000856 href="#t_integer">integer</a> type. Negative numbers may be used with signed
857 integer types.
858 </dd>
859
860 <dt><b>Floating point constants</b></dt>
861
862 <dd>Floating point constants use standard decimal notation (e.g. 123.421),
863 exponential notation (e.g. 1.23421e+2), or a more precise hexadecimal
Reid Spencercc16dc32004-12-09 18:02:53 +0000864 notation. Floating point constants have an optional hexadecimal
Chris Lattnerc3f59762004-12-09 17:30:23 +0000865 notation (see below). Floating point constants must have a <a
866 href="#t_floating">floating point</a> type. </dd>
867
868 <dt><b>Null pointer constants</b></dt>
869
John Criswell9e2485c2004-12-10 15:51:16 +0000870 <dd>The identifier '<tt>null</tt>' is recognized as a null pointer constant
Chris Lattnerc3f59762004-12-09 17:30:23 +0000871 and must be of <a href="#t_pointer">pointer type</a>.</dd>
872
873</dl>
874
John Criswell9e2485c2004-12-10 15:51:16 +0000875<p>The one non-intuitive notation for constants is the optional hexadecimal form
Chris Lattnerc3f59762004-12-09 17:30:23 +0000876of floating point constants. For example, the form '<tt>double
8770x432ff973cafa8000</tt>' is equivalent to (but harder to read than) '<tt>double
8784.5e+15</tt>'. The only time hexadecimal floating point constants are required
Reid Spencercc16dc32004-12-09 18:02:53 +0000879(and the only time that they are generated by the disassembler) is when a
880floating point constant must be emitted but it cannot be represented as a
881decimal floating point number. For example, NaN's, infinities, and other
882special values are represented in their IEEE hexadecimal format so that
883assembly and disassembly do not cause any bits to change in the constants.</p>
Chris Lattnerc3f59762004-12-09 17:30:23 +0000884
885</div>
886
887<!-- ======================================================================= -->
888<div class="doc_subsection"><a name="aggregateconstants">Aggregate Constants</a>
889</div>
890
891<div class="doc_text">
Chris Lattnerd4f6b172005-03-07 22:13:59 +0000892<p>Aggregate constants arise from aggregation of simple constants
893and smaller aggregate constants.</p>
Chris Lattnerc3f59762004-12-09 17:30:23 +0000894
895<dl>
896 <dt><b>Structure constants</b></dt>
897
898 <dd>Structure constants are represented with notation similar to structure
899 type definitions (a comma separated list of elements, surrounded by braces
Chris Lattnerd4f6b172005-03-07 22:13:59 +0000900 (<tt>{}</tt>)). For example: "<tt>{ int 4, float 17.0, int* %G }</tt>",
901 where "<tt>%G</tt>" is declared as "<tt>%G = external global int</tt>". Structure constants
902 must have <a href="#t_struct">structure type</a>, and the number and
Chris Lattnerc3f59762004-12-09 17:30:23 +0000903 types of elements must match those specified by the type.
904 </dd>
905
906 <dt><b>Array constants</b></dt>
907
908 <dd>Array constants are represented with notation similar to array type
909 definitions (a comma separated list of elements, surrounded by square brackets
John Criswell9e2485c2004-12-10 15:51:16 +0000910 (<tt>[]</tt>)). For example: "<tt>[ int 42, int 11, int 74 ]</tt>". Array
Chris Lattnerc3f59762004-12-09 17:30:23 +0000911 constants must have <a href="#t_array">array type</a>, and the number and
912 types of elements must match those specified by the type.
913 </dd>
914
915 <dt><b>Packed constants</b></dt>
916
917 <dd>Packed constants are represented with notation similar to packed type
918 definitions (a comma separated list of elements, surrounded by
John Criswell9e2485c2004-12-10 15:51:16 +0000919 less-than/greater-than's (<tt>&lt;&gt;</tt>)). For example: "<tt>&lt; int 42,
Chris Lattnerc3f59762004-12-09 17:30:23 +0000920 int 11, int 74, int 100 &gt;</tt>". Packed constants must have <a
921 href="#t_packed">packed type</a>, and the number and types of elements must
922 match those specified by the type.
923 </dd>
924
925 <dt><b>Zero initialization</b></dt>
926
927 <dd>The string '<tt>zeroinitializer</tt>' can be used to zero initialize a
928 value to zero of <em>any</em> type, including scalar and aggregate types.
929 This is often used to avoid having to print large zero initializers (e.g. for
930 large arrays), and is always exactly equivalent to using explicit zero
931 initializers.
932 </dd>
933</dl>
934
935</div>
936
937<!-- ======================================================================= -->
938<div class="doc_subsection">
939 <a name="globalconstants">Global Variable and Function Addresses</a>
940</div>
941
942<div class="doc_text">
943
944<p>The addresses of <a href="#globalvars">global variables</a> and <a
945href="#functionstructure">functions</a> are always implicitly valid (link-time)
John Criswell9e2485c2004-12-10 15:51:16 +0000946constants. These constants are explicitly referenced when the <a
947href="#identifiers">identifier for the global</a> is used and always have <a
Chris Lattnerc3f59762004-12-09 17:30:23 +0000948href="#t_pointer">pointer</a> type. For example, the following is a legal LLVM
949file:</p>
950
951<pre>
952 %X = global int 17
953 %Y = global int 42
954 %Z = global [2 x int*] [ int* %X, int* %Y ]
955</pre>
956
957</div>
958
959<!-- ======================================================================= -->
Reid Spencer2dc45b82004-12-09 18:13:12 +0000960<div class="doc_subsection"><a name="undefvalues">Undefined Values</a></div>
Chris Lattnerc3f59762004-12-09 17:30:23 +0000961<div class="doc_text">
Reid Spencer2dc45b82004-12-09 18:13:12 +0000962 <p>The string '<tt>undef</tt>' is recognized as a type-less constant that has
963 no specific value. Undefined values may be of any type, and be used anywhere
964 a constant is permitted.</p>
Chris Lattnerc3f59762004-12-09 17:30:23 +0000965
Reid Spencer2dc45b82004-12-09 18:13:12 +0000966 <p>Undefined values indicate to the compiler that the program is well defined
967 no matter what value is used, giving the compiler more freedom to optimize.
968 </p>
Chris Lattnerc3f59762004-12-09 17:30:23 +0000969</div>
970
971<!-- ======================================================================= -->
972<div class="doc_subsection"><a name="constantexprs">Constant Expressions</a>
973</div>
974
975<div class="doc_text">
976
977<p>Constant expressions are used to allow expressions involving other constants
978to be used as constants. Constant expressions may be of any <a
979href="#t_firstclass">first class</a> type, and may involve any LLVM operation
980that does not have side effects (e.g. load and call are not supported). The
981following is the syntax for constant expressions:</p>
982
983<dl>
984 <dt><b><tt>cast ( CST to TYPE )</tt></b></dt>
985
986 <dd>Cast a constant to another type.</dd>
987
988 <dt><b><tt>getelementptr ( CSTPTR, IDX0, IDX1, ... )</tt></b></dt>
989
990 <dd>Perform the <a href="#i_getelementptr">getelementptr operation</a> on
991 constants. As with the <a href="#i_getelementptr">getelementptr</a>
992 instruction, the index list may have zero or more indexes, which are required
993 to make sense for the type of "CSTPTR".</dd>
994
995 <dt><b><tt>OPCODE ( LHS, RHS )</tt></b></dt>
996
Reid Spencer2dc45b82004-12-09 18:13:12 +0000997 <dd>Perform the specified operation of the LHS and RHS constants. OPCODE may
998 be any of the <a href="#binaryops">binary</a> or <a href="#bitwiseops">bitwise
Chris Lattnerc3f59762004-12-09 17:30:23 +0000999 binary</a> operations. The constraints on operands are the same as those for
1000 the corresponding instruction (e.g. no bitwise operations on floating point
1001 are allowed).</dd>
Chris Lattnerc3f59762004-12-09 17:30:23 +00001002</dl>
Chris Lattnerc3f59762004-12-09 17:30:23 +00001003</div>
Chris Lattner9ee5d222004-03-08 16:49:10 +00001004
Chris Lattner00950542001-06-06 20:29:01 +00001005<!-- *********************************************************************** -->
Chris Lattner261efe92003-11-25 01:02:51 +00001006<div class="doc_section"> <a name="instref">Instruction Reference</a> </div>
1007<!-- *********************************************************************** -->
Chris Lattnerc3f59762004-12-09 17:30:23 +00001008
Misha Brukman9d0919f2003-11-08 01:05:38 +00001009<div class="doc_text">
Chris Lattnerc3f59762004-12-09 17:30:23 +00001010
Chris Lattner261efe92003-11-25 01:02:51 +00001011<p>The LLVM instruction set consists of several different
1012classifications of instructions: <a href="#terminators">terminator
1013instructions</a>, <a href="#binaryops">binary instructions</a>, <a
1014 href="#memoryops">memory instructions</a>, and <a href="#otherops">other
1015instructions</a>.</p>
Chris Lattnerc3f59762004-12-09 17:30:23 +00001016
Misha Brukman9d0919f2003-11-08 01:05:38 +00001017</div>
Chris Lattnerc3f59762004-12-09 17:30:23 +00001018
Chris Lattner00950542001-06-06 20:29:01 +00001019<!-- ======================================================================= -->
Chris Lattner261efe92003-11-25 01:02:51 +00001020<div class="doc_subsection"> <a name="terminators">Terminator
1021Instructions</a> </div>
Chris Lattnerc3f59762004-12-09 17:30:23 +00001022
Misha Brukman9d0919f2003-11-08 01:05:38 +00001023<div class="doc_text">
Chris Lattnerc3f59762004-12-09 17:30:23 +00001024
Chris Lattner261efe92003-11-25 01:02:51 +00001025<p>As mentioned <a href="#functionstructure">previously</a>, every
1026basic block in a program ends with a "Terminator" instruction, which
1027indicates which block should be executed after the current block is
1028finished. These terminator instructions typically yield a '<tt>void</tt>'
1029value: they produce control flow, not values (the one exception being
1030the '<a href="#i_invoke"><tt>invoke</tt></a>' instruction).</p>
John Criswell9e2485c2004-12-10 15:51:16 +00001031<p>There are six different terminator instructions: the '<a
Chris Lattner261efe92003-11-25 01:02:51 +00001032 href="#i_ret"><tt>ret</tt></a>' instruction, the '<a href="#i_br"><tt>br</tt></a>'
1033instruction, the '<a href="#i_switch"><tt>switch</tt></a>' instruction,
Chris Lattner35eca582004-10-16 18:04:13 +00001034the '<a href="#i_invoke"><tt>invoke</tt></a>' instruction, the '<a
1035 href="#i_unwind"><tt>unwind</tt></a>' instruction, and the '<a
1036 href="#i_unreachable"><tt>unreachable</tt></a>' instruction.</p>
Chris Lattnerc3f59762004-12-09 17:30:23 +00001037
Misha Brukman9d0919f2003-11-08 01:05:38 +00001038</div>
Chris Lattnerc3f59762004-12-09 17:30:23 +00001039
Chris Lattner00950542001-06-06 20:29:01 +00001040<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001041<div class="doc_subsubsection"> <a name="i_ret">'<tt>ret</tt>'
1042Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001043<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001044<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001045<pre> ret &lt;type&gt; &lt;value&gt; <i>; Return a value from a non-void function</i>
Chris Lattner7faa8832002-04-14 06:13:44 +00001046 ret void <i>; Return from void function</i>
Chris Lattner00950542001-06-06 20:29:01 +00001047</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001048<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001049<p>The '<tt>ret</tt>' instruction is used to return control flow (and a
1050value) from a function, back to the caller.</p>
John Criswell4457dc92004-04-09 16:48:45 +00001051<p>There are two forms of the '<tt>ret</tt>' instruction: one that
Chris Lattner261efe92003-11-25 01:02:51 +00001052returns a value and then causes control flow, and one that just causes
1053control flow to occur.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001054<h5>Arguments:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001055<p>The '<tt>ret</tt>' instruction may return any '<a
1056 href="#t_firstclass">first class</a>' type. Notice that a function is
1057not <a href="#wellformed">well formed</a> if there exists a '<tt>ret</tt>'
1058instruction inside of the function that returns a value that does not
1059match the return type of the function.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001060<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001061<p>When the '<tt>ret</tt>' instruction is executed, control flow
1062returns back to the calling function's context. If the caller is a "<a
John Criswellfa081872004-06-25 15:16:57 +00001063 href="#i_call"><tt>call</tt></a>" instruction, execution continues at
Chris Lattner261efe92003-11-25 01:02:51 +00001064the instruction after the call. If the caller was an "<a
1065 href="#i_invoke"><tt>invoke</tt></a>" instruction, execution continues
1066at the beginning "normal" of the destination block. If the instruction
1067returns a value, that value shall set the call or invoke instruction's
1068return value.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001069<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001070<pre> ret int 5 <i>; Return an integer value of 5</i>
Chris Lattner7faa8832002-04-14 06:13:44 +00001071 ret void <i>; Return from a void function</i>
Chris Lattner00950542001-06-06 20:29:01 +00001072</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001073</div>
Chris Lattner00950542001-06-06 20:29:01 +00001074<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001075<div class="doc_subsubsection"> <a name="i_br">'<tt>br</tt>' Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001076<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001077<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001078<pre> br bool &lt;cond&gt;, label &lt;iftrue&gt;, label &lt;iffalse&gt;<br> br label &lt;dest&gt; <i>; Unconditional branch</i>
Chris Lattner00950542001-06-06 20:29:01 +00001079</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001080<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001081<p>The '<tt>br</tt>' instruction is used to cause control flow to
1082transfer to a different basic block in the current function. There are
1083two forms of this instruction, corresponding to a conditional branch
1084and an unconditional branch.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001085<h5>Arguments:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001086<p>The conditional branch form of the '<tt>br</tt>' instruction takes a
1087single '<tt>bool</tt>' value and two '<tt>label</tt>' values. The
1088unconditional form of the '<tt>br</tt>' instruction takes a single '<tt>label</tt>'
1089value as a target.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001090<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001091<p>Upon execution of a conditional '<tt>br</tt>' instruction, the '<tt>bool</tt>'
1092argument is evaluated. If the value is <tt>true</tt>, control flows
1093to the '<tt>iftrue</tt>' <tt>label</tt> argument. If "cond" is <tt>false</tt>,
1094control flows to the '<tt>iffalse</tt>' <tt>label</tt> argument.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001095<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001096<pre>Test:<br> %cond = <a href="#i_setcc">seteq</a> int %a, %b<br> br bool %cond, label %IfEqual, label %IfUnequal<br>IfEqual:<br> <a
1097 href="#i_ret">ret</a> int 1<br>IfUnequal:<br> <a href="#i_ret">ret</a> int 0<br></pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001098</div>
Chris Lattner00950542001-06-06 20:29:01 +00001099<!-- _______________________________________________________________________ -->
Chris Lattnerc88c17b2004-02-24 04:54:45 +00001100<div class="doc_subsubsection">
1101 <a name="i_switch">'<tt>switch</tt>' Instruction</a>
1102</div>
1103
Misha Brukman9d0919f2003-11-08 01:05:38 +00001104<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001105<h5>Syntax:</h5>
Chris Lattnerc88c17b2004-02-24 04:54:45 +00001106
1107<pre>
1108 switch &lt;intty&gt; &lt;value&gt;, label &lt;defaultdest&gt; [ &lt;intty&gt; &lt;val&gt;, label &lt;dest&gt; ... ]
1109</pre>
1110
Chris Lattner00950542001-06-06 20:29:01 +00001111<h5>Overview:</h5>
Chris Lattnerc88c17b2004-02-24 04:54:45 +00001112
1113<p>The '<tt>switch</tt>' instruction is used to transfer control flow to one of
1114several different places. It is a generalization of the '<tt>br</tt>'
Misha Brukman9d0919f2003-11-08 01:05:38 +00001115instruction, allowing a branch to occur to one of many possible
1116destinations.</p>
Chris Lattnerc88c17b2004-02-24 04:54:45 +00001117
1118
Chris Lattner00950542001-06-06 20:29:01 +00001119<h5>Arguments:</h5>
Chris Lattnerc88c17b2004-02-24 04:54:45 +00001120
1121<p>The '<tt>switch</tt>' instruction uses three parameters: an integer
1122comparison value '<tt>value</tt>', a default '<tt>label</tt>' destination, and
1123an array of pairs of comparison value constants and '<tt>label</tt>'s. The
1124table is not allowed to contain duplicate constant entries.</p>
1125
Chris Lattner00950542001-06-06 20:29:01 +00001126<h5>Semantics:</h5>
Chris Lattnerc88c17b2004-02-24 04:54:45 +00001127
Chris Lattner261efe92003-11-25 01:02:51 +00001128<p>The <tt>switch</tt> instruction specifies a table of values and
1129destinations. When the '<tt>switch</tt>' instruction is executed, this
John Criswell84114752004-06-25 16:05:06 +00001130table is searched for the given value. If the value is found, control flow is
1131transfered to the corresponding destination; otherwise, control flow is
1132transfered to the default destination.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001133
Chris Lattnerc88c17b2004-02-24 04:54:45 +00001134<h5>Implementation:</h5>
1135
1136<p>Depending on properties of the target machine and the particular
1137<tt>switch</tt> instruction, this instruction may be code generated in different
John Criswell84114752004-06-25 16:05:06 +00001138ways. For example, it could be generated as a series of chained conditional
1139branches or with a lookup table.</p>
Chris Lattnerc88c17b2004-02-24 04:54:45 +00001140
1141<h5>Example:</h5>
1142
1143<pre>
1144 <i>; Emulate a conditional br instruction</i>
1145 %Val = <a href="#i_cast">cast</a> bool %value to int
1146 switch int %Val, label %truedest [int 0, label %falsedest ]
1147
1148 <i>; Emulate an unconditional br instruction</i>
1149 switch uint 0, label %dest [ ]
1150
1151 <i>; Implement a jump table:</i>
1152 switch uint %val, label %otherwise [ uint 0, label %onzero
1153 uint 1, label %onone
1154 uint 2, label %ontwo ]
Chris Lattner00950542001-06-06 20:29:01 +00001155</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001156</div>
Chris Lattner00950542001-06-06 20:29:01 +00001157<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001158<div class="doc_subsubsection"> <a name="i_invoke">'<tt>invoke</tt>'
1159Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001160<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001161<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001162<pre> &lt;result&gt; = invoke &lt;ptr to function ty&gt; %&lt;function ptr val&gt;(&lt;function args&gt;)<br> to label &lt;normal label&gt; except label &lt;exception label&gt;<br></pre>
Chris Lattner6536cfe2002-05-06 22:08:29 +00001163<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001164<p>The '<tt>invoke</tt>' instruction causes control to transfer to a
1165specified function, with the possibility of control flow transfer to
1166either the '<tt>normal</tt>' <tt>label</tt> label or the '<tt>exception</tt>'<tt>label</tt>.
1167If the callee function returns with the "<tt><a href="#i_ret">ret</a></tt>"
1168instruction, control flow will return to the "normal" label. If the
1169callee (or any indirect callees) returns with the "<a href="#i_unwind"><tt>unwind</tt></a>"
1170instruction, control is interrupted, and continued at the dynamically
1171nearest "except" label.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001172<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001173<p>This instruction requires several arguments:</p>
Chris Lattner00950542001-06-06 20:29:01 +00001174<ol>
Chris Lattner261efe92003-11-25 01:02:51 +00001175 <li>'<tt>ptr to function ty</tt>': shall be the signature of the
1176pointer to function value being invoked. In most cases, this is a
1177direct function invocation, but indirect <tt>invoke</tt>s are just as
1178possible, branching off an arbitrary pointer to function value. </li>
1179 <li>'<tt>function ptr val</tt>': An LLVM value containing a pointer
1180to a function to be invoked. </li>
1181 <li>'<tt>function args</tt>': argument list whose types match the
1182function signature argument types. If the function signature indicates
1183the function accepts a variable number of arguments, the extra
1184arguments can be specified. </li>
1185 <li>'<tt>normal label</tt>': the label reached when the called
1186function executes a '<tt><a href="#i_ret">ret</a></tt>' instruction. </li>
1187 <li>'<tt>exception label</tt>': the label reached when a callee
1188returns with the <a href="#i_unwind"><tt>unwind</tt></a> instruction. </li>
Chris Lattner00950542001-06-06 20:29:01 +00001189</ol>
Chris Lattner00950542001-06-06 20:29:01 +00001190<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001191<p>This instruction is designed to operate as a standard '<tt><a
Chris Lattner261efe92003-11-25 01:02:51 +00001192 href="#i_call">call</a></tt>' instruction in most regards. The
1193primary difference is that it establishes an association with a label,
1194which is used by the runtime library to unwind the stack.</p>
1195<p>This instruction is used in languages with destructors to ensure
1196that proper cleanup is performed in the case of either a <tt>longjmp</tt>
1197or a thrown exception. Additionally, this is important for
1198implementation of '<tt>catch</tt>' clauses in high-level languages that
1199support them.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001200<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001201<pre> %retval = invoke int %Test(int 15)<br> to label %Continue<br> except label %TestCleanup <i>; {int}:retval set</i>
Chris Lattner00950542001-06-06 20:29:01 +00001202</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001203</div>
Chris Lattner35eca582004-10-16 18:04:13 +00001204
1205
Chris Lattner27f71f22003-09-03 00:41:47 +00001206<!-- _______________________________________________________________________ -->
Chris Lattner35eca582004-10-16 18:04:13 +00001207
Chris Lattner261efe92003-11-25 01:02:51 +00001208<div class="doc_subsubsection"> <a name="i_unwind">'<tt>unwind</tt>'
1209Instruction</a> </div>
Chris Lattner35eca582004-10-16 18:04:13 +00001210
Misha Brukman9d0919f2003-11-08 01:05:38 +00001211<div class="doc_text">
Chris Lattner35eca582004-10-16 18:04:13 +00001212
Chris Lattner27f71f22003-09-03 00:41:47 +00001213<h5>Syntax:</h5>
Chris Lattner35eca582004-10-16 18:04:13 +00001214<pre>
1215 unwind
1216</pre>
1217
Chris Lattner27f71f22003-09-03 00:41:47 +00001218<h5>Overview:</h5>
Chris Lattner35eca582004-10-16 18:04:13 +00001219
1220<p>The '<tt>unwind</tt>' instruction unwinds the stack, continuing control flow
1221at the first callee in the dynamic call stack which used an <a
1222href="#i_invoke"><tt>invoke</tt></a> instruction to perform the call. This is
1223primarily used to implement exception handling.</p>
1224
Chris Lattner27f71f22003-09-03 00:41:47 +00001225<h5>Semantics:</h5>
Chris Lattner35eca582004-10-16 18:04:13 +00001226
1227<p>The '<tt>unwind</tt>' intrinsic causes execution of the current function to
1228immediately halt. The dynamic call stack is then searched for the first <a
1229href="#i_invoke"><tt>invoke</tt></a> instruction on the call stack. Once found,
1230execution continues at the "exceptional" destination block specified by the
1231<tt>invoke</tt> instruction. If there is no <tt>invoke</tt> instruction in the
1232dynamic call chain, undefined behavior results.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001233</div>
Chris Lattner35eca582004-10-16 18:04:13 +00001234
1235<!-- _______________________________________________________________________ -->
1236
1237<div class="doc_subsubsection"> <a name="i_unreachable">'<tt>unreachable</tt>'
1238Instruction</a> </div>
1239
1240<div class="doc_text">
1241
1242<h5>Syntax:</h5>
1243<pre>
1244 unreachable
1245</pre>
1246
1247<h5>Overview:</h5>
1248
1249<p>The '<tt>unreachable</tt>' instruction has no defined semantics. This
1250instruction is used to inform the optimizer that a particular portion of the
1251code is not reachable. This can be used to indicate that the code after a
1252no-return function cannot be reached, and other facts.</p>
1253
1254<h5>Semantics:</h5>
1255
1256<p>The '<tt>unreachable</tt>' instruction has no defined semantics.</p>
1257</div>
1258
1259
1260
Chris Lattner00950542001-06-06 20:29:01 +00001261<!-- ======================================================================= -->
Chris Lattner261efe92003-11-25 01:02:51 +00001262<div class="doc_subsection"> <a name="binaryops">Binary Operations</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001263<div class="doc_text">
Chris Lattner261efe92003-11-25 01:02:51 +00001264<p>Binary operators are used to do most of the computation in a
1265program. They require two operands, execute an operation on them, and
John Criswell9e2485c2004-12-10 15:51:16 +00001266produce a single value. The operands might represent
Chris Lattnera58561b2004-08-12 19:12:28 +00001267multiple data, as is the case with the <a href="#t_packed">packed</a> data type.
1268The result value of a binary operator is not
Chris Lattner261efe92003-11-25 01:02:51 +00001269necessarily the same type as its operands.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001270<p>There are several different binary operators:</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001271</div>
Chris Lattner00950542001-06-06 20:29:01 +00001272<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001273<div class="doc_subsubsection"> <a name="i_add">'<tt>add</tt>'
1274Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001275<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001276<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001277<pre> &lt;result&gt; = add &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
Chris Lattner00950542001-06-06 20:29:01 +00001278</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001279<h5>Overview:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001280<p>The '<tt>add</tt>' instruction returns the sum of its two operands.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001281<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001282<p>The two arguments to the '<tt>add</tt>' instruction must be either <a
Chris Lattnera58561b2004-08-12 19:12:28 +00001283 href="#t_integer">integer</a> or <a href="#t_floating">floating point</a> values.
1284 This instruction can also take <a href="#t_packed">packed</a> versions of the values.
1285Both arguments must have identical types.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001286<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001287<p>The value produced is the integer or floating point sum of the two
1288operands.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001289<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001290<pre> &lt;result&gt; = add int 4, %var <i>; yields {int}:result = 4 + %var</i>
Chris Lattner00950542001-06-06 20:29:01 +00001291</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001292</div>
Chris Lattner00950542001-06-06 20:29:01 +00001293<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001294<div class="doc_subsubsection"> <a name="i_sub">'<tt>sub</tt>'
1295Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001296<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001297<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001298<pre> &lt;result&gt; = sub &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
Chris Lattner00950542001-06-06 20:29:01 +00001299</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001300<h5>Overview:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001301<p>The '<tt>sub</tt>' instruction returns the difference of its two
1302operands.</p>
Chris Lattner261efe92003-11-25 01:02:51 +00001303<p>Note that the '<tt>sub</tt>' instruction is used to represent the '<tt>neg</tt>'
1304instruction present in most other intermediate representations.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001305<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001306<p>The two arguments to the '<tt>sub</tt>' instruction must be either <a
Chris Lattner261efe92003-11-25 01:02:51 +00001307 href="#t_integer">integer</a> or <a href="#t_floating">floating point</a>
Chris Lattnera58561b2004-08-12 19:12:28 +00001308values.
1309This instruction can also take <a href="#t_packed">packed</a> versions of the values.
1310Both arguments must have identical types.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001311<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001312<p>The value produced is the integer or floating point difference of
1313the two operands.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001314<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001315<pre> &lt;result&gt; = sub int 4, %var <i>; yields {int}:result = 4 - %var</i>
Chris Lattner00950542001-06-06 20:29:01 +00001316 &lt;result&gt; = sub int 0, %val <i>; yields {int}:result = -%var</i>
1317</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001318</div>
Chris Lattner00950542001-06-06 20:29:01 +00001319<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001320<div class="doc_subsubsection"> <a name="i_mul">'<tt>mul</tt>'
1321Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001322<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001323<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001324<pre> &lt;result&gt; = mul &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
Chris Lattner00950542001-06-06 20:29:01 +00001325</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001326<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001327<p>The '<tt>mul</tt>' instruction returns the product of its two
1328operands.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001329<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001330<p>The two arguments to the '<tt>mul</tt>' instruction must be either <a
Chris Lattner261efe92003-11-25 01:02:51 +00001331 href="#t_integer">integer</a> or <a href="#t_floating">floating point</a>
Chris Lattnera58561b2004-08-12 19:12:28 +00001332values.
1333This instruction can also take <a href="#t_packed">packed</a> versions of the values.
1334Both arguments must have identical types.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001335<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001336<p>The value produced is the integer or floating point product of the
Misha Brukman9d0919f2003-11-08 01:05:38 +00001337two operands.</p>
Chris Lattner261efe92003-11-25 01:02:51 +00001338<p>There is no signed vs unsigned multiplication. The appropriate
1339action is taken based on the type of the operand.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001340<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001341<pre> &lt;result&gt; = mul int 4, %var <i>; yields {int}:result = 4 * %var</i>
Chris Lattner00950542001-06-06 20:29:01 +00001342</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001343</div>
Chris Lattner00950542001-06-06 20:29:01 +00001344<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001345<div class="doc_subsubsection"> <a name="i_div">'<tt>div</tt>'
1346Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001347<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001348<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001349<pre> &lt;result&gt; = div &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
1350</pre>
1351<h5>Overview:</h5>
1352<p>The '<tt>div</tt>' instruction returns the quotient of its two
1353operands.</p>
1354<h5>Arguments:</h5>
1355<p>The two arguments to the '<tt>div</tt>' instruction must be either <a
1356 href="#t_integer">integer</a> or <a href="#t_floating">floating point</a>
Chris Lattnera58561b2004-08-12 19:12:28 +00001357values.
1358This instruction can also take <a href="#t_packed">packed</a> versions of the values.
1359Both arguments must have identical types.</p>
Chris Lattner261efe92003-11-25 01:02:51 +00001360<h5>Semantics:</h5>
1361<p>The value produced is the integer or floating point quotient of the
1362two operands.</p>
1363<h5>Example:</h5>
1364<pre> &lt;result&gt; = div int 4, %var <i>; yields {int}:result = 4 / %var</i>
1365</pre>
1366</div>
1367<!-- _______________________________________________________________________ -->
1368<div class="doc_subsubsection"> <a name="i_rem">'<tt>rem</tt>'
1369Instruction</a> </div>
1370<div class="doc_text">
1371<h5>Syntax:</h5>
1372<pre> &lt;result&gt; = rem &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
1373</pre>
1374<h5>Overview:</h5>
1375<p>The '<tt>rem</tt>' instruction returns the remainder from the
1376division of its two operands.</p>
1377<h5>Arguments:</h5>
1378<p>The two arguments to the '<tt>rem</tt>' instruction must be either <a
1379 href="#t_integer">integer</a> or <a href="#t_floating">floating point</a>
Chris Lattnera58561b2004-08-12 19:12:28 +00001380values.
1381This instruction can also take <a href="#t_packed">packed</a> versions of the values.
1382Both arguments must have identical types.</p>
Chris Lattner261efe92003-11-25 01:02:51 +00001383<h5>Semantics:</h5>
1384<p>This returns the <i>remainder</i> of a division (where the result
1385has the same sign as the divisor), not the <i>modulus</i> (where the
1386result has the same sign as the dividend) of a value. For more
1387information about the difference, see: <a
1388 href="http://mathforum.org/dr.math/problems/anne.4.28.99.html">The
1389Math Forum</a>.</p>
1390<h5>Example:</h5>
1391<pre> &lt;result&gt; = rem int 4, %var <i>; yields {int}:result = 4 % %var</i>
1392</pre>
1393</div>
1394<!-- _______________________________________________________________________ -->
1395<div class="doc_subsubsection"> <a name="i_setcc">'<tt>set<i>cc</i></tt>'
1396Instructions</a> </div>
1397<div class="doc_text">
1398<h5>Syntax:</h5>
1399<pre> &lt;result&gt; = seteq &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {bool}:result</i>
Chris Lattner00950542001-06-06 20:29:01 +00001400 &lt;result&gt; = setne &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {bool}:result</i>
1401 &lt;result&gt; = setlt &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {bool}:result</i>
1402 &lt;result&gt; = setgt &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {bool}:result</i>
1403 &lt;result&gt; = setle &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {bool}:result</i>
1404 &lt;result&gt; = setge &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {bool}:result</i>
1405</pre>
Chris Lattner261efe92003-11-25 01:02:51 +00001406<h5>Overview:</h5>
1407<p>The '<tt>set<i>cc</i></tt>' family of instructions returns a boolean
1408value based on a comparison of their two operands.</p>
1409<h5>Arguments:</h5>
1410<p>The two arguments to the '<tt>set<i>cc</i></tt>' instructions must
1411be of <a href="#t_firstclass">first class</a> type (it is not possible
1412to compare '<tt>label</tt>'s, '<tt>array</tt>'s, '<tt>structure</tt>'
1413or '<tt>void</tt>' values, etc...). Both arguments must have identical
1414types.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001415<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001416<p>The '<tt>seteq</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>'
1417value if both operands are equal.<br>
1418The '<tt>setne</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>'
1419value if both operands are unequal.<br>
1420The '<tt>setlt</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>'
1421value if the first operand is less than the second operand.<br>
1422The '<tt>setgt</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>'
1423value if the first operand is greater than the second operand.<br>
1424The '<tt>setle</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>'
1425value if the first operand is less than or equal to the second operand.<br>
1426The '<tt>setge</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>'
1427value if the first operand is greater than or equal to the second
1428operand.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001429<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001430<pre> &lt;result&gt; = seteq int 4, 5 <i>; yields {bool}:result = false</i>
Chris Lattner00950542001-06-06 20:29:01 +00001431 &lt;result&gt; = setne float 4, 5 <i>; yields {bool}:result = true</i>
1432 &lt;result&gt; = setlt uint 4, 5 <i>; yields {bool}:result = true</i>
1433 &lt;result&gt; = setgt sbyte 4, 5 <i>; yields {bool}:result = false</i>
1434 &lt;result&gt; = setle sbyte 4, 5 <i>; yields {bool}:result = true</i>
1435 &lt;result&gt; = setge sbyte 4, 5 <i>; yields {bool}:result = false</i>
1436</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001437</div>
Chris Lattner00950542001-06-06 20:29:01 +00001438<!-- ======================================================================= -->
Chris Lattner261efe92003-11-25 01:02:51 +00001439<div class="doc_subsection"> <a name="bitwiseops">Bitwise Binary
1440Operations</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001441<div class="doc_text">
Chris Lattner261efe92003-11-25 01:02:51 +00001442<p>Bitwise binary operators are used to do various forms of
1443bit-twiddling in a program. They are generally very efficient
John Criswell9e2485c2004-12-10 15:51:16 +00001444instructions and can commonly be strength reduced from other
Chris Lattner261efe92003-11-25 01:02:51 +00001445instructions. They require two operands, execute an operation on them,
1446and produce a single value. The resulting value of the bitwise binary
1447operators is always the same type as its first operand.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001448</div>
Chris Lattner00950542001-06-06 20:29:01 +00001449<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001450<div class="doc_subsubsection"> <a name="i_and">'<tt>and</tt>'
1451Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001452<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001453<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001454<pre> &lt;result&gt; = and &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
Chris Lattner00950542001-06-06 20:29:01 +00001455</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001456<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001457<p>The '<tt>and</tt>' instruction returns the bitwise logical and of
1458its two operands.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001459<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001460<p>The two arguments to the '<tt>and</tt>' instruction must be <a
Chris Lattner261efe92003-11-25 01:02:51 +00001461 href="#t_integral">integral</a> values. Both arguments must have
1462identical types.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001463<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001464<p>The truth table used for the '<tt>and</tt>' instruction is:</p>
Chris Lattner261efe92003-11-25 01:02:51 +00001465<p> </p>
Misha Brukmandaa4cb02004-03-01 17:47:27 +00001466<div style="align: center">
Misha Brukman9d0919f2003-11-08 01:05:38 +00001467<table border="1" cellspacing="0" cellpadding="4">
Chris Lattner261efe92003-11-25 01:02:51 +00001468 <tbody>
1469 <tr>
1470 <td>In0</td>
1471 <td>In1</td>
1472 <td>Out</td>
1473 </tr>
1474 <tr>
1475 <td>0</td>
1476 <td>0</td>
1477 <td>0</td>
1478 </tr>
1479 <tr>
1480 <td>0</td>
1481 <td>1</td>
1482 <td>0</td>
1483 </tr>
1484 <tr>
1485 <td>1</td>
1486 <td>0</td>
1487 <td>0</td>
1488 </tr>
1489 <tr>
1490 <td>1</td>
1491 <td>1</td>
1492 <td>1</td>
1493 </tr>
1494 </tbody>
1495</table>
Misha Brukmandaa4cb02004-03-01 17:47:27 +00001496</div>
Chris Lattner00950542001-06-06 20:29:01 +00001497<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001498<pre> &lt;result&gt; = and int 4, %var <i>; yields {int}:result = 4 &amp; %var</i>
Chris Lattner00950542001-06-06 20:29:01 +00001499 &lt;result&gt; = and int 15, 40 <i>; yields {int}:result = 8</i>
1500 &lt;result&gt; = and int 4, 8 <i>; yields {int}:result = 0</i>
1501</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001502</div>
Chris Lattner00950542001-06-06 20:29:01 +00001503<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001504<div class="doc_subsubsection"> <a name="i_or">'<tt>or</tt>' Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001505<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001506<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001507<pre> &lt;result&gt; = or &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
Chris Lattner00950542001-06-06 20:29:01 +00001508</pre>
Chris Lattner261efe92003-11-25 01:02:51 +00001509<h5>Overview:</h5>
1510<p>The '<tt>or</tt>' instruction returns the bitwise logical inclusive
1511or of its two operands.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001512<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001513<p>The two arguments to the '<tt>or</tt>' instruction must be <a
Chris Lattner261efe92003-11-25 01:02:51 +00001514 href="#t_integral">integral</a> values. Both arguments must have
1515identical types.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001516<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001517<p>The truth table used for the '<tt>or</tt>' instruction is:</p>
Chris Lattner261efe92003-11-25 01:02:51 +00001518<p> </p>
Misha Brukmandaa4cb02004-03-01 17:47:27 +00001519<div style="align: center">
Chris Lattner261efe92003-11-25 01:02:51 +00001520<table border="1" cellspacing="0" cellpadding="4">
1521 <tbody>
1522 <tr>
1523 <td>In0</td>
1524 <td>In1</td>
1525 <td>Out</td>
1526 </tr>
1527 <tr>
1528 <td>0</td>
1529 <td>0</td>
1530 <td>0</td>
1531 </tr>
1532 <tr>
1533 <td>0</td>
1534 <td>1</td>
1535 <td>1</td>
1536 </tr>
1537 <tr>
1538 <td>1</td>
1539 <td>0</td>
1540 <td>1</td>
1541 </tr>
1542 <tr>
1543 <td>1</td>
1544 <td>1</td>
1545 <td>1</td>
1546 </tr>
1547 </tbody>
1548</table>
Misha Brukmandaa4cb02004-03-01 17:47:27 +00001549</div>
Chris Lattner00950542001-06-06 20:29:01 +00001550<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001551<pre> &lt;result&gt; = or int 4, %var <i>; yields {int}:result = 4 | %var</i>
Chris Lattner00950542001-06-06 20:29:01 +00001552 &lt;result&gt; = or int 15, 40 <i>; yields {int}:result = 47</i>
1553 &lt;result&gt; = or int 4, 8 <i>; yields {int}:result = 12</i>
1554</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001555</div>
Chris Lattner00950542001-06-06 20:29:01 +00001556<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001557<div class="doc_subsubsection"> <a name="i_xor">'<tt>xor</tt>'
1558Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001559<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001560<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001561<pre> &lt;result&gt; = xor &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
Chris Lattner00950542001-06-06 20:29:01 +00001562</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001563<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001564<p>The '<tt>xor</tt>' instruction returns the bitwise logical exclusive
1565or of its two operands. The <tt>xor</tt> is used to implement the
1566"one's complement" operation, which is the "~" operator in C.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001567<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001568<p>The two arguments to the '<tt>xor</tt>' instruction must be <a
Chris Lattner261efe92003-11-25 01:02:51 +00001569 href="#t_integral">integral</a> values. Both arguments must have
1570identical types.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001571<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001572<p>The truth table used for the '<tt>xor</tt>' instruction is:</p>
Chris Lattner261efe92003-11-25 01:02:51 +00001573<p> </p>
Misha Brukmandaa4cb02004-03-01 17:47:27 +00001574<div style="align: center">
Chris Lattner261efe92003-11-25 01:02:51 +00001575<table border="1" cellspacing="0" cellpadding="4">
1576 <tbody>
1577 <tr>
1578 <td>In0</td>
1579 <td>In1</td>
1580 <td>Out</td>
1581 </tr>
1582 <tr>
1583 <td>0</td>
1584 <td>0</td>
1585 <td>0</td>
1586 </tr>
1587 <tr>
1588 <td>0</td>
1589 <td>1</td>
1590 <td>1</td>
1591 </tr>
1592 <tr>
1593 <td>1</td>
1594 <td>0</td>
1595 <td>1</td>
1596 </tr>
1597 <tr>
1598 <td>1</td>
1599 <td>1</td>
1600 <td>0</td>
1601 </tr>
1602 </tbody>
1603</table>
Misha Brukmandaa4cb02004-03-01 17:47:27 +00001604</div>
Chris Lattner261efe92003-11-25 01:02:51 +00001605<p> </p>
Chris Lattner00950542001-06-06 20:29:01 +00001606<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001607<pre> &lt;result&gt; = xor int 4, %var <i>; yields {int}:result = 4 ^ %var</i>
Chris Lattner00950542001-06-06 20:29:01 +00001608 &lt;result&gt; = xor int 15, 40 <i>; yields {int}:result = 39</i>
1609 &lt;result&gt; = xor int 4, 8 <i>; yields {int}:result = 12</i>
Chris Lattner27f71f22003-09-03 00:41:47 +00001610 &lt;result&gt; = xor int %V, -1 <i>; yields {int}:result = ~%V</i>
Chris Lattner00950542001-06-06 20:29:01 +00001611</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001612</div>
Chris Lattner00950542001-06-06 20:29:01 +00001613<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001614<div class="doc_subsubsection"> <a name="i_shl">'<tt>shl</tt>'
1615Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001616<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001617<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001618<pre> &lt;result&gt; = shl &lt;ty&gt; &lt;var1&gt;, ubyte &lt;var2&gt; <i>; yields {ty}:result</i>
Chris Lattner00950542001-06-06 20:29:01 +00001619</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001620<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001621<p>The '<tt>shl</tt>' instruction returns the first operand shifted to
1622the left a specified number of bits.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001623<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001624<p>The first argument to the '<tt>shl</tt>' instruction must be an <a
Chris Lattner261efe92003-11-25 01:02:51 +00001625 href="#t_integer">integer</a> type. The second argument must be an '<tt>ubyte</tt>'
1626type.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001627<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001628<p>The value produced is <tt>var1</tt> * 2<sup><tt>var2</tt></sup>.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001629<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001630<pre> &lt;result&gt; = shl int 4, ubyte %var <i>; yields {int}:result = 4 &lt;&lt; %var</i>
Chris Lattner00950542001-06-06 20:29:01 +00001631 &lt;result&gt; = shl int 4, ubyte 2 <i>; yields {int}:result = 16</i>
1632 &lt;result&gt; = shl int 1, ubyte 10 <i>; yields {int}:result = 1024</i>
1633</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001634</div>
Chris Lattner00950542001-06-06 20:29:01 +00001635<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001636<div class="doc_subsubsection"> <a name="i_shr">'<tt>shr</tt>'
1637Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001638<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001639<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001640<pre> &lt;result&gt; = shr &lt;ty&gt; &lt;var1&gt;, ubyte &lt;var2&gt; <i>; yields {ty}:result</i>
Chris Lattner00950542001-06-06 20:29:01 +00001641</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001642<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001643<p>The '<tt>shr</tt>' instruction returns the first operand shifted to
1644the right a specified number of bits.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001645<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001646<p>The first argument to the '<tt>shr</tt>' instruction must be an <a
Chris Lattner261efe92003-11-25 01:02:51 +00001647 href="#t_integer">integer</a> type. The second argument must be an '<tt>ubyte</tt>'
1648type.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001649<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001650<p>If the first argument is a <a href="#t_signed">signed</a> type, the
1651most significant bit is duplicated in the newly free'd bit positions.
1652If the first argument is unsigned, zero bits shall fill the empty
1653positions.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001654<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001655<pre> &lt;result&gt; = shr int 4, ubyte %var <i>; yields {int}:result = 4 &gt;&gt; %var</i>
Chris Lattner8c6bb902003-06-18 21:30:51 +00001656 &lt;result&gt; = shr uint 4, ubyte 1 <i>; yields {uint}:result = 2</i>
Chris Lattner00950542001-06-06 20:29:01 +00001657 &lt;result&gt; = shr int 4, ubyte 2 <i>; yields {int}:result = 1</i>
Chris Lattner8c6bb902003-06-18 21:30:51 +00001658 &lt;result&gt; = shr sbyte 4, ubyte 3 <i>; yields {sbyte}:result = 0</i>
1659 &lt;result&gt; = shr sbyte -2, ubyte 1 <i>; yields {sbyte}:result = -1</i>
Chris Lattner00950542001-06-06 20:29:01 +00001660</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001661</div>
Chris Lattner00950542001-06-06 20:29:01 +00001662<!-- ======================================================================= -->
Chris Lattner261efe92003-11-25 01:02:51 +00001663<div class="doc_subsection"> <a name="memoryops">Memory Access
1664Operations</a></div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001665<div class="doc_text">
Chris Lattner261efe92003-11-25 01:02:51 +00001666<p>A key design point of an SSA-based representation is how it
1667represents memory. In LLVM, no memory locations are in SSA form, which
1668makes things very simple. This section describes how to read, write,
John Criswell9e2485c2004-12-10 15:51:16 +00001669allocate, and free memory in LLVM.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001670</div>
Chris Lattner00950542001-06-06 20:29:01 +00001671<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001672<div class="doc_subsubsection"> <a name="i_malloc">'<tt>malloc</tt>'
1673Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001674<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001675<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001676<pre> &lt;result&gt; = malloc &lt;type&gt;, uint &lt;NumElements&gt; <i>; yields {type*}:result</i>
Chris Lattner7faa8832002-04-14 06:13:44 +00001677 &lt;result&gt; = malloc &lt;type&gt; <i>; yields {type*}:result</i>
Chris Lattner00950542001-06-06 20:29:01 +00001678</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001679<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001680<p>The '<tt>malloc</tt>' instruction allocates memory from the system
1681heap and returns a pointer to it.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001682<h5>Arguments:</h5>
John Criswell6e4ca612004-02-24 16:13:56 +00001683<p>The '<tt>malloc</tt>' instruction allocates <tt>sizeof(&lt;type&gt;)*NumElements</tt>
1684bytes of memory from the operating system and returns a pointer of the
Chris Lattner261efe92003-11-25 01:02:51 +00001685appropriate type to the program. The second form of the instruction is
1686a shorter version of the first instruction that defaults to allocating
1687one element.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001688<p>'<tt>type</tt>' must be a sized type.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001689<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001690<p>Memory is allocated using the system "<tt>malloc</tt>" function, and
1691a pointer is returned.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001692<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001693<pre> %array = malloc [4 x ubyte ] <i>; yields {[%4 x ubyte]*}:array</i>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001694
Chris Lattner261efe92003-11-25 01:02:51 +00001695 %size = <a
1696 href="#i_add">add</a> uint 2, 2 <i>; yields {uint}:size = uint 4</i>
Chris Lattner7faa8832002-04-14 06:13:44 +00001697 %array1 = malloc ubyte, uint 4 <i>; yields {ubyte*}:array1</i>
1698 %array2 = malloc [12 x ubyte], uint %size <i>; yields {[12 x ubyte]*}:array2</i>
Chris Lattner00950542001-06-06 20:29:01 +00001699</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001700</div>
Chris Lattner00950542001-06-06 20:29:01 +00001701<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001702<div class="doc_subsubsection"> <a name="i_free">'<tt>free</tt>'
1703Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001704<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001705<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001706<pre> free &lt;type&gt; &lt;value&gt; <i>; yields {void}</i>
Chris Lattner00950542001-06-06 20:29:01 +00001707</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001708<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001709<p>The '<tt>free</tt>' instruction returns memory back to the unused
1710memory heap, to be reallocated in the future.</p>
1711<p> </p>
Chris Lattner00950542001-06-06 20:29:01 +00001712<h5>Arguments:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001713<p>'<tt>value</tt>' shall be a pointer value that points to a value
1714that was allocated with the '<tt><a href="#i_malloc">malloc</a></tt>'
1715instruction.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001716<h5>Semantics:</h5>
John Criswell9e2485c2004-12-10 15:51:16 +00001717<p>Access to the memory pointed to by the pointer is no longer defined
Chris Lattner261efe92003-11-25 01:02:51 +00001718after this instruction executes.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001719<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001720<pre> %array = <a href="#i_malloc">malloc</a> [4 x ubyte] <i>; yields {[4 x ubyte]*}:array</i>
Chris Lattner00950542001-06-06 20:29:01 +00001721 free [4 x ubyte]* %array
1722</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001723</div>
Chris Lattner00950542001-06-06 20:29:01 +00001724<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001725<div class="doc_subsubsection"> <a name="i_alloca">'<tt>alloca</tt>'
1726Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001727<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001728<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001729<pre> &lt;result&gt; = alloca &lt;type&gt;, uint &lt;NumElements&gt; <i>; yields {type*}:result</i>
Chris Lattner7faa8832002-04-14 06:13:44 +00001730 &lt;result&gt; = alloca &lt;type&gt; <i>; yields {type*}:result</i>
Chris Lattner00950542001-06-06 20:29:01 +00001731</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001732<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001733<p>The '<tt>alloca</tt>' instruction allocates memory on the current
1734stack frame of the procedure that is live until the current function
1735returns to its caller.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001736<h5>Arguments:</h5>
John Criswell9e2485c2004-12-10 15:51:16 +00001737<p>The '<tt>alloca</tt>' instruction allocates <tt>sizeof(&lt;type&gt;)*NumElements</tt>
Chris Lattner261efe92003-11-25 01:02:51 +00001738bytes of memory on the runtime stack, returning a pointer of the
1739appropriate type to the program. The second form of the instruction is
1740a shorter version of the first that defaults to allocating one element.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001741<p>'<tt>type</tt>' may be any sized type.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001742<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001743<p>Memory is allocated, a pointer is returned. '<tt>alloca</tt>'d
1744memory is automatically released when the function returns. The '<tt>alloca</tt>'
1745instruction is commonly used to represent automatic variables that must
1746have an address available. When the function returns (either with the <tt><a
1747 href="#i_ret">ret</a></tt> or <tt><a href="#i_invoke">invoke</a></tt>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001748instructions), the memory is reclaimed.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001749<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001750<pre> %ptr = alloca int <i>; yields {int*}:ptr</i>
Chris Lattner7faa8832002-04-14 06:13:44 +00001751 %ptr = alloca int, uint 4 <i>; yields {int*}:ptr</i>
Chris Lattner00950542001-06-06 20:29:01 +00001752</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001753</div>
Chris Lattner00950542001-06-06 20:29:01 +00001754<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001755<div class="doc_subsubsection"> <a name="i_load">'<tt>load</tt>'
1756Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001757<div class="doc_text">
Chris Lattner2b7d3202002-05-06 03:03:22 +00001758<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001759<pre> &lt;result&gt; = load &lt;ty&gt;* &lt;pointer&gt;<br> &lt;result&gt; = volatile load &lt;ty&gt;* &lt;pointer&gt;<br></pre>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001760<h5>Overview:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001761<p>The '<tt>load</tt>' instruction is used to read from memory.</p>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001762<h5>Arguments:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001763<p>The argument to the '<tt>load</tt>' instruction specifies the memory
1764address to load from. The pointer must point to a <a
Chris Lattnere53e5082004-06-03 22:57:15 +00001765 href="#t_firstclass">first class</a> type. If the <tt>load</tt> is
Chris Lattner261efe92003-11-25 01:02:51 +00001766marked as <tt>volatile</tt> then the optimizer is not allowed to modify
1767the number or order of execution of this <tt>load</tt> with other
1768volatile <tt>load</tt> and <tt><a href="#i_store">store</a></tt>
1769instructions. </p>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001770<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001771<p>The location of memory pointed to is loaded.</p>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001772<h5>Examples:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001773<pre> %ptr = <a href="#i_alloca">alloca</a> int <i>; yields {int*}:ptr</i>
1774 <a
1775 href="#i_store">store</a> int 3, int* %ptr <i>; yields {void}</i>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001776 %val = load int* %ptr <i>; yields {int}:val = int 3</i>
1777</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001778</div>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001779<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001780<div class="doc_subsubsection"> <a name="i_store">'<tt>store</tt>'
1781Instruction</a> </div>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001782<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001783<pre> store &lt;ty&gt; &lt;value&gt;, &lt;ty&gt;* &lt;pointer&gt; <i>; yields {void}</i>
Chris Lattnerf0651072003-09-08 18:27:49 +00001784 volatile store &lt;ty&gt; &lt;value&gt;, &lt;ty&gt;* &lt;pointer&gt; <i>; yields {void}</i>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001785</pre>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001786<h5>Overview:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001787<p>The '<tt>store</tt>' instruction is used to write to memory.</p>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001788<h5>Arguments:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001789<p>There are two arguments to the '<tt>store</tt>' instruction: a value
1790to store and an address to store it into. The type of the '<tt>&lt;pointer&gt;</tt>'
1791operand must be a pointer to the type of the '<tt>&lt;value&gt;</tt>'
1792operand. If the <tt>store</tt> is marked as <tt>volatile</tt> then the
1793optimizer is not allowed to modify the number or order of execution of
1794this <tt>store</tt> with other volatile <tt>load</tt> and <tt><a
1795 href="#i_store">store</a></tt> instructions.</p>
1796<h5>Semantics:</h5>
1797<p>The contents of memory are updated to contain '<tt>&lt;value&gt;</tt>'
1798at the location specified by the '<tt>&lt;pointer&gt;</tt>' operand.</p>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001799<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001800<pre> %ptr = <a href="#i_alloca">alloca</a> int <i>; yields {int*}:ptr</i>
1801 <a
1802 href="#i_store">store</a> int 3, int* %ptr <i>; yields {void}</i>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001803 %val = load int* %ptr <i>; yields {int}:val = int 3</i>
1804</pre>
Chris Lattner2b7d3202002-05-06 03:03:22 +00001805<!-- _______________________________________________________________________ -->
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001806<div class="doc_subsubsection">
1807 <a name="i_getelementptr">'<tt>getelementptr</tt>' Instruction</a>
1808</div>
1809
Misha Brukman9d0919f2003-11-08 01:05:38 +00001810<div class="doc_text">
Chris Lattner7faa8832002-04-14 06:13:44 +00001811<h5>Syntax:</h5>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001812<pre>
1813 &lt;result&gt; = getelementptr &lt;ty&gt;* &lt;ptrval&gt;{, &lt;ty&gt; &lt;idx&gt;}*
1814</pre>
1815
Chris Lattner7faa8832002-04-14 06:13:44 +00001816<h5>Overview:</h5>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001817
1818<p>
1819The '<tt>getelementptr</tt>' instruction is used to get the address of a
1820subelement of an aggregate data structure.</p>
1821
Chris Lattner7faa8832002-04-14 06:13:44 +00001822<h5>Arguments:</h5>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001823
1824<p>This instruction takes a list of integer constants that indicate what
1825elements of the aggregate object to index to. The actual types of the arguments
1826provided depend on the type of the first pointer argument. The
1827'<tt>getelementptr</tt>' instruction is used to index down through the type
1828levels of a structure. When indexing into a structure, only <tt>uint</tt>
1829integer constants are allowed. When indexing into an array or pointer
1830<tt>int</tt> and <tt>long</tt> indexes are allowed of any sign.</p>
1831
Chris Lattner261efe92003-11-25 01:02:51 +00001832<p>For example, let's consider a C code fragment and how it gets
1833compiled to LLVM:</p>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001834
1835<pre>
1836 struct RT {
1837 char A;
1838 int B[10][20];
1839 char C;
1840 };
1841 struct ST {
1842 int X;
1843 double Y;
1844 struct RT Z;
1845 };
1846
1847 int *foo(struct ST *s) {
1848 return &amp;s[1].Z.B[5][13];
1849 }
1850</pre>
1851
Misha Brukman9d0919f2003-11-08 01:05:38 +00001852<p>The LLVM code generated by the GCC frontend is:</p>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001853
1854<pre>
1855 %RT = type { sbyte, [10 x [20 x int]], sbyte }
1856 %ST = type { int, double, %RT }
1857
Brian Gaeke7283e7c2004-07-02 21:08:14 +00001858 implementation
1859
1860 int* %foo(%ST* %s) {
1861 entry:
1862 %reg = getelementptr %ST* %s, int 1, uint 2, uint 1, int 5, int 13
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001863 ret int* %reg
1864 }
1865</pre>
1866
Chris Lattner7faa8832002-04-14 06:13:44 +00001867<h5>Semantics:</h5>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001868
1869<p>The index types specified for the '<tt>getelementptr</tt>' instruction depend
Chris Lattnere53e5082004-06-03 22:57:15 +00001870on the pointer type that is being index into. <a href="#t_pointer">Pointer</a>
1871and <a href="#t_array">array</a> types require <tt>uint</tt>, <tt>int</tt>,
1872<tt>ulong</tt>, or <tt>long</tt> values, and <a href="#t_struct">structure</a>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001873types require <tt>uint</tt> <b>constants</b>.</p>
1874
Misha Brukman9d0919f2003-11-08 01:05:38 +00001875<p>In the example above, the first index is indexing into the '<tt>%ST*</tt>'
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001876type, which is a pointer, yielding a '<tt>%ST</tt>' = '<tt>{ int, double, %RT
1877}</tt>' type, a structure. The second index indexes into the third element of
1878the structure, yielding a '<tt>%RT</tt>' = '<tt>{ sbyte, [10 x [20 x int]],
1879sbyte }</tt>' type, another structure. The third index indexes into the second
1880element of the structure, yielding a '<tt>[10 x [20 x int]]</tt>' type, an
1881array. The two dimensions of the array are subscripted into, yielding an
1882'<tt>int</tt>' type. The '<tt>getelementptr</tt>' instruction return a pointer
1883to this element, thus computing a value of '<tt>int*</tt>' type.</p>
1884
Chris Lattner261efe92003-11-25 01:02:51 +00001885<p>Note that it is perfectly legal to index partially through a
1886structure, returning a pointer to an inner element. Because of this,
1887the LLVM code for the given testcase is equivalent to:</p>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001888
1889<pre>
Chris Lattnerd4f6b172005-03-07 22:13:59 +00001890 int* %foo(%ST* %s) {
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001891 %t1 = getelementptr %ST* %s, int 1 <i>; yields %ST*:%t1</i>
1892 %t2 = getelementptr %ST* %t1, int 0, uint 2 <i>; yields %RT*:%t2</i>
1893 %t3 = getelementptr %RT* %t2, int 0, uint 1 <i>; yields [10 x [20 x int]]*:%t3</i>
1894 %t4 = getelementptr [10 x [20 x int]]* %t3, int 0, int 5 <i>; yields [20 x int]*:%t4</i>
1895 %t5 = getelementptr [20 x int]* %t4, int 0, int 13 <i>; yields int*:%t5</i>
1896 ret int* %t5
1897 }
Chris Lattner6536cfe2002-05-06 22:08:29 +00001898</pre>
Chris Lattner7faa8832002-04-14 06:13:44 +00001899<h5>Example:</h5>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00001900<pre>
1901 <i>; yields [12 x ubyte]*:aptr</i>
1902 %aptr = getelementptr {int, [12 x ubyte]}* %sptr, long 0, uint 1
1903</pre>
1904
1905</div>
Chris Lattner00950542001-06-06 20:29:01 +00001906<!-- ======================================================================= -->
Chris Lattner261efe92003-11-25 01:02:51 +00001907<div class="doc_subsection"> <a name="otherops">Other Operations</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001908<div class="doc_text">
John Criswell4457dc92004-04-09 16:48:45 +00001909<p>The instructions in this category are the "miscellaneous"
Chris Lattner261efe92003-11-25 01:02:51 +00001910instructions, which defy better classification.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001911</div>
Chris Lattner00950542001-06-06 20:29:01 +00001912<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001913<div class="doc_subsubsection"> <a name="i_phi">'<tt>phi</tt>'
1914Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001915<div class="doc_text">
Chris Lattner33ba0d92001-07-09 00:26:23 +00001916<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001917<pre> &lt;result&gt; = phi &lt;ty&gt; [ &lt;val0&gt;, &lt;label0&gt;], ...<br></pre>
Chris Lattner33ba0d92001-07-09 00:26:23 +00001918<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001919<p>The '<tt>phi</tt>' instruction is used to implement the &#966; node in
1920the SSA graph representing the function.</p>
Chris Lattner33ba0d92001-07-09 00:26:23 +00001921<h5>Arguments:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001922<p>The type of the incoming values are specified with the first type
1923field. After this, the '<tt>phi</tt>' instruction takes a list of pairs
1924as arguments, with one pair for each predecessor basic block of the
1925current block. Only values of <a href="#t_firstclass">first class</a>
1926type may be used as the value arguments to the PHI node. Only labels
1927may be used as the label arguments.</p>
1928<p>There must be no non-phi instructions between the start of a basic
1929block and the PHI instructions: i.e. PHI instructions must be first in
1930a basic block.</p>
Chris Lattner33ba0d92001-07-09 00:26:23 +00001931<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001932<p>At runtime, the '<tt>phi</tt>' instruction logically takes on the
1933value specified by the parameter, depending on which basic block we
1934came from in the last <a href="#terminators">terminator</a> instruction.</p>
Chris Lattner6536cfe2002-05-06 22:08:29 +00001935<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001936<pre>Loop: ; Infinite loop that counts from 0 on up...<br> %indvar = phi uint [ 0, %LoopHeader ], [ %nextindvar, %Loop ]<br> %nextindvar = add uint %indvar, 1<br> br label %Loop<br></pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001937</div>
Chris Lattnercc37aae2004-03-12 05:50:16 +00001938
Chris Lattner6536cfe2002-05-06 22:08:29 +00001939<!-- _______________________________________________________________________ -->
Chris Lattnercc37aae2004-03-12 05:50:16 +00001940<div class="doc_subsubsection">
1941 <a name="i_cast">'<tt>cast .. to</tt>' Instruction</a>
1942</div>
1943
Misha Brukman9d0919f2003-11-08 01:05:38 +00001944<div class="doc_text">
Chris Lattnercc37aae2004-03-12 05:50:16 +00001945
Chris Lattner6536cfe2002-05-06 22:08:29 +00001946<h5>Syntax:</h5>
Chris Lattnercc37aae2004-03-12 05:50:16 +00001947
1948<pre>
1949 &lt;result&gt; = cast &lt;ty&gt; &lt;value&gt; to &lt;ty2&gt; <i>; yields ty2</i>
Chris Lattner6536cfe2002-05-06 22:08:29 +00001950</pre>
Chris Lattnercc37aae2004-03-12 05:50:16 +00001951
Chris Lattner6536cfe2002-05-06 22:08:29 +00001952<h5>Overview:</h5>
Chris Lattnercc37aae2004-03-12 05:50:16 +00001953
1954<p>
1955The '<tt>cast</tt>' instruction is used as the primitive means to convert
1956integers to floating point, change data type sizes, and break type safety (by
1957casting pointers).
1958</p>
1959
1960
Chris Lattner6536cfe2002-05-06 22:08:29 +00001961<h5>Arguments:</h5>
Chris Lattnercc37aae2004-03-12 05:50:16 +00001962
1963<p>
1964The '<tt>cast</tt>' instruction takes a value to cast, which must be a first
1965class value, and a type to cast it to, which must also be a <a
1966href="#t_firstclass">first class</a> type.
1967</p>
1968
Chris Lattner6536cfe2002-05-06 22:08:29 +00001969<h5>Semantics:</h5>
Chris Lattnercc37aae2004-03-12 05:50:16 +00001970
1971<p>
1972This instruction follows the C rules for explicit casts when determining how the
1973data being cast must change to fit in its new container.
1974</p>
1975
1976<p>
1977When casting to bool, any value that would be considered true in the context of
1978a C '<tt>if</tt>' condition is converted to the boolean '<tt>true</tt>' values,
1979all else are '<tt>false</tt>'.
1980</p>
1981
1982<p>
1983When extending an integral value from a type of one signness to another (for
1984example '<tt>sbyte</tt>' to '<tt>ulong</tt>'), the value is sign-extended if the
1985<b>source</b> value is signed, and zero-extended if the source value is
1986unsigned. <tt>bool</tt> values are always zero extended into either zero or
1987one.
1988</p>
1989
Chris Lattner33ba0d92001-07-09 00:26:23 +00001990<h5>Example:</h5>
Chris Lattnercc37aae2004-03-12 05:50:16 +00001991
1992<pre>
1993 %X = cast int 257 to ubyte <i>; yields ubyte:1</i>
Chris Lattner7bae3952002-06-25 18:03:17 +00001994 %Y = cast int 123 to bool <i>; yields bool:true</i>
Chris Lattner33ba0d92001-07-09 00:26:23 +00001995</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001996</div>
Chris Lattnercc37aae2004-03-12 05:50:16 +00001997
1998<!-- _______________________________________________________________________ -->
1999<div class="doc_subsubsection">
2000 <a name="i_select">'<tt>select</tt>' Instruction</a>
2001</div>
2002
2003<div class="doc_text">
2004
2005<h5>Syntax:</h5>
2006
2007<pre>
2008 &lt;result&gt; = select bool &lt;cond&gt;, &lt;ty&gt; &lt;val1&gt;, &lt;ty&gt; &lt;val2&gt; <i>; yields ty</i>
2009</pre>
2010
2011<h5>Overview:</h5>
2012
2013<p>
2014The '<tt>select</tt>' instruction is used to choose one value based on a
2015condition, without branching.
2016</p>
2017
2018
2019<h5>Arguments:</h5>
2020
2021<p>
2022The '<tt>select</tt>' instruction requires a boolean value indicating the condition, and two values of the same <a href="#t_firstclass">first class</a> type.
2023</p>
2024
2025<h5>Semantics:</h5>
2026
2027<p>
2028If the boolean condition evaluates to true, the instruction returns the first
2029value argument, otherwise it returns the second value argument.
2030</p>
2031
2032<h5>Example:</h5>
2033
2034<pre>
2035 %X = select bool true, ubyte 17, ubyte 42 <i>; yields ubyte:17</i>
2036</pre>
2037</div>
2038
2039
2040
2041
2042
Chris Lattner33ba0d92001-07-09 00:26:23 +00002043<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00002044<div class="doc_subsubsection"> <a name="i_call">'<tt>call</tt>'
2045Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002046<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00002047<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00002048<pre> &lt;result&gt; = call &lt;ty&gt;* &lt;fnptrval&gt;(&lt;param list&gt;)<br></pre>
Chris Lattner00950542001-06-06 20:29:01 +00002049<h5>Overview:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002050<p>The '<tt>call</tt>' instruction represents a simple function call.</p>
Chris Lattner00950542001-06-06 20:29:01 +00002051<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002052<p>This instruction requires several arguments:</p>
Chris Lattner6536cfe2002-05-06 22:08:29 +00002053<ol>
Chris Lattner261efe92003-11-25 01:02:51 +00002054 <li>
2055 <p>'<tt>ty</tt>': shall be the signature of the pointer to function
2056value being invoked. The argument types must match the types implied
2057by this signature.</p>
2058 </li>
2059 <li>
2060 <p>'<tt>fnptrval</tt>': An LLVM value containing a pointer to a
2061function to be invoked. In most cases, this is a direct function
2062invocation, but indirect <tt>call</tt>s are just as possible,
2063calling an arbitrary pointer to function values.</p>
2064 </li>
2065 <li>
2066 <p>'<tt>function args</tt>': argument list whose types match the
Reid Spencera7e302a2005-05-01 22:22:57 +00002067 function signature argument types. All arguments must be of
2068 <a href="#t_firstclass">first class</a> type. If the function signature
2069 indicates the function accepts a variable number of arguments, the extra
2070 arguments can be specified.</p>
Chris Lattner261efe92003-11-25 01:02:51 +00002071 </li>
Chris Lattner6536cfe2002-05-06 22:08:29 +00002072</ol>
Chris Lattner00950542001-06-06 20:29:01 +00002073<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00002074<p>The '<tt>call</tt>' instruction is used to cause control flow to
2075transfer to a specified function, with its incoming arguments bound to
2076the specified values. Upon a '<tt><a href="#i_ret">ret</a></tt>'
2077instruction in the called function, control flow continues with the
2078instruction after the function call, and the return value of the
2079function is bound to the result argument. This is a simpler case of
2080the <a href="#i_invoke">invoke</a> instruction.</p>
Chris Lattner00950542001-06-06 20:29:01 +00002081<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00002082<pre> %retval = call int %test(int %argc)<br> call int(sbyte*, ...) *%printf(sbyte* %msg, int 12, sbyte 42);<br></pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002083</div>
Chris Lattnere19d7a72004-09-27 21:51:25 +00002084
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002085<!-- _______________________________________________________________________ -->
Chris Lattnere19d7a72004-09-27 21:51:25 +00002086<div class="doc_subsubsection">
2087 <a name="i_vanext">'<tt>vanext</tt>' Instruction</a>
2088</div>
2089
Misha Brukman9d0919f2003-11-08 01:05:38 +00002090<div class="doc_text">
Chris Lattnere19d7a72004-09-27 21:51:25 +00002091
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002092<h5>Syntax:</h5>
Chris Lattnere19d7a72004-09-27 21:51:25 +00002093
2094<pre>
2095 &lt;resultarglist&gt; = vanext &lt;va_list&gt; &lt;arglist&gt;, &lt;argty&gt;
2096</pre>
2097
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002098<h5>Overview:</h5>
Chris Lattnere19d7a72004-09-27 21:51:25 +00002099
Chris Lattner261efe92003-11-25 01:02:51 +00002100<p>The '<tt>vanext</tt>' instruction is used to access arguments passed
2101through the "variable argument" area of a function call. It is used to
2102implement the <tt>va_arg</tt> macro in C.</p>
Chris Lattnere19d7a72004-09-27 21:51:25 +00002103
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002104<h5>Arguments:</h5>
Chris Lattnere19d7a72004-09-27 21:51:25 +00002105
2106<p>This instruction takes a <tt>va_list</tt> value and the type of the
2107argument. It returns another <tt>va_list</tt>. The actual type of
2108<tt>va_list</tt> may be defined differently for different targets. Most targets
2109use a <tt>va_list</tt> type of <tt>sbyte*</tt> or some other pointer type.</p>
2110
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002111<h5>Semantics:</h5>
Chris Lattnere19d7a72004-09-27 21:51:25 +00002112
2113<p>The '<tt>vanext</tt>' instruction advances the specified <tt>va_list</tt>
Chris Lattner261efe92003-11-25 01:02:51 +00002114past an argument of the specified type. In conjunction with the <a
2115 href="#i_vaarg"><tt>vaarg</tt></a> instruction, it is used to implement
2116the <tt>va_arg</tt> macro available in C. For more information, see
2117the variable argument handling <a href="#int_varargs">Intrinsic
2118Functions</a>.</p>
Chris Lattnere19d7a72004-09-27 21:51:25 +00002119
Chris Lattner261efe92003-11-25 01:02:51 +00002120<p>It is legal for this instruction to be called in a function which
2121does not take a variable number of arguments, for example, the <tt>vfprintf</tt>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002122function.</p>
Chris Lattnere19d7a72004-09-27 21:51:25 +00002123
Misha Brukman9d0919f2003-11-08 01:05:38 +00002124<p><tt>vanext</tt> is an LLVM instruction instead of an <a
Chris Lattnere19d7a72004-09-27 21:51:25 +00002125href="#intrinsics">intrinsic function</a> because it takes a type as an
2126argument. The type refers to the current argument in the <tt>va_list</tt>, it
2127tells the compiler how far on the stack it needs to advance to find the next
2128argument</p>
2129
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002130<h5>Example:</h5>
Chris Lattnere19d7a72004-09-27 21:51:25 +00002131
Chris Lattner261efe92003-11-25 01:02:51 +00002132<p>See the <a href="#int_varargs">variable argument processing</a>
2133section.</p>
Chris Lattnere19d7a72004-09-27 21:51:25 +00002134
Misha Brukman9d0919f2003-11-08 01:05:38 +00002135</div>
Chris Lattnere19d7a72004-09-27 21:51:25 +00002136
Chris Lattner8d1a81d2003-10-18 05:51:36 +00002137<!-- _______________________________________________________________________ -->
Chris Lattnere19d7a72004-09-27 21:51:25 +00002138<div class="doc_subsubsection">
2139 <a name="i_vaarg">'<tt>vaarg</tt>' Instruction</a>
2140</div>
2141
Misha Brukman9d0919f2003-11-08 01:05:38 +00002142<div class="doc_text">
Chris Lattnere19d7a72004-09-27 21:51:25 +00002143
Chris Lattner8d1a81d2003-10-18 05:51:36 +00002144<h5>Syntax:</h5>
Chris Lattnere19d7a72004-09-27 21:51:25 +00002145
2146<pre>
2147 &lt;resultval&gt; = vaarg &lt;va_list&gt; &lt;arglist&gt;, &lt;argty&gt;
2148</pre>
2149
Chris Lattner8d1a81d2003-10-18 05:51:36 +00002150<h5>Overview:</h5>
Chris Lattnere19d7a72004-09-27 21:51:25 +00002151
2152<p>The '<tt>vaarg</tt>' instruction is used to access arguments passed through
2153the "variable argument" area of a function call. It is used to implement the
2154<tt>va_arg</tt> macro in C.</p>
2155
Chris Lattner8d1a81d2003-10-18 05:51:36 +00002156<h5>Arguments:</h5>
Chris Lattnere19d7a72004-09-27 21:51:25 +00002157
2158<p>This instruction takes a <tt>va_list</tt> value and the type of the
2159argument. It returns a value of the specified argument type. Again, the actual
2160type of <tt>va_list</tt> is target specific.</p>
2161
Chris Lattner8d1a81d2003-10-18 05:51:36 +00002162<h5>Semantics:</h5>
Chris Lattnere19d7a72004-09-27 21:51:25 +00002163
2164<p>The '<tt>vaarg</tt>' instruction loads an argument of the specified type from
2165the specified <tt>va_list</tt>. In conjunction with the <a
2166href="#i_vanext"><tt>vanext</tt></a> instruction, it is used to implement the
2167<tt>va_arg</tt> macro available in C. For more information, see the variable
2168argument handling <a href="#int_varargs">Intrinsic Functions</a>.</p>
2169
2170<p>It is legal for this instruction to be called in a function which does not
2171take a variable number of arguments, for example, the <tt>vfprintf</tt>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002172function.</p>
Chris Lattnere19d7a72004-09-27 21:51:25 +00002173
Misha Brukman9d0919f2003-11-08 01:05:38 +00002174<p><tt>vaarg</tt> is an LLVM instruction instead of an <a
Chris Lattnere19d7a72004-09-27 21:51:25 +00002175href="#intrinsics">intrinsic function</a> because it takes an type as an
2176argument.</p>
2177
Chris Lattner8d1a81d2003-10-18 05:51:36 +00002178<h5>Example:</h5>
Chris Lattnere19d7a72004-09-27 21:51:25 +00002179
2180<p>See the <a href="#int_varargs">variable argument processing</a> section.</p>
2181
Misha Brukman9d0919f2003-11-08 01:05:38 +00002182</div>
Chris Lattner8ff75902004-01-06 05:31:32 +00002183
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002184<!-- *********************************************************************** -->
Chris Lattner261efe92003-11-25 01:02:51 +00002185<div class="doc_section"> <a name="intrinsics">Intrinsic Functions</a> </div>
2186<!-- *********************************************************************** -->
Chris Lattner8ff75902004-01-06 05:31:32 +00002187
Misha Brukman9d0919f2003-11-08 01:05:38 +00002188<div class="doc_text">
Chris Lattner33aec9e2004-02-12 17:01:32 +00002189
2190<p>LLVM supports the notion of an "intrinsic function". These functions have
2191well known names and semantics, and are required to follow certain
2192restrictions. Overall, these instructions represent an extension mechanism for
2193the LLVM language that does not require changing all of the transformations in
2194LLVM to add to the language (or the bytecode reader/writer, the parser,
2195etc...).</p>
2196
2197<p>Intrinsic function names must all start with an "<tt>llvm.</tt>" prefix, this
2198prefix is reserved in LLVM for intrinsic names, thus functions may not be named
2199this. Intrinsic functions must always be external functions: you cannot define
2200the body of intrinsic functions. Intrinsic functions may only be used in call
2201or invoke instructions: it is illegal to take the address of an intrinsic
2202function. Additionally, because intrinsic functions are part of the LLVM
2203language, it is required that they all be documented here if any are added.</p>
2204
2205
2206<p>
2207Adding an intrinsic to LLVM is straight-forward if it is possible to express the
2208concept in LLVM directly (ie, code generator support is not _required_). To do
2209this, extend the default implementation of the IntrinsicLowering class to handle
2210the intrinsic. Code generators use this class to lower intrinsics they do not
2211understand to raw LLVM instructions that they do.
2212</p>
2213
Misha Brukman9d0919f2003-11-08 01:05:38 +00002214</div>
Chris Lattner8ff75902004-01-06 05:31:32 +00002215
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002216<!-- ======================================================================= -->
Chris Lattner8ff75902004-01-06 05:31:32 +00002217<div class="doc_subsection">
2218 <a name="int_varargs">Variable Argument Handling Intrinsics</a>
2219</div>
2220
Misha Brukman9d0919f2003-11-08 01:05:38 +00002221<div class="doc_text">
Chris Lattnerd7923912004-05-23 21:06:01 +00002222
Misha Brukman9d0919f2003-11-08 01:05:38 +00002223<p>Variable argument support is defined in LLVM with the <a
Chris Lattner261efe92003-11-25 01:02:51 +00002224 href="#i_vanext"><tt>vanext</tt></a> instruction and these three
2225intrinsic functions. These functions are related to the similarly
2226named macros defined in the <tt>&lt;stdarg.h&gt;</tt> header file.</p>
Chris Lattnerd7923912004-05-23 21:06:01 +00002227
Chris Lattner261efe92003-11-25 01:02:51 +00002228<p>All of these functions operate on arguments that use a
2229target-specific value type "<tt>va_list</tt>". The LLVM assembly
2230language reference manual does not define what this type is, so all
2231transformations should be prepared to handle intrinsics with any type
2232used.</p>
Chris Lattnerd7923912004-05-23 21:06:01 +00002233
Misha Brukman9d0919f2003-11-08 01:05:38 +00002234<p>This example shows how the <a href="#i_vanext"><tt>vanext</tt></a>
Chris Lattner261efe92003-11-25 01:02:51 +00002235instruction and the variable argument handling intrinsic functions are
2236used.</p>
Chris Lattnerd7923912004-05-23 21:06:01 +00002237
Chris Lattner33aec9e2004-02-12 17:01:32 +00002238<pre>
2239int %test(int %X, ...) {
2240 ; Initialize variable argument processing
2241 %ap = call sbyte* %<a href="#i_va_start">llvm.va_start</a>()
2242
2243 ; Read a single integer argument
2244 %tmp = vaarg sbyte* %ap, int
2245
2246 ; Advance to the next argument
2247 %ap2 = vanext sbyte* %ap, int
2248
2249 ; Demonstrate usage of llvm.va_copy and llvm.va_end
2250 %aq = call sbyte* %<a href="#i_va_copy">llvm.va_copy</a>(sbyte* %ap2)
2251 call void %<a href="#i_va_end">llvm.va_end</a>(sbyte* %aq)
2252
2253 ; Stop processing of arguments.
2254 call void %<a href="#i_va_end">llvm.va_end</a>(sbyte* %ap2)
2255 ret int %tmp
2256}
2257</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002258</div>
Chris Lattner8ff75902004-01-06 05:31:32 +00002259
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002260<!-- _______________________________________________________________________ -->
Chris Lattner8ff75902004-01-06 05:31:32 +00002261<div class="doc_subsubsection">
2262 <a name="i_va_start">'<tt>llvm.va_start</tt>' Intrinsic</a>
2263</div>
2264
2265
Misha Brukman9d0919f2003-11-08 01:05:38 +00002266<div class="doc_text">
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002267<h5>Syntax:</h5>
Reid Spencera8d451e2005-04-26 20:50:44 +00002268<pre> declare &lt;va_list&gt; %llvm.va_start()<br></pre>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002269<h5>Overview:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002270<p>The '<tt>llvm.va_start</tt>' intrinsic returns a new <tt>&lt;arglist&gt;</tt>
2271for subsequent use by the variable argument intrinsics.</p>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002272<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002273<p>The '<tt>llvm.va_start</tt>' intrinsic works just like the <tt>va_start</tt>
Chris Lattner261efe92003-11-25 01:02:51 +00002274macro available in C. In a target-dependent way, it initializes and
2275returns a <tt>va_list</tt> element, so that the next <tt>vaarg</tt>
2276will produce the first variable argument passed to the function. Unlike
2277the C <tt>va_start</tt> macro, this intrinsic does not need to know the
2278last argument of the function, the compiler can figure that out.</p>
2279<p>Note that this intrinsic function is only legal to be called from
2280within the body of a variable argument function.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002281</div>
Chris Lattner8ff75902004-01-06 05:31:32 +00002282
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002283<!-- _______________________________________________________________________ -->
Chris Lattner8ff75902004-01-06 05:31:32 +00002284<div class="doc_subsubsection">
2285 <a name="i_va_end">'<tt>llvm.va_end</tt>' Intrinsic</a>
2286</div>
2287
Misha Brukman9d0919f2003-11-08 01:05:38 +00002288<div class="doc_text">
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002289<h5>Syntax:</h5>
Reid Spencera8d451e2005-04-26 20:50:44 +00002290<pre> declare void %llvm.va_end(&lt;va_list&gt; &lt;arglist&gt;)<br></pre>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002291<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00002292<p>The '<tt>llvm.va_end</tt>' intrinsic destroys <tt>&lt;arglist&gt;</tt>
2293which has been initialized previously with <tt><a href="#i_va_start">llvm.va_start</a></tt>
2294or <tt><a href="#i_va_copy">llvm.va_copy</a></tt>.</p>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002295<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002296<p>The argument is a <tt>va_list</tt> to destroy.</p>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002297<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002298<p>The '<tt>llvm.va_end</tt>' intrinsic works just like the <tt>va_end</tt>
Chris Lattner261efe92003-11-25 01:02:51 +00002299macro available in C. In a target-dependent way, it destroys the <tt>va_list</tt>.
2300Calls to <a href="#i_va_start"><tt>llvm.va_start</tt></a> and <a
2301 href="#i_va_copy"><tt>llvm.va_copy</tt></a> must be matched exactly
2302with calls to <tt>llvm.va_end</tt>.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002303</div>
Chris Lattner8ff75902004-01-06 05:31:32 +00002304
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002305<!-- _______________________________________________________________________ -->
Chris Lattner8ff75902004-01-06 05:31:32 +00002306<div class="doc_subsubsection">
2307 <a name="i_va_copy">'<tt>llvm.va_copy</tt>' Intrinsic</a>
2308</div>
2309
Misha Brukman9d0919f2003-11-08 01:05:38 +00002310<div class="doc_text">
Chris Lattnerd7923912004-05-23 21:06:01 +00002311
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002312<h5>Syntax:</h5>
Chris Lattnerd7923912004-05-23 21:06:01 +00002313
2314<pre>
Reid Spencera8d451e2005-04-26 20:50:44 +00002315 declare &lt;va_list&gt; %llvm.va_copy(&lt;va_list&gt; &lt;destarglist&gt;)
Chris Lattnerd7923912004-05-23 21:06:01 +00002316</pre>
2317
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002318<h5>Overview:</h5>
Chris Lattnerd7923912004-05-23 21:06:01 +00002319
2320<p>The '<tt>llvm.va_copy</tt>' intrinsic copies the current argument position
2321from the source argument list to the destination argument list.</p>
2322
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002323<h5>Arguments:</h5>
Chris Lattnerd7923912004-05-23 21:06:01 +00002324
Misha Brukman9d0919f2003-11-08 01:05:38 +00002325<p>The argument is the <tt>va_list</tt> to copy.</p>
Chris Lattnerd7923912004-05-23 21:06:01 +00002326
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00002327<h5>Semantics:</h5>
Chris Lattnerd7923912004-05-23 21:06:01 +00002328
Misha Brukman9d0919f2003-11-08 01:05:38 +00002329<p>The '<tt>llvm.va_copy</tt>' intrinsic works just like the <tt>va_copy</tt>
Chris Lattnerd7923912004-05-23 21:06:01 +00002330macro available in C. In a target-dependent way, it copies the source
2331<tt>va_list</tt> element into the returned list. This intrinsic is necessary
Chris Lattnerfcd37252004-06-21 22:52:48 +00002332because the <tt><a href="#i_va_start">llvm.va_start</a></tt> intrinsic may be
Chris Lattnerd7923912004-05-23 21:06:01 +00002333arbitrarily complex and require memory allocation, for example.</p>
2334
Misha Brukman9d0919f2003-11-08 01:05:38 +00002335</div>
Chris Lattner8ff75902004-01-06 05:31:32 +00002336
Chris Lattner33aec9e2004-02-12 17:01:32 +00002337<!-- ======================================================================= -->
2338<div class="doc_subsection">
Chris Lattnerd7923912004-05-23 21:06:01 +00002339 <a name="int_gc">Accurate Garbage Collection Intrinsics</a>
2340</div>
2341
2342<div class="doc_text">
2343
2344<p>
2345LLVM support for <a href="GarbageCollection.html">Accurate Garbage
2346Collection</a> requires the implementation and generation of these intrinsics.
2347These intrinsics allow identification of <a href="#i_gcroot">GC roots on the
2348stack</a>, as well as garbage collector implementations that require <a
2349href="#i_gcread">read</a> and <a href="#i_gcwrite">write</a> barriers.
2350Front-ends for type-safe garbage collected languages should generate these
2351intrinsics to make use of the LLVM garbage collectors. For more details, see <a
2352href="GarbageCollection.html">Accurate Garbage Collection with LLVM</a>.
2353</p>
2354</div>
2355
2356<!-- _______________________________________________________________________ -->
2357<div class="doc_subsubsection">
2358 <a name="i_gcroot">'<tt>llvm.gcroot</tt>' Intrinsic</a>
2359</div>
2360
2361<div class="doc_text">
2362
2363<h5>Syntax:</h5>
2364
2365<pre>
Reid Spencera8d451e2005-04-26 20:50:44 +00002366 declare void %llvm.gcroot(&lt;ty&gt;** %ptrloc, &lt;ty2&gt;* %metadata)
Chris Lattnerd7923912004-05-23 21:06:01 +00002367</pre>
2368
2369<h5>Overview:</h5>
2370
John Criswell9e2485c2004-12-10 15:51:16 +00002371<p>The '<tt>llvm.gcroot</tt>' intrinsic declares the existence of a GC root to
Chris Lattnerd7923912004-05-23 21:06:01 +00002372the code generator, and allows some metadata to be associated with it.</p>
2373
2374<h5>Arguments:</h5>
2375
2376<p>The first argument specifies the address of a stack object that contains the
2377root pointer. The second pointer (which must be either a constant or a global
2378value address) contains the meta-data to be associated with the root.</p>
2379
2380<h5>Semantics:</h5>
2381
2382<p>At runtime, a call to this intrinsics stores a null pointer into the "ptrloc"
2383location. At compile-time, the code generator generates information to allow
2384the runtime to find the pointer at GC safe points.
2385</p>
2386
2387</div>
2388
2389
2390<!-- _______________________________________________________________________ -->
2391<div class="doc_subsubsection">
2392 <a name="i_gcread">'<tt>llvm.gcread</tt>' Intrinsic</a>
2393</div>
2394
2395<div class="doc_text">
2396
2397<h5>Syntax:</h5>
2398
2399<pre>
Reid Spencera8d451e2005-04-26 20:50:44 +00002400 declare sbyte* %llvm.gcread(sbyte** %Ptr)
Chris Lattnerd7923912004-05-23 21:06:01 +00002401</pre>
2402
2403<h5>Overview:</h5>
2404
2405<p>The '<tt>llvm.gcread</tt>' intrinsic identifies reads of references from heap
2406locations, allowing garbage collector implementations that require read
2407barriers.</p>
2408
2409<h5>Arguments:</h5>
2410
2411<p>The argument is the address to read from, which should be an address
2412allocated from the garbage collector.</p>
2413
2414<h5>Semantics:</h5>
2415
2416<p>The '<tt>llvm.gcread</tt>' intrinsic has the same semantics as a load
2417instruction, but may be replaced with substantially more complex code by the
2418garbage collector runtime, as needed.</p>
2419
2420</div>
2421
2422
2423<!-- _______________________________________________________________________ -->
2424<div class="doc_subsubsection">
2425 <a name="i_gcwrite">'<tt>llvm.gcwrite</tt>' Intrinsic</a>
2426</div>
2427
2428<div class="doc_text">
2429
2430<h5>Syntax:</h5>
2431
2432<pre>
Reid Spencera8d451e2005-04-26 20:50:44 +00002433 declare void %llvm.gcwrite(sbyte* %P1, sbyte** %P2)
Chris Lattnerd7923912004-05-23 21:06:01 +00002434</pre>
2435
2436<h5>Overview:</h5>
2437
2438<p>The '<tt>llvm.gcwrite</tt>' intrinsic identifies writes of references to heap
2439locations, allowing garbage collector implementations that require write
2440barriers (such as generational or reference counting collectors).</p>
2441
2442<h5>Arguments:</h5>
2443
2444<p>The first argument is the reference to store, and the second is the heap
2445location to store to.</p>
2446
2447<h5>Semantics:</h5>
2448
2449<p>The '<tt>llvm.gcwrite</tt>' intrinsic has the same semantics as a store
2450instruction, but may be replaced with substantially more complex code by the
2451garbage collector runtime, as needed.</p>
2452
2453</div>
2454
2455
2456
2457<!-- ======================================================================= -->
2458<div class="doc_subsection">
Chris Lattner10610642004-02-14 04:08:35 +00002459 <a name="int_codegen">Code Generator Intrinsics</a>
2460</div>
2461
2462<div class="doc_text">
2463<p>
2464These intrinsics are provided by LLVM to expose special features that may only
2465be implemented with code generator support.
2466</p>
2467
2468</div>
2469
2470<!-- _______________________________________________________________________ -->
2471<div class="doc_subsubsection">
2472 <a name="i_returnaddress">'<tt>llvm.returnaddress</tt>' Intrinsic</a>
2473</div>
2474
2475<div class="doc_text">
2476
2477<h5>Syntax:</h5>
2478<pre>
Reid Spencera8d451e2005-04-26 20:50:44 +00002479 declare void* %llvm.returnaddress(uint &lt;level&gt;)
Chris Lattner10610642004-02-14 04:08:35 +00002480</pre>
2481
2482<h5>Overview:</h5>
2483
2484<p>
2485The '<tt>llvm.returnaddress</tt>' intrinsic returns a target-specific value
2486indicating the return address of the current function or one of its callers.
2487</p>
2488
2489<h5>Arguments:</h5>
2490
2491<p>
2492The argument to this intrinsic indicates which function to return the address
2493for. Zero indicates the calling function, one indicates its caller, etc. The
2494argument is <b>required</b> to be a constant integer value.
2495</p>
2496
2497<h5>Semantics:</h5>
2498
2499<p>
2500The '<tt>llvm.returnaddress</tt>' intrinsic either returns a pointer indicating
2501the return address of the specified call frame, or zero if it cannot be
2502identified. The value returned by this intrinsic is likely to be incorrect or 0
2503for arguments other than zero, so it should only be used for debugging purposes.
2504</p>
2505
2506<p>
2507Note that calling this intrinsic does not prevent function inlining or other
Chris Lattnerb40bb382005-03-07 20:30:51 +00002508aggressive transformations, so the value returned may not be that of the obvious
Chris Lattner10610642004-02-14 04:08:35 +00002509source-language caller.
2510</p>
2511</div>
2512
2513
2514<!-- _______________________________________________________________________ -->
2515<div class="doc_subsubsection">
2516 <a name="i_frameaddress">'<tt>llvm.frameaddress</tt>' Intrinsic</a>
2517</div>
2518
2519<div class="doc_text">
2520
2521<h5>Syntax:</h5>
2522<pre>
Reid Spencera8d451e2005-04-26 20:50:44 +00002523 declare void* %llvm.frameaddress(uint &lt;level&gt;)
Chris Lattner10610642004-02-14 04:08:35 +00002524</pre>
2525
2526<h5>Overview:</h5>
2527
2528<p>
2529The '<tt>llvm.frameaddress</tt>' intrinsic returns the target-specific frame
2530pointer value for the specified stack frame.
2531</p>
2532
2533<h5>Arguments:</h5>
2534
2535<p>
2536The argument to this intrinsic indicates which function to return the frame
2537pointer for. Zero indicates the calling function, one indicates its caller,
2538etc. The argument is <b>required</b> to be a constant integer value.
2539</p>
2540
2541<h5>Semantics:</h5>
2542
2543<p>
2544The '<tt>llvm.frameaddress</tt>' intrinsic either returns a pointer indicating
2545the frame address of the specified call frame, or zero if it cannot be
2546identified. The value returned by this intrinsic is likely to be incorrect or 0
2547for arguments other than zero, so it should only be used for debugging purposes.
2548</p>
2549
2550<p>
2551Note that calling this intrinsic does not prevent function inlining or other
Chris Lattnerb40bb382005-03-07 20:30:51 +00002552aggressive transformations, so the value returned may not be that of the obvious
Chris Lattner10610642004-02-14 04:08:35 +00002553source-language caller.
2554</p>
2555</div>
2556
Chris Lattner9a9d7ac2005-02-28 19:24:19 +00002557<!-- _______________________________________________________________________ -->
2558<div class="doc_subsubsection">
2559 <a name="i_prefetch">'<tt>llvm.prefetch</tt>' Intrinsic</a>
2560</div>
2561
2562<div class="doc_text">
2563
2564<h5>Syntax:</h5>
2565<pre>
Reid Spencera8d451e2005-04-26 20:50:44 +00002566 declare void %llvm.prefetch(sbyte * &lt;address&gt;,
2567 uint &lt;rw&gt;, uint &lt;locality&gt;)
Chris Lattner9a9d7ac2005-02-28 19:24:19 +00002568</pre>
2569
2570<h5>Overview:</h5>
2571
2572
2573<p>
2574The '<tt>llvm.prefetch</tt>' intrinsic is a hint to the code generator to insert
2575a prefetch instruction if supported, otherwise it is a noop. Prefetches have no
Chris Lattner2a615362005-02-28 19:47:14 +00002576effect on the behavior of the program, but can change its performance
2577characteristics.
Chris Lattner9a9d7ac2005-02-28 19:24:19 +00002578</p>
2579
2580<h5>Arguments:</h5>
2581
2582<p>
2583<tt>address</tt> is the address to be prefetched, <tt>rw</tt> is the specifier
2584determining if the fetch should be for a read (0) or write (1), and
2585<tt>locality</tt> is a temporal locality specifier ranging from (0) - no
Chris Lattneraeffb4a2005-03-07 20:31:38 +00002586locality, to (3) - extremely local keep in cache. The <tt>rw</tt> and
Chris Lattner9a9d7ac2005-02-28 19:24:19 +00002587<tt>locality</tt> arguments must be constant integers.
2588</p>
2589
2590<h5>Semantics:</h5>
2591
2592<p>
2593This intrinsic does not modify the behavior of the program. In particular,
2594prefetches cannot trap and do not produce a value. On targets that support this
2595intrinsic, the prefetch can provide hints to the processor cache for better
2596performance.
2597</p>
2598
2599</div>
2600
Andrew Lenharth7f4ec3b2005-03-28 20:05:49 +00002601<!-- _______________________________________________________________________ -->
2602<div class="doc_subsubsection">
2603 <a name="i_pcmarker">'<tt>llvm.pcmarker</tt>' Intrinsic</a>
2604</div>
2605
2606<div class="doc_text">
2607
2608<h5>Syntax:</h5>
2609<pre>
Reid Spencera8d451e2005-04-26 20:50:44 +00002610 declare void %llvm.pcmarker( uint &lt;id&gt; )
Andrew Lenharth7f4ec3b2005-03-28 20:05:49 +00002611</pre>
2612
2613<h5>Overview:</h5>
2614
2615
2616<p>
2617The '<tt>llvm.pcmarker</tt>' intrinsic is a method to export a PC in a region of
2618code to simulators and other tools. The method is target specific, but it is
2619expected that the marker will use exported symbols to transmit the PC of the marker.
2620The marker makes no guaranties that it will remain with any specific instruction
2621after optimizations. It is possible that the presense of a marker will inhibit
2622optimizations. The intended use is to be inserted after optmizations to allow
2623corrolations of simulation runs.
2624</p>
2625
2626<h5>Arguments:</h5>
2627
2628<p>
2629<tt>id</tt> is a numerical id identifying the marker.
2630</p>
2631
2632<h5>Semantics:</h5>
2633
2634<p>
2635This intrinsic does not modify the behavior of the program. Backends that do not
2636support this intrinisic may ignore it.
2637</p>
2638
2639</div>
2640
Chris Lattner9a9d7ac2005-02-28 19:24:19 +00002641
John Criswell7123e272004-04-09 16:43:20 +00002642<!-- ======================================================================= -->
2643<div class="doc_subsection">
2644 <a name="int_os">Operating System Intrinsics</a>
2645</div>
2646
2647<div class="doc_text">
2648<p>
2649These intrinsics are provided by LLVM to support the implementation of
2650operating system level code.
2651</p>
2652
2653</div>
John Criswell183402a2004-04-12 15:02:16 +00002654
John Criswellcfd3bac2004-04-09 15:23:37 +00002655<!-- _______________________________________________________________________ -->
2656<div class="doc_subsubsection">
2657 <a name="i_readport">'<tt>llvm.readport</tt>' Intrinsic</a>
2658</div>
2659
2660<div class="doc_text">
2661
2662<h5>Syntax:</h5>
2663<pre>
Reid Spencera8d451e2005-04-26 20:50:44 +00002664 declare &lt;integer type&gt; %llvm.readport (&lt;integer type&gt; &lt;address&gt;)
John Criswellcfd3bac2004-04-09 15:23:37 +00002665</pre>
2666
2667<h5>Overview:</h5>
2668
2669<p>
John Criswell7123e272004-04-09 16:43:20 +00002670The '<tt>llvm.readport</tt>' intrinsic reads data from the specified hardware
2671I/O port.
John Criswellcfd3bac2004-04-09 15:23:37 +00002672</p>
2673
2674<h5>Arguments:</h5>
2675
2676<p>
John Criswell7123e272004-04-09 16:43:20 +00002677The argument to this intrinsic indicates the hardware I/O address from which
2678to read the data. The address is in the hardware I/O address namespace (as
2679opposed to being a memory location for memory mapped I/O).
John Criswellcfd3bac2004-04-09 15:23:37 +00002680</p>
2681
2682<h5>Semantics:</h5>
2683
2684<p>
John Criswell7123e272004-04-09 16:43:20 +00002685The '<tt>llvm.readport</tt>' intrinsic reads data from the hardware I/O port
2686specified by <i>address</i> and returns the value. The address and return
2687value must be integers, but the size is dependent upon the platform upon which
2688the program is code generated. For example, on x86, the address must be an
Misha Brukmancfa87bc2005-04-22 18:02:52 +00002689unsigned 16-bit value, and the return value must be 8, 16, or 32 bits.
John Criswellcfd3bac2004-04-09 15:23:37 +00002690</p>
2691
2692</div>
2693
2694<!-- _______________________________________________________________________ -->
2695<div class="doc_subsubsection">
2696 <a name="i_writeport">'<tt>llvm.writeport</tt>' Intrinsic</a>
2697</div>
2698
2699<div class="doc_text">
2700
2701<h5>Syntax:</h5>
2702<pre>
Chris Lattnerc3f59762004-12-09 17:30:23 +00002703 call void (&lt;integer type&gt;, &lt;integer type&gt;)*
2704 %llvm.writeport (&lt;integer type&gt; &lt;value&gt;,
2705 &lt;integer type&gt; &lt;address&gt;)
John Criswellcfd3bac2004-04-09 15:23:37 +00002706</pre>
2707
2708<h5>Overview:</h5>
2709
2710<p>
John Criswell7123e272004-04-09 16:43:20 +00002711The '<tt>llvm.writeport</tt>' intrinsic writes data to the specified hardware
2712I/O port.
John Criswellcfd3bac2004-04-09 15:23:37 +00002713</p>
2714
2715<h5>Arguments:</h5>
2716
2717<p>
John Criswell96db6fc2004-04-12 16:33:19 +00002718The first argument is the value to write to the I/O port.
John Criswellcfd3bac2004-04-09 15:23:37 +00002719</p>
2720
2721<p>
John Criswell96db6fc2004-04-12 16:33:19 +00002722The second argument indicates the hardware I/O address to which data should be
2723written. The address is in the hardware I/O address namespace (as opposed to
2724being a memory location for memory mapped I/O).
John Criswellcfd3bac2004-04-09 15:23:37 +00002725</p>
2726
2727<h5>Semantics:</h5>
2728
2729<p>
2730The '<tt>llvm.writeport</tt>' intrinsic writes <i>value</i> to the I/O port
2731specified by <i>address</i>. The address and value must be integers, but the
2732size is dependent upon the platform upon which the program is code generated.
Misha Brukmancfa87bc2005-04-22 18:02:52 +00002733For example, on x86, the address must be an unsigned 16-bit value, and the
John Criswell7123e272004-04-09 16:43:20 +00002734value written must be 8, 16, or 32 bits in length.
John Criswellcfd3bac2004-04-09 15:23:37 +00002735</p>
2736
2737</div>
Chris Lattner10610642004-02-14 04:08:35 +00002738
John Criswell183402a2004-04-12 15:02:16 +00002739<!-- _______________________________________________________________________ -->
2740<div class="doc_subsubsection">
2741 <a name="i_readio">'<tt>llvm.readio</tt>' Intrinsic</a>
2742</div>
2743
2744<div class="doc_text">
2745
2746<h5>Syntax:</h5>
2747<pre>
Reid Spencera8d451e2005-04-26 20:50:44 +00002748 declare &lt;result&gt; %llvm.readio (&lt;ty&gt; * &lt;pointer&gt;)
John Criswell183402a2004-04-12 15:02:16 +00002749</pre>
2750
2751<h5>Overview:</h5>
2752
2753<p>
2754The '<tt>llvm.readio</tt>' intrinsic reads data from a memory mapped I/O
2755address.
2756</p>
2757
2758<h5>Arguments:</h5>
2759
2760<p>
John Criswell96db6fc2004-04-12 16:33:19 +00002761The argument to this intrinsic is a pointer indicating the memory address from
2762which to read the data. The data must be a
2763<a href="#t_firstclass">first class</a> type.
John Criswell183402a2004-04-12 15:02:16 +00002764</p>
2765
2766<h5>Semantics:</h5>
2767
2768<p>
2769The '<tt>llvm.readio</tt>' intrinsic reads data from a memory mapped I/O
John Criswell96db6fc2004-04-12 16:33:19 +00002770location specified by <i>pointer</i> and returns the value. The argument must
2771be a pointer, and the return value must be a
2772<a href="#t_firstclass">first class</a> type. However, certain architectures
Misha Brukmancfa87bc2005-04-22 18:02:52 +00002773may not support I/O on all first class types. For example, 32-bit processors
John Criswell96db6fc2004-04-12 16:33:19 +00002774may only support I/O on data types that are 32 bits or less.
John Criswell183402a2004-04-12 15:02:16 +00002775</p>
2776
2777<p>
John Criswell96db6fc2004-04-12 16:33:19 +00002778This intrinsic enforces an in-order memory model for llvm.readio and
2779llvm.writeio calls on machines that use dynamic scheduling. Dynamically
2780scheduled processors may execute loads and stores out of order, re-ordering at
2781run time accesses to memory mapped I/O registers. Using these intrinsics
2782ensures that accesses to memory mapped I/O registers occur in program order.
John Criswell183402a2004-04-12 15:02:16 +00002783</p>
2784
2785</div>
2786
2787<!-- _______________________________________________________________________ -->
2788<div class="doc_subsubsection">
2789 <a name="i_writeio">'<tt>llvm.writeio</tt>' Intrinsic</a>
2790</div>
2791
2792<div class="doc_text">
2793
2794<h5>Syntax:</h5>
2795<pre>
Reid Spencera8d451e2005-04-26 20:50:44 +00002796 declare void %llvm.writeio (&lt;ty1&gt; &lt;value&gt;, &lt;ty2&gt; * &lt;pointer&gt;)
John Criswell183402a2004-04-12 15:02:16 +00002797</pre>
2798
2799<h5>Overview:</h5>
2800
2801<p>
2802The '<tt>llvm.writeio</tt>' intrinsic writes data to the specified memory
2803mapped I/O address.
2804</p>
2805
2806<h5>Arguments:</h5>
2807
2808<p>
John Criswell96db6fc2004-04-12 16:33:19 +00002809The first argument is the value to write to the memory mapped I/O location.
2810The second argument is a pointer indicating the memory address to which the
2811data should be written.
John Criswell183402a2004-04-12 15:02:16 +00002812</p>
2813
2814<h5>Semantics:</h5>
2815
2816<p>
2817The '<tt>llvm.writeio</tt>' intrinsic writes <i>value</i> to the memory mapped
John Criswell96db6fc2004-04-12 16:33:19 +00002818I/O address specified by <i>pointer</i>. The value must be a
2819<a href="#t_firstclass">first class</a> type. However, certain architectures
Misha Brukmancfa87bc2005-04-22 18:02:52 +00002820may not support I/O on all first class types. For example, 32-bit processors
John Criswell96db6fc2004-04-12 16:33:19 +00002821may only support I/O on data types that are 32 bits or less.
John Criswell183402a2004-04-12 15:02:16 +00002822</p>
2823
2824<p>
John Criswell96db6fc2004-04-12 16:33:19 +00002825This intrinsic enforces an in-order memory model for llvm.readio and
2826llvm.writeio calls on machines that use dynamic scheduling. Dynamically
2827scheduled processors may execute loads and stores out of order, re-ordering at
2828run time accesses to memory mapped I/O registers. Using these intrinsics
2829ensures that accesses to memory mapped I/O registers occur in program order.
John Criswell183402a2004-04-12 15:02:16 +00002830</p>
2831
2832</div>
2833
Chris Lattner10610642004-02-14 04:08:35 +00002834<!-- ======================================================================= -->
2835<div class="doc_subsection">
Chris Lattner33aec9e2004-02-12 17:01:32 +00002836 <a name="int_libc">Standard C Library Intrinsics</a>
2837</div>
2838
2839<div class="doc_text">
2840<p>
Chris Lattner10610642004-02-14 04:08:35 +00002841LLVM provides intrinsics for a few important standard C library functions.
2842These intrinsics allow source-language front-ends to pass information about the
2843alignment of the pointer arguments to the code generator, providing opportunity
2844for more efficient code generation.
Chris Lattner33aec9e2004-02-12 17:01:32 +00002845</p>
2846
2847</div>
2848
2849<!-- _______________________________________________________________________ -->
2850<div class="doc_subsubsection">
2851 <a name="i_memcpy">'<tt>llvm.memcpy</tt>' Intrinsic</a>
2852</div>
2853
2854<div class="doc_text">
2855
2856<h5>Syntax:</h5>
2857<pre>
Reid Spencerd4622352005-04-26 20:41:16 +00002858 declare void %llvm.memcpy(sbyte* &lt;dest&gt;, sbyte* &lt;src&gt;,
2859 uint &lt;len&gt;, uint &lt;align&gt;)
Chris Lattner33aec9e2004-02-12 17:01:32 +00002860</pre>
2861
2862<h5>Overview:</h5>
2863
2864<p>
2865The '<tt>llvm.memcpy</tt>' intrinsic copies a block of memory from the source
2866location to the destination location.
2867</p>
2868
2869<p>
2870Note that, unlike the standard libc function, the <tt>llvm.memcpy</tt> intrinsic
2871does not return a value, and takes an extra alignment argument.
2872</p>
2873
2874<h5>Arguments:</h5>
2875
2876<p>
2877The first argument is a pointer to the destination, the second is a pointer to
2878the source. The third argument is an (arbitrarily sized) integer argument
2879specifying the number of bytes to copy, and the fourth argument is the alignment
2880of the source and destination locations.
2881</p>
2882
Chris Lattner3301ced2004-02-12 21:18:15 +00002883<p>
2884If the call to this intrinisic has an alignment value that is not 0 or 1, then
2885the caller guarantees that the size of the copy is a multiple of the alignment
2886and that both the source and destination pointers are aligned to that boundary.
2887</p>
2888
Chris Lattner33aec9e2004-02-12 17:01:32 +00002889<h5>Semantics:</h5>
2890
2891<p>
2892The '<tt>llvm.memcpy</tt>' intrinsic copies a block of memory from the source
2893location to the destination location, which are not allowed to overlap. It
2894copies "len" bytes of memory over. If the argument is known to be aligned to
2895some boundary, this can be specified as the fourth argument, otherwise it should
2896be set to 0 or 1.
2897</p>
2898</div>
2899
2900
Chris Lattner0eb51b42004-02-12 18:10:10 +00002901<!-- _______________________________________________________________________ -->
2902<div class="doc_subsubsection">
2903 <a name="i_memmove">'<tt>llvm.memmove</tt>' Intrinsic</a>
2904</div>
2905
2906<div class="doc_text">
2907
2908<h5>Syntax:</h5>
2909<pre>
Reid Spencerd4622352005-04-26 20:41:16 +00002910 declare void %llvm.memmove(sbyte* &lt;dest&gt;, sbyte* &lt;src&gt;,
2911 uint &lt;len&gt;, uint &lt;align&gt;)
Chris Lattner0eb51b42004-02-12 18:10:10 +00002912</pre>
2913
2914<h5>Overview:</h5>
2915
2916<p>
2917The '<tt>llvm.memmove</tt>' intrinsic moves a block of memory from the source
2918location to the destination location. It is similar to the '<tt>llvm.memcpy</tt>'
2919intrinsic but allows the two memory locations to overlap.
2920</p>
2921
2922<p>
2923Note that, unlike the standard libc function, the <tt>llvm.memmove</tt> intrinsic
2924does not return a value, and takes an extra alignment argument.
2925</p>
2926
2927<h5>Arguments:</h5>
2928
2929<p>
2930The first argument is a pointer to the destination, the second is a pointer to
2931the source. The third argument is an (arbitrarily sized) integer argument
2932specifying the number of bytes to copy, and the fourth argument is the alignment
2933of the source and destination locations.
2934</p>
2935
Chris Lattner3301ced2004-02-12 21:18:15 +00002936<p>
2937If the call to this intrinisic has an alignment value that is not 0 or 1, then
2938the caller guarantees that the size of the copy is a multiple of the alignment
2939and that both the source and destination pointers are aligned to that boundary.
2940</p>
2941
Chris Lattner0eb51b42004-02-12 18:10:10 +00002942<h5>Semantics:</h5>
2943
2944<p>
2945The '<tt>llvm.memmove</tt>' intrinsic copies a block of memory from the source
2946location to the destination location, which may overlap. It
2947copies "len" bytes of memory over. If the argument is known to be aligned to
2948some boundary, this can be specified as the fourth argument, otherwise it should
2949be set to 0 or 1.
2950</p>
2951</div>
2952
Chris Lattner8ff75902004-01-06 05:31:32 +00002953
Chris Lattner10610642004-02-14 04:08:35 +00002954<!-- _______________________________________________________________________ -->
2955<div class="doc_subsubsection">
2956 <a name="i_memset">'<tt>llvm.memset</tt>' Intrinsic</a>
2957</div>
2958
2959<div class="doc_text">
2960
2961<h5>Syntax:</h5>
2962<pre>
Reid Spencerd4622352005-04-26 20:41:16 +00002963 declare void %llvm.memset(sbyte* &lt;dest&gt;, ubyte &lt;val&gt;,
2964 uint &lt;len&gt;, uint &lt;align&gt;)
Chris Lattner10610642004-02-14 04:08:35 +00002965</pre>
2966
2967<h5>Overview:</h5>
2968
2969<p>
2970The '<tt>llvm.memset</tt>' intrinsic fills a block of memory with a particular
2971byte value.
2972</p>
2973
2974<p>
2975Note that, unlike the standard libc function, the <tt>llvm.memset</tt> intrinsic
2976does not return a value, and takes an extra alignment argument.
2977</p>
2978
2979<h5>Arguments:</h5>
2980
2981<p>
2982The first argument is a pointer to the destination to fill, the second is the
2983byte value to fill it with, the third argument is an (arbitrarily sized) integer
2984argument specifying the number of bytes to fill, and the fourth argument is the
2985known alignment of destination location.
2986</p>
2987
2988<p>
2989If the call to this intrinisic has an alignment value that is not 0 or 1, then
2990the caller guarantees that the size of the copy is a multiple of the alignment
2991and that the destination pointer is aligned to that boundary.
2992</p>
2993
2994<h5>Semantics:</h5>
2995
2996<p>
2997The '<tt>llvm.memset</tt>' intrinsic fills "len" bytes of memory starting at the
2998destination location. If the argument is known to be aligned to some boundary,
2999this can be specified as the fourth argument, otherwise it should be set to 0 or
30001.
3001</p>
3002</div>
3003
3004
Chris Lattner32006282004-06-11 02:28:03 +00003005<!-- _______________________________________________________________________ -->
3006<div class="doc_subsubsection">
Alkis Evlogimenos26bbe932004-06-13 01:16:15 +00003007 <a name="i_isunordered">'<tt>llvm.isunordered</tt>' Intrinsic</a>
3008</div>
3009
3010<div class="doc_text">
3011
3012<h5>Syntax:</h5>
3013<pre>
Reid Spencera8d451e2005-04-26 20:50:44 +00003014 declare bool %llvm.isunordered(&lt;float or double&gt; Val1, &lt;float or double&gt; Val2)
Alkis Evlogimenos26bbe932004-06-13 01:16:15 +00003015</pre>
3016
3017<h5>Overview:</h5>
3018
3019<p>
3020The '<tt>llvm.isunordered</tt>' intrinsic returns true if either or both of the
3021specified floating point values is a NAN.
3022</p>
3023
3024<h5>Arguments:</h5>
3025
3026<p>
3027The arguments are floating point numbers of the same type.
3028</p>
3029
3030<h5>Semantics:</h5>
3031
3032<p>
3033If either or both of the arguments is a SNAN or QNAN, it returns true, otherwise
3034false.
3035</p>
3036</div>
3037
3038
Andrew Lenharthec370fd2005-05-03 18:01:48 +00003039<!-- ======================================================================= -->
3040<div class="doc_subsection">
3041 <a name="int_count">Bit Counting Intrinsics</a>
3042</div>
3043
3044<div class="doc_text">
3045<p>
3046LLVM provides intrinsics for a few important bit counting operations.
3047These allow efficient code generation for some algorithms.
3048</p>
3049
3050</div>
3051
3052<!-- _______________________________________________________________________ -->
3053<div class="doc_subsubsection">
3054 <a name="int_ctpop">'<tt>llvm.ctpop</tt>' Intrinsic</a>
3055</div>
3056
3057<div class="doc_text">
3058
3059<h5>Syntax:</h5>
3060<pre>
3061 declare int %llvm.ctpop(int &lt;src&gt;)
3062
3063</pre>
3064
3065<h5>Overview:</h5>
3066
3067<p>
3068The '<tt>llvm.ctpop</tt>' intrinsic counts the number of ones in a variable.
3069</p>
3070
3071<h5>Arguments:</h5>
3072
3073<p>
3074The only argument is the value to be counted.
3075</p>
3076
3077<h5>Semantics:</h5>
3078
3079<p>
3080The '<tt>llvm.ctpop</tt>' intrinsic counts the 1's in a variable.
3081</p>
3082</div>
3083
3084<!-- _______________________________________________________________________ -->
3085<div class="doc_subsubsection">
3086 <a name="int_cttz">'<tt>llvm.cttz</tt>' Intrinsic</a>
3087</div>
3088
3089<div class="doc_text">
3090
3091<h5>Syntax:</h5>
3092<pre>
3093 declare int %llvm.cttz(int &lt;src&gt;)
3094
3095</pre>
3096
3097<h5>Overview:</h5>
3098
3099<p>
3100The '<tt>llvm.cttz</tt>' intrinsic counts the number of trailing zeros.
3101</p>
3102
3103<h5>Arguments:</h5>
3104
3105<p>
3106The only argument is the value to be counted.
3107</p>
3108
3109<h5>Semantics:</h5>
3110
3111<p>
3112The '<tt>llvm.cttz</tt>' intrinsic counts the trailing zeros in a variable. If the src == 0
3113then the result is the size in bits of the type of src.
3114</p>
3115</div>
3116
3117<!-- _______________________________________________________________________ -->
3118<div class="doc_subsubsection">
3119 <a name="int_ctlz">'<tt>llvm.ctlz</tt>' Intrinsic</a>
3120</div>
3121
3122<div class="doc_text">
3123
3124<h5>Syntax:</h5>
3125<pre>
3126 declare int %llvm.ctlz(int &lt;src&gt;)
3127
3128</pre>
3129
3130<h5>Overview:</h5>
3131
3132<p>
3133The '<tt>llvm.ctlz</tt>' intrinsic counts the number of leading zeros in a variable.
3134</p>
3135
3136<h5>Arguments:</h5>
3137
3138<p>
3139The only argument is the value to be counted.
3140</p>
3141
3142<h5>Semantics:</h5>
3143
3144<p>
3145The '<tt>llvm.ctlz</tt>' intrinsic counts the leading zeros in a variable. If the src == 0
3146then the result is the size in bits of the type of src.
3147</p>
3148</div>
Chris Lattner32006282004-06-11 02:28:03 +00003149
3150
Chris Lattner8ff75902004-01-06 05:31:32 +00003151<!-- ======================================================================= -->
3152<div class="doc_subsection">
3153 <a name="int_debugger">Debugger Intrinsics</a>
3154</div>
3155
3156<div class="doc_text">
3157<p>
3158The LLVM debugger intrinsics (which all start with <tt>llvm.dbg.</tt> prefix),
3159are described in the <a
3160href="SourceLevelDebugging.html#format_common_intrinsics">LLVM Source Level
3161Debugging</a> document.
3162</p>
3163</div>
3164
3165
Chris Lattner00950542001-06-06 20:29:01 +00003166<!-- *********************************************************************** -->
Chris Lattner00950542001-06-06 20:29:01 +00003167<hr>
Misha Brukmandaa4cb02004-03-01 17:47:27 +00003168<address>
3169 <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
3170 src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
3171 <a href="http://validator.w3.org/check/referer"><img
3172 src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /></a>
3173
3174 <a href="mailto:sabre@nondot.org">Chris Lattner</a><br>
3175 <a href="http://llvm.cs.uiuc.edu">The LLVM Compiler Infrastructure</a><br>
3176 Last modified: $Date$
3177</address>
Misha Brukman9d0919f2003-11-08 01:05:38 +00003178</body>
3179</html>