Make spvOpcodeString part of the public API (#3174)

Fixes #3138
This commit is contained in:
Steven Perron 2020-02-20 14:07:57 -05:00 коммит произвёл GitHub
Родитель 03794b8f5e
Коммит 4a80497a88
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 10 добавлений и 6 удалений

Просмотреть файл

@ -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.

Просмотреть файл

@ -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<const SpvOp>(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;
};

Просмотреть файл

@ -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);