From: Lei Zhang Date: Wed, 11 Nov 2015 17:40:25 +0000 (-0500) Subject: Move info table related structs into table.h. X-Git-Tag: upstream/2018.6~1460 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7a222e4abf61cc73fffee551391ebdbefad38e05;p=platform%2Fupstream%2FSPIRV-Tools.git Move info table related structs into table.h. --- diff --git a/include/libspirv/libspirv.h b/include/libspirv/libspirv.h index 18d4d80..0244624 100644 --- a/include/libspirv/libspirv.h +++ b/include/libspirv/libspirv.h @@ -321,74 +321,16 @@ typedef struct spv_header_t { const uint32_t* instructions; // NOTE: Unfixed pointer to instruciton stream } spv_header_t; -typedef struct spv_opcode_desc_t { - const char* name; - const SpvOp opcode; - const spv_capability_mask_t - capabilities; // Bitfield of SPV_CAPABILITY_AS_MASK(spv::Capability) - // operandTypes[0..numTypes-1] describe logical operands for the instruction. - // The operand types include result id and result-type id, followed by - // the types of arguments. - uint16_t numTypes; - spv_operand_type_t operandTypes[16]; // TODO: Smaller/larger? - const bool hasResult; // Does the instruction have a result ID operand? - const bool hasType; // Does the instruction have a type ID operand? - // The operand class for each logical argument. This does *not* include - // the result Id or type ID. The list is terminated by SPV_OPERAND_TYPE_NONE. - const OperandClass operandClass[16]; -} spv_opcode_desc_t; - -typedef struct spv_opcode_table_t { - const uint32_t count; - const spv_opcode_desc_t* entries; -} spv_opcode_table_t; - -typedef struct spv_operand_desc_t { - const char* name; - const uint32_t value; - const spv_capability_mask_t - capabilities; // Bitfield of SPV_CAPABILITY_AS_MASK(spv::Capability) - const spv_operand_type_t operandTypes[16]; // TODO: Smaller/larger? -} spv_operand_desc_t; - -typedef struct spv_operand_desc_group_t { - const spv_operand_type_t type; - const uint32_t count; - const spv_operand_desc_t* entries; -} spv_operand_desc_group_t; - -typedef struct spv_operand_table_t { - const uint32_t count; - const spv_operand_desc_group_t* types; -} spv_operand_table_t; - -typedef struct spv_ext_inst_desc_t { - const char* name; - const uint32_t ext_inst; - const spv_operand_type_t operandTypes[16]; // TODO: Smaller/larger? -} spv_ext_inst_desc_t; - -typedef struct spv_ext_inst_group_t { - const spv_ext_inst_type_t type; - const uint32_t count; - const spv_ext_inst_desc_t* entries; -} spv_ext_inst_group_t; - -typedef struct spv_ext_inst_table_t { - const uint32_t count; - const spv_ext_inst_group_t* groups; -} spv_ext_inst_table_t; +typedef struct spv_const_binary_t { + const uint32_t* code; + const size_t wordCount; +} spv_const_binary_t; typedef struct spv_binary_t { uint32_t* code; size_t wordCount; } spv_binary_t; -typedef struct spv_const_binary_t { - const uint32_t* code; - const size_t wordCount; -} spv_const_binary_t; - typedef struct spv_text_t { const char* str; size_t length; @@ -408,12 +350,6 @@ typedef struct spv_diagnostic_t { // Type Definitions -typedef const spv_opcode_desc_t* spv_opcode_desc; -typedef const spv_opcode_table_t* spv_opcode_table; -typedef const spv_operand_desc_t* spv_operand_desc; -typedef const spv_operand_table_t* spv_operand_table; -typedef const spv_ext_inst_desc_t* spv_ext_inst_desc; -typedef const spv_ext_inst_table_t* spv_ext_inst_table; typedef spv_const_binary_t* spv_const_binary; typedef spv_binary_t* spv_binary; typedef spv_text_t* spv_text; diff --git a/source/assembly_grammar.h b/source/assembly_grammar.h index 197d8f7..739413a 100644 --- a/source/assembly_grammar.h +++ b/source/assembly_grammar.h @@ -29,6 +29,7 @@ #include #include "operand.h" +#include "table.h" namespace libspirv { diff --git a/source/binary.h b/source/binary.h index 889716f..73af460 100644 --- a/source/binary.h +++ b/source/binary.h @@ -28,7 +28,7 @@ #define LIBSPIRV_BINARY_H_ #include "libspirv/libspirv.h" - +#include "table.h" // TODO(dneto): Move spvBinaryParse and related type definitions to libspirv.h extern "C" { diff --git a/source/ext_inst.cpp b/source/ext_inst.cpp index 6d018a5..4c1d16d 100644 --- a/source/ext_inst.cpp +++ b/source/ext_inst.cpp @@ -1,4 +1,4 @@ -#include +#include "ext_inst.h" #include diff --git a/source/ext_inst.h b/source/ext_inst.h index d1beb9e..12eb57d 100644 --- a/source/ext_inst.h +++ b/source/ext_inst.h @@ -28,6 +28,7 @@ #define LIBSPIRV_EXT_INST_H_ #include +#include "table.h" /// @brief Get the type from the extended instruction library string /// diff --git a/source/opcode.h b/source/opcode.h index d9689e1..0ad338a 100644 --- a/source/opcode.h +++ b/source/opcode.h @@ -29,6 +29,7 @@ #include "instruction.h" #include +#include "table.h" // Functions diff --git a/source/operand.h b/source/operand.h index 8562c7b..8dcb585 100644 --- a/source/operand.h +++ b/source/operand.h @@ -30,6 +30,7 @@ #include #include +#include "table.h" /// @brief A sequence of operand types. /// diff --git a/source/table.h b/source/table.h index c31e113..f29717f 100644 --- a/source/table.h +++ b/source/table.h @@ -29,6 +29,72 @@ #include +typedef struct spv_opcode_desc_t { + const char* name; + const SpvOp opcode; + const spv_capability_mask_t + capabilities; // Bitfield of SPV_CAPABILITY_AS_MASK(spv::Capability) + // operandTypes[0..numTypes-1] describe logical operands for the instruction. + // The operand types include result id and result-type id, followed by + // the types of arguments. + uint16_t numTypes; + spv_operand_type_t operandTypes[16]; // TODO: Smaller/larger? + const bool hasResult; // Does the instruction have a result ID operand? + const bool hasType; // Does the instruction have a type ID operand? + // The operand class for each logical argument. This does *not* include + // the result Id or type ID. The list is terminated by SPV_OPERAND_TYPE_NONE. + const OperandClass operandClass[16]; +} spv_opcode_desc_t; + +typedef struct spv_operand_desc_t { + const char* name; + const uint32_t value; + const spv_capability_mask_t + capabilities; // Bitfield of SPV_CAPABILITY_AS_MASK(spv::Capability) + const spv_operand_type_t operandTypes[16]; // TODO: Smaller/larger? +} spv_operand_desc_t; + +typedef struct spv_operand_desc_group_t { + const spv_operand_type_t type; + const uint32_t count; + const spv_operand_desc_t* entries; +} spv_operand_desc_group_t; + +typedef struct spv_ext_inst_desc_t { + const char* name; + const uint32_t ext_inst; + const spv_operand_type_t operandTypes[16]; // TODO: Smaller/larger? +} spv_ext_inst_desc_t; + +typedef struct spv_ext_inst_group_t { + const spv_ext_inst_type_t type; + const uint32_t count; + const spv_ext_inst_desc_t* entries; +} spv_ext_inst_group_t; + +typedef struct spv_opcode_table_t { + const uint32_t count; + const spv_opcode_desc_t* entries; +} spv_opcode_table_t; + +typedef struct spv_operand_table_t { + const uint32_t count; + const spv_operand_desc_group_t* types; +} spv_operand_table_t; + +typedef struct spv_ext_inst_table_t { + const uint32_t count; + const spv_ext_inst_group_t* groups; +} spv_ext_inst_table_t; + +typedef const spv_opcode_desc_t* spv_opcode_desc; +typedef const spv_operand_desc_t* spv_operand_desc; +typedef const spv_ext_inst_desc_t* spv_ext_inst_desc; + +typedef const spv_opcode_table_t* spv_opcode_table; +typedef const spv_operand_table_t* spv_operand_table; +typedef const spv_ext_inst_table_t* spv_ext_inst_table; + /// @brief Populate the Opcode table /// /// @param[out] pOpcodeTable table to be populated diff --git a/source/text.cpp b/source/text.cpp index ed70309..fa6e6eb 100644 --- a/source/text.cpp +++ b/source/text.cpp @@ -46,6 +46,7 @@ #include "instruction.h" #include "opcode.h" #include "operand.h" +#include "table.h" #include "text_handler.h" #include "util/bitutils.h"