Skip to content

Commit a081752

Browse files
authored
properly handle the load and store cache control operand types (KhronosGroup#5664)
* properly handle the load and store cache control operand types Without handling these operand types, disassembling a SPIR-V module that uses the cache control extension produces an invalid operand type error. * add a round trip test for SPV_INTEL_cache_controls
1 parent d1b35bb commit a081752

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

source/binary.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,8 @@ spv_result_t Parser::parseOperand(size_t inst_offset,
673673
case SPV_OPERAND_TYPE_OPTIONAL_PACKED_VECTOR_FORMAT:
674674
case SPV_OPERAND_TYPE_FPENCODING:
675675
case SPV_OPERAND_TYPE_OPTIONAL_FPENCODING:
676+
case SPV_OPERAND_TYPE_LOAD_CACHE_CONTROL:
677+
case SPV_OPERAND_TYPE_STORE_CACHE_CONTROL:
676678
case SPV_OPERAND_TYPE_NAMED_MAXIMUM_NUMBER_OF_REGISTERS: {
677679
// A single word that is a plain enum value.
678680

test/binary_to_text_test.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,22 @@ INSTANTIATE_TEST_SUITE_P(
402402
"OpDecorateId %1 MaxByteOffsetId %2\n",
403403
})));
404404

405+
INSTANTIATE_TEST_SUITE_P(
406+
CacheControlsINTEL, RoundTripInstructionsTest,
407+
Combine(
408+
::testing::Values(SPV_ENV_UNIVERSAL_1_0),
409+
::testing::ValuesIn(std::vector<std::string>{
410+
"OpDecorate %1 CacheControlLoadINTEL 0 UncachedINTEL\n",
411+
"OpDecorate %1 CacheControlLoadINTEL 1 CachedINTEL\n",
412+
"OpDecorate %1 CacheControlLoadINTEL 2 StreamingINTEL\n",
413+
"OpDecorate %1 CacheControlLoadINTEL 3 InvalidateAfterReadINTEL\n",
414+
"OpDecorate %1 CacheControlLoadINTEL 4 ConstCachedINTEL\n",
415+
"OpDecorate %1 CacheControlStoreINTEL 0 UncachedINTEL\n",
416+
"OpDecorate %1 CacheControlStoreINTEL 1 WriteThroughINTEL\n",
417+
"OpDecorate %1 CacheControlStoreINTEL 2 WriteBackINTEL\n",
418+
"OpDecorate %1 CacheControlStoreINTEL 3 StreamingINTEL\n",
419+
})));
420+
405421
using MaskSorting = TextToBinaryTest;
406422

407423
TEST_F(MaskSorting, MasksAreSortedFromLSBToMSB) {

0 commit comments

Comments
 (0)