mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-12-24 00:40:14 +00:00
Remove concept of FIRST_CONCRETE_* operand types
This commit is contained in:
parent
616908503d
commit
0dbe184d32
@ -96,11 +96,8 @@ typedef enum spv_operand_type_t {
|
||||
// A sentinel value.
|
||||
SPV_OPERAND_TYPE_NONE = 0,
|
||||
|
||||
#define FIRST_CONCRETE(ENUM) ENUM, SPV_OPERAND_TYPE_FIRST_CONCRETE_TYPE = ENUM
|
||||
#define LAST_CONCRETE(ENUM) ENUM, SPV_OPERAND_TYPE_LAST_CONCRETE_TYPE = ENUM
|
||||
|
||||
// Set 1: Operands that are IDs.
|
||||
FIRST_CONCRETE(SPV_OPERAND_TYPE_ID),
|
||||
SPV_OPERAND_TYPE_ID,
|
||||
SPV_OPERAND_TYPE_TYPE_ID,
|
||||
SPV_OPERAND_TYPE_RESULT_ID,
|
||||
SPV_OPERAND_TYPE_MEMORY_SEMANTICS_ID, // SPIR-V Sec 3.25
|
||||
@ -150,21 +147,14 @@ typedef enum spv_operand_type_t {
|
||||
SPV_OPERAND_TYPE_KERNEL_PROFILING_INFO, // SPIR-V Sec 3.30
|
||||
SPV_OPERAND_TYPE_CAPABILITY, // SPIR-V Sec 3.31
|
||||
|
||||
// Set 5: Operands that are a single word bitmask.
|
||||
// Sometimes a set bit indicates the instruction requires still more operands.
|
||||
#define FIRST_CONCRETE_MASK(ENUM) \
|
||||
ENUM, SPV_OPERAND_TYPE_FIRST_CONCRETE_MASK_TYPE = ENUM
|
||||
FIRST_CONCRETE_MASK(SPV_OPERAND_TYPE_IMAGE), // SPIR-V Sec 3.14
|
||||
SPV_OPERAND_TYPE_FP_FAST_MATH_MODE, // SPIR-V Sec 3.15
|
||||
SPV_OPERAND_TYPE_SELECTION_CONTROL, // SPIR-V Sec 3.22
|
||||
SPV_OPERAND_TYPE_LOOP_CONTROL, // SPIR-V Sec 3.23
|
||||
SPV_OPERAND_TYPE_FUNCTION_CONTROL, // SPIR-V Sec 3.24
|
||||
LAST_CONCRETE(SPV_OPERAND_TYPE_MEMORY_ACCESS), // SPIR-V Sec 3.26
|
||||
SPV_OPERAND_TYPE_LAST_CONCRETE_MASK_TYPE =
|
||||
SPV_OPERAND_TYPE_LAST_CONCRETE_TYPE,
|
||||
#undef FIRST_CONCRETE_MASK
|
||||
#undef FIRST_CONCRETE
|
||||
#undef LAST_CONCRETE
|
||||
// Set 5: Operands that are a single word bitmask.
|
||||
// Sometimes a set bit indicates the instruction requires still more operands.
|
||||
SPV_OPERAND_TYPE_IMAGE, // SPIR-V Sec 3.14
|
||||
SPV_OPERAND_TYPE_FP_FAST_MATH_MODE, // SPIR-V Sec 3.15
|
||||
SPV_OPERAND_TYPE_SELECTION_CONTROL, // SPIR-V Sec 3.22
|
||||
SPV_OPERAND_TYPE_LOOP_CONTROL, // SPIR-V Sec 3.23
|
||||
SPV_OPERAND_TYPE_FUNCTION_CONTROL, // SPIR-V Sec 3.24
|
||||
SPV_OPERAND_TYPE_MEMORY_ACCESS, // SPIR-V Sec 3.26
|
||||
|
||||
// The remaining operand types are only used internally by the assembler.
|
||||
// There are two categories:
|
||||
|
@ -678,8 +678,7 @@ spv_result_t Parser::parseOperand(size_t inst_offset,
|
||||
return diagnostic() << "Internal error: Unhandled operand type: " << type;
|
||||
}
|
||||
|
||||
assert(int(SPV_OPERAND_TYPE_FIRST_CONCRETE_TYPE) <= int(parsed_operand.type));
|
||||
assert(int(SPV_OPERAND_TYPE_LAST_CONCRETE_TYPE) >= int(parsed_operand.type));
|
||||
assert(spvOperandIsConcrete(parsed_operand.type));
|
||||
|
||||
operands->push_back(parsed_operand);
|
||||
|
||||
|
@ -2664,8 +2664,7 @@ spv_result_t MarkvDecoder::DecodeOperand(
|
||||
|
||||
operand_.num_words = uint16_t(inst_words_.size() - first_word_index);
|
||||
|
||||
assert(int(SPV_OPERAND_TYPE_FIRST_CONCRETE_TYPE) <= int(operand_.type));
|
||||
assert(int(SPV_OPERAND_TYPE_LAST_CONCRETE_TYPE) >= int(operand_.type));
|
||||
assert(spvOperandIsConcrete(operand_.type));
|
||||
|
||||
parsed_operands_.push_back(operand_);
|
||||
|
||||
|
@ -246,9 +246,58 @@ void spvPushOperandTypesForMask(const spv_operand_table operandTable,
|
||||
}
|
||||
}
|
||||
|
||||
bool spvOperandIsConcrete(spv_operand_type_t type) {
|
||||
if (spvIsIdType(type) || spvOperandIsConcreteMask(type)) {
|
||||
return true;
|
||||
}
|
||||
switch (type) {
|
||||
case SPV_OPERAND_TYPE_LITERAL_INTEGER:
|
||||
case SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER:
|
||||
case SPV_OPERAND_TYPE_SPEC_CONSTANT_OP_NUMBER:
|
||||
case SPV_OPERAND_TYPE_TYPED_LITERAL_NUMBER:
|
||||
case SPV_OPERAND_TYPE_LITERAL_STRING:
|
||||
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_SAMPLER_IMAGE_FORMAT:
|
||||
case SPV_OPERAND_TYPE_IMAGE_CHANNEL_ORDER:
|
||||
case SPV_OPERAND_TYPE_IMAGE_CHANNEL_DATA_TYPE:
|
||||
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_GROUP_OPERATION:
|
||||
case SPV_OPERAND_TYPE_KERNEL_ENQ_FLAGS:
|
||||
case SPV_OPERAND_TYPE_KERNEL_PROFILING_INFO:
|
||||
case SPV_OPERAND_TYPE_CAPABILITY:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool spvOperandIsConcreteMask(spv_operand_type_t type) {
|
||||
return SPV_OPERAND_TYPE_FIRST_CONCRETE_MASK_TYPE <= type &&
|
||||
type <= SPV_OPERAND_TYPE_LAST_CONCRETE_MASK_TYPE;
|
||||
switch (type) {
|
||||
case SPV_OPERAND_TYPE_IMAGE:
|
||||
case SPV_OPERAND_TYPE_FP_FAST_MATH_MODE:
|
||||
case SPV_OPERAND_TYPE_SELECTION_CONTROL:
|
||||
case SPV_OPERAND_TYPE_LOOP_CONTROL:
|
||||
case SPV_OPERAND_TYPE_FUNCTION_CONTROL:
|
||||
case SPV_OPERAND_TYPE_MEMORY_ACCESS:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool spvOperandIsOptional(spv_operand_type_t type) {
|
||||
|
@ -55,7 +55,10 @@ spv_result_t spvOperandTableValueLookup(const spv_operand_table table,
|
||||
// Gets the name string of the non-variable operand type.
|
||||
const char* spvOperandTypeStr(spv_operand_type_t type);
|
||||
|
||||
// Returns true if the given type is a concrete and also a mask.
|
||||
// Returns true if the given type is concrete.
|
||||
bool spvOperandIsConcrete(spv_operand_type_t type);
|
||||
|
||||
// Returns true if the given type is concrete and also a mask.
|
||||
bool spvOperandIsConcreteMask(spv_operand_type_t type);
|
||||
|
||||
// Returns true if an operand of the given type is optional.
|
||||
|
Loading…
Reference in New Issue
Block a user