diff options
author | David Neto <dneto@google.com> | 2015-10-05 13:28:46 -0400 |
---|---|---|
committer | David Neto <dneto@google.com> | 2015-10-26 12:55:33 -0400 |
commit | 78e677b5cd57815ab7f9e7a391aa7f47aceb8b1b (patch) | |
tree | f3a4dd4ef5eca0eec543a1ac6e3ff16614c62beb /syntax.md | |
parent | 6274120eb9f4c4f53f5d5f6637916eea1da0d5af (diff) | |
download | spirv-tools-78e677b5cd57815ab7f9e7a391aa7f47aceb8b1b.tar.gz |
Parse and encode literal integers to the right width
Affects OpConstant, and OpSwitch.
Adds constant libspirv::kUnknownType for readability.
Adds tests for hexadecimal number parsing.
Updates syntax.md to describe hex parsing, including
sign extension.
Diffstat (limited to 'syntax.md')
-rw-r--r-- | syntax.md | 18 |
1 files changed, 11 insertions, 7 deletions
@@ -27,10 +27,13 @@ but the assembler does not enforce this rule. The opcode names and expected operands are described in section 3 of the SPIR-V specification. An operand is one of: -* a literal integer: A decimal integer, or a hexadecimal integer - (indicated by a leading `0x`). +* a literal integer: A decimal integer, or a hexadecimal integer. + A hexadecimal integer is indicated by a leading `0x` or `0X`. A hex + integer supplied for a signed integer value will be sign-extended. + For example, `0xffff` supplied as the literal for an `OpConstant` + on a signed 16-bit integer type will be interpreted as the value `-1`. * a literal floating point number. -* a literal string, surrounded by double-quotes ("). TODO: describe quoting and +* a literal string, surrounded by double-quotes `"`. TODO: describe quoting and escaping rules. * a named enumerated value, specific to that operand position. For example, the `OpMemoryModel` takes a named Addressing Model operand (e.g. `Logical` or @@ -151,10 +154,11 @@ instruction.) The assembler processes the tokens encountered in alternate parsing mode as follows: -* If the token is a number literal, it outputs that number as one or more words, - as defined in the SPIR-V specification for Literal Number. The number must - fit within the unsigned 32-bit range. All formats supported by `strtoul()` - are accepted. +* If the token is a number literal, since context may be lost, the number + is interpreted as a 32-bit value and output as a single word. In order to + specify multiple-word literals in alternate-parsing mode, further uses of + `!<integer>` tokens may be required. + All formats supported by `strtoul()` are accepted. * If the token is a string literal, it outputs a sequence of words representing the string as defined in the SPIR-V specification for Literal String. * If the token is an ID, it outputs the ID's internal number. |