mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2025-01-12 09:20:15 +00:00
Consolidate: spvOpcodeIsType into spvOpcodeGeneratesType
And fix the spvOpcodeGeneratesType: OpTypeForwardPointer does not generate a new type.
This commit is contained in:
parent
1a0334edee
commit
aef608c40d
@ -324,7 +324,7 @@ spv_result_t spvRegisterIdForOpcode(const spv_instruction_t* pInst,
|
||||
spv_position position,
|
||||
spv_diagnostic* pDiagnostic) {
|
||||
libspirv::IdType detected_type = libspirv::kUnknownType;
|
||||
if (spvOpcodeIsType(pOpcodeEntry->opcode)) {
|
||||
if (spvOpcodeGeneratesType(pOpcodeEntry->opcode)) {
|
||||
if (SpvOpTypeInt == pOpcodeEntry->opcode) {
|
||||
detected_type.type_class = libspirv::IdTypeClass::kScalarIntegerType;
|
||||
detected_type.bitwidth = pInst->words[2];
|
||||
|
@ -625,33 +625,6 @@ const char* spvOpcodeString(const SpvOp opcode) {
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
int32_t spvOpcodeIsType(const SpvOp opcode) {
|
||||
switch (opcode) {
|
||||
case SpvOpTypeVoid:
|
||||
case SpvOpTypeBool:
|
||||
case SpvOpTypeInt:
|
||||
case SpvOpTypeFloat:
|
||||
case SpvOpTypeVector:
|
||||
case SpvOpTypeMatrix:
|
||||
case SpvOpTypeSampler:
|
||||
case SpvOpTypeSampledImage:
|
||||
case SpvOpTypeArray:
|
||||
case SpvOpTypeRuntimeArray:
|
||||
case SpvOpTypeStruct:
|
||||
case SpvOpTypeOpaque:
|
||||
case SpvOpTypePointer:
|
||||
case SpvOpTypeFunction:
|
||||
case SpvOpTypeEvent:
|
||||
case SpvOpTypeDeviceEvent:
|
||||
case SpvOpTypeReserveId:
|
||||
case SpvOpTypeQueue:
|
||||
case SpvOpTypePipe:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t spvOpcodeIsScalarType(const SpvOp opcode) {
|
||||
switch (opcode) {
|
||||
case SpvOpTypeInt:
|
||||
@ -888,9 +861,12 @@ int32_t spvOpcodeGeneratesType(SpvOp op) {
|
||||
case SpvOpTypeReserveId:
|
||||
case SpvOpTypeQueue:
|
||||
case SpvOpTypePipe:
|
||||
case SpvOpTypeForwardPointer:
|
||||
return true;
|
||||
default:;
|
||||
default:
|
||||
// In particular, OpTypeForwardPointer does not generate a type,
|
||||
// but declares a storage class for a pointer type generated
|
||||
// by a different instruction.
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -118,13 +118,6 @@ void spvInstructionCopy(const uint32_t* words, const SpvOp opcode,
|
||||
/// @return the opcode string
|
||||
const char* spvOpcodeString(const SpvOp opcode);
|
||||
|
||||
/// @brief Determine if the Opcode is a type
|
||||
///
|
||||
/// @param[in] opcode the opcode
|
||||
///
|
||||
/// @return zero if false, non-zero otherwise
|
||||
int32_t spvOpcodeIsType(const SpvOp opcode);
|
||||
|
||||
/// @brief Determine if the OpCode is a scalar type
|
||||
///
|
||||
/// @param[in] opcode the opcode
|
||||
|
@ -376,7 +376,7 @@ bool idUsage::isValid<SpvOpTypeArray>(const spv_instruction_t* inst,
|
||||
<< inst->words[elementTypeIndex]
|
||||
<< "' is not defined.";
|
||||
return false);
|
||||
spvCheck(!spvOpcodeIsType(elementType->second.opcode),
|
||||
spvCheck(!spvOpcodeGeneratesType(elementType->second.opcode),
|
||||
DIAG(elementTypeIndex) << "OpTypeArray Element Type <id> '"
|
||||
<< inst->words[elementTypeIndex]
|
||||
<< "' is not a type.";
|
||||
@ -444,7 +444,7 @@ bool idUsage::isValid<SpvOpTypeRuntimeArray>(const spv_instruction_t* inst,
|
||||
<< inst->words[elementTypeIndex]
|
||||
<< "' is not defined.";
|
||||
return false);
|
||||
spvCheck(!spvOpcodeIsType(elementType->second.opcode),
|
||||
spvCheck(!spvOpcodeGeneratesType(elementType->second.opcode),
|
||||
DIAG(elementTypeIndex) << "OpTypeRuntimeArray Element Type <id> '"
|
||||
<< inst->words[elementTypeIndex]
|
||||
<< "' is not a type.";
|
||||
@ -463,7 +463,7 @@ bool idUsage::isValid<SpvOpTypeStruct>(const spv_instruction_t* inst,
|
||||
<< inst->words[memberTypeIndex]
|
||||
<< "' is not defined.";
|
||||
return false);
|
||||
spvCheck(!spvOpcodeIsType(memberType->second.opcode),
|
||||
spvCheck(!spvOpcodeGeneratesType(memberType->second.opcode),
|
||||
DIAG(memberTypeIndex) << "OpTypeStruct Member Type <id> '"
|
||||
<< inst->words[memberTypeIndex]
|
||||
<< "' is not a type.";
|
||||
@ -481,7 +481,7 @@ bool idUsage::isValid<SpvOpTypePointer>(const spv_instruction_t* inst,
|
||||
<< inst->words[typeIndex]
|
||||
<< "' is not defined.";
|
||||
return false);
|
||||
spvCheck(!spvOpcodeIsType(type->second.opcode),
|
||||
spvCheck(!spvOpcodeGeneratesType(type->second.opcode),
|
||||
DIAG(typeIndex) << "OpTypePointer Type <id> '"
|
||||
<< inst->words[typeIndex] << "' is not a type.";
|
||||
return false);
|
||||
@ -498,7 +498,7 @@ bool idUsage::isValid<SpvOpTypeFunction>(const spv_instruction_t* inst,
|
||||
<< inst->words[returnTypeIndex]
|
||||
<< "' is not defined";
|
||||
return false);
|
||||
spvCheck(!spvOpcodeIsType(returnType->second.opcode),
|
||||
spvCheck(!spvOpcodeGeneratesType(returnType->second.opcode),
|
||||
DIAG(returnTypeIndex) << "OpTypeFunction Return Type <id> '"
|
||||
<< inst->words[returnTypeIndex]
|
||||
<< "' is not a type.";
|
||||
@ -511,7 +511,7 @@ bool idUsage::isValid<SpvOpTypeFunction>(const spv_instruction_t* inst,
|
||||
<< inst->words[paramTypeIndex]
|
||||
<< "' is not defined.";
|
||||
return false);
|
||||
spvCheck(!spvOpcodeIsType(paramType->second.opcode),
|
||||
spvCheck(!spvOpcodeGeneratesType(paramType->second.opcode),
|
||||
DIAG(paramTypeIndex) << "OpTypeFunction Parameter Type <id> '"
|
||||
<< inst->words[paramTypeIndex]
|
||||
<< "' is not a type.";
|
||||
|
Loading…
Reference in New Issue
Block a user