mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-11-22 03:30:06 +00:00
Use Google comment style and fix typos.
This commit is contained in:
parent
287cfc1dd7
commit
af9906e4e5
@ -320,7 +320,7 @@ inline std::istream& ParseNormalFloat(std::istream& is, bool negate_value,
|
||||
// This would normally overflow a float and round to
|
||||
// infinity but this special pattern is the exact representation for a NaN,
|
||||
// and therefore is actually encoded as the correct NaN. To encode inf,
|
||||
// either 0x0p+exponent_bias can be spcified or any exponent greater than
|
||||
// either 0x0p+exponent_bias can be specified or any exponent greater than
|
||||
// exponent_bias.
|
||||
// Examples using IEEE 32-bit float encoding.
|
||||
// 0x1.0p+128 (+inf)
|
||||
|
@ -32,30 +32,21 @@
|
||||
|
||||
// Functions
|
||||
|
||||
/// @brief Grab the header from the SPV module
|
||||
///
|
||||
/// @param[in] binary the binary module
|
||||
/// @param[in] endian the endianness of the module
|
||||
/// @param[out] pHeader the returned header
|
||||
///
|
||||
/// @return result code
|
||||
// Grabs the header from the SPIR-V module given in the binary parameter. The
|
||||
// endian parameter specifies the endianness of the binary module. On success,
|
||||
// returns SPV_SUCCESS and writes the parsed header into *header.
|
||||
spv_result_t spvBinaryHeaderGet(const spv_const_binary binary,
|
||||
const spv_endianness_t endian,
|
||||
spv_header_t* pHeader);
|
||||
spv_header_t* header);
|
||||
|
||||
/// @brief Determine the type of the desired operand
|
||||
///
|
||||
/// @param[in] word the operand value
|
||||
/// @param[in] index the word index in the instruction
|
||||
/// @param[in] opcodeEntry table of specified Opcodes
|
||||
/// @param[in] operandTable table of specified operands
|
||||
/// @param[in,out] pOperandEntry the entry in the operand table
|
||||
///
|
||||
/// @return type returned
|
||||
// Determines the desired type of an operand. The operand's value is word, and
|
||||
// is the index-th word in the instruction described by the opcode_entry opcode
|
||||
// table entry. On success, returns SPV_SUCCESS and writes a handle of the
|
||||
// operand table entry for this operand into *operand_entry.
|
||||
spv_operand_type_t spvBinaryOperandInfo(const uint32_t word,
|
||||
const uint16_t index,
|
||||
const spv_opcode_desc opcodeEntry,
|
||||
const spv_operand_table operandTable,
|
||||
spv_operand_desc* pOperandEntry);
|
||||
const spv_opcode_desc opcode_entry,
|
||||
const spv_operand_table operand_table,
|
||||
spv_operand_desc* operand_entry);
|
||||
|
||||
#endif // LIBSPIRV_BINARY_H_
|
||||
|
@ -29,35 +29,18 @@
|
||||
|
||||
#include "libspirv/libspirv.h"
|
||||
|
||||
/// @brief Fix the endianness of a word
|
||||
///
|
||||
/// @param[in] word whos endianness should be fixed
|
||||
/// @param[in] endian the desired endianness
|
||||
///
|
||||
/// @return word with host endianness correction
|
||||
uint32_t spvFixWord(const uint32_t word, const spv_endianness_t endian);
|
||||
// Converts a word in the specified endianness to the host native endianness.
|
||||
uint32_t spvFixWord(const uint32_t word, const spv_endianness_t endianness);
|
||||
|
||||
/// @brief Fix the endianness of a double word
|
||||
///
|
||||
/// @param[in] low the lower 32-bit of the double word
|
||||
/// @param[in] high the higher 32-bit of the double word
|
||||
/// @param[in] endian the desired endianness
|
||||
///
|
||||
/// @return word with host endianness correction
|
||||
// Converts a pair of words in the specified endianness to the host native
|
||||
// endianness.
|
||||
uint64_t spvFixDoubleWord(const uint32_t low, const uint32_t high,
|
||||
const spv_endianness_t endian);
|
||||
const spv_endianness_t endianness);
|
||||
|
||||
/// @brief Determine the endianness of the SPV binary
|
||||
///
|
||||
/// Gets the endianness of the SPV source. Returns SPV_ENDIANNESS_UNKNOWN if
|
||||
/// the
|
||||
/// SPV magic number is invalid, otherwise the determined endianness.
|
||||
///
|
||||
/// @param[in] binary the binary module
|
||||
/// @param[out] pEndian return the endianness of the SPV module
|
||||
///
|
||||
/// @return result code
|
||||
// Gets the endianness of the SPIR-V module given in the binary parameter.
|
||||
// Returns SPV_ENDIANNESS_UNKNOWN if the SPIR-V magic number is invalid,
|
||||
// otherwise writes the determined endianness into *endian.
|
||||
spv_result_t spvBinaryEndianness(const spv_const_binary binary,
|
||||
spv_endianness_t* pEndian);
|
||||
spv_endianness_t* endian);
|
||||
|
||||
#endif // LIBSPIRV_ENDIAN_H_
|
||||
|
@ -30,34 +30,20 @@
|
||||
#include "libspirv/libspirv.h"
|
||||
#include "table.h"
|
||||
|
||||
/// @brief Get the type from the extended instruction library string
|
||||
///
|
||||
/// @param name of the library
|
||||
///
|
||||
/// @return type of the extended instruction library
|
||||
// Gets the type of the extended instruction set with the specified name.
|
||||
spv_ext_inst_type_t spvExtInstImportTypeGet(const char* name);
|
||||
|
||||
/// @brief Find the extented instruction with value in the table
|
||||
///
|
||||
/// @param table to lookup
|
||||
/// @param type of the extended instruction import
|
||||
/// @param name of the extended instruction to find
|
||||
/// @param pEntry return the extended instruction entry
|
||||
///
|
||||
/// @return result code
|
||||
// Finds the named extented instruction of the given type in the given extended
|
||||
// instruction table. On success, returns SPV_SUCCESS and writes a handle of
|
||||
// the instruction entry into *entry.
|
||||
spv_result_t spvExtInstTableNameLookup(const spv_ext_inst_table table,
|
||||
const spv_ext_inst_type_t type,
|
||||
const char* name,
|
||||
spv_ext_inst_desc* pEntry);
|
||||
spv_ext_inst_desc* entry);
|
||||
|
||||
/// @brief Find the extented instruction with value in the table
|
||||
///
|
||||
/// @param table to lookup
|
||||
/// @param type of the extended instruction import
|
||||
/// @param value of the extended instruction to find
|
||||
/// @param pEntry return the extended instruction entry
|
||||
///
|
||||
/// @return result code
|
||||
// Finds the extented instruction of the given type in the given extended
|
||||
// instruction table by value. On success, returns SPV_SUCCESS and writes a
|
||||
// handle of the instruction entry into *entry.
|
||||
spv_result_t spvExtInstTableValueLookup(const spv_ext_inst_table table,
|
||||
const spv_ext_inst_type_t type,
|
||||
const uint32_t value,
|
||||
|
183
source/opcode.h
183
source/opcode.h
@ -31,166 +31,87 @@
|
||||
#include "libspirv/libspirv.h"
|
||||
#include "table.h"
|
||||
|
||||
// Functions
|
||||
|
||||
/// @brief Get the name of the SPIR-V generator.
|
||||
///
|
||||
/// See the registry at
|
||||
/// https://www.khronos.org/registry/spir-v/api/spir-v.xml
|
||||
///
|
||||
/// @param[in] generator Khronos SPIR-V generator ID
|
||||
///
|
||||
/// @return string name
|
||||
// Returns the name of a registered SPIR-V generator as a null-terminated
|
||||
// string. If the generator is not known, then returns the string "Unknown".
|
||||
// The generator parameter should be most significant 16-bits of the generator
|
||||
// word in the SPIR-V module header.
|
||||
//
|
||||
// See the registry at https://www.khronos.org/registry/spir-v/api/spir-v.xml.
|
||||
const char* spvGeneratorStr(uint32_t generator);
|
||||
|
||||
/// @brief Combine word count and Opcode enumerant in single word
|
||||
///
|
||||
/// @param[in] wordCount Opcode consumes
|
||||
/// @param[in] opcode enumerant value
|
||||
///
|
||||
/// @return Opcode word
|
||||
uint32_t spvOpcodeMake(uint16_t wordCount, SpvOp opcode);
|
||||
// Combines word_count and opcode enumerant in single word.
|
||||
uint32_t spvOpcodeMake(uint16_t word_count, SpvOp opcode);
|
||||
|
||||
/// @brief Split the binary opcode into its constituent parts
|
||||
///
|
||||
/// @param[in] word binary opcode to split
|
||||
/// @param[out] wordCount the returned number of words (optional)
|
||||
/// @param[out] opcode the returned opcode enumerant (optional)
|
||||
void spvOpcodeSplit(const uint32_t word, uint16_t* wordCount, SpvOp* opcode);
|
||||
// Splits word into into two constituent parts: word_count and opcode.
|
||||
void spvOpcodeSplit(const uint32_t word, uint16_t* word_count, SpvOp* opcode);
|
||||
|
||||
/// @brief Find the named Opcode in the table
|
||||
///
|
||||
/// @param[in] table to lookup
|
||||
/// @param[in] name name of Opcode to find
|
||||
/// @param[out] pEntry returned Opcode table entry
|
||||
///
|
||||
/// @return result code
|
||||
// Finds the named opcode in the given opcode table. On success, returns
|
||||
// SPV_SUCCESS and writes a handle of the table entry into *entry.
|
||||
spv_result_t spvOpcodeTableNameLookup(const spv_opcode_table table,
|
||||
const char* name,
|
||||
spv_opcode_desc* pEntry);
|
||||
const char* name, spv_opcode_desc* entry);
|
||||
|
||||
/// @brief Find the opcode ID in the table
|
||||
///
|
||||
/// @param[out] table to lookup
|
||||
/// @param[in] opcode value of Opcode to fine
|
||||
/// @param[out] pEntry return Opcode table entry
|
||||
///
|
||||
/// @return result code
|
||||
// Finds the opcode by enumerant in the given opcode table. On success, returns
|
||||
// SPV_SUCCESS and writes a handle of the table entry into *entry.
|
||||
spv_result_t spvOpcodeTableValueLookup(const spv_opcode_table table,
|
||||
const SpvOp opcode,
|
||||
spv_opcode_desc* pEntry);
|
||||
spv_opcode_desc* entry);
|
||||
|
||||
/// @brief Get the argument index for the <result-id> operand, if any.
|
||||
///
|
||||
/// @param[in] entry the Opcode entry
|
||||
///
|
||||
/// @return index for the <result-id> operand, or
|
||||
/// SPV_OPERAND_INVALID_RESULT_ID_INDEX if the given opcode
|
||||
/// doesn't have a <result-id> operand.
|
||||
//
|
||||
/// For example, 0 means <result-id> is the first argument, i.e. right after
|
||||
/// the wordcount/opcode word.
|
||||
int16_t spvOpcodeResultIdIndex(spv_opcode_desc entry);
|
||||
// Determines if the opcode has capability requirements. Returns zero if false,
|
||||
// non-zero otherwise. This function does not check if the given entry is valid.
|
||||
int32_t spvOpcodeRequiresCapabilities(spv_opcode_desc opcode);
|
||||
|
||||
/// @brief Determine if the Opcode has capability requirements.
|
||||
///
|
||||
/// This function does not check if @a entry is valid.
|
||||
///
|
||||
/// @param[in] entry the Opcode entry
|
||||
///
|
||||
/// @return zero if false, non-zero otherwise
|
||||
int32_t spvOpcodeRequiresCapabilities(spv_opcode_desc entry);
|
||||
|
||||
/// @brief Copy an instructions word and fix the endianness
|
||||
///
|
||||
/// @param[in] words the input instruction stream
|
||||
/// @param[in] opcode the instructions Opcode
|
||||
/// @param[in] wordCount the number of words to copy
|
||||
/// @param[in] endian the endianness of the stream
|
||||
/// @param[out] pInst the returned instruction
|
||||
// Copies an instruction's word and fixes the endianness to host native. The
|
||||
// source instruction's stream/opcode/endianness is in the words/opcode/endian
|
||||
// parameter. The word_count parameter specifies the number of words to copy.
|
||||
// Writes copied instruction into *inst.
|
||||
void spvInstructionCopy(const uint32_t* words, const SpvOp opcode,
|
||||
const uint16_t wordCount, const spv_endianness_t endian,
|
||||
spv_instruction_t* pInst);
|
||||
const uint16_t word_count,
|
||||
const spv_endianness_t endian, spv_instruction_t* inst);
|
||||
|
||||
/// @brief Get the name of an instruction, without the "Op" prefix.
|
||||
///
|
||||
/// @param[in] opcode the opcode
|
||||
///
|
||||
/// @return the opcode string
|
||||
// Gets the name of an instruction, without the "Op" prefix.
|
||||
const char* spvOpcodeString(const SpvOp opcode);
|
||||
|
||||
/// @brief Determine if the OpCode is a scalar type
|
||||
///
|
||||
/// @param[in] opcode the opcode
|
||||
///
|
||||
/// @return zero if false, non-zero otherwise
|
||||
// Determine if the given opcode is a scalar type. Returns zero if false,
|
||||
// non-zero otherwise.
|
||||
int32_t spvOpcodeIsScalarType(const SpvOp opcode);
|
||||
|
||||
/// @brief Determine if the Opcode is a constant
|
||||
///
|
||||
/// @param[in] opcode the opcode
|
||||
///
|
||||
/// @return zero if false, non-zero otherwise
|
||||
// Determines if the given opcode is a constant. Returns zero if false, non-zero
|
||||
// otherwise.
|
||||
int32_t spvOpcodeIsConstant(const SpvOp opcode);
|
||||
|
||||
/// @brief Determine if the Opcode is a composite type
|
||||
///
|
||||
/// @param[in] opcode the opcode
|
||||
///
|
||||
/// @return zero if false, non-zero otherwise
|
||||
// Determines if the given opcode is a composite type. Returns zero if false,
|
||||
// non-zero otherwise.
|
||||
int32_t spvOpcodeIsComposite(const SpvOp opcode);
|
||||
|
||||
/// @brief Deep comparison of type declaration instructions
|
||||
///
|
||||
/// @param[in] pTypeInst0 type definition zero
|
||||
/// @param[in] pTypeInst1 type definition one
|
||||
///
|
||||
/// @return zero if false, non-zero otherwise
|
||||
int32_t spvOpcodeAreTypesEqual(const spv_instruction_t* pTypeInst0,
|
||||
const spv_instruction_t* pTypeInst1);
|
||||
// Deep equal comparison of type declaration instructions. Returns zero if
|
||||
// false, non-zero otherwise.
|
||||
int32_t spvOpcodeAreTypesEqual(const spv_instruction_t* type_inst0,
|
||||
const spv_instruction_t* type_inst1);
|
||||
|
||||
/// @brief Determine if the Opcode results in a pointer
|
||||
///
|
||||
/// @param[in] opcode the opcode
|
||||
///
|
||||
/// @return zero if false, non-zero otherwise
|
||||
// Determines if the given opcode results in a pointer. Returns zero if false,
|
||||
// non-zero otherwise.
|
||||
int32_t spvOpcodeIsPointer(const SpvOp opcode);
|
||||
|
||||
/// @brief Determine if the Opcode results in a instantation of a non-void type
|
||||
///
|
||||
/// @param[in] opcode the opcode
|
||||
///
|
||||
/// @return zero if false, non-zero otherwise
|
||||
// Determines if the given opcode results in an instantation of a non-void type.
|
||||
// Returns zero if false, non-zero otherwise.
|
||||
int32_t spvOpcodeIsObject(const SpvOp opcode);
|
||||
|
||||
/// @brief Determine if the scalar type Opcode is nullable
|
||||
///
|
||||
/// @param[in] opcode the opcode
|
||||
///
|
||||
/// @return zero if false, non-zero otherwise
|
||||
// Determines if the scalar type opcode is nullable. Returns zero if false,
|
||||
// non-zero otherwise.
|
||||
int32_t spvOpcodeIsBasicTypeNullable(SpvOp opcode);
|
||||
|
||||
/// @brief Determine if instruction is in a basic block
|
||||
///
|
||||
/// @param[in] pFirstInst first instruction in the stream
|
||||
/// @param[in] pInst current instruction
|
||||
///
|
||||
/// @return zero if false, non-zero otherwise
|
||||
int32_t spvInstructionIsInBasicBlock(const spv_instruction_t* pFirstInst,
|
||||
const spv_instruction_t* pInst);
|
||||
// Determines if an instruction is in a basic block. The first_inst parameter
|
||||
// specifies the first instruction in the stream, while the inst parameter
|
||||
// specifies the current instruction. Returns zero if false, non-zero otherwise.
|
||||
int32_t spvInstructionIsInBasicBlock(const spv_instruction_t* first_inst,
|
||||
const spv_instruction_t* inst);
|
||||
|
||||
/// @brief Determine if the Opcode contains a value
|
||||
///
|
||||
/// @param[in] opcode the opcode
|
||||
///
|
||||
/// @return zero if false, non-zero otherwise
|
||||
// Determines if the given opcode contains a value. Returns zero if false,
|
||||
// non-zero otherwise.
|
||||
int32_t spvOpcodeIsValue(SpvOp opcode);
|
||||
|
||||
/// @brief Determine if the Opcode generates a type
|
||||
///
|
||||
/// @param[in] opcode the opcode
|
||||
///
|
||||
/// @return zero if false, non-zero otherwise
|
||||
int32_t spvOpcodeGeneratesType(SpvOp op);
|
||||
// Determines if the given opcode generates a type. Returns zero if false,
|
||||
// non-zero otherwise.
|
||||
int32_t spvOpcodeGeneratesType(SpvOp opcode);
|
||||
|
||||
#endif // LIBSPIRV_OPCODE_H_
|
||||
|
159
source/operand.h
159
source/operand.h
@ -32,129 +32,96 @@
|
||||
#include "libspirv/libspirv.h"
|
||||
#include "table.h"
|
||||
|
||||
/// @brief A sequence of operand types.
|
||||
///
|
||||
/// A SPIR-V parser uses an operand pattern to describe what is expected
|
||||
/// next on the input.
|
||||
///
|
||||
/// As we parse an instruction in text or binary form from left to right,
|
||||
/// we pull and push from the front of the pattern.
|
||||
// A sequence of operand types.
|
||||
//
|
||||
// A SPIR-V parser uses an operand pattern to describe what is expected
|
||||
// next on the input.
|
||||
//
|
||||
// As we parse an instruction in text or binary form from left to right,
|
||||
// we pull and push from the front of the pattern.
|
||||
using spv_operand_pattern_t = std::deque<spv_operand_type_t>;
|
||||
|
||||
/// @brief Find the named operand in the table
|
||||
///
|
||||
/// @param[in] table to lookup
|
||||
/// @param[in] type the operand group's type
|
||||
/// @param[in] name of the operand to find
|
||||
/// @param[in] nameLength number of bytes of name to compare
|
||||
/// @param[out] pEntry returned operand table entry
|
||||
///
|
||||
/// @return result code
|
||||
// Finds the named operand in the table. The type parameter specifies the
|
||||
// operand's group. A handle of the operand table entry for this operand will
|
||||
// be written into *entry.
|
||||
spv_result_t spvOperandTableNameLookup(const spv_operand_table table,
|
||||
const spv_operand_type_t type,
|
||||
const char* name,
|
||||
const size_t nameLength,
|
||||
spv_operand_desc* pEntry);
|
||||
const size_t name_length,
|
||||
spv_operand_desc* entry);
|
||||
|
||||
/// @brief Find the operand with value in the table
|
||||
///
|
||||
/// @param[in] table to lookup
|
||||
/// @param[in] type the operand group's type
|
||||
/// @param[in] value of the operand to find
|
||||
/// @param[out] pEntry return operand table entry
|
||||
///
|
||||
/// @return result code
|
||||
// Finds the operand with value in the table. The type parameter specifies the
|
||||
// operand's group. A handle of the operand table entry for this operand will
|
||||
// be written into *entry.
|
||||
spv_result_t spvOperandTableValueLookup(const spv_operand_table table,
|
||||
const spv_operand_type_t type,
|
||||
const uint32_t value,
|
||||
spv_operand_desc* pEntry);
|
||||
spv_operand_desc* entry);
|
||||
|
||||
/// @brief Get the name string of the non-variable operand type
|
||||
///
|
||||
/// @param type the type of the operand
|
||||
///
|
||||
/// @return the string name of the operand
|
||||
// Gets the name string of the non-variable operand type.
|
||||
const char* spvOperandTypeStr(spv_operand_type_t type);
|
||||
|
||||
/// @brief Returns true if an operand of the given type is optional.
|
||||
///
|
||||
/// @param[in] type The operand type
|
||||
///
|
||||
/// @return bool
|
||||
// Returns true if an operand of the given type is optional.
|
||||
bool spvOperandIsOptional(spv_operand_type_t type);
|
||||
|
||||
/// @brief Returns true if an operand type represents zero or more
|
||||
/// logical operands.
|
||||
///
|
||||
/// Note that a single logical operand may still be a variable number
|
||||
/// of words. For example, a literal string may be many words, but
|
||||
/// is just one logical operand.
|
||||
///
|
||||
/// @param[in] type The operand type
|
||||
///
|
||||
/// @return bool
|
||||
// Returns true if an operand type represents zero or more logical operands.
|
||||
//
|
||||
// Note that a single logical operand may still be a variable number of words.
|
||||
// For example, a literal string may be many words, but is just one logical
|
||||
// operand.
|
||||
bool spvOperandIsVariable(spv_operand_type_t type);
|
||||
|
||||
/// @brief Inserts a list of operand types into the front of the given pattern.
|
||||
///
|
||||
/// @param[in] types source array of types, ending with SPV_OPERAND_TYPE_NONE.
|
||||
/// @param[in,out] pattern the destination sequence
|
||||
// Inserts a list of operand types into the front of the given pattern.
|
||||
// The types parameter specifies the source array of types, ending with
|
||||
// SPV_OPERAND_TYPE_NONE.
|
||||
void spvPrependOperandTypes(const spv_operand_type_t* types,
|
||||
spv_operand_pattern_t* pattern);
|
||||
|
||||
/// @brief Inserts the operands expected after the given typed mask onto the
|
||||
/// front of the given pattern.
|
||||
///
|
||||
/// Each set bit in the mask represents zero or more operand types that should
|
||||
/// be prepended onto the pattern. Operands for a less significant bit always
|
||||
/// appear before operands for a more significant bit.
|
||||
///
|
||||
/// If a set bit is unknown, then we assume it has no operands.
|
||||
///
|
||||
/// @param[in] operandTable the table of operand type definitions
|
||||
/// @param[in] type the type of operand
|
||||
/// @param[in] mask the mask value for the given type
|
||||
/// @param[in,out] pattern the destination sequence of operand types
|
||||
void spvPrependOperandTypesForMask(const spv_operand_table operandTable,
|
||||
const spv_operand_type_t type,
|
||||
// Inserts the operands expected after the given typed mask onto the
|
||||
// front of the given pattern.
|
||||
//
|
||||
// Each set bit in the mask represents zero or more operand types that should
|
||||
// be prepended onto the pattern. Operands for a less significant bit always
|
||||
// appear before operands for a more significant bit.
|
||||
//
|
||||
// If a set bit is unknown, then we assume it has no operands.
|
||||
void spvPrependOperandTypesForMask(const spv_operand_table operand_table,
|
||||
const spv_operand_type_t mask_type,
|
||||
const uint32_t mask,
|
||||
spv_operand_pattern_t* pattern);
|
||||
|
||||
/// @brief Expands an operand type representing zero or more logical operands,
|
||||
/// exactly once.
|
||||
///
|
||||
/// If the given type represents potentially several logical operands,
|
||||
/// then prepend the given pattern with the first expansion of the logical
|
||||
/// operands, followed by original type. Otherwise, don't modify the pattern.
|
||||
///
|
||||
/// For example, the SPV_OPERAND_TYPE_VARIABLE_ID represents zero or more
|
||||
/// IDs. In that case we would prepend the pattern with SPV_OPERAND_TYPE_ID
|
||||
/// followed by SPV_OPERAND_TYPE_VARIABLE_ID again.
|
||||
///
|
||||
/// This also applies to zero or more tuples of logical operands. In that case
|
||||
/// we prepend pattern with for the members of the tuple, followed by the
|
||||
/// original type argument. The pattern must encode the fact that if any part
|
||||
/// of the tuple is present, then all tuple members should be. So the first
|
||||
/// member of the tuple must be optional, and the remaining members
|
||||
/// non-optional.
|
||||
///
|
||||
/// @param [in] type an operand type, maybe representing a sequence of operands
|
||||
/// @param [in,out] pattern the list of operand types
|
||||
///
|
||||
/// @return true if we modified the pattern
|
||||
// Expands an operand type representing zero or more logical operands,
|
||||
// exactly once.
|
||||
//
|
||||
// If the given type represents potentially several logical operands,
|
||||
// then prepend the given pattern with the first expansion of the logical
|
||||
// operands, followed by original type. Otherwise, don't modify the pattern.
|
||||
//
|
||||
// For example, the SPV_OPERAND_TYPE_VARIABLE_ID represents zero or more
|
||||
// IDs. In that case we would prepend the pattern with SPV_OPERAND_TYPE_ID
|
||||
// followed by SPV_OPERAND_TYPE_VARIABLE_ID again.
|
||||
//
|
||||
// This also applies to zero or more tuples of logical operands. In that case
|
||||
// we prepend pattern with for the members of the tuple, followed by the
|
||||
// original type argument. The pattern must encode the fact that if any part
|
||||
// of the tuple is present, then all tuple members should be. So the first
|
||||
// member of the tuple must be optional, and the remaining members
|
||||
// non-optional.
|
||||
//
|
||||
// Returns true if we modified the pattern.
|
||||
bool spvExpandOperandSequenceOnce(spv_operand_type_t type,
|
||||
spv_operand_pattern_t* pattern);
|
||||
|
||||
/// Expands the first element in the pattern until it is a matchable operand
|
||||
/// type, then pops it off the front and returns it. The pattern must not be
|
||||
/// empty.
|
||||
///
|
||||
/// A matchable operand type is anything other than a zero-or-more-items
|
||||
/// operand type.
|
||||
// Expands the first element in the pattern until it is a matchable operand
|
||||
// type, then pops it off the front and returns it. The pattern must not be
|
||||
// empty.
|
||||
//
|
||||
// A matchable operand type is anything other than a zero-or-more-items
|
||||
// operand type.
|
||||
spv_operand_type_t spvTakeFirstMatchableOperand(spv_operand_pattern_t* pattern);
|
||||
|
||||
/// Calculates the corresponding post-immediate alternate pattern, which allows
|
||||
/// a limited set of operand types.
|
||||
// Calculates the corresponding post-immediate alternate pattern, which allows
|
||||
// a limited set of operand types.
|
||||
spv_operand_pattern_t spvAlternatePatternFollowingImmediate(
|
||||
const spv_operand_pattern_t& pattern);
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
/// @brief Wrapper for out stream selection
|
||||
// Wrapper for out stream selection.
|
||||
class out_stream {
|
||||
public:
|
||||
out_stream() : pStream(nullptr) {}
|
||||
@ -48,27 +48,27 @@ class out_stream {
|
||||
};
|
||||
|
||||
namespace clr {
|
||||
/// @brief Reset console color
|
||||
// Resets console color.
|
||||
struct reset {
|
||||
operator const char*();
|
||||
};
|
||||
/// @brief Set console color to grey
|
||||
// Sets console color to grey.
|
||||
struct grey {
|
||||
operator const char*();
|
||||
};
|
||||
/// @brief Set console color to red
|
||||
// Sets console color to red.
|
||||
struct red {
|
||||
operator const char*();
|
||||
};
|
||||
/// @brief Set console color to green
|
||||
// Sets console color to green.
|
||||
struct green {
|
||||
operator const char*();
|
||||
};
|
||||
/// @brief Set console color to yellow
|
||||
// Sets console color to yellow.
|
||||
struct yellow {
|
||||
operator const char*();
|
||||
};
|
||||
/// @brief Set console color to blue
|
||||
// Sets console color to blue.
|
||||
struct blue {
|
||||
operator const char*();
|
||||
};
|
||||
|
@ -104,12 +104,12 @@ struct spv_context_t {
|
||||
};
|
||||
|
||||
// Populates the given opcode table.
|
||||
spv_result_t spvOpcodeTableGet(spv_opcode_table* pOpcodeTable);
|
||||
spv_result_t spvOpcodeTableGet(spv_opcode_table* table);
|
||||
|
||||
// Populates the given operand table.
|
||||
spv_result_t spvOperandTableGet(spv_operand_table* pOperandTable);
|
||||
spv_result_t spvOperandTableGet(spv_operand_table* table);
|
||||
|
||||
// Populates the given extended instruction table.
|
||||
spv_result_t spvExtInstTableGet(spv_ext_inst_table* pTable);
|
||||
spv_result_t spvExtInstTableGet(spv_ext_inst_table* table);
|
||||
|
||||
#endif // LIBSPIRV_TABLE_H_
|
||||
|
@ -33,8 +33,6 @@
|
||||
#include "operand.h"
|
||||
#include "spirv_constant.h"
|
||||
|
||||
// Structures
|
||||
|
||||
typedef enum spv_literal_type_t {
|
||||
SPV_LITERAL_TYPE_INT_32,
|
||||
SPV_LITERAL_TYPE_INT_64,
|
||||
@ -59,18 +57,9 @@ typedef struct spv_literal_t {
|
||||
std::string str; // Special field for literal string.
|
||||
} spv_literal_t;
|
||||
|
||||
// Functions
|
||||
|
||||
/// @brief Convert the input text to one of the number types, or to
|
||||
/// a string.
|
||||
///
|
||||
/// String literals must be surrounded by double-quotes ("), which are
|
||||
/// then stripped.
|
||||
///
|
||||
/// @param[in] textValue input text to parse
|
||||
/// @param[out] pLiteral the returned literal
|
||||
///
|
||||
/// @return result code
|
||||
spv_result_t spvTextToLiteral(const char* textValue, spv_literal_t* pLiteral);
|
||||
// Converts the given text string to a number/string literal and writes the
|
||||
// result to *literal. String literals must be surrounded by double-quotes ("),
|
||||
// which are then stripped.
|
||||
spv_result_t spvTextToLiteral(const char* text, spv_literal_t* literal);
|
||||
|
||||
#endif // LIBSPIRV_TEXT_H_
|
||||
|
Loading…
Reference in New Issue
Block a user