Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 =================================== | |
| 2 PNaCl Bitcode File Reference Manual | |
| 3 =================================== | |
| 4 | |
| 5 .. contents:: | |
| 6 :local: | |
| 7 :backlinks: none | |
| 8 :depth: 3 | |
| 9 | |
| 10 | |
| 11 Introduction | |
| 12 ============ | |
| 13 | |
| 14 This document is a reference manual for the contents of PNaCl bitcode | |
|
Jim Stichnoth
2014/05/08 12:55:17
Formatting nit. Looks like your emacs fill column
Karl
2014/06/02 22:39:29
Done.
| |
| 15 files. It is presented using assembly language *PNaClAsm*. PNaClAsm | |
| 16 uses a *static single assignment* (SSA) model, based a representation | |
|
Jim Stichnoth
2014/05/08 12:55:17
This sentence doesn't parse. Do you mean somethin
Karl
2014/06/02 22:39:29
Done.
| |
| 17 that requires generated results to have a single (assignment) | |
| 18 source. PNaClAsm is the textual version of the bitcode file. | |
| 19 | |
| 20 PNaClAsm focusses on the semantic content of the file, not the | |
|
jvoung (off chromium)
2014/05/27 23:18:50
focuses
Karl
2014/06/02 22:39:29
Done.
| |
| 21 bit-encoding of that content. However, it does provide annotations | |
| 22 that allows one to specify how the PNaCl bitcode writer converts the | |
|
Jim Stichnoth
2014/05/08 12:55:17
allows --> allow
Karl
2014/06/02 22:39:29
Done.
| |
| 23 semantic content of a PNaClAsm program, into a specific bit sequence. | |
| 24 | |
| 25 Below PNaClAsm is the high-level form of the data stored in PNaCl | |
| 26 bitcode files. Each construct in PNaClAsm defines a corresponding | |
| 27 *PNaCl record* [ref]. A PNaCl bitcode file is simply a sequence of | |
| 28 PNaCl records. The goal of PNaClAsm is to make records easier to read, | |
| 29 and not to define a high-level user programming language. | |
| 30 | |
| 31 PNaCl records are an abstract encoding of structured data, similar | |
| 32 to XML. Like XML, PNaCl records have a notion of tags (i.e. the first | |
| 33 element in a record, called a *code*), and nested structures. The | |
| 34 nested structures are defined by corresponding *enter* and *exit* | |
| 35 block records. | |
| 36 | |
| 37 These block records must be used like parentheses to define the block | |
|
jvoung (off chromium)
2014/05/27 23:18:50
how about "like balanced parentheses" ?
Karl
2014/06/02 22:39:29
Done.
| |
| 38 structure that is imposed on top of records. Each exit record must be | |
| 39 preceded by a corresponding enter record. Blocks can be nested by | |
| 40 nesting enter/exit records appropriately. | |
| 41 | |
| 42 The *PNaCl bitcode wrtier* takes the sequence of records, defined by a | |
|
Jim Stichnoth
2014/05/08 12:55:17
writer
Karl
2014/06/02 22:39:29
Done.
| |
| 43 PNaClAsm program, and coverts each record into a (variable) sequence | |
|
Jim Stichnoth
2014/05/08 12:55:17
converts
Karl
2014/06/02 22:39:29
Done.
| |
| 44 of bits. The output of each bit sequence is appended together. The | |
| 45 resulting generated sequence of bits is the contents of the PNaCl | |
| 46 bitcode file. | |
| 47 | |
| 48 For every kind of record, there are default methods for converting | |
|
Jim Stichnoth
2014/05/08 12:55:17
"..., there is a default method ...", right?
Karl
2014/06/02 22:39:29
Done.
| |
| 49 records into bit sequences. These methods correspond to a notion of | |
| 50 *abbreviations* [ref]. Each abbreviation defines a specific bit | |
| 51 sequence conversion to be applied. The default conversion methods are | |
| 52 simply predefined abbreviations. | |
| 53 | |
| 54 The default abbreviations can be overriddeen with user-specified | |
|
binji
2014/05/02 18:04:52
overridden
Karl
2014/06/02 22:39:29
Done.
| |
| 55 abbrreviations. All user-specified abbreviations are included in the | |
|
binji
2014/05/02 18:04:52
abbreviations
Karl
2014/06/02 22:39:29
Done.
| |
| 56 generated bitcode file. Each abbreviation defines how records are | |
| 57 converted to bit sequences. The *PNaCl bitcode writer* uses these | |
| 58 abbreviations to convert the corresponding record sequence into a | |
| 59 corresponding bit sequence. As a result, all records have an | |
| 60 abbreviation (user or default) associated with them. | |
| 61 | |
| 62 The *PNaCl bitcode reader* then uses these abbreviations to convert | |
| 63 the bit sequences back into the corresponding records. | |
| 64 | |
| 65 Conceptually, abbreviations are used to define how to pack the | |
| 66 contents of records into bit sequenes. The main reason for defining | |
|
binji
2014/05/02 18:04:52
sequences
Karl
2014/06/02 22:39:29
Done.
| |
| 67 abbreviations is to save space. The default abbreviations are | |
| 68 simplistic and are intended to handle all possible records. The | |
| 69 default abbreviations do not really worry about being efficient, in | |
| 70 terms of the number of bits generated. | |
| 71 | |
| 72 By separating the concepts of PNaCl records and abbreviations, the | |
| 73 notion of data compression is cleanly seperated from semantic | |
|
binji
2014/05/02 18:04:52
separated
Karl
2014/06/02 22:39:29
Done.
| |
| 74 content. This allows different use cases to decide how much effort | |
| 75 should be spent on compressing records. | |
| 76 | |
| 77 For a JIT translator, little (if any) compression should be | |
|
Jim Stichnoth
2014/05/08 12:55:17
For PNaCl, we've been consistently using "translat
Karl
2014/06/02 22:39:29
Done.
| |
| 78 applied. In fact, the API to the JIT may just be the records | |
| 79 themselves. The goal of a JIT is to perform the final translation to | |
| 80 machine code as quickly as possible. On the other hand, when | |
| 81 delivering accross the web, one may want to compress the sequence of | |
|
binji
2014/05/02 18:04:52
across
Karl
2014/06/02 22:39:29
Done.
| |
| 82 bits considerably, to reduce costs in delivering web pages. | |
| 83 | |
| 84 High Level Basics | |
| 85 ================= | |
| 86 | |
| 87 A program is defined as a sequence of top-level Blocks. Blocks | |
| 88 can be nested within other blocks. Each *block* defines a sequence of | |
|
Jim Stichnoth
2014/05/08 12:55:17
Weird inconsistency involving capitalization and i
Karl
2014/06/02 22:39:29
Done.
| |
| 89 records. | |
| 90 | |
| 91 Most of the records, within a block, also define a unique values. | |
|
jvoung (off chromium)
2014/05/27 23:18:50
"define a unique values" -> "define unique values"
Karl
2014/06/02 22:39:29
Done.
| |
| 92 Each unique value is given a corresponding unique identifier | |
| 93 (i.e. *ID*). In PNaClAms. each kind of block defines it own kind of | |
|
binji
2014/05/02 18:04:52
PNaClAsm
Jim Stichnoth
2014/05/08 12:55:17
it --> its
Karl
2014/06/02 22:39:29
Done.
Karl
2014/06/02 22:39:29
Done.
| |
| 94 identifiers. The names of these identifiers are defined by | |
| 95 concatinating a prefix character ('@' or '%'), the kind of block (a | |
|
binji
2014/05/02 18:04:52
concatenating
Karl
2014/06/02 22:39:29
Done.
| |
| 96 single character), and a suffix index. The suffix index is defined by | |
| 97 the positional location of the defined value within the records of the | |
| 98 corresponding block. The indices are all zero based, meaning that the | |
| 99 first defined value (within a block) is defined using index 0. | |
| 100 | |
| 101 Identifiers are categorized into two types, *local* and | |
| 102 *global*. Local identifiers are identifiers that are associated with | |
| 103 the implementation of a single function. All other identifiers are | |
| 104 global. This split is intentional. Global identifiers are used by | |
| 105 multiple functions, and therefore must be unique accross all function | |
|
Jim Stichnoth
2014/05/08 12:55:17
across
Karl
2014/06/02 22:39:29
Done.
| |
| 106 implementations. Local identifiers only apply to a single function, | |
| 107 and can be reused between functions. The *PNaCl translator* uses this | |
| 108 separation to parallelize the compilation of functions. | |
| 109 | |
| 110 Global identifiers use the prefix character *'@'* while local | |
| 111 identifiers use the prefix character *'%'*. | |
| 112 | |
| 113 Note: There is one exception to this separation of local and global | |
|
jvoung (off chromium)
2014/05/27 23:18:50
How is this an exception?
For identifiers, locals
Karl
2014/06/02 22:39:29
I did not like the idea of adding abbreviation nam
| |
| 114 identifiers. Abbreviations can be defined locally and globally. An | |
| 115 abbreviation is local if it only applies to the block it appears | |
| 116 in. If it is global, the abberviation can apply to multiple block | |
|
binji
2014/05/02 18:04:52
abbreviation
Karl
2014/06/02 22:39:29
Done.
| |
| 117 instances. | |
| 118 | |
| 119 Note that by using positional location to define identifiers (within a | |
| 120 block), the values defined in PNaCl bitcode files need not be | |
| 121 explicitly included in the bitcode file. Rather, they are inferred by | |
| 122 the (ordered) position of the record in the block. This is also | |
| 123 intentional. It is used to reduce the amount of data that must be | |
| 124 (explicitly) passed to the PNaCl translator. | |
|
jvoung (off chromium)
2014/05/27 23:18:50
and downloaded through the internets ?
Karl
2014/06/02 22:39:29
Done.
| |
| 125 | |
| 126 In general, most of the records and blocks are assumed to be | |
| 127 topologically sorted, putting value definitions before thier uses. | |
|
binji
2014/05/02 18:04:52
their
Karl
2014/06/02 22:39:29
Done.
| |
| 128 This implies that records do not need to encode data if it can use the | |
| 129 corresponding information from it's uses. | |
|
Jim Stichnoth
2014/05/08 12:55:17
it's --> its
Also, there is an agreement problem,
Karl
2014/06/02 22:39:29
Done.
| |
| 130 | |
| 131 The most common use of this is that many instructions use the type of | |
| 132 their operands to determine the type of the instruction. Again, this | |
| 133 is intentional. It allows less information to be stored with the | |
| 134 instruction. | |
| 135 | |
| 136 However, For function blocks (which define instructions), no | |
|
Jim Stichnoth
2014/05/08 12:55:17
For --> for
Karl
2014/06/02 22:39:29
Done.
| |
| 137 topological sort exists. Loop carried value dependencies simply do not | |
| 138 allow topologically sorting. To deal with this, function blocks have a | |
| 139 notion of a forward (instruction value) declarations. These | |
|
Jim Stichnoth
2014/05/08 12:55:17
declarations --> declaration
Karl
2014/06/02 22:39:29
Done.
| |
| 140 decalrations must appear before any of the uses of that value, if the | |
|
binji
2014/05/02 18:04:52
declarations
Karl
2014/06/02 22:39:29
Done.
| |
| 141 (instruction) value is defined later in the function, than its first | |
|
Jim Stichnoth
2014/05/08 12:55:17
I would drop the comma.
Karl
2014/06/02 22:39:29
Done.
| |
| 142 use. | |
|
jvoung (off chromium)
2014/05/27 23:18:50
link to the special fwd ref record opcode?
Karl
2014/06/02 22:39:29
Done.
| |
| 143 | |
| 144 PNaCl Blocks | |
| 145 ============ | |
| 146 | |
| 147 Blocks are used to organize records in the bitcode file. The | |
| 148 kinds of blocks defined in PNaClAsm are: | |
| 149 | |
| 150 Types block | |
|
jvoung (off chromium)
2014/05/27 23:18:50
Is it worth splitting this into blocks that are ex
Karl
2014/06/02 22:39:29
Moved the module block first. Added clarifying par
| |
| 151 Defines the set of types used by the program. All types used in the | |
| 152 program must be defined in this block. | |
|
Jim Stichnoth
2014/05/08 12:55:17
Question. Since PNaCl bitcode types are limited t
jvoung (off chromium)
2014/05/27 23:18:50
Might be good to link to a section about the allow
Karl
2014/06/02 22:39:29
Good suggestion. done.
| |
| 153 | |
| 154 Globals block | |
| 155 Defines the set of global addresses of global variables and | |
| 156 constants, used by the program. It also defines how each global | |
|
jvoung (off chromium)
2014/05/27 23:18:50
I'm not a grammar expert, but you might not need t
Karl
2014/06/02 22:39:29
Done.
| |
| 157 (associated with the global address) is initialized. | |
| 158 | |
| 159 Valuesymtab block | |
| 160 Defines textual names for global and function addresses. | |
| 161 | |
| 162 Function block | |
| 163 Each function (implemented) in a program has it's own block that | |
|
Jim Stichnoth
2014/05/08 12:55:17
its
Karl
2014/06/02 22:39:29
Done.
| |
| 164 defines the implementation of the corresponding function. | |
| 165 | |
| 166 Constants Block | |
|
Jim Stichnoth
2014/05/08 12:55:17
Block --> block
Karl
2014/06/02 22:39:29
Done.
| |
| 167 Each implemented function, that uses constants in its | |
| 168 instructions, defines a constant block. Constants blocks appear | |
| 169 within corresponding function block. | |
|
Jim Stichnoth
2014/05/08 12:55:17
within the corresponding
Karl
2014/06/02 22:39:29
Done.
| |
| 170 | |
| 171 Modue block | |
|
binji
2014/05/02 18:04:52
Module
Karl
2014/06/02 22:39:29
Done.
| |
| 172 A top-level block defining the program. This block defines global | |
| 173 information used by the program, followed by function blocks | |
| 174 defining the implementation of functions within the program. | |
| 175 | |
| 176 Abbreviations block | |
| 177 Defines abbreviations that are used to compress PNaCl records. This | |
|
jvoung (off chromium)
2014/05/27 23:18:50
The "Abbreviations block" formerly known as the "B
Karl
2014/06/02 22:39:29
From what I can tell, the "block info block" of ll
| |
| 178 block is segmented into multiple sections, one section for each kind | |
| 179 of block. This block is optional and need not be defined. | |
| 180 | |
| 181 A PNaCl program consists of a header record, an optional abbreviations | |
| 182 block, and a module block. | |
|
jvoung (off chromium)
2014/05/27 23:18:50
Is it worth mentioning that in the next couple of
Karl
2014/06/02 22:39:29
Added an initial paragraph (after the block list)
| |
| 183 | |
| 184 Each block, within a bitcode file, defines values. These values are | |
| 185 associated with IDs. Each type of block defines different kinds of | |
| 186 IDs. | |
| 187 | |
|
jvoung (off chromium)
2014/05/27 23:18:50
How does this look in the html? Should there be a
Karl
2014/06/02 22:39:29
What I may agree on is that I am probably introduc
| |
| 188 The *types block* [ref] defines types used by the program. Each record | |
| 189 in the types block defines a separate type. Valid types include | |
| 190 various sizes of integer and floating types. They also define higher | |
| 191 level constructs such as vectors and function signatures. For each | |
| 192 definition, a type ID is defined. A type ID is of the form *@tN*, | |
| 193 where *N* corresponds to the (relative) position of the corresponding | |
| 194 defining record in the types block. | |
| 195 | |
| 196 The types block must appear within the module block, | |
| 197 and must appear before any block that uses a typed value. Many | |
| 198 PNaClAsm constructs allows one to use explicit type names, rather than | |
|
Jim Stichnoth
2014/05/08 12:55:17
allow
Karl
2014/06/02 22:39:29
Done.
| |
| 199 type IDs. However, they are internally converted to the corresponding | |
| 200 type ID in the types block. Hence, the requirement that the types | |
| 201 block must appear early in the module block. | |
| 202 | |
| 203 The *module block* [ref] contains all other blocks (except for the | |
| 204 abbreviations block, which can either appear within the module block, | |
| 205 or immediately before the module block). The only values defined in a | |
| 206 module block are function addresses. All remaining definitions appear | |
|
jvoung (off chromium)
2014/05/27 23:18:50
function address / declarations ? Is it worth usin
Karl
2014/06/02 22:39:29
Removed this, as part of the removal of the deep d
| |
| 207 within blocks of the module block. | |
| 208 | |
| 209 Function addresses are global IDs of the form *@fN*, where *N* | |
| 210 corresponds to the position of the corresponding function address | |
| 211 record in the module block. Function addresses must appear after the | |
| 212 types block. | |
| 213 | |
| 214 The *globals block* [ref] defines global addresses for global variables | |
| 215 and constants, used in the program. This block not only defines the | |
| 216 addresses, but the size of the corresponding memory associated with | |
|
Jim Stichnoth
2014/05/08 12:55:17
This block defines not only the addresses, but als
Karl
2014/06/02 22:39:29
Done.
| |
| 217 these addresses, and how the memory should be initialized. | |
| 218 | |
| 219 The globals block must appear in the module block, and after all | |
| 220 function address records. Global addresses (defined by the globals | |
| 221 block) are of the form *@gN*, where *N* is the (relative) position of | |
| 222 the corresponding defining records. | |
| 223 | |
| 224 The *valuesymtab block* [ref] does not define any values. Rather, its | |
| 225 only goal is to associate text names with previously defined global | |
| 226 addresses (i.e. function, constant, and variable). Each association | |
| 227 is defined by a record in the Valuesymtab block. Currently, only | |
|
Jim Stichnoth
2014/05/08 12:55:17
Valuesymtab --> valuesymtab
Karl
2014/06/02 22:39:29
Done.
| |
| 228 *intrinsic* [ref] function addresses need a name. All other entries in | |
| 229 this block are considered as a hint for debugging. The PNaCl | |
| 230 translator may (or may not) pass these names to the running | |
| 231 executable, allowing the (runtime) debugger to associate names with | |
| 232 addresses. | |
| 233 | |
| 234 Each *function block* [ref] defines the implementation of a single | |
| 235 function. Each function block defines the control-flow graph of the | |
|
Jim Stichnoth
2014/05/08 12:55:17
Usually "control flow graph" just refers to the ba
Karl
2014/06/02 22:39:29
Simplified paragraph, and introduced notion of int
| |
| 236 function, which consists of basic blocks and instructions. If | |
| 237 constants are used within instructions, they are defined in a | |
| 238 *constants block*, nested within the corresponding function block. | |
| 239 | |
| 240 All function blocks are associated with a corresponding function | |
| 241 address. This association is (again) positional rather than | |
| 242 explicit. That is, the Nth function block in a module block | |
| 243 corresponds to the Nth defining function address record in the | |
| 244 module block. | |
| 245 | |
| 246 Hence, within a function block, there is no explicit reference to the | |
| 247 function address the block defines. For readability, PNaClAsm uses the | |
| 248 corresponding function heading, associated with the corresponding | |
| 249 function address record, even though that data does not appear in the | |
| 250 corresponding records. | |
| 251 | |
| 252 Unlike other blocks, a function block defines multiple kinds of | |
| 253 values: parameter, basic block, and instruction. Parameter IDs (in | |
| 254 PNaClAsm) are identified using local IDs of the form *%pN*. Basic | |
| 255 block IDs are identified using local IDs of the form | |
| 256 *%bN*. Instructions that generate values are identified using local | |
| 257 IDs of the form *%vN*. | |
| 258 | |
| 259 Hence, *%pN* denotes the Nth parameter of the function. *%bN* denotes | |
| 260 the *Nth* basic block within the function. *%vN* denotes the value | |
| 261 generated by the *Nth* instruction that generates a value. Note: *%vN* | |
| 262 does not necessarily refer to the *Nth* instruction in the function | |
| 263 block, because not all instructions generate values. | |
| 264 | |
| 265 Within a function block, basic blocks are not explicitly defined in | |
| 266 the PNaCl records of a function block. Rather, the first record of the | |
| 267 block identifies how many basic blocks appear in the control flow | |
| 268 graph of the function. This record is then followed by a sequence of | |
| 269 records, each record defining a single instruction. Special | |
| 270 *terminating* [ref] (i.e. branch) instructions are used to determine | |
|
Jim Stichnoth
2014/05/08 12:55:17
i.e. --> e.g.
Karl
2014/06/02 22:39:29
Done.
| |
| 271 block boundaries. | |
| 272 | |
| 273 Each *constants block* [ref] defines constants that are used by the | |
| 274 enclosing function block. The purpose of the constant block is to | |
|
Jim Stichnoth
2014/05/08 12:55:17
constant --> constants
Karl
2014/06/02 22:39:29
Done.
| |
| 275 merge all uses of a constant (within a function) into a single | |
| 276 defining ID. Constant IDs are of the form *%cN*, where *N* | |
| 277 corresponds to the (relative) position of constant defined in the | |
|
Jim Stichnoth
2014/05/08 12:55:17
of --> of the
Karl
2014/06/02 22:39:29
Done.
| |
| 278 corresponding constants block. The constants block must appear before | |
| 279 any instruction. | |
| 280 | |
| 281 The *abbreviations block* [ref] is optional. If it is included, it is | |
| 282 divided into sections. Each section is a sequence of records. Each | |
| 283 record in the sequence defines a user-defined abbreviation. Each | |
| 284 section defines abbreviations that can be applied to all (succeeding) | |
| 285 blocks of a particular kind. These abbreviations ares denoted by the | |
|
Jim Stichnoth
2014/05/08 12:55:17
are
Karl
2014/06/02 22:39:29
Done.
| |
| 286 (global) ID of the form *@aN*. | |
| 287 | |
| 288 PNaCl Records | |
| 289 ============= | |
| 290 | |
| 291 A PNaCl record is a non-empty sequence of unsigned, 64-bit, | |
| 292 integers. A record is identified by the record *code*, which is the | |
| 293 first element in the sequence. Record codes are unique within a | |
| 294 specific kind of block, but are not necessarily unique accross | |
|
binji
2014/05/02 18:04:52
across
Karl
2014/06/02 22:39:29
Done.
| |
| 295 different kinds of blocks. The record code acts as the variant | |
| 296 descriminator (i.e. tag) within a block, to identify what type of | |
|
binji
2014/05/02 18:04:52
discriminator
Karl
2014/06/02 22:39:29
Done.
| |
| 297 record it is. | |
| 298 | |
| 299 Record codes are typically small numbers. In an ideal world, they | |
| 300 would be a consecutive sequence of integers, starting at | |
| 301 zero. However, the reality is that PNaCl records evolved over time | |
| 302 (and actually started as LLVM records[ref]). For backwards | |
|
Jim Stichnoth
2014/05/08 12:55:17
space before [ref] for consistency? (This is the
Karl
2014/06/02 22:39:29
Done.
| |
| 303 compatability, old numbers have not been reused, leaving gaps in the | |
|
binji
2014/05/02 18:04:52
compatibility
Karl
2014/06/02 22:39:29
Done.
| |
| 304 actual record code values used. | |
| 305 | |
| 306 The exception of using small numbers for record codes, are four | |
| 307 special kinds of records. What makes these four kinds of records | |
| 308 special is that they either apply in multiple blocks, or don't occur | |
|
jvoung (off chromium)
2014/05/27 23:18:50
How about these record codes as being "global", in
Karl
2014/06/02 22:39:29
I like the concept of local/global record codes.
| |
| 309 in any block. To make these cases clear, and to leave room for lots of | |
| 310 future growth in PNaClAsm, these special records have record codes | |
|
Jim Stichnoth
2014/05/08 12:55:17
hmm, are we expecting lots of future growth in our
Karl
2014/06/02 22:39:29
This gap is intentional to make them clearly disti
| |
| 311 close to value 2**16. Note: Well-formed PNaCl bitcode files do not | |
|
Jim Stichnoth
2014/05/08 12:55:17
to the value
Karl
2014/06/02 22:39:29
Done.
| |
| 312 have record codes >= 2**16. | |
| 313 | |
| 314 A PNaCl record is denoted as follows: | |
| 315 | |
| 316 .. naclcode:: | |
| 317 | |
| 318 <v1, v2, ... , vN> | |
| 319 | |
| 320 The value *v1* is the record code. The remaining values, *v2* through | |
| 321 *vN*, are parameters that fill in additional information needed by the | |
| 322 construct it represents. All records must hava record code. Hence, | |
|
binji
2014/05/02 18:04:52
have a
Karl
2014/06/02 22:39:29
Done.
| |
| 323 empty PNaCl records are not allowed. | |
| 324 | |
| 325 While most records (for a given record code) are of the same length, | |
| 326 it is not true of all record codes. Some record codes, such as the | |
| 327 records for the call instruction, can have arbitrary length. | |
|
Jim Stichnoth
2014/05/08 12:55:17
Are there any variable-length records besides call
Karl
2014/06/02 22:39:29
Enumerated the cases out.
| |
| 328 | |
| 329 In PNaClAsm, if the record is converted to a bit sequence using the | |
| 330 default abbreviation, no additional notation is used. Otherwise, the | |
|
jvoung (off chromium)
2014/05/27 23:18:50
That's not true, right? pnacl-objdump currently pr
Karl
2014/06/02 22:39:29
Yes, I am talking about the text form. I did notic
| |
| 331 record is prefixed with the the abbreviation ID *I* to use (wrt the | |
|
binji
2014/05/02 18:04:52
s/the //
Jim Stichnoth
2014/05/08 12:55:17
please spell out "with respect to"
Karl
2014/06/02 22:39:29
Removed the clause, since it didn't really provide
| |
| 332 block it appears in) as follows: | |
| 333 | |
| 334 .. naclcode:: | |
| 335 | |
| 336 I: <v1, v2, ... , vN> | |
| 337 | |
| 338 The PNaCl bitcode writer, which converts records to bit sequences, | |
| 339 does this by writing out the abbreviation index used to encode the | |
| 340 record, followed by the contents of the PNaCl record. The details of | |
| 341 this are left to section on abbreviations[ref]. However, at the PNaCL | |
|
binji
2014/05/02 18:04:52
PNaCl
Karl
2014/06/02 22:39:29
Done.
| |
| 342 record level, one important aspect of this appears in block enter | |
| 343 records. These records must define how many bits are required to hold | |
| 344 abbreviation indices associated with records of that block. | |
| 345 | |
| 346 There are 4 predefined (default) abbreviation indices, used as the | |
| 347 default abbreviations for PNaCl records. A block may (in addition), | |
| 348 define a list of block specific, user-defined, abbreviations (of | |
| 349 length *U&). The number of bits *B* specified for an enter | |
|
Jim Stichnoth
2014/05/08 12:55:17
*U& --> *U*
Karl
2014/06/02 22:39:29
Done.
| |
| 350 record must be sufficiently large such that | |
| 351 | |
| 352 .. naclcode:: | |
| 353 | |
| 354 2**B >= U + 4 | |
| 355 | |
| 356 In addition, the upper limit for B is 32. | |
| 357 | |
| 358 Like much of PNaClAsm, PNaClAsm requires that you specify sizes | |
|
Jim Stichnoth
2014/05/08 12:55:17
"Like much of PNaClAsm, PNaClAsm requires ..." sou
Karl
2014/06/02 22:39:29
Rewrote this paragraph.
| |
| 359 (associated with a block) up front so that the PNaCl bitcode | |
| 360 reader/writer can determine how to encode abbreviation indices. Hence, | |
| 361 within an enter block record, you must specify how bits will be used | |
|
Jim Stichnoth
2014/05/08 12:55:17
This seems to be the only paragraph written in the
Karl
2014/06/02 22:39:29
Done.
Jim Stichnoth
2014/06/06 18:24:46
There's still one more use of the second person at
| |
| 362 to hold abbreviation indexes. | |
|
Jim Stichnoth
2014/05/08 12:55:17
indices, since you use that everywhere else
Karl
2014/06/02 22:39:29
Done.
| |
| 363 | |
| 364 Conventions for describing records | |
| 365 ================================== | |
| 366 | |
| 367 The PNaClAsm assembler can be viewed as a parser of PNaCl records. The | |
|
Jim Stichnoth
2014/05/08 12:55:17
Remove the last "The".
jvoung (off chromium)
2014/05/27 23:18:50
Were you still planning on writing the assembler,
Karl
2014/06/02 22:39:29
Done.
| |
| 368 Each PNaCl record is described by a corresponding PNaClAsm | |
| 369 construct. These constructs are described using syntax rules, and | |
| 370 semantics on how they are converted to records. The parser also has | |
| 371 state, that is updated after the instruction is parsed. These state | |
| 372 updates are part of the sementics of the corresponding record | |
|
binji
2014/05/02 18:04:52
semantics
Karl
2014/06/02 22:39:29
Done.
| |
| 373 construct. | |
| 374 | |
| 375 For each PNaCl construct, we define multiple subsections. The **Syntax** | |
| 376 subsection defines a syntax rule for the construct. The **Record** | |
| 377 subsection defines the corresponding record associated with the syntax | |
| 378 rule. The **Semantics** subsection describes the semantics | |
| 379 associated with the record, in terms of data within the parse state | |
| 380 and the corresponding syntax. | |
|
jvoung (off chromium)
2014/05/27 23:18:50
Clarify where other high-level semantics will be d
Karl
2014/06/02 22:39:29
Added sentence to clarify this?
That is, addition
| |
| 381 | |
| 382 The **Constraints** subsection (if present) defines any constraints | |
| 383 associated with the construct. The **Updates** subsection (if present) | |
| 384 defines how the parse state is updated when the construct is parsed. | |
| 385 The **Examples** subsection gives one (or more) examples of using the | |
| 386 corresponding PNaClAsm construct. | |
| 387 | |
| 388 Some semantics subsections use functions to compute values. The | |
| 389 meaning of functions can be found in *Support Functions* [ref]. | |
| 390 | |
| 391 Within a syntax rule, there may specifications about abbreviations. | |
| 392 These abbreviation specifications, if allowed, are at the end of the | |
| 393 construct, and enclosed in *<* and *>* bracket. These abbreviation | |
| 394 specifications are optional in the syntax, and can be omitted. If they | |
| 395 are used, the abbreviation brackets are part of the actual syntax of | |
| 396 the construct. To make it clear that abbreviation specifications are | |
| 397 optional, syntax rules separate abbreviation specifications using | |
| 398 plenty of whitespace. | |
| 399 | |
| 400 Abbreviation specifications consist of user-defined abbreviations, | |
| 401 abbreviation identifiers, and the number of bits required to repressent | |
|
binji
2014/05/02 18:04:52
represent
Karl
2014/06/02 22:39:29
Done.
| |
| 402 abbreviations in a block. These notations appear, as appropriate, in | |
| 403 the corresponding syntax rules. | |
| 404 | |
| 405 The most common abbreviation syntax is the corresponding abbreviation | |
| 406 identifier to use to read/write the corresponding record. In such | |
| 407 cases, if the specified abbreviation identifier is omitted, the | |
| 408 corresponding default abbreviation will be used by the PNaCl | |
| 409 reader/writer. | |
| 410 | |
| 411 Also, within PNaClAsm, all alphabetic characters are lower case unless | |
| 412 they appear within a literal value. Hence, if we mix lower and upper | |
| 413 case letters within a name appearing in a syntax rule, the lower case | |
| 414 letters are literal while the upper case sequence of letters denote | |
| 415 (rule specific) values. If an upper case sequence of letters is | |
| 416 followed by digits, the corresponding embedded name includes both the | |
| 417 upper case letters and the digits. The valid values for each of these | |
| 418 names will be defined in the corresponding semantics subsection. | |
| 419 | |
| 420 For example, consider the following syntax rule: | |
| 421 | |
| 422 .. naclcode:: | |
| 423 | |
| 424 %vN = add T O1, O2; <A> | |
| 425 | |
| 426 This rule defines a PNaClAsm add instruction. This construct defines | |
| 427 an instruction that adds to two values (*O1* and *O2*) to generate | |
|
jvoung (off chromium)
2014/05/27 23:18:50
"adds to two values" -> "adds two values" ?
Karl
2014/06/02 22:39:29
Done.
| |
| 428 instruction value *%vN*. The types of the arguments, and the result, | |
| 429 are all of type *T*. Since abbreviation ID *A* is present, the | |
|
jvoung (off chromium)
2014/05/27 23:18:50
extra space
Karl
2014/06/02 22:39:29
Done.
| |
| 430 record is encoded using that abbreviation. | |
| 431 | |
| 432 To be concrete, the syntactic rule above defines the structure of the | |
| 433 following PNaClAsm examples. | |
| 434 | |
| 435 .. naclcode:: | |
| 436 | |
| 437 %v10 = add i32 %v1, %v2; <@a5> | |
| 438 %v11 = add i32 %v10, %v3; | |
| 439 | |
| 440 In addition to specifying the syntax, each syntax rule also specifies | |
| 441 the contents of the corresponding record in the corresponding record | |
| 442 subsection. In simple cases, the elements of the corresponding record | |
| 443 are predefined (literal) constants. Otherwise the record element is a | |
| 444 name that is defined by the other subsections associated with the | |
| 445 construct. | |
| 446 | |
| 447 Parse State | |
| 448 =========== | |
| 449 | |
| 450 This section describes the parse state of the PNaClAsm assembler. It | |
| 451 is used to define contextual data that is carried between records. The | |
| 452 following subsections describes each element of the parse state. | |
|
Jim Stichnoth
2014/05/08 12:55:17
describe
Karl
2014/06/02 22:39:29
Done.
| |
| 453 | |
| 454 Typing | |
| 455 ------ | |
| 456 | |
| 457 Associated with most identifiers is a type. This type defines what | |
| 458 type the corresponding value has. It is defined by the (initially | |
| 459 empty) map | |
| 460 | |
| 461 .. naclcode:: | |
| 462 | |
| 463 TypeOf: ID -> Type | |
| 464 | |
| 465 For each type in the *types block* [ref], a corresponding inverse map | |
| 466 | |
| 467 .. naclcode:: | |
| 468 | |
| 469 TypeID: Type -> ID | |
| 470 | |
| 471 is maintained to convert syntactic types to the corresponding type ID. | |
| 472 Note: This document assumes that map *TypeID* is automatically | |
| 473 maintained during updates to map *TypeOf* (when given a type | |
| 474 ID). Hence, *updates* subsections will not contain assignments to this | |
| 475 map. | |
| 476 | |
| 477 Associated with each function identifier is it's type signature. This | |
|
Jim Stichnoth
2014/05/08 12:55:17
its
Karl
2014/06/02 22:39:29
Done.
| |
| 478 is different than the type of the function identifer, since function | |
|
binji
2014/05/02 18:04:52
identifier
Karl
2014/06/02 22:39:29
Done.
| |
| 479 identifiers are pointers (and always implemented as a 32-bit integer). | |
| 480 | |
| 481 Function type signatures are maintained using: | |
| 482 | |
| 483 .. naclcode:: | |
| 484 | |
| 485 TypeOfFcn: ID -> Type | |
| 486 | |
| 487 In addition, if a function address is defining, there is a corresponding | |
|
Jim Stichnoth
2014/05/08 12:55:17
is defined? is being defined?
Karl
2014/06/02 22:39:29
Rewrote to clarify it has an implementing block.
| |
| 488 implementation associated with the function address. To capture this association , | |
|
Jim Stichnoth
2014/05/08 12:55:17
80-col
Karl
2014/06/02 22:39:29
Done.
| |
| 489 we use the set: | |
| 490 | |
| 491 .. naclcode:: | |
| 492 | |
| 493 DefiningFcnIDs: set(ID) | |
| 494 | |
| 495 ID Counters | |
| 496 ----------- | |
| 497 | |
| 498 Each block defines one (or more) kinds of values. Value indices are | |
| 499 generated sequentially, starting at zero. To capture this, the | |
| 500 following counters are defined: | |
| 501 | |
| 502 NumTypes | |
| 503 The number of types defined so far (in the types block) | |
| 504 | |
| 505 NumFuncAddresses | |
| 506 The number of function addresses defined so far (in the module | |
| 507 block). | |
| 508 | |
| 509 NumDefinedFcnAddresses | |
| 510 The number of defining function addresses defined so far (in the | |
| 511 module block). | |
| 512 | |
| 513 NumFuncImpls | |
| 514 The number of implemented functions defined so far (in the module block). | |
| 515 | |
| 516 NumGlobalAddresses | |
| 517 The number of global variable/constant addresses defined so far (in | |
| 518 the globals block). | |
| 519 | |
| 520 NumParams | |
| 521 The number of parameters defined for a function. | |
| 522 | |
| 523 NumFcnConsts | |
| 524 The number of constants defined in a fucntion. | |
|
binji
2014/05/02 18:04:52
function
Karl
2014/06/02 22:39:29
Done.
| |
| 525 | |
| 526 NumBasicBlocks | |
| 527 The number of basic blocks defined so far (within a function block). | |
| 528 | |
| 529 NumValuedInsts | |
| 530 The number of instructions, generating values, defined so far | |
| 531 (within a function block). | |
| 532 | |
| 533 Size Variables | |
| 534 -------------- | |
| 535 | |
| 536 A number of blocks define expected sizes of constructs. These sizes are recorded | |
| 537 in the following size variables: | |
| 538 | |
| 539 ExpectedBasicBlocks | |
| 540 The expected number of basic blocks within a function | |
| 541 implementation. | |
| 542 | |
| 543 ExpectTypes | |
| 544 The expected number of types defined in the Types Block. | |
|
Jim Stichnoth
2014/05/08 12:55:17
Types Block --> types block
Karl
2014/06/02 22:39:29
Done.
| |
| 545 | |
| 546 ExpectedGlobals | |
| 547 The expected number of global variable/constant addresses in the | |
| 548 globals block. | |
| 549 | |
| 550 ExpectedInitializers | |
| 551 The expected number of initializers for a global variable/constant | |
| 552 address in the globals block. | |
| 553 | |
| 554 Other Variables | |
| 555 --------------- | |
| 556 | |
| 557 EnclosingFcnID | |
| 558 The function ID of the function block being processed. | |
| 559 | |
| 560 Special records | |
| 561 =============== | |
| 562 | |
| 563 There are four special PNaCl records, each having their own record | |
|
Jim Stichnoth
2014/05/08 12:55:17
their --> its
Karl
2014/06/02 22:39:29
Done.
| |
| 564 code. These special records are: | |
| 565 | |
| 566 Header | |
| 567 The header record is the first record of a PNaCl bitcode file, and | |
| 568 identifies the file's magic number, as well as the bitcode version it | |
| 569 uses. The record defines the sequence of bytes that make up the | |
| 570 header and uniquely identifies the file as a PNaCl bitcode file. | |
| 571 | |
| 572 Enter | |
| 573 An enter record defines the beginning of a block. Since blocks | |
| 574 can be nested, it can appear inside other blocks, as well as at the | |
|
Jim Stichnoth
2014/05/08 12:55:17
it --> one
Karl
2014/06/02 22:39:29
Done.
| |
| 575 top level. | |
| 576 | |
| 577 Exit | |
| 578 An exit record defines the end of a block. Hence, it must appear in | |
| 579 every block, to end the block. | |
| 580 | |
| 581 Addreviation | |
|
Jim Stichnoth
2014/05/08 12:55:17
Abbreviation
Karl
2014/06/02 22:39:29
Done.
| |
| 582 An abbreviation record defines a user-defined abbreviation to be | |
| 583 applied to records within blocks. Abbreviation records appearing in | |
| 584 the abbreviations block define global abbreviations. All other | |
| 585 abbreviations are local to the block they appear in, and can only be | |
| 586 used in that block. | |
| 587 | |
| 588 All special records can't have user-defined abbreviations associated | |
| 589 with them. The default abbreviation is always used. | |
| 590 | |
| 591 The following subsections define valid special records, other than abbreviation | |
| 592 records. Abbreviation records are described in the Abbreviations[ref] section. | |
| 593 | |
| 594 Header Record | |
| 595 ------------- | |
| 596 | |
| 597 The header record must be the first record in the file. It is the only | |
| 598 record in the bitcode file that doesn't have a corresponding construct | |
| 599 in PNaClAsm. Rather, the PNaClAsm assembler always automatically | |
| 600 inserts this record as the first record of the PNaCl bitcode file. | |
| 601 | |
| 602 **Syntax** | |
| 603 | |
| 604 There is no syntax for header records in PNaClAsm. They are | |
| 605 automatically inserted by the PNaCl bitcode writer. | |
| 606 | |
| 607 **Record** | |
| 608 | |
| 609 .. naclcode:: | |
| 610 | |
| 611 <66532, 80, 69, 88, 69, 1, 0, 8, 0, 17, 0, 4, 0, 2, 0, 0, 0> | |
| 612 | |
| 613 **Semantics** | |
| 614 | |
| 615 The header record defines the initial sequence of bytes that must | |
| 616 appear at the beginning of all (PNaCl bitcode version 2) files. That | |
| 617 sequence is the list of bytes inside the record (excluding the record | |
| 618 code). As such, it uniquely identifies PNaCl bitcode files. | |
| 619 | |
| 620 **Examples** | |
| 621 | |
| 622 There are no examples for the header record, since it is not part of | |
| 623 PNaClAsm. | |
| 624 | |
| 625 Enter Block Record | |
| 626 ------------------ | |
| 627 | |
| 628 Block records can be top-level, as well as nested in other | |
| 629 blocks. Blocks must begin with an *enter* record, and end with | |
| 630 an *exit* record. | |
| 631 | |
| 632 **Syntax** | |
| 633 | |
| 634 .. naclcode:: | |
| 635 | |
| 636 N { <B> | |
| 637 | |
| 638 **Record** | |
| 639 | |
| 640 .. naclcode:: | |
| 641 | |
| 642 <655335, BlockID, B> | |
|
Jim Stichnoth
2014/05/08 12:55:17
Are these values 655335 and 655334 correct? They
Karl
2014/06/02 22:39:29
Hmm. Don't know what happened here. Fixing.
| |
| 643 | |
| 644 **Semantics** | |
| 645 | |
| 646 Enter block records define the beginning of a block. *B*, if present, | |
| 647 is the number of bits needed to represent all possible abbreviation | |
| 648 indices used within the block. If omitted, B=2 is always assumed. | |
| 649 | |
| 650 The *BlockID* value is dependent on the name *N*. Valid names and | |
| 651 corresponding *BlockID* values are defined as follows: | |
| 652 | |
| 653 ============= ======= | |
| 654 Name BlockID | |
| 655 ============= ======= | |
| 656 abbreviations 0 | |
| 657 constants 11 | |
| 658 function 12 | |
| 659 globals 19 | |
| 660 module 8 | |
| 661 types 17 | |
| 662 valuesymtab 14 | |
| 663 ============= ======= | |
| 664 | |
| 665 Note: For readability, PNaClAsm allows a more readable form of a | |
| 666 function block enter record. See *function blocks* [ref] for more | |
| 667 details. | |
| 668 | |
| 669 **Examples** | |
| 670 | |
| 671 .. naclcode:: | |
| 672 | |
| 673 module { | |
| 674 types { | |
| 675 count: 0; | |
| 676 } | |
| 677 globals { | |
| 678 count: 0; | |
| 679 } | |
| 680 } | |
| 681 | |
| 682 This example defines a module, types, and globals block. Both the type | |
| 683 and the modules block appears within the module block. | |
|
Jim Stichnoth
2014/05/08 12:55:17
modules block --> module block
Jim Stichnoth
2014/05/08 12:55:17
appears --> appear
Karl
2014/06/02 22:39:29
Done.
Karl
2014/06/02 22:39:29
Done.
| |
| 684 | |
| 685 The corresponding records are: | |
| 686 | |
| 687 .. naclcode:: | |
| 688 | |
| 689 <655335, 8, 2> | |
| 690 <655335, 17, 2> | |
| 691 <1, 0> | |
| 692 <655334> | |
| 693 <655335, 19, 2> | |
| 694 <5, 0> | |
| 695 <655334> | |
| 696 <655334> | |
| 697 | |
| 698 | |
| 699 Exit Block Record | |
| 700 ----------------- | |
| 701 | |
| 702 Block records can be top-level, as well as nested, records. Blocks must begin | |
| 703 with an *enter* record, and end with an *exit* record. | |
| 704 | |
| 705 **Syntax** | |
| 706 | |
| 707 .. naclcode:: | |
| 708 | |
| 709 } | |
| 710 | |
| 711 **Record** | |
| 712 | |
| 713 .. naclcode:: | |
| 714 | |
| 715 <65536> | |
| 716 | |
| 717 **Semantics** | |
| 718 | |
| 719 All exit records are identical, no matter what block they are ending. An | |
| 720 exit record defines the end of the block. | |
| 721 | |
| 722 **Examples** | |
| 723 | |
| 724 .. naclcode:: | |
| 725 | |
| 726 module { | |
| 727 types { | |
| 728 count: 0; | |
| 729 } | |
| 730 globals { | |
| 731 count: 0; | |
| 732 } | |
| 733 } | |
| 734 | |
| 735 This example defines a module, types, and globals block. Both the type | |
| 736 and the modules block appears within the module block. | |
|
Jim Stichnoth
2014/05/08 12:55:17
modules block --> module block
Jim Stichnoth
2014/05/08 12:55:17
appears --> appear
Karl
2014/06/02 22:39:29
Actually, I was using the names defined earlier. H
Karl
2014/06/02 22:39:29
Done.
| |
| 737 | |
| 738 The corresponding records are: | |
| 739 | |
| 740 .. naclcode:: | |
| 741 | |
| 742 <655335, 8, 2> | |
| 743 <655335, 17, 2> | |
| 744 <1, 0> | |
| 745 <655334> | |
| 746 <655335, 19, 2> | |
| 747 <5, 0> | |
| 748 <655334> | |
| 749 <655334> | |
| 750 | |
| 751 Types Block | |
| 752 =========== | |
| 753 | |
| 754 The types block defines all types used in a program. It must appear in | |
| 755 the module block, before any function address records, the globals | |
| 756 block, the valuesymtab block, and any function blocks. | |
| 757 | |
| 758 Each record in the types block defines a type used by the program. | |
| 759 Types can be broken into the following groups: | |
| 760 | |
| 761 | |
| 762 Primitive types | |
| 763 Defines the set of base types for values. This includes various | |
| 764 sizes of integral and floating types, as well as vector types. | |
| 765 | |
| 766 Void type | |
| 767 A primitive type that doesn't represent any value and has no size. | |
| 768 | |
| 769 Function types | |
| 770 The type signatures of functions. | |
| 771 | |
| 772 Vector type | |
| 773 Defines vectors of primitive types. | |
| 774 | |
| 775 In addition, any type that is not defined using another type is a | |
| 776 primitive type. All other types (i.e. function and vector)are | |
|
Jim Stichnoth
2014/05/08 12:55:17
space after parens
Karl
2014/06/02 22:39:29
Done.
| |
| 777 composite types. | |
| 778 | |
| 779 Types must be defined in a topological order, causing primitive types | |
| 780 to apear before the composite types that use them. There are no | |
|
binji
2014/05/02 18:04:52
appear
Karl
2014/06/02 22:39:29
Done.
| |
| 781 additional restrictions on the order that types can be defined in a | |
| 782 types block. | |
| 783 | |
| 784 The following subsections introduces each valid PNaClAsm type, and the | |
|
Jim Stichnoth
2014/05/08 12:55:17
introduce
Karl
2014/06/02 22:39:29
Done.
| |
| 785 corresponding PNaClAsm construct that defines the type. Types not | |
| 786 defined in the types block, can't be used in a PNaCl program. | |
| 787 | |
| 788 The first record of a types block must be a *count* record, defining | |
| 789 how many types are defined by the types block. All remaining records | |
| 790 defines a type. The following subsections define valid records within | |
|
Jim Stichnoth
2014/05/08 12:55:17
defines --> define
Karl
2014/06/02 22:39:29
Done.
| |
| 791 a types block. The order of type records is important. The position of | |
| 792 these defining records implicitly define the type ID that will be used | |
|
Jim Stichnoth
2014/05/08 12:55:17
The position of each defining record implicitly de
Karl
2014/06/02 22:39:29
Done.
| |
| 793 to denote that type, within other PNaCl records of the bitcode file. | |
| 794 | |
| 795 To make this more concrete, consider the following example types | |
| 796 block: | |
| 797 | |
| 798 .. naclcode:: | |
| 799 | |
| 800 types { | |
| 801 count: 4; | |
| 802 @t0 = void; | |
| 803 @t1 = i32; | |
| 804 @t2 = float; | |
| 805 @t3 = void (i32, float); | |
| 806 } | |
| 807 | |
| 808 This example defines a types block that defines four type IDs: | |
| 809 | |
| 810 0. The void type. | |
| 811 1. A 32-bit integer type. | |
| 812 2. A 32-bit floating type. | |
| 813 3. A function, taking 32-bit integer and float arguments, and returns void. | |
|
Jim Stichnoth
2014/05/08 12:55:17
"and returning" or "that returns"
Karl
2014/06/02 22:39:29
Done.
| |
| 814 | |
| 815 Note that the order defines the corresponding ID that will be used for | |
| 816 that type, is based on the position of the type within the types | |
|
Jim Stichnoth
2014/05/08 12:55:17
and is based
Karl
2014/06/02 22:39:29
Done.
| |
| 817 record. Hence, the assignment to ID @tN can never appear before the | |
| 818 assignment to ID @tN-1. Further, if type ID @tN is assigned, it must | |
| 819 appear immediatedly after the assignment to ID @tN-1. | |
|
Jim Stichnoth
2014/05/08 12:55:17
immediately
Karl
2014/06/02 22:39:29
Done.
| |
| 820 | |
| 821 Count Record | |
| 822 ------------ | |
| 823 | |
| 824 The *count record* defines how many types are defined in the | |
|
Jim Stichnoth
2014/05/08 12:55:17
For this and other types of count records, what ha
Karl
2014/06/02 22:39:29
This is currently undefined. Fixing code to verify
| |
| 825 types block. Following the types count record are records that define | |
| 826 types used by the PNaCl program. | |
| 827 | |
| 828 **Syntax** | |
| 829 | |
| 830 .. naclcode:: | |
| 831 | |
| 832 count: N; <I> | |
| 833 | |
| 834 **Record** | |
| 835 | |
| 836 I: <1, N> | |
| 837 | |
| 838 **Semantics** | |
| 839 | |
| 840 This construct defines the number of types used by the PNaCl program. | |
| 841 *N* is the number of types defined in the types block. It is an error | |
| 842 to define more (or less) types than value *N*, within the enclosing | |
|
Jim Stichnoth
2014/05/08 12:55:17
less --> fewer
Karl
2014/06/02 22:39:29
Done.
| |
| 843 types block. *I* is the (optional) abbreviation associated with the | |
| 844 record. | |
| 845 | |
| 846 **Updates** | |
| 847 | |
| 848 .. naclcode:: | |
| 849 | |
| 850 ExpectedTypes = N; | |
| 851 | |
| 852 **Examples** | |
| 853 | |
| 854 .. naclcode:: | |
| 855 | |
| 856 types { | |
| 857 count: 2; | |
| 858 @t0 = float; | |
| 859 @t1 = i32; | |
| 860 } | |
| 861 | |
| 862 This example defines that the only types used by the PNaCl program are | |
| 863 are 32 bit integer and floating type. | |
|
Jim Stichnoth
2014/05/08 12:55:17
are are --> are
Jim Stichnoth
2014/05/08 12:55:17
types
Karl
2014/06/02 22:39:29
Done.
Karl
2014/06/02 22:39:29
Done.
| |
| 864 | |
| 865 The corresponding PNaCl Records are: | |
|
Jim Stichnoth
2014/05/08 12:55:17
Records --> records
Karl
2014/06/02 22:39:29
Done.
| |
| 866 | |
| 867 .. naclcode:: | |
| 868 | |
| 869 <655335, 17, 2> | |
| 870 <1, 2> | |
| 871 <3> | |
| 872 <7, 32> | |
| 873 <655334> | |
| 874 | |
| 875 Void Type | |
| 876 --------- | |
| 877 | |
| 878 The *void* type record defines the void type, which corrresponds to | |
|
binji
2014/05/02 18:04:52
corresponds
Karl
2014/06/02 22:39:29
Done.
| |
| 879 the type that doesn't define any value, and has no size. | |
| 880 | |
| 881 **Syntax** | |
| 882 | |
| 883 .. naclcode:: | |
| 884 | |
| 885 @tN = void; <I> | |
| 886 | |
| 887 **Record** | |
| 888 | |
| 889 .. naclcode:: | |
| 890 | |
| 891 I: <2> | |
| 892 | |
| 893 **Semantics** | |
| 894 | |
| 895 The void type record defines the type that has no values and has no | |
|
Jim Stichnoth
2014/05/08 12:55:17
values --> value ?
Karl
2014/06/02 22:39:29
Rewrote sentence.
| |
| 896 size. *I* is the (optional) abbreviation associated with the record. | |
| 897 | |
| 898 **Constraints** | |
| 899 | |
| 900 .. naclcode:: | |
| 901 | |
| 902 N == NumTypes | |
| 903 NumTypes < ExpectedTypes | |
| 904 | |
| 905 **Updates** | |
| 906 | |
| 907 .. naclcode:: | |
| 908 | |
| 909 ++NumTypes; | |
| 910 TypeOf(@tN) = void; | |
| 911 | |
| 912 **Examples** | |
| 913 | |
| 914 .. naclcode:: | |
| 915 | |
| 916 @t0 = void; | |
| 917 | |
| 918 defines the record | |
| 919 | |
| 920 .. naclcode:: | |
| 921 | |
| 922 <2> | |
| 923 | |
| 924 Integer Types | |
| 925 ------------- | |
| 926 | |
| 927 PNaClAsm allows integral types for various bit sizes. Valid bit sizes | |
| 928 are 1, 8, 16, 32, and 64. Integers can be signed or unsigned, but the | |
| 929 signed component of in integer is not specified by the type. Rather, | |
|
Jim Stichnoth
2014/05/08 12:55:17
in integer --> an integer
Karl
2014/06/02 22:39:29
Done.
| |
| 930 individual instructions determine whether the value is assumed to be | |
| 931 signed or unsigned. | |
| 932 | |
| 933 It should be noted that in PNaClAsm, all pointers are implemented as | |
| 934 32-bit (unsigned) integers. There isn't a separate type for | |
| 935 pointers. The only way to tell that a 32-bit integer is a pointer, is | |
| 936 when it is used in an instruction that requires a pointer (such as | |
| 937 load and store instructions). | |
| 938 | |
| 939 **Syntax** | |
| 940 | |
| 941 .. naclcode:: | |
| 942 | |
| 943 @tN = iB; <I> | |
| 944 | |
| 945 **Record** | |
| 946 | |
| 947 I: <7, B> | |
| 948 | |
| 949 **Semantics** | |
| 950 | |
| 951 An integer type record defines an integral type. *B* defines the | |
| 952 number of bits of the integral type. *I* is the (optional) | |
| 953 abbreviation associated with the record. | |
| 954 | |
| 955 **Constraints** | |
| 956 | |
| 957 .. naclcode:: | |
| 958 | |
| 959 N == NumTypes | |
| 960 NumTypes < ExpectedTypes | |
| 961 B in {1, 8, 16, 32, 64} | |
| 962 | |
| 963 **Updates** | |
| 964 | |
| 965 .. naclcode:: | |
| 966 | |
| 967 ++NumTypes; | |
| 968 TypeOf(@tN) = iB; | |
| 969 | |
| 970 **Examples** | |
| 971 | |
| 972 .. naclcode:: | |
| 973 | |
| 974 @t1 = i32; | |
| 975 @t2 = i1; | |
| 976 @t3 = i64; | |
| 977 | |
| 978 defines the records | |
| 979 | |
| 980 .. naclcode:: | |
| 981 | |
| 982 <7, 32> | |
| 983 <7, 1> | |
| 984 <7, 64> | |
| 985 | |
| 986 32-Bit Floating Type | |
| 987 -------------------- | |
| 988 | |
| 989 PNaClAsm allows computation on 32-bit floating values. A floating type | |
| 990 record defines the 32-bit floating type. | |
| 991 | |
| 992 **Syntax** | |
| 993 | |
| 994 .. naclcode:: | |
| 995 | |
| 996 @tN = float; <I> | |
| 997 | |
| 998 **Record** | |
| 999 | |
| 1000 .. naclcode:: | |
| 1001 | |
| 1002 I: <3> | |
| 1003 | |
| 1004 **Semantics** | |
| 1005 | |
| 1006 A floating type record defines the 32-bit floating type. *I* is the | |
| 1007 (optional) abbreviation associated with the record. | |
| 1008 | |
| 1009 **Constraints** | |
| 1010 | |
| 1011 .. naclcode:: | |
| 1012 | |
| 1013 N == NumTypes | |
| 1014 NumTypes < ExpectedTypes | |
| 1015 | |
| 1016 **Updates** | |
| 1017 | |
| 1018 .. naclcode:: | |
| 1019 | |
| 1020 ++NumTypes; | |
| 1021 TypeOf(@tN) = float; | |
| 1022 | |
| 1023 **Examples** | |
| 1024 | |
| 1025 .. naclcode:: | |
| 1026 | |
| 1027 @t5 = float; | |
| 1028 | |
| 1029 defines the record | |
| 1030 | |
| 1031 .. naclcode:: | |
| 1032 | |
| 1033 <3> | |
| 1034 | |
| 1035 64-bit Floating Type | |
| 1036 -------------------- | |
| 1037 | |
| 1038 PNaClAsm allows computation on 64-bit floating values. A double type | |
| 1039 record defines the 64-bit floating type. | |
| 1040 | |
| 1041 **Syntax** | |
| 1042 | |
| 1043 .. naclcode:: | |
| 1044 | |
| 1045 @tN = double; <I> | |
| 1046 | |
| 1047 **Record** | |
| 1048 | |
| 1049 .. naclcode:: | |
| 1050 | |
| 1051 I: <4> | |
| 1052 | |
| 1053 **Semantics** | |
| 1054 | |
| 1055 A double type record defines the 64-bit floating type. *I* is the | |
| 1056 (optional) abbreviation associated with the record. | |
| 1057 | |
| 1058 **Constraints** | |
| 1059 | |
| 1060 .. naclcode:: | |
| 1061 | |
| 1062 N == NumTypes | |
| 1063 NumTypes < ExpectedTypes | |
| 1064 | |
| 1065 **Updates** | |
| 1066 | |
| 1067 .. naclcode:: | |
| 1068 | |
| 1069 ++NumTypes; | |
| 1070 TypeOf(@tN) = double; | |
| 1071 | |
| 1072 **Examples** | |
| 1073 | |
| 1074 .. naclcode:: | |
| 1075 | |
| 1076 @t3 = double; | |
| 1077 | |
| 1078 defines the record | |
| 1079 | |
| 1080 .. naclcode:: | |
| 1081 | |
| 1082 <4> | |
| 1083 | |
| 1084 Vector Types | |
| 1085 ------------ | |
| 1086 | |
| 1087 TBD. | |
|
Jim Stichnoth
2014/05/08 12:55:17
TODO for missing content, for easier searching, he
Karl
2014/06/02 22:39:29
Done.
| |
| 1088 | |
| 1089 Function Types | |
| 1090 -------------- | |
| 1091 | |
| 1092 TBD. | |
| 1093 | |
| 1094 Globals block | |
| 1095 ============= | |
| 1096 | |
| 1097 The globals block defines global addresses of variables and constants, | |
| 1098 used by the PNaCl program. It also defines the memory associated with | |
| 1099 the global addresses, and how to initialize each global | |
| 1100 variable/constant. It must appear in the module block. It must appear | |
| 1101 after the types block, as well as after all function address | |
| 1102 records. But, it must also appear before the valuesymtab block, and | |
| 1103 any function blocks. | |
| 1104 | |
| 1105 The globals block begins with a count record, defining how many global | |
| 1106 addresses are defined by the PNaCl program. It is then followed by a | |
| 1107 sequence of records that defines how each global addresss is | |
|
binji
2014/05/02 18:04:52
address
Karl
2014/06/02 22:39:29
Done.
| |
| 1108 initialized. | |
| 1109 | |
| 1110 The standard sequence, for defining global addresses, begins with a | |
| 1111 global address record. It is then followed by a sequence of records | |
| 1112 defining how the global address is initialized. If the initializer is | |
| 1113 simple, a single record is used. Otherwise, the initializer is | |
| 1114 preceded with a compound record, specifying a number *N*, followed by | |
| 1115 sequence of *N* simple initializer records. | |
| 1116 | |
| 1117 The size of the memory referenced by each global address is defined by | |
| 1118 its initalizer records. All simple initializer records define a | |
|
binji
2014/05/02 18:04:52
initializer
Karl
2014/06/02 22:39:29
Done.
| |
| 1119 sequence of bytes. A compound initializer defines a sequence of bytes | |
| 1120 by concatenating corresponding sequence of bytes for each of its | |
|
Jim Stichnoth
2014/05/08 12:55:17
concatenating a corresponding
Karl
2014/06/02 22:39:29
Done.
| |
| 1121 simple initializer records. | |
| 1122 | |
| 1123 For notational convenience, PNaClAsm begins a compound record with a | |
| 1124 "{", and inserts a "}" after the last initializer record associated | |
| 1125 compound record. This latter "}" does not correspond to any record. It | |
| 1126 is implicitly assumed by the size specified in the compound record, | |
| 1127 and is added only to improve readability. | |
| 1128 | |
| 1129 For example, consider the following: | |
| 1130 | |
| 1131 .. naclcode:: | |
| 1132 | |
| 1133 globals { | |
| 1134 count: 2; | |
| 1135 const @g0, align 1, | |
| 1136 zerofill 8; | |
| 1137 var @g1, align 4, | |
| 1138 initializers 2 { | |
| 1139 {1, 2, 3, 4}, | |
| 1140 zerofill 2; | |
| 1141 } | |
| 1142 } | |
| 1143 | |
| 1144 In this example, the globals block contains 9 records. All lines, | |
| 1145 inside the block delimiters of this example (except the second to | |
| 1146 last) defines a record. The first record defines the number of global | |
| 1147 addresses defined by the program, i.e. 2. The second defines that | |
| 1148 second global addresses will be defined. | |
|
Jim Stichnoth
2014/05/08 12:55:17
I'm not sure how to parse the last sentence. Shou
| |
| 1149 | |
| 1150 The third record defines the global constant address *@g0*, and it's | |
|
Jim Stichnoth
2014/05/08 12:55:17
its
Karl
2014/06/02 22:39:29
ditto.
| |
| 1151 corresponding memory layout alignment. The forth record defines to | |
|
Jim Stichnoth
2014/05/08 12:55:17
fourth
Karl
2014/06/02 22:39:29
ditto.
| |
| 1152 initialize the constant with 8 bytes, all with the value zero. This | |
|
Jim Stichnoth
2014/05/08 12:55:17
This --> The
Karl
2014/06/02 22:39:29
Ditto.
| |
| 1153 size of *@g0* is 8 bytes. | |
| 1154 | |
| 1155 The fifth record defines the global variable address *@g1*, and it's | |
|
Jim Stichnoth
2014/05/08 12:55:17
its
Karl
2014/06/02 22:39:29
Ditto.
| |
| 1156 corresponding memory layout alignment. The sixth record defines that | |
| 1157 the initial value of *@g1* is defined by the sequence of bytes defined | |
| 1158 by the following 2 initializer records. The seventh record defines that | |
| 1159 the first 4 bytes of *@g1* are initialized with bytes 1, 2, 3, 4. The | |
| 1160 eighth record initializes bytes 5 and 6 to zero. The size of *@g2* is | |
|
Jim Stichnoth
2014/05/08 12:55:17
What is @g2? This is its first mention.
Karl
2014/06/02 22:39:29
Ditto.
| |
| 1161 therefore 6 bytes. | |
| 1162 | |
| 1163 The nine record is the exit block record. | |
| 1164 | |
| 1165 In other words, the corresponding records are: | |
| 1166 | |
| 1167 .. naclcode:: | |
| 1168 | |
| 1169 <655335, 19, 2> | |
| 1170 <5, 2> | |
| 1171 <0, 1, 1> | |
| 1172 <2, 8> | |
| 1173 <0, 4, 0> | |
| 1174 <1, 2> | |
| 1175 <3, 1, 2, 3, 4> | |
| 1176 <2, 2> | |
| 1177 <655334> | |
| 1178 | |
| 1179 | |
| 1180 Count Record | |
| 1181 ------------ | |
| 1182 | |
| 1183 The count record defines the number of global addresses used by the | |
| 1184 PNaCl program. | |
| 1185 | |
| 1186 **Syntax** | |
| 1187 | |
| 1188 .. naclcode:: | |
| 1189 | |
| 1190 count: N; <I> | |
| 1191 | |
| 1192 **Record** | |
| 1193 | |
| 1194 .. naclcode:: | |
| 1195 | |
| 1196 I: <5, N> | |
| 1197 | |
| 1198 **Semantics** | |
| 1199 | |
| 1200 This record must appear first in the globals block. The count record | |
| 1201 defines the number of global addresses used by the program. *I* is the | |
| 1202 (optional) abbreviation associated with the record. | |
| 1203 | |
| 1204 **Updates** | |
| 1205 | |
| 1206 .. naclcode:: | |
| 1207 | |
| 1208 ExpectedGlobals = N; | |
| 1209 ExpectedInitializers = 0; | |
| 1210 | |
| 1211 Global Variable Addressses | |
| 1212 -------------------------- | |
| 1213 | |
| 1214 A global variable address record defines a global address to global | |
| 1215 data. The global variable address record must be immediatedly | |
|
binji
2014/05/02 18:04:52
immediately
Karl
2014/06/02 22:39:29
Done.
| |
| 1216 followed by initializer record(s) that define how the corresponding | |
| 1217 global variable is initialized. | |
| 1218 | |
| 1219 **Syntax** | |
| 1220 | |
| 1221 .. naclcode:: | |
| 1222 | |
| 1223 var @gN, align A, <I> | |
| 1224 | |
| 1225 **Record** | |
| 1226 | |
| 1227 .. naclcode:: | |
| 1228 | |
| 1229 I: <0, A, 0> | |
| 1230 | |
| 1231 **Semantics** | |
| 1232 | |
| 1233 A global varaible address record defines a global address for a global | |
|
binji
2014/05/02 18:04:52
variable
Karl
2014/06/02 22:39:29
Done.
| |
| 1234 variable. *A* is the alignment to for the global variable. *I* is | |
|
Jim Stichnoth
2014/05/08 12:55:17
to for --> for
(or "of")
Karl
2014/06/02 22:39:29
Done.
| |
| 1235 the (optional) abbreviation associated with the record. | |
| 1236 | |
| 1237 It is assumed that the memory, referenced by the global variable | |
| 1238 address, can be both read and written to. | |
| 1239 | |
| 1240 ??? Valid values for A. Section defining notion of memory alignments ??? | |
|
Jim Stichnoth
2014/05/08 12:55:17
TODO
Karl
2014/06/02 22:39:29
Done.
| |
| 1241 | |
| 1242 **Constraints** | |
| 1243 | |
| 1244 .. naclcode:: | |
| 1245 | |
| 1246 N == NumGlobalAddresses | |
| 1247 NumGlobalAddresses < ExpectedGlobals | |
| 1248 ExpectedInitializers == 0 | |
| 1249 | |
| 1250 **Updates** | |
| 1251 | |
| 1252 .. naclcode:: | |
| 1253 | |
| 1254 ++NumGlobalAddresses; | |
| 1255 ExpectedInitializers = 1; | |
| 1256 TypeOf(@gN) = i32; | |
| 1257 | |
| 1258 **Examples** | |
| 1259 | |
| 1260 .. naclcode:: | |
| 1261 | |
| 1262 var @g0, align 1, | |
| 1263 zerofill 8; | |
| 1264 var @g1, align 1, | |
| 1265 {1, 2, 3, 4} | |
| 1266 | |
| 1267 This example defines two global variable addresses, *@g0* and | |
| 1268 *@g1*. Both use memory alignment of 1. *@g0* is an 8 byte variable | |
| 1269 initialized to zero. *@g1* is a 4 byte variable, initialized by the | |
| 1270 sequence of bytes 1, 2, 3, and 4. | |
| 1271 | |
| 1272 The corresponding records defined by the example above are: | |
| 1273 | |
| 1274 .. naclcode:: | |
| 1275 | |
| 1276 <0, 1, 0> | |
| 1277 <2, 8> | |
| 1278 <0, 1, 0> | |
| 1279 <3, 1, 2, 3, 4> | |
| 1280 | |
| 1281 Glboal Constant Addresses | |
|
jvoung (off chromium)
2014/05/27 23:18:50
Global
Karl
2014/06/02 22:39:29
Done.
| |
| 1282 ------------------------- | |
| 1283 | |
| 1284 A global constant address record defines an address corresponding to a | |
| 1285 global constant that can't be modified by the program. The global | |
| 1286 constant address record must be immediatedly followed by initializer | |
|
binji
2014/05/02 18:04:52
immediately
Karl
2014/06/02 22:39:29
Done.
| |
| 1287 record(s) that define how the corresponding global constant is | |
| 1288 initialized. | |
| 1289 | |
| 1290 **Syntax** | |
| 1291 | |
| 1292 .. naclcode:: | |
| 1293 | |
| 1294 const @gN, align A, <I> | |
| 1295 | |
| 1296 **Record** | |
| 1297 | |
| 1298 .. naclcode:: | |
| 1299 | |
| 1300 I: <0, A, 1> | |
| 1301 | |
| 1302 **Semantics** | |
| 1303 | |
| 1304 A global constant address record defines a global address for a global | |
| 1305 constant. *A* is the memory alignment for the global constant. *I* is | |
| 1306 the (optional) abbreviation associated with the record. | |
| 1307 | |
| 1308 It is assumed that the memory, referenced by the global constant | |
| 1309 address, is only read, and can't be written to. | |
| 1310 | |
| 1311 ??? Valid values for A. Section defining notion of memory alignments ??? | |
|
Jim Stichnoth
2014/05/08 12:55:17
TODO
Karl
2014/06/02 22:39:29
Done.
| |
| 1312 | |
| 1313 **Constraints** | |
| 1314 | |
| 1315 .. naclcode:: | |
| 1316 | |
| 1317 N == NumGlobalAddresses | |
| 1318 NumGlobalAddresses < ExpectedGlobals | |
| 1319 ExpectedInitializers = 0 | |
| 1320 | |
| 1321 **Updates** | |
| 1322 | |
| 1323 .. naclcode:: | |
| 1324 | |
| 1325 ++NumGlobalAddresses; | |
| 1326 ExpectedInitializers = 1; | |
| 1327 TypeOf(@gN) = i32; | |
| 1328 | |
| 1329 **Examples** | |
| 1330 | |
| 1331 .. naclcode:: | |
| 1332 | |
| 1333 const @g0, align 1, | |
| 1334 zerofill 8; | |
| 1335 var @g1, align 1, | |
| 1336 {1, 2} | |
| 1337 | |
| 1338 This example defines two global constants, with global addresses *@g0* | |
| 1339 and *@g1*. Both use memory alignment of 1. *@g0* is an 8 byte constant | |
| 1340 initialized to zero. *@g1* is a 2 byte variable, initialized by the | |
| 1341 sequence of bytes 1 and 2. | |
| 1342 | |
| 1343 The corresponding PNaCl bitcode records are: | |
| 1344 | |
| 1345 .. naclcode:: | |
| 1346 | |
| 1347 <0, 1, 1> | |
| 1348 <2, 8> | |
| 1349 <0, 1, 1> | |
| 1350 <3, 1, 2> | |
| 1351 | |
| 1352 Zerofill Initializer | |
| 1353 -------------------- | |
| 1354 | |
| 1355 The zerofill initializer record intializes a sequence of bytes, | |
|
binji
2014/05/02 18:04:52
initializes
| |
| 1356 associated with a global address, with zeros. | |
| 1357 | |
| 1358 **Syntax** | |
| 1359 | |
| 1360 .. naclcode:: | |
| 1361 | |
| 1362 zerofill N; <I> | |
| 1363 | |
| 1364 **Record** | |
| 1365 | |
| 1366 .. naclcode:: | |
| 1367 | |
| 1368 I: <2, N> | |
| 1369 | |
| 1370 **Semantics** | |
| 1371 | |
| 1372 A zerofill initializer record intializes a sequence of bytes, | |
|
binji
2014/05/02 18:04:52
initializes
Karl
2014/06/02 22:39:29
Done.
Jim Stichnoth
2014/06/06 18:24:46
Actually not done (though the one above was done a
| |
| 1373 associated with a global address, with zeros. *I* is the (optional) | |
| 1374 abbreviation of the associated record. | |
| 1375 | |
| 1376 **Constraints** | |
| 1377 | |
| 1378 .. naclcode:: | |
| 1379 | |
| 1380 ExpectedInitializers > 0; | |
| 1381 | |
| 1382 **Updates** | |
| 1383 | |
| 1384 .. naclcode:: | |
| 1385 | |
| 1386 --ExpectedInitializers; | |
| 1387 | |
| 1388 **Examples** | |
| 1389 | |
| 1390 .. naclcode:: | |
| 1391 | |
| 1392 const @g0, align 1, | |
| 1393 zerofill 8; | |
| 1394 var @g1, align 1, | |
| 1395 zerofill 4; | |
| 1396 | |
| 1397 This example defines two global constants, with global addresses *@g0* | |
| 1398 and *@g1*. The global memory associated with address *@g0*, is an | |
| 1399 eight byte value, initialized to zero. The global memory associated | |
| 1400 with address *@g1*, is a 4 byte value, initialized to zero. | |
| 1401 | |
| 1402 The corresponding PNaCl records are: | |
| 1403 | |
| 1404 .. naclcode:: | |
| 1405 | |
| 1406 <0, 1, 1> | |
| 1407 <2, 8> | |
| 1408 <0, 1, 1> | |
| 1409 <2, 4> | |
| 1410 | |
| 1411 Data Initializer | |
| 1412 ---------------- | |
| 1413 | |
| 1414 Data records define a sequence of bytes, defining the contents of the | |
| 1415 corresponding memory. The bytes defined by a data record corresponds | |
| 1416 the the corresponding bytes the memory will be initialized with. | |
|
binji
2014/05/02 18:04:52
s/the //
Karl
2014/06/02 22:39:29
Done.
| |
| 1417 | |
| 1418 **Syntax** | |
| 1419 | |
| 1420 .. naclcode:: | |
| 1421 | |
| 1422 { B1 , .... , BN } <I> | |
| 1423 | |
| 1424 **Record** | |
| 1425 | |
| 1426 .. naclcode:: | |
| 1427 | |
| 1428 I: <3, B1, ..., BN> | |
| 1429 | |
| 1430 **Semantics** | |
| 1431 | |
| 1432 A data record defines a sequence of bytes *B1* throught *BN*, that | |
|
binji
2014/05/02 18:04:52
through
Karl
2014/06/02 22:39:29
Done.
| |
| 1433 intialize *N* bytes of memory. *I* is the (optional) abbreviation | |
|
binji
2014/05/02 18:04:52
initialize
Karl
2014/06/02 22:39:29
Done.
| |
| 1434 associated with the record. | |
| 1435 | |
| 1436 **Constraints** | |
| 1437 | |
| 1438 .. naclcode:: | |
| 1439 | |
| 1440 ExpectedInitializers > 0 | |
| 1441 | |
| 1442 **Updates** | |
| 1443 | |
| 1444 .. naclcode:: | |
| 1445 | |
| 1446 --ExpectedInitializers; | |
| 1447 | |
| 1448 **Examples** | |
| 1449 | |
| 1450 .. naclcode:: | |
| 1451 | |
| 1452 const @g0, align 1, | |
| 1453 {1, 2, 97, 36, 44, 88, 44} | |
| 1454 const @g1, align 1 | |
| 1455 initializers 3 { | |
| 1456 {4, 5, 6, 7} | |
| 1457 reloc @f1; | |
| 1458 {99, 66, 22, 12} | |
| 1459 } | |
| 1460 | |
| 1461 The corresponding PNaCl records are: | |
| 1462 | |
| 1463 .. naclcode:: | |
| 1464 | |
| 1465 <0, 1, 1> | |
| 1466 <3, 1, 2, 97, 36, 44, 88, 44> | |
| 1467 <0, 1, 1> | |
| 1468 <1, 3> | |
| 1469 <3, 4, 5, 6, 7> | |
| 1470 <4, 1> | |
| 1471 <3, 99, 66, 22, 12> | |
| 1472 | |
| 1473 Relocation Initializer | |
| 1474 ---------------------- | |
| 1475 | |
| 1476 A relocation initializer record allows one to fill the initial value | |
| 1477 with the value of another global address (i.e. either function, | |
| 1478 variable, or constant). Since addresses are pointers, and in PNaClAsm | |
| 1479 all pointers are of integral type i32, a relocation initializer record | |
| 1480 defines 4 bytes of memory. | |
| 1481 | |
| 1482 **Syntax** | |
| 1483 | |
| 1484 .. naclcode:: | |
| 1485 | |
| 1486 reloc A; <I> | |
| 1487 | |
| 1488 **Record** | |
| 1489 | |
| 1490 .. naclcode:: | |
| 1491 | |
| 1492 I: <4, N> | |
| 1493 | |
| 1494 **Semantics** | |
| 1495 | |
| 1496 A relocation initializer record defines a 4-byte value containing the | |
| 1497 specified global address *A*. *N* is the absolute index associated | |
| 1498 with address *A*. *I* is the (optional) abbreviation associated with | |
| 1499 the record. | |
| 1500 | |
| 1501 **Constraints** | |
| 1502 | |
| 1503 .. naclcode:: | |
| 1504 | |
| 1505 N == AbsoluteIndex(A); | |
| 1506 ExpectedInitializers > 0 | |
| 1507 | |
| 1508 **Updates** | |
| 1509 | |
| 1510 .. naclcode:: | |
| 1511 | |
| 1512 --ExpectedInitializers; | |
| 1513 | |
| 1514 **Examples** | |
| 1515 | |
| 1516 .. naclcode:: | |
| 1517 | |
| 1518 var @g0, align 1, | |
| 1519 initializers 3 { | |
| 1520 reloc @f1; | |
| 1521 reloc @g0; | |
| 1522 reloc @g10; | |
| 1523 } | |
| 1524 | |
| 1525 This example defines global address *@g0*. It defines 12 bytes of | |
| 1526 memory, and is initialized with three addresses *@f1*, *@g0*, and | |
| 1527 *@g10*. Note that all globals can be used in a relocation | |
| 1528 initialization record, even if it isn't defined yet. | |
| 1529 | |
| 1530 Assuming | |
| 1531 | |
| 1532 .. naclcode:: | |
| 1533 | |
| 1534 100 = AbsoluteIndex(@g0)) | |
| 1535 | |
| 1536 The corresponding PNaCl bitcode records are: | |
| 1537 | |
| 1538 .. naclcode:: | |
| 1539 | |
| 1540 <0, 1, 0> | |
| 1541 <1, 3> | |
| 1542 <4, 1> | |
| 1543 <4, 100> | |
| 1544 <4, 110> | |
| 1545 | |
| 1546 Subfield Relocation Initializer | |
| 1547 ------------------------------- | |
| 1548 | |
| 1549 A subfield relocation initializer record allows one to fill the | |
| 1550 initial value with the value of another (non-function) global address | |
| 1551 (i.e. either variable or constant), plus a constant. This constant | |
| 1552 must refer to an offset within the memory associated with the global | |
| 1553 address. Since addresses are pointers, and in PNaClAsm all pointers | |
| 1554 are of integral type i32, a relocation initializer record defines 4 | |
| 1555 bytes of memory. | |
| 1556 | |
| 1557 **Syntax** | |
| 1558 | |
| 1559 .. naclcode:: | |
| 1560 | |
| 1561 reloc A + V; <I> | |
| 1562 | |
| 1563 **Record** | |
| 1564 | |
| 1565 .. naclcode:: | |
| 1566 | |
| 1567 I: <4, N, V> | |
| 1568 | |
| 1569 **Semantics** | |
| 1570 | |
| 1571 A relocation initializer record defines a 4-byte value containing the | |
| 1572 specified global (non-funciton) address *A*, modified by the (unsigned | |
|
binji
2014/05/02 18:04:52
function
Karl
2014/06/02 22:39:29
Done.
| |
| 1573 integer) offset *V*. *N* is the absolute indexassociated with *A*. The | |
|
binji
2014/05/02 18:04:52
index associated
Karl
2014/06/02 22:39:29
Done.
| |
| 1574 size of *V* must refer to a byte in the memory associated with address | |
| 1575 *A*. *I* is the (optional) abbreviation associated with the record. | |
| 1576 | |
| 1577 **Constraints** | |
| 1578 | |
| 1579 .. naclcode:: | |
| 1580 | |
| 1581 N == AbsoluteIndex(A) | |
| 1582 V >= 0 | |
| 1583 ExpectedInitializers > 0 | |
| 1584 | |
| 1585 **Updates** | |
| 1586 | |
| 1587 .. naclcode:: | |
| 1588 | |
| 1589 --ExpectedInitializers; | |
| 1590 | |
| 1591 **Examples** | |
| 1592 | |
| 1593 .. naclcode:: | |
| 1594 | |
| 1595 var @g0, align 1, | |
| 1596 initializers 3 { | |
| 1597 reloc @f1; | |
| 1598 reloc @g0 + 4; | |
| 1599 reloc @g10 + 32; | |
| 1600 } | |
| 1601 | |
| 1602 This example defines global address *@g0*, and is initialized with | |
| 1603 three pointers, addresses *@f1*, *@g0+4*, and *@g10+32*. Note that all | |
| 1604 global addresses can be used in a relocation initialization record, | |
| 1605 even if it isn't defined yet. Validity of the reference can be | |
| 1606 verified, since a global address *@g10* must be smaller than the value | |
| 1607 specified in the globals count record. | |
| 1608 | |
| 1609 Assuming | |
| 1610 | |
| 1611 .. naclcode:: | |
| 1612 | |
| 1613 100 = AbsoluteIndex(@g0)) | |
| 1614 | |
| 1615 The corresponding PNaCl bitcode records are: | |
| 1616 | |
| 1617 .. naclcode:: | |
| 1618 | |
| 1619 <0, 1, 0> | |
| 1620 <1, 3> | |
| 1621 <4, 1> | |
| 1622 <4, 100, 4> | |
| 1623 <4, 110, 32> | |
| 1624 | |
| 1625 Compound Initializer | |
| 1626 -------------------- | |
| 1627 | |
| 1628 The compound initializer record must immediately follow a global variable/consta nt | |
|
Jim Stichnoth
2014/05/08 12:55:17
80-col
Karl
2014/06/02 22:39:29
Done.
| |
| 1629 address record. It defines how many (non-compound) initializer records are used to | |
| 1630 define the initializer. The size of the corresponding memory is the sum of the b ytes | |
| 1631 needed for each of the succeeding initializers. | |
| 1632 | |
| 1633 **Syntax** | |
| 1634 | |
| 1635 .. naclcode:: | |
| 1636 | |
| 1637 initializers N { <I> | |
| 1638 ... | |
| 1639 } | |
| 1640 | |
| 1641 **Record** | |
| 1642 | |
| 1643 .. naclcode:: | |
| 1644 | |
| 1645 I: <1, N> | |
| 1646 | |
| 1647 **Semantics** | |
| 1648 | |
| 1649 Defines that the next *N* initializers should be associated with the | |
| 1650 global address of the previous record. *I* is the (optional) | |
| 1651 abbreviation index associated with the record. | |
| 1652 | |
| 1653 **Constraints** | |
| 1654 | |
| 1655 .. naclcode:: | |
| 1656 | |
| 1657 ExpectedInitializers == 1 | |
| 1658 | |
| 1659 **Updates** | |
| 1660 | |
| 1661 .. naclcode:: | |
| 1662 | |
| 1663 ExpectedInitializers = N; | |
| 1664 | |
| 1665 **Examples** | |
| 1666 | |
| 1667 .. naclcode:: | |
| 1668 | |
| 1669 const @g1, align 1 | |
| 1670 initializers 3 { | |
| 1671 {4, 5, 6, 7} | |
| 1672 reloc @f1; | |
| 1673 {99, 66, 22, 12} | |
| 1674 } | |
| 1675 | |
| 1676 The corresponding PNaCl records are: | |
| 1677 | |
| 1678 .. naclcode:: | |
| 1679 | |
| 1680 <0, 1, 1> | |
| 1681 <1, 3> | |
| 1682 <3, 4, 5, 6, 7> | |
| 1683 <4, 1> | |
| 1684 <3, 99, 66, 22, 12> | |
| 1685 | |
| 1686 Valuesymtab Block | |
| 1687 ================= | |
| 1688 | |
| 1689 TBD. | |
| 1690 | |
| 1691 Module Block | |
| 1692 ============ | |
| 1693 | |
| 1694 The module block, like all blocks, are enclosed in a pair of | |
|
Jim Stichnoth
2014/05/08 12:55:17
are --> is
Karl
2014/06/02 22:39:29
Done.
| |
| 1695 enter/exit records, using block ID 8. A well-formed module block | |
| 1696 consists The following records (in order): | |
|
Jim Stichnoth
2014/05/08 12:55:17
The --> of the
Karl
2014/06/02 22:39:29
Done.
| |
| 1697 | |
| 1698 A version record | |
| 1699 The version record communicates the version of the PNaCl bitcode | |
| 1700 reader/writer to use. Note that this is different than the PNaCl | |
| 1701 bitcode (ABI) verion. The PNaCl bitcode (ABI) version defines what | |
|
binji
2014/05/02 18:04:52
version
Karl
2014/06/02 22:39:29
Done.
| |
| 1702 is expected in records, and is defined in the header record of the | |
| 1703 bitcode file. The version record defines the version of the PNaC | |
|
binji
2014/05/02 18:04:52
PNaCl
Karl
2014/06/02 22:39:29
Done.
| |
| 1704 bitcode reader/writer to use to convert records into bit | |
| 1705 sequences. | |
| 1706 | |
| 1707 Optional local abbreviations | |
| 1708 Defines a list of local abbreviations to use for records within | |
| 1709 the module block. | |
| 1710 | |
| 1711 An optional abbreviations block | |
| 1712 The abbreviations block defines user-defined, global abbreviations | |
| 1713 that are used to convert PNaCl records to bit sequences in blocks | |
| 1714 following the abbreviations block. | |
| 1715 | |
| 1716 A types block | |
| 1717 The types block defines the set of all types used in the program. | |
| 1718 | |
| 1719 A non-empty sequence of function address records | |
| 1720 Each record defines a function address used by the | |
| 1721 program. Function addresses must either be external, or defined | |
| 1722 internally by the program. If they are defined by the program, | |
| 1723 there must be a function block (appearing later in the module) | |
| 1724 that defines the sequence of instructions for each defined | |
| 1725 function. | |
| 1726 | |
| 1727 A globals block defining the global variables. | |
| 1728 This block defines the set of global variable (addresses) used by | |
| 1729 the program. In addition to the addresses, each global variable | |
| 1730 also defines how the corresponding global variable is initialized. | |
| 1731 | |
| 1732 An optional value symbol table block. | |
| 1733 This block, if defined, provides textual names for function and | |
| 1734 global variable addresses (previously defined in the module). Note | |
| 1735 that only names for instrinsic functions must be provided. Any | |
|
binji
2014/05/02 18:04:52
intrinsic
Karl
2014/06/02 22:39:29
Done.
| |
| 1736 additional names are hints that may (or may not) be used by the | |
| 1737 PNaCl translator, and be available for debugging when executed. | |
| 1738 | |
| 1739 A sequence of function blocks. | |
| 1740 Each function block defines the corresponding control flow graph | |
| 1741 for each defined function. The order of function blocks is used to | |
| 1742 associate them with function addresses. The order of the defined | |
| 1743 function blocks must follow the same order as the corresponding | |
| 1744 function addresses defined in the module block. | |
| 1745 | |
| 1746 Descriptions of the abbreviations[ref], types[ref], global | |
| 1747 variables[ref], value symbol table[ref], and function[ref] blocks are | |
| 1748 not provided here. See the appropriate reference for more details. The | |
| 1749 following subsections describe each of the records that can appear in | |
| 1750 a module block. | |
| 1751 | |
| 1752 Version | |
| 1753 ------- | |
| 1754 | |
| 1755 The version record defines the implementation of the PNaCl | |
| 1756 reader/writer that converts PNaCl records to bit sequences. Note that | |
| 1757 this is different than the PNaCl version of the bitcode file (encoded | |
| 1758 in the header record of the bitcode file). The PNaCl version defines | |
| 1759 the valid forms of PNaCl records. The version record is specific to | |
| 1760 the PNaCl version, and may have different values for different PNaCl | |
| 1761 versions. | |
| 1762 | |
| 1763 Note that currently, only PNaCl version 2, and version record value 1 | |
| 1764 is defined. Larger version record values are reserved for future | |
| 1765 changes. | |
| 1766 | |
| 1767 **Syntax** | |
| 1768 | |
| 1769 .. naclcode:: | |
| 1770 | |
| 1771 version N; <I> | |
| 1772 | |
| 1773 **Record** | |
| 1774 | |
| 1775 .. naclcode:: | |
| 1776 | |
| 1777 I: <1, N> | |
| 1778 | |
| 1779 **Semantics** | |
| 1780 | |
| 1781 The version record defines which PNaCl reader/writer rules should be | |
| 1782 followed. *N* is the version number. Currently *N* must be 1. Future | |
| 1783 versions of PNaCl may define other values. *I* is the (optional) | |
| 1784 abbreviation index associated with the record. | |
| 1785 | |
| 1786 *Examples* | |
| 1787 | |
| 1788 .. naclcode:: | |
| 1789 | |
| 1790 version 1; | |
| 1791 | |
| 1792 The corresponding record is: | |
| 1793 | |
| 1794 .. naclcode:: | |
| 1795 | |
| 1796 <1, 1> | |
| 1797 | |
| 1798 Function Address | |
| 1799 ---------------- | |
| 1800 | |
| 1801 A function address record defines a function address. Defining | |
| 1802 function addresses also imply a corresponding | |
|
Jim Stichnoth
2014/05/08 12:55:17
implies
Karl
2014/06/02 22:39:29
Done.
| |
| 1803 implementation. Implementations of function addresses are defined by a | |
| 1804 corresponding function block. The association of defining function | |
| 1805 address with the corresponding function block is based on position. | |
| 1806 The *Nth* defining function address record, in the module block, has | |
| 1807 its implementation in the *Nth* function block of that module block. | |
| 1808 | |
| 1809 **Syntax** | |
| 1810 | |
| 1811 .. naclcode:: | |
| 1812 | |
| 1813 PN LN T0 @fN ( T1 , ... , TM ); <I> | |
| 1814 | |
| 1815 **Record** | |
| 1816 | |
| 1817 .. naclcode: | |
| 1818 | |
| 1819 I: <8, T, C, P, L> | |
| 1820 | |
| 1821 **Semnatics** | |
|
Jim Stichnoth
2014/05/08 12:55:17
Semantics
Karl
2014/06/02 22:39:29
Done.
| |
| 1822 | |
| 1823 Defines the function address *@fN*. *PN* is the name that specifies | |
| 1824 the prototype value *P* associated with the function. A function | |
| 1825 address is defining only if *P==0*. Otherwise, it is only declared. | |
|
Jim Stichnoth
2014/05/08 12:55:17
defined
Karl
2014/06/02 22:39:29
Done.
| |
| 1826 The type of the function is defined by function type *@tT. *L* | |
| 1827 is the linkage specification corresponding to name *LN*. *C* is the | |
| 1828 calling convention used by the function. | |
| 1829 | |
| 1830 Type *@tT* (associated with the corresponding syntax rules) is | |
| 1831 defined as: | |
| 1832 | |
| 1833 .. naclcode:: | |
| 1834 | |
| 1835 @tT = TypeOf(T0 ( T1 , ... , TN )) | |
| 1836 | |
| 1837 Valid prototype names *PN*, and corresponding *P* values, are: | |
| 1838 | |
| 1839 = ======= | |
| 1840 P PN | |
| 1841 = ======= | |
| 1842 1 declare | |
| 1843 0 define | |
| 1844 = ======= | |
| 1845 | |
| 1846 Valid linkage names *LN*, and corresponding *L* values, are: | |
| 1847 | |
| 1848 = ======== | |
| 1849 L LN | |
| 1850 = ======== | |
| 1851 3 internal | |
| 1852 0 external | |
| 1853 = ======== | |
| 1854 | |
| 1855 Currently, only one calling convention *C* is supported: | |
| 1856 | |
| 1857 = ==================== | |
| 1858 C Calling Convention | |
| 1859 = ==================== | |
| 1860 0 C calling convention | |
| 1861 = ==================== | |
| 1862 | |
| 1863 **Constraint** | |
| 1864 | |
| 1865 .. naclcode:: | |
| 1866 | |
| 1867 N == NumFuncAddresses | |
| 1868 | |
| 1869 Updates | |
| 1870 ^^^^^^^ | |
| 1871 | |
| 1872 .. naclcode:: | |
| 1873 | |
| 1874 ++NumFuncAddresses; | |
| 1875 TypeOf(@fN) = TypeOf(TypeID(i32)); | |
| 1876 TypeOfFcn(@fN) = TypeOf(@tT); | |
| 1877 | |
| 1878 if PN == 0: | |
| 1879 DefiningFcnIDs += @FN; | |
| 1880 ++NumDefinedFunctionAddresses; | |
| 1881 | |
| 1882 **Examples** | |
| 1883 | |
| 1884 .. naclcode:: | |
| 1885 | |
| 1886 module { | |
| 1887 ... | |
| 1888 types { | |
| 1889 @t0 = void; | |
| 1890 @t1 = i32; | |
| 1891 @t3 = float; | |
| 1892 @t4 = void (i32, float); | |
| 1893 @t5 = i32 (); | |
| 1894 } | |
| 1895 ... | |
| 1896 declare external void @f0(i32, float); | |
| 1897 define internal i32 @f1(); | |
| 1898 | |
| 1899 This defines function addresses *@f0* and *@f1*. Function address | |
| 1900 *@f0* is defined externally while *@f2* has an implementation (defined | |
| 1901 by a corresponding function block). The type signature of *@f0* is | |
| 1902 defined by type *@t4* while the type signature of *@f1* is *@t5*. | |
| 1903 | |
| 1904 The corresopnding records for these two function addresses are: | |
|
binji
2014/05/02 18:04:52
corresponding
Karl
2014/06/02 22:39:29
Done.
| |
| 1905 | |
| 1906 .. naclcode:: | |
| 1907 | |
| 1908 <8, 4, 0, 1, 0> | |
| 1909 <8, 5, 0, 0, 1> | |
| 1910 | |
| 1911 Constants Blocks | |
| 1912 ================ | |
| 1913 | |
| 1914 TBD. | |
| 1915 | |
| 1916 Function Blocks | |
| 1917 =============== | |
| 1918 | |
| 1919 A function block defines the implementation of a function address. The | |
| 1920 function address it defines is based on the position of the | |
| 1921 corresponding defining function address. The Nth defining function | |
| 1922 address always corresponds to the corresponding Nth function block in | |
| 1923 the module block. | |
| 1924 | |
| 1925 A function definition contains a list of basic block, forming the CFG | |
|
Jim Stichnoth
2014/05/08 12:55:17
blocks
Karl
2014/06/02 22:39:29
Done.
| |
| 1926 (control flow graph). Each basic block contains a list of | |
| 1927 instructions, and ends with a *terminator* [ref] (branch) instruction. | |
|
Jim Stichnoth
2014/05/08 12:55:17
e.g., branch
since there are several kinds of ter
Karl
2014/06/02 22:39:29
Done.
| |
| 1928 | |
| 1929 The first basic block in a function is special in two ways: it is | |
| 1930 immediately executed on entrance to the function, and it is not | |
| 1931 allowed to have predecessor basic blocks (i.e. there can't be any | |
| 1932 branches to the entry block of a function). Because the entry block | |
| 1933 has no predecessors, it also can't have any *PHI nodes* [ref]. | |
|
Jim Stichnoth
2014/05/08 12:55:17
nodes --> instructions
Karl
2014/06/02 22:39:29
Done.
| |
| 1934 | |
| 1935 The parameters are implied by the type of the corresponding function | |
| 1936 address. One parameter is defined for each argument of the function | |
| 1937 type signature. | |
| 1938 | |
| 1939 The number of basic blocks are defined by the count record. Each | |
|
Jim Stichnoth
2014/05/08 12:55:17
are --> is
Karl
2014/06/02 22:39:29
Done.
| |
| 1940 termimintor instruction ends the current basic block, and the next | |
|
binji
2014/05/02 18:04:52
terminator
Karl
2014/06/02 22:39:29
Done.
| |
| 1941 instruction begins a new basic blocks. Basic blocks are numbered by | |
| 1942 the order they appear (starting with index 0). Basic block IDs have | |
| 1943 the form *%bN*, where *N* corresponds to the position of the basic | |
| 1944 block within the function block. | |
| 1945 | |
| 1946 Each instruction, within a function block, corresponds to a | |
| 1947 corresponding PNaCl record. The layout of a function block is the | |
| 1948 (basic block) count record, followed by a sequence of instruction | |
| 1949 records. | |
| 1950 | |
| 1951 For readability, PNaClAsm introduces block IDs. These block IDs do not | |
| 1952 correspond to PNaCl records, since basic block boundaries are defined | |
| 1953 implicitly, after terminator instructions. They appear only for | |
| 1954 readability. | |
| 1955 | |
| 1956 Most operands of instructions are encoded using a relative index | |
| 1957 value, rather than abolute. The is done because most instruction | |
|
binji
2014/05/02 18:04:52
absolute
Karl
2014/06/02 22:39:29
Done.
| |
| 1958 operands refer to values defined earlier in the (same) basic block. | |
| 1959 As a result, the relative distance (back) from the next defining | |
| 1960 instruction value index (for the function block) is frequently a small | |
| 1961 number. Small numbers tend to require less bits when they are | |
|
Jim Stichnoth
2014/05/08 12:55:17
less --> fewer
Karl
2014/06/02 22:39:29
Done.
| |
| 1962 converted to bit sequences. This distance is used in the corresponding | |
| 1963 records to denote the operand values. | |
| 1964 | |
| 1965 The following subsections define records that can appear in a function | |
| 1966 block. | |
| 1967 | |
| 1968 Function enter | |
| 1969 -------------- | |
| 1970 | |
| 1971 PNaClAsm defines a function enter block construct. The corresponding | |
| 1972 record is simply an enter block record, with BlockID value 12. All | |
| 1973 context about the defining address is implicit by the position of the | |
| 1974 function block, and the corresponding defining function address. To | |
| 1975 improve readability, PNaClAsm includes the function signature into the | |
| 1976 syntax rule. | |
| 1977 | |
| 1978 **Syntax** | |
| 1979 | |
| 1980 .. naclcode:: | |
| 1981 | |
| 1982 function TR @fN ( T0 %p0, ... , TM %pM) { <B> | |
| 1983 | |
| 1984 **Record** | |
| 1985 | |
| 1986 <655335, 12, B> | |
| 1987 | |
| 1988 **Semantics** | |
| 1989 | |
| 1990 *B* is the number of bits reserved for abbreviations in the block. See | |
| 1991 enter block records[ref] for more details. | |
| 1992 | |
| 1993 The value of *N* corresponds the the positional index of the | |
|
binji
2014/05/02 18:04:52
s/the //
Jim Stichnoth
2014/05/08 12:55:17
Actually, the the --> to the
Karl
2014/06/02 22:39:29
Done.
| |
| 1994 corresponding defining function address this block is associated | |
| 1995 with. *M* is the number of defined paramaters (plus one) | |
|
binji
2014/05/02 18:04:52
parameters
Karl
2014/06/02 22:39:29
Done.
| |
| 1996 in the function heading. | |
| 1997 | |
| 1998 **Constraints** | |
| 1999 | |
| 2000 .. naclcode:: | |
| 2001 | |
| 2002 N == NumFcnImpls | |
| 2003 @fN in DefiningFcnIDs | |
| 2004 TypeOfFcn(@fN) == TypeOf(TypeID(TR (T0, ... , TM))) | |
| 2005 | |
| 2006 **Updates** | |
| 2007 | |
| 2008 .. naclcode:: | |
| 2009 | |
| 2010 ++NumFcnImpls; | |
| 2011 EnclosingFcnID = @fN; | |
| 2012 NumBasicBlocks = 0; | |
| 2013 ExpectedBlocks = 0; | |
| 2014 NumParams = M; | |
| 2015 for I in [0..M]: | |
| 2016 TypeOf(%pI) = TypeOf(TypeID(TI)); | |
| 2017 | |
| 2018 **Examples** | |
| 2019 | |
| 2020 .. naclcode:: | |
| 2021 | |
| 2022 types { | |
| 2023 ... | |
| 2024 @t10 = void (i32, float); | |
| 2025 ... | |
| 2026 } | |
| 2027 ... | |
| 2028 define internal void @f12(i32, float); | |
| 2029 ... | |
| 2030 function void @f12(i32 %p0, float %p1) { | |
| 2031 ... | |
| 2032 } | |
| 2033 | |
| 2034 defines the enter block record: | |
| 2035 | |
| 2036 .. naclcode:: | |
| 2037 | |
| 2038 <655335, 12, 2> | |
| 2039 | |
| 2040 Count Record | |
| 2041 ------------ | |
| 2042 | |
| 2043 The count record, within a function block, defines the number of basic | |
| 2044 blocks used to define the function implementation. | |
| 2045 | |
| 2046 **Syntax** | |
| 2047 | |
| 2048 .. naclcode:: | |
| 2049 | |
| 2050 blocks: N; <I> | |
| 2051 %b0: | |
| 2052 | |
| 2053 **Record** | |
| 2054 | |
| 2055 .. naclcode:: | |
| 2056 | |
| 2057 I: <1, N> | |
| 2058 | |
| 2059 **Semantics** | |
| 2060 | |
| 2061 The count record defines the number of basic blocks *N*, defined by | |
| 2062 the implemented function. *I* is the (optional) abbreviation | |
| 2063 associated with the record. | |
| 2064 | |
| 2065 **Constraints** | |
| 2066 | |
| 2067 .. naclcode:: | |
| 2068 | |
| 2069 ExpectedBasicBlocks == 0 | |
| 2070 NumBasicBlocks == 0 | |
| 2071 | |
| 2072 Updates | |
| 2073 ^^^^^^^ | |
| 2074 | |
| 2075 .. naclcode:: | |
| 2076 | |
| 2077 ExpectedBlocks = N; | |
| 2078 | |
| 2079 **Examples** | |
| 2080 | |
| 2081 .. naclcode:: | |
| 2082 | |
| 2083 blocks: 5 | |
| 2084 | |
| 2085 The corresponding PNaCl bitcode record is: | |
| 2086 | |
| 2087 .. naclcode:: | |
| 2088 | |
| 2089 <1, 5> | |
| 2090 | |
| 2091 Terminator Instructions | |
| 2092 ----------------------- | |
| 2093 | |
| 2094 Terminator instructions are instructions that appear in a function | |
| 2095 block, and define the end of the current basic block. A terminator | |
| 2096 instuction indicates which block should be executed after the current | |
|
binji
2014/05/02 18:04:52
instruction
Karl
2014/06/02 22:39:29
Done.
| |
| 2097 block is finished. The function block is well formed only if the number | |
| 2098 of terminator instructions, in the function block, corresponds to the | |
| 2099 value defined by the corresponding count block. | |
| 2100 | |
| 2101 Return Void Instruction | |
| 2102 ^^^^^^^^^^^^^^^^^^^^^^^ | |
| 2103 | |
| 2104 The return void instruction is used to return control from a function | |
| 2105 back to the caller, without returning any value. | |
| 2106 | |
| 2107 **Syntax** | |
| 2108 | |
| 2109 .. naclcode:: | |
| 2110 | |
| 2111 ret; <I> | |
| 2112 %bB: | |
| 2113 | |
| 2114 **Record** | |
| 2115 | |
| 2116 .. naclcode:: | |
| 2117 | |
| 2118 I: <10> | |
| 2119 | |
| 2120 **Semantics** | |
| 2121 | |
| 2122 The return instruction returns control to the calling function. | |
| 2123 | |
| 2124 *B* is the number associated with the next basic block. Label *%bB:* | |
| 2125 only appears if *B + 1 < ExpectedBasicBlocks*. That is, the label is | |
| 2126 omitted only if this terminator instruction is the last instruction in | |
| 2127 the function block. *I* is the (optional) abbreviation index | |
| 2128 associated with the record. | |
| 2129 | |
| 2130 **Constraints** | |
| 2131 | |
| 2132 .. naclcode:: | |
| 2133 | |
| 2134 B == NumBasicBlocks | |
| 2135 NumBasicBlocks < ExpectedBasicBLocks | |
| 2136 ReturnType(TypeOf(EnclosingFcnID)) == void | |
| 2137 | |
| 2138 **Updates** | |
| 2139 | |
| 2140 .. naclcode:: | |
| 2141 | |
| 2142 ++NumBasicBlocks; | |
| 2143 | |
| 2144 **Examples** | |
| 2145 | |
| 2146 The following shows the implementation of a function that simply returns. | |
| 2147 | |
| 2148 .. naclcode:: | |
| 2149 | |
| 2150 function void @f5() { | |
| 2151 ret; | |
| 2152 } | |
| 2153 | |
| 2154 The corresponding PNaCl records are: | |
| 2155 | |
| 2156 .. naclcode:: | |
| 2157 | |
| 2158 <655335, 12, 2> | |
| 2159 <10> | |
| 2160 <655334> | |
| 2161 | |
| 2162 Return Value Instruction | |
| 2163 ^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 2164 | |
| 2165 The return value instruction is used to return control from a | |
| 2166 function back to the caller, including a value. The value must | |
| 2167 correspond to the return type of the enclosing function. | |
| 2168 | |
| 2169 **Syntax** | |
| 2170 | |
| 2171 .. naclcode:: | |
| 2172 | |
| 2173 ret T V; <I> | |
| 2174 %bB: | |
| 2175 | |
| 2176 **Record** | |
| 2177 | |
| 2178 .. naclcode:: | |
| 2179 | |
| 2180 I: <10, R> | |
| 2181 | |
| 2182 **Semantics** | |
| 2183 | |
| 2184 The return instruction returns control to the calling function, | |
|
Jim Stichnoth
2014/05/08 12:55:17
return instruction --> return value instruction ?
Karl
2014/06/02 22:39:29
Done.
| |
| 2185 returning the provided value. | |
| 2186 | |
| 2187 *V* is the value to return. *R* is the corresponding relative index | |
| 2188 defining the value to return. Type *T* must be of the type returned | |
| 2189 by the function. It must also be the type associated with value *V*. | |
| 2190 *I* is the (optional) abbreviation index associated with the record. | |
| 2191 | |
| 2192 *B* is the number associated with the next basic block. Label *%bB:* | |
| 2193 only appears if *B + 1 < ExpectedBasicBlocks*. That is, the label is | |
| 2194 omitted only if this terminator instruction is the last instruction in | |
| 2195 the function block. | |
| 2196 | |
| 2197 **Constraints** | |
| 2198 | |
| 2199 .. naclcode:: | |
| 2200 | |
| 2201 R = RelativeIndex(V) | |
| 2202 B == NumBasicBlocks | |
| 2203 NumBasicBlocks < ExpectedBasicBlocks | |
| 2204 T == TypeOf(V) == ReturnType(TypeOf(EnclosingFcnID)) | |
| 2205 | |
| 2206 **Updates** | |
| 2207 | |
| 2208 .. naclcode:: | |
| 2209 | |
| 2210 ++NumBasicBlocks; | |
| 2211 | |
| 2212 **Examples** | |
| 2213 | |
| 2214 The following shows a return statement that returns the value | |
| 2215 generated by the previous instruction: | |
| 2216 | |
| 2217 .. naclcode:: | |
| 2218 | |
| 2219 %v10 = add i32 %v1, @v2; | |
|
Jim Stichnoth
2014/05/08 12:55:17
If you want, you could avoid the implicit forward
Karl
2014/06/02 22:39:29
Done.
| |
| 2220 ret i32 @v10; | |
| 2221 | |
| 2222 The corresponding PNaCl records are: | |
| 2223 | |
| 2224 .. naclcode:: | |
| 2225 | |
| 2226 <2, 9, 8, 0> | |
| 2227 <10, 1> | |
| 2228 | |
| 2229 Unconditional Branch Instruction | |
| 2230 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 2231 | |
| 2232 The unconditional branch instruction is used to cause control flow to | |
| 2233 transfer to a different basic block of the function. | |
| 2234 | |
| 2235 Syntax | |
| 2236 """""" | |
| 2237 | |
| 2238 .. naclcode:: | |
| 2239 | |
| 2240 br %bN; <I> | |
| 2241 %bB: | |
| 2242 | |
| 2243 Record | |
| 2244 """""" | |
| 2245 | |
| 2246 .. naclcode:: | |
| 2247 | |
| 2248 I: <11, N> | |
| 2249 | |
| 2250 Semantics | |
| 2251 """"""""" | |
| 2252 | |
| 2253 The unconditional branch instruction causes control flow to transfer | |
| 2254 to basic block *N*. *I* is the (optional) abbreviation index | |
| 2255 associated with the record. | |
| 2256 | |
| 2257 *B* is the number associated with the next basic block. Label *%bB:* | |
| 2258 only appears if *B + 1 < ExpectedBasicBlocks*. That is, the label is | |
| 2259 omitted only if this terminator instruction is the last instruction in | |
| 2260 the function block. | |
| 2261 | |
| 2262 Constraints | |
| 2263 """"""""""" | |
| 2264 | |
| 2265 .. naclcode:: | |
| 2266 | |
| 2267 0 < N | |
| 2268 N < ExpectedBasicBlocks | |
| 2269 B == NumBasicBlocks | |
| 2270 NumBasicBlocks < ExpectedBasicBlocks | |
| 2271 | |
| 2272 Updates | |
| 2273 """"""" | |
| 2274 | |
| 2275 .. naclcode:: | |
| 2276 | |
| 2277 ++NumBasicBlocks; | |
| 2278 | |
| 2279 Examples | |
| 2280 """""""" | |
| 2281 | |
| 2282 .. naclcode:: | |
| 2283 | |
| 2284 br %b2; | |
| 2285 | |
| 2286 This branch instruction branches to the 3rd basic block of the function. It | |
| 2287 defines the following PNaCL record: | |
|
binji
2014/05/02 18:04:52
PNaCl
Karl
2014/06/02 22:39:29
Done.
| |
| 2288 | |
| 2289 .. naclcode:: | |
| 2290 | |
| 2291 <11, 2> | |
| 2292 | |
| 2293 Conditional Branch Instruction | |
| 2294 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 2295 | |
| 2296 The conditional branch instruction is used to cause control flow to | |
| 2297 transfer to a different basic block of the function, based on a | |
| 2298 boolean test condition. | |
| 2299 | |
| 2300 Syntax | |
| 2301 """""" | |
| 2302 | |
| 2303 .. naclcode:: | |
| 2304 | |
| 2305 br i1 C, %bB1, %bB2; <I> | |
| 2306 %bB: | |
| 2307 | |
| 2308 Record | |
| 2309 """""" | |
| 2310 | |
| 2311 .. naclcode:: | |
| 2312 | |
| 2313 I: <11, B1, B2, V> | |
| 2314 | |
| 2315 Semantics | |
| 2316 """"""""" | |
| 2317 | |
| 2318 Upon execution of a conditional branch instruction, the *i1* (boolean) | |
| 2319 argument *C* is evaluated. If the value is *true*, control flows to | |
| 2320 basic block *B1*. Otherwise control flows to basic block | |
| 2321 *B2*. Condition value V is the relative index of condition C. *I* is | |
| 2322 the (optional) abbreviation index associated with the record. | |
| 2323 | |
| 2324 *B* is the number associated with the next basic block. Label *%bB:* | |
| 2325 only appears if *B + 1 < ExpectedBasicBlocks*. That is, the label is | |
| 2326 omitted only if this terminator instruction is the last instruction in | |
| 2327 the function block. | |
| 2328 | |
| 2329 Constraints | |
| 2330 """"""""""" | |
| 2331 | |
| 2332 .. naclcode:: | |
| 2333 | |
| 2334 V == RelativeIndex(C) | |
| 2335 0 < B1 | |
| 2336 B1 < ExpectedBasicBlocks | |
| 2337 0 < B2 | |
| 2338 B2 < ExpectedBasicBlocks | |
| 2339 B == NumBasicBlocks and | |
| 2340 NumBasicBlocks < ExpectedBasicBlocks | |
| 2341 TypeOf(C) == i1 | |
| 2342 | |
| 2343 Updates | |
| 2344 """"""" | |
| 2345 | |
| 2346 .. naclcode:: | |
| 2347 | |
| 2348 ++NumBasicBlocks; | |
| 2349 | |
| 2350 Examples | |
| 2351 """""""" | |
| 2352 | |
| 2353 .. naclcode:: | |
| 2354 | |
| 2355 %b2: | |
| 2356 %v10 = cmp eq i32 %v8, %v9; | |
|
Jim Stichnoth
2014/05/08 12:55:17
Could avoid a forward reference to the Cmp instruc
Karl
2014/06/02 22:39:29
Can't do this. Only i32 and i64 arguments are allo
| |
| 2357 br i1 %v10, %b3, %b4; | |
| 2358 %b3: | |
| 2359 ret i32 1; | |
| 2360 %b4: | |
| 2361 ret i32 0; | |
| 2362 | |
| 2363 The record generated for the conditional branch instruction is: | |
| 2364 | |
| 2365 .. naclcode:: | |
| 2366 | |
| 2367 <11, 3, 4, 1> | |
| 2368 | |
| 2369 Unreachable | |
| 2370 ^^^^^^^^^^^ | |
| 2371 | |
| 2372 The unreachable instruction has no defined semantics. The instruction | |
| 2373 is used to inform the *PNaCl translator* that control can't reach this | |
| 2374 instruction. The most common use of this is when one calls a | |
|
Jim Stichnoth
2014/05/08 12:55:17
A more tangible/recognizable example may be the lo
Karl
2014/06/02 22:39:29
Decided to drop the clarification example.
| |
| 2375 no-return function. | |
| 2376 | |
| 2377 Syntax | |
| 2378 """""" | |
| 2379 | |
| 2380 .. naclcode:: | |
| 2381 | |
| 2382 unreachable; <I> | |
| 2383 %bB: | |
| 2384 | |
| 2385 Record | |
| 2386 """""" | |
| 2387 | |
| 2388 .. naclcode:: | |
| 2389 | |
| 2390 I: <15> | |
| 2391 | |
| 2392 Semantics | |
| 2393 """"""""" | |
| 2394 | |
| 2395 Directive to the *PNaCl translator* that this instruction is unreachable. | |
| 2396 | |
| 2397 *I* is the (optional) abbreviation index associated with the record. | |
|
jvoung (off chromium)
2014/05/27 23:18:50
Is it necessary to put these "I: " under all the R
Karl
2014/06/02 22:39:29
I agree that it is a bit repetitive. However, I ha
| |
| 2398 | |
| 2399 *B* is the number associated with the next basic block. Label *%bB:* | |
| 2400 only appears if *B + 1 < ExpectedBasicBlocks*. That is, the label is | |
| 2401 omitted only if this terminator instruction is the last instruction in | |
| 2402 the function block. | |
| 2403 | |
| 2404 Constraints | |
| 2405 """"""""""" | |
| 2406 | |
| 2407 .. naclcode:: | |
| 2408 | |
| 2409 B == NumBasicBlocks and | |
| 2410 NumBasicBlocks < ExpectedBasicBlocks | |
| 2411 | |
| 2412 Updates | |
| 2413 """"""" | |
| 2414 | |
| 2415 .. naclcode:: | |
| 2416 | |
| 2417 ++NumBasicBlocks; | |
| 2418 | |
| 2419 Examples | |
| 2420 """""""" | |
| 2421 | |
| 2422 TBD. | |
| 2423 | |
| 2424 Switch Instruction | |
| 2425 ^^^^^^^^^^^^^^^^^^ | |
| 2426 | |
| 2427 TBD. | |
| 2428 | |
| 2429 Binary Inststructions | |
|
Jim Stichnoth
2014/05/08 12:55:17
Instructions
| |
| 2430 --------------------- | |
| 2431 | |
| 2432 Binary instructions are used to do most of the computation in a | |
| 2433 program. They require two operands of the same type, execute an | |
| 2434 operation on them, and produce a value. The value may represent | |
| 2435 multiple values if the type is a vector type. The result value always | |
| 2436 has the same type as its operands. | |
| 2437 | |
| 2438 Most integer binary operations can be applied to signed and unsigned | |
| 2439 integers. In the few cases where the sign can make a difference, | |
| 2440 there are two separate binary operations, one for each case. For | |
| 2441 floating binary operations, the binary operation has the same name as | |
| 2442 the corresponding signed integer operation. One can tell whether the | |
|
Jim Stichnoth
2014/05/08 12:55:17
I don't really like this attempt at generalization
Karl
2014/06/02 22:39:29
I refactored this into two sections: Integral bina
| |
| 2443 operation is integral or floating, by the type associated with the | |
| 2444 binary operation. | |
| 2445 | |
| 2446 Add Instruction | |
| 2447 ^^^^^^^^^^^^^^^ | |
| 2448 | |
| 2449 The add instruction returns the sum of its two operands. Both | |
| 2450 arguments, and the result, must be an integer, floating, or vector | |
|
Jim Stichnoth
2014/05/08 12:55:17
"an" --> "the same", right?
Karl
2014/06/02 22:39:29
Done.
| |
| 2451 type. | |
| 2452 | |
| 2453 **Syntax** | |
| 2454 | |
| 2455 .. naclcode:: | |
| 2456 | |
| 2457 %vN = add T V1, V2; <I> | |
| 2458 | |
| 2459 **Record** | |
| 2460 | |
| 2461 I: <2, A1, A2, 0> | |
| 2462 | |
| 2463 **Semantics** | |
| 2464 | |
| 2465 The add instruction returns the sum of its two operands. Arguments | |
| 2466 *V1* and *V2*, and the result *%vN*, must be of type *T*. *T* must be | |
| 2467 an integral, floating, or vector type. *N* is defined by the record | |
| 2468 position, defining the corresponding value generated by the | |
| 2469 instruction. *I* is the (optiona) abbreviation associated with the | |
|
binji
2014/05/02 18:04:52
optional
Karl
2014/06/02 22:39:29
Done.
| |
| 2470 corresponding record. | |
| 2471 | |
| 2472 **Constraints** | |
| 2473 | |
| 2474 .. naclcode:: | |
| 2475 | |
| 2476 A1 == RelativeIndex(V1) | |
| 2477 A2 == RelativeIndex(V2) | |
| 2478 TypeOf(V1) == TypeOf(V2) | |
| 2479 N == NumValuedInsts | |
| 2480 NumBasicBlocks < ExpectedBasicBlocks | |
| 2481 | |
| 2482 **Updates** | |
| 2483 | |
| 2484 .. naclcode:: | |
| 2485 | |
| 2486 ++NumValuedInsts; | |
| 2487 TypeOf(%vN) = T | |
| 2488 | |
| 2489 **Examples** | |
| 2490 | |
| 2491 TBD. | |
| 2492 | |
| 2493 Subtract Instruction | |
| 2494 ^^^^^^^^^^^^^^^^^^^^ | |
| 2495 | |
| 2496 sub | |
| 2497 | |
| 2498 TBD. | |
| 2499 | |
| 2500 Multiply Instruction | |
| 2501 ^^^^^^^^^^^^^^^^^^^^ | |
| 2502 | |
| 2503 mul | |
| 2504 | |
| 2505 TBD. | |
| 2506 | |
| 2507 Divide Instruction | |
| 2508 ^^^^^^^^^^^^^^^^^^ | |
| 2509 | |
| 2510 div | |
| 2511 sdiv | |
| 2512 | |
| 2513 TBD. | |
| 2514 | |
| 2515 Remainder Instruction | |
| 2516 ^^^^^^^^^^^^^^^^^^^^^ | |
| 2517 | |
| 2518 div | |
| 2519 sdiv | |
|
Jim Stichnoth
2014/05/08 12:55:17
This should be rem and srem.
Karl
2014/06/02 22:39:29
Done.
| |
| 2520 | |
| 2521 TBD. | |
| 2522 | |
| 2523 Shift left Instruction | |
|
Jim Stichnoth
2014/05/08 12:55:17
left --> Left
Karl
2014/06/02 22:39:29
Done.
| |
| 2524 ^^^^^^^^^^^^^^^^^^^^^^ | |
| 2525 | |
| 2526 shl | |
| 2527 | |
| 2528 TBD. | |
| 2529 | |
| 2530 Logical Shift right Instructions | |
|
Jim Stichnoth
2014/05/08 12:55:17
right --> Right
Instructions --> Instruction
Karl
2014/06/02 22:39:29
Done.
| |
| 2531 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 2532 | |
| 2533 ashr | |
|
Jim Stichnoth
2014/05/08 12:55:17
ashr --> lshr
Karl
2014/06/02 22:39:29
Done.
| |
| 2534 | |
| 2535 TBD. | |
| 2536 | |
| 2537 Arithmetic Shift right Instructions | |
|
Jim Stichnoth
2014/05/08 12:55:17
right --> Right
Karl
2014/06/02 22:39:29
Done.
| |
| 2538 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 2539 | |
| 2540 ashr | |
| 2541 | |
| 2542 TBD. | |
| 2543 | |
| 2544 And Instruction | |
| 2545 ^^^^^^^^^^^^^^^ | |
| 2546 | |
| 2547 TBD. | |
| 2548 | |
| 2549 Or Instruction | |
| 2550 ^^^^^^^^^^^^^^ | |
| 2551 | |
| 2552 TBD. | |
| 2553 | |
| 2554 Xor Instruction | |
| 2555 ^^^^^^^^^^^^^^^ | |
| 2556 | |
| 2557 TBD. | |
| 2558 | |
| 2559 Memory creation and access Instructions | |
| 2560 --------------------------------------- | |
| 2561 | |
| 2562 TBD. | |
| 2563 | |
| 2564 Stack frame memory allocation Instruction | |
|
Jim Stichnoth
2014/05/08 12:55:17
Capitalize all words for consistency?
Karl
2014/06/02 22:39:29
Done.
| |
| 2565 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 2566 | |
| 2567 alloca | |
| 2568 | |
| 2569 TBD. | |
| 2570 | |
| 2571 Load Instruction | |
| 2572 ^^^^^^^^^^^^^^^^ | |
| 2573 | |
| 2574 load | |
| 2575 | |
| 2576 TBD. | |
| 2577 | |
| 2578 ??? Vector | |
| 2579 | |
| 2580 Store Instruction | |
| 2581 ^^^^^^^^^^^^^^^^^ | |
| 2582 | |
| 2583 store | |
| 2584 | |
| 2585 ??? Vector. | |
| 2586 | |
| 2587 Conversion Instructions | |
| 2588 ----------------------- | |
| 2589 | |
| 2590 TBD. | |
| 2591 | |
| 2592 Truncating Instructions | |
| 2593 ^^^^^^^^^^^^^^^^^^^^^^^ | |
| 2594 | |
| 2595 trunc | |
| 2596 fptrunc | |
| 2597 | |
| 2598 TBD. | |
| 2599 | |
| 2600 Extending Instructions | |
| 2601 ^^^^^^^^^^^^^^^^^^^^^^ | |
| 2602 | |
| 2603 * Extending | |
| 2604 | |
| 2605 * Type Conversion | |
| 2606 | |
| 2607 TBD. | |
| 2608 | |
| 2609 Comparison Instructions | |
| 2610 ----------------------- | |
| 2611 | |
| 2612 cmp | |
| 2613 | |
| 2614 TBD. | |
| 2615 | |
| 2616 | |
| 2617 Other Instructions | |
| 2618 ------------------ | |
| 2619 | |
| 2620 TBD. | |
| 2621 | |
| 2622 Phi Instruction | |
|
Jim Stichnoth
2014/05/08 12:55:17
Be sure to mention that within any given basic blo
Karl
2014/06/02 22:39:29
Agreed.
| |
| 2623 ^^^^^^^^^^^^^^^ | |
| 2624 | |
| 2625 TBD. | |
| 2626 | |
| 2627 Forward type declarations | |
|
Jim Stichnoth
2014/05/08 12:55:17
I know what all the other instructions are, but I
Karl
2014/06/02 22:39:29
On 2014/05/08 12:55:17, stichnot wrote:
> I know w
Jim Stichnoth
2014/06/06 18:24:46
Did you mean to add a comment here? :)
| |
| 2628 ^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 2629 | |
| 2630 TBD. | |
| 2631 | |
| 2632 | |
| 2633 Select Instruction | |
| 2634 ^^^^^^^^^^^^^^^^^^ | |
| 2635 | |
| 2636 TBD. | |
| 2637 | |
| 2638 Call Instructions | |
| 2639 ^^^^^^^^^^^^^^^^^ | |
| 2640 | |
| 2641 TBD. | |
| 2642 | |
| 2643 Intrinsic Functions | |
| 2644 ------------------- | |
| 2645 | |
| 2646 TBD. | |
| 2647 | |
| 2648 Support Functions | |
| 2649 ----------------- | |
| 2650 | |
| 2651 Defines functions used to convert syntactic representation to corresponding | |
| 2652 records. | |
| 2653 | |
| 2654 AbsoluteIndex | |
| 2655 ^^^^^^^^^^^^^ | |
| 2656 | |
| 2657 Bitcode ID's of the forms *@fN*, *@gN*, *%pN*, *%cN*, and *%vN*, are | |
| 2658 combined into a single index space. This can be done because of the | |
| 2659 ordering imposed by PNaClAsm. All function address bitcode IDs must be | |
| 2660 defined before any of the other forms of bitcode IDs. All global | |
| 2661 address bitcode IDs must be defined before any local bitcode | |
| 2662 IDs. Within a function block, the parameter bitcode IDs must be | |
| 2663 defined before constant IDs, and constant IDs must be defined before | |
| 2664 instruction value IDs. | |
| 2665 | |
| 2666 Hence, within a function block, it is safe to refer to all of these | |
| 2667 bitcode IDs using a single *absolute* index. The abolute index for | |
|
binji
2014/05/02 18:04:52
absolute
Karl
2014/06/02 22:39:29
Done.
| |
| 2668 each kind of bitcode ID is computed as follows: | |
| 2669 | |
| 2670 ========== ===================================================================== ===== | |
| 2671 Bitcode ID AbsoluteIndex | |
| 2672 ========== ===================================================================== ===== | |
| 2673 @fN N | |
| 2674 @gN N + NumDefinedFcnAddresses | |
| 2675 @pN N + NumDefinedFcnAddresses + NumGlobalAddresses | |
| 2676 @cN N + NumDefinedFcnAddresses + NumGlobalAddresses + NumParams | |
| 2677 @vN N + NumDefinedFcnAddresses + NumGlobalAddresses + NumParams + NumFcnC onsts | |
| 2678 ========== ===================================================================== ===== | |
| 2679 | |
| 2680 RelativeIndex | |
| 2681 ^^^^^^^^^^^^^ | |
| 2682 | |
| 2683 Relative indices are used to refer to values within instructions of a | |
| 2684 function. The relative index of an ID is always defined in terms of | |
| 2685 the index associated with the next value generating instruction. It is | |
| 2686 defined as follows: | |
| 2687 .. naclcode:: | |
| 2688 | |
| 2689 RelativeIndex(J) = AbsoluteIndex(NumValuedInsts) - AbsoluteIndex(J) | |
| 2690 | |
| 2691 Abbreviations | |
| 2692 ------------- | |
| 2693 | |
| 2694 TBD. | |
| 2695 | |
| 2696 Introduction | |
| 2697 ^^^^^^^^^^^^ | |
| 2698 | |
| 2699 TBD. | |
| 2700 | |
| 2701 * Blocks | |
| 2702 * Data Records | |
| 2703 * Abbreviations | |
| 2704 * Abbreviation Ids. | |
| 2705 | |
| 2706 Bitstream Format | |
| 2707 ^^^^^^^^^^^^^^^^ | |
| 2708 | |
| 2709 TBD. | |
| 2710 | |
| 2711 * Header | |
| 2712 * Block Structue | |
|
binji
2014/05/02 18:04:52
Structure
Karl
2014/06/02 22:39:29
Done.
| |
| 2713 * Primitives | |
| 2714 * Abbreviations | |
| 2715 * BlockInfoBlock | |
| 2716 | |
| 2717 Reference Implementation | |
| 2718 ------------------------ | |
| 2719 | |
| 2720 TBD. | |
| OLD | NEW |