mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-11-21 19:20:07 +00:00
02433568af
Sometimes when debugging or logging, SPIR-V may be dumped as a stream of hex values. There are tools to convert such a stream to binary (such as [1]) but they create an inconvenient extra step when for example the disassembly of that hex stream is needed. [1]: https://www.khronos.org/spir/visualizer/hexdump.html In this change, the binary reader used by the tools is enhanced to detect when the binary is actually a hex stream, and parse that instead. The following formats are accepted, detected based on how the SPIR-V magic number is output: === Words If the first token of the hex stream is one of 0x07230203, 0x7230203, x07230203, or x7230203, the hex stream is expected to consist of 32-bit hex words prefixed with 0x or x. For example: 0x7230203, 0x10400, 0x180001, 0x79, 0x0 is parsed as: 0x07230203 0x00010400 0x00180001 0x00000079 0x00000000 Note that `,` is optional in the stream, but the hex values are expected to be delimited by either `,` or whitespace. === Bytes With Prefix If the first token of the hex stream is one of 0x07, 0x7, x07, x7, 0x03, 0x3, x03, or x3, the hex stream is expected to consist of 8-bit hex bytes prefixed with 0x or x. If the first token has a value of 7, the stream is big-endian. Otherwise it's little-endian. For example: 0x3, 0x2, 0x23, 0x7, 0x0, 0x4, 0x1, 0x0, 0x1, 0x0, 0x18, 0x0, 0x79, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 is parsed as: 0x07230203 0x00010400 0x00180001 0x00000079 0x00000000 Similar to "Words", `,` is optional in the stream, but the hex values are expected to be delimited by either `,` or whitespace. === Bytes Without Prefix If the first two characters of the hex stream is 07, or 03, the hex stream is expected to consist of 8-bit hex bytes of 2 characters each. If the first token is 07, the stream is big-endian. Otherwise it's little-endian. Unlike the other modes, delimiter is optional (which automatically handles 32-bit word streams), but no 0-padding is done. For example, all of the following: 03, 02, 23, 07, 00, 04, 01, 00, 01, 00, 18, 00, 79, 00, 00, 00, 00, 00, 00, 00 03 02 23 07 00 04 01 00 01 00 18 00 79 00 00 00 00 00 00 00 03022307 00040100 01001800 79000000 00000000 07,23,02,03,00,01,04,00,00,18,00,01,00,00,00,79,00,00,00,00 07230203, 00010400, 00180001, 00000079, 00000000 are parsed as: 0x07230203 0x00010400 0x00180001 0x00000079 0x00000000 |
||
---|---|---|
.. | ||
diff | ||
fuzz | ||
fuzzers | ||
link | ||
lint | ||
opt | ||
reduce | ||
scripts | ||
tools | ||
util | ||
val | ||
wasm | ||
assembly_context_test.cpp | ||
assembly_format_test.cpp | ||
binary_destroy_test.cpp | ||
binary_endianness_test.cpp | ||
binary_header_get_test.cpp | ||
binary_parse_test.cpp | ||
binary_strnlen_s_test.cpp | ||
binary_to_text_test.cpp | ||
binary_to_text.literal_test.cpp | ||
c_interface_test.cpp | ||
CMakeLists.txt | ||
comment_test.cpp | ||
cpp_interface_test.cpp | ||
diagnostic_test.cpp | ||
enum_set_test.cpp | ||
enum_string_mapping_test.cpp | ||
ext_inst.cldebug100_test.cpp | ||
ext_inst.debuginfo_test.cpp | ||
ext_inst.glsl_test.cpp | ||
ext_inst.non_semantic_test.cpp | ||
ext_inst.opencl_test.cpp | ||
fix_word_test.cpp | ||
generator_magic_number_test.cpp | ||
hex_float_test.cpp | ||
hex_to_text_test.cpp | ||
immediate_int_test.cpp | ||
libspirv_macros_test.cpp | ||
name_mapper_test.cpp | ||
named_id_test.cpp | ||
opcode_make_test.cpp | ||
opcode_require_capabilities_test.cpp | ||
opcode_split_test.cpp | ||
opcode_table_get_test.cpp | ||
operand_capabilities_test.cpp | ||
operand_pattern_test.cpp | ||
operand_test.cpp | ||
operand-class-test-coverage.csv | ||
parse_number_test.cpp | ||
pch_test.cpp | ||
pch_test.h | ||
preserve_numeric_ids_test.cpp | ||
software_version_test.cpp | ||
string_utils_test.cpp | ||
target_env_test.cpp | ||
test_fixture.h | ||
text_advance_test.cpp | ||
text_destroy_test.cpp | ||
text_literal_test.cpp | ||
text_start_new_inst_test.cpp | ||
text_to_binary_test.cpp | ||
text_to_binary.annotation_test.cpp | ||
text_to_binary.barrier_test.cpp | ||
text_to_binary.composite_test.cpp | ||
text_to_binary.constant_test.cpp | ||
text_to_binary.control_flow_test.cpp | ||
text_to_binary.debug_test.cpp | ||
text_to_binary.device_side_enqueue_test.cpp | ||
text_to_binary.extension_test.cpp | ||
text_to_binary.function_test.cpp | ||
text_to_binary.group_test.cpp | ||
text_to_binary.image_test.cpp | ||
text_to_binary.literal_test.cpp | ||
text_to_binary.memory_test.cpp | ||
text_to_binary.misc_test.cpp | ||
text_to_binary.mode_setting_test.cpp | ||
text_to_binary.pipe_storage_test.cpp | ||
text_to_binary.reserved_sampling_test.cpp | ||
text_to_binary.subgroup_dispatch_test.cpp | ||
text_to_binary.type_declaration_test.cpp | ||
text_word_get_test.cpp | ||
timer_test.cpp | ||
to_string_test.cpp | ||
unit_spirv.cpp | ||
unit_spirv.h |