Remove SPV_OPERAND_TYPE_LITERAL

All uses of OptionalLiteral by the SPIR-V spec are used
for literal numbers.

Also rename:
- SPV_OPERAND_TYPE_OPTIONAL_LITERAL to
  SPV_OPERAND_TYPE_OPTIONAL_LITERAL_NUMBER.
- SPV_OPERAND_TYPE_VARIABLE_LITERAL to
  SPV_OPERAND_TYPE_VARIABLE_LITERAL_NUMBER.
- SPV_OPERAND_TYPE_VARIABLE_LITERAL_ID to
  SPV_OPERAND_TYPE_VARIABLE_LITERAL_NUMBER_ID.
- SPV_OPERAND_TYPE_VARIABLE_ID_LITERAL to
  SPV_OPERAND_TYPE_VARIABLE_ID_LITERAL_NUMBER.
- SPV_OPERAND_TYPE_LITERAL_IN_OPTIONAL_TUPLE to
  SPV_OPERAND_TYPE_LITERAL_NUMBER_IN_OPTIONAL_TUPLE.
This commit is contained in:
David Neto 2015-09-25 14:23:29 -04:00
Родитель f1b6471670
Коммит 561dc4e975
6 изменённых файлов: 36 добавлений и 51 удалений

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

@ -128,11 +128,6 @@ typedef enum spv_opcode_flags_t {
// The kinds of operands that an instruction may have.
//
// Sometimes an operand kind is very specific, e.g. SPV_OPERAND_TYPE_RESULT_ID
// for a result ID in a value-generating instruction.
// Other times they represent several options, e.g. a SPV_OPERAND_TYPE_LITERAL
// could either be a literal number or a literal string, depending on context.
//
// In addition to determining what kind of value an operand may be, certain
// enums capture the fact that an operand might be optional (may be absent,
// or present exactly once), or might occure zero or more times.
@ -144,10 +139,6 @@ typedef enum spv_operand_type_t {
SPV_OPERAND_TYPE_NONE = 0,
SPV_OPERAND_TYPE_ID,
SPV_OPERAND_TYPE_RESULT_ID,
// TODO(antiagainst): Instructions in opcode.inc that use
// SPV_OPERAND_TYPE_LITERAL should in fact use LITERAL_NUMBER. So
// SPV_OPERAND_TYPE_LITERAL can be removed.
SPV_OPERAND_TYPE_LITERAL, // Either a literal number or literal string
SPV_OPERAND_TYPE_LITERAL_NUMBER,
// A literal number that can (but is not required to) expand multiple words.
SPV_OPERAND_TYPE_MULTIWORD_LITERAL_NUMBER,
@ -190,9 +181,8 @@ typedef enum spv_operand_type_t {
// An optional image operands mask. A set bit in the mask may
// imply that more arguments are required.
SPV_OPERAND_TYPE_OPTIONAL_IMAGE,
// A literal number or string, but optional.
// TODO(antiagainst): change to SPV_OPERAND_TYPE_OPTIONAL_LITERAL_NUMBER.
SPV_OPERAND_TYPE_OPTIONAL_LITERAL,
// An optional literal number.
SPV_OPERAND_TYPE_OPTIONAL_LITERAL_NUMBER,
// An optional literal string.
SPV_OPERAND_TYPE_OPTIONAL_LITERAL_STRING,
// An optional memory access qualifier mask, e.g. Volatile, Aligned,
@ -204,20 +194,20 @@ typedef enum spv_operand_type_t {
// In an instruction definition, this may only appear at the end of the
// operand types.
SPV_OPERAND_TYPE_VARIABLE_ID,
SPV_OPERAND_TYPE_VARIABLE_LITERAL,
// A sequence of zero or more pairs of (Literal, Id)
SPV_OPERAND_TYPE_VARIABLE_LITERAL_ID,
// A sequence of zero or more pairs of (Id, Literal)
SPV_OPERAND_TYPE_VARIABLE_ID_LITERAL,
SPV_OPERAND_TYPE_VARIABLE_LITERAL_NUMBER,
// A sequence of zero or more pairs of (Literal number, Id)
SPV_OPERAND_TYPE_VARIABLE_LITERAL_NUMBER_ID,
// A sequence of zero or more pairs of (Id, Literal number)
SPV_OPERAND_TYPE_VARIABLE_ID_LITERAL_NUMBER,
// A sequence of zero or more execution modes
SPV_OPERAND_TYPE_VARIABLE_EXECUTION_MODE,
// An Id that is second or later in an optional tuple of operands.
// This must be present if the first operand in the tuple is present.
SPV_OPERAND_TYPE_ID_IN_OPTIONAL_TUPLE,
// A Literal that is second or later in an optional tuple of operands.
// A Literal number that is second or later in an optional tuple of operands.
// This must be present if the first operand in the tuple is present.
SPV_OPERAND_TYPE_LITERAL_IN_OPTIONAL_TUPLE,
SPV_OPERAND_TYPE_LITERAL_NUMBER_IN_OPTIONAL_TUPLE,
// This is a sentinel value, and does not represent an operand type.
// It should come last.

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

@ -257,9 +257,8 @@ spv_result_t spvBinaryDecodeOperand(
}
} // Fall through for the general case.
case SPV_OPERAND_TYPE_MULTIWORD_LITERAL_NUMBER:
case SPV_OPERAND_TYPE_LITERAL:
case SPV_OPERAND_TYPE_OPTIONAL_LITERAL:
case SPV_OPERAND_TYPE_LITERAL_IN_OPTIONAL_TUPLE: {
case SPV_OPERAND_TYPE_OPTIONAL_LITERAL_NUMBER:
case SPV_OPERAND_TYPE_LITERAL_NUMBER_IN_OPTIONAL_TUPLE: {
// TODO: Need to support multiple word literals
stream.get() << (color ? clr::red() : "");
if (numWords > 2) {

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

@ -108,11 +108,13 @@ spv_operand_type_t convertOperandClassToType(spv::Op opcode,
case OperandNone: return SPV_OPERAND_TYPE_NONE;
case OperandId: return SPV_OPERAND_TYPE_ID;
case OperandOptionalId: return SPV_OPERAND_TYPE_OPTIONAL_ID;
case OperandOptionalImage: return SPV_OPERAND_TYPE_OPTIONAL_IMAGE; // TODO(dneto): This is variable.
case OperandOptionalImage: return SPV_OPERAND_TYPE_OPTIONAL_IMAGE;
case OperandVariableIds: return SPV_OPERAND_TYPE_VARIABLE_ID;
case OperandOptionalLiteral: return SPV_OPERAND_TYPE_OPTIONAL_LITERAL;
// The spec only uses OptionalLiteral for an optional literal number.
case OperandOptionalLiteral: return SPV_OPERAND_TYPE_OPTIONAL_LITERAL_NUMBER;
case OperandOptionalLiteralString: return SPV_OPERAND_TYPE_OPTIONAL_LITERAL_STRING;
case OperandVariableLiterals: return SPV_OPERAND_TYPE_VARIABLE_LITERAL;
// This is only used for sequences of literal numbers.
case OperandVariableLiterals: return SPV_OPERAND_TYPE_VARIABLE_LITERAL_NUMBER;
case OperandLiteralNumber: return SPV_OPERAND_TYPE_LITERAL_NUMBER;
case OperandLiteralString: return SPV_OPERAND_TYPE_LITERAL_STRING;
case OperandSource: return SPV_OPERAND_TYPE_SOURCE_LANGUAGE;
@ -152,10 +154,10 @@ spv_operand_type_t convertOperandClassToType(spv::Op opcode,
case OperandCapability: return SPV_OPERAND_TYPE_CAPABILITY;
// Used by GroupMemberDecorate
case OperandVariableIdLiteral: return SPV_OPERAND_TYPE_VARIABLE_ID_LITERAL;
case OperandVariableIdLiteral: return SPV_OPERAND_TYPE_VARIABLE_ID_LITERAL_NUMBER;
// Used by Switch
case OperandVariableLiteralId: return SPV_OPERAND_TYPE_VARIABLE_LITERAL_ID;
case OperandVariableLiteralId: return SPV_OPERAND_TYPE_VARIABLE_LITERAL_NUMBER_ID;
// These exceptional cases shouldn't occur.
case OperandCount:

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

@ -1435,8 +1435,6 @@ const char *spvOperandTypeStr(spv_operand_type_t type) {
return "ID";
case SPV_OPERAND_TYPE_RESULT_ID:
return "result ID";
case SPV_OPERAND_TYPE_LITERAL:
return "literal";
case SPV_OPERAND_TYPE_LITERAL_NUMBER:
return "literal number";
case SPV_OPERAND_TYPE_MULTIWORD_LITERAL_NUMBER:
@ -1541,7 +1539,7 @@ bool spvOperandIsOptional(spv_operand_type_t type) {
switch (type) {
case SPV_OPERAND_TYPE_OPTIONAL_ID:
case SPV_OPERAND_TYPE_OPTIONAL_IMAGE:
case SPV_OPERAND_TYPE_OPTIONAL_LITERAL:
case SPV_OPERAND_TYPE_OPTIONAL_LITERAL_NUMBER:
case SPV_OPERAND_TYPE_OPTIONAL_LITERAL_STRING:
case SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS:
case SPV_OPERAND_TYPE_OPTIONAL_EXECUTION_MODE:
@ -1555,9 +1553,9 @@ bool spvOperandIsOptional(spv_operand_type_t type) {
bool spvOperandIsVariable(spv_operand_type_t type) {
switch (type) {
case SPV_OPERAND_TYPE_VARIABLE_ID:
case SPV_OPERAND_TYPE_VARIABLE_LITERAL:
case SPV_OPERAND_TYPE_VARIABLE_ID_LITERAL:
case SPV_OPERAND_TYPE_VARIABLE_LITERAL_ID:
case SPV_OPERAND_TYPE_VARIABLE_LITERAL_NUMBER:
case SPV_OPERAND_TYPE_VARIABLE_ID_LITERAL_NUMBER:
case SPV_OPERAND_TYPE_VARIABLE_LITERAL_NUMBER_ID:
case SPV_OPERAND_TYPE_VARIABLE_EXECUTION_MODE:
return true;
default:
@ -1573,21 +1571,21 @@ bool spvExpandOperandSequenceOnce(spv_operand_type_t type,
case SPV_OPERAND_TYPE_VARIABLE_ID:
pattern->insert(pattern->begin(), {SPV_OPERAND_TYPE_OPTIONAL_ID, type});
return true;
case SPV_OPERAND_TYPE_VARIABLE_LITERAL:
case SPV_OPERAND_TYPE_VARIABLE_LITERAL_NUMBER:
pattern->insert(pattern->begin(),
{SPV_OPERAND_TYPE_OPTIONAL_LITERAL, type});
{SPV_OPERAND_TYPE_OPTIONAL_LITERAL_NUMBER, type});
return true;
case SPV_OPERAND_TYPE_VARIABLE_LITERAL_ID:
// Represents Zero or more (Literal, Id) pairs.
case SPV_OPERAND_TYPE_VARIABLE_LITERAL_NUMBER_ID:
// Represents Zero or more (Literal number, Id) pairs.
pattern->insert(pattern->begin(),
{SPV_OPERAND_TYPE_OPTIONAL_LITERAL,
{SPV_OPERAND_TYPE_OPTIONAL_LITERAL_NUMBER,
SPV_OPERAND_TYPE_ID_IN_OPTIONAL_TUPLE, type});
return true;
case SPV_OPERAND_TYPE_VARIABLE_ID_LITERAL:
// Represents Zero or more (Id, Literal) pairs.
case SPV_OPERAND_TYPE_VARIABLE_ID_LITERAL_NUMBER:
// Represents Zero or more (Id, Literal number) pairs.
pattern->insert(pattern->begin(),
{SPV_OPERAND_TYPE_OPTIONAL_ID,
SPV_OPERAND_TYPE_LITERAL_IN_OPTIONAL_TUPLE, type});
SPV_OPERAND_TYPE_LITERAL_NUMBER_IN_OPTIONAL_TUPLE, type});
return true;
case SPV_OPERAND_TYPE_VARIABLE_EXECUTION_MODE:
pattern->insert(pattern->begin(), {SPV_OPERAND_TYPE_OPTIONAL_EXECUTION_MODE, type});

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

@ -478,10 +478,8 @@ spv_result_t spvTextEncodeOperand(
}
} // Fall through for the general case.
case SPV_OPERAND_TYPE_MULTIWORD_LITERAL_NUMBER:
// TODO(antiagainst): SPV_OPERAND_TYPE_LITERAL should be removed.
case SPV_OPERAND_TYPE_LITERAL:
case SPV_OPERAND_TYPE_LITERAL_IN_OPTIONAL_TUPLE:
case SPV_OPERAND_TYPE_OPTIONAL_LITERAL: {
case SPV_OPERAND_TYPE_LITERAL_NUMBER_IN_OPTIONAL_TUPLE:
case SPV_OPERAND_TYPE_OPTIONAL_LITERAL_NUMBER: {
spv_literal_t literal = {};
spv_result_t error = spvTextToLiteral(textValue, &literal);
if (error != SPV_SUCCESS) {
@ -651,11 +649,9 @@ spv_result_t encodeInstructionStartingWithImmediate(
// expanded.
spv_operand_pattern_t dummyExpectedOperands;
error = spvTextEncodeOperand(
// TODO(antiagainst): SPV_OPERAND_TYPE_OPTIONAL_LITERAL should be
// substituted by SPV_OPERAND_TYPE_OPTIONAL_LITERAL_NUMBER.
SPV_OPERAND_TYPE_OPTIONAL_LITERAL, operandValue.c_str(), operandTable,
extInstTable, namedIdTable, pInst, &dummyExpectedOperands, pBound,
position, pDiagnostic);
SPV_OPERAND_TYPE_OPTIONAL_LITERAL_NUMBER, operandValue.c_str(),
operandTable, extInstTable, namedIdTable, pInst, &dummyExpectedOperands,
pBound, position, pDiagnostic);
if (error == SPV_FAILED_MATCH) {
// It's not a literal number -- is it a literal string?
error = spvTextEncodeOperand(

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

@ -167,7 +167,7 @@ spv_result_t spvValidateBasic(const spv_instruction_t *pInsts,
words + index, wordCount - index, position, pDiagnostic));
// NOTE: String literals are always at the end of Opcodes
break;
} else if (SPV_OPERAND_TYPE_LITERAL == type) {
} else if (SPV_OPERAND_TYPE_LITERAL_NUMBER == type) {
spvCheckReturn(spvValidateOperandsLiteral(
words + index, wordCount - index, 2, position, pDiagnostic));
} else {