Run clang-format to enforce Google style globally.
Note that we are more strict than Google style for one aspect: pointer/reference indicators are adjacent to their types, not their variables. find . -name "*.h" -exec clang-format -i {} \; find . -name "*.cpp" -exec clang-format -i {} \;
This commit is contained in:
Родитель
0170752763
Коммит
1a0334edee
|
@ -1,65 +1,5 @@
|
|||
---
|
||||
Language: Cpp
|
||||
# BasedOnStyle: Google
|
||||
AccessModifierOffset: -1
|
||||
AlignAfterOpenBracket: true
|
||||
AlignEscapedNewlinesLeft: true
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortIfStatementsOnASingleLine: true
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AlwaysBreakAfterDefinitionReturnType: false
|
||||
AlwaysBreakTemplateDeclarations: true
|
||||
AlwaysBreakBeforeMultilineStrings: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BinPackParameters: true
|
||||
BinPackArguments: true
|
||||
ColumnLimit: 80
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
DerivePointerAlignment: true
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
IndentCaseLabels: true
|
||||
IndentWrappedFunctionNames: false
|
||||
IndentFunctionDeclarationAfterType: false
|
||||
MaxEmptyLinesToKeep: 1
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
NamespaceIndentation: None
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: false
|
||||
PenaltyBreakBeforeFirstCallParameter: 1
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 200
|
||||
PointerAlignment: Left
|
||||
SpacesBeforeTrailingComments: 2
|
||||
Cpp11BracedListStyle: true
|
||||
Standard: Auto
|
||||
IndentWidth: 2
|
||||
TabWidth: 8
|
||||
UseTab: Never
|
||||
BreakBeforeBraces: Attach
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
SpacesInAngles: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpaceAfterCStyleCast: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
ContinuationIndentWidth: 4
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
|
||||
SpaceBeforeParens: ControlStatements
|
||||
DisableFormat: false
|
||||
Language: Cpp
|
||||
BasedOnStyle: Google
|
||||
DerivePointerAlignment: false
|
||||
...
|
||||
|
||||
|
|
|
@ -103,7 +103,8 @@ typedef uint64_t spv_capability_mask_t;
|
|||
// be a constexpr inline function, but some important versions of MSVC don't
|
||||
// support that yet. Different from SPV_BIT, which doesn't guarantee 64-bit
|
||||
// values.
|
||||
#define SPV_CAPABILITY_AS_MASK(capability) (spv_capability_mask_t(1) << (capability))
|
||||
#define SPV_CAPABILITY_AS_MASK(capability) \
|
||||
(spv_capability_mask_t(1) << (capability))
|
||||
|
||||
// Enumerations
|
||||
|
||||
|
@ -291,11 +292,11 @@ typedef struct spv_header_t {
|
|||
uint32_t generator;
|
||||
uint32_t bound;
|
||||
uint32_t schema; // NOTE: Reserved
|
||||
const uint32_t *instructions; // NOTE: Unfixed pointer to instruciton stream
|
||||
const uint32_t* instructions; // NOTE: Unfixed pointer to instruciton stream
|
||||
} spv_header_t;
|
||||
|
||||
typedef struct spv_opcode_desc_t {
|
||||
const char *name;
|
||||
const char* name;
|
||||
const SpvOp opcode;
|
||||
const spv_capability_mask_t
|
||||
capabilities; // Bitfield of SPV_CAPABILITY_AS_MASK(spv::Capability)
|
||||
|
@ -313,11 +314,11 @@ typedef struct spv_opcode_desc_t {
|
|||
|
||||
typedef struct spv_opcode_table_t {
|
||||
const uint32_t count;
|
||||
const spv_opcode_desc_t *entries;
|
||||
const spv_opcode_desc_t* entries;
|
||||
} spv_opcode_table_t;
|
||||
|
||||
typedef struct spv_operand_desc_t {
|
||||
const char *name;
|
||||
const char* name;
|
||||
const uint32_t value;
|
||||
const spv_capability_mask_t
|
||||
capabilities; // Bitfield of SPV_CAPABILITY_AS_MASK(spv::Capability)
|
||||
|
@ -327,16 +328,16 @@ typedef struct 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;
|
||||
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;
|
||||
const spv_operand_desc_group_t* types;
|
||||
} spv_operand_table_t;
|
||||
|
||||
typedef struct spv_ext_inst_desc_t {
|
||||
const char *name;
|
||||
const char* name;
|
||||
const uint32_t ext_inst;
|
||||
const spv_operand_type_t operandTypes[16]; // TODO: Smaller/larger?
|
||||
} spv_ext_inst_desc_t;
|
||||
|
@ -344,21 +345,21 @@ typedef struct 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;
|
||||
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;
|
||||
const spv_ext_inst_group_t* groups;
|
||||
} spv_ext_inst_table_t;
|
||||
|
||||
typedef struct spv_binary_t {
|
||||
uint32_t *code;
|
||||
uint32_t* code;
|
||||
uint64_t wordCount;
|
||||
} spv_binary_t;
|
||||
|
||||
typedef struct spv_text_t {
|
||||
const char *str;
|
||||
const char* str;
|
||||
uint64_t length;
|
||||
} spv_text_t;
|
||||
|
||||
|
@ -370,22 +371,22 @@ typedef struct spv_position_t {
|
|||
|
||||
typedef struct spv_diagnostic_t {
|
||||
spv_position_t position;
|
||||
char *error;
|
||||
char* error;
|
||||
bool isTextSource;
|
||||
} 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_binary_t *spv_binary;
|
||||
typedef spv_text_t *spv_text;
|
||||
typedef spv_position_t *spv_position;
|
||||
typedef spv_diagnostic_t *spv_diagnostic;
|
||||
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_binary_t* spv_binary;
|
||||
typedef spv_text_t* spv_text;
|
||||
typedef spv_position_t* spv_position;
|
||||
typedef spv_diagnostic_t* spv_diagnostic;
|
||||
|
||||
// Platform API
|
||||
|
||||
|
@ -396,21 +397,21 @@ typedef spv_diagnostic_t *spv_diagnostic;
|
|||
/// @param[out] pOpcodeTable table to be populated
|
||||
///
|
||||
/// @return result code
|
||||
spv_result_t spvOpcodeTableGet(spv_opcode_table *pOpcodeTable);
|
||||
spv_result_t spvOpcodeTableGet(spv_opcode_table* pOpcodeTable);
|
||||
|
||||
/// @brief Populate the operand table
|
||||
///
|
||||
/// @param[in] pOperandTable table to be populated
|
||||
///
|
||||
/// @return result code
|
||||
spv_result_t spvOperandTableGet(spv_operand_table *pOperandTable);
|
||||
spv_result_t spvOperandTableGet(spv_operand_table* pOperandTable);
|
||||
|
||||
/// @brief Populate the extended instruction table
|
||||
///
|
||||
/// @param pTable table to be populated
|
||||
///
|
||||
/// @return result code
|
||||
spv_result_t spvExtInstTableGet(spv_ext_inst_table *pTable);
|
||||
spv_result_t spvExtInstTableGet(spv_ext_inst_table* pTable);
|
||||
|
||||
// Text API
|
||||
|
||||
|
@ -425,11 +426,11 @@ spv_result_t spvExtInstTableGet(spv_ext_inst_table *pTable);
|
|||
/// @param[out] pDiagnostic contains diagnostic on failure
|
||||
///
|
||||
/// @return result code
|
||||
spv_result_t spvTextToBinary(const char *text, const uint64_t length,
|
||||
spv_result_t spvTextToBinary(const char* text, const uint64_t length,
|
||||
const spv_opcode_table opcodeTable,
|
||||
const spv_operand_table operandTable,
|
||||
const spv_ext_inst_table extInstTable,
|
||||
spv_binary *pBinary, spv_diagnostic *pDiagnostic);
|
||||
spv_binary* pBinary, spv_diagnostic* pDiagnostic);
|
||||
|
||||
/// @brief Entry point to covert text form to binary form
|
||||
///
|
||||
|
@ -443,13 +444,13 @@ spv_result_t spvTextToBinary(const char *text, const uint64_t length,
|
|||
/// @param[out] pDiagnostic contains diagnostic on failure
|
||||
///
|
||||
/// @return result code
|
||||
spv_result_t spvTextWithFormatToBinary(const char *text, const uint64_t length,
|
||||
spv_result_t spvTextWithFormatToBinary(const char* text, const uint64_t length,
|
||||
spv_assembly_syntax_format_t format,
|
||||
const spv_opcode_table opcodeTable,
|
||||
const spv_operand_table operandTable,
|
||||
const spv_ext_inst_table extInstTable,
|
||||
spv_binary *pBinary,
|
||||
spv_diagnostic *pDiagnostic);
|
||||
spv_binary* pBinary,
|
||||
spv_diagnostic* pDiagnostic);
|
||||
|
||||
/// @brief Free an allocated text stream
|
||||
///
|
||||
|
@ -472,12 +473,12 @@ void spvTextDestroy(spv_text text);
|
|||
/// @param[out] pDiagnostic contains diagnostic on failure
|
||||
///
|
||||
/// @return result code
|
||||
spv_result_t spvBinaryToText(uint32_t *binary, const uint64_t wordCount,
|
||||
spv_result_t spvBinaryToText(uint32_t* binary, const uint64_t wordCount,
|
||||
const uint32_t options,
|
||||
const spv_opcode_table opcodeTable,
|
||||
const spv_operand_table operandTable,
|
||||
const spv_ext_inst_table extInstTable,
|
||||
spv_text *pText, spv_diagnostic *pDiagnostic);
|
||||
spv_text* pText, spv_diagnostic* pDiagnostic);
|
||||
|
||||
/// @brief Entry point to convert binary to text form
|
||||
///
|
||||
|
@ -493,10 +494,10 @@ spv_result_t spvBinaryToText(uint32_t *binary, const uint64_t wordCount,
|
|||
///
|
||||
/// @return result code
|
||||
spv_result_t spvBinaryToTextWithFormat(
|
||||
uint32_t *binary, const uint64_t wordCount, const uint32_t options,
|
||||
uint32_t* binary, const uint64_t wordCount, const uint32_t options,
|
||||
const spv_opcode_table opcodeTable, const spv_operand_table operandTable,
|
||||
const spv_ext_inst_table extInstTable, spv_assembly_syntax_format_t format,
|
||||
spv_text *pText, spv_diagnostic *pDiagnostic);
|
||||
spv_text* pText, spv_diagnostic* pDiagnostic);
|
||||
|
||||
/// @brief Free a binary stream from memory.
|
||||
///
|
||||
|
@ -521,7 +522,7 @@ spv_result_t spvValidate(const spv_binary binary,
|
|||
const spv_opcode_table opcodeTable,
|
||||
const spv_operand_table operandTable,
|
||||
const spv_ext_inst_table extInstTable,
|
||||
const uint32_t options, spv_diagnostic *pDiagnostic);
|
||||
const uint32_t options, spv_diagnostic* pDiagnostic);
|
||||
|
||||
// Diagnostic API
|
||||
|
||||
|
@ -532,7 +533,7 @@ spv_result_t spvValidate(const spv_binary binary,
|
|||
///
|
||||
/// @return the diagnostic object
|
||||
spv_diagnostic spvDiagnosticCreate(const spv_position position,
|
||||
const char *message);
|
||||
const char* message);
|
||||
|
||||
/// @brief Destroy a diagnostic object
|
||||
///
|
||||
|
|
|
@ -48,8 +48,7 @@ template <typename T, size_t First = 0, size_t Num = 0>
|
|||
struct SetBits {
|
||||
static_assert(First < sizeof(T) * 8,
|
||||
"Tried to set a bit that is shifted too far.");
|
||||
const static T get =
|
||||
(T(1) << First) | SetBits<T, First + 1, Num - 1>::get;
|
||||
const static T get = (T(1) << First) | SetBits<T, First + 1, Num - 1>::get;
|
||||
};
|
||||
|
||||
template <typename T, size_t Last>
|
||||
|
|
|
@ -68,9 +68,7 @@ class FloatProxy {
|
|||
|
||||
// Intentionally non-explicit. This is a proxy type so
|
||||
// implicit conversions allow us to use it more transparently.
|
||||
FloatProxy(T val) {
|
||||
data_ = BitwiseCast<uint_type>(val);
|
||||
}
|
||||
FloatProxy(T val) { data_ = BitwiseCast<uint_type>(val); }
|
||||
|
||||
// Intentionally non-explicit. This is a proxy type so
|
||||
// implicit conversions allow us to use it more transparently.
|
||||
|
|
|
@ -50,11 +50,11 @@ namespace {
|
|||
/// @return result code
|
||||
spv_result_t spvTextParseMaskOperand(const spv_operand_table operandTable,
|
||||
const spv_operand_type_t type,
|
||||
const char *textValue, uint32_t *pValue) {
|
||||
const char* textValue, uint32_t* pValue) {
|
||||
if (textValue == nullptr) return SPV_ERROR_INVALID_TEXT;
|
||||
size_t text_length = strlen(textValue);
|
||||
if (text_length == 0) return SPV_ERROR_INVALID_TEXT;
|
||||
const char *text_end = textValue + text_length;
|
||||
const char* text_end = textValue + text_length;
|
||||
|
||||
// We only support mask expressions in ASCII, so the separator value is a
|
||||
// char.
|
||||
|
@ -63,8 +63,8 @@ spv_result_t spvTextParseMaskOperand(const spv_operand_table operandTable,
|
|||
// Accumulate the result by interpreting one word at a time, scanning
|
||||
// from left to right.
|
||||
uint32_t value = 0;
|
||||
const char *begin = textValue; // The left end of the current word.
|
||||
const char *end = nullptr; // One character past the end of the current word.
|
||||
const char* begin = textValue; // The left end of the current word.
|
||||
const char* end = nullptr; // One character past the end of the current word.
|
||||
do {
|
||||
end = std::find(begin, text_end, separator);
|
||||
|
||||
|
@ -90,48 +90,48 @@ bool AssemblyGrammar::isValid() const {
|
|||
return operandTable_ && opcodeTable_ && extInstTable_;
|
||||
}
|
||||
|
||||
spv_result_t AssemblyGrammar::lookupOpcode(const char *name,
|
||||
spv_opcode_desc *desc) const {
|
||||
spv_result_t AssemblyGrammar::lookupOpcode(const char* name,
|
||||
spv_opcode_desc* desc) const {
|
||||
return spvOpcodeTableNameLookup(opcodeTable_, name, desc);
|
||||
}
|
||||
|
||||
spv_result_t AssemblyGrammar::lookupOpcode(SpvOp opcode,
|
||||
spv_opcode_desc *desc) const {
|
||||
spv_opcode_desc* desc) const {
|
||||
return spvOpcodeTableValueLookup(opcodeTable_, opcode, desc);
|
||||
}
|
||||
|
||||
spv_result_t AssemblyGrammar::lookupOperand(spv_operand_type_t type,
|
||||
const char *name, size_t name_len,
|
||||
spv_operand_desc *desc) const {
|
||||
const char* name, size_t name_len,
|
||||
spv_operand_desc* desc) const {
|
||||
return spvOperandTableNameLookup(operandTable_, type, name, name_len, desc);
|
||||
}
|
||||
|
||||
spv_result_t AssemblyGrammar::lookupOperand(spv_operand_type_t type,
|
||||
uint32_t operand,
|
||||
spv_operand_desc *desc) const {
|
||||
spv_operand_desc* desc) const {
|
||||
return spvOperandTableValueLookup(operandTable_, type, operand, desc);
|
||||
}
|
||||
|
||||
spv_result_t AssemblyGrammar::parseMaskOperand(const spv_operand_type_t type,
|
||||
const char *textValue,
|
||||
uint32_t *pValue) const {
|
||||
const char* textValue,
|
||||
uint32_t* pValue) const {
|
||||
return spvTextParseMaskOperand(operandTable_, type, textValue, pValue);
|
||||
}
|
||||
spv_result_t AssemblyGrammar::lookupExtInst(spv_ext_inst_type_t type,
|
||||
const char *textValue,
|
||||
spv_ext_inst_desc *extInst) const {
|
||||
const char* textValue,
|
||||
spv_ext_inst_desc* extInst) const {
|
||||
return spvExtInstTableNameLookup(extInstTable_, type, textValue, extInst);
|
||||
}
|
||||
|
||||
spv_result_t AssemblyGrammar::lookupExtInst(spv_ext_inst_type_t type,
|
||||
uint32_t firstWord,
|
||||
spv_ext_inst_desc *extInst) const {
|
||||
spv_ext_inst_desc* extInst) const {
|
||||
return spvExtInstTableValueLookup(extInstTable_, type, firstWord, extInst);
|
||||
}
|
||||
|
||||
void AssemblyGrammar::prependOperandTypesForMask(
|
||||
const spv_operand_type_t type, const uint32_t mask,
|
||||
spv_operand_pattern_t *pattern) const {
|
||||
spv_operand_pattern_t* pattern) const {
|
||||
spvPrependOperandTypesForMask(operandTable_, type, mask, pattern);
|
||||
}
|
||||
} // namespace libspirv
|
||||
|
|
|
@ -49,24 +49,24 @@ class AssemblyGrammar {
|
|||
// Fills in the desc parameter with the information about the opcode
|
||||
// of the given name. Returns SPV_SUCCESS if the opcode was found, and
|
||||
// SPV_ERROR_INVALID_LOOKUP if the opcode does not exist.
|
||||
spv_result_t lookupOpcode(const char *name, spv_opcode_desc *desc) const;
|
||||
spv_result_t lookupOpcode(const char* name, spv_opcode_desc* desc) const;
|
||||
|
||||
// Fills in the desc parameter with the information about the opcode
|
||||
// of the valid. Returns SPV_SUCCESS if the opcode was found, and
|
||||
// SPV_ERROR_INVALID_LOOKUP if the opcode does not exist.
|
||||
spv_result_t lookupOpcode(SpvOp opcode, spv_opcode_desc *desc) const;
|
||||
spv_result_t lookupOpcode(SpvOp opcode, spv_opcode_desc* desc) const;
|
||||
|
||||
// Fills in the desc parameter with the information about the given
|
||||
// operand. Returns SPV_SUCCESS if the operand was found, and
|
||||
// SPV_ERROR_INVALID_LOOKUP otherwise.
|
||||
spv_result_t lookupOperand(spv_operand_type_t type, const char *name,
|
||||
size_t name_len, spv_operand_desc *desc) const;
|
||||
spv_result_t lookupOperand(spv_operand_type_t type, const char* name,
|
||||
size_t name_len, spv_operand_desc* desc) const;
|
||||
|
||||
// Fills in the desc parameter with the information about the given
|
||||
// operand. Returns SPV_SUCCESS if the operand was found, and
|
||||
// SPV_ERROR_INVALID_LOOKUP otherwise.
|
||||
spv_result_t lookupOperand(spv_operand_type_t type, uint32_t operand,
|
||||
spv_operand_desc *desc) const;
|
||||
spv_operand_desc* desc) const;
|
||||
|
||||
// Parses a mask expression string for the given operand type.
|
||||
//
|
||||
|
@ -78,19 +78,19 @@ class AssemblyGrammar {
|
|||
// The operand type is defined by the type parameter, and the text to be
|
||||
// parsed is defined by the textValue parameter.
|
||||
spv_result_t parseMaskOperand(const spv_operand_type_t type,
|
||||
const char *textValue, uint32_t *pValue) const;
|
||||
const char* textValue, uint32_t* pValue) const;
|
||||
|
||||
// Writes the extended operand with the given type and text to the *extInst
|
||||
// parameter.
|
||||
// Returns SPV_SUCCESS if the value could be found.
|
||||
spv_result_t lookupExtInst(spv_ext_inst_type_t type, const char *textValue,
|
||||
spv_ext_inst_desc *extInst) const;
|
||||
spv_result_t lookupExtInst(spv_ext_inst_type_t type, const char* textValue,
|
||||
spv_ext_inst_desc* extInst) const;
|
||||
|
||||
// Writes the extended operand with the given type and first encoded word
|
||||
// to the *extInst parameter.
|
||||
// Returns SPV_SUCCESS if the value could be found.
|
||||
spv_result_t lookupExtInst(spv_ext_inst_type_t type, uint32_t firstWord,
|
||||
spv_ext_inst_desc *extInst) const;
|
||||
spv_ext_inst_desc* extInst) const;
|
||||
|
||||
// Inserts the operands expected after the given typed mask onto the front
|
||||
// of the given pattern.
|
||||
|
@ -102,7 +102,7 @@ class AssemblyGrammar {
|
|||
// If a set bit is unknown, then we assume it has no operands.
|
||||
void prependOperandTypesForMask(const spv_operand_type_t type,
|
||||
const uint32_t mask,
|
||||
spv_operand_pattern_t *pattern) const;
|
||||
spv_operand_pattern_t* pattern) const;
|
||||
|
||||
private:
|
||||
const spv_operand_table operandTable_;
|
||||
|
|
|
@ -48,7 +48,7 @@ using type_id_to_type_map = std::unordered_map<uint32_t, libspirv::IdType>;
|
|||
|
||||
spv_result_t spvBinaryHeaderGet(const spv_binary binary,
|
||||
const spv_endianness_t endian,
|
||||
spv_header_t *pHeader) {
|
||||
spv_header_t* pHeader) {
|
||||
if (!binary->code || !binary->wordCount) return SPV_ERROR_INVALID_BINARY;
|
||||
if (!pHeader) return SPV_ERROR_INVALID_POINTER;
|
||||
|
||||
|
@ -72,7 +72,7 @@ spv_operand_type_t spvBinaryOperandInfo(const uint32_t word,
|
|||
const uint16_t operandIndex,
|
||||
const spv_opcode_desc opcodeEntry,
|
||||
const spv_operand_table operandTable,
|
||||
spv_operand_desc *pOperandEntry) {
|
||||
spv_operand_desc* pOperandEntry) {
|
||||
spv_operand_type_t type;
|
||||
if (operandIndex < opcodeEntry->numTypes) {
|
||||
// NOTE: Do operand table lookup to set operandEntry if successful
|
||||
|
@ -105,7 +105,6 @@ spv_operand_type_t spvBinaryOperandInfo(const uint32_t word,
|
|||
return type;
|
||||
}
|
||||
|
||||
|
||||
/// @brief Translate a binary operand to the textual form
|
||||
///
|
||||
/// @param[in] opcode of the current instruction
|
||||
|
@ -120,11 +119,11 @@ spv_operand_type_t spvBinaryOperandInfo(const uint32_t word,
|
|||
///
|
||||
/// @return result code
|
||||
spv_result_t spvBinaryDecodeOperand(
|
||||
const SpvOp opcode, const spv_operand_type_t type, const uint32_t *words,
|
||||
const SpvOp opcode, const spv_operand_type_t type, const uint32_t* words,
|
||||
uint16_t numWords, const spv_endianness_t endian, const uint32_t options,
|
||||
const libspirv::AssemblyGrammar& grammar,
|
||||
spv_operand_pattern_t *pExpectedOperands, spv_ext_inst_type_t *pExtInstType,
|
||||
out_stream &stream, spv_position position, spv_diagnostic *pDiagnostic) {
|
||||
spv_operand_pattern_t* pExpectedOperands, spv_ext_inst_type_t* pExtInstType,
|
||||
out_stream& stream, spv_position position, spv_diagnostic* pDiagnostic) {
|
||||
if (!words || !position) return SPV_ERROR_INVALID_POINTER;
|
||||
if (!pDiagnostic) return SPV_ERROR_INVALID_DIAGNOSTIC;
|
||||
|
||||
|
@ -190,7 +189,7 @@ spv_result_t spvBinaryDecodeOperand(
|
|||
} break;
|
||||
case SPV_OPERAND_TYPE_LITERAL_STRING:
|
||||
case SPV_OPERAND_TYPE_OPTIONAL_LITERAL_STRING: {
|
||||
const char *string = (const char *)words;
|
||||
const char* string = (const char*)words;
|
||||
uint64_t stringOperandCount = (strlen(string) / 4) + 1;
|
||||
|
||||
// NOTE: Special case for extended instruction import
|
||||
|
@ -206,7 +205,7 @@ spv_result_t spvBinaryDecodeOperand(
|
|||
stream.get() << "\"";
|
||||
stream.get() << (color ? clr::green() : "");
|
||||
for (const char* p = string; *p; ++p) {
|
||||
if(*p == '"' || *p == '\\') {
|
||||
if (*p == '"' || *p == '\\') {
|
||||
stream.get() << '\\';
|
||||
}
|
||||
stream.get() << *p;
|
||||
|
@ -239,7 +238,8 @@ spv_result_t spvBinaryDecodeOperand(
|
|||
if (grammar.lookupOperand(type, spvFixWord(words[0], endian), &entry)) {
|
||||
DIAGNOSTIC << "Invalid " << spvOperandTypeStr(type) << " operand '"
|
||||
<< words[0] << "'.";
|
||||
return SPV_ERROR_INVALID_TEXT; // TODO(dneto): Surely this is invalid binary.
|
||||
return SPV_ERROR_INVALID_TEXT; // TODO(dneto): Surely this is invalid
|
||||
// binary.
|
||||
}
|
||||
stream.get() << entry->name;
|
||||
// Prepare to accept operands to this operand, if needed.
|
||||
|
@ -306,8 +306,6 @@ spv_result_t spvBinaryDecodeOperand(
|
|||
return SPV_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// @brief Regsiters the given instruction with the type and id tracking
|
||||
/// tables.
|
||||
///
|
||||
|
@ -374,15 +372,12 @@ spv_result_t spvRegisterIdForOpcode(const spv_instruction_t* pInst,
|
|||
/// @param[out] pDiag return diagnostic on error
|
||||
///
|
||||
/// @return result code
|
||||
spv_result_t spvBinaryDecodeOpcode(spv_instruction_t* pInst,
|
||||
const spv_endianness_t endian,
|
||||
const uint32_t options,
|
||||
const libspirv::AssemblyGrammar& grammar,
|
||||
type_id_to_type_map* type_map,
|
||||
id_to_type_id_map* id_map,
|
||||
spv_assembly_syntax_format_t format,
|
||||
out_stream &stream, spv_position position,
|
||||
spv_diagnostic *pDiagnostic) {
|
||||
spv_result_t spvBinaryDecodeOpcode(
|
||||
spv_instruction_t* pInst, const spv_endianness_t endian,
|
||||
const uint32_t options, const libspirv::AssemblyGrammar& grammar,
|
||||
type_id_to_type_map* type_map, id_to_type_id_map* id_map,
|
||||
spv_assembly_syntax_format_t format, out_stream& stream,
|
||||
spv_position position, spv_diagnostic* pDiagnostic) {
|
||||
if (!pInst || !position) return SPV_ERROR_INVALID_POINTER;
|
||||
if (!pDiagnostic) return SPV_ERROR_INVALID_DIAGNOSTIC;
|
||||
|
||||
|
@ -479,8 +474,7 @@ spv_result_t spvBinaryDecodeOpcode(spv_instruction_t* pInst,
|
|||
|
||||
if (spvBinaryDecodeOperand(
|
||||
opcodeEntry->opcode, type, &pInst->words[index], numWords, endian,
|
||||
options, grammar, &expectedOperands,
|
||||
&pInst->extInstType,
|
||||
options, grammar, &expectedOperands, &pInst->extInstType,
|
||||
(isAssigmentFormat && !currentIsResultId ? no_result_id_stream
|
||||
: stream),
|
||||
position, pDiagnostic)) {
|
||||
|
@ -507,22 +501,22 @@ spv_result_t spvBinaryDecodeOpcode(spv_instruction_t* pInst,
|
|||
return SPV_SUCCESS;
|
||||
}
|
||||
|
||||
spv_result_t spvBinaryToText(uint32_t *code, const uint64_t wordCount,
|
||||
spv_result_t spvBinaryToText(uint32_t* code, const uint64_t wordCount,
|
||||
const uint32_t options,
|
||||
const spv_opcode_table opcodeTable,
|
||||
const spv_operand_table operandTable,
|
||||
const spv_ext_inst_table extInstTable,
|
||||
spv_text *pText, spv_diagnostic *pDiagnostic) {
|
||||
spv_text* pText, spv_diagnostic* pDiagnostic) {
|
||||
return spvBinaryToTextWithFormat(
|
||||
code, wordCount, options, opcodeTable, operandTable, extInstTable,
|
||||
SPV_ASSEMBLY_SYNTAX_FORMAT_DEFAULT, pText, pDiagnostic);
|
||||
}
|
||||
|
||||
spv_result_t spvBinaryToTextWithFormat(
|
||||
uint32_t *code, const uint64_t wordCount, const uint32_t options,
|
||||
uint32_t* code, const uint64_t wordCount, const uint32_t options,
|
||||
const spv_opcode_table opcodeTable, const spv_operand_table operandTable,
|
||||
const spv_ext_inst_table extInstTable, spv_assembly_syntax_format_t format,
|
||||
spv_text *pText, spv_diagnostic *pDiagnostic) {
|
||||
spv_text* pText, spv_diagnostic* pDiagnostic) {
|
||||
spv_binary_t binary = {code, wordCount};
|
||||
|
||||
spv_position_t position = {};
|
||||
|
@ -575,7 +569,7 @@ spv_result_t spvBinaryToTextWithFormat(
|
|||
stream.get() << clr::reset();
|
||||
}
|
||||
|
||||
const uint32_t *words = binary.code;
|
||||
const uint32_t* words = binary.code;
|
||||
position.index = SPV_INDEX_INSTRUCTION;
|
||||
spv_ext_inst_type_t extInstType = SPV_EXT_INST_TYPE_NONE;
|
||||
|
||||
|
@ -609,7 +603,7 @@ spv_result_t spvBinaryToTextWithFormat(
|
|||
|
||||
if (!print) {
|
||||
size_t length = sstream.str().size();
|
||||
char *str = new char[length + 1];
|
||||
char* str = new char[length + 1];
|
||||
if (!str) return SPV_ERROR_OUT_OF_MEMORY;
|
||||
strncpy(str, sstream.str().c_str(), length + 1);
|
||||
spv_text text = new spv_text_t();
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
/// @return result code
|
||||
spv_result_t spvBinaryHeaderGet(const spv_binary binary,
|
||||
const spv_endianness_t endian,
|
||||
spv_header_t *pHeader);
|
||||
spv_header_t* pHeader);
|
||||
|
||||
/// @brief Determine the type of the desired operand
|
||||
///
|
||||
|
@ -58,5 +58,5 @@ 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);
|
||||
#endif // LIBSPIRV_BINARY_H_
|
||||
spv_operand_desc* pOperandEntry);
|
||||
#endif // LIBSPIRV_BINARY_H_
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
// Diagnostic API
|
||||
|
||||
spv_diagnostic spvDiagnosticCreate(const spv_position position,
|
||||
const char *message) {
|
||||
const char* message) {
|
||||
spv_diagnostic diagnostic = new spv_diagnostic_t;
|
||||
if (!diagnostic) return nullptr;
|
||||
size_t length = strlen(message) + 1;
|
||||
|
@ -80,10 +80,8 @@ spv_result_t spvDiagnosticPrint(const spv_diagnostic diagnostic) {
|
|||
return SPV_ERROR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
||||
DiagnosticStream::~DiagnosticStream() {
|
||||
if (pDiagnostic_ && error_ != SPV_FAILED_MATCH) {
|
||||
*pDiagnostic_ = spvDiagnosticCreate(position_, stream_.str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,10 +35,10 @@
|
|||
|
||||
class diagnostic_helper {
|
||||
public:
|
||||
diagnostic_helper(spv_position_t &position, spv_diagnostic *pDiagnostic)
|
||||
diagnostic_helper(spv_position_t& position, spv_diagnostic* pDiagnostic)
|
||||
: position(&position), pDiagnostic(pDiagnostic) {}
|
||||
|
||||
diagnostic_helper(spv_position position, spv_diagnostic *pDiagnostic)
|
||||
diagnostic_helper(spv_position position, spv_diagnostic* pDiagnostic)
|
||||
: position(position), pDiagnostic(pDiagnostic) {}
|
||||
|
||||
~diagnostic_helper() {
|
||||
|
@ -49,7 +49,7 @@ class diagnostic_helper {
|
|||
|
||||
private:
|
||||
spv_position position;
|
||||
spv_diagnostic *pDiagnostic;
|
||||
spv_diagnostic* pDiagnostic;
|
||||
};
|
||||
|
||||
// A DiagnosticStream remembers the current position of the input and an error
|
||||
|
@ -61,11 +61,11 @@ class diagnostic_helper {
|
|||
// eventually.
|
||||
class DiagnosticStream {
|
||||
public:
|
||||
DiagnosticStream(spv_position position, spv_diagnostic *pDiagnostic,
|
||||
DiagnosticStream(spv_position position, spv_diagnostic* pDiagnostic,
|
||||
spv_result_t error)
|
||||
: position_(position), pDiagnostic_(pDiagnostic), error_(error) {}
|
||||
|
||||
DiagnosticStream(DiagnosticStream &&other)
|
||||
DiagnosticStream(DiagnosticStream&& other)
|
||||
: stream_(other.stream_.str()),
|
||||
position_(other.position_),
|
||||
pDiagnostic_(other.pDiagnostic_),
|
||||
|
@ -80,7 +80,7 @@ class DiagnosticStream {
|
|||
|
||||
// Adds the given value to the diagnostic message to be written.
|
||||
template <typename T>
|
||||
DiagnosticStream &operator<<(const T &val) {
|
||||
DiagnosticStream& operator<<(const T& val) {
|
||||
stream_ << val;
|
||||
return *this;
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ class DiagnosticStream {
|
|||
private:
|
||||
std::stringstream stream_;
|
||||
spv_position position_;
|
||||
spv_diagnostic *pDiagnostic_;
|
||||
spv_diagnostic* pDiagnostic_;
|
||||
spv_result_t error_;
|
||||
};
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ uint64_t spvFixDoubleWord(const uint32_t low, const uint32_t high,
|
|||
}
|
||||
|
||||
spv_result_t spvBinaryEndianness(const spv_binary binary,
|
||||
spv_endianness_t *pEndian) {
|
||||
spv_endianness_t* pEndian) {
|
||||
if (!binary->code || !binary->wordCount) return SPV_ERROR_INVALID_BINARY;
|
||||
if (!pEndian) return SPV_ERROR_INVALID_POINTER;
|
||||
|
||||
|
|
|
@ -58,6 +58,6 @@ uint64_t spvFixDoubleWord(const uint32_t low, const uint32_t high,
|
|||
///
|
||||
/// @return result code
|
||||
spv_result_t spvBinaryEndianness(const spv_binary binary,
|
||||
spv_endianness_t *pEndian);
|
||||
spv_endianness_t* pEndian);
|
||||
|
||||
#endif // LIBSPIRV_ENDIAN_H_
|
||||
|
|
|
@ -97,7 +97,9 @@ static const spv_ext_inst_desc_t glslStd450Entries[] = {
|
|||
};
|
||||
|
||||
static const spv_ext_inst_desc_t openclEntries[] = {
|
||||
#define ExtInst(Name, Opcode, OperandList) {#Name, Opcode, OperandList},
|
||||
#define ExtInst(Name, Opcode, OperandList) \
|
||||
{ #Name, Opcode, OperandList } \
|
||||
,
|
||||
#define EmptyList \
|
||||
{}
|
||||
#define List(...) \
|
||||
|
@ -116,7 +118,7 @@ static const spv_ext_inst_desc_t openclEntries[] = {
|
|||
#undef OperandVariableIds
|
||||
};
|
||||
|
||||
spv_result_t spvExtInstTableGet(spv_ext_inst_table *pExtInstTable) {
|
||||
spv_result_t spvExtInstTableGet(spv_ext_inst_table* pExtInstTable) {
|
||||
if (!pExtInstTable) return SPV_ERROR_INVALID_POINTER;
|
||||
|
||||
static const spv_ext_inst_group_t groups[] = {
|
||||
|
@ -124,8 +126,7 @@ spv_result_t spvExtInstTableGet(spv_ext_inst_table *pExtInstTable) {
|
|||
sizeof(glslStd450Entries) / sizeof(spv_ext_inst_desc_t),
|
||||
glslStd450Entries},
|
||||
{SPV_EXT_INST_TYPE_OPENCL_STD,
|
||||
sizeof(openclEntries) / sizeof(spv_ext_inst_desc_t),
|
||||
openclEntries},
|
||||
sizeof(openclEntries) / sizeof(spv_ext_inst_desc_t), openclEntries},
|
||||
};
|
||||
|
||||
static const spv_ext_inst_table_t table = {
|
||||
|
@ -136,7 +137,7 @@ spv_result_t spvExtInstTableGet(spv_ext_inst_table *pExtInstTable) {
|
|||
return SPV_SUCCESS;
|
||||
}
|
||||
|
||||
spv_ext_inst_type_t spvExtInstImportTypeGet(const char *name) {
|
||||
spv_ext_inst_type_t spvExtInstImportTypeGet(const char* name) {
|
||||
// The names are specified by the respective extension instruction
|
||||
// specifications.
|
||||
if (!strcmp("GLSL.std.450", name)) {
|
||||
|
@ -150,16 +151,16 @@ spv_ext_inst_type_t spvExtInstImportTypeGet(const char *name) {
|
|||
|
||||
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) {
|
||||
const char* name,
|
||||
spv_ext_inst_desc* pEntry) {
|
||||
if (!table) return SPV_ERROR_INVALID_TABLE;
|
||||
if (!pEntry) return SPV_ERROR_INVALID_POINTER;
|
||||
|
||||
for (uint32_t groupIndex = 0; groupIndex < table->count; groupIndex++) {
|
||||
auto &group = table->groups[groupIndex];
|
||||
auto& group = table->groups[groupIndex];
|
||||
if (type == group.type) {
|
||||
for (uint32_t index = 0; index < group.count; index++) {
|
||||
auto &entry = group.entries[index];
|
||||
auto& entry = group.entries[index];
|
||||
if (!strcmp(name, entry.name)) {
|
||||
*pEntry = &table->groups[groupIndex].entries[index];
|
||||
return SPV_SUCCESS;
|
||||
|
@ -174,15 +175,15 @@ spv_result_t spvExtInstTableNameLookup(const spv_ext_inst_table table,
|
|||
spv_result_t spvExtInstTableValueLookup(const spv_ext_inst_table table,
|
||||
const spv_ext_inst_type_t type,
|
||||
const uint32_t value,
|
||||
spv_ext_inst_desc *pEntry) {
|
||||
spv_ext_inst_desc* pEntry) {
|
||||
if (!table) return SPV_ERROR_INVALID_TABLE;
|
||||
if (!pEntry) return SPV_ERROR_INVALID_POINTER;
|
||||
|
||||
for (uint32_t groupIndex = 0; groupIndex < table->count; groupIndex++) {
|
||||
auto &group = table->groups[groupIndex];
|
||||
auto& group = table->groups[groupIndex];
|
||||
if (type == group.type) {
|
||||
for (uint32_t index = 0; index < group.count; index++) {
|
||||
auto &entry = group.entries[index];
|
||||
auto& entry = group.entries[index];
|
||||
if (value == entry.ext_inst) {
|
||||
*pEntry = &table->groups[groupIndex].entries[index];
|
||||
return SPV_SUCCESS;
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
/// @param name of the library
|
||||
///
|
||||
/// @return type of the extended instruction library
|
||||
spv_ext_inst_type_t spvExtInstImportTypeGet(const char *name);
|
||||
spv_ext_inst_type_t spvExtInstImportTypeGet(const char* name);
|
||||
|
||||
/// @brief Find the extented instruction with value in the table
|
||||
///
|
||||
|
@ -46,8 +46,8 @@ spv_ext_inst_type_t spvExtInstImportTypeGet(const char *name);
|
|||
/// @return result code
|
||||
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);
|
||||
const char* name,
|
||||
spv_ext_inst_desc* pEntry);
|
||||
|
||||
/// @brief Find the extented instruction with value in the table
|
||||
///
|
||||
|
@ -60,6 +60,6 @@ spv_result_t spvExtInstTableNameLookup(const spv_ext_inst_table table,
|
|||
spv_result_t spvExtInstTableValueLookup(const spv_ext_inst_table table,
|
||||
const spv_ext_inst_type_t type,
|
||||
const uint32_t value,
|
||||
spv_ext_inst_desc *pEntry);
|
||||
spv_ext_inst_desc* pEntry);
|
||||
|
||||
#endif // LIBSPIRV_EXT_INST_H_
|
||||
|
|
|
@ -44,19 +44,25 @@ namespace {
|
|||
// TODO(dneto): Some of the macros are quite unreadable. We could make
|
||||
// good use of constexpr functions, but some compilers don't support that yet.
|
||||
spv_opcode_desc_t opcodeTableEntries[] = {
|
||||
#define EmptyList {}
|
||||
#define List(...) {__VA_ARGS__}
|
||||
#define EmptyList \
|
||||
{}
|
||||
#define List(...) \
|
||||
{ __VA_ARGS__ }
|
||||
#define Capability(X) SPV_CAPABILITY_AS_MASK(SpvCapability##X)
|
||||
#define Capability2(X,Y) Capability(X)|Capability(Y)
|
||||
#define SpvCapabilityNone 0 // Needed so Capability(None) still expands to valid syntax.
|
||||
#define Instruction(Name,HasResult,HasType,NumLogicalOperands,NumCapabilities,CapabilityRequired,IsVariable,LogicalArgsList) \
|
||||
{ #Name, \
|
||||
SpvOp##Name, \
|
||||
(NumCapabilities) ? (CapabilityRequired) : 0, \
|
||||
0, {}, /* Filled in later. Operand list, including result id and type id, if needed */ \
|
||||
HasResult, \
|
||||
HasType, \
|
||||
LogicalArgsList },
|
||||
#define Capability2(X, Y) Capability(X) | Capability(Y)
|
||||
#define SpvCapabilityNone \
|
||||
0 // Needed so Capability(None) still expands to valid syntax.
|
||||
#define Instruction(Name, HasResult, HasType, NumLogicalOperands, \
|
||||
NumCapabilities, CapabilityRequired, IsVariable, \
|
||||
LogicalArgsList) \
|
||||
{ \
|
||||
#Name, SpvOp##Name, \
|
||||
(NumCapabilities) ? (CapabilityRequired) : 0, 0, \
|
||||
{}, /* Filled in later. Operand list, including \
|
||||
result id and type id, if needed */ \
|
||||
HasResult, HasType, LogicalArgsList \
|
||||
} \
|
||||
,
|
||||
#include "opcode.inc"
|
||||
#undef EmptyList
|
||||
#undef List
|
||||
|
@ -99,80 +105,117 @@ spv_operand_type_t convertOperandClassToType(SpvOp opcode,
|
|||
return SPV_OPERAND_TYPE_MULTIWORD_LITERAL_NUMBER;
|
||||
}
|
||||
|
||||
switch(operandClass) {
|
||||
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;
|
||||
case OperandVariableIds: return SPV_OPERAND_TYPE_VARIABLE_ID;
|
||||
switch (operandClass) {
|
||||
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;
|
||||
case OperandVariableIds:
|
||||
return SPV_OPERAND_TYPE_VARIABLE_ID;
|
||||
// The spec only uses OptionalLiteral for an optional literal number.
|
||||
case OperandOptionalLiteral: return SPV_OPERAND_TYPE_OPTIONAL_LITERAL_INTEGER;
|
||||
case OperandOptionalLiteralString: return SPV_OPERAND_TYPE_OPTIONAL_LITERAL_STRING;
|
||||
case OperandOptionalLiteral:
|
||||
return SPV_OPERAND_TYPE_OPTIONAL_LITERAL_INTEGER;
|
||||
case OperandOptionalLiteralString:
|
||||
return SPV_OPERAND_TYPE_OPTIONAL_LITERAL_STRING;
|
||||
// This is only used for sequences of literal numbers.
|
||||
case OperandVariableLiterals: return SPV_OPERAND_TYPE_VARIABLE_LITERAL_INTEGER;
|
||||
case OperandVariableLiterals:
|
||||
return SPV_OPERAND_TYPE_VARIABLE_LITERAL_INTEGER;
|
||||
case OperandLiteralNumber:
|
||||
if (opcode == SpvOpExtInst) {
|
||||
// We use a special operand type for the extension instruction number.
|
||||
// For now, we assume there is only one LiteraNumber argument to OpExtInst,
|
||||
// and it is the extension instruction argument.
|
||||
// For now, we assume there is only one LiteraNumber argument to
|
||||
// OpExtInst, and it is the extension instruction argument.
|
||||
// See the ExtInst entry in opcode.inc
|
||||
// TODO(dneto): Use a function to confirm the assumption, and to verify
|
||||
// that the index into the operandClass is 1, as expected.
|
||||
return SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER;
|
||||
}
|
||||
return SPV_OPERAND_TYPE_LITERAL_INTEGER;
|
||||
case OperandLiteralString: return SPV_OPERAND_TYPE_LITERAL_STRING;
|
||||
case OperandSource: return SPV_OPERAND_TYPE_SOURCE_LANGUAGE;
|
||||
case OperandExecutionModel: return SPV_OPERAND_TYPE_EXECUTION_MODEL;
|
||||
case OperandAddressing: return SPV_OPERAND_TYPE_ADDRESSING_MODEL;
|
||||
case OperandMemory: return SPV_OPERAND_TYPE_MEMORY_MODEL;
|
||||
case OperandExecutionMode: return SPV_OPERAND_TYPE_EXECUTION_MODE;
|
||||
case OperandStorage: return SPV_OPERAND_TYPE_STORAGE_CLASS;
|
||||
case OperandDimensionality: return SPV_OPERAND_TYPE_DIMENSIONALITY;
|
||||
case OperandSamplerAddressingMode: return SPV_OPERAND_TYPE_SAMPLER_ADDRESSING_MODE;
|
||||
case OperandSamplerFilterMode: return SPV_OPERAND_TYPE_SAMPLER_FILTER_MODE;
|
||||
case OperandSamplerImageFormat: return SPV_OPERAND_TYPE_SAMPLER_IMAGE_FORMAT;
|
||||
case OperandLiteralString:
|
||||
return SPV_OPERAND_TYPE_LITERAL_STRING;
|
||||
case OperandSource:
|
||||
return SPV_OPERAND_TYPE_SOURCE_LANGUAGE;
|
||||
case OperandExecutionModel:
|
||||
return SPV_OPERAND_TYPE_EXECUTION_MODEL;
|
||||
case OperandAddressing:
|
||||
return SPV_OPERAND_TYPE_ADDRESSING_MODEL;
|
||||
case OperandMemory:
|
||||
return SPV_OPERAND_TYPE_MEMORY_MODEL;
|
||||
case OperandExecutionMode:
|
||||
return SPV_OPERAND_TYPE_EXECUTION_MODE;
|
||||
case OperandStorage:
|
||||
return SPV_OPERAND_TYPE_STORAGE_CLASS;
|
||||
case OperandDimensionality:
|
||||
return SPV_OPERAND_TYPE_DIMENSIONALITY;
|
||||
case OperandSamplerAddressingMode:
|
||||
return SPV_OPERAND_TYPE_SAMPLER_ADDRESSING_MODE;
|
||||
case OperandSamplerFilterMode:
|
||||
return SPV_OPERAND_TYPE_SAMPLER_FILTER_MODE;
|
||||
case OperandSamplerImageFormat:
|
||||
return SPV_OPERAND_TYPE_SAMPLER_IMAGE_FORMAT;
|
||||
case OperandImageChannelOrder:
|
||||
// This is only used to describe the value generated by OpImageQueryOrder.
|
||||
// It is not used as an operand.
|
||||
break;
|
||||
case OperandImageChannelDataType:
|
||||
// This is only used to describe the value generated by OpImageQueryFormat.
|
||||
// It is not used as an operand.
|
||||
// This is only used to describe the value generated by
|
||||
// OpImageQueryFormat. It is not used as an operand.
|
||||
break;
|
||||
case OperandImageOperands:
|
||||
// This is not used in opcode.inc. It only exists to generate the
|
||||
// corresponding spec section. In parsing, image operands meld into the
|
||||
// OperandOptionalImage case.
|
||||
break;
|
||||
case OperandFPFastMath: return SPV_OPERAND_TYPE_FP_FAST_MATH_MODE;
|
||||
case OperandFPRoundingMode: return SPV_OPERAND_TYPE_FP_ROUNDING_MODE;
|
||||
case OperandLinkageType: return SPV_OPERAND_TYPE_LINKAGE_TYPE;
|
||||
case OperandAccessQualifier: return SPV_OPERAND_TYPE_ACCESS_QUALIFIER;
|
||||
case OperandFuncParamAttr: return SPV_OPERAND_TYPE_FUNCTION_PARAMETER_ATTRIBUTE;
|
||||
case OperandDecoration: return SPV_OPERAND_TYPE_DECORATION;
|
||||
case OperandBuiltIn: return SPV_OPERAND_TYPE_BUILT_IN;
|
||||
case OperandSelect: return SPV_OPERAND_TYPE_SELECTION_CONTROL;
|
||||
case OperandLoop: return SPV_OPERAND_TYPE_LOOP_CONTROL;
|
||||
case OperandFunction: return SPV_OPERAND_TYPE_FUNCTION_CONTROL;
|
||||
case OperandMemorySemantics: return SPV_OPERAND_TYPE_MEMORY_SEMANTICS;
|
||||
case OperandFPFastMath:
|
||||
return SPV_OPERAND_TYPE_FP_FAST_MATH_MODE;
|
||||
case OperandFPRoundingMode:
|
||||
return SPV_OPERAND_TYPE_FP_ROUNDING_MODE;
|
||||
case OperandLinkageType:
|
||||
return SPV_OPERAND_TYPE_LINKAGE_TYPE;
|
||||
case OperandAccessQualifier:
|
||||
return SPV_OPERAND_TYPE_ACCESS_QUALIFIER;
|
||||
case OperandFuncParamAttr:
|
||||
return SPV_OPERAND_TYPE_FUNCTION_PARAMETER_ATTRIBUTE;
|
||||
case OperandDecoration:
|
||||
return SPV_OPERAND_TYPE_DECORATION;
|
||||
case OperandBuiltIn:
|
||||
return SPV_OPERAND_TYPE_BUILT_IN;
|
||||
case OperandSelect:
|
||||
return SPV_OPERAND_TYPE_SELECTION_CONTROL;
|
||||
case OperandLoop:
|
||||
return SPV_OPERAND_TYPE_LOOP_CONTROL;
|
||||
case OperandFunction:
|
||||
return SPV_OPERAND_TYPE_FUNCTION_CONTROL;
|
||||
case OperandMemorySemantics:
|
||||
return SPV_OPERAND_TYPE_MEMORY_SEMANTICS;
|
||||
case OperandMemoryAccess:
|
||||
// This case does not occur in the table for SPIR-V 0.99 Rev 32.
|
||||
// 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;
|
||||
case OperandScope: return SPV_OPERAND_TYPE_EXECUTION_SCOPE;
|
||||
case OperandGroupOperation: return SPV_OPERAND_TYPE_GROUP_OPERATION;
|
||||
case OperandKernelEnqueueFlags: return SPV_OPERAND_TYPE_KERNEL_ENQ_FLAGS;
|
||||
case OperandKernelProfilingInfo: return SPV_OPERAND_TYPE_KERNEL_PROFILING_INFO;
|
||||
case OperandCapability: return SPV_OPERAND_TYPE_CAPABILITY;
|
||||
case OperandScope:
|
||||
return SPV_OPERAND_TYPE_EXECUTION_SCOPE;
|
||||
case OperandGroupOperation:
|
||||
return SPV_OPERAND_TYPE_GROUP_OPERATION;
|
||||
case OperandKernelEnqueueFlags:
|
||||
return SPV_OPERAND_TYPE_KERNEL_ENQ_FLAGS;
|
||||
case OperandKernelProfilingInfo:
|
||||
return SPV_OPERAND_TYPE_KERNEL_PROFILING_INFO;
|
||||
case OperandCapability:
|
||||
return SPV_OPERAND_TYPE_CAPABILITY;
|
||||
|
||||
// Used by GroupMemberDecorate
|
||||
case OperandVariableIdLiteral: return SPV_OPERAND_TYPE_VARIABLE_ID_LITERAL_INTEGER;
|
||||
case OperandVariableIdLiteral:
|
||||
return SPV_OPERAND_TYPE_VARIABLE_ID_LITERAL_INTEGER;
|
||||
|
||||
// Used by Switch
|
||||
case OperandVariableLiteralId: return SPV_OPERAND_TYPE_VARIABLE_LITERAL_INTEGER_ID;
|
||||
case OperandVariableLiteralId:
|
||||
return SPV_OPERAND_TYPE_VARIABLE_LITERAL_INTEGER_ID;
|
||||
|
||||
// These exceptional cases shouldn't occur.
|
||||
case OperandCount:
|
||||
|
@ -188,7 +231,7 @@ spv_operand_type_t convertOperandClassToType(SpvOp opcode,
|
|||
// Finish populating the opcodeTableEntries array.
|
||||
void spvOpcodeTableInitialize() {
|
||||
// Compute the operandTypes field for each entry.
|
||||
for (auto &opcode : opcodeTableEntries) {
|
||||
for (auto& opcode : opcodeTableEntries) {
|
||||
opcode.numTypes = 0;
|
||||
// Type ID always comes first, if present.
|
||||
if (opcode.hasType)
|
||||
|
@ -223,7 +266,7 @@ void spvOpcodeTableInitialize() {
|
|||
opcodeTableInitialized = true;
|
||||
}
|
||||
|
||||
const char *spvGeneratorStr(uint32_t generator) {
|
||||
const char* spvGeneratorStr(uint32_t generator) {
|
||||
switch (generator) {
|
||||
case SPV_GENERATOR_KHRONOS:
|
||||
return "Khronos";
|
||||
|
@ -246,7 +289,7 @@ uint32_t spvOpcodeMake(uint16_t wordCount, SpvOp opcode) {
|
|||
return ((uint32_t)opcode) | (((uint32_t)wordCount) << 16);
|
||||
}
|
||||
|
||||
void spvOpcodeSplit(const uint32_t word, uint16_t *pWordCount, SpvOp *pOpcode) {
|
||||
void spvOpcodeSplit(const uint32_t word, uint16_t* pWordCount, SpvOp* pOpcode) {
|
||||
if (pWordCount) {
|
||||
*pWordCount = (uint16_t)((0xffff0000 & word) >> 16);
|
||||
}
|
||||
|
@ -255,7 +298,7 @@ void spvOpcodeSplit(const uint32_t word, uint16_t *pWordCount, SpvOp *pOpcode) {
|
|||
}
|
||||
}
|
||||
|
||||
spv_result_t spvOpcodeTableGet(spv_opcode_table *pInstTable) {
|
||||
spv_result_t spvOpcodeTableGet(spv_opcode_table* pInstTable) {
|
||||
if (!pInstTable) return SPV_ERROR_INVALID_POINTER;
|
||||
|
||||
static spv_opcode_table_t table = {
|
||||
|
@ -272,8 +315,8 @@ spv_result_t spvOpcodeTableGet(spv_opcode_table *pInstTable) {
|
|||
}
|
||||
|
||||
spv_result_t spvOpcodeTableNameLookup(const spv_opcode_table table,
|
||||
const char *name,
|
||||
spv_opcode_desc *pEntry) {
|
||||
const char* name,
|
||||
spv_opcode_desc* pEntry) {
|
||||
if (!name || !pEntry) return SPV_ERROR_INVALID_POINTER;
|
||||
if (!table) return SPV_ERROR_INVALID_TABLE;
|
||||
|
||||
|
@ -296,7 +339,7 @@ spv_result_t spvOpcodeTableNameLookup(const spv_opcode_table table,
|
|||
|
||||
spv_result_t spvOpcodeTableValueLookup(const spv_opcode_table table,
|
||||
const SpvOp opcode,
|
||||
spv_opcode_desc *pEntry) {
|
||||
spv_opcode_desc* pEntry) {
|
||||
if (!table) return SPV_ERROR_INVALID_TABLE;
|
||||
if (!pEntry) return SPV_ERROR_INVALID_POINTER;
|
||||
|
||||
|
@ -323,9 +366,9 @@ int32_t spvOpcodeRequiresCapabilities(spv_opcode_desc entry) {
|
|||
return entry->capabilities != 0;
|
||||
}
|
||||
|
||||
void spvInstructionCopy(const uint32_t *words, const SpvOp opcode,
|
||||
void spvInstructionCopy(const uint32_t* words, const SpvOp opcode,
|
||||
const uint16_t wordCount, const spv_endianness_t endian,
|
||||
spv_instruction_t *pInst) {
|
||||
spv_instruction_t* pInst) {
|
||||
pInst->opcode = opcode;
|
||||
pInst->words.resize(wordCount);
|
||||
for (uint16_t wordIndex = 0; wordIndex < wordCount; ++wordIndex) {
|
||||
|
@ -340,9 +383,9 @@ void spvInstructionCopy(const uint32_t *words, const SpvOp opcode,
|
|||
}
|
||||
}
|
||||
|
||||
const char *spvOpcodeString(const SpvOp opcode) {
|
||||
const char* spvOpcodeString(const SpvOp opcode) {
|
||||
#define CASE(OPCODE) \
|
||||
case Spv##OPCODE: \
|
||||
case Spv##OPCODE: \
|
||||
return #OPCODE;
|
||||
switch (opcode) {
|
||||
CASE(OpNop)
|
||||
|
@ -651,8 +694,8 @@ int32_t spvOpcodeIsComposite(const SpvOp opcode) {
|
|||
}
|
||||
}
|
||||
|
||||
int32_t spvOpcodeAreTypesEqual(const spv_instruction_t *pTypeInst0,
|
||||
const spv_instruction_t *pTypeInst1) {
|
||||
int32_t spvOpcodeAreTypesEqual(const spv_instruction_t* pTypeInst0,
|
||||
const spv_instruction_t* pTypeInst1) {
|
||||
if (pTypeInst0->opcode != pTypeInst1->opcode) return false;
|
||||
if (pTypeInst0->words[1] != pTypeInst1->words[1]) return false;
|
||||
return true;
|
||||
|
@ -801,8 +844,8 @@ int32_t spvOpcodeIsBasicTypeNullable(SpvOp opcode) {
|
|||
}
|
||||
}
|
||||
|
||||
int32_t spvInstructionIsInBasicBlock(const spv_instruction_t *pFirstInst,
|
||||
const spv_instruction_t *pInst) {
|
||||
int32_t spvInstructionIsInBasicBlock(const spv_instruction_t* pFirstInst,
|
||||
const spv_instruction_t* pInst) {
|
||||
while (pFirstInst != pInst) {
|
||||
if (SpvOpFunction == pInst->opcode) break;
|
||||
pInst--;
|
||||
|
@ -824,7 +867,7 @@ int32_t spvOpcodeIsValue(SpvOp opcode) {
|
|||
}
|
||||
|
||||
int32_t spvOpcodeGeneratesType(SpvOp op) {
|
||||
switch(op) {
|
||||
switch (op) {
|
||||
case SpvOpTypeVoid:
|
||||
case SpvOpTypeBool:
|
||||
case SpvOpTypeInt:
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
/// @param[in] generator Khronos SPIR-V generator ID
|
||||
///
|
||||
/// @return string name
|
||||
const char *spvGeneratorStr(uint32_t generator);
|
||||
const char* spvGeneratorStr(uint32_t generator);
|
||||
|
||||
/// @brief Combine word count and Opcode enumerant in single word
|
||||
///
|
||||
|
@ -55,7 +55,7 @@ uint32_t spvOpcodeMake(uint16_t wordCount, SpvOp opcode);
|
|||
/// @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);
|
||||
void spvOpcodeSplit(const uint32_t word, uint16_t* wordCount, SpvOp* opcode);
|
||||
|
||||
/// @brief Find the named Opcode in the table
|
||||
///
|
||||
|
@ -65,8 +65,8 @@ void spvOpcodeSplit(const uint32_t word, uint16_t *wordCount, SpvOp *opcode);
|
|||
///
|
||||
/// @return result code
|
||||
spv_result_t spvOpcodeTableNameLookup(const spv_opcode_table table,
|
||||
const char *name,
|
||||
spv_opcode_desc *pEntry);
|
||||
const char* name,
|
||||
spv_opcode_desc* pEntry);
|
||||
|
||||
/// @brief Find the opcode ID in the table
|
||||
///
|
||||
|
@ -77,7 +77,7 @@ spv_result_t spvOpcodeTableNameLookup(const spv_opcode_table table,
|
|||
/// @return result code
|
||||
spv_result_t spvOpcodeTableValueLookup(const spv_opcode_table table,
|
||||
const SpvOp opcode,
|
||||
spv_opcode_desc *pEntry);
|
||||
spv_opcode_desc* pEntry);
|
||||
|
||||
/// @brief Get the argument index for the <result-id> operand, if any.
|
||||
///
|
||||
|
@ -107,16 +107,16 @@ int32_t spvOpcodeRequiresCapabilities(spv_opcode_desc entry);
|
|||
/// @param[in] wordCount the number of words to copy
|
||||
/// @param[in] endian the endianness of the stream
|
||||
/// @param[out] pInst the returned instruction
|
||||
void spvInstructionCopy(const uint32_t *words, const SpvOp opcode,
|
||||
void spvInstructionCopy(const uint32_t* words, const SpvOp opcode,
|
||||
const uint16_t wordCount, const spv_endianness_t endian,
|
||||
spv_instruction_t *pInst);
|
||||
spv_instruction_t* pInst);
|
||||
|
||||
/// @brief Get the string of an OpCode
|
||||
///
|
||||
/// @param[in] opcode the opcode
|
||||
///
|
||||
/// @return the opcode string
|
||||
const char *spvOpcodeString(const SpvOp opcode);
|
||||
const char* spvOpcodeString(const SpvOp opcode);
|
||||
|
||||
/// @brief Determine if the Opcode is a type
|
||||
///
|
||||
|
@ -152,8 +152,8 @@ int32_t spvOpcodeIsComposite(const SpvOp opcode);
|
|||
/// @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);
|
||||
int32_t spvOpcodeAreTypesEqual(const spv_instruction_t* pTypeInst0,
|
||||
const spv_instruction_t* pTypeInst1);
|
||||
|
||||
/// @brief Determine if the Opcode results in a pointer
|
||||
///
|
||||
|
@ -182,8 +182,8 @@ int32_t spvOpcodeIsBasicTypeNullable(SpvOp opcode);
|
|||
/// @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);
|
||||
int32_t spvInstructionIsInBasicBlock(const spv_instruction_t* pFirstInst,
|
||||
const spv_instruction_t* pInst);
|
||||
|
||||
/// @brief Determine if the Opcode contains a value
|
||||
///
|
||||
|
|
|
@ -30,22 +30,10 @@
|
|||
#include <string.h>
|
||||
|
||||
static const spv_operand_desc_t sourceLanguageEntries[] = {
|
||||
{"Unknown",
|
||||
SpvSourceLanguageUnknown,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"ESSL",
|
||||
SpvSourceLanguageESSL,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"GLSL",
|
||||
SpvSourceLanguageGLSL,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"OpenCL",
|
||||
SpvSourceLanguageOpenCL,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"Unknown", SpvSourceLanguageUnknown, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"ESSL", SpvSourceLanguageESSL, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"GLSL", SpvSourceLanguageGLSL, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"OpenCL", SpvSourceLanguageOpenCL, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
};
|
||||
|
||||
static const spv_operand_desc_t executionModelEntries[] = {
|
||||
|
@ -80,10 +68,7 @@ static const spv_operand_desc_t executionModelEntries[] = {
|
|||
};
|
||||
|
||||
static const spv_operand_desc_t addressingModelEntries[] = {
|
||||
{"Logical",
|
||||
SpvAddressingModelLogical,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"Logical", SpvAddressingModelLogical, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"Physical32",
|
||||
SpvAddressingModelPhysical32,
|
||||
SPV_CAPABILITY_AS_MASK(SpvCapabilityAddresses),
|
||||
|
@ -203,10 +188,7 @@ static const spv_operand_desc_t storageClassEntries[] = {
|
|||
SpvStorageClassPrivateGlobal,
|
||||
SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"Function",
|
||||
SpvStorageClassFunction,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"Function", SpvStorageClassFunction, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"Generic",
|
||||
SpvStorageClassGeneric,
|
||||
SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
|
||||
|
@ -219,10 +201,7 @@ static const spv_operand_desc_t storageClassEntries[] = {
|
|||
SpvStorageClassAtomicCounter,
|
||||
SPV_CAPABILITY_AS_MASK(SpvCapabilityAtomicStorage),
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"Image",
|
||||
SpvStorageClassImage,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"Image", SpvStorageClassImage, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
};
|
||||
|
||||
static const spv_operand_desc_t dimensionalityEntries[] = {
|
||||
|
@ -341,33 +320,18 @@ static const spv_operand_desc_t samplerImageFormatEntries[] = {
|
|||
};
|
||||
|
||||
// All image channel orders depend on the Kernel capability.
|
||||
#define CASE(NAME) \
|
||||
{ \
|
||||
#NAME, SpvImageChannelOrder##NAME, SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel), \
|
||||
{ \
|
||||
SPV_OPERAND_TYPE_NONE \
|
||||
} \
|
||||
#define CASE(NAME) \
|
||||
{ \
|
||||
#NAME, SpvImageChannelOrder##NAME, \
|
||||
SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel), { \
|
||||
SPV_OPERAND_TYPE_NONE \
|
||||
} \
|
||||
}
|
||||
static const spv_operand_desc_t imageChannelOrderEntries[] = {
|
||||
CASE(R),
|
||||
CASE(A),
|
||||
CASE(RG),
|
||||
CASE(RA),
|
||||
CASE(RGB),
|
||||
CASE(RGBA),
|
||||
CASE(BGRA),
|
||||
CASE(ARGB),
|
||||
CASE(Intensity),
|
||||
CASE(Luminance),
|
||||
CASE(Rx),
|
||||
CASE(RGx),
|
||||
CASE(RGBx),
|
||||
CASE(Depth),
|
||||
CASE(DepthStencil),
|
||||
CASE(sRGB),
|
||||
CASE(sRGBx),
|
||||
CASE(sRGBA),
|
||||
CASE(sBGRA),
|
||||
CASE(R), CASE(A), CASE(RG), CASE(RA), CASE(RGB),
|
||||
CASE(RGBA), CASE(BGRA), CASE(ARGB), CASE(Intensity), CASE(Luminance),
|
||||
CASE(Rx), CASE(RGx), CASE(RGBx), CASE(Depth), CASE(DepthStencil),
|
||||
CASE(sRGB), CASE(sRGBx), CASE(sRGBA), CASE(sBGRA),
|
||||
};
|
||||
#undef CASE
|
||||
|
||||
|
@ -380,22 +344,12 @@ static const spv_operand_desc_t imageChannelOrderEntries[] = {
|
|||
} \
|
||||
}
|
||||
static const spv_operand_desc_t imageChannelDataTypeEntries[] = {
|
||||
CASE(SnormInt8),
|
||||
CASE(SnormInt16),
|
||||
CASE(UnormInt8),
|
||||
CASE(UnormInt16),
|
||||
CASE(UnormShort565),
|
||||
CASE(UnormShort555),
|
||||
CASE(UnormInt101010),
|
||||
CASE(SignedInt8),
|
||||
CASE(SignedInt16),
|
||||
CASE(SignedInt32),
|
||||
CASE(UnsignedInt8),
|
||||
CASE(UnsignedInt16),
|
||||
CASE(UnsignedInt32),
|
||||
CASE(HalfFloat),
|
||||
CASE(Float),
|
||||
CASE(UnormInt24),
|
||||
CASE(SnormInt8), CASE(SnormInt16), CASE(UnormInt8),
|
||||
CASE(UnormInt16), CASE(UnormShort565), CASE(UnormShort555),
|
||||
CASE(UnormInt101010), CASE(SignedInt8), CASE(SignedInt16),
|
||||
CASE(SignedInt32), CASE(UnsignedInt8), CASE(UnsignedInt16),
|
||||
CASE(UnsignedInt32), CASE(HalfFloat), CASE(Float),
|
||||
CASE(UnormInt24),
|
||||
};
|
||||
#undef CASE
|
||||
|
||||
|
@ -404,10 +358,8 @@ static const spv_operand_desc_t imageChannelDataTypeEntries[] = {
|
|||
// Some mask values depend on a capability.
|
||||
static const spv_operand_desc_t imageOperandEntries[] = {
|
||||
// Rev32 and later adds many more enums.
|
||||
#define CASE(NAME) \
|
||||
#NAME, SpvImageOperands##NAME##Mask, 0
|
||||
#define CASE_CAP(NAME, CAP) \
|
||||
#NAME, SpvImageOperands##NAME##Mask, CAP
|
||||
#define CASE(NAME) #NAME, SpvImageOperands##NAME##Mask, 0
|
||||
#define CASE_CAP(NAME, CAP) #NAME, SpvImageOperands##NAME##Mask, CAP
|
||||
#define ID SPV_OPERAND_TYPE_ID
|
||||
#define NONE SPV_OPERAND_TYPE_NONE
|
||||
{"None", SpvImageOperandsMaskNone, 0, {NONE}},
|
||||
|
@ -427,10 +379,7 @@ static const spv_operand_desc_t imageOperandEntries[] = {
|
|||
};
|
||||
|
||||
static const spv_operand_desc_t fpFastMathModeEntries[] = {
|
||||
{"None",
|
||||
SpvFPFastMathModeMaskNone,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"None", SpvFPFastMathModeMaskNone, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"NotNaN",
|
||||
SpvFPFastMathModeNotNaNMask,
|
||||
SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
|
||||
|
@ -612,34 +561,16 @@ static const spv_operand_desc_t decorationEntries[] = {
|
|||
SpvDecorationInvariant,
|
||||
SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"Restrict",
|
||||
SpvDecorationRestrict,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"Aliased",
|
||||
SpvDecorationAliased,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"Volatile",
|
||||
SpvDecorationVolatile,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"Restrict", SpvDecorationRestrict, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"Aliased", SpvDecorationAliased, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"Volatile", SpvDecorationVolatile, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"Constant",
|
||||
SpvDecorationConstant,
|
||||
SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"Coherent",
|
||||
SpvDecorationCoherent,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"NonWritable",
|
||||
SpvDecorationNonWritable,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"NonReadable",
|
||||
SpvDecorationNonReadable,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"Coherent", SpvDecorationCoherent, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"NonWritable", SpvDecorationNonWritable, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"NonReadable", SpvDecorationNonReadable, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"Uniform",
|
||||
SpvDecorationUniform,
|
||||
SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
|
||||
|
@ -707,8 +638,9 @@ static const spv_operand_desc_t decorationEntries[] = {
|
|||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"InputTargetIndex",
|
||||
SpvDecorationInputTargetIndex,
|
||||
SPV_CAPABILITY_AS_MASK(SpvCapabilityShader), // TODO(dneto): Should this be
|
||||
// SpvCapabilityInputTarget?
|
||||
SPV_CAPABILITY_AS_MASK(
|
||||
SpvCapabilityShader), // TODO(dneto): Should this be
|
||||
// SpvCapabilityInputTarget?
|
||||
{SPV_OPERAND_TYPE_NONE}}, // TODO(dneto): Should this have a literal
|
||||
// number argument?
|
||||
{"Alignment",
|
||||
|
@ -812,18 +744,9 @@ static const spv_operand_desc_t builtInEntries[] = {
|
|||
SpvBuiltInHelperInvocation,
|
||||
SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"NumWorkgroups",
|
||||
SpvBuiltInNumWorkgroups,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"WorkgroupSize",
|
||||
SpvBuiltInWorkgroupSize,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"WorkgroupId",
|
||||
SpvBuiltInWorkgroupId,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"NumWorkgroups", SpvBuiltInNumWorkgroups, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"WorkgroupSize", SpvBuiltInWorkgroupSize, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"WorkgroupId", SpvBuiltInWorkgroupId, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"LocalInvocationId",
|
||||
SpvBuiltInLocalInvocationId,
|
||||
0,
|
||||
|
@ -895,14 +818,8 @@ static const spv_operand_desc_t builtInEntries[] = {
|
|||
};
|
||||
|
||||
static const spv_operand_desc_t selectionControlEntries[] = {
|
||||
{"None",
|
||||
SpvSelectionControlMaskNone,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"Flatten",
|
||||
SpvSelectionControlFlattenMask,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"None", SpvSelectionControlMaskNone, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"Flatten", SpvSelectionControlFlattenMask, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"DontFlatten",
|
||||
SpvSelectionControlDontFlattenMask,
|
||||
0,
|
||||
|
@ -910,67 +827,34 @@ static const spv_operand_desc_t selectionControlEntries[] = {
|
|||
};
|
||||
|
||||
static const spv_operand_desc_t loopControlEntries[] = {
|
||||
{"None",
|
||||
SpvLoopControlMaskNone,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"Unroll",
|
||||
SpvLoopControlUnrollMask,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"DontUnroll",
|
||||
SpvLoopControlDontUnrollMask,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"None", SpvLoopControlMaskNone, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"Unroll", SpvLoopControlUnrollMask, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"DontUnroll", SpvLoopControlDontUnrollMask, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
};
|
||||
|
||||
static const spv_operand_desc_t functionControlEntries[] = {
|
||||
{"None",
|
||||
SpvFunctionControlMaskNone,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"Inline",
|
||||
SpvFunctionControlInlineMask,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"None", SpvFunctionControlMaskNone, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"Inline", SpvFunctionControlInlineMask, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"DontInline",
|
||||
SpvFunctionControlDontInlineMask,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"Pure",
|
||||
SpvFunctionControlPureMask,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"Const",
|
||||
SpvFunctionControlConstMask,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"Pure", SpvFunctionControlPureMask, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"Const", SpvFunctionControlConstMask, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
};
|
||||
|
||||
static const spv_operand_desc_t memorySemanticsEntries[] = {
|
||||
// "Relaxed" should be a synonym for "None".
|
||||
// Put the Relaxed entry first so that the disassembler
|
||||
// will prefer to emit "Relaxed".
|
||||
{"Relaxed",
|
||||
SpvMemorySemanticsMaskNone,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"None",
|
||||
SpvMemorySemanticsMaskNone,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"Relaxed", SpvMemorySemanticsMaskNone, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"None", SpvMemorySemanticsMaskNone, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"SequentiallyConsistent",
|
||||
SpvMemorySemanticsSequentiallyConsistentMask,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"Acquire",
|
||||
SpvMemorySemanticsAcquireMask,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"Release",
|
||||
SpvMemorySemanticsReleaseMask,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"Acquire", SpvMemorySemanticsAcquireMask, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"Release", SpvMemorySemanticsReleaseMask, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"UniformMemory",
|
||||
SpvMemorySemanticsUniformMemoryMask,
|
||||
SPV_CAPABILITY_AS_MASK(SpvCapabilityShader),
|
||||
|
@ -1000,45 +884,24 @@ static const spv_operand_desc_t memorySemanticsEntries[] = {
|
|||
};
|
||||
|
||||
static const spv_operand_desc_t memoryAccessEntries[] = {
|
||||
{"None",
|
||||
SpvMemoryAccessMaskNone,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"Volatile",
|
||||
SpvMemoryAccessVolatileMask,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"None", SpvMemoryAccessMaskNone, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"Volatile", SpvMemoryAccessVolatileMask, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{
|
||||
"Aligned",
|
||||
SpvMemoryAccessAlignedMask,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_LITERAL_INTEGER, SPV_OPERAND_TYPE_NONE},
|
||||
},
|
||||
{"Nontemporal",
|
||||
SpvMemoryAccessNontemporalMask,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"Nontemporal", SpvMemoryAccessNontemporalMask, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
};
|
||||
|
||||
static const spv_operand_desc_t scopeEntries[] = {
|
||||
{"CrossDevice",
|
||||
SpvScopeCrossDevice,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"CrossDevice", SpvScopeCrossDevice, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"Device", SpvScopeDevice, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"Workgroup",
|
||||
SpvScopeWorkgroup,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"Subgroup",
|
||||
SpvScopeSubgroup,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"Workgroup", SpvScopeWorkgroup, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"Subgroup", SpvScopeSubgroup, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{
|
||||
"Invocation",
|
||||
SpvScopeInvocation,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE},
|
||||
"Invocation", SpvScopeInvocation, 0, {SPV_OPERAND_TYPE_NONE},
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -1073,10 +936,7 @@ static const spv_operand_desc_t kernelKernelEnqueueFlagssEntries[] = {
|
|||
};
|
||||
|
||||
static const spv_operand_desc_t kernelProfilingInfoEntries[] = {
|
||||
{"None",
|
||||
SpvKernelProfilingInfoMaskNone,
|
||||
0,
|
||||
{SPV_OPERAND_TYPE_NONE}},
|
||||
{"None", SpvKernelProfilingInfoMaskNone, 0, {SPV_OPERAND_TYPE_NONE}},
|
||||
{"CmdExecTime",
|
||||
SpvKernelProfilingInfoCmdExecTimeMask,
|
||||
SPV_CAPABILITY_AS_MASK(SpvCapabilityKernel),
|
||||
|
|
|
@ -27,21 +27,21 @@
|
|||
#include "print.h"
|
||||
|
||||
#if defined(SPIRV_LINUX) || defined(SPIRV_MAC)
|
||||
clr::reset::operator const char *() { return "\e[0m"; }
|
||||
clr::reset::operator const char*() { return "\e[0m"; }
|
||||
|
||||
clr::grey::operator const char *() { return "\e[1;30m"; }
|
||||
clr::grey::operator const char*() { return "\e[1;30m"; }
|
||||
|
||||
clr::red::operator const char *() { return "\e[31m"; }
|
||||
clr::red::operator const char*() { return "\e[31m"; }
|
||||
|
||||
clr::green::operator const char *() { return "\e[32m"; }
|
||||
clr::green::operator const char*() { return "\e[32m"; }
|
||||
|
||||
clr::yellow::operator const char *() { return "\e[33m"; }
|
||||
clr::yellow::operator const char*() { return "\e[33m"; }
|
||||
|
||||
clr::blue::operator const char *() { return "\e[34m"; }
|
||||
clr::blue::operator const char*() { return "\e[34m"; }
|
||||
#elif defined(SPIRV_WINDOWS)
|
||||
#include <Windows.h>
|
||||
|
||||
clr::reset::operator const char *() {
|
||||
clr::reset::operator const char*() {
|
||||
const DWORD color = 0Xf;
|
||||
HANDLE hConsole;
|
||||
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
@ -51,7 +51,7 @@ clr::reset::operator const char *() {
|
|||
return "";
|
||||
}
|
||||
|
||||
clr::grey::operator const char *() {
|
||||
clr::grey::operator const char*() {
|
||||
const DWORD color = 0x8;
|
||||
HANDLE hConsole;
|
||||
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
@ -61,7 +61,7 @@ clr::grey::operator const char *() {
|
|||
return "";
|
||||
}
|
||||
|
||||
clr::red::operator const char *() {
|
||||
clr::red::operator const char*() {
|
||||
const DWORD color = 0x4;
|
||||
HANDLE hConsole;
|
||||
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
@ -71,7 +71,7 @@ clr::red::operator const char *() {
|
|||
return "";
|
||||
}
|
||||
|
||||
clr::green::operator const char *() {
|
||||
clr::green::operator const char*() {
|
||||
const DWORD color = 0x2;
|
||||
HANDLE hConsole;
|
||||
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
@ -81,7 +81,7 @@ clr::green::operator const char *() {
|
|||
return "";
|
||||
}
|
||||
|
||||
clr::yellow::operator const char *() {
|
||||
clr::yellow::operator const char*() {
|
||||
const DWORD color = 0x6;
|
||||
HANDLE hConsole;
|
||||
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
@ -91,7 +91,7 @@ clr::yellow::operator const char *() {
|
|||
return "";
|
||||
}
|
||||
|
||||
clr::blue::operator const char *() {
|
||||
clr::blue::operator const char*() {
|
||||
const DWORD color = 0x1;
|
||||
HANDLE hConsole;
|
||||
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
|
|
@ -34,9 +34,9 @@
|
|||
class out_stream {
|
||||
public:
|
||||
out_stream() : pStream(nullptr) {}
|
||||
out_stream(std::stringstream &stream) : pStream(&stream) {}
|
||||
out_stream(std::stringstream& stream) : pStream(&stream) {}
|
||||
|
||||
std::ostream &get() {
|
||||
std::ostream& get() {
|
||||
if (pStream) {
|
||||
return *pStream;
|
||||
}
|
||||
|
@ -44,33 +44,33 @@ class out_stream {
|
|||
}
|
||||
|
||||
private:
|
||||
std::stringstream *pStream;
|
||||
std::stringstream* pStream;
|
||||
};
|
||||
|
||||
namespace clr {
|
||||
/// @brief Reset console color
|
||||
struct reset {
|
||||
operator const char *();
|
||||
operator const char*();
|
||||
};
|
||||
/// @brief Set console color to grey
|
||||
struct grey {
|
||||
operator const char *();
|
||||
operator const char*();
|
||||
};
|
||||
/// @brief Set console color to red
|
||||
struct red {
|
||||
operator const char *();
|
||||
operator const char*();
|
||||
};
|
||||
/// @brief Set console color to green
|
||||
struct green {
|
||||
operator const char *();
|
||||
operator const char*();
|
||||
};
|
||||
/// @brief Set console color to yellow
|
||||
struct yellow {
|
||||
operator const char *();
|
||||
operator const char*();
|
||||
};
|
||||
/// @brief Set console color to blue
|
||||
struct blue {
|
||||
operator const char *();
|
||||
operator const char*();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,6 @@ typedef struct spv_literal_t {
|
|||
} value;
|
||||
} spv_literal_t;
|
||||
|
||||
|
||||
// Functions
|
||||
|
||||
/// @brief Convert the input text to one of the number types, or to
|
||||
|
@ -74,6 +73,6 @@ typedef struct spv_literal_t {
|
|||
/// @param[out] pLiteral the returned literal
|
||||
///
|
||||
/// @return result code
|
||||
spv_result_t spvTextToLiteral(const char *textValue, spv_literal_t *pLiteral);
|
||||
spv_result_t spvTextToLiteral(const char* textValue, spv_literal_t* pLiteral);
|
||||
|
||||
#endif // LIBSPIRV_TEXT_H_
|
||||
|
|
|
@ -111,7 +111,7 @@ spv_result_t advance(spv_text text, spv_position position) {
|
|||
/// @param[out] endPosition one past the end of the returned word
|
||||
///
|
||||
/// @return result code
|
||||
spv_result_t getWord(spv_text text, spv_position position, std::string &word,
|
||||
spv_result_t getWord(spv_text text, spv_position position, std::string& word,
|
||||
spv_position endPosition) {
|
||||
if (!text->str || !text->length) return SPV_ERROR_INVALID_TEXT;
|
||||
if (!position || !endPosition) return SPV_ERROR_INVALID_POINTER;
|
||||
|
@ -173,7 +173,7 @@ const IdType kUnknownType = {0, false, IdTypeClass::kBottom};
|
|||
|
||||
// This represents all of the data that is only valid for the duration of
|
||||
// a single compilation.
|
||||
uint32_t AssemblyContext::spvNamedIdAssignOrGet(const char *textValue) {
|
||||
uint32_t AssemblyContext::spvNamedIdAssignOrGet(const char* textValue) {
|
||||
if (named_ids_.end() == named_ids_.find(textValue)) {
|
||||
named_ids_[std::string(textValue)] = bound_++;
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ spv_result_t AssemblyContext::advance() {
|
|||
return ::advance(text_, ¤t_position_);
|
||||
}
|
||||
|
||||
spv_result_t AssemblyContext::getWord(std::string &word,
|
||||
spv_result_t AssemblyContext::getWord(std::string& word,
|
||||
spv_position endPosition) {
|
||||
return ::getWord(text_, ¤t_position_, word, endPosition);
|
||||
}
|
||||
|
@ -248,13 +248,13 @@ void AssemblyContext::seekForward(uint32_t size) {
|
|||
}
|
||||
|
||||
spv_result_t AssemblyContext::binaryEncodeU32(const uint32_t value,
|
||||
spv_instruction_t *pInst) {
|
||||
spv_instruction_t* pInst) {
|
||||
spvInstructionAddWord(pInst, value);
|
||||
return SPV_SUCCESS;
|
||||
}
|
||||
|
||||
spv_result_t AssemblyContext::binaryEncodeU64(const uint64_t value,
|
||||
spv_instruction_t *pInst) {
|
||||
spv_instruction_t* pInst) {
|
||||
uint32_t low = uint32_t(0x00000000ffffffff & value);
|
||||
uint32_t high = uint32_t((0xffffffff00000000 & value) >> 32);
|
||||
binaryEncodeU32(low, pInst);
|
||||
|
@ -263,8 +263,8 @@ spv_result_t AssemblyContext::binaryEncodeU64(const uint64_t value,
|
|||
}
|
||||
|
||||
spv_result_t AssemblyContext::binaryEncodeNumericLiteral(
|
||||
const char *val, spv_result_t error_code, const IdType &type,
|
||||
spv_instruction_t *pInst) {
|
||||
const char* val, spv_result_t error_code, const IdType& type,
|
||||
spv_instruction_t* pInst) {
|
||||
const bool is_bottom = type.type_class == libspirv::IdTypeClass::kBottom;
|
||||
const bool is_floating = libspirv::isScalarFloating(type);
|
||||
const bool is_integer = libspirv::isScalarIntegral(type);
|
||||
|
@ -286,8 +286,8 @@ spv_result_t AssemblyContext::binaryEncodeNumericLiteral(
|
|||
return binaryEncodeIntegerLiteral(val, error_code, type, pInst);
|
||||
}
|
||||
|
||||
spv_result_t AssemblyContext::binaryEncodeString(
|
||||
const char *value, spv_instruction_t *pInst) {
|
||||
spv_result_t AssemblyContext::binaryEncodeString(const char* value,
|
||||
spv_instruction_t* pInst) {
|
||||
const size_t length = strlen(value);
|
||||
const size_t wordCount = (length / 4) + 1;
|
||||
const size_t oldWordCount = pInst->words.size();
|
||||
|
@ -305,18 +305,18 @@ spv_result_t AssemblyContext::binaryEncodeString(
|
|||
// write a partial word at the end.
|
||||
pInst->words.back() = 0;
|
||||
|
||||
char *dest = (char *)&pInst->words[oldWordCount];
|
||||
char* dest = (char*)&pInst->words[oldWordCount];
|
||||
strncpy(dest, value, length);
|
||||
|
||||
return SPV_SUCCESS;
|
||||
}
|
||||
|
||||
spv_result_t AssemblyContext::recordTypeDefinition(
|
||||
const spv_instruction_t *pInst) {
|
||||
const spv_instruction_t* pInst) {
|
||||
uint32_t value = pInst->words[1];
|
||||
if (types_.find(value) != types_.end()) {
|
||||
return diagnostic()
|
||||
<< "Value " << value << " has already been used to generate a type";
|
||||
return diagnostic() << "Value " << value
|
||||
<< " has already been used to generate a type";
|
||||
}
|
||||
|
||||
if (pInst->opcode == SpvOpTypeInt) {
|
||||
|
@ -345,7 +345,7 @@ IdType AssemblyContext::getTypeOfTypeGeneratingValue(uint32_t value) const {
|
|||
IdType AssemblyContext::getTypeOfValueInstruction(uint32_t value) const {
|
||||
auto type_value = value_types_.find(value);
|
||||
if (type_value == value_types_.end()) {
|
||||
return { 0, false, IdTypeClass::kBottom};
|
||||
return {0, false, IdTypeClass::kBottom};
|
||||
}
|
||||
return getTypeOfTypeGeneratingValue(std::get<1>(*type_value));
|
||||
}
|
||||
|
@ -361,8 +361,8 @@ spv_result_t AssemblyContext::recordTypeIdForValue(uint32_t value,
|
|||
}
|
||||
|
||||
spv_result_t AssemblyContext::binaryEncodeFloatingPointLiteral(
|
||||
const char *val, spv_result_t error_code, const IdType &type,
|
||||
spv_instruction_t *pInst) {
|
||||
const char* val, spv_result_t error_code, const IdType& type,
|
||||
spv_instruction_t* pInst) {
|
||||
const auto bit_width = assumedBitWidth(type);
|
||||
switch (bit_width) {
|
||||
case 16:
|
||||
|
@ -389,8 +389,8 @@ spv_result_t AssemblyContext::binaryEncodeFloatingPointLiteral(
|
|||
}
|
||||
|
||||
spv_result_t AssemblyContext::binaryEncodeIntegerLiteral(
|
||||
const char *val, spv_result_t error_code, const IdType &type,
|
||||
spv_instruction_t *pInst) {
|
||||
const char* val, spv_result_t error_code, const IdType& type,
|
||||
spv_instruction_t* pInst) {
|
||||
const bool is_bottom = type.type_class == libspirv::IdTypeClass::kBottom;
|
||||
const auto bit_width = assumedBitWidth(type);
|
||||
|
||||
|
@ -437,8 +437,8 @@ spv_result_t AssemblyContext::binaryEncodeIntegerLiteral(
|
|||
|
||||
template <typename T>
|
||||
spv_result_t AssemblyContext::checkRangeAndIfHexThenSignExtend(
|
||||
T value, spv_result_t error_code, const IdType &type, bool is_hex,
|
||||
T *updated_value_for_hex) {
|
||||
T value, spv_result_t error_code, const IdType& type, bool is_hex,
|
||||
T* updated_value_for_hex) {
|
||||
// The encoded result has three regions of bits that are of interest, from
|
||||
// least to most significant:
|
||||
// - magnitude bits, where the magnitude of the number would be stored if
|
||||
|
@ -497,4 +497,4 @@ spv_result_t AssemblyContext::checkRangeAndIfHexThenSignExtend(
|
|||
|
||||
return SPV_SUCCESS;
|
||||
}
|
||||
} // namespace libspirv
|
||||
} // namespace libspirv
|
||||
|
|
|
@ -43,31 +43,30 @@ namespace libspirv {
|
|||
|
||||
// This is a lattice for tracking types.
|
||||
enum class IdTypeClass {
|
||||
kBottom = 0, // We have no information yet.
|
||||
kBottom = 0, // We have no information yet.
|
||||
kScalarIntegerType,
|
||||
kScalarFloatType,
|
||||
kOtherType
|
||||
};
|
||||
|
||||
|
||||
// Contains ID type information that needs to be tracked across all Ids.
|
||||
// Bitwidth is only valid when type_class is kScalarIntegerType or
|
||||
// kScalarFloatType.
|
||||
struct IdType {
|
||||
uint32_t bitwidth; // Safe to assume that we will not have > 2^32 bits.
|
||||
bool isSigned; // This is only significant if type_class is integral.
|
||||
bool isSigned; // This is only significant if type_class is integral.
|
||||
IdTypeClass type_class;
|
||||
};
|
||||
|
||||
// Default equality operator for IdType. Tests if all members are the same.
|
||||
inline bool operator==(const IdType &first, const IdType &second) {
|
||||
inline bool operator==(const IdType& first, const IdType& second) {
|
||||
return (first.bitwidth == second.bitwidth) &&
|
||||
(first.isSigned == second.isSigned) &&
|
||||
(first.type_class == second.type_class);
|
||||
}
|
||||
|
||||
// Tests whether any member of the IdTypes do not match.
|
||||
inline bool operator!=(const IdType &first, const IdType &second) {
|
||||
inline bool operator!=(const IdType& first, const IdType& second) {
|
||||
return !(first == second);
|
||||
}
|
||||
|
||||
|
@ -88,7 +87,7 @@ inline bool isScalarFloating(const IdType& type) {
|
|||
// This is only valid for bottom, scalar integer, and scalar floating
|
||||
// classes. For bottom, assume 32 bits.
|
||||
inline int assumedBitWidth(const IdType& type) {
|
||||
switch(type.type_class) {
|
||||
switch (type.type_class) {
|
||||
case IdTypeClass::kBottom:
|
||||
return 32;
|
||||
case IdTypeClass::kScalarIntegerType:
|
||||
|
@ -104,7 +103,7 @@ inline int assumedBitWidth(const IdType& type) {
|
|||
// Encapsulates the data used during the assembly of a SPIR-V module.
|
||||
class AssemblyContext {
|
||||
public:
|
||||
AssemblyContext(spv_text text, spv_diagnostic *diagnostic)
|
||||
AssemblyContext(spv_text text, spv_diagnostic* diagnostic)
|
||||
: current_position_({}),
|
||||
pDiagnostic_(diagnostic),
|
||||
text_(text),
|
||||
|
@ -112,7 +111,7 @@ class AssemblyContext {
|
|||
|
||||
// Assigns a new integer value to the given text ID, or returns the previously
|
||||
// assigned integer value if the ID has been seen before.
|
||||
uint32_t spvNamedIdAssignOrGet(const char *textValue);
|
||||
uint32_t spvNamedIdAssignOrGet(const char* textValue);
|
||||
|
||||
// Returns the largest largest numeric ID that has been assigned.
|
||||
uint32_t getBound() const;
|
||||
|
@ -123,7 +122,7 @@ class AssemblyContext {
|
|||
|
||||
// Sets word to the next word in the input text. Fills endPosition with
|
||||
// the next location past the end of the word.
|
||||
spv_result_t getWord(std::string &word, spv_position endPosition);
|
||||
spv_result_t getWord(std::string& word, spv_position endPosition);
|
||||
|
||||
// Returns the next word in the input stream. It is invalid to call this
|
||||
// method if position has been set to a location in the stream that does not
|
||||
|
@ -160,22 +159,22 @@ class AssemblyContext {
|
|||
void seekForward(uint32_t size);
|
||||
|
||||
// Sets the current position in the input stream to the given position.
|
||||
void setPosition(const spv_position_t &newPosition) {
|
||||
void setPosition(const spv_position_t& newPosition) {
|
||||
current_position_ = newPosition;
|
||||
}
|
||||
|
||||
// Returns the current position in the input stream.
|
||||
const spv_position_t &position() const { return current_position_; }
|
||||
const spv_position_t& position() const { return current_position_; }
|
||||
|
||||
// Appends the given 32-bit value to the given instruction.
|
||||
// Returns SPV_SUCCESS if the value could be correctly inserted in the
|
||||
// instruction.
|
||||
spv_result_t binaryEncodeU32(const uint32_t value, spv_instruction_t *pInst);
|
||||
spv_result_t binaryEncodeU32(const uint32_t value, spv_instruction_t* pInst);
|
||||
|
||||
// Appends the given string to the given instruction.
|
||||
// Returns SPV_SUCCESS if the value could be correctly inserted in the
|
||||
// instruction.
|
||||
spv_result_t binaryEncodeString(const char *value, spv_instruction_t *pInst);
|
||||
spv_result_t binaryEncodeString(const char* value, spv_instruction_t* pInst);
|
||||
|
||||
// Appends the given numeric literal to the given instruction.
|
||||
// Validates and respects the bitwidth supplied in the IdType argument.
|
||||
|
@ -184,10 +183,10 @@ class AssemblyContext {
|
|||
// Returns SPV_SUCCESS if the value could be correctly added to the
|
||||
// instruction. Returns the given error code on failure, and emits
|
||||
// a diagnotic if that error code is not SPV_FAILED_MATCH.
|
||||
spv_result_t binaryEncodeNumericLiteral(const char *numeric_literal,
|
||||
spv_result_t binaryEncodeNumericLiteral(const char* numeric_literal,
|
||||
spv_result_t error_code,
|
||||
const IdType &type,
|
||||
spv_instruction_t *pInst);
|
||||
const IdType& type,
|
||||
spv_instruction_t* pInst);
|
||||
|
||||
// Returns the IdType associated with this type-generating value.
|
||||
// If the type has not been previously recorded with recordTypeDefinition,
|
||||
|
@ -216,13 +215,14 @@ class AssemblyContext {
|
|||
// referenced by value_pointer. On failure, returns the given error code,
|
||||
// and emits a diagnostic if that error code is not SPV_FAILED_MATCH.
|
||||
template <typename T>
|
||||
spv_result_t parseNumber(const char *text, spv_result_t error_code,
|
||||
T *value_pointer,
|
||||
const char *error_message_fragment) {
|
||||
spv_result_t parseNumber(const char* text, spv_result_t error_code,
|
||||
T* value_pointer,
|
||||
const char* error_message_fragment) {
|
||||
// C++11 doesn't define std::istringstream(int8_t&), so calling this method
|
||||
// with a single-byte type leads to implementation-defined behaviour.
|
||||
// Similarly for uint8_t.
|
||||
static_assert(sizeof(T) > 1, "Don't use a single-byte type this parse method");
|
||||
static_assert(sizeof(T) > 1,
|
||||
"Don't use a single-byte type this parse method");
|
||||
|
||||
std::istringstream text_stream(text);
|
||||
// Allow both decimal and hex input for integers.
|
||||
|
@ -257,20 +257,20 @@ class AssemblyContext {
|
|||
// returns the given error code, and emits a diagnostic if that error
|
||||
// code is not SPV_FAILED_MATCH.
|
||||
// Only 32 and 64 bit floating point numbers are supported.
|
||||
spv_result_t binaryEncodeFloatingPointLiteral(const char *numeric_literal,
|
||||
spv_result_t binaryEncodeFloatingPointLiteral(const char* numeric_literal,
|
||||
spv_result_t error_code,
|
||||
const IdType& type,
|
||||
spv_instruction_t *pInst);
|
||||
spv_instruction_t* pInst);
|
||||
|
||||
// Appends the given integer literal to the given instruction.
|
||||
// Returns SPV_SUCCESS if the value was correctly parsed. Otherwise
|
||||
// returns the given error code, and emits a diagnostic if that error
|
||||
// code is not SPV_FAILED_MATCH.
|
||||
// Integers up to 64 bits are supported.
|
||||
spv_result_t binaryEncodeIntegerLiteral(const char *numeric_literal,
|
||||
spv_result_t binaryEncodeIntegerLiteral(const char* numeric_literal,
|
||||
spv_result_t error_code,
|
||||
const IdType &type,
|
||||
spv_instruction_t *pInst);
|
||||
const IdType& type,
|
||||
spv_instruction_t* pInst);
|
||||
|
||||
// Returns SPV_SUCCESS if the given value fits within the target scalar
|
||||
// integral type. The target type may have an unusual bit width.
|
||||
|
@ -281,13 +281,14 @@ class AssemblyContext {
|
|||
// On failure, return the given error code and emit a diagnostic if that error
|
||||
// code is not SPV_FAILED_MATCH.
|
||||
template <typename T>
|
||||
spv_result_t checkRangeAndIfHexThenSignExtend(T value, spv_result_t error_code,
|
||||
const IdType &type, bool is_hex,
|
||||
T *updated_value_for_hex);
|
||||
spv_result_t checkRangeAndIfHexThenSignExtend(T value,
|
||||
spv_result_t error_code,
|
||||
const IdType& type, bool is_hex,
|
||||
T* updated_value_for_hex);
|
||||
|
||||
// Writes the given 64-bit literal value into the instruction.
|
||||
// return SPV_SUCCESS if the value could be written in the instruction.
|
||||
spv_result_t binaryEncodeU64(const uint64_t value, spv_instruction_t *pInst);
|
||||
spv_result_t binaryEncodeU64(const uint64_t value, spv_instruction_t* pInst);
|
||||
// Maps ID names to their corresponding numerical ids.
|
||||
using spv_named_id_table = std::unordered_map<std::string, uint32_t>;
|
||||
// Maps type-defining IDs to their IdType.
|
||||
|
@ -299,7 +300,7 @@ class AssemblyContext {
|
|||
spv_id_to_type_map types_;
|
||||
spv_id_to_type_id value_types_;
|
||||
spv_position_t current_position_;
|
||||
spv_diagnostic *pDiagnostic_;
|
||||
spv_diagnostic* pDiagnostic_;
|
||||
spv_text text_;
|
||||
uint32_t bound_;
|
||||
};
|
||||
|
|
|
@ -42,11 +42,11 @@
|
|||
#define spvCheckReturn(expression) \
|
||||
if (spv_result_t error = (expression)) return error;
|
||||
|
||||
spv_result_t spvValidateOperandsString(const uint32_t *words,
|
||||
spv_result_t spvValidateOperandsString(const uint32_t* words,
|
||||
const uint16_t wordCount,
|
||||
spv_position position,
|
||||
spv_diagnostic *pDiagnostic) {
|
||||
const char *str = (const char *)words;
|
||||
spv_diagnostic* pDiagnostic) {
|
||||
const char* str = (const char*)words;
|
||||
uint64_t strWordCount = strlen(str) / sizeof(uint32_t) + 1;
|
||||
if (strWordCount < wordCount) {
|
||||
DIAGNOSTIC << "Instruction word count is too short, string extends past "
|
||||
|
@ -56,11 +56,11 @@ spv_result_t spvValidateOperandsString(const uint32_t *words,
|
|||
return SPV_SUCCESS;
|
||||
}
|
||||
|
||||
spv_result_t spvValidateOperandsLiteral(const uint32_t *words,
|
||||
spv_result_t spvValidateOperandsLiteral(const uint32_t* words,
|
||||
const uint32_t length,
|
||||
const uint16_t maxLength,
|
||||
spv_position position,
|
||||
spv_diagnostic *pDiagnostic) {
|
||||
spv_diagnostic* pDiagnostic) {
|
||||
// NOTE: A literal could either be a number consuming up to 2 words or a
|
||||
// null terminated string.
|
||||
(void)words;
|
||||
|
@ -75,7 +75,7 @@ spv_result_t spvValidateOperandValue(const spv_operand_type_t type,
|
|||
const uint32_t word,
|
||||
const spv_operand_table operandTable,
|
||||
spv_position position,
|
||||
spv_diagnostic *pDiagnostic) {
|
||||
spv_diagnostic* pDiagnostic) {
|
||||
switch (type) {
|
||||
case SPV_OPERAND_TYPE_ID:
|
||||
case SPV_OPERAND_TYPE_RESULT_ID: {
|
||||
|
@ -125,14 +125,14 @@ spv_result_t spvValidateOperandValue(const spv_operand_type_t type,
|
|||
return SPV_SUCCESS;
|
||||
}
|
||||
|
||||
spv_result_t spvValidateBasic(const spv_instruction_t *pInsts,
|
||||
spv_result_t spvValidateBasic(const spv_instruction_t* pInsts,
|
||||
const uint64_t instCount,
|
||||
const spv_opcode_table opcodeTable,
|
||||
const spv_operand_table operandTable,
|
||||
spv_position position,
|
||||
spv_diagnostic *pDiagnostic) {
|
||||
spv_diagnostic* pDiagnostic) {
|
||||
for (uint64_t instIndex = 0; instIndex < instCount; ++instIndex) {
|
||||
const uint32_t *words = pInsts[instIndex].words.data();
|
||||
const uint32_t* words = pInsts[instIndex].words.data();
|
||||
uint16_t wordCount;
|
||||
SpvOp opcode;
|
||||
spvOpcodeSplit(words[0], &wordCount, &opcode);
|
||||
|
@ -182,18 +182,18 @@ spv_result_t spvValidateBasic(const spv_instruction_t *pInsts,
|
|||
return SPV_SUCCESS;
|
||||
}
|
||||
|
||||
spv_result_t spvValidateIDs(const spv_instruction_t *pInsts,
|
||||
spv_result_t spvValidateIDs(const spv_instruction_t* pInsts,
|
||||
const uint64_t count, const uint32_t bound,
|
||||
const spv_opcode_table opcodeTable,
|
||||
const spv_operand_table operandTable,
|
||||
const spv_ext_inst_table extInstTable,
|
||||
spv_position position,
|
||||
spv_diagnostic *pDiagnostic) {
|
||||
spv_diagnostic* pDiagnostic) {
|
||||
std::vector<spv_id_info_t> idUses;
|
||||
std::vector<spv_id_info_t> idDefs;
|
||||
|
||||
for (uint64_t instIndex = 0; instIndex < count; ++instIndex) {
|
||||
const uint32_t *words = pInsts[instIndex].words.data();
|
||||
const uint32_t* words = pInsts[instIndex].words.data();
|
||||
SpvOp opcode;
|
||||
spvOpcodeSplit(words[0], nullptr, &opcode);
|
||||
|
||||
|
@ -263,7 +263,7 @@ spv_result_t spvValidate(const spv_binary binary,
|
|||
const spv_opcode_table opcodeTable,
|
||||
const spv_operand_table operandTable,
|
||||
const spv_ext_inst_table extInstTable,
|
||||
const uint32_t options, spv_diagnostic *pDiagnostic) {
|
||||
const uint32_t options, spv_diagnostic* pDiagnostic) {
|
||||
if (!opcodeTable || !operandTable) return SPV_ERROR_INVALID_TABLE;
|
||||
if (!pDiagnostic) return SPV_ERROR_INVALID_DIAGNOSTIC;
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
typedef struct spv_id_info_t {
|
||||
uint32_t id;
|
||||
SpvOp opcode;
|
||||
const spv_instruction_t *inst;
|
||||
const spv_instruction_t* inst;
|
||||
spv_position_t position;
|
||||
} spv_id_info_t;
|
||||
|
||||
|
@ -56,12 +56,12 @@ typedef struct spv_id_info_t {
|
|||
///
|
||||
/// @return result code
|
||||
spv_result_t spvValidateInstructionIDs(
|
||||
const spv_instruction_t *pInsts, const uint64_t instCount,
|
||||
const spv_id_info_t *pIdUses, const uint64_t idUsesCount,
|
||||
const spv_id_info_t *pIdDefs, const uint64_t idDefsCount,
|
||||
const spv_instruction_t* pInsts, const uint64_t instCount,
|
||||
const spv_id_info_t* pIdUses, const uint64_t idUsesCount,
|
||||
const spv_id_info_t* pIdDefs, const uint64_t idDefsCount,
|
||||
const spv_opcode_table opcodeTable, const spv_operand_table operandTable,
|
||||
const spv_ext_inst_table extInstTable, spv_position position,
|
||||
spv_diagnostic *pDiag);
|
||||
spv_diagnostic* pDiag);
|
||||
|
||||
/// @brief Validate the ID's within a SPIR-V binary
|
||||
///
|
||||
|
@ -74,11 +74,11 @@ spv_result_t spvValidateInstructionIDs(
|
|||
/// @param[out] pDiagnostic contains diagnostic on failure
|
||||
///
|
||||
/// @return result code
|
||||
spv_result_t spvValidateIDs(const spv_instruction_t *pInstructions,
|
||||
spv_result_t spvValidateIDs(const spv_instruction_t* pInstructions,
|
||||
const uint64_t count, const uint32_t bound,
|
||||
const spv_opcode_table opcodeTable,
|
||||
const spv_operand_table operandTable,
|
||||
const spv_ext_inst_table extInstTable,
|
||||
spv_position position, spv_diagnostic *pDiagnostic);
|
||||
spv_position position, spv_diagnostic* pDiagnostic);
|
||||
|
||||
#endif // LIBSPIRV_VALIDATE_H_
|
||||
|
|
|
@ -46,11 +46,11 @@ class idUsage {
|
|||
public:
|
||||
idUsage(const spv_opcode_table opcodeTable,
|
||||
const spv_operand_table operandTable,
|
||||
const spv_ext_inst_table extInstTable, const spv_id_info_t *pIdUses,
|
||||
const uint64_t idUsesCount, const spv_id_info_t *pIdDefs,
|
||||
const uint64_t idDefsCount, const spv_instruction_t *pInsts,
|
||||
const spv_ext_inst_table extInstTable, const spv_id_info_t* pIdUses,
|
||||
const uint64_t idUsesCount, const spv_id_info_t* pIdDefs,
|
||||
const uint64_t idDefsCount, const spv_instruction_t* pInsts,
|
||||
const uint64_t instCount, spv_position position,
|
||||
spv_diagnostic *pDiagnostic)
|
||||
spv_diagnostic* pDiagnostic)
|
||||
: opcodeTable(opcodeTable),
|
||||
operandTable(operandTable),
|
||||
extInstTable(extInstTable),
|
||||
|
@ -66,17 +66,17 @@ class idUsage {
|
|||
}
|
||||
}
|
||||
|
||||
bool isValid(const spv_instruction_t *inst);
|
||||
bool isValid(const spv_instruction_t* inst);
|
||||
|
||||
template <SpvOp>
|
||||
bool isValid(const spv_instruction_t *inst, const spv_opcode_desc);
|
||||
bool isValid(const spv_instruction_t* inst, const spv_opcode_desc);
|
||||
|
||||
std::unordered_map<uint32_t, spv_id_info_t>::iterator find(
|
||||
const uint32_t &id) {
|
||||
const uint32_t& id) {
|
||||
return idDefs.find(id);
|
||||
}
|
||||
std::unordered_map<uint32_t, spv_id_info_t>::const_iterator find(
|
||||
const uint32_t &id) const {
|
||||
const uint32_t& id) const {
|
||||
return idDefs.find(id);
|
||||
}
|
||||
|
||||
|
@ -88,11 +88,11 @@ class idUsage {
|
|||
}
|
||||
|
||||
std::unordered_map<uint32_t, std::vector<spv_id_info_t>>::iterator findUses(
|
||||
const uint32_t &id) {
|
||||
const uint32_t& id) {
|
||||
return idUses.find(id);
|
||||
}
|
||||
std::unordered_map<uint32_t, std::vector<spv_id_info_t>>::const_iterator
|
||||
findUses(const uint32_t &id) const {
|
||||
findUses(const uint32_t& id) const {
|
||||
return idUses.find(id);
|
||||
}
|
||||
|
||||
|
@ -109,10 +109,10 @@ class idUsage {
|
|||
const spv_opcode_table opcodeTable;
|
||||
const spv_operand_table operandTable;
|
||||
const spv_ext_inst_table extInstTable;
|
||||
const spv_instruction_t *const firstInst;
|
||||
const spv_instruction_t* const firstInst;
|
||||
const uint64_t instCount;
|
||||
spv_position position;
|
||||
spv_diagnostic *pDiagnostic;
|
||||
spv_diagnostic* pDiagnostic;
|
||||
std::unordered_map<uint32_t, std::vector<spv_id_info_t>> idUses;
|
||||
std::unordered_map<uint32_t, spv_id_info_t> idDefs;
|
||||
};
|
||||
|
@ -131,7 +131,7 @@ bool idUsage::isValid<SpvOpUndef>(const spv_instruction_t *inst,
|
|||
#endif
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpName>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpName>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto targetIndex = 1;
|
||||
auto target = find(inst->words[targetIndex]);
|
||||
|
@ -143,7 +143,7 @@ bool idUsage::isValid<SpvOpName>(const spv_instruction_t *inst,
|
|||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpMemberName>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpMemberName>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto typeIndex = 1;
|
||||
auto type = find(inst->words[typeIndex]);
|
||||
|
@ -169,7 +169,7 @@ bool idUsage::isValid<SpvOpMemberName>(const spv_instruction_t *inst,
|
|||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpLine>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpLine>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto fileIndex = 1;
|
||||
auto file = find(inst->words[fileIndex]);
|
||||
|
@ -185,7 +185,7 @@ bool idUsage::isValid<SpvOpLine>(const spv_instruction_t *inst,
|
|||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpDecorate>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpDecorate>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto targetIndex = 1;
|
||||
auto target = find(inst->words[targetIndex]);
|
||||
|
@ -197,7 +197,7 @@ bool idUsage::isValid<SpvOpDecorate>(const spv_instruction_t *inst,
|
|||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpMemberDecorate>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpMemberDecorate>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto structTypeIndex = 1;
|
||||
auto structType = find(inst->words[structTypeIndex]);
|
||||
|
@ -223,7 +223,7 @@ bool idUsage::isValid<SpvOpMemberDecorate>(const spv_instruction_t *inst,
|
|||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpGroupDecorate>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpGroupDecorate>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto decorationGroupIndex = 1;
|
||||
auto decorationGroup = find(inst->words[decorationGroupIndex]);
|
||||
|
@ -238,7 +238,8 @@ bool idUsage::isValid<SpvOpGroupDecorate>(const spv_instruction_t *inst,
|
|||
<< inst->words[decorationGroupIndex]
|
||||
<< "' is not a decoration group.";
|
||||
return false);
|
||||
for (size_t targetIndex = 2; targetIndex < inst->words.size(); ++targetIndex) {
|
||||
for (size_t targetIndex = 2; targetIndex < inst->words.size();
|
||||
++targetIndex) {
|
||||
auto target = find(inst->words[targetIndex]);
|
||||
spvCheck(!found(target), DIAG(targetIndex)
|
||||
<< "OpGroupDecorate Target <id> '"
|
||||
|
@ -262,7 +263,7 @@ bool idUsage::isValid<SpvOpExtInst>(const spv_instruction_t *inst,
|
|||
#endif
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpEntryPoint>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpEntryPoint>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto entryPointIndex = 2;
|
||||
auto entryPoint = find(inst->words[entryPointIndex]);
|
||||
|
@ -296,7 +297,7 @@ bool idUsage::isValid<SpvOpEntryPoint>(const spv_instruction_t *inst,
|
|||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpExecutionMode>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpExecutionMode>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto entryPointIndex = 1;
|
||||
auto entryPoint = find(inst->words[entryPointIndex]);
|
||||
|
@ -323,7 +324,7 @@ bool idUsage::isValid<SpvOpExecutionMode>(const spv_instruction_t *inst,
|
|||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpTypeVector>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpTypeVector>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto componentIndex = 2;
|
||||
auto componentType = find(inst->words[componentIndex]);
|
||||
|
@ -341,7 +342,7 @@ bool idUsage::isValid<SpvOpTypeVector>(const spv_instruction_t *inst,
|
|||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpTypeMatrix>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpTypeMatrix>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto columnTypeIndex = 2;
|
||||
auto columnType = find(inst->words[columnTypeIndex]);
|
||||
|
@ -359,14 +360,14 @@ bool idUsage::isValid<SpvOpTypeMatrix>(const spv_instruction_t *inst,
|
|||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpTypeSampler>(const spv_instruction_t *,
|
||||
bool idUsage::isValid<SpvOpTypeSampler>(const spv_instruction_t*,
|
||||
const spv_opcode_desc) {
|
||||
// OpTypeSampler takes no arguments in Rev31 and beyond.
|
||||
return true;
|
||||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpTypeArray>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpTypeArray>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto elementTypeIndex = 2;
|
||||
auto elementType = find(inst->words[elementTypeIndex]);
|
||||
|
@ -434,7 +435,7 @@ bool idUsage::isValid<SpvOpTypeArray>(const spv_instruction_t *inst,
|
|||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpTypeRuntimeArray>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpTypeRuntimeArray>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto elementTypeIndex = 2;
|
||||
auto elementType = find(inst->words[elementTypeIndex]);
|
||||
|
@ -452,7 +453,7 @@ bool idUsage::isValid<SpvOpTypeRuntimeArray>(const spv_instruction_t *inst,
|
|||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpTypeStruct>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpTypeStruct>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
for (size_t memberTypeIndex = 2; memberTypeIndex < inst->words.size();
|
||||
++memberTypeIndex) {
|
||||
|
@ -472,7 +473,7 @@ bool idUsage::isValid<SpvOpTypeStruct>(const spv_instruction_t *inst,
|
|||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpTypePointer>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpTypePointer>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto typeIndex = 3;
|
||||
auto type = find(inst->words[typeIndex]);
|
||||
|
@ -488,7 +489,7 @@ bool idUsage::isValid<SpvOpTypePointer>(const spv_instruction_t *inst,
|
|||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpTypeFunction>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpTypeFunction>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto returnTypeIndex = 2;
|
||||
auto returnType = find(inst->words[returnTypeIndex]);
|
||||
|
@ -520,14 +521,14 @@ bool idUsage::isValid<SpvOpTypeFunction>(const spv_instruction_t *inst,
|
|||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpTypePipe>(const spv_instruction_t *,
|
||||
bool idUsage::isValid<SpvOpTypePipe>(const spv_instruction_t*,
|
||||
const spv_opcode_desc) {
|
||||
// OpTypePipe has no ID arguments.
|
||||
return true;
|
||||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpConstantTrue>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpConstantTrue>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto resultTypeIndex = 1;
|
||||
auto resultType = find(inst->words[resultTypeIndex]);
|
||||
|
@ -545,7 +546,7 @@ bool idUsage::isValid<SpvOpConstantTrue>(const spv_instruction_t *inst,
|
|||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpConstantFalse>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpConstantFalse>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto resultTypeIndex = 1;
|
||||
auto resultType = find(inst->words[resultTypeIndex]);
|
||||
|
@ -563,7 +564,7 @@ bool idUsage::isValid<SpvOpConstantFalse>(const spv_instruction_t *inst,
|
|||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpConstant>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpConstant>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto resultTypeIndex = 1;
|
||||
auto resultType = find(inst->words[resultTypeIndex]);
|
||||
|
@ -582,7 +583,7 @@ bool idUsage::isValid<SpvOpConstant>(const spv_instruction_t *inst,
|
|||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpConstantComposite>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpConstantComposite>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto resultTypeIndex = 1;
|
||||
auto resultType = find(inst->words[resultTypeIndex]);
|
||||
|
@ -773,7 +774,7 @@ bool idUsage::isValid<SpvOpConstantComposite>(const spv_instruction_t *inst,
|
|||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpConstantSampler>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpConstantSampler>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto resultTypeIndex = 1;
|
||||
auto resultType = find(inst->words[resultTypeIndex]);
|
||||
|
@ -791,7 +792,7 @@ bool idUsage::isValid<SpvOpConstantSampler>(const spv_instruction_t *inst,
|
|||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpConstantNull>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpConstantNull>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto resultTypeIndex = 1;
|
||||
auto resultType = find(inst->words[resultTypeIndex]);
|
||||
|
@ -842,7 +843,8 @@ bool idUsage::isValid<SpvOpConstantNull>(const spv_instruction_t *inst,
|
|||
} break;
|
||||
case SpvOpTypeStruct: {
|
||||
for (size_t elementIndex = 2;
|
||||
elementIndex < resultType->second.inst->words.size(); ++elementIndex) {
|
||||
elementIndex < resultType->second.inst->words.size();
|
||||
++elementIndex) {
|
||||
auto element = find(resultType->second.inst->words[elementIndex]);
|
||||
spvCheck(!found(element), assert(0 && "Unreachable!"));
|
||||
spvCheck(!spvOpcodeIsBasicTypeNullable(element->second.inst->opcode),
|
||||
|
@ -858,7 +860,7 @@ bool idUsage::isValid<SpvOpConstantNull>(const spv_instruction_t *inst,
|
|||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpSpecConstantTrue>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpSpecConstantTrue>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto resultTypeIndex = 1;
|
||||
auto resultType = find(inst->words[resultTypeIndex]);
|
||||
|
@ -876,7 +878,7 @@ bool idUsage::isValid<SpvOpSpecConstantTrue>(const spv_instruction_t *inst,
|
|||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpSpecConstantFalse>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpSpecConstantFalse>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto resultTypeIndex = 1;
|
||||
auto resultType = find(inst->words[resultTypeIndex]);
|
||||
|
@ -894,7 +896,7 @@ bool idUsage::isValid<SpvOpSpecConstantFalse>(const spv_instruction_t *inst,
|
|||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpSpecConstant>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpSpecConstant>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto resultTypeIndex = 1;
|
||||
auto resultType = find(inst->words[resultTypeIndex]);
|
||||
|
@ -923,7 +925,7 @@ bool idUsage::isValid<SpvOpSpecConstantOp>(const spv_instruction_t *inst) {}
|
|||
#endif
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpVariable>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpVariable>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc opcodeEntry) {
|
||||
auto resultTypeIndex = 1;
|
||||
auto resultType = find(inst->words[resultTypeIndex]);
|
||||
|
@ -955,7 +957,7 @@ bool idUsage::isValid<SpvOpVariable>(const spv_instruction_t *inst,
|
|||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpLoad>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpLoad>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto resultTypeIndex = 1;
|
||||
auto resultType = find(inst->words[resultTypeIndex]);
|
||||
|
@ -987,7 +989,7 @@ bool idUsage::isValid<SpvOpLoad>(const spv_instruction_t *inst,
|
|||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpStore>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpStore>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto pointerIndex = 1;
|
||||
auto pointer = find(inst->words[pointerIndex]);
|
||||
|
@ -1004,10 +1006,10 @@ bool idUsage::isValid<SpvOpStore>(const spv_instruction_t *inst,
|
|||
spvCheck(!found(pointerType), assert(0 && "Unreachable!"));
|
||||
auto type = find(pointerType->second.inst->words[3]);
|
||||
spvCheck(!found(type), assert(0 && "Unreachable!"));
|
||||
spvCheck(SpvOpTypeVoid == type->second.opcode, DIAG(pointerIndex)
|
||||
<< "OpStore Pointer <id> '"
|
||||
<< inst->words[pointerIndex]
|
||||
<< "'s type is void.";
|
||||
spvCheck(SpvOpTypeVoid == type->second.opcode,
|
||||
DIAG(pointerIndex) << "OpStore Pointer <id> '"
|
||||
<< inst->words[pointerIndex]
|
||||
<< "'s type is void.";
|
||||
return false);
|
||||
|
||||
auto objectIndex = 2;
|
||||
|
@ -1038,7 +1040,7 @@ bool idUsage::isValid<SpvOpStore>(const spv_instruction_t *inst,
|
|||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpCopyMemory>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpCopyMemory>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto targetIndex = 1;
|
||||
auto target = find(inst->words[targetIndex]);
|
||||
|
@ -1071,7 +1073,7 @@ bool idUsage::isValid<SpvOpCopyMemory>(const spv_instruction_t *inst,
|
|||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpCopyMemorySized>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpCopyMemorySized>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto targetIndex = 1;
|
||||
auto target = find(inst->words[targetIndex]);
|
||||
|
@ -1172,7 +1174,7 @@ bool idUsage::isValid<SpvOpGenericPtrMemSemantics>(
|
|||
#endif
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpFunction>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpFunction>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto resultTypeIndex = 1;
|
||||
auto resultType = find(inst->words[resultTypeIndex]);
|
||||
|
@ -1205,7 +1207,7 @@ bool idUsage::isValid<SpvOpFunction>(const spv_instruction_t *inst,
|
|||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpFunctionParameter>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpFunctionParameter>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto resultTypeIndex = 1;
|
||||
auto resultType = find(inst->words[resultTypeIndex]);
|
||||
|
@ -1244,7 +1246,7 @@ bool idUsage::isValid<SpvOpFunctionParameter>(const spv_instruction_t *inst,
|
|||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpFunctionCall>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpFunctionCall>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto resultTypeIndex = 1;
|
||||
auto resultType = find(inst->words[resultTypeIndex]);
|
||||
|
@ -1935,7 +1937,7 @@ bool idUsage::isValid<OpSwitch>(const spv_instruction_t *inst,
|
|||
#endif
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpReturnValue>(const spv_instruction_t *inst,
|
||||
bool idUsage::isValid<SpvOpReturnValue>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto valueIndex = 1;
|
||||
auto value = find(inst->words[valueIndex]);
|
||||
|
@ -1951,7 +1953,7 @@ bool idUsage::isValid<SpvOpReturnValue>(const spv_instruction_t *inst,
|
|||
auto valueType = find(value->second.inst->words[1]);
|
||||
spvCheck(!found(valueType), assert(0 && "Unreachable!"));
|
||||
// NOTE: Find OpFunction
|
||||
const spv_instruction_t *function = inst - 1;
|
||||
const spv_instruction_t* function = inst - 1;
|
||||
while (firstInst != function) {
|
||||
spvCheck(SpvOpFunction == function->opcode, break);
|
||||
function--;
|
||||
|
@ -2364,12 +2366,12 @@ bool idUsage::isValid<OpGroupCommitWritePipe>(
|
|||
|
||||
#undef DIAG
|
||||
|
||||
bool idUsage::isValid(const spv_instruction_t *inst) {
|
||||
bool idUsage::isValid(const spv_instruction_t* inst) {
|
||||
spv_opcode_desc opcodeEntry = nullptr;
|
||||
spvCheck(spvOpcodeTableValueLookup(opcodeTable, inst->opcode, &opcodeEntry),
|
||||
return false);
|
||||
#define CASE(OpCode) \
|
||||
case Spv##OpCode: \
|
||||
#define CASE(OpCode) \
|
||||
case Spv##OpCode: \
|
||||
return isValid<Spv##OpCode>(inst, opcodeEntry);
|
||||
#define FAIL(OpCode) \
|
||||
case Spv##OpCode: \
|
||||
|
@ -2592,12 +2594,12 @@ bool idUsage::isValid(const spv_instruction_t *inst) {
|
|||
} // anonymous namespace
|
||||
|
||||
spv_result_t spvValidateInstructionIDs(
|
||||
const spv_instruction_t *pInsts, const uint64_t instCount,
|
||||
const spv_id_info_t *pIdUses, const uint64_t idUsesCount,
|
||||
const spv_id_info_t *pIdDefs, const uint64_t idDefsCount,
|
||||
const spv_instruction_t* pInsts, const uint64_t instCount,
|
||||
const spv_id_info_t* pIdUses, const uint64_t idUsesCount,
|
||||
const spv_id_info_t* pIdDefs, const uint64_t idDefsCount,
|
||||
const spv_opcode_table opcodeTable, const spv_operand_table operandTable,
|
||||
const spv_ext_inst_table extInstTable, spv_position position,
|
||||
spv_diagnostic *pDiag) {
|
||||
spv_diagnostic* pDiag) {
|
||||
idUsage idUsage(opcodeTable, operandTable, extInstTable, pIdUses, idUsesCount,
|
||||
pIdDefs, idDefsCount, pInsts, instCount, position, pDiag);
|
||||
for (uint64_t instIndex = 0; instIndex < instCount; ++instIndex) {
|
||||
|
|
|
@ -38,8 +38,7 @@ using RoundTripLiteralsTest =
|
|||
spvtest::TextToBinaryTestBase<::testing::TestWithParam<std::string>>;
|
||||
|
||||
TEST_P(RoundTripLiteralsTest, Sample) {
|
||||
EXPECT_THAT(EncodeAndDecodeSuccessfully(GetParam()),
|
||||
Eq(GetParam()));
|
||||
EXPECT_THAT(EncodeAndDecodeSuccessfully(GetParam()), Eq(GetParam()));
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
|
|
|
@ -145,8 +145,7 @@ struct FailedDecodeCase {
|
|||
};
|
||||
|
||||
using BinaryToTextFail =
|
||||
spvtest::TextToBinaryTestBase <
|
||||
::testing::TestWithParam<FailedDecodeCase>>;
|
||||
spvtest::TextToBinaryTestBase<::testing::TestWithParam<FailedDecodeCase>>;
|
||||
|
||||
TEST_P(BinaryToTextFail, EncodeSuccessfullyDecodeFailed) {
|
||||
EXPECT_THAT(EncodeSuccessfullyDecodeFailed(GetParam().source_text,
|
||||
|
@ -305,8 +304,7 @@ using RoundTripInstructionsTest =
|
|||
spvtest::TextToBinaryTestBase<::testing::TestWithParam<std::string>>;
|
||||
|
||||
TEST_P(RoundTripInstructionsTest, Sample) {
|
||||
EXPECT_THAT(EncodeAndDecodeSuccessfully(GetParam()),
|
||||
Eq(GetParam()));
|
||||
EXPECT_THAT(EncodeAndDecodeSuccessfully(GetParam()), Eq(GetParam()));
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
|
|
|
@ -92,7 +92,7 @@ TEST_P(ExtInstOpenCLStdRoundTripTest, ParameterizedExtInst) {
|
|||
#define CASE3Round(Enum, Name, Mode) \
|
||||
{ \
|
||||
uint32_t(OpenCLLIB::Entrypoints::Enum), #Name, "%4 %5 %6 " #Mode, { \
|
||||
4, 5, 6, uint32_t(SpvFPRoundingMode##Mode) \
|
||||
4, 5, 6, uint32_t(SpvFPRoundingMode##Mode) \
|
||||
} \
|
||||
}
|
||||
|
||||
|
@ -395,8 +395,7 @@ TEST_F(TextToBinaryTest, DISABLED_ExtInstFromTwoDifferentImports) {
|
|||
CompiledInstructions(input),
|
||||
Eq(Concatenate({
|
||||
MakeInstruction(SpvOpExtInstImport, {1}, MakeVector("OpenCL.std")),
|
||||
MakeInstruction(SpvOpExtInstImport, {2},
|
||||
MakeVector("GLSL.std.450")),
|
||||
MakeInstruction(SpvOpExtInstImport, {2}, MakeVector("GLSL.std.450")),
|
||||
MakeInstruction(
|
||||
SpvOpExtInst,
|
||||
{3, 4, 1, uint32_t(OpenCLLIB::Entrypoints::Native_sqrt), 5}),
|
||||
|
|
|
@ -65,8 +65,8 @@ OpEntryPoint Vertex %2 "main"
|
|||
%4 = OpTypeFunction %3
|
||||
%2 = OpFunction %3 None %5
|
||||
%6 = OpLabel
|
||||
%8 = OpExtInst %7 %1 )" + std::string(GetParam().extInstOpName) + " " +
|
||||
GetParam().extInstOperandVars + R"(
|
||||
%8 = OpExtInst %7 %1 )" + std::string(GetParam().extInstOpName) +
|
||||
" " + GetParam().extInstOperandVars + R"(
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
|
|
|
@ -61,75 +61,73 @@ TEST_P(HexFloatTest, DecodeCorrectly) {
|
|||
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
Float32Tests, HexFloatTest,
|
||||
::testing::ValuesIn(
|
||||
std::vector<std::pair<FloatProxy<float>, std::string>>({
|
||||
{0.f, "0x0p+0"},
|
||||
{1.f, "0x1p+0"},
|
||||
{2.f, "0x1p+1"},
|
||||
{3.f, "0x1.8p+1"},
|
||||
{0.5f, "0x1p-1"},
|
||||
{0.25f, "0x1p-2"},
|
||||
{0.75f, "0x1.8p-1"},
|
||||
{-0.f, "-0x0p+0"},
|
||||
{-1.f, "-0x1p+0"},
|
||||
{-0.5f, "-0x1p-1"},
|
||||
{-0.25f, "-0x1p-2"},
|
||||
{-0.75f, "-0x1.8p-1"},
|
||||
::testing::ValuesIn(std::vector<std::pair<FloatProxy<float>, std::string>>({
|
||||
{0.f, "0x0p+0"},
|
||||
{1.f, "0x1p+0"},
|
||||
{2.f, "0x1p+1"},
|
||||
{3.f, "0x1.8p+1"},
|
||||
{0.5f, "0x1p-1"},
|
||||
{0.25f, "0x1p-2"},
|
||||
{0.75f, "0x1.8p-1"},
|
||||
{-0.f, "-0x0p+0"},
|
||||
{-1.f, "-0x1p+0"},
|
||||
{-0.5f, "-0x1p-1"},
|
||||
{-0.25f, "-0x1p-2"},
|
||||
{-0.75f, "-0x1.8p-1"},
|
||||
|
||||
// Larger numbers
|
||||
{512.f, "0x1p+9"},
|
||||
{-512.f, "-0x1p+9"},
|
||||
{1024.f, "0x1p+10"},
|
||||
{-1024.f, "-0x1p+10"},
|
||||
{1024.f + 8.f, "0x1.02p+10"},
|
||||
{-1024.f - 8.f, "-0x1.02p+10"},
|
||||
// Larger numbers
|
||||
{512.f, "0x1p+9"},
|
||||
{-512.f, "-0x1p+9"},
|
||||
{1024.f, "0x1p+10"},
|
||||
{-1024.f, "-0x1p+10"},
|
||||
{1024.f + 8.f, "0x1.02p+10"},
|
||||
{-1024.f - 8.f, "-0x1.02p+10"},
|
||||
|
||||
// Small numbers
|
||||
{1.0f / 512.f, "0x1p-9"},
|
||||
{1.0f / -512.f, "-0x1p-9"},
|
||||
{1.0f / 1024.f, "0x1p-10"},
|
||||
{1.0f / -1024.f, "-0x1p-10"},
|
||||
{1.0f / 1024.f + 1.0f / 8.f, "0x1.02p-3"},
|
||||
{1.0f / -1024.f - 1.0f / 8.f, "-0x1.02p-3"},
|
||||
// Small numbers
|
||||
{1.0f / 512.f, "0x1p-9"},
|
||||
{1.0f / -512.f, "-0x1p-9"},
|
||||
{1.0f / 1024.f, "0x1p-10"},
|
||||
{1.0f / -1024.f, "-0x1p-10"},
|
||||
{1.0f / 1024.f + 1.0f / 8.f, "0x1.02p-3"},
|
||||
{1.0f / -1024.f - 1.0f / 8.f, "-0x1.02p-3"},
|
||||
|
||||
// lowest non-denorm
|
||||
{float(ldexp(1.0f, -126)), "0x1p-126"},
|
||||
{float(ldexp(-1.0f, -126)), "-0x1p-126"},
|
||||
// lowest non-denorm
|
||||
{float(ldexp(1.0f, -126)), "0x1p-126"},
|
||||
{float(ldexp(-1.0f, -126)), "-0x1p-126"},
|
||||
|
||||
// Denormalized values
|
||||
{float(ldexp(1.0f, -127)), "0x1p-127"},
|
||||
{float(ldexp(1.0f, -127) / 2.0f), "0x1p-128"},
|
||||
{float(ldexp(1.0f, -127) / 4.0f), "0x1p-129"},
|
||||
{float(ldexp(1.0f, -127) / 8.0f), "0x1p-130"},
|
||||
{float(ldexp(-1.0f, -127)), "-0x1p-127"},
|
||||
{float(ldexp(-1.0f, -127) / 2.0f), "-0x1p-128"},
|
||||
{float(ldexp(-1.0f, -127) / 4.0f), "-0x1p-129"},
|
||||
{float(ldexp(-1.0f, -127) / 8.0f), "-0x1p-130"},
|
||||
// Denormalized values
|
||||
{float(ldexp(1.0f, -127)), "0x1p-127"},
|
||||
{float(ldexp(1.0f, -127) / 2.0f), "0x1p-128"},
|
||||
{float(ldexp(1.0f, -127) / 4.0f), "0x1p-129"},
|
||||
{float(ldexp(1.0f, -127) / 8.0f), "0x1p-130"},
|
||||
{float(ldexp(-1.0f, -127)), "-0x1p-127"},
|
||||
{float(ldexp(-1.0f, -127) / 2.0f), "-0x1p-128"},
|
||||
{float(ldexp(-1.0f, -127) / 4.0f), "-0x1p-129"},
|
||||
{float(ldexp(-1.0f, -127) / 8.0f), "-0x1p-130"},
|
||||
|
||||
{float(ldexp(1.0, -127) + (ldexp(1.0, -127) / 2.0f)), "0x1.8p-127"},
|
||||
{float(ldexp(1.0, -127) / 2.0 + (ldexp(1.0, -127) / 4.0f)),
|
||||
"0x1.8p-128"},
|
||||
{float(ldexp(1.0, -127) + (ldexp(1.0, -127) / 2.0f)), "0x1.8p-127"},
|
||||
{float(ldexp(1.0, -127) / 2.0 + (ldexp(1.0, -127) / 4.0f)),
|
||||
"0x1.8p-128"},
|
||||
|
||||
})));
|
||||
})));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
Float32NanTests, HexFloatTest,
|
||||
::testing::ValuesIn(
|
||||
std::vector<std::pair<FloatProxy<float>, std::string>>({
|
||||
// Various NAN and INF cases
|
||||
{uint32_t(0xFF800000), "-0x1p+128"}, // -inf
|
||||
{uint32_t(0x7F800000), "0x1p+128"}, // inf
|
||||
{uint32_t(0xFFC00000), "-0x1.8p+128"}, // -nan
|
||||
{uint32_t(0xFF800100), "-0x1.0002p+128"}, // -nan
|
||||
{uint32_t(0xFF800c00), "-0x1.0018p+128"}, // -nan
|
||||
{uint32_t(0xFF80F000), "-0x1.01ep+128"}, // -nan
|
||||
{uint32_t(0xFFFFFFFF), "-0x1.fffffep+128"}, // -nan
|
||||
{uint32_t(0x7FC00000), "0x1.8p+128"}, // +nan
|
||||
{uint32_t(0x7F800100), "0x1.0002p+128"}, // +nan
|
||||
{uint32_t(0x7f800c00), "0x1.0018p+128"}, // +nan
|
||||
{uint32_t(0x7F80F000), "0x1.01ep+128"}, // +nan
|
||||
{uint32_t(0x7FFFFFFF), "0x1.fffffep+128"}, // +nan
|
||||
})));
|
||||
::testing::ValuesIn(std::vector<std::pair<FloatProxy<float>, std::string>>({
|
||||
// Various NAN and INF cases
|
||||
{uint32_t(0xFF800000), "-0x1p+128"}, // -inf
|
||||
{uint32_t(0x7F800000), "0x1p+128"}, // inf
|
||||
{uint32_t(0xFFC00000), "-0x1.8p+128"}, // -nan
|
||||
{uint32_t(0xFF800100), "-0x1.0002p+128"}, // -nan
|
||||
{uint32_t(0xFF800c00), "-0x1.0018p+128"}, // -nan
|
||||
{uint32_t(0xFF80F000), "-0x1.01ep+128"}, // -nan
|
||||
{uint32_t(0xFFFFFFFF), "-0x1.fffffep+128"}, // -nan
|
||||
{uint32_t(0x7FC00000), "0x1.8p+128"}, // +nan
|
||||
{uint32_t(0x7F800100), "0x1.0002p+128"}, // +nan
|
||||
{uint32_t(0x7f800c00), "0x1.0018p+128"}, // +nan
|
||||
{uint32_t(0x7F80F000), "0x1.01ep+128"}, // +nan
|
||||
{uint32_t(0x7FFFFFFF), "0x1.fffffep+128"}, // +nan
|
||||
})));
|
||||
|
||||
TEST_P(DecodeHexFloatTest, DecodeCorrectly) {
|
||||
std::stringstream ss(std::get<0>(GetParam()));
|
||||
|
@ -144,38 +142,35 @@ TEST_P(DecodeHexFloatTest, DecodeCorrectly) {
|
|||
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
Float32DecodeTests, DecodeHexFloatTest,
|
||||
::testing::ValuesIn(
|
||||
std::vector<std::pair<std::string, FloatProxy<float>>>({
|
||||
{"0x0p+000", 0.f},
|
||||
{"0x0p0", 0.f},
|
||||
{"0x0p-0", 0.f},
|
||||
::testing::ValuesIn(std::vector<std::pair<std::string, FloatProxy<float>>>({
|
||||
{"0x0p+000", 0.f},
|
||||
{"0x0p0", 0.f},
|
||||
{"0x0p-0", 0.f},
|
||||
|
||||
// flush to zero cases
|
||||
{"0x1p-500", 0.f}, // Exponent underflows.
|
||||
{"-0x1p-500", -0.f},
|
||||
{"0x0.00000000001p-126", 0.f}, // Fraction causes underflow.
|
||||
{"-0x0.0000000001p-127", -0.f},
|
||||
{"-0x0.01p-142",
|
||||
-0.f}, // Fraction causes undeflow to underflow more.
|
||||
{"0x0.01p-142", 0.f},
|
||||
// flush to zero cases
|
||||
{"0x1p-500", 0.f}, // Exponent underflows.
|
||||
{"-0x1p-500", -0.f},
|
||||
{"0x0.00000000001p-126", 0.f}, // Fraction causes underflow.
|
||||
{"-0x0.0000000001p-127", -0.f},
|
||||
{"-0x0.01p-142", -0.f}, // Fraction causes undeflow to underflow more.
|
||||
{"0x0.01p-142", 0.f},
|
||||
|
||||
// Some floats that do not encode the same way as the decode.
|
||||
{"0x2p+0", 2.f},
|
||||
{"0xFFp+0", 255.f},
|
||||
{"0x0.8p+0", 0.5f},
|
||||
{"0x0.4p+0", 0.25f},
|
||||
})));
|
||||
// Some floats that do not encode the same way as the decode.
|
||||
{"0x2p+0", 2.f},
|
||||
{"0xFFp+0", 255.f},
|
||||
{"0x0.8p+0", 0.5f},
|
||||
{"0x0.4p+0", 0.25f},
|
||||
})));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
Float32DecodeInfTests, DecodeHexFloatTest,
|
||||
::testing::ValuesIn(
|
||||
std::vector<std::pair<std::string, FloatProxy<float>>>({
|
||||
// inf cases
|
||||
{"-0x1p+128", uint32_t(0xFF800000)}, // -inf
|
||||
{"0x32p+127", uint32_t(0x7F800000)}, // inf
|
||||
{"0x32p+500", uint32_t(0x7F800000)}, // inf
|
||||
{"-0x32p+127", uint32_t(0xFF800000)}, // -inf
|
||||
})));
|
||||
::testing::ValuesIn(std::vector<std::pair<std::string, FloatProxy<float>>>({
|
||||
// inf cases
|
||||
{"-0x1p+128", uint32_t(0xFF800000)}, // -inf
|
||||
{"0x32p+127", uint32_t(0x7F800000)}, // inf
|
||||
{"0x32p+500", uint32_t(0x7F800000)}, // inf
|
||||
{"-0x32p+127", uint32_t(0xFF800000)}, // -inf
|
||||
})));
|
||||
|
||||
TEST(FloatProxy, ValidConversion) {
|
||||
EXPECT_THAT(FloatProxy<float>(1.f).getAsFloat(), Eq(1.0f));
|
||||
|
@ -185,78 +180,44 @@ TEST(FloatProxy, ValidConversion) {
|
|||
EXPECT_THAT(FloatProxy<float>(-0.f).getAsFloat(), Eq(-0.0f));
|
||||
EXPECT_THAT(FloatProxy<float>(1.2e32f).getAsFloat(), Eq(1.2e32f));
|
||||
|
||||
EXPECT_TRUE(
|
||||
std::isinf(FloatProxy<float>(uint32_t(0xFF800000)).getAsFloat()));
|
||||
EXPECT_TRUE(
|
||||
std::isinf(FloatProxy<float>(uint32_t(0x7F800000)).getAsFloat()));
|
||||
EXPECT_TRUE(
|
||||
std::isnan(FloatProxy<float>(uint32_t(0xFFC00000)).getAsFloat()));
|
||||
EXPECT_TRUE(
|
||||
std::isnan(FloatProxy<float>(uint32_t(0xFF800100)).getAsFloat()));
|
||||
EXPECT_TRUE(
|
||||
std::isnan(FloatProxy<float>(uint32_t(0xFF800c00)).getAsFloat()));
|
||||
EXPECT_TRUE(
|
||||
std::isnan(FloatProxy<float>(uint32_t(0xFF80F000)).getAsFloat()));
|
||||
EXPECT_TRUE(
|
||||
std::isnan(FloatProxy<float>(uint32_t(0xFFFFFFFF)).getAsFloat()));
|
||||
EXPECT_TRUE(
|
||||
std::isnan(FloatProxy<float>(uint32_t(0x7FC00000)).getAsFloat()));
|
||||
EXPECT_TRUE(
|
||||
std::isnan(FloatProxy<float>(uint32_t(0x7F800100)).getAsFloat()));
|
||||
EXPECT_TRUE(
|
||||
std::isnan(FloatProxy<float>(uint32_t(0x7f800c00)).getAsFloat()));
|
||||
EXPECT_TRUE(
|
||||
std::isnan(FloatProxy<float>(uint32_t(0x7F80F000)).getAsFloat()));
|
||||
EXPECT_TRUE(
|
||||
std::isnan(FloatProxy<float>(uint32_t(0x7FFFFFFF)).getAsFloat()));
|
||||
EXPECT_TRUE(std::isinf(FloatProxy<float>(uint32_t(0xFF800000)).getAsFloat()));
|
||||
EXPECT_TRUE(std::isinf(FloatProxy<float>(uint32_t(0x7F800000)).getAsFloat()));
|
||||
EXPECT_TRUE(std::isnan(FloatProxy<float>(uint32_t(0xFFC00000)).getAsFloat()));
|
||||
EXPECT_TRUE(std::isnan(FloatProxy<float>(uint32_t(0xFF800100)).getAsFloat()));
|
||||
EXPECT_TRUE(std::isnan(FloatProxy<float>(uint32_t(0xFF800c00)).getAsFloat()));
|
||||
EXPECT_TRUE(std::isnan(FloatProxy<float>(uint32_t(0xFF80F000)).getAsFloat()));
|
||||
EXPECT_TRUE(std::isnan(FloatProxy<float>(uint32_t(0xFFFFFFFF)).getAsFloat()));
|
||||
EXPECT_TRUE(std::isnan(FloatProxy<float>(uint32_t(0x7FC00000)).getAsFloat()));
|
||||
EXPECT_TRUE(std::isnan(FloatProxy<float>(uint32_t(0x7F800100)).getAsFloat()));
|
||||
EXPECT_TRUE(std::isnan(FloatProxy<float>(uint32_t(0x7f800c00)).getAsFloat()));
|
||||
EXPECT_TRUE(std::isnan(FloatProxy<float>(uint32_t(0x7F80F000)).getAsFloat()));
|
||||
EXPECT_TRUE(std::isnan(FloatProxy<float>(uint32_t(0x7FFFFFFF)).getAsFloat()));
|
||||
|
||||
EXPECT_THAT(FloatProxy<float>(uint32_t(0xFF800000)).data(),
|
||||
Eq(0xFF800000));
|
||||
EXPECT_THAT(FloatProxy<float>(uint32_t(0x7F800000)).data(),
|
||||
Eq(0x7F800000));
|
||||
EXPECT_THAT(FloatProxy<float>(uint32_t(0xFFC00000)).data(),
|
||||
Eq(0xFFC00000));
|
||||
EXPECT_THAT(FloatProxy<float>(uint32_t(0xFF800100)).data(),
|
||||
Eq(0xFF800100));
|
||||
EXPECT_THAT(FloatProxy<float>(uint32_t(0xFF800c00)).data(),
|
||||
Eq(0xFF800c00));
|
||||
EXPECT_THAT(FloatProxy<float>(uint32_t(0xFF80F000)).data(),
|
||||
Eq(0xFF80F000));
|
||||
EXPECT_THAT(FloatProxy<float>(uint32_t(0xFFFFFFFF)).data(),
|
||||
Eq(0xFFFFFFFF));
|
||||
EXPECT_THAT(FloatProxy<float>(uint32_t(0x7FC00000)).data(),
|
||||
Eq(0x7FC00000));
|
||||
EXPECT_THAT(FloatProxy<float>(uint32_t(0x7F800100)).data(),
|
||||
Eq(0x7F800100));
|
||||
EXPECT_THAT(FloatProxy<float>(uint32_t(0x7f800c00)).data(),
|
||||
Eq(0x7f800c00));
|
||||
EXPECT_THAT(FloatProxy<float>(uint32_t(0x7F80F000)).data(),
|
||||
Eq(0x7F80F000));
|
||||
EXPECT_THAT(FloatProxy<float>(uint32_t(0x7FFFFFFF)).data(),
|
||||
Eq(0x7FFFFFFF));
|
||||
EXPECT_THAT(FloatProxy<float>(uint32_t(0xFF800000)).data(), Eq(0xFF800000));
|
||||
EXPECT_THAT(FloatProxy<float>(uint32_t(0x7F800000)).data(), Eq(0x7F800000));
|
||||
EXPECT_THAT(FloatProxy<float>(uint32_t(0xFFC00000)).data(), Eq(0xFFC00000));
|
||||
EXPECT_THAT(FloatProxy<float>(uint32_t(0xFF800100)).data(), Eq(0xFF800100));
|
||||
EXPECT_THAT(FloatProxy<float>(uint32_t(0xFF800c00)).data(), Eq(0xFF800c00));
|
||||
EXPECT_THAT(FloatProxy<float>(uint32_t(0xFF80F000)).data(), Eq(0xFF80F000));
|
||||
EXPECT_THAT(FloatProxy<float>(uint32_t(0xFFFFFFFF)).data(), Eq(0xFFFFFFFF));
|
||||
EXPECT_THAT(FloatProxy<float>(uint32_t(0x7FC00000)).data(), Eq(0x7FC00000));
|
||||
EXPECT_THAT(FloatProxy<float>(uint32_t(0x7F800100)).data(), Eq(0x7F800100));
|
||||
EXPECT_THAT(FloatProxy<float>(uint32_t(0x7f800c00)).data(), Eq(0x7f800c00));
|
||||
EXPECT_THAT(FloatProxy<float>(uint32_t(0x7F80F000)).data(), Eq(0x7F80F000));
|
||||
EXPECT_THAT(FloatProxy<float>(uint32_t(0x7FFFFFFF)).data(), Eq(0x7FFFFFFF));
|
||||
}
|
||||
|
||||
TEST(FloatProxy, Nan) {
|
||||
EXPECT_TRUE(
|
||||
FloatProxy<float>(uint32_t(0xFFC00000)).isNan());
|
||||
EXPECT_TRUE(
|
||||
FloatProxy<float>(uint32_t(0xFF800100)).isNan());
|
||||
EXPECT_TRUE(
|
||||
FloatProxy<float>(uint32_t(0xFF800c00)).isNan());
|
||||
EXPECT_TRUE(
|
||||
FloatProxy<float>(uint32_t(0xFF80F000)).isNan());
|
||||
EXPECT_TRUE(
|
||||
FloatProxy<float>(uint32_t(0xFFFFFFFF)).isNan());
|
||||
EXPECT_TRUE(
|
||||
FloatProxy<float>(uint32_t(0x7FC00000)).isNan());
|
||||
EXPECT_TRUE(
|
||||
FloatProxy<float>(uint32_t(0x7F800100)).isNan());
|
||||
EXPECT_TRUE(
|
||||
FloatProxy<float>(uint32_t(0x7f800c00)).isNan());
|
||||
EXPECT_TRUE(
|
||||
FloatProxy<float>(uint32_t(0x7F80F000)).isNan());
|
||||
EXPECT_TRUE(
|
||||
FloatProxy<float>(uint32_t(0x7FFFFFFF)).isNan());
|
||||
EXPECT_TRUE(FloatProxy<float>(uint32_t(0xFFC00000)).isNan());
|
||||
EXPECT_TRUE(FloatProxy<float>(uint32_t(0xFF800100)).isNan());
|
||||
EXPECT_TRUE(FloatProxy<float>(uint32_t(0xFF800c00)).isNan());
|
||||
EXPECT_TRUE(FloatProxy<float>(uint32_t(0xFF80F000)).isNan());
|
||||
EXPECT_TRUE(FloatProxy<float>(uint32_t(0xFFFFFFFF)).isNan());
|
||||
EXPECT_TRUE(FloatProxy<float>(uint32_t(0x7FC00000)).isNan());
|
||||
EXPECT_TRUE(FloatProxy<float>(uint32_t(0x7F800100)).isNan());
|
||||
EXPECT_TRUE(FloatProxy<float>(uint32_t(0x7f800c00)).isNan());
|
||||
EXPECT_TRUE(FloatProxy<float>(uint32_t(0x7F80F000)).isNan());
|
||||
EXPECT_TRUE(FloatProxy<float>(uint32_t(0x7FFFFFFF)).isNan());
|
||||
}
|
||||
|
||||
TEST(FloatProxy, Negation) {
|
||||
|
@ -275,9 +236,9 @@ TEST(FloatProxy, Negation) {
|
|||
EXPECT_THAT(
|
||||
(-FloatProxy<float>(std::numeric_limits<float>::infinity())).getAsFloat(),
|
||||
Eq(-std::numeric_limits<float>::infinity()));
|
||||
EXPECT_THAT(
|
||||
(-FloatProxy<float>(-std::numeric_limits<float>::infinity())).getAsFloat(),
|
||||
Eq(std::numeric_limits<float>::infinity()));
|
||||
EXPECT_THAT((-FloatProxy<float>(-std::numeric_limits<float>::infinity()))
|
||||
.getAsFloat(),
|
||||
Eq(std::numeric_limits<float>::infinity()));
|
||||
}
|
||||
|
||||
// TODO(awoloszyn): Add double tests
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
namespace {
|
||||
|
||||
TEST(NamedId, Default) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical Simple
|
||||
OpEntryPoint Vertex %main "foo"
|
||||
|
|
|
@ -66,10 +66,11 @@ TEST_P(EnumCapabilityTest, Sample) {
|
|||
// See SPIR-V Section 3.3 Execution Model
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
ExecutionModel, EnumCapabilityTest,
|
||||
::testing::ValuesIn( std::vector<EnumCapabilityCase>{
|
||||
::testing::ValuesIn(std::vector<EnumCapabilityCase>{
|
||||
CASE1(EXECUTION_MODEL, ExecutionModelVertex, Shader),
|
||||
CASE1(EXECUTION_MODEL, ExecutionModelTessellationControl, Tessellation),
|
||||
CASE1(EXECUTION_MODEL, ExecutionModelTessellationEvaluation, Tessellation),
|
||||
CASE1(EXECUTION_MODEL, ExecutionModelTessellationEvaluation,
|
||||
Tessellation),
|
||||
CASE1(EXECUTION_MODEL, ExecutionModelGeometry, Geometry),
|
||||
CASE1(EXECUTION_MODEL, ExecutionModelFragment, Shader),
|
||||
CASE1(EXECUTION_MODEL, ExecutionModelGLCompute, Shader),
|
||||
|
@ -86,13 +87,12 @@ INSTANTIATE_TEST_CASE_P(
|
|||
}));
|
||||
|
||||
// See SPIR-V Section 3.5 Memory Model
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
MemoryModel, EnumCapabilityTest,
|
||||
::testing::ValuesIn(std::vector<EnumCapabilityCase>{
|
||||
CASE1(MEMORY_MODEL, MemoryModelSimple, Shader),
|
||||
CASE1(MEMORY_MODEL, MemoryModelGLSL450, Shader),
|
||||
CASE1(MEMORY_MODEL, MemoryModelOpenCL, Kernel),
|
||||
}));
|
||||
INSTANTIATE_TEST_CASE_P(MemoryModel, EnumCapabilityTest,
|
||||
::testing::ValuesIn(std::vector<EnumCapabilityCase>{
|
||||
CASE1(MEMORY_MODEL, MemoryModelSimple, Shader),
|
||||
CASE1(MEMORY_MODEL, MemoryModelGLSL450, Shader),
|
||||
CASE1(MEMORY_MODEL, MemoryModelOpenCL, Kernel),
|
||||
}));
|
||||
|
||||
// See SPIR-V Section 3.6 Execution Mode
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
|
@ -119,11 +119,13 @@ INSTANTIATE_TEST_CASE_P(
|
|||
CASE1(EXECUTION_MODE, ExecutionModeInputPoints, Geometry),
|
||||
CASE1(EXECUTION_MODE, ExecutionModeInputLines, Geometry),
|
||||
CASE1(EXECUTION_MODE, ExecutionModeInputLinesAdjacency, Geometry),
|
||||
CASE2(EXECUTION_MODE, ExecutionModeInputTriangles, Geometry, Tessellation),
|
||||
CASE2(EXECUTION_MODE, ExecutionModeInputTriangles, Geometry,
|
||||
Tessellation),
|
||||
CASE1(EXECUTION_MODE, ExecutionModeInputTrianglesAdjacency, Geometry),
|
||||
CASE1(EXECUTION_MODE, ExecutionModeInputQuads, Tessellation),
|
||||
CASE1(EXECUTION_MODE, ExecutionModeInputIsolines, Tessellation),
|
||||
CASE2(EXECUTION_MODE, ExecutionModeOutputVertices, Geometry, Tessellation),
|
||||
CASE2(EXECUTION_MODE, ExecutionModeOutputVertices, Geometry,
|
||||
Tessellation),
|
||||
CASE1(EXECUTION_MODE, ExecutionModeOutputPoints, Geometry),
|
||||
CASE1(EXECUTION_MODE, ExecutionModeOutputLineStrip, Geometry),
|
||||
CASE1(EXECUTION_MODE, ExecutionModeOutputTriangleStrip, Geometry),
|
||||
|
@ -154,10 +156,8 @@ INSTANTIATE_TEST_CASE_P(
|
|||
INSTANTIATE_TEST_CASE_P(
|
||||
Dim, EnumCapabilityTest,
|
||||
::testing::ValuesIn(std::vector<EnumCapabilityCase>{
|
||||
CASE1(DIMENSIONALITY, Dim1D, Sampled1D),
|
||||
CASE0(DIMENSIONALITY, Dim2D),
|
||||
CASE0(DIMENSIONALITY, Dim3D),
|
||||
CASE1(DIMENSIONALITY, DimCube, Shader),
|
||||
CASE1(DIMENSIONALITY, Dim1D, Sampled1D), CASE0(DIMENSIONALITY, Dim2D),
|
||||
CASE0(DIMENSIONALITY, Dim3D), CASE1(DIMENSIONALITY, DimCube, Shader),
|
||||
CASE1(DIMENSIONALITY, DimRect, SampledRect),
|
||||
CASE1(DIMENSIONALITY, DimBuffer, SampledBuffer),
|
||||
CASE1(DIMENSIONALITY, DimInputTarget, InputTarget),
|
||||
|
@ -168,10 +168,12 @@ INSTANTIATE_TEST_CASE_P(
|
|||
SamplerAddressingMode, EnumCapabilityTest,
|
||||
::testing::ValuesIn(std::vector<EnumCapabilityCase>{
|
||||
CASE1(SAMPLER_ADDRESSING_MODE, SamplerAddressingModeNone, Kernel),
|
||||
CASE1(SAMPLER_ADDRESSING_MODE, SamplerAddressingModeClampToEdge, Kernel),
|
||||
CASE1(SAMPLER_ADDRESSING_MODE, SamplerAddressingModeClampToEdge,
|
||||
Kernel),
|
||||
CASE1(SAMPLER_ADDRESSING_MODE, SamplerAddressingModeClamp, Kernel),
|
||||
CASE1(SAMPLER_ADDRESSING_MODE, SamplerAddressingModeRepeat, Kernel),
|
||||
CASE1(SAMPLER_ADDRESSING_MODE, SamplerAddressingModeRepeatMirrored, Kernel),
|
||||
CASE1(SAMPLER_ADDRESSING_MODE, SamplerAddressingModeRepeatMirrored,
|
||||
Kernel),
|
||||
}));
|
||||
|
||||
// See SPIR-V Section 3.10 Sampler Filter Mode
|
||||
|
@ -261,15 +263,21 @@ INSTANTIATE_TEST_CASE_P(
|
|||
CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeSnormInt16, Kernel),
|
||||
CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeUnormInt8, Kernel),
|
||||
CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeUnormInt16, Kernel),
|
||||
CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeUnormShort565, Kernel),
|
||||
CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeUnormShort555, Kernel),
|
||||
CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeUnormInt101010, Kernel),
|
||||
CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeUnormShort565,
|
||||
Kernel),
|
||||
CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeUnormShort555,
|
||||
Kernel),
|
||||
CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeUnormInt101010,
|
||||
Kernel),
|
||||
CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeSignedInt8, Kernel),
|
||||
CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeSignedInt16, Kernel),
|
||||
CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeSignedInt32, Kernel),
|
||||
CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeUnsignedInt8, Kernel),
|
||||
CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeUnsignedInt16, Kernel),
|
||||
CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeUnsignedInt32, Kernel),
|
||||
CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeUnsignedInt8,
|
||||
Kernel),
|
||||
CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeUnsignedInt16,
|
||||
Kernel),
|
||||
CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeUnsignedInt32,
|
||||
Kernel),
|
||||
CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeHalfFloat, Kernel),
|
||||
CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeFloat, Kernel),
|
||||
CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeUnormInt24, Kernel),
|
||||
|
@ -303,22 +311,20 @@ INSTANTIATE_TEST_CASE_P(
|
|||
}));
|
||||
|
||||
// See SPIR-V Section 3.16 FP Rounding Mode
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
FPRoundingMode, EnumCapabilityTest,
|
||||
::testing::ValuesIn(std::vector<EnumCapabilityCase>{
|
||||
CASE1(FP_ROUNDING_MODE, FPRoundingModeRTE, Kernel),
|
||||
CASE1(FP_ROUNDING_MODE, FPRoundingModeRTZ, Kernel),
|
||||
CASE1(FP_ROUNDING_MODE, FPRoundingModeRTP, Kernel),
|
||||
CASE1(FP_ROUNDING_MODE, FPRoundingModeRTN, Kernel),
|
||||
}));
|
||||
INSTANTIATE_TEST_CASE_P(FPRoundingMode, EnumCapabilityTest,
|
||||
::testing::ValuesIn(std::vector<EnumCapabilityCase>{
|
||||
CASE1(FP_ROUNDING_MODE, FPRoundingModeRTE, Kernel),
|
||||
CASE1(FP_ROUNDING_MODE, FPRoundingModeRTZ, Kernel),
|
||||
CASE1(FP_ROUNDING_MODE, FPRoundingModeRTP, Kernel),
|
||||
CASE1(FP_ROUNDING_MODE, FPRoundingModeRTN, Kernel),
|
||||
}));
|
||||
|
||||
// See SPIR-V Section 3.17 Linkage Type
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
LinkageType, EnumCapabilityTest,
|
||||
::testing::ValuesIn(std::vector<EnumCapabilityCase>{
|
||||
CASE1(LINKAGE_TYPE, LinkageTypeExport, Linkage),
|
||||
CASE1(LINKAGE_TYPE, LinkageTypeImport, Linkage),
|
||||
}));
|
||||
INSTANTIATE_TEST_CASE_P(LinkageType, EnumCapabilityTest,
|
||||
::testing::ValuesIn(std::vector<EnumCapabilityCase>{
|
||||
CASE1(LINKAGE_TYPE, LinkageTypeExport, Linkage),
|
||||
CASE1(LINKAGE_TYPE, LinkageTypeImport, Linkage),
|
||||
}));
|
||||
|
||||
// See SPIR-V Section 3.18 Access Qualifier
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
|
@ -330,18 +336,26 @@ INSTANTIATE_TEST_CASE_P(
|
|||
}));
|
||||
|
||||
// See SPIR-V Section 3.19 Function Parameter Attribute
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
FunctionParameterAttribute, EnumCapabilityTest,
|
||||
::testing::ValuesIn(std::vector<EnumCapabilityCase>{
|
||||
CASE1(FUNCTION_PARAMETER_ATTRIBUTE, FunctionParameterAttributeZext, Kernel),
|
||||
CASE1(FUNCTION_PARAMETER_ATTRIBUTE, FunctionParameterAttributeSext, Kernel),
|
||||
CASE1(FUNCTION_PARAMETER_ATTRIBUTE, FunctionParameterAttributeByVal, Kernel),
|
||||
CASE1(FUNCTION_PARAMETER_ATTRIBUTE, FunctionParameterAttributeSret, Kernel),
|
||||
CASE1(FUNCTION_PARAMETER_ATTRIBUTE, FunctionParameterAttributeNoAlias, Kernel),
|
||||
CASE1(FUNCTION_PARAMETER_ATTRIBUTE, FunctionParameterAttributeNoCapture, Kernel),
|
||||
CASE1(FUNCTION_PARAMETER_ATTRIBUTE, FunctionParameterAttributeNoWrite, Kernel),
|
||||
CASE1(FUNCTION_PARAMETER_ATTRIBUTE, FunctionParameterAttributeNoReadWrite, Kernel),
|
||||
}));
|
||||
INSTANTIATE_TEST_CASE_P(FunctionParameterAttribute, EnumCapabilityTest,
|
||||
::testing::ValuesIn(std::vector<EnumCapabilityCase>{
|
||||
CASE1(FUNCTION_PARAMETER_ATTRIBUTE,
|
||||
FunctionParameterAttributeZext, Kernel),
|
||||
CASE1(FUNCTION_PARAMETER_ATTRIBUTE,
|
||||
FunctionParameterAttributeSext, Kernel),
|
||||
CASE1(FUNCTION_PARAMETER_ATTRIBUTE,
|
||||
FunctionParameterAttributeByVal, Kernel),
|
||||
CASE1(FUNCTION_PARAMETER_ATTRIBUTE,
|
||||
FunctionParameterAttributeSret, Kernel),
|
||||
CASE1(FUNCTION_PARAMETER_ATTRIBUTE,
|
||||
FunctionParameterAttributeNoAlias, Kernel),
|
||||
CASE1(FUNCTION_PARAMETER_ATTRIBUTE,
|
||||
FunctionParameterAttributeNoCapture, Kernel),
|
||||
CASE1(FUNCTION_PARAMETER_ATTRIBUTE,
|
||||
FunctionParameterAttributeNoWrite, Kernel),
|
||||
CASE1(FUNCTION_PARAMETER_ATTRIBUTE,
|
||||
FunctionParameterAttributeNoReadWrite,
|
||||
Kernel),
|
||||
}));
|
||||
|
||||
// See SPIR-V Section 3.20 Decoration
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
|
@ -390,7 +404,9 @@ INSTANTIATE_TEST_CASE_P(
|
|||
CASE1(DECORATION, DecorationFPFastMathMode, Kernel),
|
||||
CASE1(DECORATION, DecorationLinkageAttributes, Linkage),
|
||||
CASE1(DECORATION, DecorationNoContraction, Shader),
|
||||
CASE1(DECORATION, DecorationInputTargetIndex, Shader), // TODO(dneto): Should be InputTarget. Fixed in 1.0 Rev 2
|
||||
CASE1(
|
||||
DECORATION, DecorationInputTargetIndex,
|
||||
Shader), // TODO(dneto): Should be InputTarget. Fixed in 1.0 Rev 2
|
||||
CASE1(DECORATION, DecorationAlignment, Kernel),
|
||||
}));
|
||||
|
||||
|
@ -454,30 +470,30 @@ INSTANTIATE_TEST_CASE_P(
|
|||
}));
|
||||
|
||||
// See SPIR-V Section 3.23 Loop Control
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
LoopControl, EnumCapabilityTest,
|
||||
::testing::ValuesIn(std::vector<EnumCapabilityCase>{
|
||||
CASE0(LOOP_CONTROL, LoopControlMaskNone),
|
||||
CASE0(LOOP_CONTROL, LoopControlUnrollMask),
|
||||
CASE0(LOOP_CONTROL, LoopControlDontUnrollMask),
|
||||
}));
|
||||
INSTANTIATE_TEST_CASE_P(LoopControl, EnumCapabilityTest,
|
||||
::testing::ValuesIn(std::vector<EnumCapabilityCase>{
|
||||
CASE0(LOOP_CONTROL, LoopControlMaskNone),
|
||||
CASE0(LOOP_CONTROL, LoopControlUnrollMask),
|
||||
CASE0(LOOP_CONTROL, LoopControlDontUnrollMask),
|
||||
}));
|
||||
|
||||
// See SPIR-V Section 3.24 Function Control
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
FunctionControl, EnumCapabilityTest,
|
||||
::testing::ValuesIn(std::vector<EnumCapabilityCase>{
|
||||
CASE0(FUNCTION_CONTROL, FunctionControlMaskNone),
|
||||
CASE0(FUNCTION_CONTROL, FunctionControlInlineMask),
|
||||
CASE0(FUNCTION_CONTROL, FunctionControlDontInlineMask),
|
||||
CASE0(FUNCTION_CONTROL, FunctionControlPureMask),
|
||||
CASE0(FUNCTION_CONTROL, FunctionControlConstMask),
|
||||
}));
|
||||
INSTANTIATE_TEST_CASE_P(FunctionControl, EnumCapabilityTest,
|
||||
::testing::ValuesIn(std::vector<EnumCapabilityCase>{
|
||||
CASE0(FUNCTION_CONTROL, FunctionControlMaskNone),
|
||||
CASE0(FUNCTION_CONTROL, FunctionControlInlineMask),
|
||||
CASE0(FUNCTION_CONTROL,
|
||||
FunctionControlDontInlineMask),
|
||||
CASE0(FUNCTION_CONTROL, FunctionControlPureMask),
|
||||
CASE0(FUNCTION_CONTROL, FunctionControlConstMask),
|
||||
}));
|
||||
|
||||
// See SPIR-V Section 3.25 Memory Semantics <id>
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
MemorySemantics, EnumCapabilityTest,
|
||||
::testing::ValuesIn(std::vector<EnumCapabilityCase>{
|
||||
// TODO(dneto): This enum is expanded and renumbered in SPIR-V 1.0 Rev 1.
|
||||
// TODO(dneto): This enum is expanded and renumbered in SPIR-V 1.0 Rev
|
||||
// 1.
|
||||
CASE0(MEMORY_SEMANTICS, MemorySemanticsMaskNone),
|
||||
CASE0(MEMORY_SEMANTICS, MemorySemanticsAcquireMask),
|
||||
CASE0(MEMORY_SEMANTICS, MemorySemanticsReleaseMask),
|
||||
|
@ -501,15 +517,14 @@ INSTANTIATE_TEST_CASE_P(
|
|||
}));
|
||||
|
||||
// See SPIR-V Section 3.27 Scope <id>
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
Scope, EnumCapabilityTest,
|
||||
::testing::ValuesIn(std::vector<EnumCapabilityCase>{
|
||||
CASE0(EXECUTION_SCOPE, ScopeCrossDevice),
|
||||
CASE0(EXECUTION_SCOPE, ScopeDevice),
|
||||
CASE0(EXECUTION_SCOPE, ScopeWorkgroup),
|
||||
CASE0(EXECUTION_SCOPE, ScopeSubgroup),
|
||||
CASE0(EXECUTION_SCOPE, ScopeInvocation),
|
||||
}));
|
||||
INSTANTIATE_TEST_CASE_P(Scope, EnumCapabilityTest,
|
||||
::testing::ValuesIn(std::vector<EnumCapabilityCase>{
|
||||
CASE0(EXECUTION_SCOPE, ScopeCrossDevice),
|
||||
CASE0(EXECUTION_SCOPE, ScopeDevice),
|
||||
CASE0(EXECUTION_SCOPE, ScopeWorkgroup),
|
||||
CASE0(EXECUTION_SCOPE, ScopeSubgroup),
|
||||
CASE0(EXECUTION_SCOPE, ScopeInvocation),
|
||||
}));
|
||||
|
||||
// See SPIR-V Section 3.28 Group Operation
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
|
@ -530,12 +545,13 @@ INSTANTIATE_TEST_CASE_P(
|
|||
}));
|
||||
|
||||
// See SPIR-V Section 3.30 Kernel Profiling Info
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
KernelProfilingInfo, EnumCapabilityTest,
|
||||
::testing::ValuesIn(std::vector<EnumCapabilityCase>{
|
||||
CASE0(KERNEL_PROFILING_INFO, KernelProfilingInfoMaskNone),
|
||||
CASE1(KERNEL_PROFILING_INFO, KernelProfilingInfoCmdExecTimeMask, Kernel),
|
||||
}));
|
||||
INSTANTIATE_TEST_CASE_P(KernelProfilingInfo, EnumCapabilityTest,
|
||||
::testing::ValuesIn(std::vector<EnumCapabilityCase>{
|
||||
CASE0(KERNEL_PROFILING_INFO,
|
||||
KernelProfilingInfoMaskNone),
|
||||
CASE1(KERNEL_PROFILING_INFO,
|
||||
KernelProfilingInfoCmdExecTimeMask, Kernel),
|
||||
}));
|
||||
|
||||
// See SPIR-V Section 3.31 Capability
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
|
|
|
@ -137,8 +137,7 @@ class TextToBinaryTestBase : public T {
|
|||
// is then decoded. This is expected to fail.
|
||||
// Returns the error message.
|
||||
std::string EncodeSuccessfullyDecodeFailed(
|
||||
const std::string& text,
|
||||
const SpirvVector& words_to_append) {
|
||||
const std::string& text, const SpirvVector& words_to_append) {
|
||||
SpirvVector code = spvtest::Concatenate(
|
||||
{CompileSuccessfully(text, SPV_ASSEMBLY_SYNTAX_FORMAT_DEFAULT),
|
||||
words_to_append});
|
||||
|
|
|
@ -71,8 +71,8 @@ TEST(TextAdvance, LeadingWhitespaceAfterCommentLine) {
|
|||
AutoText input("; comment\n \t \tWord");
|
||||
AssemblyContext data(input, nullptr);
|
||||
ASSERT_EQ(SPV_SUCCESS, data.advance());
|
||||
ASSERT_EQ(4, data.position().column);
|
||||
ASSERT_EQ(1, data.position().line);
|
||||
ASSERT_EQ(4, data.position().column);
|
||||
ASSERT_EQ(1, data.position().line);
|
||||
ASSERT_EQ(14, data.position().index);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
|
||||
using ::testing::Eq;
|
||||
namespace {
|
||||
|
||||
|
@ -119,26 +118,25 @@ TEST_P(GoodStringTest, GoodStrings) {
|
|||
INSTANTIATE_TEST_CASE_P(
|
||||
TextLiteral, GoodStringTest,
|
||||
::testing::ValuesIn(std::vector<std::pair<const char*, const char*>>{
|
||||
{R"("-")", "-"},
|
||||
{R"("--")", "--"},
|
||||
{R"("1-2")", "1-2"},
|
||||
{R"("123a")", "123a"},
|
||||
{R"("12.2.3")", "12.2.3"},
|
||||
{R"("\"")", "\""},
|
||||
{R"("\\")", "\\"},
|
||||
{"\"\\foo\nbar\"", "foo\nbar"},
|
||||
{"\"\\foo\\\nbar\"", "foo\nbar"},
|
||||
{"\"\xE4\xBA\xB2\"", "\xE4\xBA\xB2"},
|
||||
{"\"\\\xE4\xBA\xB2\"", "\xE4\xBA\xB2"},
|
||||
{"\"this \\\" and this \\\\ and \\\xE4\xBA\xB2\"",
|
||||
"this \" and this \\ and \xE4\xBA\xB2"}
|
||||
}));
|
||||
{R"("-")", "-"},
|
||||
{R"("--")", "--"},
|
||||
{R"("1-2")", "1-2"},
|
||||
{R"("123a")", "123a"},
|
||||
{R"("12.2.3")", "12.2.3"},
|
||||
{R"("\"")", "\""},
|
||||
{R"("\\")", "\\"},
|
||||
{"\"\\foo\nbar\"", "foo\nbar"},
|
||||
{"\"\\foo\\\nbar\"", "foo\nbar"},
|
||||
{"\"\xE4\xBA\xB2\"", "\xE4\xBA\xB2"},
|
||||
{"\"\\\xE4\xBA\xB2\"", "\xE4\xBA\xB2"},
|
||||
{"\"this \\\" and this \\\\ and \\\xE4\xBA\xB2\"",
|
||||
"this \" and this \\ and \xE4\xBA\xB2"}}));
|
||||
|
||||
TEST(TextLiteral, StringTooLong) {
|
||||
spv_literal_t l;
|
||||
std::string too_long = std::string("\"") +
|
||||
std::string(SPV_LIMIT_LITERAL_STRING_BYTES_MAX + 1, 'a') +
|
||||
"\"";
|
||||
std::string too_long =
|
||||
std::string("\"") +
|
||||
std::string(SPV_LIMIT_LITERAL_STRING_BYTES_MAX + 1, 'a') + "\"";
|
||||
EXPECT_EQ(SPV_ERROR_OUT_OF_MEMORY, spvTextToLiteral(too_long.data(), &l));
|
||||
}
|
||||
|
||||
|
@ -175,19 +173,15 @@ struct TextLiteralCase {
|
|||
std::vector<uint32_t> expected_values;
|
||||
};
|
||||
|
||||
using IntegerTest = spvtest::TextToBinaryTestBase<
|
||||
::testing::TestWithParam<TextLiteralCase>>;
|
||||
using IntegerTest =
|
||||
spvtest::TextToBinaryTestBase<::testing::TestWithParam<TextLiteralCase>>;
|
||||
|
||||
std::vector<uint32_t> successfulEncode(const TextLiteralCase& test,
|
||||
libspirv::IdTypeClass type) {
|
||||
spv_instruction_t inst;
|
||||
spv_diagnostic diagnostic;
|
||||
libspirv::IdType expected_type {
|
||||
test.bitwidth,
|
||||
test.is_signed,
|
||||
type
|
||||
};
|
||||
EXPECT_EQ(SPV_SUCCESS,
|
||||
libspirv::IdType expected_type{test.bitwidth, test.is_signed, type};
|
||||
EXPECT_EQ(SPV_SUCCESS,
|
||||
libspirv::AssemblyContext(nullptr, &diagnostic)
|
||||
.binaryEncodeNumericLiteral(test.text, SPV_ERROR_INVALID_TEXT,
|
||||
expected_type, &inst))
|
||||
|
@ -199,11 +193,7 @@ std::string failedEncode(const TextLiteralCase& test,
|
|||
libspirv::IdTypeClass type) {
|
||||
spv_instruction_t inst;
|
||||
spv_diagnostic diagnostic;
|
||||
libspirv::IdType expected_type {
|
||||
test.bitwidth,
|
||||
test.is_signed,
|
||||
type
|
||||
};
|
||||
libspirv::IdType expected_type{test.bitwidth, test.is_signed, type};
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_TEXT,
|
||||
libspirv::AssemblyContext(nullptr, &diagnostic)
|
||||
.binaryEncodeNumericLiteral(test.text, SPV_ERROR_INVALID_TEXT,
|
||||
|
@ -395,8 +385,7 @@ TEST(OverflowIntegerParse, Decimal) {
|
|||
|
||||
TEST(OverflowIntegerParse, Hex) {
|
||||
std::string input = "0x10000000000000000";
|
||||
std::string expected_message =
|
||||
"Invalid unsigned integer literal: " + input;
|
||||
std::string expected_message = "Invalid unsigned integer literal: " + input;
|
||||
EXPECT_THAT(failedEncode(Make_Bad_Signed(64, input.c_str()),
|
||||
libspirv::IdTypeClass::kScalarIntegerType),
|
||||
Eq(expected_message));
|
||||
|
|
|
@ -34,12 +34,9 @@ using libspirv::AssemblyContext;
|
|||
using spvtest::AutoText;
|
||||
|
||||
TEST(TextStartsWithOp, YesAtStart) {
|
||||
EXPECT_TRUE(
|
||||
AssemblyContext(AutoText("OpFoo"), nullptr).isStartOfNewInst());
|
||||
EXPECT_TRUE(
|
||||
AssemblyContext(AutoText("OpFoo"), nullptr).isStartOfNewInst());
|
||||
EXPECT_TRUE(
|
||||
AssemblyContext(AutoText("OpEnCL"), nullptr).isStartOfNewInst());
|
||||
EXPECT_TRUE(AssemblyContext(AutoText("OpFoo"), nullptr).isStartOfNewInst());
|
||||
EXPECT_TRUE(AssemblyContext(AutoText("OpFoo"), nullptr).isStartOfNewInst());
|
||||
EXPECT_TRUE(AssemblyContext(AutoText("OpEnCL"), nullptr).isStartOfNewInst());
|
||||
}
|
||||
|
||||
TEST(TextStartsWithOp, YesAtMiddle) {
|
||||
|
@ -62,30 +59,25 @@ TEST(TextStartsWithOp, NoIfTooFar) {
|
|||
}
|
||||
|
||||
TEST(TextStartsWithOp, NoRegular) {
|
||||
EXPECT_FALSE(AssemblyContext(AutoText("Fee Fi Fo Fum"), nullptr)
|
||||
.isStartOfNewInst());
|
||||
EXPECT_FALSE(
|
||||
AssemblyContext(AutoText("123456"), nullptr).isStartOfNewInst());
|
||||
EXPECT_FALSE(
|
||||
AssemblyContext(AutoText("123456"), nullptr).isStartOfNewInst());
|
||||
EXPECT_FALSE(
|
||||
AssemblyContext(AutoText("OpenCL"), nullptr).isStartOfNewInst());
|
||||
AssemblyContext(AutoText("Fee Fi Fo Fum"), nullptr).isStartOfNewInst());
|
||||
EXPECT_FALSE(AssemblyContext(AutoText("123456"), nullptr).isStartOfNewInst());
|
||||
EXPECT_FALSE(AssemblyContext(AutoText("123456"), nullptr).isStartOfNewInst());
|
||||
EXPECT_FALSE(AssemblyContext(AutoText("OpenCL"), nullptr).isStartOfNewInst());
|
||||
}
|
||||
|
||||
TEST(TextStartsWithOp, YesForValueGenerationForm) {
|
||||
EXPECT_TRUE(AssemblyContext(AutoText("%foo = OpAdd"), nullptr)
|
||||
.isStartOfNewInst());
|
||||
EXPECT_TRUE(AssemblyContext(AutoText("%foo = OpAdd"), nullptr)
|
||||
.isStartOfNewInst());
|
||||
EXPECT_TRUE(
|
||||
AssemblyContext(AutoText("%foo = OpAdd"), nullptr).isStartOfNewInst());
|
||||
EXPECT_TRUE(
|
||||
AssemblyContext(AutoText("%foo = OpAdd"), nullptr).isStartOfNewInst());
|
||||
}
|
||||
|
||||
TEST(TextStartsWithOp, NoForNearlyValueGeneration) {
|
||||
EXPECT_FALSE(
|
||||
AssemblyContext(AutoText("%foo = "), nullptr).isStartOfNewInst());
|
||||
EXPECT_FALSE(
|
||||
AssemblyContext(AutoText("%foo "), nullptr).isStartOfNewInst());
|
||||
EXPECT_FALSE(
|
||||
AssemblyContext(AutoText("%foo"), nullptr).isStartOfNewInst());
|
||||
EXPECT_FALSE(AssemblyContext(AutoText("%foo "), nullptr).isStartOfNewInst());
|
||||
EXPECT_FALSE(AssemblyContext(AutoText("%foo"), nullptr).isStartOfNewInst());
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
|
|
@ -130,7 +130,7 @@ TEST_P(OpDecorateEnumTest, AnyEnumDecoration) {
|
|||
"OpDecorate %1 " + GetParam().enum_name + " " + GetParam().name;
|
||||
EXPECT_THAT(CompiledInstructions(input),
|
||||
Eq(MakeInstruction(SpvOpDecorate, {1, GetParam().enum_value,
|
||||
GetParam().value})));
|
||||
GetParam().value})));
|
||||
}
|
||||
|
||||
// Test OpDecorate BuiltIn.
|
||||
|
|
|
@ -57,8 +57,7 @@ TEST_F(OpMemoryBarrier, BadMissingScopeId) {
|
|||
|
||||
TEST_F(OpMemoryBarrier, BadInvalidScopeId) {
|
||||
const std::string input = "OpMemoryBarrier 99\n";
|
||||
EXPECT_THAT(CompileFailure(input),
|
||||
Eq("Expected id to start with %."));
|
||||
EXPECT_THAT(CompileFailure(input), Eq("Expected id to start with %."));
|
||||
}
|
||||
|
||||
TEST_F(OpMemoryBarrier, BadMissingMemorySemanticsId) {
|
||||
|
@ -69,8 +68,7 @@ TEST_F(OpMemoryBarrier, BadMissingMemorySemanticsId) {
|
|||
|
||||
TEST_F(OpMemoryBarrier, BadInvalidMemorySemanticsId) {
|
||||
const std::string input = "OpMemoryBarrier %scope 14\n";
|
||||
EXPECT_THAT(CompileFailure(input),
|
||||
Eq("Expected id to start with %."));
|
||||
EXPECT_THAT(CompileFailure(input), Eq("Expected id to start with %."));
|
||||
}
|
||||
|
||||
// TODO(dneto): OpControlBarrier
|
||||
|
|
|
@ -219,11 +219,10 @@ INSTANTIATE_TEST_CASE_P(
|
|||
}));
|
||||
// clang-format on
|
||||
|
||||
using OpSpecConstantValidTest = spvtest::TextToBinaryTestBase<
|
||||
::testing::TestWithParam<ConstantTestCase>>;
|
||||
using OpSpecConstantValidTest =
|
||||
spvtest::TextToBinaryTestBase<::testing::TestWithParam<ConstantTestCase>>;
|
||||
|
||||
TEST_P(OpSpecConstantValidTest, ValidTypes)
|
||||
{
|
||||
TEST_P(OpSpecConstantValidTest, ValidTypes) {
|
||||
const std::string input = "%1 = " + GetParam().constant_type +
|
||||
"\n"
|
||||
"%2 = OpSpecConstant %1 " +
|
||||
|
@ -289,17 +288,16 @@ INSTANTIATE_TEST_CASE_P(
|
|||
}));
|
||||
// clang-format on
|
||||
|
||||
using OpSpecConstantInvalidTypeTest = spvtest::TextToBinaryTestBase<
|
||||
::testing::TestWithParam<std::string>>;
|
||||
using OpSpecConstantInvalidTypeTest =
|
||||
spvtest::TextToBinaryTestBase<::testing::TestWithParam<std::string>>;
|
||||
|
||||
TEST_P(OpSpecConstantInvalidTypeTest, InvalidTypes)
|
||||
{
|
||||
TEST_P(OpSpecConstantInvalidTypeTest, InvalidTypes) {
|
||||
const std::string input = "%1 = " + GetParam() +
|
||||
"\n"
|
||||
"%2 = OpSpecConstant %1 0\n";
|
||||
EXPECT_THAT(
|
||||
CompileFailure(input),
|
||||
Eq("Type for SpecConstant must be a scalar floating point or integer type"));
|
||||
EXPECT_THAT(CompileFailure(input),
|
||||
Eq("Type for SpecConstant must be a scalar floating point or "
|
||||
"integer type"));
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
|
@ -339,12 +337,12 @@ const int64_t kMaxSigned48Bit = (int64_t(1) << 47) - 1;
|
|||
const int64_t kMinSigned48Bit = -kMaxSigned48Bit - 1;
|
||||
|
||||
TEST_P(RoundTripTest, Sample) {
|
||||
EXPECT_THAT(EncodeAndDecodeSuccessfully(GetParam()),
|
||||
Eq(GetParam()));
|
||||
EXPECT_THAT(EncodeAndDecodeSuccessfully(GetParam()), Eq(GetParam()));
|
||||
}
|
||||
|
||||
// TODO(dneto): Enable support once this works.
|
||||
INSTANTIATE_TEST_CASE_P(DISABLED_OpConstantRoundTrip, RoundTripTest,
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
DISABLED_OpConstantRoundTrip, RoundTripTest,
|
||||
::testing::ValuesIn(std::vector<std::string>{
|
||||
// 16 bit
|
||||
"%1 = OpTypeInt 16 0\n%2 = OpConstant %1 0\n",
|
||||
|
@ -387,7 +385,8 @@ INSTANTIATE_TEST_CASE_P(DISABLED_OpConstantRoundTrip, RoundTripTest,
|
|||
}));
|
||||
|
||||
// TODO(dneto): Enable support once this works.
|
||||
INSTANTIATE_TEST_CASE_P(DISABLED_OpSpecConstantRoundTrip, RoundTripTest,
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
DISABLED_OpSpecConstantRoundTrip, RoundTripTest,
|
||||
::testing::ValuesIn(std::vector<std::string>{
|
||||
// 16 bit
|
||||
"%1 = OpTypeInt 16 0\n%2 = OpSpecConstant %1 0\n",
|
||||
|
|
|
@ -84,9 +84,8 @@ using OpLoopMergeTest = spvtest::TextToBinaryTestBase<
|
|||
|
||||
TEST_P(OpLoopMergeTest, AnySingleLoopControlMask) {
|
||||
const std::string input = "OpLoopMerge %merge %continue " + GetParam().name();
|
||||
EXPECT_THAT(
|
||||
CompiledInstructions(input),
|
||||
Eq(MakeInstruction(SpvOpLoopMerge, {1, 2, GetParam().value()})));
|
||||
EXPECT_THAT(CompiledInstructions(input),
|
||||
Eq(MakeInstruction(SpvOpLoopMerge, {1, 2, GetParam().value()})));
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
|
|
|
@ -74,10 +74,9 @@ TEST_P(OpSourceTest, AnyLanguage) {
|
|||
const std::string input = std::string("OpSource ") +
|
||||
GetParam().language_name + " " +
|
||||
std::to_string(GetParam().version);
|
||||
EXPECT_THAT(
|
||||
CompiledInstructions(input),
|
||||
Eq(MakeInstruction(SpvOpSource, {GetParam().get_language_value(),
|
||||
GetParam().version})));
|
||||
EXPECT_THAT(CompiledInstructions(input),
|
||||
Eq(MakeInstruction(SpvOpSource, {GetParam().get_language_value(),
|
||||
GetParam().version})));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(TextToBinaryTestDebug, OpSourceTest,
|
||||
|
@ -100,10 +99,9 @@ TEST_F(TextToBinaryTest, OpSourceAcceptsOptionalSourceText) {
|
|||
std::string fake_source = "To be or not to be";
|
||||
const std::string input =
|
||||
"OpSource GLSL 450 %file_id \"" + fake_source + "\"";
|
||||
EXPECT_THAT(
|
||||
CompiledInstructions(input),
|
||||
Eq(MakeInstruction(SpvOpSource, {SpvSourceLanguageGLSL, 450, 1},
|
||||
MakeVector(fake_source))));
|
||||
EXPECT_THAT(CompiledInstructions(input),
|
||||
Eq(MakeInstruction(SpvOpSource, {SpvSourceLanguageGLSL, 450, 1},
|
||||
MakeVector(fake_source))));
|
||||
};
|
||||
|
||||
// Test OpSourceContinued
|
||||
|
|
|
@ -64,13 +64,13 @@ TEST_P(OpMemoryModelTest, AnyMemoryModelCase) {
|
|||
EXPECT_THAT(
|
||||
CompiledInstructions(input),
|
||||
Eq(MakeInstruction(SpvOpMemoryModel, {GetParam().get_addressing_value(),
|
||||
GetParam().get_memory_value()})));
|
||||
GetParam().get_memory_value()})));
|
||||
}
|
||||
|
||||
#define CASE(ADDRESSING, MEMORY) \
|
||||
{ \
|
||||
SpvAddressingModel##ADDRESSING, #ADDRESSING, SpvMemoryModel##MEMORY, \
|
||||
#MEMORY \
|
||||
#define CASE(ADDRESSING, MEMORY) \
|
||||
{ \
|
||||
SpvAddressingModel##ADDRESSING, #ADDRESSING, SpvMemoryModel##MEMORY, \
|
||||
#MEMORY \
|
||||
}
|
||||
// clang-format off
|
||||
INSTANTIATE_TEST_CASE_P(TextToBinaryMemoryModel, OpMemoryModelTest,
|
||||
|
@ -112,10 +112,10 @@ TEST_P(OpEntryPointTest, AnyEntryPointCase) {
|
|||
// TODO(dneto): utf-8, escaping, quoting cases for entry point name.
|
||||
const std::string input = "OpEntryPoint " + GetParam().execution_name +
|
||||
" %1 \"" + GetParam().entry_point_name + "\"";
|
||||
EXPECT_THAT(CompiledInstructions(input),
|
||||
Eq(MakeInstruction(SpvOpEntryPoint,
|
||||
{GetParam().get_execution_value(), 1},
|
||||
MakeVector(GetParam().entry_point_name))));
|
||||
EXPECT_THAT(
|
||||
CompiledInstructions(input),
|
||||
Eq(MakeInstruction(SpvOpEntryPoint, {GetParam().get_execution_value(), 1},
|
||||
MakeVector(GetParam().entry_point_name))));
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
|
|
|
@ -48,8 +48,8 @@ TEST_P(DimTest, AnyDim) {
|
|||
GetParam().name() + " 2 3 0 4 Rgba8";
|
||||
EXPECT_THAT(
|
||||
CompiledInstructions(input),
|
||||
Eq(MakeInstruction(SpvOpTypeImage, {1, 2, GetParam().value(), 2, 3, 0,
|
||||
4, SpvImageFormatRgba8})));
|
||||
Eq(MakeInstruction(SpvOpTypeImage, {1, 2, GetParam().value(), 2, 3, 0, 4,
|
||||
SpvImageFormatRgba8})));
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
|
@ -82,8 +82,8 @@ TEST_P(ImageFormatTest, AnyImageFormat) {
|
|||
const std::string input =
|
||||
"%imageType = OpTypeImage %sampledType 1D 2 3 0 4 " + GetParam().name();
|
||||
EXPECT_THAT(CompiledInstructions(input),
|
||||
Eq(MakeInstruction(SpvOpTypeImage, {1, 2, SpvDim1D, 2, 3, 0,
|
||||
4, GetParam().value()})));
|
||||
Eq(MakeInstruction(SpvOpTypeImage, {1, 2, SpvDim1D, 2, 3, 0, 4,
|
||||
GetParam().value()})));
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
|
|
|
@ -49,14 +49,10 @@ TEST(GetWord, Simple) {
|
|||
EXPECT_EQ("", AssemblyContext(AutoText("\na"), nullptr).getWord());
|
||||
EXPECT_EQ("abc", AssemblyContext(AutoText("abc"), nullptr).getWord());
|
||||
EXPECT_EQ("abc", AssemblyContext(AutoText("abc "), nullptr).getWord());
|
||||
EXPECT_EQ("abc",
|
||||
AssemblyContext(AutoText("abc\t"), nullptr).getWord());
|
||||
EXPECT_EQ("abc",
|
||||
AssemblyContext(AutoText("abc\r"), nullptr).getWord());
|
||||
EXPECT_EQ("abc",
|
||||
AssemblyContext(AutoText("abc\v"), nullptr).getWord());
|
||||
EXPECT_EQ("abc",
|
||||
AssemblyContext(AutoText("abc\n"), nullptr).getWord());
|
||||
EXPECT_EQ("abc", AssemblyContext(AutoText("abc\t"), nullptr).getWord());
|
||||
EXPECT_EQ("abc", AssemblyContext(AutoText("abc\r"), nullptr).getWord());
|
||||
EXPECT_EQ("abc", AssemblyContext(AutoText("abc\v"), nullptr).getWord());
|
||||
EXPECT_EQ("abc", AssemblyContext(AutoText("abc\n"), nullptr).getWord());
|
||||
}
|
||||
|
||||
// An mask parsing test case.
|
||||
|
@ -603,7 +599,8 @@ TEST(AssemblyContextParseMessages, Errors) {
|
|||
int16_t i16;
|
||||
|
||||
// No message is generated for a failure to parse an optional value.
|
||||
EXPECT_EQ(SPV_FAILED_MATCH, context.parseNumber("abc", ec, &i16, "bad narrow int: "));
|
||||
EXPECT_EQ(SPV_FAILED_MATCH,
|
||||
context.parseNumber("abc", ec, &i16, "bad narrow int: "));
|
||||
EXPECT_EQ(nullptr, diag);
|
||||
|
||||
// For a required value, use the message fragment.
|
||||
|
|
|
@ -85,12 +85,11 @@ TEST(TextWordGet, MultipleWords) {
|
|||
AssemblyContext data(input, nullptr);
|
||||
|
||||
spv_position_t endPosition = {};
|
||||
const char *words[] = {"Words", "in", "a", "sentence"};
|
||||
const char* words[] = {"Words", "in", "a", "sentence"};
|
||||
|
||||
std::string word;
|
||||
for (uint32_t wordIndex = 0; wordIndex < 4; ++wordIndex) {
|
||||
ASSERT_EQ(SPV_SUCCESS,
|
||||
data.getWord(word, &endPosition));
|
||||
ASSERT_EQ(SPV_SUCCESS, data.getWord(word, &endPosition));
|
||||
ASSERT_EQ(strlen(words[wordIndex]),
|
||||
endPosition.column - data.position().column);
|
||||
ASSERT_EQ(0, endPosition.line);
|
||||
|
@ -109,13 +108,12 @@ TEST(TextWordGet, MultipleWords) {
|
|||
|
||||
TEST(TextWordGet, QuotesAreKept) {
|
||||
AutoText input(R"("quotes" "around words")");
|
||||
const char *expected[] = {R"("quotes")", R"("around words")"};
|
||||
const char* expected[] = {R"("quotes")", R"("around words")"};
|
||||
AssemblyContext data(input, nullptr);
|
||||
|
||||
std::string word;
|
||||
spv_position_t endPosition = {};
|
||||
ASSERT_EQ(SPV_SUCCESS,
|
||||
data.getWord(word, &endPosition));
|
||||
ASSERT_EQ(SPV_SUCCESS, data.getWord(word, &endPosition));
|
||||
EXPECT_EQ(8, endPosition.column);
|
||||
EXPECT_EQ(0, endPosition.line);
|
||||
EXPECT_EQ(8, endPosition.index);
|
||||
|
@ -125,8 +123,7 @@ TEST(TextWordGet, QuotesAreKept) {
|
|||
data.setPosition(endPosition);
|
||||
data.seekForward(1);
|
||||
|
||||
ASSERT_EQ(SPV_SUCCESS,
|
||||
data.getWord(word, &endPosition));
|
||||
ASSERT_EQ(SPV_SUCCESS, data.getWord(word, &endPosition));
|
||||
EXPECT_EQ(23, endPosition.column);
|
||||
EXPECT_EQ(0, endPosition.line);
|
||||
EXPECT_EQ(23, endPosition.index);
|
||||
|
@ -135,13 +132,12 @@ TEST(TextWordGet, QuotesAreKept) {
|
|||
|
||||
TEST(TextWordGet, QuotesBetweenWordsActLikeGlue) {
|
||||
AutoText input(R"(quotes" "between words)");
|
||||
const char *expected[] = {R"(quotes" "between)", "words"};
|
||||
const char* expected[] = {R"(quotes" "between)", "words"};
|
||||
AssemblyContext data(input, nullptr);
|
||||
|
||||
std::string word;
|
||||
spv_position_t endPosition = {};
|
||||
ASSERT_EQ(SPV_SUCCESS,
|
||||
data.getWord(word, &endPosition));
|
||||
ASSERT_EQ(SPV_SUCCESS, data.getWord(word, &endPosition));
|
||||
EXPECT_EQ(16, endPosition.column);
|
||||
EXPECT_EQ(0, endPosition.line);
|
||||
EXPECT_EQ(16, endPosition.index);
|
||||
|
@ -151,8 +147,7 @@ TEST(TextWordGet, QuotesBetweenWordsActLikeGlue) {
|
|||
data.setPosition(endPosition);
|
||||
data.seekForward(1);
|
||||
|
||||
ASSERT_EQ(SPV_SUCCESS,
|
||||
data.getWord(word, &endPosition));
|
||||
ASSERT_EQ(SPV_SUCCESS, data.getWord(word, &endPosition));
|
||||
EXPECT_EQ(22, endPosition.column);
|
||||
EXPECT_EQ(0, endPosition.line);
|
||||
EXPECT_EQ(22, endPosition.index);
|
||||
|
|
|
@ -121,7 +121,6 @@ inline std::vector<uint32_t> MakeInstruction(
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
// Returns a vector of words representing a single instruction with the
|
||||
// given opcode and whose operands are the concatenation of the two given
|
||||
// argument lists.
|
||||
|
@ -207,7 +206,7 @@ inline std::string MakeLongUTF8String(size_t num_4_byte_chars) {
|
|||
|
||||
std::string result;
|
||||
result.reserve(num_4_byte_chars * 4);
|
||||
for (size_t i = 0; i < num_4_byte_chars; i++ ) {
|
||||
for (size_t i = 0; i < num_4_byte_chars; i++) {
|
||||
result += earth_africa;
|
||||
}
|
||||
EXPECT_EQ(4 * num_4_byte_chars, result.size());
|
||||
|
|
|
@ -74,7 +74,7 @@ class ValidateID : public ::testing::Test {
|
|||
// TODO: OpUndef
|
||||
|
||||
TEST_F(ValidateID, OpName) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
OpName %2 "name"
|
||||
%1 = OpTypeInt 32 0
|
||||
%2 = OpTypePointer UniformConstant %1
|
||||
|
@ -83,20 +83,20 @@ TEST_F(ValidateID, OpName) {
|
|||
}
|
||||
|
||||
TEST_F(ValidateID, OpMemberNameGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
OpMemberName %2 0 "foo"
|
||||
%1 = OpTypeInt 32 0
|
||||
%2 = OpTypeStruct %1)";
|
||||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpMemberNameTypeBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
OpMemberName %1 0 "foo"
|
||||
%1 = OpTypeInt 32 0)";
|
||||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
TEST_F(ValidateID, OpMemberNameMemberBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
OpMemberName %2 1 "foo"
|
||||
%1 = OpTypeInt 32 0
|
||||
%2 = OpTypeStruct %1)";
|
||||
|
@ -104,7 +104,7 @@ TEST_F(ValidateID, OpMemberNameMemberBad) {
|
|||
}
|
||||
|
||||
TEST_F(ValidateID, OpLineGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpString "/path/to/source.file"
|
||||
OpLine %1 0 0
|
||||
%2 = OpTypeInt 32 0
|
||||
|
@ -113,7 +113,7 @@ TEST_F(ValidateID, OpLineGood) {
|
|||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpLineFileBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
OpLine %2 0 0
|
||||
%2 = OpTypeInt 32 0
|
||||
%3 = OpTypePointer Generic %2
|
||||
|
@ -122,33 +122,33 @@ TEST_F(ValidateID, OpLineFileBad) {
|
|||
}
|
||||
|
||||
TEST_F(ValidateID, OpDecorateGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
OpDecorate %2 GLSLShared
|
||||
%1 = OpTypeInt 64 0
|
||||
%2 = OpTypeStruct %1 %1)";
|
||||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpDecorateBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
OpDecorate %1 GLSLShared)";
|
||||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
|
||||
TEST_F(ValidateID, OpMemberDecorateGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
OpMemberDecorate %2 0 Uniform
|
||||
%1 = OpTypeInt 32 0
|
||||
%2 = OpTypeStruct %1 %1)";
|
||||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpMemberDecorateBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
OpMemberDecorate %1 0 Uniform
|
||||
%1 = OpTypeInt 32 0)";
|
||||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
TEST_F(ValidateID, OpMemberDecorateMemberBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
OpMemberDecorate %2 3 Uniform
|
||||
%1 = OpTypeInt 32 0
|
||||
%2 = OpTypeStruct %1 %1)";
|
||||
|
@ -156,7 +156,7 @@ TEST_F(ValidateID, OpMemberDecorateMemberBad) {
|
|||
}
|
||||
|
||||
TEST_F(ValidateID, OpGroupDecorateGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpDecorationGroup
|
||||
OpDecorate %1 Uniform
|
||||
OpDecorate %1 GLSLShared
|
||||
|
@ -167,7 +167,7 @@ TEST_F(ValidateID, OpGroupDecorateGood) {
|
|||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpGroupDecorateDecorationGroupBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
OpGroupDecorate %2 %3 %4
|
||||
%2 = OpTypeInt 32 0
|
||||
%3 = OpConstant %2 42
|
||||
|
@ -175,7 +175,7 @@ TEST_F(ValidateID, OpGroupDecorateDecorationGroupBad) {
|
|||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
TEST_F(ValidateID, OpGroupDecorateTargetBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpDecorationGroup
|
||||
OpDecorate %1 Uniform
|
||||
OpDecorate %1 GLSLShared
|
||||
|
@ -188,7 +188,7 @@ TEST_F(ValidateID, OpGroupDecorateTargetBad) {
|
|||
// TODO: OpExtInst
|
||||
|
||||
TEST_F(ValidateID, OpEntryPointGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
OpEntryPoint GLCompute %3 ""
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeFunction %1
|
||||
|
@ -200,13 +200,13 @@ TEST_F(ValidateID, OpEntryPointGood) {
|
|||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpEntryPointFunctionBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
OpEntryPoint GLCompute %1 ""
|
||||
%1 = OpTypeVoid)";
|
||||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
TEST_F(ValidateID, OpEntryPointParameterCountBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
OpEntryPoint GLCompute %3 ""
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeFunction %1 %1
|
||||
|
@ -217,7 +217,7 @@ TEST_F(ValidateID, OpEntryPointParameterCountBad) {
|
|||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
TEST_F(ValidateID, OpEntryPointReturnTypeBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
OpEntryPoint GLCompute %3 ""
|
||||
%1 = OpTypeInt 32 0
|
||||
%2 = OpTypeFunction %1
|
||||
|
@ -229,7 +229,7 @@ TEST_F(ValidateID, OpEntryPointReturnTypeBad) {
|
|||
}
|
||||
|
||||
TEST_F(ValidateID, OpExecutionModeGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
OpEntryPoint GLCompute %3 ""
|
||||
OpExecutionMode %3 LocalSize 1 1 1
|
||||
%1 = OpTypeVoid
|
||||
|
@ -241,7 +241,7 @@ TEST_F(ValidateID, OpExecutionModeGood) {
|
|||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpExecutionModeEntryPointBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
OpExecutionMode %3 LocalSize 1 1 1
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeFunction %1
|
||||
|
@ -253,13 +253,13 @@ TEST_F(ValidateID, OpExecutionModeEntryPointBad) {
|
|||
}
|
||||
|
||||
TEST_F(ValidateID, OpTypeVectorGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeFloat 32
|
||||
%2 = OpTypeVector %1 4)";
|
||||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpTypeVectorComponentTypeBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeFloat 32
|
||||
%2 = OpTypePointer UniformConstant %1
|
||||
%3 = OpTypeVector %2 4)";
|
||||
|
@ -267,14 +267,14 @@ TEST_F(ValidateID, OpTypeVectorComponentTypeBad) {
|
|||
}
|
||||
|
||||
TEST_F(ValidateID, OpTypeMatrixGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeInt 32 0
|
||||
%2 = OpTypeVector %1 2
|
||||
%3 = OpTypeMatrix %2 3)";
|
||||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpTypeMatrixColumnTypeBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeInt 32 0
|
||||
%2 = OpTypeMatrix %1 3)";
|
||||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
|
@ -282,27 +282,27 @@ TEST_F(ValidateID, OpTypeMatrixColumnTypeBad) {
|
|||
|
||||
TEST_F(ValidateID, OpTypeSamplerGood) {
|
||||
// In Rev31, OpTypeSampler takes no arguments.
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%s = OpTypeSampler)";
|
||||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_F(ValidateID, OpTypeArrayGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeInt 32 0
|
||||
%2 = OpConstant %1 1
|
||||
%3 = OpTypeArray %1 %2)";
|
||||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpTypeArrayElementTypeBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeInt 32 0
|
||||
%2 = OpConstant %1 1
|
||||
%3 = OpTypeArray %2 %2)";
|
||||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
TEST_F(ValidateID, OpTypeArrayLengthBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeInt 32 0
|
||||
%2 = OpConstant %1 0
|
||||
%3 = OpTypeArray %1 %2)";
|
||||
|
@ -310,13 +310,13 @@ TEST_F(ValidateID, OpTypeArrayLengthBad) {
|
|||
}
|
||||
|
||||
TEST_F(ValidateID, OpTypeRuntimeArrayGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeInt 32 0
|
||||
%2 = OpTypeRuntimeArray %1)";
|
||||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpTypeRuntimeArrayBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeInt 32 0
|
||||
%2 = OpConstant %1 0
|
||||
%3 = OpTypeRuntimeArray %2)";
|
||||
|
@ -326,7 +326,7 @@ TEST_F(ValidateID, OpTypeRuntimeArrayBad) {
|
|||
// Unifrom Storage Class
|
||||
|
||||
TEST_F(ValidateID, OpTypeStructGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeInt 32 0
|
||||
%2 = OpTypeFloat 64
|
||||
%3 = OpTypePointer Generic %1
|
||||
|
@ -334,7 +334,7 @@ TEST_F(ValidateID, OpTypeStructGood) {
|
|||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpTypeStructMemberTypeBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeInt 32 0
|
||||
%2 = OpTypeFloat 64
|
||||
%3 = OpConstant %2 0.0
|
||||
|
@ -343,13 +343,13 @@ TEST_F(ValidateID, OpTypeStructMemberTypeBad) {
|
|||
}
|
||||
|
||||
TEST_F(ValidateID, OpTypePointerGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeInt 32 0
|
||||
%2 = OpTypePointer Generic %1)";
|
||||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpTypePointerBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeInt 32 0
|
||||
%2 = OpConstant %1 0
|
||||
%3 = OpTypePointer Generic %2)";
|
||||
|
@ -357,20 +357,20 @@ TEST_F(ValidateID, OpTypePointerBad) {
|
|||
}
|
||||
|
||||
TEST_F(ValidateID, OpTypeFunctionGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeFunction %1)";
|
||||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpTypeFunctionReturnTypeBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeInt 32 0
|
||||
%2 = OpConstant %1 0
|
||||
%3 = OpTypeFunction %2)";
|
||||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
TEST_F(ValidateID, OpTypeFunctionParameterBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeInt 32 0
|
||||
%3 = OpConstant %2 0
|
||||
|
@ -379,7 +379,7 @@ TEST_F(ValidateID, OpTypeFunctionParameterBad) {
|
|||
}
|
||||
|
||||
TEST_F(ValidateID, OpTypePipeGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeFloat 32
|
||||
%2 = OpTypeVector %1 16
|
||||
%3 = OpTypePipe ReadOnly)";
|
||||
|
@ -387,46 +387,46 @@ TEST_F(ValidateID, OpTypePipeGood) {
|
|||
}
|
||||
|
||||
TEST_F(ValidateID, OpConstantTrueGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeBool
|
||||
%2 = OpConstantTrue %1)";
|
||||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpConstantTrueBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpConstantTrue %1)";
|
||||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
|
||||
TEST_F(ValidateID, OpConstantFalseGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeBool
|
||||
%2 = OpConstantTrue %1)";
|
||||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpConstantFalseBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpConstantFalse %1)";
|
||||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
|
||||
TEST_F(ValidateID, OpConstantGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeInt 32 0
|
||||
%2 = OpConstant %1 1)";
|
||||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpConstantBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpConstant !1 !0)";
|
||||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
|
||||
TEST_F(ValidateID, OpConstantCompositeVectorGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeFloat 32
|
||||
%2 = OpTypeVector %1 4
|
||||
%3 = OpConstant %1 3.14
|
||||
|
@ -434,7 +434,7 @@ TEST_F(ValidateID, OpConstantCompositeVectorGood) {
|
|||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpConstantCompositeVectorResultTypeBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeFloat 32
|
||||
%2 = OpTypeVector %1 4
|
||||
%3 = OpConstant %1 3.14
|
||||
|
@ -442,7 +442,7 @@ TEST_F(ValidateID, OpConstantCompositeVectorResultTypeBad) {
|
|||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
TEST_F(ValidateID, OpConstantCompositeVectorConstituentBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeFloat 32
|
||||
%2 = OpTypeVector %1 4
|
||||
%4 = OpTypeInt 32 0
|
||||
|
@ -452,7 +452,7 @@ TEST_F(ValidateID, OpConstantCompositeVectorConstituentBad) {
|
|||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
TEST_F(ValidateID, OpConstantCompositeMatrixGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeFloat 32
|
||||
%2 = OpTypeVector %1 4
|
||||
%3 = OpTypeMatrix %2 4
|
||||
|
@ -466,7 +466,7 @@ TEST_F(ValidateID, OpConstantCompositeMatrixGood) {
|
|||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpConstantCompositeMatrixConstituentBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeFloat 32
|
||||
%2 = OpTypeVector %1 4
|
||||
%11 = OpTypeVector %1 3
|
||||
|
@ -481,7 +481,7 @@ TEST_F(ValidateID, OpConstantCompositeMatrixConstituentBad) {
|
|||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
TEST_F(ValidateID, OpConstantCompositeMatrixColumnTypeBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeInt 32 0
|
||||
%2 = OpTypeFloat 32
|
||||
%3 = OpTypeVector %1 2
|
||||
|
@ -495,7 +495,7 @@ TEST_F(ValidateID, OpConstantCompositeMatrixColumnTypeBad) {
|
|||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
TEST_F(ValidateID, OpConstantCompositeArrayGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeInt 32 0
|
||||
%2 = OpConstant %1 4
|
||||
%3 = OpTypeArray %1 %2
|
||||
|
@ -503,7 +503,7 @@ TEST_F(ValidateID, OpConstantCompositeArrayGood) {
|
|||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpConstantCompositeArrayConstConstituentBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeInt 32 0
|
||||
%2 = OpConstant %1 4
|
||||
%3 = OpTypeArray %1 %2
|
||||
|
@ -511,7 +511,7 @@ TEST_F(ValidateID, OpConstantCompositeArrayConstConstituentBad) {
|
|||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
TEST_F(ValidateID, OpConstantCompositeArrayConstituentBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeInt 32 0
|
||||
%2 = OpConstant %1 4
|
||||
%3 = OpTypeArray %1 %2
|
||||
|
@ -521,7 +521,7 @@ TEST_F(ValidateID, OpConstantCompositeArrayConstituentBad) {
|
|||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
TEST_F(ValidateID, OpConstantCompositeStructGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeInt 32 0
|
||||
%2 = OpTypeInt 64 1
|
||||
%3 = OpTypeStruct %1 %1 %2
|
||||
|
@ -531,7 +531,7 @@ TEST_F(ValidateID, OpConstantCompositeStructGood) {
|
|||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpConstantCompositeStructMemberBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeInt 32 0
|
||||
%2 = OpTypeInt 64 1
|
||||
%3 = OpTypeStruct %1 %1 %2
|
||||
|
@ -542,21 +542,21 @@ TEST_F(ValidateID, OpConstantCompositeStructMemberBad) {
|
|||
}
|
||||
|
||||
TEST_F(ValidateID, OpConstantSamplerGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%float = OpTypeFloat 32
|
||||
%samplerType = OpTypeSampler
|
||||
%3 = OpConstantSampler %samplerType ClampToEdge 0 Nearest)";
|
||||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpConstantSamplerResultTypeBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeFloat 32
|
||||
%2 = OpConstantSampler %1 Clamp 0 Nearest)";
|
||||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
|
||||
TEST_F(ValidateID, OpConstantNullGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeBool
|
||||
%2 = OpConstantNull %1
|
||||
%3 = OpTypeInt 32 0
|
||||
|
@ -586,13 +586,13 @@ TEST_F(ValidateID, OpConstantNullGood) {
|
|||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpConstantNullBasicBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpConstantNull %1)";
|
||||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
TEST_F(ValidateID, OpConstantNullArrayBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%2 = OpTypeInt 32 0
|
||||
%3 = OpTypeSampler
|
||||
%4 = OpConstant %2 4
|
||||
|
@ -601,7 +601,7 @@ TEST_F(ValidateID, OpConstantNullArrayBad) {
|
|||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
TEST_F(ValidateID, OpConstantNullStructBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%2 = OpTypeSampler
|
||||
%3 = OpTypeStruct %2 %2
|
||||
%4 = OpConstantNull %3)";
|
||||
|
@ -609,39 +609,39 @@ TEST_F(ValidateID, OpConstantNullStructBad) {
|
|||
}
|
||||
|
||||
TEST_F(ValidateID, OpSpecConstantTrueGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeBool
|
||||
%2 = OpSpecConstantTrue %1)";
|
||||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpSpecConstantTrueBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpSpecConstantTrue %1)";
|
||||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
|
||||
TEST_F(ValidateID, OpSpecConstantFalseGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeBool
|
||||
%2 = OpSpecConstantFalse %1)";
|
||||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpSpecConstantFalseBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpSpecConstantFalse %1)";
|
||||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
|
||||
TEST_F(ValidateID, OpSpecConstantGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeFloat 32
|
||||
%2 = OpSpecConstant %1 42)";
|
||||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpSpecConstantBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpSpecConstant !1 !4)";
|
||||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
|
@ -651,14 +651,14 @@ TEST_F(ValidateID, OpSpecConstantBad) {
|
|||
// TODO: OpSpecConstantOp
|
||||
|
||||
TEST_F(ValidateID, OpVariableGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeInt 32 1
|
||||
%2 = OpTypePointer Generic %1
|
||||
%3 = OpVariable %2 Generic)";
|
||||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpVariableInitializerGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeInt 32 1
|
||||
%2 = OpTypePointer Generic %1
|
||||
%3 = OpConstant %1 42
|
||||
|
@ -667,13 +667,13 @@ TEST_F(ValidateID, OpVariableInitializerGood) {
|
|||
}
|
||||
// TODO: Positive test OpVariable with OpConstantNull of OpTypePointer
|
||||
TEST_F(ValidateID, OpVariableResultTypeBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeInt 32 1
|
||||
%2 = OpVariable %1 Generic)";
|
||||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
TEST_F(ValidateID, OpVariableInitializerBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeInt 32 1
|
||||
%2 = OpTypePointer Generic %1
|
||||
%3 = OpVariable %2 Generic %2)";
|
||||
|
@ -681,7 +681,7 @@ TEST_F(ValidateID, OpVariableInitializerBad) {
|
|||
}
|
||||
|
||||
TEST_F(ValidateID, OpLoadGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeInt 32 1
|
||||
%3 = OpTypePointer UniformConstant %2
|
||||
|
@ -696,7 +696,7 @@ TEST_F(ValidateID, OpLoadGood) {
|
|||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpLoadResultTypeBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeInt 32 1
|
||||
%3 = OpTypePointer UniformConstant %2
|
||||
|
@ -711,7 +711,7 @@ TEST_F(ValidateID, OpLoadResultTypeBad) {
|
|||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
TEST_F(ValidateID, OpLoadPointerBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeInt 32 1
|
||||
%9 = OpTypeFloat 32
|
||||
|
@ -727,7 +727,7 @@ TEST_F(ValidateID, OpLoadPointerBad) {
|
|||
}
|
||||
|
||||
TEST_F(ValidateID, OpStoreGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeInt 32 1
|
||||
%3 = OpTypePointer UniformConstant %2
|
||||
|
@ -742,7 +742,7 @@ TEST_F(ValidateID, OpStoreGood) {
|
|||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpStorePointerBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeInt 32 1
|
||||
%3 = OpTypePointer UniformConstant %2
|
||||
|
@ -757,7 +757,7 @@ TEST_F(ValidateID, OpStorePointerBad) {
|
|||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
TEST_F(ValidateID, OpStoreObjectGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeInt 32 1
|
||||
%3 = OpTypePointer UniformConstant %2
|
||||
|
@ -772,7 +772,7 @@ TEST_F(ValidateID, OpStoreObjectGood) {
|
|||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
TEST_F(ValidateID, OpStoreTypeBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeInt 32 1
|
||||
%9 = OpTypeFloat 32
|
||||
|
@ -789,7 +789,7 @@ TEST_F(ValidateID, OpStoreTypeBad) {
|
|||
}
|
||||
|
||||
TEST_F(ValidateID, OpCopyMemoryGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeInt 32 0
|
||||
%3 = OpTypePointer UniformConstant %2
|
||||
|
@ -807,7 +807,7 @@ TEST_F(ValidateID, OpCopyMemoryGood) {
|
|||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpCopyMemoryBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeInt 32 0
|
||||
%3 = OpTypePointer UniformConstant %2
|
||||
|
@ -828,7 +828,7 @@ TEST_F(ValidateID, OpCopyMemoryBad) {
|
|||
|
||||
// TODO: OpCopyMemorySized
|
||||
TEST_F(ValidateID, OpCopyMemorySizedGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeInt 32 0
|
||||
%3 = OpTypePointer UniformConstant %2
|
||||
|
@ -845,7 +845,7 @@ TEST_F(ValidateID, OpCopyMemorySizedGood) {
|
|||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpCopyMemorySizedTargetBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeInt 32 0
|
||||
%3 = OpTypePointer UniformConstant %2
|
||||
|
@ -861,7 +861,7 @@ TEST_F(ValidateID, OpCopyMemorySizedTargetBad) {
|
|||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
TEST_F(ValidateID, OpCopyMemorySizedSourceBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeInt 32 0
|
||||
%3 = OpTypePointer UniformConstant %2
|
||||
|
@ -877,7 +877,7 @@ TEST_F(ValidateID, OpCopyMemorySizedSourceBad) {
|
|||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
TEST_F(ValidateID, OpCopyMemorySizedSizeBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeInt 32 0
|
||||
%3 = OpTypePointer UniformConstant %2
|
||||
|
@ -894,7 +894,7 @@ TEST_F(ValidateID, OpCopyMemorySizedSizeBad) {
|
|||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
TEST_F(ValidateID, OpCopyMemorySizedSizeTypeBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeInt 32 0
|
||||
%3 = OpTypePointer UniformConstant %2
|
||||
|
@ -920,7 +920,7 @@ TEST_F(ValidateID, OpCopyMemorySizedSizeTypeBad) {
|
|||
// TODO: OpGenericPtrMemSemantics
|
||||
|
||||
TEST_F(ValidateID, OpFunctionGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeInt 32 1
|
||||
%3 = OpTypeFunction %1 %2 %2
|
||||
|
@ -929,7 +929,7 @@ TEST_F(ValidateID, OpFunctionGood) {
|
|||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpFunctionResultTypeBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeInt 32 1
|
||||
%5 = OpConstant %2 42
|
||||
|
@ -939,7 +939,7 @@ TEST_F(ValidateID, OpFunctionResultTypeBad) {
|
|||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
TEST_F(ValidateID, OpFunctionFunctionTypeBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeInt 32 1
|
||||
%4 = OpFunction %1 None %2
|
||||
|
@ -948,7 +948,7 @@ OpFunctionEnd)";
|
|||
}
|
||||
|
||||
TEST_F(ValidateID, OpFunctionParameterGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeInt 32 0
|
||||
%3 = OpTypeFunction %1 %2
|
||||
|
@ -960,7 +960,7 @@ TEST_F(ValidateID, OpFunctionParameterGood) {
|
|||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpFunctionParameterResultTypeBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeInt 32 0
|
||||
%3 = OpTypeFunction %1 %2
|
||||
|
@ -972,7 +972,7 @@ TEST_F(ValidateID, OpFunctionParameterResultTypeBad) {
|
|||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
TEST_F(ValidateID, OpFunctionParameterOrderBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeInt 32 0
|
||||
%3 = OpTypeFunction %1 %2
|
||||
|
@ -987,7 +987,7 @@ TEST_F(ValidateID, OpFunctionParameterOrderBad) {
|
|||
}
|
||||
|
||||
TEST_F(ValidateID, OpFunctionCallGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeInt 32 0
|
||||
%3 = OpTypeFunction %2 %2
|
||||
|
@ -1009,7 +1009,7 @@ TEST_F(ValidateID, OpFunctionCallGood) {
|
|||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpFunctionCallResultTypeBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeInt 32 0
|
||||
%3 = OpTypeFunction %2 %2
|
||||
|
@ -1031,7 +1031,7 @@ TEST_F(ValidateID, OpFunctionCallResultTypeBad) {
|
|||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
TEST_F(ValidateID, OpFunctionCallFunctionBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeInt 32 0
|
||||
%3 = OpTypeFunction %2 %2
|
||||
|
@ -1046,7 +1046,7 @@ TEST_F(ValidateID, OpFunctionCallFunctionBad) {
|
|||
CHECK(spirv, SPV_ERROR_INVALID_ID);
|
||||
}
|
||||
TEST_F(ValidateID, OpFunctionCallArgumentTypeBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeInt 32 0
|
||||
%3 = OpTypeFunction %2 %2
|
||||
|
@ -1227,7 +1227,7 @@ TEST_F(ValidateID, OpFunctionCallArgumentCountBar) {
|
|||
// TODO: OpSwitch
|
||||
|
||||
TEST_F(ValidateID, OpReturnValueConstantGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeInt 32 0
|
||||
%3 = OpTypeFunction %2 %2
|
||||
|
@ -1239,7 +1239,7 @@ TEST_F(ValidateID, OpReturnValueConstantGood) {
|
|||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpReturnValueVariableGood) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeInt 32 0 ;10
|
||||
%3 = OpTypeFunction %2 %2 ;14
|
||||
|
@ -1253,7 +1253,7 @@ TEST_F(ValidateID, OpReturnValueVariableGood) {
|
|||
CHECK(spirv, SPV_SUCCESS);
|
||||
}
|
||||
TEST_F(ValidateID, OpReturnValueBad) {
|
||||
const char *spirv = R"(
|
||||
const char* spirv = R"(
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeInt 32 0
|
||||
%3 = OpTypeFunction %2 %2
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int main(int argc, char** argv) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <string.h>
|
||||
#include <vector>
|
||||
|
||||
void print_usage(char *argv0) {
|
||||
void print_usage(char* argv0) {
|
||||
printf(
|
||||
"Assemble a *.svasm file into a *.sv binary.\n\n"
|
||||
"USAGE: %s [options] <filename>\n\n"
|
||||
|
@ -40,23 +40,23 @@ void print_usage(char *argv0) {
|
|||
argv0);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int main(int argc, char** argv) {
|
||||
if (2 > argc) {
|
||||
print_usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char *inFile = nullptr;
|
||||
const char *outFile = nullptr;
|
||||
const char* inFile = nullptr;
|
||||
const char* outFile = nullptr;
|
||||
|
||||
const char *assembly_format_prefix = "--assembly-format=";
|
||||
const char* assembly_format_prefix = "--assembly-format=";
|
||||
spv_assembly_syntax_format_t format = SPV_ASSEMBLY_SYNTAX_FORMAT_DEFAULT;
|
||||
|
||||
for (int argi = 1; argi < argc; ++argi) {
|
||||
if ('-' == argv[argi][0]) {
|
||||
if (!strncmp(assembly_format_prefix, argv[argi],
|
||||
strlen(assembly_format_prefix))) {
|
||||
const char *parameter = argv[argi] + strlen(assembly_format_prefix);
|
||||
const char* parameter = argv[argi] + strlen(assembly_format_prefix);
|
||||
if (!strcmp("canonical", parameter)) {
|
||||
format = SPV_ASSEMBLY_SYNTAX_FORMAT_CANONICAL;
|
||||
} else if (!strcmp("assignment", parameter)) {
|
||||
|
@ -100,7 +100,7 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
std::vector<char> contents;
|
||||
if (FILE *fp = fopen(inFile, "r")) {
|
||||
if (FILE* fp = fopen(inFile, "r")) {
|
||||
char buf[1024];
|
||||
while (size_t len = fread(buf, 1, sizeof(buf), fp))
|
||||
contents.insert(contents.end(), buf, buf + len);
|
||||
|
@ -139,7 +139,7 @@ int main(int argc, char **argv) {
|
|||
return error;
|
||||
}
|
||||
|
||||
if (FILE *fp = fopen(outFile, "wb")) {
|
||||
if (FILE* fp = fopen(outFile, "wb")) {
|
||||
size_t written =
|
||||
fwrite(binary->code, sizeof(uint32_t), (size_t)binary->wordCount, fp);
|
||||
if (binary->wordCount != written) {
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <string.h>
|
||||
#include <vector>
|
||||
|
||||
void print_usage(char *argv0) {
|
||||
void print_usage(char* argv0) {
|
||||
printf(
|
||||
"Dissassemble a *.sv file into a *.svasm text file.\n\n"
|
||||
"USAGE: %s [options] <filename>\n\n"
|
||||
|
@ -43,24 +43,24 @@ void print_usage(char *argv0) {
|
|||
argv0);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int main(int argc, char** argv) {
|
||||
if (2 > argc) {
|
||||
print_usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint32_t options = SPV_BINARY_TO_TEXT_OPTION_NONE;
|
||||
const char *inFile = nullptr;
|
||||
const char *outFile = nullptr;
|
||||
const char* inFile = nullptr;
|
||||
const char* outFile = nullptr;
|
||||
|
||||
const char *assembly_format_prefix = "--assembly-format=";
|
||||
const char* assembly_format_prefix = "--assembly-format=";
|
||||
spv_assembly_syntax_format_t format = SPV_ASSEMBLY_SYNTAX_FORMAT_DEFAULT;
|
||||
|
||||
for (int argi = 1; argi < argc; ++argi) {
|
||||
if ('-' == argv[argi][0]) {
|
||||
if (!strncmp(assembly_format_prefix, argv[argi],
|
||||
strlen(assembly_format_prefix))) {
|
||||
const char *parameter = argv[argi] + strlen(assembly_format_prefix);
|
||||
const char* parameter = argv[argi] + strlen(assembly_format_prefix);
|
||||
if (!strcmp("canonical", parameter)) {
|
||||
format = SPV_ASSEMBLY_SYNTAX_FORMAT_CANONICAL;
|
||||
} else if (!strcmp("assignment", parameter)) {
|
||||
|
@ -110,7 +110,7 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
std::vector<uint32_t> contents;
|
||||
if (FILE *fp = fopen(inFile, "rb")) {
|
||||
if (FILE* fp = fopen(inFile, "rb")) {
|
||||
uint32_t buf[1024];
|
||||
while (size_t len = fread(buf, sizeof(uint32_t), 1024, fp)) {
|
||||
contents.insert(contents.end(), buf, buf + len);
|
||||
|
@ -149,7 +149,7 @@ int main(int argc, char **argv) {
|
|||
const bool printOptionOn =
|
||||
spvIsInBitfield(SPV_BINARY_TO_TEXT_OPTION_PRINT, options);
|
||||
spv_text text;
|
||||
spv_text *textOrNull = printOptionOn ? nullptr : &text;
|
||||
spv_text* textOrNull = printOptionOn ? nullptr : &text;
|
||||
spv_diagnostic diagnostic = nullptr;
|
||||
error = spvBinaryToTextWithFormat(contents.data(), contents.size(), options,
|
||||
opcodeTable, operandTable, extInstTable,
|
||||
|
@ -162,7 +162,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
// Output the result.
|
||||
if (!printOptionOn) {
|
||||
if (FILE *fp = fopen(outFile, "w")) {
|
||||
if (FILE* fp = fopen(outFile, "w")) {
|
||||
size_t written =
|
||||
fwrite(text->str, sizeof(char), (size_t)text->length, fp);
|
||||
if (text->length != written) {
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
void print_usage(char *argv0) {
|
||||
void print_usage(char* argv0) {
|
||||
printf(
|
||||
"Validate a SPIR-V binary file.\n\n"
|
||||
"USAGE: %s [options] <filename>\n\n"
|
||||
|
@ -45,13 +45,13 @@ void print_usage(char *argv0) {
|
|||
argv0);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int main(int argc, char** argv) {
|
||||
if (2 > argc) {
|
||||
print_usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char *inFile = nullptr;
|
||||
const char* inFile = nullptr;
|
||||
uint32_t options = 0;
|
||||
|
||||
for (int argi = 1; argi < argc; ++argi) {
|
||||
|
@ -84,7 +84,7 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
std::vector<uint32_t> contents;
|
||||
if (FILE *fp = fopen(inFile, "rb")) {
|
||||
if (FILE* fp = fopen(inFile, "rb")) {
|
||||
uint32_t buf[1024];
|
||||
while (size_t len = fread(buf, sizeof(uint32_t),
|
||||
sizeof(buf) / sizeof(uint32_t), fp)) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче