From 3fca4cddee4b77f0f04bdcc1c79f3221679aa99d Mon Sep 17 00:00:00 2001 From: David Neto Date: Thu, 17 Sep 2015 17:39:45 -0400 Subject: [PATCH] Remove SPV_OPERAND_TYPE_VARIABLE_MEMORY_ACCESS If a memory mask operand is present, it is a mask. The mask appears only once, so just use SPV_OPERAND_TYPE_OPTIONAL_MEMORY_MASK. The "variable literals" aspect comes into play as follows: if the Aligned bit is set in the mask, then the parser will be made to expect the alignment value as a literal number operand that follows the mask. That is done through mask operand expansion. --- include/libspirv/libspirv.h | 5 ++--- source/opcode.cpp | 6 ++++-- source/operand.cpp | 4 ---- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/libspirv/libspirv.h b/include/libspirv/libspirv.h index f0e7b79..99df36f 100644 --- a/include/libspirv/libspirv.h +++ b/include/libspirv/libspirv.h @@ -188,7 +188,8 @@ typedef enum spv_operand_type_t { SPV_OPERAND_TYPE_OPTIONAL_LITERAL, // An optional literal string. SPV_OPERAND_TYPE_OPTIONAL_LITERAL_STRING, - // An optional memory access qualifier, e.g. Volatile + // An optional memory access qualifier mask, e.g. Volatile, Aligned, + // or a combination. SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS, // An optional execution mode SPV_OPERAND_TYPE_OPTIONAL_EXECUTION_MODE, @@ -201,8 +202,6 @@ typedef enum spv_operand_type_t { SPV_OPERAND_TYPE_VARIABLE_LITERAL_ID, // A sequence of zero or more pairs of (Id, Literal) SPV_OPERAND_TYPE_VARIABLE_ID_LITERAL, - // A sequence of zero or more memory access operands - SPV_OPERAND_TYPE_VARIABLE_MEMORY_ACCESS, // A sequence of zero or more execution modes SPV_OPERAND_TYPE_VARIABLE_EXECUTION_MODE, diff --git a/source/opcode.cpp b/source/opcode.cpp index 3c0c2f7..0c89797 100644 --- a/source/opcode.cpp +++ b/source/opcode.cpp @@ -84,7 +84,9 @@ spv_operand_type_t convertOperandClassToType(spv::Op opcode, case spv::OpStore: case spv::OpCopyMemory: case spv::OpCopyMemorySized: - return SPV_OPERAND_TYPE_VARIABLE_MEMORY_ACCESS; + // Expect an optional mask. When the Aligned bit is set in the mask, + // we will later add the expectation of a literal number operand. + return SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS; case spv::OpExecutionMode: return SPV_OPERAND_TYPE_VARIABLE_EXECUTION_MODE; default: @@ -132,7 +134,7 @@ spv_operand_type_t convertOperandClassToType(spv::Op opcode, case OperandMemorySemantics: return SPV_OPERAND_TYPE_MEMORY_SEMANTICS; case OperandMemoryAccess: // This case does not occur in Rev 31. - // We expect that it will become SPV_OPERAND_TYPE_VARIABLE_MEMORY_ACCESS, + // We expect that it will become SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS, // and we can remove the special casing above for memory operation // instructions. break; diff --git a/source/operand.cpp b/source/operand.cpp index 2c4c161..f0909b9 100644 --- a/source/operand.cpp +++ b/source/operand.cpp @@ -1631,7 +1631,6 @@ bool spvOperandIsVariable(spv_operand_type_t type) { 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_MEMORY_ACCESS: case SPV_OPERAND_TYPE_VARIABLE_EXECUTION_MODE: return true; default: @@ -1663,9 +1662,6 @@ bool spvExpandOperandSequenceOnce(spv_operand_type_t type, {SPV_OPERAND_TYPE_OPTIONAL_ID, SPV_OPERAND_TYPE_LITERAL_IN_OPTIONAL_TUPLE, type}); return true; - case SPV_OPERAND_TYPE_VARIABLE_MEMORY_ACCESS: - pattern->insert(pattern->begin(), {SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS, type}); - return true; case SPV_OPERAND_TYPE_VARIABLE_EXECUTION_MODE: pattern->insert(pattern->begin(), {SPV_OPERAND_TYPE_OPTIONAL_EXECUTION_MODE, type}); return true; -- 2.7.4