Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(429)

Side by Side Diff: native_client_sdk/src/doc/_developer.chrome.com_generated/reference/pnacl-bitcode-abi.html

Issue 140993006: [NaCl SDK Docs] Check in the generated NaCl SDK Documentation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: try without pepper_{dev,beta,stable} Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 {{+bindTo:partials.standard_nacl_article}}
2
3 <section id="pnacl-bitcode-reference-manual">
4 <h1 id="pnacl-bitcode-reference-manual">PNaCl Bitcode Reference Manual</h1>
5 <div class="contents local topic" id="contents">
6 <ul class="small-gap">
7 <li><a class="reference internal" href="#introduction" id="id1">Introduction</a> </li>
8 <li><p class="first"><a class="reference internal" href="#high-level-structure" id="id2">High Level Structure</a></p>
9 <ul class="small-gap">
10 <li><a class="reference internal" href="#data-model" id="id3">Data Model</a></li >
11 <li><a class="reference internal" href="#linkage-types" id="id4">Linkage Types</ a></li>
12 <li><a class="reference internal" href="#calling-conventions" id="id5">Calling C onventions</a></li>
13 <li><a class="reference internal" href="#visibility-styles" id="id6">Visibility Styles</a></li>
14 <li><a class="reference internal" href="#global-variables" id="id7">Global Varia bles</a></li>
15 <li><a class="reference internal" href="#functions" id="id8">Functions</a></li>
16 <li><a class="reference internal" href="#aliases" id="id9">Aliases</a></li>
17 <li><a class="reference internal" href="#named-metadata" id="id10">Named Metadat a</a></li>
18 <li><a class="reference internal" href="#module-level-inline-assembly" id="id11" >Module-Level Inline Assembly</a></li>
19 <li><a class="reference internal" href="#volatile-memory-accesses" id="id12">Vol atile Memory Accesses</a></li>
20 <li><a class="reference internal" href="#memory-model-for-concurrent-operations" id="id13">Memory Model for Concurrent Operations</a></li>
21 <li><a class="reference internal" href="#fast-math-flags" id="id14">Fast-Math Fl ags</a></li>
22 </ul>
23 </li>
24 <li><p class="first"><a class="reference internal" href="#type-system" id="id15" >Type System</a></p>
25 <ul class="small-gap">
26 <li><a class="reference internal" href="#scalar-types" id="id16">Scalar types</a ></li>
27 <li><a class="reference internal" href="#array-and-struct-types" id="id17">Array and struct types</a></li>
28 <li><a class="reference internal" href="#pointer-types" id="id18">Pointer types< /a></li>
29 <li><a class="reference internal" href="#undefined-values" id="id19">Undefined V alues</a></li>
30 <li><a class="reference internal" href="#constant-expressions" id="id20">Constan t Expressions</a></li>
31 </ul>
32 </li>
33 <li><p class="first"><a class="reference internal" href="#other-values" id="id21 ">Other Values</a></p>
34 <ul class="small-gap">
35 <li><a class="reference internal" href="#metadata-nodes-and-metadata-strings" id ="id22">Metadata Nodes and Metadata Strings</a></li>
36 </ul>
37 </li>
38 <li><a class="reference internal" href="#intrinsic-global-variables" id="id23">I ntrinsic Global Variables</a></li>
39 <li><p class="first"><a class="reference internal" href="#instruction-reference" id="id24">Instruction Reference</a></p>
40 <ul class="small-gap">
41 <li><a class="reference internal" href="#list-of-allowed-instructions" id="id25" >List of allowed instructions</a></li>
42 <li><a class="reference internal" href="#alloca" id="id26"><code>alloca</code></ a></li>
43 </ul>
44 </li>
45 <li><p class="first"><a class="reference internal" href="#intrinsic-functions" i d="id27">Intrinsic Functions</a></p>
46 <ul class="small-gap">
47 <li><a class="reference internal" href="#list-of-allowed-intrinsics" id="id28">L ist of allowed intrinsics</a></li>
48 <li><a class="reference internal" href="#thread-pointer-related-intrinsics" id=" id29">Thread pointer related intrinsics</a></li>
49 <li><a class="reference internal" href="#setjmp-and-longjmp" id="id30">Setjmp an d Longjmp</a></li>
50 <li><a class="reference internal" href="#atomic-intrinsics" id="id31">Atomic int rinsics</a></li>
51 </ul>
52 </li>
53 </ul>
54 </div>
55 <section id="introduction">
56 <h2 id="introduction">Introduction</h2>
57 <p>This document is a reference manual for the PNaCl bitcode format. It describe s
58 the bitcode on a <em>semantic</em> level; the physical encoding level will be de scribed
59 elsewhere. For the purpose of this document, the textual form of LLVM IR is
60 used to describe instructions and other bitcode constructs.</p>
61 <p>Since the PNaCl bitcode is based to a large extent on LLVM IR, many sections
62 in this document point to a relevant section of the LLVM language reference
63 manual. Only the changes, restrictions and variations specific to PNaCl are
64 described&#8212;full semantic descriptions are not duplicated from the LLVM
65 reference manual.</p>
66 </section><section id="high-level-structure">
67 <h2 id="high-level-structure">High Level Structure</h2>
68 <p>A PNaCl portable executable (<strong>pexe</strong> in short) is a single LLVM IR module.</p>
69 <section id="data-model">
70 <h3 id="data-model">Data Model</h3>
71 <p>The data model for PNaCl bitcode is fixed at little-endian ILP32: pointers ar e
72 32 bits in size. 64-bit integer types are also supported natively via the i64
73 type (for example, a front-end can generate these from the C/C++ type
74 <code>long long</code>).</p>
75 <p>Floating point support is fixed at IEEE 754 32-bit and 64-bit values (f32 and
76 f64, respectively).</p>
77 </section><section id="linkage-types">
78 <span id="bitcode-linkagetypes"></span><h3 id="linkage-types"><span id="bitcode- linkagetypes"></span>Linkage Types</h3>
79 <p><a class="reference external" href="http://llvm.org/releases/3.3/docs/LangRef .html#linkage">LLVM LangRef: Linkage Types</a></p>
80 <p>The linkage types supported by PNaCl bitcode are <code>internal</code> and <c ode>external</code>.
81 A single function in the pexe, named <code>_start</code>, has the linkage type
82 <code>external</code>. All the other functions and globals have the linkage type
83 <code>internal</code>.</p>
84 </section><section id="calling-conventions">
85 <h3 id="calling-conventions">Calling Conventions</h3>
86 <p><a class="reference external" href="http://llvm.org/releases/3.3/docs/LangRef .html#callingconv">LLVM LangRef: Calling Conventions</a></p>
87 <p>The only calling convention supported by PNaCl bitcode is <code>ccc</code> - the C
88 calling convention.</p>
89 </section><section id="visibility-styles">
90 <h3 id="visibility-styles">Visibility Styles</h3>
91 <p><a class="reference external" href="http://llvm.org/releases/3.3/docs/LangRef .html#visibility-styles">LLVM LangRef: Visibility Styles</a></p>
92 <p>PNaCl bitcode does not support visibility styles.</p>
93 </section><section id="global-variables">
94 <span id="bitcode-globalvariables"></span><h3 id="global-variables"><span id="bi tcode-globalvariables"></span>Global Variables</h3>
95 <p><a class="reference external" href="http://llvm.org/releases/3.3/docs/LangRef .html#globalvars">LLVM LangRef: Global Variables</a></p>
96 <p>Restrictions on global variables:</p>
97 <ul class="small-gap">
98 <li>PNaCl bitcode does not support LLVM IR TLS models. See
99 <a class="reference internal" href="/native-client/reference/pnacl-c-cpp-languag e-support.html#language-support-threading"><em>Threading</em></a> for more detai ls.</li>
100 <li>Restrictions on <a class="reference internal" href="#bitcode-linkagetypes">< em>linkage types</em></a>.</li>
101 <li>The <code>addrspace</code>, <code>section</code>, <code>unnamed_addr</code> and
102 <code>externally_initialized</code> attributes are not supported.</li>
103 </ul>
104 <p>Every global variable must have an initializer. Each initializer must be
105 either a <em>SimpleElement</em> or a <em>CompoundElement</em>, defined as follow s.</p>
106 <p>A <em>SimpleElement</em> is one of the following:</p>
107 <ol class="arabic simple">
108 <li>An i8 array literal or <code>zeroinitializer</code>:</li>
109 </ol>
110 <pre>
111 [SIZE x i8] c&quot;DATA&quot;
112 [SIZE x i8] zeroinitializer
113 </pre>
114 <ol class="arabic simple" start="2">
115 <li>A reference to a <em>GlobalValue</em> (a function or global variable) with a n
116 optional 32-bit byte offset added to it (the addend, which may be
117 negative):</li>
118 </ol>
119 <pre>
120 ptrtoint (TYPE* &#64;GLOBAL to i32)
121 add (i32 ptrtoint (TYPE* &#64;GLOBAL to i32), i32 ADDEND)
122 </pre>
123 <p>A <em>CompoundElement</em> is a unnamed, packed struct containing more than o ne
124 <em>SimpleElement</em>.</p>
125 </section><section id="functions">
126 <h3 id="functions">Functions</h3>
127 <p><a class="reference external" href="http://llvm.org/releases/3.3/docs/LangRef .html#functionstructure">LLVM LangRef: Functions</a></p>
128 <p>The restrictions on <a class="reference internal" href="#bitcode-linkagetypes "><em>linkage types</em></a>, calling
129 conventions and visibility styles apply to functions. In addition, the following
130 are not supported for functions:</p>
131 <ul class="small-gap">
132 <li>Function attributes (either for the the function itself, its parameters or i ts
133 return type).</li>
134 <li>Garbage collector name (<code>gc</code>).</li>
135 <li>Functions with a variable number of arguments (<em>vararg</em>).</li>
136 <li>Alignment (<code>align</code>).</li>
137 </ul>
138 </section><section id="aliases">
139 <h3 id="aliases">Aliases</h3>
140 <p><a class="reference external" href="http://llvm.org/releases/3.3/docs/LangRef .html#aliases">LLVM LangRef: Aliases</a></p>
141 <p>PNaCl bitcode does not support aliases.</p>
142 </section><section id="named-metadata">
143 <h3 id="named-metadata">Named Metadata</h3>
144 <p><a class="reference external" href="http://llvm.org/releases/3.3/docs/LangRef .html#namedmetadatastructure">LLVM LangRef: Named Metadata</a></p>
145 <p>While PNaCl bitcode has provisions for debugging metadata, it is not consider ed
146 part of the stable ABI. It exists for tool support and should not appear in
147 distributed pexes.</p>
148 <p>Other kinds of LLVM metadata are not supported.</p>
149 </section><section id="module-level-inline-assembly">
150 <h3 id="module-level-inline-assembly">Module-Level Inline Assembly</h3>
151 <p><a class="reference external" href="http://llvm.org/releases/3.3/docs/LangRef .html#moduleasm">LLVM LangRef: Module-Level Inline Assembly</a></p>
152 <p>PNaCl bitcode does not support inline assembly.</p>
153 </section><section id="volatile-memory-accesses">
154 <h3 id="volatile-memory-accesses">Volatile Memory Accesses</h3>
155 <p><a class="reference external" href="http://llvm.org/releases/3.3/docs/LangRef .html#volatile">LLVM LangRef: Volatile Memory Accesses</a></p>
156 <p>PNaCl bitcode does not support volatile memory accesses. The
157 <code>volatile</code> attribute on loads and stores is not supported. See the
158 <a class="reference internal" href="/native-client/reference/pnacl-c-cpp-languag e-support.html"><em>PNaCl C/C++ Language Support</em></a> for more details.</p>
159 </section><section id="memory-model-for-concurrent-operations">
160 <h3 id="memory-model-for-concurrent-operations">Memory Model for Concurrent Oper ations</h3>
161 <p><a class="reference external" href="http://llvm.org/releases/3.3/docs/LangRef .html#memmodel">LLVM LangRef: Memory Model for Concurrent Operations</a></p>
162 <p>See the <a class="reference external" href="PNaClDeveloperGuide.html">PNaCl D eveloper&#8217;s Guide</a> for more
163 details.</p>
164 </section><section id="fast-math-flags">
165 <h3 id="fast-math-flags">Fast-Math Flags</h3>
166 <p><a class="reference external" href="http://llvm.org/releases/3.3/docs/LangRef .html#fastmath">LLVM LangRef: Fast-Math Flags</a></p>
167 <p>Fast-math mode is not currently supported by the PNaCl bitcode.</p>
168 </section></section><section id="type-system">
169 <h2 id="type-system">Type System</h2>
170 <p><a class="reference external" href="http://llvm.org/releases/3.3/docs/LangRef .html#typesystem">LLVM LangRef: Type System</a></p>
171 <p>The LLVM types allowed in PNaCl bitcode are restricted, as follows:</p>
172 <section id="scalar-types">
173 <h3 id="scalar-types">Scalar types</h3>
174 <ul class="small-gap">
175 <li><p class="first">The only scalar types allowed are integer, float (32-bit fl oating point),
176 double (64-bit floating point) and void.</p>
177 <ul class="small-gap">
178 <li>The only integer sizes allowed are i1, i8, i16, i32 and i64.</li>
179 <li>The only integer sizes allowed for function arguments and function return
180 values are i32 and i64.</li>
181 </ul>
182 </li>
183 </ul>
184 </section><section id="array-and-struct-types">
185 <h3 id="array-and-struct-types">Array and struct types</h3>
186 <p>Array and struct types are only allowed in
187 <a class="reference internal" href="#bitcode-globalvariables"><em>global variabl e initializers</em></a>.</p>
188 </section><section id="pointer-types">
189 <span id="bitcode-pointertypes"></span><h3 id="pointer-types"><span id="bitcode- pointertypes"></span>Pointer types</h3>
190 <p>Only the following pointer types are allowed:</p>
191 <ul class="small-gap">
192 <li>Pointers to valid PNaCl bitcode scalar types, as specified above.</li>
193 <li>Pointers to functions.</li>
194 </ul>
195 <p>In addition, the address space for all pointers must be 0.</p>
196 <p>A pointer is <em>inherent</em> when it represents the return value of an <cod e>alloca</code>
197 instruction, or is an address of a global value.</p>
198 <p>A pointer is <em>normalized</em> if it&#8217;s either:</p>
199 <ul class="small-gap">
200 <li><em>inherent</em></li>
201 <li>Is the return value of a <code>bitcast</code> instruction.</li>
202 <li>Is the return value of a <code>inttoptr</code> instruction.</li>
203 </ul>
204 </section><section id="undefined-values">
205 <h3 id="undefined-values">Undefined Values</h3>
206 <p><a class="reference external" href="http://llvm.org/releases/3.3/docs/LangRef .html#undefvalues">LLVM LangRef: Undefined Values</a></p>
207 <p><code>undef</code> is only allowed within functions, not in global variable i nitializers.</p>
208 </section><section id="constant-expressions">
209 <h3 id="constant-expressions">Constant Expressions</h3>
210 <p><a class="reference external" href="http://llvm.org/releases/3.3/docs/LangRef .html#constant-expressions">LLVM LangRef: Constant Expressions</a></p>
211 <p>Constant expressions are only allowed in
212 <a class="reference internal" href="#bitcode-globalvariables"><em>global variabl e initializers</em></a>.</p>
213 </section></section><section id="other-values">
214 <h2 id="other-values">Other Values</h2>
215 <section id="metadata-nodes-and-metadata-strings">
216 <h3 id="metadata-nodes-and-metadata-strings">Metadata Nodes and Metadata Strings </h3>
217 <p><a class="reference external" href="http://llvm.org/releases/3.3/docs/LangRef .html#metadata">LLVM LangRef: Metadata Nodes and Metadata Strings</a></p>
218 <p>While PNaCl bitcode has provisions for debugging metadata, it is not consider ed
219 part of the stable ABI. It exists for tool support and should not appear in
220 distributed pexes.</p>
221 <p>Other kinds of LLVM metadata are not supported.</p>
222 </section></section><section id="intrinsic-global-variables">
223 <h2 id="intrinsic-global-variables">Intrinsic Global Variables</h2>
224 <p><a class="reference external" href="http://llvm.org/releases/3.3/docs/LangRef .html#intrinsic-global-variables">LLVM LangRef: Intrinsic Global Variables</a></ p>
225 <p>PNaCl bitcode does not support intrinsic global variables.</p>
226 </section><section id="instruction-reference">
227 <h2 id="instruction-reference">Instruction Reference</h2>
228 <section id="list-of-allowed-instructions">
229 <h3 id="list-of-allowed-instructions">List of allowed instructions</h3>
230 <p>This is a list of LLVM instructions supported by PNaCl bitcode. Where
231 applicable, PNaCl-specific restrictions are provided.</p>
232 <p>The following attributes are disallowed for all instructions:</p>
233 <ul class="small-gap">
234 <li><code>nsw</code> and <code>nuw</code></li>
235 <li><code>exact</code></li>
236 </ul>
237 <p>Only the LLVM instructions listed here are supported by PNaCl bitcode.</p>
238 <ul class="small-gap">
239 <li><code>ret</code></li>
240 <li><code>br</code></li>
241 <li><p class="first"><code>switch</code></p>
242 <p>i1 values are disallowed for <code>switch</code>.</p>
243 </li>
244 <li><p class="first"><code>add</code>, <code>sub</code>, <code>mul</code>, <code >shl</code>, <code>udiv</code>, <code>sdiv</code>, <code>urem</code>, <code>sre m</code>,
245 <code>lshr</code>, <code>ashr</code></p>
246 <p>These arithmetic operations are disallowed on values of type <code>i1</code>. </p>
247 <p>Integer division (<code>udiv</code>, <code>sdiv</code>, <code>urem</code>, <c ode>srem</code>) by zero is
248 guaranteed to trap in PNaCl bitcode.</p>
249 </li>
250 <li><code>and</code></li>
251 <li><code>or</code></li>
252 <li><code>xor</code></li>
253 <li><code>fadd</code></li>
254 <li><code>fsub</code></li>
255 <li><code>fmul</code></li>
256 <li><code>fdiv</code></li>
257 <li><code>frem</code></li>
258 <li><p class="first"><code>alloca</code></p>
259 <p>See <a class="reference internal" href="#bitcode-allocainst"><em>alloca instr uctions</em></a>.</p>
260 </li>
261 <li><p class="first"><code>load</code>, <code>store</code></p>
262 <p>The pointer argument of these instructions must be a <em>normalized</em> poin ter (see
263 <a class="reference internal" href="#bitcode-pointertypes"><em>pointer types</em ></a>). The <code>volatile</code> and <code>atomic</code>
264 attributes are not supported. Loads and stores of the type <code>i1</code> are n ot
265 supported.</p>
266 <p>These instructions must use <code>align 1</code> on integer memory accesses, <code>align 4</code>
267 for <code>float</code> accesses and <code>align 8</code> for <code>double</code> accesses.</p>
268 </li>
269 <li><code>trunc</code></li>
270 <li><code>zext</code></li>
271 <li><code>sext</code></li>
272 <li><code>fptrunc</code></li>
273 <li><code>fpext</code></li>
274 <li><code>fptoui</code></li>
275 <li><code>fptosi</code></li>
276 <li><code>uitofp</code></li>
277 <li><code>sitofp</code></li>
278 <li><p class="first"><code>ptrtoint</code></p>
279 <p>The pointer argument of a <code>ptrtoint</code> instruction must be a <em>nor malized</em>
280 pointer (see <a class="reference internal" href="#bitcode-pointertypes"><em>poin ter types</em></a>) and the integer
281 argument must be an i32.</p>
282 </li>
283 <li><p class="first"><code>inttoptr</code></p>
284 <p>The integer argument of a <code>inttoptr</code> instruction must be an i32.</ p>
285 </li>
286 <li><p class="first"><code>bitcast</code></p>
287 <p>The pointer argument of a <code>bitcast</code> instruction must be a <em>inhe rent</em> pointer
288 (see <a class="reference internal" href="#bitcode-pointertypes"><em>pointer type s</em></a>).</p>
289 </li>
290 <li><code>icmp</code></li>
291 <li><code>fcmp</code></li>
292 <li><code>phi</code></li>
293 <li><code>select</code></li>
294 <li><code>call</code></li>
295 </ul>
296 </section><section id="alloca">
297 <span id="bitcode-allocainst"></span><h3 id="alloca"><span id="bitcode-allocains t"></span><code>alloca</code></h3>
298 <p>The only allowed type for <code>alloca</code> instructions in PNaCl bitcode i s i8. The
299 size argument must be an i32. For example:</p>
300 <pre>
301 %buf = alloca i8, i32 8, align 4
302 </pre>
303 </section></section><section id="intrinsic-functions">
304 <h2 id="intrinsic-functions">Intrinsic Functions</h2>
305 <p><a class="reference external" href="http://llvm.org/releases/3.3/docs/LangRef .html#intrinsics">LLVM LangRef: Intrinsic Functions</a></p>
306 <section id="list-of-allowed-intrinsics">
307 <h3 id="list-of-allowed-intrinsics">List of allowed intrinsics</h3>
308 <p>The only intrinsics supported by PNaCl bitcode are the following.</p>
309 <ul class="small-gap">
310 <li><code>llvm.memcpy</code></li>
311 <li><code>llvm.memmove</code></li>
312 <li><p class="first"><code>llvm.memset</code></p>
313 <p>These intrinsics are only supported with an i32 <code>len</code> argument.</p >
314 </li>
315 <li><p class="first"><code>llvm.bswap</code></p>
316 <p>The overloaded <code>llvm.bswap</code> intrinsic is only supported with the f ollowing
317 argument types: i16, i32, i64 (the types supported by C-style GCC builtins).</p>
318 </li>
319 <li><code>llvm.ctlz</code></li>
320 <li><code>llvm.cttz</code></li>
321 <li><p class="first"><code>llvm.ctpop</code></p>
322 <p>The overloaded llvm.ctlz, llvm.cttz, and llvm.ctpop intrinsics are only
323 supported with the i32 and i64 argument types (the types supported by
324 C-style GCC builtins).</p>
325 </li>
326 <li><p class="first"><code>llvm.sqrt</code></p>
327 <p>The overloaded <code>llvm.sqrt</code> intrinsic is only supported for float
328 and double arguments types. Unlike the standard LLVM intrinsic,
329 PNaCl guarantees that llvm.sqrt returns a QNaN for values less than -0.0.</p>
330 </li>
331 <li><code>llvm.stacksave</code></li>
332 <li><p class="first"><code>llvm.stackrestore</code></p>
333 <p>These intrinsics are used to implement language features like scoped automati c
334 variable sized arrays in C99. <code>llvm.stacksave</code> returns a value that
335 represents the current state of the stack. This value may only be used as the
336 argument to <code>llvm.stackrestore</code>, which restores the stack to the give n
337 state.</p>
338 </li>
339 <li><p class="first"><code>llvm.trap</code></p>
340 <p>This intrinsic is lowered to a target dependent trap instruction, which abort s
341 execution.</p>
342 </li>
343 <li><p class="first"><code>llvm.nacl.read.tp</code></p>
344 <p>See <a class="reference internal" href="#bitcode-threadpointerintrinsics"><em >thread pointer related intrinsics</em></a>.</p>
345 </li>
346 <li><code>llvm.nacl.longjmp</code></li>
347 <li><p class="first"><code>llvm.nacl.setjmp</code></p>
348 <p>See <a class="reference internal" href="#bitcode-setjmplongjmp"><em>Setjmp an d Longjmp</em></a>.</p>
349 </li>
350 <li><code>llvm.nacl.atomic.store</code></li>
351 <li><code>llvm.nacl.atomic.load</code></li>
352 <li><code>llvm.nacl.atomic.rmw</code></li>
353 <li><code>llvm.nacl.atomic.cmpxchg</code></li>
354 <li><code>llvm.nacl.atomic.fence</code></li>
355 <li><code>llvm.nacl.atomic.fence.all</code></li>
356 <li><p class="first"><code>llvm.nacl.atomic.is.lock.free</code></p>
357 <p>See <a class="reference internal" href="#bitcode-atomicintrinsics"><em>atomic intrinsics</em></a>.</p>
358 </li>
359 </ul>
360 </section><section id="thread-pointer-related-intrinsics">
361 <span id="bitcode-threadpointerintrinsics"></span><h3 id="thread-pointer-related -intrinsics"><span id="bitcode-threadpointerintrinsics"></span>Thread pointer re lated intrinsics</h3>
362 <pre>
363 declare i8* &#64;llvm.nacl.read.tp()
364 </pre>
365 <p>Returns a read-only thread pointer. The value is controlled by the embedding
366 sandbox&#8217;s runtime.</p>
367 </section><section id="setjmp-and-longjmp">
368 <span id="bitcode-setjmplongjmp"></span><h3 id="setjmp-and-longjmp"><span id="bi tcode-setjmplongjmp"></span>Setjmp and Longjmp</h3>
369 <pre>
370 declare void &#64;llvm.nacl.longjmp(i8* %jmpbuf, i32)
371 declare i32 &#64;llvm.nacl.setjmp(i8* %jmpbuf)
372 </pre>
373 <p>These intrinsics implement the semantics of C11 <code>setjmp</code> and <code >longjmp</code>. The
374 <code>jmpbuf</code> pointer must be 64-bit aligned and point to at least 1024 by tes of
375 allocated memory.</p>
376 </section><section id="atomic-intrinsics">
377 <span id="bitcode-atomicintrinsics"></span><h3 id="atomic-intrinsics"><span id=" bitcode-atomicintrinsics"></span>Atomic intrinsics</h3>
378 <pre>
379 declare iN &#64;llvm.nacl.atomic.load.&lt;size&gt;(
380 iN* &lt;source&gt;, i32 &lt;memory_order&gt;)
381 declare void &#64;llvm.nacl.atomic.store.&lt;size&gt;(
382 iN &lt;operand&gt;, iN* &lt;destination&gt;, i32 &lt;memory_order&gt;)
383 declare iN &#64;llvm.nacl.atomic.rmw.&lt;size&gt;(
384 i32 &lt;computation&gt;, iN* &lt;object&gt;, iN &lt;operand&gt;, i32 & lt;memory_order&gt;)
385 declare iN &#64;llvm.nacl.atomic.cmpxchg.&lt;size&gt;(
386 iN* &lt;object&gt;, iN &lt;expected&gt;, iN &lt;desired&gt;,
387 i32 &lt;memory_order_success&gt;, i32 &lt;memory_order_failure&gt;)
388 declare void &#64;llvm.nacl.atomic.fence(i32 &lt;memory_order&gt;)
389 declare void &#64;llvm.nacl.atomic.fence.all()
390 </pre>
391 <p>Each of these intrinsics is overloaded on the <code>iN</code> argument, which is
392 reflected through <code>&lt;size&gt;</code> in the overload&#8217;s name. Integr al types of
393 8, 16, 32 and 64-bit width are supported for these arguments.</p>
394 <p>The <code>&#64;llvm.nacl.atomic.rmw</code> intrinsic implements the following
395 read-modify-write operations, from the general and arithmetic sections
396 of the C11/C++11 standards:</p>
397 <blockquote>
398 <div><ul class="small-gap">
399 <li><code>add</code></li>
400 <li><code>sub</code></li>
401 <li><code>or</code></li>
402 <li><code>and</code></li>
403 <li><code>xor</code></li>
404 <li><code>exchange</code></li>
405 </ul>
406 </div></blockquote>
407 <p>For all of these read-modify-write operations, the returned value is
408 that at <code>object</code> before the computation. The <code>computation</code> argument
409 must be a compile-time constant.</p>
410 <p>All atomic intrinsics also support C11/C++11 memory orderings, which
411 must be compile-time constants.</p>
412 <p>Integer values for these computations and memory orderings are defined
413 in <code>&quot;llvm/IR/NaClAtomicIntrinsics.h&quot;</code>.</p>
414 <p>The <code>&#64;llvm.nacl.atomic.fence.all</code> intrinsic is equivalent to t he
415 <code>&#64;llvm.nacl.atomic.fence</code> intrinsic with sequentially consistent
416 ordering and compiler barriers preventing most non-atomic memory
417 accesses from reordering around it.</p>
418 <aside class="note">
419 <blockquote>
420 <div>These intrinsics allow PNaCl to support C11/C++11 style atomic
421 operations as well as some legacy GCC-style <code>__sync_*</code> builtins
422 while remaining stable as the LLVM codebase changes. The user isn&#8217;t
423 expected to use these intrinsics directly.</div></blockquote>
424
425 </aside>
426 <pre>
427 declare i1 &#64;llvm.nacl.atomic.is.lock.free(i32 &lt;byte_size&gt;, i8* &lt;a ddress&gt;)
428 </pre>
429 <p>The <code>llvm.nacl.atomic.is.lock.free</code> intrinsic is designed to
430 determine at translation time whether atomic operations of a certain
431 <code>byte_size</code> (a compile-time constant), at a particular <code>address< /code>,
432 are lock-free or not. This reflects the C11 <code>atomic_is_lock_free</code>
433 function from header <code>&lt;stdatomic.h&gt;</code> and the C++11 <code>is_loc k_free</code>
434 member function in header <code>&lt;atomic&gt;</code>. It can be used through th e
435 <code>__nacl_atomic_is_lock_free</code> builtin.</p>
436 </section></section></section>
437
438 {{/partials.standard_nacl_article}}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698