spv_operand_type_t cleanup.
authorDavid Neto <dneto@google.com>
Wed, 4 Nov 2015 22:38:17 +0000 (17:38 -0500)
committerDavid Neto <dneto@google.com>
Tue, 10 Nov 2015 20:57:45 +0000 (15:57 -0500)
commit201caf70010d643af65a2459fa6d14e9bdb2ac6b
tree0b510397de5b2ea485cfad4e67da1199c358c866
parent97e4a5d83d6b5d067c840e4a1682c0cf5f06668b
spv_operand_type_t cleanup.

- Concrete operand types are never optional.
  Split them to make this so, e.g. add SPV_OPERAND_TYPE_IMAGE
  since there was SPV_OPERAND_TYPE_OPTIONAL_IMAGE.
  Similarly for SPV_OPERAND_TYPE_MEMORY_ACCESS.
  This entails duplicating two operand table entries.

- The above, plus some rearranging of enums, allows us to define
  first and last optional operand types, and first and last
  variable operand types.
  This lets us simplify the code for spvOperandIsOptional, and
  spvOperandIsVariable.

- Replace SPV_OPERAND_TYPE_MULTIWORD_LITERAL_NUMBER with the
  more accurately named SPV_OPERAND_TYPE_TYPED_LITERAL_NUMBER.
  Its special characteristic is that the type of the literal
  number is determined by some previous operand in the instruction.
  This is used for literals in OpSwitch, OpConstant, and OpSpecConstant.
  This lets us refactor operand parsing cases in the assembler.

- Remove the special required-thing-in-optional-tuple in favour of
  the corresponding concrete operand type:
        SPV_OPERAND_TYPE_ID_IN_OPTIONAL_TUPLE
    --> SPV_OPERAND_TYPE_ID
        SPV_OPERAND_TYPE_INTEGER_LITERAL_IN_OPTIONAL_TUPLE
    --> SPV_OPERAND_TYPE_INTEGER_LITERAL

- Constrain spvOpeandTypeStr to only have to work for non-variable
  operand types.  Add a test for this.
CMakeLists.txt
include/libspirv/libspirv.h
source/binary.cpp
source/disassemble.cpp
source/opcode.cpp
source/operand.cpp
source/operand.h
source/text.cpp
test/Operand.cpp [moved from test/OperandTableGet.cpp with 82% similarity]