blob: 7f404af10b959372945b8915479510d7a8eef3ea [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 Lattnerbad10ee2005-05-06 22:57:40 +000024 <li><a href="#callingconv">Calling Conventions</a></li>
Chris Lattnerfa730212004-12-09 16:11:40 +000025 <li><a href="#globalvars">Global Variables</a></li>
Chris Lattner4e9aba72006-01-23 23:23:47 +000026 <li><a href="#functionstructure">Functions</a></li>
27 <li><a href="#moduleasm">Module-Level Inline Assembly</a></li>
Chris Lattnerfa730212004-12-09 16:11:40 +000028 </ol>
29 </li>
Chris Lattner00950542001-06-06 20:29:01 +000030 <li><a href="#typesystem">Type System</a>
31 <ol>
Robert Bocchino7b81c752006-02-17 21:18:08 +000032 <li><a href="#t_primitive">Primitive Types</a>
Chris Lattner261efe92003-11-25 01:02:51 +000033 <ol>
Misha Brukman9d0919f2003-11-08 01:05:38 +000034 <li><a href="#t_classifications">Type Classifications</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000035 </ol>
36 </li>
Chris Lattner00950542001-06-06 20:29:01 +000037 <li><a href="#t_derived">Derived Types</a>
38 <ol>
Chris Lattner261efe92003-11-25 01:02:51 +000039 <li><a href="#t_array">Array Type</a></li>
Misha Brukman9d0919f2003-11-08 01:05:38 +000040 <li><a href="#t_function">Function Type</a></li>
41 <li><a href="#t_pointer">Pointer Type</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000042 <li><a href="#t_struct">Structure Type</a></li>
Chris Lattnera58561b2004-08-12 19:12:28 +000043 <li><a href="#t_packed">Packed Type</a></li>
Chris Lattner69c11bb2005-04-25 17:34:15 +000044 <li><a href="#t_opaque">Opaque Type</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000045 </ol>
46 </li>
47 </ol>
48 </li>
Chris Lattnerfa730212004-12-09 16:11:40 +000049 <li><a href="#constants">Constants</a>
Chris Lattnerc3f59762004-12-09 17:30:23 +000050 <ol>
51 <li><a href="#simpleconstants">Simple Constants</a>
52 <li><a href="#aggregateconstants">Aggregate Constants</a>
53 <li><a href="#globalconstants">Global Variable and Function Addresses</a>
54 <li><a href="#undefvalues">Undefined Values</a>
55 <li><a href="#constantexprs">Constant Expressions</a>
56 </ol>
Chris Lattner261efe92003-11-25 01:02:51 +000057 </li>
Chris Lattnere87d6532006-01-25 23:47:57 +000058 <li><a href="#othervalues">Other Values</a>
59 <ol>
60 <li><a href="#inlineasm">Inline Assembler Expressions</a>
61 </ol>
62 </li>
Chris Lattner00950542001-06-06 20:29:01 +000063 <li><a href="#instref">Instruction Reference</a>
64 <ol>
65 <li><a href="#terminators">Terminator Instructions</a>
66 <ol>
Chris Lattner261efe92003-11-25 01:02:51 +000067 <li><a href="#i_ret">'<tt>ret</tt>' Instruction</a></li>
68 <li><a href="#i_br">'<tt>br</tt>' Instruction</a></li>
Misha Brukman9d0919f2003-11-08 01:05:38 +000069 <li><a href="#i_switch">'<tt>switch</tt>' Instruction</a></li>
70 <li><a href="#i_invoke">'<tt>invoke</tt>' Instruction</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000071 <li><a href="#i_unwind">'<tt>unwind</tt>' Instruction</a></li>
Chris Lattner35eca582004-10-16 18:04:13 +000072 <li><a href="#i_unreachable">'<tt>unreachable</tt>' Instruction</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000073 </ol>
74 </li>
Chris Lattner00950542001-06-06 20:29:01 +000075 <li><a href="#binaryops">Binary Operations</a>
76 <ol>
Chris Lattner261efe92003-11-25 01:02:51 +000077 <li><a href="#i_add">'<tt>add</tt>' Instruction</a></li>
78 <li><a href="#i_sub">'<tt>sub</tt>' Instruction</a></li>
79 <li><a href="#i_mul">'<tt>mul</tt>' Instruction</a></li>
Reid Spencer1628cec2006-10-26 06:15:43 +000080 <li><a href="#i_udiv">'<tt>udiv</tt>' Instruction</a></li>
81 <li><a href="#i_sdiv">'<tt>sdiv</tt>' Instruction</a></li>
82 <li><a href="#i_fdiv">'<tt>fdiv</tt>' Instruction</a></li>
Reid Spencer0a783f72006-11-02 01:53:59 +000083 <li><a href="#i_urem">'<tt>urem</tt>' Instruction</a></li>
84 <li><a href="#i_srem">'<tt>srem</tt>' Instruction</a></li>
85 <li><a href="#i_frem">'<tt>frem</tt>' Instruction</a></li>
Misha Brukman9d0919f2003-11-08 01:05:38 +000086 <li><a href="#i_setcc">'<tt>set<i>cc</i></tt>' Instructions</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000087 </ol>
88 </li>
Chris Lattner00950542001-06-06 20:29:01 +000089 <li><a href="#bitwiseops">Bitwise Binary Operations</a>
90 <ol>
Misha Brukman9d0919f2003-11-08 01:05:38 +000091 <li><a href="#i_and">'<tt>and</tt>' Instruction</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000092 <li><a href="#i_or">'<tt>or</tt>' Instruction</a></li>
Misha Brukman9d0919f2003-11-08 01:05:38 +000093 <li><a href="#i_xor">'<tt>xor</tt>' Instruction</a></li>
94 <li><a href="#i_shl">'<tt>shl</tt>' Instruction</a></li>
Reid Spencer3822ff52006-11-08 06:47:33 +000095 <li><a href="#i_lshr">'<tt>lshr</tt>' Instruction</a></li>
96 <li><a href="#i_ashr">'<tt>ashr</tt>' Instruction</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +000097 </ol>
98 </li>
Chris Lattner3df241e2006-04-08 23:07:04 +000099 <li><a href="#vectorops">Vector Operations</a>
100 <ol>
101 <li><a href="#i_extractelement">'<tt>extractelement</tt>' Instruction</a></li>
102 <li><a href="#i_insertelement">'<tt>insertelement</tt>' Instruction</a></li>
103 <li><a href="#i_shufflevector">'<tt>shufflevector</tt>' Instruction</a></li>
Chris Lattner3df241e2006-04-08 23:07:04 +0000104 </ol>
105 </li>
Chris Lattner884a9702006-08-15 00:45:58 +0000106 <li><a href="#memoryops">Memory Access and Addressing Operations</a>
Chris Lattner00950542001-06-06 20:29:01 +0000107 <ol>
Chris Lattner261efe92003-11-25 01:02:51 +0000108 <li><a href="#i_malloc">'<tt>malloc</tt>' Instruction</a></li>
109 <li><a href="#i_free">'<tt>free</tt>' Instruction</a></li>
110 <li><a href="#i_alloca">'<tt>alloca</tt>' Instruction</a></li>
Robert Bocchino7b81c752006-02-17 21:18:08 +0000111 <li><a href="#i_load">'<tt>load</tt>' Instruction</a></li>
112 <li><a href="#i_store">'<tt>store</tt>' Instruction</a></li>
113 <li><a href="#i_getelementptr">'<tt>getelementptr</tt>' Instruction</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +0000114 </ol>
115 </li>
Reid Spencer2fd21e62006-11-08 01:18:52 +0000116 <li><a href="#convertops">Conversion Operations</a>
Reid Spencer9dee3ac2006-11-08 01:11:31 +0000117 <ol>
118 <li><a href="#i_trunc">'<tt>trunc .. to</tt>' Instruction</a></li>
119 <li><a href="#i_zext">'<tt>zext .. to</tt>' Instruction</a></li>
120 <li><a href="#i_sext">'<tt>sext .. to</tt>' Instruction</a></li>
121 <li><a href="#i_fptrunc">'<tt>fptrunc .. to</tt>' Instruction</a></li>
122 <li><a href="#i_fpext">'<tt>fpext .. to</tt>' Instruction</a></li>
Reid Spencerd4448792006-11-09 23:03:26 +0000123 <li><a href="#i_fptoui">'<tt>fptoui .. to</tt>' Instruction</a></li>
124 <li><a href="#i_fptosi">'<tt>fptosi .. to</tt>' Instruction</a></li>
125 <li><a href="#i_uitofp">'<tt>uitofp .. to</tt>' Instruction</a></li>
126 <li><a href="#i_sitofp">'<tt>sitofp .. to</tt>' Instruction</a></li>
Reid Spencer72679252006-11-11 21:00:47 +0000127 <li><a href="#i_ptrtoint">'<tt>ptrtoint .. to</tt>' Instruction</a></li>
128 <li><a href="#i_inttoptr">'<tt>inttoptr .. to</tt>' Instruction</a></li>
Reid Spencer5c0ef472006-11-11 23:08:07 +0000129 <li><a href="#i_bitcast">'<tt>bitcast .. to</tt>' Instruction</a></li>
Reid Spencer9dee3ac2006-11-08 01:11:31 +0000130 </ol>
Chris Lattner00950542001-06-06 20:29:01 +0000131 <li><a href="#otherops">Other Operations</a>
132 <ol>
Chris Lattner261efe92003-11-25 01:02:51 +0000133 <li><a href="#i_phi">'<tt>phi</tt>' Instruction</a></li>
Chris Lattnercc37aae2004-03-12 05:50:16 +0000134 <li><a href="#i_select">'<tt>select</tt>' Instruction</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +0000135 <li><a href="#i_call">'<tt>call</tt>' Instruction</a></li>
Chris Lattnerfb6977d2006-01-13 23:26:01 +0000136 <li><a href="#i_va_arg">'<tt>va_arg</tt>' Instruction</a></li>
Chris Lattner00950542001-06-06 20:29:01 +0000137 </ol>
Chris Lattner261efe92003-11-25 01:02:51 +0000138 </li>
Chris Lattner00950542001-06-06 20:29:01 +0000139 </ol>
Chris Lattner261efe92003-11-25 01:02:51 +0000140 </li>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +0000141 <li><a href="#intrinsics">Intrinsic Functions</a>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +0000142 <ol>
Chris Lattner261efe92003-11-25 01:02:51 +0000143 <li><a href="#int_varargs">Variable Argument Handling Intrinsics</a>
144 <ol>
145 <li><a href="#i_va_start">'<tt>llvm.va_start</tt>' Intrinsic</a></li>
146 <li><a href="#i_va_end">'<tt>llvm.va_end</tt>' Intrinsic</a></li>
147 <li><a href="#i_va_copy">'<tt>llvm.va_copy</tt>' Intrinsic</a></li>
148 </ol>
149 </li>
Chris Lattnerd7923912004-05-23 21:06:01 +0000150 <li><a href="#int_gc">Accurate Garbage Collection Intrinsics</a>
151 <ol>
152 <li><a href="#i_gcroot">'<tt>llvm.gcroot</tt>' Intrinsic</a></li>
153 <li><a href="#i_gcread">'<tt>llvm.gcread</tt>' Intrinsic</a></li>
154 <li><a href="#i_gcwrite">'<tt>llvm.gcwrite</tt>' Intrinsic</a></li>
155 </ol>
156 </li>
Chris Lattner10610642004-02-14 04:08:35 +0000157 <li><a href="#int_codegen">Code Generator Intrinsics</a>
158 <ol>
159 <li><a href="#i_returnaddress">'<tt>llvm.returnaddress</tt>' Intrinsic</a></li>
160 <li><a href="#i_frameaddress">'<tt>llvm.frameaddress</tt>' Intrinsic</a></li>
Chris Lattner57e1f392006-01-13 02:03:13 +0000161 <li><a href="#i_stacksave">'<tt>llvm.stacksave</tt>' Intrinsic</a></li>
162 <li><a href="#i_stackrestore">'<tt>llvm.stackrestore</tt>' Intrinsic</a></li>
Chris Lattner9a9d7ac2005-02-28 19:24:19 +0000163 <li><a href="#i_prefetch">'<tt>llvm.prefetch</tt>' Intrinsic</a></li>
Andrew Lenharth7f4ec3b2005-03-28 20:05:49 +0000164 <li><a href="#i_pcmarker">'<tt>llvm.pcmarker</tt>' Intrinsic</a></li>
Andrew Lenharth51b8d542005-11-11 16:47:30 +0000165 <li><a href="#i_readcyclecounter"><tt>llvm.readcyclecounter</tt>' Intrinsic</a></li>
John Criswell7123e272004-04-09 16:43:20 +0000166 </ol>
167 </li>
Chris Lattner33aec9e2004-02-12 17:01:32 +0000168 <li><a href="#int_libc">Standard C Library Intrinsics</a>
169 <ol>
Chris Lattner5b310c32006-03-03 00:07:20 +0000170 <li><a href="#i_memcpy">'<tt>llvm.memcpy.*</tt>' Intrinsic</a></li>
171 <li><a href="#i_memmove">'<tt>llvm.memmove.*</tt>' Intrinsic</a></li>
172 <li><a href="#i_memset">'<tt>llvm.memset.*</tt>' Intrinsic</a></li>
Chris Lattnerec6cb612006-01-16 22:38:59 +0000173 <li><a href="#i_isunordered">'<tt>llvm.isunordered.*</tt>' Intrinsic</a></li>
174 <li><a href="#i_sqrt">'<tt>llvm.sqrt.*</tt>' Intrinsic</a></li>
Chris Lattnerf4d252d2006-09-08 06:34:02 +0000175 <li><a href="#i_powi">'<tt>llvm.powi.*</tt>' Intrinsic</a></li>
Chris Lattner33aec9e2004-02-12 17:01:32 +0000176 </ol>
177 </li>
Nate Begeman7e36c472006-01-13 23:26:38 +0000178 <li><a href="#int_manip">Bit Manipulation Intrinsics</a>
Andrew Lenharthec370fd2005-05-03 18:01:48 +0000179 <ol>
Nate Begeman7e36c472006-01-13 23:26:38 +0000180 <li><a href="#i_bswap">'<tt>llvm.bswap.*</tt>' Intrinsics</a></li>
Chris Lattner8a886be2006-01-16 22:34:14 +0000181 <li><a href="#int_ctpop">'<tt>llvm.ctpop.*</tt>' Intrinsic </a></li>
182 <li><a href="#int_ctlz">'<tt>llvm.ctlz.*</tt>' Intrinsic </a></li>
183 <li><a href="#int_cttz">'<tt>llvm.cttz.*</tt>' Intrinsic </a></li>
Andrew Lenharthec370fd2005-05-03 18:01:48 +0000184 </ol>
185 </li>
Chris Lattnerd7923912004-05-23 21:06:01 +0000186 <li><a href="#int_debugger">Debugger intrinsics</a></li>
Chris Lattner261efe92003-11-25 01:02:51 +0000187 </ol>
188 </li>
Chris Lattner00950542001-06-06 20:29:01 +0000189</ol>
Chris Lattnerd7923912004-05-23 21:06:01 +0000190
191<div class="doc_author">
192 <p>Written by <a href="mailto:sabre@nondot.org">Chris Lattner</a>
193 and <a href="mailto:vadve@cs.uiuc.edu">Vikram Adve</a></p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000194</div>
Chris Lattnerd7923912004-05-23 21:06:01 +0000195
Chris Lattner00950542001-06-06 20:29:01 +0000196<!-- *********************************************************************** -->
Chris Lattner261efe92003-11-25 01:02:51 +0000197<div class="doc_section"> <a name="abstract">Abstract </a></div>
198<!-- *********************************************************************** -->
Chris Lattnerd7923912004-05-23 21:06:01 +0000199
Misha Brukman9d0919f2003-11-08 01:05:38 +0000200<div class="doc_text">
Chris Lattner261efe92003-11-25 01:02:51 +0000201<p>This document is a reference manual for the LLVM assembly language.
202LLVM is an SSA based representation that provides type safety,
203low-level operations, flexibility, and the capability of representing
204'all' high-level languages cleanly. It is the common code
205representation used throughout all phases of the LLVM compilation
206strategy.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000207</div>
Chris Lattnerd7923912004-05-23 21:06:01 +0000208
Chris Lattner00950542001-06-06 20:29:01 +0000209<!-- *********************************************************************** -->
Chris Lattner261efe92003-11-25 01:02:51 +0000210<div class="doc_section"> <a name="introduction">Introduction</a> </div>
211<!-- *********************************************************************** -->
Chris Lattnerd7923912004-05-23 21:06:01 +0000212
Misha Brukman9d0919f2003-11-08 01:05:38 +0000213<div class="doc_text">
Chris Lattnerd7923912004-05-23 21:06:01 +0000214
Chris Lattner261efe92003-11-25 01:02:51 +0000215<p>The LLVM code representation is designed to be used in three
216different forms: as an in-memory compiler IR, as an on-disk bytecode
217representation (suitable for fast loading by a Just-In-Time compiler),
218and as a human readable assembly language representation. This allows
219LLVM to provide a powerful intermediate representation for efficient
220compiler transformations and analysis, while providing a natural means
221to debug and visualize the transformations. The three different forms
222of LLVM are all equivalent. This document describes the human readable
223representation and notation.</p>
Chris Lattnerd7923912004-05-23 21:06:01 +0000224
John Criswellc1f786c2005-05-13 22:25:59 +0000225<p>The LLVM representation aims to be light-weight and low-level
Chris Lattner261efe92003-11-25 01:02:51 +0000226while being expressive, typed, and extensible at the same time. It
227aims to be a "universal IR" of sorts, by being at a low enough level
228that high-level ideas may be cleanly mapped to it (similar to how
229microprocessors are "universal IR's", allowing many source languages to
230be mapped to them). By providing type information, LLVM can be used as
231the target of optimizations: for example, through pointer analysis, it
232can be proven that a C automatic variable is never accessed outside of
233the current function... allowing it to be promoted to a simple SSA
234value instead of a memory location.</p>
Chris Lattnerd7923912004-05-23 21:06:01 +0000235
Misha Brukman9d0919f2003-11-08 01:05:38 +0000236</div>
Chris Lattnerd7923912004-05-23 21:06:01 +0000237
Chris Lattner00950542001-06-06 20:29:01 +0000238<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000239<div class="doc_subsubsection"> <a name="wellformed">Well-Formedness</a> </div>
Chris Lattnerd7923912004-05-23 21:06:01 +0000240
Misha Brukman9d0919f2003-11-08 01:05:38 +0000241<div class="doc_text">
Chris Lattnerd7923912004-05-23 21:06:01 +0000242
Chris Lattner261efe92003-11-25 01:02:51 +0000243<p>It is important to note that this document describes 'well formed'
244LLVM assembly language. There is a difference between what the parser
245accepts and what is considered 'well formed'. For example, the
246following instruction is syntactically okay, but not well formed:</p>
Chris Lattnerd7923912004-05-23 21:06:01 +0000247
248<pre>
249 %x = <a href="#i_add">add</a> int 1, %x
250</pre>
251
Chris Lattner261efe92003-11-25 01:02:51 +0000252<p>...because the definition of <tt>%x</tt> does not dominate all of
253its uses. The LLVM infrastructure provides a verification pass that may
254be used to verify that an LLVM module is well formed. This pass is
John Criswellc1f786c2005-05-13 22:25:59 +0000255automatically run by the parser after parsing input assembly and by
Chris Lattner261efe92003-11-25 01:02:51 +0000256the optimizer before it outputs bytecode. The violations pointed out
257by the verifier pass indicate bugs in transformation passes or input to
258the parser.</p>
Chris Lattnerd7923912004-05-23 21:06:01 +0000259
Chris Lattner261efe92003-11-25 01:02:51 +0000260<!-- Describe the typesetting conventions here. --> </div>
Chris Lattnerd7923912004-05-23 21:06:01 +0000261
Chris Lattner00950542001-06-06 20:29:01 +0000262<!-- *********************************************************************** -->
Chris Lattner261efe92003-11-25 01:02:51 +0000263<div class="doc_section"> <a name="identifiers">Identifiers</a> </div>
Chris Lattner00950542001-06-06 20:29:01 +0000264<!-- *********************************************************************** -->
Chris Lattnerd7923912004-05-23 21:06:01 +0000265
Misha Brukman9d0919f2003-11-08 01:05:38 +0000266<div class="doc_text">
Chris Lattnerd7923912004-05-23 21:06:01 +0000267
Chris Lattner261efe92003-11-25 01:02:51 +0000268<p>LLVM uses three different forms of identifiers, for different
269purposes:</p>
Chris Lattnerd7923912004-05-23 21:06:01 +0000270
Chris Lattner00950542001-06-06 20:29:01 +0000271<ol>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000272 <li>Named values are represented as a string of characters with a '%' prefix.
273 For example, %foo, %DivisionByZero, %a.really.long.identifier. The actual
274 regular expression used is '<tt>%[a-zA-Z$._][a-zA-Z$._0-9]*</tt>'.
275 Identifiers which require other characters in their names can be surrounded
276 with quotes. In this way, anything except a <tt>"</tt> character can be used
277 in a name.</li>
278
279 <li>Unnamed values are represented as an unsigned numeric value with a '%'
280 prefix. For example, %12, %2, %44.</li>
281
Reid Spencercc16dc32004-12-09 18:02:53 +0000282 <li>Constants, which are described in a <a href="#constants">section about
283 constants</a>, below.</li>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000284</ol>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000285
286<p>LLVM requires that values start with a '%' sign for two reasons: Compilers
287don't need to worry about name clashes with reserved words, and the set of
288reserved words may be expanded in the future without penalty. Additionally,
289unnamed identifiers allow a compiler to quickly come up with a temporary
290variable without having to avoid symbol table conflicts.</p>
291
Chris Lattner261efe92003-11-25 01:02:51 +0000292<p>Reserved words in LLVM are very similar to reserved words in other
Reid Spencer5c0ef472006-11-11 23:08:07 +0000293languages. There are keywords for different opcodes
294('<tt><a href="#i_add">add</a></tt>',
295 '<tt><a href="#i_bitcast">bitcast</a></tt>',
296 '<tt><a href="#i_ret">ret</a></tt>', etc...), for primitive type names ('<tt><a
Chris Lattnere5d947b2004-12-09 16:36:40 +0000297href="#t_void">void</a></tt>', '<tt><a href="#t_uint">uint</a></tt>', etc...),
298and others. These reserved words cannot conflict with variable names, because
299none of them start with a '%' character.</p>
300
301<p>Here is an example of LLVM code to multiply the integer variable
302'<tt>%X</tt>' by 8:</p>
303
Misha Brukman9d0919f2003-11-08 01:05:38 +0000304<p>The easy way:</p>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000305
306<pre>
307 %result = <a href="#i_mul">mul</a> uint %X, 8
308</pre>
309
Misha Brukman9d0919f2003-11-08 01:05:38 +0000310<p>After strength reduction:</p>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000311
312<pre>
313 %result = <a href="#i_shl">shl</a> uint %X, ubyte 3
314</pre>
315
Misha Brukman9d0919f2003-11-08 01:05:38 +0000316<p>And the hard way:</p>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000317
318<pre>
319 <a href="#i_add">add</a> uint %X, %X <i>; yields {uint}:%0</i>
320 <a href="#i_add">add</a> uint %0, %0 <i>; yields {uint}:%1</i>
321 %result = <a href="#i_add">add</a> uint %1, %1
322</pre>
323
Chris Lattner261efe92003-11-25 01:02:51 +0000324<p>This last way of multiplying <tt>%X</tt> by 8 illustrates several
325important lexical features of LLVM:</p>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000326
Chris Lattner00950542001-06-06 20:29:01 +0000327<ol>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000328
329 <li>Comments are delimited with a '<tt>;</tt>' and go until the end of
330 line.</li>
331
332 <li>Unnamed temporaries are created when the result of a computation is not
333 assigned to a named value.</li>
334
Misha Brukman9d0919f2003-11-08 01:05:38 +0000335 <li>Unnamed temporaries are numbered sequentially</li>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000336
Misha Brukman9d0919f2003-11-08 01:05:38 +0000337</ol>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000338
John Criswelle4c57cc2005-05-12 16:52:32 +0000339<p>...and it also shows a convention that we follow in this document. When
Chris Lattnere5d947b2004-12-09 16:36:40 +0000340demonstrating instructions, we will follow an instruction with a comment that
341defines the type and name of value produced. Comments are shown in italic
342text.</p>
343
Misha Brukman9d0919f2003-11-08 01:05:38 +0000344</div>
Chris Lattnerfa730212004-12-09 16:11:40 +0000345
346<!-- *********************************************************************** -->
347<div class="doc_section"> <a name="highlevel">High Level Structure</a> </div>
348<!-- *********************************************************************** -->
349
350<!-- ======================================================================= -->
351<div class="doc_subsection"> <a name="modulestructure">Module Structure</a>
352</div>
353
354<div class="doc_text">
355
356<p>LLVM programs are composed of "Module"s, each of which is a
357translation unit of the input programs. Each module consists of
358functions, global variables, and symbol table entries. Modules may be
359combined together with the LLVM linker, which merges function (and
360global variable) definitions, resolves forward declarations, and merges
361symbol table entries. Here is an example of the "hello world" module:</p>
362
363<pre><i>; Declare the string constant as a global constant...</i>
364<a href="#identifiers">%.LC0</a> = <a href="#linkage_internal">internal</a> <a
365 href="#globalvars">constant</a> <a href="#t_array">[13 x sbyte]</a> c"hello world\0A\00" <i>; [13 x sbyte]*</i>
366
367<i>; External declaration of the puts function</i>
368<a href="#functionstructure">declare</a> int %puts(sbyte*) <i>; int(sbyte*)* </i>
369
Chris Lattner81c01f02006-06-13 03:05:47 +0000370<i>; Global variable / Function body section separator</i>
371implementation
372
Chris Lattnerfa730212004-12-09 16:11:40 +0000373<i>; Definition of main function</i>
374int %main() { <i>; int()* </i>
375 <i>; Convert [13x sbyte]* to sbyte *...</i>
376 %cast210 = <a
377 href="#i_getelementptr">getelementptr</a> [13 x sbyte]* %.LC0, long 0, long 0 <i>; sbyte*</i>
378
379 <i>; Call puts function to write out the string to stdout...</i>
380 <a
381 href="#i_call">call</a> int %puts(sbyte* %cast210) <i>; int</i>
382 <a
383 href="#i_ret">ret</a> int 0<br>}<br></pre>
384
385<p>This example is made up of a <a href="#globalvars">global variable</a>
386named "<tt>.LC0</tt>", an external declaration of the "<tt>puts</tt>"
387function, and a <a href="#functionstructure">function definition</a>
388for "<tt>main</tt>".</p>
389
Chris Lattnere5d947b2004-12-09 16:36:40 +0000390<p>In general, a module is made up of a list of global values,
391where both functions and global variables are global values. Global values are
392represented by a pointer to a memory location (in this case, a pointer to an
393array of char, and a pointer to a function), and have one of the following <a
394href="#linkage">linkage types</a>.</p>
Chris Lattnerfa730212004-12-09 16:11:40 +0000395
Chris Lattner81c01f02006-06-13 03:05:47 +0000396<p>Due to a limitation in the current LLVM assembly parser (it is limited by
397one-token lookahead), modules are split into two pieces by the "implementation"
398keyword. Global variable prototypes and definitions must occur before the
399keyword, and function definitions must occur after it. Function prototypes may
400occur either before or after it. In the future, the implementation keyword may
401become a noop, if the parser gets smarter.</p>
402
Chris Lattnere5d947b2004-12-09 16:36:40 +0000403</div>
404
405<!-- ======================================================================= -->
406<div class="doc_subsection">
407 <a name="linkage">Linkage Types</a>
408</div>
409
410<div class="doc_text">
411
412<p>
413All Global Variables and Functions have one of the following types of linkage:
414</p>
Chris Lattnerfa730212004-12-09 16:11:40 +0000415
416<dl>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000417
Chris Lattnerfa730212004-12-09 16:11:40 +0000418 <dt><tt><b><a name="linkage_internal">internal</a></b></tt> </dt>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000419
420 <dd>Global values with internal linkage are only directly accessible by
421 objects in the current module. In particular, linking code into a module with
422 an internal global value may cause the internal to be renamed as necessary to
423 avoid collisions. Because the symbol is internal to the module, all
424 references can be updated. This corresponds to the notion of the
425 '<tt>static</tt>' keyword in C, or the idea of "anonymous namespaces" in C++.
Chris Lattnerfa730212004-12-09 16:11:40 +0000426 </dd>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000427
Chris Lattnerfa730212004-12-09 16:11:40 +0000428 <dt><tt><b><a name="linkage_linkonce">linkonce</a></b></tt>: </dt>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000429
430 <dd>"<tt>linkonce</tt>" linkage is similar to <tt>internal</tt> linkage, with
431 the twist that linking together two modules defining the same
432 <tt>linkonce</tt> globals will cause one of the globals to be discarded. This
433 is typically used to implement inline functions. Unreferenced
434 <tt>linkonce</tt> globals are allowed to be discarded.
Chris Lattnerfa730212004-12-09 16:11:40 +0000435 </dd>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000436
Chris Lattnerfa730212004-12-09 16:11:40 +0000437 <dt><tt><b><a name="linkage_weak">weak</a></b></tt>: </dt>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000438
439 <dd>"<tt>weak</tt>" linkage is exactly the same as <tt>linkonce</tt> linkage,
440 except that unreferenced <tt>weak</tt> globals may not be discarded. This is
441 used to implement constructs in C such as "<tt>int X;</tt>" at global scope.
Chris Lattnerfa730212004-12-09 16:11:40 +0000442 </dd>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000443
Chris Lattnerfa730212004-12-09 16:11:40 +0000444 <dt><tt><b><a name="linkage_appending">appending</a></b></tt>: </dt>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000445
446 <dd>"<tt>appending</tt>" linkage may only be applied to global variables of
447 pointer to array type. When two global variables with appending linkage are
448 linked together, the two global arrays are appended together. This is the
449 LLVM, typesafe, equivalent of having the system linker append together
450 "sections" with identical names when .o files are linked.
Chris Lattnerfa730212004-12-09 16:11:40 +0000451 </dd>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000452
Chris Lattnerfa730212004-12-09 16:11:40 +0000453 <dt><tt><b><a name="linkage_external">externally visible</a></b></tt>:</dt>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000454
455 <dd>If none of the above identifiers are used, the global is externally
456 visible, meaning that it participates in linkage and can be used to resolve
457 external symbol references.
Chris Lattnerfa730212004-12-09 16:11:40 +0000458 </dd>
Anton Korobeynikovb74ed072006-09-14 18:23:27 +0000459
460 <dt><tt><b><a name="linkage_externweak">extern_weak</a></b></tt>: </dt>
461
462 <dd>"<tt>extern_weak</tt>" TBD
463 </dd>
464
465 <p>
466 The next two types of linkage are targeted for Microsoft Windows platform
467 only. They are designed to support importing (exporting) symbols from (to)
468 DLLs.
469 </p>
470
471 <dt><tt><b><a name="linkage_dllimport">dllimport</a></b></tt>: </dt>
472
473 <dd>"<tt>dllimport</tt>" linkage causes the compiler to reference a function
474 or variable via a global pointer to a pointer that is set up by the DLL
475 exporting the symbol. On Microsoft Windows targets, the pointer name is
476 formed by combining <code>_imp__</code> and the function or variable name.
477 </dd>
478
479 <dt><tt><b><a name="linkage_dllexport">dllexport</a></b></tt>: </dt>
480
481 <dd>"<tt>dllexport</tt>" linkage causes the compiler to provide a global
482 pointer to a pointer in a DLL, so that it can be referenced with the
483 <tt>dllimport</tt> attribute. On Microsoft Windows targets, the pointer
484 name is formed by combining <code>_imp__</code> and the function or variable
485 name.
486 </dd>
487
Chris Lattnerfa730212004-12-09 16:11:40 +0000488</dl>
489
Chris Lattnerfa730212004-12-09 16:11:40 +0000490<p><a name="linkage_external">For example, since the "<tt>.LC0</tt>"
491variable is defined to be internal, if another module defined a "<tt>.LC0</tt>"
492variable and was linked with this one, one of the two would be renamed,
493preventing a collision. Since "<tt>main</tt>" and "<tt>puts</tt>" are
494external (i.e., lacking any linkage declarations), they are accessible
495outside of the current module. It is illegal for a function <i>declaration</i>
496to have any linkage type other than "externally visible".</a></p>
Chris Lattnere5d947b2004-12-09 16:36:40 +0000497
Chris Lattnerfa730212004-12-09 16:11:40 +0000498</div>
499
500<!-- ======================================================================= -->
501<div class="doc_subsection">
Chris Lattnerbad10ee2005-05-06 22:57:40 +0000502 <a name="callingconv">Calling Conventions</a>
503</div>
504
505<div class="doc_text">
506
507<p>LLVM <a href="#functionstructure">functions</a>, <a href="#i_call">calls</a>
508and <a href="#i_invoke">invokes</a> can all have an optional calling convention
509specified for the call. The calling convention of any pair of dynamic
510caller/callee must match, or the behavior of the program is undefined. The
511following calling conventions are supported by LLVM, and more may be added in
512the future:</p>
513
514<dl>
515 <dt><b>"<tt>ccc</tt>" - The C calling convention</b>:</dt>
516
517 <dd>This calling convention (the default if no other calling convention is
518 specified) matches the target C calling conventions. This calling convention
John Criswelle4c57cc2005-05-12 16:52:32 +0000519 supports varargs function calls and tolerates some mismatch in the declared
Chris Lattnerbad10ee2005-05-06 22:57:40 +0000520 prototype and implemented declaration of the function (as does normal C).
521 </dd>
522
Chris Lattner5710ce92006-05-19 21:15:36 +0000523 <dt><b>"<tt>csretcc</tt>" - The C struct return calling convention</b>:</dt>
524
525 <dd>This calling convention matches the target C calling conventions, except
526 that functions with this convention are required to take a pointer as their
527 first argument, and the return type of the function must be void. This is
528 used for C functions that return aggregates by-value. In this case, the
529 function has been transformed to take a pointer to the struct as the first
530 argument to the function. For targets where the ABI specifies specific
531 behavior for structure-return calls, the calling convention can be used to
532 distinguish between struct return functions and other functions that take a
533 pointer to a struct as the first argument.
534 </dd>
535
Chris Lattnerbad10ee2005-05-06 22:57:40 +0000536 <dt><b>"<tt>fastcc</tt>" - The fast calling convention</b>:</dt>
537
538 <dd>This calling convention attempts to make calls as fast as possible
539 (e.g. by passing things in registers). This calling convention allows the
540 target to use whatever tricks it wants to produce fast code for the target,
Chris Lattner8cdc5bc2005-05-06 23:08:23 +0000541 without having to conform to an externally specified ABI. Implementations of
542 this convention should allow arbitrary tail call optimization to be supported.
543 This calling convention does not support varargs and requires the prototype of
544 all callees to exactly match the prototype of the function definition.
Chris Lattnerbad10ee2005-05-06 22:57:40 +0000545 </dd>
546
547 <dt><b>"<tt>coldcc</tt>" - The cold calling convention</b>:</dt>
548
549 <dd>This calling convention attempts to make code in the caller as efficient
550 as possible under the assumption that the call is not commonly executed. As
551 such, these calls often preserve all registers so that the call does not break
552 any live ranges in the caller side. This calling convention does not support
553 varargs and requires the prototype of all callees to exactly match the
554 prototype of the function definition.
555 </dd>
556
Chris Lattnercfe6b372005-05-07 01:46:40 +0000557 <dt><b>"<tt>cc &lt;<em>n</em>&gt;</tt>" - Numbered convention</b>:</dt>
Chris Lattnerbad10ee2005-05-06 22:57:40 +0000558
559 <dd>Any calling convention may be specified by number, allowing
560 target-specific calling conventions to be used. Target specific calling
561 conventions start at 64.
562 </dd>
Chris Lattnercfe6b372005-05-07 01:46:40 +0000563</dl>
Chris Lattnerbad10ee2005-05-06 22:57:40 +0000564
565<p>More calling conventions can be added/defined on an as-needed basis, to
566support pascal conventions or any other well-known target-independent
567convention.</p>
568
569</div>
570
571<!-- ======================================================================= -->
572<div class="doc_subsection">
Chris Lattnerfa730212004-12-09 16:11:40 +0000573 <a name="globalvars">Global Variables</a>
574</div>
575
576<div class="doc_text">
577
Chris Lattner3689a342005-02-12 19:30:21 +0000578<p>Global variables define regions of memory allocated at compilation time
Chris Lattner88f6c462005-11-12 00:45:07 +0000579instead of run-time. Global variables may optionally be initialized, may have
580an explicit section to be placed in, and may
Chris Lattner2cbdc452005-11-06 08:02:57 +0000581have an optional explicit alignment specified. A
John Criswell0ec250c2005-10-24 16:17:18 +0000582variable may be defined as a global "constant," which indicates that the
Chris Lattner3689a342005-02-12 19:30:21 +0000583contents of the variable will <b>never</b> be modified (enabling better
584optimization, allowing the global data to be placed in the read-only section of
585an executable, etc). Note that variables that need runtime initialization
John Criswell0ec250c2005-10-24 16:17:18 +0000586cannot be marked "constant" as there is a store to the variable.</p>
Chris Lattner3689a342005-02-12 19:30:21 +0000587
588<p>
589LLVM explicitly allows <em>declarations</em> of global variables to be marked
590constant, even if the final definition of the global is not. This capability
591can be used to enable slightly better optimization of the program, but requires
592the language definition to guarantee that optimizations based on the
593'constantness' are valid for the translation units that do not include the
594definition.
595</p>
Chris Lattnerfa730212004-12-09 16:11:40 +0000596
597<p>As SSA values, global variables define pointer values that are in
598scope (i.e. they dominate) all basic blocks in the program. Global
599variables always define a pointer to their "content" type because they
600describe a region of memory, and all memory objects in LLVM are
601accessed through pointers.</p>
602
Chris Lattner88f6c462005-11-12 00:45:07 +0000603<p>LLVM allows an explicit section to be specified for globals. If the target
604supports it, it will emit globals to the section specified.</p>
605
Chris Lattner2cbdc452005-11-06 08:02:57 +0000606<p>An explicit alignment may be specified for a global. If not present, or if
607the alignment is set to zero, the alignment of the global is set by the target
608to whatever it feels convenient. If an explicit alignment is specified, the
609global is forced to have at least that much alignment. All alignments must be
610a power of 2.</p>
611
Chris Lattnerfa730212004-12-09 16:11:40 +0000612</div>
613
614
615<!-- ======================================================================= -->
616<div class="doc_subsection">
617 <a name="functionstructure">Functions</a>
618</div>
619
620<div class="doc_text">
621
Chris Lattnerbad10ee2005-05-06 22:57:40 +0000622<p>LLVM function definitions consist of an optional <a href="#linkage">linkage
623type</a>, an optional <a href="#callingconv">calling convention</a>, a return
Chris Lattner88f6c462005-11-12 00:45:07 +0000624type, a function name, a (possibly empty) argument list, an optional section,
625an optional alignment, an opening curly brace,
Chris Lattnerbad10ee2005-05-06 22:57:40 +0000626a list of basic blocks, and a closing curly brace. LLVM function declarations
627are defined with the "<tt>declare</tt>" keyword, an optional <a
Chris Lattner2cbdc452005-11-06 08:02:57 +0000628href="#callingconv">calling convention</a>, a return type, a function name,
629a possibly empty list of arguments, and an optional alignment.</p>
Chris Lattnerfa730212004-12-09 16:11:40 +0000630
631<p>A function definition contains a list of basic blocks, forming the CFG for
632the function. Each basic block may optionally start with a label (giving the
633basic block a symbol table entry), contains a list of instructions, and ends
634with a <a href="#terminators">terminator</a> instruction (such as a branch or
635function return).</p>
636
John Criswelle4c57cc2005-05-12 16:52:32 +0000637<p>The first basic block in a program is special in two ways: it is immediately
Chris Lattnerfa730212004-12-09 16:11:40 +0000638executed on entrance to the function, and it is not allowed to have predecessor
639basic blocks (i.e. there can not be any branches to the entry block of a
640function). Because the block can have no predecessors, it also cannot have any
641<a href="#i_phi">PHI nodes</a>.</p>
642
643<p>LLVM functions are identified by their name and type signature. Hence, two
644functions with the same name but different parameter lists or return values are
Chris Lattnerd4f6b172005-03-07 22:13:59 +0000645considered different functions, and LLVM will resolve references to each
Chris Lattnerfa730212004-12-09 16:11:40 +0000646appropriately.</p>
647
Chris Lattner88f6c462005-11-12 00:45:07 +0000648<p>LLVM allows an explicit section to be specified for functions. If the target
649supports it, it will emit functions to the section specified.</p>
650
Chris Lattner2cbdc452005-11-06 08:02:57 +0000651<p>An explicit alignment may be specified for a function. If not present, or if
652the alignment is set to zero, the alignment of the function is set by the target
653to whatever it feels convenient. If an explicit alignment is specified, the
654function is forced to have at least that much alignment. All alignments must be
655a power of 2.</p>
656
Chris Lattnerfa730212004-12-09 16:11:40 +0000657</div>
658
Chris Lattner4e9aba72006-01-23 23:23:47 +0000659<!-- ======================================================================= -->
660<div class="doc_subsection">
Chris Lattner1eeeb0c2006-04-08 04:40:53 +0000661 <a name="moduleasm">Module-Level Inline Assembly</a>
Chris Lattner4e9aba72006-01-23 23:23:47 +0000662</div>
663
664<div class="doc_text">
665<p>
666Modules may contain "module-level inline asm" blocks, which corresponds to the
667GCC "file scope inline asm" blocks. These blocks are internally concatenated by
668LLVM and treated as a single unit, but may be separated in the .ll file if
669desired. The syntax is very simple:
670</p>
671
672<div class="doc_code"><pre>
Chris Lattner52599e12006-01-24 00:37:20 +0000673 module asm "inline asm code goes here"
674 module asm "more can go here"
Chris Lattner4e9aba72006-01-23 23:23:47 +0000675</pre></div>
676
677<p>The strings can contain any character by escaping non-printable characters.
678 The escape sequence used is simply "\xx" where "xx" is the two digit hex code
679 for the number.
680</p>
681
682<p>
683 The inline asm code is simply printed to the machine code .s file when
684 assembly code is generated.
685</p>
686</div>
Chris Lattnerfa730212004-12-09 16:11:40 +0000687
688
Chris Lattner00950542001-06-06 20:29:01 +0000689<!-- *********************************************************************** -->
Chris Lattner261efe92003-11-25 01:02:51 +0000690<div class="doc_section"> <a name="typesystem">Type System</a> </div>
691<!-- *********************************************************************** -->
Chris Lattnerfa730212004-12-09 16:11:40 +0000692
Misha Brukman9d0919f2003-11-08 01:05:38 +0000693<div class="doc_text">
Chris Lattnerfa730212004-12-09 16:11:40 +0000694
Misha Brukman9d0919f2003-11-08 01:05:38 +0000695<p>The LLVM type system is one of the most important features of the
Chris Lattner261efe92003-11-25 01:02:51 +0000696intermediate representation. Being typed enables a number of
697optimizations to be performed on the IR directly, without having to do
698extra analyses on the side before the transformation. A strong type
699system makes it easier to read the generated code and enables novel
700analyses and transformations that are not feasible to perform on normal
701three address code representations.</p>
Chris Lattnerfa730212004-12-09 16:11:40 +0000702
703</div>
704
Chris Lattner00950542001-06-06 20:29:01 +0000705<!-- ======================================================================= -->
Chris Lattner261efe92003-11-25 01:02:51 +0000706<div class="doc_subsection"> <a name="t_primitive">Primitive Types</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000707<div class="doc_text">
John Criswell4457dc92004-04-09 16:48:45 +0000708<p>The primitive types are the fundamental building blocks of the LLVM
Chris Lattnerd4f6b172005-03-07 22:13:59 +0000709system. The current set of primitive types is as follows:</p>
Misha Brukmandaa4cb02004-03-01 17:47:27 +0000710
Reid Spencerd3f876c2004-11-01 08:19:36 +0000711<table class="layout">
712 <tr class="layout">
713 <td class="left">
714 <table>
Chris Lattner261efe92003-11-25 01:02:51 +0000715 <tbody>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000716 <tr><th>Type</th><th>Description</th></tr>
717 <tr><td><tt>void</tt></td><td>No value</td></tr>
Misha Brukmancfa87bc2005-04-22 18:02:52 +0000718 <tr><td><tt>ubyte</tt></td><td>Unsigned 8-bit value</td></tr>
719 <tr><td><tt>ushort</tt></td><td>Unsigned 16-bit value</td></tr>
720 <tr><td><tt>uint</tt></td><td>Unsigned 32-bit value</td></tr>
721 <tr><td><tt>ulong</tt></td><td>Unsigned 64-bit value</td></tr>
722 <tr><td><tt>float</tt></td><td>32-bit floating point value</td></tr>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000723 <tr><td><tt>label</tt></td><td>Branch destination</td></tr>
Chris Lattner261efe92003-11-25 01:02:51 +0000724 </tbody>
725 </table>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000726 </td>
727 <td class="right">
728 <table>
Chris Lattner261efe92003-11-25 01:02:51 +0000729 <tbody>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000730 <tr><th>Type</th><th>Description</th></tr>
731 <tr><td><tt>bool</tt></td><td>True or False value</td></tr>
Misha Brukmancfa87bc2005-04-22 18:02:52 +0000732 <tr><td><tt>sbyte</tt></td><td>Signed 8-bit value</td></tr>
733 <tr><td><tt>short</tt></td><td>Signed 16-bit value</td></tr>
734 <tr><td><tt>int</tt></td><td>Signed 32-bit value</td></tr>
735 <tr><td><tt>long</tt></td><td>Signed 64-bit value</td></tr>
736 <tr><td><tt>double</tt></td><td>64-bit floating point value</td></tr>
Chris Lattner261efe92003-11-25 01:02:51 +0000737 </tbody>
738 </table>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000739 </td>
740 </tr>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000741</table>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000742</div>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000743
Chris Lattner00950542001-06-06 20:29:01 +0000744<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000745<div class="doc_subsubsection"> <a name="t_classifications">Type
746Classifications</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000747<div class="doc_text">
Chris Lattner261efe92003-11-25 01:02:51 +0000748<p>These different primitive types fall into a few useful
749classifications:</p>
Misha Brukmandaa4cb02004-03-01 17:47:27 +0000750
751<table border="1" cellspacing="0" cellpadding="4">
Chris Lattner261efe92003-11-25 01:02:51 +0000752 <tbody>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000753 <tr><th>Classification</th><th>Types</th></tr>
Chris Lattner261efe92003-11-25 01:02:51 +0000754 <tr>
755 <td><a name="t_signed">signed</a></td>
756 <td><tt>sbyte, short, int, long, float, double</tt></td>
757 </tr>
758 <tr>
759 <td><a name="t_unsigned">unsigned</a></td>
760 <td><tt>ubyte, ushort, uint, ulong</tt></td>
761 </tr>
762 <tr>
763 <td><a name="t_integer">integer</a></td>
764 <td><tt>ubyte, sbyte, ushort, short, uint, int, ulong, long</tt></td>
765 </tr>
766 <tr>
767 <td><a name="t_integral">integral</a></td>
Misha Brukmanc24b7582004-08-12 20:16:08 +0000768 <td><tt>bool, ubyte, sbyte, ushort, short, uint, int, ulong, long</tt>
769 </td>
Chris Lattner261efe92003-11-25 01:02:51 +0000770 </tr>
771 <tr>
772 <td><a name="t_floating">floating point</a></td>
773 <td><tt>float, double</tt></td>
774 </tr>
775 <tr>
776 <td><a name="t_firstclass">first class</a></td>
Misha Brukmanc24b7582004-08-12 20:16:08 +0000777 <td><tt>bool, ubyte, sbyte, ushort, short, uint, int, ulong, long,<br>
778 float, double, <a href="#t_pointer">pointer</a>,
779 <a href="#t_packed">packed</a></tt></td>
Chris Lattner261efe92003-11-25 01:02:51 +0000780 </tr>
781 </tbody>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000782</table>
Misha Brukmandaa4cb02004-03-01 17:47:27 +0000783
Chris Lattner261efe92003-11-25 01:02:51 +0000784<p>The <a href="#t_firstclass">first class</a> types are perhaps the
785most important. Values of these types are the only ones which can be
786produced by instructions, passed as arguments, or used as operands to
787instructions. This means that all structures and arrays must be
788manipulated either by pointer or by component.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000789</div>
Chris Lattnerc3f59762004-12-09 17:30:23 +0000790
Chris Lattner00950542001-06-06 20:29:01 +0000791<!-- ======================================================================= -->
Chris Lattner261efe92003-11-25 01:02:51 +0000792<div class="doc_subsection"> <a name="t_derived">Derived Types</a> </div>
Chris Lattnerc3f59762004-12-09 17:30:23 +0000793
Misha Brukman9d0919f2003-11-08 01:05:38 +0000794<div class="doc_text">
Chris Lattnerc3f59762004-12-09 17:30:23 +0000795
Chris Lattner261efe92003-11-25 01:02:51 +0000796<p>The real power in LLVM comes from the derived types in the system.
797This is what allows a programmer to represent arrays, functions,
798pointers, and other useful types. Note that these derived types may be
799recursive: For example, it is possible to have a two dimensional array.</p>
Chris Lattnerc3f59762004-12-09 17:30:23 +0000800
Misha Brukman9d0919f2003-11-08 01:05:38 +0000801</div>
Chris Lattnerc3f59762004-12-09 17:30:23 +0000802
Chris Lattner00950542001-06-06 20:29:01 +0000803<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000804<div class="doc_subsubsection"> <a name="t_array">Array Type</a> </div>
Chris Lattnerc3f59762004-12-09 17:30:23 +0000805
Misha Brukman9d0919f2003-11-08 01:05:38 +0000806<div class="doc_text">
Chris Lattnerc3f59762004-12-09 17:30:23 +0000807
Chris Lattner00950542001-06-06 20:29:01 +0000808<h5>Overview:</h5>
Chris Lattnerc3f59762004-12-09 17:30:23 +0000809
Misha Brukman9d0919f2003-11-08 01:05:38 +0000810<p>The array type is a very simple derived type that arranges elements
Chris Lattner261efe92003-11-25 01:02:51 +0000811sequentially in memory. The array type requires a size (number of
812elements) and an underlying data type.</p>
Chris Lattnerc3f59762004-12-09 17:30:23 +0000813
Chris Lattner7faa8832002-04-14 06:13:44 +0000814<h5>Syntax:</h5>
Chris Lattnerc3f59762004-12-09 17:30:23 +0000815
816<pre>
817 [&lt;# elements&gt; x &lt;elementtype&gt;]
818</pre>
819
John Criswelle4c57cc2005-05-12 16:52:32 +0000820<p>The number of elements is a constant integer value; elementtype may
Chris Lattner261efe92003-11-25 01:02:51 +0000821be any type with a size.</p>
Chris Lattnerc3f59762004-12-09 17:30:23 +0000822
Chris Lattner7faa8832002-04-14 06:13:44 +0000823<h5>Examples:</h5>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000824<table class="layout">
825 <tr class="layout">
826 <td class="left">
827 <tt>[40 x int ]</tt><br/>
828 <tt>[41 x int ]</tt><br/>
829 <tt>[40 x uint]</tt><br/>
830 </td>
831 <td class="left">
832 Array of 40 integer values.<br/>
833 Array of 41 integer values.<br/>
834 Array of 40 unsigned integer values.<br/>
835 </td>
836 </tr>
Chris Lattner00950542001-06-06 20:29:01 +0000837</table>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000838<p>Here are some examples of multidimensional arrays:</p>
839<table class="layout">
840 <tr class="layout">
841 <td class="left">
842 <tt>[3 x [4 x int]]</tt><br/>
843 <tt>[12 x [10 x float]]</tt><br/>
844 <tt>[2 x [3 x [4 x uint]]]</tt><br/>
845 </td>
846 <td class="left">
John Criswellc1f786c2005-05-13 22:25:59 +0000847 3x4 array of integer values.<br/>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000848 12x10 array of single precision floating point values.<br/>
849 2x3x4 array of unsigned integer values.<br/>
850 </td>
851 </tr>
852</table>
Chris Lattnere67a9512005-06-24 17:22:57 +0000853
John Criswell0ec250c2005-10-24 16:17:18 +0000854<p>Note that 'variable sized arrays' can be implemented in LLVM with a zero
855length array. Normally, accesses past the end of an array are undefined in
Chris Lattnere67a9512005-06-24 17:22:57 +0000856LLVM (e.g. it is illegal to access the 5th element of a 3 element array).
857As a special case, however, zero length arrays are recognized to be variable
858length. This allows implementation of 'pascal style arrays' with the LLVM
859type "{ int, [0 x float]}", for example.</p>
860
Misha Brukman9d0919f2003-11-08 01:05:38 +0000861</div>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000862
Chris Lattner00950542001-06-06 20:29:01 +0000863<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000864<div class="doc_subsubsection"> <a name="t_function">Function Type</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000865<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +0000866<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000867<p>The function type can be thought of as a function signature. It
868consists of a return type and a list of formal parameter types.
John Criswell009900b2003-11-25 21:45:46 +0000869Function types are usually used to build virtual function tables
Chris Lattner261efe92003-11-25 01:02:51 +0000870(which are structures of pointers to functions), for indirect function
871calls, and when defining a function.</p>
John Criswell009900b2003-11-25 21:45:46 +0000872<p>
873The return type of a function type cannot be an aggregate type.
874</p>
Chris Lattner00950542001-06-06 20:29:01 +0000875<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000876<pre> &lt;returntype&gt; (&lt;parameter list&gt;)<br></pre>
John Criswell0ec250c2005-10-24 16:17:18 +0000877<p>...where '<tt>&lt;parameter list&gt;</tt>' is a comma-separated list of type
Misha Brukmanc24b7582004-08-12 20:16:08 +0000878specifiers. Optionally, the parameter list may include a type <tt>...</tt>,
Chris Lattner27f71f22003-09-03 00:41:47 +0000879which indicates that the function takes a variable number of arguments.
880Variable argument functions can access their arguments with the <a
Chris Lattner261efe92003-11-25 01:02:51 +0000881 href="#int_varargs">variable argument handling intrinsic</a> functions.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000882<h5>Examples:</h5>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000883<table class="layout">
884 <tr class="layout">
885 <td class="left">
886 <tt>int (int)</tt> <br/>
887 <tt>float (int, int *) *</tt><br/>
888 <tt>int (sbyte *, ...)</tt><br/>
889 </td>
890 <td class="left">
891 function taking an <tt>int</tt>, returning an <tt>int</tt><br/>
892 <a href="#t_pointer">Pointer</a> to a function that takes an
Misha Brukmanc24b7582004-08-12 20:16:08 +0000893 <tt>int</tt> and a <a href="#t_pointer">pointer</a> to <tt>int</tt>,
Reid Spencerd3f876c2004-11-01 08:19:36 +0000894 returning <tt>float</tt>.<br/>
895 A vararg function that takes at least one <a href="#t_pointer">pointer</a>
896 to <tt>sbyte</tt> (signed char in C), which returns an integer. This is
897 the signature for <tt>printf</tt> in LLVM.<br/>
898 </td>
899 </tr>
Chris Lattner00950542001-06-06 20:29:01 +0000900</table>
Misha Brukmandaa4cb02004-03-01 17:47:27 +0000901
Misha Brukman9d0919f2003-11-08 01:05:38 +0000902</div>
Chris Lattner00950542001-06-06 20:29:01 +0000903<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000904<div class="doc_subsubsection"> <a name="t_struct">Structure Type</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000905<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +0000906<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000907<p>The structure type is used to represent a collection of data members
908together in memory. The packing of the field types is defined to match
909the ABI of the underlying processor. The elements of a structure may
910be any type that has a size.</p>
911<p>Structures are accessed using '<tt><a href="#i_load">load</a></tt>
912and '<tt><a href="#i_store">store</a></tt>' by getting a pointer to a
913field with the '<tt><a href="#i_getelementptr">getelementptr</a></tt>'
914instruction.</p>
Chris Lattner00950542001-06-06 20:29:01 +0000915<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000916<pre> { &lt;type list&gt; }<br></pre>
Chris Lattner00950542001-06-06 20:29:01 +0000917<h5>Examples:</h5>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000918<table class="layout">
919 <tr class="layout">
920 <td class="left">
921 <tt>{ int, int, int }</tt><br/>
922 <tt>{ float, int (int) * }</tt><br/>
923 </td>
924 <td class="left">
925 a triple of three <tt>int</tt> values<br/>
926 A pair, where the first element is a <tt>float</tt> and the second element
927 is a <a href="#t_pointer">pointer</a> to a <a href="#t_function">function</a>
928 that takes an <tt>int</tt>, returning an <tt>int</tt>.<br/>
929 </td>
930 </tr>
Chris Lattner00950542001-06-06 20:29:01 +0000931</table>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000932</div>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000933
Chris Lattner00950542001-06-06 20:29:01 +0000934<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +0000935<div class="doc_subsubsection"> <a name="t_pointer">Pointer Type</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000936<div class="doc_text">
Chris Lattner7faa8832002-04-14 06:13:44 +0000937<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000938<p>As in many languages, the pointer type represents a pointer or
939reference to another object, which must live in memory.</p>
Chris Lattner7faa8832002-04-14 06:13:44 +0000940<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +0000941<pre> &lt;type&gt; *<br></pre>
Chris Lattner7faa8832002-04-14 06:13:44 +0000942<h5>Examples:</h5>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000943<table class="layout">
944 <tr class="layout">
945 <td class="left">
946 <tt>[4x int]*</tt><br/>
947 <tt>int (int *) *</tt><br/>
948 </td>
949 <td class="left">
950 A <a href="#t_pointer">pointer</a> to <a href="#t_array">array</a> of
951 four <tt>int</tt> values<br/>
952 A <a href="#t_pointer">pointer</a> to a <a
Chris Lattnera977c482005-02-19 02:22:14 +0000953 href="#t_function">function</a> that takes an <tt>int*</tt>, returning an
Reid Spencerd3f876c2004-11-01 08:19:36 +0000954 <tt>int</tt>.<br/>
955 </td>
956 </tr>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000957</table>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000958</div>
Reid Spencerd3f876c2004-11-01 08:19:36 +0000959
Chris Lattnera58561b2004-08-12 19:12:28 +0000960<!-- _______________________________________________________________________ -->
961<div class="doc_subsubsection"> <a name="t_packed">Packed Type</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000962<div class="doc_text">
Chris Lattner69c11bb2005-04-25 17:34:15 +0000963
Chris Lattnera58561b2004-08-12 19:12:28 +0000964<h5>Overview:</h5>
Chris Lattner69c11bb2005-04-25 17:34:15 +0000965
Chris Lattnera58561b2004-08-12 19:12:28 +0000966<p>A packed type is a simple derived type that represents a vector
967of elements. Packed types are used when multiple primitive data
968are operated in parallel using a single instruction (SIMD).
969A packed type requires a size (number of
Chris Lattnerb8d172f2005-11-10 01:44:22 +0000970elements) and an underlying primitive data type. Vectors must have a power
971of two length (1, 2, 4, 8, 16 ...). Packed types are
Chris Lattnera58561b2004-08-12 19:12:28 +0000972considered <a href="#t_firstclass">first class</a>.</p>
Chris Lattner69c11bb2005-04-25 17:34:15 +0000973
Chris Lattnera58561b2004-08-12 19:12:28 +0000974<h5>Syntax:</h5>
Chris Lattner69c11bb2005-04-25 17:34:15 +0000975
976<pre>
977 &lt; &lt;# elements&gt; x &lt;elementtype&gt; &gt;
978</pre>
979
John Criswellc1f786c2005-05-13 22:25:59 +0000980<p>The number of elements is a constant integer value; elementtype may
Chris Lattnera58561b2004-08-12 19:12:28 +0000981be any integral or floating point type.</p>
Chris Lattner69c11bb2005-04-25 17:34:15 +0000982
Chris Lattnera58561b2004-08-12 19:12:28 +0000983<h5>Examples:</h5>
Chris Lattner69c11bb2005-04-25 17:34:15 +0000984
Reid Spencerd3f876c2004-11-01 08:19:36 +0000985<table class="layout">
986 <tr class="layout">
987 <td class="left">
988 <tt>&lt;4 x int&gt;</tt><br/>
989 <tt>&lt;8 x float&gt;</tt><br/>
990 <tt>&lt;2 x uint&gt;</tt><br/>
991 </td>
992 <td class="left">
993 Packed vector of 4 integer values.<br/>
994 Packed vector of 8 floating-point values.<br/>
995 Packed vector of 2 unsigned integer values.<br/>
996 </td>
997 </tr>
998</table>
Misha Brukman9d0919f2003-11-08 01:05:38 +0000999</div>
1000
Chris Lattner69c11bb2005-04-25 17:34:15 +00001001<!-- _______________________________________________________________________ -->
1002<div class="doc_subsubsection"> <a name="t_opaque">Opaque Type</a> </div>
1003<div class="doc_text">
1004
1005<h5>Overview:</h5>
1006
1007<p>Opaque types are used to represent unknown types in the system. This
1008corresponds (for example) to the C notion of a foward declared structure type.
1009In LLVM, opaque types can eventually be resolved to any type (not just a
1010structure type).</p>
1011
1012<h5>Syntax:</h5>
1013
1014<pre>
1015 opaque
1016</pre>
1017
1018<h5>Examples:</h5>
1019
1020<table class="layout">
1021 <tr class="layout">
1022 <td class="left">
1023 <tt>opaque</tt>
1024 </td>
1025 <td class="left">
1026 An opaque type.<br/>
1027 </td>
1028 </tr>
1029</table>
1030</div>
1031
1032
Chris Lattnerc3f59762004-12-09 17:30:23 +00001033<!-- *********************************************************************** -->
1034<div class="doc_section"> <a name="constants">Constants</a> </div>
1035<!-- *********************************************************************** -->
1036
1037<div class="doc_text">
1038
1039<p>LLVM has several different basic types of constants. This section describes
1040them all and their syntax.</p>
1041
1042</div>
1043
1044<!-- ======================================================================= -->
Reid Spencercc16dc32004-12-09 18:02:53 +00001045<div class="doc_subsection"><a name="simpleconstants">Simple Constants</a></div>
Chris Lattnerc3f59762004-12-09 17:30:23 +00001046
1047<div class="doc_text">
1048
1049<dl>
1050 <dt><b>Boolean constants</b></dt>
1051
1052 <dd>The two strings '<tt>true</tt>' and '<tt>false</tt>' are both valid
1053 constants of the <tt><a href="#t_primitive">bool</a></tt> type.
1054 </dd>
1055
1056 <dt><b>Integer constants</b></dt>
1057
Reid Spencercc16dc32004-12-09 18:02:53 +00001058 <dd>Standard integers (such as '4') are constants of the <a
Chris Lattnerc3f59762004-12-09 17:30:23 +00001059 href="#t_integer">integer</a> type. Negative numbers may be used with signed
1060 integer types.
1061 </dd>
1062
1063 <dt><b>Floating point constants</b></dt>
1064
1065 <dd>Floating point constants use standard decimal notation (e.g. 123.421),
1066 exponential notation (e.g. 1.23421e+2), or a more precise hexadecimal
Chris Lattnerc3f59762004-12-09 17:30:23 +00001067 notation (see below). Floating point constants must have a <a
1068 href="#t_floating">floating point</a> type. </dd>
1069
1070 <dt><b>Null pointer constants</b></dt>
1071
John Criswell9e2485c2004-12-10 15:51:16 +00001072 <dd>The identifier '<tt>null</tt>' is recognized as a null pointer constant
Chris Lattnerc3f59762004-12-09 17:30:23 +00001073 and must be of <a href="#t_pointer">pointer type</a>.</dd>
1074
1075</dl>
1076
John Criswell9e2485c2004-12-10 15:51:16 +00001077<p>The one non-intuitive notation for constants is the optional hexadecimal form
Chris Lattnerc3f59762004-12-09 17:30:23 +00001078of floating point constants. For example, the form '<tt>double
10790x432ff973cafa8000</tt>' is equivalent to (but harder to read than) '<tt>double
10804.5e+15</tt>'. The only time hexadecimal floating point constants are required
Reid Spencercc16dc32004-12-09 18:02:53 +00001081(and the only time that they are generated by the disassembler) is when a
1082floating point constant must be emitted but it cannot be represented as a
1083decimal floating point number. For example, NaN's, infinities, and other
1084special values are represented in their IEEE hexadecimal format so that
1085assembly and disassembly do not cause any bits to change in the constants.</p>
Chris Lattnerc3f59762004-12-09 17:30:23 +00001086
1087</div>
1088
1089<!-- ======================================================================= -->
1090<div class="doc_subsection"><a name="aggregateconstants">Aggregate Constants</a>
1091</div>
1092
1093<div class="doc_text">
Chris Lattnerd4f6b172005-03-07 22:13:59 +00001094<p>Aggregate constants arise from aggregation of simple constants
1095and smaller aggregate constants.</p>
Chris Lattnerc3f59762004-12-09 17:30:23 +00001096
1097<dl>
1098 <dt><b>Structure constants</b></dt>
1099
1100 <dd>Structure constants are represented with notation similar to structure
1101 type definitions (a comma separated list of elements, surrounded by braces
Chris Lattnerd4f6b172005-03-07 22:13:59 +00001102 (<tt>{}</tt>)). For example: "<tt>{ int 4, float 17.0, int* %G }</tt>",
1103 where "<tt>%G</tt>" is declared as "<tt>%G = external global int</tt>". Structure constants
1104 must have <a href="#t_struct">structure type</a>, and the number and
Chris Lattnerc3f59762004-12-09 17:30:23 +00001105 types of elements must match those specified by the type.
1106 </dd>
1107
1108 <dt><b>Array constants</b></dt>
1109
1110 <dd>Array constants are represented with notation similar to array type
1111 definitions (a comma separated list of elements, surrounded by square brackets
John Criswell9e2485c2004-12-10 15:51:16 +00001112 (<tt>[]</tt>)). For example: "<tt>[ int 42, int 11, int 74 ]</tt>". Array
Chris Lattnerc3f59762004-12-09 17:30:23 +00001113 constants must have <a href="#t_array">array type</a>, and the number and
1114 types of elements must match those specified by the type.
1115 </dd>
1116
1117 <dt><b>Packed constants</b></dt>
1118
1119 <dd>Packed constants are represented with notation similar to packed type
1120 definitions (a comma separated list of elements, surrounded by
John Criswell9e2485c2004-12-10 15:51:16 +00001121 less-than/greater-than's (<tt>&lt;&gt;</tt>)). For example: "<tt>&lt; int 42,
Chris Lattnerc3f59762004-12-09 17:30:23 +00001122 int 11, int 74, int 100 &gt;</tt>". Packed constants must have <a
1123 href="#t_packed">packed type</a>, and the number and types of elements must
1124 match those specified by the type.
1125 </dd>
1126
1127 <dt><b>Zero initialization</b></dt>
1128
1129 <dd>The string '<tt>zeroinitializer</tt>' can be used to zero initialize a
1130 value to zero of <em>any</em> type, including scalar and aggregate types.
1131 This is often used to avoid having to print large zero initializers (e.g. for
John Criswell0ec250c2005-10-24 16:17:18 +00001132 large arrays) and is always exactly equivalent to using explicit zero
Chris Lattnerc3f59762004-12-09 17:30:23 +00001133 initializers.
1134 </dd>
1135</dl>
1136
1137</div>
1138
1139<!-- ======================================================================= -->
1140<div class="doc_subsection">
1141 <a name="globalconstants">Global Variable and Function Addresses</a>
1142</div>
1143
1144<div class="doc_text">
1145
1146<p>The addresses of <a href="#globalvars">global variables</a> and <a
1147href="#functionstructure">functions</a> are always implicitly valid (link-time)
John Criswell9e2485c2004-12-10 15:51:16 +00001148constants. These constants are explicitly referenced when the <a
1149href="#identifiers">identifier for the global</a> is used and always have <a
Chris Lattnerc3f59762004-12-09 17:30:23 +00001150href="#t_pointer">pointer</a> type. For example, the following is a legal LLVM
1151file:</p>
1152
1153<pre>
1154 %X = global int 17
1155 %Y = global int 42
1156 %Z = global [2 x int*] [ int* %X, int* %Y ]
1157</pre>
1158
1159</div>
1160
1161<!-- ======================================================================= -->
Reid Spencer2dc45b82004-12-09 18:13:12 +00001162<div class="doc_subsection"><a name="undefvalues">Undefined Values</a></div>
Chris Lattnerc3f59762004-12-09 17:30:23 +00001163<div class="doc_text">
Reid Spencer2dc45b82004-12-09 18:13:12 +00001164 <p>The string '<tt>undef</tt>' is recognized as a type-less constant that has
John Criswellc1f786c2005-05-13 22:25:59 +00001165 no specific value. Undefined values may be of any type and be used anywhere
Reid Spencer2dc45b82004-12-09 18:13:12 +00001166 a constant is permitted.</p>
Chris Lattnerc3f59762004-12-09 17:30:23 +00001167
Reid Spencer2dc45b82004-12-09 18:13:12 +00001168 <p>Undefined values indicate to the compiler that the program is well defined
1169 no matter what value is used, giving the compiler more freedom to optimize.
1170 </p>
Chris Lattnerc3f59762004-12-09 17:30:23 +00001171</div>
1172
1173<!-- ======================================================================= -->
1174<div class="doc_subsection"><a name="constantexprs">Constant Expressions</a>
1175</div>
1176
1177<div class="doc_text">
1178
1179<p>Constant expressions are used to allow expressions involving other constants
1180to be used as constants. Constant expressions may be of any <a
John Criswellc1f786c2005-05-13 22:25:59 +00001181href="#t_firstclass">first class</a> type and may involve any LLVM operation
Chris Lattnerc3f59762004-12-09 17:30:23 +00001182that does not have side effects (e.g. load and call are not supported). The
1183following is the syntax for constant expressions:</p>
1184
1185<dl>
Reid Spencer9dee3ac2006-11-08 01:11:31 +00001186 <dt><b><tt>trunc ( CST to TYPE )</tt></b></dt>
1187 <dd>Truncate a constant to another type. The bit size of CST must be larger
1188 than the bit size of TYPE. Both types must be integral.</dd>
Chris Lattnerc3f59762004-12-09 17:30:23 +00001189
Reid Spencer9dee3ac2006-11-08 01:11:31 +00001190 <dt><b><tt>zext ( CST to TYPE )</tt></b></dt>
1191 <dd>Zero extend a constant to another type. The bit size of CST must be
1192 smaller or equal to the bit size of TYPE. Both types must be integral.</dd>
1193
1194 <dt><b><tt>sext ( CST to TYPE )</tt></b></dt>
1195 <dd>Sign extend a constant to another type. The bit size of CST must be
1196 smaller or equal to the bit size of TYPE. Both types must be integral.</dd>
1197
1198 <dt><b><tt>fptrunc ( CST to TYPE )</tt></b></dt>
1199 <dd>Truncate a floating point constant to another floating point type. The
1200 size of CST must be larger than the size of TYPE. Both types must be
1201 floating point.</dd>
1202
1203 <dt><b><tt>fpext ( CST to TYPE )</tt></b></dt>
1204 <dd>Floating point extend a constant to another type. The size of CST must be
1205 smaller or equal to the size of TYPE. Both types must be floating point.</dd>
1206
1207 <dt><b><tt>fp2uint ( CST to TYPE )</tt></b></dt>
1208 <dd>Convert a floating point constant to the corresponding unsigned integer
1209 constant. TYPE must be an integer type. CST must be floating point. If the
1210 value won't fit in the integer type, the results are undefined.</dd>
1211
Reid Spencerd4448792006-11-09 23:03:26 +00001212 <dt><b><tt>fptosi ( CST to TYPE )</tt></b></dt>
Reid Spencer9dee3ac2006-11-08 01:11:31 +00001213 <dd>Convert a floating point constant to the corresponding signed integer
1214 constant. TYPE must be an integer type. CST must be floating point. If the
1215 value won't fit in the integer type, the results are undefined.</dd>
1216
Reid Spencerd4448792006-11-09 23:03:26 +00001217 <dt><b><tt>uitofp ( CST to TYPE )</tt></b></dt>
Reid Spencer9dee3ac2006-11-08 01:11:31 +00001218 <dd>Convert an unsigned integer constant to the corresponding floating point
1219 constant. TYPE must be floating point. CST must be of integer type. If the
1220 value won't fit in the floating point type, the results are undefined.</dd>
1221
Reid Spencerd4448792006-11-09 23:03:26 +00001222 <dt><b><tt>sitofp ( CST to TYPE )</tt></b></dt>
Reid Spencer9dee3ac2006-11-08 01:11:31 +00001223 <dd>Convert a signed integer constant to the corresponding floating point
1224 constant. TYPE must be floating point. CST must be of integer type. If the
1225 value won't fit in the floating point type, the results are undefined.</dd>
1226
Reid Spencer5c0ef472006-11-11 23:08:07 +00001227 <dt><b><tt>ptrtoint ( CST to TYPE )</tt></b></dt>
1228 <dd>Convert a pointer typed constant to the corresponding integer constant
1229 TYPE must be an integer type. CST must be of pointer type. The CST value is
1230 zero extended, truncated, or unchanged to make it fit in TYPE.</dd>
1231
1232 <dt><b><tt>inttoptr ( CST to TYPE )</tt></b></dt>
1233 <dd>Convert a integer constant to a pointer constant. TYPE must be a
1234 pointer type. CST must be of integer type. The CST value is zero extended,
1235 truncated, or unchanged to make it fit in a pointer size. This one is
1236 <i>really</i> dangerous!</dd>
1237
1238 <dt><b><tt>bitcast ( CST to TYPE )</tt></b></dt>
Reid Spencer9dee3ac2006-11-08 01:11:31 +00001239 <dd>Convert a constant, CST, to another TYPE. The size of CST and TYPE must be
1240 identical (same number of bits). The conversion is done as if the CST value
1241 was stored to memory and read back as TYPE. In other words, no bits change
Reid Spencer5c0ef472006-11-11 23:08:07 +00001242 with this operator, just the type. This can be used for conversion of
1243 packed types to any other type, as long as they have the same bit width. For
1244 pointers it is only valid to cast to another pointer type.
Reid Spencer9dee3ac2006-11-08 01:11:31 +00001245 </dd>
Chris Lattnerc3f59762004-12-09 17:30:23 +00001246
1247 <dt><b><tt>getelementptr ( CSTPTR, IDX0, IDX1, ... )</tt></b></dt>
1248
1249 <dd>Perform the <a href="#i_getelementptr">getelementptr operation</a> on
1250 constants. As with the <a href="#i_getelementptr">getelementptr</a>
1251 instruction, the index list may have zero or more indexes, which are required
1252 to make sense for the type of "CSTPTR".</dd>
1253
Robert Bocchino9fbe1452006-01-10 19:31:34 +00001254 <dt><b><tt>select ( COND, VAL1, VAL2 )</tt></b></dt>
1255
1256 <dd>Perform the <a href="#i_select">select operation</a> on
1257 constants.
1258
1259 <dt><b><tt>extractelement ( VAL, IDX )</tt></b></dt>
1260
1261 <dd>Perform the <a href="#i_extractelement">extractelement
1262 operation</a> on constants.
1263
Robert Bocchino05ccd702006-01-15 20:48:27 +00001264 <dt><b><tt>insertelement ( VAL, ELT, IDX )</tt></b></dt>
1265
1266 <dd>Perform the <a href="#i_insertelement">insertelement
1267 operation</a> on constants.
1268
Chris Lattnerc1989542006-04-08 00:13:41 +00001269
1270 <dt><b><tt>shufflevector ( VEC1, VEC2, IDXMASK )</tt></b></dt>
1271
1272 <dd>Perform the <a href="#i_shufflevector">shufflevector
1273 operation</a> on constants.
1274
Chris Lattnerc3f59762004-12-09 17:30:23 +00001275 <dt><b><tt>OPCODE ( LHS, RHS )</tt></b></dt>
1276
Reid Spencer2dc45b82004-12-09 18:13:12 +00001277 <dd>Perform the specified operation of the LHS and RHS constants. OPCODE may
1278 be any of the <a href="#binaryops">binary</a> or <a href="#bitwiseops">bitwise
Chris Lattnerc3f59762004-12-09 17:30:23 +00001279 binary</a> operations. The constraints on operands are the same as those for
1280 the corresponding instruction (e.g. no bitwise operations on floating point
John Criswelle4c57cc2005-05-12 16:52:32 +00001281 values are allowed).</dd>
Chris Lattnerc3f59762004-12-09 17:30:23 +00001282</dl>
Chris Lattnerc3f59762004-12-09 17:30:23 +00001283</div>
Chris Lattner9ee5d222004-03-08 16:49:10 +00001284
Chris Lattner00950542001-06-06 20:29:01 +00001285<!-- *********************************************************************** -->
Chris Lattnere87d6532006-01-25 23:47:57 +00001286<div class="doc_section"> <a name="othervalues">Other Values</a> </div>
1287<!-- *********************************************************************** -->
1288
1289<!-- ======================================================================= -->
1290<div class="doc_subsection">
1291<a name="inlineasm">Inline Assembler Expressions</a>
1292</div>
1293
1294<div class="doc_text">
1295
1296<p>
1297LLVM supports inline assembler expressions (as opposed to <a href="#moduleasm">
1298Module-Level Inline Assembly</a>) through the use of a special value. This
1299value represents the inline assembler as a string (containing the instructions
1300to emit), a list of operand constraints (stored as a string), and a flag that
1301indicates whether or not the inline asm expression has side effects. An example
1302inline assembler expression is:
1303</p>
1304
1305<pre>
1306 int(int) asm "bswap $0", "=r,r"
1307</pre>
1308
1309<p>
1310Inline assembler expressions may <b>only</b> be used as the callee operand of
1311a <a href="#i_call"><tt>call</tt> instruction</a>. Thus, typically we have:
1312</p>
1313
1314<pre>
1315 %X = call int asm "<a href="#i_bswap">bswap</a> $0", "=r,r"(int %Y)
1316</pre>
1317
1318<p>
1319Inline asms with side effects not visible in the constraint list must be marked
1320as having side effects. This is done through the use of the
1321'<tt>sideeffect</tt>' keyword, like so:
1322</p>
1323
1324<pre>
1325 call void asm sideeffect "eieio", ""()
1326</pre>
1327
1328<p>TODO: The format of the asm and constraints string still need to be
1329documented here. Constraints on what can be done (e.g. duplication, moving, etc
1330need to be documented).
1331</p>
1332
1333</div>
1334
1335<!-- *********************************************************************** -->
Chris Lattner261efe92003-11-25 01:02:51 +00001336<div class="doc_section"> <a name="instref">Instruction Reference</a> </div>
1337<!-- *********************************************************************** -->
Chris Lattnerc3f59762004-12-09 17:30:23 +00001338
Misha Brukman9d0919f2003-11-08 01:05:38 +00001339<div class="doc_text">
Chris Lattnerc3f59762004-12-09 17:30:23 +00001340
Chris Lattner261efe92003-11-25 01:02:51 +00001341<p>The LLVM instruction set consists of several different
1342classifications of instructions: <a href="#terminators">terminator
John Criswellc1f786c2005-05-13 22:25:59 +00001343instructions</a>, <a href="#binaryops">binary instructions</a>,
1344<a href="#bitwiseops">bitwise binary instructions</a>, <a
Chris Lattner261efe92003-11-25 01:02:51 +00001345 href="#memoryops">memory instructions</a>, and <a href="#otherops">other
1346instructions</a>.</p>
Chris Lattnerc3f59762004-12-09 17:30:23 +00001347
Misha Brukman9d0919f2003-11-08 01:05:38 +00001348</div>
Chris Lattnerc3f59762004-12-09 17:30:23 +00001349
Chris Lattner00950542001-06-06 20:29:01 +00001350<!-- ======================================================================= -->
Chris Lattner261efe92003-11-25 01:02:51 +00001351<div class="doc_subsection"> <a name="terminators">Terminator
1352Instructions</a> </div>
Chris Lattnerc3f59762004-12-09 17:30:23 +00001353
Misha Brukman9d0919f2003-11-08 01:05:38 +00001354<div class="doc_text">
Chris Lattnerc3f59762004-12-09 17:30:23 +00001355
Chris Lattner261efe92003-11-25 01:02:51 +00001356<p>As mentioned <a href="#functionstructure">previously</a>, every
1357basic block in a program ends with a "Terminator" instruction, which
1358indicates which block should be executed after the current block is
1359finished. These terminator instructions typically yield a '<tt>void</tt>'
1360value: they produce control flow, not values (the one exception being
1361the '<a href="#i_invoke"><tt>invoke</tt></a>' instruction).</p>
John Criswell9e2485c2004-12-10 15:51:16 +00001362<p>There are six different terminator instructions: the '<a
Chris Lattner261efe92003-11-25 01:02:51 +00001363 href="#i_ret"><tt>ret</tt></a>' instruction, the '<a href="#i_br"><tt>br</tt></a>'
1364instruction, the '<a href="#i_switch"><tt>switch</tt></a>' instruction,
Chris Lattner35eca582004-10-16 18:04:13 +00001365the '<a href="#i_invoke"><tt>invoke</tt></a>' instruction, the '<a
1366 href="#i_unwind"><tt>unwind</tt></a>' instruction, and the '<a
1367 href="#i_unreachable"><tt>unreachable</tt></a>' instruction.</p>
Chris Lattnerc3f59762004-12-09 17:30:23 +00001368
Misha Brukman9d0919f2003-11-08 01:05:38 +00001369</div>
Chris Lattnerc3f59762004-12-09 17:30:23 +00001370
Chris Lattner00950542001-06-06 20:29:01 +00001371<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001372<div class="doc_subsubsection"> <a name="i_ret">'<tt>ret</tt>'
1373Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001374<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001375<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001376<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 +00001377 ret void <i>; Return from void function</i>
Chris Lattner00950542001-06-06 20:29:01 +00001378</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001379<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001380<p>The '<tt>ret</tt>' instruction is used to return control flow (and a
John Criswellc1f786c2005-05-13 22:25:59 +00001381value) from a function back to the caller.</p>
John Criswell4457dc92004-04-09 16:48:45 +00001382<p>There are two forms of the '<tt>ret</tt>' instruction: one that
Chris Lattner261efe92003-11-25 01:02:51 +00001383returns a value and then causes control flow, and one that just causes
1384control flow to occur.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001385<h5>Arguments:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001386<p>The '<tt>ret</tt>' instruction may return any '<a
1387 href="#t_firstclass">first class</a>' type. Notice that a function is
1388not <a href="#wellformed">well formed</a> if there exists a '<tt>ret</tt>'
1389instruction inside of the function that returns a value that does not
1390match the return type of the function.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001391<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001392<p>When the '<tt>ret</tt>' instruction is executed, control flow
1393returns back to the calling function's context. If the caller is a "<a
John Criswellfa081872004-06-25 15:16:57 +00001394 href="#i_call"><tt>call</tt></a>" instruction, execution continues at
Chris Lattner261efe92003-11-25 01:02:51 +00001395the instruction after the call. If the caller was an "<a
1396 href="#i_invoke"><tt>invoke</tt></a>" instruction, execution continues
John Criswelle4c57cc2005-05-12 16:52:32 +00001397at the beginning of the "normal" destination block. If the instruction
Chris Lattner261efe92003-11-25 01:02:51 +00001398returns a value, that value shall set the call or invoke instruction's
1399return value.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001400<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001401<pre> ret int 5 <i>; Return an integer value of 5</i>
Chris Lattner7faa8832002-04-14 06:13:44 +00001402 ret void <i>; Return from a void function</i>
Chris Lattner00950542001-06-06 20:29:01 +00001403</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001404</div>
Chris Lattner00950542001-06-06 20:29:01 +00001405<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001406<div class="doc_subsubsection"> <a name="i_br">'<tt>br</tt>' Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001407<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001408<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001409<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 +00001410</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001411<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001412<p>The '<tt>br</tt>' instruction is used to cause control flow to
1413transfer to a different basic block in the current function. There are
1414two forms of this instruction, corresponding to a conditional branch
1415and an unconditional branch.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001416<h5>Arguments:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001417<p>The conditional branch form of the '<tt>br</tt>' instruction takes a
1418single '<tt>bool</tt>' value and two '<tt>label</tt>' values. The
1419unconditional form of the '<tt>br</tt>' instruction takes a single '<tt>label</tt>'
1420value as a target.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001421<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001422<p>Upon execution of a conditional '<tt>br</tt>' instruction, the '<tt>bool</tt>'
1423argument is evaluated. If the value is <tt>true</tt>, control flows
1424to the '<tt>iftrue</tt>' <tt>label</tt> argument. If "cond" is <tt>false</tt>,
1425control flows to the '<tt>iffalse</tt>' <tt>label</tt> argument.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001426<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001427<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
1428 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 +00001429</div>
Chris Lattner00950542001-06-06 20:29:01 +00001430<!-- _______________________________________________________________________ -->
Chris Lattnerc88c17b2004-02-24 04:54:45 +00001431<div class="doc_subsubsection">
1432 <a name="i_switch">'<tt>switch</tt>' Instruction</a>
1433</div>
1434
Misha Brukman9d0919f2003-11-08 01:05:38 +00001435<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001436<h5>Syntax:</h5>
Chris Lattnerc88c17b2004-02-24 04:54:45 +00001437
1438<pre>
1439 switch &lt;intty&gt; &lt;value&gt;, label &lt;defaultdest&gt; [ &lt;intty&gt; &lt;val&gt;, label &lt;dest&gt; ... ]
1440</pre>
1441
Chris Lattner00950542001-06-06 20:29:01 +00001442<h5>Overview:</h5>
Chris Lattnerc88c17b2004-02-24 04:54:45 +00001443
1444<p>The '<tt>switch</tt>' instruction is used to transfer control flow to one of
1445several different places. It is a generalization of the '<tt>br</tt>'
Misha Brukman9d0919f2003-11-08 01:05:38 +00001446instruction, allowing a branch to occur to one of many possible
1447destinations.</p>
Chris Lattnerc88c17b2004-02-24 04:54:45 +00001448
1449
Chris Lattner00950542001-06-06 20:29:01 +00001450<h5>Arguments:</h5>
Chris Lattnerc88c17b2004-02-24 04:54:45 +00001451
1452<p>The '<tt>switch</tt>' instruction uses three parameters: an integer
1453comparison value '<tt>value</tt>', a default '<tt>label</tt>' destination, and
1454an array of pairs of comparison value constants and '<tt>label</tt>'s. The
1455table is not allowed to contain duplicate constant entries.</p>
1456
Chris Lattner00950542001-06-06 20:29:01 +00001457<h5>Semantics:</h5>
Chris Lattnerc88c17b2004-02-24 04:54:45 +00001458
Chris Lattner261efe92003-11-25 01:02:51 +00001459<p>The <tt>switch</tt> instruction specifies a table of values and
1460destinations. When the '<tt>switch</tt>' instruction is executed, this
John Criswell84114752004-06-25 16:05:06 +00001461table is searched for the given value. If the value is found, control flow is
1462transfered to the corresponding destination; otherwise, control flow is
1463transfered to the default destination.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001464
Chris Lattnerc88c17b2004-02-24 04:54:45 +00001465<h5>Implementation:</h5>
1466
1467<p>Depending on properties of the target machine and the particular
1468<tt>switch</tt> instruction, this instruction may be code generated in different
John Criswell84114752004-06-25 16:05:06 +00001469ways. For example, it could be generated as a series of chained conditional
1470branches or with a lookup table.</p>
Chris Lattnerc88c17b2004-02-24 04:54:45 +00001471
1472<h5>Example:</h5>
1473
1474<pre>
1475 <i>; Emulate a conditional br instruction</i>
Reid Spencer9dee3ac2006-11-08 01:11:31 +00001476 %Val = <a href="#i_zext">zext</a> bool %value to int
Chris Lattnerc88c17b2004-02-24 04:54:45 +00001477 switch int %Val, label %truedest [int 0, label %falsedest ]
1478
1479 <i>; Emulate an unconditional br instruction</i>
1480 switch uint 0, label %dest [ ]
1481
1482 <i>; Implement a jump table:</i>
1483 switch uint %val, label %otherwise [ uint 0, label %onzero
1484 uint 1, label %onone
1485 uint 2, label %ontwo ]
Chris Lattner00950542001-06-06 20:29:01 +00001486</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001487</div>
Chris Lattnerbad10ee2005-05-06 22:57:40 +00001488
Chris Lattner00950542001-06-06 20:29:01 +00001489<!-- _______________________________________________________________________ -->
Chris Lattnerbad10ee2005-05-06 22:57:40 +00001490<div class="doc_subsubsection">
1491 <a name="i_invoke">'<tt>invoke</tt>' Instruction</a>
1492</div>
1493
Misha Brukman9d0919f2003-11-08 01:05:38 +00001494<div class="doc_text">
Chris Lattnerbad10ee2005-05-06 22:57:40 +00001495
Chris Lattner00950542001-06-06 20:29:01 +00001496<h5>Syntax:</h5>
Chris Lattnerbad10ee2005-05-06 22:57:40 +00001497
1498<pre>
1499 &lt;result&gt; = invoke [<a href="#callingconv">cconv</a>] &lt;ptr to function ty&gt; %&lt;function ptr val&gt;(&lt;function args&gt;)
Chris Lattner76b8a332006-05-14 18:23:06 +00001500 to label &lt;normal label&gt; unwind label &lt;exception label&gt;
Chris Lattnerbad10ee2005-05-06 22:57:40 +00001501</pre>
1502
Chris Lattner6536cfe2002-05-06 22:08:29 +00001503<h5>Overview:</h5>
Chris Lattnerbad10ee2005-05-06 22:57:40 +00001504
1505<p>The '<tt>invoke</tt>' instruction causes control to transfer to a specified
1506function, with the possibility of control flow transfer to either the
John Criswelle4c57cc2005-05-12 16:52:32 +00001507'<tt>normal</tt>' label or the
1508'<tt>exception</tt>' label. If the callee function returns with the
Chris Lattnerbad10ee2005-05-06 22:57:40 +00001509"<tt><a href="#i_ret">ret</a></tt>" instruction, control flow will return to the
1510"normal" label. If the callee (or any indirect callees) returns with the "<a
John Criswelle4c57cc2005-05-12 16:52:32 +00001511href="#i_unwind"><tt>unwind</tt></a>" instruction, control is interrupted and
1512continued at the dynamically nearest "exception" label.</p>
Chris Lattnerbad10ee2005-05-06 22:57:40 +00001513
Chris Lattner00950542001-06-06 20:29:01 +00001514<h5>Arguments:</h5>
Chris Lattnerbad10ee2005-05-06 22:57:40 +00001515
Misha Brukman9d0919f2003-11-08 01:05:38 +00001516<p>This instruction requires several arguments:</p>
Chris Lattnerbad10ee2005-05-06 22:57:40 +00001517
Chris Lattner00950542001-06-06 20:29:01 +00001518<ol>
Chris Lattnerbad10ee2005-05-06 22:57:40 +00001519 <li>
John Criswellc1f786c2005-05-13 22:25:59 +00001520 The optional "cconv" marker indicates which <a href="callingconv">calling
Chris Lattnerbad10ee2005-05-06 22:57:40 +00001521 convention</a> the call should use. If none is specified, the call defaults
1522 to using C calling conventions.
1523 </li>
1524 <li>'<tt>ptr to function ty</tt>': shall be the signature of the pointer to
1525 function value being invoked. In most cases, this is a direct function
1526 invocation, but indirect <tt>invoke</tt>s are just as possible, branching off
1527 an arbitrary pointer to function value.
1528 </li>
1529
1530 <li>'<tt>function ptr val</tt>': An LLVM value containing a pointer to a
1531 function to be invoked. </li>
1532
1533 <li>'<tt>function args</tt>': argument list whose types match the function
1534 signature argument types. If the function signature indicates the function
1535 accepts a variable number of arguments, the extra arguments can be
1536 specified. </li>
1537
1538 <li>'<tt>normal label</tt>': the label reached when the called function
1539 executes a '<tt><a href="#i_ret">ret</a></tt>' instruction. </li>
1540
1541 <li>'<tt>exception label</tt>': the label reached when a callee returns with
1542 the <a href="#i_unwind"><tt>unwind</tt></a> instruction. </li>
1543
Chris Lattner00950542001-06-06 20:29:01 +00001544</ol>
Chris Lattnerbad10ee2005-05-06 22:57:40 +00001545
Chris Lattner00950542001-06-06 20:29:01 +00001546<h5>Semantics:</h5>
Chris Lattnerbad10ee2005-05-06 22:57:40 +00001547
Misha Brukman9d0919f2003-11-08 01:05:38 +00001548<p>This instruction is designed to operate as a standard '<tt><a
Chris Lattnerbad10ee2005-05-06 22:57:40 +00001549href="#i_call">call</a></tt>' instruction in most regards. The primary
1550difference is that it establishes an association with a label, which is used by
1551the runtime library to unwind the stack.</p>
1552
1553<p>This instruction is used in languages with destructors to ensure that proper
1554cleanup is performed in the case of either a <tt>longjmp</tt> or a thrown
1555exception. Additionally, this is important for implementation of
1556'<tt>catch</tt>' clauses in high-level languages that support them.</p>
1557
Chris Lattner00950542001-06-06 20:29:01 +00001558<h5>Example:</h5>
Chris Lattnerbad10ee2005-05-06 22:57:40 +00001559<pre>
1560 %retval = invoke int %Test(int 15) to label %Continue
Chris Lattner76b8a332006-05-14 18:23:06 +00001561 unwind label %TestCleanup <i>; {int}:retval set</i>
Chris Lattnerbad10ee2005-05-06 22:57:40 +00001562 %retval = invoke <a href="#callingconv">coldcc</a> int %Test(int 15) to label %Continue
Chris Lattner76b8a332006-05-14 18:23:06 +00001563 unwind label %TestCleanup <i>; {int}:retval set</i>
Chris Lattner00950542001-06-06 20:29:01 +00001564</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001565</div>
Chris Lattner35eca582004-10-16 18:04:13 +00001566
1567
Chris Lattner27f71f22003-09-03 00:41:47 +00001568<!-- _______________________________________________________________________ -->
Chris Lattner35eca582004-10-16 18:04:13 +00001569
Chris Lattner261efe92003-11-25 01:02:51 +00001570<div class="doc_subsubsection"> <a name="i_unwind">'<tt>unwind</tt>'
1571Instruction</a> </div>
Chris Lattner35eca582004-10-16 18:04:13 +00001572
Misha Brukman9d0919f2003-11-08 01:05:38 +00001573<div class="doc_text">
Chris Lattner35eca582004-10-16 18:04:13 +00001574
Chris Lattner27f71f22003-09-03 00:41:47 +00001575<h5>Syntax:</h5>
Chris Lattner35eca582004-10-16 18:04:13 +00001576<pre>
1577 unwind
1578</pre>
1579
Chris Lattner27f71f22003-09-03 00:41:47 +00001580<h5>Overview:</h5>
Chris Lattner35eca582004-10-16 18:04:13 +00001581
1582<p>The '<tt>unwind</tt>' instruction unwinds the stack, continuing control flow
1583at the first callee in the dynamic call stack which used an <a
1584href="#i_invoke"><tt>invoke</tt></a> instruction to perform the call. This is
1585primarily used to implement exception handling.</p>
1586
Chris Lattner27f71f22003-09-03 00:41:47 +00001587<h5>Semantics:</h5>
Chris Lattner35eca582004-10-16 18:04:13 +00001588
1589<p>The '<tt>unwind</tt>' intrinsic causes execution of the current function to
1590immediately halt. The dynamic call stack is then searched for the first <a
1591href="#i_invoke"><tt>invoke</tt></a> instruction on the call stack. Once found,
1592execution continues at the "exceptional" destination block specified by the
1593<tt>invoke</tt> instruction. If there is no <tt>invoke</tt> instruction in the
1594dynamic call chain, undefined behavior results.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001595</div>
Chris Lattner35eca582004-10-16 18:04:13 +00001596
1597<!-- _______________________________________________________________________ -->
1598
1599<div class="doc_subsubsection"> <a name="i_unreachable">'<tt>unreachable</tt>'
1600Instruction</a> </div>
1601
1602<div class="doc_text">
1603
1604<h5>Syntax:</h5>
1605<pre>
1606 unreachable
1607</pre>
1608
1609<h5>Overview:</h5>
1610
1611<p>The '<tt>unreachable</tt>' instruction has no defined semantics. This
1612instruction is used to inform the optimizer that a particular portion of the
1613code is not reachable. This can be used to indicate that the code after a
1614no-return function cannot be reached, and other facts.</p>
1615
1616<h5>Semantics:</h5>
1617
1618<p>The '<tt>unreachable</tt>' instruction has no defined semantics.</p>
1619</div>
1620
1621
1622
Chris Lattner00950542001-06-06 20:29:01 +00001623<!-- ======================================================================= -->
Chris Lattner261efe92003-11-25 01:02:51 +00001624<div class="doc_subsection"> <a name="binaryops">Binary Operations</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001625<div class="doc_text">
Chris Lattner261efe92003-11-25 01:02:51 +00001626<p>Binary operators are used to do most of the computation in a
1627program. They require two operands, execute an operation on them, and
John Criswell9e2485c2004-12-10 15:51:16 +00001628produce a single value. The operands might represent
Chris Lattnera58561b2004-08-12 19:12:28 +00001629multiple data, as is the case with the <a href="#t_packed">packed</a> data type.
1630The result value of a binary operator is not
Chris Lattner261efe92003-11-25 01:02:51 +00001631necessarily the same type as its operands.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001632<p>There are several different binary operators:</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001633</div>
Chris Lattner00950542001-06-06 20:29:01 +00001634<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001635<div class="doc_subsubsection"> <a name="i_add">'<tt>add</tt>'
1636Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001637<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001638<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001639<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 +00001640</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001641<h5>Overview:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001642<p>The '<tt>add</tt>' instruction returns the sum of its two operands.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001643<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001644<p>The two arguments to the '<tt>add</tt>' instruction must be either <a
Chris Lattnera58561b2004-08-12 19:12:28 +00001645 href="#t_integer">integer</a> or <a href="#t_floating">floating point</a> values.
1646 This instruction can also take <a href="#t_packed">packed</a> versions of the values.
1647Both arguments must have identical types.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001648<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001649<p>The value produced is the integer or floating point sum of the two
1650operands.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001651<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001652<pre> &lt;result&gt; = add int 4, %var <i>; yields {int}:result = 4 + %var</i>
Chris Lattner00950542001-06-06 20:29:01 +00001653</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001654</div>
Chris Lattner00950542001-06-06 20:29:01 +00001655<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001656<div class="doc_subsubsection"> <a name="i_sub">'<tt>sub</tt>'
1657Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001658<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001659<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001660<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 +00001661</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001662<h5>Overview:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001663<p>The '<tt>sub</tt>' instruction returns the difference of its two
1664operands.</p>
Chris Lattner261efe92003-11-25 01:02:51 +00001665<p>Note that the '<tt>sub</tt>' instruction is used to represent the '<tt>neg</tt>'
1666instruction present in most other intermediate representations.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001667<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001668<p>The two arguments to the '<tt>sub</tt>' instruction must be either <a
Chris Lattner261efe92003-11-25 01:02:51 +00001669 href="#t_integer">integer</a> or <a href="#t_floating">floating point</a>
Chris Lattnera58561b2004-08-12 19:12:28 +00001670values.
1671This instruction can also take <a href="#t_packed">packed</a> versions of the values.
1672Both arguments must have identical types.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001673<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001674<p>The value produced is the integer or floating point difference of
1675the two operands.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001676<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001677<pre> &lt;result&gt; = sub int 4, %var <i>; yields {int}:result = 4 - %var</i>
Chris Lattner00950542001-06-06 20:29:01 +00001678 &lt;result&gt; = sub int 0, %val <i>; yields {int}:result = -%var</i>
1679</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001680</div>
Chris Lattner00950542001-06-06 20:29:01 +00001681<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001682<div class="doc_subsubsection"> <a name="i_mul">'<tt>mul</tt>'
1683Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001684<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001685<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001686<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 +00001687</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001688<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001689<p>The '<tt>mul</tt>' instruction returns the product of its two
1690operands.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001691<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001692<p>The two arguments to the '<tt>mul</tt>' instruction must be either <a
Chris Lattner261efe92003-11-25 01:02:51 +00001693 href="#t_integer">integer</a> or <a href="#t_floating">floating point</a>
Chris Lattnera58561b2004-08-12 19:12:28 +00001694values.
1695This instruction can also take <a href="#t_packed">packed</a> versions of the values.
1696Both arguments must have identical types.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001697<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001698<p>The value produced is the integer or floating point product of the
Misha Brukman9d0919f2003-11-08 01:05:38 +00001699two operands.</p>
Chris Lattner261efe92003-11-25 01:02:51 +00001700<p>There is no signed vs unsigned multiplication. The appropriate
1701action is taken based on the type of the operand.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001702<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001703<pre> &lt;result&gt; = mul int 4, %var <i>; yields {int}:result = 4 * %var</i>
Chris Lattner00950542001-06-06 20:29:01 +00001704</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001705</div>
Chris Lattner00950542001-06-06 20:29:01 +00001706<!-- _______________________________________________________________________ -->
Reid Spencer1628cec2006-10-26 06:15:43 +00001707<div class="doc_subsubsection"> <a name="i_udiv">'<tt>udiv</tt>' Instruction
1708</a></div>
1709<div class="doc_text">
1710<h5>Syntax:</h5>
1711<pre> &lt;result&gt; = udiv &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
1712</pre>
1713<h5>Overview:</h5>
1714<p>The '<tt>udiv</tt>' instruction returns the quotient of its two
1715operands.</p>
1716<h5>Arguments:</h5>
1717<p>The two arguments to the '<tt>udiv</tt>' instruction must be
1718<a href="#t_integer">integer</a> values. Both arguments must have identical
1719types. This instruction can also take <a href="#t_packed">packed</a> versions
1720of the values in which case the elements must be integers.</p>
1721<h5>Semantics:</h5>
1722<p>The value produced is the unsigned integer quotient of the two operands. This
1723instruction always performs an unsigned division operation, regardless of
1724whether the arguments are unsigned or not.</p>
1725<h5>Example:</h5>
1726<pre> &lt;result&gt; = udiv uint 4, %var <i>; yields {uint}:result = 4 / %var</i>
1727</pre>
1728</div>
1729<!-- _______________________________________________________________________ -->
1730<div class="doc_subsubsection"> <a name="i_sdiv">'<tt>sdiv</tt>' Instruction
1731</a> </div>
1732<div class="doc_text">
1733<h5>Syntax:</h5>
1734<pre> &lt;result&gt; = sdiv &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
1735</pre>
1736<h5>Overview:</h5>
1737<p>The '<tt>sdiv</tt>' instruction returns the quotient of its two
1738operands.</p>
1739<h5>Arguments:</h5>
1740<p>The two arguments to the '<tt>sdiv</tt>' instruction must be
1741<a href="#t_integer">integer</a> values. Both arguments must have identical
1742types. This instruction can also take <a href="#t_packed">packed</a> versions
1743of the values in which case the elements must be integers.</p>
1744<h5>Semantics:</h5>
1745<p>The value produced is the signed integer quotient of the two operands. This
1746instruction always performs a signed division operation, regardless of whether
1747the arguments are signed or not.</p>
1748<h5>Example:</h5>
1749<pre> &lt;result&gt; = sdiv int 4, %var <i>; yields {int}:result = 4 / %var</i>
1750</pre>
1751</div>
1752<!-- _______________________________________________________________________ -->
1753<div class="doc_subsubsection"> <a name="i_fdiv">'<tt>fdiv</tt>'
Chris Lattner261efe92003-11-25 01:02:51 +00001754Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001755<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001756<h5>Syntax:</h5>
Reid Spencer1628cec2006-10-26 06:15:43 +00001757<pre> &lt;result&gt; = fdiv &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
Chris Lattner261efe92003-11-25 01:02:51 +00001758</pre>
1759<h5>Overview:</h5>
Reid Spencer1628cec2006-10-26 06:15:43 +00001760<p>The '<tt>fdiv</tt>' instruction returns the quotient of its two
Chris Lattner261efe92003-11-25 01:02:51 +00001761operands.</p>
1762<h5>Arguments:</h5>
Reid Spencer1628cec2006-10-26 06:15:43 +00001763<p>The two arguments to the '<tt>div</tt>' instruction must be
1764<a href="#t_floating">floating point</a> values. Both arguments must have
1765identical types. This instruction can also take <a href="#t_packed">packed</a>
1766versions of the values in which case the elements must be floating point.</p>
Chris Lattner261efe92003-11-25 01:02:51 +00001767<h5>Semantics:</h5>
Reid Spencer1628cec2006-10-26 06:15:43 +00001768<p>The value produced is the floating point quotient of the two operands.</p>
Chris Lattner261efe92003-11-25 01:02:51 +00001769<h5>Example:</h5>
Reid Spencer1628cec2006-10-26 06:15:43 +00001770<pre> &lt;result&gt; = fdiv float 4.0, %var <i>; yields {float}:result = 4.0 / %var</i>
Chris Lattner261efe92003-11-25 01:02:51 +00001771</pre>
1772</div>
1773<!-- _______________________________________________________________________ -->
Reid Spencer0a783f72006-11-02 01:53:59 +00001774<div class="doc_subsubsection"> <a name="i_urem">'<tt>urem</tt>' Instruction</a>
1775</div>
1776<div class="doc_text">
1777<h5>Syntax:</h5>
1778<pre> &lt;result&gt; = urem &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
1779</pre>
1780<h5>Overview:</h5>
1781<p>The '<tt>urem</tt>' instruction returns the remainder from the
1782unsigned division of its two arguments.</p>
1783<h5>Arguments:</h5>
1784<p>The two arguments to the '<tt>urem</tt>' instruction must be
1785<a href="#t_integer">integer</a> values. Both arguments must have identical
1786types.</p>
1787<h5>Semantics:</h5>
1788<p>This instruction returns the unsigned integer <i>remainder</i> of a division.
1789This instruction always performs an unsigned division to get the remainder,
1790regardless of whether the arguments are unsigned or not.</p>
1791<h5>Example:</h5>
1792<pre> &lt;result&gt; = urem uint 4, %var <i>; yields {uint}:result = 4 % %var</i>
1793</pre>
1794
1795</div>
1796<!-- _______________________________________________________________________ -->
1797<div class="doc_subsubsection"> <a name="i_srem">'<tt>srem</tt>'
Chris Lattner261efe92003-11-25 01:02:51 +00001798Instruction</a> </div>
1799<div class="doc_text">
1800<h5>Syntax:</h5>
Reid Spencer0a783f72006-11-02 01:53:59 +00001801<pre> &lt;result&gt; = srem &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
Chris Lattner261efe92003-11-25 01:02:51 +00001802</pre>
1803<h5>Overview:</h5>
Reid Spencer0a783f72006-11-02 01:53:59 +00001804<p>The '<tt>srem</tt>' instruction returns the remainder from the
1805signed division of its two operands.</p>
Chris Lattner261efe92003-11-25 01:02:51 +00001806<h5>Arguments:</h5>
Reid Spencer0a783f72006-11-02 01:53:59 +00001807<p>The two arguments to the '<tt>srem</tt>' instruction must be
1808<a href="#t_integer">integer</a> values. Both arguments must have identical
1809types.</p>
Chris Lattner261efe92003-11-25 01:02:51 +00001810<h5>Semantics:</h5>
Reid Spencer0a783f72006-11-02 01:53:59 +00001811<p>This instruction returns the <i>remainder</i> of a division (where the result
Chris Lattner261efe92003-11-25 01:02:51 +00001812has the same sign as the divisor), not the <i>modulus</i> (where the
1813result has the same sign as the dividend) of a value. For more
John Criswell0ec250c2005-10-24 16:17:18 +00001814information about the difference, see <a
Chris Lattner261efe92003-11-25 01:02:51 +00001815 href="http://mathforum.org/dr.math/problems/anne.4.28.99.html">The
1816Math Forum</a>.</p>
1817<h5>Example:</h5>
Reid Spencer0a783f72006-11-02 01:53:59 +00001818<pre> &lt;result&gt; = srem int 4, %var <i>; yields {int}:result = 4 % %var</i>
1819</pre>
1820
1821</div>
1822<!-- _______________________________________________________________________ -->
1823<div class="doc_subsubsection"> <a name="i_frem">'<tt>frem</tt>'
1824Instruction</a> </div>
1825<div class="doc_text">
1826<h5>Syntax:</h5>
1827<pre> &lt;result&gt; = frem &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
1828</pre>
1829<h5>Overview:</h5>
1830<p>The '<tt>frem</tt>' instruction returns the remainder from the
1831division of its two operands.</p>
1832<h5>Arguments:</h5>
1833<p>The two arguments to the '<tt>frem</tt>' instruction must be
1834<a href="#t_floating">floating point</a> values. Both arguments must have
1835identical types.</p>
1836<h5>Semantics:</h5>
1837<p>This instruction returns the <i>remainder</i> of a division.</p>
1838<h5>Example:</h5>
1839<pre> &lt;result&gt; = frem float 4.0, %var <i>; yields {float}:result = 4.0 % %var</i>
Chris Lattner261efe92003-11-25 01:02:51 +00001840</pre>
Robert Bocchino7b81c752006-02-17 21:18:08 +00001841
Chris Lattner261efe92003-11-25 01:02:51 +00001842</div>
1843<!-- _______________________________________________________________________ -->
1844<div class="doc_subsubsection"> <a name="i_setcc">'<tt>set<i>cc</i></tt>'
1845Instructions</a> </div>
1846<div class="doc_text">
1847<h5>Syntax:</h5>
1848<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 +00001849 &lt;result&gt; = setne &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {bool}:result</i>
1850 &lt;result&gt; = setlt &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {bool}:result</i>
1851 &lt;result&gt; = setgt &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {bool}:result</i>
1852 &lt;result&gt; = setle &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {bool}:result</i>
1853 &lt;result&gt; = setge &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {bool}:result</i>
1854</pre>
Chris Lattner261efe92003-11-25 01:02:51 +00001855<h5>Overview:</h5>
1856<p>The '<tt>set<i>cc</i></tt>' family of instructions returns a boolean
1857value based on a comparison of their two operands.</p>
1858<h5>Arguments:</h5>
1859<p>The two arguments to the '<tt>set<i>cc</i></tt>' instructions must
1860be of <a href="#t_firstclass">first class</a> type (it is not possible
1861to compare '<tt>label</tt>'s, '<tt>array</tt>'s, '<tt>structure</tt>'
1862or '<tt>void</tt>' values, etc...). Both arguments must have identical
1863types.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001864<h5>Semantics:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001865<p>The '<tt>seteq</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>'
1866value if both operands are equal.<br>
1867The '<tt>setne</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>'
1868value if both operands are unequal.<br>
1869The '<tt>setlt</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>'
1870value if the first operand is less than the second operand.<br>
1871The '<tt>setgt</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>'
1872value if the first operand is greater than the second operand.<br>
1873The '<tt>setle</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>'
1874value if the first operand is less than or equal to the second operand.<br>
1875The '<tt>setge</tt>' instruction yields a <tt>true</tt> '<tt>bool</tt>'
1876value if the first operand is greater than or equal to the second
1877operand.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001878<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001879<pre> &lt;result&gt; = seteq int 4, 5 <i>; yields {bool}:result = false</i>
Chris Lattner00950542001-06-06 20:29:01 +00001880 &lt;result&gt; = setne float 4, 5 <i>; yields {bool}:result = true</i>
1881 &lt;result&gt; = setlt uint 4, 5 <i>; yields {bool}:result = true</i>
1882 &lt;result&gt; = setgt sbyte 4, 5 <i>; yields {bool}:result = false</i>
1883 &lt;result&gt; = setle sbyte 4, 5 <i>; yields {bool}:result = true</i>
1884 &lt;result&gt; = setge sbyte 4, 5 <i>; yields {bool}:result = false</i>
1885</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001886</div>
Robert Bocchino7b81c752006-02-17 21:18:08 +00001887
Chris Lattner00950542001-06-06 20:29:01 +00001888<!-- ======================================================================= -->
Chris Lattner261efe92003-11-25 01:02:51 +00001889<div class="doc_subsection"> <a name="bitwiseops">Bitwise Binary
1890Operations</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001891<div class="doc_text">
Chris Lattner261efe92003-11-25 01:02:51 +00001892<p>Bitwise binary operators are used to do various forms of
1893bit-twiddling in a program. They are generally very efficient
John Criswell9e2485c2004-12-10 15:51:16 +00001894instructions and can commonly be strength reduced from other
Chris Lattner261efe92003-11-25 01:02:51 +00001895instructions. They require two operands, execute an operation on them,
1896and produce a single value. The resulting value of the bitwise binary
1897operators is always the same type as its first operand.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001898</div>
Chris Lattner00950542001-06-06 20:29:01 +00001899<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001900<div class="doc_subsubsection"> <a name="i_and">'<tt>and</tt>'
1901Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001902<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001903<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001904<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 +00001905</pre>
Chris Lattner00950542001-06-06 20:29:01 +00001906<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001907<p>The '<tt>and</tt>' instruction returns the bitwise logical and of
1908its two operands.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001909<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001910<p>The two arguments to the '<tt>and</tt>' instruction must be <a
Chris Lattner261efe92003-11-25 01:02:51 +00001911 href="#t_integral">integral</a> values. Both arguments must have
1912identical types.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001913<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001914<p>The truth table used for the '<tt>and</tt>' instruction is:</p>
Chris Lattner261efe92003-11-25 01:02:51 +00001915<p> </p>
Misha Brukmandaa4cb02004-03-01 17:47:27 +00001916<div style="align: center">
Misha Brukman9d0919f2003-11-08 01:05:38 +00001917<table border="1" cellspacing="0" cellpadding="4">
Chris Lattner261efe92003-11-25 01:02:51 +00001918 <tbody>
1919 <tr>
1920 <td>In0</td>
1921 <td>In1</td>
1922 <td>Out</td>
1923 </tr>
1924 <tr>
1925 <td>0</td>
1926 <td>0</td>
1927 <td>0</td>
1928 </tr>
1929 <tr>
1930 <td>0</td>
1931 <td>1</td>
1932 <td>0</td>
1933 </tr>
1934 <tr>
1935 <td>1</td>
1936 <td>0</td>
1937 <td>0</td>
1938 </tr>
1939 <tr>
1940 <td>1</td>
1941 <td>1</td>
1942 <td>1</td>
1943 </tr>
1944 </tbody>
1945</table>
Misha Brukmandaa4cb02004-03-01 17:47:27 +00001946</div>
Chris Lattner00950542001-06-06 20:29:01 +00001947<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001948<pre> &lt;result&gt; = and int 4, %var <i>; yields {int}:result = 4 &amp; %var</i>
Chris Lattner00950542001-06-06 20:29:01 +00001949 &lt;result&gt; = and int 15, 40 <i>; yields {int}:result = 8</i>
1950 &lt;result&gt; = and int 4, 8 <i>; yields {int}:result = 0</i>
1951</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001952</div>
Chris Lattner00950542001-06-06 20:29:01 +00001953<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00001954<div class="doc_subsubsection"> <a name="i_or">'<tt>or</tt>' Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001955<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00001956<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00001957<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 +00001958</pre>
Chris Lattner261efe92003-11-25 01:02:51 +00001959<h5>Overview:</h5>
1960<p>The '<tt>or</tt>' instruction returns the bitwise logical inclusive
1961or of its two operands.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001962<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001963<p>The two arguments to the '<tt>or</tt>' instruction must be <a
Chris Lattner261efe92003-11-25 01:02:51 +00001964 href="#t_integral">integral</a> values. Both arguments must have
1965identical types.</p>
Chris Lattner00950542001-06-06 20:29:01 +00001966<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00001967<p>The truth table used for the '<tt>or</tt>' instruction is:</p>
Chris Lattner261efe92003-11-25 01:02:51 +00001968<p> </p>
Misha Brukmandaa4cb02004-03-01 17:47:27 +00001969<div style="align: center">
Chris Lattner261efe92003-11-25 01:02:51 +00001970<table border="1" cellspacing="0" cellpadding="4">
1971 <tbody>
1972 <tr>
1973 <td>In0</td>
1974 <td>In1</td>
1975 <td>Out</td>
1976 </tr>
1977 <tr>
1978 <td>0</td>
1979 <td>0</td>
1980 <td>0</td>
1981 </tr>
1982 <tr>
1983 <td>0</td>
1984 <td>1</td>
1985 <td>1</td>
1986 </tr>
1987 <tr>
1988 <td>1</td>
1989 <td>0</td>
1990 <td>1</td>
1991 </tr>
1992 <tr>
1993 <td>1</td>
1994 <td>1</td>
1995 <td>1</td>
1996 </tr>
1997 </tbody>
1998</table>
Misha Brukmandaa4cb02004-03-01 17:47:27 +00001999</div>
Chris Lattner00950542001-06-06 20:29:01 +00002000<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00002001<pre> &lt;result&gt; = or int 4, %var <i>; yields {int}:result = 4 | %var</i>
Chris Lattner00950542001-06-06 20:29:01 +00002002 &lt;result&gt; = or int 15, 40 <i>; yields {int}:result = 47</i>
2003 &lt;result&gt; = or int 4, 8 <i>; yields {int}:result = 12</i>
2004</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002005</div>
Chris Lattner00950542001-06-06 20:29:01 +00002006<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00002007<div class="doc_subsubsection"> <a name="i_xor">'<tt>xor</tt>'
2008Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002009<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00002010<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00002011<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 +00002012</pre>
Chris Lattner00950542001-06-06 20:29:01 +00002013<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00002014<p>The '<tt>xor</tt>' instruction returns the bitwise logical exclusive
2015or of its two operands. The <tt>xor</tt> is used to implement the
2016"one's complement" operation, which is the "~" operator in C.</p>
Chris Lattner00950542001-06-06 20:29:01 +00002017<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002018<p>The two arguments to the '<tt>xor</tt>' instruction must be <a
Chris Lattner261efe92003-11-25 01:02:51 +00002019 href="#t_integral">integral</a> values. Both arguments must have
2020identical types.</p>
Chris Lattner00950542001-06-06 20:29:01 +00002021<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002022<p>The truth table used for the '<tt>xor</tt>' instruction is:</p>
Chris Lattner261efe92003-11-25 01:02:51 +00002023<p> </p>
Misha Brukmandaa4cb02004-03-01 17:47:27 +00002024<div style="align: center">
Chris Lattner261efe92003-11-25 01:02:51 +00002025<table border="1" cellspacing="0" cellpadding="4">
2026 <tbody>
2027 <tr>
2028 <td>In0</td>
2029 <td>In1</td>
2030 <td>Out</td>
2031 </tr>
2032 <tr>
2033 <td>0</td>
2034 <td>0</td>
2035 <td>0</td>
2036 </tr>
2037 <tr>
2038 <td>0</td>
2039 <td>1</td>
2040 <td>1</td>
2041 </tr>
2042 <tr>
2043 <td>1</td>
2044 <td>0</td>
2045 <td>1</td>
2046 </tr>
2047 <tr>
2048 <td>1</td>
2049 <td>1</td>
2050 <td>0</td>
2051 </tr>
2052 </tbody>
2053</table>
Misha Brukmandaa4cb02004-03-01 17:47:27 +00002054</div>
Chris Lattner261efe92003-11-25 01:02:51 +00002055<p> </p>
Chris Lattner00950542001-06-06 20:29:01 +00002056<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00002057<pre> &lt;result&gt; = xor int 4, %var <i>; yields {int}:result = 4 ^ %var</i>
Chris Lattner00950542001-06-06 20:29:01 +00002058 &lt;result&gt; = xor int 15, 40 <i>; yields {int}:result = 39</i>
2059 &lt;result&gt; = xor int 4, 8 <i>; yields {int}:result = 12</i>
Chris Lattner27f71f22003-09-03 00:41:47 +00002060 &lt;result&gt; = xor int %V, -1 <i>; yields {int}:result = ~%V</i>
Chris Lattner00950542001-06-06 20:29:01 +00002061</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002062</div>
Chris Lattner00950542001-06-06 20:29:01 +00002063<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00002064<div class="doc_subsubsection"> <a name="i_shl">'<tt>shl</tt>'
2065Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002066<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00002067<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00002068<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 +00002069</pre>
Chris Lattner00950542001-06-06 20:29:01 +00002070<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00002071<p>The '<tt>shl</tt>' instruction returns the first operand shifted to
2072the left a specified number of bits.</p>
Chris Lattner00950542001-06-06 20:29:01 +00002073<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002074<p>The first argument to the '<tt>shl</tt>' instruction must be an <a
Chris Lattner261efe92003-11-25 01:02:51 +00002075 href="#t_integer">integer</a> type. The second argument must be an '<tt>ubyte</tt>'
2076type.</p>
Chris Lattner00950542001-06-06 20:29:01 +00002077<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002078<p>The value produced is <tt>var1</tt> * 2<sup><tt>var2</tt></sup>.</p>
Chris Lattner00950542001-06-06 20:29:01 +00002079<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00002080<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 +00002081 &lt;result&gt; = shl int 4, ubyte 2 <i>; yields {int}:result = 16</i>
2082 &lt;result&gt; = shl int 1, ubyte 10 <i>; yields {int}:result = 1024</i>
2083</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002084</div>
Chris Lattner00950542001-06-06 20:29:01 +00002085<!-- _______________________________________________________________________ -->
Reid Spencer3822ff52006-11-08 06:47:33 +00002086<div class="doc_subsubsection"> <a name="i_lshr">'<tt>lshr</tt>'
Chris Lattner261efe92003-11-25 01:02:51 +00002087Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002088<div class="doc_text">
Chris Lattner00950542001-06-06 20:29:01 +00002089<h5>Syntax:</h5>
Reid Spencer3822ff52006-11-08 06:47:33 +00002090<pre> &lt;result&gt; = lshr &lt;ty&gt; &lt;var1&gt;, ubyte &lt;var2&gt; <i>; yields {ty}:result</i>
Chris Lattner00950542001-06-06 20:29:01 +00002091</pre>
Reid Spencer3822ff52006-11-08 06:47:33 +00002092
Chris Lattner00950542001-06-06 20:29:01 +00002093<h5>Overview:</h5>
Reid Spencer3822ff52006-11-08 06:47:33 +00002094<p>The '<tt>lshr</tt>' instruction (logical shift right) returns the first
2095operand shifted to the right a specified number of bits.</p>
2096
Chris Lattner00950542001-06-06 20:29:01 +00002097<h5>Arguments:</h5>
Reid Spencer3822ff52006-11-08 06:47:33 +00002098<p>The first argument to the '<tt>lshr</tt>' instruction must be an <a
2099 href="#t_integer">integer</a> type. The second argument must be an '<tt>ubyte</tt>' type.</p>
2100
Chris Lattner00950542001-06-06 20:29:01 +00002101<h5>Semantics:</h5>
Reid Spencer3822ff52006-11-08 06:47:33 +00002102<p>This instruction always performs a logical shift right operation, regardless
2103of whether the arguments are unsigned or not. The <tt>var2</tt> most significant
2104bits will be filled with zero bits after the shift.</p>
2105
Chris Lattner00950542001-06-06 20:29:01 +00002106<h5>Example:</h5>
Reid Spencer3822ff52006-11-08 06:47:33 +00002107<pre>
2108 &lt;result&gt; = lshr uint 4, ubyte 1 <i>; yields {uint}:result = 2</i>
2109 &lt;result&gt; = lshr int 4, ubyte 2 <i>; yields {uint}:result = 1</i>
2110 &lt;result&gt; = lshr sbyte 4, ubyte 3 <i>; yields {sbyte}:result = 0</i>
2111 &lt;result&gt; = lshr sbyte -2, ubyte 1 <i>; yields {sbyte}:result = 0x7FFFFFFF </i>
2112</pre>
2113</div>
2114
2115<!-- ======================================================================= -->
2116<div class="doc_subsubsection"> <a name="i_ashr">'<tt>ashr</tt>'
2117Instruction</a> </div>
2118<div class="doc_text">
2119
2120<h5>Syntax:</h5>
2121<pre> &lt;result&gt; = ashr &lt;ty&gt; &lt;var1&gt;, ubyte &lt;var2&gt; <i>; yields {ty}:result</i>
2122</pre>
2123
2124<h5>Overview:</h5>
2125<p>The '<tt>ashr</tt>' instruction (arithmetic shift right) returns the first
2126operand shifted to the right a specified number of bits.</p>
2127
2128<h5>Arguments:</h5>
2129<p>The first argument to the '<tt>ashr</tt>' instruction must be an
2130<a href="#t_integer">integer</a> type. The second argument must be an
2131'<tt>ubyte</tt>' type.</p>
2132
2133<h5>Semantics:</h5>
2134<p>This instruction always performs an arithmetic shift right operation,
2135regardless of whether the arguments are signed or not. The <tt>var2</tt> most
2136significant bits will be filled with the sign bit of <tt>var1</tt>.</p>
2137
2138<h5>Example:</h5>
2139<pre>
2140 &lt;result&gt; = ashr uint 4, ubyte 1 <i>; yields {uint}:result = 2</i>
2141 &lt;result&gt; = ashr int 4, ubyte 2 <i>; yields {int}:result = 1</i>
2142 &lt;result&gt; = ashr ubyte 4, ubyte 3 <i>; yields {ubyte}:result = 0</i>
2143 &lt;result&gt; = ashr sbyte -2, ubyte 1 <i>; yields {sbyte}:result = -1</i>
Chris Lattner00950542001-06-06 20:29:01 +00002144</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002145</div>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002146
Chris Lattner00950542001-06-06 20:29:01 +00002147<!-- ======================================================================= -->
Chris Lattner2cbdc452005-11-06 08:02:57 +00002148<div class="doc_subsection">
Chris Lattner3df241e2006-04-08 23:07:04 +00002149 <a name="vectorops">Vector Operations</a>
2150</div>
2151
2152<div class="doc_text">
2153
2154<p>LLVM supports several instructions to represent vector operations in a
2155target-independent manner. This instructions cover the element-access and
2156vector-specific operations needed to process vectors effectively. While LLVM
2157does directly support these vector operations, many sophisticated algorithms
2158will want to use target-specific intrinsics to take full advantage of a specific
2159target.</p>
2160
2161</div>
2162
2163<!-- _______________________________________________________________________ -->
2164<div class="doc_subsubsection">
2165 <a name="i_extractelement">'<tt>extractelement</tt>' Instruction</a>
2166</div>
2167
2168<div class="doc_text">
2169
2170<h5>Syntax:</h5>
2171
2172<pre>
2173 &lt;result&gt; = extractelement &lt;n x &lt;ty&gt;&gt; &lt;val&gt;, uint &lt;idx&gt; <i>; yields &lt;ty&gt;</i>
2174</pre>
2175
2176<h5>Overview:</h5>
2177
2178<p>
2179The '<tt>extractelement</tt>' instruction extracts a single scalar
2180element from a packed vector at a specified index.
2181</p>
2182
2183
2184<h5>Arguments:</h5>
2185
2186<p>
2187The first operand of an '<tt>extractelement</tt>' instruction is a
2188value of <a href="#t_packed">packed</a> type. The second operand is
2189an index indicating the position from which to extract the element.
2190The index may be a variable.</p>
2191
2192<h5>Semantics:</h5>
2193
2194<p>
2195The result is a scalar of the same type as the element type of
2196<tt>val</tt>. Its value is the value at position <tt>idx</tt> of
2197<tt>val</tt>. If <tt>idx</tt> exceeds the length of <tt>val</tt>, the
2198results are undefined.
2199</p>
2200
2201<h5>Example:</h5>
2202
2203<pre>
2204 %result = extractelement &lt;4 x int&gt; %vec, uint 0 <i>; yields int</i>
2205</pre>
2206</div>
2207
2208
2209<!-- _______________________________________________________________________ -->
2210<div class="doc_subsubsection">
2211 <a name="i_insertelement">'<tt>insertelement</tt>' Instruction</a>
2212</div>
2213
2214<div class="doc_text">
2215
2216<h5>Syntax:</h5>
2217
2218<pre>
2219 &lt;result&gt; = insertelement &lt;n x &lt;ty&gt;&gt; &lt;val&gt;, &lt;ty&gt; &lt;elt&gt, uint &lt;idx&gt; <i>; yields &lt;n x &lt;ty&gt;&gt;</i>
2220</pre>
2221
2222<h5>Overview:</h5>
2223
2224<p>
2225The '<tt>insertelement</tt>' instruction inserts a scalar
2226element into a packed vector at a specified index.
2227</p>
2228
2229
2230<h5>Arguments:</h5>
2231
2232<p>
2233The first operand of an '<tt>insertelement</tt>' instruction is a
2234value of <a href="#t_packed">packed</a> type. The second operand is a
2235scalar value whose type must equal the element type of the first
2236operand. The third operand is an index indicating the position at
2237which to insert the value. The index may be a variable.</p>
2238
2239<h5>Semantics:</h5>
2240
2241<p>
2242The result is a packed vector of the same type as <tt>val</tt>. Its
2243element values are those of <tt>val</tt> except at position
2244<tt>idx</tt>, where it gets the value <tt>elt</tt>. If <tt>idx</tt>
2245exceeds the length of <tt>val</tt>, the results are undefined.
2246</p>
2247
2248<h5>Example:</h5>
2249
2250<pre>
2251 %result = insertelement &lt;4 x int&gt; %vec, int 1, uint 0 <i>; yields &lt;4 x int&gt;</i>
2252</pre>
2253</div>
2254
2255<!-- _______________________________________________________________________ -->
2256<div class="doc_subsubsection">
2257 <a name="i_shufflevector">'<tt>shufflevector</tt>' Instruction</a>
2258</div>
2259
2260<div class="doc_text">
2261
2262<h5>Syntax:</h5>
2263
2264<pre>
2265 &lt;result&gt; = shufflevector &lt;n x &lt;ty&gt;&gt; &lt;v1&gt;, &lt;n x &lt;ty&gt;&gt; &lt;v2&gt;, &lt;n x uint&gt; &lt;mask&gt; <i>; yields &lt;n x &lt;ty&gt;&gt;</i>
2266</pre>
2267
2268<h5>Overview:</h5>
2269
2270<p>
2271The '<tt>shufflevector</tt>' instruction constructs a permutation of elements
2272from two input vectors, returning a vector of the same type.
2273</p>
2274
2275<h5>Arguments:</h5>
2276
2277<p>
2278The first two operands of a '<tt>shufflevector</tt>' instruction are vectors
2279with types that match each other and types that match the result of the
2280instruction. The third argument is a shuffle mask, which has the same number
2281of elements as the other vector type, but whose element type is always 'uint'.
2282</p>
2283
2284<p>
2285The shuffle mask operand is required to be a constant vector with either
2286constant integer or undef values.
2287</p>
2288
2289<h5>Semantics:</h5>
2290
2291<p>
2292The elements of the two input vectors are numbered from left to right across
2293both of the vectors. The shuffle mask operand specifies, for each element of
2294the result vector, which element of the two input registers the result element
2295gets. The element selector may be undef (meaning "don't care") and the second
2296operand may be undef if performing a shuffle from only one vector.
2297</p>
2298
2299<h5>Example:</h5>
2300
2301<pre>
2302 %result = shufflevector &lt;4 x int&gt; %v1, &lt;4 x int&gt; %v2,
2303 &lt;4 x uint&gt; &lt;uint 0, uint 4, uint 1, uint 5&gt; <i>; yields &lt;4 x int&gt;</i>
2304 %result = shufflevector &lt;4 x int&gt; %v1, &lt;4 x int&gt; undef,
2305 &lt;4 x uint&gt; &lt;uint 0, uint 1, uint 2, uint 3&gt; <i>; yields &lt;4 x int&gt;</i> - Identity shuffle.
2306</pre>
2307</div>
2308
Tanya Lattner09474292006-04-14 19:24:33 +00002309
Chris Lattner3df241e2006-04-08 23:07:04 +00002310<!-- ======================================================================= -->
2311<div class="doc_subsection">
Chris Lattner884a9702006-08-15 00:45:58 +00002312 <a name="memoryops">Memory Access and Addressing Operations</a>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002313</div>
2314
Misha Brukman9d0919f2003-11-08 01:05:38 +00002315<div class="doc_text">
Chris Lattner2cbdc452005-11-06 08:02:57 +00002316
Chris Lattner261efe92003-11-25 01:02:51 +00002317<p>A key design point of an SSA-based representation is how it
2318represents memory. In LLVM, no memory locations are in SSA form, which
2319makes things very simple. This section describes how to read, write,
John Criswell9e2485c2004-12-10 15:51:16 +00002320allocate, and free memory in LLVM.</p>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002321
Misha Brukman9d0919f2003-11-08 01:05:38 +00002322</div>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002323
Chris Lattner00950542001-06-06 20:29:01 +00002324<!-- _______________________________________________________________________ -->
Chris Lattner2cbdc452005-11-06 08:02:57 +00002325<div class="doc_subsubsection">
2326 <a name="i_malloc">'<tt>malloc</tt>' Instruction</a>
2327</div>
2328
Misha Brukman9d0919f2003-11-08 01:05:38 +00002329<div class="doc_text">
Chris Lattner2cbdc452005-11-06 08:02:57 +00002330
Chris Lattner00950542001-06-06 20:29:01 +00002331<h5>Syntax:</h5>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002332
2333<pre>
2334 &lt;result&gt; = malloc &lt;type&gt;[, uint &lt;NumElements&gt;][, align &lt;alignment&gt;] <i>; yields {type*}:result</i>
Chris Lattner00950542001-06-06 20:29:01 +00002335</pre>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002336
Chris Lattner00950542001-06-06 20:29:01 +00002337<h5>Overview:</h5>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002338
Chris Lattner261efe92003-11-25 01:02:51 +00002339<p>The '<tt>malloc</tt>' instruction allocates memory from the system
2340heap and returns a pointer to it.</p>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002341
Chris Lattner00950542001-06-06 20:29:01 +00002342<h5>Arguments:</h5>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002343
2344<p>The '<tt>malloc</tt>' instruction allocates
2345<tt>sizeof(&lt;type&gt;)*NumElements</tt>
John Criswell6e4ca612004-02-24 16:13:56 +00002346bytes of memory from the operating system and returns a pointer of the
Chris Lattner2cbdc452005-11-06 08:02:57 +00002347appropriate type to the program. If "NumElements" is specified, it is the
2348number of elements allocated. If an alignment is specified, the value result
2349of the allocation is guaranteed to be aligned to at least that boundary. If
2350not specified, or if zero, the target can choose to align the allocation on any
2351convenient boundary.</p>
2352
Misha Brukman9d0919f2003-11-08 01:05:38 +00002353<p>'<tt>type</tt>' must be a sized type.</p>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002354
Chris Lattner00950542001-06-06 20:29:01 +00002355<h5>Semantics:</h5>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002356
Chris Lattner261efe92003-11-25 01:02:51 +00002357<p>Memory is allocated using the system "<tt>malloc</tt>" function, and
2358a pointer is returned.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002359
Chris Lattner2cbdc452005-11-06 08:02:57 +00002360<h5>Example:</h5>
2361
2362<pre>
2363 %array = malloc [4 x ubyte ] <i>; yields {[%4 x ubyte]*}:array</i>
2364
2365 %size = <a href="#i_add">add</a> uint 2, 2 <i>; yields {uint}:size = uint 4</i>
Chris Lattner7faa8832002-04-14 06:13:44 +00002366 %array1 = malloc ubyte, uint 4 <i>; yields {ubyte*}:array1</i>
2367 %array2 = malloc [12 x ubyte], uint %size <i>; yields {[12 x ubyte]*}:array2</i>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002368 %array3 = malloc int, uint 4, align 1024 <i>; yields {int*}:array3</i>
2369 %array4 = malloc int, align 1024 <i>; yields {int*}:array4</i>
Chris Lattner00950542001-06-06 20:29:01 +00002370</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002371</div>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002372
Chris Lattner00950542001-06-06 20:29:01 +00002373<!-- _______________________________________________________________________ -->
Chris Lattner2cbdc452005-11-06 08:02:57 +00002374<div class="doc_subsubsection">
2375 <a name="i_free">'<tt>free</tt>' Instruction</a>
2376</div>
2377
Misha Brukman9d0919f2003-11-08 01:05:38 +00002378<div class="doc_text">
Chris Lattner2cbdc452005-11-06 08:02:57 +00002379
Chris Lattner00950542001-06-06 20:29:01 +00002380<h5>Syntax:</h5>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002381
2382<pre>
2383 free &lt;type&gt; &lt;value&gt; <i>; yields {void}</i>
Chris Lattner00950542001-06-06 20:29:01 +00002384</pre>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002385
Chris Lattner00950542001-06-06 20:29:01 +00002386<h5>Overview:</h5>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002387
Chris Lattner261efe92003-11-25 01:02:51 +00002388<p>The '<tt>free</tt>' instruction returns memory back to the unused
John Criswellc1f786c2005-05-13 22:25:59 +00002389memory heap to be reallocated in the future.</p>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002390
Chris Lattner00950542001-06-06 20:29:01 +00002391<h5>Arguments:</h5>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002392
Chris Lattner261efe92003-11-25 01:02:51 +00002393<p>'<tt>value</tt>' shall be a pointer value that points to a value
2394that was allocated with the '<tt><a href="#i_malloc">malloc</a></tt>'
2395instruction.</p>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002396
Chris Lattner00950542001-06-06 20:29:01 +00002397<h5>Semantics:</h5>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002398
John Criswell9e2485c2004-12-10 15:51:16 +00002399<p>Access to the memory pointed to by the pointer is no longer defined
Chris Lattner261efe92003-11-25 01:02:51 +00002400after this instruction executes.</p>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002401
Chris Lattner00950542001-06-06 20:29:01 +00002402<h5>Example:</h5>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002403
2404<pre>
2405 %array = <a href="#i_malloc">malloc</a> [4 x ubyte] <i>; yields {[4 x ubyte]*}:array</i>
Chris Lattner00950542001-06-06 20:29:01 +00002406 free [4 x ubyte]* %array
2407</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002408</div>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002409
Chris Lattner00950542001-06-06 20:29:01 +00002410<!-- _______________________________________________________________________ -->
Chris Lattner2cbdc452005-11-06 08:02:57 +00002411<div class="doc_subsubsection">
2412 <a name="i_alloca">'<tt>alloca</tt>' Instruction</a>
2413</div>
2414
Misha Brukman9d0919f2003-11-08 01:05:38 +00002415<div class="doc_text">
Chris Lattner2cbdc452005-11-06 08:02:57 +00002416
Chris Lattner00950542001-06-06 20:29:01 +00002417<h5>Syntax:</h5>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002418
2419<pre>
2420 &lt;result&gt; = alloca &lt;type&gt;[, uint &lt;NumElements&gt;][, align &lt;alignment&gt;] <i>; yields {type*}:result</i>
Chris Lattner00950542001-06-06 20:29:01 +00002421</pre>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002422
Chris Lattner00950542001-06-06 20:29:01 +00002423<h5>Overview:</h5>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002424
Chris Lattner261efe92003-11-25 01:02:51 +00002425<p>The '<tt>alloca</tt>' instruction allocates memory on the current
2426stack frame of the procedure that is live until the current function
2427returns to its caller.</p>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002428
Chris Lattner00950542001-06-06 20:29:01 +00002429<h5>Arguments:</h5>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002430
John Criswell9e2485c2004-12-10 15:51:16 +00002431<p>The '<tt>alloca</tt>' instruction allocates <tt>sizeof(&lt;type&gt;)*NumElements</tt>
Chris Lattner261efe92003-11-25 01:02:51 +00002432bytes of memory on the runtime stack, returning a pointer of the
Chris Lattner2cbdc452005-11-06 08:02:57 +00002433appropriate type to the program. If "NumElements" is specified, it is the
2434number of elements allocated. If an alignment is specified, the value result
2435of the allocation is guaranteed to be aligned to at least that boundary. If
2436not specified, or if zero, the target can choose to align the allocation on any
2437convenient boundary.</p>
2438
Misha Brukman9d0919f2003-11-08 01:05:38 +00002439<p>'<tt>type</tt>' may be any sized type.</p>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002440
Chris Lattner00950542001-06-06 20:29:01 +00002441<h5>Semantics:</h5>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002442
John Criswellc1f786c2005-05-13 22:25:59 +00002443<p>Memory is allocated; a pointer is returned. '<tt>alloca</tt>'d
Chris Lattner261efe92003-11-25 01:02:51 +00002444memory is automatically released when the function returns. The '<tt>alloca</tt>'
2445instruction is commonly used to represent automatic variables that must
2446have an address available. When the function returns (either with the <tt><a
John Criswelldae2e932005-05-12 16:55:34 +00002447 href="#i_ret">ret</a></tt> or <tt><a href="#i_unwind">unwind</a></tt>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002448instructions), the memory is reclaimed.</p>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002449
Chris Lattner00950542001-06-06 20:29:01 +00002450<h5>Example:</h5>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002451
2452<pre>
2453 %ptr = alloca int <i>; yields {int*}:ptr</i>
Chris Lattner7faa8832002-04-14 06:13:44 +00002454 %ptr = alloca int, uint 4 <i>; yields {int*}:ptr</i>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002455 %ptr = alloca int, uint 4, align 1024 <i>; yields {int*}:ptr</i>
2456 %ptr = alloca int, align 1024 <i>; yields {int*}:ptr</i>
Chris Lattner00950542001-06-06 20:29:01 +00002457</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002458</div>
Chris Lattner2cbdc452005-11-06 08:02:57 +00002459
Chris Lattner00950542001-06-06 20:29:01 +00002460<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00002461<div class="doc_subsubsection"> <a name="i_load">'<tt>load</tt>'
2462Instruction</a> </div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002463<div class="doc_text">
Chris Lattner2b7d3202002-05-06 03:03:22 +00002464<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00002465<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 +00002466<h5>Overview:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002467<p>The '<tt>load</tt>' instruction is used to read from memory.</p>
Chris Lattner2b7d3202002-05-06 03:03:22 +00002468<h5>Arguments:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00002469<p>The argument to the '<tt>load</tt>' instruction specifies the memory
John Criswell0ec250c2005-10-24 16:17:18 +00002470address from which to load. The pointer must point to a <a
Chris Lattnere53e5082004-06-03 22:57:15 +00002471 href="#t_firstclass">first class</a> type. If the <tt>load</tt> is
John Criswell0ec250c2005-10-24 16:17:18 +00002472marked as <tt>volatile</tt>, then the optimizer is not allowed to modify
Chris Lattner261efe92003-11-25 01:02:51 +00002473the number or order of execution of this <tt>load</tt> with other
2474volatile <tt>load</tt> and <tt><a href="#i_store">store</a></tt>
2475instructions. </p>
Chris Lattner2b7d3202002-05-06 03:03:22 +00002476<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002477<p>The location of memory pointed to is loaded.</p>
Chris Lattner2b7d3202002-05-06 03:03:22 +00002478<h5>Examples:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00002479<pre> %ptr = <a href="#i_alloca">alloca</a> int <i>; yields {int*}:ptr</i>
2480 <a
2481 href="#i_store">store</a> int 3, int* %ptr <i>; yields {void}</i>
Chris Lattner2b7d3202002-05-06 03:03:22 +00002482 %val = load int* %ptr <i>; yields {int}:val = int 3</i>
2483</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002484</div>
Chris Lattner2b7d3202002-05-06 03:03:22 +00002485<!-- _______________________________________________________________________ -->
Chris Lattner261efe92003-11-25 01:02:51 +00002486<div class="doc_subsubsection"> <a name="i_store">'<tt>store</tt>'
2487Instruction</a> </div>
Reid Spencer035ab572006-11-09 21:18:01 +00002488<div class="doc_text">
Chris Lattner2b7d3202002-05-06 03:03:22 +00002489<h5>Syntax:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00002490<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 +00002491 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 +00002492</pre>
Chris Lattner2b7d3202002-05-06 03:03:22 +00002493<h5>Overview:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002494<p>The '<tt>store</tt>' instruction is used to write to memory.</p>
Chris Lattner2b7d3202002-05-06 03:03:22 +00002495<h5>Arguments:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00002496<p>There are two arguments to the '<tt>store</tt>' instruction: a value
John Criswell0ec250c2005-10-24 16:17:18 +00002497to store and an address in which to store it. The type of the '<tt>&lt;pointer&gt;</tt>'
Chris Lattner261efe92003-11-25 01:02:51 +00002498operand must be a pointer to the type of the '<tt>&lt;value&gt;</tt>'
John Criswellc1f786c2005-05-13 22:25:59 +00002499operand. If the <tt>store</tt> is marked as <tt>volatile</tt>, then the
Chris Lattner261efe92003-11-25 01:02:51 +00002500optimizer is not allowed to modify the number or order of execution of
2501this <tt>store</tt> with other volatile <tt>load</tt> and <tt><a
2502 href="#i_store">store</a></tt> instructions.</p>
2503<h5>Semantics:</h5>
2504<p>The contents of memory are updated to contain '<tt>&lt;value&gt;</tt>'
2505at the location specified by the '<tt>&lt;pointer&gt;</tt>' operand.</p>
Chris Lattner2b7d3202002-05-06 03:03:22 +00002506<h5>Example:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00002507<pre> %ptr = <a href="#i_alloca">alloca</a> int <i>; yields {int*}:ptr</i>
2508 <a
2509 href="#i_store">store</a> int 3, int* %ptr <i>; yields {void}</i>
Chris Lattner2b7d3202002-05-06 03:03:22 +00002510 %val = load int* %ptr <i>; yields {int}:val = int 3</i>
2511</pre>
Reid Spencer47ce1792006-11-09 21:15:49 +00002512</div>
2513
Chris Lattner2b7d3202002-05-06 03:03:22 +00002514<!-- _______________________________________________________________________ -->
Chris Lattnerf74d5c72004-04-05 01:30:49 +00002515<div class="doc_subsubsection">
2516 <a name="i_getelementptr">'<tt>getelementptr</tt>' Instruction</a>
2517</div>
2518
Misha Brukman9d0919f2003-11-08 01:05:38 +00002519<div class="doc_text">
Chris Lattner7faa8832002-04-14 06:13:44 +00002520<h5>Syntax:</h5>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00002521<pre>
2522 &lt;result&gt; = getelementptr &lt;ty&gt;* &lt;ptrval&gt;{, &lt;ty&gt; &lt;idx&gt;}*
2523</pre>
2524
Chris Lattner7faa8832002-04-14 06:13:44 +00002525<h5>Overview:</h5>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00002526
2527<p>
2528The '<tt>getelementptr</tt>' instruction is used to get the address of a
2529subelement of an aggregate data structure.</p>
2530
Chris Lattner7faa8832002-04-14 06:13:44 +00002531<h5>Arguments:</h5>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00002532
2533<p>This instruction takes a list of integer constants that indicate what
2534elements of the aggregate object to index to. The actual types of the arguments
2535provided depend on the type of the first pointer argument. The
2536'<tt>getelementptr</tt>' instruction is used to index down through the type
John Criswellfc6b8952005-05-16 16:17:45 +00002537levels of a structure or to a specific index in an array. When indexing into a
2538structure, only <tt>uint</tt>
John Criswellc1f786c2005-05-13 22:25:59 +00002539integer constants are allowed. When indexing into an array or pointer,
Chris Lattnerf74d5c72004-04-05 01:30:49 +00002540<tt>int</tt> and <tt>long</tt> indexes are allowed of any sign.</p>
2541
Chris Lattner261efe92003-11-25 01:02:51 +00002542<p>For example, let's consider a C code fragment and how it gets
2543compiled to LLVM:</p>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00002544
2545<pre>
2546 struct RT {
2547 char A;
2548 int B[10][20];
2549 char C;
2550 };
2551 struct ST {
2552 int X;
2553 double Y;
2554 struct RT Z;
2555 };
2556
2557 int *foo(struct ST *s) {
2558 return &amp;s[1].Z.B[5][13];
2559 }
2560</pre>
2561
Misha Brukman9d0919f2003-11-08 01:05:38 +00002562<p>The LLVM code generated by the GCC frontend is:</p>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00002563
2564<pre>
2565 %RT = type { sbyte, [10 x [20 x int]], sbyte }
2566 %ST = type { int, double, %RT }
2567
Brian Gaeke7283e7c2004-07-02 21:08:14 +00002568 implementation
2569
2570 int* %foo(%ST* %s) {
2571 entry:
2572 %reg = getelementptr %ST* %s, int 1, uint 2, uint 1, int 5, int 13
Chris Lattnerf74d5c72004-04-05 01:30:49 +00002573 ret int* %reg
2574 }
2575</pre>
2576
Chris Lattner7faa8832002-04-14 06:13:44 +00002577<h5>Semantics:</h5>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00002578
2579<p>The index types specified for the '<tt>getelementptr</tt>' instruction depend
John Criswellc1f786c2005-05-13 22:25:59 +00002580on the pointer type that is being indexed into. <a href="#t_pointer">Pointer</a>
Chris Lattnere53e5082004-06-03 22:57:15 +00002581and <a href="#t_array">array</a> types require <tt>uint</tt>, <tt>int</tt>,
2582<tt>ulong</tt>, or <tt>long</tt> values, and <a href="#t_struct">structure</a>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00002583types require <tt>uint</tt> <b>constants</b>.</p>
2584
Misha Brukman9d0919f2003-11-08 01:05:38 +00002585<p>In the example above, the first index is indexing into the '<tt>%ST*</tt>'
Chris Lattnerf74d5c72004-04-05 01:30:49 +00002586type, which is a pointer, yielding a '<tt>%ST</tt>' = '<tt>{ int, double, %RT
2587}</tt>' type, a structure. The second index indexes into the third element of
2588the structure, yielding a '<tt>%RT</tt>' = '<tt>{ sbyte, [10 x [20 x int]],
2589sbyte }</tt>' type, another structure. The third index indexes into the second
2590element of the structure, yielding a '<tt>[10 x [20 x int]]</tt>' type, an
2591array. The two dimensions of the array are subscripted into, yielding an
John Criswellfc6b8952005-05-16 16:17:45 +00002592'<tt>int</tt>' type. The '<tt>getelementptr</tt>' instruction returns a pointer
Chris Lattnerf74d5c72004-04-05 01:30:49 +00002593to this element, thus computing a value of '<tt>int*</tt>' type.</p>
2594
Chris Lattner261efe92003-11-25 01:02:51 +00002595<p>Note that it is perfectly legal to index partially through a
2596structure, returning a pointer to an inner element. Because of this,
2597the LLVM code for the given testcase is equivalent to:</p>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00002598
2599<pre>
Chris Lattnerd4f6b172005-03-07 22:13:59 +00002600 int* %foo(%ST* %s) {
Chris Lattnerf74d5c72004-04-05 01:30:49 +00002601 %t1 = getelementptr %ST* %s, int 1 <i>; yields %ST*:%t1</i>
2602 %t2 = getelementptr %ST* %t1, int 0, uint 2 <i>; yields %RT*:%t2</i>
2603 %t3 = getelementptr %RT* %t2, int 0, uint 1 <i>; yields [10 x [20 x int]]*:%t3</i>
2604 %t4 = getelementptr [10 x [20 x int]]* %t3, int 0, int 5 <i>; yields [20 x int]*:%t4</i>
2605 %t5 = getelementptr [20 x int]* %t4, int 0, int 13 <i>; yields int*:%t5</i>
2606 ret int* %t5
2607 }
Chris Lattner6536cfe2002-05-06 22:08:29 +00002608</pre>
Chris Lattnere67a9512005-06-24 17:22:57 +00002609
2610<p>Note that it is undefined to access an array out of bounds: array and
2611pointer indexes must always be within the defined bounds of the array type.
2612The one exception for this rules is zero length arrays. These arrays are
2613defined to be accessible as variable length arrays, which requires access
2614beyond the zero'th element.</p>
2615
Chris Lattner884a9702006-08-15 00:45:58 +00002616<p>The getelementptr instruction is often confusing. For some more insight
2617into how it works, see <a href="GetElementPtr.html">the getelementptr
2618FAQ</a>.</p>
2619
Chris Lattner7faa8832002-04-14 06:13:44 +00002620<h5>Example:</h5>
Chris Lattnere67a9512005-06-24 17:22:57 +00002621
Chris Lattnerf74d5c72004-04-05 01:30:49 +00002622<pre>
2623 <i>; yields [12 x ubyte]*:aptr</i>
2624 %aptr = getelementptr {int, [12 x ubyte]}* %sptr, long 0, uint 1
2625</pre>
Chris Lattnerf74d5c72004-04-05 01:30:49 +00002626</div>
Reid Spencer47ce1792006-11-09 21:15:49 +00002627
Chris Lattner00950542001-06-06 20:29:01 +00002628<!-- ======================================================================= -->
Reid Spencer2fd21e62006-11-08 01:18:52 +00002629<div class="doc_subsection"> <a name="convertops">Conversion Operations</a>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002630</div>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002631<div class="doc_text">
Reid Spencer2fd21e62006-11-08 01:18:52 +00002632<p>The instructions in this category are the conversion instructions (casting)
2633which all take a single operand and a type. They perform various bit conversions
2634on the operand.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00002635</div>
Chris Lattnercc37aae2004-03-12 05:50:16 +00002636
Chris Lattner6536cfe2002-05-06 22:08:29 +00002637<!-- _______________________________________________________________________ -->
Chris Lattnercc37aae2004-03-12 05:50:16 +00002638<div class="doc_subsubsection">
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002639 <a name="i_trunc">'<tt>trunc .. to</tt>' Instruction</a>
2640</div>
2641<div class="doc_text">
2642
2643<h5>Syntax:</h5>
2644<pre>
2645 &lt;result&gt; = trunc &lt;ty&gt; &lt;value&gt; to &lt;ty2&gt; <i>; yields ty2</i>
2646</pre>
2647
2648<h5>Overview:</h5>
2649<p>
2650The '<tt>trunc</tt>' instruction truncates its operand to the type <tt>ty2</tt>.
2651</p>
2652
2653<h5>Arguments:</h5>
2654<p>
2655The '<tt>trunc</tt>' instruction takes a <tt>value</tt> to trunc, which must
2656be an <a href="#t_integer">integer</a> type, and a type that specifies the size
2657and type of the result, which must be an <a href="#t_integral">integral</a>
Reid Spencerd4448792006-11-09 23:03:26 +00002658type. The bit size of <tt>value</tt> must be larger than the bit size of
2659<tt>ty2</tt>. Equal sized types are not allowed.</p>
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002660
2661<h5>Semantics:</h5>
2662<p>
2663The '<tt>trunc</tt>' instruction truncates the high order bits in <tt>value</tt>
Reid Spencerd4448792006-11-09 23:03:26 +00002664and converts the remaining bits to <tt>ty2</tt>. Since the source size must be
2665larger than the destination size, <tt>trunc</tt> cannot be a <i>no-op cast</i>.
2666It will always truncate bits.</p>
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002667
2668<h5>Example:</h5>
2669<pre>
2670 %X = trunc int 257 to ubyte <i>; yields ubyte:1</i>
2671 %Y = trunc int 123 to bool <i>; yields bool:true</i>
2672</pre>
2673</div>
2674
2675<!-- _______________________________________________________________________ -->
2676<div class="doc_subsubsection">
2677 <a name="i_zext">'<tt>zext .. to</tt>' Instruction</a>
2678</div>
2679<div class="doc_text">
2680
2681<h5>Syntax:</h5>
2682<pre>
2683 &lt;result&gt; = zext &lt;ty&gt; &lt;value&gt; to &lt;ty2&gt; <i>; yields ty2</i>
2684</pre>
2685
2686<h5>Overview:</h5>
2687<p>The '<tt>zext</tt>' instruction zero extends its operand to type
2688<tt>ty2</tt>.</p>
2689
2690
2691<h5>Arguments:</h5>
2692<p>The '<tt>zext</tt>' instruction takes a value to cast, which must be of
2693<a href="#t_integral">integral</a> type, and a type to cast it to, which must
2694also be of <a href="#t_integral">integral</a> type. The bit size of the
Reid Spencerd4448792006-11-09 23:03:26 +00002695<tt>value</tt> must be smaller than the bit size of the destination type,
2696<tt>ty2</tt>.</p>
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002697
2698<h5>Semantics:</h5>
2699<p>The <tt>zext</tt> fills the high order bits of the <tt>value</tt> with zero
2700bits until it reaches the size of the destination type, <tt>ty2</tt>. When the
2701the operand and the type are the same size, no bit filling is done and the
2702cast is considered a <i>no-op cast</i> because no bits change (only the type
2703changes).</p>
2704
Reid Spencerd4448792006-11-09 23:03:26 +00002705<p>When zero extending from bool, the result will alwasy be either 0 or 1.</p>
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002706
2707<h5>Example:</h5>
2708<pre>
2709 %X = zext int 257 to ulong <i>; yields ulong:257</i>
2710 %Y = zext bool true to int <i>; yields int:1</i>
2711</pre>
2712</div>
2713
2714<!-- _______________________________________________________________________ -->
2715<div class="doc_subsubsection">
2716 <a name="i_sext">'<tt>sext .. to</tt>' Instruction</a>
2717</div>
2718<div class="doc_text">
2719
2720<h5>Syntax:</h5>
2721<pre>
2722 &lt;result&gt; = sext &lt;ty&gt; &lt;value&gt; to &lt;ty2&gt; <i>; yields ty2</i>
2723</pre>
2724
2725<h5>Overview:</h5>
2726<p>The '<tt>sext</tt>' sign extends <tt>value</tt> to the type <tt>ty2</tt>.</p>
2727
2728<h5>Arguments:</h5>
2729<p>
2730The '<tt>sext</tt>' instruction takes a value to cast, which must be of
2731<a href="#t_integral">integral</a> type, and a type to cast it to, which must
Reid Spencerd4448792006-11-09 23:03:26 +00002732also be of <a href="#t_integral">integral</a> type. The bit size of the
2733<tt>value</tt> must be smaller than the bit size of the destination type,
2734<tt>ty2</tt>.</p>
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002735
2736<h5>Semantics:</h5>
2737<p>
2738The '<tt>sext</tt>' instruction performs a sign extension by copying the sign
2739bit (highest order bit) of the <tt>value</tt> until it reaches the bit size of
2740the type <tt>ty2</tt>. When the the operand and the type are the same size,
2741no bit filling is done and the cast is considered a <i>no-op cast</i> because
2742no bits change (only the type changes).</p>
2743
Reid Spencerd4448792006-11-09 23:03:26 +00002744<p>When sign extending from bool, the extension always results in -1 or 0.</p>
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002745
2746<h5>Example:</h5>
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002747<pre>
2748 %X = sext sbyte -1 to ushort <i>; yields ushort:65535</i>
2749 %Y = sext bool true to int <i>; yields int:-1</i>
2750</pre>
2751</div>
2752
2753<!-- _______________________________________________________________________ -->
2754<div class="doc_subsubsection">
Reid Spencer3fa91b02006-11-09 21:48:10 +00002755 <a name="i_fptrunc">'<tt>fptrunc .. to</tt>' Instruction</a>
2756</div>
2757
2758<div class="doc_text">
2759
2760<h5>Syntax:</h5>
2761
2762<pre>
2763 &lt;result&gt; = fptrunc &lt;ty&gt; &lt;value&gt; to &lt;ty2&gt; <i>; yields ty2</i>
2764</pre>
2765
2766<h5>Overview:</h5>
2767<p>The '<tt>fptrunc</tt>' instruction truncates <tt>value</tt> to type
2768<tt>ty2</tt>.</p>
2769
2770
2771<h5>Arguments:</h5>
2772<p>The '<tt>fptrunc</tt>' instruction takes a <a href="#t_floating">floating
2773 point</a> value to cast and a <a href="#t_floating">floating point</a> type to
2774cast it to. The size of <tt>value</tt> must be larger than the size of
2775<tt>ty2</tt>. This implies that <tt>fptrunc</tt> cannot be used to make a
2776<i>no-op cast</i>.</p>
2777
2778<h5>Semantics:</h5>
Reid Spencerd4448792006-11-09 23:03:26 +00002779<p> The '<tt>fptrunc</tt>' instruction truncates a <tt>value</tt> from a larger
2780<a href="#t_floating">floating point</a> type to a smaller
2781<a href="#t_floating">floating point</a> type. If the value cannot fit within
2782the destination type, <tt>ty2</tt>, then the results are undefined.</p>
Reid Spencer3fa91b02006-11-09 21:48:10 +00002783
2784<h5>Example:</h5>
2785<pre>
2786 %X = fptrunc double 123.0 to float <i>; yields float:123.0</i>
2787 %Y = fptrunc double 1.0E+300 to float <i>; yields undefined</i>
2788</pre>
2789</div>
2790
2791<!-- _______________________________________________________________________ -->
2792<div class="doc_subsubsection">
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002793 <a name="i_fpext">'<tt>fpext .. to</tt>' Instruction</a>
2794</div>
2795<div class="doc_text">
2796
2797<h5>Syntax:</h5>
2798<pre>
2799 &lt;result&gt; = fpext &lt;ty&gt; &lt;value&gt; to &lt;ty2&gt; <i>; yields ty2</i>
2800</pre>
2801
2802<h5>Overview:</h5>
2803<p>The '<tt>fpext</tt>' extends a floating point <tt>value</tt> to a larger
2804floating point value.</p>
2805
2806<h5>Arguments:</h5>
2807<p>The '<tt>fpext</tt>' instruction takes a
2808<a href="#t_floating">floating point</a> <tt>value</tt> to cast,
Reid Spencerd4448792006-11-09 23:03:26 +00002809and a <a href="#t_floating">floating point</a> type to cast it to. The source
2810type must be smaller than the destination type.</p>
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002811
2812<h5>Semantics:</h5>
Reid Spencerd4448792006-11-09 23:03:26 +00002813<p>The '<tt>fpext</tt>' instruction extends the <tt>value</tt> from a smaller
2814<a href="t_floating">floating point</a> type to a larger
2815<a href="t_floating">floating point</a> type. The <tt>fpext</tt> cannot be
2816used to make a <i>no-op cast</i> because it always changes bits. Use
Reid Spencer5c0ef472006-11-11 23:08:07 +00002817<tt>bitcast</tt> to make a <i>no-op cast</i> for a floating point cast.</p>
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002818
2819<h5>Example:</h5>
2820<pre>
2821 %X = fpext float 3.1415 to double <i>; yields double:3.1415</i>
2822 %Y = fpext float 1.0 to float <i>; yields float:1.0 (no-op)</i>
2823</pre>
2824</div>
2825
2826<!-- _______________________________________________________________________ -->
2827<div class="doc_subsubsection">
Reid Spencerd4448792006-11-09 23:03:26 +00002828 <a name="i_fp2uint">'<tt>fptoui .. to</tt>' Instruction</a>
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002829</div>
2830<div class="doc_text">
2831
2832<h5>Syntax:</h5>
2833<pre>
2834 &lt;result&gt; = fp2uint &lt;ty&gt; &lt;value&gt; to &lt;ty2&gt; <i>; yields ty2</i>
2835</pre>
2836
2837<h5>Overview:</h5>
2838<p>The '<tt>fp2uint</tt>' converts a floating point <tt>value</tt> to its
2839unsigned integer equivalent of type <tt>ty2</tt>.
2840</p>
2841
2842<h5>Arguments:</h5>
2843<p>The '<tt>fp2uint</tt>' instruction takes a value to cast, which must be a
2844<a href="#t_floating">floating point</a> value, and a type to cast it to, which
2845must be an <a href="#t_integral">integral</a> type.</p>
2846
2847<h5>Semantics:</h5>
2848<p> The '<tt>fp2uint</tt>' instruction converts its
2849<a href="#t_floating">floating point</a> operand into the nearest (rounding
2850towards zero) unsigned integer value. If the value cannot fit in <tt>ty2</tt>,
2851the results are undefined.</p>
2852
2853<p>When converting to bool, the conversion is done as a comparison against
2854zero. If the <tt>value</tt> was zero, the bool result will be <tt>false</tt>.
2855If the <tt>value</tt> was non-zero, the bool result will be <tt>true</tt>.</p>
2856
2857<h5>Example:</h5>
2858<pre>
2859 %X = fp2uint double 123.0 to int <i>; yields int:123</i>
2860 %Y = fp2uint float 1.0E+300 to bool <i>; yields bool:true</i>
2861 %X = fp2uint float 1.04E+17 to ubyte <i>; yields undefined:1</i>
2862</pre>
2863</div>
2864
2865<!-- _______________________________________________________________________ -->
2866<div class="doc_subsubsection">
Reid Spencerd4448792006-11-09 23:03:26 +00002867 <a name="i_fptosi">'<tt>fptosi .. to</tt>' Instruction</a>
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002868</div>
2869<div class="doc_text">
2870
2871<h5>Syntax:</h5>
2872<pre>
Reid Spencerd4448792006-11-09 23:03:26 +00002873 &lt;result&gt; = fptosi &lt;ty&gt; &lt;value&gt; to &lt;ty2&gt; <i>; yields ty2</i>
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002874</pre>
2875
2876<h5>Overview:</h5>
Reid Spencerd4448792006-11-09 23:03:26 +00002877<p>The '<tt>fptosi</tt>' instruction converts
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002878<a href="#t_floating">floating point</a> <tt>value</tt> to type <tt>ty2</tt>.
Chris Lattnercc37aae2004-03-12 05:50:16 +00002879</p>
2880
2881
Chris Lattner6536cfe2002-05-06 22:08:29 +00002882<h5>Arguments:</h5>
Reid Spencerd4448792006-11-09 23:03:26 +00002883<p> The '<tt>fptosi</tt>' instruction takes a value to cast, which must be a
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002884<a href="#t_floating">floating point</a> value, and a type to cast it to, which
2885must also be an <a href="#t_integral">integral</a> type.</p>
Chris Lattnercc37aae2004-03-12 05:50:16 +00002886
Chris Lattner6536cfe2002-05-06 22:08:29 +00002887<h5>Semantics:</h5>
Reid Spencerd4448792006-11-09 23:03:26 +00002888<p>The '<tt>fptosi</tt>' instruction converts its
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002889<a href="#t_floating">floating point</a> operand into the nearest (rounding
2890towards zero) signed integer value. If the value cannot fit in <tt>ty2</tt>,
2891the results are undefined.</p>
Chris Lattnercc37aae2004-03-12 05:50:16 +00002892
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002893<p>When converting to bool, the conversion is done as a comparison against
2894zero. If the <tt>value</tt> was zero, the bool result will be <tt>false</tt>.
2895If the <tt>value</tt> was non-zero, the bool result will be <tt>true</tt>.</p>
Chris Lattnercc37aae2004-03-12 05:50:16 +00002896
Chris Lattner33ba0d92001-07-09 00:26:23 +00002897<h5>Example:</h5>
Chris Lattnercc37aae2004-03-12 05:50:16 +00002898<pre>
Reid Spencerd4448792006-11-09 23:03:26 +00002899 %X = fptosi double -123.0 to int <i>; yields int:-123</i>
2900 %Y = fptosi float 1.0E-247 to bool <i>; yields bool:true</i>
2901 %X = fptosi float 1.04E+17 to sbyte <i>; yields undefined:1</i>
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002902</pre>
2903</div>
2904
2905<!-- _______________________________________________________________________ -->
2906<div class="doc_subsubsection">
Reid Spencerd4448792006-11-09 23:03:26 +00002907 <a name="i_uitofp">'<tt>uitofp .. to</tt>' Instruction</a>
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002908</div>
2909<div class="doc_text">
2910
2911<h5>Syntax:</h5>
2912<pre>
Reid Spencerd4448792006-11-09 23:03:26 +00002913 &lt;result&gt; = uitofp &lt;ty&gt; &lt;value&gt; to &lt;ty2&gt; <i>; yields ty2</i>
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002914</pre>
2915
2916<h5>Overview:</h5>
Reid Spencerd4448792006-11-09 23:03:26 +00002917<p>The '<tt>uitofp</tt>' instruction regards <tt>value</tt> as an unsigned
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002918integer and converts that value to the <tt>ty2</tt> type.</p>
2919
2920
2921<h5>Arguments:</h5>
Reid Spencerd4448792006-11-09 23:03:26 +00002922<p>The '<tt>uitofp</tt>' instruction takes a value to cast, which must be an
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002923<a href="#t_integral">integral</a> value, and a type to cast it to, which must
2924be a <a href="#t_floating">floating point</a> type.</p>
2925
2926<h5>Semantics:</h5>
Reid Spencerd4448792006-11-09 23:03:26 +00002927<p>The '<tt>uitofp</tt>' instruction interprets its operand as an unsigned
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002928integer quantity and converts it to the corresponding floating point value. If
2929the value cannot fit in the floating point value, the results are undefined.</p>
2930
2931
2932<h5>Example:</h5>
2933<pre>
Reid Spencerd4448792006-11-09 23:03:26 +00002934 %X = uitofp int 257 to float <i>; yields float:257.0</i>
2935 %Y = uitofp sbyte -1 to double <i>; yields double:255.0</i>
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002936</pre>
2937</div>
2938
2939<!-- _______________________________________________________________________ -->
2940<div class="doc_subsubsection">
Reid Spencerd4448792006-11-09 23:03:26 +00002941 <a name="i_sitofp">'<tt>sitofp .. to</tt>' Instruction</a>
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002942</div>
2943<div class="doc_text">
2944
2945<h5>Syntax:</h5>
2946<pre>
Reid Spencerd4448792006-11-09 23:03:26 +00002947 &lt;result&gt; = sitofp &lt;ty&gt; &lt;value&gt; to &lt;ty2&gt; <i>; yields ty2</i>
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002948</pre>
2949
2950<h5>Overview:</h5>
Reid Spencerd4448792006-11-09 23:03:26 +00002951<p>The '<tt>sitofp</tt>' instruction regards <tt>value</tt> as a signed
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002952integer and converts that value to the <tt>ty2</tt> type.</p>
2953
2954<h5>Arguments:</h5>
Reid Spencerd4448792006-11-09 23:03:26 +00002955<p>The '<tt>sitofp</tt>' instruction takes a value to cast, which must be an
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002956<a href="#t_integral">integral</a> value, and a type to cast it to, which must be
2957a <a href="#t_floating">floating point</a> type.</p>
2958
2959<h5>Semantics:</h5>
Reid Spencerd4448792006-11-09 23:03:26 +00002960<p>The '<tt>sitofp</tt>' instruction interprets its operand as a signed
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002961integer quantity and converts it to the corresponding floating point value. If
2962the value cannot fit in the floating point value, the results are undefined.</p>
2963
2964<h5>Example:</h5>
2965<pre>
Reid Spencerd4448792006-11-09 23:03:26 +00002966 %X = sitofp int 257 to float <i>; yields float:257.0</i>
2967 %Y = sitofp sbyte -1 to double <i>; yields double:-1.0</i>
Reid Spencer9dee3ac2006-11-08 01:11:31 +00002968</pre>
2969</div>
2970
2971<!-- _______________________________________________________________________ -->
2972<div class="doc_subsubsection">
Reid Spencer72679252006-11-11 21:00:47 +00002973 <a name="i_ptrtoint">'<tt>ptrtoint .. to</tt>' Instruction</a>
2974</div>
2975<div class="doc_text">
2976
2977<h5>Syntax:</h5>
2978<pre>
2979 &lt;result&gt; = ptrtoint &lt;ty&gt; &lt;value&gt; to &lt;ty2&gt; <i>; yields ty2</i>
2980</pre>
2981
2982<h5>Overview:</h5>
2983<p>The '<tt>ptrtoint</tt>' instruction converts the pointer <tt>value</tt> to
2984the integer type <tt>ty2</tt>.</p>
2985
2986<h5>Arguments:</h5>
2987<p>The '<tt>ptrtoint</tt>' instruction takes a <tt>value</tt> to cast, which
2988must be a <a href="t_pointer">pointer</a> value, and a type to cast it to
2989<tt>ty2</tt>, which must be an <a href="#t_integer">integer</a> type.
2990
2991<h5>Semantics:</h5>
2992<p>The '<tt>ptrtoint</tt>' instruction converts <tt>value</tt> to integer type
2993<tt>ty2</tt> by interpreting the pointer value as an integer and either
2994truncating or zero extending that value to the size of the integer type. If
2995<tt>value</tt> is smaller than <tt>ty2</tt> then a zero extension is done. If
2996<tt>value</tt> is larger than <tt>ty2</tt> then a truncation is done. If they
2997are the same size, then nothing is done (<i>no-op cast</i>).</p>
2998
2999<h5>Example:</h5>
3000<pre>
3001 %X = ptrtoint int* %X to sbyte <i>; yields truncation on 32-bit</i>
3002 %Y = ptrtoint int* %x to ulong <i>; yields zero extend on 32-bit</i>
3003</pre>
3004</div>
3005
3006<!-- _______________________________________________________________________ -->
3007<div class="doc_subsubsection">
3008 <a name="i_inttoptr">'<tt>inttoptr .. to</tt>' Instruction</a>
3009</div>
3010<div class="doc_text">
3011
3012<h5>Syntax:</h5>
3013<pre>
3014 &lt;result&gt; = inttoptr &lt;ty&gt; &lt;value&gt; to &lt;ty2&gt; <i>; yields ty2</i>
3015</pre>
3016
3017<h5>Overview:</h5>
3018<p>The '<tt>inttoptr</tt>' instruction converts an integer <tt>value</tt> to
3019a pointer type, <tt>ty2</tt>.</p>
3020
3021<h5>Arguments:</h5>
3022<p>The '<tt>inttoptr</tt>' instruction takes an <a href="i_integer">integer</a>
3023value to cast, and a type to cast it to, which must be a
3024<a href="#t_pointer">pointer</a> type. </tt>
3025
3026<h5>Semantics:</h5>
3027<p>The '<tt>inttoptr</tt>' instruction converts <tt>value</tt> to type
3028<tt>ty2</tt> by applying either a zero extension or a truncation depending on
3029the size of the integer <tt>value</tt>. If <tt>value</tt> is larger than the
3030size of a pointer then a truncation is done. If <tt>value</tt> is smaller than
3031the size of a pointer then a zero extension is done. If they are the same size,
3032nothing is done (<i>no-op cast</i>).</p>
3033
3034<h5>Example:</h5>
3035<pre>
3036 %X = inttoptr int 255 to int* <i>; yields zero extend on 64-bit</i>
3037 %X = inttoptr int 255 to int* <i>; yields no-op on 32-bit </i>
3038 %Y = inttoptr short 0 to int* <i>; yields zero extend on 32-bit</i>
3039</pre>
3040</div>
3041
3042<!-- _______________________________________________________________________ -->
3043<div class="doc_subsubsection">
Reid Spencer5c0ef472006-11-11 23:08:07 +00003044 <a name="i_bitcast">'<tt>bitcast .. to</tt>' Instruction</a>
Reid Spencer9dee3ac2006-11-08 01:11:31 +00003045</div>
3046<div class="doc_text">
3047
3048<h5>Syntax:</h5>
3049<pre>
Reid Spencer5c0ef472006-11-11 23:08:07 +00003050 &lt;result&gt; = bitcast &lt;ty&gt; &lt;value&gt; to &lt;ty2&gt; <i>; yields ty2</i>
Reid Spencer9dee3ac2006-11-08 01:11:31 +00003051</pre>
3052
3053<h5>Overview:</h5>
Reid Spencer5c0ef472006-11-11 23:08:07 +00003054<p>The '<tt>bitcast</tt>' instruction converts <tt>value</tt> to type
Reid Spencer9dee3ac2006-11-08 01:11:31 +00003055<tt>ty2</tt> without changing any bits.</p>
3056
3057<h5>Arguments:</h5>
Reid Spencer5c0ef472006-11-11 23:08:07 +00003058<p>The '<tt>bitcast</tt>' instruction takes a value to cast, which must be
Reid Spencer9dee3ac2006-11-08 01:11:31 +00003059a first class value, and a type to cast it to, which must also be a <a
3060 href="#t_firstclass">first class</a> type. The bit sizes of <tt>value</tt>
3061and the destination type, <tt>ty2</tt>, must be identical.</p>
3062
3063<h5>Semantics:</h5>
Reid Spencer5c0ef472006-11-11 23:08:07 +00003064<p>The '<tt>bitcast</tt>' instruction converts <tt>value</tt> to type
Reid Spencer72679252006-11-11 21:00:47 +00003065<tt>ty2</tt>. It is always a <i>no-op cast</i> because no bits change with
3066this conversion. The conversion is done as if the <tt>value</tt> had been
3067stored to memory and read back as type <tt>ty2</tt>. Pointer types may only be
3068converted to other pointer types with this instruction. To convert pointers to
3069other types, use the <a href="#i_inttoptr">inttoptr</a> or
3070<a href="#i_ptrtoint">ptrtoint</a> instructions first.</p>
Reid Spencer9dee3ac2006-11-08 01:11:31 +00003071
3072<h5>Example:</h5>
3073<pre>
Reid Spencer5c0ef472006-11-11 23:08:07 +00003074 %X = bitcast ubyte 255 to sbyte <i>; yields sbyte:-1</i>
3075 %Y = bitcast uint* %x to sint* <i>; yields sint*:%x</i>
3076 %Z = bitcast <2xint> %V to long; <i>; yields long: %V</i>
Chris Lattner33ba0d92001-07-09 00:26:23 +00003077</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00003078</div>
Chris Lattnercc37aae2004-03-12 05:50:16 +00003079
Reid Spencer2fd21e62006-11-08 01:18:52 +00003080<!-- ======================================================================= -->
3081<div class="doc_subsection"> <a name="otherops">Other Operations</a> </div>
3082<div class="doc_text">
3083<p>The instructions in this category are the "miscellaneous"
3084instructions, which defy better classification.</p>
3085</div>
3086<!-- _______________________________________________________________________ -->
3087<div class="doc_subsubsection"> <a name="i_phi">'<tt>phi</tt>'
3088Instruction</a> </div>
3089<div class="doc_text">
3090<h5>Syntax:</h5>
3091<pre> &lt;result&gt; = phi &lt;ty&gt; [ &lt;val0&gt;, &lt;label0&gt;], ...<br></pre>
3092<h5>Overview:</h5>
3093<p>The '<tt>phi</tt>' instruction is used to implement the &#966; node in
3094the SSA graph representing the function.</p>
3095<h5>Arguments:</h5>
3096<p>The type of the incoming values are specified with the first type
3097field. After this, the '<tt>phi</tt>' instruction takes a list of pairs
3098as arguments, with one pair for each predecessor basic block of the
3099current block. Only values of <a href="#t_firstclass">first class</a>
3100type may be used as the value arguments to the PHI node. Only labels
3101may be used as the label arguments.</p>
3102<p>There must be no non-phi instructions between the start of a basic
3103block and the PHI instructions: i.e. PHI instructions must be first in
3104a basic block.</p>
3105<h5>Semantics:</h5>
3106<p>At runtime, the '<tt>phi</tt>' instruction logically takes on the
3107value specified by the parameter, depending on which basic block we
3108came from in the last <a href="#terminators">terminator</a> instruction.</p>
3109<h5>Example:</h5>
3110<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>
3111</div>
3112
Chris Lattnercc37aae2004-03-12 05:50:16 +00003113<!-- _______________________________________________________________________ -->
3114<div class="doc_subsubsection">
3115 <a name="i_select">'<tt>select</tt>' Instruction</a>
3116</div>
3117
3118<div class="doc_text">
3119
3120<h5>Syntax:</h5>
3121
3122<pre>
3123 &lt;result&gt; = select bool &lt;cond&gt;, &lt;ty&gt; &lt;val1&gt;, &lt;ty&gt; &lt;val2&gt; <i>; yields ty</i>
3124</pre>
3125
3126<h5>Overview:</h5>
3127
3128<p>
3129The '<tt>select</tt>' instruction is used to choose one value based on a
3130condition, without branching.
3131</p>
3132
3133
3134<h5>Arguments:</h5>
3135
3136<p>
3137The '<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.
3138</p>
3139
3140<h5>Semantics:</h5>
3141
3142<p>
3143If the boolean condition evaluates to true, the instruction returns the first
John Criswellfc6b8952005-05-16 16:17:45 +00003144value argument; otherwise, it returns the second value argument.
Chris Lattnercc37aae2004-03-12 05:50:16 +00003145</p>
3146
3147<h5>Example:</h5>
3148
3149<pre>
3150 %X = select bool true, ubyte 17, ubyte 42 <i>; yields ubyte:17</i>
3151</pre>
3152</div>
3153
Robert Bocchino05ccd702006-01-15 20:48:27 +00003154
3155<!-- _______________________________________________________________________ -->
3156<div class="doc_subsubsection">
Chris Lattner2bff5242005-05-06 05:47:36 +00003157 <a name="i_call">'<tt>call</tt>' Instruction</a>
3158</div>
3159
Misha Brukman9d0919f2003-11-08 01:05:38 +00003160<div class="doc_text">
Chris Lattner2bff5242005-05-06 05:47:36 +00003161
Chris Lattner00950542001-06-06 20:29:01 +00003162<h5>Syntax:</h5>
Chris Lattner2bff5242005-05-06 05:47:36 +00003163<pre>
Chris Lattnerbad10ee2005-05-06 22:57:40 +00003164 &lt;result&gt; = [tail] call [<a href="#callingconv">cconv</a>] &lt;ty&gt;* &lt;fnptrval&gt;(&lt;param list&gt;)
Chris Lattner2bff5242005-05-06 05:47:36 +00003165</pre>
3166
Chris Lattner00950542001-06-06 20:29:01 +00003167<h5>Overview:</h5>
Chris Lattner2bff5242005-05-06 05:47:36 +00003168
Misha Brukman9d0919f2003-11-08 01:05:38 +00003169<p>The '<tt>call</tt>' instruction represents a simple function call.</p>
Chris Lattner2bff5242005-05-06 05:47:36 +00003170
Chris Lattner00950542001-06-06 20:29:01 +00003171<h5>Arguments:</h5>
Chris Lattner2bff5242005-05-06 05:47:36 +00003172
Misha Brukman9d0919f2003-11-08 01:05:38 +00003173<p>This instruction requires several arguments:</p>
Chris Lattner2bff5242005-05-06 05:47:36 +00003174
Chris Lattner6536cfe2002-05-06 22:08:29 +00003175<ol>
Chris Lattner261efe92003-11-25 01:02:51 +00003176 <li>
Chris Lattnerbad10ee2005-05-06 22:57:40 +00003177 <p>The optional "tail" marker indicates whether the callee function accesses
3178 any allocas or varargs in the caller. If the "tail" marker is present, the
Chris Lattner2bff5242005-05-06 05:47:36 +00003179 function call is eligible for tail call optimization. Note that calls may
3180 be marked "tail" even if they do not occur before a <a
3181 href="#i_ret"><tt>ret</tt></a> instruction.
Chris Lattner261efe92003-11-25 01:02:51 +00003182 </li>
3183 <li>
Chris Lattnerbad10ee2005-05-06 22:57:40 +00003184 <p>The optional "cconv" marker indicates which <a href="callingconv">calling
3185 convention</a> the call should use. If none is specified, the call defaults
3186 to using C calling conventions.
3187 </li>
3188 <li>
Chris Lattner2bff5242005-05-06 05:47:36 +00003189 <p>'<tt>ty</tt>': shall be the signature of the pointer to function value
3190 being invoked. The argument types must match the types implied by this
John Criswellfc6b8952005-05-16 16:17:45 +00003191 signature. This type can be omitted if the function is not varargs and
3192 if the function type does not return a pointer to a function.</p>
Chris Lattner2bff5242005-05-06 05:47:36 +00003193 </li>
3194 <li>
3195 <p>'<tt>fnptrval</tt>': An LLVM value containing a pointer to a function to
3196 be invoked. In most cases, this is a direct function invocation, but
3197 indirect <tt>call</tt>s are just as possible, calling an arbitrary pointer
John Criswellfc6b8952005-05-16 16:17:45 +00003198 to function value.</p>
Chris Lattner261efe92003-11-25 01:02:51 +00003199 </li>
3200 <li>
3201 <p>'<tt>function args</tt>': argument list whose types match the
Reid Spencera7e302a2005-05-01 22:22:57 +00003202 function signature argument types. All arguments must be of
3203 <a href="#t_firstclass">first class</a> type. If the function signature
3204 indicates the function accepts a variable number of arguments, the extra
3205 arguments can be specified.</p>
Chris Lattner261efe92003-11-25 01:02:51 +00003206 </li>
Chris Lattner6536cfe2002-05-06 22:08:29 +00003207</ol>
Chris Lattner2bff5242005-05-06 05:47:36 +00003208
Chris Lattner00950542001-06-06 20:29:01 +00003209<h5>Semantics:</h5>
Chris Lattner2bff5242005-05-06 05:47:36 +00003210
Chris Lattner261efe92003-11-25 01:02:51 +00003211<p>The '<tt>call</tt>' instruction is used to cause control flow to
3212transfer to a specified function, with its incoming arguments bound to
3213the specified values. Upon a '<tt><a href="#i_ret">ret</a></tt>'
3214instruction in the called function, control flow continues with the
3215instruction after the function call, and the return value of the
3216function is bound to the result argument. This is a simpler case of
3217the <a href="#i_invoke">invoke</a> instruction.</p>
Chris Lattner2bff5242005-05-06 05:47:36 +00003218
Chris Lattner00950542001-06-06 20:29:01 +00003219<h5>Example:</h5>
Chris Lattner2bff5242005-05-06 05:47:36 +00003220
3221<pre>
3222 %retval = call int %test(int %argc)
3223 call int(sbyte*, ...) *%printf(sbyte* %msg, int 12, sbyte 42);
3224 %X = tail call int %foo()
Chris Lattnerbad10ee2005-05-06 22:57:40 +00003225 %Y = tail call <a href="#callingconv">fastcc</a> int %foo()
Chris Lattner2bff5242005-05-06 05:47:36 +00003226</pre>
3227
Misha Brukman9d0919f2003-11-08 01:05:38 +00003228</div>
Chris Lattnere19d7a72004-09-27 21:51:25 +00003229
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00003230<!-- _______________________________________________________________________ -->
Chris Lattnere19d7a72004-09-27 21:51:25 +00003231<div class="doc_subsubsection">
Chris Lattnerfb6977d2006-01-13 23:26:01 +00003232 <a name="i_va_arg">'<tt>va_arg</tt>' Instruction</a>
Chris Lattnere19d7a72004-09-27 21:51:25 +00003233</div>
3234
Misha Brukman9d0919f2003-11-08 01:05:38 +00003235<div class="doc_text">
Chris Lattnere19d7a72004-09-27 21:51:25 +00003236
Chris Lattner8d1a81d2003-10-18 05:51:36 +00003237<h5>Syntax:</h5>
Chris Lattnere19d7a72004-09-27 21:51:25 +00003238
3239<pre>
Andrew Lenharth8bf607a2005-06-18 18:28:17 +00003240 &lt;resultval&gt; = va_arg &lt;va_list*&gt; &lt;arglist&gt;, &lt;argty&gt;
Chris Lattnere19d7a72004-09-27 21:51:25 +00003241</pre>
3242
Chris Lattner8d1a81d2003-10-18 05:51:36 +00003243<h5>Overview:</h5>
Chris Lattnere19d7a72004-09-27 21:51:25 +00003244
Andrew Lenharth8bf607a2005-06-18 18:28:17 +00003245<p>The '<tt>va_arg</tt>' instruction is used to access arguments passed through
Chris Lattnere19d7a72004-09-27 21:51:25 +00003246the "variable argument" area of a function call. It is used to implement the
3247<tt>va_arg</tt> macro in C.</p>
3248
Chris Lattner8d1a81d2003-10-18 05:51:36 +00003249<h5>Arguments:</h5>
Chris Lattnere19d7a72004-09-27 21:51:25 +00003250
Andrew Lenharth8bf607a2005-06-18 18:28:17 +00003251<p>This instruction takes a <tt>va_list*</tt> value and the type of
3252the argument. It returns a value of the specified argument type and
Jeff Cohen25d4f7e2005-11-11 02:15:27 +00003253increments the <tt>va_list</tt> to point to the next argument. Again, the
Andrew Lenharth8bf607a2005-06-18 18:28:17 +00003254actual type of <tt>va_list</tt> is target specific.</p>
Chris Lattnere19d7a72004-09-27 21:51:25 +00003255
Chris Lattner8d1a81d2003-10-18 05:51:36 +00003256<h5>Semantics:</h5>
Chris Lattnere19d7a72004-09-27 21:51:25 +00003257
Andrew Lenharth8bf607a2005-06-18 18:28:17 +00003258<p>The '<tt>va_arg</tt>' instruction loads an argument of the specified
3259type from the specified <tt>va_list</tt> and causes the
3260<tt>va_list</tt> to point to the next argument. For more information,
3261see the variable argument handling <a href="#int_varargs">Intrinsic
3262Functions</a>.</p>
Chris Lattnere19d7a72004-09-27 21:51:25 +00003263
3264<p>It is legal for this instruction to be called in a function which does not
3265take a variable number of arguments, for example, the <tt>vfprintf</tt>
Misha Brukman9d0919f2003-11-08 01:05:38 +00003266function.</p>
Chris Lattnere19d7a72004-09-27 21:51:25 +00003267
Andrew Lenharth8bf607a2005-06-18 18:28:17 +00003268<p><tt>va_arg</tt> is an LLVM instruction instead of an <a
John Criswellfc6b8952005-05-16 16:17:45 +00003269href="#intrinsics">intrinsic function</a> because it takes a type as an
Chris Lattnere19d7a72004-09-27 21:51:25 +00003270argument.</p>
3271
Chris Lattner8d1a81d2003-10-18 05:51:36 +00003272<h5>Example:</h5>
Chris Lattnere19d7a72004-09-27 21:51:25 +00003273
3274<p>See the <a href="#int_varargs">variable argument processing</a> section.</p>
3275
Misha Brukman9d0919f2003-11-08 01:05:38 +00003276</div>
Chris Lattner8ff75902004-01-06 05:31:32 +00003277
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00003278<!-- *********************************************************************** -->
Chris Lattner261efe92003-11-25 01:02:51 +00003279<div class="doc_section"> <a name="intrinsics">Intrinsic Functions</a> </div>
3280<!-- *********************************************************************** -->
Chris Lattner8ff75902004-01-06 05:31:32 +00003281
Misha Brukman9d0919f2003-11-08 01:05:38 +00003282<div class="doc_text">
Chris Lattner33aec9e2004-02-12 17:01:32 +00003283
3284<p>LLVM supports the notion of an "intrinsic function". These functions have
John Criswellfc6b8952005-05-16 16:17:45 +00003285well known names and semantics and are required to follow certain
Chris Lattner33aec9e2004-02-12 17:01:32 +00003286restrictions. Overall, these instructions represent an extension mechanism for
3287the LLVM language that does not require changing all of the transformations in
3288LLVM to add to the language (or the bytecode reader/writer, the parser,
3289etc...).</p>
3290
John Criswellfc6b8952005-05-16 16:17:45 +00003291<p>Intrinsic function names must all start with an "<tt>llvm.</tt>" prefix. This
3292prefix is reserved in LLVM for intrinsic names; thus, functions may not be named
Chris Lattner33aec9e2004-02-12 17:01:32 +00003293this. Intrinsic functions must always be external functions: you cannot define
3294the body of intrinsic functions. Intrinsic functions may only be used in call
3295or invoke instructions: it is illegal to take the address of an intrinsic
3296function. Additionally, because intrinsic functions are part of the LLVM
3297language, it is required that they all be documented here if any are added.</p>
3298
3299
John Criswellfc6b8952005-05-16 16:17:45 +00003300<p>To learn how to add an intrinsic function, please see the <a
Chris Lattner590cff32005-05-11 03:35:57 +00003301href="ExtendingLLVM.html">Extending LLVM Guide</a>.
Chris Lattner33aec9e2004-02-12 17:01:32 +00003302</p>
3303
Misha Brukman9d0919f2003-11-08 01:05:38 +00003304</div>
Chris Lattner8ff75902004-01-06 05:31:32 +00003305
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00003306<!-- ======================================================================= -->
Chris Lattner8ff75902004-01-06 05:31:32 +00003307<div class="doc_subsection">
3308 <a name="int_varargs">Variable Argument Handling Intrinsics</a>
3309</div>
3310
Misha Brukman9d0919f2003-11-08 01:05:38 +00003311<div class="doc_text">
Chris Lattnerd7923912004-05-23 21:06:01 +00003312
Misha Brukman9d0919f2003-11-08 01:05:38 +00003313<p>Variable argument support is defined in LLVM with the <a
Chris Lattnerfb6977d2006-01-13 23:26:01 +00003314 href="#i_va_arg"><tt>va_arg</tt></a> instruction and these three
Chris Lattner261efe92003-11-25 01:02:51 +00003315intrinsic functions. These functions are related to the similarly
3316named macros defined in the <tt>&lt;stdarg.h&gt;</tt> header file.</p>
Chris Lattnerd7923912004-05-23 21:06:01 +00003317
Chris Lattner261efe92003-11-25 01:02:51 +00003318<p>All of these functions operate on arguments that use a
3319target-specific value type "<tt>va_list</tt>". The LLVM assembly
3320language reference manual does not define what this type is, so all
3321transformations should be prepared to handle intrinsics with any type
3322used.</p>
Chris Lattnerd7923912004-05-23 21:06:01 +00003323
Chris Lattner374ab302006-05-15 17:26:46 +00003324<p>This example shows how the <a href="#i_va_arg"><tt>va_arg</tt></a>
Chris Lattner261efe92003-11-25 01:02:51 +00003325instruction and the variable argument handling intrinsic functions are
3326used.</p>
Chris Lattnerd7923912004-05-23 21:06:01 +00003327
Chris Lattner33aec9e2004-02-12 17:01:32 +00003328<pre>
3329int %test(int %X, ...) {
3330 ; Initialize variable argument processing
Andrew Lenharth8bf607a2005-06-18 18:28:17 +00003331 %ap = alloca sbyte*
3332 call void %<a href="#i_va_start">llvm.va_start</a>(sbyte** %ap)
Chris Lattner33aec9e2004-02-12 17:01:32 +00003333
3334 ; Read a single integer argument
Andrew Lenharth8bf607a2005-06-18 18:28:17 +00003335 %tmp = va_arg sbyte** %ap, int
Chris Lattner33aec9e2004-02-12 17:01:32 +00003336
3337 ; Demonstrate usage of llvm.va_copy and llvm.va_end
Andrew Lenharth8bf607a2005-06-18 18:28:17 +00003338 %aq = alloca sbyte*
Andrew Lenharthd0a4c622005-06-22 20:38:11 +00003339 call void %<a href="#i_va_copy">llvm.va_copy</a>(sbyte** %aq, sbyte** %ap)
Andrew Lenharth8bf607a2005-06-18 18:28:17 +00003340 call void %<a href="#i_va_end">llvm.va_end</a>(sbyte** %aq)
Chris Lattner33aec9e2004-02-12 17:01:32 +00003341
3342 ; Stop processing of arguments.
Andrew Lenharth8bf607a2005-06-18 18:28:17 +00003343 call void %<a href="#i_va_end">llvm.va_end</a>(sbyte** %ap)
Chris Lattner33aec9e2004-02-12 17:01:32 +00003344 ret int %tmp
3345}
3346</pre>
Misha Brukman9d0919f2003-11-08 01:05:38 +00003347</div>
Chris Lattner8ff75902004-01-06 05:31:32 +00003348
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00003349<!-- _______________________________________________________________________ -->
Chris Lattner8ff75902004-01-06 05:31:32 +00003350<div class="doc_subsubsection">
3351 <a name="i_va_start">'<tt>llvm.va_start</tt>' Intrinsic</a>
3352</div>
3353
3354
Misha Brukman9d0919f2003-11-08 01:05:38 +00003355<div class="doc_text">
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00003356<h5>Syntax:</h5>
Andrew Lenharth8bf607a2005-06-18 18:28:17 +00003357<pre> declare void %llvm.va_start(&lt;va_list&gt;* &lt;arglist&gt;)<br></pre>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00003358<h5>Overview:</h5>
Andrew Lenharth8bf607a2005-06-18 18:28:17 +00003359<P>The '<tt>llvm.va_start</tt>' intrinsic initializes
3360<tt>*&lt;arglist&gt;</tt> for subsequent use by <tt><a
3361href="#i_va_arg">va_arg</a></tt>.</p>
3362
3363<h5>Arguments:</h5>
3364
3365<P>The argument is a pointer to a <tt>va_list</tt> element to initialize.</p>
3366
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00003367<h5>Semantics:</h5>
Andrew Lenharth8bf607a2005-06-18 18:28:17 +00003368
3369<P>The '<tt>llvm.va_start</tt>' intrinsic works just like the <tt>va_start</tt>
3370macro available in C. In a target-dependent way, it initializes the
3371<tt>va_list</tt> element the argument points to, so that the next call to
3372<tt>va_arg</tt> will produce the first variable argument passed to the function.
3373Unlike the C <tt>va_start</tt> macro, this intrinsic does not need to know the
3374last argument of the function, the compiler can figure that out.</p>
3375
Misha Brukman9d0919f2003-11-08 01:05:38 +00003376</div>
Chris Lattner8ff75902004-01-06 05:31:32 +00003377
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00003378<!-- _______________________________________________________________________ -->
Chris Lattner8ff75902004-01-06 05:31:32 +00003379<div class="doc_subsubsection">
3380 <a name="i_va_end">'<tt>llvm.va_end</tt>' Intrinsic</a>
3381</div>
3382
Misha Brukman9d0919f2003-11-08 01:05:38 +00003383<div class="doc_text">
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00003384<h5>Syntax:</h5>
Andrew Lenharth8bf607a2005-06-18 18:28:17 +00003385<pre> declare void %llvm.va_end(&lt;va_list*&gt; &lt;arglist&gt;)<br></pre>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00003386<h5>Overview:</h5>
Chris Lattner261efe92003-11-25 01:02:51 +00003387<p>The '<tt>llvm.va_end</tt>' intrinsic destroys <tt>&lt;arglist&gt;</tt>
3388which has been initialized previously with <tt><a href="#i_va_start">llvm.va_start</a></tt>
3389or <tt><a href="#i_va_copy">llvm.va_copy</a></tt>.</p>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00003390<h5>Arguments:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00003391<p>The argument is a <tt>va_list</tt> to destroy.</p>
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00003392<h5>Semantics:</h5>
Misha Brukman9d0919f2003-11-08 01:05:38 +00003393<p>The '<tt>llvm.va_end</tt>' intrinsic works just like the <tt>va_end</tt>
Chris Lattner261efe92003-11-25 01:02:51 +00003394macro available in C. In a target-dependent way, it destroys the <tt>va_list</tt>.
3395Calls to <a href="#i_va_start"><tt>llvm.va_start</tt></a> and <a
3396 href="#i_va_copy"><tt>llvm.va_copy</tt></a> must be matched exactly
3397with calls to <tt>llvm.va_end</tt>.</p>
Misha Brukman9d0919f2003-11-08 01:05:38 +00003398</div>
Chris Lattner8ff75902004-01-06 05:31:32 +00003399
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00003400<!-- _______________________________________________________________________ -->
Chris Lattner8ff75902004-01-06 05:31:32 +00003401<div class="doc_subsubsection">
3402 <a name="i_va_copy">'<tt>llvm.va_copy</tt>' Intrinsic</a>
3403</div>
3404
Misha Brukman9d0919f2003-11-08 01:05:38 +00003405<div class="doc_text">
Chris Lattnerd7923912004-05-23 21:06:01 +00003406
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00003407<h5>Syntax:</h5>
Chris Lattnerd7923912004-05-23 21:06:01 +00003408
3409<pre>
Andrew Lenharth8bf607a2005-06-18 18:28:17 +00003410 declare void %llvm.va_copy(&lt;va_list&gt;* &lt;destarglist&gt;,
Andrew Lenharthd0a4c622005-06-22 20:38:11 +00003411 &lt;va_list&gt;* &lt;srcarglist&gt;)
Chris Lattnerd7923912004-05-23 21:06:01 +00003412</pre>
3413
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00003414<h5>Overview:</h5>
Chris Lattnerd7923912004-05-23 21:06:01 +00003415
Andrew Lenharth8bf607a2005-06-18 18:28:17 +00003416<p>The '<tt>llvm.va_copy</tt>' intrinsic copies the current argument position from
3417the source argument list to the destination argument list.</p>
Chris Lattnerd7923912004-05-23 21:06:01 +00003418
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00003419<h5>Arguments:</h5>
Chris Lattnerd7923912004-05-23 21:06:01 +00003420
Andrew Lenharth8bf607a2005-06-18 18:28:17 +00003421<p>The first argument is a pointer to a <tt>va_list</tt> element to initialize.
Andrew Lenharthd0a4c622005-06-22 20:38:11 +00003422The second argument is a pointer to a <tt>va_list</tt> element to copy from.</p>
Andrew Lenharth8bf607a2005-06-18 18:28:17 +00003423
Chris Lattnerd7923912004-05-23 21:06:01 +00003424
Chris Lattnerd9ad5b32003-05-08 04:57:36 +00003425<h5>Semantics:</h5>
Chris Lattnerd7923912004-05-23 21:06:01 +00003426
Andrew Lenharth8bf607a2005-06-18 18:28:17 +00003427<p>The '<tt>llvm.va_copy</tt>' intrinsic works just like the <tt>va_copy</tt> macro
3428available in C. In a target-dependent way, it copies the source
3429<tt>va_list</tt> element into the destination list. This intrinsic is necessary
3430because the <tt><a href="i_va_begin">llvm.va_begin</a></tt> intrinsic may be
Chris Lattnerd7923912004-05-23 21:06:01 +00003431arbitrarily complex and require memory allocation, for example.</p>
3432
Misha Brukman9d0919f2003-11-08 01:05:38 +00003433</div>
Chris Lattner8ff75902004-01-06 05:31:32 +00003434
Chris Lattner33aec9e2004-02-12 17:01:32 +00003435<!-- ======================================================================= -->
3436<div class="doc_subsection">
Chris Lattnerd7923912004-05-23 21:06:01 +00003437 <a name="int_gc">Accurate Garbage Collection Intrinsics</a>
3438</div>
3439
3440<div class="doc_text">
3441
3442<p>
3443LLVM support for <a href="GarbageCollection.html">Accurate Garbage
3444Collection</a> requires the implementation and generation of these intrinsics.
3445These intrinsics allow identification of <a href="#i_gcroot">GC roots on the
3446stack</a>, as well as garbage collector implementations that require <a
3447href="#i_gcread">read</a> and <a href="#i_gcwrite">write</a> barriers.
3448Front-ends for type-safe garbage collected languages should generate these
3449intrinsics to make use of the LLVM garbage collectors. For more details, see <a
3450href="GarbageCollection.html">Accurate Garbage Collection with LLVM</a>.
3451</p>
3452</div>
3453
3454<!-- _______________________________________________________________________ -->
3455<div class="doc_subsubsection">
3456 <a name="i_gcroot">'<tt>llvm.gcroot</tt>' Intrinsic</a>
3457</div>
3458
3459<div class="doc_text">
3460
3461<h5>Syntax:</h5>
3462
3463<pre>
Reid Spencera8d451e2005-04-26 20:50:44 +00003464 declare void %llvm.gcroot(&lt;ty&gt;** %ptrloc, &lt;ty2&gt;* %metadata)
Chris Lattnerd7923912004-05-23 21:06:01 +00003465</pre>
3466
3467<h5>Overview:</h5>
3468
John Criswell9e2485c2004-12-10 15:51:16 +00003469<p>The '<tt>llvm.gcroot</tt>' intrinsic declares the existence of a GC root to
Chris Lattnerd7923912004-05-23 21:06:01 +00003470the code generator, and allows some metadata to be associated with it.</p>
3471
3472<h5>Arguments:</h5>
3473
3474<p>The first argument specifies the address of a stack object that contains the
3475root pointer. The second pointer (which must be either a constant or a global
3476value address) contains the meta-data to be associated with the root.</p>
3477
3478<h5>Semantics:</h5>
3479
3480<p>At runtime, a call to this intrinsics stores a null pointer into the "ptrloc"
3481location. At compile-time, the code generator generates information to allow
3482the runtime to find the pointer at GC safe points.
3483</p>
3484
3485</div>
3486
3487
3488<!-- _______________________________________________________________________ -->
3489<div class="doc_subsubsection">
3490 <a name="i_gcread">'<tt>llvm.gcread</tt>' Intrinsic</a>
3491</div>
3492
3493<div class="doc_text">
3494
3495<h5>Syntax:</h5>
3496
3497<pre>
Chris Lattner80626e92006-03-14 20:02:51 +00003498 declare sbyte* %llvm.gcread(sbyte* %ObjPtr, sbyte** %Ptr)
Chris Lattnerd7923912004-05-23 21:06:01 +00003499</pre>
3500
3501<h5>Overview:</h5>
3502
3503<p>The '<tt>llvm.gcread</tt>' intrinsic identifies reads of references from heap
3504locations, allowing garbage collector implementations that require read
3505barriers.</p>
3506
3507<h5>Arguments:</h5>
3508
Chris Lattner80626e92006-03-14 20:02:51 +00003509<p>The second argument is the address to read from, which should be an address
3510allocated from the garbage collector. The first object is a pointer to the
3511start of the referenced object, if needed by the language runtime (otherwise
3512null).</p>
Chris Lattnerd7923912004-05-23 21:06:01 +00003513
3514<h5>Semantics:</h5>
3515
3516<p>The '<tt>llvm.gcread</tt>' intrinsic has the same semantics as a load
3517instruction, but may be replaced with substantially more complex code by the
3518garbage collector runtime, as needed.</p>
3519
3520</div>
3521
3522
3523<!-- _______________________________________________________________________ -->
3524<div class="doc_subsubsection">
3525 <a name="i_gcwrite">'<tt>llvm.gcwrite</tt>' Intrinsic</a>
3526</div>
3527
3528<div class="doc_text">
3529
3530<h5>Syntax:</h5>
3531
3532<pre>
Chris Lattner80626e92006-03-14 20:02:51 +00003533 declare void %llvm.gcwrite(sbyte* %P1, sbyte* %Obj, sbyte** %P2)
Chris Lattnerd7923912004-05-23 21:06:01 +00003534</pre>
3535
3536<h5>Overview:</h5>
3537
3538<p>The '<tt>llvm.gcwrite</tt>' intrinsic identifies writes of references to heap
3539locations, allowing garbage collector implementations that require write
3540barriers (such as generational or reference counting collectors).</p>
3541
3542<h5>Arguments:</h5>
3543
Chris Lattner80626e92006-03-14 20:02:51 +00003544<p>The first argument is the reference to store, the second is the start of the
3545object to store it to, and the third is the address of the field of Obj to
3546store to. If the runtime does not require a pointer to the object, Obj may be
3547null.</p>
Chris Lattnerd7923912004-05-23 21:06:01 +00003548
3549<h5>Semantics:</h5>
3550
3551<p>The '<tt>llvm.gcwrite</tt>' intrinsic has the same semantics as a store
3552instruction, but may be replaced with substantially more complex code by the
3553garbage collector runtime, as needed.</p>
3554
3555</div>
3556
3557
3558
3559<!-- ======================================================================= -->
3560<div class="doc_subsection">
Chris Lattner10610642004-02-14 04:08:35 +00003561 <a name="int_codegen">Code Generator Intrinsics</a>
3562</div>
3563
3564<div class="doc_text">
3565<p>
3566These intrinsics are provided by LLVM to expose special features that may only
3567be implemented with code generator support.
3568</p>
3569
3570</div>
3571
3572<!-- _______________________________________________________________________ -->
3573<div class="doc_subsubsection">
3574 <a name="i_returnaddress">'<tt>llvm.returnaddress</tt>' Intrinsic</a>
3575</div>
3576
3577<div class="doc_text">
3578
3579<h5>Syntax:</h5>
3580<pre>
Chris Lattnerfcf39d42006-01-13 01:20:27 +00003581 declare sbyte *%llvm.returnaddress(uint &lt;level&gt;)
Chris Lattner10610642004-02-14 04:08:35 +00003582</pre>
3583
3584<h5>Overview:</h5>
3585
3586<p>
Chris Lattner32b5d712006-10-15 20:05:59 +00003587The '<tt>llvm.returnaddress</tt>' intrinsic attempts to compute a
3588target-specific value indicating the return address of the current function
3589or one of its callers.
Chris Lattner10610642004-02-14 04:08:35 +00003590</p>
3591
3592<h5>Arguments:</h5>
3593
3594<p>
3595The argument to this intrinsic indicates which function to return the address
3596for. Zero indicates the calling function, one indicates its caller, etc. The
3597argument is <b>required</b> to be a constant integer value.
3598</p>
3599
3600<h5>Semantics:</h5>
3601
3602<p>
3603The '<tt>llvm.returnaddress</tt>' intrinsic either returns a pointer indicating
3604the return address of the specified call frame, or zero if it cannot be
3605identified. The value returned by this intrinsic is likely to be incorrect or 0
3606for arguments other than zero, so it should only be used for debugging purposes.
3607</p>
3608
3609<p>
3610Note that calling this intrinsic does not prevent function inlining or other
Chris Lattnerb40bb382005-03-07 20:30:51 +00003611aggressive transformations, so the value returned may not be that of the obvious
Chris Lattner10610642004-02-14 04:08:35 +00003612source-language caller.
3613</p>
3614</div>
3615
3616
3617<!-- _______________________________________________________________________ -->
3618<div class="doc_subsubsection">
3619 <a name="i_frameaddress">'<tt>llvm.frameaddress</tt>' Intrinsic</a>
3620</div>
3621
3622<div class="doc_text">
3623
3624<h5>Syntax:</h5>
3625<pre>
Chris Lattnerfcf39d42006-01-13 01:20:27 +00003626 declare sbyte *%llvm.frameaddress(uint &lt;level&gt;)
Chris Lattner10610642004-02-14 04:08:35 +00003627</pre>
3628
3629<h5>Overview:</h5>
3630
3631<p>
Chris Lattner32b5d712006-10-15 20:05:59 +00003632The '<tt>llvm.frameaddress</tt>' intrinsic attempts to return the
3633target-specific frame pointer value for the specified stack frame.
Chris Lattner10610642004-02-14 04:08:35 +00003634</p>
3635
3636<h5>Arguments:</h5>
3637
3638<p>
3639The argument to this intrinsic indicates which function to return the frame
3640pointer for. Zero indicates the calling function, one indicates its caller,
3641etc. The argument is <b>required</b> to be a constant integer value.
3642</p>
3643
3644<h5>Semantics:</h5>
3645
3646<p>
3647The '<tt>llvm.frameaddress</tt>' intrinsic either returns a pointer indicating
3648the frame address of the specified call frame, or zero if it cannot be
3649identified. The value returned by this intrinsic is likely to be incorrect or 0
3650for arguments other than zero, so it should only be used for debugging purposes.
3651</p>
3652
3653<p>
3654Note that calling this intrinsic does not prevent function inlining or other
Chris Lattnerb40bb382005-03-07 20:30:51 +00003655aggressive transformations, so the value returned may not be that of the obvious
Chris Lattner10610642004-02-14 04:08:35 +00003656source-language caller.
3657</p>
3658</div>
3659
Chris Lattner9a9d7ac2005-02-28 19:24:19 +00003660<!-- _______________________________________________________________________ -->
3661<div class="doc_subsubsection">
Chris Lattner57e1f392006-01-13 02:03:13 +00003662 <a name="i_stacksave">'<tt>llvm.stacksave</tt>' Intrinsic</a>
3663</div>
3664
3665<div class="doc_text">
3666
3667<h5>Syntax:</h5>
3668<pre>
3669 declare sbyte *%llvm.stacksave()
3670</pre>
3671
3672<h5>Overview:</h5>
3673
3674<p>
3675The '<tt>llvm.stacksave</tt>' intrinsic is used to remember the current state of
3676the function stack, for use with <a href="#i_stackrestore">
3677<tt>llvm.stackrestore</tt></a>. This is useful for implementing language
3678features like scoped automatic variable sized arrays in C99.
3679</p>
3680
3681<h5>Semantics:</h5>
3682
3683<p>
3684This intrinsic returns a opaque pointer value that can be passed to <a
3685href="#i_stackrestore"><tt>llvm.stackrestore</tt></a>. When an
3686<tt>llvm.stackrestore</tt> intrinsic is executed with a value saved from
3687<tt>llvm.stacksave</tt>, it effectively restores the state of the stack to the
3688state it was in when the <tt>llvm.stacksave</tt> intrinsic executed. In
3689practice, this pops any <a href="#i_alloca">alloca</a> blocks from the stack
3690that were allocated after the <tt>llvm.stacksave</tt> was executed.
3691</p>
3692
3693</div>
3694
3695<!-- _______________________________________________________________________ -->
3696<div class="doc_subsubsection">
3697 <a name="i_stackrestore">'<tt>llvm.stackrestore</tt>' Intrinsic</a>
3698</div>
3699
3700<div class="doc_text">
3701
3702<h5>Syntax:</h5>
3703<pre>
3704 declare void %llvm.stackrestore(sbyte* %ptr)
3705</pre>
3706
3707<h5>Overview:</h5>
3708
3709<p>
3710The '<tt>llvm.stackrestore</tt>' intrinsic is used to restore the state of
3711the function stack to the state it was in when the corresponding <a
3712href="#llvm.stacksave"><tt>llvm.stacksave</tt></a> intrinsic executed. This is
3713useful for implementing language features like scoped automatic variable sized
3714arrays in C99.
3715</p>
3716
3717<h5>Semantics:</h5>
3718
3719<p>
3720See the description for <a href="#i_stacksave"><tt>llvm.stacksave</tt></a>.
3721</p>
3722
3723</div>
3724
3725
3726<!-- _______________________________________________________________________ -->
3727<div class="doc_subsubsection">
Chris Lattner9a9d7ac2005-02-28 19:24:19 +00003728 <a name="i_prefetch">'<tt>llvm.prefetch</tt>' Intrinsic</a>
3729</div>
3730
3731<div class="doc_text">
3732
3733<h5>Syntax:</h5>
3734<pre>
Reid Spencera8d451e2005-04-26 20:50:44 +00003735 declare void %llvm.prefetch(sbyte * &lt;address&gt;,
3736 uint &lt;rw&gt;, uint &lt;locality&gt;)
Chris Lattner9a9d7ac2005-02-28 19:24:19 +00003737</pre>
3738
3739<h5>Overview:</h5>
3740
3741
3742<p>
3743The '<tt>llvm.prefetch</tt>' intrinsic is a hint to the code generator to insert
John Criswellfc6b8952005-05-16 16:17:45 +00003744a prefetch instruction if supported; otherwise, it is a noop. Prefetches have
3745no
3746effect on the behavior of the program but can change its performance
Chris Lattner2a615362005-02-28 19:47:14 +00003747characteristics.
Chris Lattner9a9d7ac2005-02-28 19:24:19 +00003748</p>
3749
3750<h5>Arguments:</h5>
3751
3752<p>
3753<tt>address</tt> is the address to be prefetched, <tt>rw</tt> is the specifier
3754determining if the fetch should be for a read (0) or write (1), and
3755<tt>locality</tt> is a temporal locality specifier ranging from (0) - no
Chris Lattneraeffb4a2005-03-07 20:31:38 +00003756locality, to (3) - extremely local keep in cache. The <tt>rw</tt> and
Chris Lattner9a9d7ac2005-02-28 19:24:19 +00003757<tt>locality</tt> arguments must be constant integers.
3758</p>
3759
3760<h5>Semantics:</h5>
3761
3762<p>
3763This intrinsic does not modify the behavior of the program. In particular,
3764prefetches cannot trap and do not produce a value. On targets that support this
3765intrinsic, the prefetch can provide hints to the processor cache for better
3766performance.
3767</p>
3768
3769</div>
3770
Andrew Lenharth7f4ec3b2005-03-28 20:05:49 +00003771<!-- _______________________________________________________________________ -->
3772<div class="doc_subsubsection">
3773 <a name="i_pcmarker">'<tt>llvm.pcmarker</tt>' Intrinsic</a>
3774</div>
3775
3776<div class="doc_text">
3777
3778<h5>Syntax:</h5>
3779<pre>
Reid Spencera8d451e2005-04-26 20:50:44 +00003780 declare void %llvm.pcmarker( uint &lt;id&gt; )
Andrew Lenharth7f4ec3b2005-03-28 20:05:49 +00003781</pre>
3782
3783<h5>Overview:</h5>
3784
3785
3786<p>
John Criswellfc6b8952005-05-16 16:17:45 +00003787The '<tt>llvm.pcmarker</tt>' intrinsic is a method to export a Program Counter
3788(PC) in a region of
Andrew Lenharth7f4ec3b2005-03-28 20:05:49 +00003789code to simulators and other tools. The method is target specific, but it is
3790expected that the marker will use exported symbols to transmit the PC of the marker.
Jeff Cohen25d4f7e2005-11-11 02:15:27 +00003791The marker makes no guarantees that it will remain with any specific instruction
Chris Lattnerd07c3f42005-11-15 06:07:55 +00003792after optimizations. It is possible that the presence of a marker will inhibit
Chris Lattnerb3e7afd2006-03-24 07:16:10 +00003793optimizations. The intended use is to be inserted after optimizations to allow
John Criswellfc6b8952005-05-16 16:17:45 +00003794correlations of simulation runs.
Andrew Lenharth7f4ec3b2005-03-28 20:05:49 +00003795</p>
3796
3797<h5>Arguments:</h5>
3798
3799<p>
3800<tt>id</tt> is a numerical id identifying the marker.
3801</p>
3802
3803<h5>Semantics:</h5>
3804
3805<p>
3806This intrinsic does not modify the behavior of the program. Backends that do not
3807support this intrinisic may ignore it.
3808</p>
3809
3810</div>
3811
Andrew Lenharth51b8d542005-11-11 16:47:30 +00003812<!-- _______________________________________________________________________ -->
3813<div class="doc_subsubsection">
3814 <a name="i_readcyclecounter">'<tt>llvm.readcyclecounter</tt>' Intrinsic</a>
3815</div>
3816
3817<div class="doc_text">
3818
3819<h5>Syntax:</h5>
3820<pre>
3821 declare ulong %llvm.readcyclecounter( )
3822</pre>
3823
3824<h5>Overview:</h5>
3825
3826
3827<p>
3828The '<tt>llvm.readcyclecounter</tt>' intrinsic provides access to the cycle
3829counter register (or similar low latency, high accuracy clocks) on those targets
3830that support it. On X86, it should map to RDTSC. On Alpha, it should map to RPCC.
3831As the backing counters overflow quickly (on the order of 9 seconds on alpha), this
3832should only be used for small timings.
3833</p>
3834
3835<h5>Semantics:</h5>
3836
3837<p>
3838When directly supported, reading the cycle counter should not modify any memory.
3839Implementations are allowed to either return a application specific value or a
3840system wide value. On backends without support, this is lowered to a constant 0.
3841</p>
3842
3843</div>
3844
Chris Lattner10610642004-02-14 04:08:35 +00003845<!-- ======================================================================= -->
3846<div class="doc_subsection">
Chris Lattner33aec9e2004-02-12 17:01:32 +00003847 <a name="int_libc">Standard C Library Intrinsics</a>
3848</div>
3849
3850<div class="doc_text">
3851<p>
Chris Lattner10610642004-02-14 04:08:35 +00003852LLVM provides intrinsics for a few important standard C library functions.
3853These intrinsics allow source-language front-ends to pass information about the
3854alignment of the pointer arguments to the code generator, providing opportunity
3855for more efficient code generation.
Chris Lattner33aec9e2004-02-12 17:01:32 +00003856</p>
3857
3858</div>
3859
3860<!-- _______________________________________________________________________ -->
3861<div class="doc_subsubsection">
3862 <a name="i_memcpy">'<tt>llvm.memcpy</tt>' Intrinsic</a>
3863</div>
3864
3865<div class="doc_text">
3866
3867<h5>Syntax:</h5>
3868<pre>
Chris Lattner5b310c32006-03-03 00:07:20 +00003869 declare void %llvm.memcpy.i32(sbyte* &lt;dest&gt;, sbyte* &lt;src&gt;,
3870 uint &lt;len&gt;, uint &lt;align&gt;)
3871 declare void %llvm.memcpy.i64(sbyte* &lt;dest&gt;, sbyte* &lt;src&gt;,
3872 ulong &lt;len&gt;, uint &lt;align&gt;)
Chris Lattner33aec9e2004-02-12 17:01:32 +00003873</pre>
3874
3875<h5>Overview:</h5>
3876
3877<p>
Chris Lattner5b310c32006-03-03 00:07:20 +00003878The '<tt>llvm.memcpy.*</tt>' intrinsics copy a block of memory from the source
Chris Lattner33aec9e2004-02-12 17:01:32 +00003879location to the destination location.
3880</p>
3881
3882<p>
Chris Lattner5b310c32006-03-03 00:07:20 +00003883Note that, unlike the standard libc function, the <tt>llvm.memcpy.*</tt>
3884intrinsics do not return a value, and takes an extra alignment argument.
Chris Lattner33aec9e2004-02-12 17:01:32 +00003885</p>
3886
3887<h5>Arguments:</h5>
3888
3889<p>
3890The first argument is a pointer to the destination, the second is a pointer to
Chris Lattner5b310c32006-03-03 00:07:20 +00003891the source. The third argument is an integer argument
Chris Lattner33aec9e2004-02-12 17:01:32 +00003892specifying the number of bytes to copy, and the fourth argument is the alignment
3893of the source and destination locations.
3894</p>
3895
Chris Lattner3301ced2004-02-12 21:18:15 +00003896<p>
3897If the call to this intrinisic has an alignment value that is not 0 or 1, then
Chris Lattnerf0afc2c2006-03-04 00:02:10 +00003898the caller guarantees that both the source and destination pointers are aligned
3899to that boundary.
Chris Lattner3301ced2004-02-12 21:18:15 +00003900</p>
3901
Chris Lattner33aec9e2004-02-12 17:01:32 +00003902<h5>Semantics:</h5>
3903
3904<p>
Chris Lattner5b310c32006-03-03 00:07:20 +00003905The '<tt>llvm.memcpy.*</tt>' intrinsics copy a block of memory from the source
Chris Lattner33aec9e2004-02-12 17:01:32 +00003906location to the destination location, which are not allowed to overlap. It
3907copies "len" bytes of memory over. If the argument is known to be aligned to
3908some boundary, this can be specified as the fourth argument, otherwise it should
3909be set to 0 or 1.
3910</p>
3911</div>
3912
3913
Chris Lattner0eb51b42004-02-12 18:10:10 +00003914<!-- _______________________________________________________________________ -->
3915<div class="doc_subsubsection">
3916 <a name="i_memmove">'<tt>llvm.memmove</tt>' Intrinsic</a>
3917</div>
3918
3919<div class="doc_text">
3920
3921<h5>Syntax:</h5>
3922<pre>
Chris Lattner5b310c32006-03-03 00:07:20 +00003923 declare void %llvm.memmove.i32(sbyte* &lt;dest&gt;, sbyte* &lt;src&gt;,
3924 uint &lt;len&gt;, uint &lt;align&gt;)
3925 declare void %llvm.memmove.i64(sbyte* &lt;dest&gt;, sbyte* &lt;src&gt;,
3926 ulong &lt;len&gt;, uint &lt;align&gt;)
Chris Lattner0eb51b42004-02-12 18:10:10 +00003927</pre>
3928
3929<h5>Overview:</h5>
3930
3931<p>
Chris Lattner5b310c32006-03-03 00:07:20 +00003932The '<tt>llvm.memmove.*</tt>' intrinsics move a block of memory from the source
3933location to the destination location. It is similar to the
3934'<tt>llvm.memcmp</tt>' intrinsic but allows the two memory locations to overlap.
Chris Lattner0eb51b42004-02-12 18:10:10 +00003935</p>
3936
3937<p>
Chris Lattner5b310c32006-03-03 00:07:20 +00003938Note that, unlike the standard libc function, the <tt>llvm.memmove.*</tt>
3939intrinsics do not return a value, and takes an extra alignment argument.
Chris Lattner0eb51b42004-02-12 18:10:10 +00003940</p>
3941
3942<h5>Arguments:</h5>
3943
3944<p>
3945The first argument is a pointer to the destination, the second is a pointer to
Chris Lattner5b310c32006-03-03 00:07:20 +00003946the source. The third argument is an integer argument
Chris Lattner0eb51b42004-02-12 18:10:10 +00003947specifying the number of bytes to copy, and the fourth argument is the alignment
3948of the source and destination locations.
3949</p>
3950
Chris Lattner3301ced2004-02-12 21:18:15 +00003951<p>
3952If the call to this intrinisic has an alignment value that is not 0 or 1, then
Chris Lattnerf0afc2c2006-03-04 00:02:10 +00003953the caller guarantees that the source and destination pointers are aligned to
3954that boundary.
Chris Lattner3301ced2004-02-12 21:18:15 +00003955</p>
3956
Chris Lattner0eb51b42004-02-12 18:10:10 +00003957<h5>Semantics:</h5>
3958
3959<p>
Chris Lattner5b310c32006-03-03 00:07:20 +00003960The '<tt>llvm.memmove.*</tt>' intrinsics copy a block of memory from the source
Chris Lattner0eb51b42004-02-12 18:10:10 +00003961location to the destination location, which may overlap. It
3962copies "len" bytes of memory over. If the argument is known to be aligned to
3963some boundary, this can be specified as the fourth argument, otherwise it should
3964be set to 0 or 1.
3965</p>
3966</div>
3967
Chris Lattner8ff75902004-01-06 05:31:32 +00003968
Chris Lattner10610642004-02-14 04:08:35 +00003969<!-- _______________________________________________________________________ -->
3970<div class="doc_subsubsection">
Chris Lattner5b310c32006-03-03 00:07:20 +00003971 <a name="i_memset">'<tt>llvm.memset.*</tt>' Intrinsics</a>
Chris Lattner10610642004-02-14 04:08:35 +00003972</div>
3973
3974<div class="doc_text">
3975
3976<h5>Syntax:</h5>
3977<pre>
Chris Lattner5b310c32006-03-03 00:07:20 +00003978 declare void %llvm.memset.i32(sbyte* &lt;dest&gt;, ubyte &lt;val&gt;,
3979 uint &lt;len&gt;, uint &lt;align&gt;)
3980 declare void %llvm.memset.i64(sbyte* &lt;dest&gt;, ubyte &lt;val&gt;,
3981 ulong &lt;len&gt;, uint &lt;align&gt;)
Chris Lattner10610642004-02-14 04:08:35 +00003982</pre>
3983
3984<h5>Overview:</h5>
3985
3986<p>
Chris Lattner5b310c32006-03-03 00:07:20 +00003987The '<tt>llvm.memset.*</tt>' intrinsics fill a block of memory with a particular
Chris Lattner10610642004-02-14 04:08:35 +00003988byte value.
3989</p>
3990
3991<p>
3992Note that, unlike the standard libc function, the <tt>llvm.memset</tt> intrinsic
3993does not return a value, and takes an extra alignment argument.
3994</p>
3995
3996<h5>Arguments:</h5>
3997
3998<p>
3999The first argument is a pointer to the destination to fill, the second is the
Chris Lattner5b310c32006-03-03 00:07:20 +00004000byte value to fill it with, the third argument is an integer
Chris Lattner10610642004-02-14 04:08:35 +00004001argument specifying the number of bytes to fill, and the fourth argument is the
4002known alignment of destination location.
4003</p>
4004
4005<p>
4006If the call to this intrinisic has an alignment value that is not 0 or 1, then
Chris Lattnerf0afc2c2006-03-04 00:02:10 +00004007the caller guarantees that the destination pointer is aligned to that boundary.
Chris Lattner10610642004-02-14 04:08:35 +00004008</p>
4009
4010<h5>Semantics:</h5>
4011
4012<p>
Chris Lattner5b310c32006-03-03 00:07:20 +00004013The '<tt>llvm.memset.*</tt>' intrinsics fill "len" bytes of memory starting at
4014the
Chris Lattner10610642004-02-14 04:08:35 +00004015destination location. If the argument is known to be aligned to some boundary,
4016this can be specified as the fourth argument, otherwise it should be set to 0 or
40171.
4018</p>
4019</div>
4020
4021
Chris Lattner32006282004-06-11 02:28:03 +00004022<!-- _______________________________________________________________________ -->
4023<div class="doc_subsubsection">
Reid Spencer0b118202006-01-16 21:12:35 +00004024 <a name="i_isunordered">'<tt>llvm.isunordered.*</tt>' Intrinsic</a>
Alkis Evlogimenos26bbe932004-06-13 01:16:15 +00004025</div>
4026
4027<div class="doc_text">
4028
4029<h5>Syntax:</h5>
4030<pre>
Reid Spencer0b118202006-01-16 21:12:35 +00004031 declare bool %llvm.isunordered.f32(float Val1, float Val2)
4032 declare bool %llvm.isunordered.f64(double Val1, double Val2)
Alkis Evlogimenos26bbe932004-06-13 01:16:15 +00004033</pre>
4034
4035<h5>Overview:</h5>
4036
4037<p>
Reid Spencer0b118202006-01-16 21:12:35 +00004038The '<tt>llvm.isunordered</tt>' intrinsics return true if either or both of the
Alkis Evlogimenos26bbe932004-06-13 01:16:15 +00004039specified floating point values is a NAN.
4040</p>
4041
4042<h5>Arguments:</h5>
4043
4044<p>
4045The arguments are floating point numbers of the same type.
4046</p>
4047
4048<h5>Semantics:</h5>
4049
4050<p>
4051If either or both of the arguments is a SNAN or QNAN, it returns true, otherwise
4052false.
4053</p>
4054</div>
4055
4056
Chris Lattnera4d74142005-07-21 01:29:16 +00004057<!-- _______________________________________________________________________ -->
4058<div class="doc_subsubsection">
Chris Lattnerec6cb612006-01-16 22:38:59 +00004059 <a name="i_sqrt">'<tt>llvm.sqrt.*</tt>' Intrinsic</a>
Chris Lattnera4d74142005-07-21 01:29:16 +00004060</div>
4061
4062<div class="doc_text">
4063
4064<h5>Syntax:</h5>
4065<pre>
Chris Lattnerf4d252d2006-09-08 06:34:02 +00004066 declare float %llvm.sqrt.f32(float %Val)
4067 declare double %llvm.sqrt.f64(double %Val)
Chris Lattnera4d74142005-07-21 01:29:16 +00004068</pre>
4069
4070<h5>Overview:</h5>
4071
4072<p>
Reid Spencer0b118202006-01-16 21:12:35 +00004073The '<tt>llvm.sqrt</tt>' intrinsics return the sqrt of the specified operand,
Chris Lattnera4d74142005-07-21 01:29:16 +00004074returning the same value as the libm '<tt>sqrt</tt>' function would. Unlike
4075<tt>sqrt</tt> in libm, however, <tt>llvm.sqrt</tt> has undefined behavior for
4076negative numbers (which allows for better optimization).
4077</p>
4078
4079<h5>Arguments:</h5>
4080
4081<p>
4082The argument and return value are floating point numbers of the same type.
4083</p>
4084
4085<h5>Semantics:</h5>
4086
4087<p>
4088This function returns the sqrt of the specified operand if it is a positive
4089floating point number.
4090</p>
4091</div>
4092
Chris Lattnerf4d252d2006-09-08 06:34:02 +00004093<!-- _______________________________________________________________________ -->
4094<div class="doc_subsubsection">
4095 <a name="i_powi">'<tt>llvm.powi.*</tt>' Intrinsic</a>
4096</div>
4097
4098<div class="doc_text">
4099
4100<h5>Syntax:</h5>
4101<pre>
4102 declare float %llvm.powi.f32(float %Val, int %power)
4103 declare double %llvm.powi.f64(double %Val, int %power)
4104</pre>
4105
4106<h5>Overview:</h5>
4107
4108<p>
4109The '<tt>llvm.powi.*</tt>' intrinsics return the first operand raised to the
4110specified (positive or negative) power. The order of evaluation of
4111multiplications is not defined.
4112</p>
4113
4114<h5>Arguments:</h5>
4115
4116<p>
4117The second argument is an integer power, and the first is a value to raise to
4118that power.
4119</p>
4120
4121<h5>Semantics:</h5>
4122
4123<p>
4124This function returns the first value raised to the second power with an
4125unspecified sequence of rounding operations.</p>
4126</div>
4127
4128
Andrew Lenharthec370fd2005-05-03 18:01:48 +00004129<!-- ======================================================================= -->
4130<div class="doc_subsection">
Nate Begeman7e36c472006-01-13 23:26:38 +00004131 <a name="int_manip">Bit Manipulation Intrinsics</a>
Andrew Lenharthec370fd2005-05-03 18:01:48 +00004132</div>
4133
4134<div class="doc_text">
4135<p>
Nate Begeman7e36c472006-01-13 23:26:38 +00004136LLVM provides intrinsics for a few important bit manipulation operations.
Andrew Lenharthec370fd2005-05-03 18:01:48 +00004137These allow efficient code generation for some algorithms.
4138</p>
4139
4140</div>
4141
4142<!-- _______________________________________________________________________ -->
4143<div class="doc_subsubsection">
Nate Begeman7e36c472006-01-13 23:26:38 +00004144 <a name="i_bswap">'<tt>llvm.bswap.*</tt>' Intrinsics</a>
4145</div>
4146
4147<div class="doc_text">
4148
4149<h5>Syntax:</h5>
4150<pre>
Chris Lattnerec6cb612006-01-16 22:38:59 +00004151 declare ushort %llvm.bswap.i16(ushort &lt;id&gt;)
4152 declare uint %llvm.bswap.i32(uint &lt;id&gt;)
4153 declare ulong %llvm.bswap.i64(ulong &lt;id&gt;)
Nate Begeman7e36c472006-01-13 23:26:38 +00004154</pre>
4155
4156<h5>Overview:</h5>
4157
4158<p>
4159The '<tt>llvm.bwsap</tt>' family of intrinsics is used to byteswap a 16, 32 or
416064 bit quantity. These are useful for performing operations on data that is not
4161in the target's native byte order.
4162</p>
4163
4164<h5>Semantics:</h5>
4165
4166<p>
Chris Lattnerec6cb612006-01-16 22:38:59 +00004167The <tt>llvm.bswap.16</tt> intrinsic returns a ushort value that has the high and low
4168byte of the input ushort swapped. Similarly, the <tt>llvm.bswap.i32</tt> intrinsic
Nate Begeman7e36c472006-01-13 23:26:38 +00004169returns a uint value that has the four bytes of the input uint swapped, so that
4170if the input bytes are numbered 0, 1, 2, 3 then the returned uint will have its
Chris Lattnerec6cb612006-01-16 22:38:59 +00004171bytes in 3, 2, 1, 0 order. The <tt>llvm.bswap.i64</tt> intrinsic extends this concept
Nate Begeman7e36c472006-01-13 23:26:38 +00004172to 64 bits.
4173</p>
4174
4175</div>
4176
4177<!-- _______________________________________________________________________ -->
4178<div class="doc_subsubsection">
Reid Spencer0b118202006-01-16 21:12:35 +00004179 <a name="int_ctpop">'<tt>llvm.ctpop.*</tt>' Intrinsic</a>
Andrew Lenharthec370fd2005-05-03 18:01:48 +00004180</div>
4181
4182<div class="doc_text">
4183
4184<h5>Syntax:</h5>
4185<pre>
Chris Lattnerec6cb612006-01-16 22:38:59 +00004186 declare ubyte %llvm.ctpop.i8 (ubyte &lt;src&gt;)
4187 declare ushort %llvm.ctpop.i16(ushort &lt;src&gt;)
4188 declare uint %llvm.ctpop.i32(uint &lt;src&gt;)
4189 declare ulong %llvm.ctpop.i64(ulong &lt;src&gt;)
Andrew Lenharthec370fd2005-05-03 18:01:48 +00004190</pre>
4191
4192<h5>Overview:</h5>
4193
4194<p>
Chris Lattnerec6cb612006-01-16 22:38:59 +00004195The '<tt>llvm.ctpop</tt>' family of intrinsics counts the number of bits set in a
4196value.
Andrew Lenharthec370fd2005-05-03 18:01:48 +00004197</p>
4198
4199<h5>Arguments:</h5>
4200
4201<p>
Chris Lattnercfe6b372005-05-07 01:46:40 +00004202The only argument is the value to be counted. The argument may be of any
Chris Lattnerec6cb612006-01-16 22:38:59 +00004203unsigned integer type. The return type must match the argument type.
Andrew Lenharthec370fd2005-05-03 18:01:48 +00004204</p>
4205
4206<h5>Semantics:</h5>
4207
4208<p>
4209The '<tt>llvm.ctpop</tt>' intrinsic counts the 1's in a variable.
4210</p>
4211</div>
4212
4213<!-- _______________________________________________________________________ -->
4214<div class="doc_subsubsection">
Chris Lattner8a886be2006-01-16 22:34:14 +00004215 <a name="int_ctlz">'<tt>llvm.ctlz.*</tt>' Intrinsic</a>
Andrew Lenharthec370fd2005-05-03 18:01:48 +00004216</div>
4217
4218<div class="doc_text">
4219
4220<h5>Syntax:</h5>
4221<pre>
Chris Lattnerec6cb612006-01-16 22:38:59 +00004222 declare ubyte %llvm.ctlz.i8 (ubyte &lt;src&gt;)
4223 declare ushort %llvm.ctlz.i16(ushort &lt;src&gt;)
4224 declare uint %llvm.ctlz.i32(uint &lt;src&gt;)
4225 declare ulong %llvm.ctlz.i64(ulong &lt;src&gt;)
Andrew Lenharthec370fd2005-05-03 18:01:48 +00004226</pre>
4227
4228<h5>Overview:</h5>
4229
4230<p>
Reid Spencer0b118202006-01-16 21:12:35 +00004231The '<tt>llvm.ctlz</tt>' family of intrinsic functions counts the number of
4232leading zeros in a variable.
Andrew Lenharthec370fd2005-05-03 18:01:48 +00004233</p>
4234
4235<h5>Arguments:</h5>
4236
4237<p>
Chris Lattnercfe6b372005-05-07 01:46:40 +00004238The only argument is the value to be counted. The argument may be of any
Chris Lattnerec6cb612006-01-16 22:38:59 +00004239unsigned integer type. The return type must match the argument type.
Andrew Lenharthec370fd2005-05-03 18:01:48 +00004240</p>
4241
4242<h5>Semantics:</h5>
4243
4244<p>
Chris Lattnereff29ab2005-05-15 19:39:26 +00004245The '<tt>llvm.ctlz</tt>' intrinsic counts the leading (most significant) zeros
4246in a variable. If the src == 0 then the result is the size in bits of the type
Chris Lattner99d3c272006-04-21 21:37:40 +00004247of src. For example, <tt>llvm.ctlz(int 2) = 30</tt>.
Andrew Lenharthec370fd2005-05-03 18:01:48 +00004248</p>
4249</div>
Chris Lattner32006282004-06-11 02:28:03 +00004250
4251
Chris Lattnereff29ab2005-05-15 19:39:26 +00004252
4253<!-- _______________________________________________________________________ -->
4254<div class="doc_subsubsection">
Chris Lattner8a886be2006-01-16 22:34:14 +00004255 <a name="int_cttz">'<tt>llvm.cttz.*</tt>' Intrinsic</a>
Chris Lattnereff29ab2005-05-15 19:39:26 +00004256</div>
4257
4258<div class="doc_text">
4259
4260<h5>Syntax:</h5>
4261<pre>
Chris Lattnerec6cb612006-01-16 22:38:59 +00004262 declare ubyte %llvm.cttz.i8 (ubyte &lt;src&gt;)
4263 declare ushort %llvm.cttz.i16(ushort &lt;src&gt;)
4264 declare uint %llvm.cttz.i32(uint &lt;src&gt;)
4265 declare ulong %llvm.cttz.i64(ulong &lt;src&gt;)
Chris Lattnereff29ab2005-05-15 19:39:26 +00004266</pre>
4267
4268<h5>Overview:</h5>
4269
4270<p>
Reid Spencer0b118202006-01-16 21:12:35 +00004271The '<tt>llvm.cttz</tt>' family of intrinsic functions counts the number of
4272trailing zeros.
Chris Lattnereff29ab2005-05-15 19:39:26 +00004273</p>
4274
4275<h5>Arguments:</h5>
4276
4277<p>
4278The only argument is the value to be counted. The argument may be of any
Chris Lattnerec6cb612006-01-16 22:38:59 +00004279unsigned integer type. The return type must match the argument type.
Chris Lattnereff29ab2005-05-15 19:39:26 +00004280</p>
4281
4282<h5>Semantics:</h5>
4283
4284<p>
4285The '<tt>llvm.cttz</tt>' intrinsic counts the trailing (least significant) zeros
4286in a variable. If the src == 0 then the result is the size in bits of the type
4287of src. For example, <tt>llvm.cttz(2) = 1</tt>.
4288</p>
4289</div>
4290
Chris Lattner8ff75902004-01-06 05:31:32 +00004291<!-- ======================================================================= -->
4292<div class="doc_subsection">
4293 <a name="int_debugger">Debugger Intrinsics</a>
4294</div>
4295
4296<div class="doc_text">
4297<p>
4298The LLVM debugger intrinsics (which all start with <tt>llvm.dbg.</tt> prefix),
4299are described in the <a
4300href="SourceLevelDebugging.html#format_common_intrinsics">LLVM Source Level
4301Debugging</a> document.
4302</p>
4303</div>
4304
4305
Chris Lattner00950542001-06-06 20:29:01 +00004306<!-- *********************************************************************** -->
Chris Lattner00950542001-06-06 20:29:01 +00004307<hr>
Misha Brukmandaa4cb02004-03-01 17:47:27 +00004308<address>
4309 <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
4310 src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
4311 <a href="http://validator.w3.org/check/referer"><img
4312 src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /></a>
4313
4314 <a href="mailto:sabre@nondot.org">Chris Lattner</a><br>
Reid Spencer05fe4b02006-03-14 05:39:39 +00004315 <a href="http://llvm.org">The LLVM Compiler Infrastructure</a><br>
Misha Brukmandaa4cb02004-03-01 17:47:27 +00004316 Last modified: $Date$
4317</address>
Misha Brukman9d0919f2003-11-08 01:05:38 +00004318</body>
4319</html>