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

Function GetNumericIds

source/text.cpp:864–893  ·  view source on GitHub ↗

Collects all numeric ids in the module source into |numeric_ids|. This function is essentially a dry-run of spvTextToBinary.

Source from the content-addressed store, hash-verified

862// Collects all numeric ids in the module source into |numeric_ids|.
863// This function is essentially a dry-run of spvTextToBinary.
864spv_result_t GetNumericIds(const spvtools::AssemblyGrammar& grammar,
865 const spvtools::MessageConsumer& consumer,
866 const spv_text text,
867 std::set<uint32_t>* numeric_ids) {
868 spvtools::AssemblyContext context(text, consumer);
869
870 if (!text->str) return context.diagnostic() << "Missing assembly text.";
871
872 // Skip past whitespace and comments.
873 context.advance();
874
875 while (context.hasText()) {
876 spv_instruction_t inst;
877
878 // Operand parsing sometimes involves knowing the opcode of the instruction
879 // being parsed. A malformed input might feature such an operand *before*
880 // the opcode is known. To guard against accessing an uninitialized opcode,
881 // the instruction's opcode is initialized to a default value.
882 inst.opcode = spv::Op::Max;
883
884 if (spvTextEncodeOpcode(grammar, &context, &inst)) {
885 return SPV_ERROR_INVALID_TEXT;
886 }
887
888 if (context.advance()) break;
889 }
890
891 *numeric_ids = context.GetNumericIds();
892 return SPV_SUCCESS;
893}
894
895// Translates a given assembly language module into binary form.
896// If a diagnostic is generated, it is not yet marked as being

Callers 1

spvTextToBinaryInternalFunction · 0.85

Calls 5

spvTextEncodeOpcodeFunction · 0.85
advanceMethod · 0.80
hasTextMethod · 0.80
GetNumericIdsMethod · 0.80
diagnosticMethod · 0.45

Tested by

no test coverage detected