return SPV_OPERAND_TYPE_NONE;
}
-} // anonymous namespace
+} // anonymous namespace
// 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)
// Result ID always comes next, if present
if (opcode.hasResult)
opcode.operandTypes[opcode.numTypes++] = SPV_OPERAND_TYPE_RESULT_ID;
- const uint16_t maxNumOperands = sizeof(opcode.operandTypes)/sizeof(opcode.operandTypes[0]);
- const uint16_t maxNumClasses = sizeof(opcode.operandClass)/sizeof(opcode.operandClass[0]);
- for (uint16_t classIndex = 0; opcode.numTypes < maxNumOperands && classIndex < maxNumClasses ; classIndex++ ) {
+ const uint16_t maxNumOperands =
+ sizeof(opcode.operandTypes) / sizeof(opcode.operandTypes[0]);
+ const uint16_t maxNumClasses =
+ sizeof(opcode.operandClass) / sizeof(opcode.operandClass[0]);
+ for (uint16_t classIndex = 0;
+ opcode.numTypes < maxNumOperands && classIndex < maxNumClasses;
+ classIndex++) {
const OperandClass operandClass = opcode.operandClass[classIndex];
- opcode.operandTypes[opcode.numTypes++] = convertOperandClassToType(opcode.opcode, operandClass);
+ opcode.operandTypes[opcode.numTypes++] =
+ convertOperandClassToType(opcode.opcode, operandClass);
// The OperandNone value is not explicitly represented in the .inc file.
// However, it is the zero value, and is created via implicit value
// initialization.
}
// We should have written the terminating SPV_OPERAND_TYPE_NONE entry, but
// also without overflowing.
- assert((opcode.numTypes < maxNumOperands)
- && "Operand class list is too long. Expand spv_opcode_desc_t.operandClass");
+ assert((opcode.numTypes < maxNumOperands) &&
+ "Operand class list is too long. Expand "
+ "spv_opcode_desc_t.operandClass");
}
opcodeTableInitialized = true;
}
///
/// @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
///
///
/// @return result code
spv_result_t spvOpcodeTableValueLookup(const spv_opcode_table table,
- const Op opcode, spv_opcode_desc *pEntry);
+ const Op opcode,
+ spv_opcode_desc *pEntry);
/// @brief Get the argument index for the <result-id> operand, if any.
///
/// @param[in] str the source string
///
/// @return word as a string
-std::string spvGetWord(const char* str);
+std::string spvGetWord(const char *str);
/// @brief Advance text to the start of the next line
///
const spv_operand_type_t type, const char *textValue,
const spv_operand_table operandTable, const spv_ext_inst_table extInstTable,
spv_named_id_table namedIdTable, spv_instruction_t *pInst,
- spv_operand_pattern_t* pExpectedOperands, uint32_t *pBound,
+ spv_operand_pattern_t *pExpectedOperands, uint32_t *pBound,
const spv_position_t *pPosition, spv_diagnostic *pDiagnostic);
/// @brief Translate single Opcode and operands to binary form
return idUses.end() != item;
}
bool foundUses(std::unordered_map<
- uint32_t, std::vector<spv_id_info_t>>::const_iterator item) {
+ uint32_t, std::vector<spv_id_info_t>>::const_iterator item) {
return idUses.end() != item;
}
// TODO: Output ID's on diagnostic
DIAG(inst->wordCount - 1)
<< "OpConstantComposite Constituent <id> count does not match "
- "Result Type <id> '" << resultType->second.id
- << "'s vector component count.";
+ "Result Type <id> '"
+ << resultType->second.id << "'s vector component count.";
return false);
auto componentType = find(resultType->second.inst->words[2]);
spvCheck(!found(componentType), assert(0 && "Unreachable!"));
// TODO: Output ID's on diagnostic
DIAG(inst->wordCount - 1)
<< "OpConstantComposite Constituent <id> count does not match "
- "Result Type <id> '" << resultType->second.id
- << "'s matrix column count.";
+ "Result Type <id> '"
+ << resultType->second.id << "'s matrix column count.";
return false);
auto columnType = find(resultType->second.inst->words[2]);
spvCheck(length->second.inst->words[3] != constituentCount,
DIAG(inst->wordCount - 1)
<< "OpConstantComposite Constituent count does not match "
- "Result Type <id> '" << resultType->second.id
- << "'s array length.";
+ "Result Type <id> '"
+ << resultType->second.id << "'s array length.";
return false);
for (uint64_t constituentIndex = 3; constituentIndex < inst->wordCount;
constituentIndex++) {
#undef FAIL
#undef CASE
}
-}//anonymous namespace
+} // anonymous namespace
spv_result_t spvValidateInstructionIDs(
const spv_instruction_t *pInsts, const uint64_t instCount,
spv_binary_t binary = {nullptr, 42};
spv_text text;
spv_diagnostic diagnostic = nullptr;
- ASSERT_EQ(SPV_ERROR_INVALID_BINARY,
- spvBinaryToText(nullptr, 42,
- SPV_BINARY_TO_TEXT_OPTION_NONE, opcodeTable,
- operandTable, extInstTable, &text, &diagnostic));
+ ASSERT_EQ(
+ SPV_ERROR_INVALID_BINARY,
+ spvBinaryToText(nullptr, 42, SPV_BINARY_TO_TEXT_OPTION_NONE, opcodeTable,
+ operandTable, extInstTable, &text, &diagnostic));
if (diagnostic) {
spvDiagnosticPrint(diagnostic);
spvDiagnosticDestroy(diagnostic);
(Op)0,
SPV_OPCODE_FLAGS_CAPABILITIES,
GetParam(),
- 0, {}, false, false, {}}) {}
+ 0,
+ {},
+ false,
+ false,
+ {}}) {}
virtual void SetUp() {}
CapabilityLinkage, CapabilityKernel));
TEST(OpcodeRequiresCapability, None) {
- spv_opcode_desc_t entry = {nullptr, (Op)0, SPV_OPCODE_FLAGS_NONE, 0, 0, {}, false, false, {}};
+ spv_opcode_desc_t entry = {
+ nullptr, (Op)0, SPV_OPCODE_FLAGS_NONE, 0, 0, {}, false, false, {}};
ASSERT_EQ(0, spvOpcodeRequiresCapabilities(&entry));
}
namespace {
-#define TAB "\t"
-#define NEWLINE "\n"
+#define TAB "\t"
+#define NEWLINE "\n"
#define BACKSLASH R"(\)"
-#define QUOTE R"(")"
+#define QUOTE R"(")"
TEST(TextWordGet, NullTerminator) {
char textStr[] = "Word";
#ifdef __ANDROID__
#include <sstream>
namespace std {
-template<typename T>
+template <typename T>
std::string to_string(const T& val) {
std::ostringstream os;
os << val;
uint32_t value;
} o32_host_order = {{0, 1, 2, 3}};
-
// A namespace for utilities used in SPIR-V Tools unit tests.
// TODO(dneto): Move other type declarations into this namespace.
namespace spvtest {
inline void PrintTo(const WordVector& words, ::std::ostream* os) {
size_t count = 0;
for (uint32_t value : words.value()) {
- *os << "0x" << std::setw(8) << std::setfill('0') << std::hex << value << " ";
+ *os << "0x" << std::setw(8) << std::setfill('0') << std::hex << value
+ << " ";
if (count++ % 8 == 7) {
*os << std::endl;
}
// Returns a vector of words representing a single instruction with the
// given opcode and operand words as a vector.
-inline std::vector<uint32_t> MakeInstruction(
- spv::Op opcode, std::vector<uint32_t> args) {
+inline std::vector<uint32_t> MakeInstruction(spv::Op opcode,
+ std::vector<uint32_t> args) {
std::vector<uint32_t> result{
spvOpcodeMake(uint16_t(args.size() + 1), opcode)};
result.insert(result.end(), args.begin(), args.end());
}
}
// Emit a trailing partial word.
- if ((num_bytes+1) % sizeof(uint32_t)) {
+ if ((num_bytes + 1) % sizeof(uint32_t)) {
result.push_back(word);
}
return result;
}
-} // namespace spvtest
+} // namespace spvtest
// A type for easily creating spv_text_t values, with an implicit conversion to
// spv_text.
OpFunctionEnd
)";
spv_diagnostic diagnostic = nullptr;
- ASSERT_EQ(SPV_SUCCESS, spvTextToBinary(str, strlen(str), opcodeTable, operandTable,
- extInstTable, &binary, &diagnostic));
+ ASSERT_EQ(SPV_SUCCESS,
+ spvTextToBinary(str, strlen(str), opcodeTable, operandTable,
+ extInstTable, &binary, &diagnostic));
ASSERT_EQ(SPV_ERROR_INVALID_ID,
spvValidate(binary, opcodeTable, operandTable, extInstTable,
SPV_VALIDATE_ALL, &diagnostic));