mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-11-27 13:50:07 +00:00
1773b95737
Pull out the number parsing logic from AssemblyContext::binaryEncodeNumericLiteral() to utilities. The new utility function: `ParseAndEncodeNumber()` now accepts: * number text to parse * number type * a emit function, which is a function which will be called with each parsed uint32 word. * a pointer to std::string to be overwritten with error messages. (pass nullptr if expect no error message) and returns: * an enum result type to indicate the status Type/Structs moved to utility: * template<typename T> class ClampToZeroIfUnsignedType New type: * enum EncodeNumberStatus: success or error code * NumberType: hold the number type information for the number to be parsed. * several helper functions are also added for NumberType. Functions moved to utility: * Helpers: * template<typename T> checkRangeAndIfHexThenSignExtend() -> CheckRangeAndIfHex....() * Interfaces: * template<typename T> parseNumber() -> ParseNumber() * binaryEncodeIntegerLiteral() -> ParseAndEncodeIntegerNumber() * binaryEncodeFloatingPointLiteral() -> ParseAndEncodeFloatingPointNumber() * binaryEncodeNumericLiteral() -> ParseAndEncodeNumber() Tests added/moved to test/ParseNumber.cpp, including tests for: * ParseNumber(): This is moved from TextToBinary.cpp to ParseNumber.cpp * ParseAndEncodeIntegerNumber(): New added * ParseAndEncodeFloatingPointNumber(): New added * ParseAndEncodeNumber(): New added Note that the error messages are kept almost the same as before, but they may be inappropriate for an utility function. Those will be fixed in another CL. |
||
---|---|---|
.. | ||
opt | ||
util | ||
val | ||
assembly_grammar.cpp | ||
assembly_grammar.h | ||
binary.cpp | ||
binary.h | ||
CMakeLists.txt | ||
diagnostic.cpp | ||
diagnostic.h | ||
disassemble.cpp | ||
enum_set.cpp | ||
enum_set.h | ||
ext_inst.cpp | ||
ext_inst.h | ||
extinst-1.0.opencl.std.grammar.json | ||
instruction.cpp | ||
instruction.h | ||
macro.h | ||
name_mapper.cpp | ||
name_mapper.h | ||
opcode.cpp | ||
opcode.h | ||
operand.cpp | ||
operand.h | ||
print.cpp | ||
print.h | ||
software_version.cpp | ||
spirv_constant.h | ||
spirv_definition.h | ||
spirv_endian.cpp | ||
spirv_endian.h | ||
spirv_target_env.cpp | ||
spirv_target_env.h | ||
table.cpp | ||
table.h | ||
text_handler.cpp | ||
text_handler.h | ||
text.cpp | ||
text.h | ||
validate_cfg.cpp | ||
validate_id.cpp | ||
validate_instruction.cpp | ||
validate_layout.cpp | ||
validate.cpp | ||
validate.h |