mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-10-18 11:10:05 +00:00
Remove stale code.
This commit is contained in:
parent
712bed0227
commit
2923806314
@ -39,14 +39,4 @@ spv_result_t spvBinaryHeaderGet(const spv_const_binary binary,
|
||||
const spv_endianness_t endian,
|
||||
spv_header_t* header);
|
||||
|
||||
// Determines the desired type of an operand. The operand's value is word, and
|
||||
// is the index-th word in the instruction described by the opcode_entry opcode
|
||||
// table entry. On success, returns SPV_SUCCESS and writes a handle of the
|
||||
// operand table entry for this operand into *operand_entry.
|
||||
spv_operand_type_t spvBinaryOperandInfo(const uint32_t word,
|
||||
const uint16_t index,
|
||||
const spv_opcode_desc opcode_entry,
|
||||
const spv_operand_table operand_table,
|
||||
spv_operand_desc* operand_entry);
|
||||
|
||||
#endif // LIBSPIRV_BINARY_H_
|
||||
|
@ -83,21 +83,10 @@ int32_t spvOpcodeIsConstant(const SpvOp opcode);
|
||||
// non-zero otherwise.
|
||||
int32_t spvOpcodeIsComposite(const SpvOp opcode);
|
||||
|
||||
// Deep equal comparison of type declaration instructions. Returns zero if
|
||||
// false, non-zero otherwise.
|
||||
int32_t spvOpcodeAreTypesEqual(const spv_instruction_t* type_inst0,
|
||||
const spv_instruction_t* type_inst1);
|
||||
|
||||
// Determines if the given opcode results in a pointer. Returns zero if false,
|
||||
// non-zero otherwise.
|
||||
int32_t spvOpcodeIsPointer(const SpvOp opcode);
|
||||
|
||||
// Determines if an instruction is in a basic block. The first_inst parameter
|
||||
// specifies the first instruction in the stream, while the inst parameter
|
||||
// specifies the current instruction. Returns zero if false, non-zero otherwise.
|
||||
int32_t spvInstructionIsInBasicBlock(const spv_instruction_t* first_inst,
|
||||
const spv_instruction_t* inst);
|
||||
|
||||
// Determines if the given opcode generates a type. Returns zero if false,
|
||||
// non-zero otherwise.
|
||||
int32_t spvOpcodeGeneratesType(SpvOp opcode);
|
||||
|
@ -59,152 +59,6 @@ using libspirv::ModuleLayoutPass;
|
||||
using libspirv::SsaPass;
|
||||
using libspirv::ValidationState_t;
|
||||
|
||||
#if 0
|
||||
spv_result_t spvValidateOperandsString(const uint32_t* words,
|
||||
const uint16_t wordCount,
|
||||
spv_position position,
|
||||
spv_diagnostic* pDiagnostic) {
|
||||
const char* str = (const char*)words;
|
||||
uint64_t strWordCount = strlen(str) / sizeof(uint32_t) + 1;
|
||||
if (strWordCount < wordCount) {
|
||||
DIAGNOSTIC << "Instruction word count is too short, string extends past "
|
||||
"end of instruction.";
|
||||
return SPV_WARNING;
|
||||
}
|
||||
return SPV_SUCCESS;
|
||||
}
|
||||
|
||||
spv_result_t spvValidateOperandsLiteral(const uint32_t* words,
|
||||
const uint32_t length,
|
||||
const uint16_t maxLength,
|
||||
spv_position position,
|
||||
spv_diagnostic* pDiagnostic) {
|
||||
// NOTE: A literal could either be a number consuming up to 2 words or a
|
||||
// null terminated string.
|
||||
(void)words;
|
||||
(void)length;
|
||||
(void)maxLength;
|
||||
(void)position;
|
||||
(void)pDiagnostic;
|
||||
return SPV_UNSUPPORTED;
|
||||
}
|
||||
|
||||
spv_result_t spvValidateOperandValue(const spv_operand_type_t type,
|
||||
const uint32_t word,
|
||||
const spv_operand_table operandTable,
|
||||
spv_position position,
|
||||
spv_diagnostic* pDiagnostic) {
|
||||
switch (type) {
|
||||
case SPV_OPERAND_TYPE_ID:
|
||||
case SPV_OPERAND_TYPE_TYPE_ID:
|
||||
case SPV_OPERAND_TYPE_RESULT_ID:
|
||||
case SPV_OPERAND_TYPE_MEMORY_SEMANTICS_ID:
|
||||
case SPV_OPERAND_TYPE_SCOPE_ID: {
|
||||
// NOTE: ID's are validated in SPV_VALIDATION_LEVEL_1, this is
|
||||
// SPV_VALIDATION_LEVEL_0
|
||||
} break;
|
||||
case SPV_OPERAND_TYPE_LITERAL_INTEGER: {
|
||||
// NOTE: Implicitly valid as they are encoded as 32 bit value
|
||||
} break;
|
||||
case SPV_OPERAND_TYPE_SOURCE_LANGUAGE:
|
||||
case SPV_OPERAND_TYPE_EXECUTION_MODEL:
|
||||
case SPV_OPERAND_TYPE_ADDRESSING_MODEL:
|
||||
case SPV_OPERAND_TYPE_MEMORY_MODEL:
|
||||
case SPV_OPERAND_TYPE_EXECUTION_MODE:
|
||||
case SPV_OPERAND_TYPE_STORAGE_CLASS:
|
||||
case SPV_OPERAND_TYPE_DIMENSIONALITY:
|
||||
case SPV_OPERAND_TYPE_SAMPLER_ADDRESSING_MODE:
|
||||
case SPV_OPERAND_TYPE_SAMPLER_FILTER_MODE:
|
||||
case SPV_OPERAND_TYPE_FP_FAST_MATH_MODE:
|
||||
case SPV_OPERAND_TYPE_FP_ROUNDING_MODE:
|
||||
case SPV_OPERAND_TYPE_LINKAGE_TYPE:
|
||||
case SPV_OPERAND_TYPE_ACCESS_QUALIFIER:
|
||||
case SPV_OPERAND_TYPE_FUNCTION_PARAMETER_ATTRIBUTE:
|
||||
case SPV_OPERAND_TYPE_DECORATION:
|
||||
case SPV_OPERAND_TYPE_BUILT_IN:
|
||||
case SPV_OPERAND_TYPE_SELECTION_CONTROL:
|
||||
case SPV_OPERAND_TYPE_LOOP_CONTROL:
|
||||
case SPV_OPERAND_TYPE_FUNCTION_CONTROL:
|
||||
case SPV_OPERAND_TYPE_MEMORY_SEMANTICS_ID:
|
||||
case SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS:
|
||||
case SPV_OPERAND_TYPE_SCOPE_ID:
|
||||
case SPV_OPERAND_TYPE_GROUP_OPERATION:
|
||||
case SPV_OPERAND_TYPE_KERNEL_ENQ_FLAGS:
|
||||
case SPV_OPERAND_TYPE_KERNEL_PROFILING_INFO: {
|
||||
spv_operand_desc operandEntry = nullptr;
|
||||
spv_result_t error =
|
||||
spvOperandTableValueLookup(operandTable, type, word, &operandEntry);
|
||||
if (error) {
|
||||
DIAGNOSTIC << "Invalid '" << spvOperandTypeStr(type) << "' operand '"
|
||||
<< word << "'.";
|
||||
return error;
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
assert(0 && "Invalid operand types should already have been caught!");
|
||||
}
|
||||
return SPV_SUCCESS;
|
||||
}
|
||||
|
||||
spv_result_t spvValidateBasic(const spv_instruction_t* pInsts,
|
||||
const uint64_t instCount,
|
||||
const spv_opcode_table opcodeTable,
|
||||
const spv_operand_table operandTable,
|
||||
spv_position position,
|
||||
spv_diagnostic* pDiagnostic) {
|
||||
for (uint64_t instIndex = 0; instIndex < instCount; ++instIndex) {
|
||||
const uint32_t* words = pInsts[instIndex].words.data();
|
||||
uint16_t wordCount;
|
||||
SpvOp opcode;
|
||||
spvOpcodeSplit(words[0], &wordCount, &opcode);
|
||||
|
||||
spv_opcode_desc opcodeEntry = nullptr;
|
||||
if (spvOpcodeTableValueLookup(opcodeTable, opcode, &opcodeEntry)) {
|
||||
DIAGNOSTIC << "Invalid Opcode '" << opcode << "'.";
|
||||
return SPV_ERROR_INVALID_BINARY;
|
||||
}
|
||||
position->index++;
|
||||
|
||||
if (opcodeEntry->numTypes > wordCount) {
|
||||
DIAGNOSTIC << "Instruction word count '" << wordCount
|
||||
<< "' is not small, expected at least '"
|
||||
<< opcodeEntry->numTypes << "'.";
|
||||
return SPV_ERROR_INVALID_BINARY;
|
||||
}
|
||||
|
||||
spv_operand_desc operandEntry = nullptr;
|
||||
for (uint16_t index = 1; index < pInsts[instIndex].words.size();
|
||||
++index, position->index++) {
|
||||
const uint32_t word = words[index];
|
||||
|
||||
// TODO(dneto): This strategy is inadequate for dealing with operations
|
||||
// with varying kinds or numbers of logical operands. See the definition
|
||||
// of spvBinaryOperandInfo for more.
|
||||
// We should really parse the instruction and capture and use
|
||||
// the elaborated list of logical operands generated as a side effect
|
||||
// of the parse.
|
||||
spv_operand_type_t type = spvBinaryOperandInfo(
|
||||
word, index, opcodeEntry, operandTable, &operandEntry);
|
||||
|
||||
if (SPV_OPERAND_TYPE_LITERAL_STRING == type) {
|
||||
spvCheckReturn(spvValidateOperandsString(
|
||||
words + index, wordCount - index, position, pDiagnostic));
|
||||
// NOTE: String literals are always at the end of Opcodes
|
||||
break;
|
||||
} else if (SPV_OPERAND_TYPE_LITERAL_INTEGER == type) {
|
||||
// spvCheckReturn(spvValidateOperandsNumber(
|
||||
// words + index, wordCount - index, 2, position, pDiagnostic));
|
||||
} else {
|
||||
spvCheckReturn(spvValidateOperandValue(type, word, operandTable,
|
||||
position, pDiagnostic));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return SPV_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
spv_result_t spvValidateIDs(
|
||||
const spv_instruction_t* pInsts, const uint64_t count,
|
||||
const spv_opcode_table opcodeTable, const spv_operand_table operandTable,
|
||||
|
Loading…
Reference in New Issue
Block a user