- For 32- and 64-bit floats, overflow is a parse error
This works around a difference between Xcode's istringstream
and other platforms. Xcode's runtime library will happlily
"round up" overflow values to infinity. We want to make it fail.
- When parsing a float fails due to bad syntax, follow C++11
behaviour for operator>> and set the value to zero.
- When parsing a 32-bit or 64-bit float overflows, follow C++11
behaviour for operator>> and set the value to the nearest
normal value: either max or lowest finite value for the type.
- Add FloatProxy<T>::max() and ::lowest()
- Make 16-bit overflow behaviour more consistent: we always get a
16-bit infinity of the right sign, whether the original string
is a normal value for 32-bit or an overflow value for 32-bit.
That matches our earlier intent.
Added TODO's to make 16-bit overflow always an error, just like
for 32-bit and 64-bit.
- Simplify normal parsing of Float16 values by delegating to
normal parsing of 32-bit floats.
Also checks some hex literal cases.
This addresses part of
https://github.com/KhronosGroup/SPIRV-Tools/issues/45
by removing the parseNumber case for "-0" on unsigned
integers. We don't care about that platform difference
at the level of std::istringstream, since we reject it
at a higher parsing level.
This adds half-precision constants to spirv-tools.
16-bit floats are always disassembled into hex-float format,
but can be assembled from floating point or hex-float inputs.
Add unit tests for all diagnostics issued by spvBinaryParse.
Handle image format operands in the binary parser and the
disassembler.
Document that the callback function pointers can be null,
in which case they are ignored.
Detect exhaustion of input when parsing an operand,
to avoid buffer overruns on some invalid input cases.
Fix the description strings for some operand types.
Make the diagnostic messages for those operand types
consistent between the assembler and binary parser.
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/29
The bit pattern for a hex float is preserved through
assembly and disassembly.
You can use a hex float to express Inf and any kind of NaN
in a portable way.
Zero and normal floating point values are printed with enough
enough digits to reproduce all the bits exactly.
Other float values (subnormal, infinity, and NaN) are printed
as hex floats.
Fix a binary parse bug: Count partially filled words in a
typed literal number operand.
TODO: Assembler support for hex numbers, and therefore reading
infinities and NaNs.
Note that we are more strict than Google style for one aspect:
pointer/reference indicators are adjacent to their types, not
their variables.
find . -name "*.h" -exec clang-format -i {} \;
find . -name "*.cpp" -exec clang-format -i {} \;
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.
We need to know how to generate correct SPIRV for cases like
OpConstant %int64 42 since the current parser will encode the 42 as a
32-bit value incorrectly.
This change is the first of a pair. This one tracks types, and makes
sure that OpConstant and OpSpecConstant are only ever called with
Integer or Float types, and OpSwitch is only called with integer
generating values.
Make it a class, since it has non-trivial behaviour for converting
the enumerated value to a uint32_t value. (Comply with style guide.)
Merge EnumCaseWithOperands into EnumCase.
Fixed an issue where some of the tests were testing
the wrong word with the wrong operation. (| != ||).
Coalesced the many versions of EnumCase into one.
Added a get_value() to EnumCase to convert to a uint32_t.
Replaces ASSERT_TRUE(pointer), with ASSERT_NE(nullptr, pointer),
so that we do not do implicit pointer->bool conversion.
Removed const from some test structs since gtest needs to be
able to swap them.