OLD | NEW |
1 {{+bindTo:partials.standard_nacl_article}} | 1 {{+bindTo:partials.standard_nacl_article}} |
2 | 2 |
3 <section id="pnacl-bitcode-reference-manual"> | 3 <section id="pnacl-bitcode-reference-manual"> |
4 <h1 id="pnacl-bitcode-reference-manual">PNaCl Bitcode Reference Manual</h1> | 4 <h1 id="pnacl-bitcode-reference-manual">PNaCl Bitcode Reference Manual</h1> |
5 <div class="contents local" id="contents" style="display: none"> | 5 <div class="contents local" id="contents" style="display: none"> |
6 <ul class="small-gap"> | 6 <ul class="small-gap"> |
7 <li><a class="reference internal" href="#introduction" id="id1">Introduction</a>
</li> | 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> | 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"> | 9 <ul class="small-gap"> |
10 <li><a class="reference internal" href="#data-model" id="id3">Data Model</a></li
> | 10 <li><a class="reference internal" href="#data-model" id="id3">Data Model</a></li
> |
(...skipping 18 matching lines...) Expand all Loading... |
29 <li><a class="reference internal" href="#undefined-values" id="id19">Undefined V
alues</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> | 30 <li><a class="reference internal" href="#constant-expressions" id="id20">Constan
t Expressions</a></li> |
31 </ul> | 31 </ul> |
32 </li> | 32 </li> |
33 <li><p class="first"><a class="reference internal" href="#other-values" id="id21
">Other Values</a></p> | 33 <li><p class="first"><a class="reference internal" href="#other-values" id="id21
">Other Values</a></p> |
34 <ul class="small-gap"> | 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> | 35 <li><a class="reference internal" href="#metadata-nodes-and-metadata-strings" id
="id22">Metadata Nodes and Metadata Strings</a></li> |
36 </ul> | 36 </ul> |
37 </li> | 37 </li> |
38 <li><a class="reference internal" href="#intrinsic-global-variables" id="id23">I
ntrinsic Global Variables</a></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> | 39 <li><a class="reference internal" href="#errno-and-errors-in-arithmetic-instruct
ions" id="id24">Errno and errors in arithmetic instructions</a></li> |
| 40 <li><p class="first"><a class="reference internal" href="#instruction-reference"
id="id25">Instruction Reference</a></p> |
40 <ul class="small-gap"> | 41 <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="#list-of-allowed-instructions" id="id26"
>List of allowed instructions</a></li> |
42 <li><a class="reference internal" href="#alloca" id="id26"><code>alloca</code></
a></li> | 43 <li><a class="reference internal" href="#alloca" id="id27"><code>alloca</code></
a></li> |
43 </ul> | 44 </ul> |
44 </li> | 45 </li> |
45 <li><p class="first"><a class="reference internal" href="#intrinsic-functions" i
d="id27">Intrinsic Functions</a></p> | 46 <li><p class="first"><a class="reference internal" href="#intrinsic-functions" i
d="id28">Intrinsic Functions</a></p> |
46 <ul class="small-gap"> | 47 <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="#list-of-allowed-intrinsics" id="id29">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="#thread-pointer-related-intrinsics" id="
id30">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="#setjmp-and-longjmp" id="id31">Setjmp an
d Longjmp</a></li> |
50 <li><a class="reference internal" href="#atomic-intrinsics" id="id31">Atomic int
rinsics</a></li> | 51 <li><a class="reference internal" href="#atomic-intrinsics" id="id32">Atomic int
rinsics</a></li> |
51 </ul> | 52 </ul> |
52 </li> | 53 </li> |
53 </ul> | 54 </ul> |
54 | 55 |
55 </div><section id="introduction"> | 56 </div><section id="introduction"> |
56 <h2 id="introduction">Introduction</h2> | 57 <h2 id="introduction">Introduction</h2> |
57 <p>This document is a reference manual for the PNaCl bitcode format. It describe
s | 58 <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 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 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 used to describe instructions and other bitcode constructs.</p> |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 <h3 id="metadata-nodes-and-metadata-strings">Metadata Nodes and Metadata Strings
</h3> | 217 <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><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 <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 part of the stable ABI. It exists for tool support and should not appear in |
220 distributed pexes.</p> | 221 distributed pexes.</p> |
221 <p>Other kinds of LLVM metadata are not supported.</p> | 222 <p>Other kinds of LLVM metadata are not supported.</p> |
222 </section></section><section id="intrinsic-global-variables"> | 223 </section></section><section id="intrinsic-global-variables"> |
223 <h2 id="intrinsic-global-variables">Intrinsic Global Variables</h2> | 224 <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><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 <p>PNaCl bitcode does not support intrinsic global variables.</p> |
| 227 </section><section id="errno-and-errors-in-arithmetic-instructions"> |
| 228 <span id="ir-and-errno"></span><h2 id="errno-and-errors-in-arithmetic-instructio
ns"><span id="ir-and-errno"></span>Errno and errors in arithmetic instructions</
h2> |
| 229 <p>Some arithmetic instructions and intrinsics have the similar semantics to |
| 230 libc math functions, but differ in the treatment of <code>errno</code>. While th
e |
| 231 libc functions may set <code>errno</code> for domain errors, the instructions an
d |
| 232 intrinsics do not. This is because the variable <code>errno</code> is not specia
l |
| 233 and is not required to be part of the program.</p> |
226 </section><section id="instruction-reference"> | 234 </section><section id="instruction-reference"> |
227 <h2 id="instruction-reference">Instruction Reference</h2> | 235 <h2 id="instruction-reference">Instruction Reference</h2> |
228 <section id="list-of-allowed-instructions"> | 236 <section id="list-of-allowed-instructions"> |
229 <h3 id="list-of-allowed-instructions">List of allowed instructions</h3> | 237 <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 | 238 <p>This is a list of LLVM instructions supported by PNaCl bitcode. Where |
231 applicable, PNaCl-specific restrictions are provided.</p> | 239 applicable, PNaCl-specific restrictions are provided.</p> |
232 <p>The following attributes are disallowed for all instructions:</p> | 240 <p>The following attributes are disallowed for all instructions:</p> |
233 <ul class="small-gap"> | 241 <ul class="small-gap"> |
234 <li><code>nsw</code> and <code>nuw</code></li> | 242 <li><code>nsw</code> and <code>nuw</code></li> |
235 <li><code>exact</code></li> | 243 <li><code>exact</code></li> |
(...skipping 11 matching lines...) Expand all Loading... |
247 <p>Integer division (<code>udiv</code>, <code>sdiv</code>, <code>urem</code>, <c
ode>srem</code>) by zero is | 255 <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> | 256 guaranteed to trap in PNaCl bitcode.</p> |
249 </li> | 257 </li> |
250 <li><code>and</code></li> | 258 <li><code>and</code></li> |
251 <li><code>or</code></li> | 259 <li><code>or</code></li> |
252 <li><code>xor</code></li> | 260 <li><code>xor</code></li> |
253 <li><code>fadd</code></li> | 261 <li><code>fadd</code></li> |
254 <li><code>fsub</code></li> | 262 <li><code>fsub</code></li> |
255 <li><code>fmul</code></li> | 263 <li><code>fmul</code></li> |
256 <li><code>fdiv</code></li> | 264 <li><code>fdiv</code></li> |
257 <li><code>frem</code></li> | 265 <li><p class="first"><code>frem</code></p> |
| 266 <p>The frem instruction has the semantics of the libc fmod function for |
| 267 computing the floating point remainder. If the numerator is infinity, or |
| 268 denominator is zero, or either are NaN, then the result is NaN. |
| 269 Unlike the libc fmod function, this does not set <code>errno</code> when the |
| 270 result is NaN (see the <a class="reference internal" href="#ir-and-errno"><em>in
structions and errno</em></a> |
| 271 section).</p> |
| 272 </li> |
258 <li><p class="first"><code>alloca</code></p> | 273 <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> | 274 <p>See <a class="reference internal" href="#bitcode-allocainst"><em>alloca instr
uctions</em></a>.</p> |
260 </li> | 275 </li> |
261 <li><p class="first"><code>load</code>, <code>store</code></p> | 276 <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 | 277 <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> | 278 <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 | 279 attributes are not supported. Loads and stores of the type <code>i1</code> are n
ot |
265 supported.</p> | 280 supported.</p> |
266 <p>These instructions must use <code>align 1</code> on integer memory accesses,
<code>align 4</code> | 281 <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> | 282 for <code>float</code> accesses and <code>align 8</code> for <code>double</code>
accesses.</p> |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 </li> | 333 </li> |
319 <li><code>llvm.ctlz</code></li> | 334 <li><code>llvm.ctlz</code></li> |
320 <li><code>llvm.cttz</code></li> | 335 <li><code>llvm.cttz</code></li> |
321 <li><p class="first"><code>llvm.ctpop</code></p> | 336 <li><p class="first"><code>llvm.ctpop</code></p> |
322 <p>The overloaded llvm.ctlz, llvm.cttz, and llvm.ctpop intrinsics are only | 337 <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 | 338 supported with the i32 and i64 argument types (the types supported by |
324 C-style GCC builtins).</p> | 339 C-style GCC builtins).</p> |
325 </li> | 340 </li> |
326 <li><p class="first"><code>llvm.sqrt</code></p> | 341 <li><p class="first"><code>llvm.sqrt</code></p> |
327 <p>The overloaded <code>llvm.sqrt</code> intrinsic is only supported for float | 342 <p>The overloaded <code>llvm.sqrt</code> intrinsic is only supported for float |
328 and double arguments types. Unlike the standard LLVM intrinsic, | 343 and double arguments types. This has the same semantics as the libc |
329 PNaCl guarantees that llvm.sqrt returns a QNaN for values less than -0.0.</p> | 344 sqrt function, returning NaN for values less than -0.0. However, this |
| 345 does not set <code>errno</code> when the result is NaN (see the |
| 346 <a class="reference internal" href="#ir-and-errno"><em>instructions and errno</e
m></a> section).</p> |
330 </li> | 347 </li> |
331 <li><code>llvm.stacksave</code></li> | 348 <li><code>llvm.stacksave</code></li> |
332 <li><p class="first"><code>llvm.stackrestore</code></p> | 349 <li><p class="first"><code>llvm.stackrestore</code></p> |
333 <p>These intrinsics are used to implement language features like scoped automati
c | 350 <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 | 351 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 | 352 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 | 353 argument to <code>llvm.stackrestore</code>, which restores the stack to the give
n |
337 state.</p> | 354 state.</p> |
338 </li> | 355 </li> |
339 <li><p class="first"><code>llvm.trap</code></p> | 356 <li><p class="first"><code>llvm.trap</code></p> |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 <p>The <code>llvm.nacl.atomic.is.lock.free</code> intrinsic is designed to | 446 <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 | 447 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>, | 448 <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> | 449 are lock-free or not. This reflects the C11 <code>atomic_is_lock_free</code> |
433 function from header <code><stdatomic.h></code> and the C++11 <code>is_loc
k_free</code> | 450 function from header <code><stdatomic.h></code> and the C++11 <code>is_loc
k_free</code> |
434 member function in header <code><atomic></code>. It can be used through th
e | 451 member function in header <code><atomic></code>. It can be used through th
e |
435 <code>__nacl_atomic_is_lock_free</code> builtin.</p> | 452 <code>__nacl_atomic_is_lock_free</code> builtin.</p> |
436 </section></section></section> | 453 </section></section></section> |
437 | 454 |
438 {{/partials.standard_nacl_article}} | 455 {{/partials.standard_nacl_article}} |
OLD | NEW |