diff --git a/include/spirv-tools/libspirv.h b/include/spirv-tools/libspirv.h index d63f3634..21a9608f 100644 --- a/include/spirv-tools/libspirv.h +++ b/include/spirv-tools/libspirv.h @@ -766,6 +766,9 @@ SPIRV_TOOLS_EXPORT void spvDiagnosticDestroy(spv_diagnostic diagnostic); SPIRV_TOOLS_EXPORT spv_result_t spvDiagnosticPrint(const spv_diagnostic diagnostic); +// Gets the name of an instruction, without the "Op" prefix. +SPIRV_TOOLS_EXPORT const char* spvOpcodeString(const uint32_t opcode); + // The binary parser interface. // A pointer to a function that accepts a parsed SPIR-V header. diff --git a/source/opcode.cpp b/source/opcode.cpp index 7f91a0ff..b03db165 100644 --- a/source/opcode.cpp +++ b/source/opcode.cpp @@ -181,11 +181,15 @@ void spvInstructionCopy(const uint32_t* words, const SpvOp opcode, } } -const char* spvOpcodeString(const SpvOp opcode) { +const char* spvOpcodeString(const uint32_t opcode) { const auto beg = kOpcodeTableEntries; const auto end = kOpcodeTableEntries + ARRAY_SIZE(kOpcodeTableEntries); - spv_opcode_desc_t needle = {"", opcode, 0, nullptr, 0, {}, - false, false, 0, nullptr, ~0u, ~0u}; + spv_opcode_desc_t needle = {"", static_cast(opcode), + 0, nullptr, + 0, {}, + false, false, + 0, nullptr, + ~0u, ~0u}; auto comp = [](const spv_opcode_desc_t& lhs, const spv_opcode_desc_t& rhs) { return lhs.opcode < rhs.opcode; }; diff --git a/source/opcode.h b/source/opcode.h index ed64f1b5..f79826fc 100644 --- a/source/opcode.h +++ b/source/opcode.h @@ -56,9 +56,6 @@ void spvInstructionCopy(const uint32_t* words, const SpvOp opcode, const uint16_t word_count, const spv_endianness_t endian, spv_instruction_t* inst); -// Gets the name of an instruction, without the "Op" prefix. -const char* spvOpcodeString(const SpvOp opcode); - // Determine if the given opcode is a scalar type. Returns zero if false, // non-zero otherwise. int32_t spvOpcodeIsScalarType(const SpvOp opcode);