summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorLei Zhang <antiagainst@google.com>2015-11-02 09:41:20 -0500
committerDavid Neto <dneto@google.com>2015-11-10 15:56:47 -0500
commit1a0334edee58912afa5bba8796540cdc528fba79 (patch)
tree7d87ad10c1a45c204ef730d896d6027086999d12 /source
parent0170752763493e056423c8369de02f8e5b6f7ab2 (diff)
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 {} \;
Diffstat (limited to 'source')
-rw-r--r--source/assembly_grammar.cpp32
-rw-r--r--source/assembly_grammar.h20
-rw-r--r--source/binary.cpp50
-rw-r--r--source/binary.h6
-rw-r--r--source/diagnostic.cpp4
-rw-r--r--source/diagnostic.h14
-rw-r--r--source/endian.cpp2
-rw-r--r--source/endian.h2
-rw-r--r--source/ext_inst.cpp25
-rw-r--r--source/ext_inst.h8
-rw-r--r--source/opcode.cpp183
-rw-r--r--source/opcode.h24
-rw-r--r--source/operand.cpp258
-rw-r--r--source/print.cpp24
-rw-r--r--source/print.h18
-rw-r--r--source/text.h3
-rw-r--r--source/text_handler.cpp42
-rw-r--r--source/text_handler.h61
-rw-r--r--source/validate.cpp26
-rw-r--r--source/validate.h14
-rw-r--r--source/validate_id.cpp124
21 files changed, 419 insertions, 521 deletions
diff --git a/source/assembly_grammar.cpp b/source/assembly_grammar.cpp
index de336591..bc16261c 100644
--- a/source/assembly_grammar.cpp
+++ b/source/assembly_grammar.cpp
@@ -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
diff --git a/source/assembly_grammar.h b/source/assembly_grammar.h
index 10a16582..78a501f0 100644
--- a/source/assembly_grammar.h
+++ b/source/assembly_grammar.h
@@ -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_;
diff --git a/source/binary.cpp b/source/binary.cpp
index 70b62d8c..edce883a 100644
--- a/source/binary.cpp
+++ b/source/binary.cpp
@@ -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();
diff --git a/source/binary.h b/source/binary.h
index 904dad7e..dbffbe4d 100644
--- a/source/binary.h
+++ b/source/binary.h
@@ -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_
diff --git a/source/diagnostic.cpp b/source/diagnostic.cpp
index 94f5799c..7c55bb2b 100644
--- a/source/diagnostic.cpp
+++ b/source/diagnostic.cpp
@@ -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());
}
}
-
diff --git a/source/diagnostic.h b/source/diagnostic.h
index 07bfde65..67b6c96d 100644
--- a/source/diagnostic.h
+++ b/source/diagnostic.h
@@ -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_;
};
diff --git a/source/endian.cpp b/source/endian.cpp
index 240718a5..44d9ac61 100644
--- a/source/endian.cpp
+++ b/source/endian.cpp
@@ -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;
diff --git a/source/endian.h b/source/endian.h
index 50453879..e03eeb2a 100644
--- a/source/endian.h
+++ b/source/endian.h
@@ -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_
diff --git a/source/ext_inst.cpp b/source/ext_inst.cpp
index 5eaf1f68..6d018a52 100644
--- a/source/ext_inst.cpp
+++ b/source/ext_inst.cpp
@@ -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;
diff --git a/source/ext_inst.h b/source/ext_inst.h
index 80f65c22..d1beb9ee 100644
--- a/source/ext_inst.h
+++ b/source/ext_inst.h
@@ -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_
diff --git a/source/opcode.cpp b/source/opcode.cpp
index 74f0b428..60f1ceb6 100644
--- a/source/opcode.cpp
+++ b/source/opcode.cpp
@@ -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:
diff --git a/source/opcode.h b/source/opcode.h
index b4abbc0c..2fd7a58a 100644
--- a/source/opcode.h
+++ b/source/opcode.h
@@ -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
///
diff --git a/source/operand.cpp b/source/operand.cpp
index 8e7bea84..ccbedd21 100644
--- a/source/operand.cpp
+++ b/source/operand.cpp
@@ -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),
diff --git a/source/print.cpp b/source/print.cpp
index 6ee3b01d..455f2db3 100644
--- a/source/print.cpp
+++ b/source/print.cpp
@@ -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);
diff --git a/source/print.h b/source/print.h
index e68cc43c..c96acc6b 100644
--- a/source/print.h
+++ b/source/print.h
@@ -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*();
};
}
diff --git a/source/text.h b/source/text.h
index b89444f0..9b0c978b 100644
--- a/source/text.h
+++ b/source/text.h
@@ -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_
diff --git a/source/text_handler.cpp b/source/text_handler.cpp
index 2caa2a5e..34b48f15 100644
--- a/source/text_handler.cpp
+++ b/source/text_handler.cpp
@@ -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_, &current_position_);
}
-spv_result_t AssemblyContext::getWord(std::string &word,
+spv_result_t AssemblyContext::getWord(std::string& word,
spv_position endPosition) {
return ::getWord(text_, &current_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
diff --git a/source/text_handler.h b/source/text_handler.h
index e73c4573..9c29f360 100644
--- a/source/text_handler.h
+++ b/source/text_handler.h
@@ -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_;
};
diff --git a/source/validate.cpp b/source/validate.cpp
index 53ea612a..c8de619a 100644
--- a/source/validate.cpp
+++ b/source/validate.cpp
@@ -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;
diff --git a/source/validate.h b/source/validate.h
index 51e41cf5..0c0c933f 100644
--- a/source/validate.h
+++ b/source/validate.h
@@ -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_
diff --git a/source/validate_id.cpp b/source/validate_id.cpp
index f369adc2..573f8e6b 100644
--- a/source/validate_id.cpp
+++ b/source/validate_id.cpp
@@ -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) {