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];
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:
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;
}
/// @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
<< 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.";
<< 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.";
<< 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.";
<< 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);
<< 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.";
<< 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.";