Returns the declared NSDI version from the OpExtInstImport referenced by |inst|. Returns 0 if not a NonSemantic.Shader.DebugInfo import.
| 115 | // Returns the declared NSDI version from the OpExtInstImport referenced by |
| 116 | // |inst|. Returns 0 if not a NonSemantic.Shader.DebugInfo import. |
| 117 | uint32_t GetNSDIVersion(const ValidationState_t& _, const Instruction* inst) { |
| 118 | const auto* import_inst = _.FindDef(inst->word(3)); |
| 119 | if (!import_inst) return 0; |
| 120 | const std::string name = import_inst->GetOperandAs<std::string>(1); |
| 121 | const char kPrefix[] = "NonSemantic.Shader.DebugInfo."; |
| 122 | if (name.find(kPrefix) != 0) return 0; |
| 123 | return static_cast<uint32_t>( |
| 124 | std::strtoul(name.c_str() + sizeof(kPrefix) - 1, nullptr, 10)); |
| 125 | } |
| 126 | |
| 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|. |
no test coverage detected