Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/KhronosGroup/SPIRV-Tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoralan-baker <alanbaker@google.com>2022-11-05 00:27:10 +0300
committerGitHub <noreply@github.com>2022-11-05 00:27:10 +0300
commitd35a78db57e6c0bca4b284369d12e96292e2dfd5 (patch)
treeee67caa5f3397c0dfced6bedb667c51c82b8223e /test
parentc8e1588cfa3ff9e3b5d600ef04f4261c4e68af90 (diff)
Switch SPIRV-Tools to use spirv.hpp11 internally (#4981)
Fixes #4960 * Switches to using enum classes with an underlying type to avoid undefined behaviour
Diffstat (limited to 'test')
-rw-r--r--test/binary_header_get_test.cpp6
-rw-r--r--test/binary_parse_test.cpp198
-rw-r--r--test/binary_to_text_test.cpp22
-rw-r--r--test/comment_test.cpp8
-rw-r--r--test/cpp_interface_test.cpp12
-rw-r--r--test/diff/diff_test.cpp4
-rw-r--r--test/enum_set_test.cpp99
-rw-r--r--test/enum_string_mapping_test.cpp173
-rw-r--r--test/ext_inst.cldebug100_test.cpp36
-rw-r--r--test/ext_inst.debuginfo_test.cpp25
-rw-r--r--test/ext_inst.opencl_test.cpp14
-rw-r--r--test/fuzz/available_instructions_test.cpp64
-rw-r--r--test/fuzz/data_synonym_transformation_test.cpp64
-rw-r--r--test/fuzz/fact_manager/constant_uniform_facts_test.cpp20
-rw-r--r--test/fuzz/fact_manager/data_synonym_and_id_equation_facts_test.cpp96
-rw-r--r--test/fuzz/fuzzer_pass_donate_modules_test.cpp10
-rw-r--r--test/fuzz/fuzzerutil_test.cpp258
-rw-r--r--test/fuzz/replayer_test.cpp11
-rw-r--r--test/fuzz/shrinker_test.cpp26
-rw-r--r--test/fuzz/transformation_access_chain_test.cpp169
-rw-r--r--test/fuzz/transformation_add_constant_boolean_test.cpp3
-rw-r--r--test/fuzz/transformation_add_constant_composite_test.cpp2
-rw-r--r--test/fuzz/transformation_add_constant_null_test.cpp2
-rw-r--r--test/fuzz/transformation_add_constant_scalar_test.cpp3
-rw-r--r--test/fuzz/transformation_add_copy_memory_test.cpp92
-rw-r--r--test/fuzz/transformation_add_early_terminator_wrapper_test.cpp32
-rw-r--r--test/fuzz/transformation_add_function_test.cpp554
-rw-r--r--test/fuzz/transformation_add_global_undef_test.cpp3
-rw-r--r--test/fuzz/transformation_add_global_variable_test.cpp93
-rw-r--r--test/fuzz/transformation_add_image_sample_unused_components_test.cpp24
-rw-r--r--test/fuzz/transformation_add_local_variable_test.cpp3
-rw-r--r--test/fuzz/transformation_add_opphi_synonym_test.cpp4
-rw-r--r--test/fuzz/transformation_add_synonym_test.cpp163
-rw-r--r--test/fuzz/transformation_add_type_array_test.cpp4
-rw-r--r--test/fuzz/transformation_add_type_boolean_test.cpp3
-rw-r--r--test/fuzz/transformation_add_type_float_test.cpp11
-rw-r--r--test/fuzz/transformation_add_type_int_test.cpp7
-rw-r--r--test/fuzz/transformation_add_type_matrix_test.cpp2
-rw-r--r--test/fuzz/transformation_add_type_pointer_test.cpp24
-rw-r--r--test/fuzz/transformation_add_type_struct_test.cpp2
-rw-r--r--test/fuzz/transformation_add_type_vector_test.cpp2
-rw-r--r--test/fuzz/transformation_adjust_branch_weights_test.cpp20
-rw-r--r--test/fuzz/transformation_composite_construct_test.cpp137
-rw-r--r--test/fuzz/transformation_composite_extract_test.cpp114
-rw-r--r--test/fuzz/transformation_composite_insert_test.cpp65
-rw-r--r--test/fuzz/transformation_equation_instruction_test.cpp350
-rw-r--r--test/fuzz/transformation_flatten_conditional_branch_test.cpp87
-rw-r--r--test/fuzz/transformation_function_call_test.cpp127
-rw-r--r--test/fuzz/transformation_load_test.cpp193
-rw-r--r--test/fuzz/transformation_merge_function_returns_test.cpp2
-rw-r--r--test/fuzz/transformation_move_instruction_down_test.cpp127
-rw-r--r--test/fuzz/transformation_mutate_pointer_test.cpp22
-rw-r--r--test/fuzz/transformation_permute_phi_operands_test.cpp4
-rw-r--r--test/fuzz/transformation_propagate_instruction_down_test.cpp6
-rw-r--r--test/fuzz/transformation_propagate_instruction_up_test.cpp4
-rw-r--r--test/fuzz/transformation_push_id_through_variable_test.cpp102
-rw-r--r--test/fuzz/transformation_replace_boolean_constant_with_constant_binary_test.cpp99
-rw-r--r--test/fuzz/transformation_replace_branch_from_dead_block_with_exit_test.cpp72
-rw-r--r--test/fuzz/transformation_replace_constant_with_uniform_test.cpp114
-rw-r--r--test/fuzz/transformation_replace_copy_memory_with_load_store_test.cpp6
-rw-r--r--test/fuzz/transformation_replace_copy_object_with_store_load_test.cpp23
-rw-r--r--test/fuzz/transformation_replace_id_with_synonym_test.cpp178
-rw-r--r--test/fuzz/transformation_replace_irrelevant_id_test.cpp23
-rw-r--r--test/fuzz/transformation_replace_linear_algebra_instruction_test.cpp86
-rw-r--r--test/fuzz/transformation_replace_load_store_with_copy_memory_test.cpp22
-rw-r--r--test/fuzz/transformation_set_function_control_test.cpp21
-rw-r--r--test/fuzz/transformation_set_loop_control_test.cpp668
-rw-r--r--test/fuzz/transformation_set_memory_operands_mask_test.cpp136
-rw-r--r--test/fuzz/transformation_set_selection_control_test.cpp26
-rw-r--r--test/fuzz/transformation_split_block_test.cpp92
-rw-r--r--test/fuzz/transformation_store_test.cpp241
-rw-r--r--test/fuzz/transformation_swap_commutable_operands_test.cpp64
-rw-r--r--test/fuzz/transformation_swap_conditional_branch_operands_test.cpp18
-rw-r--r--test/fuzz/transformation_toggle_access_chain_instruction_test.cpp46
-rw-r--r--test/fuzz/transformation_vector_shuffle_test.cpp159
-rw-r--r--test/fuzz/transformation_wrap_early_terminator_in_function_test.cpp43
-rw-r--r--test/immediate_int_test.cpp42
-rw-r--r--test/link/binary_version_test.cpp12
-rw-r--r--test/link/global_values_amount_test.cpp53
-rw-r--r--test/link/ids_limit_test.cpp36
-rw-r--r--test/link/memory_model_test.cpp6
-rw-r--r--test/opcode_make_test.cpp2
-rw-r--r--test/opcode_require_capabilities_test.cpp51
-rw-r--r--test/opcode_split_test.cpp2
-rw-r--r--test/operand_capabilities_test.cpp797
-rw-r--r--test/operand_pattern_test.cpp7
-rw-r--r--test/opt/analyze_live_input_test.cpp8
-rw-r--r--test/opt/dataflow.cpp2
-rw-r--r--test/opt/debug_info_manager_test.cpp4
-rw-r--r--test/opt/decoration_manager_test.cpp143
-rw-r--r--test/opt/def_use_test.cpp35
-rw-r--r--test/opt/eliminate_dead_output_stores_test.cpp12
-rw-r--r--test/opt/feature_manager_test.cpp23
-rw-r--r--test/opt/fold_test.cpp42
-rw-r--r--test/opt/function_test.cpp4
-rw-r--r--test/opt/inline_test.cpp2
-rw-r--r--test/opt/instruction_test.cpp37
-rw-r--r--test/opt/ir_builder.cpp4
-rw-r--r--test/opt/ir_context_test.cpp14
-rw-r--r--test/opt/ir_loader_test.cpp32
-rw-r--r--test/opt/loop_optimizations/dependence_analysis.cpp70
-rw-r--r--test/opt/loop_optimizations/dependence_analysis_helpers.cpp28
-rw-r--r--test/opt/loop_optimizations/peeling.cpp8
-rw-r--r--test/opt/loop_optimizations/peeling_pass.cpp172
-rw-r--r--test/opt/module_test.cpp2
-rw-r--r--test/opt/pass_manager_test.cpp4
-rw-r--r--test/opt/pass_remove_duplicates_test.cpp2
-rw-r--r--test/opt/propagator_test.cpp10
-rw-r--r--test/opt/scalar_analysis.cpp24
-rw-r--r--test/opt/type_manager_test.cpp52
-rw-r--r--test/opt/types_test.cpp60
-rw-r--r--test/reduce/reducer_test.cpp8
-rw-r--r--test/reduce/validation_during_reduction_test.cpp6
-rw-r--r--test/text_to_binary.annotation_test.cpp100
-rw-r--r--test/text_to_binary.barrier_test.cpp16
-rw-r--r--test/text_to_binary.constant_test.cpp262
-rw-r--r--test/text_to_binary.control_flow_test.cpp75
-rw-r--r--test/text_to_binary.debug_test.cpp43
-rw-r--r--test/text_to_binary.device_side_enqueue_test.cpp2
-rw-r--r--test/text_to_binary.extension_test.cpp953
-rw-r--r--test/text_to_binary.function_test.cpp31
-rw-r--r--test/text_to_binary.group_test.cpp12
-rw-r--r--test/text_to_binary.image_test.cpp16
-rw-r--r--test/text_to_binary.memory_test.cpp98
-rw-r--r--test/text_to_binary.misc_test.cpp6
-rw-r--r--test/text_to_binary.mode_setting_test.cpp50
-rw-r--r--test/text_to_binary.pipe_storage_test.cpp32
-rw-r--r--test/text_to_binary.reserved_sampling_test.cpp23
-rw-r--r--test/text_to_binary.subgroup_dispatch_test.cpp24
-rw-r--r--test/text_to_binary.type_declaration_test.cpp72
-rw-r--r--test/text_to_binary_test.cpp15
-rw-r--r--test/unit_spirv.h10
-rw-r--r--test/val/val_cfg_test.cpp408
-rw-r--r--test/val/val_decoration_test.cpp23
-rw-r--r--test/val/val_non_uniform_test.cpp33
-rw-r--r--test/val/val_state_test.cpp65
-rw-r--r--test/val/val_type_unique_test.cpp28
-rw-r--r--test/val/val_validation_state_test.cpp2
138 files changed, 5308 insertions, 4752 deletions
diff --git a/test/binary_header_get_test.cpp b/test/binary_header_get_test.cpp
index f94f0c1a6..aca09b03d 100644
--- a/test/binary_header_get_test.cpp
+++ b/test/binary_header_get_test.cpp
@@ -23,8 +23,8 @@ class BinaryHeaderGet : public ::testing::Test {
BinaryHeaderGet() { memset(code, 0, sizeof(code)); }
virtual void SetUp() {
- code[0] = SpvMagicNumber;
- code[1] = SpvVersion;
+ code[0] = static_cast<uint32_t>(spv::MagicNumber);
+ code[1] = static_cast<uint32_t>(spv::Version);
code[2] = SPV_GENERATOR_CODEPLAY;
code[3] = 1; // NOTE: Bound
code[4] = 0; // NOTE: Schema; reserved
@@ -50,7 +50,7 @@ TEST_F(BinaryHeaderGet, Default) {
spv_header_t header;
ASSERT_EQ(SPV_SUCCESS, spvBinaryHeaderGet(&const_bin, endian, &header));
- ASSERT_EQ(static_cast<uint32_t>(SpvMagicNumber), header.magic);
+ ASSERT_EQ(static_cast<uint32_t>(spv::MagicNumber), header.magic);
// Expect SPIRV-Headers updated to SPIR-V 1.6.
ASSERT_EQ(0x00010600u, header.version);
ASSERT_EQ(static_cast<uint32_t>(SPV_GENERATOR_CODEPLAY), header.generator);
diff --git a/test/binary_parse_test.cpp b/test/binary_parse_test.cpp
index f0810a358..4c699c175 100644
--- a/test/binary_parse_test.cpp
+++ b/test/binary_parse_test.cpp
@@ -54,14 +54,14 @@ using ::testing::Return;
struct ParsedInstruction {
explicit ParsedInstruction(const spv_parsed_instruction_t& inst)
: words(inst.words, inst.words + inst.num_words),
- opcode(static_cast<SpvOp>(inst.opcode)),
+ opcode(static_cast<spv::Op>(inst.opcode)),
ext_inst_type(inst.ext_inst_type),
type_id(inst.type_id),
result_id(inst.result_id),
operands(inst.operands, inst.operands + inst.num_operands) {}
std::vector<uint32_t> words;
- SpvOp opcode;
+ spv::Op opcode;
spv_ext_inst_type_t ext_inst_type;
uint32_t type_id;
uint32_t result_id;
@@ -127,14 +127,14 @@ spv_result_t invoke_instruction(
// The SPIR-V module header words for the Khronos Assembler generator,
// for a module with an ID bound of 1.
const uint32_t kHeaderForBound1[] = {
- SpvMagicNumber, SpvVersion,
+ spv::MagicNumber, spv::Version,
SPV_GENERATOR_WORD(SPV_GENERATOR_KHRONOS_ASSEMBLER, 0), 1 /*bound*/,
0 /*schema*/};
// Returns the expected SPIR-V module header words for the Khronos
// Assembler generator, and with a given Id bound.
std::vector<uint32_t> ExpectedHeaderForBound(uint32_t bound) {
- return {SpvMagicNumber, 0x10000,
+ return {spv::MagicNumber, 0x10000,
SPV_GENERATOR_WORD(SPV_GENERATOR_KHRONOS_ASSEMBLER, 0), bound, 0};
}
@@ -162,13 +162,13 @@ spv_parsed_operand_t MakeLiteralStringOperand(uint16_t offset,
// Returns a ParsedInstruction for an OpTypeVoid instruction that would
// generate the given result Id.
ParsedInstruction MakeParsedVoidTypeInstruction(uint32_t result_id) {
- const auto void_inst = MakeInstruction(SpvOpTypeVoid, {result_id});
+ const auto void_inst = MakeInstruction(spv::Op::OpTypeVoid, {result_id});
const auto void_operands = std::vector<spv_parsed_operand_t>{
MakeSimpleOperand(1, SPV_OPERAND_TYPE_RESULT_ID)};
const spv_parsed_instruction_t parsed_void_inst = {
void_inst.data(),
static_cast<uint16_t>(void_inst.size()),
- SpvOpTypeVoid,
+ uint16_t(spv::Op::OpTypeVoid),
SPV_EXT_INST_TYPE_NONE,
0, // type id
result_id,
@@ -180,14 +180,14 @@ ParsedInstruction MakeParsedVoidTypeInstruction(uint32_t result_id) {
// Returns a ParsedInstruction for an OpTypeInt instruction that generates
// the given result Id for a 32-bit signed integer scalar type.
ParsedInstruction MakeParsedInt32TypeInstruction(uint32_t result_id) {
- const auto i32_inst = MakeInstruction(SpvOpTypeInt, {result_id, 32, 1});
+ const auto i32_inst = MakeInstruction(spv::Op::OpTypeInt, {result_id, 32, 1});
const auto i32_operands = std::vector<spv_parsed_operand_t>{
MakeSimpleOperand(1, SPV_OPERAND_TYPE_RESULT_ID),
MakeLiteralNumberOperand(2), MakeLiteralNumberOperand(3)};
spv_parsed_instruction_t parsed_i32_inst = {
i32_inst.data(),
static_cast<uint16_t>(i32_inst.size()),
- SpvOpTypeInt,
+ uint16_t(spv::Op::OpTypeInt),
SPV_EXT_INST_TYPE_NONE,
0, // type id
result_id,
@@ -216,12 +216,12 @@ class BinaryParseTest : public spvtest::TextToBinaryTestBase<::testing::Test> {
// Adds an EXPECT_CALL to client_->Header() with appropriate parameters,
// including bound. Returns the EXPECT_CALL result.
-#define EXPECT_HEADER(bound) \
- EXPECT_CALL( \
- client_, \
- Header(AnyOf(SPV_ENDIANNESS_LITTLE, SPV_ENDIANNESS_BIG), SpvMagicNumber, \
- 0x10000, SPV_GENERATOR_WORD(SPV_GENERATOR_KHRONOS_ASSEMBLER, 0), \
- bound, 0 /*reserved*/))
+#define EXPECT_HEADER(bound) \
+ EXPECT_CALL(client_, \
+ Header(AnyOf(SPV_ENDIANNESS_LITTLE, SPV_ENDIANNESS_BIG), \
+ spv::MagicNumber, 0x10000, \
+ SPV_GENERATOR_WORD(SPV_GENERATOR_KHRONOS_ASSEMBLER, 0), \
+ bound, 0 /*reserved*/))
static const bool kSwapEndians[] = {false, true};
@@ -481,19 +481,20 @@ TEST_F(BinaryParseTest, InstructionWithStringOperand) {
const std::string str =
"the future is already here, it's just not evenly distributed";
const auto str_words = MakeVector(str);
- const auto instruction = MakeInstruction(SpvOpName, {99}, str_words);
+ const auto instruction = MakeInstruction(spv::Op::OpName, {99}, str_words);
const auto words = Concatenate({ExpectedHeaderForBound(100), instruction});
InSequence calls_expected_in_specific_order;
EXPECT_HEADER(100).WillOnce(Return(SPV_SUCCESS));
const auto operands = std::vector<spv_parsed_operand_t>{
MakeSimpleOperand(1, SPV_OPERAND_TYPE_ID),
MakeLiteralStringOperand(2, static_cast<uint16_t>(str_words.size()))};
- EXPECT_CALL(client_, Instruction(ParsedInstruction(spv_parsed_instruction_t{
- instruction.data(),
- static_cast<uint16_t>(instruction.size()),
- SpvOpName, SPV_EXT_INST_TYPE_NONE, 0 /*type id*/,
- 0 /* No result id for OpName*/, operands.data(),
- static_cast<uint16_t>(operands.size())})))
+ EXPECT_CALL(
+ client_,
+ Instruction(ParsedInstruction(spv_parsed_instruction_t{
+ instruction.data(), static_cast<uint16_t>(instruction.size()),
+ uint16_t(spv::Op::OpName), SPV_EXT_INST_TYPE_NONE, 0 /*type id*/,
+ 0 /* No result id for OpName*/, operands.data(),
+ static_cast<uint16_t>(operands.size())})))
.WillOnce(Return(SPV_SUCCESS));
Parse(words, SPV_SUCCESS, endian_swap);
EXPECT_EQ(nullptr, diagnostic_);
@@ -518,13 +519,13 @@ TEST_F(BinaryParseTest, ExtendedInstruction) {
MakeSimpleOperand(5, SPV_OPERAND_TYPE_ID), // Id of the argument
};
const auto instruction = MakeInstruction(
- SpvOpExtInst,
+ spv::Op::OpExtInst,
{2, 3, 1, static_cast<uint32_t>(OpenCLLIB::Entrypoints::Sqrt), 4});
EXPECT_CALL(client_,
Instruction(ParsedInstruction(spv_parsed_instruction_t{
instruction.data(), static_cast<uint16_t>(instruction.size()),
- SpvOpExtInst, SPV_EXT_INST_TYPE_OPENCL_STD, 2 /*type id*/,
- 3 /*result id*/, operands.data(),
+ uint16_t(spv::Op::OpExtInst), SPV_EXT_INST_TYPE_OPENCL_STD,
+ 2 /*type id*/, 3 /*result id*/, operands.data(),
static_cast<uint16_t>(operands.size())})))
.WillOnce(Return(SPV_SUCCESS));
// Since we are actually checking the output, don't test the
@@ -593,36 +594,38 @@ TEST_P(BinaryParseWordVectorDiagnosticTest, WordVectorCases) {
INSTANTIATE_TEST_SUITE_P(
BinaryParseDiagnostic, BinaryParseWordVectorDiagnosticTest,
::testing::ValuesIn(std::vector<WordVectorDiagnosticCase>{
- {Concatenate({ExpectedHeaderForBound(1), {spvOpcodeMake(0, SpvOpNop)}}),
+ {Concatenate({ExpectedHeaderForBound(1),
+ {spvOpcodeMake(0, spv::Op::OpNop)}}),
"Invalid instruction word count: 0"},
{Concatenate(
{ExpectedHeaderForBound(1),
- {spvOpcodeMake(1, static_cast<SpvOp>(
+ {spvOpcodeMake(1, static_cast<spv::Op>(
std::numeric_limits<uint16_t>::max()))}}),
"Invalid opcode: 65535"},
{Concatenate({ExpectedHeaderForBound(1),
- MakeInstruction(SpvOpNop, {42})}),
+ MakeInstruction(spv::Op::OpNop, {42})}),
"Invalid instruction OpNop starting at word 5: expected "
"no more operands after 1 words, but stated word count is 2."},
// Supply several more unexpected words.
{Concatenate({ExpectedHeaderForBound(1),
- MakeInstruction(SpvOpNop, {42, 43, 44, 45, 46, 47})}),
+ MakeInstruction(spv::Op::OpNop,
+ {42, 43, 44, 45, 46, 47})}),
"Invalid instruction OpNop starting at word 5: expected "
"no more operands after 1 words, but stated word count is 7."},
{Concatenate({ExpectedHeaderForBound(1),
- MakeInstruction(SpvOpTypeVoid, {1, 2})}),
+ MakeInstruction(spv::Op::OpTypeVoid, {1, 2})}),
"Invalid instruction OpTypeVoid starting at word 5: expected "
"no more operands after 2 words, but stated word count is 3."},
{Concatenate({ExpectedHeaderForBound(1),
- MakeInstruction(SpvOpTypeVoid, {1, 2, 5, 9, 10})}),
+ MakeInstruction(spv::Op::OpTypeVoid, {1, 2, 5, 9, 10})}),
"Invalid instruction OpTypeVoid starting at word 5: expected "
"no more operands after 2 words, but stated word count is 6."},
{Concatenate({ExpectedHeaderForBound(1),
- MakeInstruction(SpvOpTypeInt, {1, 32, 1, 9})}),
+ MakeInstruction(spv::Op::OpTypeInt, {1, 32, 1, 9})}),
"Invalid instruction OpTypeInt starting at word 5: expected "
"no more operands after 4 words, but stated word count is 5."},
{Concatenate({ExpectedHeaderForBound(1),
- MakeInstruction(SpvOpTypeInt, {1})}),
+ MakeInstruction(spv::Op::OpTypeInt, {1})}),
"End of input reached while decoding OpTypeInt starting at word 5:"
" expected more operands after 2 words."},
@@ -630,7 +633,7 @@ INSTANTIATE_TEST_SUITE_P(
// Detect a missing single word operand.
{Concatenate({ExpectedHeaderForBound(1),
- {spvOpcodeMake(2, SpvOpTypeStruct)}}),
+ {spvOpcodeMake(2, spv::Op::OpTypeStruct)}}),
"End of input reached while decoding OpTypeStruct starting at word"
" 5: missing result ID operand at word offset 1."},
// Detect this a missing a multi-word operand to OpConstant.
@@ -639,29 +642,29 @@ INSTANTIATE_TEST_SUITE_P(
// %1 = OpTypeInt 64 0
// %2 = OpConstant %1 <missing>
{Concatenate({ExpectedHeaderForBound(3),
- {MakeInstruction(SpvOpTypeInt, {1, 64, 0})},
- {spvOpcodeMake(5, SpvOpConstant), 1, 2}}),
+ {MakeInstruction(spv::Op::OpTypeInt, {1, 64, 0})},
+ {spvOpcodeMake(5, spv::Op::OpConstant), 1, 2}}),
"End of input reached while decoding OpConstant starting at word"
" 9: missing possibly multi-word literal number operand at word "
"offset 3."},
// Detect when we provide only one word from the 64-bit literal,
// and again lie about the number of words in the instruction.
{Concatenate({ExpectedHeaderForBound(3),
- {MakeInstruction(SpvOpTypeInt, {1, 64, 0})},
- {spvOpcodeMake(5, SpvOpConstant), 1, 2, 42}}),
+ {MakeInstruction(spv::Op::OpTypeInt, {1, 64, 0})},
+ {spvOpcodeMake(5, spv::Op::OpConstant), 1, 2, 42}}),
"End of input reached while decoding OpConstant starting at word"
" 9: truncated possibly multi-word literal number operand at word "
"offset 3."},
// Detect when a required string operand is missing.
// Also, lie about the length of the instruction.
{Concatenate({ExpectedHeaderForBound(3),
- {spvOpcodeMake(3, SpvOpString), 1}}),
+ {spvOpcodeMake(3, spv::Op::OpString), 1}}),
"End of input reached while decoding OpString starting at word"
" 5: missing literal string operand at word offset 2."},
// Detect when a required string operand is truncated: it's missing
// a null terminator. Catching the error avoids a buffer overrun.
{Concatenate({ExpectedHeaderForBound(3),
- {spvOpcodeMake(4, SpvOpString), 1, 0x41414141,
+ {spvOpcodeMake(4, spv::Op::OpString), 1, 0x41414141,
0x41414141}}),
"End of input reached while decoding OpString starting at word"
" 5: truncated literal string operand at word offset 2."},
@@ -669,9 +672,9 @@ INSTANTIATE_TEST_SUITE_P(
// a null terminator. Catching the error avoids a buffer overrun.
// (It is valid for an optional string operand to be absent.)
{Concatenate({ExpectedHeaderForBound(3),
- {spvOpcodeMake(6, SpvOpSource),
- static_cast<uint32_t>(SpvSourceLanguageOpenCL_C), 210,
- 1 /* file id */,
+ {spvOpcodeMake(6, spv::Op::OpSource),
+ static_cast<uint32_t>(spv::SourceLanguage::OpenCL_C),
+ 210, 1 /* file id */,
/*start of string*/ 0x41414141, 0x41414141}}),
"End of input reached while decoding OpSource starting at word"
" 5: truncated literal string operand at word offset 4."},
@@ -681,19 +684,19 @@ INSTANTIATE_TEST_SUITE_P(
// In this case the instruction word count is too small, where
// it would truncate a multi-word operand to OpConstant.
{Concatenate({ExpectedHeaderForBound(3),
- {MakeInstruction(SpvOpTypeInt, {1, 64, 0})},
- {spvOpcodeMake(4, SpvOpConstant), 1, 2, 44, 44}}),
+ {MakeInstruction(spv::Op::OpTypeInt, {1, 64, 0})},
+ {spvOpcodeMake(4, spv::Op::OpConstant), 1, 2, 44, 44}}),
"Invalid word count: OpConstant starting at word 9 says it has 4"
" words, but found 5 words instead."},
// Word count is to small, where it would truncate a literal string.
{Concatenate({ExpectedHeaderForBound(2),
- {spvOpcodeMake(3, SpvOpString), 1, 0x41414141, 0}}),
+ {spvOpcodeMake(3, spv::Op::OpString), 1, 0x41414141, 0}}),
"Invalid word count: OpString starting at word 5 says it has 3"
" words, but found 4 words instead."},
// Word count is too large. The string terminates before the last
// word.
{Concatenate({ExpectedHeaderForBound(2),
- {spvOpcodeMake(4, SpvOpString), 1 /* result id */},
+ {spvOpcodeMake(4, spv::Op::OpString), 1 /* result id */},
MakeVector("abc"),
{0 /* this word does not belong*/}}),
"Invalid instruction OpString starting at word 5: expected no more"
@@ -701,111 +704,116 @@ INSTANTIATE_TEST_SUITE_P(
// Word count is too large. There are too many words after the string
// literal. A linkage attribute decoration is the only case in SPIR-V
// where a string operand is followed by another operand.
- {Concatenate({ExpectedHeaderForBound(2),
- {spvOpcodeMake(6, SpvOpDecorate), 1 /* target id */,
- static_cast<uint32_t>(SpvDecorationLinkageAttributes)},
- MakeVector("abc"),
- {static_cast<uint32_t>(SpvLinkageTypeImport),
- 0 /* does not belong */}}),
+ {Concatenate(
+ {ExpectedHeaderForBound(2),
+ {spvOpcodeMake(6, spv::Op::OpDecorate), 1 /* target id */,
+ static_cast<uint32_t>(spv::Decoration::LinkageAttributes)},
+ MakeVector("abc"),
+ {static_cast<uint32_t>(spv::LinkageType::Import),
+ 0 /* does not belong */}}),
"Invalid instruction OpDecorate starting at word 5: expected no more"
" operands after 5 words, but stated word count is 6."},
// Like the previous case, but with 5 extra words.
- {Concatenate({ExpectedHeaderForBound(2),
- {spvOpcodeMake(10, SpvOpDecorate), 1 /* target id */,
- static_cast<uint32_t>(SpvDecorationLinkageAttributes)},
- MakeVector("abc"),
- {static_cast<uint32_t>(SpvLinkageTypeImport),
- /* don't belong */ 0, 1, 2, 3, 4}}),
+ {Concatenate(
+ {ExpectedHeaderForBound(2),
+ {spvOpcodeMake(10, spv::Op::OpDecorate), 1 /* target id */,
+ static_cast<uint32_t>(spv::Decoration::LinkageAttributes)},
+ MakeVector("abc"),
+ {static_cast<uint32_t>(spv::LinkageType::Import),
+ /* don't belong */ 0, 1, 2, 3, 4}}),
"Invalid instruction OpDecorate starting at word 5: expected no more"
" operands after 5 words, but stated word count is 10."},
// Like the previous two cases, but with OpMemberDecorate.
- {Concatenate({ExpectedHeaderForBound(2),
- {spvOpcodeMake(7, SpvOpMemberDecorate), 1 /* target id */,
- 42 /* member index */,
- static_cast<uint32_t>(SpvDecorationLinkageAttributes)},
- MakeVector("abc"),
- {static_cast<uint32_t>(SpvLinkageTypeImport),
- 0 /* does not belong */}}),
+ {Concatenate(
+ {ExpectedHeaderForBound(2),
+ {spvOpcodeMake(7, spv::Op::OpMemberDecorate), 1 /* target id */,
+ 42 /* member index */,
+ static_cast<uint32_t>(spv::Decoration::LinkageAttributes)},
+ MakeVector("abc"),
+ {static_cast<uint32_t>(spv::LinkageType::Import),
+ 0 /* does not belong */}}),
"Invalid instruction OpMemberDecorate starting at word 5: expected no"
" more operands after 6 words, but stated word count is 7."},
- {Concatenate({ExpectedHeaderForBound(2),
- {spvOpcodeMake(11, SpvOpMemberDecorate),
- 1 /* target id */, 42 /* member index */,
- static_cast<uint32_t>(SpvDecorationLinkageAttributes)},
- MakeVector("abc"),
- {static_cast<uint32_t>(SpvLinkageTypeImport),
- /* don't belong */ 0, 1, 2, 3, 4}}),
+ {Concatenate(
+ {ExpectedHeaderForBound(2),
+ {spvOpcodeMake(11, spv::Op::OpMemberDecorate), 1 /* target id */,
+ 42 /* member index */,
+ static_cast<uint32_t>(spv::Decoration::LinkageAttributes)},
+ MakeVector("abc"),
+ {static_cast<uint32_t>(spv::LinkageType::Import),
+ /* don't belong */ 0, 1, 2, 3, 4}}),
"Invalid instruction OpMemberDecorate starting at word 5: expected no"
" more operands after 6 words, but stated word count is 11."},
// Word count is too large. There should be no more words
// after the RelaxedPrecision decoration.
{Concatenate({ExpectedHeaderForBound(2),
- {spvOpcodeMake(4, SpvOpDecorate), 1 /* target id */,
- static_cast<uint32_t>(SpvDecorationRelaxedPrecision),
+ {spvOpcodeMake(4, spv::Op::OpDecorate), 1 /* target id */,
+ static_cast<uint32_t>(spv::Decoration::RelaxedPrecision),
0 /* does not belong */}}),
"Invalid instruction OpDecorate starting at word 5: expected no"
" more operands after 3 words, but stated word count is 4."},
// Word count is too large. There should be only one word after
// the SpecId decoration enum word.
{Concatenate({ExpectedHeaderForBound(2),
- {spvOpcodeMake(5, SpvOpDecorate), 1 /* target id */,
- static_cast<uint32_t>(SpvDecorationSpecId),
+ {spvOpcodeMake(5, spv::Op::OpDecorate), 1 /* target id */,
+ static_cast<uint32_t>(spv::Decoration::SpecId),
42 /* the spec id */, 0 /* does not belong */}}),
"Invalid instruction OpDecorate starting at word 5: expected no"
" more operands after 4 words, but stated word count is 5."},
{Concatenate({ExpectedHeaderForBound(2),
- {spvOpcodeMake(2, SpvOpTypeVoid), 0}}),
+ {spvOpcodeMake(2, spv::Op::OpTypeVoid), 0}}),
"Error: Result Id is 0"},
{Concatenate({
ExpectedHeaderForBound(2),
- {spvOpcodeMake(2, SpvOpTypeVoid), 1},
- {spvOpcodeMake(2, SpvOpTypeBool), 1},
+ {spvOpcodeMake(2, spv::Op::OpTypeVoid), 1},
+ {spvOpcodeMake(2, spv::Op::OpTypeBool), 1},
}),
"Id 1 is defined more than once"},
{Concatenate({ExpectedHeaderForBound(3),
- MakeInstruction(SpvOpExtInst, {2, 3, 100, 4, 5})}),
+ MakeInstruction(spv::Op::OpExtInst, {2, 3, 100, 4, 5})}),
"OpExtInst set Id 100 does not reference an OpExtInstImport result "
"Id"},
{Concatenate({ExpectedHeaderForBound(101),
- MakeInstruction(SpvOpExtInstImport, {100},
+ MakeInstruction(spv::Op::OpExtInstImport, {100},
MakeVector("OpenCL.std")),
// OpenCL cos is #14
- MakeInstruction(SpvOpExtInst, {2, 3, 100, 14, 5, 999})}),
+ MakeInstruction(spv::Op::OpExtInst,
+ {2, 3, 100, 14, 5, 999})}),
"Invalid instruction OpExtInst starting at word 10: expected no "
"more operands after 6 words, but stated word count is 7."},
// In this case, the OpSwitch selector refers to an invalid ID.
{Concatenate({ExpectedHeaderForBound(3),
- MakeInstruction(SpvOpSwitch, {1, 2, 42, 3})}),
+ MakeInstruction(spv::Op::OpSwitch, {1, 2, 42, 3})}),
"Invalid OpSwitch: selector id 1 has no type"},
// In this case, the OpSwitch selector refers to an ID that has
// no type.
{Concatenate({ExpectedHeaderForBound(3),
- MakeInstruction(SpvOpLabel, {1}),
- MakeInstruction(SpvOpSwitch, {1, 2, 42, 3})}),
+ MakeInstruction(spv::Op::OpLabel, {1}),
+ MakeInstruction(spv::Op::OpSwitch, {1, 2, 42, 3})}),
"Invalid OpSwitch: selector id 1 has no type"},
{Concatenate({ExpectedHeaderForBound(3),
- MakeInstruction(SpvOpTypeInt, {1, 32, 0}),
- MakeInstruction(SpvOpSwitch, {1, 3, 42, 3})}),
+ MakeInstruction(spv::Op::OpTypeInt, {1, 32, 0}),
+ MakeInstruction(spv::Op::OpSwitch, {1, 3, 42, 3})}),
"Invalid OpSwitch: selector id 1 is a type, not a value"},
{Concatenate({ExpectedHeaderForBound(3),
- MakeInstruction(SpvOpTypeFloat, {1, 32}),
- MakeInstruction(SpvOpConstant, {1, 2, 0x78f00000}),
- MakeInstruction(SpvOpSwitch, {2, 3, 42, 3})}),
+ MakeInstruction(spv::Op::OpTypeFloat, {1, 32}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 0x78f00000}),
+ MakeInstruction(spv::Op::OpSwitch, {2, 3, 42, 3})}),
"Invalid OpSwitch: selector id 2 is not a scalar integer"},
{Concatenate({ExpectedHeaderForBound(3),
- MakeInstruction(SpvOpExtInstImport, {1},
+ MakeInstruction(spv::Op::OpExtInstImport, {1},
MakeVector("invalid-import"))}),
"Invalid extended instruction import 'invalid-import'"},
{Concatenate({
ExpectedHeaderForBound(3),
- MakeInstruction(SpvOpTypeInt, {1, 32, 0}),
- MakeInstruction(SpvOpConstant, {2, 2, 42}),
+ MakeInstruction(spv::Op::OpTypeInt, {1, 32, 0}),
+ MakeInstruction(spv::Op::OpConstant, {2, 2, 42}),
}),
"Type Id 2 is not a type"},
{Concatenate({
ExpectedHeaderForBound(3),
- MakeInstruction(SpvOpTypeBool, {1}),
- MakeInstruction(SpvOpConstant, {1, 2, 42}),
+ MakeInstruction(spv::Op::OpTypeBool, {1}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 42}),
}),
"Type Id 1 is not a scalar numeric type"},
}));
diff --git a/test/binary_to_text_test.cpp b/test/binary_to_text_test.cpp
index 44705f2a5..85d5bd1d2 100644
--- a/test/binary_to_text_test.cpp
+++ b/test/binary_to_text_test.cpp
@@ -185,43 +185,43 @@ TEST_P(BinaryToTextFail, EncodeSuccessfullyDecodeFailed) {
INSTANTIATE_TEST_SUITE_P(
InvalidIds, BinaryToTextFail,
::testing::ValuesIn(std::vector<FailedDecodeCase>{
- {"", spvtest::MakeInstruction(SpvOpTypeVoid, {0}),
+ {"", spvtest::MakeInstruction(spv::Op::OpTypeVoid, {0}),
"Error: Result Id is 0"},
- {"", spvtest::MakeInstruction(SpvOpConstant, {0, 1, 42}),
+ {"", spvtest::MakeInstruction(spv::Op::OpConstant, {0, 1, 42}),
"Error: Type Id is 0"},
- {"%1 = OpTypeVoid", spvtest::MakeInstruction(SpvOpTypeVoid, {1}),
+ {"%1 = OpTypeVoid", spvtest::MakeInstruction(spv::Op::OpTypeVoid, {1}),
"Id 1 is defined more than once"},
{"%1 = OpTypeVoid\n"
"%2 = OpNot %1 %foo",
- spvtest::MakeInstruction(SpvOpNot, {1, 2, 3}),
+ spvtest::MakeInstruction(spv::Op::OpNot, {1, 2, 3}),
"Id 2 is defined more than once"},
{"%1 = OpTypeVoid\n"
"%2 = OpNot %1 %foo",
- spvtest::MakeInstruction(SpvOpNot, {1, 1, 3}),
+ spvtest::MakeInstruction(spv::Op::OpNot, {1, 1, 3}),
"Id 1 is defined more than once"},
// The following are the two failure cases for
// Parser::setNumericTypeInfoForType.
- {"", spvtest::MakeInstruction(SpvOpConstant, {500, 1, 42}),
+ {"", spvtest::MakeInstruction(spv::Op::OpConstant, {500, 1, 42}),
"Type Id 500 is not a type"},
{"%1 = OpTypeInt 32 0\n"
"%2 = OpTypeVector %1 4",
- spvtest::MakeInstruction(SpvOpConstant, {2, 3, 999}),
+ spvtest::MakeInstruction(spv::Op::OpConstant, {2, 3, 999}),
"Type Id 2 is not a scalar numeric type"},
}));
INSTANTIATE_TEST_SUITE_P(
InvalidIdsCheckedDuringLiteralCaseParsing, BinaryToTextFail,
::testing::ValuesIn(std::vector<FailedDecodeCase>{
- {"", spvtest::MakeInstruction(SpvOpSwitch, {1, 2, 3, 4}),
+ {"", spvtest::MakeInstruction(spv::Op::OpSwitch, {1, 2, 3, 4}),
"Invalid OpSwitch: selector id 1 has no type"},
{"%1 = OpTypeVoid\n",
- spvtest::MakeInstruction(SpvOpSwitch, {1, 2, 3, 4}),
+ spvtest::MakeInstruction(spv::Op::OpSwitch, {1, 2, 3, 4}),
"Invalid OpSwitch: selector id 1 is a type, not a value"},
{"%1 = OpConstantTrue !500",
- spvtest::MakeInstruction(SpvOpSwitch, {1, 2, 3, 4}),
+ spvtest::MakeInstruction(spv::Op::OpSwitch, {1, 2, 3, 4}),
"Type Id 500 is not a type"},
{"%1 = OpTypeFloat 32\n%2 = OpConstant %1 1.5",
- spvtest::MakeInstruction(SpvOpSwitch, {2, 3, 4, 5}),
+ spvtest::MakeInstruction(spv::Op::OpSwitch, {2, 3, 4, 5}),
"Invalid OpSwitch: selector id 2 is not a scalar integer"},
}));
diff --git a/test/comment_test.cpp b/test/comment_test.cpp
index 49f8df651..5cc9b1d75 100644
--- a/test/comment_test.cpp
+++ b/test/comment_test.cpp
@@ -40,10 +40,10 @@ TEST_F(TextToBinaryTest, Whitespace) {
EXPECT_THAT(
CompiledInstructions(input),
- Eq(Concatenate({MakeInstruction(SpvOpMemoryModel,
- {uint32_t(SpvAddressingModelLogical),
- uint32_t(SpvMemoryModelSimple)}),
- MakeInstruction(SpvOpExtInstImport, {1},
+ Eq(Concatenate({MakeInstruction(spv::Op::OpMemoryModel,
+ {uint32_t(spv::AddressingModel::Logical),
+ uint32_t(spv::MemoryModel::Simple)}),
+ MakeInstruction(spv::Op::OpExtInstImport, {1},
MakeVector("GLSL.std.450"))})));
}
diff --git a/test/cpp_interface_test.cpp b/test/cpp_interface_test.cpp
index 4cab4dfd8..5d1169828 100644
--- a/test/cpp_interface_test.cpp
+++ b/test/cpp_interface_test.cpp
@@ -19,7 +19,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "spirv-tools/optimizer.hpp"
-#include "spirv/1.1/spirv.h"
+#include "spirv/unified1/spirv.hpp11"
namespace spvtools {
namespace {
@@ -47,7 +47,7 @@ TEST(CppInterface, SuccessfulRoundTrip) {
std::vector<uint32_t> binary;
EXPECT_TRUE(t.Assemble(input_text, &binary));
EXPECT_TRUE(binary.size() > 5u);
- EXPECT_EQ(SpvMagicNumber, binary[0]);
+ EXPECT_EQ(spv::MagicNumber, binary[0]);
EXPECT_EQ(kExpectedSpvVersion, binary[1]);
// This cannot pass validation since %1 is not defined.
@@ -74,7 +74,7 @@ TEST(CppInterface, AssembleEmptyModule) {
EXPECT_TRUE(t.Assemble("", &binary));
// We only have the header.
EXPECT_EQ(5u, binary.size());
- EXPECT_EQ(SpvMagicNumber, binary[0]);
+ EXPECT_EQ(spv::MagicNumber, binary[0]);
EXPECT_EQ(kExpectedSpvVersion, binary[1]);
}
@@ -85,21 +85,21 @@ TEST(CppInterface, AssembleOverloads) {
std::vector<uint32_t> binary;
EXPECT_TRUE(t.Assemble(input_text, &binary));
EXPECT_TRUE(binary.size() > 5u);
- EXPECT_EQ(SpvMagicNumber, binary[0]);
+ EXPECT_EQ(spv::MagicNumber, binary[0]);
EXPECT_EQ(kExpectedSpvVersion, binary[1]);
}
{
std::vector<uint32_t> binary;
EXPECT_TRUE(t.Assemble(input_text.data(), input_text.size(), &binary));
EXPECT_TRUE(binary.size() > 5u);
- EXPECT_EQ(SpvMagicNumber, binary[0]);
+ EXPECT_EQ(spv::MagicNumber, binary[0]);
EXPECT_EQ(kExpectedSpvVersion, binary[1]);
}
{ // Ignore the last newline.
std::vector<uint32_t> binary;
EXPECT_TRUE(t.Assemble(input_text.data(), input_text.size() - 1, &binary));
EXPECT_TRUE(binary.size() > 5u);
- EXPECT_EQ(SpvMagicNumber, binary[0]);
+ EXPECT_EQ(spv::MagicNumber, binary[0]);
EXPECT_EQ(kExpectedSpvVersion, binary[1]);
}
}
diff --git a/test/diff/diff_test.cpp b/test/diff/diff_test.cpp
index 5b11d0eb2..3b63c69c7 100644
--- a/test/diff/diff_test.cpp
+++ b/test/diff/diff_test.cpp
@@ -195,14 +195,14 @@ TEST(DiffHeaderTest, Diff) {
// Differentiate them in the header.
const spvtools::opt::ModuleHeader src_header = {
- SpvMagicNumber,
+ spv::MagicNumber,
SPV_SPIRV_VERSION_WORD(1, 3),
SPV_GENERATOR_WORD(SPV_GENERATOR_KHRONOS_ASSEMBLER, 3),
src->module()->IdBound(),
src->module()->schema(),
};
const spvtools::opt::ModuleHeader dst_header = {
- SpvMagicNumber,
+ spv::MagicNumber,
SPV_SPIRV_VERSION_WORD(1, 2),
SPV_GENERATOR_WORD(SPV_GENERATOR_KHRONOS_GLSLANG, 10),
dst->module()->IdBound(),
diff --git a/test/enum_set_test.cpp b/test/enum_set_test.cpp
index 047d6427c..1f727158e 100644
--- a/test/enum_set_test.cpp
+++ b/test/enum_set_test.cpp
@@ -179,60 +179,60 @@ TEST(EnumSet, DefaultIsEmpty) {
}
TEST(CapabilitySet, ConstructSingleMemberMatrix) {
- CapabilitySet s(SpvCapabilityMatrix);
- EXPECT_TRUE(s.Contains(SpvCapabilityMatrix));
- EXPECT_FALSE(s.Contains(SpvCapabilityShader));
- EXPECT_FALSE(s.Contains(static_cast<SpvCapability>(1000)));
+ CapabilitySet s(spv::Capability::Matrix);
+ EXPECT_TRUE(s.Contains(spv::Capability::Matrix));
+ EXPECT_FALSE(s.Contains(spv::Capability::Shader));
+ EXPECT_FALSE(s.Contains(static_cast<spv::Capability>(1000)));
}
TEST(CapabilitySet, ConstructSingleMemberMaxInMask) {
- CapabilitySet s(static_cast<SpvCapability>(63));
- EXPECT_FALSE(s.Contains(SpvCapabilityMatrix));
- EXPECT_FALSE(s.Contains(SpvCapabilityShader));
- EXPECT_TRUE(s.Contains(static_cast<SpvCapability>(63)));
- EXPECT_FALSE(s.Contains(static_cast<SpvCapability>(64)));
- EXPECT_FALSE(s.Contains(static_cast<SpvCapability>(1000)));
+ CapabilitySet s(static_cast<spv::Capability>(63));
+ EXPECT_FALSE(s.Contains(spv::Capability::Matrix));
+ EXPECT_FALSE(s.Contains(spv::Capability::Shader));
+ EXPECT_TRUE(s.Contains(static_cast<spv::Capability>(63)));
+ EXPECT_FALSE(s.Contains(static_cast<spv::Capability>(64)));
+ EXPECT_FALSE(s.Contains(static_cast<spv::Capability>(1000)));
}
TEST(CapabilitySet, ConstructSingleMemberMinOverflow) {
// Check the first one that forces overflow beyond the mask.
- CapabilitySet s(static_cast<SpvCapability>(64));
- EXPECT_FALSE(s.Contains(SpvCapabilityMatrix));
- EXPECT_FALSE(s.Contains(SpvCapabilityShader));
- EXPECT_FALSE(s.Contains(static_cast<SpvCapability>(63)));
- EXPECT_TRUE(s.Contains(static_cast<SpvCapability>(64)));
- EXPECT_FALSE(s.Contains(static_cast<SpvCapability>(1000)));
+ CapabilitySet s(static_cast<spv::Capability>(64));
+ EXPECT_FALSE(s.Contains(spv::Capability::Matrix));
+ EXPECT_FALSE(s.Contains(spv::Capability::Shader));
+ EXPECT_FALSE(s.Contains(static_cast<spv::Capability>(63)));
+ EXPECT_TRUE(s.Contains(static_cast<spv::Capability>(64)));
+ EXPECT_FALSE(s.Contains(static_cast<spv::Capability>(1000)));
}
TEST(CapabilitySet, ConstructSingleMemberMaxOverflow) {
// Check the max 32-bit signed int.
- CapabilitySet s(static_cast<SpvCapability>(0x7fffffffu));
- EXPECT_FALSE(s.Contains(SpvCapabilityMatrix));
- EXPECT_FALSE(s.Contains(SpvCapabilityShader));
- EXPECT_FALSE(s.Contains(static_cast<SpvCapability>(1000)));
- EXPECT_TRUE(s.Contains(static_cast<SpvCapability>(0x7fffffffu)));
+ CapabilitySet s(static_cast<spv::Capability>(0x7fffffffu));
+ EXPECT_FALSE(s.Contains(spv::Capability::Matrix));
+ EXPECT_FALSE(s.Contains(spv::Capability::Shader));
+ EXPECT_FALSE(s.Contains(static_cast<spv::Capability>(1000)));
+ EXPECT_TRUE(s.Contains(static_cast<spv::Capability>(0x7fffffffu)));
}
TEST(CapabilitySet, AddEnum) {
- CapabilitySet s(SpvCapabilityShader);
- s.Add(SpvCapabilityKernel);
- s.Add(static_cast<SpvCapability>(42));
- EXPECT_FALSE(s.Contains(SpvCapabilityMatrix));
- EXPECT_TRUE(s.Contains(SpvCapabilityShader));
- EXPECT_TRUE(s.Contains(SpvCapabilityKernel));
- EXPECT_TRUE(s.Contains(static_cast<SpvCapability>(42)));
+ CapabilitySet s(spv::Capability::Shader);
+ s.Add(spv::Capability::Kernel);
+ s.Add(static_cast<spv::Capability>(42));
+ EXPECT_FALSE(s.Contains(spv::Capability::Matrix));
+ EXPECT_TRUE(s.Contains(spv::Capability::Shader));
+ EXPECT_TRUE(s.Contains(spv::Capability::Kernel));
+ EXPECT_TRUE(s.Contains(static_cast<spv::Capability>(42)));
}
TEST(CapabilitySet, InitializerListEmpty) {
CapabilitySet s{};
for (uint32_t i = 0; i < 1000; i++) {
- EXPECT_FALSE(s.Contains(static_cast<SpvCapability>(i)));
+ EXPECT_FALSE(s.Contains(static_cast<spv::Capability>(i)));
}
}
struct ForEachCase {
CapabilitySet capabilities;
- std::vector<SpvCapability> expected;
+ std::vector<spv::Capability> expected;
};
using CapabilitySetForEachTest = ::testing::TestWithParam<ForEachCase>;
@@ -253,7 +253,7 @@ TEST_P(CapabilitySetForEachTest, MoveConstructor) {
EXPECT_THAT(ElementsIn(moved), Eq(GetParam().expected));
// The moved-from set is empty.
- EXPECT_THAT(ElementsIn(copy), Eq(std::vector<SpvCapability>{}));
+ EXPECT_THAT(ElementsIn(copy), Eq(std::vector<spv::Capability>{}));
}
TEST_P(CapabilitySetForEachTest, OperatorEquals) {
@@ -267,24 +267,25 @@ TEST_P(CapabilitySetForEachTest, OperatorEqualsSelfAssign) {
EXPECT_THAT(ElementsIn(assigned), Eq(GetParam().expected));
}
-INSTANTIATE_TEST_SUITE_P(Samples, CapabilitySetForEachTest,
- ValuesIn(std::vector<ForEachCase>{
- {{}, {}},
- {{SpvCapabilityMatrix}, {SpvCapabilityMatrix}},
- {{SpvCapabilityKernel, SpvCapabilityShader},
- {SpvCapabilityShader, SpvCapabilityKernel}},
- {{static_cast<SpvCapability>(999)},
- {static_cast<SpvCapability>(999)}},
- {{static_cast<SpvCapability>(0x7fffffff)},
- {static_cast<SpvCapability>(0x7fffffff)}},
- // Mixture and out of order
- {{static_cast<SpvCapability>(0x7fffffff),
- static_cast<SpvCapability>(100),
- SpvCapabilityShader, SpvCapabilityMatrix},
- {SpvCapabilityMatrix, SpvCapabilityShader,
- static_cast<SpvCapability>(100),
- static_cast<SpvCapability>(0x7fffffff)}},
- }));
+INSTANTIATE_TEST_SUITE_P(
+ Samples, CapabilitySetForEachTest,
+ ValuesIn(std::vector<ForEachCase>{
+ {{}, {}},
+ {{spv::Capability::Matrix}, {spv::Capability::Matrix}},
+ {{spv::Capability::Kernel, spv::Capability::Shader},
+ {spv::Capability::Shader, spv::Capability::Kernel}},
+ {{static_cast<spv::Capability>(999)},
+ {static_cast<spv::Capability>(999)}},
+ {{static_cast<spv::Capability>(0x7fffffff)},
+ {static_cast<spv::Capability>(0x7fffffff)}},
+ // Mixture and out of order
+ {{static_cast<spv::Capability>(0x7fffffff),
+ static_cast<spv::Capability>(100), spv::Capability::Shader,
+ spv::Capability::Matrix},
+ {spv::Capability::Matrix, spv::Capability::Shader,
+ static_cast<spv::Capability>(100),
+ static_cast<spv::Capability>(0x7fffffff)}},
+ }));
} // namespace
} // namespace spvtools
diff --git a/test/enum_string_mapping_test.cpp b/test/enum_string_mapping_test.cpp
index 52aa653e6..01dede74c 100644
--- a/test/enum_string_mapping_test.cpp
+++ b/test/enum_string_mapping_test.cpp
@@ -34,7 +34,7 @@ using ExtensionTest =
::testing::TestWithParam<std::pair<Extension, std::string>>;
using UnknownExtensionTest = ::testing::TestWithParam<std::string>;
using CapabilityTest =
- ::testing::TestWithParam<std::pair<SpvCapability, std::string>>;
+ ::testing::TestWithParam<std::pair<spv::Capability, std::string>>;
TEST_P(ExtensionTest, TestExtensionFromString) {
const std::pair<Extension, std::string>& param = GetParam();
@@ -59,8 +59,8 @@ TEST_P(UnknownExtensionTest, TestExtensionFromStringFails) {
}
TEST_P(CapabilityTest, TestCapabilityToString) {
- const std::pair<SpvCapability, std::string>& param = GetParam();
- const SpvCapability capability = param.first;
+ const std::pair<spv::Capability, std::string>& param = GetParam();
+ const spv::Capability capability = param.first;
const std::string capability_str = param.second;
const std::string result_str = CapabilityToString(capability);
EXPECT_EQ(capability_str, result_str);
@@ -99,104 +99,105 @@ INSTANTIATE_TEST_SUITE_P(UnknownExtensions, UnknownExtensionTest,
INSTANTIATE_TEST_SUITE_P(
AllCapabilities, CapabilityTest,
- ValuesIn(std::vector<std::pair<SpvCapability, std::string>>(
- {{SpvCapabilityMatrix, "Matrix"},
- {SpvCapabilityShader, "Shader"},
- {SpvCapabilityGeometry, "Geometry"},
- {SpvCapabilityTessellation, "Tessellation"},
- {SpvCapabilityAddresses, "Addresses"},
- {SpvCapabilityLinkage, "Linkage"},
- {SpvCapabilityKernel, "Kernel"},
- {SpvCapabilityVector16, "Vector16"},
- {SpvCapabilityFloat16Buffer, "Float16Buffer"},
- {SpvCapabilityFloat16, "Float16"},
- {SpvCapabilityFloat64, "Float64"},
- {SpvCapabilityInt64, "Int64"},
- {SpvCapabilityInt64Atomics, "Int64Atomics"},
- {SpvCapabilityImageBasic, "ImageBasic"},
- {SpvCapabilityImageReadWrite, "ImageReadWrite"},
- {SpvCapabilityImageMipmap, "ImageMipmap"},
- {SpvCapabilityPipes, "Pipes"},
- {SpvCapabilityGroups, "Groups"},
- {SpvCapabilityDeviceEnqueue, "DeviceEnqueue"},
- {SpvCapabilityLiteralSampler, "LiteralSampler"},
- {SpvCapabilityAtomicStorage, "AtomicStorage"},
- {SpvCapabilityInt16, "Int16"},
- {SpvCapabilityTessellationPointSize, "TessellationPointSize"},
- {SpvCapabilityGeometryPointSize, "GeometryPointSize"},
- {SpvCapabilityImageGatherExtended, "ImageGatherExtended"},
- {SpvCapabilityStorageImageMultisample, "StorageImageMultisample"},
- {SpvCapabilityUniformBufferArrayDynamicIndexing,
+ ValuesIn(std::vector<std::pair<spv::Capability, std::string>>(
+ {{spv::Capability::Matrix, "Matrix"},
+ {spv::Capability::Shader, "Shader"},
+ {spv::Capability::Geometry, "Geometry"},
+ {spv::Capability::Tessellation, "Tessellation"},
+ {spv::Capability::Addresses, "Addresses"},
+ {spv::Capability::Linkage, "Linkage"},
+ {spv::Capability::Kernel, "Kernel"},
+ {spv::Capability::Vector16, "Vector16"},
+ {spv::Capability::Float16Buffer, "Float16Buffer"},
+ {spv::Capability::Float16, "Float16"},
+ {spv::Capability::Float64, "Float64"},
+ {spv::Capability::Int64, "Int64"},
+ {spv::Capability::Int64Atomics, "Int64Atomics"},
+ {spv::Capability::ImageBasic, "ImageBasic"},
+ {spv::Capability::ImageReadWrite, "ImageReadWrite"},
+ {spv::Capability::ImageMipmap, "ImageMipmap"},
+ {spv::Capability::Pipes, "Pipes"},
+ {spv::Capability::Groups, "Groups"},
+ {spv::Capability::DeviceEnqueue, "DeviceEnqueue"},
+ {spv::Capability::LiteralSampler, "LiteralSampler"},
+ {spv::Capability::AtomicStorage, "AtomicStorage"},
+ {spv::Capability::Int16, "Int16"},
+ {spv::Capability::TessellationPointSize, "TessellationPointSize"},
+ {spv::Capability::GeometryPointSize, "GeometryPointSize"},
+ {spv::Capability::ImageGatherExtended, "ImageGatherExtended"},
+ {spv::Capability::StorageImageMultisample, "StorageImageMultisample"},
+ {spv::Capability::UniformBufferArrayDynamicIndexing,
"UniformBufferArrayDynamicIndexing"},
- {SpvCapabilitySampledImageArrayDynamicIndexing,
+ {spv::Capability::SampledImageArrayDynamicIndexing,
"SampledImageArrayDynamicIndexing"},
- {SpvCapabilityStorageBufferArrayDynamicIndexing,
+ {spv::Capability::StorageBufferArrayDynamicIndexing,
"StorageBufferArrayDynamicIndexing"},
- {SpvCapabilityStorageImageArrayDynamicIndexing,
+ {spv::Capability::StorageImageArrayDynamicIndexing,
"StorageImageArrayDynamicIndexing"},
- {SpvCapabilityClipDistance, "ClipDistance"},
- {SpvCapabilityCullDistance, "CullDistance"},
- {SpvCapabilityImageCubeArray, "ImageCubeArray"},
- {SpvCapabilitySampleRateShading, "SampleRateShading"},
- {SpvCapabilityImageRect, "ImageRect"},
- {SpvCapabilitySampledRect, "SampledRect"},
- {SpvCapabilityGenericPointer, "GenericPointer"},
- {SpvCapabilityInt8, "Int8"},
- {SpvCapabilityInputAttachment, "InputAttachment"},
- {SpvCapabilitySparseResidency, "SparseResidency"},
- {SpvCapabilityMinLod, "MinLod"},
- {SpvCapabilitySampled1D, "Sampled1D"},
- {SpvCapabilityImage1D, "Image1D"},
- {SpvCapabilitySampledCubeArray, "SampledCubeArray"},
- {SpvCapabilitySampledBuffer, "SampledBuffer"},
- {SpvCapabilityImageBuffer, "ImageBuffer"},
- {SpvCapabilityImageMSArray, "ImageMSArray"},
- {SpvCapabilityStorageImageExtendedFormats,
+ {spv::Capability::ClipDistance, "ClipDistance"},
+ {spv::Capability::CullDistance, "CullDistance"},
+ {spv::Capability::ImageCubeArray, "ImageCubeArray"},
+ {spv::Capability::SampleRateShading, "SampleRateShading"},
+ {spv::Capability::ImageRect, "ImageRect"},
+ {spv::Capability::SampledRect, "SampledRect"},
+ {spv::Capability::GenericPointer, "GenericPointer"},
+ {spv::Capability::Int8, "Int8"},
+ {spv::Capability::InputAttachment, "InputAttachment"},
+ {spv::Capability::SparseResidency, "SparseResidency"},
+ {spv::Capability::MinLod, "MinLod"},
+ {spv::Capability::Sampled1D, "Sampled1D"},
+ {spv::Capability::Image1D, "Image1D"},
+ {spv::Capability::SampledCubeArray, "SampledCubeArray"},
+ {spv::Capability::SampledBuffer, "SampledBuffer"},
+ {spv::Capability::ImageBuffer, "ImageBuffer"},
+ {spv::Capability::ImageMSArray, "ImageMSArray"},
+ {spv::Capability::StorageImageExtendedFormats,
"StorageImageExtendedFormats"},
- {SpvCapabilityImageQuery, "ImageQuery"},
- {SpvCapabilityDerivativeControl, "DerivativeControl"},
- {SpvCapabilityInterpolationFunction, "InterpolationFunction"},
- {SpvCapabilityTransformFeedback, "TransformFeedback"},
- {SpvCapabilityGeometryStreams, "GeometryStreams"},
- {SpvCapabilityStorageImageReadWithoutFormat,
+ {spv::Capability::ImageQuery, "ImageQuery"},
+ {spv::Capability::DerivativeControl, "DerivativeControl"},
+ {spv::Capability::InterpolationFunction, "InterpolationFunction"},
+ {spv::Capability::TransformFeedback, "TransformFeedback"},
+ {spv::Capability::GeometryStreams, "GeometryStreams"},
+ {spv::Capability::StorageImageReadWithoutFormat,
"StorageImageReadWithoutFormat"},
- {SpvCapabilityStorageImageWriteWithoutFormat,
+ {spv::Capability::StorageImageWriteWithoutFormat,
"StorageImageWriteWithoutFormat"},
- {SpvCapabilityMultiViewport, "MultiViewport"},
- {SpvCapabilitySubgroupDispatch, "SubgroupDispatch"},
- {SpvCapabilityNamedBarrier, "NamedBarrier"},
- {SpvCapabilityPipeStorage, "PipeStorage"},
- {SpvCapabilitySubgroupBallotKHR, "SubgroupBallotKHR"},
- {SpvCapabilityDrawParameters, "DrawParameters"},
- {SpvCapabilitySubgroupVoteKHR, "SubgroupVoteKHR"},
- {SpvCapabilityStorageBuffer16BitAccess, "StorageBuffer16BitAccess"},
- {SpvCapabilityStorageUniformBufferBlock16,
+ {spv::Capability::MultiViewport, "MultiViewport"},
+ {spv::Capability::SubgroupDispatch, "SubgroupDispatch"},
+ {spv::Capability::NamedBarrier, "NamedBarrier"},
+ {spv::Capability::PipeStorage, "PipeStorage"},
+ {spv::Capability::SubgroupBallotKHR, "SubgroupBallotKHR"},
+ {spv::Capability::DrawParameters, "DrawParameters"},
+ {spv::Capability::SubgroupVoteKHR, "SubgroupVoteKHR"},
+ {spv::Capability::StorageBuffer16BitAccess,
+ "StorageBuffer16BitAccess"},
+ {spv::Capability::StorageUniformBufferBlock16,
"StorageBuffer16BitAccess"}, // Preferred name
- {SpvCapabilityUniformAndStorageBuffer16BitAccess,
+ {spv::Capability::UniformAndStorageBuffer16BitAccess,
"UniformAndStorageBuffer16BitAccess"},
- {SpvCapabilityStorageUniform16,
+ {spv::Capability::StorageUniform16,
"UniformAndStorageBuffer16BitAccess"}, // Preferred name
- {SpvCapabilityStoragePushConstant16, "StoragePushConstant16"},
- {SpvCapabilityStorageInputOutput16, "StorageInputOutput16"},
- {SpvCapabilityDeviceGroup, "DeviceGroup"},
- {SpvCapabilityAtomicFloat32AddEXT, "AtomicFloat32AddEXT"},
- {SpvCapabilityAtomicFloat64AddEXT, "AtomicFloat64AddEXT"},
- {SpvCapabilityAtomicFloat32MinMaxEXT, "AtomicFloat32MinMaxEXT"},
- {SpvCapabilityAtomicFloat64MinMaxEXT, "AtomicFloat64MinMaxEXT"},
- {SpvCapabilityMultiView, "MultiView"},
- {SpvCapabilityInt64ImageEXT, "Int64ImageEXT"},
- {SpvCapabilitySampleMaskOverrideCoverageNV,
+ {spv::Capability::StoragePushConstant16, "StoragePushConstant16"},
+ {spv::Capability::StorageInputOutput16, "StorageInputOutput16"},
+ {spv::Capability::DeviceGroup, "DeviceGroup"},
+ {spv::Capability::AtomicFloat32AddEXT, "AtomicFloat32AddEXT"},
+ {spv::Capability::AtomicFloat64AddEXT, "AtomicFloat64AddEXT"},
+ {spv::Capability::AtomicFloat32MinMaxEXT, "AtomicFloat32MinMaxEXT"},
+ {spv::Capability::AtomicFloat64MinMaxEXT, "AtomicFloat64MinMaxEXT"},
+ {spv::Capability::MultiView, "MultiView"},
+ {spv::Capability::Int64ImageEXT, "Int64ImageEXT"},
+ {spv::Capability::SampleMaskOverrideCoverageNV,
"SampleMaskOverrideCoverageNV"},
- {SpvCapabilityGeometryShaderPassthroughNV,
+ {spv::Capability::GeometryShaderPassthroughNV,
"GeometryShaderPassthroughNV"},
// The next two are different names for the same token.
- {SpvCapabilityShaderViewportIndexLayerNV,
+ {spv::Capability::ShaderViewportIndexLayerNV,
"ShaderViewportIndexLayerEXT"},
- {SpvCapabilityShaderViewportIndexLayerEXT,
+ {spv::Capability::ShaderViewportIndexLayerEXT,
"ShaderViewportIndexLayerEXT"},
- {SpvCapabilityShaderViewportMaskNV, "ShaderViewportMaskNV"},
- {SpvCapabilityShaderStereoViewNV, "ShaderStereoViewNV"},
- {SpvCapabilityPerViewAttributesNV, "PerViewAttributesNV"}})));
+ {spv::Capability::ShaderViewportMaskNV, "ShaderViewportMaskNV"},
+ {spv::Capability::ShaderStereoViewNV, "ShaderStereoViewNV"},
+ {spv::Capability::PerViewAttributesNV, "PerViewAttributesNV"}})));
} // namespace
} // namespace spvtools
diff --git a/test/ext_inst.cldebug100_test.cpp b/test/ext_inst.cldebug100_test.cpp
index 0bbdd3a9a..cfc68e874 100644
--- a/test/ext_inst.cldebug100_test.cpp
+++ b/test/ext_inst.cldebug100_test.cpp
@@ -18,7 +18,6 @@
#include "OpenCLDebugInfo100.h"
#include "gmock/gmock.h"
#include "source/util/string_utils.h"
-#include "spirv/unified1/spirv.h"
#include "test/test_fixture.h"
#include "test/unit_spirv.h"
@@ -158,12 +157,13 @@ TEST_P(ExtInstCLDebugInfo100RoundTripTest, ParameterizedExtInst) {
GetParam().name + GetParam().operands + "\n";
// First make sure it assembles correctly.
std::cout << input << std::endl;
- EXPECT_THAT(CompiledInstructions(input),
- Eq(Concatenate(
- {MakeInstruction(SpvOpExtInstImport, {1},
- MakeVector("OpenCL.DebugInfo.100")),
- MakeInstruction(SpvOpExtInst, {2, 3, 1, GetParam().opcode},
- GetParam().expected_operands)})))
+ EXPECT_THAT(
+ CompiledInstructions(input),
+ Eq(Concatenate(
+ {MakeInstruction(spv::Op::OpExtInstImport, {1},
+ MakeVector("OpenCL.DebugInfo.100")),
+ MakeInstruction(spv::Op::OpExtInst, {2, 3, 1, GetParam().opcode},
+ GetParam().expected_operands)})))
<< input;
// Now check the round trip through the disassembler.
EXPECT_THAT(EncodeAndDecodeSuccessfully(input), input) << input;
@@ -297,7 +297,7 @@ TEST_P(ExtInstCLDebugInfo100RoundTripTest, ParameterizedExtInst) {
{ \
uint32_t(OpenCLDebugInfo100Debug##Enum), EPREFIX #Enum, \
" %4 " #S0 " " Fstr, { \
- 4, uint32_t(SpvStorageClass##S0), Fnum \
+ 4, uint32_t(spv::StorageClass::S0), Fnum \
} \
}
@@ -313,7 +313,7 @@ TEST_P(ExtInstCLDebugInfo100RoundTripTest, ParameterizedExtInst) {
{ \
uint32_t(OpenCLDebugInfo100Debug##Enum), EPREFIX #Enum, \
" " #L0 " " #L1 " %4 " RawEnumName, { \
- L0, L1, 4, RawEnumValue \
+ L0, L1, 4, (uint32_t)RawEnumValue \
} \
}
@@ -574,7 +574,7 @@ INSTANTIATE_TEST_SUITE_P(OpenCLDebugInfo100DebugInfoNone,
INSTANTIATE_TEST_SUITE_P(
OpenCLDebugInfo100DebugCompilationUnit, ExtInstCLDebugInfo100RoundTripTest,
::testing::ValuesIn(std::vector<InstructionCase>({
- CASE_LLIe(CompilationUnit, 100, 42, "HLSL", SpvSourceLanguageHLSL),
+ CASE_LLIe(CompilationUnit, 100, 42, "HLSL", spv::SourceLanguage::HLSL),
})));
INSTANTIATE_TEST_SUITE_P(
@@ -612,14 +612,14 @@ TEST_F(ExtInstCLDebugInfo100RoundTripTestExplicit, FlagIsPublic) {
const std::string input = prefix + "FlagIsPublic\n";
const std::string expected = prefix + "FlagIsProtected|FlagIsPrivate\n";
// First make sure it assembles correctly.
- EXPECT_THAT(
- CompiledInstructions(input),
- Eq(Concatenate(
- {MakeInstruction(SpvOpExtInstImport, {1}, MakeVector("DebugInfo")),
- MakeInstruction(SpvOpExtInst,
- {2, 3, 1, OpenCLDebugInfo100DebugTypePointer, 4,
- uint32_t(SpvStorageClassPrivate),
- OpenCLDebugInfo100FlagIsPublic})})))
+ EXPECT_THAT(CompiledInstructions(input),
+ Eq(Concatenate(
+ {MakeInstruction(spv::Op::OpExtInstImport, {1},
+ MakeVector("DebugInfo")),
+ MakeInstruction(spv::Op::OpExtInst,
+ {2, 3, 1, OpenCLDebugInfo100DebugTypePointer,
+ 4, uint32_t(spv::StorageClass::Private),
+ OpenCLDebugInfo100FlagIsPublic})})))
<< input;
// Now check the round trip through the disassembler.
EXPECT_THAT(EncodeAndDecodeSuccessfully(input), Eq(expected)) << input;
diff --git a/test/ext_inst.debuginfo_test.cpp b/test/ext_inst.debuginfo_test.cpp
index 9090c2473..5ccbde6d3 100644
--- a/test/ext_inst.debuginfo_test.cpp
+++ b/test/ext_inst.debuginfo_test.cpp
@@ -52,12 +52,12 @@ TEST_P(ExtInstDebugInfoRoundTripTest, ParameterizedExtInst) {
"%3 = OpExtInst %2 %1 " +
GetParam().name + GetParam().operands + "\n";
// First make sure it assembles correctly.
- EXPECT_THAT(
- CompiledInstructions(input),
- Eq(Concatenate(
- {MakeInstruction(SpvOpExtInstImport, {1}, MakeVector("DebugInfo")),
- MakeInstruction(SpvOpExtInst, {2, 3, 1, GetParam().opcode},
- GetParam().expected_operands)})))
+ EXPECT_THAT(CompiledInstructions(input),
+ Eq(Concatenate({MakeInstruction(spv::Op::OpExtInstImport, {1},
+ MakeVector("DebugInfo")),
+ MakeInstruction(spv::Op::OpExtInst,
+ {2, 3, 1, GetParam().opcode},
+ GetParam().expected_operands)})))
<< input;
// Now check the round trip through the disassembler.
EXPECT_THAT(EncodeAndDecodeSuccessfully(input), input) << input;
@@ -156,7 +156,7 @@ TEST_P(ExtInstDebugInfoRoundTripTest, ParameterizedExtInst) {
#define CASE_ISF(Enum, S0, Fstr, Fnum) \
{ \
uint32_t(DebugInfoDebug##Enum), "Debug" #Enum, " %4 " #S0 " " Fstr, { \
- 4, uint32_t(SpvStorageClass##S0), Fnum \
+ 4, uint32_t(spv::StorageClass::S0), Fnum \
} \
}
@@ -408,11 +408,12 @@ TEST_F(ExtInstDebugInfoRoundTripTestExplicit, FlagIsPublic) {
// First make sure it assembles correctly.
EXPECT_THAT(
CompiledInstructions(input),
- Eq(Concatenate(
- {MakeInstruction(SpvOpExtInstImport, {1}, MakeVector("DebugInfo")),
- MakeInstruction(SpvOpExtInst, {2, 3, 1, DebugInfoDebugTypePointer, 4,
- uint32_t(SpvStorageClassPrivate),
- DebugInfoFlagIsPublic})})))
+ Eq(Concatenate({MakeInstruction(spv::Op::OpExtInstImport, {1},
+ MakeVector("DebugInfo")),
+ MakeInstruction(spv::Op::OpExtInst,
+ {2, 3, 1, DebugInfoDebugTypePointer, 4,
+ uint32_t(spv::StorageClass::Private),
+ DebugInfoFlagIsPublic})})))
<< input;
// Now check the round trip through the disassembler.
EXPECT_THAT(EncodeAndDecodeSuccessfully(input), Eq(expected)) << input;
diff --git a/test/ext_inst.opencl_test.cpp b/test/ext_inst.opencl_test.cpp
index d80a9bd74..51c2b01f3 100644
--- a/test/ext_inst.opencl_test.cpp
+++ b/test/ext_inst.opencl_test.cpp
@@ -47,12 +47,12 @@ TEST_P(ExtInstOpenCLStdRoundTripTest, ParameterizedExtInst) {
"%3 = OpExtInst %2 %1 " +
GetParam().name + " " + GetParam().operands + "\n";
// First make sure it assembles correctly.
- EXPECT_THAT(
- CompiledInstructions(input),
- Eq(Concatenate(
- {MakeInstruction(SpvOpExtInstImport, {1}, MakeVector("OpenCL.std")),
- MakeInstruction(SpvOpExtInst, {2, 3, 1, GetParam().opcode},
- GetParam().expected_operands)})))
+ EXPECT_THAT(CompiledInstructions(input),
+ Eq(Concatenate({MakeInstruction(spv::Op::OpExtInstImport, {1},
+ MakeVector("OpenCL.std")),
+ MakeInstruction(spv::Op::OpExtInst,
+ {2, 3, 1, GetParam().opcode},
+ GetParam().expected_operands)})))
<< input;
// Now check the round trip through the disassembler.
EXPECT_THAT(EncodeAndDecodeSuccessfully(input), input) << input;
@@ -85,7 +85,7 @@ TEST_P(ExtInstOpenCLStdRoundTripTest, ParameterizedExtInst) {
#define CASE3Round(Enum, Name, Mode) \
{ \
uint32_t(OpenCLLIB::Entrypoints::Enum), #Name, "%4 %5 %6 " #Mode, { \
- 4, 5, 6, uint32_t(SpvFPRoundingMode##Mode) \
+ 4, 5, 6, uint32_t(spv::FPRoundingMode::Mode) \
} \
}
diff --git a/test/fuzz/available_instructions_test.cpp b/test/fuzz/available_instructions_test.cpp
index dc8a3b5a5..bbe524a9a 100644
--- a/test/fuzz/available_instructions_test.cpp
+++ b/test/fuzz/available_instructions_test.cpp
@@ -176,41 +176,41 @@ TEST(AvailableInstructionsTest, BasicTest) {
auto available = all_instructions.GetAvailableBeforeInstruction(i1);
ASSERT_FALSE(available.empty());
ASSERT_EQ(30, available.size());
- ASSERT_EQ(SpvOpTypeVoid, available[0]->opcode());
- ASSERT_EQ(SpvOpVariable, available[15]->opcode());
+ ASSERT_EQ(spv::Op::OpTypeVoid, available[0]->opcode());
+ ASSERT_EQ(spv::Op::OpVariable, available[15]->opcode());
}
{
auto available = all_instructions.GetAvailableBeforeInstruction(i2);
ASSERT_FALSE(available.empty());
ASSERT_EQ(46, available.size());
- ASSERT_EQ(SpvOpTypeVoid, available[0]->opcode());
- ASSERT_EQ(SpvOpTypePointer, available[3]->opcode());
- ASSERT_EQ(SpvOpVariable, available[15]->opcode());
- ASSERT_EQ(SpvOpFunctionCall, available[40]->opcode());
- ASSERT_EQ(SpvOpStore, available[45]->opcode());
+ ASSERT_EQ(spv::Op::OpTypeVoid, available[0]->opcode());
+ ASSERT_EQ(spv::Op::OpTypePointer, available[3]->opcode());
+ ASSERT_EQ(spv::Op::OpVariable, available[15]->opcode());
+ ASSERT_EQ(spv::Op::OpFunctionCall, available[40]->opcode());
+ ASSERT_EQ(spv::Op::OpStore, available[45]->opcode());
}
{
auto available = all_instructions.GetAvailableBeforeInstruction(i3);
ASSERT_FALSE(available.empty());
ASSERT_EQ(45, available.size());
- ASSERT_EQ(SpvOpTypeVoid, available[0]->opcode());
- ASSERT_EQ(SpvOpTypePointer, available[3]->opcode());
- ASSERT_EQ(SpvOpVariable, available[15]->opcode());
- ASSERT_EQ(SpvOpFunctionCall, available[40]->opcode());
- ASSERT_EQ(SpvOpBranchConditional, available[44]->opcode());
+ ASSERT_EQ(spv::Op::OpTypeVoid, available[0]->opcode());
+ ASSERT_EQ(spv::Op::OpTypePointer, available[3]->opcode());
+ ASSERT_EQ(spv::Op::OpVariable, available[15]->opcode());
+ ASSERT_EQ(spv::Op::OpFunctionCall, available[40]->opcode());
+ ASSERT_EQ(spv::Op::OpBranchConditional, available[44]->opcode());
}
{
auto available = all_instructions.GetAvailableBeforeInstruction(i6);
ASSERT_FALSE(available.empty());
ASSERT_EQ(33, available.size());
- ASSERT_EQ(SpvOpTypeVoid, available[0]->opcode());
- ASSERT_EQ(SpvOpTypeFloat, available[4]->opcode());
- ASSERT_EQ(SpvOpTypePointer, available[8]->opcode());
- ASSERT_EQ(SpvOpConstantComposite, available[12]->opcode());
- ASSERT_EQ(SpvOpConstant, available[16]->opcode());
- ASSERT_EQ(SpvOpFunctionParameter, available[30]->opcode());
- ASSERT_EQ(SpvOpFunctionParameter, available[31]->opcode());
- ASSERT_EQ(SpvOpVariable, available[32]->opcode());
+ ASSERT_EQ(spv::Op::OpTypeVoid, available[0]->opcode());
+ ASSERT_EQ(spv::Op::OpTypeFloat, available[4]->opcode());
+ ASSERT_EQ(spv::Op::OpTypePointer, available[8]->opcode());
+ ASSERT_EQ(spv::Op::OpConstantComposite, available[12]->opcode());
+ ASSERT_EQ(spv::Op::OpConstant, available[16]->opcode());
+ ASSERT_EQ(spv::Op::OpFunctionParameter, available[30]->opcode());
+ ASSERT_EQ(spv::Op::OpFunctionParameter, available[31]->opcode());
+ ASSERT_EQ(spv::Op::OpVariable, available[32]->opcode());
}
}
{
@@ -225,51 +225,51 @@ TEST(AvailableInstructionsTest, BasicTest) {
auto available = vector_instructions.GetAvailableBeforeInstruction(i4);
ASSERT_FALSE(available.empty());
ASSERT_EQ(3, available.size());
- ASSERT_EQ(SpvOpConstantComposite, available[0]->opcode());
- ASSERT_EQ(SpvOpConstantComposite, available[1]->opcode());
- ASSERT_EQ(SpvOpCopyObject, available[2]->opcode());
+ ASSERT_EQ(spv::Op::OpConstantComposite, available[0]->opcode());
+ ASSERT_EQ(spv::Op::OpConstantComposite, available[1]->opcode());
+ ASSERT_EQ(spv::Op::OpCopyObject, available[2]->opcode());
}
{
auto available = vector_instructions.GetAvailableBeforeInstruction(i5);
ASSERT_FALSE(available.empty());
ASSERT_EQ(3, available.size());
- ASSERT_EQ(SpvOpConstantComposite, available[0]->opcode());
- ASSERT_EQ(SpvOpConstantComposite, available[1]->opcode());
- ASSERT_EQ(SpvOpCopyObject, available[2]->opcode());
+ ASSERT_EQ(spv::Op::OpConstantComposite, available[0]->opcode());
+ ASSERT_EQ(spv::Op::OpConstantComposite, available[1]->opcode());
+ ASSERT_EQ(spv::Op::OpCopyObject, available[2]->opcode());
}
{
auto available = vector_instructions.GetAvailableBeforeInstruction(i6);
ASSERT_FALSE(available.empty());
ASSERT_EQ(2, available.size());
- ASSERT_EQ(SpvOpConstantComposite, available[0]->opcode());
- ASSERT_EQ(SpvOpConstantComposite, available[1]->opcode());
+ ASSERT_EQ(spv::Op::OpConstantComposite, available[0]->opcode());
+ ASSERT_EQ(spv::Op::OpConstantComposite, available[1]->opcode());
}
}
{
AvailableInstructions integer_add_instructions(
context.get(), [](opt::IRContext*, opt::Instruction* inst) -> bool {
- return inst->opcode() == SpvOpIAdd;
+ return inst->opcode() == spv::Op::OpIAdd;
});
{
auto available =
integer_add_instructions.GetAvailableBeforeInstruction(i7);
ASSERT_FALSE(available.empty());
ASSERT_EQ(1, available.size());
- ASSERT_EQ(SpvOpIAdd, available[0]->opcode());
+ ASSERT_EQ(spv::Op::OpIAdd, available[0]->opcode());
}
{
auto available =
integer_add_instructions.GetAvailableBeforeInstruction(i8);
ASSERT_FALSE(available.empty());
ASSERT_EQ(1, available.size());
- ASSERT_EQ(SpvOpIAdd, available[0]->opcode());
+ ASSERT_EQ(spv::Op::OpIAdd, available[0]->opcode());
}
{
auto available =
integer_add_instructions.GetAvailableBeforeInstruction(i9);
ASSERT_FALSE(available.empty());
ASSERT_EQ(1, available.size());
- ASSERT_EQ(SpvOpIAdd, available[0]->opcode());
+ ASSERT_EQ(spv::Op::OpIAdd, available[0]->opcode());
}
}
}
diff --git a/test/fuzz/data_synonym_transformation_test.cpp b/test/fuzz/data_synonym_transformation_test.cpp
index 7e93f2918..3ba809310 100644
--- a/test/fuzz/data_synonym_transformation_test.cpp
+++ b/test/fuzz/data_synonym_transformation_test.cpp
@@ -146,12 +146,12 @@ TEST(DataSynonymTransformationTest, ArrayCompositeSynonyms) {
// Replace %12 with %100[0] in '%25 = OpAccessChain %24 %20 %12'
auto instruction_descriptor_1 =
- MakeInstructionDescriptor(25, SpvOpAccessChain, 0);
+ MakeInstructionDescriptor(25, spv::Op::OpAccessChain, 0);
auto good_extract_1 =
TransformationCompositeExtract(instruction_descriptor_1, 102, 100, {0});
// Bad: id already in use
auto bad_extract_1 = TransformationCompositeExtract(
- MakeInstructionDescriptor(25, SpvOpAccessChain, 0), 25, 100, {0});
+ MakeInstructionDescriptor(25, spv::Op::OpAccessChain, 0), 25, 100, {0});
ASSERT_TRUE(
good_extract_1.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(
@@ -166,7 +166,8 @@ TEST(DataSynonymTransformationTest, ArrayCompositeSynonyms) {
kConsoleMessageConsumer));
// Replace %13 with %100[1] in 'OpStore %15 %13'
- auto instruction_descriptor_2 = MakeInstructionDescriptor(100, SpvOpStore, 0);
+ auto instruction_descriptor_2 =
+ MakeInstructionDescriptor(100, spv::Op::OpStore, 0);
auto good_extract_2 =
TransformationCompositeExtract(instruction_descriptor_2, 103, 100, {1});
// No bad example provided here.
@@ -183,7 +184,7 @@ TEST(DataSynonymTransformationTest, ArrayCompositeSynonyms) {
// Replace %22 with %100[2] in '%23 = OpConvertSToF %16 %22'
auto instruction_descriptor_3 =
- MakeInstructionDescriptor(23, SpvOpConvertSToF, 0);
+ MakeInstructionDescriptor(23, spv::Op::OpConvertSToF, 0);
auto good_extract_3 =
TransformationCompositeExtract(instruction_descriptor_3, 104, 100, {2});
ASSERT_TRUE(
@@ -203,12 +204,13 @@ TEST(DataSynonymTransformationTest, ArrayCompositeSynonyms) {
kConsoleMessageConsumer));
// Replace %28 with %101[0] in 'OpStore %33 %28'
- auto instruction_descriptor_4 = MakeInstructionDescriptor(33, SpvOpStore, 0);
+ auto instruction_descriptor_4 =
+ MakeInstructionDescriptor(33, spv::Op::OpStore, 0);
auto good_extract_4 =
TransformationCompositeExtract(instruction_descriptor_4, 105, 101, {0});
// Bad: instruction descriptor does not identify an appropriate instruction
auto bad_extract_4 = TransformationCompositeExtract(
- MakeInstructionDescriptor(33, SpvOpCopyObject, 0), 105, 101, {0});
+ MakeInstructionDescriptor(33, spv::Op::OpCopyObject, 0), 105, 101, {0});
ASSERT_TRUE(
good_extract_4.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(
@@ -224,7 +226,7 @@ TEST(DataSynonymTransformationTest, ArrayCompositeSynonyms) {
// Replace %23 with %101[1] in '%50 = OpCopyObject %16 %23'
auto instruction_descriptor_5 =
- MakeInstructionDescriptor(50, SpvOpCopyObject, 0);
+ MakeInstructionDescriptor(50, spv::Op::OpCopyObject, 0);
auto good_extract_5 =
TransformationCompositeExtract(instruction_descriptor_5, 106, 101, {1});
ASSERT_TRUE(
@@ -244,7 +246,8 @@ TEST(DataSynonymTransformationTest, ArrayCompositeSynonyms) {
kConsoleMessageConsumer));
// Replace %32 with %101[2] in 'OpStore %33 %32'
- auto instruction_descriptor_6 = MakeInstructionDescriptor(33, SpvOpStore, 1);
+ auto instruction_descriptor_6 =
+ MakeInstructionDescriptor(33, spv::Op::OpStore, 1);
auto good_extract_6 =
TransformationCompositeExtract(instruction_descriptor_6, 107, 101, {2});
// Bad: id 1001 does not exist
@@ -265,7 +268,7 @@ TEST(DataSynonymTransformationTest, ArrayCompositeSynonyms) {
// Replace %23 with %101[3] in '%51 = OpCopyObject %16 %23'
auto instruction_descriptor_7 =
- MakeInstructionDescriptor(51, SpvOpCopyObject, 0);
+ MakeInstructionDescriptor(51, spv::Op::OpCopyObject, 0);
auto good_extract_7 =
TransformationCompositeExtract(instruction_descriptor_7, 108, 101, {3});
ASSERT_TRUE(
@@ -431,7 +434,8 @@ TEST(DataSynonymTransformationTest, MatrixCompositeSynonyms) {
MakeSynonymFact(50, {}, 100, {2}));
// Replace %23 with %100[0] in '%26 = OpFAdd %7 %23 %25'
- auto instruction_descriptor_1 = MakeInstructionDescriptor(26, SpvOpFAdd, 0);
+ auto instruction_descriptor_1 =
+ MakeInstructionDescriptor(26, spv::Op::OpFAdd, 0);
auto extract_1 =
TransformationCompositeExtract(instruction_descriptor_1, 101, 100, {0});
ASSERT_TRUE(extract_1.IsApplicable(context.get(), transformation_context));
@@ -445,7 +449,8 @@ TEST(DataSynonymTransformationTest, MatrixCompositeSynonyms) {
kConsoleMessageConsumer));
// Replace %25 with %100[1] in '%26 = OpFAdd %7 %23 %25'
- auto instruction_descriptor_2 = MakeInstructionDescriptor(26, SpvOpFAdd, 0);
+ auto instruction_descriptor_2 =
+ MakeInstructionDescriptor(26, spv::Op::OpFAdd, 0);
auto extract_2 =
TransformationCompositeExtract(instruction_descriptor_2, 102, 100, {1});
ASSERT_TRUE(extract_2.IsApplicable(context.get(), transformation_context));
@@ -611,7 +616,7 @@ TEST(DataSynonymTransformationTest, StructCompositeSynonyms) {
// Replace %45 with %100[1] in '%46 = OpCompositeConstruct %32 %35 %45'
auto instruction_descriptor_1 =
- MakeInstructionDescriptor(46, SpvOpCompositeConstruct, 0);
+ MakeInstructionDescriptor(46, spv::Op::OpCompositeConstruct, 0);
auto extract_1 =
TransformationCompositeExtract(instruction_descriptor_1, 201, 100, {1});
ASSERT_TRUE(extract_1.IsApplicable(context.get(), transformation_context));
@@ -627,7 +632,7 @@ TEST(DataSynonymTransformationTest, StructCompositeSynonyms) {
// Replace second occurrence of %27 with %101[0] in '%28 =
// OpCompositeConstruct %8 %27 %27'
auto instruction_descriptor_2 =
- MakeInstructionDescriptor(28, SpvOpCompositeConstruct, 0);
+ MakeInstructionDescriptor(28, spv::Op::OpCompositeConstruct, 0);
auto extract_2 =
TransformationCompositeExtract(instruction_descriptor_2, 202, 101, {0});
ASSERT_TRUE(extract_2.IsApplicable(context.get(), transformation_context));
@@ -642,7 +647,7 @@ TEST(DataSynonymTransformationTest, StructCompositeSynonyms) {
// Replace %36 with %101[1] in '%45 = OpCompositeConstruct %31 %36 %41 %44'
auto instruction_descriptor_3 =
- MakeInstructionDescriptor(45, SpvOpCompositeConstruct, 0);
+ MakeInstructionDescriptor(45, spv::Op::OpCompositeConstruct, 0);
auto extract_3 =
TransformationCompositeExtract(instruction_descriptor_3, 203, 101, {1});
ASSERT_TRUE(extract_3.IsApplicable(context.get(), transformation_context));
@@ -658,7 +663,7 @@ TEST(DataSynonymTransformationTest, StructCompositeSynonyms) {
// Replace first occurrence of %27 with %101[2] in '%28 = OpCompositeConstruct
// %8 %27 %27'
auto instruction_descriptor_4 =
- MakeInstructionDescriptor(28, SpvOpCompositeConstruct, 0);
+ MakeInstructionDescriptor(28, spv::Op::OpCompositeConstruct, 0);
auto extract_4 =
TransformationCompositeExtract(instruction_descriptor_4, 204, 101, {2});
ASSERT_TRUE(extract_4.IsApplicable(context.get(), transformation_context));
@@ -672,7 +677,8 @@ TEST(DataSynonymTransformationTest, StructCompositeSynonyms) {
kConsoleMessageConsumer));
// Replace %22 with %102[0] in 'OpStore %23 %22'
- auto instruction_descriptor_5 = MakeInstructionDescriptor(23, SpvOpStore, 0);
+ auto instruction_descriptor_5 =
+ MakeInstructionDescriptor(23, spv::Op::OpStore, 0);
auto extract_5 =
TransformationCompositeExtract(instruction_descriptor_5, 205, 102, {0});
ASSERT_TRUE(extract_5.IsApplicable(context.get(), transformation_context));
@@ -931,7 +937,7 @@ TEST(DataSynonymTransformationTest, VectorCompositeSynonyms) {
// Replace %20 with %100[0:2] in '%80 = OpCopyObject %16 %20'
auto instruction_descriptor_1 =
- MakeInstructionDescriptor(80, SpvOpCopyObject, 0);
+ MakeInstructionDescriptor(80, spv::Op::OpCopyObject, 0);
auto shuffle_1 = TransformationVectorShuffle(instruction_descriptor_1, 200,
100, 100, {0, 1, 2});
ASSERT_TRUE(shuffle_1.IsApplicable(context.get(), transformation_context));
@@ -948,7 +954,7 @@ TEST(DataSynonymTransformationTest, VectorCompositeSynonyms) {
// Replace %54 with %100[3] in '%56 = OpFOrdNotEqual %30 %54 %55'
auto instruction_descriptor_2 =
- MakeInstructionDescriptor(56, SpvOpFOrdNotEqual, 0);
+ MakeInstructionDescriptor(56, spv::Op::OpFOrdNotEqual, 0);
auto extract_2 =
TransformationCompositeExtract(instruction_descriptor_2, 201, 100, {3});
@@ -963,7 +969,8 @@ TEST(DataSynonymTransformationTest, VectorCompositeSynonyms) {
kConsoleMessageConsumer));
// Replace %15 with %101[0:1] in 'OpStore %12 %15'
- auto instruction_descriptor_3 = MakeInstructionDescriptor(64, SpvOpStore, 0);
+ auto instruction_descriptor_3 =
+ MakeInstructionDescriptor(64, spv::Op::OpStore, 0);
auto shuffle_3 = TransformationVectorShuffle(instruction_descriptor_3, 202,
101, 101, {0, 1});
ASSERT_TRUE(shuffle_3.IsApplicable(context.get(), transformation_context));
@@ -980,7 +987,7 @@ TEST(DataSynonymTransformationTest, VectorCompositeSynonyms) {
// Replace %19 with %101[2:3] in '%81 = OpVectorShuffle %16 %19 %19 0 0 1'
auto instruction_descriptor_4 =
- MakeInstructionDescriptor(81, SpvOpVectorShuffle, 0);
+ MakeInstructionDescriptor(81, spv::Op::OpVectorShuffle, 0);
auto shuffle_4 = TransformationVectorShuffle(instruction_descriptor_4, 203,
101, 101, {2, 3});
ASSERT_TRUE(shuffle_4.IsApplicable(context.get(), transformation_context));
@@ -998,7 +1005,7 @@ TEST(DataSynonymTransformationTest, VectorCompositeSynonyms) {
// Replace %27 with %102[0] in '%82 = OpCompositeConstruct %21 %26 %27 %28
// %25'
auto instruction_descriptor_5 =
- MakeInstructionDescriptor(82, SpvOpCompositeConstruct, 0);
+ MakeInstructionDescriptor(82, spv::Op::OpCompositeConstruct, 0);
auto extract_5 =
TransformationCompositeExtract(instruction_descriptor_5, 204, 102, {0});
@@ -1014,7 +1021,7 @@ TEST(DataSynonymTransformationTest, VectorCompositeSynonyms) {
// Replace %15 with %102[1:2] in '%83 = OpCopyObject %10 %15'
auto instruction_descriptor_6 =
- MakeInstructionDescriptor(83, SpvOpCopyObject, 0);
+ MakeInstructionDescriptor(83, spv::Op::OpCopyObject, 0);
auto shuffle_6 = TransformationVectorShuffle(instruction_descriptor_6, 205,
102, 102, {1, 2});
ASSERT_TRUE(shuffle_6.IsApplicable(context.get(), transformation_context));
@@ -1031,7 +1038,7 @@ TEST(DataSynonymTransformationTest, VectorCompositeSynonyms) {
// Replace %33 with %103[0] in '%86 = OpCopyObject %30 %33'
auto instruction_descriptor_7 =
- MakeInstructionDescriptor(86, SpvOpCopyObject, 0);
+ MakeInstructionDescriptor(86, spv::Op::OpCopyObject, 0);
auto extract_7 =
TransformationCompositeExtract(instruction_descriptor_7, 206, 103, {0});
ASSERT_TRUE(extract_7.IsApplicable(context.get(), transformation_context));
@@ -1046,7 +1053,7 @@ TEST(DataSynonymTransformationTest, VectorCompositeSynonyms) {
// Replace %47 with %103[1:3] in '%84 = OpCopyObject %39 %47'
auto instruction_descriptor_8 =
- MakeInstructionDescriptor(84, SpvOpCopyObject, 0);
+ MakeInstructionDescriptor(84, spv::Op::OpCopyObject, 0);
auto shuffle_8 = TransformationVectorShuffle(instruction_descriptor_8, 207,
103, 103, {1, 2, 3});
ASSERT_TRUE(shuffle_8.IsApplicable(context.get(), transformation_context));
@@ -1063,7 +1070,7 @@ TEST(DataSynonymTransformationTest, VectorCompositeSynonyms) {
// Replace %42 with %104[0] in '%85 = OpCopyObject %30 %42'
auto instruction_descriptor_9 =
- MakeInstructionDescriptor(85, SpvOpCopyObject, 0);
+ MakeInstructionDescriptor(85, spv::Op::OpCopyObject, 0);
auto extract_9 =
TransformationCompositeExtract(instruction_descriptor_9, 208, 104, {0});
ASSERT_TRUE(extract_9.IsApplicable(context.get(), transformation_context));
@@ -1078,7 +1085,7 @@ TEST(DataSynonymTransformationTest, VectorCompositeSynonyms) {
// Replace %45 with %104[1] in '%63 = OpLogicalOr %30 %45 %46'
auto instruction_descriptor_10 =
- MakeInstructionDescriptor(63, SpvOpLogicalOr, 0);
+ MakeInstructionDescriptor(63, spv::Op::OpLogicalOr, 0);
auto extract_10 =
TransformationCompositeExtract(instruction_descriptor_10, 209, 104, {1});
ASSERT_TRUE(extract_10.IsApplicable(context.get(), transformation_context));
@@ -1092,7 +1099,8 @@ TEST(DataSynonymTransformationTest, VectorCompositeSynonyms) {
kConsoleMessageConsumer));
// Replace %38 with %105[0:1] in 'OpStore %36 %38'
- auto instruction_descriptor_11 = MakeInstructionDescriptor(85, SpvOpStore, 0);
+ auto instruction_descriptor_11 =
+ MakeInstructionDescriptor(85, spv::Op::OpStore, 0);
auto shuffle_11 = TransformationVectorShuffle(instruction_descriptor_11, 210,
105, 105, {0, 1});
ASSERT_TRUE(shuffle_11.IsApplicable(context.get(), transformation_context));
@@ -1109,7 +1117,7 @@ TEST(DataSynonymTransformationTest, VectorCompositeSynonyms) {
// Replace %46 with %105[2] in '%62 = OpLogicalAnd %30 %45 %46'
auto instruction_descriptor_12 =
- MakeInstructionDescriptor(62, SpvOpLogicalAnd, 0);
+ MakeInstructionDescriptor(62, spv::Op::OpLogicalAnd, 0);
auto extract_12 =
TransformationCompositeExtract(instruction_descriptor_12, 211, 105, {2});
ASSERT_TRUE(extract_12.IsApplicable(context.get(), transformation_context));
diff --git a/test/fuzz/fact_manager/constant_uniform_facts_test.cpp b/test/fuzz/fact_manager/constant_uniform_facts_test.cpp
index 4d80f0a84..b267e3dc5 100644
--- a/test/fuzz/fact_manager/constant_uniform_facts_test.cpp
+++ b/test/fuzz/fact_manager/constant_uniform_facts_test.cpp
@@ -366,41 +366,41 @@ TEST(ConstantUniformFactsTest, ConstantsAvailableViaUniforms) {
opt::Instruction::OperandList operands = {
{SPV_OPERAND_TYPE_LITERAL_INTEGER, {1}}};
context->module()->AddGlobalValue(MakeUnique<opt::Instruction>(
- context.get(), SpvOpConstant, type_int32_id, 50, operands));
+ context.get(), spv::Op::OpConstant, type_int32_id, 50, operands));
operands = {{SPV_OPERAND_TYPE_LITERAL_INTEGER, {buffer_int32_min[0]}}};
context->module()->AddGlobalValue(MakeUnique<opt::Instruction>(
- context.get(), SpvOpConstant, type_int32_id, 51, operands));
+ context.get(), spv::Op::OpConstant, type_int32_id, 51, operands));
operands = {{SPV_OPERAND_TYPE_LITERAL_INTEGER, {buffer_int64_max[0]}},
{SPV_OPERAND_TYPE_LITERAL_INTEGER, {buffer_int64_max[1]}}};
context->module()->AddGlobalValue(MakeUnique<opt::Instruction>(
- context.get(), SpvOpConstant, type_int64_id, 52, operands));
+ context.get(), spv::Op::OpConstant, type_int64_id, 52, operands));
operands = {{SPV_OPERAND_TYPE_LITERAL_INTEGER, {1}}};
context->module()->AddGlobalValue(MakeUnique<opt::Instruction>(
- context.get(), SpvOpConstant, type_uint32_id, 53, operands));
+ context.get(), spv::Op::OpConstant, type_uint32_id, 53, operands));
operands = {{SPV_OPERAND_TYPE_LITERAL_INTEGER, {buffer_uint64_1[0]}},
{SPV_OPERAND_TYPE_LITERAL_INTEGER, {buffer_uint64_1[1]}}};
context->module()->AddGlobalValue(MakeUnique<opt::Instruction>(
- context.get(), SpvOpConstant, type_uint64_id, 54, operands));
+ context.get(), spv::Op::OpConstant, type_uint64_id, 54, operands));
operands = {{SPV_OPERAND_TYPE_LITERAL_INTEGER, {buffer_uint64_max[0]}},
{SPV_OPERAND_TYPE_LITERAL_INTEGER, {buffer_uint64_max[1]}}};
context->module()->AddGlobalValue(MakeUnique<opt::Instruction>(
- context.get(), SpvOpConstant, type_uint64_id, 55, operands));
+ context.get(), spv::Op::OpConstant, type_uint64_id, 55, operands));
operands = {{SPV_OPERAND_TYPE_LITERAL_INTEGER, {buffer_float_10[0]}}};
context->module()->AddGlobalValue(MakeUnique<opt::Instruction>(
- context.get(), SpvOpConstant, type_float_id, 56, operands));
+ context.get(), spv::Op::OpConstant, type_float_id, 56, operands));
operands = {{SPV_OPERAND_TYPE_LITERAL_INTEGER, {buffer_double_10[0]}},
{SPV_OPERAND_TYPE_LITERAL_INTEGER, {buffer_double_10[1]}}};
context->module()->AddGlobalValue(MakeUnique<opt::Instruction>(
- context.get(), SpvOpConstant, type_double_id, 57, operands));
+ context.get(), spv::Op::OpConstant, type_double_id, 57, operands));
operands = {{SPV_OPERAND_TYPE_LITERAL_INTEGER, {buffer_double_20[0]}},
{SPV_OPERAND_TYPE_LITERAL_INTEGER, {buffer_double_20[1]}}};
context->module()->AddGlobalValue(MakeUnique<opt::Instruction>(
- context.get(), SpvOpConstant, type_double_id, 58, operands));
+ context.get(), spv::Op::OpConstant, type_double_id, 58, operands));
// A duplicate of the constant with id 59.
operands = {{SPV_OPERAND_TYPE_LITERAL_INTEGER, {1}}};
context->module()->AddGlobalValue(MakeUnique<opt::Instruction>(
- context.get(), SpvOpConstant, type_int32_id, 59, operands));
+ context.get(), spv::Op::OpConstant, type_int32_id, 59, operands));
context->InvalidateAnalysesExceptFor(opt::IRContext::Analysis::kAnalysisNone);
diff --git a/test/fuzz/fact_manager/data_synonym_and_id_equation_facts_test.cpp b/test/fuzz/fact_manager/data_synonym_and_id_equation_facts_test.cpp
index 689d2e7dc..c3b47a469 100644
--- a/test/fuzz/fact_manager/data_synonym_and_id_equation_facts_test.cpp
+++ b/test/fuzz/fact_manager/data_synonym_and_id_equation_facts_test.cpp
@@ -136,15 +136,15 @@ TEST(DataSynonymAndIdEquationFactsTest, CorollaryConversionFacts) {
FactManager fact_manager(context.get());
// Add equation facts
- fact_manager.AddFactIdEquation(24, SpvOpConvertSToF, {15});
- fact_manager.AddFactIdEquation(25, SpvOpConvertSToF, {16});
- fact_manager.AddFactIdEquation(26, SpvOpConvertUToF, {17});
- fact_manager.AddFactIdEquation(27, SpvOpConvertSToF, {18});
- fact_manager.AddFactIdEquation(28, SpvOpConvertUToF, {19});
- fact_manager.AddFactIdEquation(29, SpvOpConvertUToF, {20});
- fact_manager.AddFactIdEquation(30, SpvOpConvertSToF, {21});
- fact_manager.AddFactIdEquation(31, SpvOpConvertUToF, {22});
- fact_manager.AddFactIdEquation(32, SpvOpConvertUToF, {23});
+ fact_manager.AddFactIdEquation(24, spv::Op::OpConvertSToF, {15});
+ fact_manager.AddFactIdEquation(25, spv::Op::OpConvertSToF, {16});
+ fact_manager.AddFactIdEquation(26, spv::Op::OpConvertUToF, {17});
+ fact_manager.AddFactIdEquation(27, spv::Op::OpConvertSToF, {18});
+ fact_manager.AddFactIdEquation(28, spv::Op::OpConvertUToF, {19});
+ fact_manager.AddFactIdEquation(29, spv::Op::OpConvertUToF, {20});
+ fact_manager.AddFactIdEquation(30, spv::Op::OpConvertSToF, {21});
+ fact_manager.AddFactIdEquation(31, spv::Op::OpConvertUToF, {22});
+ fact_manager.AddFactIdEquation(32, spv::Op::OpConvertUToF, {23});
fact_manager.AddFactDataSynonym(MakeDataDescriptor(15, {}),
MakeDataDescriptor(16, {}));
@@ -212,7 +212,7 @@ TEST(DataSynonymAndIdEquationFactsTest, HandlesCorollariesWithInvalidIds) {
// Add required facts.
transformation_context.GetFactManager()->AddFactIdEquation(
- 14, SpvOpConvertSToF, {9});
+ 14, spv::Op::OpConvertSToF, {9});
transformation_context.GetFactManager()->AddFactDataSynonym(
MakeDataDescriptor(14, {}), MakeDataDescriptor(17, {}));
@@ -232,7 +232,7 @@ TEST(DataSynonymAndIdEquationFactsTest, HandlesCorollariesWithInvalidIds) {
// Add another equation.
transformation_context.GetFactManager()->AddFactIdEquation(
- 15, SpvOpConvertSToF, {9});
+ 15, spv::Op::OpConvertSToF, {9});
// Check that two ids are synonymous even though one of them doesn't exist in
// the module (%17).
@@ -249,7 +249,7 @@ TEST(DataSynonymAndIdEquationFactsTest, HandlesCorollariesWithInvalidIds) {
ASSERT_TRUE(context->KillDef(15));
transformation_context.GetFactManager()->AddFactIdEquation(
- 18, SpvOpConvertSToF, {9});
+ 18, spv::Op::OpConvertSToF, {9});
CheckConsistencyOfSynonymFacts(context.get(), transformation_context);
@@ -294,8 +294,8 @@ TEST(DataSynonymAndIdEquationFactsTest, LogicalNotEquationFacts) {
MakeDataDescriptor(7, {}));
fact_manager.AddFactDataSynonym(MakeDataDescriptor(16, {}),
MakeDataDescriptor(14, {}));
- fact_manager.AddFactIdEquation(14, SpvOpLogicalNot, {7});
- fact_manager.AddFactIdEquation(17, SpvOpLogicalNot, {16});
+ fact_manager.AddFactIdEquation(14, spv::Op::OpLogicalNot, {7});
+ fact_manager.AddFactIdEquation(17, spv::Op::OpLogicalNot, {16});
ASSERT_TRUE(fact_manager.IsSynonymous(MakeDataDescriptor(15, {}),
MakeDataDescriptor(7, {})));
@@ -336,8 +336,8 @@ TEST(DataSynonymAndIdEquationFactsTest, SignedNegateEquationFacts) {
FactManager fact_manager(context.get());
- fact_manager.AddFactIdEquation(14, SpvOpSNegate, {7});
- fact_manager.AddFactIdEquation(15, SpvOpSNegate, {14});
+ fact_manager.AddFactIdEquation(14, spv::Op::OpSNegate, {7});
+ fact_manager.AddFactIdEquation(15, spv::Op::OpSNegate, {14});
ASSERT_TRUE(fact_manager.IsSynonymous(MakeDataDescriptor(7, {}),
MakeDataDescriptor(15, {})));
@@ -380,19 +380,19 @@ TEST(DataSynonymAndIdEquationFactsTest, AddSubNegateFacts1) {
FactManager fact_manager(context.get());
- fact_manager.AddFactIdEquation(14, SpvOpIAdd, {15, 16});
+ fact_manager.AddFactIdEquation(14, spv::Op::OpIAdd, {15, 16});
fact_manager.AddFactDataSynonym(MakeDataDescriptor(17, {}),
MakeDataDescriptor(15, {}));
fact_manager.AddFactDataSynonym(MakeDataDescriptor(18, {}),
MakeDataDescriptor(16, {}));
- fact_manager.AddFactIdEquation(19, SpvOpISub, {14, 18});
- fact_manager.AddFactIdEquation(20, SpvOpISub, {14, 17});
+ fact_manager.AddFactIdEquation(19, spv::Op::OpISub, {14, 18});
+ fact_manager.AddFactIdEquation(20, spv::Op::OpISub, {14, 17});
fact_manager.AddFactDataSynonym(MakeDataDescriptor(21, {}),
MakeDataDescriptor(14, {}));
- fact_manager.AddFactIdEquation(22, SpvOpISub, {16, 21});
+ fact_manager.AddFactIdEquation(22, spv::Op::OpISub, {16, 21});
fact_manager.AddFactDataSynonym(MakeDataDescriptor(23, {}),
MakeDataDescriptor(22, {}));
- fact_manager.AddFactIdEquation(24, SpvOpSNegate, {23});
+ fact_manager.AddFactIdEquation(24, spv::Op::OpSNegate, {23});
ASSERT_TRUE(fact_manager.IsSynonymous(MakeDataDescriptor(19, {}),
MakeDataDescriptor(15, {})));
@@ -438,31 +438,31 @@ TEST(DataSynonymAndIdEquationFactsTest, AddSubNegateFacts2) {
FactManager fact_manager(context.get());
- fact_manager.AddFactIdEquation(14, SpvOpISub, {15, 16});
- fact_manager.AddFactIdEquation(17, SpvOpIAdd, {14, 16});
+ fact_manager.AddFactIdEquation(14, spv::Op::OpISub, {15, 16});
+ fact_manager.AddFactIdEquation(17, spv::Op::OpIAdd, {14, 16});
ASSERT_TRUE(fact_manager.IsSynonymous(MakeDataDescriptor(17, {}),
MakeDataDescriptor(15, {})));
- fact_manager.AddFactIdEquation(18, SpvOpIAdd, {16, 14});
+ fact_manager.AddFactIdEquation(18, spv::Op::OpIAdd, {16, 14});
ASSERT_TRUE(fact_manager.IsSynonymous(MakeDataDescriptor(18, {}),
MakeDataDescriptor(15, {})));
ASSERT_TRUE(fact_manager.IsSynonymous(MakeDataDescriptor(17, {}),
MakeDataDescriptor(18, {})));
- fact_manager.AddFactIdEquation(19, SpvOpISub, {14, 15});
- fact_manager.AddFactIdEquation(20, SpvOpSNegate, {19});
+ fact_manager.AddFactIdEquation(19, spv::Op::OpISub, {14, 15});
+ fact_manager.AddFactIdEquation(20, spv::Op::OpSNegate, {19});
ASSERT_TRUE(fact_manager.IsSynonymous(MakeDataDescriptor(20, {}),
MakeDataDescriptor(16, {})));
- fact_manager.AddFactIdEquation(21, SpvOpISub, {14, 19});
+ fact_manager.AddFactIdEquation(21, spv::Op::OpISub, {14, 19});
ASSERT_TRUE(fact_manager.IsSynonymous(MakeDataDescriptor(21, {}),
MakeDataDescriptor(15, {})));
- fact_manager.AddFactIdEquation(22, SpvOpISub, {14, 18});
- fact_manager.AddFactIdEquation(23, SpvOpSNegate, {22});
+ fact_manager.AddFactIdEquation(22, spv::Op::OpISub, {14, 18});
+ fact_manager.AddFactIdEquation(23, spv::Op::OpSNegate, {22});
ASSERT_TRUE(fact_manager.IsSynonymous(MakeDataDescriptor(23, {}),
MakeDataDescriptor(16, {})));
}
@@ -525,31 +525,31 @@ TEST(DataSynonymAndIdEquationFactsTest, ConversionEquations) {
fact_manager.AddFactDataSynonym(MakeDataDescriptor(22, {}),
MakeDataDescriptor(23, {}));
- fact_manager.AddFactIdEquation(25, SpvOpConvertUToF, {16});
- fact_manager.AddFactIdEquation(26, SpvOpConvertUToF, {17});
+ fact_manager.AddFactIdEquation(25, spv::Op::OpConvertUToF, {16});
+ fact_manager.AddFactIdEquation(26, spv::Op::OpConvertUToF, {17});
ASSERT_TRUE(fact_manager.IsSynonymous(MakeDataDescriptor(25, {}),
MakeDataDescriptor(26, {})));
- fact_manager.AddFactIdEquation(27, SpvOpConvertSToF, {20});
- fact_manager.AddFactIdEquation(28, SpvOpConvertUToF, {21});
+ fact_manager.AddFactIdEquation(27, spv::Op::OpConvertSToF, {20});
+ fact_manager.AddFactIdEquation(28, spv::Op::OpConvertUToF, {21});
ASSERT_FALSE(fact_manager.IsSynonymous(MakeDataDescriptor(27, {}),
MakeDataDescriptor(28, {})));
- fact_manager.AddFactIdEquation(29, SpvOpConvertSToF, {18});
- fact_manager.AddFactIdEquation(30, SpvOpConvertUToF, {19});
+ fact_manager.AddFactIdEquation(29, spv::Op::OpConvertSToF, {18});
+ fact_manager.AddFactIdEquation(30, spv::Op::OpConvertUToF, {19});
ASSERT_FALSE(fact_manager.IsSynonymous(MakeDataDescriptor(29, {}),
MakeDataDescriptor(30, {})));
- fact_manager.AddFactIdEquation(31, SpvOpConvertSToF, {22});
- fact_manager.AddFactIdEquation(32, SpvOpConvertSToF, {23});
+ fact_manager.AddFactIdEquation(31, spv::Op::OpConvertSToF, {22});
+ fact_manager.AddFactIdEquation(32, spv::Op::OpConvertSToF, {23});
ASSERT_TRUE(fact_manager.IsSynonymous(MakeDataDescriptor(31, {}),
MakeDataDescriptor(32, {})));
- fact_manager.AddFactIdEquation(33, SpvOpConvertUToF, {17});
+ fact_manager.AddFactIdEquation(33, spv::Op::OpConvertUToF, {17});
ASSERT_TRUE(fact_manager.IsSynonymous(MakeDataDescriptor(33, {}),
MakeDataDescriptor(26, {})));
- fact_manager.AddFactIdEquation(34, SpvOpConvertSToF, {23});
+ fact_manager.AddFactIdEquation(34, spv::Op::OpConvertSToF, {23});
ASSERT_TRUE(fact_manager.IsSynonymous(MakeDataDescriptor(32, {}),
MakeDataDescriptor(34, {})));
}
@@ -605,7 +605,7 @@ TEST(DataSynonymAndIdEquationFactsTest, BitcastEquationFacts) {
uint32_t lhs_id = 30;
for (uint32_t rhs_id : {6, 6, 7, 7, 19, 19, 20, 20, 21, 21, 22, 22}) {
- fact_manager.AddFactIdEquation(lhs_id, SpvOpBitcast, {rhs_id});
+ fact_manager.AddFactIdEquation(lhs_id, spv::Op::OpBitcast, {rhs_id});
ASSERT_TRUE(fact_manager.IsSynonymous(MakeDataDescriptor(lhs_id, {}),
MakeDataDescriptor(rhs_id, {})));
++lhs_id;
@@ -651,37 +651,37 @@ TEST(DataSynonymAndIdEquationFactsTest, EquationAndEquivalenceFacts) {
FactManager fact_manager(context.get());
- fact_manager.AddFactIdEquation(14, SpvOpISub, {15, 16});
+ fact_manager.AddFactIdEquation(14, spv::Op::OpISub, {15, 16});
fact_manager.AddFactDataSynonym(MakeDataDescriptor(114, {}),
MakeDataDescriptor(14, {}));
- fact_manager.AddFactIdEquation(17, SpvOpIAdd, {114, 16});
+ fact_manager.AddFactIdEquation(17, spv::Op::OpIAdd, {114, 16});
ASSERT_TRUE(fact_manager.IsSynonymous(MakeDataDescriptor(17, {}),
MakeDataDescriptor(15, {})));
- fact_manager.AddFactIdEquation(18, SpvOpIAdd, {16, 114});
+ fact_manager.AddFactIdEquation(18, spv::Op::OpIAdd, {16, 114});
ASSERT_TRUE(fact_manager.IsSynonymous(MakeDataDescriptor(18, {}),
MakeDataDescriptor(15, {})));
ASSERT_TRUE(fact_manager.IsSynonymous(MakeDataDescriptor(17, {}),
MakeDataDescriptor(18, {})));
- fact_manager.AddFactIdEquation(19, SpvOpISub, {14, 15});
+ fact_manager.AddFactIdEquation(19, spv::Op::OpISub, {14, 15});
fact_manager.AddFactDataSynonym(MakeDataDescriptor(119, {}),
MakeDataDescriptor(19, {}));
- fact_manager.AddFactIdEquation(20, SpvOpSNegate, {119});
+ fact_manager.AddFactIdEquation(20, spv::Op::OpSNegate, {119});
ASSERT_TRUE(fact_manager.IsSynonymous(MakeDataDescriptor(20, {}),
MakeDataDescriptor(16, {})));
- fact_manager.AddFactIdEquation(21, SpvOpISub, {14, 19});
+ fact_manager.AddFactIdEquation(21, spv::Op::OpISub, {14, 19});
ASSERT_TRUE(fact_manager.IsSynonymous(MakeDataDescriptor(21, {}),
MakeDataDescriptor(15, {})));
- fact_manager.AddFactIdEquation(22, SpvOpISub, {14, 18});
+ fact_manager.AddFactIdEquation(22, spv::Op::OpISub, {14, 18});
fact_manager.AddFactDataSynonym(MakeDataDescriptor(22, {}),
MakeDataDescriptor(220, {}));
- fact_manager.AddFactIdEquation(23, SpvOpSNegate, {220});
+ fact_manager.AddFactIdEquation(23, spv::Op::OpSNegate, {220});
ASSERT_TRUE(fact_manager.IsSynonymous(MakeDataDescriptor(23, {}),
MakeDataDescriptor(16, {})));
}
diff --git a/test/fuzz/fuzzer_pass_donate_modules_test.cpp b/test/fuzz/fuzzer_pass_donate_modules_test.cpp
index fe8e671d1..81687ac30 100644
--- a/test/fuzz/fuzzer_pass_donate_modules_test.cpp
+++ b/test/fuzz/fuzzer_pass_donate_modules_test.cpp
@@ -2025,9 +2025,9 @@ TEST(FuzzerPassDonateModulesTest, HandlesCapabilities) {
&transformation_sequence, false, {});
ASSERT_TRUE(donor_context->get_feature_mgr()->HasCapability(
- SpvCapabilityVariablePointersStorageBuffer));
+ spv::Capability::VariablePointersStorageBuffer));
ASSERT_FALSE(recipient_context->get_feature_mgr()->HasCapability(
- SpvCapabilityVariablePointersStorageBuffer));
+ spv::Capability::VariablePointersStorageBuffer));
fuzzer_pass.DonateSingleModule(donor_context.get(), false);
@@ -2040,12 +2040,12 @@ TEST(FuzzerPassDonateModulesTest, HandlesCapabilities) {
// have different OpCapability instructions but the same capabilities. In our
// example, VariablePointers implicitly declares
// VariablePointersStorageBuffer. Thus, two modules must be compatible.
- recipient_context->AddCapability(SpvCapabilityVariablePointers);
+ recipient_context->AddCapability(spv::Capability::VariablePointers);
ASSERT_TRUE(donor_context->get_feature_mgr()->HasCapability(
- SpvCapabilityVariablePointersStorageBuffer));
+ spv::Capability::VariablePointersStorageBuffer));
ASSERT_TRUE(recipient_context->get_feature_mgr()->HasCapability(
- SpvCapabilityVariablePointersStorageBuffer));
+ spv::Capability::VariablePointersStorageBuffer));
fuzzer_pass.DonateSingleModule(donor_context.get(), false);
diff --git a/test/fuzz/fuzzerutil_test.cpp b/test/fuzz/fuzzerutil_test.cpp
index 1286d38dd..65553367f 100644
--- a/test/fuzz/fuzzerutil_test.cpp
+++ b/test/fuzz/fuzzerutil_test.cpp
@@ -939,9 +939,9 @@ TEST(FuzzerutilTest, FuzzerUtilMaybeGetPointerTypeTest) {
kConsoleMessageConsumer));
opt::IRContext* ir_context = context.get();
- auto private_storage_class = SpvStorageClassPrivate;
- auto function_storage_class = SpvStorageClassFunction;
- auto input_storage_class = SpvStorageClassInput;
+ auto private_storage_class = spv::StorageClass::Private;
+ auto function_storage_class = spv::StorageClass::Function;
+ auto input_storage_class = spv::StorageClass::Input;
// A valid pointer must have the correct |pointee_type_id| and |storageClass|.
// A function type pointer with id = 9 and pointee type id 8 should be found.
@@ -1610,196 +1610,206 @@ TEST(FuzzerutilTest, TypesAreCompatible) {
// OpAtomicLoad
#ifndef NDEBUG
- ASSERT_DEATH(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicLoad, 0,
- int_type, uint_type),
- "Signedness check should not occur on a pointer operand.");
+ ASSERT_DEATH(
+ fuzzerutil::TypesAreCompatible(context.get(), spv::Op::OpAtomicLoad, 0,
+ int_type, uint_type),
+ "Signedness check should not occur on a pointer operand.");
#endif
- ASSERT_TRUE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicLoad, 1,
- int_type, uint_type));
- ASSERT_TRUE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicLoad, 2,
- int_type, uint_type));
+ ASSERT_TRUE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicLoad, 1, int_type, uint_type));
+ ASSERT_TRUE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicLoad, 2, int_type, uint_type));
// OpAtomicExchange
#ifndef NDEBUG
- ASSERT_DEATH(fuzzerutil::TypesAreCompatible(
- context.get(), SpvOpAtomicExchange, 0, int_type, uint_type),
- "Signedness check should not occur on a pointer operand.");
+ ASSERT_DEATH(
+ fuzzerutil::TypesAreCompatible(context.get(), spv::Op::OpAtomicExchange,
+ 0, int_type, uint_type),
+ "Signedness check should not occur on a pointer operand.");
#endif
- ASSERT_TRUE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicExchange,
- 1, int_type, uint_type));
- ASSERT_TRUE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicExchange,
- 2, int_type, uint_type));
+ ASSERT_TRUE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicExchange, 1, int_type, uint_type));
+ ASSERT_TRUE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicExchange, 2, int_type, uint_type));
ASSERT_FALSE(fuzzerutil::TypesAreCompatible(
- context.get(), SpvOpAtomicExchange, 3, int_type, uint_type));
+ context.get(), spv::Op::OpAtomicExchange, 3, int_type, uint_type));
// OpAtomicStore
#ifndef NDEBUG
- ASSERT_DEATH(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicStore,
- 0, int_type, uint_type),
- "Signedness check should not occur on a pointer operand.");
+ ASSERT_DEATH(
+ fuzzerutil::TypesAreCompatible(context.get(), spv::Op::OpAtomicStore, 0,
+ int_type, uint_type),
+ "Signedness check should not occur on a pointer operand.");
#endif
- ASSERT_TRUE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicStore, 1,
- int_type, uint_type));
- ASSERT_TRUE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicStore, 2,
- int_type, uint_type));
- ASSERT_FALSE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicStore,
- 3, int_type, uint_type));
+ ASSERT_TRUE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicStore, 1, int_type, uint_type));
+ ASSERT_TRUE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicStore, 2, int_type, uint_type));
+ ASSERT_FALSE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicStore, 3, int_type, uint_type));
// OpAtomicCompareExchange
#ifndef NDEBUG
- ASSERT_DEATH(
- fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicCompareExchange,
- 0, int_type, uint_type),
- "Signedness check should not occur on a pointer operand.");
+ ASSERT_DEATH(fuzzerutil::TypesAreCompatible(context.get(),
+ spv::Op::OpAtomicCompareExchange,
+ 0, int_type, uint_type),
+ "Signedness check should not occur on a pointer operand.");
#endif
ASSERT_TRUE(fuzzerutil::TypesAreCompatible(
- context.get(), SpvOpAtomicCompareExchange, 1, int_type, uint_type));
+ context.get(), spv::Op::OpAtomicCompareExchange, 1, int_type, uint_type));
ASSERT_TRUE(fuzzerutil::TypesAreCompatible(
- context.get(), SpvOpAtomicCompareExchange, 2, int_type, uint_type));
+ context.get(), spv::Op::OpAtomicCompareExchange, 2, int_type, uint_type));
ASSERT_TRUE(fuzzerutil::TypesAreCompatible(
- context.get(), SpvOpAtomicCompareExchange, 3, int_type, uint_type));
+ context.get(), spv::Op::OpAtomicCompareExchange, 3, int_type, uint_type));
ASSERT_FALSE(fuzzerutil::TypesAreCompatible(
- context.get(), SpvOpAtomicCompareExchange, 4, int_type, uint_type));
+ context.get(), spv::Op::OpAtomicCompareExchange, 4, int_type, uint_type));
// OpAtomicIIncrement
#ifndef NDEBUG
ASSERT_DEATH(
- fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicIIncrement, 0,
- int_type, uint_type),
+ fuzzerutil::TypesAreCompatible(context.get(), spv::Op::OpAtomicIIncrement,
+ 0, int_type, uint_type),
"Signedness check should not occur on a pointer operand.");
#endif
ASSERT_TRUE(fuzzerutil::TypesAreCompatible(
- context.get(), SpvOpAtomicIIncrement, 1, int_type, uint_type));
+ context.get(), spv::Op::OpAtomicIIncrement, 1, int_type, uint_type));
ASSERT_TRUE(fuzzerutil::TypesAreCompatible(
- context.get(), SpvOpAtomicIIncrement, 2, int_type, uint_type));
+ context.get(), spv::Op::OpAtomicIIncrement, 2, int_type, uint_type));
// OpAtomicIDecrement
#ifndef NDEBUG
- ASSERT_DEATH(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicStore,
- 0, int_type, uint_type),
- "Signedness check should not occur on a pointer operand.");
+ ASSERT_DEATH(
+ fuzzerutil::TypesAreCompatible(context.get(), spv::Op::OpAtomicStore, 0,
+ int_type, uint_type),
+ "Signedness check should not occur on a pointer operand.");
#endif
- ASSERT_TRUE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicStore, 1,
- int_type, uint_type));
- ASSERT_TRUE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicStore, 2,
- int_type, uint_type));
+ ASSERT_TRUE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicStore, 1, int_type, uint_type));
+ ASSERT_TRUE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicStore, 2, int_type, uint_type));
// OpAtomicIAdd
#ifndef NDEBUG
- ASSERT_DEATH(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicIAdd, 0,
- int_type, uint_type),
- "Signedness check should not occur on a pointer operand.");
+ ASSERT_DEATH(
+ fuzzerutil::TypesAreCompatible(context.get(), spv::Op::OpAtomicIAdd, 0,
+ int_type, uint_type),
+ "Signedness check should not occur on a pointer operand.");
#endif
- ASSERT_TRUE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicIAdd, 1,
- int_type, uint_type));
- ASSERT_TRUE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicIAdd, 2,
- int_type, uint_type));
- ASSERT_FALSE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicIAdd, 3,
- int_type, uint_type));
+ ASSERT_TRUE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicIAdd, 1, int_type, uint_type));
+ ASSERT_TRUE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicIAdd, 2, int_type, uint_type));
+ ASSERT_FALSE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicIAdd, 3, int_type, uint_type));
// OpAtomicISub
#ifndef NDEBUG
- ASSERT_DEATH(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicISub, 0,
- int_type, uint_type),
- "Signedness check should not occur on a pointer operand.");
+ ASSERT_DEATH(
+ fuzzerutil::TypesAreCompatible(context.get(), spv::Op::OpAtomicISub, 0,
+ int_type, uint_type),
+ "Signedness check should not occur on a pointer operand.");
#endif
- ASSERT_TRUE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicISub, 1,
- int_type, uint_type));
- ASSERT_TRUE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicISub, 2,
- int_type, uint_type));
- ASSERT_FALSE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicISub, 3,
- int_type, uint_type));
+ ASSERT_TRUE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicISub, 1, int_type, uint_type));
+ ASSERT_TRUE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicISub, 2, int_type, uint_type));
+ ASSERT_FALSE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicISub, 3, int_type, uint_type));
// OpAtomicSMin
#ifndef NDEBUG
- ASSERT_DEATH(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicSMin, 0,
- int_type, uint_type),
- "Signedness check should not occur on a pointer operand.");
+ ASSERT_DEATH(
+ fuzzerutil::TypesAreCompatible(context.get(), spv::Op::OpAtomicSMin, 0,
+ int_type, uint_type),
+ "Signedness check should not occur on a pointer operand.");
#endif
- ASSERT_TRUE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicSMin, 1,
- int_type, uint_type));
- ASSERT_TRUE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicSMin, 2,
- int_type, uint_type));
- ASSERT_FALSE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicSMin, 3,
- int_type, uint_type));
+ ASSERT_TRUE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicSMin, 1, int_type, uint_type));
+ ASSERT_TRUE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicSMin, 2, int_type, uint_type));
+ ASSERT_FALSE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicSMin, 3, int_type, uint_type));
// OpAtomicUMin
#ifndef NDEBUG
- ASSERT_DEATH(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicUMin, 0,
- int_type, uint_type),
- "Signedness check should not occur on a pointer operand.");
+ ASSERT_DEATH(
+ fuzzerutil::TypesAreCompatible(context.get(), spv::Op::OpAtomicUMin, 0,
+ int_type, uint_type),
+ "Signedness check should not occur on a pointer operand.");
#endif
- ASSERT_TRUE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicUMin, 1,
- int_type, uint_type));
- ASSERT_TRUE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicUMin, 2,
- int_type, uint_type));
- ASSERT_FALSE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicUMin, 3,
- int_type, uint_type));
+ ASSERT_TRUE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicUMin, 1, int_type, uint_type));
+ ASSERT_TRUE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicUMin, 2, int_type, uint_type));
+ ASSERT_FALSE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicUMin, 3, int_type, uint_type));
// OpAtomicSMax
#ifndef NDEBUG
- ASSERT_DEATH(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicSMax, 0,
- int_type, uint_type),
- "Signedness check should not occur on a pointer operand.");
+ ASSERT_DEATH(
+ fuzzerutil::TypesAreCompatible(context.get(), spv::Op::OpAtomicSMax, 0,
+ int_type, uint_type),
+ "Signedness check should not occur on a pointer operand.");
#endif
- ASSERT_TRUE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicSMax, 1,
- int_type, uint_type));
- ASSERT_TRUE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicSMax, 2,
- int_type, uint_type));
- ASSERT_FALSE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicSMax, 3,
- int_type, uint_type));
+ ASSERT_TRUE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicSMax, 1, int_type, uint_type));
+ ASSERT_TRUE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicSMax, 2, int_type, uint_type));
+ ASSERT_FALSE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicSMax, 3, int_type, uint_type));
// OpAtomicUMax
#ifndef NDEBUG
- ASSERT_DEATH(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicUMax, 0,
- int_type, uint_type),
- "Signedness check should not occur on a pointer operand.");
+ ASSERT_DEATH(
+ fuzzerutil::TypesAreCompatible(context.get(), spv::Op::OpAtomicUMax, 0,
+ int_type, uint_type),
+ "Signedness check should not occur on a pointer operand.");
#endif
- ASSERT_TRUE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicUMax, 1,
- int_type, uint_type));
- ASSERT_TRUE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicUMax, 2,
- int_type, uint_type));
- ASSERT_FALSE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicUMax, 3,
- int_type, uint_type));
+ ASSERT_TRUE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicUMax, 1, int_type, uint_type));
+ ASSERT_TRUE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicUMax, 2, int_type, uint_type));
+ ASSERT_FALSE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicUMax, 3, int_type, uint_type));
// OpAtomicAnd
#ifndef NDEBUG
- ASSERT_DEATH(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicAnd, 0,
- int_type, uint_type),
+ ASSERT_DEATH(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicAnd, 0, int_type, uint_type),
"Signedness check should not occur on a pointer operand.");
#endif
- ASSERT_TRUE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicAnd, 1,
- int_type, uint_type));
- ASSERT_TRUE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicAnd, 2,
- int_type, uint_type));
- ASSERT_FALSE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicAnd, 3,
- int_type, uint_type));
+ ASSERT_TRUE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicAnd, 1, int_type, uint_type));
+ ASSERT_TRUE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicAnd, 2, int_type, uint_type));
+ ASSERT_FALSE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicAnd, 3, int_type, uint_type));
// OpAtomicOr
#ifndef NDEBUG
- ASSERT_DEATH(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicOr, 0,
- int_type, uint_type),
+ ASSERT_DEATH(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicOr, 0, int_type, uint_type),
"Signedness check should not occur on a pointer operand.");
#endif
- ASSERT_TRUE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicOr, 1,
- int_type, uint_type));
- ASSERT_TRUE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicOr, 2,
- int_type, uint_type));
- ASSERT_FALSE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicOr, 3,
- int_type, uint_type));
+ ASSERT_TRUE(fuzzerutil::TypesAreCompatible(context.get(), spv::Op::OpAtomicOr,
+ 1, int_type, uint_type));
+ ASSERT_TRUE(fuzzerutil::TypesAreCompatible(context.get(), spv::Op::OpAtomicOr,
+ 2, int_type, uint_type));
+ ASSERT_FALSE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicOr, 3, int_type, uint_type));
// OpAtomicXor
#ifndef NDEBUG
- ASSERT_DEATH(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicXor, 0,
- int_type, uint_type),
+ ASSERT_DEATH(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicXor, 0, int_type, uint_type),
"Signedness check should not occur on a pointer operand.");
#endif
- ASSERT_TRUE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicXor, 1,
- int_type, uint_type));
- ASSERT_TRUE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicXor, 2,
- int_type, uint_type));
- ASSERT_FALSE(fuzzerutil::TypesAreCompatible(context.get(), SpvOpAtomicXor, 3,
- int_type, uint_type));
+ ASSERT_TRUE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicXor, 1, int_type, uint_type));
+ ASSERT_TRUE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicXor, 2, int_type, uint_type));
+ ASSERT_FALSE(fuzzerutil::TypesAreCompatible(
+ context.get(), spv::Op::OpAtomicXor, 3, int_type, uint_type));
}
} // namespace
diff --git a/test/fuzz/replayer_test.cpp b/test/fuzz/replayer_test.cpp
index 151f26326..b87d4f8eb 100644
--- a/test/fuzz/replayer_test.cpp
+++ b/test/fuzz/replayer_test.cpp
@@ -90,8 +90,8 @@ TEST(ReplayerTest, PartialReplay) {
protobufs::TransformationSequence transformations;
for (uint32_t id = 12; id <= 22; id++) {
*transformations.add_transformation() =
- TransformationSplitBlock(MakeInstructionDescriptor(id, SpvOpLoad, 0),
- id + 100)
+ TransformationSplitBlock(
+ MakeInstructionDescriptor(id, spv::Op::OpLoad, 0), id + 100)
.ToMessage();
}
@@ -335,7 +335,7 @@ TEST(ReplayerTest, CheckFactsAfterReplay) {
*transformations.add_transformation() =
TransformationAddConstantScalar(100, 8, {42}, true).ToMessage();
*transformations.add_transformation() =
- TransformationAddGlobalVariable(101, 50, SpvStorageClassPrivate, 100,
+ TransformationAddGlobalVariable(101, 50, spv::StorageClass::Private, 100,
true)
.ToMessage();
*transformations.add_transformation() =
@@ -345,7 +345,7 @@ TEST(ReplayerTest, CheckFactsAfterReplay) {
11,
protobufs::TransformationAddSynonym::SynonymType::
TransformationAddSynonym_SynonymType_COPY_OBJECT,
- 104, MakeInstructionDescriptor(12, SpvOpFunctionCall, 0))
+ 104, MakeInstructionDescriptor(12, spv::Op::OpFunctionCall, 0))
.ToMessage();
// Full replay
@@ -455,7 +455,8 @@ TEST(ReplayerTest, ReplayWithOverflowIds) {
*transformations.add_transformation() =
TransformationFlattenConditionalBranch(5, true, 0, 0, 0, {}).ToMessage();
*transformations.add_transformation() =
- TransformationAddGlobalVariable(101, 50, SpvStorageClassPrivate, 11, true)
+ TransformationAddGlobalVariable(101, 50, spv::StorageClass::Private, 11,
+ true)
.ToMessage();
protobufs::FactSequence empty_facts;
diff --git a/test/fuzz/shrinker_test.cpp b/test/fuzz/shrinker_test.cpp
index 942de29a3..699730c3f 100644
--- a/test/fuzz/shrinker_test.cpp
+++ b/test/fuzz/shrinker_test.cpp
@@ -186,9 +186,9 @@ TEST(ShrinkerTest, ReduceAddedFunctions) {
for (auto& function : *temp_ir_context->module()) {
for (auto& block : function) {
for (auto& inst : block) {
- if (inst.opcode() == SpvOpNot) {
+ if (inst.opcode() == spv::Op::OpNot) {
found_op_not = true;
- } else if (inst.opcode() == SpvOpFunctionCall) {
+ } else if (inst.opcode() == spv::Op::OpFunctionCall) {
op_call_count++;
}
}
@@ -221,21 +221,21 @@ TEST(ShrinkerTest, ReduceAddedFunctions) {
for (auto& inst : block) {
switch (counter) {
case 0:
- ASSERT_EQ(SpvOpVariable, inst.opcode());
+ ASSERT_EQ(spv::Op::OpVariable, inst.opcode());
ASSERT_EQ(11, inst.result_id());
break;
case 1:
- ASSERT_EQ(SpvOpStore, inst.opcode());
+ ASSERT_EQ(spv::Op::OpStore, inst.opcode());
break;
case 2:
- ASSERT_EQ(SpvOpLoad, inst.opcode());
+ ASSERT_EQ(spv::Op::OpLoad, inst.opcode());
ASSERT_EQ(12, inst.result_id());
break;
case 3:
- ASSERT_EQ(SpvOpStore, inst.opcode());
+ ASSERT_EQ(spv::Op::OpStore, inst.opcode());
break;
case 4:
- ASSERT_EQ(SpvOpReturn, inst.opcode());
+ ASSERT_EQ(spv::Op::OpReturn, inst.opcode());
break;
default:
FAIL();
@@ -250,11 +250,11 @@ TEST(ShrinkerTest, ReduceAddedFunctions) {
first_block = false;
for (auto& inst : block) {
switch (inst.opcode()) {
- case SpvOpVariable:
- case SpvOpNot:
- case SpvOpReturn:
- case SpvOpReturnValue:
- case SpvOpFunctionCall:
+ case spv::Op::OpVariable:
+ case spv::Op::OpNot:
+ case spv::Op::OpReturn:
+ case spv::Op::OpReturnValue:
+ case spv::Op::OpFunctionCall:
// These are the only instructions we expect to see.
break;
default:
@@ -362,7 +362,7 @@ TEST(ShrinkerTest, HitStepLimitWhenReducingAddedFunctions) {
uint32_t copy_object_count = 0;
temp_ir_context->module()->ForEachInst(
[&copy_object_count](opt::Instruction* inst) {
- if (inst->opcode() == SpvOpCopyObject) {
+ if (inst->opcode() == spv::Op::OpCopyObject) {
copy_object_count++;
}
});
diff --git a/test/fuzz/transformation_access_chain_test.cpp b/test/fuzz/transformation_access_chain_test.cpp
index bddcf5fe5..fa19aa50f 100644
--- a/test/fuzz/transformation_access_chain_test.cpp
+++ b/test/fuzz/transformation_access_chain_test.cpp
@@ -129,7 +129,7 @@ TEST(TransformationAccessChainTest, BasicTest) {
// Check the case where the index type is not a 32-bit integer.
TransformationAccessChain invalid_index_example1(
- 101, 28, {29}, MakeInstructionDescriptor(42, SpvOpReturn, 0));
+ 101, 28, {29}, MakeInstructionDescriptor(42, spv::Op::OpReturn, 0));
// Since the index is not a 32-bit integer type but a 32-bit float type,
// ValidIndexComposite should return false and thus the transformation is not
@@ -138,86 +138,95 @@ TEST(TransformationAccessChainTest, BasicTest) {
transformation_context));
// Bad: id is not fresh
- ASSERT_FALSE(TransformationAccessChain(
- 43, 43, {80}, MakeInstructionDescriptor(24, SpvOpLoad, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationAccessChain(
+ 43, 43, {80}, MakeInstructionDescriptor(24, spv::Op::OpLoad, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: pointer id does not exist
- ASSERT_FALSE(TransformationAccessChain(
- 100, 1000, {80}, MakeInstructionDescriptor(24, SpvOpLoad, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationAccessChain(
+ 100, 1000, {80}, MakeInstructionDescriptor(24, spv::Op::OpLoad, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: pointer id is not a type
- ASSERT_FALSE(TransformationAccessChain(
- 100, 5, {80}, MakeInstructionDescriptor(24, SpvOpLoad, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationAccessChain(
+ 100, 5, {80}, MakeInstructionDescriptor(24, spv::Op::OpLoad, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: pointer id is not a pointer
- ASSERT_FALSE(TransformationAccessChain(
- 100, 23, {80}, MakeInstructionDescriptor(24, SpvOpLoad, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationAccessChain(
+ 100, 23, {80}, MakeInstructionDescriptor(24, spv::Op::OpLoad, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: index id does not exist
- ASSERT_FALSE(TransformationAccessChain(
- 100, 43, {1000}, MakeInstructionDescriptor(24, SpvOpLoad, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationAccessChain(
+ 100, 43, {1000}, MakeInstructionDescriptor(24, spv::Op::OpLoad, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: index id is not a constant and the pointer refers to a struct
- ASSERT_FALSE(TransformationAccessChain(
- 100, 43, {24}, MakeInstructionDescriptor(25, SpvOpIAdd, 0))
- .IsApplicable(context.get(), transformation_context));
-
- // Bad: too many indices
ASSERT_FALSE(
- TransformationAccessChain(100, 43, {80, 80, 80},
- MakeInstructionDescriptor(24, SpvOpLoad, 0))
+ TransformationAccessChain(
+ 100, 43, {24}, MakeInstructionDescriptor(25, spv::Op::OpIAdd, 0))
.IsApplicable(context.get(), transformation_context));
+ // Bad: too many indices
+ ASSERT_FALSE(TransformationAccessChain(
+ 100, 43, {80, 80, 80},
+ MakeInstructionDescriptor(24, spv::Op::OpLoad, 0))
+ .IsApplicable(context.get(), transformation_context));
+
// Bad: index id is out of bounds when accessing a struct
ASSERT_FALSE(
- TransformationAccessChain(100, 43, {83, 80},
- MakeInstructionDescriptor(24, SpvOpLoad, 0))
+ TransformationAccessChain(
+ 100, 43, {83, 80}, MakeInstructionDescriptor(24, spv::Op::OpLoad, 0))
.IsApplicable(context.get(), transformation_context));
// Bad: attempt to insert before variable
- ASSERT_FALSE(TransformationAccessChain(
- 100, 34, {}, MakeInstructionDescriptor(36, SpvOpVariable, 0))
- .IsApplicable(context.get(), transformation_context));
-
- // Bad: OpTypeBool must be present in the module to clamp an index
ASSERT_FALSE(
- TransformationAccessChain(100, 36, {80, 81},
- MakeInstructionDescriptor(37, SpvOpStore, 0))
+ TransformationAccessChain(
+ 100, 34, {}, MakeInstructionDescriptor(36, spv::Op::OpVariable, 0))
.IsApplicable(context.get(), transformation_context));
- // Bad: pointer not available
+ // Bad: OpTypeBool must be present in the module to clamp an index
ASSERT_FALSE(
TransformationAccessChain(
- 100, 43, {80}, MakeInstructionDescriptor(21, SpvOpAccessChain, 0))
+ 100, 36, {80, 81}, MakeInstructionDescriptor(37, spv::Op::OpStore, 0))
.IsApplicable(context.get(), transformation_context));
- // Bad: instruction descriptor does not identify anything
+ // Bad: pointer not available
ASSERT_FALSE(TransformationAccessChain(
- 100, 43, {80}, MakeInstructionDescriptor(24, SpvOpLoad, 100))
+ 100, 43, {80},
+ MakeInstructionDescriptor(21, spv::Op::OpAccessChain, 0))
.IsApplicable(context.get(), transformation_context));
+ // Bad: instruction descriptor does not identify anything
+ ASSERT_FALSE(
+ TransformationAccessChain(
+ 100, 43, {80}, MakeInstructionDescriptor(24, spv::Op::OpLoad, 100))
+ .IsApplicable(context.get(), transformation_context));
+
#ifndef NDEBUG
// Bad: pointer is null
ASSERT_DEATH(
- TransformationAccessChain(100, 46, {80},
- MakeInstructionDescriptor(24, SpvOpLoad, 0))
+ TransformationAccessChain(
+ 100, 46, {80}, MakeInstructionDescriptor(24, spv::Op::OpLoad, 0))
.IsApplicable(context.get(), transformation_context),
"Access chains should not be created from null/undefined pointers");
#endif
// Bad: pointer to result type does not exist
- ASSERT_FALSE(TransformationAccessChain(
- 100, 52, {0}, MakeInstructionDescriptor(24, SpvOpLoad, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationAccessChain(
+ 100, 52, {0}, MakeInstructionDescriptor(24, spv::Op::OpLoad, 0))
+ .IsApplicable(context.get(), transformation_context));
{
TransformationAccessChain transformation(
- 100, 43, {80}, MakeInstructionDescriptor(24, SpvOpLoad, 0));
+ 100, 43, {80}, MakeInstructionDescriptor(24, spv::Op::OpLoad, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -230,7 +239,7 @@ TEST(TransformationAccessChainTest, BasicTest) {
{
TransformationAccessChain transformation(
- 101, 28, {81}, MakeInstructionDescriptor(42, SpvOpReturn, 0));
+ 101, 28, {81}, MakeInstructionDescriptor(42, spv::Op::OpReturn, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -243,7 +252,7 @@ TEST(TransformationAccessChainTest, BasicTest) {
{
TransformationAccessChain transformation(
- 102, 44, {}, MakeInstructionDescriptor(44, SpvOpStore, 0));
+ 102, 44, {}, MakeInstructionDescriptor(44, spv::Op::OpStore, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -256,7 +265,8 @@ TEST(TransformationAccessChainTest, BasicTest) {
{
TransformationAccessChain transformation(
- 103, 13, {80}, MakeInstructionDescriptor(21, SpvOpAccessChain, 0));
+ 103, 13, {80},
+ MakeInstructionDescriptor(21, spv::Op::OpAccessChain, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -269,7 +279,7 @@ TEST(TransformationAccessChainTest, BasicTest) {
{
TransformationAccessChain transformation(
- 104, 34, {}, MakeInstructionDescriptor(44, SpvOpStore, 1));
+ 104, 34, {}, MakeInstructionDescriptor(44, spv::Op::OpStore, 1));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -282,7 +292,7 @@ TEST(TransformationAccessChainTest, BasicTest) {
{
TransformationAccessChain transformation(
- 105, 38, {}, MakeInstructionDescriptor(40, SpvOpFunctionCall, 0));
+ 105, 38, {}, MakeInstructionDescriptor(40, spv::Op::OpFunctionCall, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -295,7 +305,7 @@ TEST(TransformationAccessChainTest, BasicTest) {
{
TransformationAccessChain transformation(
- 106, 14, {}, MakeInstructionDescriptor(24, SpvOpLoad, 0));
+ 106, 14, {}, MakeInstructionDescriptor(24, spv::Op::OpLoad, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -309,7 +319,7 @@ TEST(TransformationAccessChainTest, BasicTest) {
// Check the case where the access chain's base pointer has the irrelevant
// pointee fact; the resulting access chain should inherit this fact.
TransformationAccessChain transformation(
- 107, 54, {}, MakeInstructionDescriptor(24, SpvOpLoad, 0));
+ 107, 54, {}, MakeInstructionDescriptor(24, spv::Op::OpLoad, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -440,9 +450,10 @@ TEST(TransformationAccessChainTest, StructIndexMustBeConstant) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
// Bad: %9 is a pointer to a struct, but %20 is not a constant.
- ASSERT_FALSE(TransformationAccessChain(
- 100, 9, {20}, MakeInstructionDescriptor(9, SpvOpReturn, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationAccessChain(
+ 100, 9, {20}, MakeInstructionDescriptor(9, spv::Op::OpReturn, 0))
+ .IsApplicable(context.get(), transformation_context));
}
TEST(TransformationAccessChainTest, IsomorphicStructs) {
@@ -478,7 +489,7 @@ TEST(TransformationAccessChainTest, IsomorphicStructs) {
MakeUnique<FactManager>(context.get()), validator_options);
{
TransformationAccessChain transformation(
- 100, 11, {}, MakeInstructionDescriptor(5, SpvOpReturn, 0));
+ 100, 11, {}, MakeInstructionDescriptor(5, spv::Op::OpReturn, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -488,7 +499,7 @@ TEST(TransformationAccessChainTest, IsomorphicStructs) {
}
{
TransformationAccessChain transformation(
- 101, 12, {}, MakeInstructionDescriptor(5, SpvOpReturn, 0));
+ 101, 12, {}, MakeInstructionDescriptor(5, spv::Op::OpReturn, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -587,51 +598,56 @@ TEST(TransformationAccessChainTest, ClampingVariables) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
// Bad: no ids given for clamping
- ASSERT_FALSE(TransformationAccessChain(
- 100, 29, {17}, MakeInstructionDescriptor(36, SpvOpLoad, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationAccessChain(
+ 100, 29, {17}, MakeInstructionDescriptor(36, spv::Op::OpLoad, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: an id given for clamping is not fresh
ASSERT_FALSE(TransformationAccessChain(
- 100, 29, {17}, MakeInstructionDescriptor(36, SpvOpLoad, 0),
+ 100, 29, {17},
+ MakeInstructionDescriptor(36, spv::Op::OpLoad, 0),
{{46, 201}})
.IsApplicable(context.get(), transformation_context));
// Bad: an id given for clamping is not fresh
ASSERT_FALSE(TransformationAccessChain(
- 100, 29, {17}, MakeInstructionDescriptor(36, SpvOpLoad, 0),
+ 100, 29, {17},
+ MakeInstructionDescriptor(36, spv::Op::OpLoad, 0),
{{200, 46}})
.IsApplicable(context.get(), transformation_context));
// Bad: an id given for clamping is the same as the id for the access chain
ASSERT_FALSE(TransformationAccessChain(
- 100, 29, {17}, MakeInstructionDescriptor(36, SpvOpLoad, 0),
+ 100, 29, {17},
+ MakeInstructionDescriptor(36, spv::Op::OpLoad, 0),
{{100, 201}})
.IsApplicable(context.get(), transformation_context));
// Bad: the fresh ids given are not distinct
ASSERT_FALSE(TransformationAccessChain(
- 100, 29, {17}, MakeInstructionDescriptor(36, SpvOpLoad, 0),
+ 100, 29, {17},
+ MakeInstructionDescriptor(36, spv::Op::OpLoad, 0),
{{200, 200}})
.IsApplicable(context.get(), transformation_context));
// Bad: not enough ids given for clamping (2 pairs needed)
- ASSERT_FALSE(
- TransformationAccessChain(104, 34, {45, 10, 46},
- MakeInstructionDescriptor(46, SpvOpReturn, 0),
- {{208, 209}, {209, 211}})
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationAccessChain(
+ 104, 34, {45, 10, 46},
+ MakeInstructionDescriptor(46, spv::Op::OpReturn, 0),
+ {{208, 209}, {209, 211}})
+ .IsApplicable(context.get(), transformation_context));
// Bad: the fresh ids given are not distinct
- ASSERT_FALSE(
- TransformationAccessChain(104, 34, {45, 10, 46},
- MakeInstructionDescriptor(46, SpvOpReturn, 0),
- {{208, 209}, {209, 211}})
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationAccessChain(
+ 104, 34, {45, 10, 46},
+ MakeInstructionDescriptor(46, spv::Op::OpReturn, 0),
+ {{208, 209}, {209, 211}})
+ .IsApplicable(context.get(), transformation_context));
{
TransformationAccessChain transformation(
- 100, 29, {17}, MakeInstructionDescriptor(36, SpvOpLoad, 0),
+ 100, 29, {17}, MakeInstructionDescriptor(36, spv::Op::OpLoad, 0),
{{200, 201}});
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
@@ -643,7 +659,7 @@ TEST(TransformationAccessChainTest, ClampingVariables) {
{
TransformationAccessChain transformation(
- 101, 29, {36}, MakeInstructionDescriptor(38, SpvOpLoad, 0),
+ 101, 29, {36}, MakeInstructionDescriptor(38, spv::Op::OpLoad, 0),
{{202, 203}});
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
@@ -655,7 +671,7 @@ TEST(TransformationAccessChainTest, ClampingVariables) {
{
TransformationAccessChain transformation(
- 102, 32, {10, 40}, MakeInstructionDescriptor(42, SpvOpLoad, 0),
+ 102, 32, {10, 40}, MakeInstructionDescriptor(42, spv::Op::OpLoad, 0),
{{204, 205}});
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
@@ -667,7 +683,7 @@ TEST(TransformationAccessChainTest, ClampingVariables) {
{
TransformationAccessChain transformation(
- 103, 34, {11}, MakeInstructionDescriptor(45, SpvOpLoad, 0),
+ 103, 34, {11}, MakeInstructionDescriptor(45, spv::Op::OpLoad, 0),
{{206, 207}});
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
@@ -679,7 +695,8 @@ TEST(TransformationAccessChainTest, ClampingVariables) {
{
TransformationAccessChain transformation(
- 104, 34, {45, 10, 46}, MakeInstructionDescriptor(46, SpvOpReturn, 0),
+ 104, 34, {45, 10, 46},
+ MakeInstructionDescriptor(46, spv::Op::OpReturn, 0),
{{208, 209}, {210, 211}});
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
diff --git a/test/fuzz/transformation_add_constant_boolean_test.cpp b/test/fuzz/transformation_add_constant_boolean_test.cpp
index bd8d91c9e..bb8817e9d 100644
--- a/test/fuzz/transformation_add_constant_boolean_test.cpp
+++ b/test/fuzz/transformation_add_constant_boolean_test.cpp
@@ -72,7 +72,8 @@ TEST(TransformationAddConstantBooleanTest, NeitherPresentInitiallyAddBoth) {
ASSERT_EQ(nullptr, context->get_def_use_mgr()->GetDef(7));
ASSERT_EQ(nullptr, context->get_constant_mgr()->FindDeclaredConstant(7));
ApplyAndCheckFreshIds(add_true, context.get(), &transformation_context);
- ASSERT_EQ(SpvOpConstantTrue, context->get_def_use_mgr()->GetDef(7)->opcode());
+ ASSERT_EQ(spv::Op::OpConstantTrue,
+ context->get_def_use_mgr()->GetDef(7)->opcode());
ASSERT_TRUE(context->get_constant_mgr()
->FindDeclaredConstant(7)
->AsBoolConstant()
diff --git a/test/fuzz/transformation_add_constant_composite_test.cpp b/test/fuzz/transformation_add_constant_composite_test.cpp
index e5cbeec2d..193aa0ada 100644
--- a/test/fuzz/transformation_add_constant_composite_test.cpp
+++ b/test/fuzz/transformation_add_constant_composite_test.cpp
@@ -91,7 +91,7 @@ TEST(TransformationAddConstantCompositeTest, BasicTest) {
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
&transformation_context);
- ASSERT_EQ(SpvOpConstantComposite,
+ ASSERT_EQ(spv::Op::OpConstantComposite,
context->get_def_use_mgr()->GetDef(100)->opcode());
ASSERT_EQ(0.0F, context->get_constant_mgr()
->FindDeclaredConstant(100)
diff --git a/test/fuzz/transformation_add_constant_null_test.cpp b/test/fuzz/transformation_add_constant_null_test.cpp
index 1553e9f97..44e92f858 100644
--- a/test/fuzz/transformation_add_constant_null_test.cpp
+++ b/test/fuzz/transformation_add_constant_null_test.cpp
@@ -87,7 +87,7 @@ TEST(TransformationAddConstantNullTest, BasicTest) {
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
&transformation_context);
- ASSERT_EQ(SpvOpConstantNull,
+ ASSERT_EQ(spv::Op::OpConstantNull,
context->get_def_use_mgr()->GetDef(100)->opcode());
ASSERT_EQ(
0.0F,
diff --git a/test/fuzz/transformation_add_constant_scalar_test.cpp b/test/fuzz/transformation_add_constant_scalar_test.cpp
index 00c05416c..8c742a4c7 100644
--- a/test/fuzz/transformation_add_constant_scalar_test.cpp
+++ b/test/fuzz/transformation_add_constant_scalar_test.cpp
@@ -179,7 +179,8 @@ TEST(TransformationAddConstantScalarTest, Apply) {
ASSERT_EQ(nullptr, context->get_def_use_mgr()->GetDef(19));
ASSERT_EQ(nullptr, context->get_constant_mgr()->FindDeclaredConstant(19));
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
- ASSERT_EQ(SpvOpConstant, context->get_def_use_mgr()->GetDef(19)->opcode());
+ ASSERT_EQ(spv::Op::OpConstant,
+ context->get_def_use_mgr()->GetDef(19)->opcode());
ASSERT_EQ(4, context->get_constant_mgr()->FindDeclaredConstant(19)->GetU32());
auto* constant_instruction = context->get_def_use_mgr()->GetDef(19);
EXPECT_EQ(constant_instruction->NumInOperands(), 1);
diff --git a/test/fuzz/transformation_add_copy_memory_test.cpp b/test/fuzz/transformation_add_copy_memory_test.cpp
index ff8ac72e0..29a936c1f 100644
--- a/test/fuzz/transformation_add_copy_memory_test.cpp
+++ b/test/fuzz/transformation_add_copy_memory_test.cpp
@@ -148,89 +148,89 @@ TEST(TransformationAddCopyMemoryTest, BasicTest) {
MakeUnique<FactManager>(context.get()), validator_options);
// Target id is not fresh (59).
ASSERT_FALSE(TransformationAddCopyMemory(
- MakeInstructionDescriptor(27, SpvOpFunctionCall, 0), 59, 19,
- SpvStorageClassPrivate, 20)
+ MakeInstructionDescriptor(27, spv::Op::OpFunctionCall, 0),
+ 59, 19, spv::StorageClass::Private, 20)
.IsApplicable(context.get(), transformation_context));
// Instruction descriptor is invalid (id 90 is undefined).
ASSERT_FALSE(TransformationAddCopyMemory(
- MakeInstructionDescriptor(90, SpvOpVariable, 0), 90, 19,
- SpvStorageClassPrivate, 20)
+ MakeInstructionDescriptor(90, spv::Op::OpVariable, 0), 90,
+ 19, spv::StorageClass::Private, 20)
.IsApplicable(context.get(), transformation_context));
// Cannot insert OpCopyMemory before OpPhi.
- ASSERT_FALSE(
- TransformationAddCopyMemory(MakeInstructionDescriptor(75, SpvOpPhi, 0),
- 90, 19, SpvStorageClassPrivate, 20)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationAddCopyMemory(
+ MakeInstructionDescriptor(75, spv::Op::OpPhi, 0), 90, 19,
+ spv::StorageClass::Private, 20)
+ .IsApplicable(context.get(), transformation_context));
// Source instruction is invalid.
ASSERT_FALSE(TransformationAddCopyMemory(
- MakeInstructionDescriptor(27, SpvOpFunctionCall, 0), 90, 76,
- SpvStorageClassPrivate, 0)
+ MakeInstructionDescriptor(27, spv::Op::OpFunctionCall, 0),
+ 90, 76, spv::StorageClass::Private, 0)
.IsApplicable(context.get(), transformation_context));
// Source instruction's type doesn't exist.
ASSERT_FALSE(TransformationAddCopyMemory(
- MakeInstructionDescriptor(27, SpvOpFunctionCall, 0), 90, 5,
- SpvStorageClassPrivate, 0)
+ MakeInstructionDescriptor(27, spv::Op::OpFunctionCall, 0),
+ 90, 5, spv::StorageClass::Private, 0)
.IsApplicable(context.get(), transformation_context));
// Source instruction's type is invalid.
- ASSERT_FALSE(
- TransformationAddCopyMemory(MakeInstructionDescriptor(41, SpvOpLoad, 0),
- 90, 40, SpvStorageClassPrivate, 0)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationAddCopyMemory(
+ MakeInstructionDescriptor(41, spv::Op::OpLoad, 0), 90, 40,
+ spv::StorageClass::Private, 0)
+ .IsApplicable(context.get(), transformation_context));
// Source instruction is OpConstantNull.
- ASSERT_FALSE(
- TransformationAddCopyMemory(MakeInstructionDescriptor(41, SpvOpLoad, 0),
- 90, 88, SpvStorageClassPrivate, 0)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationAddCopyMemory(
+ MakeInstructionDescriptor(41, spv::Op::OpLoad, 0), 90, 88,
+ spv::StorageClass::Private, 0)
+ .IsApplicable(context.get(), transformation_context));
// Storage class is invalid.
ASSERT_FALSE(TransformationAddCopyMemory(
- MakeInstructionDescriptor(27, SpvOpFunctionCall, 0), 90, 19,
- SpvStorageClassWorkgroup, 20)
+ MakeInstructionDescriptor(27, spv::Op::OpFunctionCall, 0),
+ 90, 19, spv::StorageClass::Workgroup, 20)
.IsApplicable(context.get(), transformation_context));
// Initializer is 0.
ASSERT_FALSE(TransformationAddCopyMemory(
- MakeInstructionDescriptor(27, SpvOpFunctionCall, 0), 90, 19,
- SpvStorageClassPrivate, 0)
+ MakeInstructionDescriptor(27, spv::Op::OpFunctionCall, 0),
+ 90, 19, spv::StorageClass::Private, 0)
.IsApplicable(context.get(), transformation_context));
// Initializer has wrong type.
ASSERT_FALSE(TransformationAddCopyMemory(
- MakeInstructionDescriptor(27, SpvOpFunctionCall, 0), 90, 19,
- SpvStorageClassPrivate, 25)
+ MakeInstructionDescriptor(27, spv::Op::OpFunctionCall, 0),
+ 90, 19, spv::StorageClass::Private, 25)
.IsApplicable(context.get(), transformation_context));
// Source and target instructions are in different functions.
- ASSERT_FALSE(
- TransformationAddCopyMemory(MakeInstructionDescriptor(13, SpvOpLoad, 0),
- 90, 19, SpvStorageClassPrivate, 20)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationAddCopyMemory(
+ MakeInstructionDescriptor(13, spv::Op::OpLoad, 0), 90, 19,
+ spv::StorageClass::Private, 20)
+ .IsApplicable(context.get(), transformation_context));
// Source instruction doesn't dominate the target instruction.
ASSERT_FALSE(TransformationAddCopyMemory(
- MakeInstructionDescriptor(77, SpvOpLogicalEqual, 0), 90, 89,
- SpvStorageClassPrivate, 20)
+ MakeInstructionDescriptor(77, spv::Op::OpLogicalEqual, 0),
+ 90, 89, spv::StorageClass::Private, 20)
.IsApplicable(context.get(), transformation_context));
// Source and target instructions are the same.
ASSERT_FALSE(TransformationAddCopyMemory(
- MakeInstructionDescriptor(19, SpvOpVariable, 0), 90, 19,
- SpvStorageClassPrivate, 20)
+ MakeInstructionDescriptor(19, spv::Op::OpVariable, 0), 90,
+ 19, spv::StorageClass::Private, 20)
.IsApplicable(context.get(), transformation_context));
// Correct transformations.
uint32_t fresh_id = 90;
- auto descriptor = MakeInstructionDescriptor(27, SpvOpFunctionCall, 0);
+ auto descriptor = MakeInstructionDescriptor(27, spv::Op::OpFunctionCall, 0);
std::vector<uint32_t> source_ids = {19, 23, 26, 30, 35, 39, 68, 86};
std::vector<uint32_t> initializers = {20, 24, 25, 25, 36, 84, 85, 20};
- std::vector<SpvStorageClass> storage_classes = {SpvStorageClassPrivate,
- SpvStorageClassFunction};
+ std::vector<spv::StorageClass> storage_classes = {
+ spv::StorageClass::Private, spv::StorageClass::Function};
for (size_t i = 0, n = source_ids.size(); i < n; ++i) {
TransformationAddCopyMemory transformation(
descriptor, fresh_id, source_ids[i],
@@ -420,10 +420,10 @@ TEST(TransformationAddCopyMemoryTest, DisallowBufferBlockDecoration) {
kConsoleMessageConsumer));
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
- ASSERT_FALSE(
- TransformationAddCopyMemory(MakeInstructionDescriptor(5, SpvOpReturn, 0),
- 100, 9, SpvStorageClassPrivate, 50)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationAddCopyMemory(
+ MakeInstructionDescriptor(5, spv::Op::OpReturn, 0), 100, 9,
+ spv::StorageClass::Private, 50)
+ .IsApplicable(context.get(), transformation_context));
}
TEST(TransformationAddCopyMemoryTest, DisallowBlockDecoration) {
@@ -466,12 +466,12 @@ TEST(TransformationAddCopyMemoryTest, DisallowBlockDecoration) {
kConsoleMessageConsumer));
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
- ASSERT_FALSE(
- TransformationAddCopyMemory(MakeInstructionDescriptor(5, SpvOpReturn, 0),
- 100, 9, SpvStorageClassPrivate, 50)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationAddCopyMemory(
+ MakeInstructionDescriptor(5, spv::Op::OpReturn, 0), 100, 9,
+ spv::StorageClass::Private, 50)
+ .IsApplicable(context.get(), transformation_context));
}
} // namespace
} // namespace fuzz
-} // namespace spvtools \ No newline at end of file
+} // namespace spvtools
diff --git a/test/fuzz/transformation_add_early_terminator_wrapper_test.cpp b/test/fuzz/transformation_add_early_terminator_wrapper_test.cpp
index 8239e2173..8cb04a931 100644
--- a/test/fuzz/transformation_add_early_terminator_wrapper_test.cpp
+++ b/test/fuzz/transformation_add_early_terminator_wrapper_test.cpp
@@ -40,8 +40,9 @@ TEST(TransformationAddEarlyTerminatorWrapperTest, NoVoidType) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
- ASSERT_FALSE(TransformationAddEarlyTerminatorWrapper(100, 101, SpvOpKill)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationAddEarlyTerminatorWrapper(100, 101, spv::Op::OpKill)
+ .IsApplicable(context.get(), transformation_context));
}
TEST(TransformationAddEarlyTerminatorWrapperTest, NoVoidFunctionType) {
@@ -63,8 +64,9 @@ TEST(TransformationAddEarlyTerminatorWrapperTest, NoVoidFunctionType) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
- ASSERT_FALSE(TransformationAddEarlyTerminatorWrapper(100, 101, SpvOpKill)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationAddEarlyTerminatorWrapper(100, 101, spv::Op::OpKill)
+ .IsApplicable(context.get(), transformation_context));
}
TEST(TransformationAddEarlyTerminatorWrapperTest, BasicTest) {
@@ -93,25 +95,27 @@ TEST(TransformationAddEarlyTerminatorWrapperTest, BasicTest) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
- ASSERT_FALSE(TransformationAddEarlyTerminatorWrapper(2, 101, SpvOpKill)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(TransformationAddEarlyTerminatorWrapper(100, 4, SpvOpKill)
+ ASSERT_FALSE(TransformationAddEarlyTerminatorWrapper(2, 101, spv::Op::OpKill)
.IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(TransformationAddEarlyTerminatorWrapper(100, 100, SpvOpKill)
+ ASSERT_FALSE(TransformationAddEarlyTerminatorWrapper(100, 4, spv::Op::OpKill)
.IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationAddEarlyTerminatorWrapper(100, 100, spv::Op::OpKill)
+ .IsApplicable(context.get(), transformation_context));
#ifndef NDEBUG
- ASSERT_DEATH(TransformationAddEarlyTerminatorWrapper(100, 101, SpvOpReturn)
- .IsApplicable(context.get(), transformation_context),
- "Invalid opcode.");
+ ASSERT_DEATH(
+ TransformationAddEarlyTerminatorWrapper(100, 101, spv::Op::OpReturn)
+ .IsApplicable(context.get(), transformation_context),
+ "Invalid opcode.");
#endif
auto transformation1 =
- TransformationAddEarlyTerminatorWrapper(100, 101, SpvOpKill);
+ TransformationAddEarlyTerminatorWrapper(100, 101, spv::Op::OpKill);
auto transformation2 =
- TransformationAddEarlyTerminatorWrapper(102, 103, SpvOpUnreachable);
+ TransformationAddEarlyTerminatorWrapper(102, 103, spv::Op::OpUnreachable);
auto transformation3 = TransformationAddEarlyTerminatorWrapper(
- 104, 105, SpvOpTerminateInvocation);
+ 104, 105, spv::Op::OpTerminateInvocation);
ASSERT_TRUE(
transformation1.IsApplicable(context.get(), transformation_context));
diff --git a/test/fuzz/transformation_add_function_test.cpp b/test/fuzz/transformation_add_function_test.cpp
index d55fb9318..65ae2f2dd 100644
--- a/test/fuzz/transformation_add_function_test.cpp
+++ b/test/fuzz/transformation_add_function_test.cpp
@@ -84,7 +84,7 @@ bool AllVariablesAndParametersExceptLoopLimiterAreIrrelevant(
&found_non_irrelevant_parameter](
opt::Instruction* inst) {
if (context->get_def_use_mgr()->GetDef(inst->type_id())->opcode() ==
- SpvOpTypePointer &&
+ spv::Op::OpTypePointer &&
!transformation_context.GetFactManager()->PointeeValueIsIrrelevant(
inst->result_id())) {
found_non_irrelevant_parameter = true;
@@ -96,7 +96,7 @@ bool AllVariablesAndParametersExceptLoopLimiterAreIrrelevant(
}
// Look through the instructions in the function's first block.
for (auto& inst : *function.begin()) {
- if (inst.opcode() != SpvOpVariable) {
+ if (inst.opcode() != spv::Op::OpVariable) {
// We have found a non-variable instruction; this means we have gotten
// past all variables, so we are done.
return true;
@@ -154,73 +154,84 @@ TEST(TransformationAddFunctionTest, BasicTest) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
TransformationAddFunction transformation1(std::vector<protobufs::Instruction>(
- {MakeInstructionMessage(
- SpvOpFunction, 8, 13,
- {{SPV_OPERAND_TYPE_FUNCTION_CONTROL, {SpvFunctionControlMaskNone}},
- {SPV_OPERAND_TYPE_ID, {10}}}),
- MakeInstructionMessage(SpvOpFunctionParameter, 7, 11, {}),
- MakeInstructionMessage(SpvOpFunctionParameter, 9, 12, {}),
- MakeInstructionMessage(SpvOpLabel, 0, 14, {}),
+ {MakeInstructionMessage(spv::Op::OpFunction, 8, 13,
+ {{SPV_OPERAND_TYPE_FUNCTION_CONTROL,
+ {uint32_t(spv::FunctionControlMask::MaskNone)}},
+ {SPV_OPERAND_TYPE_ID, {10}}}),
+ MakeInstructionMessage(spv::Op::OpFunctionParameter, 7, 11, {}),
+ MakeInstructionMessage(spv::Op::OpFunctionParameter, 9, 12, {}),
+ MakeInstructionMessage(spv::Op::OpLabel, 0, 14, {}),
+ MakeInstructionMessage(spv::Op::OpVariable, 9, 17,
+ {{SPV_OPERAND_TYPE_STORAGE_CLASS,
+ {uint32_t(spv::StorageClass::Function)}}}),
+ MakeInstructionMessage(spv::Op::OpVariable, 7, 19,
+ {{SPV_OPERAND_TYPE_STORAGE_CLASS,
+ {uint32_t(spv::StorageClass::Function)}}}),
MakeInstructionMessage(
- SpvOpVariable, 9, 17,
- {{SPV_OPERAND_TYPE_STORAGE_CLASS, {SpvStorageClassFunction}}}),
- MakeInstructionMessage(
- SpvOpVariable, 7, 19,
- {{SPV_OPERAND_TYPE_STORAGE_CLASS, {SpvStorageClassFunction}}}),
- MakeInstructionMessage(
- SpvOpStore, 0, 0,
+ spv::Op::OpStore, 0, 0,
{{SPV_OPERAND_TYPE_ID, {17}}, {SPV_OPERAND_TYPE_ID, {18}}}),
MakeInstructionMessage(
- SpvOpStore, 0, 0,
+ spv::Op::OpStore, 0, 0,
{{SPV_OPERAND_TYPE_ID, {19}}, {SPV_OPERAND_TYPE_ID, {20}}}),
- MakeInstructionMessage(SpvOpBranch, 0, 0, {{SPV_OPERAND_TYPE_ID, {21}}}),
- MakeInstructionMessage(SpvOpLabel, 0, 21, {}),
+ MakeInstructionMessage(spv::Op::OpBranch, 0, 0,
+ {{SPV_OPERAND_TYPE_ID, {21}}}),
+ MakeInstructionMessage(spv::Op::OpLabel, 0, 21, {}),
+ MakeInstructionMessage(spv::Op::OpLoopMerge, 0, 0,
+ {{SPV_OPERAND_TYPE_ID, {23}},
+ {SPV_OPERAND_TYPE_ID, {24}},
+ {SPV_OPERAND_TYPE_LOOP_CONTROL,
+ {uint32_t(spv::LoopControlMask::MaskNone)}}}),
+ MakeInstructionMessage(spv::Op::OpBranch, 0, 0,
+ {{SPV_OPERAND_TYPE_ID, {25}}}),
+ MakeInstructionMessage(spv::Op::OpLabel, 0, 25, {}),
+ MakeInstructionMessage(spv::Op::OpLoad, 6, 26,
+ {{SPV_OPERAND_TYPE_ID, {19}}}),
+ MakeInstructionMessage(spv::Op::OpLoad, 6, 27,
+ {{SPV_OPERAND_TYPE_ID, {11}}}),
MakeInstructionMessage(
- SpvOpLoopMerge, 0, 0,
- {{SPV_OPERAND_TYPE_ID, {23}},
- {SPV_OPERAND_TYPE_ID, {24}},
- {SPV_OPERAND_TYPE_LOOP_CONTROL, {SpvLoopControlMaskNone}}}),
- MakeInstructionMessage(SpvOpBranch, 0, 0, {{SPV_OPERAND_TYPE_ID, {25}}}),
- MakeInstructionMessage(SpvOpLabel, 0, 25, {}),
- MakeInstructionMessage(SpvOpLoad, 6, 26, {{SPV_OPERAND_TYPE_ID, {19}}}),
- MakeInstructionMessage(SpvOpLoad, 6, 27, {{SPV_OPERAND_TYPE_ID, {11}}}),
- MakeInstructionMessage(
- SpvOpSLessThan, 28, 29,
+ spv::Op::OpSLessThan, 28, 29,
{{SPV_OPERAND_TYPE_ID, {26}}, {SPV_OPERAND_TYPE_ID, {27}}}),
- MakeInstructionMessage(SpvOpBranchConditional, 0, 0,
+ MakeInstructionMessage(spv::Op::OpBranchConditional, 0, 0,
{{SPV_OPERAND_TYPE_ID, {29}},
{SPV_OPERAND_TYPE_ID, {22}},
{SPV_OPERAND_TYPE_ID, {23}}}),
- MakeInstructionMessage(SpvOpLabel, 0, 22, {}),
- MakeInstructionMessage(SpvOpLoad, 8, 30, {{SPV_OPERAND_TYPE_ID, {12}}}),
- MakeInstructionMessage(SpvOpLoad, 6, 31, {{SPV_OPERAND_TYPE_ID, {19}}}),
- MakeInstructionMessage(SpvOpConvertSToF, 8, 32,
+ MakeInstructionMessage(spv::Op::OpLabel, 0, 22, {}),
+ MakeInstructionMessage(spv::Op::OpLoad, 8, 30,
+ {{SPV_OPERAND_TYPE_ID, {12}}}),
+ MakeInstructionMessage(spv::Op::OpLoad, 6, 31,
+ {{SPV_OPERAND_TYPE_ID, {19}}}),
+ MakeInstructionMessage(spv::Op::OpConvertSToF, 8, 32,
{{SPV_OPERAND_TYPE_ID, {31}}}),
MakeInstructionMessage(
- SpvOpFMul, 8, 33,
+ spv::Op::OpFMul, 8, 33,
{{SPV_OPERAND_TYPE_ID, {30}}, {SPV_OPERAND_TYPE_ID, {32}}}),
- MakeInstructionMessage(SpvOpLoad, 8, 34, {{SPV_OPERAND_TYPE_ID, {17}}}),
+ MakeInstructionMessage(spv::Op::OpLoad, 8, 34,
+ {{SPV_OPERAND_TYPE_ID, {17}}}),
MakeInstructionMessage(
- SpvOpFAdd, 8, 35,
+ spv::Op::OpFAdd, 8, 35,
{{SPV_OPERAND_TYPE_ID, {34}}, {SPV_OPERAND_TYPE_ID, {33}}}),
MakeInstructionMessage(
- SpvOpStore, 0, 0,
+ spv::Op::OpStore, 0, 0,
{{SPV_OPERAND_TYPE_ID, {17}}, {SPV_OPERAND_TYPE_ID, {35}}}),
- MakeInstructionMessage(SpvOpBranch, 0, 0, {{SPV_OPERAND_TYPE_ID, {24}}}),
- MakeInstructionMessage(SpvOpLabel, 0, 24, {}),
- MakeInstructionMessage(SpvOpLoad, 6, 36, {{SPV_OPERAND_TYPE_ID, {19}}}),
+ MakeInstructionMessage(spv::Op::OpBranch, 0, 0,
+ {{SPV_OPERAND_TYPE_ID, {24}}}),
+ MakeInstructionMessage(spv::Op::OpLabel, 0, 24, {}),
+ MakeInstructionMessage(spv::Op::OpLoad, 6, 36,
+ {{SPV_OPERAND_TYPE_ID, {19}}}),
MakeInstructionMessage(
- SpvOpIAdd, 6, 38,
+ spv::Op::OpIAdd, 6, 38,
{{SPV_OPERAND_TYPE_ID, {36}}, {SPV_OPERAND_TYPE_ID, {37}}}),
MakeInstructionMessage(
- SpvOpStore, 0, 0,
+ spv::Op::OpStore, 0, 0,
{{SPV_OPERAND_TYPE_ID, {19}}, {SPV_OPERAND_TYPE_ID, {38}}}),
- MakeInstructionMessage(SpvOpBranch, 0, 0, {{SPV_OPERAND_TYPE_ID, {21}}}),
- MakeInstructionMessage(SpvOpLabel, 0, 23, {}),
- MakeInstructionMessage(SpvOpLoad, 8, 39, {{SPV_OPERAND_TYPE_ID, {17}}}),
- MakeInstructionMessage(SpvOpReturnValue, 0, 0,
+ MakeInstructionMessage(spv::Op::OpBranch, 0, 0,
+ {{SPV_OPERAND_TYPE_ID, {21}}}),
+ MakeInstructionMessage(spv::Op::OpLabel, 0, 23, {}),
+ MakeInstructionMessage(spv::Op::OpLoad, 8, 39,
+ {{SPV_OPERAND_TYPE_ID, {17}}}),
+ MakeInstructionMessage(spv::Op::OpReturnValue, 0, 0,
{{SPV_OPERAND_TYPE_ID, {39}}}),
- MakeInstructionMessage(SpvOpFunctionEnd, 0, 0, {})}));
+ MakeInstructionMessage(spv::Op::OpFunctionEnd, 0, 0, {})}));
ASSERT_TRUE(
transformation1.IsApplicable(context.get(), transformation_context));
@@ -299,51 +310,51 @@ TEST(TransformationAddFunctionTest, BasicTest) {
ASSERT_TRUE(transformation_context.GetFactManager()->BlockIsDead(25));
TransformationAddFunction transformation2(std::vector<protobufs::Instruction>(
- {MakeInstructionMessage(
- SpvOpFunction, 2, 15,
- {{SPV_OPERAND_TYPE_FUNCTION_CONTROL, {SpvFunctionControlMaskNone}},
- {SPV_OPERAND_TYPE_ID, {3}}}),
- MakeInstructionMessage(SpvOpLabel, 0, 16, {}),
- MakeInstructionMessage(
- SpvOpVariable, 7, 44,
- {{SPV_OPERAND_TYPE_STORAGE_CLASS, {SpvStorageClassFunction}}}),
- MakeInstructionMessage(
- SpvOpVariable, 9, 45,
- {{SPV_OPERAND_TYPE_STORAGE_CLASS, {SpvStorageClassFunction}}}),
- MakeInstructionMessage(
- SpvOpVariable, 7, 48,
- {{SPV_OPERAND_TYPE_STORAGE_CLASS, {SpvStorageClassFunction}}}),
- MakeInstructionMessage(
- SpvOpVariable, 9, 49,
- {{SPV_OPERAND_TYPE_STORAGE_CLASS, {SpvStorageClassFunction}}}),
+ {MakeInstructionMessage(spv::Op::OpFunction, 2, 15,
+ {{SPV_OPERAND_TYPE_FUNCTION_CONTROL,
+ {uint32_t(spv::FunctionControlMask::MaskNone)}},
+ {SPV_OPERAND_TYPE_ID, {3}}}),
+ MakeInstructionMessage(spv::Op::OpLabel, 0, 16, {}),
+ MakeInstructionMessage(spv::Op::OpVariable, 7, 44,
+ {{SPV_OPERAND_TYPE_STORAGE_CLASS,
+ {uint32_t(spv::StorageClass::Function)}}}),
+ MakeInstructionMessage(spv::Op::OpVariable, 9, 45,
+ {{SPV_OPERAND_TYPE_STORAGE_CLASS,
+ {uint32_t(spv::StorageClass::Function)}}}),
+ MakeInstructionMessage(spv::Op::OpVariable, 7, 48,
+ {{SPV_OPERAND_TYPE_STORAGE_CLASS,
+ {uint32_t(spv::StorageClass::Function)}}}),
+ MakeInstructionMessage(spv::Op::OpVariable, 9, 49,
+ {{SPV_OPERAND_TYPE_STORAGE_CLASS,
+ {uint32_t(spv::StorageClass::Function)}}}),
MakeInstructionMessage(
- SpvOpStore, 0, 0,
+ spv::Op::OpStore, 0, 0,
{{SPV_OPERAND_TYPE_ID, {44}}, {SPV_OPERAND_TYPE_ID, {20}}}),
MakeInstructionMessage(
- SpvOpStore, 0, 0,
+ spv::Op::OpStore, 0, 0,
{{SPV_OPERAND_TYPE_ID, {45}}, {SPV_OPERAND_TYPE_ID, {18}}}),
- MakeInstructionMessage(SpvOpFunctionCall, 8, 46,
+ MakeInstructionMessage(spv::Op::OpFunctionCall, 8, 46,
{{SPV_OPERAND_TYPE_ID, {13}},
{SPV_OPERAND_TYPE_ID, {44}},
{SPV_OPERAND_TYPE_ID, {45}}}),
MakeInstructionMessage(
- SpvOpStore, 0, 0,
+ spv::Op::OpStore, 0, 0,
{{SPV_OPERAND_TYPE_ID, {48}}, {SPV_OPERAND_TYPE_ID, {37}}}),
MakeInstructionMessage(
- SpvOpStore, 0, 0,
+ spv::Op::OpStore, 0, 0,
{{SPV_OPERAND_TYPE_ID, {49}}, {SPV_OPERAND_TYPE_ID, {47}}}),
- MakeInstructionMessage(SpvOpFunctionCall, 8, 50,
+ MakeInstructionMessage(spv::Op::OpFunctionCall, 8, 50,
{{SPV_OPERAND_TYPE_ID, {13}},
{SPV_OPERAND_TYPE_ID, {48}},
{SPV_OPERAND_TYPE_ID, {49}}}),
MakeInstructionMessage(
- SpvOpFAdd, 8, 51,
+ spv::Op::OpFAdd, 8, 51,
{{SPV_OPERAND_TYPE_ID, {46}}, {SPV_OPERAND_TYPE_ID, {50}}}),
MakeInstructionMessage(
- SpvOpStore, 0, 0,
+ spv::Op::OpStore, 0, 0,
{{SPV_OPERAND_TYPE_ID, {43}}, {SPV_OPERAND_TYPE_ID, {51}}}),
- MakeInstructionMessage(SpvOpReturn, 0, 0, {}),
- MakeInstructionMessage(SpvOpFunctionEnd, 0, 0, {})}));
+ MakeInstructionMessage(spv::Op::OpReturn, 0, 0, {}),
+ MakeInstructionMessage(spv::Op::OpFunctionEnd, 0, 0, {})}));
ASSERT_TRUE(
transformation2.IsApplicable(context.get(), transformation_context));
@@ -513,45 +524,46 @@ TEST(TransformationAddFunctionTest, InapplicableTransformations) {
ASSERT_FALSE(
TransformationAddFunction(
std::vector<protobufs::Instruction>(
- {MakeInstructionMessage(SpvOpFunctionParameter, 7, 11, {}),
- MakeInstructionMessage(SpvOpFunctionParameter, 9, 12, {}),
- MakeInstructionMessage(SpvOpLabel, 0, 14, {})}))
+ {MakeInstructionMessage(spv::Op::OpFunctionParameter, 7, 11, {}),
+ MakeInstructionMessage(spv::Op::OpFunctionParameter, 9, 12, {}),
+ MakeInstructionMessage(spv::Op::OpLabel, 0, 14, {})}))
.IsApplicable(context.get(), transformation_context));
// No OpLabel
ASSERT_FALSE(
TransformationAddFunction(
std::vector<protobufs::Instruction>(
- {MakeInstructionMessage(SpvOpFunction, 8, 13,
- {{SPV_OPERAND_TYPE_FUNCTION_CONTROL,
- {SpvFunctionControlMaskNone}},
- {SPV_OPERAND_TYPE_ID, {10}}}),
- MakeInstructionMessage(SpvOpReturnValue, 0, 0,
+ {MakeInstructionMessage(
+ spv::Op::OpFunction, 8, 13,
+ {{SPV_OPERAND_TYPE_FUNCTION_CONTROL,
+ {uint32_t(spv::FunctionControlMask::MaskNone)}},
+ {SPV_OPERAND_TYPE_ID, {10}}}),
+ MakeInstructionMessage(spv::Op::OpReturnValue, 0, 0,
{{SPV_OPERAND_TYPE_ID, {39}}}),
- MakeInstructionMessage(SpvOpFunctionEnd, 0, 0, {})}))
+ MakeInstructionMessage(spv::Op::OpFunctionEnd, 0, 0, {})}))
.IsApplicable(context.get(), transformation_context));
// Abrupt end of instructions
ASSERT_FALSE(TransformationAddFunction(
std::vector<protobufs::Instruction>({MakeInstructionMessage(
- SpvOpFunction, 8, 13,
+ spv::Op::OpFunction, 8, 13,
{{SPV_OPERAND_TYPE_FUNCTION_CONTROL,
- {SpvFunctionControlMaskNone}},
+ {uint32_t(spv::FunctionControlMask::MaskNone)}},
{SPV_OPERAND_TYPE_ID, {10}}})}))
.IsApplicable(context.get(), transformation_context));
// No function end
- ASSERT_FALSE(
- TransformationAddFunction(
- std::vector<protobufs::Instruction>(
- {MakeInstructionMessage(SpvOpFunction, 8, 13,
- {{SPV_OPERAND_TYPE_FUNCTION_CONTROL,
- {SpvFunctionControlMaskNone}},
- {SPV_OPERAND_TYPE_ID, {10}}}),
- MakeInstructionMessage(SpvOpLabel, 0, 14, {}),
- MakeInstructionMessage(SpvOpReturnValue, 0, 0,
- {{SPV_OPERAND_TYPE_ID, {39}}})}))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationAddFunction(
+ std::vector<protobufs::Instruction>(
+ {MakeInstructionMessage(
+ spv::Op::OpFunction, 8, 13,
+ {{SPV_OPERAND_TYPE_FUNCTION_CONTROL,
+ {uint32_t(spv::FunctionControlMask::MaskNone)}},
+ {SPV_OPERAND_TYPE_ID, {10}}}),
+ MakeInstructionMessage(spv::Op::OpLabel, 0, 14, {}),
+ MakeInstructionMessage(spv::Op::OpReturnValue, 0, 0,
+ {{SPV_OPERAND_TYPE_ID, {39}}})}))
+ .IsApplicable(context.get(), transformation_context));
}
TEST(TransformationAddFunctionTest, LoopLimiters) {
@@ -581,61 +593,69 @@ TEST(TransformationAddFunctionTest, LoopLimiters) {
const auto consumer = nullptr;
std::vector<protobufs::Instruction> instructions;
- instructions.push_back(MakeInstructionMessage(
- SpvOpFunction, 2, 30,
- {{SPV_OPERAND_TYPE_FUNCTION_CONTROL, {SpvFunctionControlMaskNone}},
- {SPV_OPERAND_TYPE_TYPE_ID, {3}}}));
- instructions.push_back(MakeInstructionMessage(SpvOpLabel, 0, 31, {}));
instructions.push_back(
- MakeInstructionMessage(SpvOpBranch, 0, 0, {{SPV_OPERAND_TYPE_ID, {20}}}));
- instructions.push_back(MakeInstructionMessage(SpvOpLabel, 0, 20, {}));
- instructions.push_back(MakeInstructionMessage(
- SpvOpLoopMerge, 0, 0,
- {{SPV_OPERAND_TYPE_ID, {21}},
- {SPV_OPERAND_TYPE_ID, {22}},
- {SPV_OPERAND_TYPE_LOOP_CONTROL, {SpvLoopControlMaskNone}}}));
- instructions.push_back(MakeInstructionMessage(SpvOpBranchConditional, 0, 0,
+ MakeInstructionMessage(spv::Op::OpFunction, 2, 30,
+ {{SPV_OPERAND_TYPE_FUNCTION_CONTROL,
+ {uint32_t(spv::FunctionControlMask::MaskNone)}},
+ {SPV_OPERAND_TYPE_TYPE_ID, {3}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLabel, 0, 31, {}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpBranch, 0, 0,
+ {{SPV_OPERAND_TYPE_ID, {20}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLabel, 0, 20, {}));
+ instructions.push_back(
+ MakeInstructionMessage(spv::Op::OpLoopMerge, 0, 0,
+ {{SPV_OPERAND_TYPE_ID, {21}},
+ {SPV_OPERAND_TYPE_ID, {22}},
+ {SPV_OPERAND_TYPE_LOOP_CONTROL,
+ {uint32_t(spv::LoopControlMask::MaskNone)}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpBranchConditional, 0,
+ 0,
{{SPV_OPERAND_TYPE_ID, {12}},
{SPV_OPERAND_TYPE_ID, {23}},
{SPV_OPERAND_TYPE_ID, {21}}}));
- instructions.push_back(MakeInstructionMessage(SpvOpLabel, 0, 23, {}));
- instructions.push_back(MakeInstructionMessage(
- SpvOpLoopMerge, 0, 0,
- {{SPV_OPERAND_TYPE_ID, {25}},
- {SPV_OPERAND_TYPE_ID, {26}},
- {SPV_OPERAND_TYPE_LOOP_CONTROL, {SpvLoopControlMaskNone}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLabel, 0, 23, {}));
instructions.push_back(
- MakeInstructionMessage(SpvOpBranch, 0, 0, {{SPV_OPERAND_TYPE_ID, {28}}}));
- instructions.push_back(MakeInstructionMessage(SpvOpLabel, 0, 28, {}));
- instructions.push_back(MakeInstructionMessage(SpvOpBranchConditional, 0, 0,
+ MakeInstructionMessage(spv::Op::OpLoopMerge, 0, 0,
+ {{SPV_OPERAND_TYPE_ID, {25}},
+ {SPV_OPERAND_TYPE_ID, {26}},
+ {SPV_OPERAND_TYPE_LOOP_CONTROL,
+ {uint32_t(spv::LoopControlMask::MaskNone)}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpBranch, 0, 0,
+ {{SPV_OPERAND_TYPE_ID, {28}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLabel, 0, 28, {}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpBranchConditional, 0,
+ 0,
{{SPV_OPERAND_TYPE_ID, {12}},
{SPV_OPERAND_TYPE_ID, {26}},
{SPV_OPERAND_TYPE_ID, {25}}}));
- instructions.push_back(MakeInstructionMessage(SpvOpLabel, 0, 26, {}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLabel, 0, 26, {}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpBranch, 0, 0,
+ {{SPV_OPERAND_TYPE_ID, {23}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLabel, 0, 25, {}));
instructions.push_back(
- MakeInstructionMessage(SpvOpBranch, 0, 0, {{SPV_OPERAND_TYPE_ID, {23}}}));
- instructions.push_back(MakeInstructionMessage(SpvOpLabel, 0, 25, {}));
- instructions.push_back(MakeInstructionMessage(
- SpvOpLoopMerge, 0, 0,
- {{SPV_OPERAND_TYPE_ID, {24}},
- {SPV_OPERAND_TYPE_ID, {27}},
- {SPV_OPERAND_TYPE_LOOP_CONTROL, {SpvLoopControlMaskNone}}}));
- instructions.push_back(MakeInstructionMessage(SpvOpBranchConditional, 0, 0,
+ MakeInstructionMessage(spv::Op::OpLoopMerge, 0, 0,
+ {{SPV_OPERAND_TYPE_ID, {24}},
+ {SPV_OPERAND_TYPE_ID, {27}},
+ {SPV_OPERAND_TYPE_LOOP_CONTROL,
+ {uint32_t(spv::LoopControlMask::MaskNone)}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpBranchConditional, 0,
+ 0,
{{SPV_OPERAND_TYPE_ID, {12}},
{SPV_OPERAND_TYPE_ID, {24}},
{SPV_OPERAND_TYPE_ID, {27}}}));
- instructions.push_back(MakeInstructionMessage(SpvOpLabel, 0, 27, {}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLabel, 0, 27, {}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpBranch, 0, 0,
+ {{SPV_OPERAND_TYPE_ID, {25}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLabel, 0, 24, {}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpBranch, 0, 0,
+ {{SPV_OPERAND_TYPE_ID, {22}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLabel, 0, 22, {}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpBranch, 0, 0,
+ {{SPV_OPERAND_TYPE_ID, {20}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLabel, 0, 21, {}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpReturn, 0, 0, {}));
instructions.push_back(
- MakeInstructionMessage(SpvOpBranch, 0, 0, {{SPV_OPERAND_TYPE_ID, {25}}}));
- instructions.push_back(MakeInstructionMessage(SpvOpLabel, 0, 24, {}));
- instructions.push_back(
- MakeInstructionMessage(SpvOpBranch, 0, 0, {{SPV_OPERAND_TYPE_ID, {22}}}));
- instructions.push_back(MakeInstructionMessage(SpvOpLabel, 0, 22, {}));
- instructions.push_back(
- MakeInstructionMessage(SpvOpBranch, 0, 0, {{SPV_OPERAND_TYPE_ID, {20}}}));
- instructions.push_back(MakeInstructionMessage(SpvOpLabel, 0, 21, {}));
- instructions.push_back(MakeInstructionMessage(SpvOpReturn, 0, 0, {}));
- instructions.push_back(MakeInstructionMessage(SpvOpFunctionEnd, 0, 0, {}));
+ MakeInstructionMessage(spv::Op::OpFunctionEnd, 0, 0, {}));
spvtools::ValidatorOptions validator_options;
@@ -837,31 +857,36 @@ TEST(TransformationAddFunctionTest, KillAndUnreachableInVoidFunction) {
std::vector<protobufs::Instruction> instructions;
- instructions.push_back(MakeInstructionMessage(
- SpvOpFunction, 2, 10,
- {{SPV_OPERAND_TYPE_FUNCTION_CONTROL, {SpvFunctionControlMaskNone}},
- {SPV_OPERAND_TYPE_TYPE_ID, {8}}}));
instructions.push_back(
- MakeInstructionMessage(SpvOpFunctionParameter, 7, 9, {}));
- instructions.push_back(MakeInstructionMessage(SpvOpLabel, 0, 11, {}));
+ MakeInstructionMessage(spv::Op::OpFunction, 2, 10,
+ {{SPV_OPERAND_TYPE_FUNCTION_CONTROL,
+ {uint32_t(spv::FunctionControlMask::MaskNone)}},
+ {SPV_OPERAND_TYPE_TYPE_ID, {8}}}));
instructions.push_back(
- MakeInstructionMessage(SpvOpLoad, 6, 12, {{SPV_OPERAND_TYPE_ID, {9}}}));
+ MakeInstructionMessage(spv::Op::OpFunctionParameter, 7, 9, {}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLabel, 0, 11, {}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLoad, 6, 12,
+ {{SPV_OPERAND_TYPE_ID, {9}}}));
instructions.push_back(MakeInstructionMessage(
- SpvOpIEqual, 14, 15,
+ spv::Op::OpIEqual, 14, 15,
{{SPV_OPERAND_TYPE_ID, {12}}, {SPV_OPERAND_TYPE_ID, {13}}}));
instructions.push_back(MakeInstructionMessage(
- SpvOpSelectionMerge, 0, 0,
+ spv::Op::OpSelectionMerge, 0, 0,
{{SPV_OPERAND_TYPE_ID, {17}},
- {SPV_OPERAND_TYPE_SELECTION_CONTROL, {SpvSelectionControlMaskNone}}}));
- instructions.push_back(MakeInstructionMessage(SpvOpBranchConditional, 0, 0,
+ {SPV_OPERAND_TYPE_SELECTION_CONTROL,
+ {uint32_t(spv::SelectionControlMask::MaskNone)}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpBranchConditional, 0,
+ 0,
{{SPV_OPERAND_TYPE_ID, {15}},
{SPV_OPERAND_TYPE_ID, {16}},
{SPV_OPERAND_TYPE_ID, {17}}}));
- instructions.push_back(MakeInstructionMessage(SpvOpLabel, 0, 16, {}));
- instructions.push_back(MakeInstructionMessage(SpvOpUnreachable, 0, 0, {}));
- instructions.push_back(MakeInstructionMessage(SpvOpLabel, 0, 17, {}));
- instructions.push_back(MakeInstructionMessage(SpvOpKill, 0, 0, {}));
- instructions.push_back(MakeInstructionMessage(SpvOpFunctionEnd, 0, 0, {}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLabel, 0, 16, {}));
+ instructions.push_back(
+ MakeInstructionMessage(spv::Op::OpUnreachable, 0, 0, {}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLabel, 0, 17, {}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpKill, 0, 0, {}));
+ instructions.push_back(
+ MakeInstructionMessage(spv::Op::OpFunctionEnd, 0, 0, {}));
spvtools::ValidatorOptions validator_options;
@@ -996,31 +1021,36 @@ TEST(TransformationAddFunctionTest, KillAndUnreachableInNonVoidFunction) {
std::vector<protobufs::Instruction> instructions;
- instructions.push_back(MakeInstructionMessage(
- SpvOpFunction, 6, 10,
- {{SPV_OPERAND_TYPE_FUNCTION_CONTROL, {SpvFunctionControlMaskNone}},
- {SPV_OPERAND_TYPE_TYPE_ID, {50}}}));
instructions.push_back(
- MakeInstructionMessage(SpvOpFunctionParameter, 7, 9, {}));
- instructions.push_back(MakeInstructionMessage(SpvOpLabel, 0, 11, {}));
+ MakeInstructionMessage(spv::Op::OpFunction, 6, 10,
+ {{SPV_OPERAND_TYPE_FUNCTION_CONTROL,
+ {uint32_t(spv::FunctionControlMask::MaskNone)}},
+ {SPV_OPERAND_TYPE_TYPE_ID, {50}}}));
instructions.push_back(
- MakeInstructionMessage(SpvOpLoad, 6, 12, {{SPV_OPERAND_TYPE_ID, {9}}}));
+ MakeInstructionMessage(spv::Op::OpFunctionParameter, 7, 9, {}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLabel, 0, 11, {}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLoad, 6, 12,
+ {{SPV_OPERAND_TYPE_ID, {9}}}));
instructions.push_back(MakeInstructionMessage(
- SpvOpIEqual, 14, 15,
+ spv::Op::OpIEqual, 14, 15,
{{SPV_OPERAND_TYPE_ID, {12}}, {SPV_OPERAND_TYPE_ID, {13}}}));
instructions.push_back(MakeInstructionMessage(
- SpvOpSelectionMerge, 0, 0,
+ spv::Op::OpSelectionMerge, 0, 0,
{{SPV_OPERAND_TYPE_ID, {17}},
- {SPV_OPERAND_TYPE_SELECTION_CONTROL, {SpvSelectionControlMaskNone}}}));
- instructions.push_back(MakeInstructionMessage(SpvOpBranchConditional, 0, 0,
+ {SPV_OPERAND_TYPE_SELECTION_CONTROL,
+ {uint32_t(spv::SelectionControlMask::MaskNone)}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpBranchConditional, 0,
+ 0,
{{SPV_OPERAND_TYPE_ID, {15}},
{SPV_OPERAND_TYPE_ID, {16}},
{SPV_OPERAND_TYPE_ID, {17}}}));
- instructions.push_back(MakeInstructionMessage(SpvOpLabel, 0, 16, {}));
- instructions.push_back(MakeInstructionMessage(SpvOpUnreachable, 0, 0, {}));
- instructions.push_back(MakeInstructionMessage(SpvOpLabel, 0, 17, {}));
- instructions.push_back(MakeInstructionMessage(SpvOpKill, 0, 0, {}));
- instructions.push_back(MakeInstructionMessage(SpvOpFunctionEnd, 0, 0, {}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLabel, 0, 16, {}));
+ instructions.push_back(
+ MakeInstructionMessage(spv::Op::OpUnreachable, 0, 0, {}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLabel, 0, 17, {}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpKill, 0, 0, {}));
+ instructions.push_back(
+ MakeInstructionMessage(spv::Op::OpFunctionEnd, 0, 0, {}));
spvtools::ValidatorOptions validator_options;
@@ -1189,129 +1219,133 @@ TEST(TransformationAddFunctionTest, ClampedAccessChains) {
std::vector<protobufs::Instruction> instructions;
- instructions.push_back(MakeInstructionMessage(
- SpvOpFunction, 2, 12,
- {{SPV_OPERAND_TYPE_FUNCTION_CONTROL, {SpvFunctionControlMaskNone}},
- {SPV_OPERAND_TYPE_TYPE_ID, {8}}}));
instructions.push_back(
- MakeInstructionMessage(SpvOpFunctionParameter, 7, 9, {}));
+ MakeInstructionMessage(spv::Op::OpFunction, 2, 12,
+ {{SPV_OPERAND_TYPE_FUNCTION_CONTROL,
+ {uint32_t(spv::FunctionControlMask::MaskNone)}},
+ {SPV_OPERAND_TYPE_TYPE_ID, {8}}}));
instructions.push_back(
- MakeInstructionMessage(SpvOpFunctionParameter, 102, 10, {}));
+ MakeInstructionMessage(spv::Op::OpFunctionParameter, 7, 9, {}));
instructions.push_back(
- MakeInstructionMessage(SpvOpFunctionParameter, 7, 11, {}));
- instructions.push_back(MakeInstructionMessage(SpvOpLabel, 0, 13, {}));
+ MakeInstructionMessage(spv::Op::OpFunctionParameter, 102, 10, {}));
+ instructions.push_back(
+ MakeInstructionMessage(spv::Op::OpFunctionParameter, 7, 11, {}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLabel, 0, 13, {}));
- instructions.push_back(MakeInstructionMessage(
- SpvOpVariable, 7, 14,
- {{SPV_OPERAND_TYPE_STORAGE_CLASS, {SpvStorageClassFunction}}}));
- instructions.push_back(MakeInstructionMessage(
- SpvOpVariable, 26, 27,
- {{SPV_OPERAND_TYPE_STORAGE_CLASS, {SpvStorageClassFunction}}}));
instructions.push_back(
- MakeInstructionMessage(SpvOpLoad, 6, 22, {{SPV_OPERAND_TYPE_ID, {11}}}));
- instructions.push_back(MakeInstructionMessage(SpvOpAccessChain, 23, 24,
+ MakeInstructionMessage(spv::Op::OpVariable, 7, 14,
+ {{SPV_OPERAND_TYPE_STORAGE_CLASS,
+ {uint32_t(spv::StorageClass::Function)}}}));
+ instructions.push_back(
+ MakeInstructionMessage(spv::Op::OpVariable, 26, 27,
+ {{SPV_OPERAND_TYPE_STORAGE_CLASS,
+ {uint32_t(spv::StorageClass::Function)}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLoad, 6, 22,
+ {{SPV_OPERAND_TYPE_ID, {11}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpAccessChain, 23, 24,
{{SPV_OPERAND_TYPE_ID, {20}},
{SPV_OPERAND_TYPE_ID, {21}},
{SPV_OPERAND_TYPE_ID, {22}}}));
- instructions.push_back(
- MakeInstructionMessage(SpvOpLoad, 6, 25, {{SPV_OPERAND_TYPE_ID, {24}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLoad, 6, 25,
+ {{SPV_OPERAND_TYPE_ID, {24}}}));
instructions.push_back(MakeInstructionMessage(
- SpvOpStore, 0, 0,
+ spv::Op::OpStore, 0, 0,
{{SPV_OPERAND_TYPE_ID, {14}}, {SPV_OPERAND_TYPE_ID, {25}}}));
- instructions.push_back(
- MakeInstructionMessage(SpvOpLoad, 15, 28, {{SPV_OPERAND_TYPE_ID, {10}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLoad, 15, 28,
+ {{SPV_OPERAND_TYPE_ID, {10}}}));
instructions.push_back(MakeInstructionMessage(
- SpvOpAccessChain, 29, 30,
+ spv::Op::OpAccessChain, 29, 30,
{{SPV_OPERAND_TYPE_ID, {20}}, {SPV_OPERAND_TYPE_ID, {28}}}));
- instructions.push_back(
- MakeInstructionMessage(SpvOpLoad, 17, 31, {{SPV_OPERAND_TYPE_ID, {30}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLoad, 17, 31,
+ {{SPV_OPERAND_TYPE_ID, {30}}}));
instructions.push_back(MakeInstructionMessage(
- SpvOpStore, 0, 0,
+ spv::Op::OpStore, 0, 0,
{{SPV_OPERAND_TYPE_ID, {27}}, {SPV_OPERAND_TYPE_ID, {31}}}));
- instructions.push_back(
- MakeInstructionMessage(SpvOpLoad, 6, 32, {{SPV_OPERAND_TYPE_ID, {9}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLoad, 6, 32,
+ {{SPV_OPERAND_TYPE_ID, {9}}}));
instructions.push_back(MakeInstructionMessage(
- SpvOpInBoundsAccessChain, 7, 34,
+ spv::Op::OpInBoundsAccessChain, 7, 34,
{{SPV_OPERAND_TYPE_ID, {27}}, {SPV_OPERAND_TYPE_ID, {32}}}));
instructions.push_back(MakeInstructionMessage(
- SpvOpStore, 0, 0,
+ spv::Op::OpStore, 0, 0,
{{SPV_OPERAND_TYPE_ID, {34}}, {SPV_OPERAND_TYPE_ID, {33}}}));
- instructions.push_back(
- MakeInstructionMessage(SpvOpLoad, 6, 39, {{SPV_OPERAND_TYPE_ID, {9}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLoad, 6, 39,
+ {{SPV_OPERAND_TYPE_ID, {9}}}));
instructions.push_back(MakeInstructionMessage(
- SpvOpAccessChain, 23, 40,
+ spv::Op::OpAccessChain, 23, 40,
{{SPV_OPERAND_TYPE_ID, {38}}, {SPV_OPERAND_TYPE_ID, {33}}}));
- instructions.push_back(
- MakeInstructionMessage(SpvOpLoad, 6, 41, {{SPV_OPERAND_TYPE_ID, {40}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLoad, 6, 41,
+ {{SPV_OPERAND_TYPE_ID, {40}}}));
instructions.push_back(MakeInstructionMessage(
- SpvOpInBoundsAccessChain, 23, 42,
+ spv::Op::OpInBoundsAccessChain, 23, 42,
{{SPV_OPERAND_TYPE_ID, {38}}, {SPV_OPERAND_TYPE_ID, {39}}}));
instructions.push_back(MakeInstructionMessage(
- SpvOpStore, 0, 0,
+ spv::Op::OpStore, 0, 0,
{{SPV_OPERAND_TYPE_ID, {42}}, {SPV_OPERAND_TYPE_ID, {41}}}));
- instructions.push_back(
- MakeInstructionMessage(SpvOpLoad, 15, 43, {{SPV_OPERAND_TYPE_ID, {10}}}));
- instructions.push_back(
- MakeInstructionMessage(SpvOpLoad, 6, 44, {{SPV_OPERAND_TYPE_ID, {11}}}));
- instructions.push_back(
- MakeInstructionMessage(SpvOpLoad, 6, 45, {{SPV_OPERAND_TYPE_ID, {9}}}));
- instructions.push_back(
- MakeInstructionMessage(SpvOpLoad, 15, 46, {{SPV_OPERAND_TYPE_ID, {10}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLoad, 15, 43,
+ {{SPV_OPERAND_TYPE_ID, {10}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLoad, 6, 44,
+ {{SPV_OPERAND_TYPE_ID, {11}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLoad, 6, 45,
+ {{SPV_OPERAND_TYPE_ID, {9}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLoad, 15, 46,
+ {{SPV_OPERAND_TYPE_ID, {10}}}));
instructions.push_back(MakeInstructionMessage(
- SpvOpIAdd, 6, 47,
+ spv::Op::OpIAdd, 6, 47,
{{SPV_OPERAND_TYPE_ID, {45}}, {SPV_OPERAND_TYPE_ID, {46}}}));
instructions.push_back(MakeInstructionMessage(
- SpvOpAccessChain, 23, 48,
+ spv::Op::OpAccessChain, 23, 48,
{{SPV_OPERAND_TYPE_ID, {38}}, {SPV_OPERAND_TYPE_ID, {47}}}));
- instructions.push_back(
- MakeInstructionMessage(SpvOpLoad, 6, 49, {{SPV_OPERAND_TYPE_ID, {48}}}));
- instructions.push_back(MakeInstructionMessage(SpvOpInBoundsAccessChain, 23,
- 50,
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLoad, 6, 49,
+ {{SPV_OPERAND_TYPE_ID, {48}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpInBoundsAccessChain,
+ 23, 50,
{{SPV_OPERAND_TYPE_ID, {20}},
{SPV_OPERAND_TYPE_ID, {43}},
{SPV_OPERAND_TYPE_ID, {44}}}));
- instructions.push_back(
- MakeInstructionMessage(SpvOpLoad, 6, 51, {{SPV_OPERAND_TYPE_ID, {50}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLoad, 6, 51,
+ {{SPV_OPERAND_TYPE_ID, {50}}}));
instructions.push_back(MakeInstructionMessage(
- SpvOpIAdd, 6, 52,
+ spv::Op::OpIAdd, 6, 52,
{{SPV_OPERAND_TYPE_ID, {51}}, {SPV_OPERAND_TYPE_ID, {49}}}));
- instructions.push_back(MakeInstructionMessage(SpvOpAccessChain, 23, 53,
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpAccessChain, 23, 53,
{{SPV_OPERAND_TYPE_ID, {20}},
{SPV_OPERAND_TYPE_ID, {43}},
{SPV_OPERAND_TYPE_ID, {44}}}));
instructions.push_back(MakeInstructionMessage(
- SpvOpStore, 0, 0,
+ spv::Op::OpStore, 0, 0,
{{SPV_OPERAND_TYPE_ID, {53}}, {SPV_OPERAND_TYPE_ID, {52}}}));
- instructions.push_back(
- MakeInstructionMessage(SpvOpLoad, 15, 58, {{SPV_OPERAND_TYPE_ID, {10}}}));
- instructions.push_back(
- MakeInstructionMessage(SpvOpLoad, 6, 63, {{SPV_OPERAND_TYPE_ID, {11}}}));
- instructions.push_back(MakeInstructionMessage(SpvOpAccessChain, 64, 65,
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLoad, 15, 58,
+ {{SPV_OPERAND_TYPE_ID, {10}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLoad, 6, 63,
+ {{SPV_OPERAND_TYPE_ID, {11}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpAccessChain, 64, 65,
{{SPV_OPERAND_TYPE_ID, {62}},
{SPV_OPERAND_TYPE_ID, {21}},
{SPV_OPERAND_TYPE_ID, {63}}}));
- instructions.push_back(MakeInstructionMessage(SpvOpAccessChain, 64, 101,
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpAccessChain, 64, 101,
{{SPV_OPERAND_TYPE_ID, {62}},
{SPV_OPERAND_TYPE_ID, {45}},
{SPV_OPERAND_TYPE_ID, {46}}}));
- instructions.push_back(
- MakeInstructionMessage(SpvOpLoad, 54, 66, {{SPV_OPERAND_TYPE_ID, {65}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLoad, 54, 66,
+ {{SPV_OPERAND_TYPE_ID, {65}}}));
instructions.push_back(MakeInstructionMessage(
- SpvOpAccessChain, 64, 67,
+ spv::Op::OpAccessChain, 64, 67,
{{SPV_OPERAND_TYPE_ID, {57}}, {SPV_OPERAND_TYPE_ID, {58}}}));
instructions.push_back(MakeInstructionMessage(
- SpvOpStore, 0, 0,
+ spv::Op::OpStore, 0, 0,
{{SPV_OPERAND_TYPE_ID, {67}}, {SPV_OPERAND_TYPE_ID, {66}}}));
- instructions.push_back(
- MakeInstructionMessage(SpvOpLoad, 6, 68, {{SPV_OPERAND_TYPE_ID, {9}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLoad, 6, 68,
+ {{SPV_OPERAND_TYPE_ID, {9}}}));
instructions.push_back(MakeInstructionMessage(
- SpvOpInBoundsAccessChain, 64, 70,
+ spv::Op::OpInBoundsAccessChain, 64, 70,
{{SPV_OPERAND_TYPE_ID, {57}}, {SPV_OPERAND_TYPE_ID, {68}}}));
instructions.push_back(MakeInstructionMessage(
- SpvOpStore, 0, 0,
+ spv::Op::OpStore, 0, 0,
{{SPV_OPERAND_TYPE_ID, {70}}, {SPV_OPERAND_TYPE_ID, {69}}}));
- instructions.push_back(MakeInstructionMessage(SpvOpReturn, 0, 0, {}));
- instructions.push_back(MakeInstructionMessage(SpvOpFunctionEnd, 0, 0, {}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpReturn, 0, 0, {}));
+ instructions.push_back(
+ MakeInstructionMessage(spv::Op::OpFunctionEnd, 0, 0, {}));
spvtools::ValidatorOptions validator_options;
@@ -1634,15 +1668,17 @@ TEST(TransformationAddFunctionTest, LivesafeCanCallLivesafe) {
std::vector<protobufs::Instruction> instructions;
- instructions.push_back(MakeInstructionMessage(
- SpvOpFunction, 2, 8,
- {{SPV_OPERAND_TYPE_FUNCTION_CONTROL, {SpvFunctionControlMaskNone}},
- {SPV_OPERAND_TYPE_TYPE_ID, {3}}}));
- instructions.push_back(MakeInstructionMessage(SpvOpLabel, 0, 9, {}));
- instructions.push_back(MakeInstructionMessage(SpvOpFunctionCall, 2, 11,
+ instructions.push_back(
+ MakeInstructionMessage(spv::Op::OpFunction, 2, 8,
+ {{SPV_OPERAND_TYPE_FUNCTION_CONTROL,
+ {uint32_t(spv::FunctionControlMask::MaskNone)}},
+ {SPV_OPERAND_TYPE_TYPE_ID, {3}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLabel, 0, 9, {}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpFunctionCall, 2, 11,
{{SPV_OPERAND_TYPE_ID, {6}}}));
- instructions.push_back(MakeInstructionMessage(SpvOpReturn, 0, 0, {}));
- instructions.push_back(MakeInstructionMessage(SpvOpFunctionEnd, 0, 0, {}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpReturn, 0, 0, {}));
+ instructions.push_back(
+ MakeInstructionMessage(spv::Op::OpFunctionEnd, 0, 0, {}));
spvtools::ValidatorOptions validator_options;
@@ -1738,15 +1774,17 @@ TEST(TransformationAddFunctionTest, LivesafeOnlyCallsLivesafe) {
std::vector<protobufs::Instruction> instructions;
- instructions.push_back(MakeInstructionMessage(
- SpvOpFunction, 2, 8,
- {{SPV_OPERAND_TYPE_FUNCTION_CONTROL, {SpvFunctionControlMaskNone}},
- {SPV_OPERAND_TYPE_TYPE_ID, {3}}}));
- instructions.push_back(MakeInstructionMessage(SpvOpLabel, 0, 9, {}));
- instructions.push_back(MakeInstructionMessage(SpvOpFunctionCall, 2, 11,
+ instructions.push_back(
+ MakeInstructionMessage(spv::Op::OpFunction, 2, 8,
+ {{SPV_OPERAND_TYPE_FUNCTION_CONTROL,
+ {uint32_t(spv::FunctionControlMask::MaskNone)}},
+ {SPV_OPERAND_TYPE_TYPE_ID, {3}}}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpLabel, 0, 9, {}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpFunctionCall, 2, 11,
{{SPV_OPERAND_TYPE_ID, {6}}}));
- instructions.push_back(MakeInstructionMessage(SpvOpReturn, 0, 0, {}));
- instructions.push_back(MakeInstructionMessage(SpvOpFunctionEnd, 0, 0, {}));
+ instructions.push_back(MakeInstructionMessage(spv::Op::OpReturn, 0, 0, {}));
+ instructions.push_back(
+ MakeInstructionMessage(spv::Op::OpFunctionEnd, 0, 0, {}));
spvtools::ValidatorOptions validator_options;
diff --git a/test/fuzz/transformation_add_global_undef_test.cpp b/test/fuzz/transformation_add_global_undef_test.cpp
index 03b915705..b87970fa7 100644
--- a/test/fuzz/transformation_add_global_undef_test.cpp
+++ b/test/fuzz/transformation_add_global_undef_test.cpp
@@ -71,7 +71,8 @@ TEST(TransformationAddGlobalUndefTest, BasicTest) {
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
&transformation_context);
- ASSERT_EQ(SpvOpUndef, context->get_def_use_mgr()->GetDef(100)->opcode());
+ ASSERT_EQ(spv::Op::OpUndef,
+ context->get_def_use_mgr()->GetDef(100)->opcode());
}
TransformationAddGlobalUndef transformations[] = {
diff --git a/test/fuzz/transformation_add_global_variable_test.cpp b/test/fuzz/transformation_add_global_variable_test.cpp
index 9531ade7c..fc452df3d 100644
--- a/test/fuzz/transformation_add_global_variable_test.cpp
+++ b/test/fuzz/transformation_add_global_variable_test.cpp
@@ -66,94 +66,95 @@ TEST(TransformationAddGlobalVariableTest, BasicTest) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
// Id already in use
- ASSERT_FALSE(
- TransformationAddGlobalVariable(4, 10, SpvStorageClassPrivate, 0, true)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationAddGlobalVariable(
+ 4, 10, spv::StorageClass::Private, 0, true)
+ .IsApplicable(context.get(), transformation_context));
// %1 is not a type
- ASSERT_FALSE(
- TransformationAddGlobalVariable(100, 1, SpvStorageClassPrivate, 0, false)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationAddGlobalVariable(
+ 100, 1, spv::StorageClass::Private, 0, false)
+ .IsApplicable(context.get(), transformation_context));
// %7 is not a pointer type
- ASSERT_FALSE(
- TransformationAddGlobalVariable(100, 7, SpvStorageClassPrivate, 0, true)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationAddGlobalVariable(
+ 100, 7, spv::StorageClass::Private, 0, true)
+ .IsApplicable(context.get(), transformation_context));
// %9 does not have Private storage class
- ASSERT_FALSE(
- TransformationAddGlobalVariable(100, 9, SpvStorageClassPrivate, 0, false)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationAddGlobalVariable(
+ 100, 9, spv::StorageClass::Private, 0, false)
+ .IsApplicable(context.get(), transformation_context));
// %15 does not have Private storage class
- ASSERT_FALSE(
- TransformationAddGlobalVariable(100, 15, SpvStorageClassPrivate, 0, true)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationAddGlobalVariable(
+ 100, 15, spv::StorageClass::Private, 0, true)
+ .IsApplicable(context.get(), transformation_context));
// %10 is a pointer to float, while %16 is an int constant
- ASSERT_FALSE(TransformationAddGlobalVariable(100, 10, SpvStorageClassPrivate,
- 16, false)
+ ASSERT_FALSE(TransformationAddGlobalVariable(
+ 100, 10, spv::StorageClass::Private, 16, false)
.IsApplicable(context.get(), transformation_context));
// %10 is a Private pointer to float, while %15 is a variable with type
// Uniform float pointer
- ASSERT_FALSE(
- TransformationAddGlobalVariable(100, 10, SpvStorageClassPrivate, 15, true)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationAddGlobalVariable(
+ 100, 10, spv::StorageClass::Private, 15, true)
+ .IsApplicable(context.get(), transformation_context));
// %12 is a Private pointer to int, while %10 is a variable with type
// Private float pointer
- ASSERT_FALSE(TransformationAddGlobalVariable(100, 12, SpvStorageClassPrivate,
- 10, false)
+ ASSERT_FALSE(TransformationAddGlobalVariable(
+ 100, 12, spv::StorageClass::Private, 10, false)
.IsApplicable(context.get(), transformation_context));
// %10 is pointer-to-float, and %14 has type pointer-to-float; that's not OK
// since the initializer's type should be the *pointee* type.
- ASSERT_FALSE(
- TransformationAddGlobalVariable(104, 10, SpvStorageClassPrivate, 14, true)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationAddGlobalVariable(
+ 104, 10, spv::StorageClass::Private, 14, true)
+ .IsApplicable(context.get(), transformation_context));
// This would work in principle, but logical addressing does not allow
// a pointer to a pointer.
- ASSERT_FALSE(TransformationAddGlobalVariable(104, 17, SpvStorageClassPrivate,
- 14, false)
+ ASSERT_FALSE(TransformationAddGlobalVariable(
+ 104, 17, spv::StorageClass::Private, 14, false)
.IsApplicable(context.get(), transformation_context));
{
// %100 = OpVariable %12 Private
ASSERT_EQ(nullptr, context->get_def_use_mgr()->GetDef(100));
TransformationAddGlobalVariable transformation(
- 100, 12, SpvStorageClassPrivate, 16, true);
+ 100, 12, spv::StorageClass::Private, 16, true);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
&transformation_context);
- ASSERT_EQ(SpvOpVariable, context->get_def_use_mgr()->GetDef(100)->opcode());
+ ASSERT_EQ(spv::Op::OpVariable,
+ context->get_def_use_mgr()->GetDef(100)->opcode());
ASSERT_EQ(
- SpvStorageClassPrivate,
- static_cast<SpvStorageClass>(
+ spv::StorageClass::Private,
+ static_cast<spv::StorageClass>(
context->get_def_use_mgr()->GetDef(100)->GetSingleWordInOperand(
0)));
}
TransformationAddGlobalVariable transformations[] = {
// %101 = OpVariable %10 Private
- TransformationAddGlobalVariable(101, 10, SpvStorageClassPrivate, 40,
+ TransformationAddGlobalVariable(101, 10, spv::StorageClass::Private, 40,
false),
// %102 = OpVariable %13 Private
- TransformationAddGlobalVariable(102, 13, SpvStorageClassPrivate, 41,
+ TransformationAddGlobalVariable(102, 13, spv::StorageClass::Private, 41,
true),
// %103 = OpVariable %12 Private %16
- TransformationAddGlobalVariable(103, 12, SpvStorageClassPrivate, 16,
+ TransformationAddGlobalVariable(103, 12, spv::StorageClass::Private, 16,
false),
// %104 = OpVariable %19 Private %21
- TransformationAddGlobalVariable(104, 19, SpvStorageClassPrivate, 21,
+ TransformationAddGlobalVariable(104, 19, spv::StorageClass::Private, 21,
true),
// %105 = OpVariable %19 Private %22
- TransformationAddGlobalVariable(105, 19, SpvStorageClassPrivate, 22,
+ TransformationAddGlobalVariable(105, 19, spv::StorageClass::Private, 22,
false)};
for (auto& transformation : transformations) {
@@ -269,15 +270,15 @@ TEST(TransformationAddGlobalVariableTest, TestEntryPointInterfaceEnlargement) {
MakeUnique<FactManager>(context.get()), validator_options);
TransformationAddGlobalVariable transformations[] = {
// %100 = OpVariable %12 Private
- TransformationAddGlobalVariable(100, 12, SpvStorageClassPrivate, 16,
+ TransformationAddGlobalVariable(100, 12, spv::StorageClass::Private, 16,
true),
// %101 = OpVariable %12 Private %16
- TransformationAddGlobalVariable(101, 12, SpvStorageClassPrivate, 16,
+ TransformationAddGlobalVariable(101, 12, spv::StorageClass::Private, 16,
false),
// %102 = OpVariable %19 Private %21
- TransformationAddGlobalVariable(102, 19, SpvStorageClassPrivate, 21,
+ TransformationAddGlobalVariable(102, 19, spv::StorageClass::Private, 21,
true)};
for (auto& transformation : transformations) {
@@ -388,15 +389,15 @@ TEST(TransformationAddGlobalVariableTest,
MakeUnique<FactManager>(context.get()), validator_options);
TransformationAddGlobalVariable transformations[] = {
// %100 = OpVariable %12 Private
- TransformationAddGlobalVariable(100, 12, SpvStorageClassPrivate, 16,
+ TransformationAddGlobalVariable(100, 12, spv::StorageClass::Private, 16,
true),
// %101 = OpVariable %12 Private %16
- TransformationAddGlobalVariable(101, 12, SpvStorageClassPrivate, 16,
+ TransformationAddGlobalVariable(101, 12, spv::StorageClass::Private, 16,
false),
// %102 = OpVariable %19 Private %21
- TransformationAddGlobalVariable(102, 19, SpvStorageClassPrivate, 21,
+ TransformationAddGlobalVariable(102, 19, spv::StorageClass::Private, 21,
true)};
for (auto& transformation : transformations) {
@@ -486,7 +487,8 @@ TEST(TransformationAddGlobalVariableTest, TestAddingWorkgroupGlobals) {
MakeUnique<FactManager>(context.get()), validator_options);
#ifndef NDEBUG
ASSERT_DEATH(
- TransformationAddGlobalVariable(8, 7, SpvStorageClassWorkgroup, 50, true)
+ TransformationAddGlobalVariable(8, 7, spv::StorageClass::Workgroup, 50,
+ true)
.IsApplicable(context.get(), transformation_context),
"By construction this transformation should not have an.*initializer "
"when Workgroup storage class is used");
@@ -494,10 +496,11 @@ TEST(TransformationAddGlobalVariableTest, TestAddingWorkgroupGlobals) {
TransformationAddGlobalVariable transformations[] = {
// %8 = OpVariable %7 Workgroup
- TransformationAddGlobalVariable(8, 7, SpvStorageClassWorkgroup, 0, true),
+ TransformationAddGlobalVariable(8, 7, spv::StorageClass::Workgroup, 0,
+ true),
// %10 = OpVariable %7 Workgroup
- TransformationAddGlobalVariable(10, 7, SpvStorageClassWorkgroup, 0,
+ TransformationAddGlobalVariable(10, 7, spv::StorageClass::Workgroup, 0,
false)};
for (auto& transformation : transformations) {
diff --git a/test/fuzz/transformation_add_image_sample_unused_components_test.cpp b/test/fuzz/transformation_add_image_sample_unused_components_test.cpp
index 072378cac..7047544b9 100644
--- a/test/fuzz/transformation_add_image_sample_unused_components_test.cpp
+++ b/test/fuzz/transformation_add_image_sample_unused_components_test.cpp
@@ -73,14 +73,14 @@ TEST(TransformationAddImageSampleUnusedComponentsTest, IsApplicable) {
MakeUnique<FactManager>(context.get()), validator_options);
// Tests applicable image instruction.
auto instruction_descriptor =
- MakeInstructionDescriptor(25, SpvOpImageSampleImplicitLod, 0);
+ MakeInstructionDescriptor(25, spv::Op::OpImageSampleImplicitLod, 0);
auto transformation =
TransformationAddImageSampleUnusedComponents(23, instruction_descriptor);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
instruction_descriptor =
- MakeInstructionDescriptor(26, SpvOpImageSampleExplicitLod, 0);
+ MakeInstructionDescriptor(26, spv::Op::OpImageSampleExplicitLod, 0);
transformation =
TransformationAddImageSampleUnusedComponents(24, instruction_descriptor);
ASSERT_TRUE(
@@ -88,27 +88,27 @@ TEST(TransformationAddImageSampleUnusedComponentsTest, IsApplicable) {
// Tests undefined image instructions.
instruction_descriptor =
- MakeInstructionDescriptor(27, SpvOpImageSampleImplicitLod, 0);
+ MakeInstructionDescriptor(27, spv::Op::OpImageSampleImplicitLod, 0);
transformation =
TransformationAddImageSampleUnusedComponents(23, instruction_descriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
instruction_descriptor =
- MakeInstructionDescriptor(28, SpvOpImageSampleExplicitLod, 0);
+ MakeInstructionDescriptor(28, spv::Op::OpImageSampleExplicitLod, 0);
transformation =
TransformationAddImageSampleUnusedComponents(23, instruction_descriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
// Tests non-image instructions.
- instruction_descriptor = MakeInstructionDescriptor(19, SpvOpLabel, 0);
+ instruction_descriptor = MakeInstructionDescriptor(19, spv::Op::OpLabel, 0);
transformation =
TransformationAddImageSampleUnusedComponents(24, instruction_descriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
- instruction_descriptor = MakeInstructionDescriptor(20, SpvOpLoad, 0);
+ instruction_descriptor = MakeInstructionDescriptor(20, spv::Op::OpLoad, 0);
transformation =
TransformationAddImageSampleUnusedComponents(24, instruction_descriptor);
ASSERT_FALSE(
@@ -116,7 +116,7 @@ TEST(TransformationAddImageSampleUnusedComponentsTest, IsApplicable) {
// Tests coordinate operand being a vec4.
instruction_descriptor =
- MakeInstructionDescriptor(27, SpvOpImageSampleExplicitLod, 0);
+ MakeInstructionDescriptor(27, spv::Op::OpImageSampleExplicitLod, 0);
transformation =
TransformationAddImageSampleUnusedComponents(22, instruction_descriptor);
ASSERT_FALSE(
@@ -124,7 +124,7 @@ TEST(TransformationAddImageSampleUnusedComponentsTest, IsApplicable) {
// Tests undefined coordinate with unused operands.
instruction_descriptor =
- MakeInstructionDescriptor(25, SpvOpImageSampleImplicitLod, 0);
+ MakeInstructionDescriptor(25, spv::Op::OpImageSampleImplicitLod, 0);
transformation =
TransformationAddImageSampleUnusedComponents(27, instruction_descriptor);
ASSERT_FALSE(
@@ -133,7 +133,7 @@ TEST(TransformationAddImageSampleUnusedComponentsTest, IsApplicable) {
// Tests coordinate with unused operands being a non-OpCompositeConstruct
// instruction.
instruction_descriptor =
- MakeInstructionDescriptor(25, SpvOpImageSampleImplicitLod, 0);
+ MakeInstructionDescriptor(25, spv::Op::OpImageSampleImplicitLod, 0);
transformation =
TransformationAddImageSampleUnusedComponents(21, instruction_descriptor);
ASSERT_FALSE(
@@ -142,7 +142,7 @@ TEST(TransformationAddImageSampleUnusedComponentsTest, IsApplicable) {
// Tests the first OpCompositeConstruct constituent not being the original
// coordinate.
instruction_descriptor =
- MakeInstructionDescriptor(25, SpvOpImageSampleImplicitLod, 0);
+ MakeInstructionDescriptor(25, spv::Op::OpImageSampleImplicitLod, 0);
transformation =
TransformationAddImageSampleUnusedComponents(22, instruction_descriptor);
ASSERT_FALSE(
@@ -198,13 +198,13 @@ TEST(TransformationAddImageSampleUnusedComponentsTest, Apply) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
auto instruction_descriptor =
- MakeInstructionDescriptor(25, SpvOpImageSampleImplicitLod, 0);
+ MakeInstructionDescriptor(25, spv::Op::OpImageSampleImplicitLod, 0);
auto transformation =
TransformationAddImageSampleUnusedComponents(23, instruction_descriptor);
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
instruction_descriptor =
- MakeInstructionDescriptor(26, SpvOpImageSampleExplicitLod, 0);
+ MakeInstructionDescriptor(26, spv::Op::OpImageSampleExplicitLod, 0);
transformation =
TransformationAddImageSampleUnusedComponents(24, instruction_descriptor);
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
diff --git a/test/fuzz/transformation_add_local_variable_test.cpp b/test/fuzz/transformation_add_local_variable_test.cpp
index de88573a4..2af85971e 100644
--- a/test/fuzz/transformation_add_local_variable_test.cpp
+++ b/test/fuzz/transformation_add_local_variable_test.cpp
@@ -104,7 +104,8 @@ TEST(TransformationAddLocalVariableTest, BasicTest) {
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
&transformation_context);
- ASSERT_EQ(SpvOpVariable, context->get_def_use_mgr()->GetDef(105)->opcode());
+ ASSERT_EQ(spv::Op::OpVariable,
+ context->get_def_use_mgr()->GetDef(105)->opcode());
ASSERT_EQ(5, context->get_instr_block(105)->id());
}
diff --git a/test/fuzz/transformation_add_opphi_synonym_test.cpp b/test/fuzz/transformation_add_opphi_synonym_test.cpp
index 3501f8edf..4aca30ce6 100644
--- a/test/fuzz/transformation_add_opphi_synonym_test.cpp
+++ b/test/fuzz/transformation_add_opphi_synonym_test.cpp
@@ -366,7 +366,7 @@ TEST(TransformationAddOpPhiSynonymTest, VariablePointers) {
// Remove the VariablePointers capability.
context.get()->get_feature_mgr()->RemoveCapability(
- SpvCapabilityVariablePointers);
+ spv::Capability::VariablePointers);
// The VariablePointers capability is required to add an OpPhi instruction of
// pointer type.
@@ -375,7 +375,7 @@ TEST(TransformationAddOpPhiSynonymTest, VariablePointers) {
// Add the VariablePointers capability back.
context.get()->get_feature_mgr()->AddCapability(
- SpvCapabilityVariablePointers);
+ spv::Capability::VariablePointers);
// If the ids have pointer type, the storage class must be Workgroup or
// StorageBuffer, but it is Function in this case.
diff --git a/test/fuzz/transformation_add_synonym_test.cpp b/test/fuzz/transformation_add_synonym_test.cpp
index ffcf1c9bd..385590e61 100644
--- a/test/fuzz/transformation_add_synonym_test.cpp
+++ b/test/fuzz/transformation_add_synonym_test.cpp
@@ -77,7 +77,7 @@ TEST(TransformationAddSynonymTest, NotApplicable) {
MakeUnique<FactManager>(context.get()), validator_options);
transformation_context.GetFactManager()->AddFactIdIsIrrelevant(24);
- auto insert_before = MakeInstructionDescriptor(22, SpvOpReturn, 0);
+ auto insert_before = MakeInstructionDescriptor(22, spv::Op::OpReturn, 0);
#ifndef NDEBUG
ASSERT_DEATH(
@@ -126,34 +126,34 @@ TEST(TransformationAddSynonymTest, NotApplicable) {
.IsApplicable(context.get(), transformation_context));
// |insert_before| is invalid.
- ASSERT_FALSE(
- TransformationAddSynonym(9, synonym_type, 40,
- MakeInstructionDescriptor(25, SpvOpStore, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationAddSynonym(
+ 9, synonym_type, 40,
+ MakeInstructionDescriptor(25, spv::Op::OpStore, 0))
+ .IsApplicable(context.get(), transformation_context));
// Can't insert before |insert_before|.
- ASSERT_FALSE(
- TransformationAddSynonym(9, synonym_type, 40,
- MakeInstructionDescriptor(5, SpvOpLabel, 0))
- .IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(TransformationAddSynonym(
9, synonym_type, 40,
- MakeInstructionDescriptor(22, SpvOpVariable, 0))
+ MakeInstructionDescriptor(5, spv::Op::OpLabel, 0))
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationAddSynonym(
+ 9, synonym_type, 40,
+ MakeInstructionDescriptor(22, spv::Op::OpVariable, 0))
.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(TransformationAddSynonym(
9, synonym_type, 40,
- MakeInstructionDescriptor(25, SpvOpFunctionEnd, 0))
+ MakeInstructionDescriptor(25, spv::Op::OpFunctionEnd, 0))
.IsApplicable(context.get(), transformation_context));
// Domination rules are not satisfied.
- ASSERT_FALSE(
- TransformationAddSynonym(27, synonym_type, 40,
- MakeInstructionDescriptor(27, SpvOpLoad, 0))
- .IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(
- TransformationAddSynonym(27, synonym_type, 40,
- MakeInstructionDescriptor(22, SpvOpStore, 1))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationAddSynonym(
+ 27, synonym_type, 40,
+ MakeInstructionDescriptor(27, spv::Op::OpLoad, 0))
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationAddSynonym(
+ 27, synonym_type, 40,
+ MakeInstructionDescriptor(22, spv::Op::OpStore, 1))
+ .IsApplicable(context.get(), transformation_context));
}
}
@@ -212,7 +212,7 @@ TEST(TransformationAddSynonymTest, AddZeroSubZeroMulOne) {
kConsoleMessageConsumer));
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
- auto insert_before = MakeInstructionDescriptor(5, SpvOpReturn, 0);
+ auto insert_before = MakeInstructionDescriptor(5, spv::Op::OpReturn, 0);
uint32_t fresh_id = 50;
for (auto synonym_type : {protobufs::TransformationAddSynonym::ADD_ZERO,
@@ -374,7 +374,7 @@ TEST(TransformationAddSynonymTest, LogicalAndLogicalOr) {
kConsoleMessageConsumer));
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
- auto insert_before = MakeInstructionDescriptor(5, SpvOpReturn, 0);
+ auto insert_before = MakeInstructionDescriptor(5, spv::Op::OpReturn, 0);
uint32_t fresh_id = 50;
for (auto synonym_type : {protobufs::TransformationAddSynonym::LOGICAL_AND,
@@ -467,7 +467,7 @@ TEST(TransformationAddSynonymTest, LogicalAndConstantIsNotPresent) {
kConsoleMessageConsumer));
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
- auto insert_before = MakeInstructionDescriptor(5, SpvOpReturn, 0);
+ auto insert_before = MakeInstructionDescriptor(5, spv::Op::OpReturn, 0);
const auto synonym_type = protobufs::TransformationAddSynonym::LOGICAL_AND;
// Required constant is not present in the module.
@@ -505,7 +505,7 @@ TEST(TransformationAddSynonymTest, LogicalOrConstantIsNotPresent) {
kConsoleMessageConsumer));
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
- auto insert_before = MakeInstructionDescriptor(5, SpvOpReturn, 0);
+ auto insert_before = MakeInstructionDescriptor(5, spv::Op::OpReturn, 0);
const auto synonym_type = protobufs::TransformationAddSynonym::LOGICAL_OR;
// Required constant is not present in the module.
@@ -563,7 +563,7 @@ TEST(TransformationAddSynonymTest, CopyObject) {
kConsoleMessageConsumer));
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
- auto insert_before = MakeInstructionDescriptor(5, SpvOpReturn, 0);
+ auto insert_before = MakeInstructionDescriptor(5, spv::Op::OpReturn, 0);
const auto synonym_type = protobufs::TransformationAddSynonym::COPY_OBJECT;
ASSERT_FALSE(
@@ -666,7 +666,7 @@ TEST(TransformationAddSynonymTest, CopyBooleanConstants) {
{
TransformationAddSynonym copy_true(
7, protobufs::TransformationAddSynonym::COPY_OBJECT, 100,
- MakeInstructionDescriptor(5, SpvOpReturn, 0));
+ MakeInstructionDescriptor(5, spv::Op::OpReturn, 0));
ASSERT_TRUE(copy_true.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(copy_true, context.get(), &transformation_context);
@@ -687,7 +687,7 @@ TEST(TransformationAddSynonymTest, CopyBooleanConstants) {
{
TransformationAddSynonym copy_false(
8, protobufs::TransformationAddSynonym::COPY_OBJECT, 101,
- MakeInstructionDescriptor(100, SpvOpReturn, 0));
+ MakeInstructionDescriptor(100, spv::Op::OpReturn, 0));
ASSERT_TRUE(copy_false.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(copy_false, context.get(), &transformation_context);
std::vector<uint32_t> ids_for_which_synonyms_are_known =
@@ -707,7 +707,7 @@ TEST(TransformationAddSynonymTest, CopyBooleanConstants) {
{
TransformationAddSynonym copy_false_again(
101, protobufs::TransformationAddSynonym::COPY_OBJECT, 102,
- MakeInstructionDescriptor(5, SpvOpReturn, 0));
+ MakeInstructionDescriptor(5, spv::Op::OpReturn, 0));
ASSERT_TRUE(
copy_false_again.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(copy_false_again, context.get(),
@@ -730,7 +730,7 @@ TEST(TransformationAddSynonymTest, CopyBooleanConstants) {
{
TransformationAddSynonym copy_true_again(
7, protobufs::TransformationAddSynonym::COPY_OBJECT, 103,
- MakeInstructionDescriptor(102, SpvOpReturn, 0));
+ MakeInstructionDescriptor(102, spv::Op::OpReturn, 0));
ASSERT_TRUE(
copy_true_again.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(copy_true_again, context.get(),
@@ -970,128 +970,133 @@ TEST(TransformationAddSynonymTest, CheckIllegalCases) {
// Inapplicable because %18 is decorated.
ASSERT_FALSE(TransformationAddSynonym(
18, protobufs::TransformationAddSynonym::COPY_OBJECT, 200,
- MakeInstructionDescriptor(21, SpvOpAccessChain, 0))
+ MakeInstructionDescriptor(21, spv::Op::OpAccessChain, 0))
.IsApplicable(context.get(), transformation_context));
// Inapplicable because %77 is decorated.
ASSERT_FALSE(TransformationAddSynonym(
77, protobufs::TransformationAddSynonym::COPY_OBJECT, 200,
- MakeInstructionDescriptor(77, SpvOpBranch, 0))
+ MakeInstructionDescriptor(77, spv::Op::OpBranch, 0))
.IsApplicable(context.get(), transformation_context));
// Inapplicable because %80 is decorated.
ASSERT_FALSE(TransformationAddSynonym(
80, protobufs::TransformationAddSynonym::COPY_OBJECT, 200,
- MakeInstructionDescriptor(77, SpvOpIAdd, 0))
+ MakeInstructionDescriptor(77, spv::Op::OpIAdd, 0))
.IsApplicable(context.get(), transformation_context));
// Inapplicable because %84 is not available at the requested point
- ASSERT_FALSE(TransformationAddSynonym(
- 84, protobufs::TransformationAddSynonym::COPY_OBJECT, 200,
- MakeInstructionDescriptor(32, SpvOpCompositeExtract, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationAddSynonym(
+ 84, protobufs::TransformationAddSynonym::COPY_OBJECT, 200,
+ MakeInstructionDescriptor(32, spv::Op::OpCompositeExtract, 0))
+ .IsApplicable(context.get(), transformation_context));
// Fine because %84 is available at the requested point
- ASSERT_TRUE(TransformationAddSynonym(
- 84, protobufs::TransformationAddSynonym::COPY_OBJECT, 200,
- MakeInstructionDescriptor(32, SpvOpCompositeConstruct, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(
+ TransformationAddSynonym(
+ 84, protobufs::TransformationAddSynonym::COPY_OBJECT, 200,
+ MakeInstructionDescriptor(32, spv::Op::OpCompositeConstruct, 0))
+ .IsApplicable(context.get(), transformation_context));
// Inapplicable because id %9 is already in use
- ASSERT_FALSE(TransformationAddSynonym(
- 84, protobufs::TransformationAddSynonym::COPY_OBJECT, 9,
- MakeInstructionDescriptor(32, SpvOpCompositeConstruct, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationAddSynonym(
+ 84, protobufs::TransformationAddSynonym::COPY_OBJECT, 9,
+ MakeInstructionDescriptor(32, spv::Op::OpCompositeConstruct, 0))
+ .IsApplicable(context.get(), transformation_context));
// Inapplicable because the requested point does not exist
ASSERT_FALSE(TransformationAddSynonym(
84, protobufs::TransformationAddSynonym::COPY_OBJECT, 200,
- MakeInstructionDescriptor(86, SpvOpReturn, 2))
+ MakeInstructionDescriptor(86, spv::Op::OpReturn, 2))
.IsApplicable(context.get(), transformation_context));
// Inapplicable because %9 is not in a function
ASSERT_FALSE(TransformationAddSynonym(
9, protobufs::TransformationAddSynonym::COPY_OBJECT, 200,
- MakeInstructionDescriptor(9, SpvOpTypeInt, 0))
+ MakeInstructionDescriptor(9, spv::Op::OpTypeInt, 0))
.IsApplicable(context.get(), transformation_context));
// Inapplicable because the insert point is right before, or inside, a chunk
// of OpPhis
ASSERT_FALSE(TransformationAddSynonym(
9, protobufs::TransformationAddSynonym::COPY_OBJECT, 200,
- MakeInstructionDescriptor(30, SpvOpPhi, 0))
+ MakeInstructionDescriptor(30, spv::Op::OpPhi, 0))
.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(TransformationAddSynonym(
9, protobufs::TransformationAddSynonym::COPY_OBJECT, 200,
- MakeInstructionDescriptor(99, SpvOpPhi, 1))
+ MakeInstructionDescriptor(99, spv::Op::OpPhi, 1))
.IsApplicable(context.get(), transformation_context));
// OK, because the insert point is just after a chunk of OpPhis.
ASSERT_TRUE(TransformationAddSynonym(
9, protobufs::TransformationAddSynonym::COPY_OBJECT, 200,
- MakeInstructionDescriptor(96, SpvOpAccessChain, 0))
+ MakeInstructionDescriptor(96, spv::Op::OpAccessChain, 0))
.IsApplicable(context.get(), transformation_context));
// Inapplicable because the insert point is right after an OpSelectionMerge
- ASSERT_FALSE(TransformationAddSynonym(
- 9, protobufs::TransformationAddSynonym::COPY_OBJECT, 200,
- MakeInstructionDescriptor(58, SpvOpBranchConditional, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationAddSynonym(
+ 9, protobufs::TransformationAddSynonym::COPY_OBJECT, 200,
+ MakeInstructionDescriptor(58, spv::Op::OpBranchConditional, 0))
+ .IsApplicable(context.get(), transformation_context));
// OK, because the insert point is right before the OpSelectionMerge
ASSERT_TRUE(TransformationAddSynonym(
9, protobufs::TransformationAddSynonym::COPY_OBJECT, 200,
- MakeInstructionDescriptor(58, SpvOpSelectionMerge, 0))
+ MakeInstructionDescriptor(58, spv::Op::OpSelectionMerge, 0))
.IsApplicable(context.get(), transformation_context));
// Inapplicable because the insert point is right after an OpSelectionMerge
ASSERT_FALSE(TransformationAddSynonym(
9, protobufs::TransformationAddSynonym::COPY_OBJECT, 200,
- MakeInstructionDescriptor(43, SpvOpSwitch, 0))
+ MakeInstructionDescriptor(43, spv::Op::OpSwitch, 0))
.IsApplicable(context.get(), transformation_context));
// OK, because the insert point is right before the OpSelectionMerge
ASSERT_TRUE(TransformationAddSynonym(
9, protobufs::TransformationAddSynonym::COPY_OBJECT, 200,
- MakeInstructionDescriptor(43, SpvOpSelectionMerge, 0))
+ MakeInstructionDescriptor(43, spv::Op::OpSelectionMerge, 0))
.IsApplicable(context.get(), transformation_context));
// Inapplicable because the insert point is right after an OpLoopMerge
- ASSERT_FALSE(TransformationAddSynonym(
- 9, protobufs::TransformationAddSynonym::COPY_OBJECT, 200,
- MakeInstructionDescriptor(40, SpvOpBranchConditional, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationAddSynonym(
+ 9, protobufs::TransformationAddSynonym::COPY_OBJECT, 200,
+ MakeInstructionDescriptor(40, spv::Op::OpBranchConditional, 0))
+ .IsApplicable(context.get(), transformation_context));
// OK, because the insert point is right before the OpLoopMerge
ASSERT_TRUE(TransformationAddSynonym(
9, protobufs::TransformationAddSynonym::COPY_OBJECT, 200,
- MakeInstructionDescriptor(40, SpvOpLoopMerge, 0))
+ MakeInstructionDescriptor(40, spv::Op::OpLoopMerge, 0))
.IsApplicable(context.get(), transformation_context));
// Inapplicable because id %300 does not exist
ASSERT_FALSE(TransformationAddSynonym(
300, protobufs::TransformationAddSynonym::COPY_OBJECT, 200,
- MakeInstructionDescriptor(40, SpvOpLoopMerge, 0))
+ MakeInstructionDescriptor(40, spv::Op::OpLoopMerge, 0))
.IsApplicable(context.get(), transformation_context));
// Inapplicable because the following instruction is OpVariable
ASSERT_FALSE(TransformationAddSynonym(
9, protobufs::TransformationAddSynonym::COPY_OBJECT, 200,
- MakeInstructionDescriptor(180, SpvOpVariable, 0))
+ MakeInstructionDescriptor(180, spv::Op::OpVariable, 0))
.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(TransformationAddSynonym(
9, protobufs::TransformationAddSynonym::COPY_OBJECT, 200,
- MakeInstructionDescriptor(181, SpvOpVariable, 0))
+ MakeInstructionDescriptor(181, spv::Op::OpVariable, 0))
.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(TransformationAddSynonym(
9, protobufs::TransformationAddSynonym::COPY_OBJECT, 200,
- MakeInstructionDescriptor(182, SpvOpVariable, 0))
+ MakeInstructionDescriptor(182, spv::Op::OpVariable, 0))
.IsApplicable(context.get(), transformation_context));
// OK, because this is just past the group of OpVariable instructions.
ASSERT_TRUE(TransformationAddSynonym(
9, protobufs::TransformationAddSynonym::COPY_OBJECT, 200,
- MakeInstructionDescriptor(182, SpvOpAccessChain, 0))
+ MakeInstructionDescriptor(182, spv::Op::OpAccessChain, 0))
.IsApplicable(context.get(), transformation_context));
}
@@ -1163,25 +1168,25 @@ TEST(TransformationAddSynonymTest, MiscellaneousCopies) {
std::vector<TransformationAddSynonym> transformations = {
TransformationAddSynonym(
19, protobufs::TransformationAddSynonym::COPY_OBJECT, 100,
- MakeInstructionDescriptor(22, SpvOpStore, 0)),
+ MakeInstructionDescriptor(22, spv::Op::OpStore, 0)),
TransformationAddSynonym(
22, protobufs::TransformationAddSynonym::COPY_OBJECT, 101,
- MakeInstructionDescriptor(22, SpvOpCopyObject, 0)),
+ MakeInstructionDescriptor(22, spv::Op::OpCopyObject, 0)),
TransformationAddSynonym(
12, protobufs::TransformationAddSynonym::COPY_OBJECT, 102,
- MakeInstructionDescriptor(22, SpvOpCopyObject, 0)),
+ MakeInstructionDescriptor(22, spv::Op::OpCopyObject, 0)),
TransformationAddSynonym(
11, protobufs::TransformationAddSynonym::COPY_OBJECT, 103,
- MakeInstructionDescriptor(22, SpvOpCopyObject, 0)),
+ MakeInstructionDescriptor(22, spv::Op::OpCopyObject, 0)),
TransformationAddSynonym(
16, protobufs::TransformationAddSynonym::COPY_OBJECT, 104,
- MakeInstructionDescriptor(22, SpvOpCopyObject, 0)),
+ MakeInstructionDescriptor(22, spv::Op::OpCopyObject, 0)),
TransformationAddSynonym(
8, protobufs::TransformationAddSynonym::COPY_OBJECT, 105,
- MakeInstructionDescriptor(22, SpvOpCopyObject, 0)),
+ MakeInstructionDescriptor(22, spv::Op::OpCopyObject, 0)),
TransformationAddSynonym(
17, protobufs::TransformationAddSynonym::COPY_OBJECT, 106,
- MakeInstructionDescriptor(22, SpvOpCopyObject, 0))};
+ MakeInstructionDescriptor(22, spv::Op::OpCopyObject, 0))};
for (auto& transformation : transformations) {
ASSERT_TRUE(
@@ -1273,7 +1278,7 @@ TEST(TransformationAddSynonymTest, DoNotCopyNullPointers) {
// Illegal to copy null.
ASSERT_FALSE(TransformationAddSynonym(
8, protobufs::TransformationAddSynonym::COPY_OBJECT, 100,
- MakeInstructionDescriptor(5, SpvOpReturn, 0))
+ MakeInstructionDescriptor(5, spv::Op::OpReturn, 0))
.IsApplicable(context.get(), transformation_context));
}
@@ -1312,13 +1317,13 @@ TEST(TransformationAddSynonymTest, PropagateIrrelevantPointeeFact) {
TransformationAddSynonym transformation1(
8, protobufs::TransformationAddSynonym::COPY_OBJECT, 100,
- MakeInstructionDescriptor(9, SpvOpReturn, 0));
+ MakeInstructionDescriptor(9, spv::Op::OpReturn, 0));
TransformationAddSynonym transformation2(
9, protobufs::TransformationAddSynonym::COPY_OBJECT, 101,
- MakeInstructionDescriptor(9, SpvOpReturn, 0));
+ MakeInstructionDescriptor(9, spv::Op::OpReturn, 0));
TransformationAddSynonym transformation3(
100, protobufs::TransformationAddSynonym::COPY_OBJECT, 102,
- MakeInstructionDescriptor(9, SpvOpReturn, 0));
+ MakeInstructionDescriptor(9, spv::Op::OpReturn, 0));
ASSERT_TRUE(
transformation1.IsApplicable(context.get(), transformation_context));
@@ -1397,7 +1402,7 @@ TEST(TransformationAddSynonymTest, DoNotCopyOpSampledImage) {
ASSERT_FALSE(
TransformationAddSynonym(
216, protobufs::TransformationAddSynonym::COPY_OBJECT, 500,
- MakeInstructionDescriptor(217, SpvOpImageSampleImplicitLod, 0))
+ MakeInstructionDescriptor(217, spv::Op::OpImageSampleImplicitLod, 0))
.IsApplicable(context.get(), transformation_context));
}
@@ -1434,7 +1439,7 @@ TEST(TransformationAddSynonymTest, DoNotCopyVoidRunctionResult) {
MakeUnique<FactManager>(context.get()), validator_options);
ASSERT_FALSE(TransformationAddSynonym(
8, protobufs::TransformationAddSynonym::COPY_OBJECT, 500,
- MakeInstructionDescriptor(8, SpvOpReturn, 0))
+ MakeInstructionDescriptor(8, spv::Op::OpReturn, 0))
.IsApplicable(context.get(), transformation_context));
}
@@ -1475,7 +1480,7 @@ TEST(TransformationAddSynonymTest, HandlesDeadBlocks) {
transformation_context.GetFactManager()->AddFactBlockIsDead(9);
- auto insert_before = MakeInstructionDescriptor(9, SpvOpBranch, 0);
+ auto insert_before = MakeInstructionDescriptor(9, spv::Op::OpBranch, 0);
ASSERT_FALSE(TransformationAddSynonym(
7, protobufs::TransformationAddSynonym::COPY_OBJECT, 100,
diff --git a/test/fuzz/transformation_add_type_array_test.cpp b/test/fuzz/transformation_add_type_array_test.cpp
index 2ef8200ed..ab480fbab 100644
--- a/test/fuzz/transformation_add_type_array_test.cpp
+++ b/test/fuzz/transformation_add_type_array_test.cpp
@@ -99,7 +99,7 @@ TEST(TransformationAddTypeArrayTest, BasicTest) {
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
&transformation_context);
- ASSERT_EQ(SpvOpTypeArray,
+ ASSERT_EQ(spv::Op::OpTypeArray,
context->get_def_use_mgr()->GetDef(100)->opcode());
ASSERT_NE(nullptr, context->get_type_mgr()->GetType(100)->AsArray());
}
@@ -113,7 +113,7 @@ TEST(TransformationAddTypeArrayTest, BasicTest) {
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
&transformation_context);
- ASSERT_EQ(SpvOpTypeArray,
+ ASSERT_EQ(spv::Op::OpTypeArray,
context->get_def_use_mgr()->GetDef(100)->opcode());
ASSERT_NE(nullptr, context->get_type_mgr()->GetType(100)->AsArray());
}
diff --git a/test/fuzz/transformation_add_type_boolean_test.cpp b/test/fuzz/transformation_add_type_boolean_test.cpp
index a8e657ba9..388d4f659 100644
--- a/test/fuzz/transformation_add_type_boolean_test.cpp
+++ b/test/fuzz/transformation_add_type_boolean_test.cpp
@@ -57,7 +57,8 @@ TEST(TransformationAddTypeBooleanTest, BasicTest) {
ASSERT_TRUE(
add_type_bool.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(add_type_bool, context.get(), &transformation_context);
- ASSERT_EQ(SpvOpTypeBool, context->get_def_use_mgr()->GetDef(100)->opcode());
+ ASSERT_EQ(spv::Op::OpTypeBool,
+ context->get_def_use_mgr()->GetDef(100)->opcode());
ASSERT_NE(nullptr, context->get_type_mgr()->GetType(100)->AsBool());
ASSERT_TRUE(fuzzerutil::IsValidAndWellFormed(context.get(), validator_options,
kConsoleMessageConsumer));
diff --git a/test/fuzz/transformation_add_type_float_test.cpp b/test/fuzz/transformation_add_type_float_test.cpp
index 9275bec14..75f37887a 100644
--- a/test/fuzz/transformation_add_type_float_test.cpp
+++ b/test/fuzz/transformation_add_type_float_test.cpp
@@ -74,7 +74,7 @@ TEST(TransformationAddTypeFloatTest, IsApplicable) {
// By default, SPIR-V does not support 64-bit float types.
// Below we add such capability, so the test should now pass.
- context.get()->get_feature_mgr()->AddCapability(SpvCapabilityFloat64);
+ context.get()->get_feature_mgr()->AddCapability(spv::Capability::Float64);
ASSERT_TRUE(TransformationAddTypeFloat(7, 64).IsApplicable(
context.get(), transformation_context));
@@ -120,7 +120,8 @@ TEST(TransformationAddTypeFloatTest, Apply) {
ASSERT_EQ(nullptr, context->get_def_use_mgr()->GetDef(6));
ASSERT_EQ(nullptr, context->get_type_mgr()->GetType(6));
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
- ASSERT_EQ(SpvOpTypeFloat, context->get_def_use_mgr()->GetDef(6)->opcode());
+ ASSERT_EQ(spv::Op::OpTypeFloat,
+ context->get_def_use_mgr()->GetDef(6)->opcode());
ASSERT_NE(nullptr, context->get_type_mgr()->GetType(6)->AsFloat());
// Adds 32-bit float type.
@@ -128,7 +129,8 @@ TEST(TransformationAddTypeFloatTest, Apply) {
ASSERT_EQ(nullptr, context->get_def_use_mgr()->GetDef(7));
ASSERT_EQ(nullptr, context->get_type_mgr()->GetType(7));
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
- ASSERT_EQ(SpvOpTypeFloat, context->get_def_use_mgr()->GetDef(7)->opcode());
+ ASSERT_EQ(spv::Op::OpTypeFloat,
+ context->get_def_use_mgr()->GetDef(7)->opcode());
ASSERT_NE(nullptr, context->get_type_mgr()->GetType(7)->AsFloat());
// Adds 64-bit float type.
@@ -136,7 +138,8 @@ TEST(TransformationAddTypeFloatTest, Apply) {
ASSERT_EQ(nullptr, context->get_def_use_mgr()->GetDef(8));
ASSERT_EQ(nullptr, context->get_type_mgr()->GetType(8));
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
- ASSERT_EQ(SpvOpTypeFloat, context->get_def_use_mgr()->GetDef(8)->opcode());
+ ASSERT_EQ(spv::Op::OpTypeFloat,
+ context->get_def_use_mgr()->GetDef(8)->opcode());
ASSERT_NE(nullptr, context->get_type_mgr()->GetType(8)->AsFloat());
std::string variant_shader = R"(
diff --git a/test/fuzz/transformation_add_type_int_test.cpp b/test/fuzz/transformation_add_type_int_test.cpp
index 4cbfed0fd..b41d42037 100644
--- a/test/fuzz/transformation_add_type_int_test.cpp
+++ b/test/fuzz/transformation_add_type_int_test.cpp
@@ -88,13 +88,13 @@ TEST(TransformationAddTypeIntTest, IsApplicable) {
// By default SPIR-V does not support 16-bit integers.
// Below we add such capability, so the test should now be successful.
- context.get()->get_feature_mgr()->AddCapability(SpvCapabilityInt16);
+ context.get()->get_feature_mgr()->AddCapability(spv::Capability::Int16);
ASSERT_TRUE(TransformationAddTypeInt(7, 16, true)
.IsApplicable(context.get(), transformation_context));
// By default SPIR-V does not support 64-bit integers.
// Below we add such capability, so the test should now pass.
- context.get()->get_feature_mgr()->AddCapability(SpvCapabilityInt64);
+ context.get()->get_feature_mgr()->AddCapability(spv::Capability::Int64);
ASSERT_TRUE(TransformationAddTypeInt(7, 64, true)
.IsApplicable(context.get(), transformation_context));
@@ -147,7 +147,8 @@ TEST(TransformationAddTypeIntTest, Apply) {
ASSERT_EQ(nullptr, context->get_def_use_mgr()->GetDef(6));
ASSERT_EQ(nullptr, context->get_type_mgr()->GetType(6));
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
- ASSERT_EQ(SpvOpTypeInt, context->get_def_use_mgr()->GetDef(6)->opcode());
+ ASSERT_EQ(spv::Op::OpTypeInt,
+ context->get_def_use_mgr()->GetDef(6)->opcode());
ASSERT_NE(nullptr, context->get_type_mgr()->GetType(6)->AsInteger());
// Adds signed 16-bit integer type.
diff --git a/test/fuzz/transformation_add_type_matrix_test.cpp b/test/fuzz/transformation_add_type_matrix_test.cpp
index df0111e2d..9b10dbd69 100644
--- a/test/fuzz/transformation_add_type_matrix_test.cpp
+++ b/test/fuzz/transformation_add_type_matrix_test.cpp
@@ -72,7 +72,7 @@ TEST(TransformationAddTypeMatrixTest, BasicTest) {
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
&transformation_context);
- ASSERT_EQ(SpvOpTypeMatrix,
+ ASSERT_EQ(spv::Op::OpTypeMatrix,
context->get_def_use_mgr()->GetDef(100)->opcode());
ASSERT_NE(nullptr, context->get_type_mgr()->GetType(100)->AsMatrix());
}
diff --git a/test/fuzz/transformation_add_type_pointer_test.cpp b/test/fuzz/transformation_add_type_pointer_test.cpp
index b9072e3c1..5e25f0eff 100644
--- a/test/fuzz/transformation_add_type_pointer_test.cpp
+++ b/test/fuzz/transformation_add_type_pointer_test.cpp
@@ -103,28 +103,28 @@ TEST(TransformationAddTypePointerTest, BasicTest) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
auto bad_type_id_does_not_exist =
- TransformationAddTypePointer(100, SpvStorageClassFunction, 101);
+ TransformationAddTypePointer(100, spv::StorageClass::Function, 101);
auto bad_type_id_is_not_type =
- TransformationAddTypePointer(100, SpvStorageClassFunction, 23);
+ TransformationAddTypePointer(100, spv::StorageClass::Function, 23);
auto bad_result_id_is_not_fresh =
- TransformationAddTypePointer(17, SpvStorageClassFunction, 21);
+ TransformationAddTypePointer(17, spv::StorageClass::Function, 21);
auto good_new_private_pointer_to_t =
- TransformationAddTypePointer(101, SpvStorageClassPrivate, 7);
+ TransformationAddTypePointer(101, spv::StorageClass::Private, 7);
auto good_new_uniform_pointer_to_t =
- TransformationAddTypePointer(102, SpvStorageClassUniform, 7);
+ TransformationAddTypePointer(102, spv::StorageClass::Uniform, 7);
auto good_another_function_pointer_to_s =
- TransformationAddTypePointer(103, SpvStorageClassFunction, 8);
+ TransformationAddTypePointer(103, spv::StorageClass::Function, 8);
auto good_new_uniform_pointer_to_s =
- TransformationAddTypePointer(104, SpvStorageClassUniform, 8);
+ TransformationAddTypePointer(104, spv::StorageClass::Uniform, 8);
auto good_another_private_pointer_to_float =
- TransformationAddTypePointer(105, SpvStorageClassPrivate, 21);
+ TransformationAddTypePointer(105, spv::StorageClass::Private, 21);
auto good_new_private_pointer_to_private_pointer_to_float =
- TransformationAddTypePointer(106, SpvStorageClassPrivate, 105);
+ TransformationAddTypePointer(106, spv::StorageClass::Private, 105);
auto good_new_uniform_pointer_to_vec2 =
- TransformationAddTypePointer(107, SpvStorageClassUniform, 24);
+ TransformationAddTypePointer(107, spv::StorageClass::Uniform, 24);
auto good_new_private_pointer_to_uniform_pointer_to_vec2 =
- TransformationAddTypePointer(108, SpvStorageClassPrivate, 107);
+ TransformationAddTypePointer(108, spv::StorageClass::Private, 107);
ASSERT_FALSE(bad_type_id_does_not_exist.IsApplicable(context.get(),
transformation_context));
@@ -143,7 +143,7 @@ TEST(TransformationAddTypePointerTest, BasicTest) {
&transformation_context);
ASSERT_TRUE(fuzzerutil::IsValidAndWellFormed(
context.get(), validator_options, kConsoleMessageConsumer));
- ASSERT_EQ(SpvOpTypePointer,
+ ASSERT_EQ(spv::Op::OpTypePointer,
context->get_def_use_mgr()->GetDef(101)->opcode());
ASSERT_NE(nullptr, context->get_type_mgr()->GetType(101)->AsPointer());
}
diff --git a/test/fuzz/transformation_add_type_struct_test.cpp b/test/fuzz/transformation_add_type_struct_test.cpp
index 7fb91ab4c..1440b4a4e 100644
--- a/test/fuzz/transformation_add_type_struct_test.cpp
+++ b/test/fuzz/transformation_add_type_struct_test.cpp
@@ -72,7 +72,7 @@ TEST(TransformationAddTypeStructTest, BasicTest) {
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
&transformation_context);
- ASSERT_EQ(SpvOpTypeStruct,
+ ASSERT_EQ(spv::Op::OpTypeStruct,
context->get_def_use_mgr()->GetDef(100)->opcode());
ASSERT_NE(nullptr, context->get_type_mgr()->GetType(100)->AsStruct());
}
diff --git a/test/fuzz/transformation_add_type_vector_test.cpp b/test/fuzz/transformation_add_type_vector_test.cpp
index 755bc4a81..b39c1c981 100644
--- a/test/fuzz/transformation_add_type_vector_test.cpp
+++ b/test/fuzz/transformation_add_type_vector_test.cpp
@@ -66,7 +66,7 @@ TEST(TransformationAddTypeVectorTest, BasicTest) {
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
&transformation_context);
- ASSERT_EQ(SpvOpTypeVector,
+ ASSERT_EQ(spv::Op::OpTypeVector,
context->get_def_use_mgr()->GetDef(100)->opcode());
ASSERT_NE(nullptr, context->get_type_mgr()->GetType(100)->AsVector());
}
diff --git a/test/fuzz/transformation_adjust_branch_weights_test.cpp b/test/fuzz/transformation_adjust_branch_weights_test.cpp
index 5984a3e99..2b532bf3a 100644
--- a/test/fuzz/transformation_adjust_branch_weights_test.cpp
+++ b/test/fuzz/transformation_adjust_branch_weights_test.cpp
@@ -108,7 +108,7 @@ TEST(TransformationAdjustBranchWeightsTest, IsApplicableTest) {
MakeUnique<FactManager>(context.get()), validator_options);
// Tests OpBranchConditional instruction with weights.
auto instruction_descriptor =
- MakeInstructionDescriptor(33, SpvOpBranchConditional, 0);
+ MakeInstructionDescriptor(33, spv::Op::OpBranchConditional, 0);
auto transformation =
TransformationAdjustBranchWeights(instruction_descriptor, {0, 1});
ASSERT_TRUE(
@@ -116,7 +116,7 @@ TEST(TransformationAdjustBranchWeightsTest, IsApplicableTest) {
// Tests the two branch weights equal to 0.
instruction_descriptor =
- MakeInstructionDescriptor(33, SpvOpBranchConditional, 0);
+ MakeInstructionDescriptor(33, spv::Op::OpBranchConditional, 0);
transformation =
TransformationAdjustBranchWeights(instruction_descriptor, {0, 0});
#ifndef NDEBUG
@@ -127,14 +127,14 @@ TEST(TransformationAdjustBranchWeightsTest, IsApplicableTest) {
// Tests 32-bit unsigned integer overflow.
instruction_descriptor =
- MakeInstructionDescriptor(33, SpvOpBranchConditional, 0);
+ MakeInstructionDescriptor(33, spv::Op::OpBranchConditional, 0);
transformation = TransformationAdjustBranchWeights(instruction_descriptor,
{UINT32_MAX, 0});
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
instruction_descriptor =
- MakeInstructionDescriptor(33, SpvOpBranchConditional, 0);
+ MakeInstructionDescriptor(33, spv::Op::OpBranchConditional, 0);
transformation = TransformationAdjustBranchWeights(instruction_descriptor,
{1, UINT32_MAX});
#ifndef NDEBUG
@@ -145,26 +145,26 @@ TEST(TransformationAdjustBranchWeightsTest, IsApplicableTest) {
// Tests OpBranchConditional instruction with no weights.
instruction_descriptor =
- MakeInstructionDescriptor(21, SpvOpBranchConditional, 0);
+ MakeInstructionDescriptor(21, spv::Op::OpBranchConditional, 0);
transformation =
TransformationAdjustBranchWeights(instruction_descriptor, {0, 1});
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
// Tests non-OpBranchConditional instructions.
- instruction_descriptor = MakeInstructionDescriptor(2, SpvOpTypeVoid, 0);
+ instruction_descriptor = MakeInstructionDescriptor(2, spv::Op::OpTypeVoid, 0);
transformation =
TransformationAdjustBranchWeights(instruction_descriptor, {5, 6});
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
- instruction_descriptor = MakeInstructionDescriptor(20, SpvOpLabel, 0);
+ instruction_descriptor = MakeInstructionDescriptor(20, spv::Op::OpLabel, 0);
transformation =
TransformationAdjustBranchWeights(instruction_descriptor, {1, 2});
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
- instruction_descriptor = MakeInstructionDescriptor(49, SpvOpIAdd, 0);
+ instruction_descriptor = MakeInstructionDescriptor(49, spv::Op::OpIAdd, 0);
transformation =
TransformationAdjustBranchWeights(instruction_descriptor, {1, 2});
ASSERT_FALSE(
@@ -255,13 +255,13 @@ TEST(TransformationAdjustBranchWeightsTest, ApplyTest) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
auto instruction_descriptor =
- MakeInstructionDescriptor(33, SpvOpBranchConditional, 0);
+ MakeInstructionDescriptor(33, spv::Op::OpBranchConditional, 0);
auto transformation =
TransformationAdjustBranchWeights(instruction_descriptor, {5, 6});
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
instruction_descriptor =
- MakeInstructionDescriptor(21, SpvOpBranchConditional, 0);
+ MakeInstructionDescriptor(21, spv::Op::OpBranchConditional, 0);
transformation =
TransformationAdjustBranchWeights(instruction_descriptor, {7, 8});
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
diff --git a/test/fuzz/transformation_composite_construct_test.cpp b/test/fuzz/transformation_composite_construct_test.cpp
index 3c5f7310a..c4eef8722 100644
--- a/test/fuzz/transformation_composite_construct_test.cpp
+++ b/test/fuzz/transformation_composite_construct_test.cpp
@@ -136,16 +136,17 @@ TEST(TransformationCompositeConstructTest, ConstructArrays) {
MakeUnique<FactManager>(context.get()), validator_options);
// Make a vec2[3]
TransformationCompositeConstruct make_vec2_array_length_3(
- 37, {41, 45, 27}, MakeInstructionDescriptor(46, SpvOpAccessChain, 0),
- 200);
+ 37, {41, 45, 27},
+ MakeInstructionDescriptor(46, spv::Op::OpAccessChain, 0), 200);
// Bad: there are too many components
TransformationCompositeConstruct make_vec2_array_length_3_bad(
- 37, {41, 45, 27, 27}, MakeInstructionDescriptor(46, SpvOpAccessChain, 0),
- 200);
+ 37, {41, 45, 27, 27},
+ MakeInstructionDescriptor(46, spv::Op::OpAccessChain, 0), 200);
// The first component does not correspond to an instruction with a result
// type so this check should return false.
TransformationCompositeConstruct make_vec2_array_length_3_nores(
- 37, {2, 45, 27}, MakeInstructionDescriptor(46, SpvOpAccessChain, 0), 200);
+ 37, {2, 45, 27}, MakeInstructionDescriptor(46, spv::Op::OpAccessChain, 0),
+ 200);
ASSERT_TRUE(make_vec2_array_length_3.IsApplicable(context.get(),
transformation_context));
ASSERT_FALSE(make_vec2_array_length_3_bad.IsApplicable(
@@ -159,7 +160,7 @@ TEST(TransformationCompositeConstructTest, ConstructArrays) {
uint32_t num_uses_of_27_before = context->get_def_use_mgr()->NumUses(27);
ApplyAndCheckFreshIds(make_vec2_array_length_3, context.get(),
&transformation_context);
- ASSERT_EQ(SpvOpCompositeConstruct,
+ ASSERT_EQ(spv::Op::OpCompositeConstruct,
context->get_def_use_mgr()->GetDef(200)->opcode());
ASSERT_EQ(34, context->get_instr_block(200)->id());
ASSERT_EQ(num_uses_of_41_before + 1, context->get_def_use_mgr()->NumUses(41));
@@ -176,10 +177,10 @@ TEST(TransformationCompositeConstructTest, ConstructArrays) {
// Make a float[2]
TransformationCompositeConstruct make_float_array_length_2(
- 9, {24, 40}, MakeInstructionDescriptor(71, SpvOpStore, 0), 201);
+ 9, {24, 40}, MakeInstructionDescriptor(71, spv::Op::OpStore, 0), 201);
// Bad: %41 does not have type float
TransformationCompositeConstruct make_float_array_length_2_bad(
- 9, {41, 40}, MakeInstructionDescriptor(71, SpvOpStore, 0), 201);
+ 9, {41, 40}, MakeInstructionDescriptor(71, spv::Op::OpStore, 0), 201);
ASSERT_TRUE(make_float_array_length_2.IsApplicable(context.get(),
transformation_context));
ASSERT_FALSE(make_float_array_length_2_bad.IsApplicable(
@@ -195,12 +196,12 @@ TEST(TransformationCompositeConstructTest, ConstructArrays) {
// Make a bool[3]
TransformationCompositeConstruct make_bool_array_length_3(
- 47, {33, 50, 50}, MakeInstructionDescriptor(33, SpvOpSelectionMerge, 0),
- 202);
+ 47, {33, 50, 50},
+ MakeInstructionDescriptor(33, spv::Op::OpSelectionMerge, 0), 202);
// Bad: %54 is not available at the desired program point.
TransformationCompositeConstruct make_bool_array_length_3_bad(
- 47, {33, 54, 50}, MakeInstructionDescriptor(33, SpvOpSelectionMerge, 0),
- 202);
+ 47, {33, 54, 50},
+ MakeInstructionDescriptor(33, spv::Op::OpSelectionMerge, 0), 202);
ASSERT_TRUE(make_bool_array_length_3.IsApplicable(context.get(),
transformation_context));
ASSERT_FALSE(make_bool_array_length_3_bad.IsApplicable(
@@ -218,10 +219,10 @@ TEST(TransformationCompositeConstructTest, ConstructArrays) {
// make a uvec3[2][2]
TransformationCompositeConstruct make_uvec3_array_length_2_2(
- 58, {69, 100}, MakeInstructionDescriptor(64, SpvOpStore, 0), 203);
+ 58, {69, 100}, MakeInstructionDescriptor(64, spv::Op::OpStore, 0), 203);
// Bad: Skip count 100 is too large.
TransformationCompositeConstruct make_uvec3_array_length_2_2_bad(
- 58, {33, 54}, MakeInstructionDescriptor(64, SpvOpStore, 100), 203);
+ 58, {33, 54}, MakeInstructionDescriptor(64, spv::Op::OpStore, 100), 203);
ASSERT_TRUE(make_uvec3_array_length_2_2.IsApplicable(context.get(),
transformation_context));
ASSERT_FALSE(make_uvec3_array_length_2_2_bad.IsApplicable(
@@ -425,14 +426,17 @@ TEST(TransformationCompositeConstructTest, ConstructMatrices) {
MakeUnique<FactManager>(context.get()), validator_options);
// make a mat3x4
TransformationCompositeConstruct make_mat34(
- 32, {25, 28, 31}, MakeInstructionDescriptor(31, SpvOpReturn, 0), 200);
+ 32, {25, 28, 31}, MakeInstructionDescriptor(31, spv::Op::OpReturn, 0),
+ 200);
// Bad: %35 is mat4x3, not mat3x4.
TransformationCompositeConstruct make_mat34_bad(
- 35, {25, 28, 31}, MakeInstructionDescriptor(31, SpvOpReturn, 0), 200);
+ 35, {25, 28, 31}, MakeInstructionDescriptor(31, spv::Op::OpReturn, 0),
+ 200);
// The first component does not correspond to an instruction with a result
// type so this check should return false.
TransformationCompositeConstruct make_mat34_nores(
- 32, {2, 28, 31}, MakeInstructionDescriptor(31, SpvOpReturn, 0), 200);
+ 32, {2, 28, 31}, MakeInstructionDescriptor(31, spv::Op::OpReturn, 0),
+ 200);
ASSERT_TRUE(make_mat34.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(
make_mat34_bad.IsApplicable(context.get(), transformation_context));
@@ -450,10 +454,12 @@ TEST(TransformationCompositeConstructTest, ConstructMatrices) {
// make a mat4x3
TransformationCompositeConstruct make_mat43(
- 35, {11, 13, 16, 100}, MakeInstructionDescriptor(31, SpvOpStore, 0), 201);
+ 35, {11, 13, 16, 100}, MakeInstructionDescriptor(31, spv::Op::OpStore, 0),
+ 201);
// Bad: %25 does not match the matrix's column type.
TransformationCompositeConstruct make_mat43_bad(
- 35, {25, 13, 16, 100}, MakeInstructionDescriptor(31, SpvOpStore, 0), 201);
+ 35, {25, 13, 16, 100}, MakeInstructionDescriptor(31, spv::Op::OpStore, 0),
+ 201);
ASSERT_TRUE(make_mat43.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(
make_mat43_bad.IsApplicable(context.get(), transformation_context));
@@ -644,14 +650,16 @@ TEST(TransformationCompositeConstructTest, ConstructStructs) {
MakeUnique<FactManager>(context.get()), validator_options);
// make an Inner
TransformationCompositeConstruct make_inner(
- 9, {25, 19}, MakeInstructionDescriptor(57, SpvOpAccessChain, 0), 200);
+ 9, {25, 19}, MakeInstructionDescriptor(57, spv::Op::OpAccessChain, 0),
+ 200);
// Bad: Too few fields to make the struct.
TransformationCompositeConstruct make_inner_bad(
- 9, {25}, MakeInstructionDescriptor(57, SpvOpAccessChain, 0), 200);
+ 9, {25}, MakeInstructionDescriptor(57, spv::Op::OpAccessChain, 0), 200);
// The first component does not correspond to an instruction with a result
// type so this check should return false.
TransformationCompositeConstruct make_inner_nores(
- 9, {2, 19}, MakeInstructionDescriptor(57, SpvOpAccessChain, 0), 200);
+ 9, {2, 19}, MakeInstructionDescriptor(57, spv::Op::OpAccessChain, 0),
+ 200);
ASSERT_TRUE(make_inner.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(
make_inner_bad.IsApplicable(context.get(), transformation_context));
@@ -667,12 +675,12 @@ TEST(TransformationCompositeConstructTest, ConstructStructs) {
// make an Outer
TransformationCompositeConstruct make_outer(
- 33, {46, 200, 56}, MakeInstructionDescriptor(200, SpvOpAccessChain, 0),
- 201);
+ 33, {46, 200, 56},
+ MakeInstructionDescriptor(200, spv::Op::OpAccessChain, 0), 201);
// Bad: %200 is not available at the desired program point.
TransformationCompositeConstruct make_outer_bad(
33, {46, 200, 56},
- MakeInstructionDescriptor(200, SpvOpCompositeConstruct, 0), 201);
+ MakeInstructionDescriptor(200, spv::Op::OpCompositeConstruct, 0), 201);
ASSERT_TRUE(make_outer.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(
make_outer_bad.IsApplicable(context.get(), transformation_context));
@@ -973,10 +981,10 @@ TEST(TransformationCompositeConstructTest, ConstructVectors) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
TransformationCompositeConstruct make_vec2(
- 7, {17, 11}, MakeInstructionDescriptor(100, SpvOpStore, 0), 200);
+ 7, {17, 11}, MakeInstructionDescriptor(100, spv::Op::OpStore, 0), 200);
// Bad: not enough data for a vec2
TransformationCompositeConstruct make_vec2_bad(
- 7, {11}, MakeInstructionDescriptor(100, SpvOpStore, 0), 200);
+ 7, {11}, MakeInstructionDescriptor(100, spv::Op::OpStore, 0), 200);
ASSERT_TRUE(make_vec2.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(
make_vec2_bad.IsApplicable(context.get(), transformation_context));
@@ -989,12 +997,12 @@ TEST(TransformationCompositeConstructTest, ConstructVectors) {
MakeDataDescriptor(11, {}), MakeDataDescriptor(200, {1})));
TransformationCompositeConstruct make_vec3(
- 25, {12, 32}, MakeInstructionDescriptor(35, SpvOpCompositeConstruct, 0),
- 201);
+ 25, {12, 32},
+ MakeInstructionDescriptor(35, spv::Op::OpCompositeConstruct, 0), 201);
// Bad: too much data for a vec3
TransformationCompositeConstruct make_vec3_bad(
25, {12, 32, 32},
- MakeInstructionDescriptor(35, SpvOpCompositeConstruct, 0), 201);
+ MakeInstructionDescriptor(35, spv::Op::OpCompositeConstruct, 0), 201);
ASSERT_TRUE(make_vec3.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(
make_vec3_bad.IsApplicable(context.get(), transformation_context));
@@ -1009,12 +1017,12 @@ TEST(TransformationCompositeConstructTest, ConstructVectors) {
MakeDataDescriptor(32, {}), MakeDataDescriptor(201, {2})));
TransformationCompositeConstruct make_vec4(
- 44, {32, 32, 10, 11}, MakeInstructionDescriptor(75, SpvOpAccessChain, 0),
- 202);
+ 44, {32, 32, 10, 11},
+ MakeInstructionDescriptor(75, spv::Op::OpAccessChain, 0), 202);
// Bad: id 48 is not available at the insertion points
TransformationCompositeConstruct make_vec4_bad(
- 44, {48, 32, 10, 11}, MakeInstructionDescriptor(75, SpvOpAccessChain, 0),
- 202);
+ 44, {48, 32, 10, 11},
+ MakeInstructionDescriptor(75, spv::Op::OpAccessChain, 0), 202);
ASSERT_TRUE(make_vec4.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(
make_vec4_bad.IsApplicable(context.get(), transformation_context));
@@ -1031,10 +1039,10 @@ TEST(TransformationCompositeConstructTest, ConstructVectors) {
MakeDataDescriptor(11, {}), MakeDataDescriptor(202, {3})));
TransformationCompositeConstruct make_ivec2(
- 51, {126, 120}, MakeInstructionDescriptor(128, SpvOpLoad, 0), 203);
+ 51, {126, 120}, MakeInstructionDescriptor(128, spv::Op::OpLoad, 0), 203);
// Bad: if 128 is not available at the instruction that defines 128
TransformationCompositeConstruct make_ivec2_bad(
- 51, {128, 120}, MakeInstructionDescriptor(128, SpvOpLoad, 0), 203);
+ 51, {128, 120}, MakeInstructionDescriptor(128, spv::Op::OpLoad, 0), 203);
ASSERT_TRUE(make_ivec2.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(
make_ivec2_bad.IsApplicable(context.get(), transformation_context));
@@ -1047,12 +1055,12 @@ TEST(TransformationCompositeConstructTest, ConstructVectors) {
MakeDataDescriptor(120, {}), MakeDataDescriptor(203, {1})));
TransformationCompositeConstruct make_ivec3(
- 114, {56, 117, 56}, MakeInstructionDescriptor(66, SpvOpAccessChain, 0),
- 204);
+ 114, {56, 117, 56},
+ MakeInstructionDescriptor(66, spv::Op::OpAccessChain, 0), 204);
// Bad because 1300 is not an id
TransformationCompositeConstruct make_ivec3_bad(
- 114, {56, 117, 1300}, MakeInstructionDescriptor(66, SpvOpAccessChain, 0),
- 204);
+ 114, {56, 117, 1300},
+ MakeInstructionDescriptor(66, spv::Op::OpAccessChain, 0), 204);
ASSERT_TRUE(make_ivec3.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(
make_ivec3_bad.IsApplicable(context.get(), transformation_context));
@@ -1067,12 +1075,12 @@ TEST(TransformationCompositeConstructTest, ConstructVectors) {
MakeDataDescriptor(56, {}), MakeDataDescriptor(204, {2})));
TransformationCompositeConstruct make_ivec4(
- 122, {56, 117, 117, 117}, MakeInstructionDescriptor(66, SpvOpIAdd, 0),
- 205);
+ 122, {56, 117, 117, 117},
+ MakeInstructionDescriptor(66, spv::Op::OpIAdd, 0), 205);
// Bad because 86 is the wrong type.
TransformationCompositeConstruct make_ivec4_bad(
- 86, {56, 117, 117, 117}, MakeInstructionDescriptor(66, SpvOpIAdd, 0),
- 205);
+ 86, {56, 117, 117, 117},
+ MakeInstructionDescriptor(66, spv::Op::OpIAdd, 0), 205);
ASSERT_TRUE(make_ivec4.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(
make_ivec4_bad.IsApplicable(context.get(), transformation_context));
@@ -1089,9 +1097,11 @@ TEST(TransformationCompositeConstructTest, ConstructVectors) {
MakeDataDescriptor(117, {}), MakeDataDescriptor(205, {3})));
TransformationCompositeConstruct make_uvec2(
- 86, {18, 38}, MakeInstructionDescriptor(133, SpvOpAccessChain, 0), 206);
+ 86, {18, 38}, MakeInstructionDescriptor(133, spv::Op::OpAccessChain, 0),
+ 206);
TransformationCompositeConstruct make_uvec2_bad(
- 86, {18, 38}, MakeInstructionDescriptor(133, SpvOpAccessChain, 200), 206);
+ 86, {18, 38}, MakeInstructionDescriptor(133, spv::Op::OpAccessChain, 200),
+ 206);
ASSERT_TRUE(make_uvec2.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(
make_uvec2_bad.IsApplicable(context.get(), transformation_context));
@@ -1104,10 +1114,12 @@ TEST(TransformationCompositeConstructTest, ConstructVectors) {
MakeDataDescriptor(38, {}), MakeDataDescriptor(206, {1})));
TransformationCompositeConstruct make_uvec3(
- 59, {14, 18, 136}, MakeInstructionDescriptor(137, SpvOpReturn, 0), 207);
+ 59, {14, 18, 136}, MakeInstructionDescriptor(137, spv::Op::OpReturn, 0),
+ 207);
// Bad because 1300 is not an id
TransformationCompositeConstruct make_uvec3_bad(
- 59, {14, 18, 1300}, MakeInstructionDescriptor(137, SpvOpReturn, 0), 207);
+ 59, {14, 18, 1300}, MakeInstructionDescriptor(137, spv::Op::OpReturn, 0),
+ 207);
ASSERT_TRUE(make_uvec3.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(
make_uvec3_bad.IsApplicable(context.get(), transformation_context));
@@ -1123,11 +1135,11 @@ TEST(TransformationCompositeConstructTest, ConstructVectors) {
TransformationCompositeConstruct make_uvec4(
131, {14, 18, 136, 136},
- MakeInstructionDescriptor(137, SpvOpAccessChain, 0), 208);
+ MakeInstructionDescriptor(137, spv::Op::OpAccessChain, 0), 208);
// Bad because 86 is the wrong type.
TransformationCompositeConstruct make_uvec4_bad(
86, {14, 18, 136, 136},
- MakeInstructionDescriptor(137, SpvOpAccessChain, 0), 208);
+ MakeInstructionDescriptor(137, spv::Op::OpAccessChain, 0), 208);
ASSERT_TRUE(make_uvec4.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(
make_uvec4_bad.IsApplicable(context.get(), transformation_context));
@@ -1149,7 +1161,7 @@ TEST(TransformationCompositeConstructTest, ConstructVectors) {
111,
41,
},
- MakeInstructionDescriptor(75, SpvOpAccessChain, 0), 209);
+ MakeInstructionDescriptor(75, spv::Op::OpAccessChain, 0), 209);
// Bad because 0 is not a valid base instruction id
TransformationCompositeConstruct make_bvec2_bad(
102,
@@ -1157,7 +1169,7 @@ TEST(TransformationCompositeConstructTest, ConstructVectors) {
111,
41,
},
- MakeInstructionDescriptor(0, SpvOpExtInstImport, 0), 209);
+ MakeInstructionDescriptor(0, spv::Op::OpExtInstImport, 0), 209);
ASSERT_TRUE(make_bvec2.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(
make_bvec2_bad.IsApplicable(context.get(), transformation_context));
@@ -1170,10 +1182,10 @@ TEST(TransformationCompositeConstructTest, ConstructVectors) {
MakeDataDescriptor(41, {}), MakeDataDescriptor(209, {1})));
TransformationCompositeConstruct make_bvec3(
- 93, {108, 73}, MakeInstructionDescriptor(108, SpvOpStore, 0), 210);
+ 93, {108, 73}, MakeInstructionDescriptor(108, spv::Op::OpStore, 0), 210);
// Bad because there are too many components for a bvec3
TransformationCompositeConstruct make_bvec3_bad(
- 93, {108, 108}, MakeInstructionDescriptor(108, SpvOpStore, 0), 210);
+ 93, {108, 108}, MakeInstructionDescriptor(108, spv::Op::OpStore, 0), 210);
ASSERT_TRUE(make_bvec3.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(
make_bvec3_bad.IsApplicable(context.get(), transformation_context));
@@ -1188,10 +1200,11 @@ TEST(TransformationCompositeConstructTest, ConstructVectors) {
MakeDataDescriptor(73, {}), MakeDataDescriptor(210, {2})));
TransformationCompositeConstruct make_bvec4(
- 70, {108, 108}, MakeInstructionDescriptor(108, SpvOpBranch, 0), 211);
+ 70, {108, 108}, MakeInstructionDescriptor(108, spv::Op::OpBranch, 0),
+ 211);
// Bad because 21 is a type, not a result id
TransformationCompositeConstruct make_bvec4_bad(
- 70, {21, 108}, MakeInstructionDescriptor(108, SpvOpBranch, 0), 211);
+ 70, {21, 108}, MakeInstructionDescriptor(108, spv::Op::OpBranch, 0), 211);
ASSERT_TRUE(make_bvec4.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(
make_bvec4_bad.IsApplicable(context.get(), transformation_context));
@@ -1477,7 +1490,8 @@ TEST(TransformationCompositeConstructTest, AddSynonymsForRelevantIds) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
TransformationCompositeConstruct transformation(
- 32, {25, 28, 31}, MakeInstructionDescriptor(31, SpvOpReturn, 0), 200);
+ 32, {25, 28, 31}, MakeInstructionDescriptor(31, spv::Op::OpReturn, 0),
+ 200);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
@@ -1562,7 +1576,8 @@ TEST(TransformationCompositeConstructTest, DontAddSynonymsForIrrelevantIds) {
transformation_context.GetFactManager()->AddFactIdIsIrrelevant(25);
TransformationCompositeConstruct transformation(
- 32, {25, 28, 31}, MakeInstructionDescriptor(31, SpvOpReturn, 0), 200);
+ 32, {25, 28, 31}, MakeInstructionDescriptor(31, spv::Op::OpReturn, 0),
+ 200);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
@@ -1618,7 +1633,7 @@ TEST(TransformationCompositeConstructTest, DontAddSynonymsInDeadBlock) {
transformation_context.GetFactManager()->AddFactBlockIsDead(15);
TransformationCompositeConstruct transformation(
- 7, {10, 11}, MakeInstructionDescriptor(15, SpvOpBranch, 0), 100);
+ 7, {10, 11}, MakeInstructionDescriptor(15, spv::Op::OpBranch, 0), 100);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
@@ -1660,7 +1675,7 @@ TEST(TransformationCompositeConstructTest, OneIrrelevantComponent) {
transformation_context.GetFactManager()->AddFactIdIsIrrelevant(8);
TransformationCompositeConstruct transformation(
- 7, {8, 9, 10}, MakeInstructionDescriptor(5, SpvOpReturn, 0), 100);
+ 7, {8, 9, 10}, MakeInstructionDescriptor(5, spv::Op::OpReturn, 0), 100);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
@@ -1707,7 +1722,7 @@ TEST(TransformationCompositeConstructTest, IrrelevantVec2ThenFloat) {
transformation_context.GetFactManager()->AddFactIdIsIrrelevant(10);
TransformationCompositeConstruct transformation(
- 8, {10, 9}, MakeInstructionDescriptor(5, SpvOpReturn, 0), 100);
+ 8, {10, 9}, MakeInstructionDescriptor(5, spv::Op::OpReturn, 0), 100);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
diff --git a/test/fuzz/transformation_composite_extract_test.cpp b/test/fuzz/transformation_composite_extract_test.cpp
index 1df55918c..d468e41d1 100644
--- a/test/fuzz/transformation_composite_extract_test.cpp
+++ b/test/fuzz/transformation_composite_extract_test.cpp
@@ -102,47 +102,49 @@ TEST(TransformationCompositeExtractTest, BasicTest) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
// Instruction does not exist.
- ASSERT_FALSE(TransformationCompositeExtract(
- MakeInstructionDescriptor(36, SpvOpIAdd, 0), 200, 101, {0})
- .IsApplicable(context.get(), transformation_context));
-
- // Id for composite is not a composite.
ASSERT_FALSE(
TransformationCompositeExtract(
- MakeInstructionDescriptor(37, SpvOpAccessChain, 0), 200, 32, {})
+ MakeInstructionDescriptor(36, spv::Op::OpIAdd, 0), 200, 101, {0})
.IsApplicable(context.get(), transformation_context));
- // Composite does not dominate instruction being inserted before.
+ // Id for composite is not a composite.
ASSERT_FALSE(
TransformationCompositeExtract(
- MakeInstructionDescriptor(37, SpvOpAccessChain, 0), 200, 101, {0})
+ MakeInstructionDescriptor(37, spv::Op::OpAccessChain, 0), 200, 32, {})
.IsApplicable(context.get(), transformation_context));
+ // Composite does not dominate instruction being inserted before.
+ ASSERT_FALSE(TransformationCompositeExtract(
+ MakeInstructionDescriptor(37, spv::Op::OpAccessChain, 0),
+ 200, 101, {0})
+ .IsApplicable(context.get(), transformation_context));
+
// Too many indices for extraction from struct composite.
- ASSERT_FALSE(
- TransformationCompositeExtract(
- MakeInstructionDescriptor(24, SpvOpAccessChain, 0), 200, 101, {0, 0})
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationCompositeExtract(
+ MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0),
+ 200, 101, {0, 0})
+ .IsApplicable(context.get(), transformation_context));
// Too many indices for extraction from struct composite.
- ASSERT_FALSE(
- TransformationCompositeExtract(
- MakeInstructionDescriptor(13, SpvOpIEqual, 0), 200, 104, {0, 0, 0})
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationCompositeExtract(
+ MakeInstructionDescriptor(13, spv::Op::OpIEqual, 0), 200,
+ 104, {0, 0, 0})
+ .IsApplicable(context.get(), transformation_context));
// Out of bounds index for extraction from struct composite.
ASSERT_FALSE(
TransformationCompositeExtract(
- MakeInstructionDescriptor(13, SpvOpIEqual, 0), 200, 104, {0, 3})
+ MakeInstructionDescriptor(13, spv::Op::OpIEqual, 0), 200, 104, {0, 3})
.IsApplicable(context.get(), transformation_context));
// Result id already used.
- ASSERT_FALSE(TransformationCompositeExtract(
- MakeInstructionDescriptor(35, SpvOpFAdd, 0), 80, 103, {0})
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationCompositeExtract(
+ MakeInstructionDescriptor(35, spv::Op::OpFAdd, 0), 80, 103, {0})
+ .IsApplicable(context.get(), transformation_context));
TransformationCompositeExtract transformation_1(
- MakeInstructionDescriptor(36, SpvOpConvertFToS, 0), 201, 100, {2});
+ MakeInstructionDescriptor(36, spv::Op::OpConvertFToS, 0), 201, 100, {2});
ASSERT_EQ(nullptr, context->get_def_use_mgr()->GetDef(201));
ASSERT_EQ(nullptr, context->get_instr_block(201));
uint32_t num_uses_of_100_before = context->get_def_use_mgr()->NumUses(100);
@@ -150,7 +152,7 @@ TEST(TransformationCompositeExtractTest, BasicTest) {
transformation_1.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation_1, context.get(),
&transformation_context);
- ASSERT_EQ(SpvOpCompositeExtract,
+ ASSERT_EQ(spv::Op::OpCompositeExtract,
context->get_def_use_mgr()->GetDef(201)->opcode());
ASSERT_EQ(15, context->get_instr_block(201)->id());
ASSERT_EQ(num_uses_of_100_before + 1,
@@ -159,7 +161,8 @@ TEST(TransformationCompositeExtractTest, BasicTest) {
kConsoleMessageConsumer));
TransformationCompositeExtract transformation_2(
- MakeInstructionDescriptor(37, SpvOpAccessChain, 0), 202, 104, {0, 2});
+ MakeInstructionDescriptor(37, spv::Op::OpAccessChain, 0), 202, 104,
+ {0, 2});
ASSERT_TRUE(
transformation_2.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation_2, context.get(),
@@ -168,7 +171,7 @@ TEST(TransformationCompositeExtractTest, BasicTest) {
kConsoleMessageConsumer));
TransformationCompositeExtract transformation_3(
- MakeInstructionDescriptor(29, SpvOpAccessChain, 0), 203, 104, {0});
+ MakeInstructionDescriptor(29, spv::Op::OpAccessChain, 0), 203, 104, {0});
ASSERT_TRUE(
transformation_3.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation_3, context.get(),
@@ -177,7 +180,7 @@ TEST(TransformationCompositeExtractTest, BasicTest) {
kConsoleMessageConsumer));
TransformationCompositeExtract transformation_4(
- MakeInstructionDescriptor(24, SpvOpStore, 0), 204, 101, {0});
+ MakeInstructionDescriptor(24, spv::Op::OpStore, 0), 204, 101, {0});
ASSERT_TRUE(
transformation_4.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation_4, context.get(),
@@ -186,7 +189,7 @@ TEST(TransformationCompositeExtractTest, BasicTest) {
kConsoleMessageConsumer));
TransformationCompositeExtract transformation_5(
- MakeInstructionDescriptor(29, SpvOpBranch, 0), 205, 102, {2});
+ MakeInstructionDescriptor(29, spv::Op::OpBranch, 0), 205, 102, {2});
ASSERT_TRUE(
transformation_5.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation_5, context.get(),
@@ -195,7 +198,7 @@ TEST(TransformationCompositeExtractTest, BasicTest) {
kConsoleMessageConsumer));
TransformationCompositeExtract transformation_6(
- MakeInstructionDescriptor(37, SpvOpReturn, 0), 206, 103, {1});
+ MakeInstructionDescriptor(37, spv::Op::OpReturn, 0), 206, 103, {1});
ASSERT_TRUE(
transformation_6.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation_6, context.get(),
@@ -378,45 +381,50 @@ TEST(TransformationCompositeExtractTest, IllegalInsertionPoints) {
// Cannot insert before the OpVariables of a function.
ASSERT_FALSE(
TransformationCompositeExtract(
- MakeInstructionDescriptor(101, SpvOpVariable, 0), 200, 14, {0})
+ MakeInstructionDescriptor(101, spv::Op::OpVariable, 0), 200, 14, {0})
.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(
TransformationCompositeExtract(
- MakeInstructionDescriptor(101, SpvOpVariable, 1), 200, 14, {1})
+ MakeInstructionDescriptor(101, spv::Op::OpVariable, 1), 200, 14, {1})
.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(
TransformationCompositeExtract(
- MakeInstructionDescriptor(102, SpvOpVariable, 0), 200, 14, {1})
+ MakeInstructionDescriptor(102, spv::Op::OpVariable, 0), 200, 14, {1})
.IsApplicable(context.get(), transformation_context));
// OK to insert right after the OpVariables.
- ASSERT_FALSE(TransformationCompositeExtract(
- MakeInstructionDescriptor(102, SpvOpBranch, 1), 200, 14, {1})
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationCompositeExtract(
+ MakeInstructionDescriptor(102, spv::Op::OpBranch, 1), 200, 14, {1})
+ .IsApplicable(context.get(), transformation_context));
// Cannot insert before the OpPhis of a block.
- ASSERT_FALSE(TransformationCompositeExtract(
- MakeInstructionDescriptor(60, SpvOpPhi, 0), 200, 14, {2})
- .IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(TransformationCompositeExtract(
- MakeInstructionDescriptor(59, SpvOpPhi, 0), 200, 14, {3})
- .IsApplicable(context.get(), transformation_context));
- // OK to insert after the OpPhis.
- ASSERT_TRUE(
+ ASSERT_FALSE(
TransformationCompositeExtract(
- MakeInstructionDescriptor(59, SpvOpAccessChain, 0), 200, 14, {3})
+ MakeInstructionDescriptor(60, spv::Op::OpPhi, 0), 200, 14, {2})
.IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationCompositeExtract(
+ MakeInstructionDescriptor(59, spv::Op::OpPhi, 0), 200, 14, {3})
+ .IsApplicable(context.get(), transformation_context));
+ // OK to insert after the OpPhis.
+ ASSERT_TRUE(TransformationCompositeExtract(
+ MakeInstructionDescriptor(59, spv::Op::OpAccessChain, 0), 200,
+ 14, {3})
+ .IsApplicable(context.get(), transformation_context));
// Cannot insert before OpLoopMerge
- ASSERT_FALSE(TransformationCompositeExtract(
- MakeInstructionDescriptor(33, SpvOpBranchConditional, 0),
- 200, 14, {3})
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationCompositeExtract(
+ MakeInstructionDescriptor(33, spv::Op::OpBranchConditional, 0), 200,
+ 14, {3})
+ .IsApplicable(context.get(), transformation_context));
// Cannot insert before OpSelectionMerge
- ASSERT_FALSE(TransformationCompositeExtract(
- MakeInstructionDescriptor(21, SpvOpBranchConditional, 0),
- 200, 14, {2})
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationCompositeExtract(
+ MakeInstructionDescriptor(21, spv::Op::OpBranchConditional, 0), 200,
+ 14, {2})
+ .IsApplicable(context.get(), transformation_context));
}
TEST(TransformationCompositeExtractTest, AddSynonymsForRelevantIds) {
@@ -498,7 +506,7 @@ TEST(TransformationCompositeExtractTest, AddSynonymsForRelevantIds) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
TransformationCompositeExtract transformation(
- MakeInstructionDescriptor(36, SpvOpConvertFToS, 0), 201, 100, {2});
+ MakeInstructionDescriptor(36, spv::Op::OpConvertFToS, 0), 201, 100, {2});
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
@@ -586,7 +594,7 @@ TEST(TransformationCompositeExtractTest, DontAddSynonymsForIrrelevantIds) {
MakeUnique<FactManager>(context.get()), validator_options);
transformation_context.GetFactManager()->AddFactIdIsIrrelevant(100);
TransformationCompositeExtract transformation(
- MakeInstructionDescriptor(36, SpvOpConvertFToS, 0), 201, 100, {2});
+ MakeInstructionDescriptor(36, spv::Op::OpConvertFToS, 0), 201, 100, {2});
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
@@ -635,7 +643,7 @@ TEST(TransformationCompositeExtractTest, DontAddSynonymInDeadBlock) {
MakeUnique<FactManager>(context.get()), validator_options);
transformation_context.GetFactManager()->AddFactBlockIsDead(15);
TransformationCompositeExtract transformation(
- MakeInstructionDescriptor(15, SpvOpBranch, 0), 100, 12, {0});
+ MakeInstructionDescriptor(15, spv::Op::OpBranch, 0), 100, 12, {0});
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
diff --git a/test/fuzz/transformation_composite_insert_test.cpp b/test/fuzz/transformation_composite_insert_test.cpp
index 3b6f34d34..e61c0fa5b 100644
--- a/test/fuzz/transformation_composite_insert_test.cpp
+++ b/test/fuzz/transformation_composite_insert_test.cpp
@@ -103,65 +103,69 @@ TEST(TransformationCompositeInsertTest, NotApplicableScenarios) {
MakeUnique<FactManager>(context.get()), validator_options);
// Bad: |fresh_id| is not fresh.
auto transformation_bad_1 = TransformationCompositeInsert(
- MakeInstructionDescriptor(29, SpvOpStore, 0), 20, 29, 11, {1, 0, 0});
+ MakeInstructionDescriptor(29, spv::Op::OpStore, 0), 20, 29, 11,
+ {1, 0, 0});
ASSERT_FALSE(
transformation_bad_1.IsApplicable(context.get(), transformation_context));
// Bad: |composite_id| does not refer to a existing instruction.
auto transformation_bad_2 = TransformationCompositeInsert(
- MakeInstructionDescriptor(29, SpvOpStore, 0), 50, 40, 11, {1, 0, 0});
+ MakeInstructionDescriptor(29, spv::Op::OpStore, 0), 50, 40, 11,
+ {1, 0, 0});
ASSERT_FALSE(
transformation_bad_2.IsApplicable(context.get(), transformation_context));
// Bad: |composite_id| does not refer to a composite value.
auto transformation_bad_3 = TransformationCompositeInsert(
- MakeInstructionDescriptor(29, SpvOpStore, 0), 50, 9, 11, {1, 0, 0});
+ MakeInstructionDescriptor(29, spv::Op::OpStore, 0), 50, 9, 11, {1, 0, 0});
ASSERT_FALSE(
transformation_bad_3.IsApplicable(context.get(), transformation_context));
// Bad: |object_id| does not refer to a defined instruction.
auto transformation_bad_4 = TransformationCompositeInsert(
- MakeInstructionDescriptor(29, SpvOpStore, 0), 50, 29, 40, {1, 0, 0});
+ MakeInstructionDescriptor(29, spv::Op::OpStore, 0), 50, 29, 40,
+ {1, 0, 0});
ASSERT_FALSE(
transformation_bad_4.IsApplicable(context.get(), transformation_context));
// Bad: |object_id| cannot refer to a pointer.
auto transformation_bad_5 = TransformationCompositeInsert(
- MakeInstructionDescriptor(29, SpvOpStore, 0), 50, 29, 8, {1, 0, 0});
+ MakeInstructionDescriptor(29, spv::Op::OpStore, 0), 50, 29, 8, {1, 0, 0});
ASSERT_FALSE(
transformation_bad_5.IsApplicable(context.get(), transformation_context));
// Bad: |index| is not a correct index.
auto transformation_bad_6 = TransformationCompositeInsert(
- MakeInstructionDescriptor(29, SpvOpStore, 0), 50, 29, 11, {2, 0, 0});
+ MakeInstructionDescriptor(29, spv::Op::OpStore, 0), 50, 29, 11,
+ {2, 0, 0});
ASSERT_FALSE(
transformation_bad_6.IsApplicable(context.get(), transformation_context));
// Bad: Type id of the object to be inserted and the type id of the
// component at |index| are not the same.
auto transformation_bad_7 = TransformationCompositeInsert(
- MakeInstructionDescriptor(29, SpvOpStore, 0), 50, 29, 11, {1, 0});
+ MakeInstructionDescriptor(29, spv::Op::OpStore, 0), 50, 29, 11, {1, 0});
ASSERT_FALSE(
transformation_bad_7.IsApplicable(context.get(), transformation_context));
// Bad: |instruction_to_insert_before| does not refer to a defined
// instruction.
auto transformation_bad_8 = TransformationCompositeInsert(
- MakeInstructionDescriptor(29, SpvOpIMul, 0), 50, 29, 11, {1, 0, 0});
+ MakeInstructionDescriptor(29, spv::Op::OpIMul, 0), 50, 29, 11, {1, 0, 0});
ASSERT_FALSE(
transformation_bad_8.IsApplicable(context.get(), transformation_context));
// Bad: OpCompositeInsert cannot be inserted before OpBranchConditional with
// OpSelectionMerge above it.
auto transformation_bad_9 = TransformationCompositeInsert(
- MakeInstructionDescriptor(29, SpvOpBranchConditional, 0), 50, 29, 11,
- {1, 0, 0});
+ MakeInstructionDescriptor(29, spv::Op::OpBranchConditional, 0), 50, 29,
+ 11, {1, 0, 0});
ASSERT_FALSE(
transformation_bad_9.IsApplicable(context.get(), transformation_context));
// Bad: |composite_id| does not have a type_id.
auto transformation_bad_10 = TransformationCompositeInsert(
- MakeInstructionDescriptor(29, SpvOpStore, 0), 50, 1, 11, {1, 0, 0});
+ MakeInstructionDescriptor(29, spv::Op::OpStore, 0), 50, 1, 11, {1, 0, 0});
ASSERT_FALSE(transformation_bad_10.IsApplicable(context.get(),
transformation_context));
}
@@ -222,14 +226,14 @@ TEST(TransformationCompositeInsertTest, EmptyCompositeScenarios) {
MakeUnique<FactManager>(context.get()), validator_options);
// Bad: The composite with |composite_id| cannot be empty.
auto transformation_bad_1 = TransformationCompositeInsert(
- MakeInstructionDescriptor(64, SpvOpStore, 0), 50, 61, 62, {1});
+ MakeInstructionDescriptor(64, spv::Op::OpStore, 0), 50, 61, 62, {1});
ASSERT_FALSE(
transformation_bad_1.IsApplicable(context.get(), transformation_context));
// Good: It is possible to insert into a composite an element which is an
// empty composite.
auto transformation_good_1 = TransformationCompositeInsert(
- MakeInstructionDescriptor(64, SpvOpStore, 0), 50, 64, 62, {1});
+ MakeInstructionDescriptor(64, spv::Op::OpStore, 0), 50, 64, 62, {1});
ASSERT_TRUE(transformation_good_1.IsApplicable(context.get(),
transformation_context));
ApplyAndCheckFreshIds(transformation_good_1, context.get(),
@@ -368,7 +372,8 @@ TEST(TransformationCompositeInsertTest, IrrelevantCompositeNoSynonyms) {
transformation_context.GetFactManager()->AddFactIdIsIrrelevant(30);
auto transformation_good_1 = TransformationCompositeInsert(
- MakeInstructionDescriptor(30, SpvOpStore, 0), 50, 30, 11, {1, 0, 0});
+ MakeInstructionDescriptor(30, spv::Op::OpStore, 0), 50, 30, 11,
+ {1, 0, 0});
ASSERT_TRUE(transformation_good_1.IsApplicable(context.get(),
transformation_context));
ApplyAndCheckFreshIds(transformation_good_1, context.get(),
@@ -473,7 +478,8 @@ TEST(TransformationCompositeInsertTest, IrrelevantObjectNoSynonyms) {
transformation_context.GetFactManager()->AddFactIdIsIrrelevant(11);
auto transformation_good_1 = TransformationCompositeInsert(
- MakeInstructionDescriptor(30, SpvOpStore, 0), 50, 30, 11, {1, 0, 0});
+ MakeInstructionDescriptor(30, spv::Op::OpStore, 0), 50, 30, 11,
+ {1, 0, 0});
ASSERT_TRUE(transformation_good_1.IsApplicable(context.get(),
transformation_context));
ApplyAndCheckFreshIds(transformation_good_1, context.get(),
@@ -580,7 +586,8 @@ TEST(TransformationCompositeInsertTest, ApplicableCreatedSynonyms) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
auto transformation_good_1 = TransformationCompositeInsert(
- MakeInstructionDescriptor(30, SpvOpStore, 0), 50, 30, 11, {1, 0, 0});
+ MakeInstructionDescriptor(30, spv::Op::OpStore, 0), 50, 30, 11,
+ {1, 0, 0});
ASSERT_TRUE(transformation_good_1.IsApplicable(context.get(),
transformation_context));
ApplyAndCheckFreshIds(transformation_good_1, context.get(),
@@ -609,7 +616,8 @@ TEST(TransformationCompositeInsertTest, ApplicableCreatedSynonyms) {
MakeDataDescriptor(30, {1, 0, 0}), MakeDataDescriptor(50, {1, 0, 0})));
auto transformation_good_2 = TransformationCompositeInsert(
- MakeInstructionDescriptor(50, SpvOpStore, 0), 51, 50, 11, {0, 1, 1});
+ MakeInstructionDescriptor(50, spv::Op::OpStore, 0), 51, 50, 11,
+ {0, 1, 1});
ASSERT_TRUE(transformation_good_2.IsApplicable(context.get(),
transformation_context));
ApplyAndCheckFreshIds(transformation_good_2, context.get(),
@@ -787,30 +795,30 @@ TEST(TransformationCompositeInsertTest, IdNotAvailableScenarios) {
// Bad: The object with |object_id| is not available at
// |instruction_to_insert_before|.
auto transformation_bad_1 = TransformationCompositeInsert(
- MakeInstructionDescriptor(31, SpvOpIMul, 0), 50, 27, 60, {1});
+ MakeInstructionDescriptor(31, spv::Op::OpIMul, 0), 50, 27, 60, {1});
ASSERT_FALSE(
transformation_bad_1.IsApplicable(context.get(), transformation_context));
// Bad: The composite with |composite_id| is not available at
// |instruction_to_insert_before|.
auto transformation_bad_2 = TransformationCompositeInsert(
- MakeInstructionDescriptor(31, SpvOpIMul, 0), 50, 61, 21, {1});
+ MakeInstructionDescriptor(31, spv::Op::OpIMul, 0), 50, 61, 21, {1});
ASSERT_FALSE(
transformation_bad_2.IsApplicable(context.get(), transformation_context));
// Bad: The |instruction_to_insert_before| is the composite itself and is
// available.
auto transformation_bad_3 = TransformationCompositeInsert(
- MakeInstructionDescriptor(61, SpvOpCompositeConstruct, 0), 50, 61, 21,
- {1});
+ MakeInstructionDescriptor(61, spv::Op::OpCompositeConstruct, 0), 50, 61,
+ 21, {1});
ASSERT_FALSE(
transformation_bad_3.IsApplicable(context.get(), transformation_context));
// Bad: The |instruction_to_insert_before| is the object itself and is not
// available.
auto transformation_bad_4 = TransformationCompositeInsert(
- MakeInstructionDescriptor(60, SpvOpCompositeConstruct, 0), 50, 27, 60,
- {1});
+ MakeInstructionDescriptor(60, spv::Op::OpCompositeConstruct, 0), 50, 27,
+ 60, {1});
ASSERT_FALSE(
transformation_bad_4.IsApplicable(context.get(), transformation_context));
}
@@ -863,7 +871,8 @@ TEST(TransformationCompositeInsertTest, CompositeInsertionWithIrrelevantIds) {
// Leads to synonyms - nothing is irrelevant.
auto transformation1 = TransformationCompositeInsert(
- MakeInstructionDescriptor(13, SpvOpSelectionMerge, 0), 100, 9, 17, {0});
+ MakeInstructionDescriptor(13, spv::Op::OpSelectionMerge, 0), 100, 9, 17,
+ {0});
ASSERT_TRUE(
transformation1.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation1, context.get(),
@@ -876,7 +885,8 @@ TEST(TransformationCompositeInsertTest, CompositeInsertionWithIrrelevantIds) {
// Because %16 is irrelevant, we don't get a synonym with the component to
// which it has been inserted (but we do for the other component).
auto transformation2 = TransformationCompositeInsert(
- MakeInstructionDescriptor(13, SpvOpSelectionMerge, 0), 101, 9, 16, {0});
+ MakeInstructionDescriptor(13, spv::Op::OpSelectionMerge, 0), 101, 9, 16,
+ {0});
ASSERT_TRUE(
transformation2.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation2, context.get(),
@@ -889,7 +899,8 @@ TEST(TransformationCompositeInsertTest, CompositeInsertionWithIrrelevantIds) {
// Because %18 is irrelevant we only get a synonym for the component into
// which insertion has taken place.
auto transformation3 = TransformationCompositeInsert(
- MakeInstructionDescriptor(13, SpvOpSelectionMerge, 0), 102, 18, 17, {0});
+ MakeInstructionDescriptor(13, spv::Op::OpSelectionMerge, 0), 102, 18, 17,
+ {0});
ASSERT_TRUE(
transformation3.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation3, context.get(),
@@ -901,7 +912,7 @@ TEST(TransformationCompositeInsertTest, CompositeInsertionWithIrrelevantIds) {
// Does not lead to synonyms as block %14 is dead.
auto transformation4 = TransformationCompositeInsert(
- MakeInstructionDescriptor(14, SpvOpBranch, 0), 103, 9, 17, {0});
+ MakeInstructionDescriptor(14, spv::Op::OpBranch, 0), 103, 9, 17, {0});
ASSERT_TRUE(
transformation4.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation4, context.get(),
diff --git a/test/fuzz/transformation_equation_instruction_test.cpp b/test/fuzz/transformation_equation_instruction_test.cpp
index 5b5033d23..3653fcab9 100644
--- a/test/fuzz/transformation_equation_instruction_test.cpp
+++ b/test/fuzz/transformation_equation_instruction_test.cpp
@@ -54,65 +54,66 @@ TEST(TransformationEquationInstructionTest, SignedNegate) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
protobufs::InstructionDescriptor return_instruction =
- MakeInstructionDescriptor(13, SpvOpReturn, 0);
+ MakeInstructionDescriptor(13, spv::Op::OpReturn, 0);
// Bad: id already in use.
- ASSERT_FALSE(TransformationEquationInstruction(7, SpvOpSNegate, {7},
+ ASSERT_FALSE(TransformationEquationInstruction(7, spv::Op::OpSNegate, {7},
return_instruction)
.IsApplicable(context.get(), transformation_context));
// Bad: identified instruction does not exist.
- ASSERT_FALSE(
- TransformationEquationInstruction(
- 14, SpvOpSNegate, {7}, MakeInstructionDescriptor(13, SpvOpLoad, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationEquationInstruction(
+ 14, spv::Op::OpSNegate, {7},
+ MakeInstructionDescriptor(13, spv::Op::OpLoad, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: id 100 does not exist
- ASSERT_FALSE(TransformationEquationInstruction(14, SpvOpSNegate, {100},
+ ASSERT_FALSE(TransformationEquationInstruction(14, spv::Op::OpSNegate, {100},
return_instruction)
.IsApplicable(context.get(), transformation_context));
// Bad: id 20 is an OpUndef
- ASSERT_FALSE(TransformationEquationInstruction(14, SpvOpSNegate, {20},
+ ASSERT_FALSE(TransformationEquationInstruction(14, spv::Op::OpSNegate, {20},
return_instruction)
.IsApplicable(context.get(), transformation_context));
// Bad: id 30 is not available right before its definition
ASSERT_FALSE(TransformationEquationInstruction(
- 14, SpvOpSNegate, {30},
- MakeInstructionDescriptor(30, SpvOpCopyObject, 0))
+ 14, spv::Op::OpSNegate, {30},
+ MakeInstructionDescriptor(30, spv::Op::OpCopyObject, 0))
.IsApplicable(context.get(), transformation_context));
// Bad: too many arguments to OpSNegate.
- ASSERT_FALSE(TransformationEquationInstruction(14, SpvOpSNegate, {7, 7},
+ ASSERT_FALSE(TransformationEquationInstruction(14, spv::Op::OpSNegate, {7, 7},
return_instruction)
.IsApplicable(context.get(), transformation_context));
// Bad: 40 is a type id.
- ASSERT_FALSE(TransformationEquationInstruction(14, SpvOpSNegate, {40},
+ ASSERT_FALSE(TransformationEquationInstruction(14, spv::Op::OpSNegate, {40},
return_instruction)
.IsApplicable(context.get(), transformation_context));
// Bad: wrong type of argument to OpSNegate.
- ASSERT_FALSE(TransformationEquationInstruction(14, SpvOpSNegate, {41},
+ ASSERT_FALSE(TransformationEquationInstruction(14, spv::Op::OpSNegate, {41},
return_instruction)
.IsApplicable(context.get(), transformation_context));
auto transformation1 = TransformationEquationInstruction(
- 14, SpvOpSNegate, {7}, return_instruction);
+ 14, spv::Op::OpSNegate, {7}, return_instruction);
ASSERT_TRUE(
transformation1.IsApplicable(context.get(), transformation_context));
ASSERT_EQ(nullptr, context->get_def_use_mgr()->GetDef(14));
ASSERT_EQ(nullptr, context->get_instr_block(14));
ApplyAndCheckFreshIds(transformation1, context.get(),
&transformation_context);
- ASSERT_EQ(SpvOpSNegate, context->get_def_use_mgr()->GetDef(14)->opcode());
+ ASSERT_EQ(spv::Op::OpSNegate,
+ context->get_def_use_mgr()->GetDef(14)->opcode());
ASSERT_EQ(13, context->get_instr_block(14)->id());
ASSERT_TRUE(fuzzerutil::IsValidAndWellFormed(context.get(), validator_options,
kConsoleMessageConsumer));
auto transformation2 = TransformationEquationInstruction(
- 15, SpvOpSNegate, {14}, return_instruction);
+ 15, spv::Op::OpSNegate, {14}, return_instruction);
ASSERT_TRUE(
transformation2.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation2, context.get(),
@@ -178,25 +179,25 @@ TEST(TransformationEquationInstructionTest, LogicalNot) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
protobufs::InstructionDescriptor return_instruction =
- MakeInstructionDescriptor(13, SpvOpReturn, 0);
+ MakeInstructionDescriptor(13, spv::Op::OpReturn, 0);
// Bad: too few arguments to OpLogicalNot.
- ASSERT_FALSE(TransformationEquationInstruction(14, SpvOpLogicalNot, {},
+ ASSERT_FALSE(TransformationEquationInstruction(14, spv::Op::OpLogicalNot, {},
return_instruction)
.IsApplicable(context.get(), transformation_context));
// Bad: 6 is a type id.
- ASSERT_FALSE(TransformationEquationInstruction(14, SpvOpLogicalNot, {6},
+ ASSERT_FALSE(TransformationEquationInstruction(14, spv::Op::OpLogicalNot, {6},
return_instruction)
.IsApplicable(context.get(), transformation_context));
// Bad: wrong type of argument to OpLogicalNot.
- ASSERT_FALSE(TransformationEquationInstruction(14, SpvOpLogicalNot, {21},
- return_instruction)
+ ASSERT_FALSE(TransformationEquationInstruction(14, spv::Op::OpLogicalNot,
+ {21}, return_instruction)
.IsApplicable(context.get(), transformation_context));
auto transformation1 = TransformationEquationInstruction(
- 14, SpvOpLogicalNot, {7}, return_instruction);
+ 14, spv::Op::OpLogicalNot, {7}, return_instruction);
ASSERT_TRUE(
transformation1.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation1, context.get(),
@@ -205,7 +206,7 @@ TEST(TransformationEquationInstructionTest, LogicalNot) {
kConsoleMessageConsumer));
auto transformation2 = TransformationEquationInstruction(
- 15, SpvOpLogicalNot, {14}, return_instruction);
+ 15, spv::Op::OpLogicalNot, {14}, return_instruction);
ASSERT_TRUE(
transformation2.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation2, context.get(),
@@ -272,31 +273,31 @@ TEST(TransformationEquationInstructionTest, AddSubNegate1) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
protobufs::InstructionDescriptor return_instruction =
- MakeInstructionDescriptor(13, SpvOpReturn, 0);
+ MakeInstructionDescriptor(13, spv::Op::OpReturn, 0);
// Bad: too many arguments to OpIAdd.
- ASSERT_FALSE(TransformationEquationInstruction(14, SpvOpIAdd, {15, 16, 16},
- return_instruction)
+ ASSERT_FALSE(TransformationEquationInstruction(
+ 14, spv::Op::OpIAdd, {15, 16, 16}, return_instruction)
.IsApplicable(context.get(), transformation_context));
// Bad: boolean argument to OpIAdd.
- ASSERT_FALSE(TransformationEquationInstruction(14, SpvOpIAdd, {15, 32},
+ ASSERT_FALSE(TransformationEquationInstruction(14, spv::Op::OpIAdd, {15, 32},
return_instruction)
.IsApplicable(context.get(), transformation_context));
// Bad: type as argument to OpIAdd.
- ASSERT_FALSE(TransformationEquationInstruction(14, SpvOpIAdd, {33, 16},
+ ASSERT_FALSE(TransformationEquationInstruction(14, spv::Op::OpIAdd, {33, 16},
return_instruction)
.IsApplicable(context.get(), transformation_context));
// Bad: arguments of mismatched widths
- ASSERT_FALSE(TransformationEquationInstruction(14, SpvOpIAdd, {15, 31},
+ ASSERT_FALSE(TransformationEquationInstruction(14, spv::Op::OpIAdd, {15, 31},
return_instruction)
.IsApplicable(context.get(), transformation_context));
// Bad: arguments of mismatched widths
- ASSERT_FALSE(TransformationEquationInstruction(14, SpvOpIAdd, {31, 15},
+ ASSERT_FALSE(TransformationEquationInstruction(14, spv::Op::OpIAdd, {31, 15},
return_instruction)
.IsApplicable(context.get(), transformation_context));
auto transformation1 = TransformationEquationInstruction(
- 14, SpvOpIAdd, {15, 16}, return_instruction);
+ 14, spv::Op::OpIAdd, {15, 16}, return_instruction);
ASSERT_TRUE(
transformation1.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation1, context.get(),
@@ -305,7 +306,7 @@ TEST(TransformationEquationInstructionTest, AddSubNegate1) {
kConsoleMessageConsumer));
auto transformation2 = TransformationEquationInstruction(
- 19, SpvOpISub, {14, 16}, return_instruction);
+ 19, spv::Op::OpISub, {14, 16}, return_instruction);
ASSERT_TRUE(
transformation2.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation2, context.get(),
@@ -316,7 +317,7 @@ TEST(TransformationEquationInstructionTest, AddSubNegate1) {
MakeDataDescriptor(15, {}), MakeDataDescriptor(19, {})));
auto transformation3 = TransformationEquationInstruction(
- 20, SpvOpISub, {14, 15}, return_instruction);
+ 20, spv::Op::OpISub, {14, 15}, return_instruction);
ASSERT_TRUE(
transformation3.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation3, context.get(),
@@ -327,7 +328,7 @@ TEST(TransformationEquationInstructionTest, AddSubNegate1) {
MakeDataDescriptor(20, {}), MakeDataDescriptor(16, {})));
auto transformation4 = TransformationEquationInstruction(
- 22, SpvOpISub, {16, 14}, return_instruction);
+ 22, spv::Op::OpISub, {16, 14}, return_instruction);
ASSERT_TRUE(
transformation4.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation4, context.get(),
@@ -336,7 +337,7 @@ TEST(TransformationEquationInstructionTest, AddSubNegate1) {
kConsoleMessageConsumer));
auto transformation5 = TransformationEquationInstruction(
- 24, SpvOpSNegate, {22}, return_instruction);
+ 24, spv::Op::OpSNegate, {22}, return_instruction);
ASSERT_TRUE(
transformation5.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation5, context.get(),
@@ -404,10 +405,10 @@ TEST(TransformationEquationInstructionTest, AddSubNegate2) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
protobufs::InstructionDescriptor return_instruction =
- MakeInstructionDescriptor(13, SpvOpReturn, 0);
+ MakeInstructionDescriptor(13, spv::Op::OpReturn, 0);
auto transformation1 = TransformationEquationInstruction(
- 14, SpvOpISub, {15, 16}, return_instruction);
+ 14, spv::Op::OpISub, {15, 16}, return_instruction);
ASSERT_TRUE(
transformation1.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation1, context.get(),
@@ -416,7 +417,7 @@ TEST(TransformationEquationInstructionTest, AddSubNegate2) {
kConsoleMessageConsumer));
auto transformation2 = TransformationEquationInstruction(
- 17, SpvOpIAdd, {14, 16}, return_instruction);
+ 17, spv::Op::OpIAdd, {14, 16}, return_instruction);
ASSERT_TRUE(
transformation2.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation2, context.get(),
@@ -427,7 +428,7 @@ TEST(TransformationEquationInstructionTest, AddSubNegate2) {
MakeDataDescriptor(17, {}), MakeDataDescriptor(15, {})));
auto transformation3 = TransformationEquationInstruction(
- 18, SpvOpIAdd, {16, 14}, return_instruction);
+ 18, spv::Op::OpIAdd, {16, 14}, return_instruction);
ASSERT_TRUE(
transformation3.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation3, context.get(),
@@ -440,7 +441,7 @@ TEST(TransformationEquationInstructionTest, AddSubNegate2) {
MakeDataDescriptor(18, {}), MakeDataDescriptor(15, {})));
auto transformation4 = TransformationEquationInstruction(
- 19, SpvOpISub, {14, 15}, return_instruction);
+ 19, spv::Op::OpISub, {14, 15}, return_instruction);
ASSERT_TRUE(
transformation4.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation4, context.get(),
@@ -449,7 +450,7 @@ TEST(TransformationEquationInstructionTest, AddSubNegate2) {
kConsoleMessageConsumer));
auto transformation5 = TransformationEquationInstruction(
- 20, SpvOpSNegate, {19}, return_instruction);
+ 20, spv::Op::OpSNegate, {19}, return_instruction);
ASSERT_TRUE(
transformation5.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation5, context.get(),
@@ -460,7 +461,7 @@ TEST(TransformationEquationInstructionTest, AddSubNegate2) {
MakeDataDescriptor(20, {}), MakeDataDescriptor(16, {})));
auto transformation6 = TransformationEquationInstruction(
- 21, SpvOpISub, {14, 19}, return_instruction);
+ 21, spv::Op::OpISub, {14, 19}, return_instruction);
ASSERT_TRUE(
transformation6.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation6, context.get(),
@@ -471,7 +472,7 @@ TEST(TransformationEquationInstructionTest, AddSubNegate2) {
MakeDataDescriptor(21, {}), MakeDataDescriptor(15, {})));
auto transformation7 = TransformationEquationInstruction(
- 22, SpvOpISub, {14, 18}, return_instruction);
+ 22, spv::Op::OpISub, {14, 18}, return_instruction);
ASSERT_TRUE(
transformation7.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation7, context.get(),
@@ -480,7 +481,7 @@ TEST(TransformationEquationInstructionTest, AddSubNegate2) {
kConsoleMessageConsumer));
auto transformation8 = TransformationEquationInstruction(
- 23, SpvOpSNegate, {22}, return_instruction);
+ 23, spv::Op::OpSNegate, {22}, return_instruction);
ASSERT_TRUE(
transformation8.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation8, context.get(),
@@ -559,51 +560,51 @@ TEST(TransformationEquationInstructionTest, Bitcast) {
kConsoleMessageConsumer));
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
- auto insert_before = MakeInstructionDescriptor(13, SpvOpReturn, 0);
+ auto insert_before = MakeInstructionDescriptor(13, spv::Op::OpReturn, 0);
// Too many operands.
- ASSERT_FALSE(TransformationEquationInstruction(50, SpvOpBitcast, {15, 16},
- insert_before)
+ ASSERT_FALSE(TransformationEquationInstruction(50, spv::Op::OpBitcast,
+ {15, 16}, insert_before)
.IsApplicable(context.get(), transformation_context));
// Too few operands.
- ASSERT_FALSE(
- TransformationEquationInstruction(50, SpvOpBitcast, {}, insert_before)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationEquationInstruction(50, spv::Op::OpBitcast, {},
+ insert_before)
+ .IsApplicable(context.get(), transformation_context));
// Operand's id is invalid.
- ASSERT_FALSE(
- TransformationEquationInstruction(50, SpvOpBitcast, {50}, insert_before)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationEquationInstruction(50, spv::Op::OpBitcast, {50},
+ insert_before)
+ .IsApplicable(context.get(), transformation_context));
// Operand's type is invalid
- ASSERT_FALSE(
- TransformationEquationInstruction(50, SpvOpBitcast, {13}, insert_before)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationEquationInstruction(50, spv::Op::OpBitcast, {13},
+ insert_before)
+ .IsApplicable(context.get(), transformation_context));
// Operand must be a scalar or a vector of numerical type.
#ifndef NDEBUG
- ASSERT_DEATH(
- TransformationEquationInstruction(50, SpvOpBitcast, {23}, insert_before)
- .IsApplicable(context.get(), transformation_context),
- "Operand is not a scalar or a vector of numerical type");
- ASSERT_DEATH(
- TransformationEquationInstruction(50, SpvOpBitcast, {24}, insert_before)
- .IsApplicable(context.get(), transformation_context),
- "Only vectors of numerical components are supported");
+ ASSERT_DEATH(TransformationEquationInstruction(50, spv::Op::OpBitcast, {23},
+ insert_before)
+ .IsApplicable(context.get(), transformation_context),
+ "Operand is not a scalar or a vector of numerical type");
+ ASSERT_DEATH(TransformationEquationInstruction(50, spv::Op::OpBitcast, {24},
+ insert_before)
+ .IsApplicable(context.get(), transformation_context),
+ "Only vectors of numerical components are supported");
#else
- ASSERT_FALSE(
- TransformationEquationInstruction(50, SpvOpBitcast, {23}, insert_before)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(
- TransformationEquationInstruction(50, SpvOpBitcast, {24}, insert_before)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationEquationInstruction(50, spv::Op::OpBitcast, {23},
+ insert_before)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationEquationInstruction(50, spv::Op::OpBitcast, {24},
+ insert_before)
+ .IsApplicable(context.get(), transformation_context));
#endif
for (uint32_t operand_id = 15, fresh_id = 50; operand_id <= 20;
++operand_id, ++fresh_id) {
TransformationEquationInstruction transformation(
- fresh_id, SpvOpBitcast, {operand_id}, insert_before);
+ fresh_id, spv::Op::OpBitcast, {operand_id}, insert_before);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -683,23 +684,23 @@ TEST(TransformationEquationInstructionTest,
kConsoleMessageConsumer));
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
- auto insert_before = MakeInstructionDescriptor(13, SpvOpReturn, 0);
+ auto insert_before = MakeInstructionDescriptor(13, spv::Op::OpReturn, 0);
// Scalar floating-point type does not exist.
- ASSERT_FALSE(
- TransformationEquationInstruction(50, SpvOpBitcast, {15}, insert_before)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(
- TransformationEquationInstruction(50, SpvOpBitcast, {16}, insert_before)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationEquationInstruction(50, spv::Op::OpBitcast, {15},
+ insert_before)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationEquationInstruction(50, spv::Op::OpBitcast, {16},
+ insert_before)
+ .IsApplicable(context.get(), transformation_context));
// Vector of floating-point components does not exist.
- ASSERT_FALSE(
- TransformationEquationInstruction(50, SpvOpBitcast, {18}, insert_before)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(
- TransformationEquationInstruction(50, SpvOpBitcast, {19}, insert_before)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationEquationInstruction(50, spv::Op::OpBitcast, {18},
+ insert_before)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationEquationInstruction(50, spv::Op::OpBitcast, {19},
+ insert_before)
+ .IsApplicable(context.get(), transformation_context));
}
TEST(TransformationEquationInstructionTest, BitcastResultTypeIntDoesNotExist1) {
@@ -730,17 +731,17 @@ TEST(TransformationEquationInstructionTest, BitcastResultTypeIntDoesNotExist1) {
kConsoleMessageConsumer));
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
- auto insert_before = MakeInstructionDescriptor(13, SpvOpReturn, 0);
+ auto insert_before = MakeInstructionDescriptor(13, spv::Op::OpReturn, 0);
// Scalar integral type does not exist.
- ASSERT_FALSE(
- TransformationEquationInstruction(50, SpvOpBitcast, {17}, insert_before)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationEquationInstruction(50, spv::Op::OpBitcast, {17},
+ insert_before)
+ .IsApplicable(context.get(), transformation_context));
// Vector of integral components does not exist.
- ASSERT_FALSE(
- TransformationEquationInstruction(50, SpvOpBitcast, {20}, insert_before)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationEquationInstruction(50, spv::Op::OpBitcast, {20},
+ insert_before)
+ .IsApplicable(context.get(), transformation_context));
}
TEST(TransformationEquationInstructionTest, BitcastResultTypeIntDoesNotExist2) {
@@ -773,19 +774,19 @@ TEST(TransformationEquationInstructionTest, BitcastResultTypeIntDoesNotExist2) {
kConsoleMessageConsumer));
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
- auto insert_before = MakeInstructionDescriptor(13, SpvOpReturn, 0);
+ auto insert_before = MakeInstructionDescriptor(13, spv::Op::OpReturn, 0);
{
- TransformationEquationInstruction transformation(50, SpvOpBitcast, {17},
- insert_before);
+ TransformationEquationInstruction transformation(50, spv::Op::OpBitcast,
+ {17}, insert_before);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
&transformation_context);
}
{
- TransformationEquationInstruction transformation(51, SpvOpBitcast, {20},
- insert_before);
+ TransformationEquationInstruction transformation(51, spv::Op::OpBitcast,
+ {20}, insert_before);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -848,19 +849,19 @@ TEST(TransformationEquationInstructionTest, BitcastResultTypeIntDoesNotExist3) {
kConsoleMessageConsumer));
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
- auto insert_before = MakeInstructionDescriptor(13, SpvOpReturn, 0);
+ auto insert_before = MakeInstructionDescriptor(13, spv::Op::OpReturn, 0);
{
- TransformationEquationInstruction transformation(50, SpvOpBitcast, {17},
- insert_before);
+ TransformationEquationInstruction transformation(50, spv::Op::OpBitcast,
+ {17}, insert_before);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
&transformation_context);
}
{
- TransformationEquationInstruction transformation(51, SpvOpBitcast, {20},
- insert_before);
+ TransformationEquationInstruction transformation(51, spv::Op::OpBitcast,
+ {20}, insert_before);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -922,20 +923,20 @@ TEST(TransformationEquationInstructionTest, BitcastResultTypeIntDoesNotExist4) {
kConsoleMessageConsumer));
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
- auto insert_before = MakeInstructionDescriptor(13, SpvOpReturn, 0);
+ auto insert_before = MakeInstructionDescriptor(13, spv::Op::OpReturn, 0);
{
- TransformationEquationInstruction transformation(50, SpvOpBitcast, {17},
- insert_before);
+ TransformationEquationInstruction transformation(50, spv::Op::OpBitcast,
+ {17}, insert_before);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
&transformation_context);
}
- ASSERT_FALSE(
- TransformationEquationInstruction(51, SpvOpBitcast, {20}, insert_before)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationEquationInstruction(51, spv::Op::OpBitcast, {20},
+ insert_before)
+ .IsApplicable(context.get(), transformation_context));
ASSERT_TRUE(fuzzerutil::IsValidAndWellFormed(context.get(), validator_options,
kConsoleMessageConsumer));
@@ -993,20 +994,20 @@ TEST(TransformationEquationInstructionTest, BitcastResultTypeIntDoesNotExist5) {
kConsoleMessageConsumer));
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
- auto insert_before = MakeInstructionDescriptor(13, SpvOpReturn, 0);
+ auto insert_before = MakeInstructionDescriptor(13, spv::Op::OpReturn, 0);
{
- TransformationEquationInstruction transformation(50, SpvOpBitcast, {17},
- insert_before);
+ TransformationEquationInstruction transformation(50, spv::Op::OpBitcast,
+ {17}, insert_before);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
&transformation_context);
}
- ASSERT_FALSE(
- TransformationEquationInstruction(51, SpvOpBitcast, {20}, insert_before)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationEquationInstruction(51, spv::Op::OpBitcast, {20},
+ insert_before)
+ .IsApplicable(context.get(), transformation_context));
ASSERT_TRUE(fuzzerutil::IsValidAndWellFormed(context.get(), validator_options,
kConsoleMessageConsumer));
@@ -1066,19 +1067,19 @@ TEST(TransformationEquationInstructionTest, BitcastResultTypeIntDoesNotExist6) {
kConsoleMessageConsumer));
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
- auto insert_before = MakeInstructionDescriptor(13, SpvOpReturn, 0);
+ auto insert_before = MakeInstructionDescriptor(13, spv::Op::OpReturn, 0);
{
- TransformationEquationInstruction transformation(50, SpvOpBitcast, {17},
- insert_before);
+ TransformationEquationInstruction transformation(50, spv::Op::OpBitcast,
+ {17}, insert_before);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
&transformation_context);
}
{
- TransformationEquationInstruction transformation(51, SpvOpBitcast, {20},
- insert_before);
+ TransformationEquationInstruction transformation(51, spv::Op::OpBitcast,
+ {20}, insert_before);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -1146,19 +1147,19 @@ TEST(TransformationEquationInstructionTest, BitcastResultTypeIntDoesNotExist7) {
kConsoleMessageConsumer));
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
- auto insert_before = MakeInstructionDescriptor(13, SpvOpReturn, 0);
+ auto insert_before = MakeInstructionDescriptor(13, spv::Op::OpReturn, 0);
{
- TransformationEquationInstruction transformation(50, SpvOpBitcast, {17},
- insert_before);
+ TransformationEquationInstruction transformation(50, spv::Op::OpBitcast,
+ {17}, insert_before);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
&transformation_context);
}
{
- TransformationEquationInstruction transformation(51, SpvOpBitcast, {20},
- insert_before);
+ TransformationEquationInstruction transformation(51, spv::Op::OpBitcast,
+ {20}, insert_before);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -1222,10 +1223,10 @@ TEST(TransformationEquationInstructionTest, Miscellaneous1) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
protobufs::InstructionDescriptor return_instruction =
- MakeInstructionDescriptor(13, SpvOpReturn, 0);
+ MakeInstructionDescriptor(13, spv::Op::OpReturn, 0);
auto transformation1 = TransformationEquationInstruction(
- 522, SpvOpISub, {113, 113}, return_instruction);
+ 522, spv::Op::OpISub, {113, 113}, return_instruction);
ASSERT_TRUE(
transformation1.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation1, context.get(),
@@ -1234,7 +1235,7 @@ TEST(TransformationEquationInstructionTest, Miscellaneous1) {
kConsoleMessageConsumer));
auto transformation2 = TransformationEquationInstruction(
- 570, SpvOpIAdd, {522, 113}, return_instruction);
+ 570, spv::Op::OpIAdd, {522, 113}, return_instruction);
ASSERT_TRUE(
transformation2.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation2, context.get(),
@@ -1294,10 +1295,10 @@ TEST(TransformationEquationInstructionTest, Miscellaneous2) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
protobufs::InstructionDescriptor return_instruction =
- MakeInstructionDescriptor(13, SpvOpReturn, 0);
+ MakeInstructionDescriptor(13, spv::Op::OpReturn, 0);
auto transformation1 = TransformationEquationInstruction(
- 522, SpvOpISub, {113, 113}, return_instruction);
+ 522, spv::Op::OpISub, {113, 113}, return_instruction);
ASSERT_TRUE(
transformation1.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation1, context.get(),
@@ -1306,7 +1307,7 @@ TEST(TransformationEquationInstructionTest, Miscellaneous2) {
kConsoleMessageConsumer));
auto transformation2 = TransformationEquationInstruction(
- 570, SpvOpIAdd, {522, 113}, return_instruction);
+ 570, spv::Op::OpIAdd, {522, 113}, return_instruction);
ASSERT_TRUE(
transformation2.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation2, context.get(),
@@ -1380,97 +1381,97 @@ TEST(TransformationEquationInstructionTest, ConversionInstructions) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
protobufs::InstructionDescriptor return_instruction =
- MakeInstructionDescriptor(13, SpvOpReturn, 0);
+ MakeInstructionDescriptor(13, spv::Op::OpReturn, 0);
// Too few instruction operands.
- ASSERT_FALSE(TransformationEquationInstruction(50, SpvOpConvertSToF, {},
+ ASSERT_FALSE(TransformationEquationInstruction(50, spv::Op::OpConvertSToF, {},
return_instruction)
.IsApplicable(context.get(), transformation_context));
// Too many instruction operands.
- ASSERT_FALSE(TransformationEquationInstruction(50, SpvOpConvertSToF, {15, 16},
- return_instruction)
+ ASSERT_FALSE(TransformationEquationInstruction(50, spv::Op::OpConvertSToF,
+ {15, 16}, return_instruction)
.IsApplicable(context.get(), transformation_context));
// Operand has no type id.
- ASSERT_FALSE(TransformationEquationInstruction(50, SpvOpConvertSToF, {7},
- return_instruction)
+ ASSERT_FALSE(TransformationEquationInstruction(50, spv::Op::OpConvertSToF,
+ {7}, return_instruction)
.IsApplicable(context.get(), transformation_context));
// OpConvertSToF and OpConvertUToF require an operand to have scalar or vector
// of integral components type.
- ASSERT_FALSE(TransformationEquationInstruction(50, SpvOpConvertSToF, {17},
- return_instruction)
+ ASSERT_FALSE(TransformationEquationInstruction(50, spv::Op::OpConvertSToF,
+ {17}, return_instruction)
.IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(TransformationEquationInstruction(50, SpvOpConvertSToF, {14},
- return_instruction)
+ ASSERT_FALSE(TransformationEquationInstruction(50, spv::Op::OpConvertSToF,
+ {14}, return_instruction)
.IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(TransformationEquationInstruction(50, SpvOpConvertUToF, {17},
- return_instruction)
+ ASSERT_FALSE(TransformationEquationInstruction(50, spv::Op::OpConvertUToF,
+ {17}, return_instruction)
.IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(TransformationEquationInstruction(50, SpvOpConvertUToF, {14},
- return_instruction)
+ ASSERT_FALSE(TransformationEquationInstruction(50, spv::Op::OpConvertUToF,
+ {14}, return_instruction)
.IsApplicable(context.get(), transformation_context));
{
- TransformationEquationInstruction transformation(50, SpvOpConvertSToF, {15},
- return_instruction);
+ TransformationEquationInstruction transformation(50, spv::Op::OpConvertSToF,
+ {15}, return_instruction);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
&transformation_context);
}
{
- TransformationEquationInstruction transformation(51, SpvOpConvertSToF, {10},
- return_instruction);
+ TransformationEquationInstruction transformation(51, spv::Op::OpConvertSToF,
+ {10}, return_instruction);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
&transformation_context);
}
{
- TransformationEquationInstruction transformation(52, SpvOpConvertUToF, {16},
- return_instruction);
+ TransformationEquationInstruction transformation(52, spv::Op::OpConvertUToF,
+ {16}, return_instruction);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
&transformation_context);
}
{
- TransformationEquationInstruction transformation(53, SpvOpConvertUToF, {11},
- return_instruction);
+ TransformationEquationInstruction transformation(53, spv::Op::OpConvertUToF,
+ {11}, return_instruction);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
&transformation_context);
}
{
- TransformationEquationInstruction transformation(58, SpvOpConvertSToF, {18},
- return_instruction);
+ TransformationEquationInstruction transformation(58, spv::Op::OpConvertSToF,
+ {18}, return_instruction);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
&transformation_context);
}
{
- TransformationEquationInstruction transformation(59, SpvOpConvertUToF, {19},
- return_instruction);
+ TransformationEquationInstruction transformation(59, spv::Op::OpConvertUToF,
+ {19}, return_instruction);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
&transformation_context);
}
{
- TransformationEquationInstruction transformation(60, SpvOpConvertSToF, {20},
- return_instruction);
+ TransformationEquationInstruction transformation(60, spv::Op::OpConvertSToF,
+ {20}, return_instruction);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
&transformation_context);
}
{
- TransformationEquationInstruction transformation(61, SpvOpConvertUToF, {21},
- return_instruction);
+ TransformationEquationInstruction transformation(61, spv::Op::OpConvertUToF,
+ {21}, return_instruction);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -1555,22 +1556,22 @@ TEST(TransformationEquationInstructionTest, FloatResultTypeDoesNotExist) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
protobufs::InstructionDescriptor return_instruction =
- MakeInstructionDescriptor(13, SpvOpReturn, 0);
+ MakeInstructionDescriptor(13, spv::Op::OpReturn, 0);
// Scalar float type doesn't exist.
- ASSERT_FALSE(TransformationEquationInstruction(16, SpvOpConvertUToF, {10},
- return_instruction)
+ ASSERT_FALSE(TransformationEquationInstruction(16, spv::Op::OpConvertUToF,
+ {10}, return_instruction)
.IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(TransformationEquationInstruction(16, SpvOpConvertSToF, {11},
- return_instruction)
+ ASSERT_FALSE(TransformationEquationInstruction(16, spv::Op::OpConvertSToF,
+ {11}, return_instruction)
.IsApplicable(context.get(), transformation_context));
// Vector float type doesn't exist.
- ASSERT_FALSE(TransformationEquationInstruction(16, SpvOpConvertUToF, {14},
- return_instruction)
+ ASSERT_FALSE(TransformationEquationInstruction(16, spv::Op::OpConvertUToF,
+ {14}, return_instruction)
.IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(TransformationEquationInstruction(16, SpvOpConvertSToF, {15},
- return_instruction)
+ ASSERT_FALSE(TransformationEquationInstruction(16, spv::Op::OpConvertSToF,
+ {15}, return_instruction)
.IsApplicable(context.get(), transformation_context));
}
@@ -1605,11 +1606,11 @@ TEST(TransformationEquationInstructionTest, HandlesIrrelevantIds) {
kConsoleMessageConsumer));
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
- auto return_instruction = MakeInstructionDescriptor(13, SpvOpReturn, 0);
+ auto return_instruction = MakeInstructionDescriptor(13, spv::Op::OpReturn, 0);
// Applicable.
- TransformationEquationInstruction transformation(14, SpvOpIAdd, {15, 16},
- return_instruction);
+ TransformationEquationInstruction transformation(
+ 14, spv::Op::OpIAdd, {15, 16}, return_instruction);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
@@ -1662,11 +1663,12 @@ TEST(TransformationEquationInstructionTest, HandlesDeadBlock) {
transformation_context.GetFactManager()->AddFactBlockIsDead(41);
TransformationEquationInstruction transformation1(
- 14, SpvOpIAdd, {15, 16},
- MakeInstructionDescriptor(13, SpvOpSelectionMerge, 0));
+ 14, spv::Op::OpIAdd, {15, 16},
+ MakeInstructionDescriptor(13, spv::Op::OpSelectionMerge, 0));
// No synonym is created since block is dead.
TransformationEquationInstruction transformation2(
- 100, SpvOpISub, {14, 16}, MakeInstructionDescriptor(41, SpvOpBranch, 0));
+ 100, spv::Op::OpISub, {14, 16},
+ MakeInstructionDescriptor(41, spv::Op::OpBranch, 0));
ASSERT_TRUE(
transformation1.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation1, context.get(),
diff --git a/test/fuzz/transformation_flatten_conditional_branch_test.cpp b/test/fuzz/transformation_flatten_conditional_branch_test.cpp
index 800af0ea9..063189908 100644
--- a/test/fuzz/transformation_flatten_conditional_branch_test.cpp
+++ b/test/fuzz/transformation_flatten_conditional_branch_test.cpp
@@ -441,8 +441,8 @@ TEST(TransformationFlattenConditionalBranchTest, LoadStoreFunctionCall) {
ASSERT_DEATH(TransformationFlattenConditionalBranch(
31, true, 0, 0, 0,
{{MakeSideEffectWrapperInfo(
- MakeInstructionDescriptor(6, SpvOpLoad, 0), 100, 101,
- 102, 103, 104, 14)}})
+ MakeInstructionDescriptor(6, spv::Op::OpLoad, 0), 100,
+ 101, 102, 103, 104, 14)}})
.IsApplicable(context.get(), transformation_context),
"Bad attempt to query whether overflow ids are available.");
#endif
@@ -451,52 +451,55 @@ TEST(TransformationFlattenConditionalBranchTest, LoadStoreFunctionCall) {
ASSERT_FALSE(TransformationFlattenConditionalBranch(
31, true, 0, 0, 0,
{{MakeSideEffectWrapperInfo(
- MakeInstructionDescriptor(6, SpvOpLoad, 0), 100, 101,
- 102, 103, 0, 0)}})
+ MakeInstructionDescriptor(6, spv::Op::OpLoad, 0), 100,
+ 101, 102, 103, 0, 0)}})
.IsApplicable(context.get(), transformation_context));
// Not all fresh ids given are distinct.
ASSERT_FALSE(TransformationFlattenConditionalBranch(
31, true, 0, 0, 0,
{{MakeSideEffectWrapperInfo(
- MakeInstructionDescriptor(6, SpvOpLoad, 0), 100, 100,
- 102, 103, 104, 0)}})
+ MakeInstructionDescriptor(6, spv::Op::OpLoad, 0), 100,
+ 100, 102, 103, 104, 0)}})
.IsApplicable(context.get(), transformation_context));
// %48 heads a construct containing an OpSampledImage instruction.
ASSERT_FALSE(TransformationFlattenConditionalBranch(
48, true, 0, 0, 0,
{{MakeSideEffectWrapperInfo(
- MakeInstructionDescriptor(53, SpvOpLoad, 0), 100, 101,
- 102, 103, 104, 0)}})
+ MakeInstructionDescriptor(53, spv::Op::OpLoad, 0), 100,
+ 101, 102, 103, 104, 0)}})
.IsApplicable(context.get(), transformation_context));
// %0 is not a valid id.
ASSERT_FALSE(
TransformationFlattenConditionalBranch(
31, true, 0, 0, 0,
- {MakeSideEffectWrapperInfo(MakeInstructionDescriptor(6, SpvOpLoad, 0),
- 104, 100, 101, 102, 103, 0),
+ {MakeSideEffectWrapperInfo(
+ MakeInstructionDescriptor(6, spv::Op::OpLoad, 0), 104, 100, 101,
+ 102, 103, 0),
MakeSideEffectWrapperInfo(
- MakeInstructionDescriptor(6, SpvOpStore, 0), 106, 105)})
+ MakeInstructionDescriptor(6, spv::Op::OpStore, 0), 106, 105)})
.IsApplicable(context.get(), transformation_context));
// %17 is a float constant, while %6 has int type.
ASSERT_FALSE(
TransformationFlattenConditionalBranch(
31, true, 0, 0, 0,
- {MakeSideEffectWrapperInfo(MakeInstructionDescriptor(6, SpvOpLoad, 0),
- 104, 100, 101, 102, 103, 17),
+ {MakeSideEffectWrapperInfo(
+ MakeInstructionDescriptor(6, spv::Op::OpLoad, 0), 104, 100, 101,
+ 102, 103, 17),
MakeSideEffectWrapperInfo(
- MakeInstructionDescriptor(6, SpvOpStore, 0), 106, 105)})
+ MakeInstructionDescriptor(6, spv::Op::OpStore, 0), 106, 105)})
.IsApplicable(context.get(), transformation_context));
auto transformation1 = TransformationFlattenConditionalBranch(
31, true, 0, 0, 0,
- {MakeSideEffectWrapperInfo(MakeInstructionDescriptor(6, SpvOpLoad, 0),
- 104, 100, 101, 102, 103, 70),
- MakeSideEffectWrapperInfo(MakeInstructionDescriptor(6, SpvOpStore, 0),
- 106, 105)});
+ {MakeSideEffectWrapperInfo(
+ MakeInstructionDescriptor(6, spv::Op::OpLoad, 0), 104, 100, 101, 102,
+ 103, 70),
+ MakeSideEffectWrapperInfo(
+ MakeInstructionDescriptor(6, spv::Op::OpStore, 0), 106, 105)});
ASSERT_TRUE(
transformation1.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation1, context.get(),
@@ -514,8 +517,8 @@ TEST(TransformationFlattenConditionalBranchTest, LoadStoreFunctionCall) {
auto transformation2 = TransformationFlattenConditionalBranch(
36, false, 0, 0, 0,
- {MakeSideEffectWrapperInfo(MakeInstructionDescriptor(8, SpvOpStore, 0),
- 114, 113)});
+ {MakeSideEffectWrapperInfo(
+ MakeInstructionDescriptor(8, spv::Op::OpStore, 0), 114, 113)});
ASSERT_TRUE(
transformation2.IsApplicable(context.get(), new_transformation_context));
ApplyAndCheckFreshIds(transformation2, context.get(),
@@ -717,7 +720,8 @@ TEST(TransformationFlattenConditionalBranchTest, EdgeCases) {
auto transformation1 = TransformationFlattenConditionalBranch(
7, true, 0, 0, 0,
{{MakeSideEffectWrapperInfo(
- MakeInstructionDescriptor(10, SpvOpFunctionCall, 0), 100, 101)}});
+ MakeInstructionDescriptor(10, spv::Op::OpFunctionCall, 0), 100,
+ 101)}});
ASSERT_TRUE(
transformation1.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation1, context.get(),
@@ -729,7 +733,8 @@ TEST(TransformationFlattenConditionalBranchTest, EdgeCases) {
TransformationFlattenConditionalBranch(
7, true, 0, 0, 0,
{{MakeSideEffectWrapperInfo(
- MakeInstructionDescriptor(14, SpvOpFunctionCall, 0), 102, 103)}})
+ MakeInstructionDescriptor(14, spv::Op::OpFunctionCall, 0), 102,
+ 103)}})
.IsApplicable(context.get(), transformation_context));
// Block %16 is unreachable.
@@ -1126,10 +1131,12 @@ TEST(TransformationFlattenConditionalBranchTest, PhiToSelect5) {
auto transformation = TransformationFlattenConditionalBranch(
7, true, 0, 0, 0,
- {MakeSideEffectWrapperInfo(MakeInstructionDescriptor(522, SpvOpLoad, 0),
- 200, 201, 202, 203, 204, 5),
- MakeSideEffectWrapperInfo(MakeInstructionDescriptor(466, SpvOpLoad, 0),
- 300, 301, 302, 303, 304, 5)});
+ {MakeSideEffectWrapperInfo(
+ MakeInstructionDescriptor(522, spv::Op::OpLoad, 0), 200, 201, 202,
+ 203, 204, 5),
+ MakeSideEffectWrapperInfo(
+ MakeInstructionDescriptor(466, spv::Op::OpLoad, 0), 300, 301, 302,
+ 303, 304, 5)});
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
@@ -1231,8 +1238,9 @@ TEST(TransformationFlattenConditionalBranchTest,
auto transformation = TransformationFlattenConditionalBranch(
5, true, 0, 0, 0,
- {MakeSideEffectWrapperInfo(MakeInstructionDescriptor(20, SpvOpLoad, 0),
- 100, 101, 102, 103, 104, 21)});
+ {MakeSideEffectWrapperInfo(
+ MakeInstructionDescriptor(20, spv::Op::OpLoad, 0), 100, 101, 102, 103,
+ 104, 21)});
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
@@ -1299,8 +1307,8 @@ TEST(TransformationFlattenConditionalBranchTest, InapplicableSampledImageLoad) {
ASSERT_FALSE(TransformationFlattenConditionalBranch(
28, true, 0, 0, 0,
{MakeSideEffectWrapperInfo(
- MakeInstructionDescriptor(40, SpvOpLoad, 0), 100, 101,
- 102, 103, 104, 200)})
+ MakeInstructionDescriptor(40, spv::Op::OpLoad, 0), 100,
+ 101, 102, 103, 104, 200)})
.IsApplicable(context.get(), transformation_context));
}
@@ -1730,7 +1738,7 @@ TEST(TransformationFlattenConditionalBranchTest, ApplicablePhiToSelectVector3) {
// Check that the in operands of any OpSelect instructions all have the
// appropriate operand type.
context->module()->ForEachInst([](opt::Instruction* inst) {
- if (inst->opcode() == SpvOpSelect) {
+ if (inst->opcode() == spv::Op::OpSelect) {
ASSERT_EQ(SPV_OPERAND_TYPE_ID, inst->GetInOperand(0).type);
ASSERT_EQ(SPV_OPERAND_TYPE_ID, inst->GetInOperand(1).type);
ASSERT_EQ(SPV_OPERAND_TYPE_ID, inst->GetInOperand(2).type);
@@ -2183,14 +2191,15 @@ TEST(TransformationFlattenConditionalBranchTest, ContainsSynonymCreation) {
transformation_context.GetFactManager()->AddFactDataSynonym(
MakeDataDescriptor(10, {}), MakeDataDescriptor(21, {}));
- ASSERT_FALSE(TransformationFlattenConditionalBranch(
- 12, true, 0, 0, 0,
- {MakeSideEffectWrapperInfo(
- MakeInstructionDescriptor(30, SpvOpStore, 0), 100, 101),
- MakeSideEffectWrapperInfo(
- MakeInstructionDescriptor(21, SpvOpLoad, 0), 102, 103,
- 104, 105, 106, 80)})
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationFlattenConditionalBranch(
+ 12, true, 0, 0, 0,
+ {MakeSideEffectWrapperInfo(
+ MakeInstructionDescriptor(30, spv::Op::OpStore, 0), 100, 101),
+ MakeSideEffectWrapperInfo(
+ MakeInstructionDescriptor(21, spv::Op::OpLoad, 0), 102, 103, 104,
+ 105, 106, 80)})
+ .IsApplicable(context.get(), transformation_context));
}
} // namespace
diff --git a/test/fuzz/transformation_function_call_test.cpp b/test/fuzz/transformation_function_call_test.cpp
index b27b3ca97..c963e3399 100644
--- a/test/fuzz/transformation_function_call_test.cpp
+++ b/test/fuzz/transformation_function_call_test.cpp
@@ -174,88 +174,91 @@ TEST(TransformationFunctionCallTest, BasicTest) {
// Bad transformations
// Too many arguments
- ASSERT_FALSE(
- TransformationFunctionCall(100, 21, {71, 72, 71},
- MakeInstructionDescriptor(59, SpvOpBranch, 0))
- .IsApplicable(context.get(), transformation_context));
- // Too few arguments
ASSERT_FALSE(TransformationFunctionCall(
- 100, 21, {71}, MakeInstructionDescriptor(59, SpvOpBranch, 0))
+ 100, 21, {71, 72, 71},
+ MakeInstructionDescriptor(59, spv::Op::OpBranch, 0))
.IsApplicable(context.get(), transformation_context));
- // Arguments are the wrong way around (types do not match)
+ // Too few arguments
ASSERT_FALSE(
- TransformationFunctionCall(100, 21, {72, 71},
- MakeInstructionDescriptor(59, SpvOpBranch, 0))
+ TransformationFunctionCall(
+ 100, 21, {71}, MakeInstructionDescriptor(59, spv::Op::OpBranch, 0))
.IsApplicable(context.get(), transformation_context));
+ // Arguments are the wrong way around (types do not match)
+ ASSERT_FALSE(TransformationFunctionCall(
+ 100, 21, {72, 71},
+ MakeInstructionDescriptor(59, spv::Op::OpBranch, 0))
+ .IsApplicable(context.get(), transformation_context));
// 21 is not an appropriate argument
- ASSERT_FALSE(
- TransformationFunctionCall(100, 21, {21, 72},
- MakeInstructionDescriptor(59, SpvOpBranch, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationFunctionCall(
+ 100, 21, {21, 72},
+ MakeInstructionDescriptor(59, spv::Op::OpBranch, 0))
+ .IsApplicable(context.get(), transformation_context));
// 300 does not exist
- ASSERT_FALSE(
- TransformationFunctionCall(100, 21, {300, 72},
- MakeInstructionDescriptor(59, SpvOpBranch, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationFunctionCall(
+ 100, 21, {300, 72},
+ MakeInstructionDescriptor(59, spv::Op::OpBranch, 0))
+ .IsApplicable(context.get(), transformation_context));
// 71 is not a function
- ASSERT_FALSE(
- TransformationFunctionCall(100, 71, {71, 72},
- MakeInstructionDescriptor(59, SpvOpBranch, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationFunctionCall(
+ 100, 71, {71, 72},
+ MakeInstructionDescriptor(59, spv::Op::OpBranch, 0))
+ .IsApplicable(context.get(), transformation_context));
// 500 does not exist
- ASSERT_FALSE(
- TransformationFunctionCall(100, 500, {71, 72},
- MakeInstructionDescriptor(59, SpvOpBranch, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationFunctionCall(
+ 100, 500, {71, 72},
+ MakeInstructionDescriptor(59, spv::Op::OpBranch, 0))
+ .IsApplicable(context.get(), transformation_context));
// Id is not fresh
ASSERT_FALSE(
- TransformationFunctionCall(21, 21, {71, 72},
- MakeInstructionDescriptor(59, SpvOpBranch, 0))
+ TransformationFunctionCall(
+ 21, 21, {71, 72}, MakeInstructionDescriptor(59, spv::Op::OpBranch, 0))
.IsApplicable(context.get(), transformation_context));
// Access chain as pointer parameter
- ASSERT_FALSE(
- TransformationFunctionCall(100, 21, {98, 72},
- MakeInstructionDescriptor(59, SpvOpBranch, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationFunctionCall(
+ 100, 21, {98, 72},
+ MakeInstructionDescriptor(59, spv::Op::OpBranch, 0))
+ .IsApplicable(context.get(), transformation_context));
// Copied object as pointer parameter
- ASSERT_FALSE(
- TransformationFunctionCall(100, 21, {99, 72},
- MakeInstructionDescriptor(59, SpvOpBranch, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationFunctionCall(
+ 100, 21, {99, 72},
+ MakeInstructionDescriptor(59, spv::Op::OpBranch, 0))
+ .IsApplicable(context.get(), transformation_context));
// Non-livesafe called from original live block
- ASSERT_FALSE(
- TransformationFunctionCall(
- 100, 10, {71}, MakeInstructionDescriptor(99, SpvOpSelectionMerge, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationFunctionCall(
+ 100, 10, {71},
+ MakeInstructionDescriptor(99, spv::Op::OpSelectionMerge, 0))
+ .IsApplicable(context.get(), transformation_context));
// Non-livesafe called from livesafe function
+ ASSERT_FALSE(TransformationFunctionCall(
+ 100, 10, {19},
+ MakeInstructionDescriptor(38, spv::Op::OpConvertFToS, 0))
+ .IsApplicable(context.get(), transformation_context));
+ // Livesafe function called with pointer to non-arbitrary local variable
+ ASSERT_FALSE(TransformationFunctionCall(
+ 100, 21, {61, 72},
+ MakeInstructionDescriptor(38, spv::Op::OpConvertFToS, 0))
+ .IsApplicable(context.get(), transformation_context));
+ // Direct recursion
ASSERT_FALSE(
TransformationFunctionCall(
- 100, 10, {19}, MakeInstructionDescriptor(38, SpvOpConvertFToS, 0))
+ 100, 4, {}, MakeInstructionDescriptor(59, spv::Op::OpBranch, 0))
.IsApplicable(context.get(), transformation_context));
- // Livesafe function called with pointer to non-arbitrary local variable
+ // Indirect recursion
ASSERT_FALSE(
TransformationFunctionCall(
- 100, 21, {61, 72}, MakeInstructionDescriptor(38, SpvOpConvertFToS, 0))
+ 100, 24, {9}, MakeInstructionDescriptor(96, spv::Op::OpBranch, 0))
.IsApplicable(context.get(), transformation_context));
- // Direct recursion
- ASSERT_FALSE(TransformationFunctionCall(
- 100, 4, {}, MakeInstructionDescriptor(59, SpvOpBranch, 0))
- .IsApplicable(context.get(), transformation_context));
- // Indirect recursion
- ASSERT_FALSE(TransformationFunctionCall(
- 100, 24, {9}, MakeInstructionDescriptor(96, SpvOpBranch, 0))
- .IsApplicable(context.get(), transformation_context));
// Parameter 23 is not available at the call site
ASSERT_FALSE(
- TransformationFunctionCall(104, 10, {23},
- MakeInstructionDescriptor(205, SpvOpBranch, 0))
+ TransformationFunctionCall(
+ 104, 10, {23}, MakeInstructionDescriptor(205, spv::Op::OpBranch, 0))
.IsApplicable(context.get(), transformation_context));
// Good transformations
{
// Livesafe called from dead block: fine
TransformationFunctionCall transformation(
- 100, 21, {71, 72}, MakeInstructionDescriptor(59, SpvOpBranch, 0));
+ 100, 21, {71, 72}, MakeInstructionDescriptor(59, spv::Op::OpBranch, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -266,7 +269,8 @@ TEST(TransformationFunctionCallTest, BasicTest) {
{
// Livesafe called from original live block: fine
TransformationFunctionCall transformation(
- 101, 21, {71, 72}, MakeInstructionDescriptor(98, SpvOpAccessChain, 0));
+ 101, 21, {71, 72},
+ MakeInstructionDescriptor(98, spv::Op::OpAccessChain, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -277,7 +281,7 @@ TEST(TransformationFunctionCallTest, BasicTest) {
{
// Livesafe called from livesafe function: fine
TransformationFunctionCall transformation(
- 102, 200, {19, 20}, MakeInstructionDescriptor(36, SpvOpLoad, 0));
+ 102, 200, {19, 20}, MakeInstructionDescriptor(36, spv::Op::OpLoad, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -288,7 +292,7 @@ TEST(TransformationFunctionCallTest, BasicTest) {
{
// Dead called from dead block in injected function: fine
TransformationFunctionCall transformation(
- 103, 10, {23}, MakeInstructionDescriptor(45, SpvOpLoad, 0));
+ 103, 10, {23}, MakeInstructionDescriptor(45, spv::Op::OpLoad, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -299,7 +303,7 @@ TEST(TransformationFunctionCallTest, BasicTest) {
{
// Non-livesafe called from dead block in livesafe function: OK
TransformationFunctionCall transformation(
- 104, 10, {201}, MakeInstructionDescriptor(205, SpvOpBranch, 0));
+ 104, 10, {201}, MakeInstructionDescriptor(205, spv::Op::OpBranch, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -310,7 +314,7 @@ TEST(TransformationFunctionCallTest, BasicTest) {
{
// Livesafe called from dead block with non-arbitrary parameter
TransformationFunctionCall transformation(
- 105, 21, {62, 65}, MakeInstructionDescriptor(59, SpvOpBranch, 0));
+ 105, 21, {62, 65}, MakeInstructionDescriptor(59, spv::Op::OpBranch, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -465,9 +469,10 @@ TEST(TransformationFunctionCallTest, DoNotInvokeEntryPoint) {
transformation_context.GetFactManager()->AddFactBlockIsDead(11);
// 4 is an entry point, so it is not legal for it to be the target of a call.
- ASSERT_FALSE(TransformationFunctionCall(
- 100, 4, {}, MakeInstructionDescriptor(11, SpvOpReturn, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationFunctionCall(
+ 100, 4, {}, MakeInstructionDescriptor(11, spv::Op::OpReturn, 0))
+ .IsApplicable(context.get(), transformation_context));
}
} // namespace
diff --git a/test/fuzz/transformation_load_test.cpp b/test/fuzz/transformation_load_test.cpp
index 370826eb8..6fde49ab9 100644
--- a/test/fuzz/transformation_load_test.cpp
+++ b/test/fuzz/transformation_load_test.cpp
@@ -131,67 +131,68 @@ TEST(TransformationLoadTest, BasicTest) {
// 60 - null
// Bad: id is not fresh
- ASSERT_FALSE(
- TransformationLoad(33, 33, false, 0, 0,
- MakeInstructionDescriptor(38, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationLoad(
+ 33, 33, false, 0, 0,
+ MakeInstructionDescriptor(38, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: attempt to load from 11 from outside its function
- ASSERT_FALSE(
- TransformationLoad(100, 11, false, 0, 0,
- MakeInstructionDescriptor(38, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationLoad(
+ 100, 11, false, 0, 0,
+ MakeInstructionDescriptor(38, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: pointer is not available
- ASSERT_FALSE(
- TransformationLoad(100, 33, false, 0, 0,
- MakeInstructionDescriptor(45, SpvOpCopyObject, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationLoad(
+ 100, 33, false, 0, 0,
+ MakeInstructionDescriptor(45, spv::Op::OpCopyObject, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: attempt to insert before OpVariable
ASSERT_FALSE(
TransformationLoad(100, 27, false, 0, 0,
- MakeInstructionDescriptor(27, SpvOpVariable, 0))
+ MakeInstructionDescriptor(27, spv::Op::OpVariable, 0))
.IsApplicable(context.get(), transformation_context));
// Bad: pointer id does not exist
- ASSERT_FALSE(
- TransformationLoad(100, 1000, false, 0, 0,
- MakeInstructionDescriptor(38, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationLoad(
+ 100, 1000, false, 0, 0,
+ MakeInstructionDescriptor(38, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: pointer id exists but does not have a type
- ASSERT_FALSE(
- TransformationLoad(100, 5, false, 0, 0,
- MakeInstructionDescriptor(38, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationLoad(
+ 100, 5, false, 0, 0,
+ MakeInstructionDescriptor(38, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: pointer id exists and has a type, but is not a pointer
- ASSERT_FALSE(
- TransformationLoad(100, 24, false, 0, 0,
- MakeInstructionDescriptor(38, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationLoad(
+ 100, 24, false, 0, 0,
+ MakeInstructionDescriptor(38, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: attempt to load from null pointer
- ASSERT_FALSE(
- TransformationLoad(100, 60, false, 0, 0,
- MakeInstructionDescriptor(38, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationLoad(
+ 100, 60, false, 0, 0,
+ MakeInstructionDescriptor(38, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: %40 is not available at the program point
- ASSERT_FALSE(TransformationLoad(100, 40, false, 0, 0,
- MakeInstructionDescriptor(37, SpvOpReturn, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationLoad(100, 40, false, 0, 0,
+ MakeInstructionDescriptor(37, spv::Op::OpReturn, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: The described instruction does not exist
ASSERT_FALSE(
TransformationLoad(100, 33, false, 0, 0,
- MakeInstructionDescriptor(1000, SpvOpReturn, 0))
+ MakeInstructionDescriptor(1000, spv::Op::OpReturn, 0))
.IsApplicable(context.get(), transformation_context));
{
TransformationLoad transformation(
100, 33, false, 0, 0,
- MakeInstructionDescriptor(38, SpvOpAccessChain, 0));
+ MakeInstructionDescriptor(38, spv::Op::OpAccessChain, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -203,7 +204,7 @@ TEST(TransformationLoadTest, BasicTest) {
{
TransformationLoad transformation(
101, 46, false, 0, 0,
- MakeInstructionDescriptor(16, SpvOpReturnValue, 0));
+ MakeInstructionDescriptor(16, spv::Op::OpReturnValue, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -215,7 +216,7 @@ TEST(TransformationLoadTest, BasicTest) {
{
TransformationLoad transformation(
102, 16, false, 0, 0,
- MakeInstructionDescriptor(16, SpvOpReturnValue, 0));
+ MakeInstructionDescriptor(16, spv::Op::OpReturnValue, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -227,7 +228,7 @@ TEST(TransformationLoadTest, BasicTest) {
{
TransformationLoad transformation(
103, 40, false, 0, 0,
- MakeInstructionDescriptor(43, SpvOpAccessChain, 0));
+ MakeInstructionDescriptor(43, spv::Op::OpAccessChain, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -344,80 +345,80 @@ TEST(TransformationLoadTest, AtomicLoadTestCase) {
MakeUnique<FactManager>(context.get()), validator_options);
// Bad: id is not fresh.
- ASSERT_FALSE(
- TransformationLoad(14, 14, true, 15, 20,
- MakeInstructionDescriptor(24, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationLoad(
+ 14, 14, true, 15, 20,
+ MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: id 100 of memory scope instruction does not exist.
- ASSERT_FALSE(
- TransformationLoad(21, 14, true, 100, 20,
- MakeInstructionDescriptor(24, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationLoad(
+ 21, 14, true, 100, 20,
+ MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: id 100 of memory semantics instruction does not exist.
- ASSERT_FALSE(
- TransformationLoad(21, 14, true, 15, 100,
- MakeInstructionDescriptor(24, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationLoad(
+ 21, 14, true, 15, 100,
+ MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: memory scope should be |OpConstant| opcode.
- ASSERT_FALSE(
- TransformationLoad(21, 14, true, 5, 20,
- MakeInstructionDescriptor(24, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationLoad(
+ 21, 14, true, 5, 20,
+ MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: memory semantics should be |OpConstant| opcode.
- ASSERT_FALSE(
- TransformationLoad(21, 14, true, 15, 5,
- MakeInstructionDescriptor(24, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationLoad(
+ 21, 14, true, 15, 5,
+ MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: The memory scope instruction must have an Integer operand.
- ASSERT_FALSE(
- TransformationLoad(21, 14, true, 15, 19,
- MakeInstructionDescriptor(24, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationLoad(
+ 21, 14, true, 15, 19,
+ MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: The memory memory semantics instruction must have an Integer operand.
- ASSERT_FALSE(
- TransformationLoad(21, 14, true, 19, 20,
- MakeInstructionDescriptor(24, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationLoad(
+ 21, 14, true, 19, 20,
+ MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: Integer size of the memory scope must be equal to 32 bits.
- ASSERT_FALSE(
- TransformationLoad(21, 14, true, 17, 20,
- MakeInstructionDescriptor(24, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationLoad(
+ 21, 14, true, 17, 20,
+ MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: Integer size of memory semantics must be equal to 32 bits.
- ASSERT_FALSE(
- TransformationLoad(21, 14, true, 15, 17,
- MakeInstructionDescriptor(24, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationLoad(
+ 21, 14, true, 15, 17,
+ MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
- // Bad: memory scope value must be 4 (SpvScopeInvocation).
- ASSERT_FALSE(
- TransformationLoad(21, 14, true, 16, 20,
- MakeInstructionDescriptor(24, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ // Bad: memory scope value must be 4 (spv::Scope::Invocation).
+ ASSERT_FALSE(TransformationLoad(
+ 21, 14, true, 16, 20,
+ MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: memory semantics value must be either:
// 64 (SpvMemorySemanticsUniformMemoryMask)
// 256 (SpvMemorySemanticsWorkgroupMemoryMask)
- ASSERT_FALSE(
- TransformationLoad(21, 14, true, 15, 16,
- MakeInstructionDescriptor(24, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationLoad(
+ 21, 14, true, 15, 16,
+ MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: The described instruction does not exist
- ASSERT_FALSE(
- TransformationLoad(21, 14, false, 15, 20,
- MakeInstructionDescriptor(150, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationLoad(
+ 21, 14, false, 15, 20,
+ MakeInstructionDescriptor(150, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Successful transformations.
{
TransformationLoad transformation(
21, 14, true, 15, 20,
- MakeInstructionDescriptor(24, SpvOpAccessChain, 0));
+ MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -518,22 +519,22 @@ TEST(TransformationLoadTest, AtomicLoadTestCaseForWorkgroupMemory) {
MakeUnique<FactManager>(context.get()), validator_options);
// Bad: Can't insert OpAccessChain before the id 23 of memory scope.
- ASSERT_FALSE(
- TransformationLoad(60, 38, true, 21, 23,
- MakeInstructionDescriptor(23, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationLoad(
+ 60, 38, true, 21, 23,
+ MakeInstructionDescriptor(23, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: Can't insert OpAccessChain before the id 23 of memory semantics.
- ASSERT_FALSE(
- TransformationLoad(60, 38, true, 21, 23,
- MakeInstructionDescriptor(21, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationLoad(
+ 60, 38, true, 21, 23,
+ MakeInstructionDescriptor(21, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Successful transformations.
{
TransformationLoad transformation(
60, 38, true, 21, 23,
- MakeInstructionDescriptor(40, SpvOpAccessChain, 0));
+ MakeInstructionDescriptor(40, spv::Op::OpAccessChain, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
diff --git a/test/fuzz/transformation_merge_function_returns_test.cpp b/test/fuzz/transformation_merge_function_returns_test.cpp
index 400d49ad0..dd1869f05 100644
--- a/test/fuzz/transformation_merge_function_returns_test.cpp
+++ b/test/fuzz/transformation_merge_function_returns_test.cpp
@@ -1884,7 +1884,7 @@ TEST(TransformationMergeFunctionReturnsTest, OpPhiAfterFirstBlock) {
// Ensure that all input operands of OpBranchConditional instructions have
// the right operand type.
context->module()->ForEachInst([](opt::Instruction* inst) {
- if (inst->opcode() == SpvOpBranchConditional) {
+ if (inst->opcode() == spv::Op::OpBranchConditional) {
ASSERT_EQ(inst->GetInOperand(0).type, SPV_OPERAND_TYPE_ID);
ASSERT_EQ(inst->GetInOperand(1).type, SPV_OPERAND_TYPE_ID);
ASSERT_EQ(inst->GetInOperand(2).type, SPV_OPERAND_TYPE_ID);
diff --git a/test/fuzz/transformation_move_instruction_down_test.cpp b/test/fuzz/transformation_move_instruction_down_test.cpp
index 45dde7da7..5ab1619b2 100644
--- a/test/fuzz/transformation_move_instruction_down_test.cpp
+++ b/test/fuzz/transformation_move_instruction_down_test.cpp
@@ -73,44 +73,45 @@ TEST(TransformationMoveInstructionDownTest, BasicTest) {
MakeUnique<FactManager>(context.get()), validator_options);
// Instruction descriptor is invalid.
ASSERT_FALSE(TransformationMoveInstructionDown(
- MakeInstructionDescriptor(30, SpvOpNop, 0))
+ MakeInstructionDescriptor(30, spv::Op::OpNop, 0))
.IsApplicable(context.get(), transformation_context));
// Opcode is not supported.
ASSERT_FALSE(TransformationMoveInstructionDown(
- MakeInstructionDescriptor(5, SpvOpLabel, 0))
+ MakeInstructionDescriptor(5, spv::Op::OpLabel, 0))
.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(TransformationMoveInstructionDown(
- MakeInstructionDescriptor(12, SpvOpVariable, 0))
+ MakeInstructionDescriptor(12, spv::Op::OpVariable, 0))
.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(TransformationMoveInstructionDown(
- MakeInstructionDescriptor(42, SpvOpFunctionCall, 0))
+ MakeInstructionDescriptor(42, spv::Op::OpFunctionCall, 0))
.IsApplicable(context.get(), transformation_context));
// Can't move the last instruction in the block.
- ASSERT_FALSE(TransformationMoveInstructionDown(
- MakeInstructionDescriptor(15, SpvOpBranchConditional, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationMoveInstructionDown(
+ MakeInstructionDescriptor(15, spv::Op::OpBranchConditional, 0))
+ .IsApplicable(context.get(), transformation_context));
// Can't move the instruction if the next instruction is the last one in the
// block.
ASSERT_FALSE(TransformationMoveInstructionDown(
- MakeInstructionDescriptor(21, SpvOpIAdd, 0))
+ MakeInstructionDescriptor(21, spv::Op::OpIAdd, 0))
.IsApplicable(context.get(), transformation_context));
// Can't insert instruction's opcode after its successor.
ASSERT_FALSE(TransformationMoveInstructionDown(
- MakeInstructionDescriptor(15, SpvOpIMul, 0))
+ MakeInstructionDescriptor(15, spv::Op::OpIMul, 0))
.IsApplicable(context.get(), transformation_context));
// Instruction's successor depends on the instruction.
ASSERT_FALSE(TransformationMoveInstructionDown(
- MakeInstructionDescriptor(10, SpvOpIAdd, 0))
+ MakeInstructionDescriptor(10, spv::Op::OpIAdd, 0))
.IsApplicable(context.get(), transformation_context));
{
TransformationMoveInstructionDown transformation(
- MakeInstructionDescriptor(11, SpvOpISub, 0));
+ MakeInstructionDescriptor(11, spv::Op::OpISub, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -120,7 +121,7 @@ TEST(TransformationMoveInstructionDownTest, BasicTest) {
}
{
TransformationMoveInstructionDown transformation(
- MakeInstructionDescriptor(22, SpvOpIAdd, 0));
+ MakeInstructionDescriptor(22, spv::Op::OpIAdd, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -218,17 +219,17 @@ TEST(TransformationMoveInstructionDownTest, HandlesUnsupportedInstructions) {
MakeUnique<FactManager>(context.get()), validator_options);
// Swap memory instruction with an unsupported one.
ASSERT_FALSE(TransformationMoveInstructionDown(
- MakeInstructionDescriptor(22, SpvOpLoad, 0))
+ MakeInstructionDescriptor(22, spv::Op::OpLoad, 0))
.IsApplicable(context.get(), transformation_context));
// Swap memory barrier with an unsupported one.
ASSERT_FALSE(TransformationMoveInstructionDown(
- MakeInstructionDescriptor(23, SpvOpMemoryBarrier, 0))
+ MakeInstructionDescriptor(23, spv::Op::OpMemoryBarrier, 0))
.IsApplicable(context.get(), transformation_context));
// Swap simple instruction with an unsupported one.
TransformationMoveInstructionDown transformation(
- MakeInstructionDescriptor(8, SpvOpCopyObject, 0));
+ MakeInstructionDescriptor(8, spv::Op::OpCopyObject, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
@@ -322,21 +323,21 @@ TEST(TransformationMoveInstructionDownTest, HandlesBarrierInstructions) {
MakeUnique<FactManager>(context.get()), validator_options);
// Swap two barrier instructions.
ASSERT_FALSE(TransformationMoveInstructionDown(
- MakeInstructionDescriptor(21, SpvOpMemoryBarrier, 0))
+ MakeInstructionDescriptor(21, spv::Op::OpMemoryBarrier, 0))
.IsApplicable(context.get(), transformation_context));
// Swap barrier and memory instructions.
ASSERT_FALSE(TransformationMoveInstructionDown(
- MakeInstructionDescriptor(21, SpvOpMemoryBarrier, 2))
+ MakeInstructionDescriptor(21, spv::Op::OpMemoryBarrier, 2))
.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(TransformationMoveInstructionDown(
- MakeInstructionDescriptor(22, SpvOpLoad, 0))
+ MakeInstructionDescriptor(22, spv::Op::OpLoad, 0))
.IsApplicable(context.get(), transformation_context));
// Swap barrier and simple instructions.
{
TransformationMoveInstructionDown transformation(
- MakeInstructionDescriptor(23, SpvOpCopyObject, 0));
+ MakeInstructionDescriptor(23, spv::Op::OpCopyObject, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -346,7 +347,7 @@ TEST(TransformationMoveInstructionDownTest, HandlesBarrierInstructions) {
}
{
TransformationMoveInstructionDown transformation(
- MakeInstructionDescriptor(22, SpvOpMemoryBarrier, 1));
+ MakeInstructionDescriptor(22, spv::Op::OpMemoryBarrier, 1));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -406,7 +407,7 @@ TEST(TransformationMoveInstructionDownTest, HandlesSimpleInstructions) {
// Swap simple and barrier instructions.
{
TransformationMoveInstructionDown transformation(
- MakeInstructionDescriptor(40, SpvOpCopyObject, 0));
+ MakeInstructionDescriptor(40, spv::Op::OpCopyObject, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -416,7 +417,7 @@ TEST(TransformationMoveInstructionDownTest, HandlesSimpleInstructions) {
}
{
TransformationMoveInstructionDown transformation(
- MakeInstructionDescriptor(21, SpvOpMemoryBarrier, 0));
+ MakeInstructionDescriptor(21, spv::Op::OpMemoryBarrier, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -428,7 +429,7 @@ TEST(TransformationMoveInstructionDownTest, HandlesSimpleInstructions) {
// Swap simple and memory instructions.
{
TransformationMoveInstructionDown transformation(
- MakeInstructionDescriptor(41, SpvOpCopyObject, 0));
+ MakeInstructionDescriptor(41, spv::Op::OpCopyObject, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -438,7 +439,7 @@ TEST(TransformationMoveInstructionDownTest, HandlesSimpleInstructions) {
}
{
TransformationMoveInstructionDown transformation(
- MakeInstructionDescriptor(22, SpvOpLoad, 0));
+ MakeInstructionDescriptor(22, spv::Op::OpLoad, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -450,7 +451,7 @@ TEST(TransformationMoveInstructionDownTest, HandlesSimpleInstructions) {
// Swap two simple instructions.
{
TransformationMoveInstructionDown transformation(
- MakeInstructionDescriptor(23, SpvOpCopyObject, 0));
+ MakeInstructionDescriptor(23, spv::Op::OpCopyObject, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -625,22 +626,22 @@ TEST(TransformationMoveInstructionDownTest, HandlesMemoryInstructions) {
protobufs::InstructionDescriptor invalid_swaps[] = {
// R and RW
- MakeInstructionDescriptor(25, SpvOpLoad, 0),
+ MakeInstructionDescriptor(25, spv::Op::OpLoad, 0),
// R and W
- MakeInstructionDescriptor(29, SpvOpLoad, 0),
+ MakeInstructionDescriptor(29, spv::Op::OpLoad, 0),
// RW and RW
- MakeInstructionDescriptor(32, SpvOpCopyMemory, 0),
- MakeInstructionDescriptor(32, SpvOpCopyMemory, 2),
- MakeInstructionDescriptor(32, SpvOpCopyMemory, 4),
+ MakeInstructionDescriptor(32, spv::Op::OpCopyMemory, 0),
+ MakeInstructionDescriptor(32, spv::Op::OpCopyMemory, 2),
+ MakeInstructionDescriptor(32, spv::Op::OpCopyMemory, 4),
// RW and W
- MakeInstructionDescriptor(32, SpvOpCopyMemory, 12),
- MakeInstructionDescriptor(32, SpvOpStore, 1),
+ MakeInstructionDescriptor(32, spv::Op::OpCopyMemory, 12),
+ MakeInstructionDescriptor(32, spv::Op::OpStore, 1),
// W and W
- MakeInstructionDescriptor(32, SpvOpStore, 6),
+ MakeInstructionDescriptor(32, spv::Op::OpStore, 6),
};
for (const auto& descriptor : invalid_swaps) {
@@ -651,55 +652,55 @@ TEST(TransformationMoveInstructionDownTest, HandlesMemoryInstructions) {
// Valid swaps.
protobufs::InstructionDescriptor valid_swaps[] = {
// R and R
- MakeInstructionDescriptor(23, SpvOpLoad, 0),
- MakeInstructionDescriptor(24, SpvOpLoad, 0),
+ MakeInstructionDescriptor(23, spv::Op::OpLoad, 0),
+ MakeInstructionDescriptor(24, spv::Op::OpLoad, 0),
// R and RW
- MakeInstructionDescriptor(26, SpvOpLoad, 0),
- MakeInstructionDescriptor(25, SpvOpCopyMemory, 1),
+ MakeInstructionDescriptor(26, spv::Op::OpLoad, 0),
+ MakeInstructionDescriptor(25, spv::Op::OpCopyMemory, 1),
- MakeInstructionDescriptor(27, SpvOpLoad, 0),
- MakeInstructionDescriptor(26, SpvOpCopyMemory, 1),
+ MakeInstructionDescriptor(27, spv::Op::OpLoad, 0),
+ MakeInstructionDescriptor(26, spv::Op::OpCopyMemory, 1),
- MakeInstructionDescriptor(28, SpvOpLoad, 0),
- MakeInstructionDescriptor(27, SpvOpCopyMemory, 1),
+ MakeInstructionDescriptor(28, spv::Op::OpLoad, 0),
+ MakeInstructionDescriptor(27, spv::Op::OpCopyMemory, 1),
// R and W
- MakeInstructionDescriptor(30, SpvOpLoad, 0),
- MakeInstructionDescriptor(29, SpvOpStore, 1),
+ MakeInstructionDescriptor(30, spv::Op::OpLoad, 0),
+ MakeInstructionDescriptor(29, spv::Op::OpStore, 1),
- MakeInstructionDescriptor(31, SpvOpLoad, 0),
- MakeInstructionDescriptor(30, SpvOpStore, 1),
+ MakeInstructionDescriptor(31, spv::Op::OpLoad, 0),
+ MakeInstructionDescriptor(30, spv::Op::OpStore, 1),
- MakeInstructionDescriptor(32, SpvOpLoad, 0),
- MakeInstructionDescriptor(31, SpvOpStore, 1),
+ MakeInstructionDescriptor(32, spv::Op::OpLoad, 0),
+ MakeInstructionDescriptor(31, spv::Op::OpStore, 1),
// RW and RW
- MakeInstructionDescriptor(32, SpvOpCopyMemory, 6),
- MakeInstructionDescriptor(32, SpvOpCopyMemory, 6),
+ MakeInstructionDescriptor(32, spv::Op::OpCopyMemory, 6),
+ MakeInstructionDescriptor(32, spv::Op::OpCopyMemory, 6),
- MakeInstructionDescriptor(32, SpvOpCopyMemory, 8),
- MakeInstructionDescriptor(32, SpvOpCopyMemory, 8),
+ MakeInstructionDescriptor(32, spv::Op::OpCopyMemory, 8),
+ MakeInstructionDescriptor(32, spv::Op::OpCopyMemory, 8),
- MakeInstructionDescriptor(32, SpvOpCopyMemory, 10),
- MakeInstructionDescriptor(32, SpvOpCopyMemory, 10),
+ MakeInstructionDescriptor(32, spv::Op::OpCopyMemory, 10),
+ MakeInstructionDescriptor(32, spv::Op::OpCopyMemory, 10),
// RW and W
- MakeInstructionDescriptor(32, SpvOpCopyMemory, 14),
- MakeInstructionDescriptor(32, SpvOpStore, 3),
+ MakeInstructionDescriptor(32, spv::Op::OpCopyMemory, 14),
+ MakeInstructionDescriptor(32, spv::Op::OpStore, 3),
- MakeInstructionDescriptor(32, SpvOpCopyMemory, 15),
- MakeInstructionDescriptor(32, SpvOpStore, 4),
+ MakeInstructionDescriptor(32, spv::Op::OpCopyMemory, 15),
+ MakeInstructionDescriptor(32, spv::Op::OpStore, 4),
- MakeInstructionDescriptor(32, SpvOpCopyMemory, 16),
- MakeInstructionDescriptor(32, SpvOpStore, 5),
+ MakeInstructionDescriptor(32, spv::Op::OpCopyMemory, 16),
+ MakeInstructionDescriptor(32, spv::Op::OpStore, 5),
// W and W
- MakeInstructionDescriptor(32, SpvOpStore, 8),
- MakeInstructionDescriptor(32, SpvOpStore, 8),
+ MakeInstructionDescriptor(32, spv::Op::OpStore, 8),
+ MakeInstructionDescriptor(32, spv::Op::OpStore, 8),
- MakeInstructionDescriptor(32, SpvOpStore, 10),
- MakeInstructionDescriptor(32, SpvOpStore, 10),
+ MakeInstructionDescriptor(32, spv::Op::OpStore, 10),
+ MakeInstructionDescriptor(32, spv::Op::OpStore, 10),
};
for (const auto& descriptor : valid_swaps) {
diff --git a/test/fuzz/transformation_mutate_pointer_test.cpp b/test/fuzz/transformation_mutate_pointer_test.cpp
index e869efa6f..e0cb61541 100644
--- a/test/fuzz/transformation_mutate_pointer_test.cpp
+++ b/test/fuzz/transformation_mutate_pointer_test.cpp
@@ -86,7 +86,8 @@ TEST(TransformationMutatePointerTest, BasicTest) {
transformation_context.GetFactManager()->AddFactIdIsIrrelevant(35);
transformation_context.GetFactManager()->AddFactIdIsIrrelevant(39);
- const auto insert_before = MakeInstructionDescriptor(26, SpvOpReturn, 0);
+ const auto insert_before =
+ MakeInstructionDescriptor(26, spv::Op::OpReturn, 0);
// 20 is not a fresh id.
ASSERT_FALSE(TransformationMutatePointer(20, 20, insert_before)
@@ -94,13 +95,14 @@ TEST(TransformationMutatePointerTest, BasicTest) {
// |insert_before| instruction descriptor is invalid.
ASSERT_FALSE(TransformationMutatePointer(
- 20, 70, MakeInstructionDescriptor(26, SpvOpStore, 0))
+ 20, 70, MakeInstructionDescriptor(26, spv::Op::OpStore, 0))
.IsApplicable(context.get(), transformation_context));
// Can't insert OpLoad before OpVariable.
- ASSERT_FALSE(TransformationMutatePointer(
- 20, 70, MakeInstructionDescriptor(26, SpvOpVariable, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationMutatePointer(
+ 20, 70, MakeInstructionDescriptor(26, spv::Op::OpVariable, 0))
+ .IsApplicable(context.get(), transformation_context));
// |pointer_id| doesn't exist in the module.
ASSERT_FALSE(TransformationMutatePointer(70, 70, insert_before)
@@ -131,9 +133,10 @@ TEST(TransformationMutatePointerTest, BasicTest) {
.IsApplicable(context.get(), transformation_context));
// |pointer_id| is not available before |insert_before|.
- ASSERT_FALSE(TransformationMutatePointer(
- 26, 70, MakeInstructionDescriptor(26, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationMutatePointer(
+ 26, 70, MakeInstructionDescriptor(26, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
transformation_context.GetFactManager()->AddFactIdIsIrrelevant(40);
@@ -274,7 +277,8 @@ TEST(TransformationMutatePointerTest, HandlesUnreachableBlocks) {
ASSERT_FALSE(
context->GetDominatorAnalysis(context->GetFunction(4))->IsReachable(10));
- const auto insert_before = MakeInstructionDescriptor(10, SpvOpReturn, 0);
+ const auto insert_before =
+ MakeInstructionDescriptor(10, spv::Op::OpReturn, 0);
// Can mutate a global variable in an unreachable block.
TransformationMutatePointer transformation(12, 50, insert_before);
diff --git a/test/fuzz/transformation_permute_phi_operands_test.cpp b/test/fuzz/transformation_permute_phi_operands_test.cpp
index 0774dcf3d..320dd1d49 100644
--- a/test/fuzz/transformation_permute_phi_operands_test.cpp
+++ b/test/fuzz/transformation_permute_phi_operands_test.cpp
@@ -128,11 +128,11 @@ TEST(TransformationPermutePhiOperandsTest, BasicTest) {
context->get_def_use_mgr()->ForEachUse(
25, [&found_use_in_store, &found_use_in_add_lhs, &found_use_in_add_rhs](
opt::Instruction* inst, uint32_t operand_index) {
- if (inst->opcode() == SpvOpStore) {
+ if (inst->opcode() == spv::Op::OpStore) {
ASSERT_FALSE(found_use_in_store);
found_use_in_store = true;
} else {
- ASSERT_EQ(SpvOpIAdd, inst->opcode());
+ ASSERT_EQ(spv::Op::OpIAdd, inst->opcode());
if (operand_index == 2) {
ASSERT_FALSE(found_use_in_add_lhs);
found_use_in_add_lhs = true;
diff --git a/test/fuzz/transformation_propagate_instruction_down_test.cpp b/test/fuzz/transformation_propagate_instruction_down_test.cpp
index 52974cacd..8bedef2cc 100644
--- a/test/fuzz/transformation_propagate_instruction_down_test.cpp
+++ b/test/fuzz/transformation_propagate_instruction_down_test.cpp
@@ -499,13 +499,13 @@ TEST(TransformationPropagateInstructionDownTest, VariablePointersCapability) {
TransformationPropagateInstructionDown transformation(
5, 200, {{{15, 203}, {16, 204}}});
ASSERT_FALSE(context->get_feature_mgr()->HasCapability(
- SpvCapabilityVariablePointersStorageBuffer));
+ spv::Capability::VariablePointersStorageBuffer));
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
- context->AddCapability(SpvCapabilityVariablePointers);
+ context->AddCapability(spv::Capability::VariablePointers);
ASSERT_TRUE(context->get_feature_mgr()->HasCapability(
- SpvCapabilityVariablePointersStorageBuffer));
+ spv::Capability::VariablePointersStorageBuffer));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
diff --git a/test/fuzz/transformation_propagate_instruction_up_test.cpp b/test/fuzz/transformation_propagate_instruction_up_test.cpp
index 8a04270f7..20cf4b3e1 100644
--- a/test/fuzz/transformation_propagate_instruction_up_test.cpp
+++ b/test/fuzz/transformation_propagate_instruction_up_test.cpp
@@ -699,7 +699,7 @@ TEST(TransformationPropagateInstructionUpTest,
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
- context->AddCapability(SpvCapabilityVariablePointers);
+ context->AddCapability(spv::Capability::VariablePointers);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
@@ -779,7 +779,7 @@ TEST(TransformationPropagateInstructionUpTest,
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
- context->AddCapability(SpvCapabilityVariablePointersStorageBuffer);
+ context->AddCapability(spv::Capability::VariablePointersStorageBuffer);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
diff --git a/test/fuzz/transformation_push_id_through_variable_test.cpp b/test/fuzz/transformation_push_id_through_variable_test.cpp
index b0fff5887..0d4850d4f 100644
--- a/test/fuzz/transformation_push_id_through_variable_test.cpp
+++ b/test/fuzz/transformation_push_id_through_variable_test.cpp
@@ -110,9 +110,9 @@ TEST(TransformationPushIdThroughVariableTest, IsApplicable) {
uint32_t value_synonym_id = 62;
uint32_t variable_id = 63;
uint32_t initializer_id = 23;
- uint32_t variable_storage_class = SpvStorageClassPrivate;
+ uint32_t variable_storage_class = (uint32_t)spv::StorageClass::Private;
auto instruction_descriptor =
- MakeInstructionDescriptor(95, SpvOpReturnValue, 0);
+ MakeInstructionDescriptor(95, spv::Op::OpReturnValue, 0);
auto transformation = TransformationPushIdThroughVariable(
value_id, value_synonym_id, variable_id, variable_storage_class,
initializer_id, instruction_descriptor);
@@ -124,8 +124,9 @@ TEST(TransformationPushIdThroughVariableTest, IsApplicable) {
value_synonym_id = 60;
variable_id = 61;
initializer_id = 80;
- variable_storage_class = SpvStorageClassFunction;
- instruction_descriptor = MakeInstructionDescriptor(38, SpvOpAccessChain, 0);
+ variable_storage_class = (uint32_t)spv::StorageClass::Function;
+ instruction_descriptor =
+ MakeInstructionDescriptor(38, spv::Op::OpAccessChain, 0);
transformation = TransformationPushIdThroughVariable(
value_id, value_synonym_id, variable_id, variable_storage_class,
initializer_id, instruction_descriptor);
@@ -137,8 +138,9 @@ TEST(TransformationPushIdThroughVariableTest, IsApplicable) {
value_synonym_id = 62;
variable_id = 63;
initializer_id = 80;
- variable_storage_class = SpvStorageClassFunction;
- instruction_descriptor = MakeInstructionDescriptor(64, SpvOpAccessChain, 0);
+ variable_storage_class = (uint32_t)spv::StorageClass::Function;
+ instruction_descriptor =
+ MakeInstructionDescriptor(64, spv::Op::OpAccessChain, 0);
transformation = TransformationPushIdThroughVariable(
value_id, value_synonym_id, variable_id, variable_storage_class,
initializer_id, instruction_descriptor);
@@ -151,8 +153,9 @@ TEST(TransformationPushIdThroughVariableTest, IsApplicable) {
value_synonym_id = 62;
variable_id = 63;
initializer_id = 24;
- variable_storage_class = SpvStorageClassFunction;
- instruction_descriptor = MakeInstructionDescriptor(27, SpvOpVariable, 0);
+ variable_storage_class = (uint32_t)spv::StorageClass::Function;
+ instruction_descriptor =
+ MakeInstructionDescriptor(27, spv::Op::OpVariable, 0);
transformation = TransformationPushIdThroughVariable(
value_id, value_synonym_id, variable_id, variable_storage_class,
initializer_id, instruction_descriptor);
@@ -164,8 +167,9 @@ TEST(TransformationPushIdThroughVariableTest, IsApplicable) {
value_synonym_id = 62;
variable_id = 63;
initializer_id = 80;
- variable_storage_class = SpvStorageClassFunction;
- instruction_descriptor = MakeInstructionDescriptor(100, SpvOpUnreachable, 0);
+ variable_storage_class = (uint32_t)spv::StorageClass::Function;
+ instruction_descriptor =
+ MakeInstructionDescriptor(100, spv::Op::OpUnreachable, 0);
transformation = TransformationPushIdThroughVariable(
value_id, value_synonym_id, variable_id, variable_storage_class,
initializer_id, instruction_descriptor);
@@ -177,8 +181,9 @@ TEST(TransformationPushIdThroughVariableTest, IsApplicable) {
value_synonym_id = 62;
variable_id = 63;
initializer_id = 23;
- variable_storage_class = SpvStorageClassFunction;
- instruction_descriptor = MakeInstructionDescriptor(95, SpvOpReturnValue, 0);
+ variable_storage_class = (uint32_t)spv::StorageClass::Function;
+ instruction_descriptor =
+ MakeInstructionDescriptor(95, spv::Op::OpReturnValue, 0);
transformation = TransformationPushIdThroughVariable(
value_id, value_synonym_id, variable_id, variable_storage_class,
initializer_id, instruction_descriptor);
@@ -190,8 +195,9 @@ TEST(TransformationPushIdThroughVariableTest, IsApplicable) {
value_synonym_id = 62;
variable_id = 63;
initializer_id = 80;
- variable_storage_class = SpvStorageClassPrivate;
- instruction_descriptor = MakeInstructionDescriptor(95, SpvOpReturnValue, 0);
+ variable_storage_class = (uint32_t)spv::StorageClass::Private;
+ instruction_descriptor =
+ MakeInstructionDescriptor(95, spv::Op::OpReturnValue, 0);
transformation = TransformationPushIdThroughVariable(
value_id, value_synonym_id, variable_id, variable_storage_class,
initializer_id, instruction_descriptor);
@@ -203,8 +209,9 @@ TEST(TransformationPushIdThroughVariableTest, IsApplicable) {
value_synonym_id = 62;
variable_id = 63;
initializer_id = 93;
- variable_storage_class = SpvStorageClassInput;
- instruction_descriptor = MakeInstructionDescriptor(95, SpvOpReturnValue, 0);
+ variable_storage_class = (uint32_t)spv::StorageClass::Input;
+ instruction_descriptor =
+ MakeInstructionDescriptor(95, spv::Op::OpReturnValue, 0);
transformation = TransformationPushIdThroughVariable(
value_id, value_synonym_id, variable_id, variable_storage_class,
initializer_id, instruction_descriptor);
@@ -219,8 +226,9 @@ TEST(TransformationPushIdThroughVariableTest, IsApplicable) {
value_synonym_id = 62;
variable_id = 63;
initializer_id = 80;
- variable_storage_class = SpvStorageClassFunction;
- instruction_descriptor = MakeInstructionDescriptor(40, SpvOpAccessChain, 0);
+ variable_storage_class = (uint32_t)spv::StorageClass::Function;
+ instruction_descriptor =
+ MakeInstructionDescriptor(40, spv::Op::OpAccessChain, 0);
transformation = TransformationPushIdThroughVariable(
value_id, value_synonym_id, variable_id, variable_storage_class,
initializer_id, instruction_descriptor);
@@ -232,8 +240,9 @@ TEST(TransformationPushIdThroughVariableTest, IsApplicable) {
value_synonym_id = 62;
variable_id = 63;
initializer_id = 95;
- variable_storage_class = SpvStorageClassFunction;
- instruction_descriptor = MakeInstructionDescriptor(40, SpvOpAccessChain, 0);
+ variable_storage_class = (uint32_t)spv::StorageClass::Function;
+ instruction_descriptor =
+ MakeInstructionDescriptor(40, spv::Op::OpAccessChain, 0);
transformation = TransformationPushIdThroughVariable(
value_id, value_synonym_id, variable_id, variable_storage_class,
initializer_id, instruction_descriptor);
@@ -245,8 +254,9 @@ TEST(TransformationPushIdThroughVariableTest, IsApplicable) {
value_synonym_id = 62;
variable_id = 63;
initializer_id = 93;
- variable_storage_class = SpvStorageClassFunction;
- instruction_descriptor = MakeInstructionDescriptor(40, SpvOpAccessChain, 0);
+ variable_storage_class = (uint32_t)spv::StorageClass::Function;
+ instruction_descriptor =
+ MakeInstructionDescriptor(40, spv::Op::OpAccessChain, 0);
transformation = TransformationPushIdThroughVariable(
value_id, value_synonym_id, variable_id, variable_storage_class,
initializer_id, instruction_descriptor);
@@ -335,9 +345,9 @@ TEST(TransformationPushIdThroughVariableTest, Apply) {
uint32_t value_synonym_id = 100;
uint32_t variable_id = 101;
uint32_t initializer_id = 80;
- uint32_t variable_storage_class = SpvStorageClassFunction;
+ uint32_t variable_storage_class = (uint32_t)spv::StorageClass::Function;
auto instruction_descriptor =
- MakeInstructionDescriptor(38, SpvOpAccessChain, 0);
+ MakeInstructionDescriptor(38, spv::Op::OpAccessChain, 0);
auto transformation = TransformationPushIdThroughVariable(
value_id, value_synonym_id, variable_id, variable_storage_class,
initializer_id, instruction_descriptor);
@@ -346,18 +356,18 @@ TEST(TransformationPushIdThroughVariableTest, Apply) {
ASSERT_EQ(nullptr, context->get_def_use_mgr()->GetDef(variable_id));
ASSERT_EQ(nullptr, context->get_instr_block(variable_id));
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
- ASSERT_EQ(SpvOpLoad,
+ ASSERT_EQ(spv::Op::OpLoad,
context->get_def_use_mgr()->GetDef(value_synonym_id)->opcode());
ASSERT_EQ(36, context->get_instr_block(value_synonym_id)->id());
- ASSERT_EQ(SpvOpVariable,
+ ASSERT_EQ(spv::Op::OpVariable,
context->get_def_use_mgr()->GetDef(variable_id)->opcode());
ASSERT_EQ(5, context->get_instr_block(variable_id)->id());
uint32_t variable_use_count = 0;
context->get_def_use_mgr()->ForEachUse(
variable_id,
[&variable_use_count](opt::Instruction* inst, uint32_t /*unused*/) {
- ASSERT_TRUE(inst->opcode() == SpvOpLoad ||
- inst->opcode() == SpvOpStore);
+ ASSERT_TRUE(inst->opcode() == spv::Op::OpLoad ||
+ inst->opcode() == spv::Op::OpStore);
variable_use_count++;
});
ASSERT_EQ(2, variable_use_count);
@@ -366,8 +376,9 @@ TEST(TransformationPushIdThroughVariableTest, Apply) {
value_synonym_id = 102;
variable_id = 103;
initializer_id = 21;
- variable_storage_class = SpvStorageClassFunction;
- instruction_descriptor = MakeInstructionDescriptor(38, SpvOpAccessChain, 0);
+ variable_storage_class = (uint32_t)spv::StorageClass::Function;
+ instruction_descriptor =
+ MakeInstructionDescriptor(38, spv::Op::OpAccessChain, 0);
transformation = TransformationPushIdThroughVariable(
value_id, value_synonym_id, variable_id, variable_storage_class,
initializer_id, instruction_descriptor);
@@ -377,8 +388,9 @@ TEST(TransformationPushIdThroughVariableTest, Apply) {
value_synonym_id = 104;
variable_id = 105;
initializer_id = 80;
- variable_storage_class = SpvStorageClassFunction;
- instruction_descriptor = MakeInstructionDescriptor(95, SpvOpReturnValue, 0);
+ variable_storage_class = (uint32_t)spv::StorageClass::Function;
+ instruction_descriptor =
+ MakeInstructionDescriptor(95, spv::Op::OpReturnValue, 0);
transformation = TransformationPushIdThroughVariable(
value_id, value_synonym_id, variable_id, variable_storage_class,
initializer_id, instruction_descriptor);
@@ -388,8 +400,9 @@ TEST(TransformationPushIdThroughVariableTest, Apply) {
value_synonym_id = 106;
variable_id = 107;
initializer_id = 80;
- variable_storage_class = SpvStorageClassFunction;
- instruction_descriptor = MakeInstructionDescriptor(95, SpvOpReturnValue, 0);
+ variable_storage_class = (uint32_t)spv::StorageClass::Function;
+ instruction_descriptor =
+ MakeInstructionDescriptor(95, spv::Op::OpReturnValue, 0);
transformation = TransformationPushIdThroughVariable(
value_id, value_synonym_id, variable_id, variable_storage_class,
initializer_id, instruction_descriptor);
@@ -399,8 +412,9 @@ TEST(TransformationPushIdThroughVariableTest, Apply) {
value_synonym_id = 108;
variable_id = 109;
initializer_id = 21;
- variable_storage_class = SpvStorageClassPrivate;
- instruction_descriptor = MakeInstructionDescriptor(95, SpvOpReturnValue, 0);
+ variable_storage_class = (uint32_t)spv::StorageClass::Private;
+ instruction_descriptor =
+ MakeInstructionDescriptor(95, spv::Op::OpReturnValue, 0);
transformation = TransformationPushIdThroughVariable(
value_id, value_synonym_id, variable_id, variable_storage_class,
initializer_id, instruction_descriptor);
@@ -410,8 +424,8 @@ TEST(TransformationPushIdThroughVariableTest, Apply) {
value_synonym_id = 110;
variable_id = 111;
initializer_id = 21;
- variable_storage_class = SpvStorageClassPrivate;
- instruction_descriptor = MakeInstructionDescriptor(27, SpvOpStore, 0);
+ variable_storage_class = (uint32_t)spv::StorageClass::Private;
+ instruction_descriptor = MakeInstructionDescriptor(27, spv::Op::OpStore, 0);
transformation = TransformationPushIdThroughVariable(
value_id, value_synonym_id, variable_id, variable_storage_class,
initializer_id, instruction_descriptor);
@@ -602,9 +616,9 @@ TEST(TransformationPushIdThroughVariableTest, AddSynonymsForRelevantIds) {
uint32_t value_synonym_id = 62;
uint32_t variable_id = 63;
uint32_t initializer_id = 23;
- uint32_t variable_storage_class = SpvStorageClassPrivate;
+ uint32_t variable_storage_class = (uint32_t)spv::StorageClass::Private;
auto instruction_descriptor =
- MakeInstructionDescriptor(95, SpvOpReturnValue, 0);
+ MakeInstructionDescriptor(95, spv::Op::OpReturnValue, 0);
auto transformation = TransformationPushIdThroughVariable(
value_id, value_synonym_id, variable_id, variable_storage_class,
initializer_id, instruction_descriptor);
@@ -705,9 +719,9 @@ TEST(TransformationPushIdThroughVariableTest, DontAddSynonymsForIrrelevantIds) {
uint32_t value_synonym_id = 62;
uint32_t variable_id = 63;
uint32_t initializer_id = 23;
- uint32_t variable_storage_class = SpvStorageClassPrivate;
+ uint32_t variable_storage_class = (uint32_t)spv::StorageClass::Private;
auto instruction_descriptor =
- MakeInstructionDescriptor(95, SpvOpReturnValue, 0);
+ MakeInstructionDescriptor(95, spv::Op::OpReturnValue, 0);
auto transformation = TransformationPushIdThroughVariable(
value_id, value_synonym_id, variable_id, variable_storage_class,
initializer_id, instruction_descriptor);
@@ -766,8 +780,8 @@ TEST(TransformationPushIdThroughVariableTest, DontAddSynonymsInDeadBlocks) {
transformation_context.GetFactManager()->AddFactBlockIsDead(15);
auto transformation = TransformationPushIdThroughVariable(
- 14, 100, 101, SpvStorageClassFunction, 14,
- MakeInstructionDescriptor(15, SpvOpBranch, 0));
+ 14, 100, 101, uint32_t(spv::StorageClass::Function), 14,
+ MakeInstructionDescriptor(15, spv::Op::OpBranch, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
diff --git a/test/fuzz/transformation_replace_boolean_constant_with_constant_binary_test.cpp b/test/fuzz/transformation_replace_boolean_constant_with_constant_binary_test.cpp
index b8c2a8ad4..65cf3d430 100644
--- a/test/fuzz/transformation_replace_boolean_constant_with_constant_binary_test.cpp
+++ b/test/fuzz/transformation_replace_boolean_constant_with_constant_binary_test.cpp
@@ -167,34 +167,38 @@ TEST(TransformationReplaceBooleanConstantWithConstantBinaryTest,
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
std::vector<protobufs::IdUseDescriptor> uses_of_true = {
- MakeIdUseDescriptor(41, MakeInstructionDescriptor(44, SpvOpStore, 12), 1),
- MakeIdUseDescriptor(41, MakeInstructionDescriptor(46, SpvOpLogicalOr, 0),
- 0)};
+ MakeIdUseDescriptor(
+ 41, MakeInstructionDescriptor(44, spv::Op::OpStore, 12), 1),
+ MakeIdUseDescriptor(
+ 41, MakeInstructionDescriptor(46, spv::Op::OpLogicalOr, 0), 0)};
std::vector<protobufs::IdUseDescriptor> uses_of_false = {
- MakeIdUseDescriptor(43, MakeInstructionDescriptor(44, SpvOpStore, 13), 1),
- MakeIdUseDescriptor(43, MakeInstructionDescriptor(48, SpvOpLogicalAnd, 0),
- 1)};
+ MakeIdUseDescriptor(
+ 43, MakeInstructionDescriptor(44, spv::Op::OpStore, 13), 1),
+ MakeIdUseDescriptor(
+ 43, MakeInstructionDescriptor(48, spv::Op::OpLogicalAnd, 0), 1)};
const uint32_t fresh_id = 100;
- std::vector<SpvOp> fp_gt_opcodes = {
- SpvOpFOrdGreaterThan, SpvOpFOrdGreaterThanEqual, SpvOpFUnordGreaterThan,
- SpvOpFUnordGreaterThanEqual};
+ std::vector<spv::Op> fp_gt_opcodes = {
+ spv::Op::OpFOrdGreaterThan, spv::Op::OpFOrdGreaterThanEqual,
+ spv::Op::OpFUnordGreaterThan, spv::Op::OpFUnordGreaterThanEqual};
- std::vector<SpvOp> fp_lt_opcodes = {SpvOpFOrdLessThan, SpvOpFOrdLessThanEqual,
- SpvOpFUnordLessThan,
- SpvOpFUnordLessThanEqual};
+ std::vector<spv::Op> fp_lt_opcodes = {
+ spv::Op::OpFOrdLessThan, spv::Op::OpFOrdLessThanEqual,
+ spv::Op::OpFUnordLessThan, spv::Op::OpFUnordLessThanEqual};
- std::vector<SpvOp> int_gt_opcodes = {SpvOpSGreaterThan,
- SpvOpSGreaterThanEqual};
+ std::vector<spv::Op> int_gt_opcodes = {spv::Op::OpSGreaterThan,
+ spv::Op::OpSGreaterThanEqual};
- std::vector<SpvOp> int_lt_opcodes = {SpvOpSLessThan, SpvOpSLessThanEqual};
+ std::vector<spv::Op> int_lt_opcodes = {spv::Op::OpSLessThan,
+ spv::Op::OpSLessThanEqual};
- std::vector<SpvOp> uint_gt_opcodes = {SpvOpUGreaterThan,
- SpvOpUGreaterThanEqual};
+ std::vector<spv::Op> uint_gt_opcodes = {spv::Op::OpUGreaterThan,
+ spv::Op::OpUGreaterThanEqual};
- std::vector<SpvOp> uint_lt_opcodes = {SpvOpULessThan, SpvOpULessThanEqual};
+ std::vector<spv::Op> uint_lt_opcodes = {spv::Op::OpULessThan,
+ spv::Op::OpULessThanEqual};
#define CHECK_OPERATOR(USE_DESCRIPTOR, LHS_ID, RHS_ID, OPCODE, FRESH_ID) \
ASSERT_TRUE(TransformationReplaceBooleanConstantWithConstantBinary( \
@@ -253,41 +257,41 @@ TEST(TransformationReplaceBooleanConstantWithConstantBinaryTest,
// Target id is not fresh
ASSERT_FALSE(TransformationReplaceBooleanConstantWithConstantBinary(
- uses_of_true[0], 15, 17, SpvOpFOrdLessThan, 15)
+ uses_of_true[0], 15, 17, spv::Op::OpFOrdLessThan, 15)
.IsApplicable(context.get(), transformation_context));
// LHS id does not exist
ASSERT_FALSE(TransformationReplaceBooleanConstantWithConstantBinary(
- uses_of_true[0], 300, 17, SpvOpFOrdLessThan, 200)
+ uses_of_true[0], 300, 17, spv::Op::OpFOrdLessThan, 200)
.IsApplicable(context.get(), transformation_context));
// RHS id does not exist
ASSERT_FALSE(TransformationReplaceBooleanConstantWithConstantBinary(
- uses_of_true[0], 15, 300, SpvOpFOrdLessThan, 200)
+ uses_of_true[0], 15, 300, spv::Op::OpFOrdLessThan, 200)
.IsApplicable(context.get(), transformation_context));
// LHS and RHS ids do not match type
ASSERT_FALSE(TransformationReplaceBooleanConstantWithConstantBinary(
- uses_of_true[0], 11, 17, SpvOpFOrdLessThan, 200)
+ uses_of_true[0], 11, 17, spv::Op::OpFOrdLessThan, 200)
.IsApplicable(context.get(), transformation_context));
// Opcode not appropriate
ASSERT_FALSE(TransformationReplaceBooleanConstantWithConstantBinary(
- uses_of_true[0], 15, 17, SpvOpFDiv, 200)
+ uses_of_true[0], 15, 17, spv::Op::OpFDiv, 200)
.IsApplicable(context.get(), transformation_context));
auto replace_true_with_double_comparison =
TransformationReplaceBooleanConstantWithConstantBinary(
- uses_of_true[0], 11, 9, SpvOpFUnordGreaterThan, 100);
+ uses_of_true[0], 11, 9, spv::Op::OpFUnordGreaterThan, 100);
auto replace_true_with_uint32_comparison =
TransformationReplaceBooleanConstantWithConstantBinary(
- uses_of_true[1], 27, 29, SpvOpULessThanEqual, 101);
+ uses_of_true[1], 27, 29, spv::Op::OpULessThanEqual, 101);
auto replace_false_with_float_comparison =
TransformationReplaceBooleanConstantWithConstantBinary(
- uses_of_false[0], 17, 15, SpvOpFOrdLessThan, 102);
+ uses_of_false[0], 17, 15, spv::Op::OpFOrdLessThan, 102);
auto replace_false_with_sint64_comparison =
TransformationReplaceBooleanConstantWithConstantBinary(
- uses_of_false[1], 33, 31, SpvOpSLessThan, 103);
+ uses_of_false[1], 33, 31, spv::Op::OpSLessThan, 103);
ASSERT_TRUE(replace_true_with_double_comparison.IsApplicable(
context.get(), transformation_context));
@@ -423,13 +427,13 @@ TEST(TransformationReplaceBooleanConstantWithConstantBinaryTest,
{SPV_OPERAND_TYPE_LITERAL_INTEGER, {words[0]}},
{SPV_OPERAND_TYPE_LITERAL_INTEGER, {words[1]}}};
context->module()->AddGlobalValue(MakeUnique<opt::Instruction>(
- context.get(), SpvOpConstant, 6, 200, operands));
+ context.get(), spv::Op::OpConstant, 6, 200, operands));
fuzzerutil::UpdateModuleIdBound(context.get(), 200);
ASSERT_TRUE(fuzzerutil::IsValidAndWellFormed(
context.get(), validator_options, kConsoleMessageConsumer));
// The transformation is not applicable because %200 is NaN.
ASSERT_FALSE(TransformationReplaceBooleanConstantWithConstantBinary(
- uses_of_true[0], 11, 200, SpvOpFOrdLessThan, 300)
+ uses_of_true[0], 11, 200, spv::Op::OpFOrdLessThan, 300)
.IsApplicable(context.get(), transformation_context));
}
if (std::numeric_limits<double>::has_infinity) {
@@ -440,14 +444,14 @@ TEST(TransformationReplaceBooleanConstantWithConstantBinaryTest,
{SPV_OPERAND_TYPE_LITERAL_INTEGER, {words[0]}},
{SPV_OPERAND_TYPE_LITERAL_INTEGER, {words[1]}}};
context->module()->AddGlobalValue(MakeUnique<opt::Instruction>(
- context.get(), SpvOpConstant, 6, 201, operands));
+ context.get(), spv::Op::OpConstant, 6, 201, operands));
fuzzerutil::UpdateModuleIdBound(context.get(), 201);
ASSERT_TRUE(fuzzerutil::IsValidAndWellFormed(
context.get(), validator_options, kConsoleMessageConsumer));
// Even though the double constant %11 is less than the infinity %201, the
// transformation is restricted to only apply to finite values.
ASSERT_FALSE(TransformationReplaceBooleanConstantWithConstantBinary(
- uses_of_true[0], 11, 201, SpvOpFOrdLessThan, 300)
+ uses_of_true[0], 11, 201, spv::Op::OpFOrdLessThan, 300)
.IsApplicable(context.get(), transformation_context));
}
if (std::numeric_limits<float>::has_infinity) {
@@ -459,13 +463,14 @@ TEST(TransformationReplaceBooleanConstantWithConstantBinaryTest,
memcpy(words_negative_infinity, &negative_infinity_float, sizeof(float));
opt::Instruction::OperandList operands_positive_infinity = {
{SPV_OPERAND_TYPE_LITERAL_INTEGER, {words_positive_infinity[0]}}};
- context->module()->AddGlobalValue(MakeUnique<opt::Instruction>(
- context.get(), SpvOpConstant, 12, 202, operands_positive_infinity));
+ context->module()->AddGlobalValue(
+ MakeUnique<opt::Instruction>(context.get(), spv::Op::OpConstant, 12,
+ 202, operands_positive_infinity));
fuzzerutil::UpdateModuleIdBound(context.get(), 202);
opt::Instruction::OperandList operands = {
{SPV_OPERAND_TYPE_LITERAL_INTEGER, {words_negative_infinity[0]}}};
context->module()->AddGlobalValue(MakeUnique<opt::Instruction>(
- context.get(), SpvOpConstant, 12, 203, operands));
+ context.get(), spv::Op::OpConstant, 12, 203, operands));
fuzzerutil::UpdateModuleIdBound(context.get(), 203);
ASSERT_TRUE(fuzzerutil::IsValidAndWellFormed(
context.get(), validator_options, kConsoleMessageConsumer));
@@ -473,7 +478,7 @@ TEST(TransformationReplaceBooleanConstantWithConstantBinaryTest,
// infinity %202, the transformation is restricted to only apply to finite
// values.
ASSERT_FALSE(TransformationReplaceBooleanConstantWithConstantBinary(
- uses_of_true[0], 203, 202, SpvOpFOrdLessThan, 300)
+ uses_of_true[0], 203, 202, spv::Op::OpFOrdLessThan, 300)
.IsApplicable(context.get(), transformation_context));
}
}
@@ -547,14 +552,14 @@ TEST(TransformationReplaceBooleanConstantWithConstantBinaryTest,
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
auto use_of_true_in_if = MakeIdUseDescriptor(
- 13, MakeInstructionDescriptor(10, SpvOpBranchConditional, 0), 0);
+ 13, MakeInstructionDescriptor(10, spv::Op::OpBranchConditional, 0), 0);
auto use_of_false_in_while = MakeIdUseDescriptor(
- 21, MakeInstructionDescriptor(16, SpvOpBranchConditional, 0), 0);
+ 21, MakeInstructionDescriptor(16, spv::Op::OpBranchConditional, 0), 0);
auto replacement_1 = TransformationReplaceBooleanConstantWithConstantBinary(
- use_of_true_in_if, 9, 11, SpvOpSLessThan, 100);
+ use_of_true_in_if, 9, 11, spv::Op::OpSLessThan, 100);
auto replacement_2 = TransformationReplaceBooleanConstantWithConstantBinary(
- use_of_false_in_while, 9, 11, SpvOpSGreaterThanEqual, 101);
+ use_of_false_in_while, 9, 11, spv::Op::OpSGreaterThanEqual, 101);
ASSERT_TRUE(
replacement_1.IsApplicable(context.get(), transformation_context));
@@ -662,10 +667,11 @@ TEST(TransformationReplaceBooleanConstantWithConstantBinaryTest, OpPhi) {
kConsoleMessageConsumer));
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
- auto instruction_descriptor = MakeInstructionDescriptor(14, SpvOpPhi, 0);
+ auto instruction_descriptor =
+ MakeInstructionDescriptor(14, spv::Op::OpPhi, 0);
auto id_use_descriptor = MakeIdUseDescriptor(8, instruction_descriptor, 0);
auto transformation = TransformationReplaceBooleanConstantWithConstantBinary(
- id_use_descriptor, 6, 7, SpvOpULessThan, 15);
+ id_use_descriptor, 6, 7, spv::Op::OpULessThan, 15);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
@@ -740,11 +746,12 @@ TEST(TransformationReplaceBooleanConstantWithConstantBinaryTest,
kConsoleMessageConsumer));
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
- ASSERT_FALSE(TransformationReplaceBooleanConstantWithConstantBinary(
- MakeIdUseDescriptor(
- 9, MakeInstructionDescriptor(50, SpvOpVariable, 0), 1),
- 13, 15, SpvOpSLessThan, 100)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationReplaceBooleanConstantWithConstantBinary(
+ MakeIdUseDescriptor(
+ 9, MakeInstructionDescriptor(50, spv::Op::OpVariable, 0), 1),
+ 13, 15, spv::Op::OpSLessThan, 100)
+ .IsApplicable(context.get(), transformation_context));
}
} // namespace
diff --git a/test/fuzz/transformation_replace_branch_from_dead_block_with_exit_test.cpp b/test/fuzz/transformation_replace_branch_from_dead_block_with_exit_test.cpp
index 6bba14f63..012e3172a 100644
--- a/test/fuzz/transformation_replace_branch_from_dead_block_with_exit_test.cpp
+++ b/test/fuzz/transformation_replace_branch_from_dead_block_with_exit_test.cpp
@@ -79,35 +79,37 @@ TEST(TransformationReplaceBranchFromDeadBlockWithExitTest, BasicTest) {
transformation_context.GetFactManager()->AddFactBlockIsDead(20);
// Bad: 4 is not a block
- ASSERT_FALSE(TransformationReplaceBranchFromDeadBlockWithExit(4, SpvOpKill, 0)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationReplaceBranchFromDeadBlockWithExit(4, spv::Op::OpKill, 0)
+ .IsApplicable(context.get(), transformation_context));
// Bad: 200 does not exist
ASSERT_FALSE(
- TransformationReplaceBranchFromDeadBlockWithExit(200, SpvOpKill, 0)
+ TransformationReplaceBranchFromDeadBlockWithExit(200, spv::Op::OpKill, 0)
.IsApplicable(context.get(), transformation_context));
// Bad: 21 is not a dead block
ASSERT_FALSE(
- TransformationReplaceBranchFromDeadBlockWithExit(21, SpvOpKill, 0)
+ TransformationReplaceBranchFromDeadBlockWithExit(21, spv::Op::OpKill, 0)
.IsApplicable(context.get(), transformation_context));
// Bad: terminator of 8 is not OpBranch
- ASSERT_FALSE(TransformationReplaceBranchFromDeadBlockWithExit(8, SpvOpKill, 0)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationReplaceBranchFromDeadBlockWithExit(8, spv::Op::OpKill, 0)
+ .IsApplicable(context.get(), transformation_context));
// Bad: 10's successor only has 10 as a predecessor
ASSERT_FALSE(
- TransformationReplaceBranchFromDeadBlockWithExit(10, SpvOpKill, 0)
+ TransformationReplaceBranchFromDeadBlockWithExit(10, spv::Op::OpKill, 0)
.IsApplicable(context.get(), transformation_context));
#ifndef NDEBUG
ASSERT_DEATH(
- TransformationReplaceBranchFromDeadBlockWithExit(20, SpvOpSwitch, 0)
+ TransformationReplaceBranchFromDeadBlockWithExit(20, spv::Op::OpSwitch, 0)
.IsApplicable(context.get(), transformation_context),
"Invalid early exit opcode.");
#endif
auto transformation1 =
- TransformationReplaceBranchFromDeadBlockWithExit(20, SpvOpKill, 0);
+ TransformationReplaceBranchFromDeadBlockWithExit(20, spv::Op::OpKill, 0);
auto transformation2 =
- TransformationReplaceBranchFromDeadBlockWithExit(16, SpvOpKill, 0);
+ TransformationReplaceBranchFromDeadBlockWithExit(16, spv::Op::OpKill, 0);
ASSERT_TRUE(
transformation1.IsApplicable(context.get(), transformation_context));
ASSERT_TRUE(
@@ -281,48 +283,48 @@ TEST(TransformationReplaceBranchFromDeadBlockWithExitTest,
// Bad: OpKill not allowed in vertex shader
ASSERT_FALSE(
- TransformationReplaceBranchFromDeadBlockWithExit(201, SpvOpKill, 0)
+ TransformationReplaceBranchFromDeadBlockWithExit(201, spv::Op::OpKill, 0)
.IsApplicable(context.get(), transformation_context));
// Bad: OpReturn is not allowed in function that expects a returned value.
- ASSERT_FALSE(
- TransformationReplaceBranchFromDeadBlockWithExit(200, SpvOpReturn, 0)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationReplaceBranchFromDeadBlockWithExit(
+ 200, spv::Op::OpReturn, 0)
+ .IsApplicable(context.get(), transformation_context));
// Bad: Return value id does not exist
ASSERT_FALSE(TransformationReplaceBranchFromDeadBlockWithExit(
- 201, SpvOpReturnValue, 1000)
+ 201, spv::Op::OpReturnValue, 1000)
.IsApplicable(context.get(), transformation_context));
// Bad: Return value id does not have a type
- ASSERT_FALSE(
- TransformationReplaceBranchFromDeadBlockWithExit(200, SpvOpReturnValue, 6)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationReplaceBranchFromDeadBlockWithExit(
+ 200, spv::Op::OpReturnValue, 6)
+ .IsApplicable(context.get(), transformation_context));
// Bad: Return value id does not have the right type
ASSERT_FALSE(TransformationReplaceBranchFromDeadBlockWithExit(
- 201, SpvOpReturnValue, 48)
+ 201, spv::Op::OpReturnValue, 48)
.IsApplicable(context.get(), transformation_context));
// Bad: Return value id is not available
ASSERT_FALSE(TransformationReplaceBranchFromDeadBlockWithExit(
- 200, SpvOpReturnValue, 400)
+ 200, spv::Op::OpReturnValue, 400)
.IsApplicable(context.get(), transformation_context));
// Bad: Early exit now allowed in continue construct
- ASSERT_FALSE(
- TransformationReplaceBranchFromDeadBlockWithExit(101, SpvOpUnreachable, 0)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationReplaceBranchFromDeadBlockWithExit(
+ 101, spv::Op::OpUnreachable, 0)
+ .IsApplicable(context.get(), transformation_context));
// Bad: Early exit now allowed in continue construct (again)
ASSERT_FALSE(TransformationReplaceBranchFromDeadBlockWithExit(
- 300, SpvOpReturnValue, 14)
+ 300, spv::Op::OpReturnValue, 14)
.IsApplicable(context.get(), transformation_context));
auto transformation1 = TransformationReplaceBranchFromDeadBlockWithExit(
- 200, SpvOpUnreachable, 0);
+ 200, spv::Op::OpUnreachable, 0);
auto transformation2 = TransformationReplaceBranchFromDeadBlockWithExit(
- 201, SpvOpReturnValue, 400);
+ 201, spv::Op::OpReturnValue, 400);
ASSERT_TRUE(
transformation1.IsApplicable(context.get(), transformation_context));
@@ -339,7 +341,7 @@ TEST(TransformationReplaceBranchFromDeadBlockWithExitTest,
opt::Instruction* return_value_inst =
context->get_instr_block(201)->terminator();
- ASSERT_EQ(SpvOpReturnValue, return_value_inst->opcode());
+ ASSERT_EQ(spv::Op::OpReturnValue, return_value_inst->opcode());
ASSERT_EQ(SPV_OPERAND_TYPE_ID, return_value_inst->GetInOperand(0).type);
ASSERT_EQ(400, return_value_inst->GetSingleWordInOperand(0));
@@ -504,9 +506,9 @@ TEST(TransformationReplaceBranchFromDeadBlockWithExitTest, OpPhi) {
transformation_context.GetFactManager()->AddFactBlockIsDead(20);
auto transformation1 =
- TransformationReplaceBranchFromDeadBlockWithExit(20, SpvOpKill, 0);
+ TransformationReplaceBranchFromDeadBlockWithExit(20, spv::Op::OpKill, 0);
auto transformation2 =
- TransformationReplaceBranchFromDeadBlockWithExit(16, SpvOpKill, 0);
+ TransformationReplaceBranchFromDeadBlockWithExit(16, spv::Op::OpKill, 0);
ASSERT_TRUE(
transformation1.IsApplicable(context.get(), transformation_context));
ASSERT_TRUE(
@@ -609,9 +611,9 @@ TEST(TransformationReplaceBranchFromDeadBlockWithExitTest,
transformation_context.GetFactManager()->AddFactBlockIsDead(9);
transformation_context.GetFactManager()->AddFactBlockIsDead(11);
- ASSERT_FALSE(
- TransformationReplaceBranchFromDeadBlockWithExit(11, SpvOpUnreachable, 0)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationReplaceBranchFromDeadBlockWithExit(
+ 11, spv::Op::OpUnreachable, 0)
+ .IsApplicable(context.get(), transformation_context));
}
TEST(TransformationReplaceBranchFromDeadBlockWithExitTest,
@@ -658,7 +660,7 @@ TEST(TransformationReplaceBranchFromDeadBlockWithExitTest,
transformation_context.GetFactManager()->AddFactBlockIsDead(11);
TransformationReplaceBranchFromDeadBlockWithExit transformation(
- 11, SpvOpUnreachable, 0);
+ 11, spv::Op::OpUnreachable, 0);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
transformation.Apply(context.get(), &transformation_context);
@@ -741,7 +743,7 @@ TEST(TransformationReplaceBranchFromDeadBlockWithExitTest,
transformation_context.GetFactManager()->AddFactBlockIsDead(13);
TransformationReplaceBranchFromDeadBlockWithExit transformation(
- 13, SpvOpUnreachable, 0);
+ 13, spv::Op::OpUnreachable, 0);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
transformation.Apply(context.get(), &transformation_context);
@@ -823,7 +825,7 @@ TEST(TransformationReplaceBranchFromDeadBlockWithExitTest,
transformation_context.GetFactManager()->AddFactBlockIsDead(10);
TransformationReplaceBranchFromDeadBlockWithExit transformation(
- 10, SpvOpUnreachable, 0);
+ 10, spv::Op::OpUnreachable, 0);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
transformation.Apply(context.get(), &transformation_context);
diff --git a/test/fuzz/transformation_replace_constant_with_uniform_test.cpp b/test/fuzz/transformation_replace_constant_with_uniform_test.cpp
index fe760680a..7c6d12639 100644
--- a/test/fuzz/transformation_replace_constant_with_uniform_test.cpp
+++ b/test/fuzz/transformation_replace_constant_with_uniform_test.cpp
@@ -121,12 +121,12 @@ TEST(TransformationReplaceConstantWithUniformTest, BasicReplacements) {
ASSERT_TRUE(AddFactHelper(&transformation_context, 3, blockname_c));
// The constant ids are 9, 11 and 14, for 1, 2 and 3 respectively.
- protobufs::IdUseDescriptor use_of_9_in_store =
- MakeIdUseDescriptor(9, MakeInstructionDescriptor(8, SpvOpStore, 0), 1);
- protobufs::IdUseDescriptor use_of_11_in_add =
- MakeIdUseDescriptor(11, MakeInstructionDescriptor(12, SpvOpIAdd, 0), 1);
- protobufs::IdUseDescriptor use_of_14_in_add =
- MakeIdUseDescriptor(14, MakeInstructionDescriptor(15, SpvOpIAdd, 0), 0);
+ protobufs::IdUseDescriptor use_of_9_in_store = MakeIdUseDescriptor(
+ 9, MakeInstructionDescriptor(8, spv::Op::OpStore, 0), 1);
+ protobufs::IdUseDescriptor use_of_11_in_add = MakeIdUseDescriptor(
+ 11, MakeInstructionDescriptor(12, spv::Op::OpIAdd, 0), 1);
+ protobufs::IdUseDescriptor use_of_14_in_add = MakeIdUseDescriptor(
+ 14, MakeInstructionDescriptor(15, spv::Op::OpIAdd, 0), 0);
// These transformations work: they match the facts.
auto transformation_use_of_9_in_store =
@@ -172,8 +172,8 @@ TEST(TransformationReplaceConstantWithUniformTest, BasicReplacements) {
// The following transformation does not apply because the id descriptor is
// not sensible.
- protobufs::IdUseDescriptor nonsense_id_use_descriptor =
- MakeIdUseDescriptor(9, MakeInstructionDescriptor(15, SpvOpIAdd, 0), 0);
+ protobufs::IdUseDescriptor nonsense_id_use_descriptor = MakeIdUseDescriptor(
+ 9, MakeInstructionDescriptor(15, spv::Op::OpIAdd, 0), 0);
ASSERT_FALSE(TransformationReplaceConstantWithUniform(
nonsense_id_use_descriptor, blockname_a, 101, 102)
.IsApplicable(context.get(), transformation_context));
@@ -490,14 +490,14 @@ TEST(TransformationReplaceConstantWithUniformTest, NestedStruct) {
ASSERT_TRUE(AddFactHelper(&transformation_context, 4, blockname_4));
// The constant ids are 13, 15, 17 and 20, for 1, 2, 3 and 4 respectively.
- protobufs::IdUseDescriptor use_of_13_in_store =
- MakeIdUseDescriptor(13, MakeInstructionDescriptor(21, SpvOpStore, 0), 1);
- protobufs::IdUseDescriptor use_of_15_in_add =
- MakeIdUseDescriptor(15, MakeInstructionDescriptor(16, SpvOpIAdd, 0), 1);
- protobufs::IdUseDescriptor use_of_17_in_add =
- MakeIdUseDescriptor(17, MakeInstructionDescriptor(19, SpvOpIAdd, 0), 0);
- protobufs::IdUseDescriptor use_of_20_in_store =
- MakeIdUseDescriptor(20, MakeInstructionDescriptor(19, SpvOpStore, 1), 1);
+ protobufs::IdUseDescriptor use_of_13_in_store = MakeIdUseDescriptor(
+ 13, MakeInstructionDescriptor(21, spv::Op::OpStore, 0), 1);
+ protobufs::IdUseDescriptor use_of_15_in_add = MakeIdUseDescriptor(
+ 15, MakeInstructionDescriptor(16, spv::Op::OpIAdd, 0), 1);
+ protobufs::IdUseDescriptor use_of_17_in_add = MakeIdUseDescriptor(
+ 17, MakeInstructionDescriptor(19, spv::Op::OpIAdd, 0), 0);
+ protobufs::IdUseDescriptor use_of_20_in_store = MakeIdUseDescriptor(
+ 20, MakeInstructionDescriptor(19, spv::Op::OpStore, 1), 1);
// These transformations work: they match the facts.
auto transformation_use_of_13_in_store =
@@ -726,8 +726,8 @@ TEST(TransformationReplaceConstantWithUniformTest, NoUniformIntPointerPresent) {
ASSERT_TRUE(AddFactHelper(&transformation_context, 0, blockname_0));
// The constant id is 9 for 0.
- protobufs::IdUseDescriptor use_of_9_in_store =
- MakeIdUseDescriptor(9, MakeInstructionDescriptor(8, SpvOpStore, 0), 1);
+ protobufs::IdUseDescriptor use_of_9_in_store = MakeIdUseDescriptor(
+ 9, MakeInstructionDescriptor(8, spv::Op::OpStore, 0), 1);
// This transformation is not available because no uniform pointer to integer
// type is present:
@@ -803,8 +803,8 @@ TEST(TransformationReplaceConstantWithUniformTest, NoConstantPresentForIndex) {
ASSERT_TRUE(AddFactHelper(&transformation_context, 9, blockname_9));
// The constant id is 9 for 9.
- protobufs::IdUseDescriptor use_of_9_in_store =
- MakeIdUseDescriptor(9, MakeInstructionDescriptor(8, SpvOpStore, 0), 1);
+ protobufs::IdUseDescriptor use_of_9_in_store = MakeIdUseDescriptor(
+ 9, MakeInstructionDescriptor(8, spv::Op::OpStore, 0), 1);
// This transformation is not available because no constant is present for the
// index 1 required to index into the uniform buffer:
@@ -879,8 +879,8 @@ TEST(TransformationReplaceConstantWithUniformTest,
AddFactHelper(&transformation_context, float_data[0], blockname_3));
// The constant id is 9 for 3.0.
- protobufs::IdUseDescriptor use_of_9_in_store =
- MakeIdUseDescriptor(9, MakeInstructionDescriptor(8, SpvOpStore, 0), 1);
+ protobufs::IdUseDescriptor use_of_9_in_store = MakeIdUseDescriptor(
+ 9, MakeInstructionDescriptor(8, spv::Op::OpStore, 0), 1);
// This transformation is not available because no integer type is present to
// allow a constant index to be expressed:
@@ -966,10 +966,10 @@ TEST(TransformationReplaceConstantWithUniformTest,
ASSERT_TRUE(AddFactHelper(&transformation_context, 10, blockname_10));
// The constant ids for 9 and 10 are 9 and 11 respectively
- protobufs::IdUseDescriptor use_of_9_in_store =
- MakeIdUseDescriptor(9, MakeInstructionDescriptor(10, SpvOpStore, 0), 1);
- protobufs::IdUseDescriptor use_of_11_in_store =
- MakeIdUseDescriptor(11, MakeInstructionDescriptor(10, SpvOpStore, 1), 1);
+ protobufs::IdUseDescriptor use_of_9_in_store = MakeIdUseDescriptor(
+ 9, MakeInstructionDescriptor(10, spv::Op::OpStore, 0), 1);
+ protobufs::IdUseDescriptor use_of_11_in_store = MakeIdUseDescriptor(
+ 11, MakeInstructionDescriptor(10, spv::Op::OpStore, 1), 1);
// These are right:
ASSERT_TRUE(TransformationReplaceConstantWithUniform(use_of_9_in_store,
@@ -1251,57 +1251,73 @@ TEST(TransformationReplaceConstantWithUniformTest, ComplexReplacements) {
std::vector<TransformationReplaceConstantWithUniform> transformations;
transformations.emplace_back(TransformationReplaceConstantWithUniform(
- MakeIdUseDescriptor(18, MakeInstructionDescriptor(20, SpvOpStore, 0), 1),
+ MakeIdUseDescriptor(
+ 18, MakeInstructionDescriptor(20, spv::Op::OpStore, 0), 1),
uniform_f_a_4, 200, 201));
transformations.emplace_back(TransformationReplaceConstantWithUniform(
- MakeIdUseDescriptor(22, MakeInstructionDescriptor(23, SpvOpStore, 0), 1),
+ MakeIdUseDescriptor(
+ 22, MakeInstructionDescriptor(23, spv::Op::OpStore, 0), 1),
uniform_f_a_3, 202, 203));
transformations.emplace_back(TransformationReplaceConstantWithUniform(
- MakeIdUseDescriptor(25, MakeInstructionDescriptor(26, SpvOpStore, 0), 1),
+ MakeIdUseDescriptor(
+ 25, MakeInstructionDescriptor(26, spv::Op::OpStore, 0), 1),
uniform_f_a_2, 204, 205));
transformations.emplace_back(TransformationReplaceConstantWithUniform(
- MakeIdUseDescriptor(28, MakeInstructionDescriptor(29, SpvOpStore, 0), 1),
+ MakeIdUseDescriptor(
+ 28, MakeInstructionDescriptor(29, spv::Op::OpStore, 0), 1),
uniform_f_a_1, 206, 207));
transformations.emplace_back(TransformationReplaceConstantWithUniform(
- MakeIdUseDescriptor(31, MakeInstructionDescriptor(32, SpvOpStore, 0), 1),
+ MakeIdUseDescriptor(
+ 31, MakeInstructionDescriptor(32, spv::Op::OpStore, 0), 1),
uniform_f_a_0, 208, 209));
transformations.emplace_back(TransformationReplaceConstantWithUniform(
- MakeIdUseDescriptor(30, MakeInstructionDescriptor(35, SpvOpStore, 0), 1),
+ MakeIdUseDescriptor(
+ 30, MakeInstructionDescriptor(35, spv::Op::OpStore, 0), 1),
uniform_f_b_w, 210, 211));
transformations.emplace_back(TransformationReplaceConstantWithUniform(
- MakeIdUseDescriptor(27, MakeInstructionDescriptor(37, SpvOpStore, 0), 1),
+ MakeIdUseDescriptor(
+ 27, MakeInstructionDescriptor(37, spv::Op::OpStore, 0), 1),
uniform_f_b_z, 212, 213));
transformations.emplace_back(TransformationReplaceConstantWithUniform(
- MakeIdUseDescriptor(24, MakeInstructionDescriptor(39, SpvOpStore, 0), 1),
+ MakeIdUseDescriptor(
+ 24, MakeInstructionDescriptor(39, spv::Op::OpStore, 0), 1),
uniform_f_b_y, 214, 215));
transformations.emplace_back(TransformationReplaceConstantWithUniform(
- MakeIdUseDescriptor(21, MakeInstructionDescriptor(41, SpvOpStore, 0), 1),
+ MakeIdUseDescriptor(
+ 21, MakeInstructionDescriptor(41, spv::Op::OpStore, 0), 1),
uniform_f_b_x, 216, 217));
transformations.emplace_back(TransformationReplaceConstantWithUniform(
- MakeIdUseDescriptor(44, MakeInstructionDescriptor(45, SpvOpStore, 0), 1),
+ MakeIdUseDescriptor(
+ 44, MakeInstructionDescriptor(45, spv::Op::OpStore, 0), 1),
uniform_f_c_z, 220, 221));
transformations.emplace_back(TransformationReplaceConstantWithUniform(
- MakeIdUseDescriptor(46, MakeInstructionDescriptor(47, SpvOpStore, 0), 1),
+ MakeIdUseDescriptor(
+ 46, MakeInstructionDescriptor(47, spv::Op::OpStore, 0), 1),
uniform_f_c_y, 222, 223));
transformations.emplace_back(TransformationReplaceConstantWithUniform(
- MakeIdUseDescriptor(48, MakeInstructionDescriptor(49, SpvOpStore, 0), 1),
+ MakeIdUseDescriptor(
+ 48, MakeInstructionDescriptor(49, spv::Op::OpStore, 0), 1),
uniform_f_c_x, 224, 225));
transformations.emplace_back(TransformationReplaceConstantWithUniform(
- MakeIdUseDescriptor(50, MakeInstructionDescriptor(52, SpvOpStore, 0), 1),
+ MakeIdUseDescriptor(
+ 50, MakeInstructionDescriptor(52, spv::Op::OpStore, 0), 1),
uniform_f_d, 226, 227));
transformations.emplace_back(TransformationReplaceConstantWithUniform(
- MakeIdUseDescriptor(53, MakeInstructionDescriptor(54, SpvOpStore, 0), 1),
+ MakeIdUseDescriptor(
+ 53, MakeInstructionDescriptor(54, spv::Op::OpStore, 0), 1),
uniform_h_x, 228, 229));
transformations.emplace_back(TransformationReplaceConstantWithUniform(
- MakeIdUseDescriptor(55, MakeInstructionDescriptor(56, SpvOpStore, 0), 1),
+ MakeIdUseDescriptor(
+ 55, MakeInstructionDescriptor(56, spv::Op::OpStore, 0), 1),
uniform_h_y, 230, 231));
transformations.emplace_back(TransformationReplaceConstantWithUniform(
- MakeIdUseDescriptor(42, MakeInstructionDescriptor(43, SpvOpStore, 0), 1),
+ MakeIdUseDescriptor(
+ 42, MakeInstructionDescriptor(43, spv::Op::OpStore, 0), 1),
uniform_g, 218, 219));
for (auto& transformation : transformations) {
@@ -1520,11 +1536,12 @@ TEST(TransformationReplaceConstantWithUniformTest,
ASSERT_TRUE(AddFactHelper(&transformation_context, 0, blockname_a));
- ASSERT_FALSE(TransformationReplaceConstantWithUniform(
- MakeIdUseDescriptor(
- 50, MakeInstructionDescriptor(8, SpvOpVariable, 0), 1),
- blockname_a, 100, 101)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationReplaceConstantWithUniform(
+ MakeIdUseDescriptor(
+ 50, MakeInstructionDescriptor(8, spv::Op::OpVariable, 0), 1),
+ blockname_a, 100, 101)
+ .IsApplicable(context.get(), transformation_context));
}
TEST(TransformationReplaceConstantWithUniformTest, ReplaceOpPhiOperand) {
@@ -1579,7 +1596,8 @@ TEST(TransformationReplaceConstantWithUniformTest, ReplaceOpPhiOperand) {
{
TransformationReplaceConstantWithUniform transformation(
- MakeIdUseDescriptor(7, MakeInstructionDescriptor(23, SpvOpPhi, 0), 0),
+ MakeIdUseDescriptor(7, MakeInstructionDescriptor(23, spv::Op::OpPhi, 0),
+ 0),
int_descriptor, 50, 51);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
diff --git a/test/fuzz/transformation_replace_copy_memory_with_load_store_test.cpp b/test/fuzz/transformation_replace_copy_memory_with_load_store_test.cpp
index bcd04afa8..689cf1932 100644
--- a/test/fuzz/transformation_replace_copy_memory_with_load_store_test.cpp
+++ b/test/fuzz/transformation_replace_copy_memory_with_load_store_test.cpp
@@ -75,11 +75,11 @@ TEST(TransformationReplaceCopyMemoryWithLoadStoreTest, BasicScenarios) {
kConsoleMessageConsumer));
auto instruction_descriptor_invalid_1 =
- MakeInstructionDescriptor(5, SpvOpStore, 0);
+ MakeInstructionDescriptor(5, spv::Op::OpStore, 0);
auto instruction_descriptor_valid_1 =
- MakeInstructionDescriptor(5, SpvOpCopyMemory, 0);
+ MakeInstructionDescriptor(5, spv::Op::OpCopyMemory, 0);
auto instruction_descriptor_valid_2 =
- MakeInstructionDescriptor(5, SpvOpCopyMemory, 0);
+ MakeInstructionDescriptor(5, spv::Op::OpCopyMemory, 0);
// Invalid: |source_id| is not a fresh id.
auto transformation_invalid_1 = TransformationReplaceCopyMemoryWithLoadStore(
diff --git a/test/fuzz/transformation_replace_copy_object_with_store_load_test.cpp b/test/fuzz/transformation_replace_copy_object_with_store_load_test.cpp
index fa8c068ee..368e20861 100644
--- a/test/fuzz/transformation_replace_copy_object_with_store_load_test.cpp
+++ b/test/fuzz/transformation_replace_copy_object_with_store_load_test.cpp
@@ -88,44 +88,45 @@ TEST(TransformationReplaceCopyObjectWithStoreLoad, BasicScenarios) {
// Invalid: fresh_variable_id=10 is not fresh.
auto transformation_invalid_1 = TransformationReplaceCopyObjectWithStoreLoad(
- 27, 10, SpvStorageClassFunction, 9);
+ 27, 10, (uint32_t)spv::StorageClass::Function, 9);
ASSERT_FALSE(transformation_invalid_1.IsApplicable(context.get(),
transformation_context));
// Invalid: copy_object_result_id=26 is not a CopyObject instruction.
auto transformation_invalid_2 = TransformationReplaceCopyObjectWithStoreLoad(
- 26, 30, SpvStorageClassFunction, 9);
+ 26, 30, (uint32_t)spv::StorageClass::Function, 9);
ASSERT_FALSE(transformation_invalid_2.IsApplicable(context.get(),
transformation_context));
// Invalid: copy_object_result_id=40 is of type pointer.
auto transformation_invalid_3 = TransformationReplaceCopyObjectWithStoreLoad(
- 40, 30, SpvStorageClassFunction, 9);
+ 40, 30, (uint32_t)spv::StorageClass::Function, 9);
ASSERT_FALSE(transformation_invalid_3.IsApplicable(context.get(),
transformation_context));
// Invalid: Pointer type instruction in this storage class pointing to the
// value type is not defined.
auto transformation_invalid_4 = TransformationReplaceCopyObjectWithStoreLoad(
- 40, 30, SpvStorageClassPrivate, 9);
+ 40, 30, (uint32_t)spv::StorageClass::Private, 9);
ASSERT_FALSE(transformation_invalid_4.IsApplicable(context.get(),
transformation_context));
// Invalid: initializer_id=15 has the wrong type relative to the OpCopyObject
// instruction.
auto transformation_invalid_5 = TransformationReplaceCopyObjectWithStoreLoad(
- 27, 30, SpvStorageClassFunction, 15);
+ 27, 30, (uint32_t)spv::StorageClass::Function, 15);
ASSERT_FALSE(transformation_invalid_5.IsApplicable(context.get(),
transformation_context));
- // Invalid: SpvStorageClassUniform is not applicable to the transformation.
+ // Invalid: spv::StorageClass::Uniform is not applicable to the
+ // transformation.
auto transformation_invalid_6 = TransformationReplaceCopyObjectWithStoreLoad(
- 27, 30, SpvStorageClassUniform, 9);
+ 27, 30, (uint32_t)spv::StorageClass::Uniform, 9);
ASSERT_FALSE(transformation_invalid_6.IsApplicable(context.get(),
transformation_context));
auto transformation_valid_1 = TransformationReplaceCopyObjectWithStoreLoad(
- 27, 30, SpvStorageClassFunction, 9);
+ 27, 30, (uint32_t)spv::StorageClass::Function, 9);
ASSERT_TRUE(transformation_valid_1.IsApplicable(context.get(),
transformation_context));
ApplyAndCheckFreshIds(transformation_valid_1, context.get(),
@@ -134,7 +135,7 @@ TEST(TransformationReplaceCopyObjectWithStoreLoad, BasicScenarios) {
kConsoleMessageConsumer));
auto transformation_valid_2 = TransformationReplaceCopyObjectWithStoreLoad(
- 28, 32, SpvStorageClassPrivate, 15);
+ 28, 32, (uint32_t)spv::StorageClass::Private, 15);
ASSERT_TRUE(transformation_valid_2.IsApplicable(context.get(),
transformation_context));
ApplyAndCheckFreshIds(transformation_valid_2, context.get(),
@@ -244,7 +245,7 @@ TEST(TransformationReplaceCopyObjectWithStoreLoad, IrrelevantIdsAndDeadBlocks) {
transformation_context.GetFactManager()->AddFactIdIsIrrelevant(11);
auto transformation_1 = TransformationReplaceCopyObjectWithStoreLoad(
- 50, 100, SpvStorageClassFunction, 10);
+ 50, 100, (uint32_t)spv::StorageClass::Function, 10);
ASSERT_TRUE(
transformation_1.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation_1, context.get(),
@@ -253,7 +254,7 @@ TEST(TransformationReplaceCopyObjectWithStoreLoad, IrrelevantIdsAndDeadBlocks) {
MakeDataDescriptor(100, {}), MakeDataDescriptor(50, {})));
auto transformation_2 = TransformationReplaceCopyObjectWithStoreLoad(
- 51, 101, SpvStorageClassFunction, 10);
+ 51, 101, (uint32_t)spv::StorageClass::Function, 10);
ASSERT_TRUE(
transformation_2.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation_2, context.get(),
diff --git a/test/fuzz/transformation_replace_id_with_synonym_test.cpp b/test/fuzz/transformation_replace_id_with_synonym_test.cpp
index b33dd48ca..bd27c2996 100644
--- a/test/fuzz/transformation_replace_id_with_synonym_test.cpp
+++ b/test/fuzz/transformation_replace_id_with_synonym_test.cpp
@@ -230,7 +230,8 @@ TEST(TransformationReplaceIdWithSynonymTest, IllegalTransformations) {
// %202 cannot replace %15 as in-operand 0 of %300, since %202 does not
// dominate %300.
auto synonym_does_not_dominate_use = TransformationReplaceIdWithSynonym(
- MakeIdUseDescriptor(15, MakeInstructionDescriptor(300, SpvOpIAdd, 0), 0),
+ MakeIdUseDescriptor(
+ 15, MakeInstructionDescriptor(300, spv::Op::OpIAdd, 0), 0),
202);
ASSERT_FALSE(synonym_does_not_dominate_use.IsApplicable(
context.get(), transformation_context));
@@ -239,8 +240,8 @@ TEST(TransformationReplaceIdWithSynonymTest, IllegalTransformations) {
// incoming value for block %72, and %202 does not dominate %72.
auto synonym_does_not_dominate_use_op_phi =
TransformationReplaceIdWithSynonym(
- MakeIdUseDescriptor(15, MakeInstructionDescriptor(301, SpvOpPhi, 0),
- 2),
+ MakeIdUseDescriptor(
+ 15, MakeInstructionDescriptor(301, spv::Op::OpPhi, 0), 2),
202);
ASSERT_FALSE(synonym_does_not_dominate_use_op_phi.IsApplicable(
context.get(), transformation_context));
@@ -248,14 +249,15 @@ TEST(TransformationReplaceIdWithSynonymTest, IllegalTransformations) {
// %200 is not a synonym for %84
auto id_in_use_is_not_synonymous = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 84, MakeInstructionDescriptor(67, SpvOpSGreaterThan, 0), 0),
+ 84, MakeInstructionDescriptor(67, spv::Op::OpSGreaterThan, 0), 0),
200);
ASSERT_FALSE(id_in_use_is_not_synonymous.IsApplicable(
context.get(), transformation_context));
// %86 is not a synonym for anything (and in particular not for %74)
auto id_has_no_synonyms = TransformationReplaceIdWithSynonym(
- MakeIdUseDescriptor(86, MakeInstructionDescriptor(84, SpvOpPhi, 0), 2),
+ MakeIdUseDescriptor(86, MakeInstructionDescriptor(84, spv::Op::OpPhi, 0),
+ 2),
74);
ASSERT_FALSE(
id_has_no_synonyms.IsApplicable(context.get(), transformation_context));
@@ -264,7 +266,7 @@ TEST(TransformationReplaceIdWithSynonymTest, IllegalTransformations) {
auto synonym_use_is_in_synonym_definition =
TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 84, MakeInstructionDescriptor(207, SpvOpCopyObject, 0), 0),
+ 84, MakeInstructionDescriptor(207, spv::Op::OpCopyObject, 0), 0),
207);
ASSERT_FALSE(synonym_use_is_in_synonym_definition.IsApplicable(
context.get(), transformation_context));
@@ -273,7 +275,7 @@ TEST(TransformationReplaceIdWithSynonymTest, IllegalTransformations) {
// definition of %207)
auto bad_id_use_descriptor = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 84, MakeInstructionDescriptor(200, SpvOpCopyObject, 0), 0),
+ 84, MakeInstructionDescriptor(200, spv::Op::OpCopyObject, 0), 0),
207);
ASSERT_FALSE(bad_id_use_descriptor.IsApplicable(context.get(),
transformation_context));
@@ -282,7 +284,7 @@ TEST(TransformationReplaceIdWithSynonymTest, IllegalTransformations) {
// non-constant index.
auto bad_access_chain = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 12, MakeInstructionDescriptor(14, SpvOpAccessChain, 0), 1),
+ 12, MakeInstructionDescriptor(14, spv::Op::OpAccessChain, 0), 1),
209);
ASSERT_FALSE(
bad_access_chain.IsApplicable(context.get(), transformation_context));
@@ -301,7 +303,8 @@ TEST(TransformationReplaceIdWithSynonymTest, LegalTransformations) {
SetUpIdSynonyms(transformation_context.GetFactManager());
auto global_constant_synonym = TransformationReplaceIdWithSynonym(
- MakeIdUseDescriptor(19, MakeInstructionDescriptor(47, SpvOpStore, 0), 1),
+ MakeIdUseDescriptor(
+ 19, MakeInstructionDescriptor(47, spv::Op::OpStore, 0), 1),
210);
uint32_t num_uses_of_original_id_before_replacement =
context->get_def_use_mgr()->NumUses(19);
@@ -320,7 +323,7 @@ TEST(TransformationReplaceIdWithSynonymTest, LegalTransformations) {
auto replace_vector_access_chain_index = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 54, MakeInstructionDescriptor(55, SpvOpAccessChain, 0), 1),
+ 54, MakeInstructionDescriptor(55, spv::Op::OpAccessChain, 0), 1),
204);
ASSERT_TRUE(replace_vector_access_chain_index.IsApplicable(
context.get(), transformation_context));
@@ -333,7 +336,7 @@ TEST(TransformationReplaceIdWithSynonymTest, LegalTransformations) {
// copied with something that is already a synonym.
auto regular_replacement = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 15, MakeInstructionDescriptor(202, SpvOpCopyObject, 0), 0),
+ 15, MakeInstructionDescriptor(202, spv::Op::OpCopyObject, 0), 0),
201);
ASSERT_TRUE(
regular_replacement.IsApplicable(context.get(), transformation_context));
@@ -343,7 +346,8 @@ TEST(TransformationReplaceIdWithSynonymTest, LegalTransformations) {
kConsoleMessageConsumer));
auto regular_replacement2 = TransformationReplaceIdWithSynonym(
- MakeIdUseDescriptor(55, MakeInstructionDescriptor(203, SpvOpStore, 0), 0),
+ MakeIdUseDescriptor(
+ 55, MakeInstructionDescriptor(203, spv::Op::OpStore, 0), 0),
203);
ASSERT_TRUE(
regular_replacement2.IsApplicable(context.get(), transformation_context));
@@ -353,7 +357,8 @@ TEST(TransformationReplaceIdWithSynonymTest, LegalTransformations) {
kConsoleMessageConsumer));
auto good_op_phi = TransformationReplaceIdWithSynonym(
- MakeIdUseDescriptor(74, MakeInstructionDescriptor(86, SpvOpPhi, 0), 2),
+ MakeIdUseDescriptor(74, MakeInstructionDescriptor(86, spv::Op::OpPhi, 0),
+ 2),
205);
ASSERT_TRUE(good_op_phi.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(good_op_phi, context.get(), &transformation_context);
@@ -543,7 +548,8 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfVariables) {
// Replace %10 with %100 in:
// %11 = OpLoad %6 %10
auto replacement1 = TransformationReplaceIdWithSynonym(
- MakeIdUseDescriptor(10, MakeInstructionDescriptor(11, SpvOpLoad, 0), 0),
+ MakeIdUseDescriptor(10, MakeInstructionDescriptor(11, spv::Op::OpLoad, 0),
+ 0),
100);
ASSERT_TRUE(replacement1.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(replacement1, context.get(), &transformation_context);
@@ -553,7 +559,8 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfVariables) {
// Replace %8 with %101 in:
// OpStore %8 %11
auto replacement2 = TransformationReplaceIdWithSynonym(
- MakeIdUseDescriptor(8, MakeInstructionDescriptor(11, SpvOpStore, 0), 0),
+ MakeIdUseDescriptor(8, MakeInstructionDescriptor(11, spv::Op::OpStore, 0),
+ 0),
101);
ASSERT_TRUE(replacement2.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(replacement2, context.get(), &transformation_context);
@@ -563,7 +570,8 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfVariables) {
// Replace %8 with %101 in:
// %12 = OpLoad %6 %8
auto replacement3 = TransformationReplaceIdWithSynonym(
- MakeIdUseDescriptor(8, MakeInstructionDescriptor(12, SpvOpLoad, 0), 0),
+ MakeIdUseDescriptor(8, MakeInstructionDescriptor(12, spv::Op::OpLoad, 0),
+ 0),
101);
ASSERT_TRUE(replacement3.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(replacement3, context.get(), &transformation_context);
@@ -573,7 +581,8 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfVariables) {
// Replace %10 with %100 in:
// OpStore %10 %12
auto replacement4 = TransformationReplaceIdWithSynonym(
- MakeIdUseDescriptor(10, MakeInstructionDescriptor(12, SpvOpStore, 0), 0),
+ MakeIdUseDescriptor(
+ 10, MakeInstructionDescriptor(12, spv::Op::OpStore, 0), 0),
100);
ASSERT_TRUE(replacement4.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(replacement4, context.get(), &transformation_context);
@@ -678,7 +687,7 @@ TEST(TransformationReplaceIdWithSynonymTest,
// %16 = OpFunctionCall %2 %10 %14
auto replacement = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 14, MakeInstructionDescriptor(16, SpvOpFunctionCall, 0), 1),
+ 14, MakeInstructionDescriptor(16, spv::Op::OpFunctionCall, 0), 1),
100);
ASSERT_FALSE(replacement.IsApplicable(context.get(), transformation_context));
}
@@ -871,7 +880,7 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfAccessChainIndices) {
// The index %16 used for a cannot be replaced
auto replacement1 = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 16, MakeInstructionDescriptor(20, SpvOpAccessChain, 0), 1),
+ 16, MakeInstructionDescriptor(20, spv::Op::OpAccessChain, 0), 1),
100);
ASSERT_FALSE(
replacement1.IsApplicable(context.get(), transformation_context));
@@ -881,7 +890,7 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfAccessChainIndices) {
// The index %16 used for f cannot be replaced
auto replacement2 = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 16, MakeInstructionDescriptor(39, SpvOpAccessChain, 0), 1),
+ 16, MakeInstructionDescriptor(39, spv::Op::OpAccessChain, 0), 1),
100);
ASSERT_FALSE(
replacement2.IsApplicable(context.get(), transformation_context));
@@ -891,7 +900,7 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfAccessChainIndices) {
// The index %16 used for a cannot be replaced
auto replacement3 = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 16, MakeInstructionDescriptor(41, SpvOpAccessChain, 0), 2),
+ 16, MakeInstructionDescriptor(41, spv::Op::OpAccessChain, 0), 2),
100);
ASSERT_FALSE(
replacement3.IsApplicable(context.get(), transformation_context));
@@ -901,7 +910,7 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfAccessChainIndices) {
// The index %16 used for 0 *can* be replaced
auto replacement4 = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 16, MakeInstructionDescriptor(52, SpvOpAccessChain, 0), 1),
+ 16, MakeInstructionDescriptor(52, spv::Op::OpAccessChain, 0), 1),
100);
ASSERT_TRUE(replacement4.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(replacement4, context.get(), &transformation_context);
@@ -913,7 +922,7 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfAccessChainIndices) {
// The index %16 used for f cannot be replaced
auto replacement5 = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 16, MakeInstructionDescriptor(52, SpvOpAccessChain, 0), 2),
+ 16, MakeInstructionDescriptor(52, spv::Op::OpAccessChain, 0), 2),
100);
ASSERT_FALSE(
replacement5.IsApplicable(context.get(), transformation_context));
@@ -923,7 +932,7 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfAccessChainIndices) {
// The index %16 used for a cannot be replaced
auto replacement6 = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 16, MakeInstructionDescriptor(53, SpvOpAccessChain, 0), 3),
+ 16, MakeInstructionDescriptor(53, spv::Op::OpAccessChain, 0), 3),
100);
ASSERT_FALSE(
replacement6.IsApplicable(context.get(), transformation_context));
@@ -933,7 +942,7 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfAccessChainIndices) {
// The index %16 used for 0 *can* be replaced
auto replacement7 = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 16, MakeInstructionDescriptor(53, SpvOpAccessChain, 0), 4),
+ 16, MakeInstructionDescriptor(53, spv::Op::OpAccessChain, 0), 4),
100);
ASSERT_TRUE(replacement7.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(replacement7, context.get(), &transformation_context);
@@ -947,7 +956,7 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfAccessChainIndices) {
// The index %24 used for b cannot be replaced
auto replacement8 = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 21, MakeInstructionDescriptor(24, SpvOpAccessChain, 0), 1),
+ 21, MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0), 1),
101);
ASSERT_FALSE(
replacement8.IsApplicable(context.get(), transformation_context));
@@ -957,7 +966,7 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfAccessChainIndices) {
// The index %24 used for g cannot be replaced
auto replacement9 = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 21, MakeInstructionDescriptor(41, SpvOpAccessChain, 0), 1),
+ 21, MakeInstructionDescriptor(41, spv::Op::OpAccessChain, 0), 1),
101);
ASSERT_FALSE(
replacement9.IsApplicable(context.get(), transformation_context));
@@ -967,7 +976,7 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfAccessChainIndices) {
// The index %24 used for 1 *can* be replaced
auto replacement10 = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 21, MakeInstructionDescriptor(41, SpvOpAccessChain, 0), 3),
+ 21, MakeInstructionDescriptor(41, spv::Op::OpAccessChain, 0), 3),
101);
ASSERT_TRUE(
replacement10.IsApplicable(context.get(), transformation_context));
@@ -980,7 +989,7 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfAccessChainIndices) {
// The index %24 used for g cannot be replaced
auto replacement11 = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 21, MakeInstructionDescriptor(44, SpvOpAccessChain, 0), 1),
+ 21, MakeInstructionDescriptor(44, spv::Op::OpAccessChain, 0), 1),
101);
ASSERT_FALSE(
replacement11.IsApplicable(context.get(), transformation_context));
@@ -990,7 +999,7 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfAccessChainIndices) {
// The index %24 used for b cannot be replaced
auto replacement12 = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 21, MakeInstructionDescriptor(44, SpvOpAccessChain, 0), 2),
+ 21, MakeInstructionDescriptor(44, spv::Op::OpAccessChain, 0), 2),
101);
ASSERT_FALSE(
replacement12.IsApplicable(context.get(), transformation_context));
@@ -1000,7 +1009,7 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfAccessChainIndices) {
// The index %24 used for g cannot be replaced
auto replacement13 = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 21, MakeInstructionDescriptor(46, SpvOpAccessChain, 0), 1),
+ 21, MakeInstructionDescriptor(46, spv::Op::OpAccessChain, 0), 1),
101);
ASSERT_FALSE(
replacement13.IsApplicable(context.get(), transformation_context));
@@ -1010,7 +1019,7 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfAccessChainIndices) {
// The index %24 used for 1 *can* be replaced
auto replacement14 = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 21, MakeInstructionDescriptor(53, SpvOpAccessChain, 0), 1),
+ 21, MakeInstructionDescriptor(53, spv::Op::OpAccessChain, 0), 1),
101);
ASSERT_TRUE(
replacement14.IsApplicable(context.get(), transformation_context));
@@ -1023,7 +1032,7 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfAccessChainIndices) {
// The index %24 used for g cannot be replaced
auto replacement15 = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 21, MakeInstructionDescriptor(53, SpvOpAccessChain, 0), 2),
+ 21, MakeInstructionDescriptor(53, spv::Op::OpAccessChain, 0), 2),
101);
ASSERT_FALSE(
replacement15.IsApplicable(context.get(), transformation_context));
@@ -1033,7 +1042,7 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfAccessChainIndices) {
// The index %24 used for g cannot be replaced
auto replacement16 = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 21, MakeInstructionDescriptor(56, SpvOpAccessChain, 0), 2),
+ 21, MakeInstructionDescriptor(56, spv::Op::OpAccessChain, 0), 2),
101);
ASSERT_FALSE(
replacement16.IsApplicable(context.get(), transformation_context));
@@ -1043,7 +1052,7 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfAccessChainIndices) {
// The index %24 used for b cannot be replaced
auto replacement17 = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 21, MakeInstructionDescriptor(56, SpvOpAccessChain, 0), 3),
+ 21, MakeInstructionDescriptor(56, spv::Op::OpAccessChain, 0), 3),
101);
ASSERT_FALSE(
replacement17.IsApplicable(context.get(), transformation_context));
@@ -1053,7 +1062,8 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfAccessChainIndices) {
// The index %24 used for g cannot be replaced
auto replacement18 = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 21, MakeInstructionDescriptor(58, SpvOpInBoundsAccessChain, 0), 2),
+ 21, MakeInstructionDescriptor(58, spv::Op::OpInBoundsAccessChain, 0),
+ 2),
101);
ASSERT_FALSE(
replacement18.IsApplicable(context.get(), transformation_context));
@@ -1065,7 +1075,7 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfAccessChainIndices) {
// The index %17 used for 2 *can* be replaced
auto replacement19 = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 17, MakeInstructionDescriptor(20, SpvOpAccessChain, 0), 2),
+ 17, MakeInstructionDescriptor(20, spv::Op::OpAccessChain, 0), 2),
102);
ASSERT_TRUE(
replacement19.IsApplicable(context.get(), transformation_context));
@@ -1078,7 +1088,7 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfAccessChainIndices) {
// The index %17 used for c cannot be replaced
auto replacement20 = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 17, MakeInstructionDescriptor(27, SpvOpAccessChain, 0), 1),
+ 17, MakeInstructionDescriptor(27, spv::Op::OpAccessChain, 0), 1),
102);
ASSERT_FALSE(
replacement20.IsApplicable(context.get(), transformation_context));
@@ -1088,7 +1098,7 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfAccessChainIndices) {
// The index %17 used for c cannot be replaced
auto replacement21 = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 17, MakeInstructionDescriptor(46, SpvOpAccessChain, 0), 2),
+ 17, MakeInstructionDescriptor(46, spv::Op::OpAccessChain, 0), 2),
102);
ASSERT_FALSE(
replacement21.IsApplicable(context.get(), transformation_context));
@@ -1098,7 +1108,7 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfAccessChainIndices) {
// The index %17 used for 2 *can* be replaced
auto replacement22 = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 17, MakeInstructionDescriptor(56, SpvOpAccessChain, 0), 1),
+ 17, MakeInstructionDescriptor(56, spv::Op::OpAccessChain, 0), 1),
102);
ASSERT_TRUE(
replacement22.IsApplicable(context.get(), transformation_context));
@@ -1111,7 +1121,8 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfAccessChainIndices) {
// The index %17 used for c cannot be replaced
auto replacement23 = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 17, MakeInstructionDescriptor(58, SpvOpInBoundsAccessChain, 0), 3),
+ 17, MakeInstructionDescriptor(58, spv::Op::OpInBoundsAccessChain, 0),
+ 3),
102);
ASSERT_FALSE(
replacement23.IsApplicable(context.get(), transformation_context));
@@ -1123,7 +1134,8 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfAccessChainIndices) {
// The index %57 used for 3 *can* be replaced
auto replacement24 = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 57, MakeInstructionDescriptor(58, SpvOpInBoundsAccessChain, 0), 1),
+ 57, MakeInstructionDescriptor(58, spv::Op::OpInBoundsAccessChain, 0),
+ 1),
103);
ASSERT_TRUE(
replacement24.IsApplicable(context.get(), transformation_context));
@@ -1138,7 +1150,7 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfAccessChainIndices) {
// The index %32 used for 17 *can* be replaced
auto replacement25 = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 32, MakeInstructionDescriptor(34, SpvOpAccessChain, 0), 1),
+ 32, MakeInstructionDescriptor(34, spv::Op::OpAccessChain, 0), 1),
106);
ASSERT_TRUE(
replacement25.IsApplicable(context.get(), transformation_context));
@@ -1153,7 +1165,7 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfAccessChainIndices) {
// The index %43 used for 0 *can* be replaced
auto replacement26 = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 43, MakeInstructionDescriptor(44, SpvOpAccessChain, 0), 3),
+ 43, MakeInstructionDescriptor(44, spv::Op::OpAccessChain, 0), 3),
107);
ASSERT_TRUE(
replacement26.IsApplicable(context.get(), transformation_context));
@@ -1168,7 +1180,7 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfAccessChainIndices) {
// The index %55 used for 1 *can* be replaced
auto replacement27 = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 55, MakeInstructionDescriptor(56, SpvOpAccessChain, 0), 4),
+ 55, MakeInstructionDescriptor(56, spv::Op::OpAccessChain, 0), 4),
108);
ASSERT_TRUE(
replacement27.IsApplicable(context.get(), transformation_context));
@@ -1182,8 +1194,8 @@ TEST(TransformationReplaceIdWithSynonymTest, SynonymsOfAccessChainIndices) {
// Corresponds to d.b[*3*]
// The index %8 used for 3 *can* be replaced
auto replacement28 = TransformationReplaceIdWithSynonym(
- MakeIdUseDescriptor(8, MakeInstructionDescriptor(24, SpvOpAccessChain, 0),
- 2),
+ MakeIdUseDescriptor(
+ 8, MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0), 2),
109);
ASSERT_TRUE(
replacement28.IsApplicable(context.get(), transformation_context));
@@ -1356,14 +1368,14 @@ TEST(TransformationReplaceIdWithSynonymTest, RuntimeArrayTest) {
ASSERT_FALSE(
TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 12, MakeInstructionDescriptor(16, SpvOpAccessChain, 0), 1),
+ 12, MakeInstructionDescriptor(16, spv::Op::OpAccessChain, 0), 1),
50)
.IsApplicable(context.get(), transformation_context));
// Fine to replace an index into a runtime array.
auto replacement1 = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 12, MakeInstructionDescriptor(16, SpvOpAccessChain, 0), 2),
+ 12, MakeInstructionDescriptor(16, spv::Op::OpAccessChain, 0), 2),
50);
ASSERT_TRUE(replacement1.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(replacement1, context.get(), &transformation_context);
@@ -1371,7 +1383,7 @@ TEST(TransformationReplaceIdWithSynonymTest, RuntimeArrayTest) {
// Fine to replace an index into a vector inside the runtime array.
auto replacement2 = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 14, MakeInstructionDescriptor(16, SpvOpAccessChain, 0), 3),
+ 14, MakeInstructionDescriptor(16, spv::Op::OpAccessChain, 0), 3),
51);
ASSERT_TRUE(replacement2.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(replacement2, context.get(), &transformation_context);
@@ -1466,7 +1478,8 @@ TEST(TransformationReplaceIdWithSynonymTest,
ASSERT_FALSE(
TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 9, MakeInstructionDescriptor(20, SpvOpImageTexelPointer, 0), 2),
+ 9, MakeInstructionDescriptor(20, spv::Op::OpImageTexelPointer, 0),
+ 2),
100)
.IsApplicable(context.get(), transformation_context));
}
@@ -1524,56 +1537,61 @@ TEST(TransformationReplaceIdWithSynonymTest, EquivalentIntegerConstants) {
// Legal because OpSNegate always considers the integer as signed
auto replacement1 = TransformationReplaceIdWithSynonym(
- MakeIdUseDescriptor(10, MakeInstructionDescriptor(15, SpvOpSNegate, 0),
- 0),
+ MakeIdUseDescriptor(
+ 10, MakeInstructionDescriptor(15, spv::Op::OpSNegate, 0), 0),
13);
ASSERT_TRUE(replacement1.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(replacement1, context.get(), &transformation_context);
// Legal because OpIAdd does not care about the signedness of the operands
auto replacement2 = TransformationReplaceIdWithSynonym(
- MakeIdUseDescriptor(10, MakeInstructionDescriptor(16, SpvOpIAdd, 0), 0),
+ MakeIdUseDescriptor(10, MakeInstructionDescriptor(16, spv::Op::OpIAdd, 0),
+ 0),
13);
ASSERT_TRUE(replacement2.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(replacement2, context.get(), &transformation_context);
// Legal because OpSDiv does not care about the signedness of the operands
auto replacement3 = TransformationReplaceIdWithSynonym(
- MakeIdUseDescriptor(10, MakeInstructionDescriptor(17, SpvOpSDiv, 0), 0),
+ MakeIdUseDescriptor(10, MakeInstructionDescriptor(17, spv::Op::OpSDiv, 0),
+ 0),
13);
ASSERT_TRUE(replacement3.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(replacement3, context.get(), &transformation_context);
// Not legal because OpUDiv requires unsigned integers
- ASSERT_FALSE(TransformationReplaceIdWithSynonym(
- MakeIdUseDescriptor(
- 13, MakeInstructionDescriptor(18, SpvOpUDiv, 0), 0),
- 10)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationReplaceIdWithSynonym(
+ MakeIdUseDescriptor(
+ 13, MakeInstructionDescriptor(18, spv::Op::OpUDiv, 0), 0),
+ 10)
+ .IsApplicable(context.get(), transformation_context));
// Legal because OpSDiv does not care about the signedness of the operands
auto replacement4 = TransformationReplaceIdWithSynonym(
- MakeIdUseDescriptor(10, MakeInstructionDescriptor(19, SpvOpBitwiseAnd, 0),
- 0),
+ MakeIdUseDescriptor(
+ 10, MakeInstructionDescriptor(19, spv::Op::OpBitwiseAnd, 0), 0),
13);
ASSERT_TRUE(replacement4.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(replacement4, context.get(), &transformation_context);
// Not legal because OpSelect requires both operands to have the same type as
// the result type
- ASSERT_FALSE(TransformationReplaceIdWithSynonym(
- MakeIdUseDescriptor(
- 10, MakeInstructionDescriptor(20, SpvOpUDiv, 0), 1),
- 13)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationReplaceIdWithSynonym(
+ MakeIdUseDescriptor(
+ 10, MakeInstructionDescriptor(20, spv::Op::OpUDiv, 0), 1),
+ 13)
+ .IsApplicable(context.get(), transformation_context));
// Not legal because OpStore requires the object to match the type pointed
// to by the pointer.
- ASSERT_FALSE(TransformationReplaceIdWithSynonym(
- MakeIdUseDescriptor(
- 10, MakeInstructionDescriptor(21, SpvOpStore, 0), 1),
- 13)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationReplaceIdWithSynonym(
+ MakeIdUseDescriptor(
+ 10, MakeInstructionDescriptor(21, spv::Op::OpStore, 0), 1),
+ 13)
+ .IsApplicable(context.get(), transformation_context));
ASSERT_TRUE(fuzzerutil::IsValidAndWellFormed(context.get(), validator_options,
kConsoleMessageConsumer));
@@ -1668,18 +1686,20 @@ TEST(TransformationReplaceIdWithSynonymTest, EquivalentIntegerVectorConstants) {
// Legal because OpIAdd does not consider the signedness of the operands
auto replacement1 = TransformationReplaceIdWithSynonym(
- MakeIdUseDescriptor(14, MakeInstructionDescriptor(18, SpvOpIAdd, 0), 0),
+ MakeIdUseDescriptor(14, MakeInstructionDescriptor(18, spv::Op::OpIAdd, 0),
+ 0),
15);
ASSERT_TRUE(replacement1.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(replacement1, context.get(), &transformation_context);
// Not legal because OpStore requires the object to match the type pointed
// to by the pointer.
- ASSERT_FALSE(TransformationReplaceIdWithSynonym(
- MakeIdUseDescriptor(
- 14, MakeInstructionDescriptor(18, SpvOpStore, 0), 1),
- 15)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationReplaceIdWithSynonym(
+ MakeIdUseDescriptor(
+ 14, MakeInstructionDescriptor(18, spv::Op::OpStore, 0), 1),
+ 15)
+ .IsApplicable(context.get(), transformation_context));
// Add synonym fact relating %12 and %13 (equivalent integer constants with
// different signedness).
@@ -1689,7 +1709,7 @@ TEST(TransformationReplaceIdWithSynonymTest, EquivalentIntegerVectorConstants) {
// Legal because the indices of OpAccessChain are always treated as signed
auto replacement2 = TransformationReplaceIdWithSynonym(
MakeIdUseDescriptor(
- 13, MakeInstructionDescriptor(19, SpvOpAccessChain, 0), 1),
+ 13, MakeInstructionDescriptor(19, spv::Op::OpAccessChain, 0), 1),
12);
ASSERT_TRUE(replacement2.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(replacement2, context.get(), &transformation_context);
diff --git a/test/fuzz/transformation_replace_irrelevant_id_test.cpp b/test/fuzz/transformation_replace_irrelevant_id_test.cpp
index c04a091db..c5d6981c8 100644
--- a/test/fuzz/transformation_replace_irrelevant_id_test.cpp
+++ b/test/fuzz/transformation_replace_irrelevant_id_test.cpp
@@ -82,8 +82,9 @@ TEST(TransformationReplaceIrrelevantIdTest, Inapplicable) {
SetUpIrrelevantIdFacts(transformation_context.GetFactManager());
auto instruction_21_descriptor =
- MakeInstructionDescriptor(21, SpvOpAccessChain, 0);
- auto instruction_24_descriptor = MakeInstructionDescriptor(24, SpvOpIAdd, 0);
+ MakeInstructionDescriptor(21, spv::Op::OpAccessChain, 0);
+ auto instruction_24_descriptor =
+ MakeInstructionDescriptor(24, spv::Op::OpIAdd, 0);
// %20 has not been declared as irrelevant.
ASSERT_FALSE(TransformationReplaceIrrelevantId(
@@ -132,7 +133,8 @@ TEST(TransformationReplaceIrrelevantIdTest, Apply) {
MakeUnique<FactManager>(context.get()), validator_options);
SetUpIrrelevantIdFacts(transformation_context.GetFactManager());
- auto instruction_24_descriptor = MakeInstructionDescriptor(24, SpvOpIAdd, 0);
+ auto instruction_24_descriptor =
+ MakeInstructionDescriptor(24, spv::Op::OpIAdd, 0);
// Replace the use of %23 in %24 with %22.
auto transformation = TransformationReplaceIrrelevantId(
@@ -229,11 +231,12 @@ TEST(TransformationReplaceIrrelevantIdTest,
// We cannot replace the use of %13 in the initializer of %12 with %9 because
// %9 is not a constant.
- ASSERT_FALSE(TransformationReplaceIrrelevantId(
- MakeIdUseDescriptor(
- 13, MakeInstructionDescriptor(12, SpvOpVariable, 0), 1),
- 9)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationReplaceIrrelevantId(
+ MakeIdUseDescriptor(
+ 13, MakeInstructionDescriptor(12, spv::Op::OpVariable, 0), 1),
+ 9)
+ .IsApplicable(context.get(), transformation_context));
}
TEST(TransformationReplaceIrrelevantIdTest,
@@ -280,7 +283,7 @@ TEST(TransformationReplaceIrrelevantIdTest,
ASSERT_FALSE(
TransformationReplaceIrrelevantId(
MakeIdUseDescriptor(
- 20, MakeInstructionDescriptor(21, SpvOpCopyObject, 0), 0),
+ 20, MakeInstructionDescriptor(21, spv::Op::OpCopyObject, 0), 0),
10)
.IsApplicable(context.get(), transformation_context));
}
@@ -326,7 +329,7 @@ TEST(TransformationReplaceIrrelevantIdTest, OpAccessChainIrrelevantIndex) {
ASSERT_FALSE(
TransformationReplaceIrrelevantId(
MakeIdUseDescriptor(
- 10, MakeInstructionDescriptor(12, SpvOpAccessChain, 0), 1),
+ 10, MakeInstructionDescriptor(12, spv::Op::OpAccessChain, 0), 1),
11)
.IsApplicable(context.get(), transformation_context));
}
diff --git a/test/fuzz/transformation_replace_linear_algebra_instruction_test.cpp b/test/fuzz/transformation_replace_linear_algebra_instruction_test.cpp
index 8ec5552cf..2dedea13b 100644
--- a/test/fuzz/transformation_replace_linear_algebra_instruction_test.cpp
+++ b/test/fuzz/transformation_replace_linear_algebra_instruction_test.cpp
@@ -76,54 +76,56 @@ TEST(TransformationReplaceLinearAlgebraInstructionTest, IsApplicable) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
// Tests linear algebra instructions.
- auto instruction_descriptor = MakeInstructionDescriptor(24, SpvOpDot, 0);
+ auto instruction_descriptor =
+ MakeInstructionDescriptor(24, spv::Op::OpDot, 0);
auto transformation = TransformationReplaceLinearAlgebraInstruction(
{33, 34, 35, 36, 37, 38}, instruction_descriptor);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
instruction_descriptor =
- MakeInstructionDescriptor(27, SpvOpVectorTimesScalar, 0);
+ MakeInstructionDescriptor(27, spv::Op::OpVectorTimesScalar, 0);
transformation = TransformationReplaceLinearAlgebraInstruction(
{33, 34, 35, 36}, instruction_descriptor);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
// Tests non-linear algebra instructions.
- instruction_descriptor = MakeInstructionDescriptor(30, SpvOpCopyObject, 0);
+ instruction_descriptor =
+ MakeInstructionDescriptor(30, spv::Op::OpCopyObject, 0);
transformation = TransformationReplaceLinearAlgebraInstruction(
{33, 34, 35, 36, 37, 38}, instruction_descriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
- instruction_descriptor = MakeInstructionDescriptor(31, SpvOpFAdd, 0);
+ instruction_descriptor = MakeInstructionDescriptor(31, spv::Op::OpFAdd, 0);
transformation = TransformationReplaceLinearAlgebraInstruction(
{33, 34, 35, 36, 37}, instruction_descriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
- instruction_descriptor = MakeInstructionDescriptor(32, SpvOpFMul, 0);
+ instruction_descriptor = MakeInstructionDescriptor(32, spv::Op::OpFMul, 0);
transformation = TransformationReplaceLinearAlgebraInstruction(
{33, 34, 35, 36}, instruction_descriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
// Tests number of fresh ids is different than necessary.
- instruction_descriptor = MakeInstructionDescriptor(25, SpvOpDot, 0);
+ instruction_descriptor = MakeInstructionDescriptor(25, spv::Op::OpDot, 0);
transformation = TransformationReplaceLinearAlgebraInstruction(
{33, 34, 35, 36}, instruction_descriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
instruction_descriptor =
- MakeInstructionDescriptor(28, SpvOpVectorTimesScalar, 0);
+ MakeInstructionDescriptor(28, spv::Op::OpVectorTimesScalar, 0);
transformation = TransformationReplaceLinearAlgebraInstruction(
{33, 34, 35, 36, 37, 38, 39}, instruction_descriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
// Tests non-fresh ids.
- instruction_descriptor = MakeInstructionDescriptor(26, SpvOpDot, 0);
+ instruction_descriptor = MakeInstructionDescriptor(26, spv::Op::OpDot, 0);
transformation = TransformationReplaceLinearAlgebraInstruction(
{33, 34, 5, 36, 37, 8, 39, 40, 1, 42, 3, 44, 45, 46},
instruction_descriptor);
@@ -131,7 +133,7 @@ TEST(TransformationReplaceLinearAlgebraInstructionTest, IsApplicable) {
transformation.IsApplicable(context.get(), transformation_context));
instruction_descriptor =
- MakeInstructionDescriptor(29, SpvOpVectorTimesScalar, 0);
+ MakeInstructionDescriptor(29, spv::Op::OpVectorTimesScalar, 0);
transformation = TransformationReplaceLinearAlgebraInstruction(
{33, 34, 35, 36, 7, 38, 9, 40}, instruction_descriptor);
ASSERT_FALSE(
@@ -249,32 +251,36 @@ TEST(TransformationReplaceLinearAlgebraInstructionTest, ReplaceOpTranspose) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
auto instruction_descriptor =
- MakeInstructionDescriptor(56, SpvOpTranspose, 0);
+ MakeInstructionDescriptor(56, spv::Op::OpTranspose, 0);
auto transformation = TransformationReplaceLinearAlgebraInstruction(
{65, 66, 67, 68, 69, 70, 71, 72, 73, 74}, instruction_descriptor);
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
- instruction_descriptor = MakeInstructionDescriptor(57, SpvOpTranspose, 0);
+ instruction_descriptor =
+ MakeInstructionDescriptor(57, spv::Op::OpTranspose, 0);
transformation = TransformationReplaceLinearAlgebraInstruction(
{75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88},
instruction_descriptor);
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
- instruction_descriptor = MakeInstructionDescriptor(58, SpvOpTranspose, 0);
+ instruction_descriptor =
+ MakeInstructionDescriptor(58, spv::Op::OpTranspose, 0);
transformation = TransformationReplaceLinearAlgebraInstruction(
{89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
106},
instruction_descriptor);
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
- instruction_descriptor = MakeInstructionDescriptor(59, SpvOpTranspose, 0);
+ instruction_descriptor =
+ MakeInstructionDescriptor(59, spv::Op::OpTranspose, 0);
transformation = TransformationReplaceLinearAlgebraInstruction(
{107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120,
121},
instruction_descriptor);
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
- instruction_descriptor = MakeInstructionDescriptor(60, SpvOpTranspose, 0);
+ instruction_descriptor =
+ MakeInstructionDescriptor(60, spv::Op::OpTranspose, 0);
transformation = TransformationReplaceLinearAlgebraInstruction(
{122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132,
133, 134, 135, 136, 137, 138, 139, 140, 141, 142},
@@ -506,19 +512,19 @@ TEST(TransformationReplaceLinearAlgebraInstructionTest,
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
auto instruction_descriptor =
- MakeInstructionDescriptor(17, SpvOpVectorTimesScalar, 0);
+ MakeInstructionDescriptor(17, spv::Op::OpVectorTimesScalar, 0);
auto transformation = TransformationReplaceLinearAlgebraInstruction(
{20, 21, 22, 23}, instruction_descriptor);
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
instruction_descriptor =
- MakeInstructionDescriptor(18, SpvOpVectorTimesScalar, 0);
+ MakeInstructionDescriptor(18, spv::Op::OpVectorTimesScalar, 0);
transformation = TransformationReplaceLinearAlgebraInstruction(
{24, 25, 26, 27, 28, 29}, instruction_descriptor);
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
instruction_descriptor =
- MakeInstructionDescriptor(19, SpvOpVectorTimesScalar, 0);
+ MakeInstructionDescriptor(19, spv::Op::OpVectorTimesScalar, 0);
transformation = TransformationReplaceLinearAlgebraInstruction(
{30, 31, 32, 33, 34, 35, 36, 37}, instruction_descriptor);
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
@@ -677,20 +683,20 @@ TEST(TransformationReplaceLinearAlgebraInstructionTest,
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
auto instruction_descriptor =
- MakeInstructionDescriptor(56, SpvOpMatrixTimesScalar, 0);
+ MakeInstructionDescriptor(56, spv::Op::OpMatrixTimesScalar, 0);
auto transformation = TransformationReplaceLinearAlgebraInstruction(
{65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76}, instruction_descriptor);
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
instruction_descriptor =
- MakeInstructionDescriptor(57, SpvOpMatrixTimesScalar, 0);
+ MakeInstructionDescriptor(57, spv::Op::OpMatrixTimesScalar, 0);
transformation = TransformationReplaceLinearAlgebraInstruction(
{77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94},
instruction_descriptor);
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
instruction_descriptor =
- MakeInstructionDescriptor(58, SpvOpMatrixTimesScalar, 0);
+ MakeInstructionDescriptor(58, spv::Op::OpMatrixTimesScalar, 0);
transformation = TransformationReplaceLinearAlgebraInstruction(
{95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118},
@@ -964,14 +970,14 @@ TEST(TransformationReplaceLinearAlgebraInstructionTest,
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
auto instruction_descriptor =
- MakeInstructionDescriptor(56, SpvOpVectorTimesMatrix, 0);
+ MakeInstructionDescriptor(56, spv::Op::OpVectorTimesMatrix, 0);
auto transformation = TransformationReplaceLinearAlgebraInstruction(
{65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78},
instruction_descriptor);
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
instruction_descriptor =
- MakeInstructionDescriptor(57, SpvOpVectorTimesMatrix, 0);
+ MakeInstructionDescriptor(57, spv::Op::OpVectorTimesMatrix, 0);
transformation = TransformationReplaceLinearAlgebraInstruction(
{79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
89, 90, 91, 92, 93, 94, 95, 96, 97, 98},
@@ -979,7 +985,7 @@ TEST(TransformationReplaceLinearAlgebraInstructionTest,
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
instruction_descriptor =
- MakeInstructionDescriptor(58, SpvOpVectorTimesMatrix, 0);
+ MakeInstructionDescriptor(58, spv::Op::OpVectorTimesMatrix, 0);
transformation = TransformationReplaceLinearAlgebraInstruction(
{99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124},
@@ -987,7 +993,7 @@ TEST(TransformationReplaceLinearAlgebraInstructionTest,
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
instruction_descriptor =
- MakeInstructionDescriptor(59, SpvOpVectorTimesMatrix, 0);
+ MakeInstructionDescriptor(59, spv::Op::OpVectorTimesMatrix, 0);
transformation = TransformationReplaceLinearAlgebraInstruction(
{125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135,
136, 137, 138, 139, 140, 141, 142, 143, 144, 145},
@@ -1298,14 +1304,14 @@ TEST(TransformationReplaceLinearAlgebraInstructionTest,
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
auto instruction_descriptor =
- MakeInstructionDescriptor(56, SpvOpMatrixTimesVector, 0);
+ MakeInstructionDescriptor(56, spv::Op::OpMatrixTimesVector, 0);
auto transformation = TransformationReplaceLinearAlgebraInstruction(
{65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78},
instruction_descriptor);
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
instruction_descriptor =
- MakeInstructionDescriptor(57, SpvOpMatrixTimesVector, 0);
+ MakeInstructionDescriptor(57, spv::Op::OpMatrixTimesVector, 0);
transformation = TransformationReplaceLinearAlgebraInstruction(
{79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
97},
@@ -1313,7 +1319,7 @@ TEST(TransformationReplaceLinearAlgebraInstructionTest,
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
instruction_descriptor =
- MakeInstructionDescriptor(58, SpvOpMatrixTimesVector, 0);
+ MakeInstructionDescriptor(58, spv::Op::OpMatrixTimesVector, 0);
transformation = TransformationReplaceLinearAlgebraInstruction(
{98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121},
@@ -1321,7 +1327,7 @@ TEST(TransformationReplaceLinearAlgebraInstructionTest,
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
instruction_descriptor =
- MakeInstructionDescriptor(59, SpvOpMatrixTimesVector, 0);
+ MakeInstructionDescriptor(59, spv::Op::OpMatrixTimesVector, 0);
transformation = TransformationReplaceLinearAlgebraInstruction(
{122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132,
133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143},
@@ -1684,7 +1690,7 @@ TEST(TransformationReplaceLinearAlgebraInstructionTest,
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
auto instruction_descriptor =
- MakeInstructionDescriptor(56, SpvOpMatrixTimesMatrix, 0);
+ MakeInstructionDescriptor(56, spv::Op::OpMatrixTimesMatrix, 0);
auto transformation = TransformationReplaceLinearAlgebraInstruction(
{83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
@@ -1693,7 +1699,7 @@ TEST(TransformationReplaceLinearAlgebraInstructionTest,
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
instruction_descriptor =
- MakeInstructionDescriptor(57, SpvOpMatrixTimesMatrix, 0);
+ MakeInstructionDescriptor(57, spv::Op::OpMatrixTimesMatrix, 0);
transformation = TransformationReplaceLinearAlgebraInstruction(
{123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146,
@@ -1704,7 +1710,7 @@ TEST(TransformationReplaceLinearAlgebraInstructionTest,
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
instruction_descriptor =
- MakeInstructionDescriptor(58, SpvOpMatrixTimesMatrix, 0);
+ MakeInstructionDescriptor(58, spv::Op::OpMatrixTimesMatrix, 0);
transformation = TransformationReplaceLinearAlgebraInstruction(
{183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196,
197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210,
@@ -2157,25 +2163,28 @@ TEST(TransformationReplaceLinearAlgebraInstructionTest, ReplaceOpOuterProduct) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
auto instruction_descriptor =
- MakeInstructionDescriptor(47, SpvOpOuterProduct, 0);
+ MakeInstructionDescriptor(47, spv::Op::OpOuterProduct, 0);
auto transformation = TransformationReplaceLinearAlgebraInstruction(
{56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67}, instruction_descriptor);
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
- instruction_descriptor = MakeInstructionDescriptor(48, SpvOpOuterProduct, 0);
+ instruction_descriptor =
+ MakeInstructionDescriptor(48, spv::Op::OpOuterProduct, 0);
transformation = TransformationReplaceLinearAlgebraInstruction(
{68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85},
instruction_descriptor);
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
- instruction_descriptor = MakeInstructionDescriptor(49, SpvOpOuterProduct, 0);
+ instruction_descriptor =
+ MakeInstructionDescriptor(49, spv::Op::OpOuterProduct, 0);
transformation = TransformationReplaceLinearAlgebraInstruction(
{86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97,
98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109},
instruction_descriptor);
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
- instruction_descriptor = MakeInstructionDescriptor(50, SpvOpOuterProduct, 0);
+ instruction_descriptor =
+ MakeInstructionDescriptor(50, spv::Op::OpOuterProduct, 0);
transformation = TransformationReplaceLinearAlgebraInstruction(
{110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
124, 125},
@@ -2393,17 +2402,18 @@ TEST(TransformationReplaceLinearAlgebraInstructionTest, ReplaceOpDot) {
kConsoleMessageConsumer));
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
- auto instruction_descriptor = MakeInstructionDescriptor(24, SpvOpDot, 0);
+ auto instruction_descriptor =
+ MakeInstructionDescriptor(24, spv::Op::OpDot, 0);
auto transformation = TransformationReplaceLinearAlgebraInstruction(
{27, 28, 29, 30, 31, 32}, instruction_descriptor);
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
- instruction_descriptor = MakeInstructionDescriptor(25, SpvOpDot, 0);
+ instruction_descriptor = MakeInstructionDescriptor(25, spv::Op::OpDot, 0);
transformation = TransformationReplaceLinearAlgebraInstruction(
{33, 34, 35, 36, 37, 38, 39, 40, 41, 42}, instruction_descriptor);
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
- instruction_descriptor = MakeInstructionDescriptor(26, SpvOpDot, 0);
+ instruction_descriptor = MakeInstructionDescriptor(26, spv::Op::OpDot, 0);
transformation = TransformationReplaceLinearAlgebraInstruction(
{43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56},
instruction_descriptor);
diff --git a/test/fuzz/transformation_replace_load_store_with_copy_memory_test.cpp b/test/fuzz/transformation_replace_load_store_with_copy_memory_test.cpp
index bc100990b..74da98b47 100644
--- a/test/fuzz/transformation_replace_load_store_with_copy_memory_test.cpp
+++ b/test/fuzz/transformation_replace_load_store_with_copy_memory_test.cpp
@@ -118,29 +118,29 @@ TEST(TransformationReplaceLoadStoreWithCopyMemoryTest, BasicScenarios) {
kConsoleMessageConsumer));
auto bad_instruction_descriptor_1 =
- MakeInstructionDescriptor(11, SpvOpConstant, 0);
+ MakeInstructionDescriptor(11, spv::Op::OpConstant, 0);
auto load_instruction_descriptor_1 =
- MakeInstructionDescriptor(22, SpvOpLoad, 0);
+ MakeInstructionDescriptor(22, spv::Op::OpLoad, 0);
auto load_instruction_descriptor_2 =
- MakeInstructionDescriptor(23, SpvOpLoad, 0);
+ MakeInstructionDescriptor(23, spv::Op::OpLoad, 0);
auto load_instruction_descriptor_3 =
- MakeInstructionDescriptor(24, SpvOpLoad, 0);
+ MakeInstructionDescriptor(24, spv::Op::OpLoad, 0);
auto load_instruction_descriptor_other_block =
- MakeInstructionDescriptor(34, SpvOpLoad, 0);
+ MakeInstructionDescriptor(34, spv::Op::OpLoad, 0);
auto load_instruction_descriptor_unsafe =
- MakeInstructionDescriptor(29, SpvOpLoad, 0);
+ MakeInstructionDescriptor(29, spv::Op::OpLoad, 0);
auto store_instruction_descriptor_1 =
- MakeInstructionDescriptor(22, SpvOpStore, 0);
+ MakeInstructionDescriptor(22, spv::Op::OpStore, 0);
auto store_instruction_descriptor_2 =
- MakeInstructionDescriptor(23, SpvOpStore, 0);
+ MakeInstructionDescriptor(23, spv::Op::OpStore, 0);
auto store_instruction_descriptor_3 =
- MakeInstructionDescriptor(24, SpvOpStore, 0);
+ MakeInstructionDescriptor(24, spv::Op::OpStore, 0);
auto store_instruction_descriptor_other_block =
- MakeInstructionDescriptor(37, SpvOpStore, 0);
+ MakeInstructionDescriptor(37, spv::Op::OpStore, 0);
auto store_instruction_descriptor_unsafe =
- MakeInstructionDescriptor(29, SpvOpStore, 0);
+ MakeInstructionDescriptor(29, spv::Op::OpStore, 0);
// Bad: |load_instruction_descriptor| is incorrect.
auto transformation_bad_1 = TransformationReplaceLoadStoreWithCopyMemory(
diff --git a/test/fuzz/transformation_set_function_control_test.cpp b/test/fuzz/transformation_set_function_control_test.cpp
index 85402e171..e51e24afe 100644
--- a/test/fuzz/transformation_set_function_control_test.cpp
+++ b/test/fuzz/transformation_set_function_control_test.cpp
@@ -124,19 +124,22 @@ TEST(TransformationSetFunctionControlTest, VariousScenarios) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
// %36 is not a function
- ASSERT_FALSE(TransformationSetFunctionControl(36, SpvFunctionControlMaskNone)
+ ASSERT_FALSE(TransformationSetFunctionControl(
+ 36, uint32_t(spv::FunctionControlMask::MaskNone))
.IsApplicable(context.get(), transformation_context));
// Cannot add the Pure function control to %4 as it did not already have it
- ASSERT_FALSE(TransformationSetFunctionControl(4, SpvFunctionControlPureMask)
+ ASSERT_FALSE(TransformationSetFunctionControl(
+ 4, uint32_t(spv::FunctionControlMask::Pure))
.IsApplicable(context.get(), transformation_context));
// Cannot add the Const function control to %21 as it did not already
// have it
- ASSERT_FALSE(TransformationSetFunctionControl(21, SpvFunctionControlConstMask)
+ ASSERT_FALSE(TransformationSetFunctionControl(
+ 21, uint32_t(spv::FunctionControlMask::Const))
.IsApplicable(context.get(), transformation_context));
// Set to None, removing Const
- TransformationSetFunctionControl transformation1(11,
- SpvFunctionControlMaskNone);
+ TransformationSetFunctionControl transformation1(
+ 11, uint32_t(spv::FunctionControlMask::MaskNone));
ASSERT_TRUE(
transformation1.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation1, context.get(),
@@ -144,15 +147,15 @@ TEST(TransformationSetFunctionControlTest, VariousScenarios) {
// Set to Inline; silly to do it on an entry point, but it is allowed
TransformationSetFunctionControl transformation2(
- 4, SpvFunctionControlInlineMask);
+ 4, uint32_t(spv::FunctionControlMask::Inline));
ASSERT_TRUE(
transformation2.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation2, context.get(),
&transformation_context);
// Set to Pure, removing DontInline
- TransformationSetFunctionControl transformation3(17,
- SpvFunctionControlPureMask);
+ TransformationSetFunctionControl transformation3(
+ 17, uint32_t(spv::FunctionControlMask::Pure));
ASSERT_TRUE(
transformation3.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation3, context.get(),
@@ -160,7 +163,7 @@ TEST(TransformationSetFunctionControlTest, VariousScenarios) {
// Change from Inline to DontInline
TransformationSetFunctionControl transformation4(
- 13, SpvFunctionControlDontInlineMask);
+ 13, uint32_t(spv::FunctionControlMask::DontInline));
ASSERT_TRUE(
transformation4.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation4, context.get(),
diff --git a/test/fuzz/transformation_set_loop_control_test.cpp b/test/fuzz/transformation_set_loop_control_test.cpp
index 88b4aab58..94a5b3667 100644
--- a/test/fuzz/transformation_set_loop_control_test.cpp
+++ b/test/fuzz/transformation_set_loop_control_test.cpp
@@ -278,398 +278,458 @@ TEST(TransformationSetLoopControlTest, VariousScenarios) {
// DependencyLength|MinIterations|MaxIterations|IterationMultiple|PeelCount|PartialCount
// 2 5 90 4 7 14
- ASSERT_TRUE(TransformationSetLoopControl(10, SpvLoopControlMaskNone, 0, 0)
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 10, (uint32_t)spv::LoopControlMask::MaskNone, 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 10, (uint32_t)spv::LoopControlMask::Unroll, 0, 0)
.IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(TransformationSetLoopControl(10, SpvLoopControlUnrollMask, 0, 0)
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 10, (uint32_t)spv::LoopControlMask::DontUnroll, 0, 0)
.IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(
- TransformationSetLoopControl(10, SpvLoopControlDontUnrollMask, 0, 0)
- .IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(TransformationSetLoopControl(
- 10, SpvLoopControlDependencyInfiniteMask, 0, 0)
+ 10, (uint32_t)spv::LoopControlMask::DependencyInfinite, 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationSetLoopControl(
+ 10, (uint32_t)spv::LoopControlMask::DependencyLength, 0, 0)
.IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(
- TransformationSetLoopControl(10, SpvLoopControlDependencyLengthMask, 0, 0)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(
- TransformationSetLoopControl(10, SpvLoopControlMinIterationsMask, 0, 0)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(
- TransformationSetLoopControl(10, SpvLoopControlMaxIterationsMask, 0, 0)
- .IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(TransformationSetLoopControl(
- 10, SpvLoopControlIterationMultipleMask, 0, 0)
+ 10, (uint32_t)spv::LoopControlMask::MinIterations, 0, 0)
.IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(
- TransformationSetLoopControl(10, SpvLoopControlPeelCountMask, 3, 0)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(
- TransformationSetLoopControl(10, SpvLoopControlPeelCountMask, 3, 3)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(
- TransformationSetLoopControl(10, SpvLoopControlPartialCountMask, 0, 3)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(
- TransformationSetLoopControl(10, SpvLoopControlPartialCountMask, 3, 3)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationSetLoopControl(
+ 10, (uint32_t)spv::LoopControlMask::MaxIterations, 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationSetLoopControl(
+ 10, (uint32_t)spv::LoopControlMask::IterationMultiple, 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 10, (uint32_t)spv::LoopControlMask::PeelCount, 3, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationSetLoopControl(
+ 10, (uint32_t)spv::LoopControlMask::PeelCount, 3, 3)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 10, (uint32_t)spv::LoopControlMask::PartialCount, 0, 3)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationSetLoopControl(
+ 10, (uint32_t)spv::LoopControlMask::PartialCount, 3, 3)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 10,
+ (uint32_t)spv::LoopControlMask::PeelCount |
+ (uint32_t)spv::LoopControlMask::PartialCount,
+ 3, 3)
+ .IsApplicable(context.get(), transformation_context));
ASSERT_TRUE(TransformationSetLoopControl(
10,
- SpvLoopControlPeelCountMask | SpvLoopControlPartialCountMask,
+ (uint32_t)spv::LoopControlMask::Unroll |
+ (uint32_t)spv::LoopControlMask::PeelCount |
+ (uint32_t)spv::LoopControlMask::PartialCount,
3, 3)
.IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(TransformationSetLoopControl(10,
- SpvLoopControlUnrollMask |
- SpvLoopControlPeelCountMask |
- SpvLoopControlPartialCountMask,
- 3, 3)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(TransformationSetLoopControl(10,
- SpvLoopControlDontUnrollMask |
- SpvLoopControlPeelCountMask |
- SpvLoopControlPartialCountMask,
- 3, 3)
+ ASSERT_FALSE(TransformationSetLoopControl(
+ 10,
+ (uint32_t)spv::LoopControlMask::DontUnroll |
+ (uint32_t)spv::LoopControlMask::PeelCount |
+ (uint32_t)spv::LoopControlMask::PartialCount,
+ 3, 3)
.IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(TransformationSetLoopControl(23, SpvLoopControlMaskNone, 0, 0)
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 23, (uint32_t)spv::LoopControlMask::MaskNone, 0, 0)
.IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(TransformationSetLoopControl(23, SpvLoopControlUnrollMask, 0, 0)
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 23, (uint32_t)spv::LoopControlMask::Unroll, 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 23, (uint32_t)spv::LoopControlMask::DontUnroll, 0, 0)
.IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(
- TransformationSetLoopControl(23, SpvLoopControlDontUnrollMask, 0, 0)
- .IsApplicable(context.get(), transformation_context));
ASSERT_TRUE(TransformationSetLoopControl(
23,
- SpvLoopControlPeelCountMask | SpvLoopControlPartialCountMask,
+ (uint32_t)spv::LoopControlMask::PeelCount |
+ (uint32_t)spv::LoopControlMask::PartialCount,
3, 3)
.IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(
- TransformationSetLoopControl(23, SpvLoopControlMaxIterationsMask, 2, 3)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationSetLoopControl(
+ 23, (uint32_t)spv::LoopControlMask::MaxIterations, 2, 3)
+ .IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(TransformationSetLoopControl(33, SpvLoopControlMaskNone, 0, 0)
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 33, (uint32_t)spv::LoopControlMask::MaskNone, 0, 0)
.IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(TransformationSetLoopControl(33, SpvLoopControlUnrollMask, 0, 0)
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 33, (uint32_t)spv::LoopControlMask::Unroll, 0, 0)
.IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(
- TransformationSetLoopControl(33, SpvLoopControlDontUnrollMask, 0, 0)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(
- TransformationSetLoopControl(33, SpvLoopControlMinIterationsMask, 0, 0)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(
- TransformationSetLoopControl(
- 33, SpvLoopControlUnrollMask | SpvLoopControlPeelCountMask, 5, 0)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(TransformationSetLoopControl(33,
- SpvLoopControlDontUnrollMask |
- SpvLoopControlPartialCountMask,
- 0, 10)
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 33, (uint32_t)spv::LoopControlMask::DontUnroll, 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationSetLoopControl(
+ 33, (uint32_t)spv::LoopControlMask::MinIterations, 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 33,
+ (uint32_t)spv::LoopControlMask::Unroll |
+ (uint32_t)spv::LoopControlMask::PeelCount,
+ 5, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationSetLoopControl(
+ 33,
+ (uint32_t)spv::LoopControlMask::DontUnroll |
+ (uint32_t)spv::LoopControlMask::PartialCount,
+ 0, 10)
.IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(TransformationSetLoopControl(43, SpvLoopControlMaskNone, 0, 0)
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 43, (uint32_t)spv::LoopControlMask::MaskNone, 0, 0)
.IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(TransformationSetLoopControl(43, SpvLoopControlUnrollMask, 0, 0)
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 43, (uint32_t)spv::LoopControlMask::Unroll, 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 43, (uint32_t)spv::LoopControlMask::DontUnroll, 0, 0)
.IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(
- TransformationSetLoopControl(43, SpvLoopControlDontUnrollMask, 0, 0)
- .IsApplicable(context.get(), transformation_context));
ASSERT_TRUE(TransformationSetLoopControl(
43,
- SpvLoopControlMaskNone | SpvLoopControlDependencyInfiniteMask,
+ (uint32_t)spv::LoopControlMask::MaskNone |
+ (uint32_t)spv::LoopControlMask::DependencyInfinite,
0, 0)
.IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(
- TransformationSetLoopControl(
- 43, SpvLoopControlUnrollMask | SpvLoopControlDependencyInfiniteMask,
- 0, 0)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(
- TransformationSetLoopControl(
- 43,
- SpvLoopControlDontUnrollMask | SpvLoopControlDependencyInfiniteMask,
- 0, 0)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(
- TransformationSetLoopControl(43,
- SpvLoopControlDependencyInfiniteMask |
- SpvLoopControlDependencyLengthMask,
- 0, 0)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(
- TransformationSetLoopControl(
- 43, SpvLoopControlUnrollMask | SpvLoopControlPeelCountMask, 5, 0)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 43,
+ (uint32_t)spv::LoopControlMask::Unroll |
+ (uint32_t)spv::LoopControlMask::DependencyInfinite,
+ 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 43,
+ (uint32_t)spv::LoopControlMask::DontUnroll |
+ (uint32_t)spv::LoopControlMask::DependencyInfinite,
+ 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationSetLoopControl(
+ 43,
+ (uint32_t)spv::LoopControlMask::DependencyInfinite |
+ (uint32_t)spv::LoopControlMask::DependencyLength,
+ 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 43,
+ (uint32_t)spv::LoopControlMask::Unroll |
+ (uint32_t)spv::LoopControlMask::PeelCount,
+ 5, 0)
+ .IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(TransformationSetLoopControl(53, SpvLoopControlMaskNone, 0, 0)
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 53, (uint32_t)spv::LoopControlMask::MaskNone, 0, 0)
.IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(TransformationSetLoopControl(53, SpvLoopControlUnrollMask, 0, 0)
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 53, (uint32_t)spv::LoopControlMask::Unroll, 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 53, (uint32_t)spv::LoopControlMask::DontUnroll, 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationSetLoopControl(
+ 53, (uint32_t)spv::LoopControlMask::MaxIterations, 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 53,
+ (uint32_t)spv::LoopControlMask::MaskNone |
+ (uint32_t)spv::LoopControlMask::DependencyLength,
+ 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationSetLoopControl(
+ 53,
+ (uint32_t)spv::LoopControlMask::Unroll |
+ (uint32_t)spv::LoopControlMask::DependencyInfinite,
+ 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 53,
+ (uint32_t)spv::LoopControlMask::DontUnroll |
+ (uint32_t)spv::LoopControlMask::DependencyLength,
+ 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationSetLoopControl(
+ 53,
+ (uint32_t)spv::LoopControlMask::DependencyInfinite |
+ (uint32_t)spv::LoopControlMask::DependencyLength,
+ 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 53,
+ (uint32_t)spv::LoopControlMask::Unroll |
+ (uint32_t)spv::LoopControlMask::DependencyLength |
+ (uint32_t)spv::LoopControlMask::PeelCount |
+ (uint32_t)spv::LoopControlMask::PartialCount,
+ 5, 3)
.IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(
- TransformationSetLoopControl(53, SpvLoopControlDontUnrollMask, 0, 0)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(
- TransformationSetLoopControl(53, SpvLoopControlMaxIterationsMask, 0, 0)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(
- TransformationSetLoopControl(
- 53, SpvLoopControlMaskNone | SpvLoopControlDependencyLengthMask, 0, 0)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(
- TransformationSetLoopControl(
- 53, SpvLoopControlUnrollMask | SpvLoopControlDependencyInfiniteMask,
- 0, 0)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(
- TransformationSetLoopControl(
- 53, SpvLoopControlDontUnrollMask | SpvLoopControlDependencyLengthMask,
- 0, 0)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(
- TransformationSetLoopControl(53,
- SpvLoopControlDependencyInfiniteMask |
- SpvLoopControlDependencyLengthMask,
- 0, 0)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(
- TransformationSetLoopControl(
- 53,
- SpvLoopControlUnrollMask | SpvLoopControlDependencyLengthMask |
- SpvLoopControlPeelCountMask | SpvLoopControlPartialCountMask,
- 5, 3)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(TransformationSetLoopControl(63, SpvLoopControlMaskNone, 0, 0)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(TransformationSetLoopControl(63, SpvLoopControlUnrollMask, 0, 0)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(
- TransformationSetLoopControl(63, SpvLoopControlDontUnrollMask, 0, 0)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(TransformationSetLoopControl(63,
- SpvLoopControlUnrollMask |
- SpvLoopControlMinIterationsMask |
- SpvLoopControlPeelCountMask |
- SpvLoopControlPartialCountMask,
- 5, 3)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(TransformationSetLoopControl(63,
- SpvLoopControlUnrollMask |
- SpvLoopControlMinIterationsMask |
- SpvLoopControlPeelCountMask,
- 23, 0)
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 63, (uint32_t)spv::LoopControlMask::MaskNone, 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 63, (uint32_t)spv::LoopControlMask::Unroll, 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 63, (uint32_t)spv::LoopControlMask::DontUnroll, 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 63,
+ (uint32_t)spv::LoopControlMask::Unroll |
+ (uint32_t)spv::LoopControlMask::MinIterations |
+ (uint32_t)spv::LoopControlMask::PeelCount |
+ (uint32_t)spv::LoopControlMask::PartialCount,
+ 5, 3)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 63,
+ (uint32_t)spv::LoopControlMask::Unroll |
+ (uint32_t)spv::LoopControlMask::MinIterations |
+ (uint32_t)spv::LoopControlMask::PeelCount,
+ 23, 0)
.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(TransformationSetLoopControl(
63,
- SpvLoopControlUnrollMask | SpvLoopControlMinIterationsMask |
- SpvLoopControlPeelCountMask,
+ (uint32_t)spv::LoopControlMask::Unroll |
+ (uint32_t)spv::LoopControlMask::MinIterations |
+ (uint32_t)spv::LoopControlMask::PeelCount,
2, 23)
.IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(TransformationSetLoopControl(73, SpvLoopControlMaskNone, 0, 0)
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 73, (uint32_t)spv::LoopControlMask::MaskNone, 0, 0)
.IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(TransformationSetLoopControl(73, SpvLoopControlUnrollMask, 0, 0)
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 73, (uint32_t)spv::LoopControlMask::Unroll, 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 73, (uint32_t)spv::LoopControlMask::DontUnroll, 0, 0)
.IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(
- TransformationSetLoopControl(73, SpvLoopControlDontUnrollMask, 0, 0)
- .IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(TransformationSetLoopControl(
73,
- SpvLoopControlUnrollMask | SpvLoopControlMinIterationsMask |
- SpvLoopControlPeelCountMask |
- SpvLoopControlPartialCountMask,
+ (uint32_t)spv::LoopControlMask::Unroll |
+ (uint32_t)spv::LoopControlMask::MinIterations |
+ (uint32_t)spv::LoopControlMask::PeelCount |
+ (uint32_t)spv::LoopControlMask::PartialCount,
5, 3)
.IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(TransformationSetLoopControl(73,
- SpvLoopControlUnrollMask |
- SpvLoopControlMaxIterationsMask |
- SpvLoopControlPeelCountMask,
- 23, 0)
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 73,
+ (uint32_t)spv::LoopControlMask::Unroll |
+ (uint32_t)spv::LoopControlMask::MaxIterations |
+ (uint32_t)spv::LoopControlMask::PeelCount,
+ 23, 0)
.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(TransformationSetLoopControl(
73,
- SpvLoopControlUnrollMask | SpvLoopControlMaxIterationsMask |
- SpvLoopControlPeelCountMask,
+ (uint32_t)spv::LoopControlMask::Unroll |
+ (uint32_t)spv::LoopControlMask::MaxIterations |
+ (uint32_t)spv::LoopControlMask::PeelCount,
2, 23)
.IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(TransformationSetLoopControl(83, SpvLoopControlMaskNone, 0, 0)
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 83, (uint32_t)spv::LoopControlMask::MaskNone, 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 83, (uint32_t)spv::LoopControlMask::Unroll, 0, 0)
.IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(TransformationSetLoopControl(83, SpvLoopControlUnrollMask, 0, 0)
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 83, (uint32_t)spv::LoopControlMask::DontUnroll, 0, 0)
.IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(
- TransformationSetLoopControl(83, SpvLoopControlDontUnrollMask, 0, 0)
- .IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(TransformationSetLoopControl(
83,
- SpvLoopControlUnrollMask | SpvLoopControlMinIterationsMask |
- SpvLoopControlPeelCountMask |
- SpvLoopControlPartialCountMask,
+ (uint32_t)spv::LoopControlMask::Unroll |
+ (uint32_t)spv::LoopControlMask::MinIterations |
+ (uint32_t)spv::LoopControlMask::PeelCount |
+ (uint32_t)spv::LoopControlMask::PartialCount,
5, 3)
.IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(
- TransformationSetLoopControl(83,
- SpvLoopControlUnrollMask |
- SpvLoopControlIterationMultipleMask |
- SpvLoopControlPeelCountMask,
- 23, 0)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(
- TransformationSetLoopControl(83,
- SpvLoopControlUnrollMask |
- SpvLoopControlIterationMultipleMask |
- SpvLoopControlPeelCountMask,
- 2, 23)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 83,
+ (uint32_t)spv::LoopControlMask::Unroll |
+ (uint32_t)spv::LoopControlMask::IterationMultiple |
+ (uint32_t)spv::LoopControlMask::PeelCount,
+ 23, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationSetLoopControl(
+ 83,
+ (uint32_t)spv::LoopControlMask::Unroll |
+ (uint32_t)spv::LoopControlMask::IterationMultiple |
+ (uint32_t)spv::LoopControlMask::PeelCount,
+ 2, 23)
+ .IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(TransformationSetLoopControl(93, SpvLoopControlMaskNone, 0, 0)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(TransformationSetLoopControl(93, SpvLoopControlUnrollMask, 0, 0)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(
- TransformationSetLoopControl(93, SpvLoopControlDontUnrollMask, 0, 0)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(
- TransformationSetLoopControl(93, SpvLoopControlPeelCountMask, 8, 0)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(
- TransformationSetLoopControl(93, SpvLoopControlPeelCountMask, 8, 8)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(
- TransformationSetLoopControl(93, SpvLoopControlPartialCountMask, 0, 8)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 93, (uint32_t)spv::LoopControlMask::MaskNone, 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 93, (uint32_t)spv::LoopControlMask::Unroll, 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 93, (uint32_t)spv::LoopControlMask::DontUnroll, 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 93, (uint32_t)spv::LoopControlMask::PeelCount, 8, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationSetLoopControl(
+ 93, (uint32_t)spv::LoopControlMask::PeelCount, 8, 8)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 93, (uint32_t)spv::LoopControlMask::PartialCount, 0, 8)
+ .IsApplicable(context.get(), transformation_context));
ASSERT_TRUE(TransformationSetLoopControl(
93,
- SpvLoopControlPeelCountMask | SpvLoopControlPartialCountMask,
+ (uint32_t)spv::LoopControlMask::PeelCount |
+ (uint32_t)spv::LoopControlMask::PartialCount,
16, 8)
.IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(TransformationSetLoopControl(103, SpvLoopControlMaskNone, 0, 0)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(TransformationSetLoopControl(103, SpvLoopControlUnrollMask, 0, 0)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(
- TransformationSetLoopControl(103, SpvLoopControlDontUnrollMask, 0, 0)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(
- TransformationSetLoopControl(103, SpvLoopControlPartialCountMask, 0, 60)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(TransformationSetLoopControl(103,
- SpvLoopControlDontUnrollMask |
- SpvLoopControlPartialCountMask,
- 0, 60)
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 103, (uint32_t)spv::LoopControlMask::MaskNone, 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 103, (uint32_t)spv::LoopControlMask::Unroll, 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 103, (uint32_t)spv::LoopControlMask::DontUnroll, 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 103, (uint32_t)spv::LoopControlMask::PartialCount, 0, 60)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationSetLoopControl(
+ 103,
+ (uint32_t)spv::LoopControlMask::DontUnroll |
+ (uint32_t)spv::LoopControlMask::PartialCount,
+ 0, 60)
.IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(TransformationSetLoopControl(113, SpvLoopControlMaskNone, 0, 0)
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 113, (uint32_t)spv::LoopControlMask::MaskNone, 0, 0)
.IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(TransformationSetLoopControl(113, SpvLoopControlUnrollMask, 0, 0)
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 113, (uint32_t)spv::LoopControlMask::Unroll, 0, 0)
.IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(
- TransformationSetLoopControl(113, SpvLoopControlDontUnrollMask, 0, 0)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(
- TransformationSetLoopControl(113, SpvLoopControlPeelCountMask, 12, 0)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(
- TransformationSetLoopControl(
- 113,
- SpvLoopControlIterationMultipleMask | SpvLoopControlPeelCountMask, 12,
- 0)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 113, (uint32_t)spv::LoopControlMask::DontUnroll, 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 113, (uint32_t)spv::LoopControlMask::PeelCount, 12, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationSetLoopControl(
+ 113,
+ (uint32_t)spv::LoopControlMask::IterationMultiple |
+ (uint32_t)spv::LoopControlMask::PeelCount,
+ 12, 0)
+ .IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(TransformationSetLoopControl(123, SpvLoopControlMaskNone, 0, 0)
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 123, (uint32_t)spv::LoopControlMask::MaskNone, 0, 0)
.IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(TransformationSetLoopControl(123, SpvLoopControlUnrollMask, 0, 0)
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 123, (uint32_t)spv::LoopControlMask::Unroll, 0, 0)
.IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(
- TransformationSetLoopControl(123, SpvLoopControlDontUnrollMask, 0, 0)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(
- TransformationSetLoopControl(
- 123,
- SpvLoopControlMinIterationsMask | SpvLoopControlMaxIterationsMask |
- SpvLoopControlIterationMultipleMask |
- SpvLoopControlPeelCountMask | SpvLoopControlPartialCountMask,
- 7, 8)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_TRUE(TransformationSetLoopControl(123,
- SpvLoopControlUnrollMask |
- SpvLoopControlMinIterationsMask |
- SpvLoopControlMaxIterationsMask |
- SpvLoopControlPartialCountMask,
- 0, 9)
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 123, (uint32_t)spv::LoopControlMask::DontUnroll, 0, 0)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 123,
+ (uint32_t)spv::LoopControlMask::MinIterations |
+ (uint32_t)spv::LoopControlMask::MaxIterations |
+ (uint32_t)spv::LoopControlMask::IterationMultiple |
+ (uint32_t)spv::LoopControlMask::PeelCount |
+ (uint32_t)spv::LoopControlMask::PartialCount,
+ 7, 8)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSetLoopControl(
+ 123,
+ (uint32_t)spv::LoopControlMask::Unroll |
+ (uint32_t)spv::LoopControlMask::MinIterations |
+ (uint32_t)spv::LoopControlMask::MaxIterations |
+ (uint32_t)spv::LoopControlMask::PartialCount,
+ 0, 9)
.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(TransformationSetLoopControl(
123,
- SpvLoopControlUnrollMask | SpvLoopControlMinIterationsMask |
- SpvLoopControlMaxIterationsMask |
- SpvLoopControlPartialCountMask,
+ (uint32_t)spv::LoopControlMask::Unroll |
+ (uint32_t)spv::LoopControlMask::MinIterations |
+ (uint32_t)spv::LoopControlMask::MaxIterations |
+ (uint32_t)spv::LoopControlMask::PartialCount,
+ 7, 9)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationSetLoopControl(
+ 123,
+ (uint32_t)spv::LoopControlMask::DontUnroll |
+ (uint32_t)spv::LoopControlMask::MinIterations |
+ (uint32_t)spv::LoopControlMask::MaxIterations |
+ (uint32_t)spv::LoopControlMask::PartialCount,
7, 9)
.IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(
- TransformationSetLoopControl(
- 123,
- SpvLoopControlDontUnrollMask | SpvLoopControlMinIterationsMask |
- SpvLoopControlMaxIterationsMask | SpvLoopControlPartialCountMask,
- 7, 9)
- .IsApplicable(context.get(), transformation_context));
+ ApplyAndCheckFreshIds(TransformationSetLoopControl(
+ 10,
+ (uint32_t)spv::LoopControlMask::Unroll |
+ (uint32_t)spv::LoopControlMask::PeelCount |
+ (uint32_t)spv::LoopControlMask::PartialCount,
+ 3, 3),
+ context.get(), &transformation_context);
ApplyAndCheckFreshIds(
- TransformationSetLoopControl(10,
- SpvLoopControlUnrollMask |
- SpvLoopControlPeelCountMask |
- SpvLoopControlPartialCountMask,
- 3, 3),
- context.get(), &transformation_context);
- ApplyAndCheckFreshIds(
- TransformationSetLoopControl(23, SpvLoopControlDontUnrollMask, 0, 0),
- context.get(), &transformation_context);
- ApplyAndCheckFreshIds(
- TransformationSetLoopControl(33, SpvLoopControlUnrollMask, 0, 0),
+ TransformationSetLoopControl(
+ 23, (uint32_t)spv::LoopControlMask::DontUnroll, 0, 0),
context.get(), &transformation_context);
+ ApplyAndCheckFreshIds(TransformationSetLoopControl(
+ 33, (uint32_t)spv::LoopControlMask::Unroll, 0, 0),
+ context.get(), &transformation_context);
ApplyAndCheckFreshIds(
TransformationSetLoopControl(
43,
- SpvLoopControlDontUnrollMask | SpvLoopControlDependencyInfiniteMask,
+ (uint32_t)spv::LoopControlMask::DontUnroll |
+ (uint32_t)spv::LoopControlMask::DependencyInfinite,
0, 0),
context.get(), &transformation_context);
- ApplyAndCheckFreshIds(
- TransformationSetLoopControl(53, SpvLoopControlMaskNone, 0, 0),
- context.get(), &transformation_context);
- ApplyAndCheckFreshIds(
- TransformationSetLoopControl(63,
- SpvLoopControlUnrollMask |
- SpvLoopControlMinIterationsMask |
- SpvLoopControlPeelCountMask,
- 23, 0),
- context.get(), &transformation_context);
- ApplyAndCheckFreshIds(
- TransformationSetLoopControl(73,
- SpvLoopControlUnrollMask |
- SpvLoopControlMaxIterationsMask |
- SpvLoopControlPeelCountMask,
- 23, 0),
- context.get(), &transformation_context);
- ApplyAndCheckFreshIds(
- TransformationSetLoopControl(83, SpvLoopControlDontUnrollMask, 0, 0),
- context.get(), &transformation_context);
+ ApplyAndCheckFreshIds(TransformationSetLoopControl(
+ 53, (uint32_t)spv::LoopControlMask::MaskNone, 0, 0),
+ context.get(), &transformation_context);
+ ApplyAndCheckFreshIds(TransformationSetLoopControl(
+ 63,
+ (uint32_t)spv::LoopControlMask::Unroll |
+ (uint32_t)spv::LoopControlMask::MinIterations |
+ (uint32_t)spv::LoopControlMask::PeelCount,
+ 23, 0),
+ context.get(), &transformation_context);
+ ApplyAndCheckFreshIds(TransformationSetLoopControl(
+ 73,
+ (uint32_t)spv::LoopControlMask::Unroll |
+ (uint32_t)spv::LoopControlMask::MaxIterations |
+ (uint32_t)spv::LoopControlMask::PeelCount,
+ 23, 0),
+ context.get(), &transformation_context);
ApplyAndCheckFreshIds(
TransformationSetLoopControl(
- 93, SpvLoopControlPeelCountMask | SpvLoopControlPartialCountMask, 16,
- 8),
+ 83, (uint32_t)spv::LoopControlMask::DontUnroll, 0, 0),
context.get(), &transformation_context);
+ ApplyAndCheckFreshIds(TransformationSetLoopControl(
+ 93,
+ (uint32_t)spv::LoopControlMask::PeelCount |
+ (uint32_t)spv::LoopControlMask::PartialCount,
+ 16, 8),
+ context.get(), &transformation_context);
ApplyAndCheckFreshIds(
- TransformationSetLoopControl(103, SpvLoopControlPartialCountMask, 0, 60),
- context.get(), &transformation_context);
- ApplyAndCheckFreshIds(
- TransformationSetLoopControl(113, SpvLoopControlPeelCountMask, 12, 0),
+ TransformationSetLoopControl(
+ 103, (uint32_t)spv::LoopControlMask::PartialCount, 0, 60),
context.get(), &transformation_context);
ApplyAndCheckFreshIds(
TransformationSetLoopControl(
- 123,
- SpvLoopControlUnrollMask | SpvLoopControlMinIterationsMask |
- SpvLoopControlMaxIterationsMask | SpvLoopControlPartialCountMask,
- 0, 9),
+ 113, (uint32_t)spv::LoopControlMask::PeelCount, 12, 0),
context.get(), &transformation_context);
+ ApplyAndCheckFreshIds(TransformationSetLoopControl(
+ 123,
+ (uint32_t)spv::LoopControlMask::Unroll |
+ (uint32_t)spv::LoopControlMask::MinIterations |
+ (uint32_t)spv::LoopControlMask::MaxIterations |
+ (uint32_t)spv::LoopControlMask::PartialCount,
+ 0, 9),
+ context.get(), &transformation_context);
std::string after_transformation = R"(
OpCapability Shader
@@ -958,10 +1018,10 @@ TEST(TransformationSetLoopControlTest, CheckSPIRVVersionsRespected) {
context.get(), validator_options, kConsoleMessageConsumer));
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
- TransformationSetLoopControl peel_count(10, SpvLoopControlPeelCountMask, 4,
- 0);
+ TransformationSetLoopControl peel_count(
+ 10, (uint32_t)spv::LoopControlMask::PeelCount, 4, 0);
TransformationSetLoopControl partial_count(
- 10, SpvLoopControlPartialCountMask, 0, 4);
+ 10, (uint32_t)spv::LoopControlMask::PartialCount, 0, 4);
switch (env) {
case SPV_ENV_UNIVERSAL_1_0:
diff --git a/test/fuzz/transformation_set_memory_operands_mask_test.cpp b/test/fuzz/transformation_set_memory_operands_mask_test.cpp
index 29e57f42e..44901f9c7 100644
--- a/test/fuzz/transformation_set_memory_operands_mask_test.cpp
+++ b/test/fuzz/transformation_set_memory_operands_mask_test.cpp
@@ -106,8 +106,10 @@ TEST(TransformationSetMemoryOperandsMaskTest, PreSpirv14) {
{
// Not OK: multiple operands are not supported pre SPIR-V 1.4.
TransformationSetMemoryOperandsMask transformation(
- MakeInstructionDescriptor(21, SpvOpCopyMemory, 3),
- SpvMemoryAccessNontemporalMask | SpvMemoryAccessVolatileMask, 1);
+ MakeInstructionDescriptor(21, spv::Op::OpCopyMemory, 3),
+ (uint32_t)spv::MemoryAccessMask::Nontemporal |
+ (uint32_t)spv::MemoryAccessMask::Volatile,
+ 1);
ASSERT_DEATH(
transformation.IsApplicable(context.get(), transformation_context),
"Multiple memory operand masks are not supported");
@@ -116,21 +118,24 @@ TEST(TransformationSetMemoryOperandsMaskTest, PreSpirv14) {
// Not OK: the instruction is not a memory access.
ASSERT_FALSE(TransformationSetMemoryOperandsMask(
- MakeInstructionDescriptor(21, SpvOpAccessChain, 0),
- SpvMemoryAccessMaskNone, 0)
+ MakeInstructionDescriptor(21, spv::Op::OpAccessChain, 0),
+ (uint32_t)spv::MemoryAccessMask::MaskNone, 0)
.IsApplicable(context.get(), transformation_context));
// Not OK to remove Aligned
- ASSERT_FALSE(
- TransformationSetMemoryOperandsMask(
- MakeInstructionDescriptor(147, SpvOpLoad, 0),
- SpvMemoryAccessVolatileMask | SpvMemoryAccessNontemporalMask, 0)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationSetMemoryOperandsMask(
+ MakeInstructionDescriptor(147, spv::Op::OpLoad, 0),
+ (uint32_t)spv::MemoryAccessMask::Volatile |
+ (uint32_t)spv::MemoryAccessMask::Nontemporal,
+ 0)
+ .IsApplicable(context.get(), transformation_context));
{
TransformationSetMemoryOperandsMask transformation(
- MakeInstructionDescriptor(147, SpvOpLoad, 0),
- SpvMemoryAccessAlignedMask | SpvMemoryAccessVolatileMask, 0);
+ MakeInstructionDescriptor(147, spv::Op::OpLoad, 0),
+ (uint32_t)spv::MemoryAccessMask::Aligned |
+ (uint32_t)spv::MemoryAccessMask::Volatile,
+ 0);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -139,22 +144,23 @@ TEST(TransformationSetMemoryOperandsMaskTest, PreSpirv14) {
// Not OK to remove Aligned
ASSERT_FALSE(TransformationSetMemoryOperandsMask(
- MakeInstructionDescriptor(21, SpvOpCopyMemory, 0),
- SpvMemoryAccessMaskNone, 0)
+ MakeInstructionDescriptor(21, spv::Op::OpCopyMemory, 0),
+ (uint32_t)spv::MemoryAccessMask::MaskNone, 0)
.IsApplicable(context.get(), transformation_context));
// OK: leaves the mask as is
ASSERT_TRUE(TransformationSetMemoryOperandsMask(
- MakeInstructionDescriptor(21, SpvOpCopyMemory, 0),
- SpvMemoryAccessAlignedMask, 0)
+ MakeInstructionDescriptor(21, spv::Op::OpCopyMemory, 0),
+ (uint32_t)spv::MemoryAccessMask::Aligned, 0)
.IsApplicable(context.get(), transformation_context));
{
// OK: adds Nontemporal and Volatile
TransformationSetMemoryOperandsMask transformation(
- MakeInstructionDescriptor(21, SpvOpCopyMemory, 0),
- SpvMemoryAccessAlignedMask | SpvMemoryAccessNontemporalMask |
- SpvMemoryAccessVolatileMask,
+ MakeInstructionDescriptor(21, spv::Op::OpCopyMemory, 0),
+ (uint32_t)spv::MemoryAccessMask::Aligned |
+ (uint32_t)spv::MemoryAccessMask::Nontemporal |
+ (uint32_t)spv::MemoryAccessMask::Volatile,
0);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
@@ -164,22 +170,25 @@ TEST(TransformationSetMemoryOperandsMaskTest, PreSpirv14) {
// Not OK to remove Volatile
ASSERT_FALSE(TransformationSetMemoryOperandsMask(
- MakeInstructionDescriptor(21, SpvOpCopyMemory, 1),
- SpvMemoryAccessNontemporalMask, 0)
+ MakeInstructionDescriptor(21, spv::Op::OpCopyMemory, 1),
+ (uint32_t)spv::MemoryAccessMask::Nontemporal, 0)
.IsApplicable(context.get(), transformation_context));
// Not OK to add Aligned
ASSERT_FALSE(TransformationSetMemoryOperandsMask(
- MakeInstructionDescriptor(21, SpvOpCopyMemory, 1),
- SpvMemoryAccessAlignedMask | SpvMemoryAccessVolatileMask,
+ MakeInstructionDescriptor(21, spv::Op::OpCopyMemory, 1),
+ (uint32_t)spv::MemoryAccessMask::Aligned |
+ (uint32_t)spv::MemoryAccessMask::Volatile,
0)
.IsApplicable(context.get(), transformation_context));
{
// OK: adds Nontemporal
TransformationSetMemoryOperandsMask transformation(
- MakeInstructionDescriptor(21, SpvOpCopyMemory, 1),
- SpvMemoryAccessNontemporalMask | SpvMemoryAccessVolatileMask, 0);
+ MakeInstructionDescriptor(21, spv::Op::OpCopyMemory, 1),
+ (uint32_t)spv::MemoryAccessMask::Nontemporal |
+ (uint32_t)spv::MemoryAccessMask::Volatile,
+ 0);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -189,8 +198,10 @@ TEST(TransformationSetMemoryOperandsMaskTest, PreSpirv14) {
{
// OK: adds Nontemporal (creates new operand)
TransformationSetMemoryOperandsMask transformation(
- MakeInstructionDescriptor(21, SpvOpCopyMemory, 2),
- SpvMemoryAccessNontemporalMask | SpvMemoryAccessVolatileMask, 0);
+ MakeInstructionDescriptor(21, spv::Op::OpCopyMemory, 2),
+ (uint32_t)spv::MemoryAccessMask::Nontemporal |
+ (uint32_t)spv::MemoryAccessMask::Volatile,
+ 0);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -200,8 +211,10 @@ TEST(TransformationSetMemoryOperandsMaskTest, PreSpirv14) {
{
// OK: adds Nontemporal and Volatile
TransformationSetMemoryOperandsMask transformation(
- MakeInstructionDescriptor(138, SpvOpCopyMemory, 0),
- SpvMemoryAccessNontemporalMask | SpvMemoryAccessVolatileMask, 0);
+ MakeInstructionDescriptor(138, spv::Op::OpCopyMemory, 0),
+ (uint32_t)spv::MemoryAccessMask::Nontemporal |
+ (uint32_t)spv::MemoryAccessMask::Volatile,
+ 0);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -211,8 +224,8 @@ TEST(TransformationSetMemoryOperandsMaskTest, PreSpirv14) {
{
// OK: removes Nontemporal, adds Volatile
TransformationSetMemoryOperandsMask transformation(
- MakeInstructionDescriptor(148, SpvOpStore, 0),
- SpvMemoryAccessVolatileMask, 0);
+ MakeInstructionDescriptor(148, spv::Op::OpStore, 0),
+ (uint32_t)spv::MemoryAccessMask::Volatile, 0);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -369,12 +382,14 @@ TEST(TransformationSetMemoryOperandsMaskTest, Spirv14OrHigher) {
MakeUnique<FactManager>(context.get()), validator_options);
{
TransformationSetMemoryOperandsMask transformation(
- MakeInstructionDescriptor(21, SpvOpCopyMemory, 0),
- SpvMemoryAccessAlignedMask | SpvMemoryAccessVolatileMask, 1);
+ MakeInstructionDescriptor(21, spv::Op::OpCopyMemory, 0),
+ (uint32_t)spv::MemoryAccessMask::Aligned |
+ (uint32_t)spv::MemoryAccessMask::Volatile,
+ 1);
// Bad: cannot remove aligned
ASSERT_FALSE(TransformationSetMemoryOperandsMask(
- MakeInstructionDescriptor(21, SpvOpCopyMemory, 0),
- SpvMemoryAccessVolatileMask, 1)
+ MakeInstructionDescriptor(21, spv::Op::OpCopyMemory, 0),
+ (uint32_t)spv::MemoryAccessMask::Volatile, 1)
.IsApplicable(context.get(), transformation_context));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
@@ -384,12 +399,14 @@ TEST(TransformationSetMemoryOperandsMaskTest, Spirv14OrHigher) {
{
TransformationSetMemoryOperandsMask transformation(
- MakeInstructionDescriptor(21, SpvOpCopyMemory, 1),
- SpvMemoryAccessNontemporalMask | SpvMemoryAccessVolatileMask, 1);
+ MakeInstructionDescriptor(21, spv::Op::OpCopyMemory, 1),
+ (uint32_t)spv::MemoryAccessMask::Nontemporal |
+ (uint32_t)spv::MemoryAccessMask::Volatile,
+ 1);
// Bad: cannot remove volatile
ASSERT_FALSE(TransformationSetMemoryOperandsMask(
- MakeInstructionDescriptor(21, SpvOpCopyMemory, 1),
- SpvMemoryAccessNontemporalMask, 0)
+ MakeInstructionDescriptor(21, spv::Op::OpCopyMemory, 1),
+ (uint32_t)spv::MemoryAccessMask::Nontemporal, 0)
.IsApplicable(context.get(), transformation_context));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
@@ -400,8 +417,10 @@ TEST(TransformationSetMemoryOperandsMaskTest, Spirv14OrHigher) {
{
// Creates the first operand.
TransformationSetMemoryOperandsMask transformation(
- MakeInstructionDescriptor(21, SpvOpCopyMemory, 2),
- SpvMemoryAccessNontemporalMask | SpvMemoryAccessVolatileMask, 0);
+ MakeInstructionDescriptor(21, spv::Op::OpCopyMemory, 2),
+ (uint32_t)spv::MemoryAccessMask::Nontemporal |
+ (uint32_t)spv::MemoryAccessMask::Volatile,
+ 0);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -411,8 +430,10 @@ TEST(TransformationSetMemoryOperandsMaskTest, Spirv14OrHigher) {
{
// Creates both operands.
TransformationSetMemoryOperandsMask transformation(
- MakeInstructionDescriptor(21, SpvOpCopyMemory, 3),
- SpvMemoryAccessNontemporalMask | SpvMemoryAccessVolatileMask, 1);
+ MakeInstructionDescriptor(21, spv::Op::OpCopyMemory, 3),
+ (uint32_t)spv::MemoryAccessMask::Nontemporal |
+ (uint32_t)spv::MemoryAccessMask::Volatile,
+ 1);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -421,14 +442,17 @@ TEST(TransformationSetMemoryOperandsMaskTest, Spirv14OrHigher) {
{
TransformationSetMemoryOperandsMask transformation(
- MakeInstructionDescriptor(138, SpvOpCopyMemory, 0),
- SpvMemoryAccessAlignedMask | SpvMemoryAccessNontemporalMask, 1);
+ MakeInstructionDescriptor(138, spv::Op::OpCopyMemory, 0),
+ (uint32_t)spv::MemoryAccessMask::Aligned |
+ (uint32_t)spv::MemoryAccessMask::Nontemporal,
+ 1);
// Bad: the first mask is None, so Aligned cannot be added to it.
- ASSERT_FALSE(
- TransformationSetMemoryOperandsMask(
- MakeInstructionDescriptor(138, SpvOpCopyMemory, 0),
- SpvMemoryAccessAlignedMask | SpvMemoryAccessNontemporalMask, 0)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationSetMemoryOperandsMask(
+ MakeInstructionDescriptor(138, spv::Op::OpCopyMemory, 0),
+ (uint32_t)spv::MemoryAccessMask::Aligned |
+ (uint32_t)spv::MemoryAccessMask::Nontemporal,
+ 0)
+ .IsApplicable(context.get(), transformation_context));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -437,8 +461,8 @@ TEST(TransformationSetMemoryOperandsMaskTest, Spirv14OrHigher) {
{
TransformationSetMemoryOperandsMask transformation(
- MakeInstructionDescriptor(138, SpvOpCopyMemory, 1),
- SpvMemoryAccessVolatileMask, 1);
+ MakeInstructionDescriptor(138, spv::Op::OpCopyMemory, 1),
+ (uint32_t)spv::MemoryAccessMask::Volatile, 1);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -447,8 +471,10 @@ TEST(TransformationSetMemoryOperandsMaskTest, Spirv14OrHigher) {
{
TransformationSetMemoryOperandsMask transformation(
- MakeInstructionDescriptor(147, SpvOpLoad, 0),
- SpvMemoryAccessVolatileMask | SpvMemoryAccessAlignedMask, 0);
+ MakeInstructionDescriptor(147, spv::Op::OpLoad, 0),
+ (uint32_t)spv::MemoryAccessMask::Volatile |
+ (uint32_t)spv::MemoryAccessMask::Aligned,
+ 0);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -457,8 +483,8 @@ TEST(TransformationSetMemoryOperandsMaskTest, Spirv14OrHigher) {
{
TransformationSetMemoryOperandsMask transformation(
- MakeInstructionDescriptor(148, SpvOpStore, 0),
- SpvMemoryAccessMaskNone, 0);
+ MakeInstructionDescriptor(148, spv::Op::OpStore, 0),
+ (uint32_t)spv::MemoryAccessMask::MaskNone, 0);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
diff --git a/test/fuzz/transformation_set_selection_control_test.cpp b/test/fuzz/transformation_set_selection_control_test.cpp
index c584ff131..4cecd23e7 100644
--- a/test/fuzz/transformation_set_selection_control_test.cpp
+++ b/test/fuzz/transformation_set_selection_control_test.cpp
@@ -109,41 +109,41 @@ TEST(TransformationSetSelectionControlTest, VariousScenarios) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
// %44 is not a block
- ASSERT_FALSE(
- TransformationSetSelectionControl(44, SpvSelectionControlFlattenMask)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationSetSelectionControl(
+ 44, uint32_t(spv::SelectionControlMask::Flatten))
+ .IsApplicable(context.get(), transformation_context));
// %13 does not end with OpSelectionMerge
- ASSERT_FALSE(
- TransformationSetSelectionControl(13, SpvSelectionControlMaskNone)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationSetSelectionControl(
+ 13, uint32_t(spv::SelectionControlMask::MaskNone))
+ .IsApplicable(context.get(), transformation_context));
// %10 ends in OpLoopMerge, not OpSelectionMerge
- ASSERT_FALSE(
- TransformationSetSelectionControl(10, SpvSelectionControlMaskNone)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationSetSelectionControl(
+ 10, uint32_t(spv::SelectionControlMask::MaskNone))
+ .IsApplicable(context.get(), transformation_context));
TransformationSetSelectionControl transformation1(
- 11, SpvSelectionControlDontFlattenMask);
+ 11, uint32_t(spv::SelectionControlMask::DontFlatten));
ASSERT_TRUE(
transformation1.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation1, context.get(),
&transformation_context);
TransformationSetSelectionControl transformation2(
- 23, SpvSelectionControlFlattenMask);
+ 23, uint32_t(spv::SelectionControlMask::Flatten));
ASSERT_TRUE(
transformation2.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation2, context.get(),
&transformation_context);
TransformationSetSelectionControl transformation3(
- 31, SpvSelectionControlMaskNone);
+ 31, uint32_t(spv::SelectionControlMask::MaskNone));
ASSERT_TRUE(
transformation3.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation3, context.get(),
&transformation_context);
TransformationSetSelectionControl transformation4(
- 31, SpvSelectionControlFlattenMask);
+ 31, uint32_t(spv::SelectionControlMask::Flatten));
ASSERT_TRUE(
transformation4.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation4, context.get(),
diff --git a/test/fuzz/transformation_split_block_test.cpp b/test/fuzz/transformation_split_block_test.cpp
index 55091dede..1cef18230 100644
--- a/test/fuzz/transformation_split_block_test.cpp
+++ b/test/fuzz/transformation_split_block_test.cpp
@@ -96,53 +96,54 @@ TEST(TransformationSplitBlockTest, NotApplicable) {
MakeUnique<FactManager>(context.get()), validator_options);
// No split before OpVariable
ASSERT_FALSE(TransformationSplitBlock(
- MakeInstructionDescriptor(8, SpvOpVariable, 0), 100)
+ MakeInstructionDescriptor(8, spv::Op::OpVariable, 0), 100)
.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(TransformationSplitBlock(
- MakeInstructionDescriptor(8, SpvOpVariable, 1), 100)
+ MakeInstructionDescriptor(8, spv::Op::OpVariable, 1), 100)
.IsApplicable(context.get(), transformation_context));
// No split before OpLabel
ASSERT_FALSE(TransformationSplitBlock(
- MakeInstructionDescriptor(14, SpvOpLabel, 0), 100)
+ MakeInstructionDescriptor(14, spv::Op::OpLabel, 0), 100)
.IsApplicable(context.get(), transformation_context));
// No split if base instruction is outside a function
- ASSERT_FALSE(
- TransformationSplitBlock(MakeInstructionDescriptor(1, SpvOpLabel, 0), 100)
- .IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(TransformationSplitBlock(
- MakeInstructionDescriptor(1, SpvOpExecutionMode, 0), 100)
+ MakeInstructionDescriptor(1, spv::Op::OpLabel, 0), 100)
.IsApplicable(context.get(), transformation_context));
-
- // No split if block is loop header
ASSERT_FALSE(
- TransformationSplitBlock(MakeInstructionDescriptor(27, SpvOpPhi, 0), 100)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(
- TransformationSplitBlock(MakeInstructionDescriptor(27, SpvOpPhi, 1), 100)
+ TransformationSplitBlock(
+ MakeInstructionDescriptor(1, spv::Op::OpExecutionMode, 0), 100)
.IsApplicable(context.get(), transformation_context));
+ // No split if block is loop header
+ ASSERT_FALSE(TransformationSplitBlock(
+ MakeInstructionDescriptor(27, spv::Op::OpPhi, 0), 100)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationSplitBlock(
+ MakeInstructionDescriptor(27, spv::Op::OpPhi, 1), 100)
+ .IsApplicable(context.get(), transformation_context));
+
// No split if base instruction does not exist
- ASSERT_FALSE(
- TransformationSplitBlock(MakeInstructionDescriptor(88, SpvOpIAdd, 0), 100)
- .IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(TransformationSplitBlock(
- MakeInstructionDescriptor(88, SpvOpIMul, 22), 100)
+ MakeInstructionDescriptor(88, spv::Op::OpIAdd, 0), 100)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationSplitBlock(
+ MakeInstructionDescriptor(88, spv::Op::OpIMul, 22), 100)
.IsApplicable(context.get(), transformation_context));
// No split if too many instructions with the desired opcode are skipped
ASSERT_FALSE(
TransformationSplitBlock(
- MakeInstructionDescriptor(18, SpvOpBranchConditional, 1), 100)
+ MakeInstructionDescriptor(18, spv::Op::OpBranchConditional, 1), 100)
.IsApplicable(context.get(), transformation_context));
// No split if id in use
ASSERT_FALSE(TransformationSplitBlock(
- MakeInstructionDescriptor(18, SpvOpSLessThan, 0), 27)
+ MakeInstructionDescriptor(18, spv::Op::OpSLessThan, 0), 27)
.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(TransformationSplitBlock(
- MakeInstructionDescriptor(18, SpvOpSLessThan, 0), 14)
+ MakeInstructionDescriptor(18, spv::Op::OpSLessThan, 0), 14)
.IsApplicable(context.get(), transformation_context));
}
@@ -206,7 +207,7 @@ TEST(TransformationSplitBlockTest, SplitBlockSeveralTimes) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
auto split_1 = TransformationSplitBlock(
- MakeInstructionDescriptor(5, SpvOpStore, 0), 100);
+ MakeInstructionDescriptor(5, spv::Op::OpStore, 0), 100);
ASSERT_TRUE(split_1.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(split_1, context.get(), &transformation_context);
ASSERT_TRUE(fuzzerutil::IsValidAndWellFormed(context.get(), validator_options,
@@ -255,7 +256,7 @@ TEST(TransformationSplitBlockTest, SplitBlockSeveralTimes) {
ASSERT_TRUE(IsEqual(env, after_split_1, context.get()));
auto split_2 = TransformationSplitBlock(
- MakeInstructionDescriptor(11, SpvOpStore, 0), 101);
+ MakeInstructionDescriptor(11, spv::Op::OpStore, 0), 101);
ASSERT_TRUE(split_2.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(split_2, context.get(), &transformation_context);
ASSERT_TRUE(fuzzerutil::IsValidAndWellFormed(context.get(), validator_options,
@@ -306,7 +307,7 @@ TEST(TransformationSplitBlockTest, SplitBlockSeveralTimes) {
ASSERT_TRUE(IsEqual(env, after_split_2, context.get()));
auto split_3 = TransformationSplitBlock(
- MakeInstructionDescriptor(14, SpvOpLoad, 0), 102);
+ MakeInstructionDescriptor(14, spv::Op::OpLoad, 0), 102);
ASSERT_TRUE(split_3.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(split_3, context.get(), &transformation_context);
ASSERT_TRUE(fuzzerutil::IsValidAndWellFormed(context.get(), validator_options,
@@ -425,15 +426,15 @@ TEST(TransformationSplitBlockTest, SplitBlockBeforeSelectBranch) {
// Illegal to split between the merge and the conditional branch.
ASSERT_FALSE(
TransformationSplitBlock(
- MakeInstructionDescriptor(14, SpvOpBranchConditional, 0), 100)
+ MakeInstructionDescriptor(14, spv::Op::OpBranchConditional, 0), 100)
.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(
TransformationSplitBlock(
- MakeInstructionDescriptor(12, SpvOpBranchConditional, 0), 100)
+ MakeInstructionDescriptor(12, spv::Op::OpBranchConditional, 0), 100)
.IsApplicable(context.get(), transformation_context));
auto split = TransformationSplitBlock(
- MakeInstructionDescriptor(14, SpvOpSelectionMerge, 0), 100);
+ MakeInstructionDescriptor(14, spv::Op::OpSelectionMerge, 0), 100);
ASSERT_TRUE(split.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(split, context.get(), &transformation_context);
ASSERT_TRUE(fuzzerutil::IsValidAndWellFormed(context.get(), validator_options,
@@ -555,14 +556,14 @@ TEST(TransformationSplitBlockTest, SplitBlockBeforeSwitchBranch) {
MakeUnique<FactManager>(context.get()), validator_options);
// Illegal to split between the merge and the conditional branch.
ASSERT_FALSE(TransformationSplitBlock(
- MakeInstructionDescriptor(9, SpvOpSwitch, 0), 100)
+ MakeInstructionDescriptor(9, spv::Op::OpSwitch, 0), 100)
.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(TransformationSplitBlock(
- MakeInstructionDescriptor(15, SpvOpSwitch, 0), 100)
+ MakeInstructionDescriptor(15, spv::Op::OpSwitch, 0), 100)
.IsApplicable(context.get(), transformation_context));
auto split = TransformationSplitBlock(
- MakeInstructionDescriptor(9, SpvOpSelectionMerge, 0), 100);
+ MakeInstructionDescriptor(9, spv::Op::OpSelectionMerge, 0), 100);
ASSERT_TRUE(split.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(split, context.get(), &transformation_context);
ASSERT_TRUE(fuzzerutil::IsValidAndWellFormed(context.get(), validator_options,
@@ -690,15 +691,15 @@ TEST(TransformationSplitBlockTest, NoSplitDuringOpPhis) {
MakeUnique<FactManager>(context.get()), validator_options);
// We cannot split before OpPhi instructions, since the number of incoming
// blocks may not appropriately match after splitting.
- ASSERT_FALSE(
- TransformationSplitBlock(MakeInstructionDescriptor(26, SpvOpPhi, 0), 100)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(
- TransformationSplitBlock(MakeInstructionDescriptor(27, SpvOpPhi, 0), 100)
- .IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(
- TransformationSplitBlock(MakeInstructionDescriptor(27, SpvOpPhi, 1), 100)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationSplitBlock(
+ MakeInstructionDescriptor(26, spv::Op::OpPhi, 0), 100)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationSplitBlock(
+ MakeInstructionDescriptor(27, spv::Op::OpPhi, 0), 100)
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationSplitBlock(
+ MakeInstructionDescriptor(27, spv::Op::OpPhi, 1), 100)
+ .IsApplicable(context.get(), transformation_context));
}
TEST(TransformationSplitBlockTest, SplitOpPhiWithSinglePredecessor) {
@@ -741,13 +742,13 @@ TEST(TransformationSplitBlockTest, SplitOpPhiWithSinglePredecessor) {
spvtools::ValidatorOptions validator_options;
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
- ASSERT_TRUE(
- TransformationSplitBlock(MakeInstructionDescriptor(21, SpvOpPhi, 0), 100)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_TRUE(TransformationSplitBlock(
+ MakeInstructionDescriptor(21, spv::Op::OpPhi, 0), 100)
+ .IsApplicable(context.get(), transformation_context));
// An equivalent transformation to the above, just described with respect to a
// different base instruction.
- auto split =
- TransformationSplitBlock(MakeInstructionDescriptor(20, SpvOpPhi, 0), 100);
+ auto split = TransformationSplitBlock(
+ MakeInstructionDescriptor(20, spv::Op::OpPhi, 0), 100);
ASSERT_TRUE(split.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(split, context.get(), &transformation_context);
ASSERT_TRUE(fuzzerutil::IsValidAndWellFormed(context.get(), validator_options,
@@ -826,7 +827,7 @@ TEST(TransformationSplitBlockTest, DeadBlockShouldSplitToTwoDeadBlocks) {
transformation_context.GetFactManager()->AddFactBlockIsDead(8);
auto split = TransformationSplitBlock(
- MakeInstructionDescriptor(8, SpvOpBranch, 0), 100);
+ MakeInstructionDescriptor(8, spv::Op::OpBranch, 0), 100);
ASSERT_TRUE(split.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(split, context.get(), &transformation_context);
ASSERT_TRUE(fuzzerutil::IsValidAndWellFormed(context.get(), validator_options,
@@ -912,7 +913,8 @@ TEST(TransformationSplitBlockTest, DoNotSplitUseOfOpSampledImage) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
auto split = TransformationSplitBlock(
- MakeInstructionDescriptor(217, SpvOpImageSampleImplicitLod, 0), 500);
+ MakeInstructionDescriptor(217, spv::Op::OpImageSampleImplicitLod, 0),
+ 500);
ASSERT_FALSE(split.IsApplicable(context.get(), transformation_context));
}
diff --git a/test/fuzz/transformation_store_test.cpp b/test/fuzz/transformation_store_test.cpp
index dd653e28d..fe24d744a 100644
--- a/test/fuzz/transformation_store_test.cpp
+++ b/test/fuzz/transformation_store_test.cpp
@@ -148,107 +148,107 @@ TEST(TransformationStoreTest, BasicTest) {
// 61 - undefined
// Bad: attempt to store to 11 from outside its function
- ASSERT_FALSE(
- TransformationStore(11, false, 0, 0, 80,
- MakeInstructionDescriptor(38, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationStore(
+ 11, false, 0, 0, 80,
+ MakeInstructionDescriptor(38, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: pointer is not available
- ASSERT_FALSE(
- TransformationStore(81, false, 0, 0, 80,
- MakeInstructionDescriptor(45, SpvOpCopyObject, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationStore(
+ 81, false, 0, 0, 80,
+ MakeInstructionDescriptor(45, spv::Op::OpCopyObject, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: attempt to insert before OpVariable
ASSERT_FALSE(
TransformationStore(52, false, 0, 0, 24,
- MakeInstructionDescriptor(27, SpvOpVariable, 0))
+ MakeInstructionDescriptor(27, spv::Op::OpVariable, 0))
.IsApplicable(context.get(), transformation_context));
// Bad: pointer id does not exist
- ASSERT_FALSE(
- TransformationStore(1000, false, 0, 0, 24,
- MakeInstructionDescriptor(38, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationStore(
+ 1000, false, 0, 0, 24,
+ MakeInstructionDescriptor(38, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: pointer id exists but does not have a type
- ASSERT_FALSE(
- TransformationStore(5, false, 0, 0, 24,
- MakeInstructionDescriptor(38, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationStore(
+ 5, false, 0, 0, 24,
+ MakeInstructionDescriptor(38, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: pointer id exists and has a type, but is not a pointer
- ASSERT_FALSE(
- TransformationStore(24, false, 0, 0, 24,
- MakeInstructionDescriptor(38, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationStore(
+ 24, false, 0, 0, 24,
+ MakeInstructionDescriptor(38, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: attempt to store to a null pointer
- ASSERT_FALSE(
- TransformationStore(60, false, 0, 0, 24,
- MakeInstructionDescriptor(38, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationStore(
+ 60, false, 0, 0, 24,
+ MakeInstructionDescriptor(38, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: attempt to store to an undefined pointer
- ASSERT_FALSE(
- TransformationStore(61, false, 0, 0, 21,
- MakeInstructionDescriptor(38, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationStore(
+ 61, false, 0, 0, 21,
+ MakeInstructionDescriptor(38, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: %82 is not available at the program point
ASSERT_FALSE(
TransformationStore(82, false, 0, 0, 80,
- MakeInstructionDescriptor(37, SpvOpReturn, 0))
+ MakeInstructionDescriptor(37, spv::Op::OpReturn, 0))
.IsApplicable(context.get(), transformation_context));
// Bad: value id does not exist
- ASSERT_FALSE(
- TransformationStore(27, false, 0, 0, 1000,
- MakeInstructionDescriptor(38, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationStore(
+ 27, false, 0, 0, 1000,
+ MakeInstructionDescriptor(38, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: value id exists but does not have a type
- ASSERT_FALSE(
- TransformationStore(27, false, 0, 0, 15,
- MakeInstructionDescriptor(38, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationStore(
+ 27, false, 0, 0, 15,
+ MakeInstructionDescriptor(38, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: value id exists but has the wrong type
- ASSERT_FALSE(
- TransformationStore(27, false, 0, 0, 14,
- MakeInstructionDescriptor(38, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationStore(
+ 27, false, 0, 0, 14,
+ MakeInstructionDescriptor(38, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: attempt to store to read-only variable
- ASSERT_FALSE(
- TransformationStore(92, false, 0, 0, 93,
- MakeInstructionDescriptor(40, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationStore(
+ 92, false, 0, 0, 93,
+ MakeInstructionDescriptor(40, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: value is not available
- ASSERT_FALSE(
- TransformationStore(27, false, 0, 0, 95,
- MakeInstructionDescriptor(40, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationStore(
+ 27, false, 0, 0, 95,
+ MakeInstructionDescriptor(40, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: variable being stored to does not have an irrelevant pointee value,
// and the store is not in a dead block.
- ASSERT_FALSE(
- TransformationStore(20, false, 0, 0, 95,
- MakeInstructionDescriptor(45, SpvOpCopyObject, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationStore(
+ 20, false, 0, 0, 95,
+ MakeInstructionDescriptor(45, spv::Op::OpCopyObject, 0))
+ .IsApplicable(context.get(), transformation_context));
// The described instruction does not exist.
- ASSERT_FALSE(
- TransformationStore(27, false, 0, 0, 80,
- MakeInstructionDescriptor(1000, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationStore(
+ 27, false, 0, 0, 80,
+ MakeInstructionDescriptor(1000, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
{
// Store to irrelevant variable from dead block.
TransformationStore transformation(
27, false, 0, 0, 80,
- MakeInstructionDescriptor(38, SpvOpAccessChain, 0));
+ MakeInstructionDescriptor(38, spv::Op::OpAccessChain, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -261,7 +261,7 @@ TEST(TransformationStoreTest, BasicTest) {
// Store to irrelevant variable from live block.
TransformationStore transformation(
11, false, 0, 0, 95,
- MakeInstructionDescriptor(95, SpvOpReturnValue, 0));
+ MakeInstructionDescriptor(95, spv::Op::OpReturnValue, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -274,7 +274,7 @@ TEST(TransformationStoreTest, BasicTest) {
// Store to irrelevant variable from live block.
TransformationStore transformation(
46, false, 0, 0, 80,
- MakeInstructionDescriptor(95, SpvOpReturnValue, 0));
+ MakeInstructionDescriptor(95, spv::Op::OpReturnValue, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -287,7 +287,7 @@ TEST(TransformationStoreTest, BasicTest) {
// Store to irrelevant variable from live block.
TransformationStore transformation(
16, false, 0, 0, 21,
- MakeInstructionDescriptor(95, SpvOpReturnValue, 0));
+ MakeInstructionDescriptor(95, spv::Op::OpReturnValue, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -300,7 +300,7 @@ TEST(TransformationStoreTest, BasicTest) {
// Store to non-irrelevant variable from dead block.
TransformationStore transformation(
53, false, 0, 0, 21,
- MakeInstructionDescriptor(38, SpvOpAccessChain, 0));
+ MakeInstructionDescriptor(38, spv::Op::OpAccessChain, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
@@ -436,15 +436,15 @@ TEST(TransformationStoreTest, DoNotAllowStoresToReadOnlyMemory) {
ASSERT_FALSE(
TransformationStore(15, false, 0, 0, 13,
- MakeInstructionDescriptor(27, SpvOpReturn, 0))
+ MakeInstructionDescriptor(27, spv::Op::OpReturn, 0))
.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(
TransformationStore(19, false, 0, 0, 50,
- MakeInstructionDescriptor(27, SpvOpReturn, 0))
+ MakeInstructionDescriptor(27, spv::Op::OpReturn, 0))
.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(
TransformationStore(27, false, 0, 0, 50,
- MakeInstructionDescriptor(27, SpvOpReturn, 0))
+ MakeInstructionDescriptor(27, spv::Op::OpReturn, 0))
.IsApplicable(context.get(), transformation_context));
}
@@ -495,84 +495,85 @@ TEST(TransformationStoreTest, SupportAtomicStore) {
14);
// Bad: id 100 of memory scope instruction does not exist.
- ASSERT_FALSE(
- TransformationStore(14, true, 100, 20, 21,
- MakeInstructionDescriptor(24, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationStore(
+ 14, true, 100, 20, 21,
+ MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: id 100 of memory semantics instruction does not exist.
- ASSERT_FALSE(
- TransformationStore(14, true, 15, 100, 21,
- MakeInstructionDescriptor(24, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationStore(
+ 14, true, 15, 100, 21,
+ MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: memory scope should be |OpConstant| opcode.
- ASSERT_FALSE(
- TransformationStore(14, true, 5, 20, 21,
- MakeInstructionDescriptor(24, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationStore(
+ 14, true, 5, 20, 21,
+ MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: memory semantics should be |OpConstant| opcode.
- ASSERT_FALSE(
- TransformationStore(14, true, 15, 5, 21,
- MakeInstructionDescriptor(24, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationStore(
+ 14, true, 15, 5, 21,
+ MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: The memory scope instruction must have an Integer operand.
- ASSERT_FALSE(
- TransformationStore(14, true, 15, 19, 21,
- MakeInstructionDescriptor(24, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationStore(
+ 14, true, 15, 19, 21,
+ MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: The memory memory semantics instruction must have an Integer operand.
- ASSERT_FALSE(
- TransformationStore(14, true, 19, 20, 21,
- MakeInstructionDescriptor(24, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationStore(
+ 14, true, 19, 20, 21,
+ MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: Integer size of the memory scope must be equal to 32 bits.
- ASSERT_FALSE(
- TransformationStore(14, true, 17, 20, 21,
- MakeInstructionDescriptor(24, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationStore(
+ 14, true, 17, 20, 21,
+ MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: Integer size of memory semantics must be equal to 32 bits.
- ASSERT_FALSE(
- TransformationStore(14, true, 15, 17, 21,
- MakeInstructionDescriptor(24, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationStore(
+ 14, true, 15, 17, 21,
+ MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
- // Bad: memory scope value must be 4 (SpvScopeInvocation).
- ASSERT_FALSE(
- TransformationStore(14, true, 16, 20, 21,
- MakeInstructionDescriptor(24, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ // Bad: memory scope value must be 4 (spv::Scope::Invocation).
+ ASSERT_FALSE(TransformationStore(
+ 14, true, 16, 20, 21,
+ MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: memory semantics value must be either:
// 64 (SpvMemorySemanticsUniformMemoryMask)
// 256 (SpvMemorySemanticsWorkgroupMemoryMask)
- ASSERT_FALSE(
- TransformationStore(14, true, 15, 16, 21,
- MakeInstructionDescriptor(24, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationStore(
+ 14, true, 15, 16, 21,
+ MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: The described instruction does not exist
- ASSERT_FALSE(
- TransformationStore(14, true, 15, 20, 21,
- MakeInstructionDescriptor(150, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationStore(
+ 14, true, 15, 20, 21,
+ MakeInstructionDescriptor(150, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: Can't insert OpAccessChain before the id 15 of memory scope.
- ASSERT_FALSE(
- TransformationStore(14, true, 15, 20, 21,
- MakeInstructionDescriptor(15, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationStore(
+ 14, true, 15, 20, 21,
+ MakeInstructionDescriptor(15, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Bad: Can't insert OpAccessChain before the id 20 of memory semantics.
- ASSERT_FALSE(
- TransformationStore(14, true, 15, 20, 21,
- MakeInstructionDescriptor(20, SpvOpAccessChain, 0))
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationStore(
+ 14, true, 15, 20, 21,
+ MakeInstructionDescriptor(20, spv::Op::OpAccessChain, 0))
+ .IsApplicable(context.get(), transformation_context));
// Successful transformations.
{
TransformationStore transformation(
- 14, true, 15, 20, 21, MakeInstructionDescriptor(24, SpvOpReturn, 0));
+ 14, true, 15, 20, 21,
+ MakeInstructionDescriptor(24, spv::Op::OpReturn, 0));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(),
diff --git a/test/fuzz/transformation_swap_commutable_operands_test.cpp b/test/fuzz/transformation_swap_commutable_operands_test.cpp
index 07315294a..789dd09aa 100644
--- a/test/fuzz/transformation_swap_commutable_operands_test.cpp
+++ b/test/fuzz/transformation_swap_commutable_operands_test.cpp
@@ -118,103 +118,108 @@ TEST(TransformationSwapCommutableOperandsTest, IsApplicableTest) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
// Tests existing commutative instructions
- auto instructionDescriptor = MakeInstructionDescriptor(22, SpvOpIAdd, 0);
+ auto instructionDescriptor =
+ MakeInstructionDescriptor(22, spv::Op::OpIAdd, 0);
auto transformation =
TransformationSwapCommutableOperands(instructionDescriptor);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
- instructionDescriptor = MakeInstructionDescriptor(28, SpvOpIMul, 0);
+ instructionDescriptor = MakeInstructionDescriptor(28, spv::Op::OpIMul, 0);
transformation = TransformationSwapCommutableOperands(instructionDescriptor);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
- instructionDescriptor = MakeInstructionDescriptor(42, SpvOpFAdd, 0);
+ instructionDescriptor = MakeInstructionDescriptor(42, spv::Op::OpFAdd, 0);
transformation = TransformationSwapCommutableOperands(instructionDescriptor);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
- instructionDescriptor = MakeInstructionDescriptor(48, SpvOpFMul, 0);
+ instructionDescriptor = MakeInstructionDescriptor(48, spv::Op::OpFMul, 0);
transformation = TransformationSwapCommutableOperands(instructionDescriptor);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
- instructionDescriptor = MakeInstructionDescriptor(66, SpvOpDot, 0);
+ instructionDescriptor = MakeInstructionDescriptor(66, spv::Op::OpDot, 0);
transformation = TransformationSwapCommutableOperands(instructionDescriptor);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
// Tests existing non-commutative instructions
- instructionDescriptor = MakeInstructionDescriptor(1, SpvOpExtInstImport, 0);
+ instructionDescriptor =
+ MakeInstructionDescriptor(1, spv::Op::OpExtInstImport, 0);
transformation = TransformationSwapCommutableOperands(instructionDescriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
- instructionDescriptor = MakeInstructionDescriptor(5, SpvOpLabel, 0);
+ instructionDescriptor = MakeInstructionDescriptor(5, spv::Op::OpLabel, 0);
transformation = TransformationSwapCommutableOperands(instructionDescriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
- instructionDescriptor = MakeInstructionDescriptor(8, SpvOpConstant, 0);
+ instructionDescriptor = MakeInstructionDescriptor(8, spv::Op::OpConstant, 0);
transformation = TransformationSwapCommutableOperands(instructionDescriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
- instructionDescriptor = MakeInstructionDescriptor(11, SpvOpVariable, 0);
+ instructionDescriptor = MakeInstructionDescriptor(11, spv::Op::OpVariable, 0);
transformation = TransformationSwapCommutableOperands(instructionDescriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
instructionDescriptor =
- MakeInstructionDescriptor(14, SpvOpConstantComposite, 0);
+ MakeInstructionDescriptor(14, spv::Op::OpConstantComposite, 0);
transformation = TransformationSwapCommutableOperands(instructionDescriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
// Tests the base instruction id not existing
- instructionDescriptor = MakeInstructionDescriptor(67, SpvOpIAddCarry, 0);
+ instructionDescriptor =
+ MakeInstructionDescriptor(67, spv::Op::OpIAddCarry, 0);
transformation = TransformationSwapCommutableOperands(instructionDescriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
- instructionDescriptor = MakeInstructionDescriptor(68, SpvOpIEqual, 0);
+ instructionDescriptor = MakeInstructionDescriptor(68, spv::Op::OpIEqual, 0);
transformation = TransformationSwapCommutableOperands(instructionDescriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
- instructionDescriptor = MakeInstructionDescriptor(69, SpvOpINotEqual, 0);
+ instructionDescriptor =
+ MakeInstructionDescriptor(69, spv::Op::OpINotEqual, 0);
transformation = TransformationSwapCommutableOperands(instructionDescriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
- instructionDescriptor = MakeInstructionDescriptor(70, SpvOpFOrdEqual, 0);
+ instructionDescriptor =
+ MakeInstructionDescriptor(70, spv::Op::OpFOrdEqual, 0);
transformation = TransformationSwapCommutableOperands(instructionDescriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
- instructionDescriptor = MakeInstructionDescriptor(71, SpvOpPtrEqual, 0);
+ instructionDescriptor = MakeInstructionDescriptor(71, spv::Op::OpPtrEqual, 0);
transformation = TransformationSwapCommutableOperands(instructionDescriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
// Tests there being no instruction with the desired opcode after the base
// instruction id
- instructionDescriptor = MakeInstructionDescriptor(24, SpvOpIAdd, 0);
+ instructionDescriptor = MakeInstructionDescriptor(24, spv::Op::OpIAdd, 0);
transformation = TransformationSwapCommutableOperands(instructionDescriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
- instructionDescriptor = MakeInstructionDescriptor(38, SpvOpIMul, 0);
+ instructionDescriptor = MakeInstructionDescriptor(38, spv::Op::OpIMul, 0);
transformation = TransformationSwapCommutableOperands(instructionDescriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
- instructionDescriptor = MakeInstructionDescriptor(45, SpvOpFAdd, 0);
+ instructionDescriptor = MakeInstructionDescriptor(45, spv::Op::OpFAdd, 0);
transformation = TransformationSwapCommutableOperands(instructionDescriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
- instructionDescriptor = MakeInstructionDescriptor(66, SpvOpFMul, 0);
+ instructionDescriptor = MakeInstructionDescriptor(66, spv::Op::OpFMul, 0);
transformation = TransformationSwapCommutableOperands(instructionDescriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
@@ -222,27 +227,27 @@ TEST(TransformationSwapCommutableOperandsTest, IsApplicableTest) {
// Tests there being an instruction with the desired opcode after the base
// instruction id, but the skip count associated with the instruction
// descriptor being so high.
- instructionDescriptor = MakeInstructionDescriptor(11, SpvOpIAdd, 100);
+ instructionDescriptor = MakeInstructionDescriptor(11, spv::Op::OpIAdd, 100);
transformation = TransformationSwapCommutableOperands(instructionDescriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
- instructionDescriptor = MakeInstructionDescriptor(16, SpvOpIMul, 100);
+ instructionDescriptor = MakeInstructionDescriptor(16, spv::Op::OpIMul, 100);
transformation = TransformationSwapCommutableOperands(instructionDescriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
- instructionDescriptor = MakeInstructionDescriptor(23, SpvOpFAdd, 100);
+ instructionDescriptor = MakeInstructionDescriptor(23, spv::Op::OpFAdd, 100);
transformation = TransformationSwapCommutableOperands(instructionDescriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
- instructionDescriptor = MakeInstructionDescriptor(32, SpvOpFMul, 100);
+ instructionDescriptor = MakeInstructionDescriptor(32, spv::Op::OpFMul, 100);
transformation = TransformationSwapCommutableOperands(instructionDescriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
- instructionDescriptor = MakeInstructionDescriptor(37, SpvOpDot, 100);
+ instructionDescriptor = MakeInstructionDescriptor(37, spv::Op::OpDot, 100);
transformation = TransformationSwapCommutableOperands(instructionDescriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
@@ -342,24 +347,25 @@ TEST(TransformationSwapCommutableOperandsTest, ApplyTest) {
kConsoleMessageConsumer));
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
- auto instructionDescriptor = MakeInstructionDescriptor(22, SpvOpIAdd, 0);
+ auto instructionDescriptor =
+ MakeInstructionDescriptor(22, spv::Op::OpIAdd, 0);
auto transformation =
TransformationSwapCommutableOperands(instructionDescriptor);
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
- instructionDescriptor = MakeInstructionDescriptor(28, SpvOpIMul, 0);
+ instructionDescriptor = MakeInstructionDescriptor(28, spv::Op::OpIMul, 0);
transformation = TransformationSwapCommutableOperands(instructionDescriptor);
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
- instructionDescriptor = MakeInstructionDescriptor(42, SpvOpFAdd, 0);
+ instructionDescriptor = MakeInstructionDescriptor(42, spv::Op::OpFAdd, 0);
transformation = TransformationSwapCommutableOperands(instructionDescriptor);
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
- instructionDescriptor = MakeInstructionDescriptor(48, SpvOpFMul, 0);
+ instructionDescriptor = MakeInstructionDescriptor(48, spv::Op::OpFMul, 0);
transformation = TransformationSwapCommutableOperands(instructionDescriptor);
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
- instructionDescriptor = MakeInstructionDescriptor(66, SpvOpDot, 0);
+ instructionDescriptor = MakeInstructionDescriptor(66, spv::Op::OpDot, 0);
transformation = TransformationSwapCommutableOperands(instructionDescriptor);
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
diff --git a/test/fuzz/transformation_swap_conditional_branch_operands_test.cpp b/test/fuzz/transformation_swap_conditional_branch_operands_test.cpp
index 6133a7a8e..5f7ffe40c 100644
--- a/test/fuzz/transformation_swap_conditional_branch_operands_test.cpp
+++ b/test/fuzz/transformation_swap_conditional_branch_operands_test.cpp
@@ -76,27 +76,29 @@ TEST(TransformationSwapConditionalBranchOperandsTest, BasicTest) {
MakeUnique<FactManager>(context.get()), validator_options);
// Invalid instruction descriptor.
ASSERT_FALSE(TransformationSwapConditionalBranchOperands(
- MakeInstructionDescriptor(26, SpvOpPhi, 0), 26)
+ MakeInstructionDescriptor(26, spv::Op::OpPhi, 0), 26)
.IsApplicable(context.get(), transformation_context));
// Descriptor for a wrong instruction.
ASSERT_FALSE(TransformationSwapConditionalBranchOperands(
- MakeInstructionDescriptor(25, SpvOpPhi, 0), 26)
+ MakeInstructionDescriptor(25, spv::Op::OpPhi, 0), 26)
.IsApplicable(context.get(), transformation_context));
// Fresh id is not fresh.
- ASSERT_FALSE(TransformationSwapConditionalBranchOperands(
- MakeInstructionDescriptor(15, SpvOpBranchConditional, 0), 25)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationSwapConditionalBranchOperands(
+ MakeInstructionDescriptor(15, spv::Op::OpBranchConditional, 0), 25)
+ .IsApplicable(context.get(), transformation_context));
TransformationSwapConditionalBranchOperands transformation(
- MakeInstructionDescriptor(15, SpvOpBranchConditional, 0), 26);
+ MakeInstructionDescriptor(15, spv::Op::OpBranchConditional, 0), 26);
ASSERT_EQ(nullptr, context->get_def_use_mgr()->GetDef(26));
ASSERT_EQ(nullptr, context->get_instr_block(26));
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
- ASSERT_EQ(SpvOpLogicalNot, context->get_def_use_mgr()->GetDef(26)->opcode());
+ ASSERT_EQ(spv::Op::OpLogicalNot,
+ context->get_def_use_mgr()->GetDef(26)->opcode());
ASSERT_EQ(5, context->get_instr_block(26)->id());
ASSERT_EQ(1, context->get_def_use_mgr()->NumUses(26));
@@ -109,7 +111,7 @@ TEST(TransformationSwapConditionalBranchOperandsTest, BasicTest) {
context->get_def_use_mgr()->WhileEachUse(
entry.first,
[&entry](opt::Instruction* inst, uint32_t operand_index) -> bool {
- if (inst->opcode() == SpvOpBranchConditional) {
+ if (inst->opcode() == spv::Op::OpBranchConditional) {
EXPECT_EQ(entry.second, operand_index);
return false;
}
diff --git a/test/fuzz/transformation_toggle_access_chain_instruction_test.cpp b/test/fuzz/transformation_toggle_access_chain_instruction_test.cpp
index 84ed20d28..94ca80441 100644
--- a/test/fuzz/transformation_toggle_access_chain_instruction_test.cpp
+++ b/test/fuzz/transformation_toggle_access_chain_instruction_test.cpp
@@ -119,67 +119,71 @@ TEST(TransformationToggleAccessChainInstructionTest, IsApplicableTest) {
MakeUnique<FactManager>(context.get()), validator_options);
// Tests existing access chain instructions
auto instructionDescriptor =
- MakeInstructionDescriptor(18, SpvOpAccessChain, 0);
+ MakeInstructionDescriptor(18, spv::Op::OpAccessChain, 0);
auto transformation =
TransformationToggleAccessChainInstruction(instructionDescriptor);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
instructionDescriptor =
- MakeInstructionDescriptor(20, SpvOpInBoundsAccessChain, 0);
+ MakeInstructionDescriptor(20, spv::Op::OpInBoundsAccessChain, 0);
transformation =
TransformationToggleAccessChainInstruction(instructionDescriptor);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
- instructionDescriptor = MakeInstructionDescriptor(24, SpvOpAccessChain, 0);
+ instructionDescriptor =
+ MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0);
transformation =
TransformationToggleAccessChainInstruction(instructionDescriptor);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
instructionDescriptor =
- MakeInstructionDescriptor(26, SpvOpInBoundsAccessChain, 0);
+ MakeInstructionDescriptor(26, spv::Op::OpInBoundsAccessChain, 0);
transformation =
TransformationToggleAccessChainInstruction(instructionDescriptor);
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
// Tests existing non-access chain instructions
- instructionDescriptor = MakeInstructionDescriptor(1, SpvOpExtInstImport, 0);
+ instructionDescriptor =
+ MakeInstructionDescriptor(1, spv::Op::OpExtInstImport, 0);
transformation =
TransformationToggleAccessChainInstruction(instructionDescriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
- instructionDescriptor = MakeInstructionDescriptor(5, SpvOpLabel, 0);
+ instructionDescriptor = MakeInstructionDescriptor(5, spv::Op::OpLabel, 0);
transformation =
TransformationToggleAccessChainInstruction(instructionDescriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
instructionDescriptor =
- MakeInstructionDescriptor(14, SpvOpConstantComposite, 0);
+ MakeInstructionDescriptor(14, spv::Op::OpConstantComposite, 0);
transformation =
TransformationToggleAccessChainInstruction(instructionDescriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
// Tests the base instruction id not existing
- instructionDescriptor = MakeInstructionDescriptor(67, SpvOpAccessChain, 0);
+ instructionDescriptor =
+ MakeInstructionDescriptor(67, spv::Op::OpAccessChain, 0);
transformation =
TransformationToggleAccessChainInstruction(instructionDescriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
- instructionDescriptor = MakeInstructionDescriptor(68, SpvOpAccessChain, 0);
+ instructionDescriptor =
+ MakeInstructionDescriptor(68, spv::Op::OpAccessChain, 0);
transformation =
TransformationToggleAccessChainInstruction(instructionDescriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
instructionDescriptor =
- MakeInstructionDescriptor(69, SpvOpInBoundsAccessChain, 0);
+ MakeInstructionDescriptor(69, spv::Op::OpInBoundsAccessChain, 0);
transformation =
TransformationToggleAccessChainInstruction(instructionDescriptor);
ASSERT_FALSE(
@@ -187,14 +191,15 @@ TEST(TransformationToggleAccessChainInstructionTest, IsApplicableTest) {
// Tests there being no instruction with the desired opcode after the base
// instruction id
- instructionDescriptor = MakeInstructionDescriptor(65, SpvOpAccessChain, 0);
+ instructionDescriptor =
+ MakeInstructionDescriptor(65, spv::Op::OpAccessChain, 0);
transformation =
TransformationToggleAccessChainInstruction(instructionDescriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
instructionDescriptor =
- MakeInstructionDescriptor(66, SpvOpInBoundsAccessChain, 0);
+ MakeInstructionDescriptor(66, spv::Op::OpInBoundsAccessChain, 0);
transformation =
TransformationToggleAccessChainInstruction(instructionDescriptor);
ASSERT_FALSE(
@@ -203,14 +208,15 @@ TEST(TransformationToggleAccessChainInstructionTest, IsApplicableTest) {
// Tests there being an instruction with the desired opcode after the base
// instruction id, but the skip count associated with the instruction
// descriptor being so high.
- instructionDescriptor = MakeInstructionDescriptor(11, SpvOpAccessChain, 100);
+ instructionDescriptor =
+ MakeInstructionDescriptor(11, spv::Op::OpAccessChain, 100);
transformation =
TransformationToggleAccessChainInstruction(instructionDescriptor);
ASSERT_FALSE(
transformation.IsApplicable(context.get(), transformation_context));
instructionDescriptor =
- MakeInstructionDescriptor(16, SpvOpInBoundsAccessChain, 100);
+ MakeInstructionDescriptor(16, spv::Op::OpInBoundsAccessChain, 100);
transformation =
TransformationToggleAccessChainInstruction(instructionDescriptor);
ASSERT_FALSE(
@@ -312,29 +318,31 @@ TEST(TransformationToggleAccessChainInstructionTest, ApplyTest) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
auto instructionDescriptor =
- MakeInstructionDescriptor(18, SpvOpAccessChain, 0);
+ MakeInstructionDescriptor(18, spv::Op::OpAccessChain, 0);
auto transformation =
TransformationToggleAccessChainInstruction(instructionDescriptor);
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
instructionDescriptor =
- MakeInstructionDescriptor(20, SpvOpInBoundsAccessChain, 0);
+ MakeInstructionDescriptor(20, spv::Op::OpInBoundsAccessChain, 0);
transformation =
TransformationToggleAccessChainInstruction(instructionDescriptor);
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
- instructionDescriptor = MakeInstructionDescriptor(24, SpvOpAccessChain, 0);
+ instructionDescriptor =
+ MakeInstructionDescriptor(24, spv::Op::OpAccessChain, 0);
transformation =
TransformationToggleAccessChainInstruction(instructionDescriptor);
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
instructionDescriptor =
- MakeInstructionDescriptor(26, SpvOpInBoundsAccessChain, 0);
+ MakeInstructionDescriptor(26, spv::Op::OpInBoundsAccessChain, 0);
transformation =
TransformationToggleAccessChainInstruction(instructionDescriptor);
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
- instructionDescriptor = MakeInstructionDescriptor(38, SpvOpAccessChain, 0);
+ instructionDescriptor =
+ MakeInstructionDescriptor(38, spv::Op::OpAccessChain, 0);
transformation =
TransformationToggleAccessChainInstruction(instructionDescriptor);
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
diff --git a/test/fuzz/transformation_vector_shuffle_test.cpp b/test/fuzz/transformation_vector_shuffle_test.cpp
index e3dc0a7e5..4d8f985bd 100644
--- a/test/fuzz/transformation_vector_shuffle_test.cpp
+++ b/test/fuzz/transformation_vector_shuffle_test.cpp
@@ -172,80 +172,82 @@ TEST(TransformationVectorShuffleTest, BasicTest) {
// %103 does not dominate the return instruction.
ASSERT_FALSE(TransformationVectorShuffle(
- MakeInstructionDescriptor(100, SpvOpReturn, 0), 200, 103, 65,
- {3, 5, 7})
+ MakeInstructionDescriptor(100, spv::Op::OpReturn, 0), 200,
+ 103, 65, {3, 5, 7})
.IsApplicable(context.get(), transformation_context));
// Illegal to shuffle a bvec2 and a vec3
ASSERT_FALSE(TransformationVectorShuffle(
- MakeInstructionDescriptor(100, SpvOpReturn, 0), 200, 112, 61,
- {0, 2, 4})
+ MakeInstructionDescriptor(100, spv::Op::OpReturn, 0), 200,
+ 112, 61, {0, 2, 4})
.IsApplicable(context.get(), transformation_context));
// Illegal to shuffle an ivec2 and a uvec4
ASSERT_FALSE(TransformationVectorShuffle(
- MakeInstructionDescriptor(100, SpvOpReturn, 0), 200, 27, 50,
- {1, 3, 5})
+ MakeInstructionDescriptor(100, spv::Op::OpReturn, 0), 200,
+ 27, 50, {1, 3, 5})
.IsApplicable(context.get(), transformation_context));
// Vector 1 does not exist
ASSERT_FALSE(TransformationVectorShuffle(
- MakeInstructionDescriptor(100, SpvOpReturn, 0), 200, 300, 50,
- {1, 3, 5})
+ MakeInstructionDescriptor(100, spv::Op::OpReturn, 0), 200,
+ 300, 50, {1, 3, 5})
.IsApplicable(context.get(), transformation_context));
// Vector 2 does not exist
ASSERT_FALSE(TransformationVectorShuffle(
- MakeInstructionDescriptor(100, SpvOpReturn, 0), 200, 27, 300,
- {1, 3, 5})
+ MakeInstructionDescriptor(100, spv::Op::OpReturn, 0), 200,
+ 27, 300, {1, 3, 5})
.IsApplicable(context.get(), transformation_context));
// Index out of range
- ASSERT_FALSE(
- TransformationVectorShuffle(
- MakeInstructionDescriptor(100, SpvOpReturn, 0), 200, 12, 112, {0, 20})
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationVectorShuffle(
+ MakeInstructionDescriptor(100, spv::Op::OpReturn, 0), 200,
+ 12, 112, {0, 20})
+ .IsApplicable(context.get(), transformation_context));
// Too many indices
ASSERT_FALSE(TransformationVectorShuffle(
- MakeInstructionDescriptor(100, SpvOpReturn, 0), 200, 12, 112,
- {0, 1, 0, 1, 0, 1, 0, 1})
+ MakeInstructionDescriptor(100, spv::Op::OpReturn, 0), 200,
+ 12, 112, {0, 1, 0, 1, 0, 1, 0, 1})
.IsApplicable(context.get(), transformation_context));
// Too few indices
- ASSERT_FALSE(
- TransformationVectorShuffle(
- MakeInstructionDescriptor(100, SpvOpReturn, 0), 200, 12, 112, {})
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationVectorShuffle(
+ MakeInstructionDescriptor(100, spv::Op::OpReturn, 0), 200,
+ 12, 112, {})
+ .IsApplicable(context.get(), transformation_context));
// Too few indices again
- ASSERT_FALSE(
- TransformationVectorShuffle(
- MakeInstructionDescriptor(100, SpvOpReturn, 0), 200, 12, 112, {0})
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationVectorShuffle(
+ MakeInstructionDescriptor(100, spv::Op::OpReturn, 0), 200,
+ 12, 112, {0})
+ .IsApplicable(context.get(), transformation_context));
// Indices define unknown type: we do not have vec2
+ ASSERT_FALSE(TransformationVectorShuffle(
+ MakeInstructionDescriptor(100, spv::Op::OpReturn, 0), 200,
+ 65, 65, {0, 1})
+ .IsApplicable(context.get(), transformation_context));
+
+ // The instruction to insert before does not exist
ASSERT_FALSE(
TransformationVectorShuffle(
- MakeInstructionDescriptor(100, SpvOpReturn, 0), 200, 65, 65, {0, 1})
+ MakeInstructionDescriptor(100, spv::Op::OpCompositeConstruct, 1), 201,
+ 20, 12, {0xFFFFFFFF, 3, 5})
.IsApplicable(context.get(), transformation_context));
- // The instruction to insert before does not exist
- ASSERT_FALSE(TransformationVectorShuffle(
- MakeInstructionDescriptor(100, SpvOpCompositeConstruct, 1),
- 201, 20, 12, {0xFFFFFFFF, 3, 5})
- .IsApplicable(context.get(), transformation_context));
-
// The 'fresh' id is already in use
ASSERT_FALSE(
TransformationVectorShuffle(
- MakeInstructionDescriptor(100, SpvOpReturn, 0), 12, 12, 112, {})
+ MakeInstructionDescriptor(100, spv::Op::OpReturn, 0), 12, 12, 112, {})
.IsApplicable(context.get(), transformation_context));
protobufs::DataDescriptor temp_dd;
TransformationVectorShuffle transformation1(
- MakeInstructionDescriptor(100, SpvOpReturn, 0), 200, 12, 112, {1, 0});
+ MakeInstructionDescriptor(100, spv::Op::OpReturn, 0), 200, 12, 112,
+ {1, 0});
ASSERT_TRUE(
transformation1.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation1, context.get(),
@@ -258,7 +260,7 @@ TEST(TransformationVectorShuffleTest, BasicTest) {
MakeDataDescriptor(10, {}), temp_dd));
TransformationVectorShuffle transformation2(
- MakeInstructionDescriptor(100, SpvOpReturn, 0), 201, 20, 12,
+ MakeInstructionDescriptor(100, spv::Op::OpReturn, 0), 201, 20, 12,
{0xFFFFFFFF, 3, 5});
ASSERT_TRUE(
transformation2.IsApplicable(context.get(), transformation_context));
@@ -272,7 +274,8 @@ TEST(TransformationVectorShuffleTest, BasicTest) {
MakeDataDescriptor(11, {}), temp_dd));
TransformationVectorShuffle transformation3(
- MakeInstructionDescriptor(100, SpvOpReturn, 0), 202, 27, 35, {5, 4, 1});
+ MakeInstructionDescriptor(100, spv::Op::OpReturn, 0), 202, 27, 35,
+ {5, 4, 1});
ASSERT_TRUE(
transformation3.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation3, context.get(),
@@ -288,7 +291,8 @@ TEST(TransformationVectorShuffleTest, BasicTest) {
MakeDataDescriptor(26, {}), temp_dd));
TransformationVectorShuffle transformation4(
- MakeInstructionDescriptor(100, SpvOpReturn, 0), 203, 42, 46, {0, 1});
+ MakeInstructionDescriptor(100, spv::Op::OpReturn, 0), 203, 42, 46,
+ {0, 1});
ASSERT_TRUE(
transformation4.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation4, context.get(),
@@ -301,7 +305,8 @@ TEST(TransformationVectorShuffleTest, BasicTest) {
MakeDataDescriptor(41, {}), temp_dd));
TransformationVectorShuffle transformation5(
- MakeInstructionDescriptor(100, SpvOpReturn, 0), 204, 42, 46, {2, 3, 4});
+ MakeInstructionDescriptor(100, spv::Op::OpReturn, 0), 204, 42, 46,
+ {2, 3, 4});
ASSERT_TRUE(
transformation5.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation5, context.get(),
@@ -317,7 +322,7 @@ TEST(TransformationVectorShuffleTest, BasicTest) {
MakeDataDescriptor(40, {}), temp_dd));
TransformationVectorShuffle transformation6(
- MakeInstructionDescriptor(100, SpvOpReturn, 0), 205, 42, 42,
+ MakeInstructionDescriptor(100, spv::Op::OpReturn, 0), 205, 42, 42,
{0, 1, 2, 3});
ASSERT_TRUE(
transformation6.IsApplicable(context.get(), transformation_context));
@@ -338,7 +343,7 @@ TEST(TransformationVectorShuffleTest, BasicTest) {
// swizzle vec4 from vec4 and vec4 using some undefs
TransformationVectorShuffle transformation7(
- MakeInstructionDescriptor(100, SpvOpReturn, 0), 206, 65, 65,
+ MakeInstructionDescriptor(100, spv::Op::OpReturn, 0), 206, 65, 65,
{0xFFFFFFFF, 3, 6, 0xFFFFFFFF});
ASSERT_TRUE(
transformation7.IsApplicable(context.get(), transformation_context));
@@ -500,50 +505,52 @@ TEST(TransformationVectorShuffleTest, IllegalInsertionPoints) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
// Cannot insert before the OpVariables of a function.
- ASSERT_FALSE(
- TransformationVectorShuffle(
- MakeInstructionDescriptor(101, SpvOpVariable, 0), 200, 14, 14, {0, 1})
- .IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(
- TransformationVectorShuffle(
- MakeInstructionDescriptor(101, SpvOpVariable, 1), 200, 14, 14, {1, 2})
- .IsApplicable(context.get(), transformation_context));
- ASSERT_FALSE(
- TransformationVectorShuffle(
- MakeInstructionDescriptor(102, SpvOpVariable, 0), 200, 14, 14, {1, 2})
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationVectorShuffle(
+ MakeInstructionDescriptor(101, spv::Op::OpVariable, 0), 200,
+ 14, 14, {0, 1})
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationVectorShuffle(
+ MakeInstructionDescriptor(101, spv::Op::OpVariable, 1), 200,
+ 14, 14, {1, 2})
+ .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationVectorShuffle(
+ MakeInstructionDescriptor(102, spv::Op::OpVariable, 0), 200,
+ 14, 14, {1, 2})
+ .IsApplicable(context.get(), transformation_context));
// OK to insert right after the OpVariables.
- ASSERT_FALSE(
- TransformationVectorShuffle(
- MakeInstructionDescriptor(102, SpvOpBranch, 1), 200, 14, 14, {1, 1})
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(TransformationVectorShuffle(
+ MakeInstructionDescriptor(102, spv::Op::OpBranch, 1), 200,
+ 14, 14, {1, 1})
+ .IsApplicable(context.get(), transformation_context));
// Cannot insert before the OpPhis of a block.
ASSERT_FALSE(
- TransformationVectorShuffle(MakeInstructionDescriptor(60, SpvOpPhi, 0),
- 200, 14, 14, {2, 0})
+ TransformationVectorShuffle(
+ MakeInstructionDescriptor(60, spv::Op::OpPhi, 0), 200, 14, 14, {2, 0})
.IsApplicable(context.get(), transformation_context));
ASSERT_FALSE(
- TransformationVectorShuffle(MakeInstructionDescriptor(59, SpvOpPhi, 0),
- 200, 14, 14, {3, 0})
+ TransformationVectorShuffle(
+ MakeInstructionDescriptor(59, spv::Op::OpPhi, 0), 200, 14, 14, {3, 0})
.IsApplicable(context.get(), transformation_context));
// OK to insert after the OpPhis.
ASSERT_TRUE(TransformationVectorShuffle(
- MakeInstructionDescriptor(59, SpvOpAccessChain, 0), 200, 14,
- 14, {3, 4})
+ MakeInstructionDescriptor(59, spv::Op::OpAccessChain, 0), 200,
+ 14, 14, {3, 4})
.IsApplicable(context.get(), transformation_context));
// Cannot insert before OpLoopMerge
- ASSERT_FALSE(TransformationVectorShuffle(
- MakeInstructionDescriptor(33, SpvOpBranchConditional, 0),
- 200, 14, 14, {3})
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationVectorShuffle(
+ MakeInstructionDescriptor(33, spv::Op::OpBranchConditional, 0), 200,
+ 14, 14, {3})
+ .IsApplicable(context.get(), transformation_context));
// Cannot insert before OpSelectionMerge
- ASSERT_FALSE(TransformationVectorShuffle(
- MakeInstructionDescriptor(21, SpvOpBranchConditional, 0),
- 200, 14, 14, {2})
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationVectorShuffle(
+ MakeInstructionDescriptor(21, spv::Op::OpBranchConditional, 0), 200,
+ 14, 14, {2})
+ .IsApplicable(context.get(), transformation_context));
}
TEST(TransformationVectorShuffleTest, HandlesIrrelevantIds1) {
@@ -615,7 +622,8 @@ TEST(TransformationVectorShuffleTest, HandlesIrrelevantIds1) {
TransformationContext transformation_context(
MakeUnique<FactManager>(context.get()), validator_options);
TransformationVectorShuffle transformation(
- MakeInstructionDescriptor(100, SpvOpReturn, 0), 200, 12, 112, {2, 0});
+ MakeInstructionDescriptor(100, spv::Op::OpReturn, 0), 200, 12, 112,
+ {2, 0});
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
@@ -697,7 +705,8 @@ TEST(TransformationVectorShuffleTest, HandlesIrrelevantIds2) {
MakeUnique<FactManager>(context.get()), validator_options);
transformation_context.GetFactManager()->AddFactIdIsIrrelevant(112);
TransformationVectorShuffle transformation(
- MakeInstructionDescriptor(100, SpvOpReturn, 0), 200, 12, 112, {2, 0});
+ MakeInstructionDescriptor(100, spv::Op::OpReturn, 0), 200, 12, 112,
+ {2, 0});
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation, context.get(), &transformation_context);
@@ -755,7 +764,7 @@ TEST(TransformationVectorShuffleTest, HandlesIrrelevantIds3) {
transformation_context.GetFactManager()->AddFactBlockIsDead(15);
TransformationVectorShuffle transformation1(
- MakeInstructionDescriptor(15, SpvOpBranch, 0), 200, 12, 12, {0, 3});
+ MakeInstructionDescriptor(15, spv::Op::OpBranch, 0), 200, 12, 12, {0, 3});
ASSERT_TRUE(
transformation1.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation1, context.get(),
@@ -766,7 +775,7 @@ TEST(TransformationVectorShuffleTest, HandlesIrrelevantIds3) {
MakeDataDescriptor(200, {1}), MakeDataDescriptor(12, {1})));
TransformationVectorShuffle transformation2(
- MakeInstructionDescriptor(16, SpvOpReturn, 0), 201, 12, 40, {0, 1});
+ MakeInstructionDescriptor(16, spv::Op::OpReturn, 0), 201, 12, 40, {0, 1});
ASSERT_TRUE(
transformation2.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation2, context.get(),
@@ -777,7 +786,7 @@ TEST(TransformationVectorShuffleTest, HandlesIrrelevantIds3) {
MakeDataDescriptor(201, {1}), MakeDataDescriptor(12, {1})));
TransformationVectorShuffle transformation3(
- MakeInstructionDescriptor(16, SpvOpReturn, 0), 202, 40, 12, {2, 3});
+ MakeInstructionDescriptor(16, spv::Op::OpReturn, 0), 202, 40, 12, {2, 3});
ASSERT_TRUE(
transformation3.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation3, context.get(),
@@ -788,7 +797,7 @@ TEST(TransformationVectorShuffleTest, HandlesIrrelevantIds3) {
MakeDataDescriptor(202, {1}), MakeDataDescriptor(12, {1})));
TransformationVectorShuffle transformation4(
- MakeInstructionDescriptor(16, SpvOpReturn, 0), 203, 40, 12, {0, 3});
+ MakeInstructionDescriptor(16, spv::Op::OpReturn, 0), 203, 40, 12, {0, 3});
ASSERT_TRUE(
transformation4.IsApplicable(context.get(), transformation_context));
ApplyAndCheckFreshIds(transformation4, context.get(),
diff --git a/test/fuzz/transformation_wrap_early_terminator_in_function_test.cpp b/test/fuzz/transformation_wrap_early_terminator_in_function_test.cpp
index 7b4e487c5..fbbf57b3b 100644
--- a/test/fuzz/transformation_wrap_early_terminator_in_function_test.cpp
+++ b/test/fuzz/transformation_wrap_early_terminator_in_function_test.cpp
@@ -98,48 +98,50 @@ TEST(TransformationWrapEarlyTerminatorInFunctionTest, IsApplicable) {
// Bad: id is not fresh
ASSERT_FALSE(TransformationWrapEarlyTerminatorInFunction(
- 61, MakeInstructionDescriptor(8, SpvOpKill, 0), 0)
+ 61, MakeInstructionDescriptor(8, spv::Op::OpKill, 0), 0)
.IsApplicable(context.get(), transformation_context));
// Bad: early terminator instruction descriptor does not exist
ASSERT_FALSE(TransformationWrapEarlyTerminatorInFunction(
- 100, MakeInstructionDescriptor(82, SpvOpKill, 0), 0)
+ 100, MakeInstructionDescriptor(82, spv::Op::OpKill, 0), 0)
.IsApplicable(context.get(), transformation_context));
// Bad: early terminator instruction does not identify an early terminator
- ASSERT_FALSE(TransformationWrapEarlyTerminatorInFunction(
- 100, MakeInstructionDescriptor(5, SpvOpSelectionMerge, 0), 0)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationWrapEarlyTerminatorInFunction(
+ 100, MakeInstructionDescriptor(5, spv::Op::OpSelectionMerge, 0), 0)
+ .IsApplicable(context.get(), transformation_context));
// Bad: no wrapper function is available
- ASSERT_FALSE(TransformationWrapEarlyTerminatorInFunction(
- 100, MakeInstructionDescriptor(9, SpvOpUnreachable, 0), 0)
- .IsApplicable(context.get(), transformation_context));
+ ASSERT_FALSE(
+ TransformationWrapEarlyTerminatorInFunction(
+ 100, MakeInstructionDescriptor(9, spv::Op::OpUnreachable, 0), 0)
+ .IsApplicable(context.get(), transformation_context));
// Bad: returned value does not exist
ASSERT_FALSE(TransformationWrapEarlyTerminatorInFunction(
- 100, MakeInstructionDescriptor(62, SpvOpKill, 0), 1000)
+ 100, MakeInstructionDescriptor(62, spv::Op::OpKill, 0), 1000)
.IsApplicable(context.get(), transformation_context));
// Bad: returned value does not have a type
ASSERT_FALSE(TransformationWrapEarlyTerminatorInFunction(
- 100, MakeInstructionDescriptor(62, SpvOpKill, 0), 61)
+ 100, MakeInstructionDescriptor(62, spv::Op::OpKill, 0), 61)
.IsApplicable(context.get(), transformation_context));
// Bad: returned value type does not match
ASSERT_FALSE(TransformationWrapEarlyTerminatorInFunction(
- 100, MakeInstructionDescriptor(62, SpvOpKill, 0), 91)
+ 100, MakeInstructionDescriptor(62, spv::Op::OpKill, 0), 91)
.IsApplicable(context.get(), transformation_context));
// Bad: returned value is not available
ASSERT_FALSE(TransformationWrapEarlyTerminatorInFunction(
- 100, MakeInstructionDescriptor(62, SpvOpKill, 0), 81)
+ 100, MakeInstructionDescriptor(62, spv::Op::OpKill, 0), 81)
.IsApplicable(context.get(), transformation_context));
// Bad: the OpKill being targeted is in the only available wrapper; we cannot
// have the wrapper call itself.
ASSERT_FALSE(TransformationWrapEarlyTerminatorInFunction(
- 100, MakeInstructionDescriptor(31, SpvOpKill, 0), 0)
+ 100, MakeInstructionDescriptor(31, spv::Op::OpKill, 0), 0)
.IsApplicable(context.get(), transformation_context));
}
@@ -220,17 +222,20 @@ TEST(TransformationWrapEarlyTerminatorInFunctionTest, Apply) {
for (auto& transformation :
{TransformationWrapEarlyTerminatorInFunction(
- 100, MakeInstructionDescriptor(8, SpvOpKill, 0), 0),
+ 100, MakeInstructionDescriptor(8, spv::Op::OpKill, 0), 0),
TransformationWrapEarlyTerminatorInFunction(
- 101, MakeInstructionDescriptor(9, SpvOpUnreachable, 0), 0),
+ 101, MakeInstructionDescriptor(9, spv::Op::OpUnreachable, 0), 0),
TransformationWrapEarlyTerminatorInFunction(
- 102, MakeInstructionDescriptor(10, SpvOpTerminateInvocation, 0), 0),
+ 102,
+ MakeInstructionDescriptor(10, spv::Op::OpTerminateInvocation, 0),
+ 0),
TransformationWrapEarlyTerminatorInFunction(
- 103, MakeInstructionDescriptor(62, SpvOpKill, 0), 0),
+ 103, MakeInstructionDescriptor(62, spv::Op::OpKill, 0), 0),
TransformationWrapEarlyTerminatorInFunction(
- 104, MakeInstructionDescriptor(71, SpvOpUnreachable, 0), 7),
+ 104, MakeInstructionDescriptor(71, spv::Op::OpUnreachable, 0), 7),
TransformationWrapEarlyTerminatorInFunction(
- 105, MakeInstructionDescriptor(82, SpvOpTerminateInvocation, 0),
+ 105,
+ MakeInstructionDescriptor(82, spv::Op::OpTerminateInvocation, 0),
0)}) {
ASSERT_TRUE(
transformation.IsApplicable(context.get(), transformation_context));
diff --git a/test/immediate_int_test.cpp b/test/immediate_int_test.cpp
index 393075a4e..8e7a8fd30 100644
--- a/test/immediate_int_test.cpp
+++ b/test/immediate_int_test.cpp
@@ -57,34 +57,34 @@ using ImmediateIntTest = TextToBinaryTest;
TEST_F(ImmediateIntTest, AnyWordInSimpleStatement) {
EXPECT_THAT(CompiledInstructions("!0x00040018 %a %b %123"),
- Eq(MakeInstruction(SpvOpTypeMatrix, {1, 2, 3})));
+ Eq(MakeInstruction(spv::Op::OpTypeMatrix, {1, 2, 3})));
EXPECT_THAT(CompiledInstructions("!0x00040018 !1 %b %123"),
- Eq(MakeInstruction(SpvOpTypeMatrix, {1, 1, 2})));
+ Eq(MakeInstruction(spv::Op::OpTypeMatrix, {1, 1, 2})));
EXPECT_THAT(CompiledInstructions("%a = OpTypeMatrix !2 %123"),
- Eq(MakeInstruction(SpvOpTypeMatrix, {1, 2, 2})));
+ Eq(MakeInstruction(spv::Op::OpTypeMatrix, {1, 2, 2})));
EXPECT_THAT(CompiledInstructions("%a = OpTypeMatrix %b !123"),
- Eq(MakeInstruction(SpvOpTypeMatrix, {1, 2, 123})));
+ Eq(MakeInstruction(spv::Op::OpTypeMatrix, {1, 2, 123})));
EXPECT_THAT(CompiledInstructions("!0x00040018 %a !2 %123"),
- Eq(MakeInstruction(SpvOpTypeMatrix, {1, 2, 2})));
+ Eq(MakeInstruction(spv::Op::OpTypeMatrix, {1, 2, 2})));
EXPECT_THAT(CompiledInstructions("!0x00040018 !1 %b !123"),
- Eq(MakeInstruction(SpvOpTypeMatrix, {1, 1, 123})));
+ Eq(MakeInstruction(spv::Op::OpTypeMatrix, {1, 1, 123})));
EXPECT_THAT(CompiledInstructions("!0x00040018 !1 !2 !123"),
- Eq(MakeInstruction(SpvOpTypeMatrix, {1, 2, 123})));
+ Eq(MakeInstruction(spv::Op::OpTypeMatrix, {1, 2, 123})));
}
TEST_F(ImmediateIntTest, AnyWordAfterEqualsAndOpCode) {
EXPECT_THAT(CompiledInstructions("%a = OpArrayLength !2 %c 123"),
- Eq(MakeInstruction(SpvOpArrayLength, {2, 1, 2, 123})));
+ Eq(MakeInstruction(spv::Op::OpArrayLength, {2, 1, 2, 123})));
EXPECT_THAT(CompiledInstructions("%a = OpArrayLength %b !3 123"),
- Eq(MakeInstruction(SpvOpArrayLength, {1, 2, 3, 123})));
+ Eq(MakeInstruction(spv::Op::OpArrayLength, {1, 2, 3, 123})));
EXPECT_THAT(CompiledInstructions("%a = OpArrayLength %b %c !123"),
- Eq(MakeInstruction(SpvOpArrayLength, {1, 2, 3, 123})));
+ Eq(MakeInstruction(spv::Op::OpArrayLength, {1, 2, 3, 123})));
EXPECT_THAT(CompiledInstructions("%a = OpArrayLength %b !3 !123"),
- Eq(MakeInstruction(SpvOpArrayLength, {1, 2, 3, 123})));
+ Eq(MakeInstruction(spv::Op::OpArrayLength, {1, 2, 3, 123})));
EXPECT_THAT(CompiledInstructions("%a = OpArrayLength !2 !3 123"),
- Eq(MakeInstruction(SpvOpArrayLength, {2, 1, 3, 123})));
+ Eq(MakeInstruction(spv::Op::OpArrayLength, {2, 1, 3, 123})));
EXPECT_THAT(CompiledInstructions("%a = OpArrayLength !2 !3 !123"),
- Eq(MakeInstruction(SpvOpArrayLength, {2, 1, 3, 123})));
+ Eq(MakeInstruction(spv::Op::OpArrayLength, {2, 1, 3, 123})));
}
TEST_F(ImmediateIntTest, ResultIdInAssignment) {
@@ -108,8 +108,8 @@ TEST_F(ImmediateIntTest, IntegerFollowingImmediate) {
// With !<integer>, we can (and can only) accept 32-bit number literals,
// even when we declare the return type is 64-bit.
EXPECT_EQ(Concatenate({
- MakeInstruction(SpvOpTypeInt, {1, 64, 0}),
- MakeInstruction(SpvOpConstant, {1, 2, 4294967295}),
+ MakeInstruction(spv::Op::OpTypeInt, {1, 64, 0}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 4294967295}),
}),
CompiledInstructions("%i64 = OpTypeInt 64 0\n"
"!0x0004002b %i64 !2 4294967295"));
@@ -151,9 +151,9 @@ TEST_F(ImmediateIntTest, FloatFollowingImmediate) {
CompiledInstructions("%1 = OpTypeFloat 32\n!0x0004002b %1 %2 -0.5"));
EXPECT_EQ(Concatenate({
- MakeInstruction(SpvOpTypeInt, {1, 64, 0}),
- MakeInstruction(SpvOpConstant, {1, 2, 0xb, 0xa}),
- MakeInstruction(SpvOpSwitch,
+ MakeInstruction(spv::Op::OpTypeInt, {1, 64, 0}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 0xb, 0xa}),
+ MakeInstruction(spv::Op::OpSwitch,
{2, 1234, BitwiseCast<uint32_t>(2.5f), 3}),
}),
CompiledInstructions("%i64 = OpTypeInt 64 0\n"
@@ -174,7 +174,7 @@ TEST_F(ImmediateIntTest, StringFollowingImmediate) {
CompiledInstructions("OpMemberName !1 !4 \"" + name + "\""))
<< name;
const uint16_t wordCount = static_cast<uint16_t>(4 + name.size() / 4);
- const uint32_t firstWord = spvOpcodeMake(wordCount, SpvOpMemberName);
+ const uint32_t firstWord = spvOpcodeMake(wordCount, spv::Op::OpMemberName);
EXPECT_EQ(original, CompiledInstructions("!" + std::to_string(firstWord) +
" %10 !4 \"" + name + "\""))
<< name;
@@ -205,8 +205,8 @@ TEST_F(ImmediateIntTest, InvalidStatementBetweenValidOnes) {
EXPECT_THAT(Subvector(CompileSuccessfully(
"%10 = OpTypeFloat 32 !5 !6 !7 OpEmitVertex"),
kFirstInstruction),
- ElementsAre(spvOpcodeMake(3, SpvOpTypeFloat), 1, 32, 5, 6, 7,
- spvOpcodeMake(1, SpvOpEmitVertex)));
+ ElementsAre(spvOpcodeMake(3, spv::Op::OpTypeFloat), 1, 32, 5, 6,
+ 7, spvOpcodeMake(1, spv::Op::OpEmitVertex)));
}
TEST_F(ImmediateIntTest, NextOpcodeRecognized) {
diff --git a/test/link/binary_version_test.cpp b/test/link/binary_version_test.cpp
index a56030f4e..78da1aece 100644
--- a/test/link/binary_version_test.cpp
+++ b/test/link/binary_version_test.cpp
@@ -27,20 +27,20 @@ spvtest::Binary CreateBinary(uint32_t version) {
return {
// clang-format off
// Header
- SpvMagicNumber,
+ static_cast<uint32_t>(spv::MagicNumber),
version,
SPV_GENERATOR_WORD(SPV_GENERATOR_KHRONOS, 0),
1u, // NOTE: Bound
0u, // NOTE: Schema; reserved
// OpCapability Shader
- SpvOpCapability | 2u << SpvWordCountShift,
- SpvCapabilityShader,
+ static_cast<uint32_t>(spv::Op::OpCapability) | 2u << spv::WordCountShift,
+ static_cast<uint32_t>(spv::Capability::Shader),
// OpMemoryModel Logical Simple
- SpvOpMemoryModel | 3u << SpvWordCountShift,
- SpvAddressingModelLogical,
- SpvMemoryModelSimple
+ static_cast<uint32_t>(spv::Op::OpMemoryModel) | 3u << spv::WordCountShift,
+ static_cast<uint32_t>(spv::AddressingModel::Logical),
+ static_cast<uint32_t>(spv::MemoryModel::Simple)
// clang-format on
};
}
diff --git a/test/link/global_values_amount_test.cpp b/test/link/global_values_amount_test.cpp
index 3158b7ec7..fda55d6a4 100644
--- a/test/link/global_values_amount_test.cpp
+++ b/test/link/global_values_amount_test.cpp
@@ -34,26 +34,26 @@ class EntryPointsAmountTest : public spvtest::LinkerTest {
spvtest::Binary common_binary = {
// clang-format off
- SpvMagicNumber,
- SpvVersion,
+ static_cast<uint32_t>(spv::MagicNumber),
+ static_cast<uint32_t>(spv::Version),
SPV_GENERATOR_WORD(SPV_GENERATOR_KHRONOS, 0),
3u + global_variable_count_per_binary, // NOTE: Bound
0u, // NOTE: Schema; reserved
- SpvOpCapability | 2u << SpvWordCountShift,
- SpvCapabilityShader,
+ static_cast<uint32_t>(spv::Op::OpCapability) | 2u << spv::WordCountShift,
+ static_cast<uint32_t>(spv::Capability::Shader),
- SpvOpMemoryModel | 3u << SpvWordCountShift,
- SpvAddressingModelLogical,
- SpvMemoryModelSimple,
+ static_cast<uint32_t>(spv::Op::OpMemoryModel) | 3u << spv::WordCountShift,
+ static_cast<uint32_t>(spv::AddressingModel::Logical),
+ static_cast<uint32_t>(spv::MemoryModel::Simple),
- SpvOpTypeFloat | 3u << SpvWordCountShift,
+ static_cast<uint32_t>(spv::Op::OpTypeFloat) | 3u << spv::WordCountShift,
1u, // NOTE: Result ID
32u, // NOTE: Width
- SpvOpTypePointer | 4u << SpvWordCountShift,
+ static_cast<uint32_t>(spv::Op::OpTypePointer) | 4u << spv::WordCountShift,
2u, // NOTE: Result ID
- SpvStorageClassInput,
+ static_cast<uint32_t>(spv::StorageClass::Input),
1u // NOTE: Type ID
// clang-format on
};
@@ -64,10 +64,11 @@ class EntryPointsAmountTest : public spvtest::LinkerTest {
binary.insert(binary.end(), common_binary.cbegin(), common_binary.cend());
for (uint32_t i = 0u; i < global_variable_count_per_binary; ++i) {
- binary.push_back(SpvOpVariable | 4u << SpvWordCountShift);
+ binary.push_back(static_cast<uint32_t>(spv::Op::OpVariable) |
+ 4u << spv::WordCountShift);
binary.push_back(2u); // NOTE: Type ID
binary.push_back(3u + i); // NOTE: Result ID
- binary.push_back(SpvStorageClassInput);
+ binary.push_back(static_cast<uint32_t>(spv::StorageClass::Input));
}
for (uint32_t i = 0u; i < binary_count - 1u; ++i) {
@@ -89,37 +90,37 @@ TEST_F(EntryPointsAmountTest, UnderLimit) {
TEST_F(EntryPointsAmountTest, OverLimit) {
binaries.push_back({
// clang-format off
- SpvMagicNumber,
- SpvVersion,
+ static_cast<uint32_t>(spv::MagicNumber),
+ static_cast<uint32_t>(spv::Version),
SPV_GENERATOR_WORD(SPV_GENERATOR_KHRONOS, 0),
5u, // NOTE: Bound
0u, // NOTE: Schema; reserved
- SpvOpCapability | 2u << SpvWordCountShift,
- SpvCapabilityShader,
+ static_cast<uint32_t>(spv::Op::OpCapability) | 2u << spv::WordCountShift,
+ static_cast<uint32_t>(spv::Capability::Shader),
- SpvOpMemoryModel | 3u << SpvWordCountShift,
- SpvAddressingModelLogical,
- SpvMemoryModelSimple,
+ static_cast<uint32_t>(spv::Op::OpMemoryModel) | 3u << spv::WordCountShift,
+ static_cast<uint32_t>(spv::AddressingModel::Logical),
+ static_cast<uint32_t>(spv::MemoryModel::Simple),
- SpvOpTypeFloat | 3u << SpvWordCountShift,
+ static_cast<uint32_t>(spv::Op::OpTypeFloat) | 3u << spv::WordCountShift,
1u, // NOTE: Result ID
32u, // NOTE: Width
- SpvOpTypePointer | 4u << SpvWordCountShift,
+ static_cast<uint32_t>(spv::Op::OpTypePointer) | 4u << spv::WordCountShift,
2u, // NOTE: Result ID
- SpvStorageClassInput,
+ static_cast<uint32_t>(spv::StorageClass::Input),
1u, // NOTE: Type ID
- SpvOpVariable | 4u << SpvWordCountShift,
+ static_cast<uint32_t>(spv::Op::OpVariable) | 4u << spv::WordCountShift,
2u, // NOTE: Type ID
3u, // NOTE: Result ID
- SpvStorageClassInput,
+ static_cast<uint32_t>(spv::StorageClass::Input),
- SpvOpVariable | 4u << SpvWordCountShift,
+ static_cast<uint32_t>(spv::Op::OpVariable) | 4u << spv::WordCountShift,
2u, // NOTE: Type ID
4u, // NOTE: Result ID
- SpvStorageClassInput
+ static_cast<uint32_t>(spv::StorageClass::Input)
// clang-format on
});
diff --git a/test/link/ids_limit_test.cpp b/test/link/ids_limit_test.cpp
index 846fbef89..8182e5d63 100644
--- a/test/link/ids_limit_test.cpp
+++ b/test/link/ids_limit_test.cpp
@@ -36,20 +36,20 @@ class IdsLimit : public spvtest::LinkerTest {
// running the RemoveDuplicates pass.
spvtest::Binary common_binary = {
// clang-format off
- SpvMagicNumber,
- SpvVersion,
+ spv::MagicNumber,
+ spv::Version,
SPV_GENERATOR_WORD(SPV_GENERATOR_KHRONOS, 0),
id_bound, // NOTE: Bound
0u, // NOTE: Schema; reserved
- SpvOpCapability | 2u << SpvWordCountShift,
- SpvCapabilityShader,
+ static_cast<uint32_t>(spv::Op::OpCapability) | 2u << spv::WordCountShift,
+ static_cast<uint32_t>(spv::Capability::Shader),
- SpvOpMemoryModel | 3u << SpvWordCountShift,
- SpvAddressingModelLogical,
- SpvMemoryModelSimple,
+ static_cast<uint32_t>(spv::Op::OpMemoryModel) | 3u << spv::WordCountShift,
+ static_cast<uint32_t>(spv::AddressingModel::Logical),
+ static_cast<uint32_t>(spv::MemoryModel::Simple),
- SpvOpTypeBool | 2u << SpvWordCountShift,
+ static_cast<uint32_t>(spv::Op::OpTypeBool) | 2u << spv::WordCountShift,
1u // NOTE: Result ID
// clang-format on
};
@@ -60,7 +60,8 @@ class IdsLimit : public spvtest::LinkerTest {
binary.insert(binary.end(), common_binary.cbegin(), common_binary.cend());
for (uint32_t i = 0u; i < constant_count; ++i) {
- binary.push_back(SpvOpConstantTrue | 3u << SpvWordCountShift);
+ binary.push_back(static_cast<uint32_t>(spv::Op::OpConstantTrue) |
+ 3u << spv::WordCountShift);
binary.push_back(1u); // NOTE: Type ID
binary.push_back(2u + i); // NOTE: Result ID
}
@@ -74,20 +75,20 @@ spvtest::Binary CreateBinary(uint32_t id_bound) {
return {
// clang-format off
// Header
- SpvMagicNumber,
- SpvVersion,
+ spv::MagicNumber,
+ spv::Version,
SPV_GENERATOR_WORD(SPV_GENERATOR_KHRONOS, 0),
id_bound, // NOTE: Bound
0u, // NOTE: Schema; reserved
// OpCapability Shader
- SpvOpCapability | 2u << SpvWordCountShift,
- SpvCapabilityShader,
+ static_cast<uint32_t>(spv::Op::OpCapability) | 2u << spv::WordCountShift,
+ static_cast<uint32_t>(spv::Capability::Shader),
// OpMemoryModel Logical Simple
- SpvOpMemoryModel | 3u << SpvWordCountShift,
- SpvAddressingModelLogical,
- SpvMemoryModelSimple
+ static_cast<uint32_t>(spv::Op::OpMemoryModel) | 3u << spv::WordCountShift,
+ static_cast<uint32_t>(spv::AddressingModel::Logical),
+ static_cast<uint32_t>(spv::MemoryModel::Simple)
// clang-format on
};
}
@@ -105,7 +106,8 @@ TEST_F(IdsLimit, DISABLED_OverLimit) {
const uint32_t id_bound = binary[3];
binary[3] = id_bound + 1u;
- binary.push_back(SpvOpConstantFalse | 3u << SpvWordCountShift);
+ binary.push_back(static_cast<uint32_t>(spv::Op::OpConstantFalse) |
+ 3u << spv::WordCountShift);
binary.push_back(1u); // NOTE: Type ID
binary.push_back(id_bound); // NOTE: Result ID
diff --git a/test/link/memory_model_test.cpp b/test/link/memory_model_test.cpp
index 280a776a0..ee63c59f7 100644
--- a/test/link/memory_model_test.cpp
+++ b/test/link/memory_model_test.cpp
@@ -35,8 +35,10 @@ OpMemoryModel Logical Simple
ASSERT_EQ(SPV_SUCCESS, AssembleAndLink({body1, body2}, &linked_binary));
EXPECT_THAT(GetErrorMessage(), std::string());
- EXPECT_EQ(SpvAddressingModelLogical, linked_binary[6]);
- EXPECT_EQ(SpvMemoryModelSimple, linked_binary[7]);
+ EXPECT_EQ(spv::AddressingModel::Logical,
+ static_cast<spv::AddressingModel>(linked_binary[6]));
+ EXPECT_EQ(spv::MemoryModel::Simple,
+ static_cast<spv::MemoryModel>(linked_binary[7]));
}
TEST_F(MemoryModel, AddressingMismatch) {
diff --git a/test/opcode_make_test.cpp b/test/opcode_make_test.cpp
index 6481ef326..6c1dab60b 100644
--- a/test/opcode_make_test.cpp
+++ b/test/opcode_make_test.cpp
@@ -35,7 +35,7 @@ TEST(OpcodeMake, Samples) {
uint32_t word = 0;
word |= uint32_t(opcode);
word |= uint32_t(wordCount) << 16;
- EXPECT_EQ(word, spvOpcodeMake(wordCount, SpvOp(opcode)));
+ EXPECT_EQ(word, spvOpcodeMake(wordCount, spv::Op(opcode)));
}
}
}
diff --git a/test/opcode_require_capabilities_test.cpp b/test/opcode_require_capabilities_test.cpp
index 07e86f87b..37097c6ff 100644
--- a/test/opcode_require_capabilities_test.cpp
+++ b/test/opcode_require_capabilities_test.cpp
@@ -23,7 +23,7 @@ using spvtest::ElementsIn;
// Capabilities required by an Opcode.
struct ExpectedOpCodeCapabilities {
- SpvOp opcode;
+ spv::Op opcode;
CapabilitySet capabilities;
};
@@ -46,33 +46,36 @@ INSTANTIATE_TEST_SUITE_P(
TableRowTest, OpcodeTableCapabilitiesTest,
// Spot-check a few opcodes.
::testing::Values(
+ ExpectedOpCodeCapabilities{spv::Op::OpImageQuerySize,
+ CapabilitySet{spv::Capability::Kernel,
+ spv::Capability::ImageQuery}},
+ ExpectedOpCodeCapabilities{spv::Op::OpImageQuerySizeLod,
+ CapabilitySet{spv::Capability::Kernel,
+ spv::Capability::ImageQuery}},
+ ExpectedOpCodeCapabilities{spv::Op::OpImageQueryLevels,
+ CapabilitySet{spv::Capability::Kernel,
+ spv::Capability::ImageQuery}},
+ ExpectedOpCodeCapabilities{spv::Op::OpImageQuerySamples,
+ CapabilitySet{spv::Capability::Kernel,
+ spv::Capability::ImageQuery}},
ExpectedOpCodeCapabilities{
- SpvOpImageQuerySize,
- CapabilitySet{SpvCapabilityKernel, SpvCapabilityImageQuery}},
+ spv::Op::OpImageSparseSampleImplicitLod,
+ CapabilitySet{spv::Capability::SparseResidency}},
+ ExpectedOpCodeCapabilities{spv::Op::OpCopyMemorySized,
+ CapabilitySet{spv::Capability::Addresses}},
+ ExpectedOpCodeCapabilities{spv::Op::OpArrayLength,
+ CapabilitySet{spv::Capability::Shader}},
+ ExpectedOpCodeCapabilities{spv::Op::OpFunction, CapabilitySet()},
+ ExpectedOpCodeCapabilities{spv::Op::OpConvertFToS, CapabilitySet()},
ExpectedOpCodeCapabilities{
- SpvOpImageQuerySizeLod,
- CapabilitySet{SpvCapabilityKernel, SpvCapabilityImageQuery}},
+ spv::Op::OpEmitStreamVertex,
+ CapabilitySet{spv::Capability::GeometryStreams}},
ExpectedOpCodeCapabilities{
- SpvOpImageQueryLevels,
- CapabilitySet{SpvCapabilityKernel, SpvCapabilityImageQuery}},
+ spv::Op::OpTypeNamedBarrier,
+ CapabilitySet{spv::Capability::NamedBarrier}},
ExpectedOpCodeCapabilities{
- SpvOpImageQuerySamples,
- CapabilitySet{SpvCapabilityKernel, SpvCapabilityImageQuery}},
- ExpectedOpCodeCapabilities{SpvOpImageSparseSampleImplicitLod,
- CapabilitySet{SpvCapabilitySparseResidency}},
- ExpectedOpCodeCapabilities{SpvOpCopyMemorySized,
- CapabilitySet{SpvCapabilityAddresses}},
- ExpectedOpCodeCapabilities{SpvOpArrayLength,
- CapabilitySet{SpvCapabilityShader}},
- ExpectedOpCodeCapabilities{SpvOpFunction, CapabilitySet()},
- ExpectedOpCodeCapabilities{SpvOpConvertFToS, CapabilitySet()},
- ExpectedOpCodeCapabilities{SpvOpEmitStreamVertex,
- CapabilitySet{SpvCapabilityGeometryStreams}},
- ExpectedOpCodeCapabilities{SpvOpTypeNamedBarrier,
- CapabilitySet{SpvCapabilityNamedBarrier}},
- ExpectedOpCodeCapabilities{
- SpvOpGetKernelMaxNumSubgroups,
- CapabilitySet{SpvCapabilitySubgroupDispatch}}));
+ spv::Op::OpGetKernelMaxNumSubgroups,
+ CapabilitySet{spv::Capability::SubgroupDispatch}}));
} // namespace
} // namespace spvtools
diff --git a/test/opcode_split_test.cpp b/test/opcode_split_test.cpp
index 43fedb385..e8a67b681 100644
--- a/test/opcode_split_test.cpp
+++ b/test/opcode_split_test.cpp
@@ -18,7 +18,7 @@ namespace spvtools {
namespace {
TEST(OpcodeSplit, Default) {
- uint32_t word = spvOpcodeMake(42, (SpvOp)23);
+ uint32_t word = spvOpcodeMake(42, (spv::Op)23);
uint16_t wordCount = 0;
uint16_t opcode;
spvOpcodeSplit(word, &wordCount, &opcode);
diff --git a/test/operand_capabilities_test.cpp b/test/operand_capabilities_test.cpp
index 60503461e..10ed82a18 100644
--- a/test/operand_capabilities_test.cpp
+++ b/test/operand_capabilities_test.cpp
@@ -62,47 +62,47 @@ TEST_P(EnumCapabilityTest, Sample) {
#define CASE0(TYPE, VALUE) \
{ \
- SPV_OPERAND_TYPE_##TYPE, uint32_t(Spv##VALUE), {} \
+ SPV_OPERAND_TYPE_##TYPE, uint32_t(spv::VALUE), {} \
}
#define CASE1(TYPE, VALUE, CAP) \
{ \
- SPV_OPERAND_TYPE_##TYPE, uint32_t(Spv##VALUE), CapabilitySet { \
- SpvCapability##CAP \
+ SPV_OPERAND_TYPE_##TYPE, uint32_t(spv::VALUE), CapabilitySet { \
+ spv::Capability::CAP \
} \
}
#define CASE2(TYPE, VALUE, CAP1, CAP2) \
{ \
- SPV_OPERAND_TYPE_##TYPE, uint32_t(Spv##VALUE), CapabilitySet { \
- SpvCapability##CAP1, SpvCapability##CAP2 \
+ SPV_OPERAND_TYPE_##TYPE, uint32_t(spv::VALUE), CapabilitySet { \
+ spv::Capability::CAP1, spv::Capability::CAP2 \
} \
}
-#define CASE3(TYPE, VALUE, CAP1, CAP2, CAP3) \
- { \
- SPV_OPERAND_TYPE_##TYPE, uint32_t(Spv##VALUE), CapabilitySet { \
- SpvCapability##CAP1, SpvCapability##CAP2, SpvCapability##CAP3 \
- } \
+#define CASE3(TYPE, VALUE, CAP1, CAP2, CAP3) \
+ { \
+ SPV_OPERAND_TYPE_##TYPE, uint32_t(spv::VALUE), CapabilitySet { \
+ spv::Capability::CAP1, spv::Capability::CAP2, spv::Capability::CAP3 \
+ } \
}
-#define CASE4(TYPE, VALUE, CAP1, CAP2, CAP3, CAP4) \
- { \
- SPV_OPERAND_TYPE_##TYPE, uint32_t(Spv##VALUE), CapabilitySet { \
- SpvCapability##CAP1, SpvCapability##CAP2, SpvCapability##CAP3, \
- SpvCapability##CAP4 \
- } \
+#define CASE4(TYPE, VALUE, CAP1, CAP2, CAP3, CAP4) \
+ { \
+ SPV_OPERAND_TYPE_##TYPE, uint32_t(spv::VALUE), CapabilitySet { \
+ spv::Capability::CAP1, spv::Capability::CAP2, spv::Capability::CAP3, \
+ spv::Capability::CAP4 \
+ } \
}
-#define CASE5(TYPE, VALUE, CAP1, CAP2, CAP3, CAP4, CAP5) \
- { \
- SPV_OPERAND_TYPE_##TYPE, uint32_t(Spv##VALUE), CapabilitySet { \
- SpvCapability##CAP1, SpvCapability##CAP2, SpvCapability##CAP3, \
- SpvCapability##CAP4, SpvCapability##CAP5 \
- } \
+#define CASE5(TYPE, VALUE, CAP1, CAP2, CAP3, CAP4, CAP5) \
+ { \
+ SPV_OPERAND_TYPE_##TYPE, uint32_t(spv::VALUE), CapabilitySet { \
+ spv::Capability::CAP1, spv::Capability::CAP2, spv::Capability::CAP3, \
+ spv::Capability::CAP4, spv::Capability::CAP5 \
+ } \
}
-#define CASE6(TYPE, VALUE, CAP1, CAP2, CAP3, CAP4, CAP5, CAP6) \
- { \
- SPV_OPERAND_TYPE_##TYPE, uint32_t(Spv##VALUE), CapabilitySet { \
- SpvCapability##CAP1, SpvCapability##CAP2, SpvCapability##CAP3, \
- SpvCapability##CAP4, SpvCapability##CAP5, SpvCapability##CAP6 \
- } \
+#define CASE6(TYPE, VALUE, CAP1, CAP2, CAP3, CAP4, CAP5, CAP6) \
+ { \
+ SPV_OPERAND_TYPE_##TYPE, uint32_t(spv::VALUE), CapabilitySet { \
+ spv::Capability::CAP1, spv::Capability::CAP2, spv::Capability::CAP3, \
+ spv::Capability::CAP4, spv::Capability::CAP5, spv::Capability::CAP6 \
+ } \
}
// See SPIR-V Section 3.3 Execution Model
@@ -110,15 +110,15 @@ INSTANTIATE_TEST_SUITE_P(
ExecutionModel, EnumCapabilityTest,
Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
ValuesIn(std::vector<EnumCapabilityCase>{
- CASE1(EXECUTION_MODEL, ExecutionModelVertex, Shader),
- CASE1(EXECUTION_MODEL, ExecutionModelTessellationControl,
+ CASE1(EXECUTION_MODEL, ExecutionModel::Vertex, Shader),
+ CASE1(EXECUTION_MODEL, ExecutionModel::TessellationControl,
Tessellation),
- CASE1(EXECUTION_MODEL, ExecutionModelTessellationEvaluation,
+ CASE1(EXECUTION_MODEL, ExecutionModel::TessellationEvaluation,
Tessellation),
- CASE1(EXECUTION_MODEL, ExecutionModelGeometry, Geometry),
- CASE1(EXECUTION_MODEL, ExecutionModelFragment, Shader),
- CASE1(EXECUTION_MODEL, ExecutionModelGLCompute, Shader),
- CASE1(EXECUTION_MODEL, ExecutionModelKernel, Kernel),
+ CASE1(EXECUTION_MODEL, ExecutionModel::Geometry, Geometry),
+ CASE1(EXECUTION_MODEL, ExecutionModel::Fragment, Shader),
+ CASE1(EXECUTION_MODEL, ExecutionModel::GLCompute, Shader),
+ CASE1(EXECUTION_MODEL, ExecutionModel::Kernel, Kernel),
})));
// See SPIR-V Section 3.4 Addressing Model
@@ -126,9 +126,9 @@ INSTANTIATE_TEST_SUITE_P(
AddressingModel, EnumCapabilityTest,
Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
ValuesIn(std::vector<EnumCapabilityCase>{
- CASE0(ADDRESSING_MODEL, AddressingModelLogical),
- CASE1(ADDRESSING_MODEL, AddressingModelPhysical32, Addresses),
- CASE1(ADDRESSING_MODEL, AddressingModelPhysical64, Addresses),
+ CASE0(ADDRESSING_MODEL, AddressingModel::Logical),
+ CASE1(ADDRESSING_MODEL, AddressingModel::Physical32, Addresses),
+ CASE1(ADDRESSING_MODEL, AddressingModel::Physical64, Addresses),
})));
// See SPIR-V Section 3.5 Memory Model
@@ -136,9 +136,9 @@ INSTANTIATE_TEST_SUITE_P(
MemoryModel, EnumCapabilityTest,
Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
ValuesIn(std::vector<EnumCapabilityCase>{
- CASE1(MEMORY_MODEL, MemoryModelSimple, Shader),
- CASE1(MEMORY_MODEL, MemoryModelGLSL450, Shader),
- CASE1(MEMORY_MODEL, MemoryModelOpenCL, Kernel),
+ CASE1(MEMORY_MODEL, MemoryModel::Simple, Shader),
+ CASE1(MEMORY_MODEL, MemoryModel::GLSL450, Shader),
+ CASE1(MEMORY_MODEL, MemoryModel::OpenCL, Kernel),
})));
// See SPIR-V Section 3.6 Execution Mode
@@ -147,54 +147,54 @@ INSTANTIATE_TEST_SUITE_P(
Combine(
Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
ValuesIn(std::vector<EnumCapabilityCase>{
- CASE1(EXECUTION_MODE, ExecutionModeInvocations, Geometry),
- CASE1(EXECUTION_MODE, ExecutionModeSpacingEqual, Tessellation),
- CASE1(EXECUTION_MODE, ExecutionModeSpacingFractionalEven,
+ CASE1(EXECUTION_MODE, ExecutionMode::Invocations, Geometry),
+ CASE1(EXECUTION_MODE, ExecutionMode::SpacingEqual, Tessellation),
+ CASE1(EXECUTION_MODE, ExecutionMode::SpacingFractionalEven,
Tessellation),
- CASE1(EXECUTION_MODE, ExecutionModeSpacingFractionalOdd,
+ CASE1(EXECUTION_MODE, ExecutionMode::SpacingFractionalOdd,
Tessellation),
- CASE1(EXECUTION_MODE, ExecutionModeVertexOrderCw, Tessellation),
- CASE1(EXECUTION_MODE, ExecutionModeVertexOrderCcw, Tessellation),
- CASE1(EXECUTION_MODE, ExecutionModePixelCenterInteger, Shader),
- CASE1(EXECUTION_MODE, ExecutionModeOriginUpperLeft, Shader),
- CASE1(EXECUTION_MODE, ExecutionModeOriginLowerLeft, Shader),
- CASE1(EXECUTION_MODE, ExecutionModeEarlyFragmentTests, Shader),
- CASE1(EXECUTION_MODE, ExecutionModePointMode, Tessellation),
- CASE1(EXECUTION_MODE, ExecutionModeXfb, TransformFeedback),
- CASE1(EXECUTION_MODE, ExecutionModeDepthReplacing, Shader),
- CASE1(EXECUTION_MODE, ExecutionModeDepthGreater, Shader),
- CASE1(EXECUTION_MODE, ExecutionModeDepthLess, Shader),
- CASE1(EXECUTION_MODE, ExecutionModeDepthUnchanged, Shader),
- CASE0(EXECUTION_MODE, ExecutionModeLocalSize),
- CASE1(EXECUTION_MODE, ExecutionModeLocalSizeHint, Kernel),
- CASE1(EXECUTION_MODE, ExecutionModeInputPoints, Geometry),
- CASE1(EXECUTION_MODE, ExecutionModeInputLines, Geometry),
- CASE1(EXECUTION_MODE, ExecutionModeInputLinesAdjacency, Geometry),
- CASE2(EXECUTION_MODE, ExecutionModeTriangles, Geometry,
+ CASE1(EXECUTION_MODE, ExecutionMode::VertexOrderCw, Tessellation),
+ CASE1(EXECUTION_MODE, ExecutionMode::VertexOrderCcw, Tessellation),
+ CASE1(EXECUTION_MODE, ExecutionMode::PixelCenterInteger, Shader),
+ CASE1(EXECUTION_MODE, ExecutionMode::OriginUpperLeft, Shader),
+ CASE1(EXECUTION_MODE, ExecutionMode::OriginLowerLeft, Shader),
+ CASE1(EXECUTION_MODE, ExecutionMode::EarlyFragmentTests, Shader),
+ CASE1(EXECUTION_MODE, ExecutionMode::PointMode, Tessellation),
+ CASE1(EXECUTION_MODE, ExecutionMode::Xfb, TransformFeedback),
+ CASE1(EXECUTION_MODE, ExecutionMode::DepthReplacing, Shader),
+ CASE1(EXECUTION_MODE, ExecutionMode::DepthGreater, Shader),
+ CASE1(EXECUTION_MODE, ExecutionMode::DepthLess, Shader),
+ CASE1(EXECUTION_MODE, ExecutionMode::DepthUnchanged, Shader),
+ CASE0(EXECUTION_MODE, ExecutionMode::LocalSize),
+ CASE1(EXECUTION_MODE, ExecutionMode::LocalSizeHint, Kernel),
+ CASE1(EXECUTION_MODE, ExecutionMode::InputPoints, Geometry),
+ CASE1(EXECUTION_MODE, ExecutionMode::InputLines, Geometry),
+ CASE1(EXECUTION_MODE, ExecutionMode::InputLinesAdjacency, Geometry),
+ CASE2(EXECUTION_MODE, ExecutionMode::Triangles, Geometry,
Tessellation),
- CASE1(EXECUTION_MODE, ExecutionModeInputTrianglesAdjacency,
+ CASE1(EXECUTION_MODE, ExecutionMode::InputTrianglesAdjacency,
Geometry),
- CASE1(EXECUTION_MODE, ExecutionModeQuads, Tessellation),
- CASE1(EXECUTION_MODE, ExecutionModeIsolines, Tessellation),
- CASE4(EXECUTION_MODE, ExecutionModeOutputVertices, Geometry,
+ CASE1(EXECUTION_MODE, ExecutionMode::Quads, Tessellation),
+ CASE1(EXECUTION_MODE, ExecutionMode::Isolines, Tessellation),
+ CASE4(EXECUTION_MODE, ExecutionMode::OutputVertices, Geometry,
Tessellation, MeshShadingNV, MeshShadingEXT),
- CASE3(EXECUTION_MODE, ExecutionModeOutputPoints, Geometry,
+ CASE3(EXECUTION_MODE, ExecutionMode::OutputPoints, Geometry,
MeshShadingNV, MeshShadingEXT),
- CASE1(EXECUTION_MODE, ExecutionModeOutputLineStrip, Geometry),
- CASE1(EXECUTION_MODE, ExecutionModeOutputTriangleStrip, Geometry),
- CASE1(EXECUTION_MODE, ExecutionModeVecTypeHint, Kernel),
- CASE1(EXECUTION_MODE, ExecutionModeContractionOff, Kernel),
+ CASE1(EXECUTION_MODE, ExecutionMode::OutputLineStrip, Geometry),
+ CASE1(EXECUTION_MODE, ExecutionMode::OutputTriangleStrip, Geometry),
+ CASE1(EXECUTION_MODE, ExecutionMode::VecTypeHint, Kernel),
+ CASE1(EXECUTION_MODE, ExecutionMode::ContractionOff, Kernel),
})));
INSTANTIATE_TEST_SUITE_P(
ExecutionModeV11, EnumCapabilityTest,
Combine(Values(SPV_ENV_UNIVERSAL_1_1),
ValuesIn(std::vector<EnumCapabilityCase>{
- CASE1(EXECUTION_MODE, ExecutionModeInitializer, Kernel),
- CASE1(EXECUTION_MODE, ExecutionModeFinalizer, Kernel),
- CASE1(EXECUTION_MODE, ExecutionModeSubgroupSize,
+ CASE1(EXECUTION_MODE, ExecutionMode::Initializer, Kernel),
+ CASE1(EXECUTION_MODE, ExecutionMode::Finalizer, Kernel),
+ CASE1(EXECUTION_MODE, ExecutionMode::SubgroupSize,
SubgroupDispatch),
- CASE1(EXECUTION_MODE, ExecutionModeSubgroupsPerWorkgroup,
+ CASE1(EXECUTION_MODE, ExecutionMode::SubgroupsPerWorkgroup,
SubgroupDispatch)})));
// See SPIR-V Section 3.7 Storage Class
@@ -202,19 +202,20 @@ INSTANTIATE_TEST_SUITE_P(
StorageClass, EnumCapabilityTest,
Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
ValuesIn(std::vector<EnumCapabilityCase>{
- CASE0(STORAGE_CLASS, StorageClassUniformConstant),
- CASE1(STORAGE_CLASS, StorageClassUniform, Shader),
- CASE1(STORAGE_CLASS, StorageClassOutput, Shader),
- CASE0(STORAGE_CLASS, StorageClassWorkgroup),
- CASE0(STORAGE_CLASS, StorageClassCrossWorkgroup),
- CASE2(STORAGE_CLASS, StorageClassPrivate, Shader,
+ CASE0(STORAGE_CLASS, StorageClass::UniformConstant),
+ CASE1(STORAGE_CLASS, StorageClass::Uniform, Shader),
+ CASE1(STORAGE_CLASS, StorageClass::Output, Shader),
+ CASE0(STORAGE_CLASS, StorageClass::Workgroup),
+ CASE0(STORAGE_CLASS, StorageClass::CrossWorkgroup),
+ CASE2(STORAGE_CLASS, StorageClass::Private, Shader,
VectorComputeINTEL),
- CASE0(STORAGE_CLASS, StorageClassFunction),
- CASE1(STORAGE_CLASS, StorageClassGeneric,
+ CASE0(STORAGE_CLASS, StorageClass::Function),
+ CASE1(STORAGE_CLASS, StorageClass::Generic,
GenericPointer), // Bug 14287
- CASE1(STORAGE_CLASS, StorageClassPushConstant, Shader),
- CASE1(STORAGE_CLASS, StorageClassAtomicCounter, AtomicStorage),
- CASE0(STORAGE_CLASS, StorageClassImage),
+ CASE1(STORAGE_CLASS, StorageClass::PushConstant, Shader),
+ CASE1(STORAGE_CLASS, StorageClass::AtomicCounter,
+ AtomicStorage),
+ CASE0(STORAGE_CLASS, StorageClass::Image),
})));
// See SPIR-V Section 3.8 Dim
@@ -222,37 +223,39 @@ INSTANTIATE_TEST_SUITE_P(
Dim, EnumCapabilityTest,
Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
ValuesIn(std::vector<EnumCapabilityCase>{
- CASE2(DIMENSIONALITY, Dim1D, Sampled1D, Image1D),
- CASE3(DIMENSIONALITY, Dim2D, Kernel, Shader, ImageMSArray),
- CASE0(DIMENSIONALITY, Dim3D),
- CASE2(DIMENSIONALITY, DimCube, Shader, ImageCubeArray),
- CASE2(DIMENSIONALITY, DimRect, SampledRect, ImageRect),
- CASE2(DIMENSIONALITY, DimBuffer, SampledBuffer, ImageBuffer),
- CASE1(DIMENSIONALITY, DimSubpassData, InputAttachment),
+ CASE2(DIMENSIONALITY, Dim::Dim1D, Sampled1D, Image1D),
+ CASE3(DIMENSIONALITY, Dim::Dim2D, Kernel, Shader, ImageMSArray),
+ CASE0(DIMENSIONALITY, Dim::Dim3D),
+ CASE2(DIMENSIONALITY, Dim::Cube, Shader, ImageCubeArray),
+ CASE2(DIMENSIONALITY, Dim::Rect, SampledRect, ImageRect),
+ CASE2(DIMENSIONALITY, Dim::Buffer, SampledBuffer, ImageBuffer),
+ CASE1(DIMENSIONALITY, Dim::SubpassData, InputAttachment),
})));
// See SPIR-V Section 3.9 Sampler Addressing Mode
INSTANTIATE_TEST_SUITE_P(
SamplerAddressingMode, EnumCapabilityTest,
- Combine(
- Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
- ValuesIn(std::vector<EnumCapabilityCase>{
- CASE1(SAMPLER_ADDRESSING_MODE, SamplerAddressingModeNone, Kernel),
- CASE1(SAMPLER_ADDRESSING_MODE, SamplerAddressingModeClampToEdge,
- Kernel),
- CASE1(SAMPLER_ADDRESSING_MODE, SamplerAddressingModeClamp, Kernel),
- CASE1(SAMPLER_ADDRESSING_MODE, SamplerAddressingModeRepeat, Kernel),
- CASE1(SAMPLER_ADDRESSING_MODE, SamplerAddressingModeRepeatMirrored,
- Kernel),
- })));
+ Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
+ ValuesIn(std::vector<EnumCapabilityCase>{
+ CASE1(SAMPLER_ADDRESSING_MODE, SamplerAddressingMode::None,
+ Kernel),
+ CASE1(SAMPLER_ADDRESSING_MODE,
+ SamplerAddressingMode::ClampToEdge, Kernel),
+ CASE1(SAMPLER_ADDRESSING_MODE, SamplerAddressingMode::Clamp,
+ Kernel),
+ CASE1(SAMPLER_ADDRESSING_MODE, SamplerAddressingMode::Repeat,
+ Kernel),
+ CASE1(SAMPLER_ADDRESSING_MODE,
+ SamplerAddressingMode::RepeatMirrored, Kernel),
+ })));
// See SPIR-V Section 3.10 Sampler Filter Mode
INSTANTIATE_TEST_SUITE_P(
SamplerFilterMode, EnumCapabilityTest,
Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
ValuesIn(std::vector<EnumCapabilityCase>{
- CASE1(SAMPLER_FILTER_MODE, SamplerFilterModeNearest, Kernel),
- CASE1(SAMPLER_FILTER_MODE, SamplerFilterModeLinear, Kernel),
+ CASE1(SAMPLER_FILTER_MODE, SamplerFilterMode::Nearest, Kernel),
+ CASE1(SAMPLER_FILTER_MODE, SamplerFilterMode::Linear, Kernel),
})));
// See SPIR-V Section 3.11 Image Format
@@ -261,76 +264,76 @@ INSTANTIATE_TEST_SUITE_P(
Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
ValuesIn(std::vector<EnumCapabilityCase>{
// clang-format off
- CASE0(SAMPLER_IMAGE_FORMAT, ImageFormatUnknown),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatRgba32f, Shader),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatRgba16f, Shader),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatR32f, Shader),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatRgba8, Shader),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatRgba8Snorm, Shader),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatRg32f, StorageImageExtendedFormats),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatRg16f, StorageImageExtendedFormats),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatR11fG11fB10f, StorageImageExtendedFormats),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatR16f, StorageImageExtendedFormats),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatRgba16, StorageImageExtendedFormats),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatRgb10A2, StorageImageExtendedFormats),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatRg16, StorageImageExtendedFormats),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatRg8, StorageImageExtendedFormats),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatR16, StorageImageExtendedFormats),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatR8, StorageImageExtendedFormats),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatRgba16Snorm, StorageImageExtendedFormats),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatRg16Snorm, StorageImageExtendedFormats),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatRg8Snorm, StorageImageExtendedFormats),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatR16Snorm, StorageImageExtendedFormats),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatR8Snorm, StorageImageExtendedFormats),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatRgba32i, Shader),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatRgba16i, Shader),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatRgba8i, Shader),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatR32i, Shader),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatRg32i, StorageImageExtendedFormats),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatRg16i, StorageImageExtendedFormats),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatRg8i, StorageImageExtendedFormats),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatR16i, StorageImageExtendedFormats),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatR8i, StorageImageExtendedFormats),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatRgba32ui, Shader),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatRgba16ui, Shader),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatRgba8ui, Shader),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatRgba8ui, Shader),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatRgb10a2ui, StorageImageExtendedFormats),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatRg32ui, StorageImageExtendedFormats),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatRg16ui, StorageImageExtendedFormats),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatRg8ui, StorageImageExtendedFormats),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatR16ui, StorageImageExtendedFormats),
- CASE1(SAMPLER_IMAGE_FORMAT, ImageFormatR8ui, StorageImageExtendedFormats),
+ CASE0(SAMPLER_IMAGE_FORMAT, ImageFormat::Unknown),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::Rgba32f, Shader),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::Rgba16f, Shader),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::R32f, Shader),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::Rgba8, Shader),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::Rgba8Snorm, Shader),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::Rg32f, StorageImageExtendedFormats),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::Rg16f, StorageImageExtendedFormats),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::R11fG11fB10f, StorageImageExtendedFormats),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::R16f, StorageImageExtendedFormats),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::Rgba16, StorageImageExtendedFormats),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::Rgb10A2, StorageImageExtendedFormats),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::Rg16, StorageImageExtendedFormats),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::Rg8, StorageImageExtendedFormats),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::R16, StorageImageExtendedFormats),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::R8, StorageImageExtendedFormats),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::Rgba16Snorm, StorageImageExtendedFormats),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::Rg16Snorm, StorageImageExtendedFormats),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::Rg8Snorm, StorageImageExtendedFormats),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::R16Snorm, StorageImageExtendedFormats),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::R8Snorm, StorageImageExtendedFormats),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::Rgba32i, Shader),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::Rgba16i, Shader),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::Rgba8i, Shader),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::R32i, Shader),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::Rg32i, StorageImageExtendedFormats),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::Rg16i, StorageImageExtendedFormats),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::Rg8i, StorageImageExtendedFormats),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::R16i, StorageImageExtendedFormats),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::R8i, StorageImageExtendedFormats),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::Rgba32ui, Shader),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::Rgba16ui, Shader),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::Rgba8ui, Shader),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::Rgba8ui, Shader),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::Rgb10a2ui, StorageImageExtendedFormats),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::Rg32ui, StorageImageExtendedFormats),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::Rg16ui, StorageImageExtendedFormats),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::Rg8ui, StorageImageExtendedFormats),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::R16ui, StorageImageExtendedFormats),
+ CASE1(SAMPLER_IMAGE_FORMAT, ImageFormat::R8ui, StorageImageExtendedFormats),
// clang-format on
})));
// See SPIR-V Section 3.12 Image Channel Order
INSTANTIATE_TEST_SUITE_P(
ImageChannelOrder, EnumCapabilityTest,
- Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
- ValuesIn(std::vector<EnumCapabilityCase>{
- CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrderR, Kernel),
- CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrderA, Kernel),
- CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrderRG, Kernel),
- CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrderRA, Kernel),
- CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrderRGB, Kernel),
- CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrderRGBA, Kernel),
- CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrderBGRA, Kernel),
- CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrderARGB, Kernel),
- CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrderIntensity, Kernel),
- CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrderLuminance, Kernel),
- CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrderRx, Kernel),
- CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrderRGx, Kernel),
- CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrderRGBx, Kernel),
- CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrderDepth, Kernel),
- CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrderDepthStencil,
- Kernel),
- CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrdersRGB, Kernel),
- CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrdersRGBx, Kernel),
- CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrdersRGBA, Kernel),
- CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrdersBGRA, Kernel),
- CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrderABGR, Kernel),
- })));
+ Combine(
+ Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
+ ValuesIn(std::vector<EnumCapabilityCase>{
+ CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::R, Kernel),
+ CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::A, Kernel),
+ CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::RG, Kernel),
+ CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::RA, Kernel),
+ CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::RGB, Kernel),
+ CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::RGBA, Kernel),
+ CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::BGRA, Kernel),
+ CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::ARGB, Kernel),
+ CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::Intensity, Kernel),
+ CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::Luminance, Kernel),
+ CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::Rx, Kernel),
+ CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::RGx, Kernel),
+ CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::RGBx, Kernel),
+ CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::Depth, Kernel),
+ CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::DepthStencil, Kernel),
+ CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::sRGB, Kernel),
+ CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::sRGBx, Kernel),
+ CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::sRGBA, Kernel),
+ CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::sBGRA, Kernel),
+ CASE1(IMAGE_CHANNEL_ORDER, ImageChannelOrder::ABGR, Kernel),
+ })));
// See SPIR-V Section 3.13 Image Channel Data Type
INSTANTIATE_TEST_SUITE_P(
@@ -338,23 +341,23 @@ INSTANTIATE_TEST_SUITE_P(
Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
ValuesIn(std::vector<EnumCapabilityCase>{
// clang-format off
- CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeSnormInt8, Kernel),
- CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeSnormInt16, Kernel),
- CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeUnormInt8, Kernel),
- CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeUnormInt16, Kernel),
- CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeUnormShort565, Kernel),
- CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeUnormShort555, Kernel),
- CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeUnormInt101010, Kernel),
- CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeSignedInt8, Kernel),
- CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeSignedInt16, Kernel),
- CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeSignedInt32, Kernel),
- CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeUnsignedInt8, Kernel),
- CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeUnsignedInt16, Kernel),
- CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeUnsignedInt32, Kernel),
- CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeHalfFloat, Kernel),
- CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeFloat, Kernel),
- CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeUnormInt24, Kernel),
- CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataTypeUnormInt101010_2, Kernel),
+ CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::SnormInt8, Kernel),
+ CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::SnormInt16, Kernel),
+ CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::UnormInt8, Kernel),
+ CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::UnormInt16, Kernel),
+ CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::UnormShort565, Kernel),
+ CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::UnormShort555, Kernel),
+ CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::UnormInt101010, Kernel),
+ CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::SignedInt8, Kernel),
+ CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::SignedInt16, Kernel),
+ CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::SignedInt32, Kernel),
+ CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::UnsignedInt8, Kernel),
+ CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::UnsignedInt16, Kernel),
+ CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::UnsignedInt32, Kernel),
+ CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::HalfFloat, Kernel),
+ CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::Float, Kernel),
+ CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::UnormInt24, Kernel),
+ CASE1(IMAGE_CHANNEL_DATA_TYPE, ImageChannelDataType::UnormInt101010_2, Kernel),
// clang-format on
})));
@@ -364,15 +367,15 @@ INSTANTIATE_TEST_SUITE_P(
Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
ValuesIn(std::vector<EnumCapabilityCase>{
// clang-format off
- CASE0(OPTIONAL_IMAGE, ImageOperandsMaskNone),
- CASE1(OPTIONAL_IMAGE, ImageOperandsBiasMask, Shader),
- CASE0(OPTIONAL_IMAGE, ImageOperandsLodMask),
- CASE0(OPTIONAL_IMAGE, ImageOperandsGradMask),
- CASE0(OPTIONAL_IMAGE, ImageOperandsConstOffsetMask),
- CASE1(OPTIONAL_IMAGE, ImageOperandsOffsetMask, ImageGatherExtended),
- CASE1(OPTIONAL_IMAGE, ImageOperandsConstOffsetsMask, ImageGatherExtended),
- CASE0(OPTIONAL_IMAGE, ImageOperandsSampleMask),
- CASE1(OPTIONAL_IMAGE, ImageOperandsMinLodMask, MinLod),
+ CASE0(OPTIONAL_IMAGE, ImageOperandsMask::MaskNone),
+ CASE1(OPTIONAL_IMAGE, ImageOperandsMask::Bias, Shader),
+ CASE0(OPTIONAL_IMAGE, ImageOperandsMask::Lod),
+ CASE0(OPTIONAL_IMAGE, ImageOperandsMask::Grad),
+ CASE0(OPTIONAL_IMAGE, ImageOperandsMask::ConstOffset),
+ CASE1(OPTIONAL_IMAGE, ImageOperandsMask::Offset, ImageGatherExtended),
+ CASE1(OPTIONAL_IMAGE, ImageOperandsMask::ConstOffsets, ImageGatherExtended),
+ CASE0(OPTIONAL_IMAGE, ImageOperandsMask::Sample),
+ CASE1(OPTIONAL_IMAGE, ImageOperandsMask::MinLod, MinLod),
// clang-format on
})));
@@ -381,8 +384,8 @@ INSTANTIATE_TEST_SUITE_P(
LinkageType, EnumCapabilityTest,
Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
ValuesIn(std::vector<EnumCapabilityCase>{
- CASE1(LINKAGE_TYPE, LinkageTypeExport, Linkage),
- CASE1(LINKAGE_TYPE, LinkageTypeImport, Linkage),
+ CASE1(LINKAGE_TYPE, LinkageType::Export, Linkage),
+ CASE1(LINKAGE_TYPE, LinkageType::Import, Linkage),
})));
// See SPIR-V Section 3.18 Access Qualifier
@@ -390,9 +393,9 @@ INSTANTIATE_TEST_SUITE_P(
AccessQualifier, EnumCapabilityTest,
Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
ValuesIn(std::vector<EnumCapabilityCase>{
- CASE1(ACCESS_QUALIFIER, AccessQualifierReadOnly, Kernel),
- CASE1(ACCESS_QUALIFIER, AccessQualifierWriteOnly, Kernel),
- CASE1(ACCESS_QUALIFIER, AccessQualifierReadWrite, Kernel),
+ CASE1(ACCESS_QUALIFIER, AccessQualifier::ReadOnly, Kernel),
+ CASE1(ACCESS_QUALIFIER, AccessQualifier::WriteOnly, Kernel),
+ CASE1(ACCESS_QUALIFIER, AccessQualifier::ReadWrite, Kernel),
})));
// See SPIR-V Section 3.19 Function Parameter Attribute
@@ -401,14 +404,14 @@ INSTANTIATE_TEST_SUITE_P(
Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
ValuesIn(std::vector<EnumCapabilityCase>{
// clang-format off
- CASE1(FUNCTION_PARAMETER_ATTRIBUTE, FunctionParameterAttributeZext, Kernel),
- CASE1(FUNCTION_PARAMETER_ATTRIBUTE, FunctionParameterAttributeSext, Kernel),
- CASE1(FUNCTION_PARAMETER_ATTRIBUTE, FunctionParameterAttributeByVal, Kernel),
- CASE1(FUNCTION_PARAMETER_ATTRIBUTE, FunctionParameterAttributeSret, Kernel),
- CASE1(FUNCTION_PARAMETER_ATTRIBUTE, FunctionParameterAttributeNoAlias, Kernel),
- CASE1(FUNCTION_PARAMETER_ATTRIBUTE, FunctionParameterAttributeNoCapture, Kernel),
- CASE1(FUNCTION_PARAMETER_ATTRIBUTE, FunctionParameterAttributeNoWrite, Kernel),
- CASE1(FUNCTION_PARAMETER_ATTRIBUTE, FunctionParameterAttributeNoReadWrite, Kernel),
+ CASE1(FUNCTION_PARAMETER_ATTRIBUTE, FunctionParameterAttribute::Zext, Kernel),
+ CASE1(FUNCTION_PARAMETER_ATTRIBUTE, FunctionParameterAttribute::Sext, Kernel),
+ CASE1(FUNCTION_PARAMETER_ATTRIBUTE, FunctionParameterAttribute::ByVal, Kernel),
+ CASE1(FUNCTION_PARAMETER_ATTRIBUTE, FunctionParameterAttribute::Sret, Kernel),
+ CASE1(FUNCTION_PARAMETER_ATTRIBUTE, FunctionParameterAttribute::NoAlias, Kernel),
+ CASE1(FUNCTION_PARAMETER_ATTRIBUTE, FunctionParameterAttribute::NoCapture, Kernel),
+ CASE1(FUNCTION_PARAMETER_ATTRIBUTE, FunctionParameterAttribute::NoWrite, Kernel),
+ CASE1(FUNCTION_PARAMETER_ATTRIBUTE, FunctionParameterAttribute::NoReadWrite, Kernel),
// clang-format on
})));
@@ -417,52 +420,53 @@ INSTANTIATE_TEST_SUITE_P(
Decoration, EnumCapabilityTest,
Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
ValuesIn(std::vector<EnumCapabilityCase>{
- CASE1(DECORATION, DecorationRelaxedPrecision, Shader),
+ CASE1(DECORATION, Decoration::RelaxedPrecision, Shader),
// DecorationSpecId handled below.
- CASE1(DECORATION, DecorationBlock, Shader),
- CASE1(DECORATION, DecorationBufferBlock, Shader),
- CASE1(DECORATION, DecorationRowMajor, Matrix),
- CASE1(DECORATION, DecorationColMajor, Matrix),
- CASE1(DECORATION, DecorationArrayStride, Shader),
- CASE1(DECORATION, DecorationMatrixStride, Matrix), // Bug 15234
- CASE1(DECORATION, DecorationGLSLShared, Shader),
- CASE1(DECORATION, DecorationGLSLPacked, Shader),
- CASE1(DECORATION, DecorationCPacked, Kernel),
- CASE0(DECORATION, DecorationBuiltIn), // Bug 15248
+ CASE1(DECORATION, Decoration::Block, Shader),
+ CASE1(DECORATION, Decoration::BufferBlock, Shader),
+ CASE1(DECORATION, Decoration::RowMajor, Matrix),
+ CASE1(DECORATION, Decoration::ColMajor, Matrix),
+ CASE1(DECORATION, Decoration::ArrayStride, Shader),
+ CASE1(DECORATION, Decoration::MatrixStride,
+ Matrix), // Bug 15234
+ CASE1(DECORATION, Decoration::GLSLShared, Shader),
+ CASE1(DECORATION, Decoration::GLSLPacked, Shader),
+ CASE1(DECORATION, Decoration::CPacked, Kernel),
+ CASE0(DECORATION, Decoration::BuiltIn), // Bug 15248
// Value 12 placeholder
- CASE1(DECORATION, DecorationNoPerspective, Shader),
- CASE1(DECORATION, DecorationFlat, Shader),
- CASE1(DECORATION, DecorationPatch, Tessellation),
- CASE1(DECORATION, DecorationCentroid, Shader),
- CASE1(DECORATION, DecorationSample,
+ CASE1(DECORATION, Decoration::NoPerspective, Shader),
+ CASE1(DECORATION, Decoration::Flat, Shader),
+ CASE1(DECORATION, Decoration::Patch, Tessellation),
+ CASE1(DECORATION, Decoration::Centroid, Shader),
+ CASE1(DECORATION, Decoration::Sample,
SampleRateShading), // Bug 15234
- CASE1(DECORATION, DecorationInvariant, Shader),
- CASE0(DECORATION, DecorationRestrict),
- CASE0(DECORATION, DecorationAliased),
- CASE0(DECORATION, DecorationVolatile),
- CASE1(DECORATION, DecorationConstant, Kernel),
- CASE0(DECORATION, DecorationCoherent),
- CASE0(DECORATION, DecorationNonWritable),
- CASE0(DECORATION, DecorationNonReadable),
- CASE1(DECORATION, DecorationUniform, Shader),
+ CASE1(DECORATION, Decoration::Invariant, Shader),
+ CASE0(DECORATION, Decoration::Restrict),
+ CASE0(DECORATION, Decoration::Aliased),
+ CASE0(DECORATION, Decoration::Volatile),
+ CASE1(DECORATION, Decoration::Constant, Kernel),
+ CASE0(DECORATION, Decoration::Coherent),
+ CASE0(DECORATION, Decoration::NonWritable),
+ CASE0(DECORATION, Decoration::NonReadable),
+ CASE1(DECORATION, Decoration::Uniform, Shader),
// Value 27 is an intentional gap in the spec numbering.
- CASE1(DECORATION, DecorationSaturatedConversion, Kernel),
- CASE1(DECORATION, DecorationStream, GeometryStreams),
- CASE1(DECORATION, DecorationLocation, Shader),
- CASE1(DECORATION, DecorationComponent, Shader),
- CASE1(DECORATION, DecorationIndex, Shader),
- CASE1(DECORATION, DecorationBinding, Shader),
- CASE1(DECORATION, DecorationDescriptorSet, Shader),
- CASE1(DECORATION, DecorationOffset, Shader), // Bug 15268
- CASE1(DECORATION, DecorationXfbBuffer, TransformFeedback),
- CASE1(DECORATION, DecorationXfbStride, TransformFeedback),
- CASE1(DECORATION, DecorationFuncParamAttr, Kernel),
- CASE1(DECORATION, DecorationFPFastMathMode, Kernel),
- CASE1(DECORATION, DecorationLinkageAttributes, Linkage),
- CASE1(DECORATION, DecorationNoContraction, Shader),
- CASE1(DECORATION, DecorationInputAttachmentIndex,
+ CASE1(DECORATION, Decoration::SaturatedConversion, Kernel),
+ CASE1(DECORATION, Decoration::Stream, GeometryStreams),
+ CASE1(DECORATION, Decoration::Location, Shader),
+ CASE1(DECORATION, Decoration::Component, Shader),
+ CASE1(DECORATION, Decoration::Index, Shader),
+ CASE1(DECORATION, Decoration::Binding, Shader),
+ CASE1(DECORATION, Decoration::DescriptorSet, Shader),
+ CASE1(DECORATION, Decoration::Offset, Shader), // Bug 15268
+ CASE1(DECORATION, Decoration::XfbBuffer, TransformFeedback),
+ CASE1(DECORATION, Decoration::XfbStride, TransformFeedback),
+ CASE1(DECORATION, Decoration::FuncParamAttr, Kernel),
+ CASE1(DECORATION, Decoration::FPFastMathMode, Kernel),
+ CASE1(DECORATION, Decoration::LinkageAttributes, Linkage),
+ CASE1(DECORATION, Decoration::NoContraction, Shader),
+ CASE1(DECORATION, Decoration::InputAttachmentIndex,
InputAttachment),
- CASE1(DECORATION, DecorationAlignment, Kernel),
+ CASE1(DECORATION, Decoration::Alignment, Kernel),
})));
#if 0
@@ -477,8 +481,8 @@ INSTANTIATE_TEST_SUITE_P(
DecorationV11, EnumCapabilityTest,
Combine(Values(SPV_ENV_UNIVERSAL_1_1),
ValuesIn(std::vector<EnumCapabilityCase>{
- CASE2(DECORATION, DecorationSpecId, Shader, Kernel),
- CASE1(DECORATION, DecorationMaxByteOffset, Addresses)})));
+ CASE2(DECORATION, Decoration::SpecId, Shader, Kernel),
+ CASE1(DECORATION, Decoration::MaxByteOffset, Addresses)})));
// See SPIR-V Section 3.21 BuiltIn
INSTANTIATE_TEST_SUITE_P(
@@ -487,51 +491,51 @@ INSTANTIATE_TEST_SUITE_P(
Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
ValuesIn(std::vector<EnumCapabilityCase>{
// clang-format off
- CASE1(BUILT_IN, BuiltInPosition, Shader),
- CASE1(BUILT_IN, BuiltInPointSize, Shader),
+ CASE1(BUILT_IN, BuiltIn::Position, Shader),
+ CASE1(BUILT_IN, BuiltIn::PointSize, Shader),
// 2 is an intentional gap in the spec numbering.
- CASE1(BUILT_IN, BuiltInClipDistance, ClipDistance), // Bug 1407, 15234
- CASE1(BUILT_IN, BuiltInCullDistance, CullDistance), // Bug 1407, 15234
- CASE1(BUILT_IN, BuiltInVertexId, Shader),
- CASE1(BUILT_IN, BuiltInInstanceId, Shader),
- CASE6(BUILT_IN, BuiltInPrimitiveId, Geometry, Tessellation,
+ CASE1(BUILT_IN, BuiltIn::ClipDistance, ClipDistance), // Bug 1407, 15234
+ CASE1(BUILT_IN, BuiltIn::CullDistance, CullDistance), // Bug 1407, 15234
+ CASE1(BUILT_IN, BuiltIn::VertexId, Shader),
+ CASE1(BUILT_IN, BuiltIn::InstanceId, Shader),
+ CASE6(BUILT_IN, BuiltIn::PrimitiveId, Geometry, Tessellation,
RayTracingNV, RayTracingKHR, MeshShadingNV, MeshShadingEXT),
- CASE2(BUILT_IN, BuiltInInvocationId, Geometry, Tessellation),
- CASE4(BUILT_IN, BuiltInLayer, Geometry, ShaderViewportIndexLayerEXT, MeshShadingNV, MeshShadingEXT),
- CASE4(BUILT_IN, BuiltInViewportIndex, MultiViewport, ShaderViewportIndexLayerEXT, MeshShadingNV, MeshShadingEXT), // Bug 15234
- CASE1(BUILT_IN, BuiltInTessLevelOuter, Tessellation),
- CASE1(BUILT_IN, BuiltInTessLevelInner, Tessellation),
- CASE1(BUILT_IN, BuiltInTessCoord, Tessellation),
- CASE1(BUILT_IN, BuiltInPatchVertices, Tessellation),
- CASE1(BUILT_IN, BuiltInFragCoord, Shader),
- CASE1(BUILT_IN, BuiltInPointCoord, Shader),
- CASE1(BUILT_IN, BuiltInFrontFacing, Shader),
- CASE1(BUILT_IN, BuiltInSampleId, SampleRateShading), // Bug 15234
- CASE1(BUILT_IN, BuiltInSamplePosition, SampleRateShading), // Bug 15234
- CASE1(BUILT_IN, BuiltInSampleMask, Shader), // Bug 15234, Issue 182
+ CASE2(BUILT_IN, BuiltIn::InvocationId, Geometry, Tessellation),
+ CASE4(BUILT_IN, BuiltIn::Layer, Geometry, ShaderViewportIndexLayerEXT, MeshShadingNV, MeshShadingEXT),
+ CASE4(BUILT_IN, BuiltIn::ViewportIndex, MultiViewport, ShaderViewportIndexLayerEXT, MeshShadingNV, MeshShadingEXT), // Bug 15234
+ CASE1(BUILT_IN, BuiltIn::TessLevelOuter, Tessellation),
+ CASE1(BUILT_IN, BuiltIn::TessLevelInner, Tessellation),
+ CASE1(BUILT_IN, BuiltIn::TessCoord, Tessellation),
+ CASE1(BUILT_IN, BuiltIn::PatchVertices, Tessellation),
+ CASE1(BUILT_IN, BuiltIn::FragCoord, Shader),
+ CASE1(BUILT_IN, BuiltIn::PointCoord, Shader),
+ CASE1(BUILT_IN, BuiltIn::FrontFacing, Shader),
+ CASE1(BUILT_IN, BuiltIn::SampleId, SampleRateShading), // Bug 15234
+ CASE1(BUILT_IN, BuiltIn::SamplePosition, SampleRateShading), // Bug 15234
+ CASE1(BUILT_IN, BuiltIn::SampleMask, Shader), // Bug 15234, Issue 182
// Value 21 intentionally missing
- CASE1(BUILT_IN, BuiltInFragDepth, Shader),
- CASE1(BUILT_IN, BuiltInHelperInvocation, Shader),
- CASE0(BUILT_IN, BuiltInNumWorkgroups),
- CASE0(BUILT_IN, BuiltInWorkgroupSize),
- CASE0(BUILT_IN, BuiltInWorkgroupId),
- CASE0(BUILT_IN, BuiltInLocalInvocationId),
- CASE0(BUILT_IN, BuiltInGlobalInvocationId),
- CASE0(BUILT_IN, BuiltInLocalInvocationIndex),
- CASE1(BUILT_IN, BuiltInWorkDim, Kernel),
- CASE1(BUILT_IN, BuiltInGlobalSize, Kernel),
- CASE1(BUILT_IN, BuiltInEnqueuedWorkgroupSize, Kernel),
- CASE1(BUILT_IN, BuiltInGlobalOffset, Kernel),
- CASE1(BUILT_IN, BuiltInGlobalLinearId, Kernel),
+ CASE1(BUILT_IN, BuiltIn::FragDepth, Shader),
+ CASE1(BUILT_IN, BuiltIn::HelperInvocation, Shader),
+ CASE0(BUILT_IN, BuiltIn::NumWorkgroups),
+ CASE0(BUILT_IN, BuiltIn::WorkgroupSize),
+ CASE0(BUILT_IN, BuiltIn::WorkgroupId),
+ CASE0(BUILT_IN, BuiltIn::LocalInvocationId),
+ CASE0(BUILT_IN, BuiltIn::GlobalInvocationId),
+ CASE0(BUILT_IN, BuiltIn::LocalInvocationIndex),
+ CASE1(BUILT_IN, BuiltIn::WorkDim, Kernel),
+ CASE1(BUILT_IN, BuiltIn::GlobalSize, Kernel),
+ CASE1(BUILT_IN, BuiltIn::EnqueuedWorkgroupSize, Kernel),
+ CASE1(BUILT_IN, BuiltIn::GlobalOffset, Kernel),
+ CASE1(BUILT_IN, BuiltIn::GlobalLinearId, Kernel),
// Value 35 intentionally missing
- CASE2(BUILT_IN, BuiltInSubgroupSize, Kernel, SubgroupBallotKHR),
- CASE1(BUILT_IN, BuiltInSubgroupMaxSize, Kernel),
- CASE1(BUILT_IN, BuiltInNumSubgroups, Kernel),
- CASE1(BUILT_IN, BuiltInNumEnqueuedSubgroups, Kernel),
- CASE1(BUILT_IN, BuiltInSubgroupId, Kernel),
- CASE2(BUILT_IN, BuiltInSubgroupLocalInvocationId, Kernel, SubgroupBallotKHR),
- CASE1(BUILT_IN, BuiltInVertexIndex, Shader),
- CASE1(BUILT_IN, BuiltInInstanceIndex, Shader),
+ CASE2(BUILT_IN, BuiltIn::SubgroupSize, Kernel, SubgroupBallotKHR),
+ CASE1(BUILT_IN, BuiltIn::SubgroupMaxSize, Kernel),
+ CASE1(BUILT_IN, BuiltIn::NumSubgroups, Kernel),
+ CASE1(BUILT_IN, BuiltIn::NumEnqueuedSubgroups, Kernel),
+ CASE1(BUILT_IN, BuiltIn::SubgroupId, Kernel),
+ CASE2(BUILT_IN, BuiltIn::SubgroupLocalInvocationId, Kernel, SubgroupBallotKHR),
+ CASE1(BUILT_IN, BuiltIn::VertexIndex, Shader),
+ CASE1(BUILT_IN, BuiltIn::InstanceIndex, Shader),
// clang-format on
})));
@@ -541,9 +545,9 @@ INSTANTIATE_TEST_SUITE_P(
Values(SPV_ENV_UNIVERSAL_1_5),
ValuesIn(std::vector<EnumCapabilityCase>{
// SPIR-V 1.5 adds new capabilities to enable these two builtins.
- CASE5(BUILT_IN, BuiltInLayer, Geometry, ShaderLayer,
+ CASE5(BUILT_IN, BuiltIn::Layer, Geometry, ShaderLayer,
ShaderViewportIndexLayerEXT, MeshShadingNV, MeshShadingEXT),
- CASE5(BUILT_IN, BuiltInViewportIndex, MultiViewport,
+ CASE5(BUILT_IN, BuiltIn::ViewportIndex, MultiViewport,
ShaderViewportIndex, ShaderViewportIndexLayerEXT,
MeshShadingNV, MeshShadingEXT),
})));
@@ -553,9 +557,9 @@ INSTANTIATE_TEST_SUITE_P(
SelectionControl, EnumCapabilityTest,
Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
ValuesIn(std::vector<EnumCapabilityCase>{
- CASE0(SELECTION_CONTROL, SelectionControlMaskNone),
- CASE0(SELECTION_CONTROL, SelectionControlFlattenMask),
- CASE0(SELECTION_CONTROL, SelectionControlDontFlattenMask),
+ CASE0(SELECTION_CONTROL, SelectionControlMask::MaskNone),
+ CASE0(SELECTION_CONTROL, SelectionControlMask::Flatten),
+ CASE0(SELECTION_CONTROL, SelectionControlMask::DontFlatten),
})));
// See SPIR-V Section 3.23 Loop Control
@@ -563,17 +567,17 @@ INSTANTIATE_TEST_SUITE_P(
LoopControl, EnumCapabilityTest,
Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
ValuesIn(std::vector<EnumCapabilityCase>{
- CASE0(LOOP_CONTROL, LoopControlMaskNone),
- CASE0(LOOP_CONTROL, LoopControlUnrollMask),
- CASE0(LOOP_CONTROL, LoopControlDontUnrollMask),
+ CASE0(LOOP_CONTROL, LoopControlMask::MaskNone),
+ CASE0(LOOP_CONTROL, LoopControlMask::Unroll),
+ CASE0(LOOP_CONTROL, LoopControlMask::DontUnroll),
})));
INSTANTIATE_TEST_SUITE_P(
LoopControlV11, EnumCapabilityTest,
Combine(Values(SPV_ENV_UNIVERSAL_1_1),
ValuesIn(std::vector<EnumCapabilityCase>{
- CASE0(LOOP_CONTROL, LoopControlDependencyInfiniteMask),
- CASE0(LOOP_CONTROL, LoopControlDependencyLengthMask),
+ CASE0(LOOP_CONTROL, LoopControlMask::DependencyInfinite),
+ CASE0(LOOP_CONTROL, LoopControlMask::DependencyLength),
})));
// See SPIR-V Section 3.24 Function Control
@@ -581,11 +585,11 @@ INSTANTIATE_TEST_SUITE_P(
FunctionControl, EnumCapabilityTest,
Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
ValuesIn(std::vector<EnumCapabilityCase>{
- CASE0(FUNCTION_CONTROL, FunctionControlMaskNone),
- CASE0(FUNCTION_CONTROL, FunctionControlInlineMask),
- CASE0(FUNCTION_CONTROL, FunctionControlDontInlineMask),
- CASE0(FUNCTION_CONTROL, FunctionControlPureMask),
- CASE0(FUNCTION_CONTROL, FunctionControlConstMask),
+ CASE0(FUNCTION_CONTROL, FunctionControlMask::MaskNone),
+ CASE0(FUNCTION_CONTROL, FunctionControlMask::Inline),
+ CASE0(FUNCTION_CONTROL, FunctionControlMask::DontInline),
+ CASE0(FUNCTION_CONTROL, FunctionControlMask::Pure),
+ CASE0(FUNCTION_CONTROL, FunctionControlMask::Const),
})));
// See SPIR-V Section 3.25 Memory Semantics <id>
@@ -594,20 +598,21 @@ INSTANTIATE_TEST_SUITE_P(
Combine(
Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
ValuesIn(std::vector<EnumCapabilityCase>{
- CASE0(MEMORY_SEMANTICS_ID, MemorySemanticsMaskNone),
- CASE0(MEMORY_SEMANTICS_ID, MemorySemanticsAcquireMask),
- CASE0(MEMORY_SEMANTICS_ID, MemorySemanticsReleaseMask),
- CASE0(MEMORY_SEMANTICS_ID, MemorySemanticsAcquireReleaseMask),
+ CASE0(MEMORY_SEMANTICS_ID, MemorySemanticsMask::MaskNone),
+ CASE0(MEMORY_SEMANTICS_ID, MemorySemanticsMask::Acquire),
+ CASE0(MEMORY_SEMANTICS_ID, MemorySemanticsMask::Release),
+ CASE0(MEMORY_SEMANTICS_ID, MemorySemanticsMask::AcquireRelease),
CASE0(MEMORY_SEMANTICS_ID,
- MemorySemanticsSequentiallyConsistentMask),
- CASE1(MEMORY_SEMANTICS_ID, MemorySemanticsUniformMemoryMask,
+ MemorySemanticsMask::SequentiallyConsistent),
+ CASE1(MEMORY_SEMANTICS_ID, MemorySemanticsMask::UniformMemory,
Shader),
- CASE0(MEMORY_SEMANTICS_ID, MemorySemanticsSubgroupMemoryMask),
- CASE0(MEMORY_SEMANTICS_ID, MemorySemanticsWorkgroupMemoryMask),
- CASE0(MEMORY_SEMANTICS_ID, MemorySemanticsCrossWorkgroupMemoryMask),
- CASE1(MEMORY_SEMANTICS_ID, MemorySemanticsAtomicCounterMemoryMask,
+ CASE0(MEMORY_SEMANTICS_ID, MemorySemanticsMask::SubgroupMemory),
+ CASE0(MEMORY_SEMANTICS_ID, MemorySemanticsMask::WorkgroupMemory),
+ CASE0(MEMORY_SEMANTICS_ID,
+ MemorySemanticsMask::CrossWorkgroupMemory),
+ CASE1(MEMORY_SEMANTICS_ID, MemorySemanticsMask::AtomicCounterMemory,
AtomicStorage), // Bug 15234
- CASE0(MEMORY_SEMANTICS_ID, MemorySemanticsImageMemoryMask),
+ CASE0(MEMORY_SEMANTICS_ID, MemorySemanticsMask::ImageMemory),
})));
// See SPIR-V Section 3.26 Memory Access
@@ -615,10 +620,10 @@ INSTANTIATE_TEST_SUITE_P(
MemoryAccess, EnumCapabilityTest,
Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
ValuesIn(std::vector<EnumCapabilityCase>{
- CASE0(OPTIONAL_MEMORY_ACCESS, MemoryAccessMaskNone),
- CASE0(OPTIONAL_MEMORY_ACCESS, MemoryAccessVolatileMask),
- CASE0(OPTIONAL_MEMORY_ACCESS, MemoryAccessAlignedMask),
- CASE0(OPTIONAL_MEMORY_ACCESS, MemoryAccessNontemporalMask),
+ CASE0(OPTIONAL_MEMORY_ACCESS, MemoryAccessMask::MaskNone),
+ CASE0(OPTIONAL_MEMORY_ACCESS, MemoryAccessMask::Volatile),
+ CASE0(OPTIONAL_MEMORY_ACCESS, MemoryAccessMask::Aligned),
+ CASE0(OPTIONAL_MEMORY_ACCESS, MemoryAccessMask::Nontemporal),
})));
// See SPIR-V Section 3.27 Scope <id>
@@ -627,12 +632,12 @@ INSTANTIATE_TEST_SUITE_P(
Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_3),
ValuesIn(std::vector<EnumCapabilityCase>{
- CASE0(SCOPE_ID, ScopeCrossDevice),
- CASE0(SCOPE_ID, ScopeDevice),
- CASE0(SCOPE_ID, ScopeWorkgroup),
- CASE0(SCOPE_ID, ScopeSubgroup),
- CASE0(SCOPE_ID, ScopeInvocation),
- CASE1(SCOPE_ID, ScopeQueueFamilyKHR, VulkanMemoryModelKHR),
+ CASE0(SCOPE_ID, Scope::CrossDevice),
+ CASE0(SCOPE_ID, Scope::Device),
+ CASE0(SCOPE_ID, Scope::Workgroup),
+ CASE0(SCOPE_ID, Scope::Subgroup),
+ CASE0(SCOPE_ID, Scope::Invocation),
+ CASE1(SCOPE_ID, Scope::QueueFamilyKHR, VulkanMemoryModelKHR),
})));
// See SPIR-V Section 3.28 Group Operation
@@ -640,11 +645,11 @@ INSTANTIATE_TEST_SUITE_P(
GroupOperation, EnumCapabilityTest,
Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
ValuesIn(std::vector<EnumCapabilityCase>{
- CASE3(GROUP_OPERATION, GroupOperationReduce, Kernel,
+ CASE3(GROUP_OPERATION, GroupOperation::Reduce, Kernel,
GroupNonUniformArithmetic, GroupNonUniformBallot),
- CASE3(GROUP_OPERATION, GroupOperationInclusiveScan, Kernel,
+ CASE3(GROUP_OPERATION, GroupOperation::InclusiveScan, Kernel,
GroupNonUniformArithmetic, GroupNonUniformBallot),
- CASE3(GROUP_OPERATION, GroupOperationExclusiveScan, Kernel,
+ CASE3(GROUP_OPERATION, GroupOperation::ExclusiveScan, Kernel,
GroupNonUniformArithmetic, GroupNonUniformBallot),
})));
@@ -653,9 +658,9 @@ INSTANTIATE_TEST_SUITE_P(
KernelEnqueueFlags, EnumCapabilityTest,
Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
ValuesIn(std::vector<EnumCapabilityCase>{
- CASE1(KERNEL_ENQ_FLAGS, KernelEnqueueFlagsNoWait, Kernel),
- CASE1(KERNEL_ENQ_FLAGS, KernelEnqueueFlagsWaitKernel, Kernel),
- CASE1(KERNEL_ENQ_FLAGS, KernelEnqueueFlagsWaitWorkGroup,
+ CASE1(KERNEL_ENQ_FLAGS, KernelEnqueueFlags::NoWait, Kernel),
+ CASE1(KERNEL_ENQ_FLAGS, KernelEnqueueFlags::WaitKernel, Kernel),
+ CASE1(KERNEL_ENQ_FLAGS, KernelEnqueueFlags::WaitWorkGroup,
Kernel),
})));
@@ -664,9 +669,9 @@ INSTANTIATE_TEST_SUITE_P(
KernelProfilingInfo, EnumCapabilityTest,
Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
ValuesIn(std::vector<EnumCapabilityCase>{
- CASE0(KERNEL_PROFILING_INFO, KernelProfilingInfoMaskNone),
- CASE1(KERNEL_PROFILING_INFO, KernelProfilingInfoCmdExecTimeMask,
- Kernel),
+ CASE0(KERNEL_PROFILING_INFO, KernelProfilingInfoMask::MaskNone),
+ CASE1(KERNEL_PROFILING_INFO,
+ KernelProfilingInfoMask::CmdExecTime, Kernel),
})));
// See SPIR-V Section 3.31 Capability
@@ -676,62 +681,62 @@ INSTANTIATE_TEST_SUITE_P(
Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
ValuesIn(std::vector<EnumCapabilityCase>{
// clang-format off
- CASE0(CAPABILITY, CapabilityMatrix),
- CASE1(CAPABILITY, CapabilityShader, Matrix),
- CASE1(CAPABILITY, CapabilityGeometry, Shader),
- CASE1(CAPABILITY, CapabilityTessellation, Shader),
- CASE0(CAPABILITY, CapabilityAddresses),
- CASE0(CAPABILITY, CapabilityLinkage),
- CASE0(CAPABILITY, CapabilityKernel),
- CASE1(CAPABILITY, CapabilityVector16, Kernel),
- CASE1(CAPABILITY, CapabilityFloat16Buffer, Kernel),
- CASE0(CAPABILITY, CapabilityFloat16), // Bug 15234
- CASE0(CAPABILITY, CapabilityFloat64),
- CASE0(CAPABILITY, CapabilityInt64),
- CASE1(CAPABILITY, CapabilityInt64Atomics, Int64),
- CASE1(CAPABILITY, CapabilityImageBasic, Kernel),
- CASE1(CAPABILITY, CapabilityImageReadWrite, ImageBasic),
- CASE1(CAPABILITY, CapabilityImageMipmap, ImageBasic),
+ CASE0(CAPABILITY, Capability::Matrix),
+ CASE1(CAPABILITY, Capability::Shader, Matrix),
+ CASE1(CAPABILITY, Capability::Geometry, Shader),
+ CASE1(CAPABILITY, Capability::Tessellation, Shader),
+ CASE0(CAPABILITY, Capability::Addresses),
+ CASE0(CAPABILITY, Capability::Linkage),
+ CASE0(CAPABILITY, Capability::Kernel),
+ CASE1(CAPABILITY, Capability::Vector16, Kernel),
+ CASE1(CAPABILITY, Capability::Float16Buffer, Kernel),
+ CASE0(CAPABILITY, Capability::Float16), // Bug 15234
+ CASE0(CAPABILITY, Capability::Float64),
+ CASE0(CAPABILITY, Capability::Int64),
+ CASE1(CAPABILITY, Capability::Int64Atomics, Int64),
+ CASE1(CAPABILITY, Capability::ImageBasic, Kernel),
+ CASE1(CAPABILITY, Capability::ImageReadWrite, ImageBasic),
+ CASE1(CAPABILITY, Capability::ImageMipmap, ImageBasic),
// Value 16 intentionally missing.
- CASE1(CAPABILITY, CapabilityPipes, Kernel),
- CASE0(CAPABILITY, CapabilityGroups),
- CASE1(CAPABILITY, CapabilityDeviceEnqueue, Kernel),
- CASE1(CAPABILITY, CapabilityLiteralSampler, Kernel),
- CASE1(CAPABILITY, CapabilityAtomicStorage, Shader),
- CASE0(CAPABILITY, CapabilityInt16),
- CASE1(CAPABILITY, CapabilityTessellationPointSize, Tessellation),
- CASE1(CAPABILITY, CapabilityGeometryPointSize, Geometry),
- CASE1(CAPABILITY, CapabilityImageGatherExtended, Shader),
+ CASE1(CAPABILITY, Capability::Pipes, Kernel),
+ CASE0(CAPABILITY, Capability::Groups),
+ CASE1(CAPABILITY, Capability::DeviceEnqueue, Kernel),
+ CASE1(CAPABILITY, Capability::LiteralSampler, Kernel),
+ CASE1(CAPABILITY, Capability::AtomicStorage, Shader),
+ CASE0(CAPABILITY, Capability::Int16),
+ CASE1(CAPABILITY, Capability::TessellationPointSize, Tessellation),
+ CASE1(CAPABILITY, Capability::GeometryPointSize, Geometry),
+ CASE1(CAPABILITY, Capability::ImageGatherExtended, Shader),
// Value 26 intentionally missing.
- CASE1(CAPABILITY, CapabilityStorageImageMultisample, Shader),
- CASE1(CAPABILITY, CapabilityUniformBufferArrayDynamicIndexing, Shader),
- CASE1(CAPABILITY, CapabilitySampledImageArrayDynamicIndexing, Shader),
- CASE1(CAPABILITY, CapabilityStorageBufferArrayDynamicIndexing, Shader),
- CASE1(CAPABILITY, CapabilityStorageImageArrayDynamicIndexing, Shader),
- CASE1(CAPABILITY, CapabilityClipDistance, Shader),
- CASE1(CAPABILITY, CapabilityCullDistance, Shader),
- CASE1(CAPABILITY, CapabilityImageCubeArray, SampledCubeArray),
- CASE1(CAPABILITY, CapabilitySampleRateShading, Shader),
- CASE1(CAPABILITY, CapabilityImageRect, SampledRect),
- CASE1(CAPABILITY, CapabilitySampledRect, Shader),
- CASE1(CAPABILITY, CapabilityGenericPointer, Addresses),
- CASE0(CAPABILITY, CapabilityInt8),
- CASE1(CAPABILITY, CapabilityInputAttachment, Shader),
- CASE1(CAPABILITY, CapabilitySparseResidency, Shader),
- CASE1(CAPABILITY, CapabilityMinLod, Shader),
- CASE1(CAPABILITY, CapabilityImage1D, Sampled1D),
- CASE1(CAPABILITY, CapabilitySampledCubeArray, Shader),
- CASE1(CAPABILITY, CapabilityImageBuffer, SampledBuffer),
- CASE1(CAPABILITY, CapabilityImageMSArray, Shader),
- CASE1(CAPABILITY, CapabilityStorageImageExtendedFormats, Shader),
- CASE1(CAPABILITY, CapabilityImageQuery, Shader),
- CASE1(CAPABILITY, CapabilityDerivativeControl, Shader),
- CASE1(CAPABILITY, CapabilityInterpolationFunction, Shader),
- CASE1(CAPABILITY, CapabilityTransformFeedback, Shader),
- CASE1(CAPABILITY, CapabilityGeometryStreams, Geometry),
- CASE1(CAPABILITY, CapabilityStorageImageReadWithoutFormat, Shader),
- CASE1(CAPABILITY, CapabilityStorageImageWriteWithoutFormat, Shader),
- CASE1(CAPABILITY, CapabilityMultiViewport, Geometry),
+ CASE1(CAPABILITY, Capability::StorageImageMultisample, Shader),
+ CASE1(CAPABILITY, Capability::UniformBufferArrayDynamicIndexing, Shader),
+ CASE1(CAPABILITY, Capability::SampledImageArrayDynamicIndexing, Shader),
+ CASE1(CAPABILITY, Capability::StorageBufferArrayDynamicIndexing, Shader),
+ CASE1(CAPABILITY, Capability::StorageImageArrayDynamicIndexing, Shader),
+ CASE1(CAPABILITY, Capability::ClipDistance, Shader),
+ CASE1(CAPABILITY, Capability::CullDistance, Shader),
+ CASE1(CAPABILITY, Capability::ImageCubeArray, SampledCubeArray),
+ CASE1(CAPABILITY, Capability::SampleRateShading, Shader),
+ CASE1(CAPABILITY, Capability::ImageRect, SampledRect),
+ CASE1(CAPABILITY, Capability::SampledRect, Shader),
+ CASE1(CAPABILITY, Capability::GenericPointer, Addresses),
+ CASE0(CAPABILITY, Capability::Int8),
+ CASE1(CAPABILITY, Capability::InputAttachment, Shader),
+ CASE1(CAPABILITY, Capability::SparseResidency, Shader),
+ CASE1(CAPABILITY, Capability::MinLod, Shader),
+ CASE1(CAPABILITY, Capability::Image1D, Sampled1D),
+ CASE1(CAPABILITY, Capability::SampledCubeArray, Shader),
+ CASE1(CAPABILITY, Capability::ImageBuffer, SampledBuffer),
+ CASE1(CAPABILITY, Capability::ImageMSArray, Shader),
+ CASE1(CAPABILITY, Capability::StorageImageExtendedFormats, Shader),
+ CASE1(CAPABILITY, Capability::ImageQuery, Shader),
+ CASE1(CAPABILITY, Capability::DerivativeControl, Shader),
+ CASE1(CAPABILITY, Capability::InterpolationFunction, Shader),
+ CASE1(CAPABILITY, Capability::TransformFeedback, Shader),
+ CASE1(CAPABILITY, Capability::GeometryStreams, Geometry),
+ CASE1(CAPABILITY, Capability::StorageImageReadWithoutFormat, Shader),
+ CASE1(CAPABILITY, Capability::StorageImageWriteWithoutFormat, Shader),
+ CASE1(CAPABILITY, Capability::MultiViewport, Geometry),
// clang-format on
})));
@@ -739,9 +744,9 @@ INSTANTIATE_TEST_SUITE_P(
CapabilityDependsOnV11, EnumCapabilityTest,
Combine(Values(SPV_ENV_UNIVERSAL_1_1),
ValuesIn(std::vector<EnumCapabilityCase>{
- CASE1(CAPABILITY, CapabilitySubgroupDispatch, DeviceEnqueue),
- CASE1(CAPABILITY, CapabilityNamedBarrier, Kernel),
- CASE1(CAPABILITY, CapabilityPipeStorage, Pipes),
+ CASE1(CAPABILITY, Capability::SubgroupDispatch, DeviceEnqueue),
+ CASE1(CAPABILITY, Capability::NamedBarrier, Kernel),
+ CASE1(CAPABILITY, Capability::PipeStorage, Pipes),
})));
#undef CASE0
diff --git a/test/operand_pattern_test.cpp b/test/operand_pattern_test.cpp
index a98a9d76d..58b8a0866 100644
--- a/test/operand_pattern_test.cpp
+++ b/test/operand_pattern_test.cpp
@@ -103,17 +103,18 @@ INSTANTIATE_TEST_SUITE_P(
{PREFIX1}},
// Volatile has no operands.
{SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS,
- SpvMemoryAccessVolatileMask,
+ uint32_t(spv::MemoryAccessMask::Volatile),
{PREFIX0},
{PREFIX0}},
// Aligned has one literal number operand.
{SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS,
- SpvMemoryAccessAlignedMask,
+ uint32_t(spv::MemoryAccessMask::Aligned),
{PREFIX1},
{PREFIX1, SPV_OPERAND_TYPE_LITERAL_INTEGER}},
// Volatile with Aligned still has just one literal number operand.
{SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS,
- SpvMemoryAccessVolatileMask | SpvMemoryAccessAlignedMask,
+ uint32_t(spv::MemoryAccessMask::Volatile |
+ spv::MemoryAccessMask::Aligned),
{PREFIX1},
{PREFIX1, SPV_OPERAND_TYPE_LITERAL_INTEGER}},
// Newer masks are not tested
diff --git a/test/opt/analyze_live_input_test.cpp b/test/opt/analyze_live_input_test.cpp
index d61dbdb85..c2a8f4cb5 100644
--- a/test/opt/analyze_live_input_test.cpp
+++ b/test/opt/analyze_live_input_test.cpp
@@ -696,11 +696,11 @@ TEST_F(AnalyzeLiveInputTest, Builtins) {
auto result = SinglePassRunToBinary<AnalyzeLiveInputPass>(
text, true, &live_inputs, &live_builtins);
- auto itr0 = live_builtins.find(SpvBuiltInPointSize);
- auto itr1 = live_builtins.find(SpvBuiltInClipDistance);
- auto itr2 = live_builtins.find(SpvBuiltInCullDistance);
+ auto itr0 = live_builtins.find((uint32_t)spv::BuiltIn::PointSize);
+ auto itr1 = live_builtins.find((uint32_t)spv::BuiltIn::ClipDistance);
+ auto itr2 = live_builtins.find((uint32_t)spv::BuiltIn::CullDistance);
- // Expect live_builtins == { SpvBuiltInPointSize }
+ // Expect live_builtins == { spv::BuiltIn::PointSize }
EXPECT_TRUE(itr0 != live_builtins.end());
EXPECT_TRUE(itr1 == live_builtins.end());
EXPECT_TRUE(itr2 == live_builtins.end());
diff --git a/test/opt/dataflow.cpp b/test/opt/dataflow.cpp
index 4742015a7..51473d84e 100644
--- a/test/opt/dataflow.cpp
+++ b/test/opt/dataflow.cpp
@@ -66,7 +66,7 @@ struct BackwardReachability : public ForwardDataFlowAnalysis {
VisitResult Visit(Instruction* inst) override {
// Conditional branches can be enqueued from labels, so skip them.
- if (inst->opcode() != SpvOpLabel)
+ if (inst->opcode() != spv::Op::OpLabel)
return DataFlowAnalysis::VisitResult::kResultFixed;
uint32_t id = inst->result_id();
VisitResult ret = DataFlowAnalysis::VisitResult::kResultFixed;
diff --git a/test/opt/debug_info_manager_test.cpp b/test/opt/debug_info_manager_test.cpp
index e87d0beaf..9e479c0fb 100644
--- a/test/opt/debug_info_manager_test.cpp
+++ b/test/opt/debug_info_manager_test.cpp
@@ -155,7 +155,7 @@ void main(float in_var_color : COLOR) {
EXPECT_EQ(inlined_at->NumOperands(), kDebugInlinedAtOperandScopeIndex + 1);
const uint32_t line_number = 77U;
- Instruction line(context.get(), SpvOpLine);
+ Instruction line(context.get(), spv::Op::OpLine);
line.SetInOperands({
{spv_operand_type_t::SPV_OPERAND_TYPE_ID, {5U}},
{spv_operand_type_t::SPV_OPERAND_TYPE_LITERAL_INTEGER, {line_number}},
@@ -278,7 +278,7 @@ OpFunctionEnd
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
const uint32_t line_number = 7U;
- Instruction line(context.get(), SpvOpLine);
+ Instruction line(context.get(), spv::Op::OpLine);
line.SetInOperands({
{spv_operand_type_t::SPV_OPERAND_TYPE_ID, {5U}},
{spv_operand_type_t::SPV_OPERAND_TYPE_LITERAL_INTEGER, {line_number}},
diff --git a/test/opt/decoration_manager_test.cpp b/test/opt/decoration_manager_test.cpp
index c9fabe789..cf3516a9f 100644
--- a/test/opt/decoration_manager_test.cpp
+++ b/test/opt/decoration_manager_test.cpp
@@ -88,7 +88,7 @@ class DecorationManagerTest : public ::testing::Test {
std::string GetErrorMessage() const { return error_message_; }
std::string ToText(const std::vector<Instruction*>& inst) {
- std::vector<uint32_t> binary = {SpvMagicNumber, 0x10200, 0u, 2u, 0u};
+ std::vector<uint32_t> binary = {spv::MagicNumber, 0x10200, 0u, 2u, 0u};
for (const Instruction* i : inst)
i->ToBinaryWithoutAttachedDebugInsts(&binary);
std::string text;
@@ -118,16 +118,17 @@ class DecorationManagerTest : public ::testing::Test {
TEST_F(DecorationManagerTest,
ComparingDecorationsWithDiffOpcodesDecorateDecorateId) {
IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
- // This parameter can be interpreted both as { SpvDecorationConstant }
+ // This parameter can be interpreted both as { spv::Decoration::Constant }
// and also as a list of IDs: { 22 }
- const std::vector<uint32_t> param{SpvDecorationConstant};
+ const std::vector<uint32_t> param{
+ static_cast<uint32_t>(spv::Decoration::Constant)};
// OpDecorate %1 Constant
Instruction inst1(
- &ir_context, SpvOpDecorate, 0u, 0u,
+ &ir_context, spv::Op::OpDecorate, 0u, 0u,
{{SPV_OPERAND_TYPE_ID, {1u}}, {SPV_OPERAND_TYPE_DECORATION, param}});
// OpDecorateId %1 %22 ; 'Constant' is decoration number 22
Instruction inst2(
- &ir_context, SpvOpDecorateId, 0u, 0u,
+ &ir_context, spv::Op::OpDecorateId, 0u, 0u,
{{SPV_OPERAND_TYPE_ID, {1u}}, {SPV_OPERAND_TYPE_ID, param}});
DecorationManager* decoManager = ir_context.get_decoration_mgr();
EXPECT_THAT(GetErrorMessage(), "");
@@ -137,16 +138,17 @@ TEST_F(DecorationManagerTest,
TEST_F(DecorationManagerTest,
ComparingDecorationsWithDiffOpcodesDecorateDecorateString) {
IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
- // This parameter can be interpreted both as { SpvDecorationConstant }
+ // This parameter can be interpreted both as { spv::Decoration::Constant }
// and also as a null-terminated string with a single character with value 22.
- const std::vector<uint32_t> param{SpvDecorationConstant};
+ const std::vector<uint32_t> param{
+ static_cast<uint32_t>(spv::Decoration::Constant)};
// OpDecorate %1 Constant
Instruction inst1(
- &ir_context, SpvOpDecorate, 0u, 0u,
+ &ir_context, spv::Op::OpDecorate, 0u, 0u,
{{SPV_OPERAND_TYPE_ID, {1u}}, {SPV_OPERAND_TYPE_DECORATION, param}});
// OpDecorateStringGOOGLE %1 !22
Instruction inst2(
- &ir_context, SpvOpDecorateStringGOOGLE, 0u, 0u,
+ &ir_context, spv::Op::OpDecorateStringGOOGLE, 0u, 0u,
{{SPV_OPERAND_TYPE_ID, {1u}}, {SPV_OPERAND_TYPE_LITERAL_STRING, param}});
DecorationManager* decoManager = ir_context.get_decoration_mgr();
EXPECT_THAT(GetErrorMessage(), "");
@@ -156,13 +158,15 @@ TEST_F(DecorationManagerTest,
TEST_F(DecorationManagerTest, ComparingDecorationsWithDiffDecorateParam) {
IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
// OpDecorate %1 Constant
- Instruction inst1(&ir_context, SpvOpDecorate, 0u, 0u,
- {{SPV_OPERAND_TYPE_ID, {1u}},
- {SPV_OPERAND_TYPE_DECORATION, {SpvDecorationConstant}}});
+ Instruction inst1(
+ &ir_context, spv::Op::OpDecorate, 0u, 0u,
+ {{SPV_OPERAND_TYPE_ID, {1u}},
+ {SPV_OPERAND_TYPE_DECORATION, {uint32_t(spv::Decoration::Constant)}}});
// OpDecorate %1 Restrict
- Instruction inst2(&ir_context, SpvOpDecorate, 0u, 0u,
- {{SPV_OPERAND_TYPE_ID, {1u}},
- {SPV_OPERAND_TYPE_DECORATION, {SpvDecorationRestrict}}});
+ Instruction inst2(
+ &ir_context, spv::Op::OpDecorate, 0u, 0u,
+ {{SPV_OPERAND_TYPE_ID, {1u}},
+ {SPV_OPERAND_TYPE_DECORATION, {uint32_t(spv::Decoration::Restrict)}}});
DecorationManager* decoManager = ir_context.get_decoration_mgr();
EXPECT_THAT(GetErrorMessage(), "");
EXPECT_FALSE(decoManager->AreDecorationsTheSame(&inst1, &inst2, true));
@@ -172,11 +176,11 @@ TEST_F(DecorationManagerTest, ComparingDecorationsWithDiffDecorateIdParam) {
IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
// OpDecorate %1 Constant
Instruction inst1(
- &ir_context, SpvOpDecorateId, 0u, 0u,
+ &ir_context, spv::Op::OpDecorateId, 0u, 0u,
{{SPV_OPERAND_TYPE_ID, {1u}}, {SPV_OPERAND_TYPE_ID, {555}}});
// OpDecorate %1 Restrict
Instruction inst2(
- &ir_context, SpvOpDecorateId, 0u, 0u,
+ &ir_context, spv::Op::OpDecorateId, 0u, 0u,
{{SPV_OPERAND_TYPE_ID, {1u}}, {SPV_OPERAND_TYPE_ID, {666}}});
DecorationManager* decoManager = ir_context.get_decoration_mgr();
EXPECT_THAT(GetErrorMessage(), "");
@@ -186,11 +190,11 @@ TEST_F(DecorationManagerTest, ComparingDecorationsWithDiffDecorateIdParam) {
TEST_F(DecorationManagerTest, ComparingDecorationsWithDiffDecorateStringParam) {
IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
// OpDecorate %1 Constant
- Instruction inst1(&ir_context, SpvOpDecorateStringGOOGLE, 0u, 0u,
+ Instruction inst1(&ir_context, spv::Op::OpDecorateStringGOOGLE, 0u, 0u,
{{SPV_OPERAND_TYPE_ID, {1u}},
{SPV_OPERAND_TYPE_LITERAL_STRING, MakeVector("Hello!")}});
// OpDecorate %1 Restrict
- Instruction inst2(&ir_context, SpvOpDecorateStringGOOGLE, 0u, 0u,
+ Instruction inst2(&ir_context, spv::Op::OpDecorateStringGOOGLE, 0u, 0u,
{{SPV_OPERAND_TYPE_ID, {1u}},
{SPV_OPERAND_TYPE_LITERAL_STRING, MakeVector("Hellx")}});
DecorationManager* decoManager = ir_context.get_decoration_mgr();
@@ -201,13 +205,15 @@ TEST_F(DecorationManagerTest, ComparingDecorationsWithDiffDecorateStringParam) {
TEST_F(DecorationManagerTest, ComparingSameDecorationsOnDiffTargetAllowed) {
IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
// OpDecorate %1 Constant
- Instruction inst1(&ir_context, SpvOpDecorate, 0u, 0u,
- {{SPV_OPERAND_TYPE_ID, {1u}},
- {SPV_OPERAND_TYPE_DECORATION, {SpvDecorationConstant}}});
+ Instruction inst1(
+ &ir_context, spv::Op::OpDecorate, 0u, 0u,
+ {{SPV_OPERAND_TYPE_ID, {1u}},
+ {SPV_OPERAND_TYPE_DECORATION, {uint32_t(spv::Decoration::Constant)}}});
// OpDecorate %2 Constant
- Instruction inst2(&ir_context, SpvOpDecorate, 0u, 0u,
- {{SPV_OPERAND_TYPE_ID, {2u}},
- {SPV_OPERAND_TYPE_DECORATION, {SpvDecorationConstant}}});
+ Instruction inst2(
+ &ir_context, spv::Op::OpDecorate, 0u, 0u,
+ {{SPV_OPERAND_TYPE_ID, {2u}},
+ {SPV_OPERAND_TYPE_DECORATION, {uint32_t(spv::Decoration::Constant)}}});
DecorationManager* decoManager = ir_context.get_decoration_mgr();
EXPECT_THAT(GetErrorMessage(), "");
EXPECT_TRUE(decoManager->AreDecorationsTheSame(&inst1, &inst2, true));
@@ -216,10 +222,10 @@ TEST_F(DecorationManagerTest, ComparingSameDecorationsOnDiffTargetAllowed) {
TEST_F(DecorationManagerTest, ComparingSameDecorationIdsOnDiffTargetAllowed) {
IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
Instruction inst1(
- &ir_context, SpvOpDecorateId, 0u, 0u,
+ &ir_context, spv::Op::OpDecorateId, 0u, 0u,
{{SPV_OPERAND_TYPE_ID, {1u}}, {SPV_OPERAND_TYPE_DECORATION, {44}}});
Instruction inst2(
- &ir_context, SpvOpDecorateId, 0u, 0u,
+ &ir_context, spv::Op::OpDecorateId, 0u, 0u,
{{SPV_OPERAND_TYPE_ID, {2u}}, {SPV_OPERAND_TYPE_DECORATION, {44}}});
DecorationManager* decoManager = ir_context.get_decoration_mgr();
EXPECT_THAT(GetErrorMessage(), "");
@@ -229,10 +235,10 @@ TEST_F(DecorationManagerTest, ComparingSameDecorationIdsOnDiffTargetAllowed) {
TEST_F(DecorationManagerTest,
ComparingSameDecorationStringsOnDiffTargetAllowed) {
IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
- Instruction inst1(&ir_context, SpvOpDecorateStringGOOGLE, 0u, 0u,
+ Instruction inst1(&ir_context, spv::Op::OpDecorateStringGOOGLE, 0u, 0u,
{{SPV_OPERAND_TYPE_ID, {1u}},
{SPV_OPERAND_TYPE_LITERAL_STRING, MakeVector("hello")}});
- Instruction inst2(&ir_context, SpvOpDecorateStringGOOGLE, 0u, 0u,
+ Instruction inst2(&ir_context, spv::Op::OpDecorateStringGOOGLE, 0u, 0u,
{{SPV_OPERAND_TYPE_ID, {2u}},
{SPV_OPERAND_TYPE_LITERAL_STRING, MakeVector("hello")}});
DecorationManager* decoManager = ir_context.get_decoration_mgr();
@@ -243,13 +249,15 @@ TEST_F(DecorationManagerTest,
TEST_F(DecorationManagerTest, ComparingSameDecorationsOnDiffTargetDisallowed) {
IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
// OpDecorate %1 Constant
- Instruction inst1(&ir_context, SpvOpDecorate, 0u, 0u,
- {{SPV_OPERAND_TYPE_ID, {1u}},
- {SPV_OPERAND_TYPE_DECORATION, {SpvDecorationConstant}}});
+ Instruction inst1(
+ &ir_context, spv::Op::OpDecorate, 0u, 0u,
+ {{SPV_OPERAND_TYPE_ID, {1u}},
+ {SPV_OPERAND_TYPE_DECORATION, {uint32_t(spv::Decoration::Constant)}}});
// OpDecorate %2 Constant
- Instruction inst2(&ir_context, SpvOpDecorate, 0u, 0u,
- {{SPV_OPERAND_TYPE_ID, {2u}},
- {SPV_OPERAND_TYPE_DECORATION, {SpvDecorationConstant}}});
+ Instruction inst2(
+ &ir_context, spv::Op::OpDecorate, 0u, 0u,
+ {{SPV_OPERAND_TYPE_ID, {2u}},
+ {SPV_OPERAND_TYPE_DECORATION, {uint32_t(spv::Decoration::Constant)}}});
DecorationManager* decoManager = ir_context.get_decoration_mgr();
EXPECT_THAT(GetErrorMessage(), "");
EXPECT_FALSE(decoManager->AreDecorationsTheSame(&inst1, &inst2, false));
@@ -258,15 +266,17 @@ TEST_F(DecorationManagerTest, ComparingSameDecorationsOnDiffTargetDisallowed) {
TEST_F(DecorationManagerTest, ComparingMemberDecorationsOnSameTypeDiffMember) {
IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
// OpMemberDecorate %1 0 Constant
- Instruction inst1(&ir_context, SpvOpMemberDecorate, 0u, 0u,
- {{SPV_OPERAND_TYPE_ID, {1u}},
- {SPV_OPERAND_TYPE_LITERAL_INTEGER, {0u}},
- {SPV_OPERAND_TYPE_DECORATION, {SpvDecorationConstant}}});
+ Instruction inst1(
+ &ir_context, spv::Op::OpMemberDecorate, 0u, 0u,
+ {{SPV_OPERAND_TYPE_ID, {1u}},
+ {SPV_OPERAND_TYPE_LITERAL_INTEGER, {0u}},
+ {SPV_OPERAND_TYPE_DECORATION, {uint32_t(spv::Decoration::Constant)}}});
// OpMemberDecorate %1 1 Constant
- Instruction inst2(&ir_context, SpvOpMemberDecorate, 0u, 0u,
- {{SPV_OPERAND_TYPE_ID, {1u}},
- {SPV_OPERAND_TYPE_LITERAL_INTEGER, {1u}},
- {SPV_OPERAND_TYPE_DECORATION, {SpvDecorationConstant}}});
+ Instruction inst2(
+ &ir_context, spv::Op::OpMemberDecorate, 0u, 0u,
+ {{SPV_OPERAND_TYPE_ID, {1u}},
+ {SPV_OPERAND_TYPE_LITERAL_INTEGER, {1u}},
+ {SPV_OPERAND_TYPE_DECORATION, {uint32_t(spv::Decoration::Constant)}}});
DecorationManager* decoManager = ir_context.get_decoration_mgr();
EXPECT_THAT(GetErrorMessage(), "");
EXPECT_FALSE(decoManager->AreDecorationsTheSame(&inst1, &inst2, true));
@@ -276,15 +286,17 @@ TEST_F(DecorationManagerTest,
ComparingSameMemberDecorationsOnDiffTargetAllowed) {
IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
// OpMemberDecorate %1 0 Constant
- Instruction inst1(&ir_context, SpvOpMemberDecorate, 0u, 0u,
- {{SPV_OPERAND_TYPE_ID, {1u}},
- {SPV_OPERAND_TYPE_LITERAL_INTEGER, {0u}},
- {SPV_OPERAND_TYPE_DECORATION, {SpvDecorationConstant}}});
+ Instruction inst1(
+ &ir_context, spv::Op::OpMemberDecorate, 0u, 0u,
+ {{SPV_OPERAND_TYPE_ID, {1u}},
+ {SPV_OPERAND_TYPE_LITERAL_INTEGER, {0u}},
+ {SPV_OPERAND_TYPE_DECORATION, {uint32_t(spv::Decoration::Constant)}}});
// OpMemberDecorate %2 0 Constant
- Instruction inst2(&ir_context, SpvOpMemberDecorate, 0u, 0u,
- {{SPV_OPERAND_TYPE_ID, {2u}},
- {SPV_OPERAND_TYPE_LITERAL_INTEGER, {0u}},
- {SPV_OPERAND_TYPE_DECORATION, {SpvDecorationConstant}}});
+ Instruction inst2(
+ &ir_context, spv::Op::OpMemberDecorate, 0u, 0u,
+ {{SPV_OPERAND_TYPE_ID, {2u}},
+ {SPV_OPERAND_TYPE_LITERAL_INTEGER, {0u}},
+ {SPV_OPERAND_TYPE_DECORATION, {uint32_t(spv::Decoration::Constant)}}});
DecorationManager* decoManager = ir_context.get_decoration_mgr();
EXPECT_THAT(GetErrorMessage(), "");
EXPECT_TRUE(decoManager->AreDecorationsTheSame(&inst1, &inst2, true));
@@ -294,15 +306,17 @@ TEST_F(DecorationManagerTest,
ComparingSameMemberDecorationsOnDiffTargetDisallowed) {
IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
// OpMemberDecorate %1 0 Constant
- Instruction inst1(&ir_context, SpvOpMemberDecorate, 0u, 0u,
- {{SPV_OPERAND_TYPE_ID, {1u}},
- {SPV_OPERAND_TYPE_LITERAL_INTEGER, {0u}},
- {SPV_OPERAND_TYPE_DECORATION, {SpvDecorationConstant}}});
+ Instruction inst1(
+ &ir_context, spv::Op::OpMemberDecorate, 0u, 0u,
+ {{SPV_OPERAND_TYPE_ID, {1u}},
+ {SPV_OPERAND_TYPE_LITERAL_INTEGER, {0u}},
+ {SPV_OPERAND_TYPE_DECORATION, {uint32_t(spv::Decoration::Constant)}}});
// OpMemberDecorate %2 0 Constant
- Instruction inst2(&ir_context, SpvOpMemberDecorate, 0u, 0u,
- {{SPV_OPERAND_TYPE_ID, {2u}},
- {SPV_OPERAND_TYPE_LITERAL_INTEGER, {0u}},
- {SPV_OPERAND_TYPE_DECORATION, {SpvDecorationConstant}}});
+ Instruction inst2(
+ &ir_context, spv::Op::OpMemberDecorate, 0u, 0u,
+ {{SPV_OPERAND_TYPE_ID, {2u}},
+ {SPV_OPERAND_TYPE_LITERAL_INTEGER, {0u}},
+ {SPV_OPERAND_TYPE_DECORATION, {uint32_t(spv::Decoration::Constant)}}});
DecorationManager* decoManager = ir_context.get_decoration_mgr();
EXPECT_THAT(GetErrorMessage(), "");
EXPECT_FALSE(decoManager->AreDecorationsTheSame(&inst1, &inst2, false));
@@ -486,7 +500,7 @@ OpGroupDecorate %3 %1
DecorationManager* decoManager = GetDecorationManager(spirv);
EXPECT_THAT(GetErrorMessage(), "");
decoManager->RemoveDecorationsFrom(1u, [](const Instruction& inst) {
- return inst.opcode() == SpvOpDecorate &&
+ return inst.opcode() == spv::Op::OpDecorate &&
inst.GetSingleWordInOperand(0u) == 3u;
});
auto decorations = decoManager->GetDecorationsFor(1u, false);
@@ -537,9 +551,10 @@ OpGroupDecorate %3 %1
DecorationManager* decoManager = GetDecorationManager(spirv);
EXPECT_THAT(GetErrorMessage(), "");
decoManager->RemoveDecorationsFrom(1u, [](const Instruction& inst) {
- return inst.opcode() == SpvOpDecorate &&
+ return inst.opcode() == spv::Op::OpDecorate &&
inst.GetSingleWordInOperand(0u) == 3u &&
- inst.GetSingleWordInOperand(1u) == SpvDecorationBuiltIn;
+ spv::Decoration(inst.GetSingleWordInOperand(1u)) ==
+ spv::Decoration::BuiltIn;
});
auto decorations = decoManager->GetDecorationsFor(1u, false);
EXPECT_THAT(GetErrorMessage(), "");
@@ -763,7 +778,7 @@ OpFunctionEnd
EXPECT_EQ(GetErrorMessage(), "");
EXPECT_TRUE(decorations.empty());
- decoManager->CloneDecorations(1u, 8u, {SpvDecorationRelaxedPrecision});
+ decoManager->CloneDecorations(1u, 8u, {spv::Decoration::RelaxedPrecision});
decorations = decoManager->GetDecorationsFor(8u, false);
EXPECT_THAT(GetErrorMessage(), "");
@@ -822,7 +837,7 @@ OpFunctionEnd
EXPECT_EQ(GetErrorMessage(), "");
EXPECT_TRUE(decorations.empty());
- decoManager->CloneDecorations(2u, 9u, {SpvDecorationRelaxedPrecision});
+ decoManager->CloneDecorations(2u, 9u, {spv::Decoration::RelaxedPrecision});
decorations = decoManager->GetDecorationsFor(9u, false);
EXPECT_THAT(GetErrorMessage(), "");
diff --git a/test/opt/def_use_test.cpp b/test/opt/def_use_test.cpp
index 0210095d4..431501274 100644
--- a/test/opt/def_use_test.cpp
+++ b/test/opt/def_use_test.cpp
@@ -50,9 +50,9 @@ uint32_t NumUses(const std::unique_ptr<IRContext>& context, uint32_t id) {
//
// If |id| is used multiple times in a single instruction, that instruction's
// opcode will appear a corresponding number of times.
-std::vector<SpvOp> GetUseOpcodes(const std::unique_ptr<IRContext>& context,
- uint32_t id) {
- std::vector<SpvOp> opcodes;
+std::vector<spv::Op> GetUseOpcodes(const std::unique_ptr<IRContext>& context,
+ uint32_t id) {
+ std::vector<spv::Op> opcodes;
context->get_def_use_mgr()->ForEachUse(
id, [&opcodes](Instruction* user, uint32_t) {
opcodes.push_back(user->opcode());
@@ -99,7 +99,7 @@ void CheckDef(const InstDefUse& expected_defs_uses,
const auto expected_def = expected_defs_uses.defs[i].second;
ASSERT_EQ(1u, actual_defs.count(id)) << "expected to def id [" << id << "]";
auto def = actual_defs.at(id);
- if (def->opcode() != SpvOpConstant) {
+ if (def->opcode() != spv::Op::OpConstant) {
// Constants don't disassemble properly without a full context.
EXPECT_EQ(expected_def, DisassembleInst(actual_defs.at(id)));
}
@@ -116,7 +116,7 @@ UserMap BuildAllUsers(const DefUseManager* mgr, uint32_t idBound) {
for (uint32_t id = 0; id != idBound; ++id) {
if (mgr->GetDef(id)) {
mgr->ForEachUser(id, [id, &userMap](Instruction* user) {
- if (user->opcode() != SpvOpConstant) {
+ if (user->opcode() != spv::Op::OpConstant) {
userMap[id].push_back(user);
}
});
@@ -1298,21 +1298,23 @@ TEST(DefUseTest, OpSwitch) {
{
EXPECT_EQ(2u, NumUses(context, 6));
- std::vector<SpvOp> opcodes = GetUseOpcodes(context, 6u);
- EXPECT_THAT(opcodes, UnorderedElementsAre(SpvOpSwitch, SpvOpReturnValue));
+ std::vector<spv::Op> opcodes = GetUseOpcodes(context, 6u);
+ EXPECT_THAT(opcodes, UnorderedElementsAre(spv::Op::OpSwitch,
+ spv::Op::OpReturnValue));
}
{
EXPECT_EQ(6u, NumUses(context, 7));
- std::vector<SpvOp> opcodes = GetUseOpcodes(context, 7u);
+ std::vector<spv::Op> opcodes = GetUseOpcodes(context, 7u);
// OpSwitch is now a user of %7.
- EXPECT_THAT(opcodes, UnorderedElementsAre(SpvOpSelectionMerge, SpvOpBranch,
- SpvOpBranch, SpvOpBranch,
- SpvOpBranch, SpvOpSwitch));
+ EXPECT_THAT(opcodes, UnorderedElementsAre(
+ spv::Op::OpSelectionMerge, spv::Op::OpBranch,
+ spv::Op::OpBranch, spv::Op::OpBranch,
+ spv::Op::OpBranch, spv::Op::OpSwitch));
}
// Check all ids only used by OpSwitch after replacement.
for (const auto id : {8u, 10u, 11u}) {
EXPECT_EQ(1u, NumUses(context, id));
- EXPECT_EQ(SpvOpSwitch, GetUseOpcodes(context, id).back());
+ EXPECT_EQ(spv::Op::OpSwitch, GetUseOpcodes(context, id).back());
}
}
@@ -1378,10 +1380,11 @@ TEST(AnalyzeInstDefUse, UseWithNoResultId) {
// Analyze the instructions.
DefUseManager manager(context.module());
- Instruction label(&context, SpvOpLabel, 0, 2, {});
+ Instruction label(&context, spv::Op::OpLabel, 0, 2, {});
manager.AnalyzeInstDefUse(&label);
- Instruction branch(&context, SpvOpBranch, 0, 0, {{SPV_OPERAND_TYPE_ID, {2}}});
+ Instruction branch(&context, spv::Op::OpBranch, 0, 0,
+ {{SPV_OPERAND_TYPE_ID, {2}}});
manager.AnalyzeInstDefUse(&branch);
context.module()->SetIdBound(3);
@@ -1409,7 +1412,7 @@ TEST(AnalyzeInstDefUse, AddNewInstruction) {
// Analyze the instructions.
DefUseManager manager(context->module());
- Instruction newInst(context.get(), SpvOpConstantTrue, 1, 2, {});
+ Instruction newInst(context.get(), spv::Op::OpConstantTrue, 1, 2, {});
manager.AnalyzeInstDefUse(&newInst);
InstDefUse expected = {
@@ -1703,7 +1706,7 @@ TEST_F(UpdateUsesTest, KeepOldUses) {
DefUseManager* def_use_mgr = context->get_def_use_mgr();
Instruction* def = def_use_mgr->GetDef(9);
Instruction* use = def_use_mgr->GetDef(10);
- def->SetOpcode(SpvOpCopyObject);
+ def->SetOpcode(spv::Op::OpCopyObject);
def->SetInOperands({{SPV_OPERAND_TYPE_ID, {25}}});
context->UpdateDefUse(def);
diff --git a/test/opt/eliminate_dead_output_stores_test.cpp b/test/opt/eliminate_dead_output_stores_test.cpp
index 6e382c243..470e709eb 100644
--- a/test/opt/eliminate_dead_output_stores_test.cpp
+++ b/test/opt/eliminate_dead_output_stores_test.cpp
@@ -652,9 +652,9 @@ TEST_F(ElimDeadOutputStoresTest, ScalarBuiltins) {
std::unordered_set<uint32_t> live_inputs;
std::unordered_set<uint32_t> live_builtins;
- // Omit SpvBuiltInPointSize
- live_builtins.insert(SpvBuiltInClipDistance);
- live_builtins.insert(SpvBuiltInCullDistance);
+ // Omit spv::BuiltIn::PointSize
+ live_builtins.insert((uint32_t)spv::BuiltIn::ClipDistance);
+ live_builtins.insert((uint32_t)spv::BuiltIn::CullDistance);
SinglePassRunAndMatch<EliminateDeadOutputStoresPass>(text, true, &live_inputs,
&live_builtins);
}
@@ -783,9 +783,9 @@ TEST_F(ElimDeadOutputStoresTest, ArrayedBuiltins) {
std::unordered_set<uint32_t> live_inputs;
std::unordered_set<uint32_t> live_builtins;
- // Omit SpvBuiltInPointSize
- live_builtins.insert(SpvBuiltInClipDistance);
- live_builtins.insert(SpvBuiltInCullDistance);
+ // Omit spv::BuiltIn::PointSize
+ live_builtins.insert((uint32_t)spv::BuiltIn::ClipDistance);
+ live_builtins.insert((uint32_t)spv::BuiltIn::CullDistance);
SinglePassRunAndMatch<EliminateDeadOutputStoresPass>(text, true, &live_inputs,
&live_builtins);
}
diff --git a/test/opt/feature_manager_test.cpp b/test/opt/feature_manager_test.cpp
index 767376cf5..94c7734b8 100644
--- a/test/opt/feature_manager_test.cpp
+++ b/test/opt/feature_manager_test.cpp
@@ -100,8 +100,10 @@ OpMemoryModel Logical GLSL450
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
ASSERT_NE(context, nullptr);
- EXPECT_TRUE(context->get_feature_mgr()->HasCapability(SpvCapabilityShader));
- EXPECT_FALSE(context->get_feature_mgr()->HasCapability(SpvCapabilityKernel));
+ EXPECT_TRUE(
+ context->get_feature_mgr()->HasCapability(spv::Capability::Shader));
+ EXPECT_FALSE(
+ context->get_feature_mgr()->HasCapability(spv::Capability::Kernel));
}
TEST_F(FeatureManagerTest, ExplicitlyPresent2) {
@@ -114,8 +116,10 @@ OpMemoryModel Logical GLSL450
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
ASSERT_NE(context, nullptr);
- EXPECT_FALSE(context->get_feature_mgr()->HasCapability(SpvCapabilityShader));
- EXPECT_TRUE(context->get_feature_mgr()->HasCapability(SpvCapabilityKernel));
+ EXPECT_FALSE(
+ context->get_feature_mgr()->HasCapability(spv::Capability::Shader));
+ EXPECT_TRUE(
+ context->get_feature_mgr()->HasCapability(spv::Capability::Kernel));
}
TEST_F(FeatureManagerTest, ImplicitlyPresent) {
@@ -131,10 +135,13 @@ OpMemoryModel Logical GLSL450
// Check multiple levels of indirection. Tessellation implies Shader, which
// implies Matrix.
EXPECT_TRUE(
- context->get_feature_mgr()->HasCapability(SpvCapabilityTessellation));
- EXPECT_TRUE(context->get_feature_mgr()->HasCapability(SpvCapabilityShader));
- EXPECT_TRUE(context->get_feature_mgr()->HasCapability(SpvCapabilityMatrix));
- EXPECT_FALSE(context->get_feature_mgr()->HasCapability(SpvCapabilityKernel));
+ context->get_feature_mgr()->HasCapability(spv::Capability::Tessellation));
+ EXPECT_TRUE(
+ context->get_feature_mgr()->HasCapability(spv::Capability::Shader));
+ EXPECT_TRUE(
+ context->get_feature_mgr()->HasCapability(spv::Capability::Matrix));
+ EXPECT_FALSE(
+ context->get_feature_mgr()->HasCapability(spv::Capability::Kernel));
}
} // namespace
diff --git a/test/opt/fold_test.cpp b/test/opt/fold_test.cpp
index b32480326..06b91f3a6 100644
--- a/test/opt/fold_test.cpp
+++ b/test/opt/fold_test.cpp
@@ -88,9 +88,9 @@ TEST_P(IntegerInstructionFoldingTest, Case) {
// Make sure the instruction folded as expected.
EXPECT_TRUE(succeeded);
if (inst != nullptr) {
- EXPECT_EQ(inst->opcode(), SpvOpCopyObject);
+ EXPECT_EQ(inst->opcode(), spv::Op::OpCopyObject);
inst = def_use_mgr->GetDef(inst->GetSingleWordInOperand(0));
- EXPECT_EQ(inst->opcode(), SpvOpConstant);
+ EXPECT_EQ(inst->opcode(), spv::Op::OpConstant);
analysis::ConstantManager* const_mrg = context->get_constant_mgr();
const analysis::Constant* constant = const_mrg->GetConstantFromInst(inst);
// We expect to see either integer types or 16-bit float types here.
@@ -896,15 +896,15 @@ TEST_P(IntVectorInstructionFoldingTest, Case) {
// Fold the instruction to test.
analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
- SpvOp original_opcode = inst->opcode();
+ spv::Op original_opcode = inst->opcode();
bool succeeded = context->get_instruction_folder().FoldInstruction(inst);
// Make sure the instruction folded as expected.
EXPECT_EQ(succeeded, inst == nullptr || inst->opcode() != original_opcode);
if (succeeded && inst != nullptr) {
- EXPECT_EQ(inst->opcode(), SpvOpCopyObject);
+ EXPECT_EQ(inst->opcode(), spv::Op::OpCopyObject);
inst = def_use_mgr->GetDef(inst->GetSingleWordInOperand(0));
- std::vector<SpvOp> opcodes = {SpvOpConstantComposite};
+ std::vector<spv::Op> opcodes = {spv::Op::OpConstantComposite};
EXPECT_THAT(opcodes, Contains(inst->opcode()));
analysis::ConstantManager* const_mrg = context->get_constant_mgr();
const analysis::Constant* result = const_mrg->GetConstantFromInst(inst);
@@ -993,9 +993,9 @@ TEST_P(DoubleVectorInstructionFoldingTest, Case) {
// Make sure the instruction folded as expected.
EXPECT_TRUE(succeeded);
if (succeeded && inst != nullptr) {
- EXPECT_EQ(inst->opcode(), SpvOpCopyObject);
+ EXPECT_EQ(inst->opcode(), spv::Op::OpCopyObject);
inst = def_use_mgr->GetDef(inst->GetSingleWordInOperand(0));
- std::vector<SpvOp> opcodes = {SpvOpConstantComposite};
+ std::vector<spv::Op> opcodes = {spv::Op::OpConstantComposite};
EXPECT_THAT(opcodes, Contains(inst->opcode()));
analysis::ConstantManager* const_mrg = context->get_constant_mgr();
const analysis::Constant* result = const_mrg->GetConstantFromInst(inst);
@@ -1094,15 +1094,15 @@ TEST_P(FloatVectorInstructionFoldingTest, Case) {
// Fold the instruction to test.
analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
- SpvOp original_opcode = inst->opcode();
+ spv::Op original_opcode = inst->opcode();
bool succeeded = context->get_instruction_folder().FoldInstruction(inst);
// Make sure the instruction folded as expected.
EXPECT_EQ(succeeded, inst == nullptr || inst->opcode() != original_opcode);
if (succeeded && inst != nullptr) {
- EXPECT_EQ(inst->opcode(), SpvOpCopyObject);
+ EXPECT_EQ(inst->opcode(), spv::Op::OpCopyObject);
inst = def_use_mgr->GetDef(inst->GetSingleWordInOperand(0));
- std::vector<SpvOp> opcodes = {SpvOpConstantComposite};
+ std::vector<spv::Op> opcodes = {spv::Op::OpConstantComposite};
EXPECT_THAT(opcodes, Contains(inst->opcode()));
analysis::ConstantManager* const_mrg = context->get_constant_mgr();
const analysis::Constant* result = const_mrg->GetConstantFromInst(inst);
@@ -1222,9 +1222,10 @@ TEST_P(BooleanInstructionFoldingTest, Case) {
// Make sure the instruction folded as expected.
EXPECT_TRUE(succeeded);
if (inst != nullptr) {
- EXPECT_EQ(inst->opcode(), SpvOpCopyObject);
+ EXPECT_EQ(inst->opcode(), spv::Op::OpCopyObject);
inst = def_use_mgr->GetDef(inst->GetSingleWordInOperand(0));
- std::vector<SpvOp> bool_opcodes = {SpvOpConstantTrue, SpvOpConstantFalse};
+ std::vector<spv::Op> bool_opcodes = {spv::Op::OpConstantTrue,
+ spv::Op::OpConstantFalse};
EXPECT_THAT(bool_opcodes, Contains(inst->opcode()));
analysis::ConstantManager* const_mrg = context->get_constant_mgr();
const analysis::BoolConstant* result =
@@ -1833,9 +1834,9 @@ TEST_P(FloatInstructionFoldingTest, Case) {
// Make sure the instruction folded as expected.
EXPECT_TRUE(succeeded);
if (inst != nullptr) {
- EXPECT_EQ(inst->opcode(), SpvOpCopyObject);
+ EXPECT_EQ(inst->opcode(), spv::Op::OpCopyObject);
inst = def_use_mgr->GetDef(inst->GetSingleWordInOperand(0));
- EXPECT_EQ(inst->opcode(), SpvOpConstant);
+ EXPECT_EQ(inst->opcode(), spv::Op::OpConstant);
analysis::ConstantManager* const_mrg = context->get_constant_mgr();
const analysis::FloatConstant* result =
const_mrg->GetConstantFromInst(inst)->AsFloatConstant();
@@ -2266,9 +2267,9 @@ TEST_P(DoubleInstructionFoldingTest, Case) {
// Make sure the instruction folded as expected.
EXPECT_TRUE(succeeded);
if (inst != nullptr) {
- EXPECT_EQ(inst->opcode(), SpvOpCopyObject);
+ EXPECT_EQ(inst->opcode(), spv::Op::OpCopyObject);
inst = def_use_mgr->GetDef(inst->GetSingleWordInOperand(0));
- EXPECT_EQ(inst->opcode(), SpvOpConstant);
+ EXPECT_EQ(inst->opcode(), spv::Op::OpConstant);
analysis::ConstantManager* const_mrg = context->get_constant_mgr();
const analysis::FloatConstant* result =
const_mrg->GetConstantFromInst(inst)->AsFloatConstant();
@@ -3153,7 +3154,7 @@ TEST_P(IntegerInstructionFoldingTestWithMap, Case) {
// Make sure the instruction folded as expected.
EXPECT_NE(inst, nullptr);
if (inst != nullptr) {
- EXPECT_EQ(inst->opcode(), SpvOpConstant);
+ EXPECT_EQ(inst->opcode(), spv::Op::OpConstant);
analysis::ConstantManager* const_mrg = context->get_constant_mgr();
const analysis::IntConstant* result =
const_mrg->GetConstantFromInst(inst)->AsIntConstant();
@@ -3201,7 +3202,8 @@ TEST_P(BooleanInstructionFoldingTestWithMap, Case) {
// Make sure the instruction folded as expected.
EXPECT_NE(inst, nullptr);
if (inst != nullptr) {
- std::vector<SpvOp> bool_opcodes = {SpvOpConstantTrue, SpvOpConstantFalse};
+ std::vector<spv::Op> bool_opcodes = {spv::Op::OpConstantTrue,
+ spv::Op::OpConstantFalse};
EXPECT_THAT(bool_opcodes, Contains(inst->opcode()));
analysis::ConstantManager* const_mrg = context->get_constant_mgr();
const analysis::BoolConstant* result =
@@ -3253,7 +3255,7 @@ TEST_P(GeneralInstructionFoldingTest, Case) {
EXPECT_EQ(inst->type_id(), original_inst->type_id());
EXPECT_TRUE((!succeeded) == (tc.expected_result == 0));
if (succeeded) {
- EXPECT_EQ(inst->opcode(), SpvOpCopyObject);
+ EXPECT_EQ(inst->opcode(), spv::Op::OpCopyObject);
EXPECT_EQ(inst->GetSingleWordInOperand(0), tc.expected_result);
} else {
EXPECT_EQ(inst->NumInOperands(), original_inst->NumInOperands());
@@ -4911,7 +4913,7 @@ TEST_P(ToNegateFoldingTest, Case) {
EXPECT_EQ(inst->type_id(), original_inst->type_id());
EXPECT_TRUE((!succeeded) == (tc.expected_result == 0));
if (succeeded) {
- EXPECT_EQ(inst->opcode(), SpvOpFNegate);
+ EXPECT_EQ(inst->opcode(), spv::Op::OpFNegate);
EXPECT_EQ(inst->GetSingleWordInOperand(0), tc.expected_result);
} else {
EXPECT_EQ(inst->NumInOperands(), original_inst->NumInOperands());
diff --git a/test/opt/function_test.cpp b/test/opt/function_test.cpp
index 34a03871a..09cca3349 100644
--- a/test/opt/function_test.cpp
+++ b/test/opt/function_test.cpp
@@ -248,7 +248,7 @@ OpFunctionEnd
std::unordered_set<uint32_t> non_semantic_ids;
func->ForEachInst(
[&non_semantic_ids](const Instruction* inst) {
- if (inst->opcode() == SpvOpExtInst) {
+ if (inst->opcode() == spv::Op::OpExtInst) {
non_semantic_ids.insert(inst->result_id());
}
},
@@ -285,7 +285,7 @@ OpFunctionEnd
std::unordered_set<uint32_t> non_semantic_ids;
func->ForEachInst(
[&non_semantic_ids](const Instruction* inst) {
- if (inst->opcode() == SpvOpExtInst) {
+ if (inst->opcode() == spv::Op::OpExtInst) {
non_semantic_ids.insert(inst->result_id());
}
},
diff --git a/test/opt/inline_test.cpp b/test/opt/inline_test.cpp
index f3ff81ce6..1e5d9f3b4 100644
--- a/test/opt/inline_test.cpp
+++ b/test/opt/inline_test.cpp
@@ -4437,7 +4437,7 @@ OpFunctionEnd
// Callee function returns a value generated outside the callee,
// e.g. a constant value. This might exercise some logic not yet
// exercised by the current tests: the false branch in the "if"
-// inside the SpvOpReturnValue case in InlinePass::GenInlineCode?
+// inside the spv::Op::OpReturnValue case in InlinePass::GenInlineCode?
// SampledImage before function call, but callee is only single block.
// Then the SampledImage instruction is not cloned. Documents existing
// behaviour.
diff --git a/test/opt/instruction_test.cpp b/test/opt/instruction_test.cpp
index dd749ab48..6ea7fccef 100644
--- a/test/opt/instruction_test.cpp
+++ b/test/opt/instruction_test.cpp
@@ -39,7 +39,7 @@ using VulkanBufferTest = PassTest<::testing::Test>;
TEST(InstructionTest, CreateTrivial) {
Instruction empty;
- EXPECT_EQ(SpvOpNop, empty.opcode());
+ EXPECT_EQ(spv::Op::OpNop, empty.opcode());
EXPECT_EQ(0u, empty.type_id());
EXPECT_EQ(0u, empty.result_id());
EXPECT_EQ(0u, empty.NumOperands());
@@ -51,8 +51,8 @@ TEST(InstructionTest, CreateTrivial) {
TEST(InstructionTest, CreateWithOpcodeAndNoOperands) {
IRContext context(SPV_ENV_UNIVERSAL_1_2, nullptr);
- Instruction inst(&context, SpvOpReturn);
- EXPECT_EQ(SpvOpReturn, inst.opcode());
+ Instruction inst(&context, spv::Op::OpReturn);
+ EXPECT_EQ(spv::Op::OpReturn, inst.opcode());
EXPECT_EQ(0u, inst.type_id());
EXPECT_EQ(0u, inst.result_id());
EXPECT_EQ(0u, inst.NumOperands());
@@ -81,8 +81,8 @@ TEST(InstructionTest, OperandAsLiteralUint64_64bits) {
}
// The words for an OpTypeInt for 32-bit signed integer resulting in Id 44.
-uint32_t kSampleInstructionWords[] = {(4 << 16) | uint32_t(SpvOpTypeInt), 44,
- 32, 1};
+uint32_t kSampleInstructionWords[] = {(4 << 16) | uint32_t(spv::Op::OpTypeInt),
+ 44, 32, 1};
// The operands that would be parsed from kSampleInstructionWords
spv_parsed_operand_t kSampleParsedOperands[] = {
{1, 1, SPV_OPERAND_TYPE_RESULT_ID, SPV_NUMBER_NONE, 0},
@@ -91,18 +91,19 @@ spv_parsed_operand_t kSampleParsedOperands[] = {
};
// A valid parse of kSampleParsedOperands.
-spv_parsed_instruction_t kSampleParsedInstruction = {kSampleInstructionWords,
- uint16_t(4),
- uint16_t(SpvOpTypeInt),
- SPV_EXT_INST_TYPE_NONE,
- 0, // type id
- 44, // result id
- kSampleParsedOperands,
- 3};
+spv_parsed_instruction_t kSampleParsedInstruction = {
+ kSampleInstructionWords,
+ uint16_t(4),
+ uint16_t(spv::Op::OpTypeInt),
+ SPV_EXT_INST_TYPE_NONE,
+ 0, // type id
+ 44, // result id
+ kSampleParsedOperands,
+ 3};
// The words for an OpAccessChain instruction.
uint32_t kSampleAccessChainInstructionWords[] = {
- (7 << 16) | uint32_t(SpvOpAccessChain), 100, 101, 102, 103, 104, 105};
+ (7 << 16) | uint32_t(spv::Op::OpAccessChain), 100, 101, 102, 103, 104, 105};
// The operands that would be parsed from kSampleAccessChainInstructionWords.
spv_parsed_operand_t kSampleAccessChainOperands[] = {
@@ -118,7 +119,7 @@ spv_parsed_operand_t kSampleAccessChainOperands[] = {
spv_parsed_instruction_t kSampleAccessChainInstruction = {
kSampleAccessChainInstructionWords,
uint16_t(7),
- uint16_t(SpvOpAccessChain),
+ uint16_t(spv::Op::OpAccessChain),
SPV_EXT_INST_TYPE_NONE,
100, // type id
101, // result id
@@ -127,7 +128,7 @@ spv_parsed_instruction_t kSampleAccessChainInstruction = {
// The words for an OpControlBarrier instruction.
uint32_t kSampleControlBarrierInstructionWords[] = {
- (4 << 16) | uint32_t(SpvOpControlBarrier), 100, 101, 102};
+ (4 << 16) | uint32_t(spv::Op::OpControlBarrier), 100, 101, 102};
// The operands that would be parsed from kSampleControlBarrierInstructionWords.
spv_parsed_operand_t kSampleControlBarrierOperands[] = {
@@ -141,7 +142,7 @@ spv_parsed_operand_t kSampleControlBarrierOperands[] = {
spv_parsed_instruction_t kSampleControlBarrierInstruction = {
kSampleControlBarrierInstructionWords,
uint16_t(4),
- uint16_t(SpvOpControlBarrier),
+ uint16_t(spv::Op::OpControlBarrier),
SPV_EXT_INST_TYPE_NONE,
0, // type id
0, // result id
@@ -151,7 +152,7 @@ spv_parsed_instruction_t kSampleControlBarrierInstruction = {
TEST(InstructionTest, CreateWithOpcodeAndOperands) {
IRContext context(SPV_ENV_UNIVERSAL_1_2, nullptr);
Instruction inst(&context, kSampleParsedInstruction);
- EXPECT_EQ(SpvOpTypeInt, inst.opcode());
+ EXPECT_EQ(spv::Op::OpTypeInt, inst.opcode());
EXPECT_EQ(0u, inst.type_id());
EXPECT_EQ(44u, inst.result_id());
EXPECT_EQ(3u, inst.NumOperands());
diff --git a/test/opt/ir_builder.cpp b/test/opt/ir_builder.cpp
index cb234e004..e04e7815f 100644
--- a/test/opt/ir_builder.cpp
+++ b/test/opt/ir_builder.cpp
@@ -201,7 +201,7 @@ TEST_F(IRBuilderTest, TestCondBranchAddition) {
// TODO(1841): Handle id overflow.
fn.begin().InsertBefore(std::unique_ptr<BasicBlock>(
new BasicBlock(std::unique_ptr<Instruction>(new Instruction(
- context.get(), SpvOpLabel, 0, context->TakeNextId(), {})))));
+ context.get(), spv::Op::OpLabel, 0, context->TakeNextId(), {})))));
BasicBlock& bb_true = *fn.begin();
{
InstructionBuilder builder(context.get(), &*bb_true.begin());
@@ -211,7 +211,7 @@ TEST_F(IRBuilderTest, TestCondBranchAddition) {
// TODO(1841): Handle id overflow.
fn.begin().InsertBefore(std::unique_ptr<BasicBlock>(
new BasicBlock(std::unique_ptr<Instruction>(new Instruction(
- context.get(), SpvOpLabel, 0, context->TakeNextId(), {})))));
+ context.get(), spv::Op::OpLabel, 0, context->TakeNextId(), {})))));
BasicBlock& bb_cond = *fn.begin();
InstructionBuilder builder(context.get(), &bb_cond);
diff --git a/test/opt/ir_context_test.cpp b/test/opt/ir_context_test.cpp
index dcae7cf81..86a3f4596 100644
--- a/test/opt/ir_context_test.cpp
+++ b/test/opt/ir_context_test.cpp
@@ -229,12 +229,12 @@ TEST_F(IRContextTest, KillMemberName) {
// Make sure all of the name are removed.
for (auto& inst : context->debugs2()) {
- EXPECT_EQ(inst.opcode(), SpvOpNop);
+ EXPECT_EQ(inst.opcode(), spv::Op::OpNop);
}
// Make sure all of the decorations are removed.
for (auto& inst : context->annotations()) {
- EXPECT_EQ(inst.opcode(), SpvOpNop);
+ EXPECT_EQ(inst.opcode(), spv::Op::OpNop);
}
}
@@ -276,17 +276,17 @@ TEST_F(IRContextTest, KillGroupDecoration) {
// Check the OpDecorate instruction
auto inst = context->annotation_begin();
- EXPECT_EQ(inst->opcode(), SpvOpDecorate);
+ EXPECT_EQ(inst->opcode(), spv::Op::OpDecorate);
EXPECT_EQ(inst->GetSingleWordInOperand(0), 3);
// Check the OpDecorationGroup Instruction
++inst;
- EXPECT_EQ(inst->opcode(), SpvOpDecorationGroup);
+ EXPECT_EQ(inst->opcode(), spv::Op::OpDecorationGroup);
EXPECT_EQ(inst->result_id(), 3);
// Check that %5 is no longer part of the group.
++inst;
- EXPECT_EQ(inst->opcode(), SpvOpGroupDecorate);
+ EXPECT_EQ(inst->opcode(), spv::Op::OpGroupDecorate);
EXPECT_EQ(inst->NumInOperands(), 2);
EXPECT_EQ(inst->GetSingleWordInOperand(0), 3);
EXPECT_EQ(inst->GetSingleWordInOperand(1), 4);
@@ -340,12 +340,12 @@ TEST_F(IRContextTest, KillGroupDecorationWitNoDecorations) {
// Check the OpDecorationGroup Instruction
auto inst = context->annotation_begin();
- EXPECT_EQ(inst->opcode(), SpvOpDecorationGroup);
+ EXPECT_EQ(inst->opcode(), spv::Op::OpDecorationGroup);
EXPECT_EQ(inst->result_id(), 3);
// Check that %5 is no longer part of the group.
++inst;
- EXPECT_EQ(inst->opcode(), SpvOpGroupDecorate);
+ EXPECT_EQ(inst->opcode(), spv::Op::OpGroupDecorate);
EXPECT_EQ(inst->NumInOperands(), 2);
EXPECT_EQ(inst->GetSingleWordInOperand(0), 3);
EXPECT_EQ(inst->GetSingleWordInOperand(1), 4);
diff --git a/test/opt/ir_loader_test.cpp b/test/opt/ir_loader_test.cpp
index ccdd032ee..45104f471 100644
--- a/test/opt/ir_loader_test.cpp
+++ b/test/opt/ir_loader_test.cpp
@@ -244,10 +244,10 @@ TEST(IrBuilder, DistributeLineDebugInfo) {
auto& lines = def_use_mgr->GetDef(check.id)->dbg_line_insts();
for (uint32_t i = 0; i < check.line_numbers.size(); ++i) {
if (check.line_numbers[i] == kNoLine) {
- EXPECT_EQ(lines[i].opcode(), SpvOpNoLine);
+ EXPECT_EQ(lines[i].opcode(), spv::Op::OpNoLine);
continue;
}
- EXPECT_EQ(lines[i].opcode(), SpvOpLine);
+ EXPECT_EQ(lines[i].opcode(), spv::Op::OpLine);
EXPECT_EQ(lines[i].GetSingleWordOperand(kOpLineOperandLineIndex),
check.line_numbers[i]);
}
@@ -286,9 +286,10 @@ OpFunctionEnd
spvtools::opt::analysis::DefUseManager* def_use_mgr =
context->get_def_use_mgr();
- std::vector<SpvOp> opcodes;
+ std::vector<spv::Op> opcodes;
for (auto* inst = def_use_mgr->GetDef(1);
- inst && (inst->opcode() != SpvOpFunctionEnd); inst = inst->NextNode()) {
+ inst && (inst->opcode() != spv::Op::OpFunctionEnd);
+ inst = inst->NextNode()) {
inst->ForEachInst(
[&opcodes](spvtools::opt::Instruction* sub_inst) {
opcodes.push_back(sub_inst->opcode());
@@ -296,9 +297,9 @@ OpFunctionEnd
true);
}
- EXPECT_THAT(opcodes,
- ContainerEq(std::vector<SpvOp>{SpvOpFAdd, SpvOpLine, SpvOpFMul,
- SpvOpFSub, SpvOpReturn}));
+ EXPECT_THAT(opcodes, ContainerEq(std::vector<spv::Op>{
+ spv::Op::OpFAdd, spv::Op::OpLine, spv::Op::OpFMul,
+ spv::Op::OpFSub, spv::Op::OpReturn}));
}
TEST(IrBuilder, BuildModule_WithExtraLines_IsDefault) {
@@ -333,9 +334,10 @@ OpFunctionEnd
spvtools::opt::analysis::DefUseManager* def_use_mgr =
context->get_def_use_mgr();
- std::vector<SpvOp> opcodes;
+ std::vector<spv::Op> opcodes;
for (auto* inst = def_use_mgr->GetDef(1);
- inst && (inst->opcode() != SpvOpFunctionEnd); inst = inst->NextNode()) {
+ inst && (inst->opcode() != spv::Op::OpFunctionEnd);
+ inst = inst->NextNode()) {
inst->ForEachInst(
[&opcodes](spvtools::opt::Instruction* sub_inst) {
opcodes.push_back(sub_inst->opcode());
@@ -343,9 +345,10 @@ OpFunctionEnd
true);
}
- EXPECT_THAT(opcodes, ContainerEq(std::vector<SpvOp>{
- SpvOpFAdd, SpvOpLine, SpvOpFMul, SpvOpLine,
- SpvOpFSub, SpvOpLine, SpvOpReturn}));
+ EXPECT_THAT(opcodes, ContainerEq(std::vector<spv::Op>{
+ spv::Op::OpFAdd, spv::Op::OpLine, spv::Op::OpFMul,
+ spv::Op::OpLine, spv::Op::OpFSub, spv::Op::OpLine,
+ spv::Op::OpReturn}));
}
TEST(IrBuilder, ConsumeDebugInfoInst) {
@@ -1297,8 +1300,9 @@ TEST(IrBuilder, OpUndefOutsideFunction) {
const auto opundef_count = std::count_if(
context->module()->types_values_begin(),
- context->module()->types_values_end(),
- [](const Instruction& inst) { return inst.opcode() == SpvOpUndef; });
+ context->module()->types_values_end(), [](const Instruction& inst) {
+ return inst.opcode() == spv::Op::OpUndef;
+ });
EXPECT_EQ(3, opundef_count);
std::vector<uint32_t> binary;
diff --git a/test/opt/loop_optimizations/dependence_analysis.cpp b/test/opt/loop_optimizations/dependence_analysis.cpp
index 8aeb20afc..42d9acba1 100644
--- a/test/opt/loop_optimizations/dependence_analysis.cpp
+++ b/test/opt/loop_optimizations/dependence_analysis.cpp
@@ -135,7 +135,7 @@ TEST(DependencyAnalysis, ZIV) {
const Instruction* store[4];
int stores_found = 0;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 13)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store[stores_found] = &inst;
++stores_found;
}
@@ -292,7 +292,7 @@ TEST(DependencyAnalysis, SymbolicZIV) {
const Instruction* store[4];
int stores_found = 0;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 22)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store[stores_found] = &inst;
++stores_found;
}
@@ -528,7 +528,7 @@ TEST(DependencyAnalysis, SIV) {
const Instruction* store[4];
int stores_found = 0;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 17)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store[stores_found] = &inst;
++stores_found;
}
@@ -601,7 +601,7 @@ TEST(DependencyAnalysis, SIV) {
const Instruction* store[4];
int stores_found = 0;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 68)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store[stores_found] = &inst;
++stores_found;
}
@@ -922,7 +922,7 @@ TEST(DependencyAnalysis, SymbolicSIV) {
const Instruction* store[4];
int stores_found = 0;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 29)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store[stores_found] = &inst;
++stores_found;
}
@@ -978,7 +978,7 @@ TEST(DependencyAnalysis, SymbolicSIV) {
const Instruction* store[4];
int stores_found = 0;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 114)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store[stores_found] = &inst;
++stores_found;
}
@@ -1420,7 +1420,7 @@ TEST(DependencyAnalysis, Crossing) {
const Instruction* store = nullptr;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 29)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store = &inst;
}
}
@@ -1441,7 +1441,7 @@ TEST(DependencyAnalysis, Crossing) {
const Instruction* store = nullptr;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 54)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store = &inst;
}
}
@@ -1463,7 +1463,7 @@ TEST(DependencyAnalysis, Crossing) {
const Instruction* store = nullptr;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 75)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store = &inst;
}
}
@@ -1484,7 +1484,7 @@ TEST(DependencyAnalysis, Crossing) {
const Instruction* store = nullptr;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 99)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store = &inst;
}
}
@@ -1506,7 +1506,7 @@ TEST(DependencyAnalysis, Crossing) {
const Instruction* store = nullptr;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 121)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store = &inst;
}
}
@@ -1527,7 +1527,7 @@ TEST(DependencyAnalysis, Crossing) {
const Instruction* store = nullptr;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 142)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store = &inst;
}
}
@@ -1549,7 +1549,7 @@ TEST(DependencyAnalysis, Crossing) {
const Instruction* store = nullptr;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 162)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store = &inst;
}
}
@@ -1570,7 +1570,7 @@ TEST(DependencyAnalysis, Crossing) {
const Instruction* store = nullptr;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 183)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store = &inst;
}
}
@@ -1846,7 +1846,7 @@ TEST(DependencyAnalysis, WeakZeroSIV) {
const Instruction* store[4];
int stores_found = 0;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 19)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store[stores_found] = &inst;
++stores_found;
}
@@ -1914,7 +1914,7 @@ TEST(DependencyAnalysis, WeakZeroSIV) {
const Instruction* store[4];
int stores_found = 0;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 54)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store[stores_found] = &inst;
++stores_found;
}
@@ -1981,7 +1981,7 @@ TEST(DependencyAnalysis, WeakZeroSIV) {
const Instruction* store[4];
int stores_found = 0;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 84)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store[stores_found] = &inst;
++stores_found;
}
@@ -2049,7 +2049,7 @@ TEST(DependencyAnalysis, WeakZeroSIV) {
const Instruction* store[4];
int stores_found = 0;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 111)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store[stores_found] = &inst;
++stores_found;
}
@@ -2210,7 +2210,7 @@ TEST(DependencyAnalysis, MultipleSubscriptZIVSIV) {
const Instruction* store[6];
int stores_found = 0;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 11)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store[stores_found] = &inst;
++stores_found;
}
@@ -2443,7 +2443,7 @@ TEST(DependencyAnalysis, IrrelevantSubscripts) {
const Instruction* store[1];
int stores_found = 0;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 25)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store[stores_found] = &inst;
++stores_found;
}
@@ -2479,7 +2479,7 @@ TEST(DependencyAnalysis, IrrelevantSubscripts) {
const Instruction* store[1];
int stores_found = 0;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 56)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store[stores_found] = &inst;
++stores_found;
}
@@ -2790,12 +2790,12 @@ TEST(DependencyAnalysis, MIV) {
ASSERT_TRUE(spvtest::GetBasicBlock(f, block_id));
for (const Instruction& inst : *spvtest::GetBasicBlock(f, block_id)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store[stores_found] = &inst;
++stores_found;
}
- if (inst.opcode() == SpvOp::SpvOpLoad) {
+ if (inst.opcode() == spv::Op::OpLoad) {
load[loads_found] = &inst;
++loads_found;
}
@@ -3080,12 +3080,12 @@ TEST(DependencyAnalysis, SubscriptPartitioning) {
ASSERT_TRUE(spvtest::GetBasicBlock(f, block_id));
for (const Instruction& inst : *spvtest::GetBasicBlock(f, block_id)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store[stores_found] = &inst;
++stores_found;
}
- if (inst.opcode() == SpvOp::SpvOpLoad) {
+ if (inst.opcode() == spv::Op::OpLoad) {
load[loads_found] = &inst;
++loads_found;
}
@@ -3461,11 +3461,11 @@ TEST(DependencyAnalysis, Delta) {
ASSERT_TRUE(spvtest::GetBasicBlock(f, block_id));
for (const Instruction& inst : *spvtest::GetBasicBlock(f, block_id)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store = &inst;
}
- if (inst.opcode() == SpvOp::SpvOpLoad) {
+ if (inst.opcode() == spv::Op::OpLoad) {
load = &inst;
}
}
@@ -3502,11 +3502,11 @@ TEST(DependencyAnalysis, Delta) {
ASSERT_TRUE(spvtest::GetBasicBlock(f, block_id));
for (const Instruction& inst : *spvtest::GetBasicBlock(f, block_id)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store = &inst;
}
- if (inst.opcode() == SpvOp::SpvOpLoad) {
+ if (inst.opcode() == spv::Op::OpLoad) {
load = &inst;
}
}
@@ -3534,11 +3534,11 @@ TEST(DependencyAnalysis, Delta) {
ASSERT_TRUE(spvtest::GetBasicBlock(f, block_id));
for (const Instruction& inst : *spvtest::GetBasicBlock(f, block_id)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store = &inst;
}
- if (inst.opcode() == SpvOp::SpvOpLoad) {
+ if (inst.opcode() == spv::Op::OpLoad) {
load = &inst;
}
}
@@ -3569,11 +3569,11 @@ TEST(DependencyAnalysis, Delta) {
ASSERT_TRUE(spvtest::GetBasicBlock(f, block_id));
for (const Instruction& inst : *spvtest::GetBasicBlock(f, block_id)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store = &inst;
}
- if (inst.opcode() == SpvOp::SpvOpLoad) {
+ if (inst.opcode() == spv::Op::OpLoad) {
load = &inst;
}
}
@@ -3611,11 +3611,11 @@ TEST(DependencyAnalysis, Delta) {
ASSERT_TRUE(spvtest::GetBasicBlock(f, block_id));
for (const Instruction& inst : *spvtest::GetBasicBlock(f, block_id)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store = &inst;
}
- if (inst.opcode() == SpvOp::SpvOpLoad) {
+ if (inst.opcode() == spv::Op::OpLoad) {
load = &inst;
}
}
diff --git a/test/opt/loop_optimizations/dependence_analysis_helpers.cpp b/test/opt/loop_optimizations/dependence_analysis_helpers.cpp
index 715cf541d..aabf47844 100644
--- a/test/opt/loop_optimizations/dependence_analysis_helpers.cpp
+++ b/test/opt/loop_optimizations/dependence_analysis_helpers.cpp
@@ -172,7 +172,7 @@ TEST(DependencyAnalysisHelpers, UnsupportedLoops) {
const Instruction* store[1] = {nullptr};
int stores_found = 0;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 16)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store[stores_found] = &inst;
++stores_found;
}
@@ -199,7 +199,7 @@ TEST(DependencyAnalysisHelpers, UnsupportedLoops) {
const Instruction* store[1] = {nullptr};
int stores_found = 0;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 47)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store[stores_found] = &inst;
++stores_found;
}
@@ -1495,7 +1495,7 @@ TEST(DependencyAnalysisHelpers, const_to_symbolic) {
const Instruction* stores[2];
int stores_found = 0;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 30)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
stores[stores_found] = &inst;
++stores_found;
}
@@ -1576,7 +1576,7 @@ TEST(DependencyAnalysisHelpers, const_to_symbolic) {
const Instruction* stores[2];
int stores_found = 0;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 65)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
stores[stores_found] = &inst;
++stores_found;
}
@@ -1655,7 +1655,7 @@ TEST(DependencyAnalysisHelpers, const_to_symbolic) {
const Instruction* stores[2];
int stores_found = 0;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 96)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
stores[stores_found] = &inst;
++stores_found;
}
@@ -1734,7 +1734,7 @@ TEST(DependencyAnalysisHelpers, const_to_symbolic) {
const Instruction* stores[2];
int stores_found = 0;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 126)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
stores[stores_found] = &inst;
++stores_found;
}
@@ -2067,7 +2067,7 @@ TEST(DependencyAnalysisHelpers, symbolic_to_const) {
const Instruction* stores[2];
int stores_found = 0;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 30)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
stores[stores_found] = &inst;
++stores_found;
}
@@ -2148,7 +2148,7 @@ TEST(DependencyAnalysisHelpers, symbolic_to_const) {
const Instruction* stores[2];
int stores_found = 0;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 66)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
stores[stores_found] = &inst;
++stores_found;
}
@@ -2229,7 +2229,7 @@ TEST(DependencyAnalysisHelpers, symbolic_to_const) {
const Instruction* stores[2];
int stores_found = 0;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 96)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
stores[stores_found] = &inst;
++stores_found;
}
@@ -2310,7 +2310,7 @@ TEST(DependencyAnalysisHelpers, symbolic_to_const) {
const Instruction* stores[2];
int stores_found = 0;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 127)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
stores[stores_found] = &inst;
++stores_found;
}
@@ -2705,7 +2705,7 @@ TEST(DependencyAnalysisHelpers, symbolic_to_symbolic) {
const Instruction* stores[2];
int stores_found = 0;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 35)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
stores[stores_found] = &inst;
++stores_found;
}
@@ -2784,7 +2784,7 @@ TEST(DependencyAnalysisHelpers, symbolic_to_symbolic) {
const Instruction* stores[2];
int stores_found = 0;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 90)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
stores[stores_found] = &inst;
++stores_found;
}
@@ -2863,7 +2863,7 @@ TEST(DependencyAnalysisHelpers, symbolic_to_symbolic) {
const Instruction* stores[2];
int stores_found = 0;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 139)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
stores[stores_found] = &inst;
++stores_found;
}
@@ -2942,7 +2942,7 @@ TEST(DependencyAnalysisHelpers, symbolic_to_symbolic) {
const Instruction* stores[2];
int stores_found = 0;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 188)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
stores[stores_found] = &inst;
++stores_found;
}
diff --git a/test/opt/loop_optimizations/peeling.cpp b/test/opt/loop_optimizations/peeling.cpp
index 10d8add38..4ff7a5a2e 100644
--- a/test/opt/loop_optimizations/peeling.cpp
+++ b/test/opt/loop_optimizations/peeling.cpp
@@ -765,7 +765,7 @@ TEST_F(PeelingTest, PeelingUncountable) {
EXPECT_EQ(ld.NumLoops(), 1u);
Instruction* loop_count = context->get_def_use_mgr()->GetDef(16);
- EXPECT_EQ(loop_count->opcode(), SpvOpLoad);
+ EXPECT_EQ(loop_count->opcode(), spv::Op::OpLoad);
LoopPeeling peel(&*ld.begin(), loop_count);
EXPECT_TRUE(peel.CanPeelLoop());
@@ -817,7 +817,7 @@ CHECK-NEXT: OpLoopMerge
EXPECT_EQ(ld.NumLoops(), 1u);
Instruction* loop_count = context->get_def_use_mgr()->GetDef(16);
- EXPECT_EQ(loop_count->opcode(), SpvOpLoad);
+ EXPECT_EQ(loop_count->opcode(), spv::Op::OpLoad);
LoopPeeling peel(&*ld.begin(), loop_count);
EXPECT_TRUE(peel.CanPeelLoop());
@@ -1090,7 +1090,7 @@ TEST_F(PeelingTest, PeelingLoopWithStore) {
EXPECT_EQ(ld.NumLoops(), 1u);
Instruction* loop_count = context->get_def_use_mgr()->GetDef(15);
- EXPECT_EQ(loop_count->opcode(), SpvOpLoad);
+ EXPECT_EQ(loop_count->opcode(), spv::Op::OpLoad);
LoopPeeling peel(&*ld.begin(), loop_count);
EXPECT_TRUE(peel.CanPeelLoop());
@@ -1142,7 +1142,7 @@ CHECK-NEXT: OpLoopMerge
EXPECT_EQ(ld.NumLoops(), 1u);
Instruction* loop_count = context->get_def_use_mgr()->GetDef(15);
- EXPECT_EQ(loop_count->opcode(), SpvOpLoad);
+ EXPECT_EQ(loop_count->opcode(), spv::Op::OpLoad);
LoopPeeling peel(&*ld.begin(), loop_count);
EXPECT_TRUE(peel.CanPeelLoop());
diff --git a/test/opt/loop_optimizations/peeling_pass.cpp b/test/opt/loop_optimizations/peeling_pass.cpp
index 284ad838d..1b5a12d24 100644
--- a/test/opt/loop_optimizations/peeling_pass.cpp
+++ b/test/opt/loop_optimizations/peeling_pass.cpp
@@ -30,27 +30,27 @@ class PeelingPassTest : public PassTest<::testing::Test> {
public:
// Generic routine to run the loop peeling pass and check
LoopPeelingPass::LoopPeelingStats AssembleAndRunPeelingTest(
- const std::string& text_head, const std::string& text_tail, SpvOp opcode,
- const std::string& res_id, const std::string& op1,
+ const std::string& text_head, const std::string& text_tail,
+ spv::Op opcode, const std::string& res_id, const std::string& op1,
const std::string& op2) {
std::string opcode_str;
switch (opcode) {
- case SpvOpSLessThan:
+ case spv::Op::OpSLessThan:
opcode_str = "OpSLessThan";
break;
- case SpvOpSGreaterThan:
+ case spv::Op::OpSGreaterThan:
opcode_str = "OpSGreaterThan";
break;
- case SpvOpSLessThanEqual:
+ case spv::Op::OpSLessThanEqual:
opcode_str = "OpSLessThanEqual";
break;
- case SpvOpSGreaterThanEqual:
+ case spv::Op::OpSGreaterThanEqual:
opcode_str = "OpSGreaterThanEqual";
break;
- case SpvOpIEqual:
+ case spv::Op::OpIEqual:
opcode_str = "OpIEqual";
break;
- case SpvOpINotEqual:
+ case spv::Op::OpINotEqual:
opcode_str = "OpINotEqual";
break;
default:
@@ -69,9 +69,9 @@ class PeelingPassTest : public PassTest<::testing::Test> {
// Generic routine to run the loop peeling pass and check
LoopPeelingPass::LoopPeelingStats RunPeelingTest(
- const std::string& text_head, const std::string& text_tail, SpvOp opcode,
- const std::string& res_id, const std::string& op1, const std::string& op2,
- size_t nb_of_loops) {
+ const std::string& text_head, const std::string& text_tail,
+ spv::Op opcode, const std::string& res_id, const std::string& op1,
+ const std::string& op2, size_t nb_of_loops) {
LoopPeelingPass::LoopPeelingStats stats = AssembleAndRunPeelingTest(
text_head, text_tail, opcode, res_id, op1, op2);
@@ -86,7 +86,7 @@ class PeelingPassTest : public PassTest<::testing::Test> {
std::vector<std::pair<LoopPeelingPass::PeelDirection, uint32_t>>;
void BuildAndCheckTrace(const std::string& text_head,
- const std::string& text_tail, SpvOp opcode,
+ const std::string& text_tail, spv::Op opcode,
const std::string& res_id, const std::string& op1,
const std::string& op2,
const PeelTraceType& expected_peel_trace,
@@ -203,7 +203,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
OpFunctionEnd
)";
- auto run_test = [&text_head, &text_tail, this](SpvOp opcode,
+ auto run_test = [&text_head, &text_tail, this](spv::Op opcode,
const std::string& op1,
const std::string& op2) {
auto stats =
@@ -225,7 +225,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel before iv < 4");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSLessThan, "%32", "%int_4");
+ run_test(spv::Op::OpSLessThan, "%32", "%int_4");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kBefore);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -233,7 +233,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel before 4 > iv");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSGreaterThan, "%int_4", "%32");
+ run_test(spv::Op::OpSGreaterThan, "%int_4", "%32");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kBefore);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -241,7 +241,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel before iv < 5");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSLessThan, "%32", "%int_5");
+ run_test(spv::Op::OpSLessThan, "%32", "%int_5");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kBefore);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -249,7 +249,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel before 5 > iv");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSGreaterThan, "%int_5", "%32");
+ run_test(spv::Op::OpSGreaterThan, "%int_5", "%32");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kBefore);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -259,7 +259,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel after iv < 16");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSLessThan, "%32", "%int_16");
+ run_test(spv::Op::OpSLessThan, "%32", "%int_16");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kAfter);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -267,7 +267,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel after 16 > iv");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSGreaterThan, "%int_16", "%32");
+ run_test(spv::Op::OpSGreaterThan, "%int_16", "%32");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kAfter);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -275,7 +275,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel after iv < 17");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSLessThan, "%32", "%int_17");
+ run_test(spv::Op::OpSLessThan, "%32", "%int_17");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kAfter);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -283,7 +283,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel after 17 > iv");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSGreaterThan, "%int_17", "%32");
+ run_test(spv::Op::OpSGreaterThan, "%int_17", "%32");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kAfter);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -294,7 +294,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel before iv > 5");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSGreaterThan, "%32", "%int_5");
+ run_test(spv::Op::OpSGreaterThan, "%32", "%int_5");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kBefore);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -302,7 +302,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel before 5 < iv");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSLessThan, "%int_5", "%32");
+ run_test(spv::Op::OpSLessThan, "%int_5", "%32");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kBefore);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -310,7 +310,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel before iv > 4");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSGreaterThan, "%32", "%int_4");
+ run_test(spv::Op::OpSGreaterThan, "%32", "%int_4");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kBefore);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -318,7 +318,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel before 4 < iv");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSLessThan, "%int_4", "%32");
+ run_test(spv::Op::OpSLessThan, "%int_4", "%32");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kBefore);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -328,7 +328,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel after iv > 16");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSGreaterThan, "%32", "%int_16");
+ run_test(spv::Op::OpSGreaterThan, "%32", "%int_16");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kAfter);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -336,7 +336,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel after 16 < iv");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSLessThan, "%int_16", "%32");
+ run_test(spv::Op::OpSLessThan, "%int_16", "%32");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kAfter);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -344,7 +344,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel after iv > 17");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSGreaterThan, "%32", "%int_17");
+ run_test(spv::Op::OpSGreaterThan, "%32", "%int_17");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kAfter);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -352,7 +352,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel after 17 < iv");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSLessThan, "%int_17", "%32");
+ run_test(spv::Op::OpSLessThan, "%int_17", "%32");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kAfter);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -363,7 +363,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel before iv <= 4");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSLessThanEqual, "%32", "%int_4");
+ run_test(spv::Op::OpSLessThanEqual, "%32", "%int_4");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kBefore);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -371,7 +371,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel before 4 => iv");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSGreaterThanEqual, "%int_4", "%32");
+ run_test(spv::Op::OpSGreaterThanEqual, "%int_4", "%32");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kBefore);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -379,7 +379,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel before iv <= 3");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSLessThanEqual, "%32", "%int_3");
+ run_test(spv::Op::OpSLessThanEqual, "%32", "%int_3");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kBefore);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -387,7 +387,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel before 3 => iv");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSGreaterThanEqual, "%int_3", "%32");
+ run_test(spv::Op::OpSGreaterThanEqual, "%int_3", "%32");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kBefore);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -397,7 +397,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel after iv <= 16");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSLessThanEqual, "%32", "%int_16");
+ run_test(spv::Op::OpSLessThanEqual, "%32", "%int_16");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kAfter);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -405,7 +405,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel after 16 => iv");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSGreaterThanEqual, "%int_16", "%32");
+ run_test(spv::Op::OpSGreaterThanEqual, "%int_16", "%32");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kAfter);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -413,7 +413,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel after iv <= 15");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSLessThanEqual, "%32", "%int_15");
+ run_test(spv::Op::OpSLessThanEqual, "%32", "%int_15");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kAfter);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -421,7 +421,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel after 15 => iv");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSGreaterThanEqual, "%int_15", "%32");
+ run_test(spv::Op::OpSGreaterThanEqual, "%int_15", "%32");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kAfter);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -432,7 +432,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel before iv >= 5");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSGreaterThanEqual, "%32", "%int_5");
+ run_test(spv::Op::OpSGreaterThanEqual, "%32", "%int_5");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kBefore);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -440,7 +440,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel before 35 >= iv");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSLessThanEqual, "%int_5", "%32");
+ run_test(spv::Op::OpSLessThanEqual, "%int_5", "%32");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kBefore);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -448,7 +448,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel before iv >= 4");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSGreaterThanEqual, "%32", "%int_4");
+ run_test(spv::Op::OpSGreaterThanEqual, "%32", "%int_4");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kBefore);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -456,7 +456,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel before 4 <= iv");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSLessThanEqual, "%int_4", "%32");
+ run_test(spv::Op::OpSLessThanEqual, "%int_4", "%32");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kBefore);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -466,7 +466,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel after iv >= 17");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSGreaterThanEqual, "%32", "%int_17");
+ run_test(spv::Op::OpSGreaterThanEqual, "%32", "%int_17");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kAfter);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -474,7 +474,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel after 17 <= iv");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSLessThanEqual, "%int_17", "%32");
+ run_test(spv::Op::OpSLessThanEqual, "%int_17", "%32");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kAfter);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -482,7 +482,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel after iv >= 16");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSGreaterThanEqual, "%32", "%int_16");
+ run_test(spv::Op::OpSGreaterThanEqual, "%32", "%int_16");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kAfter);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -490,7 +490,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel after 16 <= iv");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpSLessThanEqual, "%int_16", "%32");
+ run_test(spv::Op::OpSLessThanEqual, "%int_16", "%32");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kAfter);
EXPECT_EQ(peel_info.second, 2u);
}
@@ -501,7 +501,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel before iv == 1");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpIEqual, "%32", "%int_1");
+ run_test(spv::Op::OpIEqual, "%32", "%int_1");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kBefore);
EXPECT_EQ(peel_info.second, 1u);
}
@@ -509,7 +509,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel before 1 == iv");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpIEqual, "%int_1", "%32");
+ run_test(spv::Op::OpIEqual, "%int_1", "%32");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kBefore);
EXPECT_EQ(peel_info.second, 1u);
}
@@ -519,7 +519,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel after iv == 19");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpIEqual, "%32", "%int_19");
+ run_test(spv::Op::OpIEqual, "%32", "%int_19");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kAfter);
EXPECT_EQ(peel_info.second, 1u);
}
@@ -527,7 +527,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel after 19 == iv");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpIEqual, "%int_19", "%32");
+ run_test(spv::Op::OpIEqual, "%int_19", "%32");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kAfter);
EXPECT_EQ(peel_info.second, 1u);
}
@@ -538,7 +538,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel before iv != 1");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpINotEqual, "%32", "%int_1");
+ run_test(spv::Op::OpINotEqual, "%32", "%int_1");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kBefore);
EXPECT_EQ(peel_info.second, 1u);
}
@@ -546,7 +546,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel before 1 != iv");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpINotEqual, "%int_1", "%32");
+ run_test(spv::Op::OpINotEqual, "%int_1", "%32");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kBefore);
EXPECT_EQ(peel_info.second, 1u);
}
@@ -556,7 +556,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel after iv != 19");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpINotEqual, "%32", "%int_19");
+ run_test(spv::Op::OpINotEqual, "%32", "%int_19");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kAfter);
EXPECT_EQ(peel_info.second, 1u);
}
@@ -564,7 +564,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
SCOPED_TRACE("Peel after 19 != iv");
std::pair<LoopPeelingPass::PeelDirection, uint32_t> peel_info =
- run_test(SpvOpINotEqual, "%int_19", "%32");
+ run_test(spv::Op::OpINotEqual, "%int_19", "%32");
EXPECT_EQ(peel_info.first, LoopPeelingPass::PeelDirection::kAfter);
EXPECT_EQ(peel_info.second, 1u);
}
@@ -573,7 +573,7 @@ TEST_F(PeelingPassTest, PeelingPassBasic) {
{
SCOPED_TRACE("No Peel: 20 => iv");
- auto stats = RunPeelingTest(text_head, text_tail, SpvOpSLessThanEqual,
+ auto stats = RunPeelingTest(text_head, text_tail, spv::Op::OpSLessThanEqual,
"%22", "%int_20", "%32", 1);
EXPECT_EQ(stats.peeled_loops_.size(), 0u);
@@ -673,7 +673,7 @@ TEST_F(PeelingPassTest, MultiplePeelingPass) {
)";
auto run_test = [&text_head, &text_tail, this](
- SpvOp opcode, const std::string& op1,
+ spv::Op opcode, const std::string& op1,
const std::string& op2,
const PeelTraceType& expected_peel_trace) {
BuildAndCheckTrace(text_head, text_tail, opcode, "%22", op1, op2,
@@ -685,13 +685,13 @@ TEST_F(PeelingPassTest, MultiplePeelingPass) {
{
SCOPED_TRACE("Peel before iv < 3");
- run_test(SpvOpSLessThan, "%38", "%int_3",
+ run_test(spv::Op::OpSLessThan, "%38", "%int_3",
{{LoopPeelingPass::PeelDirection::kBefore, 3u}});
}
{
SCOPED_TRACE("Peel before 3 > iv");
- run_test(SpvOpSGreaterThan, "%int_3", "%38",
+ run_test(spv::Op::OpSGreaterThan, "%int_3", "%38",
{{LoopPeelingPass::PeelDirection::kBefore, 3u}});
}
@@ -699,13 +699,13 @@ TEST_F(PeelingPassTest, MultiplePeelingPass) {
{
SCOPED_TRACE("Peel after iv < 8");
- run_test(SpvOpSLessThan, "%38", "%int_8",
+ run_test(spv::Op::OpSLessThan, "%38", "%int_8",
{{LoopPeelingPass::PeelDirection::kAfter, 2u}});
}
{
SCOPED_TRACE("Peel after 8 > iv");
- run_test(SpvOpSGreaterThan, "%int_8", "%38",
+ run_test(spv::Op::OpSGreaterThan, "%int_8", "%38",
{{LoopPeelingPass::PeelDirection::kAfter, 2u}});
}
@@ -714,13 +714,13 @@ TEST_F(PeelingPassTest, MultiplePeelingPass) {
{
SCOPED_TRACE("Peel before iv > 2");
- run_test(SpvOpSGreaterThan, "%38", "%int_2",
+ run_test(spv::Op::OpSGreaterThan, "%38", "%int_2",
{{LoopPeelingPass::PeelDirection::kBefore, 2u}});
}
{
SCOPED_TRACE("Peel before 2 < iv");
- run_test(SpvOpSLessThan, "%int_2", "%38",
+ run_test(spv::Op::OpSLessThan, "%int_2", "%38",
{{LoopPeelingPass::PeelDirection::kBefore, 2u}});
}
@@ -728,13 +728,13 @@ TEST_F(PeelingPassTest, MultiplePeelingPass) {
{
SCOPED_TRACE("Peel after iv > 7");
- run_test(SpvOpSGreaterThan, "%38", "%int_7",
+ run_test(spv::Op::OpSGreaterThan, "%38", "%int_7",
{{LoopPeelingPass::PeelDirection::kAfter, 3u}});
}
{
SCOPED_TRACE("Peel after 7 < iv");
- run_test(SpvOpSLessThan, "%int_7", "%38",
+ run_test(spv::Op::OpSLessThan, "%int_7", "%38",
{{LoopPeelingPass::PeelDirection::kAfter, 3u}});
}
@@ -743,13 +743,13 @@ TEST_F(PeelingPassTest, MultiplePeelingPass) {
{
SCOPED_TRACE("Peel before iv <= 1");
- run_test(SpvOpSLessThanEqual, "%38", "%int_1",
+ run_test(spv::Op::OpSLessThanEqual, "%38", "%int_1",
{{LoopPeelingPass::PeelDirection::kBefore, 2u}});
}
{
SCOPED_TRACE("Peel before 1 => iv");
- run_test(SpvOpSGreaterThanEqual, "%int_1", "%38",
+ run_test(spv::Op::OpSGreaterThanEqual, "%int_1", "%38",
{{LoopPeelingPass::PeelDirection::kBefore, 2u}});
}
@@ -757,13 +757,13 @@ TEST_F(PeelingPassTest, MultiplePeelingPass) {
{
SCOPED_TRACE("Peel after iv <= 7");
- run_test(SpvOpSLessThanEqual, "%38", "%int_7",
+ run_test(spv::Op::OpSLessThanEqual, "%38", "%int_7",
{{LoopPeelingPass::PeelDirection::kAfter, 2u}});
}
{
SCOPED_TRACE("Peel after 7 => iv");
- run_test(SpvOpSGreaterThanEqual, "%int_7", "%38",
+ run_test(spv::Op::OpSGreaterThanEqual, "%int_7", "%38",
{{LoopPeelingPass::PeelDirection::kAfter, 2u}});
}
@@ -772,13 +772,13 @@ TEST_F(PeelingPassTest, MultiplePeelingPass) {
{
SCOPED_TRACE("Peel before iv >= 2");
- run_test(SpvOpSGreaterThanEqual, "%38", "%int_2",
+ run_test(spv::Op::OpSGreaterThanEqual, "%38", "%int_2",
{{LoopPeelingPass::PeelDirection::kBefore, 2u}});
}
{
SCOPED_TRACE("Peel before 2 <= iv");
- run_test(SpvOpSLessThanEqual, "%int_2", "%38",
+ run_test(spv::Op::OpSLessThanEqual, "%int_2", "%38",
{{LoopPeelingPass::PeelDirection::kBefore, 2u}});
}
@@ -786,13 +786,13 @@ TEST_F(PeelingPassTest, MultiplePeelingPass) {
{
SCOPED_TRACE("Peel after iv >= 8");
- run_test(SpvOpSGreaterThanEqual, "%38", "%int_8",
+ run_test(spv::Op::OpSGreaterThanEqual, "%38", "%int_8",
{{LoopPeelingPass::PeelDirection::kAfter, 2u}});
}
{
SCOPED_TRACE("Peel after 8 <= iv");
- run_test(SpvOpSLessThanEqual, "%int_8", "%38",
+ run_test(spv::Op::OpSLessThanEqual, "%int_8", "%38",
{{LoopPeelingPass::PeelDirection::kAfter, 2u}});
}
// Test EQ
@@ -800,13 +800,13 @@ TEST_F(PeelingPassTest, MultiplePeelingPass) {
{
SCOPED_TRACE("Peel before iv == 0");
- run_test(SpvOpIEqual, "%38", "%int_0",
+ run_test(spv::Op::OpIEqual, "%38", "%int_0",
{{LoopPeelingPass::PeelDirection::kBefore, 1u}});
}
{
SCOPED_TRACE("Peel before 0 == iv");
- run_test(SpvOpIEqual, "%int_0", "%38",
+ run_test(spv::Op::OpIEqual, "%int_0", "%38",
{{LoopPeelingPass::PeelDirection::kBefore, 1u}});
}
@@ -814,13 +814,13 @@ TEST_F(PeelingPassTest, MultiplePeelingPass) {
{
SCOPED_TRACE("Peel after iv == 9");
- run_test(SpvOpIEqual, "%38", "%int_9",
+ run_test(spv::Op::OpIEqual, "%38", "%int_9",
{{LoopPeelingPass::PeelDirection::kBefore, 1u}});
}
{
SCOPED_TRACE("Peel after 9 == iv");
- run_test(SpvOpIEqual, "%int_9", "%38",
+ run_test(spv::Op::OpIEqual, "%int_9", "%38",
{{LoopPeelingPass::PeelDirection::kBefore, 1u}});
}
@@ -829,13 +829,13 @@ TEST_F(PeelingPassTest, MultiplePeelingPass) {
{
SCOPED_TRACE("Peel before iv != 0");
- run_test(SpvOpINotEqual, "%38", "%int_0",
+ run_test(spv::Op::OpINotEqual, "%38", "%int_0",
{{LoopPeelingPass::PeelDirection::kBefore, 1u}});
}
{
SCOPED_TRACE("Peel before 0 != iv");
- run_test(SpvOpINotEqual, "%int_0", "%38",
+ run_test(spv::Op::OpINotEqual, "%int_0", "%38",
{{LoopPeelingPass::PeelDirection::kBefore, 1u}});
}
@@ -843,13 +843,13 @@ TEST_F(PeelingPassTest, MultiplePeelingPass) {
{
SCOPED_TRACE("Peel after iv != 9");
- run_test(SpvOpINotEqual, "%38", "%int_9",
+ run_test(spv::Op::OpINotEqual, "%38", "%int_9",
{{LoopPeelingPass::PeelDirection::kBefore, 1u}});
}
{
SCOPED_TRACE("Peel after 9 != iv");
- run_test(SpvOpINotEqual, "%int_9", "%38",
+ run_test(spv::Op::OpINotEqual, "%int_9", "%38",
{{LoopPeelingPass::PeelDirection::kBefore, 1u}});
}
}
@@ -952,7 +952,7 @@ TEST_F(PeelingPassTest, PeelingNestedPass) {
auto run_test =
[&text_head, &text_tail, this](
- SpvOp opcode, const std::string& op1, const std::string& op2,
+ spv::Op opcode, const std::string& op1, const std::string& op2,
const PeelTraceType& expected_peel_trace, size_t nb_of_loops) {
BuildAndCheckTrace(text_head, text_tail, opcode, "%30", op1, op2,
expected_peel_trace, nb_of_loops);
@@ -963,7 +963,7 @@ TEST_F(PeelingPassTest, PeelingNestedPass) {
SCOPED_TRACE("Peel before iv_i < 3");
// Expect peel before by a factor of 3 and 4 loops at the end.
- run_test(SpvOpSLessThan, "%42", "%int_3",
+ run_test(spv::Op::OpSLessThan, "%42", "%int_3",
{{LoopPeelingPass::PeelDirection::kBefore, 3u}}, 4);
}
// Peeling outer loop after by a factor of 3.
@@ -971,7 +971,7 @@ TEST_F(PeelingPassTest, PeelingNestedPass) {
SCOPED_TRACE("Peel after iv_i < 7");
// Expect peel after by a factor of 3 and 4 loops at the end.
- run_test(SpvOpSLessThan, "%42", "%int_7",
+ run_test(spv::Op::OpSLessThan, "%42", "%int_7",
{{LoopPeelingPass::PeelDirection::kAfter, 3u}}, 4);
}
@@ -980,7 +980,7 @@ TEST_F(PeelingPassTest, PeelingNestedPass) {
SCOPED_TRACE("Peel before iv_j < 3");
// Expect peel before by a factor of 3 and 3 loops at the end.
- run_test(SpvOpSLessThan, "%46", "%int_3",
+ run_test(spv::Op::OpSLessThan, "%46", "%int_3",
{{LoopPeelingPass::PeelDirection::kBefore, 3u}}, 3);
}
// Peeling inner loop after by a factor of 3.
@@ -988,7 +988,7 @@ TEST_F(PeelingPassTest, PeelingNestedPass) {
SCOPED_TRACE("Peel after iv_j < 7");
// Expect peel after by a factor of 3 and 3 loops at the end.
- run_test(SpvOpSLessThan, "%46", "%int_7",
+ run_test(spv::Op::OpSLessThan, "%46", "%int_7",
{{LoopPeelingPass::PeelDirection::kAfter, 3u}}, 3);
}
@@ -997,7 +997,7 @@ TEST_F(PeelingPassTest, PeelingNestedPass) {
SCOPED_TRACE("No peel");
// Expect no peeling and 2 loops at the end.
- run_test(SpvOpSLessThan, "%46", "%42", {}, 2);
+ run_test(spv::Op::OpSLessThan, "%46", "%42", {}, 2);
}
// Could do a peeling of 3, but the goes over the threshold.
@@ -1007,7 +1007,7 @@ TEST_F(PeelingPassTest, PeelingNestedPass) {
size_t current_threshold = LoopPeelingPass::GetLoopPeelingThreshold();
LoopPeelingPass::SetLoopPeelingThreshold(1u);
// Expect no peeling and 2 loops at the end.
- run_test(SpvOpSLessThan, "%46", "%int_7", {}, 2);
+ run_test(spv::Op::OpSLessThan, "%46", "%int_7", {}, 2);
LoopPeelingPass::SetLoopPeelingThreshold(current_threshold);
}
}
diff --git a/test/opt/module_test.cpp b/test/opt/module_test.cpp
index 17a13650f..33dc05f8a 100644
--- a/test/opt/module_test.cpp
+++ b/test/opt/module_test.cpp
@@ -324,7 +324,7 @@ OpFunctionEnd
std::unordered_set<uint32_t> non_semantic_ids;
context->module()->ForEachInst(
[&non_semantic_ids](const Instruction* inst) {
- if (inst->opcode() == SpvOpExtInst) {
+ if (inst->opcode() == spv::Op::OpExtInst) {
non_semantic_ids.insert(inst->result_id());
}
},
diff --git a/test/opt/pass_manager_test.cpp b/test/opt/pass_manager_test.cpp
index 4f36d5b26..ec11069b6 100644
--- a/test/opt/pass_manager_test.cpp
+++ b/test/opt/pass_manager_test.cpp
@@ -144,8 +144,8 @@ class AppendTypeVoidInstPass : public Pass {
const char* name() const override { return "AppendTypeVoidInstPass"; }
Status Process() override {
- auto inst = MakeUnique<Instruction>(context(), SpvOpTypeVoid, 0, result_id_,
- std::vector<Operand>{});
+ auto inst = MakeUnique<Instruction>(context(), spv::Op::OpTypeVoid, 0,
+ result_id_, std::vector<Operand>{});
context()->AddType(std::move(inst));
return Status::SuccessWithChange;
}
diff --git a/test/opt/pass_remove_duplicates_test.cpp b/test/opt/pass_remove_duplicates_test.cpp
index 887fdfdb4..ac87db17f 100644
--- a/test/opt/pass_remove_duplicates_test.cpp
+++ b/test/opt/pass_remove_duplicates_test.cpp
@@ -91,7 +91,7 @@ class RemoveDuplicatesTest : public ::testing::Test {
std::string GetErrorMessage() const { return error_message_; }
std::string ToText(const std::vector<Instruction*>& inst) {
- std::vector<uint32_t> binary = {SpvMagicNumber, 0x10200, 0u, 2u, 0u};
+ std::vector<uint32_t> binary = {spv::MagicNumber, 0x10200, 0u, 2u, 0u};
for (const Instruction* i : inst)
i->ToBinaryWithoutAttachedDebugInsts(&binary);
std::string text;
diff --git a/test/opt/propagator_test.cpp b/test/opt/propagator_test.cpp
index fb8e487cc..76211a58f 100644
--- a/test/opt/propagator_test.cpp
+++ b/test/opt/propagator_test.cpp
@@ -107,11 +107,11 @@ TEST_F(PropagatorTest, LocalPropagate) {
const auto visit_fn = [this](Instruction* instr, BasicBlock** dest_bb) {
*dest_bb = nullptr;
- if (instr->opcode() == SpvOpStore) {
+ if (instr->opcode() == spv::Op::OpStore) {
uint32_t lhs_id = instr->GetSingleWordOperand(0);
uint32_t rhs_id = instr->GetSingleWordOperand(1);
Instruction* rhs_def = ctx_->get_def_use_mgr()->GetDef(rhs_id);
- if (rhs_def->opcode() == SpvOpConstant) {
+ if (rhs_def->opcode() == spv::Op::OpConstant) {
uint32_t val = rhs_def->GetSingleWordOperand(2);
values_[lhs_id] = val;
return SSAPropagator::kInteresting;
@@ -175,15 +175,15 @@ TEST_F(PropagatorTest, PropagateThroughPhis) {
const auto visit_fn = [this, &phi_instr](Instruction* instr,
BasicBlock** dest_bb) {
*dest_bb = nullptr;
- if (instr->opcode() == SpvOpLoad) {
+ if (instr->opcode() == spv::Op::OpLoad) {
uint32_t rhs_id = instr->GetSingleWordOperand(2);
Instruction* rhs_def = ctx_->get_def_use_mgr()->GetDef(rhs_id);
- if (rhs_def->opcode() == SpvOpConstant) {
+ if (rhs_def->opcode() == spv::Op::OpConstant) {
uint32_t val = rhs_def->GetSingleWordOperand(2);
values_[instr->result_id()] = val;
return SSAPropagator::kInteresting;
}
- } else if (instr->opcode() == SpvOpPhi) {
+ } else if (instr->opcode() == spv::Op::OpPhi) {
phi_instr = instr;
SSAPropagator::PropStatus retval;
for (uint32_t i = 2; i < instr->NumOperands(); i += 2) {
diff --git a/test/opt/scalar_analysis.cpp b/test/opt/scalar_analysis.cpp
index df2aa8f89..14f82af68 100644
--- a/test/opt/scalar_analysis.cpp
+++ b/test/opt/scalar_analysis.cpp
@@ -109,10 +109,10 @@ TEST_F(ScalarAnalysisTest, BasicEvolutionTest) {
const Instruction* store = nullptr;
const Instruction* load = nullptr;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 11)) {
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
store = &inst;
}
- if (inst.opcode() == SpvOp::SpvOpLoad) {
+ if (inst.opcode() == spv::Op::OpLoad) {
load = &inst;
}
}
@@ -236,7 +236,7 @@ TEST_F(ScalarAnalysisTest, LoadTest) {
const Instruction* load = nullptr;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 28)) {
- if (inst.opcode() == SpvOp::SpvOpLoad) {
+ if (inst.opcode() == spv::Op::OpLoad) {
load = &inst;
}
}
@@ -352,7 +352,7 @@ TEST_F(ScalarAnalysisTest, SimplifySimple) {
const Instruction* load = nullptr;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 21)) {
- if (inst.opcode() == SpvOp::SpvOpLoad && inst.result_id() == 33) {
+ if (inst.opcode() == spv::Op::OpLoad && inst.result_id() == 33) {
load = &inst;
}
}
@@ -506,11 +506,11 @@ TEST_F(ScalarAnalysisTest, Simplify) {
int store_count = 0;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 22)) {
- if (inst.opcode() == SpvOp::SpvOpLoad) {
+ if (inst.opcode() == spv::Op::OpLoad) {
loads[load_count] = &inst;
++load_count;
}
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
stores[store_count] = &inst;
++store_count;
}
@@ -745,11 +745,11 @@ TEST_F(ScalarAnalysisTest, SimplifyMultiplyInductions) {
int store_count = 0;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 31)) {
- if (inst.opcode() == SpvOp::SpvOpLoad) {
+ if (inst.opcode() == spv::Op::OpLoad) {
loads[load_count] = &inst;
++load_count;
}
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
stores[store_count] = &inst;
++store_count;
}
@@ -880,7 +880,7 @@ TEST_F(ScalarAnalysisTest, SimplifyNegativeSteps) {
int load_count = 0;
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 29)) {
- if (inst.opcode() == SpvOp::SpvOpLoad) {
+ if (inst.opcode() == spv::Op::OpLoad) {
loads[load_count] = &inst;
++load_count;
}
@@ -1025,10 +1025,10 @@ TEST_F(ScalarAnalysisTest, SimplifyInductionsAndLoads) {
std::vector<const Instruction*> stores{};
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 30)) {
- if (inst.opcode() == SpvOp::SpvOpLoad) {
+ if (inst.opcode() == spv::Op::OpLoad) {
loads.push_back(&inst);
}
- if (inst.opcode() == SpvOp::SpvOpStore) {
+ if (inst.opcode() == spv::Op::OpStore) {
stores.push_back(&inst);
}
}
@@ -1194,7 +1194,7 @@ TEST_F(ScalarAnalysisTest, InductionWithVariantStep) {
std::vector<const Instruction*> phis{};
for (const Instruction& inst : *spvtest::GetBasicBlock(f, 21)) {
- if (inst.opcode() == SpvOp::SpvOpPhi) {
+ if (inst.opcode() == spv::Op::OpPhi) {
phis.push_back(&inst);
}
}
diff --git a/test/opt/type_manager_test.cpp b/test/opt/type_manager_test.cpp
index df216bc92..eebc50d59 100644
--- a/test/opt/type_manager_test.cpp
+++ b/test/opt/type_manager_test.cpp
@@ -98,15 +98,19 @@ std::vector<std::unique_ptr<Type>> GenerateAllTypes() {
types.emplace_back(new Matrix(v3f32, 4));
// Images
- types.emplace_back(new Image(s32, SpvDim2D, 0, 0, 0, 0, SpvImageFormatRg8,
- SpvAccessQualifierReadOnly));
+ types.emplace_back(new Image(s32, spv::Dim::Dim2D, 0, 0, 0, 0,
+ spv::ImageFormat::Rg8,
+ spv::AccessQualifier::ReadOnly));
auto* image1 = types.back().get();
- types.emplace_back(new Image(s32, SpvDim2D, 0, 1, 0, 0, SpvImageFormatRg8,
- SpvAccessQualifierReadOnly));
- types.emplace_back(new Image(s32, SpvDim3D, 0, 1, 0, 0, SpvImageFormatRg8,
- SpvAccessQualifierReadOnly));
- types.emplace_back(new Image(voidt, SpvDim3D, 0, 1, 0, 1, SpvImageFormatRg8,
- SpvAccessQualifierReadWrite));
+ types.emplace_back(new Image(s32, spv::Dim::Dim2D, 0, 1, 0, 0,
+ spv::ImageFormat::Rg8,
+ spv::AccessQualifier::ReadOnly));
+ types.emplace_back(new Image(s32, spv::Dim::Dim3D, 0, 1, 0, 0,
+ spv::ImageFormat::Rg8,
+ spv::AccessQualifier::ReadOnly));
+ types.emplace_back(new Image(voidt, spv::Dim::Dim3D, 0, 1, 0, 1,
+ spv::ImageFormat::Rg8,
+ spv::AccessQualifier::ReadWrite));
auto* image2 = types.back().get();
// Sampler
@@ -140,9 +144,9 @@ std::vector<std::unique_ptr<Type>> GenerateAllTypes() {
types.emplace_back(new Opaque("world"));
// Pointer
- types.emplace_back(new Pointer(f32, SpvStorageClassInput));
- types.emplace_back(new Pointer(sts32f32, SpvStorageClassFunction));
- types.emplace_back(new Pointer(a42f32, SpvStorageClassFunction));
+ types.emplace_back(new Pointer(f32, spv::StorageClass::Input));
+ types.emplace_back(new Pointer(sts32f32, spv::StorageClass::Function));
+ types.emplace_back(new Pointer(a42f32, spv::StorageClass::Function));
// Function
types.emplace_back(new Function(voidt, {}));
@@ -158,11 +162,11 @@ std::vector<std::unique_ptr<Type>> GenerateAllTypes() {
// Pipe, Forward Pointer, PipeStorage, NamedBarrier, AccelerationStructureNV,
// CooperativeMatrixNV
- types.emplace_back(new Pipe(SpvAccessQualifierReadWrite));
- types.emplace_back(new Pipe(SpvAccessQualifierReadOnly));
- types.emplace_back(new ForwardPointer(1, SpvStorageClassInput));
- types.emplace_back(new ForwardPointer(2, SpvStorageClassInput));
- types.emplace_back(new ForwardPointer(2, SpvStorageClassUniform));
+ types.emplace_back(new Pipe(spv::AccessQualifier::ReadWrite));
+ types.emplace_back(new Pipe(spv::AccessQualifier::ReadOnly));
+ types.emplace_back(new ForwardPointer(1, spv::StorageClass::Input));
+ types.emplace_back(new ForwardPointer(2, spv::StorageClass::Input));
+ types.emplace_back(new ForwardPointer(2, spv::StorageClass::Uniform));
types.emplace_back(new PipeStorage());
types.emplace_back(new NamedBarrier());
types.emplace_back(new AccelerationStructureNV());
@@ -814,22 +818,22 @@ OpMemoryModel Logical GLSL450
EXPECT_NE(context, nullptr);
Integer u32(32, false);
- Pointer u32Ptr(&u32, SpvStorageClassFunction);
+ Pointer u32Ptr(&u32, spv::StorageClass::Function);
Struct st({&u32});
- Pointer stPtr(&st, SpvStorageClassInput);
+ Pointer stPtr(&st, spv::StorageClass::Input);
auto pair = context->get_type_mgr()->GetTypeAndPointerType(
- 3u, SpvStorageClassFunction);
+ 3u, spv::StorageClass::Function);
ASSERT_EQ(nullptr, pair.first);
ASSERT_EQ(nullptr, pair.second);
pair = context->get_type_mgr()->GetTypeAndPointerType(
- 1u, SpvStorageClassFunction);
+ 1u, spv::StorageClass::Function);
ASSERT_TRUE(pair.first->IsSame(&u32));
ASSERT_TRUE(pair.second->IsSame(&u32Ptr));
- pair =
- context->get_type_mgr()->GetTypeAndPointerType(2u, SpvStorageClassInput);
+ pair = context->get_type_mgr()->GetTypeAndPointerType(
+ 2u, spv::StorageClass::Input);
ASSERT_TRUE(pair.first->IsSame(&st));
ASSERT_TRUE(pair.second->IsSame(&stPtr));
}
@@ -1155,7 +1159,7 @@ OpMemoryModel Logical GLSL450
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
EXPECT_NE(context, nullptr);
- context->get_type_mgr()->FindPointerToType(1, SpvStorageClassFunction);
+ context->get_type_mgr()->FindPointerToType(1, spv::StorageClass::Function);
Match(text, context.get());
}
@@ -1180,7 +1184,7 @@ OpMemoryModel Logical GLSL450
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
EXPECT_NE(context, nullptr);
- context->get_type_mgr()->FindPointerToType(2, SpvStorageClassFunction);
+ context->get_type_mgr()->FindPointerToType(2, spv::StorageClass::Function);
Match(text, context.get());
}
diff --git a/test/opt/types_test.cpp b/test/opt/types_test.cpp
index 552ad97cf..4352b7cf5 100644
--- a/test/opt/types_test.cpp
+++ b/test/opt/types_test.cpp
@@ -34,9 +34,9 @@ class SameTypeTest : public ::testing::Test {
u32_t_ = MakeUnique<Integer>(32, false);
f64_t_ = MakeUnique<Float>(64);
v3u32_t_ = MakeUnique<Vector>(u32_t_.get(), 3);
- image_t_ =
- MakeUnique<Image>(f64_t_.get(), SpvDim2D, 1, 1, 0, 0, SpvImageFormatR16,
- SpvAccessQualifierReadWrite);
+ image_t_ = MakeUnique<Image>(f64_t_.get(), spv::Dim::Dim2D, 1, 1, 0, 0,
+ spv::ImageFormat::R16,
+ spv::AccessQualifier::ReadWrite);
}
// Element types to be used for constructing other types for testing.
@@ -72,9 +72,9 @@ TestMultipleInstancesOfTheSameType(Integer, 32, true)
TestMultipleInstancesOfTheSameType(Float, 64)
TestMultipleInstancesOfTheSameType(Vector, u32_t_.get(), 3)
TestMultipleInstancesOfTheSameType(Matrix, v3u32_t_.get(), 4)
-TestMultipleInstancesOfTheSameType(Image, f64_t_.get(), SpvDimCube, 0, 0, 1, 1,
- SpvImageFormatRgb10A2,
- SpvAccessQualifierWriteOnly)
+TestMultipleInstancesOfTheSameType(Image, f64_t_.get(), spv::Dim::Cube, 0, 0, 1, 1,
+ spv::ImageFormat::Rgb10A2,
+ spv::AccessQualifier::WriteOnly)
TestMultipleInstancesOfTheSameType(Sampler)
TestMultipleInstancesOfTheSameType(SampledImage, image_t_.get())
// There are three classes of arrays, based on the kinds of length information
@@ -98,15 +98,15 @@ TestMultipleInstancesOfTheSameType(RuntimeArray, u32_t_.get())
TestMultipleInstancesOfTheSameType(Struct, std::vector<const Type*>{
u32_t_.get(), f64_t_.get()})
TestMultipleInstancesOfTheSameType(Opaque, "testing rocks")
-TestMultipleInstancesOfTheSameType(Pointer, u32_t_.get(), SpvStorageClassInput)
+TestMultipleInstancesOfTheSameType(Pointer, u32_t_.get(), spv::StorageClass::Input)
TestMultipleInstancesOfTheSameType(Function, u32_t_.get(),
{f64_t_.get(), f64_t_.get()})
TestMultipleInstancesOfTheSameType(Event)
TestMultipleInstancesOfTheSameType(DeviceEvent)
TestMultipleInstancesOfTheSameType(ReserveId)
TestMultipleInstancesOfTheSameType(Queue)
-TestMultipleInstancesOfTheSameType(Pipe, SpvAccessQualifierReadWrite)
-TestMultipleInstancesOfTheSameType(ForwardPointer, 10, SpvStorageClassUniform)
+TestMultipleInstancesOfTheSameType(Pipe, spv::AccessQualifier::ReadWrite)
+TestMultipleInstancesOfTheSameType(ForwardPointer, 10, spv::StorageClass::Uniform)
TestMultipleInstancesOfTheSameType(PipeStorage)
TestMultipleInstancesOfTheSameType(NamedBarrier)
TestMultipleInstancesOfTheSameType(AccelerationStructureNV)
@@ -119,8 +119,8 @@ std::vector<std::unique_ptr<Type>> GenerateAllTypes() {
std::vector<std::unique_ptr<Type>> types;
// Forward Pointer
- types.emplace_back(new ForwardPointer(10000, SpvStorageClassInput));
- types.emplace_back(new ForwardPointer(20000, SpvStorageClassInput));
+ types.emplace_back(new ForwardPointer(10000, spv::StorageClass::Input));
+ types.emplace_back(new ForwardPointer(20000, spv::StorageClass::Input));
// Void, Bool
types.emplace_back(new Void());
@@ -155,15 +155,19 @@ std::vector<std::unique_ptr<Type>> GenerateAllTypes() {
types.emplace_back(new Matrix(v3f32, 4));
// Images
- types.emplace_back(new Image(s32, SpvDim2D, 0, 0, 0, 0, SpvImageFormatRg8,
- SpvAccessQualifierReadOnly));
+ types.emplace_back(new Image(s32, spv::Dim::Dim2D, 0, 0, 0, 0,
+ spv::ImageFormat::Rg8,
+ spv::AccessQualifier::ReadOnly));
auto* image1 = types.back().get();
- types.emplace_back(new Image(s32, SpvDim2D, 0, 1, 0, 0, SpvImageFormatRg8,
- SpvAccessQualifierReadOnly));
- types.emplace_back(new Image(s32, SpvDim3D, 0, 1, 0, 0, SpvImageFormatRg8,
- SpvAccessQualifierReadOnly));
- types.emplace_back(new Image(voidt, SpvDim3D, 0, 1, 0, 1, SpvImageFormatRg8,
- SpvAccessQualifierReadWrite));
+ types.emplace_back(new Image(s32, spv::Dim::Dim2D, 0, 1, 0, 0,
+ spv::ImageFormat::Rg8,
+ spv::AccessQualifier::ReadOnly));
+ types.emplace_back(new Image(s32, spv::Dim::Dim3D, 0, 1, 0, 0,
+ spv::ImageFormat::Rg8,
+ spv::AccessQualifier::ReadOnly));
+ types.emplace_back(new Image(voidt, spv::Dim::Dim3D, 0, 1, 0, 1,
+ spv::ImageFormat::Rg8,
+ spv::AccessQualifier::ReadWrite));
auto* image2 = types.back().get();
// Sampler
@@ -218,10 +222,10 @@ std::vector<std::unique_ptr<Type>> GenerateAllTypes() {
types.emplace_back(new Opaque("world"));
// Pointer
- types.emplace_back(new Pointer(f32, SpvStorageClassInput));
- types.emplace_back(new Pointer(sts32f32, SpvStorageClassFunction));
- types.emplace_back(new Pointer(a42f32, SpvStorageClassFunction));
- types.emplace_back(new Pointer(voidt, SpvStorageClassFunction));
+ types.emplace_back(new Pointer(f32, spv::StorageClass::Input));
+ types.emplace_back(new Pointer(sts32f32, spv::StorageClass::Function));
+ types.emplace_back(new Pointer(a42f32, spv::StorageClass::Function));
+ types.emplace_back(new Pointer(voidt, spv::StorageClass::Function));
// Function
types.emplace_back(new Function(voidt, {}));
@@ -236,11 +240,11 @@ std::vector<std::unique_ptr<Type>> GenerateAllTypes() {
types.emplace_back(new Queue());
// Pipe, Forward Pointer, PipeStorage, NamedBarrier
- types.emplace_back(new Pipe(SpvAccessQualifierReadWrite));
- types.emplace_back(new Pipe(SpvAccessQualifierReadOnly));
- types.emplace_back(new ForwardPointer(1, SpvStorageClassInput));
- types.emplace_back(new ForwardPointer(2, SpvStorageClassInput));
- types.emplace_back(new ForwardPointer(2, SpvStorageClassUniform));
+ types.emplace_back(new Pipe(spv::AccessQualifier::ReadWrite));
+ types.emplace_back(new Pipe(spv::AccessQualifier::ReadOnly));
+ types.emplace_back(new ForwardPointer(1, spv::StorageClass::Input));
+ types.emplace_back(new ForwardPointer(2, spv::StorageClass::Input));
+ types.emplace_back(new ForwardPointer(2, spv::StorageClass::Uniform));
types.emplace_back(new PipeStorage());
types.emplace_back(new NamedBarrier());
diff --git a/test/reduce/reducer_test.cpp b/test/reduce/reducer_test.cpp
index 276aedc8f..019e14ec7 100644
--- a/test/reduce/reducer_test.cpp
+++ b/test/reduce/reducer_test.cpp
@@ -222,7 +222,7 @@ TEST(ReducerTest, ExprToConstantAndRemoveUnreferenced) {
}
bool InterestingWhileOpcodeExists(const std::vector<uint32_t>& binary,
- uint32_t opcode, uint32_t count, bool dump) {
+ spv::Op opcode, uint32_t count, bool dump) {
if (dump) {
std::stringstream ss;
ss << "temp_" << count << ".spv";
@@ -238,7 +238,7 @@ bool InterestingWhileOpcodeExists(const std::vector<uint32_t>& binary,
&*function.begin(),
[opcode, &interesting](opt::BasicBlock* block) -> void {
for (auto& inst : *block) {
- if (inst.opcode() == opcode) {
+ if (inst.opcode() == spv::Op(opcode)) {
interesting = true;
break;
}
@@ -253,12 +253,12 @@ bool InterestingWhileOpcodeExists(const std::vector<uint32_t>& binary,
bool InterestingWhileIMulReachable(const std::vector<uint32_t>& binary,
uint32_t count) {
- return InterestingWhileOpcodeExists(binary, SpvOpIMul, count, false);
+ return InterestingWhileOpcodeExists(binary, spv::Op::OpIMul, count, false);
}
bool InterestingWhileSDivReachable(const std::vector<uint32_t>& binary,
uint32_t count) {
- return InterestingWhileOpcodeExists(binary, SpvOpSDiv, count, false);
+ return InterestingWhileOpcodeExists(binary, spv::Op::OpSDiv, count, false);
}
// The shader below was derived from the following GLSL, and optimized.
diff --git a/test/reduce/validation_during_reduction_test.cpp b/test/reduce/validation_during_reduction_test.cpp
index 04a49234d..8cf14a3ce 100644
--- a/test/reduce/validation_during_reduction_test.cpp
+++ b/test/reduce/validation_during_reduction_test.cpp
@@ -67,7 +67,7 @@ class OpVariableDuplicatorReductionOpportunity : public ReductionOpportunity {
bool PreconditionHolds() override {
Instruction* first_instruction = &*function_->begin()[0].begin();
- return first_instruction->opcode() == SpvOpVariable;
+ return first_instruction->opcode() == spv::Op::OpVariable;
}
protected:
@@ -75,7 +75,7 @@ class OpVariableDuplicatorReductionOpportunity : public ReductionOpportunity {
// Duplicate the first OpVariable instruction.
Instruction* first_instruction = &*function_->begin()[0].begin();
- assert(first_instruction->opcode() == SpvOpVariable &&
+ assert(first_instruction->opcode() == spv::Op::OpVariable &&
"Expected first instruction to be OpVariable");
IRContext* context = first_instruction->context();
Instruction* cloned_instruction = first_instruction->Clone(context);
@@ -105,7 +105,7 @@ class OpVariableDuplicatorReductionOpportunityFinder
std::vector<std::unique_ptr<ReductionOpportunity>> result;
for (auto& function : *context->module()) {
Instruction* first_instruction = &*function.begin()[0].begin();
- if (first_instruction->opcode() == SpvOpVariable) {
+ if (first_instruction->opcode() == spv::Op::OpVariable) {
result.push_back(
MakeUnique<OpVariableDuplicatorReductionOpportunity>(&function));
}
diff --git a/test/text_to_binary.annotation_test.cpp b/test/text_to_binary.annotation_test.cpp
index 76776de94..826812bf2 100644
--- a/test/text_to_binary.annotation_test.cpp
+++ b/test/text_to_binary.annotation_test.cpp
@@ -41,7 +41,7 @@ using ::testing::ValuesIn;
using OpDecorateSimpleTest =
spvtest::TextToBinaryTestBase<::testing::TestWithParam<
- std::tuple<spv_target_env, EnumCase<SpvDecoration>>>>;
+ std::tuple<spv_target_env, EnumCase<spv::Decoration>>>>;
TEST_P(OpDecorateSimpleTest, AnySimpleDecoration) {
// This string should assemble, but should not validate.
@@ -51,7 +51,7 @@ TEST_P(OpDecorateSimpleTest, AnySimpleDecoration) {
input << " " << operand;
input << std::endl;
EXPECT_THAT(CompiledInstructions(input.str(), std::get<0>(GetParam())),
- Eq(MakeInstruction(SpvOpDecorate,
+ Eq(MakeInstruction(spv::Op::OpDecorate,
{1, uint32_t(std::get<1>(GetParam()).value())},
std::get<1>(GetParam()).operands())));
// Also check disassembly.
@@ -64,7 +64,7 @@ TEST_P(OpDecorateSimpleTest, AnySimpleDecoration) {
// Like above, but parameters to the decoration are IDs.
using OpDecorateSimpleIdTest =
spvtest::TextToBinaryTestBase<::testing::TestWithParam<
- std::tuple<spv_target_env, EnumCase<SpvDecoration>>>>;
+ std::tuple<spv_target_env, EnumCase<spv::Decoration>>>>;
TEST_P(OpDecorateSimpleIdTest, AnySimpleDecoration) {
// This string should assemble, but should not validate.
@@ -74,7 +74,7 @@ TEST_P(OpDecorateSimpleIdTest, AnySimpleDecoration) {
input << " %" << operand;
input << std::endl;
EXPECT_THAT(CompiledInstructions(input.str(), std::get<0>(GetParam())),
- Eq(MakeInstruction(SpvOpDecorateId,
+ Eq(MakeInstruction(spv::Op::OpDecorateId,
{1, uint32_t(std::get<1>(GetParam()).value())},
std::get<1>(GetParam()).operands())));
// Also check disassembly.
@@ -84,11 +84,11 @@ TEST_P(OpDecorateSimpleIdTest, AnySimpleDecoration) {
Eq(input.str()));
}
-#define CASE(NAME) SpvDecoration##NAME, #NAME
+#define CASE(NAME) spv::Decoration::NAME, #NAME
INSTANTIATE_TEST_SUITE_P(
TextToBinaryDecorateSimple, OpDecorateSimpleTest,
Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
- ValuesIn(std::vector<EnumCase<SpvDecoration>>{
+ ValuesIn(std::vector<EnumCase<spv::Decoration>>{
// The operand literal values are arbitrarily chosen,
// but there are the right number of them.
{CASE(RelaxedPrecision), {}},
@@ -134,23 +134,24 @@ INSTANTIATE_TEST_SUITE_P(
INSTANTIATE_TEST_SUITE_P(TextToBinaryDecorateSimpleV11, OpDecorateSimpleTest,
Combine(Values(SPV_ENV_UNIVERSAL_1_1),
- Values(EnumCase<SpvDecoration>{
+ Values(EnumCase<spv::Decoration>{
CASE(MaxByteOffset), {128}})));
-INSTANTIATE_TEST_SUITE_P(TextToBinaryDecorateSimpleV14, OpDecorateSimpleTest,
- Combine(Values(SPV_ENV_UNIVERSAL_1_4),
- ValuesIn(std::vector<EnumCase<SpvDecoration>>{
- {CASE(Uniform), {}},
- })));
-
-INSTANTIATE_TEST_SUITE_P(TextToBinaryDecorateSimpleIdV14,
- OpDecorateSimpleIdTest,
- Combine(Values(SPV_ENV_UNIVERSAL_1_4),
- ValuesIn(std::vector<EnumCase<SpvDecoration>>{
- // In 1.4, UniformId decoration takes a
- // scope Id.
- {CASE(UniformId), {1}},
- })));
+INSTANTIATE_TEST_SUITE_P(
+ TextToBinaryDecorateSimpleV14, OpDecorateSimpleTest,
+ Combine(Values(SPV_ENV_UNIVERSAL_1_4),
+ ValuesIn(std::vector<EnumCase<spv::Decoration>>{
+ {CASE(Uniform), {}},
+ })));
+
+INSTANTIATE_TEST_SUITE_P(
+ TextToBinaryDecorateSimpleIdV14, OpDecorateSimpleIdTest,
+ Combine(Values(SPV_ENV_UNIVERSAL_1_4),
+ ValuesIn(std::vector<EnumCase<spv::Decoration>>{
+ // In 1.4, UniformId decoration takes a
+ // scope Id.
+ {CASE(UniformId), {1}},
+ })));
#undef CASE
TEST_F(OpDecorateSimpleTest, WrongDecoration) {
@@ -195,14 +196,14 @@ TEST_P(OpDecorateEnumTest, AnyEnumDecoration) {
const std::string input =
"OpDecorate %1 " + GetParam().enum_name + " " + GetParam().name;
EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpDecorate, {1, GetParam().enum_value,
- GetParam().value})));
+ Eq(MakeInstruction(spv::Op::OpDecorate, {1, GetParam().enum_value,
+ GetParam().value})));
}
// Test OpDecorate BuiltIn.
// clang-format off
#define CASE(NAME) \
- { SpvBuiltIn##NAME, #NAME, SpvDecorationBuiltIn, "BuiltIn" }
+ { uint32_t(spv::BuiltIn::NAME), #NAME, uint32_t(spv::Decoration::BuiltIn), "BuiltIn" }
INSTANTIATE_TEST_SUITE_P(TextToBinaryDecorateBuiltIn, OpDecorateEnumTest,
::testing::ValuesIn(std::vector<DecorateEnumCase>{
CASE(Position),
@@ -260,7 +261,7 @@ TEST_F(OpDecorateEnumTest, WrongBuiltIn) {
// Test OpDecorate FuncParamAttr
// clang-format off
#define CASE(NAME) \
- { SpvFunctionParameterAttribute##NAME, #NAME, SpvDecorationFuncParamAttr, "FuncParamAttr" }
+ { uint32_t(spv::FunctionParameterAttribute::NAME), #NAME, uint32_t(spv::Decoration::FuncParamAttr), "FuncParamAttr" }
INSTANTIATE_TEST_SUITE_P(TextToBinaryDecorateFuncParamAttr, OpDecorateEnumTest,
::testing::ValuesIn(std::vector<DecorateEnumCase>{
CASE(Zext),
@@ -283,7 +284,7 @@ TEST_F(OpDecorateEnumTest, WrongFuncParamAttr) {
// Test OpDecorate FPRoundingMode
// clang-format off
#define CASE(NAME) \
- { SpvFPRoundingMode##NAME, #NAME, SpvDecorationFPRoundingMode, "FPRoundingMode" }
+ { uint32_t(spv::FPRoundingMode::NAME), #NAME, uint32_t(spv::Decoration::FPRoundingMode), "FPRoundingMode" }
INSTANTIATE_TEST_SUITE_P(TextToBinaryDecorateFPRoundingMode, OpDecorateEnumTest,
::testing::ValuesIn(std::vector<DecorateEnumCase>{
CASE(RTE),
@@ -306,15 +307,15 @@ TEST_F(OpDecorateEnumTest, WrongFPRoundingMode) {
// clang-format off
#define CASE(ENUM,NAME) \
- { SpvFPFastMathMode##ENUM, #NAME, SpvDecorationFPFastMathMode, "FPFastMathMode" }
+ { uint32_t(spv::FPFastMathModeMask::ENUM), #NAME, uint32_t(spv::Decoration::FPFastMathMode), "FPFastMathMode" }
INSTANTIATE_TEST_SUITE_P(TextToBinaryDecorateFPFastMathMode, OpDecorateEnumTest,
::testing::ValuesIn(std::vector<DecorateEnumCase>{
CASE(MaskNone, None),
- CASE(NotNaNMask, NotNaN),
- CASE(NotInfMask, NotInf),
- CASE(NSZMask, NSZ),
- CASE(AllowRecipMask, AllowRecip),
- CASE(FastMask, Fast),
+ CASE(NotNaN, NotNaN),
+ CASE(NotInf, NotInf),
+ CASE(NSZ, NSZ),
+ CASE(AllowRecip, AllowRecip),
+ CASE(Fast, Fast),
}));
#undef CASE
// clang-format on
@@ -323,13 +324,13 @@ TEST_F(OpDecorateEnumTest, CombinedFPFastMathMask) {
// Sample a single combination. This ensures we've integrated
// the instruction parsing logic with spvTextParseMask.
const std::string input = "OpDecorate %1 FPFastMathMode NotNaN|NotInf|NSZ";
- const uint32_t expected_enum = SpvDecorationFPFastMathMode;
- const uint32_t expected_mask = SpvFPFastMathModeNotNaNMask |
- SpvFPFastMathModeNotInfMask |
- SpvFPFastMathModeNSZMask;
- EXPECT_THAT(
- CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpDecorate, {1, expected_enum, expected_mask})));
+ const uint32_t expected_enum = uint32_t(spv::Decoration::FPFastMathMode);
+ const uint32_t expected_mask = uint32_t(spv::FPFastMathModeMask::NotNaN) |
+ uint32_t(spv::FPFastMathModeMask::NotInf) |
+ uint32_t(spv::FPFastMathModeMask::NSZ);
+ EXPECT_THAT(CompiledInstructions(input),
+ Eq(MakeInstruction(spv::Op::OpDecorate,
+ {1, expected_enum, expected_mask})));
}
TEST_F(OpDecorateEnumTest, WrongFPFastMathMode) {
@@ -355,7 +356,8 @@ TEST_P(OpDecorateLinkageTest, AnyLinkageDecoration) {
const std::string input = "OpDecorate %1 LinkageAttributes \"" +
GetParam().external_name + "\" " +
GetParam().linkage_type_name;
- std::vector<uint32_t> expected_operands{1, SpvDecorationLinkageAttributes};
+ std::vector<uint32_t> expected_operands{
+ 1, uint32_t(spv::Decoration::LinkageAttributes)};
std::vector<uint32_t> encoded_external_name =
MakeVector(GetParam().external_name);
expected_operands.insert(expected_operands.end(),
@@ -363,11 +365,11 @@ TEST_P(OpDecorateLinkageTest, AnyLinkageDecoration) {
encoded_external_name.end());
expected_operands.push_back(GetParam().linkage_type_value);
EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpDecorate, expected_operands)));
+ Eq(MakeInstruction(spv::Op::OpDecorate, expected_operands)));
}
// clang-format off
-#define CASE(ENUM) SpvLinkageType##ENUM, #ENUM
+#define CASE(ENUM) uint32_t(spv::LinkageType::ENUM), #ENUM
INSTANTIATE_TEST_SUITE_P(TextToBinaryDecorateLinkage, OpDecorateLinkageTest,
::testing::ValuesIn(std::vector<DecorateLinkageCase>{
{ CASE(Import), "a" },
@@ -387,13 +389,13 @@ TEST_F(OpDecorateLinkageTest, WrongType) {
TEST_F(TextToBinaryTest, GroupMemberDecorateGoodOneTarget) {
EXPECT_THAT(CompiledInstructions("OpGroupMemberDecorate %group %id0 42"),
- Eq(MakeInstruction(SpvOpGroupMemberDecorate, {1, 2, 42})));
+ Eq(MakeInstruction(spv::Op::OpGroupMemberDecorate, {1, 2, 42})));
}
TEST_F(TextToBinaryTest, GroupMemberDecorateGoodTwoTargets) {
EXPECT_THAT(
CompiledInstructions("OpGroupMemberDecorate %group %id0 96 %id1 42"),
- Eq(MakeInstruction(SpvOpGroupMemberDecorate, {1, 2, 96, 3, 42})));
+ Eq(MakeInstruction(spv::Op::OpGroupMemberDecorate, {1, 2, 96, 3, 42})));
}
TEST_F(TextToBinaryTest, GroupMemberDecorateMissingGroupId) {
@@ -443,7 +445,7 @@ TEST_F(TextToBinaryTest, GroupMemberDecorateInvalidSecondTargetMemberNumber) {
using OpMemberDecorateSimpleTest =
spvtest::TextToBinaryTestBase<::testing::TestWithParam<
- std::tuple<spv_target_env, EnumCase<SpvDecoration>>>>;
+ std::tuple<spv_target_env, EnumCase<spv::Decoration>>>>;
TEST_P(OpMemberDecorateSimpleTest, AnySimpleDecoration) {
// This string should assemble, but should not validate.
@@ -454,7 +456,7 @@ TEST_P(OpMemberDecorateSimpleTest, AnySimpleDecoration) {
input << std::endl;
EXPECT_THAT(
CompiledInstructions(input.str(), std::get<0>(GetParam())),
- Eq(MakeInstruction(SpvOpMemberDecorate,
+ Eq(MakeInstruction(spv::Op::OpMemberDecorate,
{1, 42, uint32_t(std::get<1>(GetParam()).value())},
std::get<1>(GetParam()).operands())));
// Also check disassembly.
@@ -464,11 +466,11 @@ TEST_P(OpMemberDecorateSimpleTest, AnySimpleDecoration) {
Eq(input.str()));
}
-#define CASE(NAME) SpvDecoration##NAME, #NAME
+#define CASE(NAME) spv::Decoration::NAME, #NAME
INSTANTIATE_TEST_SUITE_P(
TextToBinaryDecorateSimple, OpMemberDecorateSimpleTest,
Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
- ValuesIn(std::vector<EnumCase<SpvDecoration>>{
+ ValuesIn(std::vector<EnumCase<spv::Decoration>>{
// The operand literal values are arbitrarily chosen,
// but there are the right number of them.
{CASE(RelaxedPrecision), {}},
@@ -515,7 +517,7 @@ INSTANTIATE_TEST_SUITE_P(
INSTANTIATE_TEST_SUITE_P(
TextToBinaryDecorateSimpleV11, OpMemberDecorateSimpleTest,
Combine(Values(SPV_ENV_UNIVERSAL_1_1),
- Values(EnumCase<SpvDecoration>{CASE(MaxByteOffset), {128}})));
+ Values(EnumCase<spv::Decoration>{CASE(MaxByteOffset), {128}})));
#undef CASE
TEST_F(OpMemberDecorateSimpleTest, WrongDecoration) {
diff --git a/test/text_to_binary.barrier_test.cpp b/test/text_to_binary.barrier_test.cpp
index f1cb4fbe3..380cacb31 100644
--- a/test/text_to_binary.barrier_test.cpp
+++ b/test/text_to_binary.barrier_test.cpp
@@ -37,7 +37,7 @@ using OpMemoryBarrier = spvtest::TextToBinaryTest;
TEST_F(OpMemoryBarrier, Good) {
const std::string input = "OpMemoryBarrier %1 %2\n";
EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpMemoryBarrier, {1, 2})));
+ Eq(MakeInstruction(spv::Op::OpMemoryBarrier, {1, 2})));
EXPECT_THAT(EncodeAndDecodeSuccessfully(input), Eq(input));
}
@@ -89,7 +89,7 @@ TEST_F(NamedMemoryBarrierTest, OpcodeAssemblesInV10) {
EXPECT_THAT(
CompiledInstructions("OpMemoryNamedBarrier %bar %scope %semantics",
SPV_ENV_UNIVERSAL_1_0),
- ElementsAre(spvOpcodeMake(4, SpvOpMemoryNamedBarrier), _, _, _));
+ ElementsAre(spvOpcodeMake(4, spv::Op::OpMemoryNamedBarrier), _, _, _));
}
TEST_F(NamedMemoryBarrierTest, ArgumentCount) {
@@ -107,7 +107,7 @@ TEST_F(NamedMemoryBarrierTest, ArgumentCount) {
EXPECT_THAT(
CompiledInstructions("OpMemoryNamedBarrier %bar %scope %semantics",
SPV_ENV_UNIVERSAL_1_1),
- ElementsAre(spvOpcodeMake(4, SpvOpMemoryNamedBarrier), _, _, _));
+ ElementsAre(spvOpcodeMake(4, spv::Op::OpMemoryNamedBarrier), _, _, _));
EXPECT_THAT(
CompileFailure("OpMemoryNamedBarrier %bar %scope %semantics %extra",
SPV_ENV_UNIVERSAL_1_1),
@@ -128,7 +128,7 @@ using TypeNamedBarrierTest = spvtest::TextToBinaryTest;
TEST_F(TypeNamedBarrierTest, OpcodeAssemblesInV10) {
EXPECT_THAT(
CompiledInstructions("%t = OpTypeNamedBarrier", SPV_ENV_UNIVERSAL_1_0),
- ElementsAre(spvOpcodeMake(2, SpvOpTypeNamedBarrier), _));
+ ElementsAre(spvOpcodeMake(2, spv::Op::OpTypeNamedBarrier), _));
}
TEST_F(TypeNamedBarrierTest, ArgumentCount) {
@@ -137,7 +137,7 @@ TEST_F(TypeNamedBarrierTest, ArgumentCount) {
"found 'OpTypeNamedBarrier'."));
EXPECT_THAT(
CompiledInstructions("%t = OpTypeNamedBarrier", SPV_ENV_UNIVERSAL_1_1),
- ElementsAre(spvOpcodeMake(2, SpvOpTypeNamedBarrier), _));
+ ElementsAre(spvOpcodeMake(2, spv::Op::OpTypeNamedBarrier), _));
EXPECT_THAT(
CompileFailure("%t = OpTypeNamedBarrier 1 2 3", SPV_ENV_UNIVERSAL_1_1),
Eq("Expected <opcode> or <result-id> at the beginning of an instruction, "
@@ -150,7 +150,8 @@ TEST_F(NamedBarrierInitializeTest, OpcodeAssemblesInV10) {
EXPECT_THAT(
CompiledInstructions("%bar = OpNamedBarrierInitialize %type %count",
SPV_ENV_UNIVERSAL_1_0),
- ElementsAre(spvOpcodeMake(4, SpvOpNamedBarrierInitialize), _, _, _));
+ ElementsAre(spvOpcodeMake(4, spv::Op::OpNamedBarrierInitialize), _, _,
+ _));
}
TEST_F(NamedBarrierInitializeTest, ArgumentCount) {
@@ -165,7 +166,8 @@ TEST_F(NamedBarrierInitializeTest, ArgumentCount) {
EXPECT_THAT(
CompiledInstructions("%bar = OpNamedBarrierInitialize %type %count",
SPV_ENV_UNIVERSAL_1_1),
- ElementsAre(spvOpcodeMake(4, SpvOpNamedBarrierInitialize), _, _, _));
+ ElementsAre(spvOpcodeMake(4, spv::Op::OpNamedBarrierInitialize), _, _,
+ _));
EXPECT_THAT(
CompileFailure("%bar = OpNamedBarrierInitialize %type %count \"extra\"",
SPV_ENV_UNIVERSAL_1_1),
diff --git a/test/text_to_binary.constant_test.cpp b/test/text_to_binary.constant_test.cpp
index 7ab4ca513..bc5cd0647 100644
--- a/test/text_to_binary.constant_test.cpp
+++ b/test/text_to_binary.constant_test.cpp
@@ -35,21 +35,21 @@ using ::testing::Eq;
// Test Sampler Addressing Mode enum values
using SamplerAddressingModeTest = spvtest::TextToBinaryTestBase<
- ::testing::TestWithParam<EnumCase<SpvSamplerAddressingMode>>>;
+ ::testing::TestWithParam<EnumCase<spv::SamplerAddressingMode>>>;
TEST_P(SamplerAddressingModeTest, AnySamplerAddressingMode) {
const std::string input =
"%result = OpConstantSampler %type " + GetParam().name() + " 0 Nearest";
EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpConstantSampler,
- {1, 2, GetParam().value(), 0, 0})));
+ Eq(MakeInstruction(spv::Op::OpConstantSampler,
+ {1, 2, uint32_t(GetParam().value()), 0, 0})));
}
// clang-format off
-#define CASE(NAME) { SpvSamplerAddressingMode##NAME, #NAME }
+#define CASE(NAME) { spv::SamplerAddressingMode::NAME, #NAME }
INSTANTIATE_TEST_SUITE_P(
TextToBinarySamplerAddressingMode, SamplerAddressingModeTest,
- ::testing::ValuesIn(std::vector<EnumCase<SpvSamplerAddressingMode>>{
+ ::testing::ValuesIn(std::vector<EnumCase<spv::SamplerAddressingMode>>{
CASE(None),
CASE(ClampToEdge),
CASE(Clamp),
@@ -67,21 +67,21 @@ TEST_F(SamplerAddressingModeTest, WrongMode) {
// Test Sampler Filter Mode enum values
using SamplerFilterModeTest = spvtest::TextToBinaryTestBase<
- ::testing::TestWithParam<EnumCase<SpvSamplerFilterMode>>>;
+ ::testing::TestWithParam<EnumCase<spv::SamplerFilterMode>>>;
TEST_P(SamplerFilterModeTest, AnySamplerFilterMode) {
const std::string input =
"%result = OpConstantSampler %type Clamp 0 " + GetParam().name();
EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpConstantSampler,
- {1, 2, 2, 0, GetParam().value()})));
+ Eq(MakeInstruction(spv::Op::OpConstantSampler,
+ {1, 2, 2, 0, uint32_t(GetParam().value())})));
}
// clang-format off
-#define CASE(NAME) { SpvSamplerFilterMode##NAME, #NAME}
+#define CASE(NAME) { spv::SamplerFilterMode::NAME, #NAME}
INSTANTIATE_TEST_SUITE_P(
TextToBinarySamplerFilterMode, SamplerFilterModeTest,
- ::testing::ValuesIn(std::vector<EnumCase<SpvSamplerFilterMode>>{
+ ::testing::ValuesIn(std::vector<EnumCase<spv::SamplerFilterMode>>{
CASE(Nearest),
CASE(Linear),
}));
@@ -119,119 +119,119 @@ INSTANTIATE_TEST_SUITE_P(
::testing::ValuesIn(std::vector<ConstantTestCase>{
// Check 16 bits
{"OpTypeInt 16 0", "0x1234",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 16, 0}),
- MakeInstruction(SpvOpConstant, {1, 2, 0x1234})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 16, 0}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 0x1234})})},
{"OpTypeInt 16 0", "0x8000",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 16, 0}),
- MakeInstruction(SpvOpConstant, {1, 2, 0x8000})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 16, 0}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 0x8000})})},
{"OpTypeInt 16 0", "0",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 16, 0}),
- MakeInstruction(SpvOpConstant, {1, 2, 0})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 16, 0}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 0})})},
{"OpTypeInt 16 0", "65535",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 16, 0}),
- MakeInstruction(SpvOpConstant, {1, 2, 65535})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 16, 0}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 65535})})},
{"OpTypeInt 16 0", "0xffff",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 16, 0}),
- MakeInstruction(SpvOpConstant, {1, 2, 65535})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 16, 0}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 65535})})},
{"OpTypeInt 16 1", "0x8000", // Test sign extension.
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 16, 1}),
- MakeInstruction(SpvOpConstant, {1, 2, 0xffff8000})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 16, 1}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 0xffff8000})})},
{"OpTypeInt 16 1", "-32",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 16, 1}),
- MakeInstruction(SpvOpConstant, {1, 2, uint32_t(-32)})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 16, 1}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, uint32_t(-32)})})},
{"OpTypeInt 16 1", "0",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 16, 1}),
- MakeInstruction(SpvOpConstant, {1, 2, 0})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 16, 1}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 0})})},
{"OpTypeInt 16 1", "-0",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 16, 1}),
- MakeInstruction(SpvOpConstant, {1, 2, 0})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 16, 1}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 0})})},
{"OpTypeInt 16 1", "-0x0",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 16, 1}),
- MakeInstruction(SpvOpConstant, {1, 2, 0})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 16, 1}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 0})})},
{"OpTypeInt 16 1", "-32768",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 16, 1}),
- MakeInstruction(SpvOpConstant, {1, 2, uint32_t(-32768)})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 16, 1}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, uint32_t(-32768)})})},
// Check 32 bits
{"OpTypeInt 32 0", "42",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 32, 0}),
- MakeInstruction(SpvOpConstant, {1, 2, 42})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 32, 0}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 42})})},
{"OpTypeInt 32 1", "-32",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 32, 1}),
- MakeInstruction(SpvOpConstant, {1, 2, uint32_t(-32)})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 32, 1}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, uint32_t(-32)})})},
{"OpTypeInt 32 1", "0",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 32, 1}),
- MakeInstruction(SpvOpConstant, {1, 2, 0})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 32, 1}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 0})})},
{"OpTypeInt 32 1", "-0",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 32, 1}),
- MakeInstruction(SpvOpConstant, {1, 2, 0})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 32, 1}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 0})})},
{"OpTypeInt 32 1", "-0x0",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 32, 1}),
- MakeInstruction(SpvOpConstant, {1, 2, 0})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 32, 1}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 0})})},
{"OpTypeInt 32 1", "-0x001",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 32, 1}),
- MakeInstruction(SpvOpConstant, {1, 2, uint32_t(-1)})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 32, 1}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, uint32_t(-1)})})},
{"OpTypeInt 32 1", "2147483647",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 32, 1}),
- MakeInstruction(SpvOpConstant, {1, 2, 0x7fffffffu})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 32, 1}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 0x7fffffffu})})},
{"OpTypeInt 32 1", "-2147483648",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 32, 1}),
- MakeInstruction(SpvOpConstant, {1, 2, 0x80000000u})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 32, 1}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 0x80000000u})})},
{"OpTypeFloat 32", "1.0",
- Concatenate({MakeInstruction(SpvOpTypeFloat, {1, 32}),
- MakeInstruction(SpvOpConstant, {1, 2, 0x3f800000})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeFloat, {1, 32}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 0x3f800000})})},
{"OpTypeFloat 32", "10.0",
- Concatenate({MakeInstruction(SpvOpTypeFloat, {1, 32}),
- MakeInstruction(SpvOpConstant, {1, 2, 0x41200000})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeFloat, {1, 32}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 0x41200000})})},
{"OpTypeFloat 32", "-0x1p+128", // -infinity
- Concatenate({MakeInstruction(SpvOpTypeFloat, {1, 32}),
- MakeInstruction(SpvOpConstant, {1, 2, 0xFF800000})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeFloat, {1, 32}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 0xFF800000})})},
{"OpTypeFloat 32", "0x1p+128", // +infinity
- Concatenate({MakeInstruction(SpvOpTypeFloat, {1, 32}),
- MakeInstruction(SpvOpConstant, {1, 2, 0x7F800000})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeFloat, {1, 32}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 0x7F800000})})},
{"OpTypeFloat 32", "-0x1.8p+128", // A -NaN
- Concatenate({MakeInstruction(SpvOpTypeFloat, {1, 32}),
- MakeInstruction(SpvOpConstant, {1, 2, 0xFFC00000})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeFloat, {1, 32}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 0xFFC00000})})},
{"OpTypeFloat 32", "-0x1.0002p+128", // A +NaN
- Concatenate({MakeInstruction(SpvOpTypeFloat, {1, 32}),
- MakeInstruction(SpvOpConstant, {1, 2, 0xFF800100})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeFloat, {1, 32}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 0xFF800100})})},
// Check 48 bits
{"OpTypeInt 48 0", "0x1234",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 48, 0}),
- MakeInstruction(SpvOpConstant, {1, 2, 0x1234, 0})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 48, 0}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 0x1234, 0})})},
{"OpTypeInt 48 0", "0x800000000001",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 48, 0}),
- MakeInstruction(SpvOpConstant, {1, 2, 1, 0x00008000})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 48, 0}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 1, 0x00008000})})},
{"OpTypeInt 48 1", "0x800000000000", // Test sign extension.
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 48, 1}),
- MakeInstruction(SpvOpConstant, {1, 2, 0, 0xffff8000})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 48, 1}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 0, 0xffff8000})})},
{"OpTypeInt 48 1", "-32",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 48, 1}),
- MakeInstruction(SpvOpConstant, {1, 2, uint32_t(-32), uint32_t(-1)})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 48, 1}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, uint32_t(-32), uint32_t(-1)})})},
// Check 64 bits
{"OpTypeInt 64 0", "0x1234",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 64, 0}),
- MakeInstruction(SpvOpConstant, {1, 2, 0x1234, 0})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 64, 0}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 0x1234, 0})})},
{"OpTypeInt 64 0", "18446744073709551615",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 64, 0}),
- MakeInstruction(SpvOpConstant, {1, 2, 0xffffffffu, 0xffffffffu})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 64, 0}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 0xffffffffu, 0xffffffffu})})},
{"OpTypeInt 64 0", "0xffffffffffffffff",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 64, 0}),
- MakeInstruction(SpvOpConstant, {1, 2, 0xffffffffu, 0xffffffffu})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 64, 0}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 0xffffffffu, 0xffffffffu})})},
{"OpTypeInt 64 1", "0x1234",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 64, 1}),
- MakeInstruction(SpvOpConstant, {1, 2, 0x1234, 0})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 64, 1}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 0x1234, 0})})},
{"OpTypeInt 64 1", "-42",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 64, 1}),
- MakeInstruction(SpvOpConstant, {1, 2, uint32_t(-42), uint32_t(-1)})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 64, 1}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, uint32_t(-42), uint32_t(-1)})})},
{"OpTypeInt 64 1", "-0x01",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 64, 1}),
- MakeInstruction(SpvOpConstant, {1, 2, 0xffffffffu, 0xffffffffu})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 64, 1}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 0xffffffffu, 0xffffffffu})})},
{"OpTypeInt 64 1", "9223372036854775807",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 64, 1}),
- MakeInstruction(SpvOpConstant, {1, 2, 0xffffffffu, 0x7fffffffu})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 64, 1}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 0xffffffffu, 0x7fffffffu})})},
{"OpTypeInt 64 1", "0x7fffffff",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 64, 1}),
- MakeInstruction(SpvOpConstant, {1, 2, 0x7fffffffu, 0})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 64, 1}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 0x7fffffffu, 0})})},
}));
// clang-format on
@@ -388,53 +388,53 @@ INSTANTIATE_TEST_SUITE_P(
::testing::ValuesIn(std::vector<ConstantTestCase>{
// Check 16 bits
{"OpTypeInt 16 0", "0x1234",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 16, 0}),
- MakeInstruction(SpvOpSpecConstant, {1, 2, 0x1234})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 16, 0}),
+ MakeInstruction(spv::Op::OpSpecConstant, {1, 2, 0x1234})})},
{"OpTypeInt 16 0", "0x8000",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 16, 0}),
- MakeInstruction(SpvOpSpecConstant, {1, 2, 0x8000})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 16, 0}),
+ MakeInstruction(spv::Op::OpSpecConstant, {1, 2, 0x8000})})},
{"OpTypeInt 16 1", "0x8000", // Test sign extension.
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 16, 1}),
- MakeInstruction(SpvOpSpecConstant, {1, 2, 0xffff8000})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 16, 1}),
+ MakeInstruction(spv::Op::OpSpecConstant, {1, 2, 0xffff8000})})},
{"OpTypeInt 16 1", "-32",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 16, 1}),
- MakeInstruction(SpvOpSpecConstant, {1, 2, uint32_t(-32)})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 16, 1}),
+ MakeInstruction(spv::Op::OpSpecConstant, {1, 2, uint32_t(-32)})})},
// Check 32 bits
{"OpTypeInt 32 0", "42",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 32, 0}),
- MakeInstruction(SpvOpSpecConstant, {1, 2, 42})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 32, 0}),
+ MakeInstruction(spv::Op::OpSpecConstant, {1, 2, 42})})},
{"OpTypeInt 32 1", "-32",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 32, 1}),
- MakeInstruction(SpvOpSpecConstant, {1, 2, uint32_t(-32)})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 32, 1}),
+ MakeInstruction(spv::Op::OpSpecConstant, {1, 2, uint32_t(-32)})})},
{"OpTypeFloat 32", "1.0",
- Concatenate({MakeInstruction(SpvOpTypeFloat, {1, 32}),
- MakeInstruction(SpvOpSpecConstant, {1, 2, 0x3f800000})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeFloat, {1, 32}),
+ MakeInstruction(spv::Op::OpSpecConstant, {1, 2, 0x3f800000})})},
{"OpTypeFloat 32", "10.0",
- Concatenate({MakeInstruction(SpvOpTypeFloat, {1, 32}),
- MakeInstruction(SpvOpSpecConstant, {1, 2, 0x41200000})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeFloat, {1, 32}),
+ MakeInstruction(spv::Op::OpSpecConstant, {1, 2, 0x41200000})})},
// Check 48 bits
{"OpTypeInt 48 0", "0x1234",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 48, 0}),
- MakeInstruction(SpvOpSpecConstant, {1, 2, 0x1234, 0})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 48, 0}),
+ MakeInstruction(spv::Op::OpSpecConstant, {1, 2, 0x1234, 0})})},
{"OpTypeInt 48 0", "0x800000000001",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 48, 0}),
- MakeInstruction(SpvOpSpecConstant, {1, 2, 1, 0x00008000})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 48, 0}),
+ MakeInstruction(spv::Op::OpSpecConstant, {1, 2, 1, 0x00008000})})},
{"OpTypeInt 48 1", "0x800000000000", // Test sign extension.
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 48, 1}),
- MakeInstruction(SpvOpSpecConstant, {1, 2, 0, 0xffff8000})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 48, 1}),
+ MakeInstruction(spv::Op::OpSpecConstant, {1, 2, 0, 0xffff8000})})},
{"OpTypeInt 48 1", "-32",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 48, 1}),
- MakeInstruction(SpvOpSpecConstant, {1, 2, uint32_t(-32), uint32_t(-1)})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 48, 1}),
+ MakeInstruction(spv::Op::OpSpecConstant, {1, 2, uint32_t(-32), uint32_t(-1)})})},
// Check 64 bits
{"OpTypeInt 64 0", "0x1234",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 64, 0}),
- MakeInstruction(SpvOpSpecConstant, {1, 2, 0x1234, 0})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 64, 0}),
+ MakeInstruction(spv::Op::OpSpecConstant, {1, 2, 0x1234, 0})})},
{"OpTypeInt 64 1", "0x1234",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 64, 1}),
- MakeInstruction(SpvOpSpecConstant, {1, 2, 0x1234, 0})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 64, 1}),
+ MakeInstruction(spv::Op::OpSpecConstant, {1, 2, 0x1234, 0})})},
{"OpTypeInt 64 1", "-42",
- Concatenate({MakeInstruction(SpvOpTypeInt, {1, 64, 1}),
- MakeInstruction(SpvOpSpecConstant, {1, 2, uint32_t(-42), uint32_t(-1)})})},
+ Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 64, 1}),
+ MakeInstruction(spv::Op::OpSpecConstant, {1, 2, uint32_t(-42), uint32_t(-1)})})},
}));
// clang-format on
@@ -648,7 +648,7 @@ INSTANTIATE_TEST_SUITE_P(
// Test OpSpecConstantOp
using OpSpecConstantOpTestWithIds =
- spvtest::TextToBinaryTestBase<::testing::TestWithParam<EnumCase<SpvOp>>>;
+ spvtest::TextToBinaryTestBase<::testing::TestWithParam<EnumCase<spv::Op>>>;
// The operands to the OpSpecConstantOp opcode are all Ids.
TEST_P(OpSpecConstantOpTestWithIds, Assembly) {
@@ -658,7 +658,7 @@ TEST_P(OpSpecConstantOpTestWithIds, Assembly) {
input << "\n";
EXPECT_THAT(CompiledInstructions(input.str()),
- Eq(MakeInstruction(SpvOpSpecConstantOp,
+ Eq(MakeInstruction(spv::Op::OpSpecConstantOp,
{1, 2, uint32_t(GetParam().value())},
GetParam().operands())));
@@ -667,15 +667,15 @@ TEST_P(OpSpecConstantOpTestWithIds, Assembly) {
}
// clang-format off
-#define CASE1(NAME) { SpvOp##NAME, #NAME, {3} }
-#define CASE2(NAME) { SpvOp##NAME, #NAME, {3, 4} }
-#define CASE3(NAME) { SpvOp##NAME, #NAME, {3, 4, 5} }
-#define CASE4(NAME) { SpvOp##NAME, #NAME, {3, 4, 5, 6} }
-#define CASE5(NAME) { SpvOp##NAME, #NAME, {3, 4, 5, 6, 7} }
-#define CASE6(NAME) { SpvOp##NAME, #NAME, {3, 4, 5, 6, 7, 8} }
+#define CASE1(NAME) { spv::Op::Op##NAME, #NAME, {3} }
+#define CASE2(NAME) { spv::Op::Op##NAME, #NAME, {3, 4} }
+#define CASE3(NAME) { spv::Op::Op##NAME, #NAME, {3, 4, 5} }
+#define CASE4(NAME) { spv::Op::Op##NAME, #NAME, {3, 4, 5, 6} }
+#define CASE5(NAME) { spv::Op::Op##NAME, #NAME, {3, 4, 5, 6, 7} }
+#define CASE6(NAME) { spv::Op::Op##NAME, #NAME, {3, 4, 5, 6, 7, 8} }
INSTANTIATE_TEST_SUITE_P(
TextToBinaryOpSpecConstantOp, OpSpecConstantOpTestWithIds,
- ::testing::ValuesIn(std::vector<EnumCase<SpvOp>>{
+ ::testing::ValuesIn(std::vector<EnumCase<spv::Op>>{
// Conversion
CASE1(SConvert),
CASE1(FConvert),
@@ -759,7 +759,7 @@ INSTANTIATE_TEST_SUITE_P(
// clang-format on
using OpSpecConstantOpTestWithTwoIdsThenLiteralNumbers =
- spvtest::TextToBinaryTestBase<::testing::TestWithParam<EnumCase<SpvOp>>>;
+ spvtest::TextToBinaryTestBase<::testing::TestWithParam<EnumCase<spv::Op>>>;
// The operands to the OpSpecConstantOp opcode are two Ids followed by a
// sequence of literal numbers.
@@ -770,7 +770,7 @@ TEST_P(OpSpecConstantOpTestWithTwoIdsThenLiteralNumbers, Assembly) {
input << "\n";
EXPECT_THAT(CompiledInstructions(input.str()),
- Eq(MakeInstruction(SpvOpSpecConstantOp,
+ Eq(MakeInstruction(spv::Op::OpSpecConstantOp,
{1, 2, uint32_t(GetParam().value()), 3, 4},
GetParam().operands())));
@@ -778,11 +778,11 @@ TEST_P(OpSpecConstantOpTestWithTwoIdsThenLiteralNumbers, Assembly) {
EXPECT_THAT(EncodeAndDecodeSuccessfully(input.str()), input.str());
}
-#define CASE(NAME) SpvOp##NAME, #NAME
+#define CASE(NAME) spv::Op::Op##NAME, #NAME
INSTANTIATE_TEST_SUITE_P(
TextToBinaryOpSpecConstantOp,
OpSpecConstantOpTestWithTwoIdsThenLiteralNumbers,
- ::testing::ValuesIn(std::vector<EnumCase<SpvOp>>{
+ ::testing::ValuesIn(std::vector<EnumCase<spv::Op>>{
// For VectorShuffle, there are two vector operands, and at least
// two selector Ids. OpenCL can have up to 16-element vectors.
{CASE(VectorShuffle), {0, 0}},
@@ -797,7 +797,7 @@ INSTANTIATE_TEST_SUITE_P(
}));
using OpSpecConstantOpTestWithOneIdThenLiteralNumbers =
- spvtest::TextToBinaryTestBase<::testing::TestWithParam<EnumCase<SpvOp>>>;
+ spvtest::TextToBinaryTestBase<::testing::TestWithParam<EnumCase<spv::Op>>>;
// The operands to the OpSpecConstantOp opcode are one Id followed by a
// sequence of literal numbers.
@@ -808,7 +808,7 @@ TEST_P(OpSpecConstantOpTestWithOneIdThenLiteralNumbers, Assembly) {
input << "\n";
EXPECT_THAT(CompiledInstructions(input.str()),
- Eq(MakeInstruction(SpvOpSpecConstantOp,
+ Eq(MakeInstruction(spv::Op::OpSpecConstantOp,
{1, 2, uint32_t(GetParam().value()), 3},
GetParam().operands())));
@@ -816,11 +816,11 @@ TEST_P(OpSpecConstantOpTestWithOneIdThenLiteralNumbers, Assembly) {
EXPECT_THAT(EncodeAndDecodeSuccessfully(input.str()), input.str());
}
-#define CASE(NAME) SpvOp##NAME, #NAME
+#define CASE(NAME) spv::Op::Op##NAME, #NAME
INSTANTIATE_TEST_SUITE_P(
TextToBinaryOpSpecConstantOp,
OpSpecConstantOpTestWithOneIdThenLiteralNumbers,
- ::testing::ValuesIn(std::vector<EnumCase<SpvOp>>{
+ ::testing::ValuesIn(std::vector<EnumCase<spv::Op>>{
// For CompositeExtract, the universal limit permits up to 255 literal
// indices. Let's only test a few.
{CASE(CompositeExtract), {0}},
diff --git a/test/text_to_binary.control_flow_test.cpp b/test/text_to_binary.control_flow_test.cpp
index 472cb6dac..bc64aa3f6 100644
--- a/test/text_to_binary.control_flow_test.cpp
+++ b/test/text_to_binary.control_flow_test.cpp
@@ -40,22 +40,22 @@ using ::testing::ValuesIn;
// Test OpSelectionMerge
using OpSelectionMergeTest = spvtest::TextToBinaryTestBase<
- TestWithParam<EnumCase<SpvSelectionControlMask>>>;
+ TestWithParam<EnumCase<spv::SelectionControlMask>>>;
TEST_P(OpSelectionMergeTest, AnySingleSelectionControlMask) {
const std::string input = "OpSelectionMerge %1 " + GetParam().name();
- EXPECT_THAT(
- CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpSelectionMerge, {1, GetParam().value()})));
+ EXPECT_THAT(CompiledInstructions(input),
+ Eq(MakeInstruction(spv::Op::OpSelectionMerge,
+ {1, uint32_t(GetParam().value())})));
}
// clang-format off
-#define CASE(VALUE,NAME) { SpvSelectionControl##VALUE, NAME}
+#define CASE(VALUE,NAME) { spv::SelectionControlMask::VALUE, NAME}
INSTANTIATE_TEST_SUITE_P(TextToBinarySelectionMerge, OpSelectionMergeTest,
- ValuesIn(std::vector<EnumCase<SpvSelectionControlMask>>{
+ ValuesIn(std::vector<EnumCase<spv::SelectionControlMask>>{
CASE(MaskNone, "None"),
- CASE(FlattenMask, "Flatten"),
- CASE(DontFlattenMask, "DontFlatten"),
+ CASE(Flatten, "Flatten"),
+ CASE(DontFlatten, "DontFlatten"),
}));
#undef CASE
// clang-format on
@@ -63,9 +63,11 @@ INSTANTIATE_TEST_SUITE_P(TextToBinarySelectionMerge, OpSelectionMergeTest,
TEST_F(OpSelectionMergeTest, CombinedSelectionControlMask) {
const std::string input = "OpSelectionMerge %1 Flatten|DontFlatten";
const uint32_t expected_mask =
- SpvSelectionControlFlattenMask | SpvSelectionControlDontFlattenMask;
- EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpSelectionMerge, {1, expected_mask})));
+ uint32_t(spv::SelectionControlMask::Flatten |
+ spv::SelectionControlMask::DontFlatten);
+ EXPECT_THAT(
+ CompiledInstructions(input),
+ Eq(MakeInstruction(spv::Op::OpSelectionMerge, {1, expected_mask})));
}
TEST_F(OpSelectionMergeTest, WrongSelectionControl) {
@@ -85,15 +87,15 @@ TEST_P(OpLoopMergeTest, AnySingleLoopControlMask) {
input << "OpLoopMerge %merge %continue " << ctrl.name();
for (auto num : ctrl.operands()) input << " " << num;
EXPECT_THAT(CompiledInstructions(input.str(), std::get<0>(GetParam())),
- Eq(MakeInstruction(SpvOpLoopMerge, {1, 2, ctrl.value()},
+ Eq(MakeInstruction(spv::Op::OpLoopMerge, {1, 2, ctrl.value()},
ctrl.operands())));
}
#define CASE(VALUE, NAME) \
- { SpvLoopControl##VALUE, NAME }
-#define CASE1(VALUE, NAME, PARM) \
- { \
- SpvLoopControl##VALUE, NAME, { PARM } \
+ { int32_t(spv::LoopControlMask::VALUE), NAME }
+#define CASE1(VALUE, NAME, PARM) \
+ { \
+ int32_t(spv::LoopControlMask::VALUE), NAME, { PARM } \
}
INSTANTIATE_TEST_SUITE_P(
TextToBinaryLoopMerge, OpLoopMergeTest,
@@ -101,8 +103,8 @@ INSTANTIATE_TEST_SUITE_P(
ValuesIn(std::vector<EnumCase<int>>{
// clang-format off
CASE(MaskNone, "None"),
- CASE(UnrollMask, "Unroll"),
- CASE(DontUnrollMask, "DontUnroll"),
+ CASE(Unroll, "Unroll"),
+ CASE(DontUnroll, "DontUnroll"),
// clang-format on
})));
@@ -111,9 +113,9 @@ INSTANTIATE_TEST_SUITE_P(
Combine(Values(SPV_ENV_UNIVERSAL_1_1),
ValuesIn(std::vector<EnumCase<int>>{
// clang-format off
- CASE(DependencyInfiniteMask, "DependencyInfinite"),
- CASE1(DependencyLengthMask, "DependencyLength", 234),
- {SpvLoopControlUnrollMask|SpvLoopControlDependencyLengthMask,
+ CASE(DependencyInfinite, "DependencyInfinite"),
+ CASE1(DependencyLength, "DependencyLength", 234),
+ {int32_t(spv::LoopControlMask::Unroll|spv::LoopControlMask::DependencyLength),
"DependencyLength|Unroll", {33}},
// clang-format on
})));
@@ -123,9 +125,9 @@ INSTANTIATE_TEST_SUITE_P(
TEST_F(OpLoopMergeTest, CombinedLoopControlMask) {
const std::string input = "OpLoopMerge %merge %continue Unroll|DontUnroll";
const uint32_t expected_mask =
- SpvLoopControlUnrollMask | SpvLoopControlDontUnrollMask;
+ uint32_t(spv::LoopControlMask::Unroll | spv::LoopControlMask::DontUnroll);
EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpLoopMerge, {1, 2, expected_mask})));
+ Eq(MakeInstruction(spv::Op::OpLoopMerge, {1, 2, expected_mask})));
}
TEST_F(OpLoopMergeTest, WrongLoopControl) {
@@ -137,16 +139,17 @@ TEST_F(OpLoopMergeTest, WrongLoopControl) {
TEST_F(TextToBinaryTest, SwitchGoodZeroTargets) {
EXPECT_THAT(CompiledInstructions("OpSwitch %selector %default"),
- Eq(MakeInstruction(SpvOpSwitch, {1, 2})));
+ Eq(MakeInstruction(spv::Op::OpSwitch, {1, 2})));
}
TEST_F(TextToBinaryTest, SwitchGoodOneTarget) {
- EXPECT_THAT(CompiledInstructions("%1 = OpTypeInt 32 0\n"
- "%2 = OpConstant %1 52\n"
- "OpSwitch %2 %default 12 %target0"),
- Eq(Concatenate({MakeInstruction(SpvOpTypeInt, {1, 32, 0}),
- MakeInstruction(SpvOpConstant, {1, 2, 52}),
- MakeInstruction(SpvOpSwitch, {2, 3, 12, 4})})));
+ EXPECT_THAT(
+ CompiledInstructions("%1 = OpTypeInt 32 0\n"
+ "%2 = OpConstant %1 52\n"
+ "OpSwitch %2 %default 12 %target0"),
+ Eq(Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 32, 0}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 52}),
+ MakeInstruction(spv::Op::OpSwitch, {2, 3, 12, 4})})));
}
TEST_F(TextToBinaryTest, SwitchGoodTwoTargets) {
@@ -155,9 +158,9 @@ TEST_F(TextToBinaryTest, SwitchGoodTwoTargets) {
"%2 = OpConstant %1 52\n"
"OpSwitch %2 %default 12 %target0 42 %target1"),
Eq(Concatenate({
- MakeInstruction(SpvOpTypeInt, {1, 32, 0}),
- MakeInstruction(SpvOpConstant, {1, 2, 52}),
- MakeInstruction(SpvOpSwitch, {2, 3, 12, 4, 42, 5}),
+ MakeInstruction(spv::Op::OpTypeInt, {1, 32, 0}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 52}),
+ MakeInstruction(spv::Op::OpSwitch, {2, 3, 12, 4, 42, 5}),
})));
}
@@ -246,11 +249,11 @@ SwitchTestCase MakeSwitchTestCase(uint32_t integer_width,
constant_str,
case_value_str,
{Concatenate(
- {MakeInstruction(SpvOpTypeInt,
+ {MakeInstruction(spv::Op::OpTypeInt,
{1, integer_width, integer_signedness}),
- MakeInstruction(SpvOpConstant,
+ MakeInstruction(spv::Op::OpConstant,
Concatenate({{1, 2}, encoded_constant})),
- MakeInstruction(SpvOpSwitch,
+ MakeInstruction(spv::Op::OpSwitch,
Concatenate({{2, 3}, encoded_case_value, {4}}))})}};
}
diff --git a/test/text_to_binary.debug_test.cpp b/test/text_to_binary.debug_test.cpp
index 39ba5c524..013107b3f 100644
--- a/test/text_to_binary.debug_test.cpp
+++ b/test/text_to_binary.debug_test.cpp
@@ -39,7 +39,7 @@ struct LanguageCase {
return static_cast<uint32_t>(language_value);
}
const char* language_name;
- SpvSourceLanguage language_value;
+ spv::SourceLanguage language_value;
uint32_t version;
};
@@ -47,7 +47,7 @@ struct LanguageCase {
// The list of OpSource cases to use.
const LanguageCase kLanguageCases[] = {
#define CASE(NAME, VERSION) \
- { #NAME, SpvSourceLanguage##NAME, VERSION }
+ { #NAME, spv::SourceLanguage::NAME, VERSION }
CASE(Unknown, 0),
CASE(Unknown, 999),
CASE(ESSL, 310),
@@ -69,9 +69,10 @@ TEST_P(OpSourceTest, AnyLanguage) {
const std::string input = std::string("OpSource ") +
GetParam().language_name + " " +
std::to_string(GetParam().version);
- EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpSource, {GetParam().get_language_value(),
- GetParam().version})));
+ EXPECT_THAT(
+ CompiledInstructions(input),
+ Eq(MakeInstruction(spv::Op::OpSource, {GetParam().get_language_value(),
+ GetParam().version})));
}
INSTANTIATE_TEST_SUITE_P(TextToBinaryTestDebug, OpSourceTest,
@@ -87,7 +88,8 @@ TEST_F(TextToBinaryTest, OpSourceAcceptsOptionalFileId) {
const std::string input = "OpSource GLSL 450 %file_id";
EXPECT_THAT(
CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpSource, {SpvSourceLanguageGLSL, 450, 1})));
+ Eq(MakeInstruction(spv::Op::OpSource,
+ {uint32_t(spv::SourceLanguage::GLSL), 450, 1})));
}
TEST_F(TextToBinaryTest, OpSourceAcceptsOptionalSourceText) {
@@ -95,7 +97,8 @@ TEST_F(TextToBinaryTest, OpSourceAcceptsOptionalSourceText) {
const std::string input =
"OpSource GLSL 450 %file_id \"" + fake_source + "\"";
EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpSource, {SpvSourceLanguageGLSL, 450, 1},
+ Eq(MakeInstruction(spv::Op::OpSource,
+ {uint32_t(spv::SourceLanguage::GLSL), 450, 1},
MakeVector(fake_source))));
}
@@ -110,7 +113,7 @@ TEST_P(OpSourceContinuedTest, AnyExtension) {
std::string("OpSourceContinued \"") + GetParam() + "\"";
EXPECT_THAT(
CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpSourceContinued, MakeVector(GetParam()))));
+ Eq(MakeInstruction(spv::Op::OpSourceContinued, MakeVector(GetParam()))));
}
// TODO(dneto): utf-8, quoting, escaping
@@ -129,7 +132,7 @@ TEST_P(OpSourceExtensionTest, AnyExtension) {
std::string("OpSourceExtension \"") + GetParam() + "\"";
EXPECT_THAT(
CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpSourceExtension, MakeVector(GetParam()))));
+ Eq(MakeInstruction(spv::Op::OpSourceExtension, MakeVector(GetParam()))));
}
// TODO(dneto): utf-8, quoting, escaping
@@ -139,12 +142,12 @@ INSTANTIATE_TEST_SUITE_P(TextToBinaryTestDebug, OpSourceExtensionTest,
TEST_F(TextToBinaryTest, OpLine) {
EXPECT_THAT(CompiledInstructions("OpLine %srcfile 42 99"),
- Eq(MakeInstruction(SpvOpLine, {1, 42, 99})));
+ Eq(MakeInstruction(spv::Op::OpLine, {1, 42, 99})));
}
TEST_F(TextToBinaryTest, OpNoLine) {
EXPECT_THAT(CompiledInstructions("OpNoLine"),
- Eq(MakeInstruction(SpvOpNoLine, {})));
+ Eq(MakeInstruction(spv::Op::OpNoLine, {})));
}
using OpStringTest =
@@ -154,8 +157,9 @@ TEST_P(OpStringTest, AnyString) {
// TODO(dneto): utf-8, quoting, escaping
const std::string input =
std::string("%result = OpString \"") + GetParam() + "\"";
- EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpString, {1}, MakeVector(GetParam()))));
+ EXPECT_THAT(
+ CompiledInstructions(input),
+ Eq(MakeInstruction(spv::Op::OpString, {1}, MakeVector(GetParam()))));
}
// TODO(dneto): utf-8, quoting, escaping
@@ -169,8 +173,9 @@ using OpNameTest =
TEST_P(OpNameTest, AnyString) {
const std::string input =
std::string("OpName %target \"") + GetParam() + "\"";
- EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpName, {1}, MakeVector(GetParam()))));
+ EXPECT_THAT(
+ CompiledInstructions(input),
+ Eq(MakeInstruction(spv::Op::OpName, {1}, MakeVector(GetParam()))));
}
// UTF-8, quoting, escaping, etc. are covered in the StringLiterals tests in
@@ -185,9 +190,9 @@ TEST_P(OpMemberNameTest, AnyString) {
// TODO(dneto): utf-8, quoting, escaping
const std::string input =
std::string("OpMemberName %type 42 \"") + GetParam() + "\"";
- EXPECT_THAT(
- CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpMemberName, {1, 42}, MakeVector(GetParam()))));
+ EXPECT_THAT(CompiledInstructions(input),
+ Eq(MakeInstruction(spv::Op::OpMemberName, {1, 42},
+ MakeVector(GetParam()))));
}
// TODO(dneto): utf-8, quoting, escaping
@@ -205,7 +210,7 @@ TEST_P(OpModuleProcessedTest, AnyString) {
std::string("OpModuleProcessed \"") + GetParam() + "\"";
EXPECT_THAT(
CompiledInstructions(input, SPV_ENV_UNIVERSAL_1_1),
- Eq(MakeInstruction(SpvOpModuleProcessed, MakeVector(GetParam()))));
+ Eq(MakeInstruction(spv::Op::OpModuleProcessed, MakeVector(GetParam()))));
}
INSTANTIATE_TEST_SUITE_P(TextToBinaryTestDebug, OpModuleProcessedTest,
diff --git a/test/text_to_binary.device_side_enqueue_test.cpp b/test/text_to_binary.device_side_enqueue_test.cpp
index 2f4dd7057..7f424f37b 100644
--- a/test/text_to_binary.device_side_enqueue_test.cpp
+++ b/test/text_to_binary.device_side_enqueue_test.cpp
@@ -44,7 +44,7 @@ TEST_P(OpEnqueueKernelGood, Sample) {
" %wait_events %ret_event %invoke %param %param_size %param_align " +
GetParam().local_size_source;
EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpEnqueueKernel,
+ Eq(MakeInstruction(spv::Op::OpEnqueueKernel,
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12},
GetParam().local_size_operands)));
}
diff --git a/test/text_to_binary.extension_test.cpp b/test/text_to_binary.extension_test.cpp
index cf4919acc..6780c7e83 100644
--- a/test/text_to_binary.extension_test.cpp
+++ b/test/text_to_binary.extension_test.cpp
@@ -87,12 +87,14 @@ TEST_F(TextToBinaryTest, ExtInstFromTwoDifferentImports) {
EXPECT_THAT(
CompiledInstructions(input),
Eq(Concatenate({
- MakeInstruction(SpvOpExtInstImport, {1}, MakeVector("OpenCL.std")),
- MakeInstruction(SpvOpExtInstImport, {2}, MakeVector("GLSL.std.450")),
+ MakeInstruction(spv::Op::OpExtInstImport, {1},
+ MakeVector("OpenCL.std")),
+ MakeInstruction(spv::Op::OpExtInstImport, {2},
+ MakeVector("GLSL.std.450")),
MakeInstruction(
- SpvOpExtInst,
+ spv::Op::OpExtInst,
{3, 4, 1, uint32_t(OpenCLLIB::Entrypoints::Native_sqrt), 5}),
- MakeInstruction(SpvOpExtInst,
+ MakeInstruction(spv::Op::OpExtInst,
{6, 7, 2, uint32_t(GLSLstd450MatrixInverse), 8}),
})));
@@ -140,62 +142,74 @@ INSTANTIATE_TEST_SUITE_P(
SPV_KHR_shader_ballot, ExtensionRoundTripTest,
// We'll get coverage over operand tables by trying the universal
// environments, and at least one specific environment.
- Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
- SPV_ENV_VULKAN_1_0),
- ValuesIn(std::vector<AssemblyCase>{
- {"OpCapability SubgroupBallotKHR\n",
- MakeInstruction(SpvOpCapability,
- {SpvCapabilitySubgroupBallotKHR})},
- {"%2 = OpSubgroupBallotKHR %1 %3\n",
- MakeInstruction(SpvOpSubgroupBallotKHR, {1, 2, 3})},
- {"%2 = OpSubgroupFirstInvocationKHR %1 %3\n",
- MakeInstruction(SpvOpSubgroupFirstInvocationKHR, {1, 2, 3})},
- {"OpDecorate %1 BuiltIn SubgroupEqMask\n",
- MakeInstruction(SpvOpDecorate, {1, SpvDecorationBuiltIn,
- SpvBuiltInSubgroupEqMaskKHR})},
- {"OpDecorate %1 BuiltIn SubgroupGeMask\n",
- MakeInstruction(SpvOpDecorate, {1, SpvDecorationBuiltIn,
- SpvBuiltInSubgroupGeMaskKHR})},
- {"OpDecorate %1 BuiltIn SubgroupGtMask\n",
- MakeInstruction(SpvOpDecorate, {1, SpvDecorationBuiltIn,
- SpvBuiltInSubgroupGtMaskKHR})},
- {"OpDecorate %1 BuiltIn SubgroupLeMask\n",
- MakeInstruction(SpvOpDecorate, {1, SpvDecorationBuiltIn,
- SpvBuiltInSubgroupLeMaskKHR})},
- {"OpDecorate %1 BuiltIn SubgroupLtMask\n",
- MakeInstruction(SpvOpDecorate, {1, SpvDecorationBuiltIn,
- SpvBuiltInSubgroupLtMaskKHR})},
- })));
+ Combine(
+ Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
+ SPV_ENV_VULKAN_1_0),
+ ValuesIn(std::vector<AssemblyCase>{
+ {"OpCapability SubgroupBallotKHR\n",
+ MakeInstruction(spv::Op::OpCapability,
+ {uint32_t(spv::Capability::SubgroupBallotKHR)})},
+ {"%2 = OpSubgroupBallotKHR %1 %3\n",
+ MakeInstruction(spv::Op::OpSubgroupBallotKHR, {1, 2, 3})},
+ {"%2 = OpSubgroupFirstInvocationKHR %1 %3\n",
+ MakeInstruction(spv::Op::OpSubgroupFirstInvocationKHR, {1, 2, 3})},
+ {"OpDecorate %1 BuiltIn SubgroupEqMask\n",
+ MakeInstruction(spv::Op::OpDecorate,
+ {1, uint32_t(spv::Decoration::BuiltIn),
+ uint32_t(spv::BuiltIn::SubgroupEqMaskKHR)})},
+ {"OpDecorate %1 BuiltIn SubgroupGeMask\n",
+ MakeInstruction(spv::Op::OpDecorate,
+ {1, uint32_t(spv::Decoration::BuiltIn),
+ uint32_t(spv::BuiltIn::SubgroupGeMaskKHR)})},
+ {"OpDecorate %1 BuiltIn SubgroupGtMask\n",
+ MakeInstruction(spv::Op::OpDecorate,
+ {1, uint32_t(spv::Decoration::BuiltIn),
+ uint32_t(spv::BuiltIn::SubgroupGtMaskKHR)})},
+ {"OpDecorate %1 BuiltIn SubgroupLeMask\n",
+ MakeInstruction(spv::Op::OpDecorate,
+ {1, uint32_t(spv::Decoration::BuiltIn),
+ uint32_t(spv::BuiltIn::SubgroupLeMaskKHR)})},
+ {"OpDecorate %1 BuiltIn SubgroupLtMask\n",
+ MakeInstruction(spv::Op::OpDecorate,
+ {1, uint32_t(spv::Decoration::BuiltIn),
+ uint32_t(spv::BuiltIn::SubgroupLtMaskKHR)})},
+ })));
INSTANTIATE_TEST_SUITE_P(
SPV_KHR_shader_ballot_vulkan_1_1, ExtensionRoundTripTest,
// In SPIR-V 1.3 and Vulkan 1.1 we can drop the KHR suffix on the
// builtin enums.
- Combine(Values(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_1),
- ValuesIn(std::vector<AssemblyCase>{
- {"OpCapability SubgroupBallotKHR\n",
- MakeInstruction(SpvOpCapability,
- {SpvCapabilitySubgroupBallotKHR})},
- {"%2 = OpSubgroupBallotKHR %1 %3\n",
- MakeInstruction(SpvOpSubgroupBallotKHR, {1, 2, 3})},
- {"%2 = OpSubgroupFirstInvocationKHR %1 %3\n",
- MakeInstruction(SpvOpSubgroupFirstInvocationKHR, {1, 2, 3})},
- {"OpDecorate %1 BuiltIn SubgroupEqMask\n",
- MakeInstruction(SpvOpDecorate, {1, SpvDecorationBuiltIn,
- SpvBuiltInSubgroupEqMask})},
- {"OpDecorate %1 BuiltIn SubgroupGeMask\n",
- MakeInstruction(SpvOpDecorate, {1, SpvDecorationBuiltIn,
- SpvBuiltInSubgroupGeMask})},
- {"OpDecorate %1 BuiltIn SubgroupGtMask\n",
- MakeInstruction(SpvOpDecorate, {1, SpvDecorationBuiltIn,
- SpvBuiltInSubgroupGtMask})},
- {"OpDecorate %1 BuiltIn SubgroupLeMask\n",
- MakeInstruction(SpvOpDecorate, {1, SpvDecorationBuiltIn,
- SpvBuiltInSubgroupLeMask})},
- {"OpDecorate %1 BuiltIn SubgroupLtMask\n",
- MakeInstruction(SpvOpDecorate, {1, SpvDecorationBuiltIn,
- SpvBuiltInSubgroupLtMask})},
- })));
+ Combine(
+ Values(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_1),
+ ValuesIn(std::vector<AssemblyCase>{
+ {"OpCapability SubgroupBallotKHR\n",
+ MakeInstruction(spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::SubgroupBallotKHR})},
+ {"%2 = OpSubgroupBallotKHR %1 %3\n",
+ MakeInstruction(spv::Op::OpSubgroupBallotKHR, {1, 2, 3})},
+ {"%2 = OpSubgroupFirstInvocationKHR %1 %3\n",
+ MakeInstruction(spv::Op::OpSubgroupFirstInvocationKHR, {1, 2, 3})},
+ {"OpDecorate %1 BuiltIn SubgroupEqMask\n",
+ MakeInstruction(spv::Op::OpDecorate,
+ {1, uint32_t(spv::Decoration::BuiltIn),
+ uint32_t(spv::BuiltIn::SubgroupEqMask)})},
+ {"OpDecorate %1 BuiltIn SubgroupGeMask\n",
+ MakeInstruction(spv::Op::OpDecorate,
+ {1, uint32_t(spv::Decoration::BuiltIn),
+ uint32_t(spv::BuiltIn::SubgroupGeMask)})},
+ {"OpDecorate %1 BuiltIn SubgroupGtMask\n",
+ MakeInstruction(spv::Op::OpDecorate,
+ {1, uint32_t(spv::Decoration::BuiltIn),
+ uint32_t(spv::BuiltIn::SubgroupGtMask)})},
+ {"OpDecorate %1 BuiltIn SubgroupLeMask\n",
+ MakeInstruction(spv::Op::OpDecorate,
+ {1, uint32_t(spv::Decoration::BuiltIn),
+ uint32_t(spv::BuiltIn::SubgroupLeMask)})},
+ {"OpDecorate %1 BuiltIn SubgroupLtMask\n",
+ MakeInstruction(spv::Op::OpDecorate,
+ {1, uint32_t(spv::Decoration::BuiltIn),
+ uint32_t(spv::BuiltIn::SubgroupLtMask)})},
+ })));
// The old builtin names (with KHR suffix) still work in the assembler, and
// map to the enums without the KHR.
@@ -206,20 +220,25 @@ INSTANTIATE_TEST_SUITE_P(
Combine(Values(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_1),
ValuesIn(std::vector<AssemblyCase>{
{"OpDecorate %1 BuiltIn SubgroupEqMaskKHR\n",
- MakeInstruction(SpvOpDecorate, {1, SpvDecorationBuiltIn,
- SpvBuiltInSubgroupEqMask})},
+ MakeInstruction(spv::Op::OpDecorate,
+ {1, (uint32_t)spv::Decoration::BuiltIn,
+ (uint32_t)spv::BuiltIn::SubgroupEqMask})},
{"OpDecorate %1 BuiltIn SubgroupGeMaskKHR\n",
- MakeInstruction(SpvOpDecorate, {1, SpvDecorationBuiltIn,
- SpvBuiltInSubgroupGeMask})},
+ MakeInstruction(spv::Op::OpDecorate,
+ {1, (uint32_t)spv::Decoration::BuiltIn,
+ (uint32_t)spv::BuiltIn::SubgroupGeMask})},
{"OpDecorate %1 BuiltIn SubgroupGtMaskKHR\n",
- MakeInstruction(SpvOpDecorate, {1, SpvDecorationBuiltIn,
- SpvBuiltInSubgroupGtMask})},
+ MakeInstruction(spv::Op::OpDecorate,
+ {1, (uint32_t)spv::Decoration::BuiltIn,
+ (uint32_t)spv::BuiltIn::SubgroupGtMask})},
{"OpDecorate %1 BuiltIn SubgroupLeMaskKHR\n",
- MakeInstruction(SpvOpDecorate, {1, SpvDecorationBuiltIn,
- SpvBuiltInSubgroupLeMask})},
+ MakeInstruction(spv::Op::OpDecorate,
+ {1, (uint32_t)spv::Decoration::BuiltIn,
+ (uint32_t)spv::BuiltIn::SubgroupLeMask})},
{"OpDecorate %1 BuiltIn SubgroupLtMaskKHR\n",
- MakeInstruction(SpvOpDecorate, {1, SpvDecorationBuiltIn,
- SpvBuiltInSubgroupLtMask})},
+ MakeInstruction(spv::Op::OpDecorate,
+ {1, (uint32_t)spv::Decoration::BuiltIn,
+ (uint32_t)spv::BuiltIn::SubgroupLtMask})},
})));
// SPV_KHR_shader_draw_parameters
@@ -228,21 +247,24 @@ INSTANTIATE_TEST_SUITE_P(
SPV_KHR_shader_draw_parameters, ExtensionRoundTripTest,
// We'll get coverage over operand tables by trying the universal
// environments, and at least one specific environment.
- Combine(
- ValuesIn(CommonVulkanEnvs()),
- ValuesIn(std::vector<AssemblyCase>{
- {"OpCapability DrawParameters\n",
- MakeInstruction(SpvOpCapability, {SpvCapabilityDrawParameters})},
- {"OpDecorate %1 BuiltIn BaseVertex\n",
- MakeInstruction(SpvOpDecorate,
- {1, SpvDecorationBuiltIn, SpvBuiltInBaseVertex})},
- {"OpDecorate %1 BuiltIn BaseInstance\n",
- MakeInstruction(SpvOpDecorate, {1, SpvDecorationBuiltIn,
- SpvBuiltInBaseInstance})},
- {"OpDecorate %1 BuiltIn DrawIndex\n",
- MakeInstruction(SpvOpDecorate,
- {1, SpvDecorationBuiltIn, SpvBuiltInDrawIndex})},
- })));
+ Combine(ValuesIn(CommonVulkanEnvs()),
+ ValuesIn(std::vector<AssemblyCase>{
+ {"OpCapability DrawParameters\n",
+ MakeInstruction(spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::DrawParameters})},
+ {"OpDecorate %1 BuiltIn BaseVertex\n",
+ MakeInstruction(spv::Op::OpDecorate,
+ {1, (uint32_t)spv::Decoration::BuiltIn,
+ (uint32_t)spv::BuiltIn::BaseVertex})},
+ {"OpDecorate %1 BuiltIn BaseInstance\n",
+ MakeInstruction(spv::Op::OpDecorate,
+ {1, (uint32_t)spv::Decoration::BuiltIn,
+ (uint32_t)spv::BuiltIn::BaseInstance})},
+ {"OpDecorate %1 BuiltIn DrawIndex\n",
+ MakeInstruction(spv::Op::OpDecorate,
+ {1, (uint32_t)spv::Decoration::BuiltIn,
+ (uint32_t)spv::BuiltIn::DrawIndex})},
+ })));
// SPV_KHR_subgroup_vote
@@ -253,14 +275,14 @@ INSTANTIATE_TEST_SUITE_P(
Combine(ValuesIn(CommonVulkanEnvs()),
ValuesIn(std::vector<AssemblyCase>{
{"OpCapability SubgroupVoteKHR\n",
- MakeInstruction(SpvOpCapability,
- {SpvCapabilitySubgroupVoteKHR})},
+ MakeInstruction(spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::SubgroupVoteKHR})},
{"%2 = OpSubgroupAnyKHR %1 %3\n",
- MakeInstruction(SpvOpSubgroupAnyKHR, {1, 2, 3})},
+ MakeInstruction(spv::Op::OpSubgroupAnyKHR, {1, 2, 3})},
{"%2 = OpSubgroupAllKHR %1 %3\n",
- MakeInstruction(SpvOpSubgroupAllKHR, {1, 2, 3})},
+ MakeInstruction(spv::Op::OpSubgroupAllKHR, {1, 2, 3})},
{"%2 = OpSubgroupAllEqualKHR %1 %3\n",
- MakeInstruction(SpvOpSubgroupAllEqualKHR, {1, 2, 3})},
+ MakeInstruction(spv::Op::OpSubgroupAllEqualKHR, {1, 2, 3})},
})));
// SPV_KHR_16bit_storage
@@ -269,42 +291,50 @@ INSTANTIATE_TEST_SUITE_P(
SPV_KHR_16bit_storage, ExtensionRoundTripTest,
// We'll get coverage over operand tables by trying the universal
// environments, and at least one specific environment.
- Combine(ValuesIn(CommonVulkanEnvs()),
- ValuesIn(std::vector<AssemblyCase>{
- {"OpCapability StorageBuffer16BitAccess\n",
- MakeInstruction(SpvOpCapability,
- {SpvCapabilityStorageUniformBufferBlock16})},
- {"OpCapability StorageBuffer16BitAccess\n",
- MakeInstruction(SpvOpCapability,
- {SpvCapabilityStorageBuffer16BitAccess})},
- {"OpCapability UniformAndStorageBuffer16BitAccess\n",
- MakeInstruction(
- SpvOpCapability,
- {SpvCapabilityUniformAndStorageBuffer16BitAccess})},
- {"OpCapability UniformAndStorageBuffer16BitAccess\n",
- MakeInstruction(SpvOpCapability,
- {SpvCapabilityStorageUniform16})},
- {"OpCapability StoragePushConstant16\n",
- MakeInstruction(SpvOpCapability,
- {SpvCapabilityStoragePushConstant16})},
- {"OpCapability StorageInputOutput16\n",
- MakeInstruction(SpvOpCapability,
- {SpvCapabilityStorageInputOutput16})},
- })));
+ Combine(
+ ValuesIn(CommonVulkanEnvs()),
+ ValuesIn(std::vector<AssemblyCase>{
+ {"OpCapability StorageBuffer16BitAccess\n",
+ MakeInstruction(
+ spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::StorageUniformBufferBlock16})},
+ {"OpCapability StorageBuffer16BitAccess\n",
+ MakeInstruction(
+ spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::StorageBuffer16BitAccess})},
+ {"OpCapability UniformAndStorageBuffer16BitAccess\n",
+ MakeInstruction(
+ spv::Op::OpCapability,
+ {(uint32_t)
+ spv::Capability::UniformAndStorageBuffer16BitAccess})},
+ {"OpCapability UniformAndStorageBuffer16BitAccess\n",
+ MakeInstruction(spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::StorageUniform16})},
+ {"OpCapability StoragePushConstant16\n",
+ MakeInstruction(
+ spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::StoragePushConstant16})},
+ {"OpCapability StorageInputOutput16\n",
+ MakeInstruction(
+ spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::StorageInputOutput16})},
+ })));
INSTANTIATE_TEST_SUITE_P(
SPV_KHR_16bit_storage_alias_check, ExtensionAssemblyTest,
- Combine(ValuesIn(CommonVulkanEnvs()),
- ValuesIn(std::vector<AssemblyCase>{
- // The old name maps to the new enum.
- {"OpCapability StorageUniformBufferBlock16\n",
- MakeInstruction(SpvOpCapability,
- {SpvCapabilityStorageBuffer16BitAccess})},
- // The new name maps to the old enum.
- {"OpCapability UniformAndStorageBuffer16BitAccess\n",
- MakeInstruction(SpvOpCapability,
- {SpvCapabilityStorageUniform16})},
- })));
+ Combine(
+ ValuesIn(CommonVulkanEnvs()),
+ ValuesIn(std::vector<AssemblyCase>{
+ // The old name maps to the new enum.
+ {"OpCapability StorageUniformBufferBlock16\n",
+ MakeInstruction(
+ spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::StorageBuffer16BitAccess})},
+ // The new name maps to the old enum.
+ {"OpCapability UniformAndStorageBuffer16BitAccess\n",
+ MakeInstruction(spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::StorageUniform16})},
+ })));
// SPV_KHR_device_group
@@ -315,10 +345,12 @@ INSTANTIATE_TEST_SUITE_P(
Combine(ValuesIn(CommonVulkanEnvs()),
ValuesIn(std::vector<AssemblyCase>{
{"OpCapability DeviceGroup\n",
- MakeInstruction(SpvOpCapability, {SpvCapabilityDeviceGroup})},
+ MakeInstruction(spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::DeviceGroup})},
{"OpDecorate %1 BuiltIn DeviceIndex\n",
- MakeInstruction(SpvOpDecorate, {1, SpvDecorationBuiltIn,
- SpvBuiltInDeviceIndex})},
+ MakeInstruction(spv::Op::OpDecorate,
+ {1, (uint32_t)spv::Decoration::BuiltIn,
+ (uint32_t)spv::BuiltIn::DeviceIndex})},
})));
// SPV_KHR_8bit_storage
@@ -327,19 +359,22 @@ INSTANTIATE_TEST_SUITE_P(
SPV_KHR_8bit_storage, ExtensionRoundTripTest,
// We'll get coverage over operand tables by trying the universal
// environments, and at least one specific environment.
- Combine(
- ValuesIn(CommonVulkanEnvs()),
- ValuesIn(std::vector<AssemblyCase>{
- {"OpCapability StorageBuffer8BitAccess\n",
- MakeInstruction(SpvOpCapability,
- {SpvCapabilityStorageBuffer8BitAccess})},
- {"OpCapability UniformAndStorageBuffer8BitAccess\n",
- MakeInstruction(SpvOpCapability,
- {SpvCapabilityUniformAndStorageBuffer8BitAccess})},
- {"OpCapability StoragePushConstant8\n",
- MakeInstruction(SpvOpCapability,
- {SpvCapabilityStoragePushConstant8})},
- })));
+ Combine(ValuesIn(CommonVulkanEnvs()),
+ ValuesIn(std::vector<AssemblyCase>{
+ {"OpCapability StorageBuffer8BitAccess\n",
+ MakeInstruction(
+ spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::StorageBuffer8BitAccess})},
+ {"OpCapability UniformAndStorageBuffer8BitAccess\n",
+ MakeInstruction(
+ spv::Op::OpCapability,
+ {(uint32_t)
+ spv::Capability::UniformAndStorageBuffer8BitAccess})},
+ {"OpCapability StoragePushConstant8\n",
+ MakeInstruction(
+ spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::StoragePushConstant8})},
+ })));
// SPV_KHR_multiview
@@ -351,10 +386,12 @@ INSTANTIATE_TEST_SUITE_P(
SPV_ENV_VULKAN_1_0),
ValuesIn(std::vector<AssemblyCase>{
{"OpCapability MultiView\n",
- MakeInstruction(SpvOpCapability, {SpvCapabilityMultiView})},
+ MakeInstruction(spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::MultiView})},
{"OpDecorate %1 BuiltIn ViewIndex\n",
- MakeInstruction(SpvOpDecorate, {1, SpvDecorationBuiltIn,
- SpvBuiltInViewIndex})},
+ MakeInstruction(spv::Op::OpDecorate,
+ {1, (uint32_t)spv::Decoration::BuiltIn,
+ (uint32_t)spv::BuiltIn::ViewIndex})},
})));
// SPV_AMD_shader_explicit_vertex_parameter
@@ -372,9 +409,9 @@ INSTANTIATE_TEST_SUITE_P(
{PREAMBLE "%3 = OpExtInst %2 %1 InterpolateAtVertexAMD %4 %5\n",
Concatenate(
{MakeInstruction(
- SpvOpExtInstImport, {1},
+ spv::Op::OpExtInstImport, {1},
MakeVector("SPV_AMD_shader_explicit_vertex_parameter")),
- MakeInstruction(SpvOpExtInst, {2, 3, 1, 1, 4, 5})})},
+ MakeInstruction(spv::Op::OpExtInst, {2, 3, 1, 1, 4, 5})})},
})));
#undef PREAMBLE
@@ -391,49 +428,49 @@ INSTANTIATE_TEST_SUITE_P(
ValuesIn(std::vector<AssemblyCase>{
{PREAMBLE "%3 = OpExtInst %2 %1 FMin3AMD %4 %5 %6\n",
Concatenate(
- {MakeInstruction(SpvOpExtInstImport, {1},
+ {MakeInstruction(spv::Op::OpExtInstImport, {1},
MakeVector("SPV_AMD_shader_trinary_minmax")),
- MakeInstruction(SpvOpExtInst, {2, 3, 1, 1, 4, 5, 6})})},
+ MakeInstruction(spv::Op::OpExtInst, {2, 3, 1, 1, 4, 5, 6})})},
{PREAMBLE "%3 = OpExtInst %2 %1 UMin3AMD %4 %5 %6\n",
Concatenate(
- {MakeInstruction(SpvOpExtInstImport, {1},
+ {MakeInstruction(spv::Op::OpExtInstImport, {1},
MakeVector("SPV_AMD_shader_trinary_minmax")),
- MakeInstruction(SpvOpExtInst, {2, 3, 1, 2, 4, 5, 6})})},
+ MakeInstruction(spv::Op::OpExtInst, {2, 3, 1, 2, 4, 5, 6})})},
{PREAMBLE "%3 = OpExtInst %2 %1 SMin3AMD %4 %5 %6\n",
Concatenate(
- {MakeInstruction(SpvOpExtInstImport, {1},
+ {MakeInstruction(spv::Op::OpExtInstImport, {1},
MakeVector("SPV_AMD_shader_trinary_minmax")),
- MakeInstruction(SpvOpExtInst, {2, 3, 1, 3, 4, 5, 6})})},
+ MakeInstruction(spv::Op::OpExtInst, {2, 3, 1, 3, 4, 5, 6})})},
{PREAMBLE "%3 = OpExtInst %2 %1 FMax3AMD %4 %5 %6\n",
Concatenate(
- {MakeInstruction(SpvOpExtInstImport, {1},
+ {MakeInstruction(spv::Op::OpExtInstImport, {1},
MakeVector("SPV_AMD_shader_trinary_minmax")),
- MakeInstruction(SpvOpExtInst, {2, 3, 1, 4, 4, 5, 6})})},
+ MakeInstruction(spv::Op::OpExtInst, {2, 3, 1, 4, 4, 5, 6})})},
{PREAMBLE "%3 = OpExtInst %2 %1 UMax3AMD %4 %5 %6\n",
Concatenate(
- {MakeInstruction(SpvOpExtInstImport, {1},
+ {MakeInstruction(spv::Op::OpExtInstImport, {1},
MakeVector("SPV_AMD_shader_trinary_minmax")),
- MakeInstruction(SpvOpExtInst, {2, 3, 1, 5, 4, 5, 6})})},
+ MakeInstruction(spv::Op::OpExtInst, {2, 3, 1, 5, 4, 5, 6})})},
{PREAMBLE "%3 = OpExtInst %2 %1 SMax3AMD %4 %5 %6\n",
Concatenate(
- {MakeInstruction(SpvOpExtInstImport, {1},
+ {MakeInstruction(spv::Op::OpExtInstImport, {1},
MakeVector("SPV_AMD_shader_trinary_minmax")),
- MakeInstruction(SpvOpExtInst, {2, 3, 1, 6, 4, 5, 6})})},
+ MakeInstruction(spv::Op::OpExtInst, {2, 3, 1, 6, 4, 5, 6})})},
{PREAMBLE "%3 = OpExtInst %2 %1 FMid3AMD %4 %5 %6\n",
Concatenate(
- {MakeInstruction(SpvOpExtInstImport, {1},
+ {MakeInstruction(spv::Op::OpExtInstImport, {1},
MakeVector("SPV_AMD_shader_trinary_minmax")),
- MakeInstruction(SpvOpExtInst, {2, 3, 1, 7, 4, 5, 6})})},
+ MakeInstruction(spv::Op::OpExtInst, {2, 3, 1, 7, 4, 5, 6})})},
{PREAMBLE "%3 = OpExtInst %2 %1 UMid3AMD %4 %5 %6\n",
Concatenate(
- {MakeInstruction(SpvOpExtInstImport, {1},
+ {MakeInstruction(spv::Op::OpExtInstImport, {1},
MakeVector("SPV_AMD_shader_trinary_minmax")),
- MakeInstruction(SpvOpExtInst, {2, 3, 1, 8, 4, 5, 6})})},
+ MakeInstruction(spv::Op::OpExtInst, {2, 3, 1, 8, 4, 5, 6})})},
{PREAMBLE "%3 = OpExtInst %2 %1 SMid3AMD %4 %5 %6\n",
Concatenate(
- {MakeInstruction(SpvOpExtInstImport, {1},
+ {MakeInstruction(spv::Op::OpExtInstImport, {1},
MakeVector("SPV_AMD_shader_trinary_minmax")),
- MakeInstruction(SpvOpExtInst, {2, 3, 1, 9, 4, 5, 6})})},
+ MakeInstruction(spv::Op::OpExtInst, {2, 3, 1, 9, 4, 5, 6})})},
})));
#undef PREAMBLE
@@ -444,22 +481,25 @@ INSTANTIATE_TEST_SUITE_P(
SPV_AMD_gcn_shader, ExtensionRoundTripTest,
// We'll get coverage over operand tables by trying the universal
// environments, and at least one specific environment.
- Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
- SPV_ENV_VULKAN_1_0),
- ValuesIn(std::vector<AssemblyCase>{
- {PREAMBLE "%3 = OpExtInst %2 %1 CubeFaceIndexAMD %4\n",
- Concatenate({MakeInstruction(SpvOpExtInstImport, {1},
- MakeVector("SPV_AMD_gcn_shader")),
- MakeInstruction(SpvOpExtInst, {2, 3, 1, 1, 4})})},
- {PREAMBLE "%3 = OpExtInst %2 %1 CubeFaceCoordAMD %4\n",
- Concatenate({MakeInstruction(SpvOpExtInstImport, {1},
- MakeVector("SPV_AMD_gcn_shader")),
- MakeInstruction(SpvOpExtInst, {2, 3, 1, 2, 4})})},
- {PREAMBLE "%3 = OpExtInst %2 %1 TimeAMD\n",
- Concatenate({MakeInstruction(SpvOpExtInstImport, {1},
- MakeVector("SPV_AMD_gcn_shader")),
- MakeInstruction(SpvOpExtInst, {2, 3, 1, 3})})},
- })));
+ Combine(
+ Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
+ SPV_ENV_VULKAN_1_0),
+ ValuesIn(std::vector<AssemblyCase>{
+ {PREAMBLE "%3 = OpExtInst %2 %1 CubeFaceIndexAMD %4\n",
+ Concatenate({MakeInstruction(spv::Op::OpExtInstImport, {1},
+ MakeVector("SPV_AMD_gcn_shader")),
+ MakeInstruction(spv::Op::OpExtInst,
+ {2, 3, 1, 1, 4})})},
+ {PREAMBLE "%3 = OpExtInst %2 %1 CubeFaceCoordAMD %4\n",
+ Concatenate({MakeInstruction(spv::Op::OpExtInstImport, {1},
+ MakeVector("SPV_AMD_gcn_shader")),
+ MakeInstruction(spv::Op::OpExtInst,
+ {2, 3, 1, 2, 4})})},
+ {PREAMBLE "%3 = OpExtInst %2 %1 TimeAMD\n",
+ Concatenate({MakeInstruction(spv::Op::OpExtInstImport, {1},
+ MakeVector("SPV_AMD_gcn_shader")),
+ MakeInstruction(spv::Op::OpExtInst, {2, 3, 1, 3})})},
+ })));
#undef PREAMBLE
// SPV_AMD_shader_ballot
@@ -474,23 +514,26 @@ INSTANTIATE_TEST_SUITE_P(
SPV_ENV_VULKAN_1_0),
ValuesIn(std::vector<AssemblyCase>{
{PREAMBLE "%3 = OpExtInst %2 %1 SwizzleInvocationsAMD %4 %5\n",
- Concatenate({MakeInstruction(SpvOpExtInstImport, {1},
+ Concatenate({MakeInstruction(spv::Op::OpExtInstImport, {1},
MakeVector("SPV_AMD_shader_ballot")),
- MakeInstruction(SpvOpExtInst, {2, 3, 1, 1, 4, 5})})},
+ MakeInstruction(spv::Op::OpExtInst,
+ {2, 3, 1, 1, 4, 5})})},
{PREAMBLE
"%3 = OpExtInst %2 %1 SwizzleInvocationsMaskedAMD %4 %5\n",
- Concatenate({MakeInstruction(SpvOpExtInstImport, {1},
+ Concatenate({MakeInstruction(spv::Op::OpExtInstImport, {1},
MakeVector("SPV_AMD_shader_ballot")),
- MakeInstruction(SpvOpExtInst, {2, 3, 1, 2, 4, 5})})},
+ MakeInstruction(spv::Op::OpExtInst,
+ {2, 3, 1, 2, 4, 5})})},
{PREAMBLE "%3 = OpExtInst %2 %1 WriteInvocationAMD %4 %5 %6\n",
- Concatenate({MakeInstruction(SpvOpExtInstImport, {1},
+ Concatenate({MakeInstruction(spv::Op::OpExtInstImport, {1},
MakeVector("SPV_AMD_shader_ballot")),
- MakeInstruction(SpvOpExtInst,
+ MakeInstruction(spv::Op::OpExtInst,
{2, 3, 1, 3, 4, 5, 6})})},
{PREAMBLE "%3 = OpExtInst %2 %1 MbcntAMD %4\n",
- Concatenate({MakeInstruction(SpvOpExtInstImport, {1},
+ Concatenate({MakeInstruction(spv::Op::OpExtInstImport, {1},
MakeVector("SPV_AMD_shader_ballot")),
- MakeInstruction(SpvOpExtInst, {2, 3, 1, 4, 4})})},
+ MakeInstruction(spv::Op::OpExtInst,
+ {2, 3, 1, 4, 4})})},
})));
#undef PREAMBLE
@@ -500,16 +543,18 @@ INSTANTIATE_TEST_SUITE_P(
SPV_KHR_variable_pointers, ExtensionRoundTripTest,
// We'll get coverage over operand tables by trying the universal
// environments, and at least one specific environment.
- Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
- SPV_ENV_VULKAN_1_0),
- ValuesIn(std::vector<AssemblyCase>{
- {"OpCapability VariablePointers\n",
- MakeInstruction(SpvOpCapability,
- {SpvCapabilityVariablePointers})},
- {"OpCapability VariablePointersStorageBuffer\n",
- MakeInstruction(SpvOpCapability,
- {SpvCapabilityVariablePointersStorageBuffer})},
- })));
+ Combine(
+ Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
+ SPV_ENV_VULKAN_1_0),
+ ValuesIn(std::vector<AssemblyCase>{
+ {"OpCapability VariablePointers\n",
+ MakeInstruction(spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::VariablePointers})},
+ {"OpCapability VariablePointersStorageBuffer\n",
+ MakeInstruction(
+ spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::VariablePointersStorageBuffer})},
+ })));
// SPV_KHR_vulkan_memory_model
@@ -528,126 +573,145 @@ INSTANTIATE_TEST_SUITE_P(
SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1),
ValuesIn(std::vector<AssemblyCase>{
{"OpCapability VulkanMemoryModel\n",
- MakeInstruction(SpvOpCapability,
- {SpvCapabilityVulkanMemoryModelKHR})},
+ MakeInstruction(
+ spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::VulkanMemoryModelKHR})},
{"OpCapability VulkanMemoryModelDeviceScope\n",
- MakeInstruction(SpvOpCapability,
- {SpvCapabilityVulkanMemoryModelDeviceScopeKHR})},
+ MakeInstruction(
+ spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::VulkanMemoryModelDeviceScopeKHR})},
{"OpMemoryModel Logical Vulkan\n",
- MakeInstruction(SpvOpMemoryModel, {SpvAddressingModelLogical,
- SpvMemoryModelVulkanKHR})},
+ MakeInstruction(spv::Op::OpMemoryModel,
+ {(uint32_t)spv::AddressingModel::Logical,
+ (uint32_t)spv::MemoryModel::VulkanKHR})},
{"OpStore %1 %2 MakePointerAvailable %3\n",
- MakeInstruction(SpvOpStore,
- {1, 2, SpvMemoryAccessMakePointerAvailableKHRMask,
- 3})},
+ MakeInstruction(
+ spv::Op::OpStore,
+ {1, 2,
+ (uint32_t)spv::MemoryAccessMask::MakePointerAvailableKHR,
+ 3})},
{"OpStore %1 %2 Volatile|MakePointerAvailable %3\n",
- MakeInstruction(SpvOpStore,
- {1, 2,
- int(SpvMemoryAccessMakePointerAvailableKHRMask) |
- int(SpvMemoryAccessVolatileMask),
- 3})},
+ MakeInstruction(
+ spv::Op::OpStore,
+ {1, 2,
+ int(spv::MemoryAccessMask::MakePointerAvailableKHR) |
+ int(spv::MemoryAccessMask::Volatile),
+ 3})},
{"OpStore %1 %2 Aligned|MakePointerAvailable 4 %3\n",
- MakeInstruction(SpvOpStore,
- {1, 2,
- int(SpvMemoryAccessMakePointerAvailableKHRMask) |
- int(SpvMemoryAccessAlignedMask),
- 4, 3})},
+ MakeInstruction(
+ spv::Op::OpStore,
+ {1, 2,
+ int(spv::MemoryAccessMask::MakePointerAvailableKHR) |
+ int(spv::MemoryAccessMask::Aligned),
+ 4, 3})},
{"OpStore %1 %2 MakePointerAvailable|NonPrivatePointer %3\n",
- MakeInstruction(SpvOpStore,
- {1, 2,
- int(SpvMemoryAccessMakePointerAvailableKHRMask) |
- int(SpvMemoryAccessNonPrivatePointerKHRMask),
- 3})},
+ MakeInstruction(
+ spv::Op::OpStore,
+ {1, 2,
+ int(spv::MemoryAccessMask::MakePointerAvailableKHR) |
+ int(spv::MemoryAccessMask::NonPrivatePointerKHR),
+ 3})},
{"%2 = OpLoad %1 %3 MakePointerVisible %4\n",
- MakeInstruction(SpvOpLoad,
- {1, 2, 3, SpvMemoryAccessMakePointerVisibleKHRMask,
- 4})},
+ MakeInstruction(
+ spv::Op::OpLoad,
+ {1, 2, 3,
+ (uint32_t)spv::MemoryAccessMask::MakePointerVisibleKHR, 4})},
{"%2 = OpLoad %1 %3 Volatile|MakePointerVisible %4\n",
- MakeInstruction(SpvOpLoad,
- {1, 2, 3,
- int(SpvMemoryAccessMakePointerVisibleKHRMask) |
- int(SpvMemoryAccessVolatileMask),
- 4})},
+ MakeInstruction(
+ spv::Op::OpLoad,
+ {1, 2, 3,
+ int(spv::MemoryAccessMask::MakePointerVisibleKHR) |
+ int(spv::MemoryAccessMask::Volatile),
+ 4})},
{"%2 = OpLoad %1 %3 Aligned|MakePointerVisible 8 %4\n",
- MakeInstruction(SpvOpLoad,
- {1, 2, 3,
- int(SpvMemoryAccessMakePointerVisibleKHRMask) |
- int(SpvMemoryAccessAlignedMask),
- 8, 4})},
+ MakeInstruction(
+ spv::Op::OpLoad,
+ {1, 2, 3,
+ int(spv::MemoryAccessMask::MakePointerVisibleKHR) |
+ int(spv::MemoryAccessMask::Aligned),
+ 8, 4})},
{"%2 = OpLoad %1 %3 MakePointerVisible|NonPrivatePointer "
"%4\n",
- MakeInstruction(SpvOpLoad,
- {1, 2, 3,
- int(SpvMemoryAccessMakePointerVisibleKHRMask) |
- int(SpvMemoryAccessNonPrivatePointerKHRMask),
- 4})},
+ MakeInstruction(
+ spv::Op::OpLoad,
+ {1, 2, 3,
+ int(spv::MemoryAccessMask::MakePointerVisibleKHR) |
+ int(spv::MemoryAccessMask::NonPrivatePointerKHR),
+ 4})},
{"OpCopyMemory %1 %2 "
"MakePointerAvailable|"
"MakePointerVisible|"
"NonPrivatePointer "
"%3 %4\n",
- MakeInstruction(SpvOpCopyMemory,
- {1, 2,
- (int(SpvMemoryAccessMakePointerVisibleKHRMask) |
- int(SpvMemoryAccessMakePointerAvailableKHRMask) |
- int(SpvMemoryAccessNonPrivatePointerKHRMask)),
- 3, 4})},
+ MakeInstruction(
+ spv::Op::OpCopyMemory,
+ {1, 2,
+ (int(spv::MemoryAccessMask::MakePointerVisibleKHR) |
+ int(spv::MemoryAccessMask::MakePointerAvailableKHR) |
+ int(spv::MemoryAccessMask::NonPrivatePointerKHR)),
+ 3, 4})},
{"OpCopyMemorySized %1 %2 %3 "
"MakePointerAvailable|"
"MakePointerVisible|"
"NonPrivatePointer "
"%4 %5\n",
- MakeInstruction(SpvOpCopyMemorySized,
- {1, 2, 3,
- (int(SpvMemoryAccessMakePointerVisibleKHRMask) |
- int(SpvMemoryAccessMakePointerAvailableKHRMask) |
- int(SpvMemoryAccessNonPrivatePointerKHRMask)),
- 4, 5})},
+ MakeInstruction(
+ spv::Op::OpCopyMemorySized,
+ {1, 2, 3,
+ (int(spv::MemoryAccessMask::MakePointerVisibleKHR) |
+ int(spv::MemoryAccessMask::MakePointerAvailableKHR) |
+ int(spv::MemoryAccessMask::NonPrivatePointerKHR)),
+ 4, 5})},
// Image operands
{"OpImageWrite %1 %2 %3 MakeTexelAvailable "
"%4\n",
MakeInstruction(
- SpvOpImageWrite,
- {1, 2, 3, int(SpvImageOperandsMakeTexelAvailableKHRMask), 4})},
+ spv::Op::OpImageWrite,
+ {1, 2, 3, int(spv::ImageOperandsMask::MakeTexelAvailableKHR),
+ 4})},
{"OpImageWrite %1 %2 %3 MakeTexelAvailable|NonPrivateTexel "
"%4\n",
- MakeInstruction(SpvOpImageWrite,
- {1, 2, 3,
- int(SpvImageOperandsMakeTexelAvailableKHRMask) |
- int(SpvImageOperandsNonPrivateTexelKHRMask),
- 4})},
+ MakeInstruction(
+ spv::Op::OpImageWrite,
+ {1, 2, 3,
+ int(spv::ImageOperandsMask::MakeTexelAvailableKHR) |
+ int(spv::ImageOperandsMask::NonPrivateTexelKHR),
+ 4})},
{"OpImageWrite %1 %2 %3 "
"MakeTexelAvailable|NonPrivateTexel|VolatileTexel "
"%4\n",
- MakeInstruction(SpvOpImageWrite,
- {1, 2, 3,
- int(SpvImageOperandsMakeTexelAvailableKHRMask) |
- int(SpvImageOperandsNonPrivateTexelKHRMask) |
- int(SpvImageOperandsVolatileTexelKHRMask),
- 4})},
+ MakeInstruction(
+ spv::Op::OpImageWrite,
+ {1, 2, 3,
+ int(spv::ImageOperandsMask::MakeTexelAvailableKHR) |
+ int(spv::ImageOperandsMask::NonPrivateTexelKHR) |
+ int(spv::ImageOperandsMask::VolatileTexelKHR),
+ 4})},
{"%2 = OpImageRead %1 %3 %4 MakeTexelVisible "
"%5\n",
- MakeInstruction(SpvOpImageRead,
+ MakeInstruction(spv::Op::OpImageRead,
{1, 2, 3, 4,
- int(SpvImageOperandsMakeTexelVisibleKHRMask),
+ int(spv::ImageOperandsMask::MakeTexelVisibleKHR),
5})},
{"%2 = OpImageRead %1 %3 %4 "
"MakeTexelVisible|NonPrivateTexel "
"%5\n",
- MakeInstruction(SpvOpImageRead,
- {1, 2, 3, 4,
- int(SpvImageOperandsMakeTexelVisibleKHRMask) |
- int(SpvImageOperandsNonPrivateTexelKHRMask),
- 5})},
+ MakeInstruction(
+ spv::Op::OpImageRead,
+ {1, 2, 3, 4,
+ int(spv::ImageOperandsMask::MakeTexelVisibleKHR) |
+ int(spv::ImageOperandsMask::NonPrivateTexelKHR),
+ 5})},
{"%2 = OpImageRead %1 %3 %4 "
"MakeTexelVisible|NonPrivateTexel|VolatileTexel "
"%5\n",
- MakeInstruction(SpvOpImageRead,
- {1, 2, 3, 4,
- int(SpvImageOperandsMakeTexelVisibleKHRMask) |
- int(SpvImageOperandsNonPrivateTexelKHRMask) |
- int(SpvImageOperandsVolatileTexelKHRMask),
- 5})},
+ MakeInstruction(
+ spv::Op::OpImageRead,
+ {1, 2, 3, 4,
+ int(spv::ImageOperandsMask::MakeTexelVisibleKHR) |
+ int(spv::ImageOperandsMask::NonPrivateTexelKHR) |
+ int(spv::ImageOperandsMask::VolatileTexelKHR),
+ 5})},
// Memory semantics ID values are numbers put into a SPIR-V
// constant integer referenced by Id. There is no token for
@@ -670,20 +734,20 @@ INSTANTIATE_TEST_SUITE_P(
SPV_ENV_UNIVERSAL_1_2, SPV_ENV_VULKAN_1_0),
ValuesIn(std::vector<AssemblyCase>{
{"OpDecorateString %1 UserSemantic \"ABC\"\n",
- MakeInstruction(SpvOpDecorateStringGOOGLE,
- {1, SpvDecorationHlslSemanticGOOGLE},
+ MakeInstruction(spv::Op::OpDecorateStringGOOGLE,
+ {1, (uint32_t)spv::Decoration::HlslSemanticGOOGLE},
MakeVector("ABC"))},
{"OpDecorateString %1 UserSemantic \"ABC\"\n",
- MakeInstruction(SpvOpDecorateString,
- {1, SpvDecorationUserSemantic},
+ MakeInstruction(spv::Op::OpDecorateString,
+ {1, (uint32_t)spv::Decoration::UserSemantic},
MakeVector("ABC"))},
{"OpMemberDecorateString %1 3 UserSemantic \"DEF\"\n",
- MakeInstruction(SpvOpMemberDecorateStringGOOGLE,
- {1, 3, SpvDecorationUserSemantic},
+ MakeInstruction(spv::Op::OpMemberDecorateStringGOOGLE,
+ {1, 3, (uint32_t)spv::Decoration::UserSemantic},
MakeVector("DEF"))},
{"OpMemberDecorateString %1 3 UserSemantic \"DEF\"\n",
- MakeInstruction(SpvOpMemberDecorateString,
- {1, 3, SpvDecorationUserSemantic},
+ MakeInstruction(spv::Op::OpMemberDecorateString,
+ {1, 3, (uint32_t)spv::Decoration::UserSemantic},
MakeVector("DEF"))},
})));
@@ -696,12 +760,13 @@ INSTANTIATE_TEST_SUITE_P(
SPV_ENV_UNIVERSAL_1_2, SPV_ENV_VULKAN_1_0),
ValuesIn(std::vector<AssemblyCase>{
{"OpDecorateStringGOOGLE %1 HlslSemanticGOOGLE \"ABC\"\n",
- MakeInstruction(SpvOpDecorateStringGOOGLE,
- {1, SpvDecorationHlslSemanticGOOGLE},
+ MakeInstruction(spv::Op::OpDecorateStringGOOGLE,
+ {1, (uint32_t)spv::Decoration::HlslSemanticGOOGLE},
MakeVector("ABC"))},
{"OpMemberDecorateStringGOOGLE %1 3 HlslSemanticGOOGLE \"DEF\"\n",
- MakeInstruction(SpvOpMemberDecorateStringGOOGLE,
- {1, 3, SpvDecorationHlslSemanticGOOGLE},
+ MakeInstruction(spv::Op::OpMemberDecorateStringGOOGLE,
+ {1, 3,
+ (uint32_t)spv::Decoration::HlslSemanticGOOGLE},
MakeVector("DEF"))},
})));
@@ -721,11 +786,12 @@ INSTANTIATE_TEST_SUITE_P(
// they are coupled together.
ValuesIn(std::vector<AssemblyCase>{
{"OpDecorateId %1 CounterBuffer %2\n",
- MakeInstruction(SpvOpDecorateId,
- {1, SpvDecorationHlslCounterBufferGOOGLE, 2})},
+ MakeInstruction(
+ spv::Op::OpDecorateId,
+ {1, (uint32_t)spv::Decoration::HlslCounterBufferGOOGLE, 2})},
{"OpDecorateId %1 CounterBuffer %2\n",
- MakeInstruction(SpvOpDecorateId,
- {1, SpvDecorationCounterBuffer, 2})},
+ MakeInstruction(spv::Op::OpDecorateId,
+ {1, (uint32_t)spv::Decoration::CounterBuffer, 2})},
})));
INSTANTIATE_TEST_SUITE_P(
@@ -739,8 +805,9 @@ INSTANTIATE_TEST_SUITE_P(
// they are coupled together.
ValuesIn(std::vector<AssemblyCase>{
{"OpDecorateId %1 HlslCounterBufferGOOGLE %2\n",
- MakeInstruction(SpvOpDecorateId,
- {1, SpvDecorationHlslCounterBufferGOOGLE, 2})},
+ MakeInstruction(
+ spv::Op::OpDecorateId,
+ {1, (uint32_t)spv::Decoration::HlslCounterBufferGOOGLE, 2})},
})));
// SPV_NV_viewport_array2
@@ -752,23 +819,26 @@ INSTANTIATE_TEST_SUITE_P(
SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1),
ValuesIn(std::vector<AssemblyCase>{
{"OpExtension \"SPV_NV_viewport_array2\"\n",
- MakeInstruction(SpvOpExtension,
+ MakeInstruction(spv::Op::OpExtension,
MakeVector("SPV_NV_viewport_array2"))},
// The EXT and NV extensions have the same token number for this
// capability.
{"OpCapability ShaderViewportIndexLayerEXT\n",
- MakeInstruction(SpvOpCapability,
- {SpvCapabilityShaderViewportIndexLayerNV})},
+ MakeInstruction(
+ spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::ShaderViewportIndexLayerNV})},
// Check the new capability's token number
{"OpCapability ShaderViewportIndexLayerEXT\n",
- MakeInstruction(SpvOpCapability, {5254})},
+ MakeInstruction(spv::Op::OpCapability, {5254})},
// Decorations
{"OpDecorate %1 ViewportRelativeNV\n",
- MakeInstruction(SpvOpDecorate,
- {1, SpvDecorationViewportRelativeNV})},
+ MakeInstruction(
+ spv::Op::OpDecorate,
+ {1, (uint32_t)spv::Decoration::ViewportRelativeNV})},
{"OpDecorate %1 BuiltIn ViewportMaskNV\n",
- MakeInstruction(SpvOpDecorate, {1, SpvDecorationBuiltIn,
- SpvBuiltInViewportMaskNV})},
+ MakeInstruction(spv::Op::OpDecorate,
+ {1, (uint32_t)spv::Decoration::BuiltIn,
+ (uint32_t)spv::BuiltIn::ViewportMaskNV})},
})));
// SPV_NV_shader_subgroup_partitioned
@@ -779,38 +849,44 @@ INSTANTIATE_TEST_SUITE_P(
Values(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_1),
ValuesIn(std::vector<AssemblyCase>{
{"OpExtension \"SPV_NV_shader_subgroup_partitioned\"\n",
- MakeInstruction(SpvOpExtension,
+ MakeInstruction(spv::Op::OpExtension,
MakeVector("SPV_NV_shader_subgroup_partitioned"))},
{"OpCapability GroupNonUniformPartitionedNV\n",
- MakeInstruction(SpvOpCapability,
- {SpvCapabilityGroupNonUniformPartitionedNV})},
+ MakeInstruction(
+ spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::GroupNonUniformPartitionedNV})},
// Check the new capability's token number
{"OpCapability GroupNonUniformPartitionedNV\n",
- MakeInstruction(SpvOpCapability, {5297})},
+ MakeInstruction(spv::Op::OpCapability, {5297})},
{"%2 = OpGroupNonUniformPartitionNV %1 %3\n",
- MakeInstruction(SpvOpGroupNonUniformPartitionNV, {1, 2, 3})},
+ MakeInstruction(spv::Op::OpGroupNonUniformPartitionNV, {1, 2, 3})},
// Check the new instruction's token number
{"%2 = OpGroupNonUniformPartitionNV %1 %3\n",
- MakeInstruction(static_cast<SpvOp>(5296), {1, 2, 3})},
+ MakeInstruction(static_cast<spv::Op>(5296), {1, 2, 3})},
// Check the new group operations
{"%2 = OpGroupIAdd %1 %3 PartitionedReduceNV %4\n",
- MakeInstruction(SpvOpGroupIAdd,
- {1, 2, 3, SpvGroupOperationPartitionedReduceNV,
- 4})},
+ MakeInstruction(
+ spv::Op::OpGroupIAdd,
+ {1, 2, 3, (uint32_t)spv::GroupOperation::PartitionedReduceNV,
+ 4})},
{"%2 = OpGroupIAdd %1 %3 PartitionedReduceNV %4\n",
- MakeInstruction(SpvOpGroupIAdd, {1, 2, 3, 6, 4})},
+ MakeInstruction(spv::Op::OpGroupIAdd, {1, 2, 3, 6, 4})},
{"%2 = OpGroupIAdd %1 %3 PartitionedInclusiveScanNV %4\n",
- MakeInstruction(SpvOpGroupIAdd,
- {1, 2, 3,
- SpvGroupOperationPartitionedInclusiveScanNV, 4})},
+ MakeInstruction(
+ spv::Op::OpGroupIAdd,
+ {1, 2, 3,
+ (uint32_t)spv::GroupOperation::PartitionedInclusiveScanNV,
+ 4})},
{"%2 = OpGroupIAdd %1 %3 PartitionedInclusiveScanNV %4\n",
- MakeInstruction(SpvOpGroupIAdd, {1, 2, 3, 7, 4})},
+ MakeInstruction(spv::Op::OpGroupIAdd, {1, 2, 3, 7, 4})},
{"%2 = OpGroupIAdd %1 %3 PartitionedExclusiveScanNV %4\n",
- MakeInstruction(SpvOpGroupIAdd,
- {1, 2, 3,
- SpvGroupOperationPartitionedExclusiveScanNV, 4})},
+ MakeInstruction(
+ spv::Op::OpGroupIAdd,
+ {1, 2, 3,
+ (uint32_t)spv::GroupOperation::PartitionedExclusiveScanNV,
+ 4})},
{"%2 = OpGroupIAdd %1 %3 PartitionedExclusiveScanNV %4\n",
- MakeInstruction(SpvOpGroupIAdd, {1, 2, 3, 8, 4})},
+ MakeInstruction(spv::Op::OpGroupIAdd, {1, 2, 3, 8, 4})},
})));
// SPV_EXT_descriptor_indexing
@@ -823,86 +899,90 @@ INSTANTIATE_TEST_SUITE_P(
SPV_ENV_VULKAN_1_1),
ValuesIn(std::vector<AssemblyCase>{
{"OpExtension \"SPV_EXT_descriptor_indexing\"\n",
- MakeInstruction(SpvOpExtension,
+ MakeInstruction(spv::Op::OpExtension,
MakeVector("SPV_EXT_descriptor_indexing"))},
// Check capabilities, by name
{"OpCapability ShaderNonUniform\n",
- MakeInstruction(SpvOpCapability,
- {SpvCapabilityShaderNonUniformEXT})},
+ MakeInstruction(spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::ShaderNonUniformEXT})},
{"OpCapability RuntimeDescriptorArray\n",
- MakeInstruction(SpvOpCapability,
- {SpvCapabilityRuntimeDescriptorArrayEXT})},
- {"OpCapability InputAttachmentArrayDynamicIndexing\n",
MakeInstruction(
- SpvOpCapability,
- {SpvCapabilityInputAttachmentArrayDynamicIndexingEXT})},
+ spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::RuntimeDescriptorArrayEXT})},
+ {"OpCapability InputAttachmentArrayDynamicIndexing\n",
+ MakeInstruction(spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::
+ InputAttachmentArrayDynamicIndexingEXT})},
{"OpCapability UniformTexelBufferArrayDynamicIndexing\n",
- MakeInstruction(
- SpvOpCapability,
- {SpvCapabilityUniformTexelBufferArrayDynamicIndexingEXT})},
+ MakeInstruction(spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::
+ UniformTexelBufferArrayDynamicIndexingEXT})},
{"OpCapability StorageTexelBufferArrayDynamicIndexing\n",
- MakeInstruction(
- SpvOpCapability,
- {SpvCapabilityStorageTexelBufferArrayDynamicIndexingEXT})},
+ MakeInstruction(spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::
+ StorageTexelBufferArrayDynamicIndexingEXT})},
{"OpCapability UniformBufferArrayNonUniformIndexing\n",
- MakeInstruction(
- SpvOpCapability,
- {SpvCapabilityUniformBufferArrayNonUniformIndexingEXT})},
+ MakeInstruction(spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::
+ UniformBufferArrayNonUniformIndexingEXT})},
{"OpCapability SampledImageArrayNonUniformIndexing\n",
- MakeInstruction(
- SpvOpCapability,
- {SpvCapabilitySampledImageArrayNonUniformIndexingEXT})},
+ MakeInstruction(spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::
+ SampledImageArrayNonUniformIndexingEXT})},
{"OpCapability StorageBufferArrayNonUniformIndexing\n",
- MakeInstruction(
- SpvOpCapability,
- {SpvCapabilityStorageBufferArrayNonUniformIndexingEXT})},
+ MakeInstruction(spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::
+ StorageBufferArrayNonUniformIndexingEXT})},
{"OpCapability StorageImageArrayNonUniformIndexing\n",
- MakeInstruction(
- SpvOpCapability,
- {SpvCapabilityStorageImageArrayNonUniformIndexingEXT})},
+ MakeInstruction(spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::
+ StorageImageArrayNonUniformIndexingEXT})},
{"OpCapability InputAttachmentArrayNonUniformIndexing\n",
- MakeInstruction(
- SpvOpCapability,
- {SpvCapabilityInputAttachmentArrayNonUniformIndexingEXT})},
+ MakeInstruction(spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::
+ InputAttachmentArrayNonUniformIndexingEXT})},
{"OpCapability UniformTexelBufferArrayNonUniformIndexing\n",
MakeInstruction(
- SpvOpCapability,
- {SpvCapabilityUniformTexelBufferArrayNonUniformIndexingEXT})},
+ spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::
+ UniformTexelBufferArrayNonUniformIndexingEXT})},
{"OpCapability StorageTexelBufferArrayNonUniformIndexing\n",
MakeInstruction(
- SpvOpCapability,
- {SpvCapabilityStorageTexelBufferArrayNonUniformIndexingEXT})},
+ spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::
+ StorageTexelBufferArrayNonUniformIndexingEXT})},
// Check capabilities, by number
{"OpCapability ShaderNonUniform\n",
- MakeInstruction(SpvOpCapability, {5301})},
+ MakeInstruction(spv::Op::OpCapability, {5301})},
{"OpCapability RuntimeDescriptorArray\n",
- MakeInstruction(SpvOpCapability, {5302})},
+ MakeInstruction(spv::Op::OpCapability, {5302})},
{"OpCapability InputAttachmentArrayDynamicIndexing\n",
- MakeInstruction(SpvOpCapability, {5303})},
+ MakeInstruction(spv::Op::OpCapability, {5303})},
{"OpCapability UniformTexelBufferArrayDynamicIndexing\n",
- MakeInstruction(SpvOpCapability, {5304})},
+ MakeInstruction(spv::Op::OpCapability, {5304})},
{"OpCapability StorageTexelBufferArrayDynamicIndexing\n",
- MakeInstruction(SpvOpCapability, {5305})},
+ MakeInstruction(spv::Op::OpCapability, {5305})},
{"OpCapability UniformBufferArrayNonUniformIndexing\n",
- MakeInstruction(SpvOpCapability, {5306})},
+ MakeInstruction(spv::Op::OpCapability, {5306})},
{"OpCapability SampledImageArrayNonUniformIndexing\n",
- MakeInstruction(SpvOpCapability, {5307})},
+ MakeInstruction(spv::Op::OpCapability, {5307})},
{"OpCapability StorageBufferArrayNonUniformIndexing\n",
- MakeInstruction(SpvOpCapability, {5308})},
+ MakeInstruction(spv::Op::OpCapability, {5308})},
{"OpCapability StorageImageArrayNonUniformIndexing\n",
- MakeInstruction(SpvOpCapability, {5309})},
+ MakeInstruction(spv::Op::OpCapability, {5309})},
{"OpCapability InputAttachmentArrayNonUniformIndexing\n",
- MakeInstruction(SpvOpCapability, {5310})},
+ MakeInstruction(spv::Op::OpCapability, {5310})},
{"OpCapability UniformTexelBufferArrayNonUniformIndexing\n",
- MakeInstruction(SpvOpCapability, {5311})},
+ MakeInstruction(spv::Op::OpCapability, {5311})},
{"OpCapability StorageTexelBufferArrayNonUniformIndexing\n",
- MakeInstruction(SpvOpCapability, {5312})},
+ MakeInstruction(spv::Op::OpCapability, {5312})},
// Check the decoration token
{"OpDecorate %1 NonUniform\n",
- MakeInstruction(SpvOpDecorate, {1, SpvDecorationNonUniformEXT})},
+ MakeInstruction(spv::Op::OpDecorate,
+ {1, (uint32_t)spv::Decoration::NonUniformEXT})},
{"OpDecorate %1 NonUniform\n",
- MakeInstruction(SpvOpDecorate, {1, 5300})},
+ MakeInstruction(spv::Op::OpDecorate, {1, 5300})},
})));
// SPV_KHR_linkonce_odr
@@ -914,13 +994,14 @@ INSTANTIATE_TEST_SUITE_P(
SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_2),
ValuesIn(std::vector<AssemblyCase>{
{"OpExtension \"SPV_KHR_linkonce_odr\"\n",
- MakeInstruction(SpvOpExtension,
+ MakeInstruction(spv::Op::OpExtension,
MakeVector("SPV_KHR_linkonce_odr"))},
{"OpDecorate %1 LinkageAttributes \"foobar\" LinkOnceODR\n",
- MakeInstruction(SpvOpDecorate,
- Concatenate({{1, SpvDecorationLinkageAttributes},
- MakeVector("foobar"),
- {SpvLinkageTypeLinkOnceODR}}))},
+ MakeInstruction(
+ spv::Op::OpDecorate,
+ Concatenate({{1, (uint32_t)spv::Decoration::LinkageAttributes},
+ MakeVector("foobar"),
+ {(uint32_t)spv::LinkageType::LinkOnceODR}}))},
})));
// SPV_KHR_expect_assume
@@ -931,10 +1012,10 @@ INSTANTIATE_TEST_SUITE_P(
SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_2),
ValuesIn(std::vector<AssemblyCase>{
{"OpExtension \"SPV_KHR_expect_assume\"\n",
- MakeInstruction(SpvOpExtension,
+ MakeInstruction(spv::Op::OpExtension,
MakeVector("SPV_KHR_expect_assume"))},
{"OpAssumeTrueKHR %1\n",
- MakeInstruction(SpvOpAssumeTrueKHR, {1})}})));
+ MakeInstruction(spv::Op::OpAssumeTrueKHR, {1})}})));
// SPV_KHR_subgroup_uniform_control_flow
INSTANTIATE_TEST_SUITE_P(
@@ -944,12 +1025,12 @@ INSTANTIATE_TEST_SUITE_P(
ValuesIn(std::vector<AssemblyCase>{
{"OpExtension \"SPV_KHR_subgroup_uniform_control_flow\"\n",
MakeInstruction(
- SpvOpExtension,
+ spv::Op::OpExtension,
MakeVector("SPV_KHR_subgroup_uniform_control_flow"))},
{"OpExecutionMode %1 SubgroupUniformControlFlowKHR\n",
- MakeInstruction(
- SpvOpExecutionMode,
- {1, SpvExecutionModeSubgroupUniformControlFlowKHR})},
+ MakeInstruction(spv::Op::OpExecutionMode,
+ {1, (uint32_t)spv::ExecutionMode::
+ SubgroupUniformControlFlowKHR})},
})));
// SPV_KHR_integer_dot_product
@@ -962,61 +1043,71 @@ INSTANTIATE_TEST_SUITE_P(
SPV_ENV_VULKAN_1_2, SPV_ENV_VULKAN_1_3),
ValuesIn(std::vector<AssemblyCase>{
{"OpExtension \"SPV_KHR_integer_dot_product\"\n",
- MakeInstruction(SpvOpExtension,
+ MakeInstruction(spv::Op::OpExtension,
MakeVector("SPV_KHR_integer_dot_product"))},
{"OpCapability DotProductInputAll\n",
- MakeInstruction(SpvOpCapability,
- {SpvCapabilityDotProductInputAllKHR})},
+ MakeInstruction(
+ spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::DotProductInputAllKHR})},
{"OpCapability DotProductInput4x8Bit\n",
- MakeInstruction(SpvOpCapability,
- {SpvCapabilityDotProductInput4x8BitKHR})},
+ MakeInstruction(
+ spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::DotProductInput4x8BitKHR})},
{"OpCapability DotProductInput4x8BitPacked\n",
- MakeInstruction(SpvOpCapability,
- {SpvCapabilityDotProductInput4x8BitPackedKHR})},
+ MakeInstruction(
+ spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::DotProductInput4x8BitPackedKHR})},
{"OpCapability DotProduct\n",
- MakeInstruction(SpvOpCapability, {SpvCapabilityDotProductKHR})},
+ MakeInstruction(spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::DotProductKHR})},
{"%2 = OpSDot %1 %3 %4\n",
- MakeInstruction(SpvOpSDotKHR, {1, 2, 3, 4})},
+ MakeInstruction(spv::Op::OpSDotKHR, {1, 2, 3, 4})},
{"%2 = OpSDot %1 %3 %4 PackedVectorFormat4x8Bit\n",
MakeInstruction(
- SpvOpSDotKHR,
+ spv::Op::OpSDotKHR,
{1, 2, 3, 4,
- SpvPackedVectorFormatPackedVectorFormat4x8BitKHR})},
+ (uint32_t)
+ spv::PackedVectorFormat::PackedVectorFormat4x8BitKHR})},
{"%2 = OpUDot %1 %3 %4\n",
- MakeInstruction(SpvOpUDotKHR, {1, 2, 3, 4})},
+ MakeInstruction(spv::Op::OpUDotKHR, {1, 2, 3, 4})},
{"%2 = OpUDot %1 %3 %4 PackedVectorFormat4x8Bit\n",
MakeInstruction(
- SpvOpUDotKHR,
+ spv::Op::OpUDotKHR,
{1, 2, 3, 4,
- SpvPackedVectorFormatPackedVectorFormat4x8BitKHR})},
+ (uint32_t)
+ spv::PackedVectorFormat::PackedVectorFormat4x8BitKHR})},
{"%2 = OpSUDot %1 %3 %4\n",
- MakeInstruction(SpvOpSUDotKHR, {1, 2, 3, 4})},
+ MakeInstruction(spv::Op::OpSUDotKHR, {1, 2, 3, 4})},
{"%2 = OpSUDot %1 %3 %4 PackedVectorFormat4x8Bit\n",
MakeInstruction(
- SpvOpSUDotKHR,
+ spv::Op::OpSUDotKHR,
{1, 2, 3, 4,
- SpvPackedVectorFormatPackedVectorFormat4x8BitKHR})},
+ (uint32_t)
+ spv::PackedVectorFormat::PackedVectorFormat4x8BitKHR})},
{"%2 = OpSDotAccSat %1 %3 %4 %5\n",
- MakeInstruction(SpvOpSDotAccSatKHR, {1, 2, 3, 4, 5})},
+ MakeInstruction(spv::Op::OpSDotAccSatKHR, {1, 2, 3, 4, 5})},
{"%2 = OpSDotAccSat %1 %3 %4 %5 PackedVectorFormat4x8Bit\n",
MakeInstruction(
- SpvOpSDotAccSatKHR,
+ spv::Op::OpSDotAccSatKHR,
{1, 2, 3, 4, 5,
- SpvPackedVectorFormatPackedVectorFormat4x8BitKHR})},
+ (uint32_t)
+ spv::PackedVectorFormat::PackedVectorFormat4x8BitKHR})},
{"%2 = OpUDotAccSat %1 %3 %4 %5\n",
- MakeInstruction(SpvOpUDotAccSatKHR, {1, 2, 3, 4, 5})},
+ MakeInstruction(spv::Op::OpUDotAccSatKHR, {1, 2, 3, 4, 5})},
{"%2 = OpUDotAccSat %1 %3 %4 %5 PackedVectorFormat4x8Bit\n",
MakeInstruction(
- SpvOpUDotAccSatKHR,
+ spv::Op::OpUDotAccSatKHR,
{1, 2, 3, 4, 5,
- SpvPackedVectorFormatPackedVectorFormat4x8BitKHR})},
+ (uint32_t)
+ spv::PackedVectorFormat::PackedVectorFormat4x8BitKHR})},
{"%2 = OpSUDotAccSat %1 %3 %4 %5\n",
- MakeInstruction(SpvOpSUDotAccSatKHR, {1, 2, 3, 4, 5})},
+ MakeInstruction(spv::Op::OpSUDotAccSatKHR, {1, 2, 3, 4, 5})},
{"%2 = OpSUDotAccSat %1 %3 %4 %5 PackedVectorFormat4x8Bit\n",
MakeInstruction(
- SpvOpSUDotAccSatKHR,
+ spv::Op::OpSUDotAccSatKHR,
{1, 2, 3, 4, 5,
- SpvPackedVectorFormatPackedVectorFormat4x8BitKHR})},
+ (uint32_t)
+ spv::PackedVectorFormat::PackedVectorFormat4x8BitKHR})},
})));
// SPV_KHR_bit_instructions
@@ -1027,11 +1118,11 @@ INSTANTIATE_TEST_SUITE_P(
SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_2),
ValuesIn(std::vector<AssemblyCase>{
{"OpExtension \"SPV_KHR_bit_instructions\"\n",
- MakeInstruction(SpvOpExtension,
+ MakeInstruction(spv::Op::OpExtension,
MakeVector("SPV_KHR_bit_instructions"))},
{"OpCapability BitInstructions\n",
- MakeInstruction(SpvOpCapability,
- {SpvCapabilityBitInstructions})},
+ MakeInstruction(spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::BitInstructions})},
})));
// SPV_KHR_uniform_group_instructions
@@ -1044,35 +1135,44 @@ INSTANTIATE_TEST_SUITE_P(
SPV_ENV_VULKAN_1_2, SPV_ENV_VULKAN_1_3),
ValuesIn(std::vector<AssemblyCase>{
{"OpExtension \"SPV_KHR_uniform_group_instructions\"\n",
- MakeInstruction(SpvOpExtension,
+ MakeInstruction(spv::Op::OpExtension,
MakeVector("SPV_KHR_uniform_group_instructions"))},
{"OpCapability GroupUniformArithmeticKHR\n",
- MakeInstruction(SpvOpCapability,
- {SpvCapabilityGroupUniformArithmeticKHR})},
+ MakeInstruction(
+ spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::GroupUniformArithmeticKHR})},
{"%2 = OpGroupIMulKHR %1 %3 Reduce %4\n",
- MakeInstruction(SpvOpGroupIMulKHR,
- {1, 2, 3, SpvGroupOperationReduce, 4})},
+ MakeInstruction(spv::Op::OpGroupIMulKHR,
+ {1, 2, 3, (uint32_t)spv::GroupOperation::Reduce,
+ 4})},
{"%2 = OpGroupFMulKHR %1 %3 Reduce %4\n",
- MakeInstruction(SpvOpGroupFMulKHR,
- {1, 2, 3, SpvGroupOperationReduce, 4})},
+ MakeInstruction(spv::Op::OpGroupFMulKHR,
+ {1, 2, 3, (uint32_t)spv::GroupOperation::Reduce,
+ 4})},
{"%2 = OpGroupBitwiseAndKHR %1 %3 Reduce %4\n",
- MakeInstruction(SpvOpGroupBitwiseAndKHR,
- {1, 2, 3, SpvGroupOperationReduce, 4})},
+ MakeInstruction(spv::Op::OpGroupBitwiseAndKHR,
+ {1, 2, 3, (uint32_t)spv::GroupOperation::Reduce,
+ 4})},
{"%2 = OpGroupBitwiseOrKHR %1 %3 Reduce %4\n",
- MakeInstruction(SpvOpGroupBitwiseOrKHR,
- {1, 2, 3, SpvGroupOperationReduce, 4})},
+ MakeInstruction(spv::Op::OpGroupBitwiseOrKHR,
+ {1, 2, 3, (uint32_t)spv::GroupOperation::Reduce,
+ 4})},
{"%2 = OpGroupBitwiseXorKHR %1 %3 Reduce %4\n",
- MakeInstruction(SpvOpGroupBitwiseXorKHR,
- {1, 2, 3, SpvGroupOperationReduce, 4})},
+ MakeInstruction(spv::Op::OpGroupBitwiseXorKHR,
+ {1, 2, 3, (uint32_t)spv::GroupOperation::Reduce,
+ 4})},
{"%2 = OpGroupLogicalAndKHR %1 %3 Reduce %4\n",
- MakeInstruction(SpvOpGroupLogicalAndKHR,
- {1, 2, 3, SpvGroupOperationReduce, 4})},
+ MakeInstruction(spv::Op::OpGroupLogicalAndKHR,
+ {1, 2, 3, (uint32_t)spv::GroupOperation::Reduce,
+ 4})},
{"%2 = OpGroupLogicalOrKHR %1 %3 Reduce %4\n",
- MakeInstruction(SpvOpGroupLogicalOrKHR,
- {1, 2, 3, SpvGroupOperationReduce, 4})},
+ MakeInstruction(spv::Op::OpGroupLogicalOrKHR,
+ {1, 2, 3, (uint32_t)spv::GroupOperation::Reduce,
+ 4})},
{"%2 = OpGroupLogicalXorKHR %1 %3 Reduce %4\n",
- MakeInstruction(SpvOpGroupLogicalXorKHR,
- {1, 2, 3, SpvGroupOperationReduce, 4})},
+ MakeInstruction(spv::Op::OpGroupLogicalXorKHR,
+ {1, 2, 3, (uint32_t)spv::GroupOperation::Reduce,
+ 4})},
})));
// SPV_KHR_subgroup_rotate
@@ -1084,16 +1184,17 @@ INSTANTIATE_TEST_SUITE_P(
SPV_ENV_VULKAN_1_3, SPV_ENV_OPENCL_2_1),
ValuesIn(std::vector<AssemblyCase>{
{"OpExtension \"SPV_KHR_subgroup_rotate\"\n",
- MakeInstruction(SpvOpExtension,
+ MakeInstruction(spv::Op::OpExtension,
MakeVector("SPV_KHR_subgroup_rotate"))},
{"OpCapability GroupNonUniformRotateKHR\n",
- MakeInstruction(SpvOpCapability,
- {SpvCapabilityGroupNonUniformRotateKHR})},
+ MakeInstruction(
+ spv::Op::OpCapability,
+ {(uint32_t)spv::Capability::GroupNonUniformRotateKHR})},
{"%2 = OpGroupNonUniformRotateKHR %1 %3 %4 %5\n",
- MakeInstruction(SpvOpGroupNonUniformRotateKHR,
+ MakeInstruction(spv::Op::OpGroupNonUniformRotateKHR,
{1, 2, 3, 4, 5})},
{"%2 = OpGroupNonUniformRotateKHR %1 %3 %4 %5 %6\n",
- MakeInstruction(SpvOpGroupNonUniformRotateKHR,
+ MakeInstruction(spv::Op::OpGroupNonUniformRotateKHR,
{1, 2, 3, 4, 5, 6})},
})));
diff --git a/test/text_to_binary.function_test.cpp b/test/text_to_binary.function_test.cpp
index 55a8e6ce6..9361d6c6c 100644
--- a/test/text_to_binary.function_test.cpp
+++ b/test/text_to_binary.function_test.cpp
@@ -33,25 +33,25 @@ using ::testing::Eq;
// Test OpFunction
using OpFunctionControlTest = spvtest::TextToBinaryTestBase<
- ::testing::TestWithParam<EnumCase<SpvFunctionControlMask>>>;
+ ::testing::TestWithParam<EnumCase<spv::FunctionControlMask>>>;
TEST_P(OpFunctionControlTest, AnySingleFunctionControlMask) {
const std::string input = "%result_id = OpFunction %result_type " +
GetParam().name() + " %function_type ";
- EXPECT_THAT(
- CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpFunction, {1, 2, GetParam().value(), 3})));
+ EXPECT_THAT(CompiledInstructions(input),
+ Eq(MakeInstruction(spv::Op::OpFunction,
+ {1, 2, (uint32_t)GetParam().value(), 3})));
}
// clang-format off
-#define CASE(VALUE,NAME) { SpvFunctionControl##VALUE, NAME }
+#define CASE(VALUE,NAME) { spv::FunctionControlMask::VALUE, NAME }
INSTANTIATE_TEST_SUITE_P(TextToBinaryFunctionTest, OpFunctionControlTest,
- ::testing::ValuesIn(std::vector<EnumCase<SpvFunctionControlMask>>{
+ ::testing::ValuesIn(std::vector<EnumCase<spv::FunctionControlMask>>{
CASE(MaskNone, "None"),
- CASE(InlineMask, "Inline"),
- CASE(DontInlineMask, "DontInline"),
- CASE(PureMask, "Pure"),
- CASE(ConstMask, "Const"),
+ CASE(Inline, "Inline"),
+ CASE(DontInline, "DontInline"),
+ CASE(Pure, "Pure"),
+ CASE(Const, "Const"),
}));
#undef CASE
// clang-format on
@@ -61,11 +61,12 @@ TEST_F(OpFunctionControlTest, CombinedFunctionControlMask) {
// the instruction parsing logic with spvTextParseMask.
const std::string input =
"%result_id = OpFunction %result_type Inline|Pure|Const %function_type";
- const uint32_t expected_mask = SpvFunctionControlInlineMask |
- SpvFunctionControlPureMask |
- SpvFunctionControlConstMask;
- EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpFunction, {1, 2, expected_mask, 3})));
+ const uint32_t expected_mask = uint32_t(spv::FunctionControlMask::Inline |
+ spv::FunctionControlMask::Pure |
+ spv::FunctionControlMask::Const);
+ EXPECT_THAT(
+ CompiledInstructions(input),
+ Eq(MakeInstruction(spv::Op::OpFunction, {1, 2, expected_mask, 3})));
}
TEST_F(OpFunctionControlTest, WrongFunctionControl) {
diff --git a/test/text_to_binary.group_test.cpp b/test/text_to_binary.group_test.cpp
index becc3aa6f..606e00e9d 100644
--- a/test/text_to_binary.group_test.cpp
+++ b/test/text_to_binary.group_test.cpp
@@ -32,20 +32,20 @@ using ::testing::Eq;
// Test GroupOperation enum
using GroupOperationTest = spvtest::TextToBinaryTestBase<
- ::testing::TestWithParam<EnumCase<SpvGroupOperation>>>;
+ ::testing::TestWithParam<EnumCase<spv::GroupOperation>>>;
TEST_P(GroupOperationTest, AnyGroupOperation) {
const std::string input =
"%result = OpGroupIAdd %type %scope " + GetParam().name() + " %x";
- EXPECT_THAT(
- CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpGroupIAdd, {1, 2, 3, GetParam().value(), 4})));
+ EXPECT_THAT(CompiledInstructions(input),
+ Eq(MakeInstruction(spv::Op::OpGroupIAdd,
+ {1, 2, 3, (uint32_t)GetParam().value(), 4})));
}
// clang-format off
-#define CASE(NAME) { SpvGroupOperation##NAME, #NAME}
+#define CASE(NAME) { spv::GroupOperation::NAME, #NAME}
INSTANTIATE_TEST_SUITE_P(TextToBinaryGroupOperation, GroupOperationTest,
- ::testing::ValuesIn(std::vector<EnumCase<SpvGroupOperation>>{
+ ::testing::ValuesIn(std::vector<EnumCase<spv::GroupOperation>>{
CASE(Reduce),
CASE(InclusiveScan),
CASE(ExclusiveScan),
diff --git a/test/text_to_binary.image_test.cpp b/test/text_to_binary.image_test.cpp
index 8d8ff4328..3e7a560ad 100644
--- a/test/text_to_binary.image_test.cpp
+++ b/test/text_to_binary.image_test.cpp
@@ -45,11 +45,11 @@ TEST_P(ImageOperandsTest, Sample) {
const std::string input =
"%2 = OpImageFetch %1 %3 %4" + GetParam().image_operands + "\n";
EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpImageFetch, {1, 2, 3, 4},
+ Eq(MakeInstruction(spv::Op::OpImageFetch, {1, 2, 3, 4},
GetParam().expected_mask_and_operands)));
}
-#define MASK(NAME) SpvImageOperands##NAME##Mask
+#define MASK(NAME) uint32_t(spv::ImageOperandsMask::NAME)
INSTANTIATE_TEST_SUITE_P(
TextToBinaryImageOperandsAny, ImageOperandsTest,
::testing::ValuesIn(std::vector<ImageOperandsCase>{
@@ -68,7 +68,7 @@ INSTANTIATE_TEST_SUITE_P(
{" MinLod %5", {MASK(MinLod), 5}},
}));
#undef MASK
-#define MASK(NAME) static_cast<uint32_t>(SpvImageOperands##NAME##Mask)
+#define MASK(NAME) static_cast<uint32_t>(spv::ImageOperandsMask::NAME)
INSTANTIATE_TEST_SUITE_P(
TextToBinaryImageOperandsCombination, ImageOperandsTest,
::testing::ValuesIn(std::vector<ImageOperandsCase>{
@@ -110,7 +110,7 @@ using OpImageTest = TextToBinaryTest;
TEST_F(OpImageTest, Valid) {
const std::string input = "%2 = OpImage %1 %3\n";
EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpImage, {1, 2, 3})));
+ Eq(MakeInstruction(spv::Op::OpImage, {1, 2, 3})));
// Test the disassembler.
EXPECT_THAT(EncodeAndDecodeSuccessfully(input), input);
@@ -153,7 +153,7 @@ using OpImageSparseReadTest = TextToBinaryTest;
TEST_F(OpImageSparseReadTest, OnlyRequiredOperands) {
const std::string input = "%2 = OpImageSparseRead %1 %3 %4\n";
EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpImageSparseRead, {1, 2, 3, 4})));
+ Eq(MakeInstruction(spv::Op::OpImageSparseRead, {1, 2, 3, 4})));
// Test the disassembler.
EXPECT_THAT(EncodeAndDecodeSuccessfully(input), input);
}
@@ -167,13 +167,13 @@ TEST_P(ImageSparseReadImageOperandsTest, Sample) {
const std::string input =
"%2 = OpImageSparseRead %1 %3 %4" + GetParam().image_operands + "\n";
EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpImageSparseRead, {1, 2, 3, 4},
+ Eq(MakeInstruction(spv::Op::OpImageSparseRead, {1, 2, 3, 4},
GetParam().expected_mask_and_operands)));
// Test the disassembler.
EXPECT_THAT(EncodeAndDecodeSuccessfully(input), input);
}
-#define MASK(NAME) SpvImageOperands##NAME##Mask
+#define MASK(NAME) uint32_t(spv::ImageOperandsMask::NAME)
INSTANTIATE_TEST_SUITE_P(ImageSparseReadImageOperandsAny,
ImageSparseReadImageOperandsTest,
::testing::ValuesIn(std::vector<ImageOperandsCase>{
@@ -190,7 +190,7 @@ INSTANTIATE_TEST_SUITE_P(ImageSparseReadImageOperandsAny,
{" MinLod %5", {MASK(MinLod), 5}},
}));
#undef MASK
-#define MASK(NAME) static_cast<uint32_t>(SpvImageOperands##NAME##Mask)
+#define MASK(NAME) static_cast<uint32_t>(spv::ImageOperandsMask::NAME)
INSTANTIATE_TEST_SUITE_P(
ImageSparseReadImageOperandsCombination, ImageSparseReadImageOperandsTest,
::testing::ValuesIn(std::vector<ImageOperandsCase>{
diff --git a/test/text_to_binary.memory_test.cpp b/test/text_to_binary.memory_test.cpp
index f94c134a0..629ab661b 100644
--- a/test/text_to_binary.memory_test.cpp
+++ b/test/text_to_binary.memory_test.cpp
@@ -35,51 +35,53 @@ using ::testing::HasSubstr;
// Test assembly of Memory Access masks
using MemoryAccessTest = spvtest::TextToBinaryTestBase<
- ::testing::TestWithParam<EnumCase<SpvMemoryAccessMask>>>;
+ ::testing::TestWithParam<EnumCase<spv::MemoryAccessMask>>>;
TEST_P(MemoryAccessTest, AnySingleMemoryAccessMask) {
std::stringstream input;
input << "OpStore %ptr %value " << GetParam().name();
for (auto operand : GetParam().operands()) input << " " << operand;
- EXPECT_THAT(CompiledInstructions(input.str()),
- Eq(MakeInstruction(SpvOpStore, {1, 2, GetParam().value()},
- GetParam().operands())));
+ EXPECT_THAT(
+ CompiledInstructions(input.str()),
+ Eq(MakeInstruction(spv::Op::OpStore, {1, 2, (uint32_t)GetParam().value()},
+ GetParam().operands())));
}
INSTANTIATE_TEST_SUITE_P(
TextToBinaryMemoryAccessTest, MemoryAccessTest,
- ::testing::ValuesIn(std::vector<EnumCase<SpvMemoryAccessMask>>{
- {SpvMemoryAccessMaskNone, "None", {}},
- {SpvMemoryAccessVolatileMask, "Volatile", {}},
- {SpvMemoryAccessAlignedMask, "Aligned", {16}},
- {SpvMemoryAccessNontemporalMask, "Nontemporal", {}},
+ ::testing::ValuesIn(std::vector<EnumCase<spv::MemoryAccessMask>>{
+ {spv::MemoryAccessMask::MaskNone, "None", {}},
+ {spv::MemoryAccessMask::Volatile, "Volatile", {}},
+ {spv::MemoryAccessMask::Aligned, "Aligned", {16}},
+ {spv::MemoryAccessMask::Nontemporal, "Nontemporal", {}},
}));
TEST_F(TextToBinaryTest, CombinedMemoryAccessMask) {
const std::string input = "OpStore %ptr %value Volatile|Aligned 16";
- const uint32_t expected_mask =
- SpvMemoryAccessVolatileMask | SpvMemoryAccessAlignedMask;
+ const uint32_t expected_mask = uint32_t(spv::MemoryAccessMask::Volatile |
+ spv::MemoryAccessMask::Aligned);
EXPECT_THAT(expected_mask, Eq(3u));
EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpStore, {1, 2, expected_mask, 16})));
+ Eq(MakeInstruction(spv::Op::OpStore, {1, 2, expected_mask, 16})));
}
// Test Storage Class enum values
using StorageClassTest = spvtest::TextToBinaryTestBase<
- ::testing::TestWithParam<EnumCase<SpvStorageClass>>>;
+ ::testing::TestWithParam<EnumCase<spv::StorageClass>>>;
TEST_P(StorageClassTest, AnyStorageClass) {
const std::string input = "%1 = OpVariable %2 " + GetParam().name();
EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpVariable, {1, 2, GetParam().value()})));
+ Eq(MakeInstruction(spv::Op::OpVariable,
+ {1, 2, (uint32_t)GetParam().value()})));
}
// clang-format off
-#define CASE(NAME) { SpvStorageClass##NAME, #NAME, {} }
+#define CASE(NAME) { spv::StorageClass::NAME, #NAME, {} }
INSTANTIATE_TEST_SUITE_P(
TextToBinaryStorageClassTest, StorageClassTest,
- ::testing::ValuesIn(std::vector<EnumCase<SpvStorageClass>>{
+ ::testing::ValuesIn(std::vector<EnumCase<spv::StorageClass>>{
CASE(UniformConstant),
CASE(Input),
CASE(Uniform),
@@ -103,7 +105,7 @@ using MemoryRoundTripTest = RoundTripTest;
TEST_F(MemoryRoundTripTest, OpPtrEqualGood) {
std::string spirv = "%2 = OpPtrEqual %1 %3 %4\n";
EXPECT_THAT(CompiledInstructions(spirv, SPV_ENV_UNIVERSAL_1_4),
- Eq(MakeInstruction(SpvOpPtrEqual, {1, 2, 3, 4})));
+ Eq(MakeInstruction(spv::Op::OpPtrEqual, {1, 2, 3, 4})));
std::string disassembly = EncodeAndDecodeSuccessfully(
spirv, SPV_BINARY_TO_TEXT_OPTION_NONE, SPV_ENV_UNIVERSAL_1_4);
EXPECT_THAT(disassembly, Eq(spirv));
@@ -120,7 +122,7 @@ TEST_F(MemoryRoundTripTest, OpPtrEqualV13Bad) {
TEST_F(MemoryRoundTripTest, OpPtrNotEqualGood) {
std::string spirv = "%2 = OpPtrNotEqual %1 %3 %4\n";
EXPECT_THAT(CompiledInstructions(spirv, SPV_ENV_UNIVERSAL_1_4),
- Eq(MakeInstruction(SpvOpPtrNotEqual, {1, 2, 3, 4})));
+ Eq(MakeInstruction(spv::Op::OpPtrNotEqual, {1, 2, 3, 4})));
std::string disassembly = EncodeAndDecodeSuccessfully(
spirv, SPV_BINARY_TO_TEXT_OPTION_NONE, SPV_ENV_UNIVERSAL_1_4);
EXPECT_THAT(disassembly, Eq(spirv));
@@ -137,7 +139,7 @@ TEST_F(MemoryRoundTripTest, OpPtrNotEqualV13Bad) {
TEST_F(MemoryRoundTripTest, OpPtrDiffGood) {
std::string spirv = "%2 = OpPtrDiff %1 %3 %4\n";
EXPECT_THAT(CompiledInstructions(spirv, SPV_ENV_UNIVERSAL_1_4),
- Eq(MakeInstruction(SpvOpPtrDiff, {1, 2, 3, 4})));
+ Eq(MakeInstruction(spv::Op::OpPtrDiff, {1, 2, 3, 4})));
std::string disassembly = EncodeAndDecodeSuccessfully(
spirv, SPV_BINARY_TO_TEXT_OPTION_NONE, SPV_ENV_UNIVERSAL_1_4);
EXPECT_THAT(disassembly, Eq(spirv));
@@ -157,7 +159,7 @@ TEST_F(MemoryRoundTripTest, OpPtrDiffV13Good) {
TEST_F(MemoryRoundTripTest, OpCopyMemoryNoMemAccessGood) {
std::string spirv = "OpCopyMemory %1 %2\n";
EXPECT_THAT(CompiledInstructions(spirv),
- Eq(MakeInstruction(SpvOpCopyMemory, {1, 2})));
+ Eq(MakeInstruction(spv::Op::OpCopyMemory, {1, 2})));
std::string disassembly =
EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE);
EXPECT_THAT(disassembly, Eq(spirv));
@@ -179,7 +181,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemoryTooManyArgsBad) {
TEST_F(MemoryRoundTripTest, OpCopyMemoryAccessNoneGood) {
std::string spirv = "OpCopyMemory %1 %2 None\n";
EXPECT_THAT(CompiledInstructions(spirv),
- Eq(MakeInstruction(SpvOpCopyMemory, {1, 2, 0})));
+ Eq(MakeInstruction(spv::Op::OpCopyMemory, {1, 2, 0})));
std::string disassembly =
EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE);
EXPECT_THAT(disassembly, Eq(spirv));
@@ -188,7 +190,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemoryAccessNoneGood) {
TEST_F(MemoryRoundTripTest, OpCopyMemoryAccessVolatileGood) {
std::string spirv = "OpCopyMemory %1 %2 Volatile\n";
EXPECT_THAT(CompiledInstructions(spirv),
- Eq(MakeInstruction(SpvOpCopyMemory, {1, 2, 1})));
+ Eq(MakeInstruction(spv::Op::OpCopyMemory, {1, 2, 1})));
std::string disassembly =
EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE);
EXPECT_THAT(disassembly, Eq(spirv));
@@ -197,7 +199,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemoryAccessVolatileGood) {
TEST_F(MemoryRoundTripTest, OpCopyMemoryAccessAligned8Good) {
std::string spirv = "OpCopyMemory %1 %2 Aligned 8\n";
EXPECT_THAT(CompiledInstructions(spirv),
- Eq(MakeInstruction(SpvOpCopyMemory, {1, 2, 2, 8})));
+ Eq(MakeInstruction(spv::Op::OpCopyMemory, {1, 2, 2, 8})));
std::string disassembly =
EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE);
EXPECT_THAT(disassembly, Eq(spirv));
@@ -206,7 +208,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemoryAccessAligned8Good) {
TEST_F(MemoryRoundTripTest, OpCopyMemoryAccessNontemporalGood) {
std::string spirv = "OpCopyMemory %1 %2 Nontemporal\n";
EXPECT_THAT(CompiledInstructions(spirv),
- Eq(MakeInstruction(SpvOpCopyMemory, {1, 2, 4})));
+ Eq(MakeInstruction(spv::Op::OpCopyMemory, {1, 2, 4})));
std::string disassembly =
EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE);
EXPECT_THAT(disassembly, Eq(spirv));
@@ -215,7 +217,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemoryAccessNontemporalGood) {
TEST_F(MemoryRoundTripTest, OpCopyMemoryAccessAvGood) {
std::string spirv = "OpCopyMemory %1 %2 MakePointerAvailable %3\n";
EXPECT_THAT(CompiledInstructions(spirv),
- Eq(MakeInstruction(SpvOpCopyMemory, {1, 2, 8, 3})));
+ Eq(MakeInstruction(spv::Op::OpCopyMemory, {1, 2, 8, 3})));
std::string disassembly =
EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE);
EXPECT_THAT(disassembly, Eq(spirv));
@@ -224,7 +226,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemoryAccessAvGood) {
TEST_F(MemoryRoundTripTest, OpCopyMemoryAccessVisGood) {
std::string spirv = "OpCopyMemory %1 %2 MakePointerVisible %3\n";
EXPECT_THAT(CompiledInstructions(spirv),
- Eq(MakeInstruction(SpvOpCopyMemory, {1, 2, 16, 3})));
+ Eq(MakeInstruction(spv::Op::OpCopyMemory, {1, 2, 16, 3})));
std::string disassembly =
EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE);
EXPECT_THAT(disassembly, Eq(spirv));
@@ -233,7 +235,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemoryAccessVisGood) {
TEST_F(MemoryRoundTripTest, OpCopyMemoryAccessNonPrivateGood) {
std::string spirv = "OpCopyMemory %1 %2 NonPrivatePointer\n";
EXPECT_THAT(CompiledInstructions(spirv),
- Eq(MakeInstruction(SpvOpCopyMemory, {1, 2, 32})));
+ Eq(MakeInstruction(spv::Op::OpCopyMemory, {1, 2, 32})));
std::string disassembly =
EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE);
EXPECT_THAT(disassembly, Eq(spirv));
@@ -245,7 +247,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemoryAccessMixedGood) {
"Volatile|Aligned|Nontemporal|MakePointerAvailable|"
"MakePointerVisible|NonPrivatePointer 16 %3 %4\n";
EXPECT_THAT(CompiledInstructions(spirv),
- Eq(MakeInstruction(SpvOpCopyMemory, {1, 2, 63, 16, 3, 4})));
+ Eq(MakeInstruction(spv::Op::OpCopyMemory, {1, 2, 63, 16, 3, 4})));
std::string disassembly =
EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE);
EXPECT_THAT(disassembly, Eq(spirv));
@@ -255,7 +257,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemoryTwoAccessV13Good) {
std::string spirv = "OpCopyMemory %1 %2 Volatile Volatile\n";
// Note: This will assemble but should not validate for SPIR-V 1.3
EXPECT_THAT(CompiledInstructions(spirv, SPV_ENV_UNIVERSAL_1_3),
- Eq(MakeInstruction(SpvOpCopyMemory, {1, 2, 1, 1})));
+ Eq(MakeInstruction(spv::Op::OpCopyMemory, {1, 2, 1, 1})));
std::string disassembly =
EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE);
EXPECT_THAT(disassembly, Eq(spirv));
@@ -264,7 +266,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemoryTwoAccessV13Good) {
TEST_F(MemoryRoundTripTest, OpCopyMemoryTwoAccessV14Good) {
std::string spirv = "OpCopyMemory %1 %2 Volatile Volatile\n";
EXPECT_THAT(CompiledInstructions(spirv, SPV_ENV_UNIVERSAL_1_4),
- Eq(MakeInstruction(SpvOpCopyMemory, {1, 2, 1, 1})));
+ Eq(MakeInstruction(spv::Op::OpCopyMemory, {1, 2, 1, 1})));
std::string disassembly =
EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE);
EXPECT_THAT(disassembly, Eq(spirv));
@@ -275,8 +277,9 @@ TEST_F(MemoryRoundTripTest, OpCopyMemoryTwoAccessMixedV14Good) {
"OpCopyMemory %1 %2 Volatile|Nontemporal|"
"MakePointerVisible %3 "
"Aligned|MakePointerAvailable|NonPrivatePointer 16 %4\n";
- EXPECT_THAT(CompiledInstructions(spirv),
- Eq(MakeInstruction(SpvOpCopyMemory, {1, 2, 21, 3, 42, 16, 4})));
+ EXPECT_THAT(
+ CompiledInstructions(spirv),
+ Eq(MakeInstruction(spv::Op::OpCopyMemory, {1, 2, 21, 3, 42, 16, 4})));
std::string disassembly =
EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE);
EXPECT_THAT(disassembly, Eq(spirv));
@@ -287,7 +290,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemoryTwoAccessMixedV14Good) {
TEST_F(MemoryRoundTripTest, OpCopyMemorySizedNoMemAccessGood) {
std::string spirv = "OpCopyMemorySized %1 %2 %3\n";
EXPECT_THAT(CompiledInstructions(spirv),
- Eq(MakeInstruction(SpvOpCopyMemorySized, {1, 2, 3})));
+ Eq(MakeInstruction(spv::Op::OpCopyMemorySized, {1, 2, 3})));
std::string disassembly =
EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE);
EXPECT_THAT(disassembly, Eq(spirv));
@@ -309,7 +312,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemorySizedTooManyArgsBad) {
TEST_F(MemoryRoundTripTest, OpCopyMemorySizedAccessNoneGood) {
std::string spirv = "OpCopyMemorySized %1 %2 %3 None\n";
EXPECT_THAT(CompiledInstructions(spirv),
- Eq(MakeInstruction(SpvOpCopyMemorySized, {1, 2, 3, 0})));
+ Eq(MakeInstruction(spv::Op::OpCopyMemorySized, {1, 2, 3, 0})));
std::string disassembly =
EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE);
EXPECT_THAT(disassembly, Eq(spirv));
@@ -318,7 +321,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemorySizedAccessNoneGood) {
TEST_F(MemoryRoundTripTest, OpCopyMemorySizedAccessVolatileGood) {
std::string spirv = "OpCopyMemorySized %1 %2 %3 Volatile\n";
EXPECT_THAT(CompiledInstructions(spirv),
- Eq(MakeInstruction(SpvOpCopyMemorySized, {1, 2, 3, 1})));
+ Eq(MakeInstruction(spv::Op::OpCopyMemorySized, {1, 2, 3, 1})));
std::string disassembly =
EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE);
EXPECT_THAT(disassembly, Eq(spirv));
@@ -327,7 +330,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemorySizedAccessVolatileGood) {
TEST_F(MemoryRoundTripTest, OpCopyMemorySizedAccessAligned8Good) {
std::string spirv = "OpCopyMemorySized %1 %2 %3 Aligned 8\n";
EXPECT_THAT(CompiledInstructions(spirv),
- Eq(MakeInstruction(SpvOpCopyMemorySized, {1, 2, 3, 2, 8})));
+ Eq(MakeInstruction(spv::Op::OpCopyMemorySized, {1, 2, 3, 2, 8})));
std::string disassembly =
EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE);
EXPECT_THAT(disassembly, Eq(spirv));
@@ -336,7 +339,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemorySizedAccessAligned8Good) {
TEST_F(MemoryRoundTripTest, OpCopyMemorySizedAccessNontemporalGood) {
std::string spirv = "OpCopyMemorySized %1 %2 %3 Nontemporal\n";
EXPECT_THAT(CompiledInstructions(spirv),
- Eq(MakeInstruction(SpvOpCopyMemorySized, {1, 2, 3, 4})));
+ Eq(MakeInstruction(spv::Op::OpCopyMemorySized, {1, 2, 3, 4})));
std::string disassembly =
EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE);
EXPECT_THAT(disassembly, Eq(spirv));
@@ -345,7 +348,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemorySizedAccessNontemporalGood) {
TEST_F(MemoryRoundTripTest, OpCopyMemorySizedAccessAvGood) {
std::string spirv = "OpCopyMemorySized %1 %2 %3 MakePointerAvailable %4\n";
EXPECT_THAT(CompiledInstructions(spirv),
- Eq(MakeInstruction(SpvOpCopyMemorySized, {1, 2, 3, 8, 4})));
+ Eq(MakeInstruction(spv::Op::OpCopyMemorySized, {1, 2, 3, 8, 4})));
std::string disassembly =
EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE);
EXPECT_THAT(disassembly, Eq(spirv));
@@ -353,8 +356,9 @@ TEST_F(MemoryRoundTripTest, OpCopyMemorySizedAccessAvGood) {
TEST_F(MemoryRoundTripTest, OpCopyMemorySizedAccessVisGood) {
std::string spirv = "OpCopyMemorySized %1 %2 %3 MakePointerVisible %4\n";
- EXPECT_THAT(CompiledInstructions(spirv),
- Eq(MakeInstruction(SpvOpCopyMemorySized, {1, 2, 3, 16, 4})));
+ EXPECT_THAT(
+ CompiledInstructions(spirv),
+ Eq(MakeInstruction(spv::Op::OpCopyMemorySized, {1, 2, 3, 16, 4})));
std::string disassembly =
EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE);
EXPECT_THAT(disassembly, Eq(spirv));
@@ -363,7 +367,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemorySizedAccessVisGood) {
TEST_F(MemoryRoundTripTest, OpCopyMemorySizedAccessNonPrivateGood) {
std::string spirv = "OpCopyMemorySized %1 %2 %3 NonPrivatePointer\n";
EXPECT_THAT(CompiledInstructions(spirv),
- Eq(MakeInstruction(SpvOpCopyMemorySized, {1, 2, 3, 32})));
+ Eq(MakeInstruction(spv::Op::OpCopyMemorySized, {1, 2, 3, 32})));
std::string disassembly =
EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE);
EXPECT_THAT(disassembly, Eq(spirv));
@@ -376,7 +380,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemorySizedAccessMixedGood) {
"MakePointerVisible|NonPrivatePointer 16 %4 %5\n";
EXPECT_THAT(
CompiledInstructions(spirv),
- Eq(MakeInstruction(SpvOpCopyMemorySized, {1, 2, 3, 63, 16, 4, 5})));
+ Eq(MakeInstruction(spv::Op::OpCopyMemorySized, {1, 2, 3, 63, 16, 4, 5})));
std::string disassembly =
EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE);
EXPECT_THAT(disassembly, Eq(spirv));
@@ -386,7 +390,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemorySizedTwoAccessV13Good) {
std::string spirv = "OpCopyMemorySized %1 %2 %3 Volatile Volatile\n";
// Note: This will assemble but should not validate for SPIR-V 1.3
EXPECT_THAT(CompiledInstructions(spirv, SPV_ENV_UNIVERSAL_1_3),
- Eq(MakeInstruction(SpvOpCopyMemorySized, {1, 2, 3, 1, 1})));
+ Eq(MakeInstruction(spv::Op::OpCopyMemorySized, {1, 2, 3, 1, 1})));
std::string disassembly =
EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE);
EXPECT_THAT(disassembly, Eq(spirv));
@@ -395,7 +399,7 @@ TEST_F(MemoryRoundTripTest, OpCopyMemorySizedTwoAccessV13Good) {
TEST_F(MemoryRoundTripTest, OpCopyMemorySizedTwoAccessV14Good) {
std::string spirv = "OpCopyMemorySized %1 %2 %3 Volatile Volatile\n";
EXPECT_THAT(CompiledInstructions(spirv, SPV_ENV_UNIVERSAL_1_4),
- Eq(MakeInstruction(SpvOpCopyMemorySized, {1, 2, 3, 1, 1})));
+ Eq(MakeInstruction(spv::Op::OpCopyMemorySized, {1, 2, 3, 1, 1})));
std::string disassembly =
EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE);
EXPECT_THAT(disassembly, Eq(spirv));
@@ -406,9 +410,9 @@ TEST_F(MemoryRoundTripTest, OpCopyMemorySizedTwoAccessMixedV14Good) {
"OpCopyMemorySized %1 %2 %3 Volatile|Nontemporal|"
"MakePointerVisible %4 "
"Aligned|MakePointerAvailable|NonPrivatePointer 16 %5\n";
- EXPECT_THAT(
- CompiledInstructions(spirv),
- Eq(MakeInstruction(SpvOpCopyMemorySized, {1, 2, 3, 21, 4, 42, 16, 5})));
+ EXPECT_THAT(CompiledInstructions(spirv),
+ Eq(MakeInstruction(spv::Op::OpCopyMemorySized,
+ {1, 2, 3, 21, 4, 42, 16, 5})));
std::string disassembly =
EncodeAndDecodeSuccessfully(spirv, SPV_BINARY_TO_TEXT_OPTION_NONE);
EXPECT_THAT(disassembly, Eq(spirv));
diff --git a/test/text_to_binary.misc_test.cpp b/test/text_to_binary.misc_test.cpp
index 03b1e0914..9ee425a18 100644
--- a/test/text_to_binary.misc_test.cpp
+++ b/test/text_to_binary.misc_test.cpp
@@ -29,7 +29,8 @@ using ::testing::Eq;
using TextToBinaryMisc = spvtest::TextToBinaryTest;
TEST_F(TextToBinaryMisc, OpNop) {
- EXPECT_THAT(CompiledInstructions("OpNop"), Eq(MakeInstruction(SpvOpNop, {})));
+ EXPECT_THAT(CompiledInstructions("OpNop"),
+ Eq(MakeInstruction(spv::Op::OpNop, {})));
}
TEST_F(TextToBinaryMisc, OpUndef) {
@@ -37,7 +38,8 @@ TEST_F(TextToBinaryMisc, OpUndef) {
%u = OpUndef %f32)");
const uint32_t typeID = 1;
EXPECT_THAT(code[1], Eq(typeID));
- EXPECT_THAT(Subvector(code, 3), Eq(MakeInstruction(SpvOpUndef, {typeID, 2})));
+ EXPECT_THAT(Subvector(code, 3),
+ Eq(MakeInstruction(spv::Op::OpUndef, {typeID, 2})));
}
TEST_F(TextToBinaryMisc, OpWrong) {
diff --git a/test/text_to_binary.mode_setting_test.cpp b/test/text_to_binary.mode_setting_test.cpp
index 7f15c8b4f..c62ba3eb1 100644
--- a/test/text_to_binary.mode_setting_test.cpp
+++ b/test/text_to_binary.mode_setting_test.cpp
@@ -46,9 +46,9 @@ struct MemoryModelCase {
uint32_t get_memory_value() const {
return static_cast<uint32_t>(memory_value);
}
- SpvAddressingModel addressing_value;
+ spv::AddressingModel addressing_value;
std::string addressing_name;
- SpvMemoryModel memory_value;
+ spv::MemoryModel memory_value;
std::string memory_name;
};
@@ -58,16 +58,16 @@ using OpMemoryModelTest =
TEST_P(OpMemoryModelTest, AnyMemoryModelCase) {
const std::string input = "OpMemoryModel " + GetParam().addressing_name +
" " + GetParam().memory_name;
- EXPECT_THAT(
- CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpMemoryModel, {GetParam().get_addressing_value(),
- GetParam().get_memory_value()})));
+ EXPECT_THAT(CompiledInstructions(input),
+ Eq(MakeInstruction(spv::Op::OpMemoryModel,
+ {GetParam().get_addressing_value(),
+ GetParam().get_memory_value()})));
}
-#define CASE(ADDRESSING, MEMORY) \
- { \
- SpvAddressingModel##ADDRESSING, #ADDRESSING, SpvMemoryModel##MEMORY, \
- #MEMORY \
+#define CASE(ADDRESSING, MEMORY) \
+ { \
+ spv::AddressingModel::ADDRESSING, #ADDRESSING, spv::MemoryModel::MEMORY, \
+ #MEMORY \
}
// clang-format off
INSTANTIATE_TEST_SUITE_P(TextToBinaryMemoryModel, OpMemoryModelTest,
@@ -97,7 +97,7 @@ struct EntryPointCase {
uint32_t get_execution_value() const {
return static_cast<uint32_t>(execution_value);
}
- SpvExecutionModel execution_value;
+ spv::ExecutionModel execution_value;
std::string execution_name;
std::string entry_point_name;
};
@@ -109,14 +109,14 @@ TEST_P(OpEntryPointTest, AnyEntryPointCase) {
// TODO(dneto): utf-8, escaping, quoting cases for entry point name.
const std::string input = "OpEntryPoint " + GetParam().execution_name +
" %1 \"" + GetParam().entry_point_name + "\"";
- EXPECT_THAT(
- CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpEntryPoint, {GetParam().get_execution_value(), 1},
- MakeVector(GetParam().entry_point_name))));
+ EXPECT_THAT(CompiledInstructions(input),
+ Eq(MakeInstruction(spv::Op::OpEntryPoint,
+ {GetParam().get_execution_value(), 1},
+ MakeVector(GetParam().entry_point_name))));
}
// clang-format off
-#define CASE(NAME) SpvExecutionModel##NAME, #NAME
+#define CASE(NAME) spv::ExecutionModel::NAME, #NAME
INSTANTIATE_TEST_SUITE_P(TextToBinaryEntryPoint, OpEntryPointTest,
ValuesIn(std::vector<EntryPointCase>{
{ CASE(Vertex), "" },
@@ -137,7 +137,7 @@ TEST_F(OpEntryPointTest, WrongModel) {
// Test OpExecutionMode
using OpExecutionModeTest = spvtest::TextToBinaryTestBase<
- TestWithParam<std::tuple<spv_target_env, EnumCase<SpvExecutionMode>>>>;
+ TestWithParam<std::tuple<spv_target_env, EnumCase<spv::ExecutionMode>>>>;
TEST_P(OpExecutionModeTest, AnyExecutionMode) {
// This string should assemble, but should not validate.
@@ -146,16 +146,16 @@ TEST_P(OpExecutionModeTest, AnyExecutionMode) {
for (auto operand : std::get<1>(GetParam()).operands())
input << " " << operand;
EXPECT_THAT(CompiledInstructions(input.str(), std::get<0>(GetParam())),
- Eq(MakeInstruction(SpvOpExecutionMode,
+ Eq(MakeInstruction(spv::Op::OpExecutionMode,
{1, std::get<1>(GetParam()).value()},
std::get<1>(GetParam()).operands())));
}
-#define CASE(NAME) SpvExecutionMode##NAME, #NAME
+#define CASE(NAME) spv::ExecutionMode::NAME, #NAME
INSTANTIATE_TEST_SUITE_P(
TextToBinaryExecutionMode, OpExecutionModeTest,
Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
- ValuesIn(std::vector<EnumCase<SpvExecutionMode>>{
+ ValuesIn(std::vector<EnumCase<spv::ExecutionMode>>{
// The operand literal values are arbitrarily chosen,
// but there are the right number of them.
{CASE(Invocations), {101}},
@@ -195,7 +195,7 @@ INSTANTIATE_TEST_SUITE_P(
INSTANTIATE_TEST_SUITE_P(
TextToBinaryExecutionModeV11, OpExecutionModeTest,
Combine(Values(SPV_ENV_UNIVERSAL_1_1),
- ValuesIn(std::vector<EnumCase<SpvExecutionMode>>{
+ ValuesIn(std::vector<EnumCase<spv::ExecutionMode>>{
{CASE(Initializer)},
{CASE(Finalizer)},
{CASE(SubgroupSize), {12}},
@@ -216,18 +216,18 @@ TEST_F(OpExecutionModeTest, TooManyModes) {
// Test OpCapability
using OpCapabilityTest =
- spvtest::TextToBinaryTestBase<TestWithParam<EnumCase<SpvCapability>>>;
+ spvtest::TextToBinaryTestBase<TestWithParam<EnumCase<spv::Capability>>>;
TEST_P(OpCapabilityTest, AnyCapability) {
const std::string input = "OpCapability " + GetParam().name();
EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpCapability, {GetParam().value()})));
+ Eq(MakeInstruction(spv::Op::OpCapability, {GetParam().value()})));
}
// clang-format off
-#define CASE(NAME) { SpvCapability##NAME, #NAME }
+#define CASE(NAME) { spv::Capability::NAME, #NAME }
INSTANTIATE_TEST_SUITE_P(TextToBinaryCapability, OpCapabilityTest,
- ValuesIn(std::vector<EnumCase<SpvCapability>>{
+ ValuesIn(std::vector<EnumCase<spv::Capability>>{
CASE(Matrix),
CASE(Shader),
CASE(Geometry),
diff --git a/test/text_to_binary.pipe_storage_test.cpp b/test/text_to_binary.pipe_storage_test.cpp
index 955f5ef80..2a41d427d 100644
--- a/test/text_to_binary.pipe_storage_test.cpp
+++ b/test/text_to_binary.pipe_storage_test.cpp
@@ -28,7 +28,7 @@ using OpTypePipeStorageTest = spvtest::TextToBinaryTest;
TEST_F(OpTypePipeStorageTest, OpcodeAssemblesInV10) {
EXPECT_THAT(
CompiledInstructions("%res = OpTypePipeStorage", SPV_ENV_UNIVERSAL_1_0),
- Eq(MakeInstruction(SpvOpTypePipeStorage, {1})));
+ Eq(MakeInstruction(spv::Op::OpTypePipeStorage, {1})));
}
TEST_F(OpTypePipeStorageTest, ArgumentCount) {
@@ -38,7 +38,7 @@ TEST_F(OpTypePipeStorageTest, ArgumentCount) {
"'OpTypePipeStorage'."));
EXPECT_THAT(
CompiledInstructions("%res = OpTypePipeStorage", SPV_ENV_UNIVERSAL_1_1),
- Eq(MakeInstruction(SpvOpTypePipeStorage, {1})));
+ Eq(MakeInstruction(spv::Op::OpTypePipeStorage, {1})));
EXPECT_THAT(CompileFailure("%res = OpTypePipeStorage %1 %2 %3 %4 %5",
SPV_ENV_UNIVERSAL_1_1),
Eq("'=' expected after result id."));
@@ -47,9 +47,10 @@ TEST_F(OpTypePipeStorageTest, ArgumentCount) {
using OpConstantPipeStorageTest = spvtest::TextToBinaryTest;
TEST_F(OpConstantPipeStorageTest, OpcodeAssemblesInV10) {
- EXPECT_THAT(CompiledInstructions("%1 = OpConstantPipeStorage %2 3 4 5",
- SPV_ENV_UNIVERSAL_1_0),
- Eq(MakeInstruction(SpvOpConstantPipeStorage, {1, 2, 3, 4, 5})));
+ EXPECT_THAT(
+ CompiledInstructions("%1 = OpConstantPipeStorage %2 3 4 5",
+ SPV_ENV_UNIVERSAL_1_0),
+ Eq(MakeInstruction(spv::Op::OpConstantPipeStorage, {1, 2, 3, 4, 5})));
}
TEST_F(OpConstantPipeStorageTest, ArgumentCount) {
@@ -65,9 +66,10 @@ TEST_F(OpConstantPipeStorageTest, ArgumentCount) {
SPV_ENV_UNIVERSAL_1_1),
Eq("Expected operand for OpConstantPipeStorage instruction, but "
"found the end of the stream."));
- EXPECT_THAT(CompiledInstructions("%1 = OpConstantPipeStorage %2 3 4 5",
- SPV_ENV_UNIVERSAL_1_1),
- Eq(MakeInstruction(SpvOpConstantPipeStorage, {1, 2, 3, 4, 5})));
+ EXPECT_THAT(
+ CompiledInstructions("%1 = OpConstantPipeStorage %2 3 4 5",
+ SPV_ENV_UNIVERSAL_1_1),
+ Eq(MakeInstruction(spv::Op::OpConstantPipeStorage, {1, 2, 3, 4, 5})));
EXPECT_THAT(CompileFailure("%1 = OpConstantPipeStorage %2 3 4 5 %6 %7",
SPV_ENV_UNIVERSAL_1_1),
Eq("'=' expected after result id."));
@@ -91,9 +93,10 @@ TEST_F(OpConstantPipeStorageTest, ArgumentTypes) {
using OpCreatePipeFromPipeStorageTest = spvtest::TextToBinaryTest;
TEST_F(OpCreatePipeFromPipeStorageTest, OpcodeAssemblesInV10) {
- EXPECT_THAT(CompiledInstructions("%1 = OpCreatePipeFromPipeStorage %2 %3",
- SPV_ENV_UNIVERSAL_1_0),
- Eq(MakeInstruction(SpvOpCreatePipeFromPipeStorage, {1, 2, 3})));
+ EXPECT_THAT(
+ CompiledInstructions("%1 = OpCreatePipeFromPipeStorage %2 %3",
+ SPV_ENV_UNIVERSAL_1_0),
+ Eq(MakeInstruction(spv::Op::OpCreatePipeFromPipeStorage, {1, 2, 3})));
}
TEST_F(OpCreatePipeFromPipeStorageTest, ArgumentCount) {
@@ -109,9 +112,10 @@ TEST_F(OpCreatePipeFromPipeStorageTest, ArgumentCount) {
SPV_ENV_UNIVERSAL_1_1),
Eq("Expected operand for OpCreatePipeFromPipeStorage "
"instruction, but found the next instruction instead."));
- EXPECT_THAT(CompiledInstructions("%1 = OpCreatePipeFromPipeStorage %2 %3",
- SPV_ENV_UNIVERSAL_1_1),
- Eq(MakeInstruction(SpvOpCreatePipeFromPipeStorage, {1, 2, 3})));
+ EXPECT_THAT(
+ CompiledInstructions("%1 = OpCreatePipeFromPipeStorage %2 %3",
+ SPV_ENV_UNIVERSAL_1_1),
+ Eq(MakeInstruction(spv::Op::OpCreatePipeFromPipeStorage, {1, 2, 3})));
EXPECT_THAT(CompileFailure("%1 = OpCreatePipeFromPipeStorage %2 %3 %4 %5",
SPV_ENV_UNIVERSAL_1_1),
Eq("'=' expected after result id."));
diff --git a/test/text_to_binary.reserved_sampling_test.cpp b/test/text_to_binary.reserved_sampling_test.cpp
index 42e4e2aeb..abc166727 100644
--- a/test/text_to_binary.reserved_sampling_test.cpp
+++ b/test/text_to_binary.reserved_sampling_test.cpp
@@ -30,33 +30,36 @@ using ReservedSamplingInstTest = RoundTripTest;
TEST_F(ReservedSamplingInstTest, OpImageSparseSampleProjImplicitLod) {
std::string input = "%2 = OpImageSparseSampleProjImplicitLod %1 %3 %4\n";
- EXPECT_THAT(
- CompiledInstructions(input, SPV_ENV_UNIVERSAL_1_0),
- Eq(MakeInstruction(SpvOpImageSparseSampleProjImplicitLod, {1, 2, 3, 4})));
+ EXPECT_THAT(CompiledInstructions(input, SPV_ENV_UNIVERSAL_1_0),
+ Eq(MakeInstruction(spv::Op::OpImageSparseSampleProjImplicitLod,
+ {1, 2, 3, 4})));
}
TEST_F(ReservedSamplingInstTest, OpImageSparseSampleProjExplicitLod) {
std::string input =
"%2 = OpImageSparseSampleProjExplicitLod %1 %3 %4 Lod %5\n";
EXPECT_THAT(CompiledInstructions(input, SPV_ENV_UNIVERSAL_1_0),
- Eq(MakeInstruction(SpvOpImageSparseSampleProjExplicitLod,
- {1, 2, 3, 4, SpvImageOperandsLodMask, 5})));
+ Eq(MakeInstruction(
+ spv::Op::OpImageSparseSampleProjExplicitLod,
+ {1, 2, 3, 4, (uint32_t)spv::ImageOperandsMask::Lod, 5})));
}
TEST_F(ReservedSamplingInstTest, OpImageSparseSampleProjDrefImplicitLod) {
std::string input =
"%2 = OpImageSparseSampleProjDrefImplicitLod %1 %3 %4 %5\n";
- EXPECT_THAT(CompiledInstructions(input, SPV_ENV_UNIVERSAL_1_0),
- Eq(MakeInstruction(SpvOpImageSparseSampleProjDrefImplicitLod,
- {1, 2, 3, 4, 5})));
+ EXPECT_THAT(
+ CompiledInstructions(input, SPV_ENV_UNIVERSAL_1_0),
+ Eq(MakeInstruction(spv::Op::OpImageSparseSampleProjDrefImplicitLod,
+ {1, 2, 3, 4, 5})));
}
TEST_F(ReservedSamplingInstTest, OpImageSparseSampleProjDrefExplicitLod) {
std::string input =
"%2 = OpImageSparseSampleProjDrefExplicitLod %1 %3 %4 %5 Lod %6\n";
EXPECT_THAT(CompiledInstructions(input, SPV_ENV_UNIVERSAL_1_0),
- Eq(MakeInstruction(SpvOpImageSparseSampleProjDrefExplicitLod,
- {1, 2, 3, 4, 5, SpvImageOperandsLodMask, 6})));
+ Eq(MakeInstruction(
+ spv::Op::OpImageSparseSampleProjDrefExplicitLod,
+ {1, 2, 3, 4, 5, (uint32_t)spv::ImageOperandsMask::Lod, 6})));
}
} // namespace
diff --git a/test/text_to_binary.subgroup_dispatch_test.cpp b/test/text_to_binary.subgroup_dispatch_test.cpp
index 8c4044577..45d77806e 100644
--- a/test/text_to_binary.subgroup_dispatch_test.cpp
+++ b/test/text_to_binary.subgroup_dispatch_test.cpp
@@ -35,7 +35,7 @@ TEST_F(OpGetKernelLocalSizeForSubgroupCountTest, OpcodeAssemblesInV10) {
CompiledInstructions("%res = OpGetKernelLocalSizeForSubgroupCount %type "
"%sgcount %invoke %param %param_size %param_align",
SPV_ENV_UNIVERSAL_1_0),
- Eq(MakeInstruction(SpvOpGetKernelLocalSizeForSubgroupCount,
+ Eq(MakeInstruction(spv::Op::OpGetKernelLocalSizeForSubgroupCount,
{1, 2, 3, 4, 5, 6, 7})));
}
@@ -57,7 +57,7 @@ TEST_F(OpGetKernelLocalSizeForSubgroupCountTest, ArgumentCount) {
CompiledInstructions("%res = OpGetKernelLocalSizeForSubgroupCount %type "
"%sgcount %invoke %param %param_size %param_align",
SPV_ENV_UNIVERSAL_1_1),
- Eq(MakeInstruction(SpvOpGetKernelLocalSizeForSubgroupCount,
+ Eq(MakeInstruction(spv::Op::OpGetKernelLocalSizeForSubgroupCount,
{1, 2, 3, 4, 5, 6, 7})));
EXPECT_THAT(
CompileFailure("%res = OpGetKernelLocalSizeForSubgroupCount %type "
@@ -81,11 +81,11 @@ TEST_F(OpGetKernelLocalSizeForSubgroupCountTest, ArgumentTypes) {
using OpGetKernelMaxNumSubgroupsTest = spvtest::TextToBinaryTest;
TEST_F(OpGetKernelMaxNumSubgroupsTest, OpcodeAssemblesInV10) {
- EXPECT_THAT(
- CompiledInstructions("%res = OpGetKernelMaxNumSubgroups %type "
- "%invoke %param %param_size %param_align",
- SPV_ENV_UNIVERSAL_1_0),
- Eq(MakeInstruction(SpvOpGetKernelMaxNumSubgroups, {1, 2, 3, 4, 5, 6})));
+ EXPECT_THAT(CompiledInstructions("%res = OpGetKernelMaxNumSubgroups %type "
+ "%invoke %param %param_size %param_align",
+ SPV_ENV_UNIVERSAL_1_0),
+ Eq(MakeInstruction(spv::Op::OpGetKernelMaxNumSubgroups,
+ {1, 2, 3, 4, 5, 6})));
}
TEST_F(OpGetKernelMaxNumSubgroupsTest, ArgumentCount) {
@@ -101,11 +101,11 @@ TEST_F(OpGetKernelMaxNumSubgroupsTest, ArgumentCount) {
SPV_ENV_UNIVERSAL_1_1),
Eq("Expected operand for OpGetKernelMaxNumSubgroups instruction, "
"but found the end of the stream."));
- EXPECT_THAT(
- CompiledInstructions("%res = OpGetKernelMaxNumSubgroups %type "
- "%invoke %param %param_size %param_align",
- SPV_ENV_UNIVERSAL_1_1),
- Eq(MakeInstruction(SpvOpGetKernelMaxNumSubgroups, {1, 2, 3, 4, 5, 6})));
+ EXPECT_THAT(CompiledInstructions("%res = OpGetKernelMaxNumSubgroups %type "
+ "%invoke %param %param_size %param_align",
+ SPV_ENV_UNIVERSAL_1_1),
+ Eq(MakeInstruction(spv::Op::OpGetKernelMaxNumSubgroups,
+ {1, 2, 3, 4, 5, 6})));
EXPECT_THAT(CompileFailure("%res = OpGetKernelMaxNumSubgroups %type %invoke "
"%param %param_size %param_align %extra",
SPV_ENV_UNIVERSAL_1_1),
diff --git a/test/text_to_binary.type_declaration_test.cpp b/test/text_to_binary.type_declaration_test.cpp
index 65a23554a..241600eeb 100644
--- a/test/text_to_binary.type_declaration_test.cpp
+++ b/test/text_to_binary.type_declaration_test.cpp
@@ -32,28 +32,29 @@ using ::testing::Eq;
// Test Dim enums via OpTypeImage
using DimTest =
- spvtest::TextToBinaryTestBase<::testing::TestWithParam<EnumCase<SpvDim>>>;
+ spvtest::TextToBinaryTestBase<::testing::TestWithParam<EnumCase<spv::Dim>>>;
TEST_P(DimTest, AnyDim) {
const std::string input =
"%1 = OpTypeImage %2 " + GetParam().name() + " 2 3 0 4 Rgba8\n";
- EXPECT_THAT(
- CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpTypeImage, {1, 2, GetParam().value(), 2, 3, 0, 4,
- SpvImageFormatRgba8})));
+ EXPECT_THAT(CompiledInstructions(input),
+ Eq(MakeInstruction(spv::Op::OpTypeImage,
+ {1, 2, (uint32_t)GetParam().value(), 2, 3, 0,
+ 4, (uint32_t)spv::ImageFormat::Rgba8})));
// Check the disassembler as well.
EXPECT_THAT(EncodeAndDecodeSuccessfully(input), Eq(input));
}
// clang-format off
-#define CASE(NAME) {SpvDim##NAME, #NAME}
+#define CASE(NAME) {spv::Dim::NAME, #NAME}
+#define CASE1(DIM, NAME) {spv::Dim::DIM, #NAME}
INSTANTIATE_TEST_SUITE_P(
TextToBinaryDim, DimTest,
- ::testing::ValuesIn(std::vector<EnumCase<SpvDim>>{
- CASE(1D),
- CASE(2D),
- CASE(3D),
+ ::testing::ValuesIn(std::vector<EnumCase<spv::Dim>>{
+ CASE1(Dim1D, 1D),
+ CASE1(Dim2D, 2D),
+ CASE1(Dim3D, 3D),
CASE(Cube),
CASE(Rect),
CASE(Buffer),
@@ -70,23 +71,24 @@ TEST_F(DimTest, WrongDim) {
// Test ImageFormat enums via OpTypeImage
using ImageFormatTest = spvtest::TextToBinaryTestBase<
- ::testing::TestWithParam<EnumCase<SpvImageFormat>>>;
+ ::testing::TestWithParam<EnumCase<spv::ImageFormat>>>;
TEST_P(ImageFormatTest, AnyImageFormatAndNoAccessQualifier) {
const std::string input =
"%1 = OpTypeImage %2 1D 2 3 0 4 " + GetParam().name() + "\n";
EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpTypeImage, {1, 2, SpvDim1D, 2, 3, 0, 4,
- GetParam().value()})));
+ Eq(MakeInstruction(spv::Op::OpTypeImage,
+ {1, 2, (uint32_t)spv::Dim::Dim1D, 2, 3, 0, 4,
+ GetParam().value()})));
// Check the disassembler as well.
EXPECT_THAT(EncodeAndDecodeSuccessfully(input), Eq(input));
}
// clang-format off
-#define CASE(NAME) {SpvImageFormat##NAME, #NAME}
+#define CASE(NAME) {spv::ImageFormat::NAME, #NAME}
INSTANTIATE_TEST_SUITE_P(
TextToBinaryImageFormat, ImageFormatTest,
- ::testing::ValuesIn(std::vector<EnumCase<SpvImageFormat>>{
+ ::testing::ValuesIn(std::vector<EnumCase<spv::ImageFormat>>{
CASE(Unknown),
CASE(Rgba32f),
CASE(Rgba16f),
@@ -138,24 +140,25 @@ TEST_F(ImageFormatTest, WrongFormat) {
// Test AccessQualifier enums via OpTypeImage.
using ImageAccessQualifierTest = spvtest::TextToBinaryTestBase<
- ::testing::TestWithParam<EnumCase<SpvAccessQualifier>>>;
+ ::testing::TestWithParam<EnumCase<spv::AccessQualifier>>>;
TEST_P(ImageAccessQualifierTest, AnyAccessQualifier) {
const std::string input =
"%1 = OpTypeImage %2 1D 2 3 0 4 Rgba8 " + GetParam().name() + "\n";
EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpTypeImage,
- {1, 2, SpvDim1D, 2, 3, 0, 4,
- SpvImageFormatRgba8, GetParam().value()})));
+ Eq(MakeInstruction(
+ spv::Op::OpTypeImage,
+ {1, 2, (uint32_t)spv::Dim::Dim1D, 2, 3, 0, 4,
+ (uint32_t)spv::ImageFormat::Rgba8, GetParam().value()})));
// Check the disassembler as well.
EXPECT_THAT(EncodeAndDecodeSuccessfully(input), Eq(input));
}
// clang-format off
-#define CASE(NAME) {SpvAccessQualifier##NAME, #NAME}
+#define CASE(NAME) {spv::AccessQualifier::NAME, #NAME}
INSTANTIATE_TEST_SUITE_P(
AccessQualifier, ImageAccessQualifierTest,
- ::testing::ValuesIn(std::vector<EnumCase<SpvAccessQualifier>>{
+ ::testing::ValuesIn(std::vector<EnumCase<spv::AccessQualifier>>{
CASE(ReadOnly),
CASE(WriteOnly),
CASE(ReadWrite),
@@ -166,21 +169,22 @@ INSTANTIATE_TEST_SUITE_P(
// Test AccessQualifier enums via OpTypePipe.
using OpTypePipeTest = spvtest::TextToBinaryTestBase<
- ::testing::TestWithParam<EnumCase<SpvAccessQualifier>>>;
+ ::testing::TestWithParam<EnumCase<spv::AccessQualifier>>>;
TEST_P(OpTypePipeTest, AnyAccessQualifier) {
const std::string input = "%1 = OpTypePipe " + GetParam().name() + "\n";
- EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(SpvOpTypePipe, {1, GetParam().value()})));
+ EXPECT_THAT(
+ CompiledInstructions(input),
+ Eq(MakeInstruction(spv::Op::OpTypePipe, {1, GetParam().value()})));
// Check the disassembler as well.
EXPECT_THAT(EncodeAndDecodeSuccessfully(input), Eq(input));
}
// clang-format off
-#define CASE(NAME) {SpvAccessQualifier##NAME, #NAME}
+#define CASE(NAME) {spv::AccessQualifier::NAME, #NAME}
INSTANTIATE_TEST_SUITE_P(
TextToBinaryTypePipe, OpTypePipeTest,
- ::testing::ValuesIn(std::vector<EnumCase<SpvAccessQualifier>>{
+ ::testing::ValuesIn(std::vector<EnumCase<spv::AccessQualifier>>{
CASE(ReadOnly),
CASE(WriteOnly),
CASE(ReadWrite),
@@ -195,12 +199,12 @@ TEST_F(OpTypePipeTest, WrongAccessQualifier) {
using OpTypeForwardPointerTest = spvtest::TextToBinaryTest;
-#define CASE(storage_class) \
- do { \
- EXPECT_THAT( \
- CompiledInstructions("OpTypeForwardPointer %pt " #storage_class), \
- Eq(MakeInstruction(SpvOpTypeForwardPointer, \
- {1, SpvStorageClass##storage_class}))); \
+#define CASE(storage_class) \
+ do { \
+ EXPECT_THAT( \
+ CompiledInstructions("OpTypeForwardPointer %pt " #storage_class), \
+ Eq(MakeInstruction(spv::Op::OpTypeForwardPointer, \
+ {1, (uint32_t)spv::StorageClass::storage_class}))); \
} while (0)
TEST_F(OpTypeForwardPointerTest, ValidStorageClass) {
@@ -245,7 +249,7 @@ using OpSizeOfTest = spvtest::TextToBinaryTest;
TEST_F(OpSizeOfTest, OpcodeAssemblesInV10) {
EXPECT_THAT(
CompiledInstructions("%1 = OpSizeOf %2 %3", SPV_ENV_UNIVERSAL_1_0),
- Eq(MakeInstruction(SpvOpSizeOf, {1, 2, 3})));
+ Eq(MakeInstruction(spv::Op::OpSizeOf, {1, 2, 3})));
}
TEST_F(OpSizeOfTest, ArgumentCount) {
@@ -258,7 +262,7 @@ TEST_F(OpSizeOfTest, ArgumentCount) {
"next instruction instead."));
EXPECT_THAT(
CompiledInstructions("%1 = OpSizeOf %2 %3", SPV_ENV_UNIVERSAL_1_1),
- Eq(MakeInstruction(SpvOpSizeOf, {1, 2, 3})));
+ Eq(MakeInstruction(spv::Op::OpSizeOf, {1, 2, 3})));
EXPECT_THAT(
CompileFailure("%1 = OpSizeOf %2 %3 44 55 ", SPV_ENV_UNIVERSAL_1_1),
Eq("Expected <opcode> or <result-id> at the beginning of an instruction, "
diff --git a/test/text_to_binary_test.cpp b/test/text_to_binary_test.cpp
index 0b348e87b..a9580972c 100644
--- a/test/text_to_binary_test.cpp
+++ b/test/text_to_binary_test.cpp
@@ -180,9 +180,10 @@ TEST_F(TextToBinaryTest, WrongOpCode) {
TEST_F(TextToBinaryTest, CRLF) {
const std::string input =
"%i32 = OpTypeInt 32 1\r\n%c = OpConstant %i32 123\r\n";
- EXPECT_THAT(CompiledInstructions(input),
- Eq(Concatenate({MakeInstruction(SpvOpTypeInt, {1, 32, 1}),
- MakeInstruction(SpvOpConstant, {1, 2, 123})})));
+ EXPECT_THAT(
+ CompiledInstructions(input),
+ Eq(Concatenate({MakeInstruction(spv::Op::OpTypeInt, {1, 32, 1}),
+ MakeInstruction(spv::Op::OpConstant, {1, 2, 123})})));
}
using TextToBinaryFloatValueTest = spvtest::TextToBinaryTestBase<
@@ -192,8 +193,8 @@ TEST_P(TextToBinaryFloatValueTest, Samples) {
const std::string input =
"%1 = OpTypeFloat 32\n%2 = OpConstant %1 " + GetParam().first;
EXPECT_THAT(CompiledInstructions(input),
- Eq(Concatenate({MakeInstruction(SpvOpTypeFloat, {1, 32}),
- MakeInstruction(SpvOpConstant,
+ Eq(Concatenate({MakeInstruction(spv::Op::OpTypeFloat, {1, 32}),
+ MakeInstruction(spv::Op::OpConstant,
{1, 2, GetParam().second})})));
}
@@ -222,8 +223,8 @@ TEST_P(TextToBinaryHalfValueTest, Samples) {
const std::string input =
"%1 = OpTypeFloat 16\n%2 = OpConstant %1 " + GetParam().first;
EXPECT_THAT(CompiledInstructions(input),
- Eq(Concatenate({MakeInstruction(SpvOpTypeFloat, {1, 16}),
- MakeInstruction(SpvOpConstant,
+ Eq(Concatenate({MakeInstruction(spv::Op::OpTypeFloat, {1, 16}),
+ MakeInstruction(spv::Op::OpConstant,
{1, 2, GetParam().second})})));
}
diff --git a/test/unit_spirv.h b/test/unit_spirv.h
index f0a2958db..bc9857e69 100644
--- a/test/unit_spirv.h
+++ b/test/unit_spirv.h
@@ -105,7 +105,7 @@ inline void PrintTo(const WordVector& words, ::std::ostream* os) {
// 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(
- SpvOp opcode, const std::vector<uint32_t>& args) {
+ spv::Op opcode, const 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());
@@ -116,7 +116,7 @@ inline std::vector<uint32_t> MakeInstruction(
// given opcode and whose operands are the concatenation of the two given
// argument lists.
inline std::vector<uint32_t> MakeInstruction(
- SpvOp opcode, std::vector<uint32_t> args,
+ spv::Op opcode, std::vector<uint32_t> args,
const std::vector<uint32_t>& extra_args) {
args.insert(args.end(), extra_args.begin(), extra_args.end());
return MakeInstruction(opcode, args);
@@ -200,10 +200,10 @@ inline std::vector<spv_target_env> AllTargetEnvironments() {
}
// Returns the capabilities in a CapabilitySet as an ordered vector.
-inline std::vector<SpvCapability> ElementsIn(
+inline std::vector<spv::Capability> ElementsIn(
const spvtools::CapabilitySet& capabilities) {
- std::vector<SpvCapability> result;
- capabilities.ForEach([&result](SpvCapability c) { result.push_back(c); });
+ std::vector<spv::Capability> result;
+ capabilities.ForEach([&result](spv::Capability c) { result.push_back(c); });
return result;
}
diff --git a/test/val/val_cfg_test.cpp b/test/val/val_cfg_test.cpp
index c8dd4a2fd..d2edec1d5 100644
--- a/test/val/val_cfg_test.cpp
+++ b/test/val/val_cfg_test.cpp
@@ -37,7 +37,7 @@ namespace {
using ::testing::HasSubstr;
using ::testing::MatchesRegex;
-using ValidateCFG = spvtest::ValidateBase<SpvCapability>;
+using ValidateCFG = spvtest::ValidateBase<spv::Capability>;
using spvtest::ScopedContext;
std::string nameOps() { return ""; }
@@ -58,7 +58,7 @@ std::string nameOps(std::string head, Args... names) {
class Block {
std::string label_;
std::string body_;
- SpvOp type_;
+ spv::Op type_;
std::vector<Block> successors_;
public:
@@ -66,7 +66,7 @@ class Block {
///
/// @param[in]: label the label id of the block
/// @param[in]: type the branch instruction that ends the block
- explicit Block(std::string label, SpvOp type = SpvOpBranch)
+ explicit Block(std::string label, spv::Op type = spv::Op::OpBranch)
: label_(label), body_(), type_(type), successors_() {}
/// Sets the instructions which will appear in the body of the block
@@ -89,13 +89,13 @@ class Block {
}
switch (type_) {
- case SpvOpBranchConditional:
+ case spv::Op::OpBranchConditional:
out << "OpBranchConditional %cond ";
for (Block& b : successors_) {
out << "%" + b.label_ + " ";
}
break;
- case SpvOpSwitch: {
+ case spv::Op::OpSwitch: {
out << "OpSwitch %one %" + successors_.front().label_;
std::stringstream ss;
for (size_t i = 1; i < successors_.size(); i++) {
@@ -103,25 +103,25 @@ class Block {
}
out << ss.str();
} break;
- case SpvOpLoopMerge: {
+ case spv::Op::OpLoopMerge: {
assert(successors_.size() == 2);
out << "OpLoopMerge %" + successors_[0].label_ + " %" +
successors_[0].label_ + "None";
} break;
- case SpvOpReturn:
+ case spv::Op::OpReturn:
assert(successors_.size() == 0);
out << "OpReturn\n";
break;
- case SpvOpUnreachable:
+ case spv::Op::OpUnreachable:
assert(successors_.size() == 0);
out << "OpUnreachable\n";
break;
- case SpvOpBranch:
+ case spv::Op::OpBranch:
assert(successors_.size() == 1);
out << "OpBranch %" + successors_.front().label_;
break;
- case SpvOpKill:
+ case spv::Op::OpKill:
assert(successors_.size() == 0);
out << "OpKill\n";
break;
@@ -138,9 +138,9 @@ class Block {
/// Assigns the successors for the Block on the lhs
Block& operator>>(Block& lhs, std::vector<Block> successors) {
- if (lhs.type_ == SpvOpBranchConditional) {
+ if (lhs.type_ == spv::Op::OpBranchConditional) {
assert(successors.size() == 2);
- } else if (lhs.type_ == SpvOpSwitch) {
+ } else if (lhs.type_ == spv::Op::OpSwitch) {
assert(successors.size() > 1);
}
lhs.successors_ = successors;
@@ -149,12 +149,12 @@ Block& operator>>(Block& lhs, std::vector<Block> successors) {
/// Assigns the successor for the Block on the lhs
Block& operator>>(Block& lhs, Block& successor) {
- assert(lhs.type_ == SpvOpBranch);
+ assert(lhs.type_ == spv::Op::OpBranch);
lhs.successors_.push_back(successor);
return lhs;
}
-const std::string& GetDefaultHeader(SpvCapability cap) {
+const std::string& GetDefaultHeader(spv::Capability cap) {
static const std::string shader_header =
"OpCapability Shader\n"
"OpCapability Linkage\n"
@@ -165,7 +165,7 @@ const std::string& GetDefaultHeader(SpvCapability cap) {
"OpCapability Linkage\n"
"OpMemoryModel Logical OpenCL\n";
- return (cap == SpvCapabilityShader) ? shader_header : kernel_header;
+ return (cap == spv::Capability::Shader) ? shader_header : kernel_header;
}
const std::string& types_consts() {
@@ -181,8 +181,8 @@ const std::string& types_consts() {
}
INSTANTIATE_TEST_SUITE_P(StructuredControlFlow, ValidateCFG,
- ::testing::Values(SpvCapabilityShader,
- SpvCapabilityKernel));
+ ::testing::Values(spv::Capability::Shader,
+ spv::Capability::Kernel));
TEST_P(ValidateCFG, LoopReachableFromEntryButNeverLeadingToReturn) {
// In this case, the loop is reachable from a node without a predecessor,
@@ -268,11 +268,11 @@ TEST_P(ValidateCFG, LoopUnreachableFromEntryButLeadingToReturn) {
}
TEST_P(ValidateCFG, Simple) {
- bool is_shader = GetParam() == SpvCapabilityShader;
+ bool is_shader = GetParam() == spv::Capability::Shader;
Block entry("entry");
- Block loop("loop", SpvOpBranchConditional);
+ Block loop("loop", spv::Op::OpBranchConditional);
Block cont("cont");
- Block merge("merge", SpvOpReturn);
+ Block merge("merge", spv::Op::OpReturn);
entry.SetBody("%cond = OpSLessThan %boolt %one %two\n");
if (is_shader) {
@@ -298,7 +298,7 @@ TEST_P(ValidateCFG, Simple) {
TEST_P(ValidateCFG, Variable) {
Block entry("entry");
Block cont("cont");
- Block exit("exit", SpvOpReturn);
+ Block exit("exit", spv::Op::OpReturn);
entry.SetBody("%var = OpVariable %ptrt Function\n");
@@ -317,7 +317,7 @@ TEST_P(ValidateCFG, Variable) {
TEST_P(ValidateCFG, VariableNotInFirstBlockBad) {
Block entry("entry");
Block cont("cont");
- Block exit("exit", SpvOpReturn);
+ Block exit("exit", spv::Op::OpReturn);
// This operation should only be performed in the entry block
cont.SetBody("%var = OpVariable %ptrt Function\n");
@@ -339,10 +339,10 @@ TEST_P(ValidateCFG, VariableNotInFirstBlockBad) {
}
TEST_P(ValidateCFG, BlockSelfLoopIsOk) {
- bool is_shader = GetParam() == SpvCapabilityShader;
+ bool is_shader = GetParam() == spv::Capability::Shader;
Block entry("entry");
- Block loop("loop", SpvOpBranchConditional);
- Block merge("merge", SpvOpReturn);
+ Block loop("loop", spv::Op::OpBranchConditional);
+ Block merge("merge", spv::Op::OpReturn);
entry.SetBody("%cond = OpSLessThan %boolt %one %two\n");
if (is_shader) loop.SetBody("OpLoopMerge %merge %loop None\n");
@@ -363,11 +363,11 @@ TEST_P(ValidateCFG, BlockSelfLoopIsOk) {
}
TEST_P(ValidateCFG, BlockAppearsBeforeDominatorBad) {
- bool is_shader = GetParam() == SpvCapabilityShader;
+ bool is_shader = GetParam() == spv::Capability::Shader;
Block entry("entry");
Block cont("cont");
- Block branch("branch", SpvOpBranchConditional);
- Block merge("merge", SpvOpReturn);
+ Block branch("branch", spv::Op::OpBranchConditional);
+ Block merge("merge", spv::Op::OpReturn);
entry.SetBody("%cond = OpSLessThan %boolt %one %two\n");
if (is_shader) branch.SetBody("OpSelectionMerge %merge None\n");
@@ -392,11 +392,11 @@ TEST_P(ValidateCFG, BlockAppearsBeforeDominatorBad) {
}
TEST_P(ValidateCFG, MergeBlockTargetedByMultipleHeaderBlocksBad) {
- bool is_shader = GetParam() == SpvCapabilityShader;
+ bool is_shader = GetParam() == spv::Capability::Shader;
Block entry("entry");
Block loop("loop");
- Block selection("selection", SpvOpBranchConditional);
- Block merge("merge", SpvOpReturn);
+ Block selection("selection", spv::Op::OpBranchConditional);
+ Block merge("merge", spv::Op::OpReturn);
entry.SetBody("%cond = OpSLessThan %boolt %one %two\n");
if (is_shader) loop.SetBody(" OpLoopMerge %merge %loop None\n");
@@ -428,11 +428,11 @@ TEST_P(ValidateCFG, MergeBlockTargetedByMultipleHeaderBlocksBad) {
}
TEST_P(ValidateCFG, MergeBlockTargetedByMultipleHeaderBlocksSelectionBad) {
- bool is_shader = GetParam() == SpvCapabilityShader;
+ bool is_shader = GetParam() == spv::Capability::Shader;
Block entry("entry");
- Block loop("loop", SpvOpBranchConditional);
- Block selection("selection", SpvOpBranchConditional);
- Block merge("merge", SpvOpReturn);
+ Block loop("loop", spv::Op::OpBranchConditional);
+ Block selection("selection", spv::Op::OpBranchConditional);
+ Block merge("merge", spv::Op::OpReturn);
entry.SetBody("%cond = OpSLessThan %boolt %one %two\n");
if (is_shader) selection.SetBody(" OpSelectionMerge %merge None\n");
@@ -466,7 +466,7 @@ TEST_P(ValidateCFG, MergeBlockTargetedByMultipleHeaderBlocksSelectionBad) {
TEST_P(ValidateCFG, BranchTargetFirstBlockBadSinceEntryBlock) {
Block entry("entry");
Block bad("bad");
- Block end("end", SpvOpReturn);
+ Block end("end", spv::Op::OpReturn);
std::string str = GetDefaultHeader(GetParam()) +
nameOps("entry", "bad", std::make_pair("func", "Main")) +
types_consts() +
@@ -489,7 +489,7 @@ TEST_P(ValidateCFG, BranchTargetFirstBlockBadSinceValue) {
Block entry("entry");
entry.SetBody("%undef = OpUndef %boolt\n");
Block bad("bad");
- Block end("end", SpvOpReturn);
+ Block end("end", spv::Op::OpReturn);
Block badvalue("undef"); // This references the OpUndef.
std::string str = GetDefaultHeader(GetParam()) +
nameOps("entry", "bad", std::make_pair("func", "Main")) +
@@ -511,8 +511,8 @@ TEST_P(ValidateCFG, BranchTargetFirstBlockBadSinceValue) {
TEST_P(ValidateCFG, BranchConditionalTrueTargetFirstBlockBad) {
Block entry("entry");
- Block bad("bad", SpvOpBranchConditional);
- Block exit("exit", SpvOpReturn);
+ Block bad("bad", spv::Op::OpBranchConditional);
+ Block exit("exit", spv::Op::OpReturn);
entry.SetBody("%cond = OpSLessThan %boolt %one %two\n");
bad.SetBody(" OpLoopMerge %entry %exit None\n");
@@ -538,10 +538,10 @@ TEST_P(ValidateCFG, BranchConditionalTrueTargetFirstBlockBad) {
TEST_P(ValidateCFG, BranchConditionalFalseTargetFirstBlockBad) {
Block entry("entry");
- Block bad("bad", SpvOpBranchConditional);
+ Block bad("bad", spv::Op::OpBranchConditional);
Block t("t");
Block merge("merge");
- Block end("end", SpvOpReturn);
+ Block end("end", spv::Op::OpReturn);
entry.SetBody("%cond = OpSLessThan %boolt %one %two\n");
bad.SetBody("OpLoopMerge %merge %cont None\n");
@@ -568,13 +568,13 @@ TEST_P(ValidateCFG, BranchConditionalFalseTargetFirstBlockBad) {
TEST_P(ValidateCFG, SwitchTargetFirstBlockBad) {
Block entry("entry");
- Block bad("bad", SpvOpSwitch);
+ Block bad("bad", spv::Op::OpSwitch);
Block block1("block1");
Block block2("block2");
Block block3("block3");
Block def("def"); // default block
Block merge("merge");
- Block end("end", SpvOpReturn);
+ Block end("end", spv::Op::OpReturn);
entry.SetBody("%cond = OpSLessThan %boolt %one %two\n");
bad.SetBody("OpSelectionMerge %merge None\n");
@@ -605,15 +605,15 @@ TEST_P(ValidateCFG, SwitchTargetFirstBlockBad) {
TEST_P(ValidateCFG, BranchToBlockInOtherFunctionBad) {
Block entry("entry");
- Block middle("middle", SpvOpBranchConditional);
- Block end("end", SpvOpReturn);
+ Block middle("middle", spv::Op::OpBranchConditional);
+ Block end("end", spv::Op::OpReturn);
entry.SetBody("%cond = OpSLessThan %boolt %one %two\n");
middle.SetBody("OpSelectionMerge %end None\n");
Block entry2("entry2");
Block middle2("middle2");
- Block end2("end2", SpvOpReturn);
+ Block end2("end2", spv::Op::OpReturn);
std::string str = GetDefaultHeader(GetParam()) +
nameOps("middle2", std::make_pair("func", "Main")) +
@@ -643,9 +643,9 @@ TEST_P(ValidateCFG, BranchToBlockInOtherFunctionBad) {
TEST_P(ValidateCFG, HeaderDoesntStrictlyDominateMergeBad) {
// If a merge block is reachable, then it must be strictly dominated by
// its header block.
- bool is_shader = GetParam() == SpvCapabilityShader;
- Block head("head", SpvOpBranchConditional);
- Block exit("exit", SpvOpReturn);
+ bool is_shader = GetParam() == spv::Capability::Shader;
+ Block head("head", spv::Op::OpBranchConditional);
+ Block exit("exit", spv::Op::OpReturn);
head.SetBody("%cond = OpSLessThan %boolt %one %two\n");
@@ -675,16 +675,16 @@ TEST_P(ValidateCFG, HeaderDoesntStrictlyDominateMergeBad) {
}
}
-std::string GetUnreachableMergeNoMergeInst(SpvCapability cap) {
+std::string GetUnreachableMergeNoMergeInst(spv::Capability cap) {
std::string header = GetDefaultHeader(cap);
Block entry("entry");
- Block branch("branch", SpvOpBranchConditional);
- Block t("t", SpvOpReturn);
- Block f("f", SpvOpReturn);
- Block merge("merge", SpvOpReturn);
+ Block branch("branch", spv::Op::OpBranchConditional);
+ Block t("t", spv::Op::OpReturn);
+ Block f("f", spv::Op::OpReturn);
+ Block merge("merge", spv::Op::OpReturn);
entry.SetBody("%cond = OpSLessThan %boolt %one %two\n");
- if (cap == SpvCapabilityShader)
+ if (cap == spv::Capability::Shader)
branch.AppendBody("OpSelectionMerge %merge None\n");
std::string str = header;
@@ -705,18 +705,18 @@ TEST_P(ValidateCFG, UnreachableMergeNoMergeInst) {
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
}
-std::string GetUnreachableMergeTerminatedBy(SpvCapability cap, SpvOp op) {
+std::string GetUnreachableMergeTerminatedBy(spv::Capability cap, spv::Op op) {
std::string header = GetDefaultHeader(cap);
Block entry("entry");
- Block branch("branch", SpvOpBranchConditional);
- Block t("t", SpvOpReturn);
- Block f("f", SpvOpReturn);
+ Block branch("branch", spv::Op::OpBranchConditional);
+ Block t("t", spv::Op::OpReturn);
+ Block f("f", spv::Op::OpReturn);
Block merge("merge", op);
entry.SetBody("%cond = OpSLessThan %boolt %one %two\n");
std::string str = header;
- if (cap == SpvCapabilityShader)
+ if (cap == spv::Capability::Shader)
branch.AppendBody("OpSelectionMerge %merge None\n");
str += nameOps("branch", "merge", std::make_pair("func", "Main"));
@@ -734,33 +734,35 @@ std::string GetUnreachableMergeTerminatedBy(SpvCapability cap, SpvOp op) {
TEST_P(ValidateCFG, UnreachableMergeTerminatedByOpUnreachable) {
CompileSuccessfully(
- GetUnreachableMergeTerminatedBy(GetParam(), SpvOpUnreachable));
+ GetUnreachableMergeTerminatedBy(GetParam(), spv::Op::OpUnreachable));
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
}
TEST_F(ValidateCFG, UnreachableMergeTerminatedByOpKill) {
- CompileSuccessfully(
- GetUnreachableMergeTerminatedBy(SpvCapabilityShader, SpvOpKill));
+ CompileSuccessfully(GetUnreachableMergeTerminatedBy(spv::Capability::Shader,
+ spv::Op::OpKill));
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
}
TEST_P(ValidateCFG, UnreachableMergeTerminatedByOpReturn) {
- CompileSuccessfully(GetUnreachableMergeTerminatedBy(GetParam(), SpvOpReturn));
+ CompileSuccessfully(
+ GetUnreachableMergeTerminatedBy(GetParam(), spv::Op::OpReturn));
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
}
-std::string GetUnreachableContinueTerminatedBy(SpvCapability cap, SpvOp op) {
+std::string GetUnreachableContinueTerminatedBy(spv::Capability cap,
+ spv::Op op) {
std::string header = GetDefaultHeader(cap);
Block entry("entry");
- Block branch("branch", SpvOpBranch);
- Block merge("merge", SpvOpReturn);
+ Block branch("branch", spv::Op::OpBranch);
+ Block merge("merge", spv::Op::OpReturn);
Block target("target", op);
- if (op == SpvOpBranch) target >> branch;
+ if (op == spv::Op::OpBranch) target >> branch;
std::string str = header;
- if (cap == SpvCapabilityShader)
+ if (cap == spv::Capability::Shader)
branch.AppendBody("OpLoopMerge %merge %target None\n");
str += nameOps("branch", "merge", "target", std::make_pair("func", "Main"));
@@ -775,10 +777,10 @@ std::string GetUnreachableContinueTerminatedBy(SpvCapability cap, SpvOp op) {
return str;
}
-TEST_P(ValidateCFG, UnreachableContinueTerminatedBySpvOpUnreachable) {
+TEST_P(ValidateCFG, UnreachableContinueTerminatedByOpUnreachable) {
CompileSuccessfully(
- GetUnreachableContinueTerminatedBy(GetParam(), SpvOpUnreachable));
- if (GetParam() == SpvCapabilityShader) {
+ GetUnreachableContinueTerminatedBy(GetParam(), spv::Op::OpUnreachable));
+ if (GetParam() == spv::Capability::Shader) {
ASSERT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions());
EXPECT_THAT(getDiagnosticString(),
HasSubstr("targeted by 0 back-edge blocks"));
@@ -787,18 +789,18 @@ TEST_P(ValidateCFG, UnreachableContinueTerminatedBySpvOpUnreachable) {
}
}
-TEST_F(ValidateCFG, UnreachableContinueTerminatedBySpvOpKill) {
- CompileSuccessfully(
- GetUnreachableContinueTerminatedBy(SpvCapabilityShader, SpvOpKill));
+TEST_F(ValidateCFG, UnreachableContinueTerminatedByOpKill) {
+ CompileSuccessfully(GetUnreachableContinueTerminatedBy(
+ spv::Capability::Shader, spv::Op::OpKill));
ASSERT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions());
EXPECT_THAT(getDiagnosticString(),
HasSubstr("targeted by 0 back-edge blocks"));
}
-TEST_P(ValidateCFG, UnreachableContinueTerminatedBySpvOpReturn) {
+TEST_P(ValidateCFG, UnreachableContinueTerminatedByOpReturn) {
CompileSuccessfully(
- GetUnreachableContinueTerminatedBy(GetParam(), SpvOpReturn));
- if (GetParam() == SpvCapabilityShader) {
+ GetUnreachableContinueTerminatedBy(GetParam(), spv::Op::OpReturn));
+ if (GetParam() == spv::Capability::Shader) {
ASSERT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions());
EXPECT_THAT(getDiagnosticString(),
HasSubstr("targeted by 0 back-edge blocks"));
@@ -807,25 +809,25 @@ TEST_P(ValidateCFG, UnreachableContinueTerminatedBySpvOpReturn) {
}
}
-TEST_P(ValidateCFG, UnreachableContinueTerminatedBySpvOpBranch) {
+TEST_P(ValidateCFG, UnreachableContinueTerminatedByOpBranch) {
CompileSuccessfully(
- GetUnreachableContinueTerminatedBy(GetParam(), SpvOpBranch));
+ GetUnreachableContinueTerminatedBy(GetParam(), spv::Op::OpBranch));
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
}
-std::string GetUnreachableMergeUnreachableMergeInst(SpvCapability cap) {
+std::string GetUnreachableMergeUnreachableMergeInst(spv::Capability cap) {
std::string header = GetDefaultHeader(cap);
- Block body("body", SpvOpReturn);
+ Block body("body", spv::Op::OpReturn);
Block entry("entry");
- Block branch("branch", SpvOpBranchConditional);
- Block t("t", SpvOpReturn);
- Block f("f", SpvOpReturn);
- Block merge("merge", SpvOpUnreachable);
+ Block branch("branch", spv::Op::OpBranchConditional);
+ Block t("t", spv::Op::OpReturn);
+ Block f("f", spv::Op::OpReturn);
+ Block merge("merge", spv::Op::OpUnreachable);
entry.SetBody("%cond = OpSLessThan %boolt %one %two\n");
std::string str = header;
- if (cap == SpvCapabilityShader)
+ if (cap == spv::Capability::Shader)
branch.AppendBody("OpSelectionMerge %merge None\n");
str += nameOps("branch", "merge", std::make_pair("func", "Main"));
@@ -847,19 +849,19 @@ TEST_P(ValidateCFG, UnreachableMergeUnreachableMergeInst) {
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
}
-std::string GetUnreachableContinueUnreachableLoopInst(SpvCapability cap) {
+std::string GetUnreachableContinueUnreachableLoopInst(spv::Capability cap) {
std::string header = GetDefaultHeader(cap);
- Block body("body", SpvOpReturn);
+ Block body("body", spv::Op::OpReturn);
Block entry("entry");
- Block branch("branch", SpvOpBranch);
- Block merge("merge", SpvOpReturn);
- Block target("target", SpvOpBranch);
+ Block branch("branch", spv::Op::OpBranch);
+ Block merge("merge", spv::Op::OpReturn);
+ Block target("target", spv::Op::OpBranch);
target >> branch;
std::string str = header;
- if (cap == SpvCapabilityShader)
+ if (cap == spv::Capability::Shader)
branch.AppendBody("OpLoopMerge %merge %target None\n");
str += nameOps("branch", "merge", "target", std::make_pair("func", "Main"));
@@ -880,21 +882,21 @@ TEST_P(ValidateCFG, UnreachableContinueUnreachableLoopInst) {
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
}
-std::string GetUnreachableMergeWithComplexBody(SpvCapability cap) {
+std::string GetUnreachableMergeWithComplexBody(spv::Capability cap) {
std::string header = GetDefaultHeader(cap);
Block entry("entry");
- Block branch("branch", SpvOpBranchConditional);
- Block t("t", SpvOpReturn);
- Block f("f", SpvOpReturn);
- Block merge("merge", SpvOpUnreachable);
+ Block branch("branch", spv::Op::OpBranchConditional);
+ Block t("t", spv::Op::OpReturn);
+ Block f("f", spv::Op::OpReturn);
+ Block merge("merge", spv::Op::OpUnreachable);
entry.AppendBody("%placeholder = OpVariable %intptrt Function\n");
entry.AppendBody("%cond = OpSLessThan %boolt %one %two\n");
merge.AppendBody("OpStore %placeholder %one\n");
std::string str = header;
- if (cap == SpvCapabilityShader)
+ if (cap == spv::Capability::Shader)
branch.AppendBody("OpSelectionMerge %merge None\n");
str += nameOps("branch", "merge", std::make_pair("func", "Main"));
@@ -916,13 +918,13 @@ TEST_P(ValidateCFG, UnreachableMergeWithComplexBody) {
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
}
-std::string GetUnreachableContinueWithComplexBody(SpvCapability cap) {
+std::string GetUnreachableContinueWithComplexBody(spv::Capability cap) {
std::string header = GetDefaultHeader(cap);
Block entry("entry");
- Block branch("branch", SpvOpBranch);
- Block merge("merge", SpvOpReturn);
- Block target("target", SpvOpBranch);
+ Block branch("branch", spv::Op::OpBranch);
+ Block merge("merge", spv::Op::OpReturn);
+ Block target("target", spv::Op::OpBranch);
target >> branch;
@@ -930,7 +932,7 @@ std::string GetUnreachableContinueWithComplexBody(SpvCapability cap) {
target.AppendBody("OpStore %placeholder %one\n");
std::string str = header;
- if (cap == SpvCapabilityShader)
+ if (cap == spv::Capability::Shader)
branch.AppendBody("OpLoopMerge %merge %target None\n");
str += nameOps("branch", "merge", "target", std::make_pair("func", "Main"));
@@ -951,19 +953,19 @@ TEST_P(ValidateCFG, UnreachableContinueWithComplexBody) {
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
}
-std::string GetUnreachableMergeWithBranchUse(SpvCapability cap) {
+std::string GetUnreachableMergeWithBranchUse(spv::Capability cap) {
std::string header = GetDefaultHeader(cap);
Block entry("entry");
- Block branch("branch", SpvOpBranchConditional);
- Block t("t", SpvOpBranch);
- Block f("f", SpvOpReturn);
- Block merge("merge", SpvOpUnreachable);
+ Block branch("branch", spv::Op::OpBranchConditional);
+ Block t("t", spv::Op::OpBranch);
+ Block f("f", spv::Op::OpReturn);
+ Block merge("merge", spv::Op::OpUnreachable);
entry.AppendBody("%cond = OpSLessThan %boolt %one %two\n");
std::string str = header;
- if (cap == SpvCapabilityShader)
+ if (cap == spv::Capability::Shader)
branch.AppendBody("OpSelectionMerge %merge None\n");
str += nameOps("branch", "merge", std::make_pair("func", "Main"));
@@ -984,20 +986,20 @@ TEST_P(ValidateCFG, UnreachableMergeWithBranchUse) {
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions());
}
-std::string GetUnreachableMergeWithMultipleUses(SpvCapability cap) {
+std::string GetUnreachableMergeWithMultipleUses(spv::Capability cap) {
std::string header = GetDefaultHeader(cap);
Block entry("entry");
- Block branch("branch", SpvOpBranchConditional);
- Block t("t", SpvOpReturn);
- Block f("f", SpvOpReturn);
- Block merge("merge", SpvOpUnreachable);
- Block duplicate("duplicate", SpvOpBranchConditional);
+ Block branch("branch", spv::Op::OpBranchConditional);
+ Block t("t", spv::Op::OpReturn);
+ Block f("f", spv::Op::OpReturn);
+ Block merge("merge", spv::Op::OpUnreachable);
+ Block duplicate("duplicate", spv::Op::OpBranchConditional);
entry.AppendBody("%cond = OpSLessThan %boolt %one %two\n");
std::string str = header;
- if (cap == SpvCapabilityShader) {
+ if (cap == spv::Capability::Shader) {
branch.AppendBody("OpSelectionMerge %merge None\n");
duplicate.AppendBody("OpSelectionMerge %merge None\n");
}
@@ -1018,7 +1020,7 @@ std::string GetUnreachableMergeWithMultipleUses(SpvCapability cap) {
TEST_P(ValidateCFG, UnreachableMergeWithMultipleUses) {
CompileSuccessfully(GetUnreachableMergeWithMultipleUses(GetParam()));
- if (GetParam() == SpvCapabilityShader) {
+ if (GetParam() == spv::Capability::Shader) {
ASSERT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions());
EXPECT_THAT(getDiagnosticString(),
HasSubstr("is already a merge block for another header"));
@@ -1027,20 +1029,20 @@ TEST_P(ValidateCFG, UnreachableMergeWithMultipleUses) {
}
}
-std::string GetUnreachableContinueWithBranchUse(SpvCapability cap) {
+std::string GetUnreachableContinueWithBranchUse(spv::Capability cap) {
std::string header = GetDefaultHeader(cap);
Block entry("entry");
- Block branch("branch", SpvOpBranch);
- Block merge("merge", SpvOpReturn);
- Block target("target", SpvOpBranch);
+ Block branch("branch", spv::Op::OpBranch);
+ Block merge("merge", spv::Op::OpReturn);
+ Block target("target", spv::Op::OpBranch);
target >> branch;
entry.AppendBody("%placeholder = OpVariable %intptrt Function\n");
std::string str = header;
- if (cap == SpvCapabilityShader)
+ if (cap == spv::Capability::Shader)
branch.AppendBody("OpLoopMerge %merge %target None\n");
str += nameOps("branch", "merge", "target", std::make_pair("func", "Main"));
@@ -1061,16 +1063,16 @@ TEST_P(ValidateCFG, UnreachableContinueWithBranchUse) {
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
}
-std::string GetReachableMergeAndContinue(SpvCapability cap) {
+std::string GetReachableMergeAndContinue(spv::Capability cap) {
std::string header = GetDefaultHeader(cap);
Block entry("entry");
- Block branch("branch", SpvOpBranch);
- Block merge("merge", SpvOpReturn);
- Block target("target", SpvOpBranch);
- Block body("body", SpvOpBranchConditional);
- Block t("t", SpvOpBranch);
- Block f("f", SpvOpBranch);
+ Block branch("branch", spv::Op::OpBranch);
+ Block merge("merge", spv::Op::OpReturn);
+ Block target("target", spv::Op::OpBranch);
+ Block body("body", spv::Op::OpBranchConditional);
+ Block t("t", spv::Op::OpBranch);
+ Block f("f", spv::Op::OpBranch);
target >> branch;
body.SetBody("%cond = OpSLessThan %boolt %one %two\n");
@@ -1078,7 +1080,7 @@ std::string GetReachableMergeAndContinue(SpvCapability cap) {
f >> target;
std::string str = header;
- if (cap == SpvCapabilityShader) {
+ if (cap == spv::Capability::Shader) {
branch.AppendBody("OpLoopMerge %merge %target None\n");
body.AppendBody("OpSelectionMerge %f None\n");
}
@@ -1104,23 +1106,23 @@ TEST_P(ValidateCFG, ReachableMergeAndContinue) {
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
}
-std::string GetUnreachableMergeAndContinue(SpvCapability cap) {
+std::string GetUnreachableMergeAndContinue(spv::Capability cap) {
std::string header = GetDefaultHeader(cap);
Block entry("entry");
- Block branch("branch", SpvOpBranch);
- Block merge("merge", SpvOpReturn);
- Block target("target", SpvOpBranch);
- Block body("body", SpvOpBranchConditional);
- Block t("t", SpvOpReturn);
- Block f("f", SpvOpReturn);
- Block pre_target("pre_target", SpvOpBranch);
+ Block branch("branch", spv::Op::OpBranch);
+ Block merge("merge", spv::Op::OpReturn);
+ Block target("target", spv::Op::OpBranch);
+ Block body("body", spv::Op::OpBranchConditional);
+ Block t("t", spv::Op::OpReturn);
+ Block f("f", spv::Op::OpReturn);
+ Block pre_target("pre_target", spv::Op::OpBranch);
target >> branch;
body.SetBody("%cond = OpSLessThan %boolt %one %two\n");
std::string str = header;
- if (cap == SpvCapabilityShader) {
+ if (cap == spv::Capability::Shader) {
branch.AppendBody("OpLoopMerge %merge %target None\n");
body.AppendBody("OpSelectionMerge %pre_target None\n");
}
@@ -1147,12 +1149,12 @@ TEST_P(ValidateCFG, UnreachableMergeAndContinue) {
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
}
-std::string GetUnreachableBlock(SpvCapability cap) {
+std::string GetUnreachableBlock(spv::Capability cap) {
std::string header = GetDefaultHeader(cap);
Block entry("entry");
Block unreachable("unreachable");
- Block exit("exit", SpvOpReturn);
+ Block exit("exit", spv::Op::OpReturn);
std::string str = header;
str += nameOps("unreachable", "exit", std::make_pair("func", "Main"));
@@ -1171,18 +1173,18 @@ TEST_P(ValidateCFG, UnreachableBlock) {
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
}
-std::string GetUnreachableBranch(SpvCapability cap) {
+std::string GetUnreachableBranch(spv::Capability cap) {
std::string header = GetDefaultHeader(cap);
Block entry("entry");
- Block unreachable("unreachable", SpvOpBranchConditional);
+ Block unreachable("unreachable", spv::Op::OpBranchConditional);
Block unreachablechildt("unreachablechildt");
Block unreachablechildf("unreachablechildf");
Block merge("merge");
- Block exit("exit", SpvOpReturn);
+ Block exit("exit", spv::Op::OpReturn);
unreachable.SetBody("%cond = OpSLessThan %boolt %one %two\n");
- if (cap == SpvCapabilityShader)
+ if (cap == spv::Capability::Shader)
unreachable.AppendBody("OpSelectionMerge %merge None\n");
std::string str = header;
@@ -1219,10 +1221,10 @@ TEST_P(ValidateCFG, EmptyFunction) {
}
TEST_P(ValidateCFG, SingleBlockLoop) {
- bool is_shader = GetParam() == SpvCapabilityShader;
+ bool is_shader = GetParam() == spv::Capability::Shader;
Block entry("entry");
- Block loop("loop", SpvOpBranchConditional);
- Block exit("exit", SpvOpReturn);
+ Block loop("loop", spv::Op::OpBranchConditional);
+ Block exit("exit", spv::Op::OpReturn);
entry.SetBody("%cond = OpSLessThan %boolt %one %two\n");
if (is_shader) loop.AppendBody("OpLoopMerge %exit %loop None\n");
@@ -1240,15 +1242,15 @@ TEST_P(ValidateCFG, SingleBlockLoop) {
}
TEST_P(ValidateCFG, NestedLoops) {
- bool is_shader = GetParam() == SpvCapabilityShader;
+ bool is_shader = GetParam() == spv::Capability::Shader;
Block entry("entry");
Block loop1("loop1");
Block loop1_cont_break_block("loop1_cont_break_block",
- SpvOpBranchConditional);
- Block loop2("loop2", SpvOpBranchConditional);
+ spv::Op::OpBranchConditional);
+ Block loop2("loop2", spv::Op::OpBranchConditional);
Block loop2_merge("loop2_merge");
Block loop1_merge("loop1_merge");
- Block exit("exit", SpvOpReturn);
+ Block exit("exit", spv::Op::OpReturn);
entry.SetBody("%cond = OpSLessThan %boolt %one %two\n");
if (is_shader) {
@@ -1275,7 +1277,7 @@ TEST_P(ValidateCFG, NestedLoops) {
}
TEST_P(ValidateCFG, NestedSelection) {
- bool is_shader = GetParam() == SpvCapabilityShader;
+ bool is_shader = GetParam() == spv::Capability::Shader;
Block entry("entry");
const int N = 256;
std::vector<Block> if_blocks;
@@ -1284,18 +1286,18 @@ TEST_P(ValidateCFG, NestedSelection) {
entry.SetBody("%cond = OpSLessThan %boolt %one %two\n");
- if_blocks.emplace_back("if0", SpvOpBranchConditional);
+ if_blocks.emplace_back("if0", spv::Op::OpBranchConditional);
if (is_shader) if_blocks[0].SetBody("OpSelectionMerge %if_merge0 None\n");
- merge_blocks.emplace_back("if_merge0", SpvOpReturn);
+ merge_blocks.emplace_back("if_merge0", spv::Op::OpReturn);
for (int i = 1; i < N; i++) {
std::stringstream ss;
ss << i;
- if_blocks.emplace_back("if" + ss.str(), SpvOpBranchConditional);
+ if_blocks.emplace_back("if" + ss.str(), spv::Op::OpBranchConditional);
if (is_shader)
if_blocks[i].SetBody("OpSelectionMerge %if_merge" + ss.str() + " None\n");
- merge_blocks.emplace_back("if_merge" + ss.str(), SpvOpBranch);
+ merge_blocks.emplace_back("if_merge" + ss.str(), spv::Op::OpBranch);
}
std::string str = GetDefaultHeader(GetParam()) + std::string(types_consts()) +
"%func = OpFunction %voidt None %funct\n";
@@ -1318,14 +1320,14 @@ TEST_P(ValidateCFG, NestedSelection) {
}
TEST_P(ValidateCFG, BackEdgeBlockDoesntPostDominateContinueTargetBad) {
- bool is_shader = GetParam() == SpvCapabilityShader;
+ bool is_shader = GetParam() == spv::Capability::Shader;
Block entry("entry");
- Block loop1("loop1", SpvOpBranchConditional);
- Block loop2("loop2", SpvOpBranchConditional);
+ Block loop1("loop1", spv::Op::OpBranchConditional);
+ Block loop2("loop2", spv::Op::OpBranchConditional);
Block loop2_merge("loop2_merge");
- Block loop1_cont("loop1_cont", SpvOpBranchConditional);
+ Block loop1_cont("loop1_cont", spv::Op::OpBranchConditional);
Block be_block("be_block");
- Block exit("exit", SpvOpReturn);
+ Block exit("exit", spv::Op::OpReturn);
entry.SetBody("%cond = OpSLessThan %boolt %one %two\n");
if (is_shader) {
@@ -1348,7 +1350,7 @@ TEST_P(ValidateCFG, BackEdgeBlockDoesntPostDominateContinueTargetBad) {
str += "OpFunctionEnd";
CompileSuccessfully(str);
- if (GetParam() == SpvCapabilityShader) {
+ if (GetParam() == spv::Capability::Shader) {
ASSERT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions());
EXPECT_THAT(
getDiagnosticString(),
@@ -1363,12 +1365,12 @@ TEST_P(ValidateCFG, BackEdgeBlockDoesntPostDominateContinueTargetBad) {
}
TEST_P(ValidateCFG, BranchingToNonLoopHeaderBlockBad) {
- bool is_shader = GetParam() == SpvCapabilityShader;
+ bool is_shader = GetParam() == spv::Capability::Shader;
Block entry("entry");
- Block split("split", SpvOpBranchConditional);
+ Block split("split", spv::Op::OpBranchConditional);
Block t("t");
Block f("f");
- Block exit("exit", SpvOpReturn);
+ Block exit("exit", spv::Op::OpReturn);
entry.SetBody("%cond = OpSLessThan %boolt %one %two\n");
if (is_shader) split.SetBody("OpSelectionMerge %exit None\n");
@@ -1398,10 +1400,10 @@ TEST_P(ValidateCFG, BranchingToNonLoopHeaderBlockBad) {
}
TEST_P(ValidateCFG, BranchingToSameNonLoopHeaderBlockBad) {
- bool is_shader = GetParam() == SpvCapabilityShader;
+ bool is_shader = GetParam() == spv::Capability::Shader;
Block entry("entry");
- Block split("split", SpvOpBranchConditional);
- Block exit("exit", SpvOpReturn);
+ Block split("split", spv::Op::OpBranchConditional);
+ Block exit("exit", spv::Op::OpReturn);
entry.SetBody("%cond = OpSLessThan %boolt %one %two\n");
if (is_shader) split.SetBody("OpSelectionMerge %exit None\n");
@@ -1429,12 +1431,12 @@ TEST_P(ValidateCFG, BranchingToSameNonLoopHeaderBlockBad) {
}
TEST_P(ValidateCFG, MultipleBackEdgeBlocksToLoopHeaderBad) {
- bool is_shader = GetParam() == SpvCapabilityShader;
+ bool is_shader = GetParam() == spv::Capability::Shader;
Block entry("entry");
- Block loop("loop", SpvOpBranchConditional);
+ Block loop("loop", spv::Op::OpBranchConditional);
Block back0("back0");
Block back1("back1");
- Block merge("merge", SpvOpReturn);
+ Block merge("merge", spv::Op::OpReturn);
entry.SetBody("%cond = OpSLessThan %boolt %one %two\n");
if (is_shader) loop.SetBody("OpLoopMerge %merge %back0 None\n");
@@ -1465,13 +1467,13 @@ TEST_P(ValidateCFG, MultipleBackEdgeBlocksToLoopHeaderBad) {
}
TEST_P(ValidateCFG, ContinueTargetMustBePostDominatedByBackEdge) {
- bool is_shader = GetParam() == SpvCapabilityShader;
+ bool is_shader = GetParam() == spv::Capability::Shader;
Block entry("entry");
- Block loop("loop", SpvOpBranchConditional);
- Block cheader("cheader", SpvOpBranchConditional);
+ Block loop("loop", spv::Op::OpBranchConditional);
+ Block cheader("cheader", spv::Op::OpBranchConditional);
Block be_block("be_block");
- Block merge("merge", SpvOpReturn);
- Block exit("exit", SpvOpReturn);
+ Block merge("merge", spv::Op::OpReturn);
+ Block exit("exit", spv::Op::OpReturn);
entry.SetBody("%cond = OpSLessThan %boolt %one %two\n");
if (is_shader) loop.SetBody("OpLoopMerge %merge %cheader None\n");
@@ -1504,11 +1506,11 @@ TEST_P(ValidateCFG, ContinueTargetMustBePostDominatedByBackEdge) {
}
TEST_P(ValidateCFG, BranchOutOfConstructToMergeBad) {
- bool is_shader = GetParam() == SpvCapabilityShader;
+ bool is_shader = GetParam() == spv::Capability::Shader;
Block entry("entry");
- Block loop("loop", SpvOpBranchConditional);
- Block cont("cont", SpvOpBranchConditional);
- Block merge("merge", SpvOpReturn);
+ Block loop("loop", spv::Op::OpBranchConditional);
+ Block cont("cont", spv::Op::OpBranchConditional);
+ Block merge("merge", spv::Op::OpReturn);
entry.SetBody("%cond = OpSLessThan %boolt %one %two\n");
if (is_shader) loop.SetBody("OpLoopMerge %merge %loop None\n");
@@ -1539,12 +1541,12 @@ TEST_P(ValidateCFG, BranchOutOfConstructToMergeBad) {
}
TEST_P(ValidateCFG, BranchOutOfConstructBad) {
- bool is_shader = GetParam() == SpvCapabilityShader;
+ bool is_shader = GetParam() == spv::Capability::Shader;
Block entry("entry");
- Block loop("loop", SpvOpBranchConditional);
- Block cont("cont", SpvOpBranchConditional);
+ Block loop("loop", spv::Op::OpBranchConditional);
+ Block cont("cont", spv::Op::OpBranchConditional);
Block merge("merge");
- Block exit("exit", SpvOpReturn);
+ Block exit("exit", spv::Op::OpReturn);
entry.SetBody("%cond = OpSLessThan %boolt %one %two\n");
if (is_shader) loop.SetBody("OpLoopMerge %merge %loop None\n");
@@ -1575,12 +1577,12 @@ TEST_P(ValidateCFG, BranchOutOfConstructBad) {
}
TEST_F(ValidateCFG, OpSwitchToUnreachableBlock) {
- Block entry("entry", SpvOpSwitch);
+ Block entry("entry", spv::Op::OpSwitch);
Block case0("case0");
Block case1("case1");
Block case2("case2");
- Block def("default", SpvOpUnreachable);
- Block phi("phi", SpvOpReturn);
+ Block def("default", spv::Op::OpUnreachable);
+ Block phi("phi", spv::Op::OpReturn);
std::string str = R"(
OpCapability Shader
@@ -1687,13 +1689,13 @@ TEST_P(ValidateCFG,
// The nested construct has an unreachable merge block. In the
// augmented CFG that merge block
// we still determine that the
- bool is_shader = GetParam() == SpvCapabilityShader;
- Block entry("entry", SpvOpBranchConditional);
- Block inner_head("inner_head", SpvOpBranchConditional);
- Block inner_true("inner_true", SpvOpReturn);
- Block inner_false("inner_false", SpvOpReturn);
+ bool is_shader = GetParam() == spv::Capability::Shader;
+ Block entry("entry", spv::Op::OpBranchConditional);
+ Block inner_head("inner_head", spv::Op::OpBranchConditional);
+ Block inner_true("inner_true", spv::Op::OpReturn);
+ Block inner_false("inner_false", spv::Op::OpReturn);
Block inner_merge("inner_merge");
- Block exit("exit", SpvOpReturn);
+ Block exit("exit", spv::Op::OpReturn);
entry.SetBody("%cond = OpSLessThan %boolt %one %two\n");
if (is_shader) {
@@ -1721,13 +1723,13 @@ TEST_P(ValidateCFG, ContinueTargetCanBeMergeBlockForNestedStructure) {
// The continue construct cannot be the merge target of a nested selection
// because the loop construct must contain "if_merge" because it contains
// "if_head".
- bool is_shader = GetParam() == SpvCapabilityShader;
+ bool is_shader = GetParam() == spv::Capability::Shader;
Block entry("entry");
Block loop("loop");
- Block if_head("if_head", SpvOpBranchConditional);
+ Block if_head("if_head", spv::Op::OpBranchConditional);
Block if_true("if_true");
- Block if_merge("if_merge", SpvOpBranchConditional);
- Block merge("merge", SpvOpReturn);
+ Block if_merge("if_merge", spv::Op::OpBranchConditional);
+ Block merge("merge", spv::Op::OpReturn);
entry.SetBody("%cond = OpSLessThan %boolt %one %two\n");
if (is_shader) {
@@ -1765,11 +1767,11 @@ TEST_P(ValidateCFG, ContinueTargetCanBeMergeBlockForNestedStructure) {
TEST_P(ValidateCFG, SingleLatchBlockMultipleBranchesToLoopHeader) {
// This test case ensures we allow both branches of a loop latch block
// to go back to the loop header. It still counts as a single back edge.
- bool is_shader = GetParam() == SpvCapabilityShader;
+ bool is_shader = GetParam() == spv::Capability::Shader;
Block entry("entry");
- Block loop("loop", SpvOpBranchConditional);
- Block latch("latch", SpvOpBranchConditional);
- Block merge("merge", SpvOpReturn);
+ Block loop("loop", spv::Op::OpBranchConditional);
+ Block latch("latch", spv::Op::OpBranchConditional);
+ Block merge("merge", spv::Op::OpReturn);
entry.SetBody("%cond = OpSLessThan %boolt %one %two\n");
if (is_shader) {
diff --git a/test/val/val_decoration_test.cpp b/test/val/val_decoration_test.cpp
index d864bbf2e..64ab8d05e 100644
--- a/test/val/val_decoration_test.cpp
+++ b/test/val/val_decoration_test.cpp
@@ -62,9 +62,10 @@ TEST_F(ValidateDecorations, ValidateOpDecorateRegistration) {
CompileSuccessfully(spirv);
EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState());
// Must have 2 decorations.
- EXPECT_THAT(vstate_->id_decorations(id),
- Eq(std::set<Decoration>{Decoration(SpvDecorationLocation, {4}),
- Decoration(SpvDecorationCentroid)}));
+ EXPECT_THAT(
+ vstate_->id_decorations(id),
+ Eq(std::set<Decoration>{Decoration(spv::Decoration::Location, {4}),
+ Decoration(spv::Decoration::Centroid)}));
}
TEST_F(ValidateDecorations, ValidateOpMemberDecorateRegistration) {
@@ -89,15 +90,15 @@ TEST_F(ValidateDecorations, ValidateOpMemberDecorateRegistration) {
const uint32_t arr_id = 1;
EXPECT_THAT(
vstate_->id_decorations(arr_id),
- Eq(std::set<Decoration>{Decoration(SpvDecorationArrayStride, {4})}));
+ Eq(std::set<Decoration>{Decoration(spv::Decoration::ArrayStride, {4})}));
// The struct must have 3 decorations.
const uint32_t struct_id = 2;
EXPECT_THAT(
vstate_->id_decorations(struct_id),
- Eq(std::set<Decoration>{Decoration(SpvDecorationNonReadable, {}, 2),
- Decoration(SpvDecorationOffset, {2}, 2),
- Decoration(SpvDecorationBufferBlock)}));
+ Eq(std::set<Decoration>{Decoration(spv::Decoration::NonReadable, {}, 2),
+ Decoration(spv::Decoration::Offset, {2}, 2),
+ Decoration(spv::Decoration::BufferBlock)}));
}
TEST_F(ValidateDecorations, ValidateOpMemberDecorateOutOfBound) {
@@ -152,9 +153,9 @@ TEST_F(ValidateDecorations, ValidateGroupDecorateRegistration) {
// Decoration group has 3 decorations.
auto expected_decorations =
- std::set<Decoration>{Decoration(SpvDecorationDescriptorSet, {0}),
- Decoration(SpvDecorationRelaxedPrecision),
- Decoration(SpvDecorationRestrict)};
+ std::set<Decoration>{Decoration(spv::Decoration::DescriptorSet, {0}),
+ Decoration(spv::Decoration::RelaxedPrecision),
+ Decoration(spv::Decoration::Restrict)};
// Decoration group is applied to id 1, 2, 3, and 4. Note that id 1 (which is
// the decoration group id) also has all the decorations.
@@ -182,7 +183,7 @@ TEST_F(ValidateDecorations, ValidateGroupMemberDecorateRegistration) {
EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState());
// Decoration group has 1 decoration.
auto expected_decorations =
- std::set<Decoration>{Decoration(SpvDecorationOffset, {3}, 3)};
+ std::set<Decoration>{Decoration(spv::Decoration::Offset, {3}, 3)};
// Decoration group is applied to id 2, 3, and 4.
EXPECT_THAT(vstate_->id_decorations(2), Eq(expected_decorations));
diff --git a/test/val/val_non_uniform_test.cpp b/test/val/val_non_uniform_test.cpp
index 3840eec6a..af571d3a9 100644
--- a/test/val/val_non_uniform_test.cpp
+++ b/test/val/val_non_uniform_test.cpp
@@ -97,24 +97,25 @@ OpFunctionEnd)";
return ss.str();
}
-SpvScope scopes[] = {SpvScopeCrossDevice, SpvScopeDevice, SpvScopeWorkgroup,
- SpvScopeSubgroup, SpvScopeInvocation};
+spv::Scope scopes[] = {spv::Scope::CrossDevice, spv::Scope::Device,
+ spv::Scope::Workgroup, spv::Scope::Subgroup,
+ spv::Scope::Invocation};
using ValidateGroupNonUniform = spvtest::ValidateBase<bool>;
using GroupNonUniform = spvtest::ValidateBase<
- std::tuple<std::string, std::string, SpvScope, std::string, std::string>>;
+ std::tuple<std::string, std::string, spv::Scope, std::string, std::string>>;
-std::string ConvertScope(SpvScope scope) {
+std::string ConvertScope(spv::Scope scope) {
switch (scope) {
- case SpvScopeCrossDevice:
+ case spv::Scope::CrossDevice:
return "%cross_device";
- case SpvScopeDevice:
+ case spv::Scope::Device:
return "%device";
- case SpvScopeWorkgroup:
+ case spv::Scope::Workgroup:
return "%workgroup";
- case SpvScopeSubgroup:
+ case spv::Scope::Subgroup:
return "%subgroup";
- case SpvScopeInvocation:
+ case spv::Scope::Invocation:
return "%invocation";
default:
return "";
@@ -124,7 +125,7 @@ std::string ConvertScope(SpvScope scope) {
TEST_P(GroupNonUniform, Vulkan1p1) {
std::string opcode = std::get<0>(GetParam());
std::string type = std::get<1>(GetParam());
- SpvScope execution_scope = std::get<2>(GetParam());
+ spv::Scope execution_scope = std::get<2>(GetParam());
std::string args = std::get<3>(GetParam());
std::string error = std::get<4>(GetParam());
@@ -137,7 +138,7 @@ TEST_P(GroupNonUniform, Vulkan1p1) {
CompileSuccessfully(GenerateShaderCode(sstr.str()), SPV_ENV_VULKAN_1_1);
spv_result_t result = ValidateInstructions(SPV_ENV_VULKAN_1_1);
if (error == "") {
- if (execution_scope == SpvScopeSubgroup) {
+ if (execution_scope == spv::Scope::Subgroup) {
EXPECT_EQ(SPV_SUCCESS, result);
} else {
EXPECT_EQ(SPV_ERROR_INVALID_DATA, result);
@@ -157,7 +158,7 @@ TEST_P(GroupNonUniform, Vulkan1p1) {
TEST_P(GroupNonUniform, Spirv1p3) {
std::string opcode = std::get<0>(GetParam());
std::string type = std::get<1>(GetParam());
- SpvScope execution_scope = std::get<2>(GetParam());
+ spv::Scope execution_scope = std::get<2>(GetParam());
std::string args = std::get<3>(GetParam());
std::string error = std::get<4>(GetParam());
@@ -170,8 +171,8 @@ TEST_P(GroupNonUniform, Spirv1p3) {
CompileSuccessfully(GenerateShaderCode(sstr.str()), SPV_ENV_UNIVERSAL_1_3);
spv_result_t result = ValidateInstructions(SPV_ENV_UNIVERSAL_1_3);
if (error == "") {
- if (execution_scope == SpvScopeSubgroup ||
- execution_scope == SpvScopeWorkgroup) {
+ if (execution_scope == spv::Scope::Subgroup ||
+ execution_scope == spv::Scope::Workgroup) {
EXPECT_EQ(SPV_SUCCESS, result);
} else {
EXPECT_EQ(SPV_ERROR_INVALID_DATA, result);
@@ -280,12 +281,12 @@ INSTANTIATE_TEST_SUITE_P(
GroupNonUniformBallotBitCountBadResultType, GroupNonUniform,
Combine(
Values("OpGroupNonUniformBallotBitCount"), Values("%float", "%int"),
- Values(SpvScopeSubgroup), Values("Reduce %u32vec4_null"),
+ Values(spv::Scope::Subgroup), Values("Reduce %u32vec4_null"),
Values("Expected Result Type to be an unsigned integer type scalar.")));
INSTANTIATE_TEST_SUITE_P(GroupNonUniformBallotBitCountBadValue, GroupNonUniform,
Combine(Values("OpGroupNonUniformBallotBitCount"),
- Values("%u32"), Values(SpvScopeSubgroup),
+ Values("%u32"), Values(spv::Scope::Subgroup),
Values("Reduce %u32vec3_null", "Reduce %u32_0",
"Reduce %float_0"),
Values("Expected Value to be a vector of four "
diff --git a/test/val/val_state_test.cpp b/test/val/val_state_test.cpp
index 65cb1c3ad..4097a1feb 100644
--- a/test/val/val_state_test.cpp
+++ b/test/val/val_state_test.cpp
@@ -59,40 +59,41 @@ using ValidationState_HasAnyOfCapabilities = ValidationStateTest;
TEST_F(ValidationState_HasAnyOfCapabilities, EmptyMask) {
EXPECT_TRUE(state_.HasAnyOfCapabilities({}));
- state_.RegisterCapability(SpvCapabilityMatrix);
+ state_.RegisterCapability(spv::Capability::Matrix);
EXPECT_TRUE(state_.HasAnyOfCapabilities({}));
- state_.RegisterCapability(SpvCapabilityImageMipmap);
+ state_.RegisterCapability(spv::Capability::ImageMipmap);
EXPECT_TRUE(state_.HasAnyOfCapabilities({}));
- state_.RegisterCapability(SpvCapabilityPipes);
+ state_.RegisterCapability(spv::Capability::Pipes);
EXPECT_TRUE(state_.HasAnyOfCapabilities({}));
- state_.RegisterCapability(SpvCapabilityStorageImageArrayDynamicIndexing);
+ state_.RegisterCapability(spv::Capability::StorageImageArrayDynamicIndexing);
EXPECT_TRUE(state_.HasAnyOfCapabilities({}));
- state_.RegisterCapability(SpvCapabilityClipDistance);
+ state_.RegisterCapability(spv::Capability::ClipDistance);
EXPECT_TRUE(state_.HasAnyOfCapabilities({}));
- state_.RegisterCapability(SpvCapabilityStorageImageWriteWithoutFormat);
+ state_.RegisterCapability(spv::Capability::StorageImageWriteWithoutFormat);
EXPECT_TRUE(state_.HasAnyOfCapabilities({}));
}
TEST_F(ValidationState_HasAnyOfCapabilities, SingleCapMask) {
- EXPECT_FALSE(state_.HasAnyOfCapabilities({SpvCapabilityMatrix}));
- EXPECT_FALSE(state_.HasAnyOfCapabilities({SpvCapabilityImageMipmap}));
- state_.RegisterCapability(SpvCapabilityMatrix);
- EXPECT_TRUE(state_.HasAnyOfCapabilities({SpvCapabilityMatrix}));
- EXPECT_FALSE(state_.HasAnyOfCapabilities({SpvCapabilityImageMipmap}));
- state_.RegisterCapability(SpvCapabilityImageMipmap);
- EXPECT_TRUE(state_.HasAnyOfCapabilities({SpvCapabilityMatrix}));
- EXPECT_TRUE(state_.HasAnyOfCapabilities({SpvCapabilityImageMipmap}));
+ EXPECT_FALSE(state_.HasAnyOfCapabilities({spv::Capability::Matrix}));
+ EXPECT_FALSE(state_.HasAnyOfCapabilities({spv::Capability::ImageMipmap}));
+ state_.RegisterCapability(spv::Capability::Matrix);
+ EXPECT_TRUE(state_.HasAnyOfCapabilities({spv::Capability::Matrix}));
+ EXPECT_FALSE(state_.HasAnyOfCapabilities({spv::Capability::ImageMipmap}));
+ state_.RegisterCapability(spv::Capability::ImageMipmap);
+ EXPECT_TRUE(state_.HasAnyOfCapabilities({spv::Capability::Matrix}));
+ EXPECT_TRUE(state_.HasAnyOfCapabilities({spv::Capability::ImageMipmap}));
}
TEST_F(ValidationState_HasAnyOfCapabilities, MultiCapMask) {
const auto set1 =
- CapabilitySet{SpvCapabilitySampledRect, SpvCapabilityImageBuffer};
- const auto set2 = CapabilitySet{SpvCapabilityStorageImageWriteWithoutFormat,
- SpvCapabilityStorageImageReadWithoutFormat,
- SpvCapabilityGeometryStreams};
+ CapabilitySet{spv::Capability::SampledRect, spv::Capability::ImageBuffer};
+ const auto set2 =
+ CapabilitySet{spv::Capability::StorageImageWriteWithoutFormat,
+ spv::Capability::StorageImageReadWithoutFormat,
+ spv::Capability::GeometryStreams};
EXPECT_FALSE(state_.HasAnyOfCapabilities(set1));
EXPECT_FALSE(state_.HasAnyOfCapabilities(set2));
- state_.RegisterCapability(SpvCapabilityImageBuffer);
+ state_.RegisterCapability(spv::Capability::ImageBuffer);
EXPECT_TRUE(state_.HasAnyOfCapabilities(set1));
EXPECT_FALSE(state_.HasAnyOfCapabilities(set2));
}
@@ -139,50 +140,52 @@ using ValidationState_InLayoutState = ValidationStateTest;
TEST_F(ValidationState_InLayoutState, Variable) {
state_.SetCurrentLayoutSectionForTesting(kLayoutTypes);
- EXPECT_TRUE(state_.IsOpcodeInCurrentLayoutSection(SpvOpVariable));
+ EXPECT_TRUE(state_.IsOpcodeInCurrentLayoutSection(spv::Op::OpVariable));
state_.SetCurrentLayoutSectionForTesting(kLayoutFunctionDefinitions);
- EXPECT_TRUE(state_.IsOpcodeInCurrentLayoutSection(SpvOpVariable));
+ EXPECT_TRUE(state_.IsOpcodeInCurrentLayoutSection(spv::Op::OpVariable));
}
TEST_F(ValidationState_InLayoutState, ExtInst) {
state_.SetCurrentLayoutSectionForTesting(kLayoutTypes);
- EXPECT_TRUE(state_.IsOpcodeInCurrentLayoutSection(SpvOpExtInst));
+ EXPECT_TRUE(state_.IsOpcodeInCurrentLayoutSection(spv::Op::OpExtInst));
state_.SetCurrentLayoutSectionForTesting(kLayoutFunctionDefinitions);
- EXPECT_TRUE(state_.IsOpcodeInCurrentLayoutSection(SpvOpExtInst));
+ EXPECT_TRUE(state_.IsOpcodeInCurrentLayoutSection(spv::Op::OpExtInst));
}
TEST_F(ValidationState_InLayoutState, Undef) {
state_.SetCurrentLayoutSectionForTesting(kLayoutTypes);
- EXPECT_TRUE(state_.IsOpcodeInCurrentLayoutSection(SpvOpUndef));
+ EXPECT_TRUE(state_.IsOpcodeInCurrentLayoutSection(spv::Op::OpUndef));
state_.SetCurrentLayoutSectionForTesting(kLayoutFunctionDefinitions);
- EXPECT_TRUE(state_.IsOpcodeInCurrentLayoutSection(SpvOpUndef));
+ EXPECT_TRUE(state_.IsOpcodeInCurrentLayoutSection(spv::Op::OpUndef));
}
TEST_F(ValidationState_InLayoutState, Function) {
state_.SetCurrentLayoutSectionForTesting(kLayoutFunctionDeclarations);
- EXPECT_TRUE(state_.IsOpcodeInCurrentLayoutSection(SpvOpFunction));
+ EXPECT_TRUE(state_.IsOpcodeInCurrentLayoutSection(spv::Op::OpFunction));
state_.SetCurrentLayoutSectionForTesting(kLayoutFunctionDefinitions);
- EXPECT_TRUE(state_.IsOpcodeInCurrentLayoutSection(SpvOpFunction));
+ EXPECT_TRUE(state_.IsOpcodeInCurrentLayoutSection(spv::Op::OpFunction));
}
TEST_F(ValidationState_InLayoutState, FunctionParameter) {
state_.SetCurrentLayoutSectionForTesting(kLayoutFunctionDeclarations);
- EXPECT_TRUE(state_.IsOpcodeInCurrentLayoutSection(SpvOpFunctionParameter));
+ EXPECT_TRUE(
+ state_.IsOpcodeInCurrentLayoutSection(spv::Op::OpFunctionParameter));
state_.SetCurrentLayoutSectionForTesting(kLayoutFunctionDefinitions);
- EXPECT_TRUE(state_.IsOpcodeInCurrentLayoutSection(SpvOpFunctionParameter));
+ EXPECT_TRUE(
+ state_.IsOpcodeInCurrentLayoutSection(spv::Op::OpFunctionParameter));
}
TEST_F(ValidationState_InLayoutState, FunctionEnd) {
state_.SetCurrentLayoutSectionForTesting(kLayoutFunctionDeclarations);
- EXPECT_TRUE(state_.IsOpcodeInCurrentLayoutSection(SpvOpFunctionEnd));
+ EXPECT_TRUE(state_.IsOpcodeInCurrentLayoutSection(spv::Op::OpFunctionEnd));
state_.SetCurrentLayoutSectionForTesting(kLayoutFunctionDefinitions);
- EXPECT_TRUE(state_.IsOpcodeInCurrentLayoutSection(SpvOpFunctionEnd));
+ EXPECT_TRUE(state_.IsOpcodeInCurrentLayoutSection(spv::Op::OpFunctionEnd));
}
} // namespace
diff --git a/test/val/val_type_unique_test.cpp b/test/val/val_type_unique_test.cpp
index 45a4d5048..31ad3a659 100644
--- a/test/val/val_type_unique_test.cpp
+++ b/test/val/val_type_unique_test.cpp
@@ -90,7 +90,7 @@ OpFunctionEnd
// Returns expected error string if |opcode| produces a duplicate type
// declaration.
-std::string GetErrorString(SpvOp opcode) {
+std::string GetErrorString(spv::Op opcode) {
return "Duplicate non-aggregate type declarations are not allowed. Opcode: " +
std::string(spvOpcodeString(opcode));
}
@@ -107,7 +107,8 @@ TEST_F(ValidateTypeUnique, duplicate_void) {
)" + GetBody();
CompileSuccessfully(str.c_str());
ASSERT_EQ(kDuplicateTypeError, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(), HasSubstr(GetErrorString(SpvOpTypeVoid)));
+ EXPECT_THAT(getDiagnosticString(),
+ HasSubstr(GetErrorString(spv::Op::OpTypeVoid)));
}
TEST_F(ValidateTypeUnique, duplicate_bool) {
@@ -116,7 +117,8 @@ TEST_F(ValidateTypeUnique, duplicate_bool) {
)" + GetBody();
CompileSuccessfully(str.c_str());
ASSERT_EQ(kDuplicateTypeError, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(), HasSubstr(GetErrorString(SpvOpTypeBool)));
+ EXPECT_THAT(getDiagnosticString(),
+ HasSubstr(GetErrorString(spv::Op::OpTypeBool)));
}
TEST_F(ValidateTypeUnique, duplicate_int) {
@@ -125,7 +127,8 @@ TEST_F(ValidateTypeUnique, duplicate_int) {
)" + GetBody();
CompileSuccessfully(str.c_str());
ASSERT_EQ(kDuplicateTypeError, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(), HasSubstr(GetErrorString(SpvOpTypeInt)));
+ EXPECT_THAT(getDiagnosticString(),
+ HasSubstr(GetErrorString(spv::Op::OpTypeInt)));
}
TEST_F(ValidateTypeUnique, duplicate_float) {
@@ -134,7 +137,8 @@ TEST_F(ValidateTypeUnique, duplicate_float) {
)" + GetBody();
CompileSuccessfully(str.c_str());
ASSERT_EQ(kDuplicateTypeError, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(), HasSubstr(GetErrorString(SpvOpTypeFloat)));
+ EXPECT_THAT(getDiagnosticString(),
+ HasSubstr(GetErrorString(spv::Op::OpTypeFloat)));
}
TEST_F(ValidateTypeUnique, duplicate_vec3) {
@@ -144,7 +148,7 @@ TEST_F(ValidateTypeUnique, duplicate_vec3) {
CompileSuccessfully(str.c_str());
ASSERT_EQ(kDuplicateTypeError, ValidateInstructions());
EXPECT_THAT(getDiagnosticString(),
- HasSubstr(GetErrorString(SpvOpTypeVector)));
+ HasSubstr(GetErrorString(spv::Op::OpTypeVector)));
}
TEST_F(ValidateTypeUnique, duplicate_mat33) {
@@ -154,7 +158,7 @@ TEST_F(ValidateTypeUnique, duplicate_mat33) {
CompileSuccessfully(str.c_str());
ASSERT_EQ(kDuplicateTypeError, ValidateInstructions());
EXPECT_THAT(getDiagnosticString(),
- HasSubstr(GetErrorString(SpvOpTypeMatrix)));
+ HasSubstr(GetErrorString(spv::Op::OpTypeMatrix)));
}
TEST_F(ValidateTypeUnique, duplicate_vfunc) {
@@ -164,7 +168,7 @@ TEST_F(ValidateTypeUnique, duplicate_vfunc) {
CompileSuccessfully(str.c_str());
ASSERT_EQ(kDuplicateTypeError, ValidateInstructions());
EXPECT_THAT(getDiagnosticString(),
- HasSubstr(GetErrorString(SpvOpTypeFunction)));
+ HasSubstr(GetErrorString(spv::Op::OpTypeFunction)));
}
TEST_F(ValidateTypeUnique, duplicate_pipe_storage) {
@@ -181,7 +185,7 @@ OpMemoryModel Physical32 OpenCL
CompileSuccessfully(str.c_str(), SPV_ENV_UNIVERSAL_1_1);
ASSERT_EQ(kDuplicateTypeError, ValidateInstructions(SPV_ENV_UNIVERSAL_1_1));
EXPECT_THAT(getDiagnosticString(),
- HasSubstr(GetErrorString(SpvOpTypePipeStorage)));
+ HasSubstr(GetErrorString(spv::Op::OpTypePipeStorage)));
}
TEST_F(ValidateTypeUnique, duplicate_named_barrier) {
@@ -197,7 +201,7 @@ OpMemoryModel Physical32 OpenCL
CompileSuccessfully(str.c_str(), SPV_ENV_UNIVERSAL_1_1);
ASSERT_EQ(kDuplicateTypeError, ValidateInstructions(SPV_ENV_UNIVERSAL_1_1));
EXPECT_THAT(getDiagnosticString(),
- HasSubstr(GetErrorString(SpvOpTypeNamedBarrier)));
+ HasSubstr(GetErrorString(spv::Op::OpTypeNamedBarrier)));
}
TEST_F(ValidateTypeUnique, duplicate_forward_pointer) {
@@ -234,7 +238,7 @@ OpMemoryModel Physical32 OpenCL
CompileSuccessfully(str.c_str());
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
EXPECT_THAT(getDiagnosticString(),
- Not(HasSubstr(GetErrorString(SpvOpTypeVoid))));
+ Not(HasSubstr(GetErrorString(spv::Op::OpTypeVoid))));
}
TEST_F(ValidateTypeUnique, DuplicatePointerTypesNoExtension) {
@@ -263,7 +267,7 @@ OpMemoryModel Logical GLSL450
CompileSuccessfully(str.c_str());
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
EXPECT_THAT(getDiagnosticString(),
- Not(HasSubstr(GetErrorString(SpvOpTypePointer))));
+ Not(HasSubstr(GetErrorString(spv::Op::OpTypePointer))));
}
} // namespace
diff --git a/test/val/val_validation_state_test.cpp b/test/val/val_validation_state_test.cpp
index 3dd9e64a6..a5e88deab 100644
--- a/test/val/val_validation_state_test.cpp
+++ b/test/val/val_validation_state_test.cpp
@@ -180,7 +180,7 @@ TEST_F(ValidationStateTest, CheckEntryPoints) {
CompileSuccessfully(spirv);
EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState());
EXPECT_EQ(size_t(1), vstate_->entry_points().size());
- EXPECT_EQ(SpvOpFunction,
+ EXPECT_EQ(spv::Op::OpFunction,
vstate_->FindDef(vstate_->entry_points()[0])->opcode());
}