MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / ValidateOperandForDebugInfo

Function ValidateOperandForDebugInfo

source/val/validate_extensions.cpp:129–150  ·  view source on GitHub ↗

Check that the operand of a debug info instruction |inst| at |word_index| is a result id of an instruction with |expected_opcode|.

Source from the content-addressed store, hash-verified

127// Check that the operand of a debug info instruction |inst| at |word_index|
128// is a result id of an instruction with |expected_opcode|.
129spv_result_t ValidateOperandForDebugInfo(ValidationState_t& _,
130 const std::string& operand_name,
131 spv::Op expected_opcode,
132 const Instruction* inst,
133 uint32_t word_index) {
134 auto* operand = _.FindDef(inst->word(word_index));
135 if (operand->opcode() != expected_opcode) {
136 const spvtools::InstructionDesc* desc = nullptr;
137 if (spvtools::LookupOpcodeForEnv(_.context()->target_env, expected_opcode,
138 &desc) != SPV_SUCCESS ||
139 !desc) {
140 return _.diag(SPV_ERROR_INVALID_DATA, inst)
141 << GetExtInstName(_, inst) << ": " << "expected operand "
142 << operand_name << " is invalid";
143 }
144 return _.diag(SPV_ERROR_INVALID_DATA, inst)
145 << GetExtInstName(_, inst) << ": " << "expected operand "
146 << operand_name << " must be a result id of " << "Op"
147 << desc->name().data();
148 }
149 return SPV_SUCCESS;
150}
151
152// For NonSemantic.Shader.DebugInfo.100 check that the operand of a debug info
153// instruction |inst| at |word_index| is a result id of a 32-bit integer

Callers

nothing calls this directly

Calls 9

LookupOpcodeForEnvFunction · 0.85
GetExtInstNameFunction · 0.85
FindDefMethod · 0.80
wordMethod · 0.80
diagMethod · 0.80
opcodeMethod · 0.45
contextMethod · 0.45
dataMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected