Skip to content

Commit

Permalink
Add operand types for SPV_NV_raw_access_chains (#5602)
Browse files Browse the repository at this point in the history
This is needed to unblock builds with updated SPIR-V headers.
It is not a replacement for #5568.
  • Loading branch information
rlocatti-nv authored Mar 6, 2024
1 parent 5bc7c28 commit 7c36305
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions include/spirv-tools/libspirv.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,10 @@ typedef enum spv_operand_type_t {
SPV_OPERAND_TYPE_STORE_CACHE_CONTROL,
// Enum type from SPV_INTEL_maximum_registers
SPV_OPERAND_TYPE_NAMED_MAXIMUM_NUMBER_OF_REGISTERS,
// Enum type from SPV_NV_raw_access_chains
SPV_OPERAND_TYPE_RAW_ACCESS_CHAIN_OPERANDS,
// Optional enum type from SPV_NV_raw_access_chains
SPV_OPERAND_TYPE_OPTIONAL_RAW_ACCESS_CHAIN_OPERANDS,

// This is a sentinel value, and does not represent an operand type.
// It should come last.
Expand Down
5 changes: 4 additions & 1 deletion source/binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,7 @@ spv_result_t Parser::parseOperand(size_t inst_offset,
case SPV_OPERAND_TYPE_IMAGE:
case SPV_OPERAND_TYPE_OPTIONAL_IMAGE:
case SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS:
case SPV_OPERAND_TYPE_OPTIONAL_RAW_ACCESS_CHAIN_OPERANDS:
case SPV_OPERAND_TYPE_SELECTION_CONTROL:
case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_INFO_FLAGS:
case SPV_OPERAND_TYPE_DEBUG_INFO_FLAGS:
Expand All @@ -721,10 +722,12 @@ spv_result_t Parser::parseOperand(size_t inst_offset,
// Map an optional operand type to its corresponding concrete type.
if (type == SPV_OPERAND_TYPE_OPTIONAL_IMAGE)
parsed_operand.type = SPV_OPERAND_TYPE_IMAGE;
else if (type == SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS)
if (type == SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS)
parsed_operand.type = SPV_OPERAND_TYPE_MEMORY_ACCESS;
if (type == SPV_OPERAND_TYPE_OPTIONAL_COOPERATIVE_MATRIX_OPERANDS)
parsed_operand.type = SPV_OPERAND_TYPE_COOPERATIVE_MATRIX_OPERANDS;
if (type == SPV_OPERAND_TYPE_OPTIONAL_RAW_ACCESS_CHAIN_OPERANDS)
parsed_operand.type = SPV_OPERAND_TYPE_RAW_ACCESS_CHAIN_OPERANDS;

// Check validity of set mask bits. Also prepare for operands for those
// masks if they have any. To get operand order correct, scan from
Expand Down
1 change: 1 addition & 0 deletions source/disassemble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ void InstructionDisassembler::EmitOperand(const spv_parsed_instruction_t& inst,
case SPV_OPERAND_TYPE_SELECTION_CONTROL:
case SPV_OPERAND_TYPE_DEBUG_INFO_FLAGS:
case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_INFO_FLAGS:
case SPV_OPERAND_TYPE_RAW_ACCESS_CHAIN_OPERANDS:
EmitMaskOperand(operand.type, word);
break;
default:
Expand Down
5 changes: 5 additions & 0 deletions source/operand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ const char* spvOperandTypeStr(spv_operand_type_t type) {
return "store cache control";
case SPV_OPERAND_TYPE_NAMED_MAXIMUM_NUMBER_OF_REGISTERS:
return "named maximum number of registers";
case SPV_OPERAND_TYPE_RAW_ACCESS_CHAIN_OPERANDS:
case SPV_OPERAND_TYPE_OPTIONAL_RAW_ACCESS_CHAIN_OPERANDS:
return "raw access chain operands";
case SPV_OPERAND_TYPE_IMAGE:
case SPV_OPERAND_TYPE_OPTIONAL_IMAGE:
return "image";
Expand Down Expand Up @@ -382,6 +385,7 @@ bool spvOperandIsConcreteMask(spv_operand_type_t type) {
case SPV_OPERAND_TYPE_DEBUG_INFO_FLAGS:
case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_INFO_FLAGS:
case SPV_OPERAND_TYPE_COOPERATIVE_MATRIX_OPERANDS:
case SPV_OPERAND_TYPE_RAW_ACCESS_CHAIN_OPERANDS:
return true;
default:
break;
Expand All @@ -402,6 +406,7 @@ bool spvOperandIsOptional(spv_operand_type_t type) {
case SPV_OPERAND_TYPE_OPTIONAL_PACKED_VECTOR_FORMAT:
case SPV_OPERAND_TYPE_OPTIONAL_COOPERATIVE_MATRIX_OPERANDS:
case SPV_OPERAND_TYPE_OPTIONAL_CIV:
case SPV_OPERAND_TYPE_OPTIONAL_RAW_ACCESS_CHAIN_OPERANDS:
return true;
default:
break;
Expand Down
1 change: 1 addition & 0 deletions source/text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ spv_result_t spvTextEncodeOperand(const spvtools::AssemblyGrammar& grammar,
case SPV_OPERAND_TYPE_IMAGE:
case SPV_OPERAND_TYPE_OPTIONAL_IMAGE:
case SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS:
case SPV_OPERAND_TYPE_OPTIONAL_RAW_ACCESS_CHAIN_OPERANDS:
case SPV_OPERAND_TYPE_SELECTION_CONTROL:
case SPV_OPERAND_TYPE_DEBUG_INFO_FLAGS:
case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_INFO_FLAGS:
Expand Down
2 changes: 1 addition & 1 deletion utils/generate_grammar_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ def generate_operand_kind_table(enums):

# We have a few operand kinds that require their optional counterpart to
# exist in the operand info table.
optional_enums = ['ImageOperands', 'AccessQualifier', 'MemoryAccess', 'PackedVectorFormat', 'CooperativeMatrixOperands']
optional_enums = ['ImageOperands', 'AccessQualifier', 'MemoryAccess', 'PackedVectorFormat', 'CooperativeMatrixOperands', 'RawAccessChainOperands']
optional_enums = [e for e in enums if e[0] in optional_enums]
enums.extend(optional_enums)

Expand Down

0 comments on commit 7c36305

Please sign in to comment.