aboutsummaryrefslogtreecommitdiff
path: root/source/fuzz
diff options
context:
space:
mode:
Diffstat (limited to 'source/fuzz')
-rw-r--r--source/fuzz/CMakeLists.txt5
-rw-r--r--source/fuzz/added_function_reducer.cpp4
-rw-r--r--source/fuzz/call_graph.cpp2
-rw-r--r--source/fuzz/fact_manager/constant_uniform_facts.cpp11
-rw-r--r--source/fuzz/fact_manager/data_synonym_and_id_equation_facts.cpp47
-rw-r--r--source/fuzz/fact_manager/data_synonym_and_id_equation_facts.h4
-rw-r--r--source/fuzz/fact_manager/fact_manager.cpp6
-rw-r--r--source/fuzz/fact_manager/fact_manager.h2
-rw-r--r--source/fuzz/force_render_red.cpp51
-rw-r--r--source/fuzz/fuzzer_pass.cpp71
-rw-r--r--source/fuzz/fuzzer_pass.h6
-rw-r--r--source/fuzz/fuzzer_pass_add_access_chains.cpp37
-rw-r--r--source/fuzz/fuzzer_pass_add_composite_extract.cpp20
-rw-r--r--source/fuzz/fuzzer_pass_add_composite_inserts.cpp11
-rw-r--r--source/fuzz/fuzzer_pass_add_composite_types.cpp14
-rw-r--r--source/fuzz/fuzzer_pass_add_copy_memory.cpp6
-rw-r--r--source/fuzz/fuzzer_pass_add_equation_instructions.cpp36
-rw-r--r--source/fuzz/fuzzer_pass_add_function_calls.cpp16
-rw-r--r--source/fuzz/fuzzer_pass_add_global_variables.cpp11
-rw-r--r--source/fuzz/fuzzer_pass_add_loads.cpp36
-rw-r--r--source/fuzz/fuzzer_pass_add_local_variables.cpp4
-rw-r--r--source/fuzz/fuzzer_pass_add_opphi_synonyms.cpp4
-rw-r--r--source/fuzz/fuzzer_pass_add_parameters.cpp6
-rw-r--r--source/fuzz/fuzzer_pass_add_stores.cpp43
-rw-r--r--source/fuzz/fuzzer_pass_add_synonyms.cpp3
-rw-r--r--source/fuzz/fuzzer_pass_add_vector_shuffle_instructions.cpp11
-rw-r--r--source/fuzz/fuzzer_pass_adjust_branch_weights.cpp2
-rw-r--r--source/fuzz/fuzzer_pass_adjust_function_controls.cpp16
-rw-r--r--source/fuzz/fuzzer_pass_adjust_loop_controls.cpp30
-rw-r--r--source/fuzz/fuzzer_pass_adjust_memory_operands_masks.cpp20
-rw-r--r--source/fuzz/fuzzer_pass_adjust_selection_controls.cpp13
-rw-r--r--source/fuzz/fuzzer_pass_apply_id_synonyms.cpp10
-rw-r--r--source/fuzz/fuzzer_pass_apply_id_synonyms.h2
-rw-r--r--source/fuzz/fuzzer_pass_construct_composites.cpp18
-rw-r--r--source/fuzz/fuzzer_pass_copy_objects.cpp11
-rw-r--r--source/fuzz/fuzzer_pass_donate_modules.cpp279
-rw-r--r--source/fuzz/fuzzer_pass_donate_modules.h3
-rw-r--r--source/fuzz/fuzzer_pass_expand_vector_reductions.cpp4
-rw-r--r--source/fuzz/fuzzer_pass_flatten_conditional_branches.cpp16
-rw-r--r--source/fuzz/fuzzer_pass_inline_functions.cpp2
-rw-r--r--source/fuzz/fuzzer_pass_make_vector_operations_dynamic.cpp14
-rw-r--r--source/fuzz/fuzzer_pass_merge_function_returns.cpp21
-rw-r--r--source/fuzz/fuzzer_pass_mutate_pointers.cpp3
-rw-r--r--source/fuzz/fuzzer_pass_obfuscate_constants.cpp62
-rw-r--r--source/fuzz/fuzzer_pass_obfuscate_constants.h6
-rw-r--r--source/fuzz/fuzzer_pass_outline_functions.cpp10
-rw-r--r--source/fuzz/fuzzer_pass_permute_function_variables.cpp2
-rw-r--r--source/fuzz/fuzzer_pass_permute_phi_operands.cpp2
-rw-r--r--source/fuzz/fuzzer_pass_push_ids_through_variables.cpp34
-rw-r--r--source/fuzz/fuzzer_pass_replace_branches_from_dead_blocks_with_exits.cpp24
-rw-r--r--source/fuzz/fuzzer_pass_replace_copy_memories_with_loads_stores.cpp2
-rw-r--r--source/fuzz/fuzzer_pass_replace_copy_objects_with_stores_loads.cpp15
-rw-r--r--source/fuzz/fuzzer_pass_replace_irrelevant_ids.cpp2
-rw-r--r--source/fuzz/fuzzer_pass_replace_loads_stores_with_copy_memories.cpp6
-rw-r--r--source/fuzz/fuzzer_pass_replace_opphi_ids_from_dead_predecessors.cpp2
-rw-r--r--source/fuzz/fuzzer_pass_replace_opselects_with_conditional_branches.cpp8
-rw-r--r--source/fuzz/fuzzer_pass_replace_parameter_with_global.cpp3
-rw-r--r--source/fuzz/fuzzer_pass_split_blocks.cpp4
-rw-r--r--source/fuzz/fuzzer_pass_swap_conditional_branch_operands.cpp2
-rw-r--r--source/fuzz/fuzzer_pass_toggle_access_chain_instruction.cpp5
-rw-r--r--source/fuzz/fuzzer_pass_wrap_vector_synonym.cpp2
-rw-r--r--source/fuzz/fuzzer_util.cpp599
-rw-r--r--source/fuzz/fuzzer_util.h22
-rw-r--r--source/fuzz/instruction_descriptor.cpp11
-rw-r--r--source/fuzz/instruction_descriptor.h2
-rw-r--r--source/fuzz/instruction_message.cpp6
-rw-r--r--source/fuzz/instruction_message.h2
-rw-r--r--source/fuzz/transformation_access_chain.cpp32
-rw-r--r--source/fuzz/transformation_add_bit_instruction_synonym.cpp43
-rw-r--r--source/fuzz/transformation_add_constant_boolean.cpp3
-rw-r--r--source/fuzz/transformation_add_constant_composite.cpp10
-rw-r--r--source/fuzz/transformation_add_constant_null.cpp4
-rw-r--r--source/fuzz/transformation_add_constant_scalar.cpp2
-rw-r--r--source/fuzz/transformation_add_copy_memory.cpp26
-rw-r--r--source/fuzz/transformation_add_copy_memory.h2
-rw-r--r--source/fuzz/transformation_add_dead_block.cpp12
-rw-r--r--source/fuzz/transformation_add_dead_break.cpp2
-rw-r--r--source/fuzz/transformation_add_dead_continue.cpp2
-rw-r--r--source/fuzz/transformation_add_early_terminator_wrapper.cpp25
-rw-r--r--source/fuzz/transformation_add_early_terminator_wrapper.h2
-rw-r--r--source/fuzz/transformation_add_function.cpp132
-rw-r--r--source/fuzz/transformation_add_global_undef.cpp6
-rw-r--r--source/fuzz/transformation_add_global_variable.cpp14
-rw-r--r--source/fuzz/transformation_add_global_variable.h2
-rw-r--r--source/fuzz/transformation_add_image_sample_unused_components.cpp2
-rw-r--r--source/fuzz/transformation_add_local_variable.cpp6
-rw-r--r--source/fuzz/transformation_add_loop_preheader.cpp10
-rw-r--r--source/fuzz/transformation_add_loop_to_create_int_constant_synonym.cpp38
-rw-r--r--source/fuzz/transformation_add_no_contraction_decoration.cpp90
-rw-r--r--source/fuzz/transformation_add_no_contraction_decoration.h2
-rw-r--r--source/fuzz/transformation_add_opphi_synonym.cpp10
-rw-r--r--source/fuzz/transformation_add_parameter.cpp28
-rw-r--r--source/fuzz/transformation_add_relaxed_decoration.cpp144
-rw-r--r--source/fuzz/transformation_add_relaxed_decoration.h2
-rw-r--r--source/fuzz/transformation_add_spec_constant_op.cpp8
-rw-r--r--source/fuzz/transformation_add_spec_constant_op.h2
-rw-r--r--source/fuzz/transformation_add_synonym.cpp23
-rw-r--r--source/fuzz/transformation_add_type_array.cpp2
-rw-r--r--source/fuzz/transformation_add_type_boolean.cpp2
-rw-r--r--source/fuzz/transformation_add_type_float.cpp8
-rw-r--r--source/fuzz/transformation_add_type_int.cpp11
-rw-r--r--source/fuzz/transformation_add_type_matrix.cpp2
-rw-r--r--source/fuzz/transformation_add_type_pointer.cpp6
-rw-r--r--source/fuzz/transformation_add_type_pointer.h3
-rw-r--r--source/fuzz/transformation_add_type_struct.cpp5
-rw-r--r--source/fuzz/transformation_add_type_vector.cpp2
-rw-r--r--source/fuzz/transformation_adjust_branch_weights.cpp4
-rw-r--r--source/fuzz/transformation_composite_construct.cpp2
-rw-r--r--source/fuzz/transformation_composite_extract.cpp4
-rw-r--r--source/fuzz/transformation_composite_insert.cpp6
-rw-r--r--source/fuzz/transformation_duplicate_region_with_selection.cpp58
-rw-r--r--source/fuzz/transformation_equation_instruction.cpp27
-rw-r--r--source/fuzz/transformation_equation_instruction.h2
-rw-r--r--source/fuzz/transformation_expand_vector_reduction.cpp15
-rw-r--r--source/fuzz/transformation_flatten_conditional_branch.cpp81
-rw-r--r--source/fuzz/transformation_function_call.cpp14
-rw-r--r--source/fuzz/transformation_inline_function.cpp18
-rw-r--r--source/fuzz/transformation_invert_comparison_operator.cpp143
-rw-r--r--source/fuzz/transformation_invert_comparison_operator.h4
-rw-r--r--source/fuzz/transformation_load.cpp34
-rw-r--r--source/fuzz/transformation_load.h2
-rw-r--r--source/fuzz/transformation_make_vector_operation_dynamic.cpp16
-rw-r--r--source/fuzz/transformation_merge_function_returns.cpp47
-rw-r--r--source/fuzz/transformation_move_instruction_down.cpp468
-rw-r--r--source/fuzz/transformation_mutate_pointer.cpp24
-rw-r--r--source/fuzz/transformation_outline_function.cpp55
-rw-r--r--source/fuzz/transformation_permute_function_parameters.cpp2
-rw-r--r--source/fuzz/transformation_permute_phi_operands.cpp2
-rw-r--r--source/fuzz/transformation_propagate_instruction_down.cpp218
-rw-r--r--source/fuzz/transformation_propagate_instruction_down.h4
-rw-r--r--source/fuzz/transformation_propagate_instruction_up.cpp222
-rw-r--r--source/fuzz/transformation_propagate_instruction_up.h2
-rw-r--r--source/fuzz/transformation_push_id_through_variable.cpp23
-rw-r--r--source/fuzz/transformation_replace_add_sub_mul_with_carrying_extended.cpp28
-rw-r--r--source/fuzz/transformation_replace_boolean_constant_with_constant_binary.cpp67
-rw-r--r--source/fuzz/transformation_replace_boolean_constant_with_constant_binary.h2
-rw-r--r--source/fuzz/transformation_replace_branch_from_dead_block_with_exit.cpp30
-rw-r--r--source/fuzz/transformation_replace_branch_from_dead_block_with_exit.h2
-rw-r--r--source/fuzz/transformation_replace_constant_with_uniform.cpp29
-rw-r--r--source/fuzz/transformation_replace_copy_memory_with_load_store.cpp12
-rw-r--r--source/fuzz/transformation_replace_copy_object_with_store_load.cpp25
-rw-r--r--source/fuzz/transformation_replace_irrelevant_id.cpp4
-rw-r--r--source/fuzz/transformation_replace_linear_algebra_instruction.cpp131
-rw-r--r--source/fuzz/transformation_replace_load_store_with_copy_memory.cpp40
-rw-r--r--source/fuzz/transformation_replace_load_store_with_copy_memory.h6
-rw-r--r--source/fuzz/transformation_replace_opphi_id_from_dead_predecessor.cpp2
-rw-r--r--source/fuzz/transformation_replace_opselect_with_conditional_branch.cpp24
-rw-r--r--source/fuzz/transformation_replace_parameter_with_global.cpp22
-rw-r--r--source/fuzz/transformation_replace_params_with_struct.cpp16
-rw-r--r--source/fuzz/transformation_set_function_control.cpp18
-rw-r--r--source/fuzz/transformation_set_loop_control.cpp64
-rw-r--r--source/fuzz/transformation_set_loop_control.h2
-rw-r--r--source/fuzz/transformation_set_memory_operands_mask.cpp57
-rw-r--r--source/fuzz/transformation_set_selection_control.cpp11
-rw-r--r--source/fuzz/transformation_split_block.cpp8
-rw-r--r--source/fuzz/transformation_store.cpp30
-rw-r--r--source/fuzz/transformation_store.h2
-rw-r--r--source/fuzz/transformation_swap_commutable_operands.cpp4
-rw-r--r--source/fuzz/transformation_swap_conditional_branch_operands.cpp12
-rw-r--r--source/fuzz/transformation_swap_function_variables.cpp4
-rw-r--r--source/fuzz/transformation_toggle_access_chain_instruction.cpp15
-rw-r--r--source/fuzz/transformation_vector_shuffle.cpp6
-rw-r--r--source/fuzz/transformation_wrap_early_terminator_in_function.cpp20
-rw-r--r--source/fuzz/transformation_wrap_early_terminator_in_function.h4
-rw-r--r--source/fuzz/transformation_wrap_region_in_selection.cpp10
-rw-r--r--source/fuzz/transformation_wrap_vector_synonym.cpp18
-rw-r--r--source/fuzz/uniform_buffer_element_descriptor.cpp9
167 files changed, 2294 insertions, 2426 deletions
diff --git a/source/fuzz/CMakeLists.txt b/source/fuzz/CMakeLists.txt
index 86ee657a..dd674dd0 100644
--- a/source/fuzz/CMakeLists.txt
+++ b/source/fuzz/CMakeLists.txt
@@ -470,7 +470,10 @@ if(SPIRV_BUILD_FUZZER)
spvtools_check_symbol_exports(SPIRV-Tools-fuzz)
if(ENABLE_SPIRV_TOOLS_INSTALL)
- install(TARGETS SPIRV-Tools-fuzz EXPORT SPIRV-Tools-fuzzTargets)
+ install(TARGETS SPIRV-Tools-fuzz EXPORT SPIRV-Tools-fuzzTargets
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
export(EXPORT SPIRV-Tools-fuzzTargets FILE SPIRV-Tools-fuzzTarget.cmake)
spvtools_config_package_dir(SPIRV-Tools-fuzz PACKAGE_DIR)
diff --git a/source/fuzz/added_function_reducer.cpp b/source/fuzz/added_function_reducer.cpp
index 95cf9d6d..e7cb027b 100644
--- a/source/fuzz/added_function_reducer.cpp
+++ b/source/fuzz/added_function_reducer.cpp
@@ -130,7 +130,7 @@ bool AddedFunctionReducer::InterestingnessFunctionForReducingAddedFunction(
binary_under_reduction.size());
assert(ir_context != nullptr && "The binary should be parsable.");
for (auto& type_or_value : ir_context->module()->types_values()) {
- if (type_or_value.opcode() != spv::Op::OpVariable) {
+ if (type_or_value.opcode() != SpvOpVariable) {
continue;
}
if (irrelevant_pointee_global_variables.count(type_or_value.result_id())) {
@@ -202,7 +202,7 @@ void AddedFunctionReducer::ReplayPrefixAndAddFunction(
auto* ir_context = replay_result.transformed_module.get();
for (auto& type_or_value : ir_context->module()->types_values()) {
- if (type_or_value.opcode() != spv::Op::OpVariable) {
+ if (type_or_value.opcode() != SpvOpVariable) {
continue;
}
if (replay_result.transformation_context->GetFactManager()
diff --git a/source/fuzz/call_graph.cpp b/source/fuzz/call_graph.cpp
index d61a5f84..c52bc342 100644
--- a/source/fuzz/call_graph.cpp
+++ b/source/fuzz/call_graph.cpp
@@ -54,7 +54,7 @@ void CallGraph::BuildGraphAndGetDepthOfFunctionCalls(
// Consider every function call instruction in every block.
for (auto& block : function) {
for (auto& instruction : block) {
- if (instruction.opcode() != spv::Op::OpFunctionCall) {
+ if (instruction.opcode() != SpvOpFunctionCall) {
continue;
}
// Get the id of the function being called.
diff --git a/source/fuzz/fact_manager/constant_uniform_facts.cpp b/source/fuzz/fact_manager/constant_uniform_facts.cpp
index 461859bd..a629c0d3 100644
--- a/source/fuzz/fact_manager/constant_uniform_facts.cpp
+++ b/source/fuzz/fact_manager/constant_uniform_facts.cpp
@@ -63,7 +63,7 @@ std::vector<uint32_t> ConstantUniformFacts::GetConstantWords(
bool ConstantUniformFacts::DataMatches(
const opt::Instruction& constant_instruction,
const protobufs::FactConstantUniform& constant_uniform_fact) {
- assert(constant_instruction.opcode() == spv::Op::OpConstant);
+ assert(constant_instruction.opcode() == SpvOpConstant);
std::vector<uint32_t> data_in_constant;
for (uint32_t i = 0; i < constant_instruction.NumInOperands(); i++) {
data_in_constant.push_back(constant_instruction.GetSingleWordInOperand(i));
@@ -95,7 +95,7 @@ ConstantUniformFacts::GetUniformDescriptorsForConstant(
uint32_t constant_id) const {
std::vector<protobufs::UniformBufferElementDescriptor> result;
auto constant_inst = ir_context_->get_def_use_mgr()->GetDef(constant_id);
- assert(constant_inst->opcode() == spv::Op::OpConstant &&
+ assert(constant_inst->opcode() == SpvOpConstant &&
"The given id must be that of a constant");
auto type_id = constant_inst->type_id();
for (auto& fact_and_type_id : facts_and_type_ids_) {
@@ -175,9 +175,8 @@ bool ConstantUniformFacts::MaybeAddFact(
return false;
}
- assert(spv::Op::OpVariable == uniform_variable->opcode());
- assert(spv::StorageClass::Uniform ==
- spv::StorageClass(uniform_variable->GetSingleWordInOperand(0)));
+ assert(SpvOpVariable == uniform_variable->opcode());
+ assert(SpvStorageClassUniform == uniform_variable->GetSingleWordInOperand(0));
auto should_be_uniform_pointer_type =
ir_context_->get_type_mgr()->GetType(uniform_variable->type_id());
@@ -185,7 +184,7 @@ bool ConstantUniformFacts::MaybeAddFact(
return false;
}
if (should_be_uniform_pointer_type->AsPointer()->storage_class() !=
- spv::StorageClass::Uniform) {
+ SpvStorageClassUniform) {
return false;
}
auto should_be_uniform_pointer_instruction =
diff --git a/source/fuzz/fact_manager/data_synonym_and_id_equation_facts.cpp b/source/fuzz/fact_manager/data_synonym_and_id_equation_facts.cpp
index b43b8edf..a2c1f2ca 100644
--- a/source/fuzz/fact_manager/data_synonym_and_id_equation_facts.cpp
+++ b/source/fuzz/fact_manager/data_synonym_and_id_equation_facts.cpp
@@ -23,7 +23,7 @@ namespace fact_manager {
size_t DataSynonymAndIdEquationFacts::OperationHash::operator()(
const Operation& operation) const {
std::u32string hash;
- hash.push_back(uint32_t(operation.opcode));
+ hash.push_back(operation.opcode);
for (auto operand : operation.operands) {
hash.push_back(static_cast<uint32_t>(DataDescriptorHash()(operand)));
}
@@ -104,8 +104,7 @@ bool DataSynonymAndIdEquationFacts::MaybeAddFact(
}
// Now add the fact.
- AddEquationFactRecursive(lhs_dd, static_cast<spv::Op>(fact.opcode()),
- rhs_dds);
+ AddEquationFactRecursive(lhs_dd, static_cast<SpvOp>(fact.opcode()), rhs_dds);
return true;
}
@@ -120,7 +119,7 @@ DataSynonymAndIdEquationFacts::GetEquations(
}
void DataSynonymAndIdEquationFacts::AddEquationFactRecursive(
- const protobufs::DataDescriptor& lhs_dd, spv::Op opcode,
+ const protobufs::DataDescriptor& lhs_dd, SpvOp opcode,
const std::vector<const protobufs::DataDescriptor*>& rhs_dds) {
assert(synonymous_.Exists(lhs_dd) &&
"The LHS must be known to the equivalence relation.");
@@ -156,21 +155,21 @@ void DataSynonymAndIdEquationFacts::AddEquationFactRecursive(
// Now try to work out corollaries implied by the new equation and existing
// facts.
switch (opcode) {
- case spv::Op::OpConvertSToF:
- case spv::Op::OpConvertUToF:
+ case SpvOpConvertSToF:
+ case SpvOpConvertUToF:
ComputeConversionDataSynonymFacts(*rhs_dds[0]);
break;
- case spv::Op::OpBitcast: {
+ case SpvOpBitcast: {
assert(DataDescriptorsAreWellFormedAndComparable(lhs_dd, *rhs_dds[0]) &&
"Operands of OpBitcast equation fact must have compatible types");
if (!synonymous_.IsEquivalent(lhs_dd, *rhs_dds[0])) {
AddDataSynonymFactRecursive(lhs_dd, *rhs_dds[0]);
}
} break;
- case spv::Op::OpIAdd: {
+ case SpvOpIAdd: {
// Equation form: "a = b + c"
for (const auto& equation : GetEquations(rhs_dds[0])) {
- if (equation.opcode == spv::Op::OpISub) {
+ if (equation.opcode == SpvOpISub) {
// Equation form: "a = (d - e) + c"
if (synonymous_.IsEquivalent(*equation.operands[1], *rhs_dds[1])) {
// Equation form: "a = (d - c) + c"
@@ -180,7 +179,7 @@ void DataSynonymAndIdEquationFacts::AddEquationFactRecursive(
}
}
for (const auto& equation : GetEquations(rhs_dds[1])) {
- if (equation.opcode == spv::Op::OpISub) {
+ if (equation.opcode == SpvOpISub) {
// Equation form: "a = b + (d - e)"
if (synonymous_.IsEquivalent(*equation.operands[1], *rhs_dds[0])) {
// Equation form: "a = b + (d - b)"
@@ -191,10 +190,10 @@ void DataSynonymAndIdEquationFacts::AddEquationFactRecursive(
}
break;
}
- case spv::Op::OpISub: {
+ case SpvOpISub: {
// Equation form: "a = b - c"
for (const auto& equation : GetEquations(rhs_dds[0])) {
- if (equation.opcode == spv::Op::OpIAdd) {
+ if (equation.opcode == SpvOpIAdd) {
// Equation form: "a = (d + e) - c"
if (synonymous_.IsEquivalent(*equation.operands[0], *rhs_dds[1])) {
// Equation form: "a = (c + e) - c"
@@ -208,34 +207,34 @@ void DataSynonymAndIdEquationFacts::AddEquationFactRecursive(
}
}
- if (equation.opcode == spv::Op::OpISub) {
+ if (equation.opcode == SpvOpISub) {
// Equation form: "a = (d - e) - c"
if (synonymous_.IsEquivalent(*equation.operands[0], *rhs_dds[1])) {
// Equation form: "a = (c - e) - c"
// We can thus infer "a = -e"
- AddEquationFactRecursive(lhs_dd, spv::Op::OpSNegate,
+ AddEquationFactRecursive(lhs_dd, SpvOpSNegate,
{equation.operands[1]});
}
}
}
for (const auto& equation : GetEquations(rhs_dds[1])) {
- if (equation.opcode == spv::Op::OpIAdd) {
+ if (equation.opcode == SpvOpIAdd) {
// Equation form: "a = b - (d + e)"
if (synonymous_.IsEquivalent(*equation.operands[0], *rhs_dds[0])) {
// Equation form: "a = b - (b + e)"
// We can thus infer "a = -e"
- AddEquationFactRecursive(lhs_dd, spv::Op::OpSNegate,
+ AddEquationFactRecursive(lhs_dd, SpvOpSNegate,
{equation.operands[1]});
}
if (synonymous_.IsEquivalent(*equation.operands[1], *rhs_dds[0])) {
// Equation form: "a = b - (d + b)"
// We can thus infer "a = -d"
- AddEquationFactRecursive(lhs_dd, spv::Op::OpSNegate,
+ AddEquationFactRecursive(lhs_dd, SpvOpSNegate,
{equation.operands[0]});
}
}
- if (equation.opcode == spv::Op::OpISub) {
+ if (equation.opcode == SpvOpISub) {
// Equation form: "a = b - (d - e)"
if (synonymous_.IsEquivalent(*equation.operands[0], *rhs_dds[0])) {
// Equation form: "a = b - (b - e)"
@@ -246,8 +245,8 @@ void DataSynonymAndIdEquationFacts::AddEquationFactRecursive(
}
break;
}
- case spv::Op::OpLogicalNot:
- case spv::Op::OpSNegate: {
+ case SpvOpLogicalNot:
+ case SpvOpSNegate: {
// Equation form: "a = !b" or "a = -b"
for (const auto& equation : GetEquations(rhs_dds[0])) {
if (equation.opcode == opcode) {
@@ -322,9 +321,9 @@ void DataSynonymAndIdEquationFacts::ComputeConversionDataSynonymFacts(
for (const auto& equation : fact.second) {
if (synonymous_.IsEquivalent(*equation.operands[0], dd)) {
- if (equation.opcode == spv::Op::OpConvertSToF) {
+ if (equation.opcode == SpvOpConvertSToF) {
convert_s_to_f_lhs.push_back(*dd_it);
- } else if (equation.opcode == spv::Op::OpConvertUToF) {
+ } else if (equation.opcode == SpvOpConvertUToF) {
convert_u_to_f_lhs.push_back(*dd_it);
}
}
@@ -809,9 +808,9 @@ bool DataSynonymAndIdEquationFacts::DataDescriptorsAreWellFormedAndComparable(
}
// Neither end type is allowed to be void.
if (ir_context_->get_def_use_mgr()->GetDef(end_type_id_1)->opcode() ==
- spv::Op::OpTypeVoid ||
+ SpvOpTypeVoid ||
ir_context_->get_def_use_mgr()->GetDef(end_type_id_2)->opcode() ==
- spv::Op::OpTypeVoid) {
+ SpvOpTypeVoid) {
return false;
}
// If the end types are the same, the data descriptors are comparable.
diff --git a/source/fuzz/fact_manager/data_synonym_and_id_equation_facts.h b/source/fuzz/fact_manager/data_synonym_and_id_equation_facts.h
index 36d92ca7..6652f30a 100644
--- a/source/fuzz/fact_manager/data_synonym_and_id_equation_facts.h
+++ b/source/fuzz/fact_manager/data_synonym_and_id_equation_facts.h
@@ -79,7 +79,7 @@ class DataSynonymAndIdEquationFacts {
// This helper struct represents the right hand side of an equation as an
// operator applied to a number of data descriptor operands.
struct Operation {
- spv::Op opcode;
+ SpvOp opcode;
std::vector<const protobufs::DataDescriptor*> operands;
};
@@ -144,7 +144,7 @@ class DataSynonymAndIdEquationFacts {
// corollaries, in the form of data synonym or equation facts, that follow
// from this and other known facts.
void AddEquationFactRecursive(
- const protobufs::DataDescriptor& lhs_dd, spv::Op opcode,
+ const protobufs::DataDescriptor& lhs_dd, SpvOp opcode,
const std::vector<const protobufs::DataDescriptor*>& rhs_dds);
// Returns true if and only if |dd.object()| still exists in the module.
diff --git a/source/fuzz/fact_manager/fact_manager.cpp b/source/fuzz/fact_manager/fact_manager.cpp
index c99f690d..40c0865f 100644
--- a/source/fuzz/fact_manager/fact_manager.cpp
+++ b/source/fuzz/fact_manager/fact_manager.cpp
@@ -64,7 +64,7 @@ std::string ToString(const protobufs::FactDataSynonym& fact) {
std::string ToString(const protobufs::FactIdEquation& fact) {
std::stringstream stream;
stream << fact.lhs_id();
- stream << " " << fact.opcode();
+ stream << " " << static_cast<SpvOp>(fact.opcode());
for (auto rhs_id : fact.rhs_id()) {
stream << " " << rhs_id;
}
@@ -255,11 +255,11 @@ void FactManager::AddFactIdIsIrrelevant(uint32_t result_id) {
assert(success && "|result_id| is invalid");
}
-void FactManager::AddFactIdEquation(uint32_t lhs_id, spv::Op opcode,
+void FactManager::AddFactIdEquation(uint32_t lhs_id, SpvOp opcode,
const std::vector<uint32_t>& rhs_id) {
protobufs::FactIdEquation fact;
fact.set_lhs_id(lhs_id);
- fact.set_opcode(uint32_t(opcode));
+ fact.set_opcode(opcode);
for (auto an_rhs_id : rhs_id) {
fact.add_rhs_id(an_rhs_id);
}
diff --git a/source/fuzz/fact_manager/fact_manager.h b/source/fuzz/fact_manager/fact_manager.h
index 4453e445..ce28ae4c 100644
--- a/source/fuzz/fact_manager/fact_manager.h
+++ b/source/fuzz/fact_manager/fact_manager.h
@@ -83,7 +83,7 @@ class FactManager {
// |lhs_id| = |opcode| |rhs_id[0]| ... |rhs_id[N-1]|
//
// Neither |lhs_id| nor any of |rhs_id| may be irrelevant.
- void AddFactIdEquation(uint32_t lhs_id, spv::Op opcode,
+ void AddFactIdEquation(uint32_t lhs_id, SpvOp opcode,
const std::vector<uint32_t>& rhs_id);
// Inspects all known facts and adds corollary facts; e.g. if we know that
diff --git a/source/fuzz/force_render_red.cpp b/source/fuzz/force_render_red.cpp
index 191fd716..3267487a 100644
--- a/source/fuzz/force_render_red.cpp
+++ b/source/fuzz/force_render_red.cpp
@@ -36,9 +36,8 @@ opt::Function* FindFragmentShaderEntryPoint(opt::IRContext* ir_context,
// Check that this is a fragment shader
bool found_capability_shader = false;
for (auto& capability : ir_context->capabilities()) {
- assert(capability.opcode() == spv::Op::OpCapability);
- if (spv::Capability(capability.GetSingleWordInOperand(0)) ==
- spv::Capability::Shader) {
+ assert(capability.opcode() == SpvOpCapability);
+ if (capability.GetSingleWordInOperand(0) == SpvCapabilityShader) {
found_capability_shader = true;
break;
}
@@ -52,8 +51,7 @@ opt::Function* FindFragmentShaderEntryPoint(opt::IRContext* ir_context,
opt::Instruction* fragment_entry_point = nullptr;
for (auto& entry_point : ir_context->module()->entry_points()) {
- if (spv::ExecutionModel(entry_point.GetSingleWordInOperand(0)) ==
- spv::ExecutionModel::Fragment) {
+ if (entry_point.GetSingleWordInOperand(0) == SpvExecutionModelFragment) {
fragment_entry_point = &entry_point;
break;
}
@@ -83,9 +81,8 @@ opt::Instruction* FindVec4OutputVariable(opt::IRContext* ir_context,
MessageConsumer message_consumer) {
opt::Instruction* output_variable = nullptr;
for (auto& inst : ir_context->types_values()) {
- if (inst.opcode() == spv::Op::OpVariable &&
- spv::StorageClass(inst.GetSingleWordInOperand(0)) ==
- spv::StorageClass::Output) {
+ if (inst.opcode() == SpvOpVariable &&
+ inst.GetSingleWordInOperand(0) == SpvStorageClassOutput) {
if (output_variable != nullptr) {
message_consumer(SPV_MSG_ERROR, nullptr, {},
"Only one output variable can be handled at present; "
@@ -147,11 +144,10 @@ MakeConstantUniformReplacement(opt::IRContext* ir_context,
uint32_t greater_than_instruction,
uint32_t in_operand_index) {
return MakeUnique<TransformationReplaceConstantWithUniform>(
- MakeIdUseDescriptor(
- constant_id,
- MakeInstructionDescriptor(greater_than_instruction,
- spv::Op::OpFOrdGreaterThan, 0),
- in_operand_index),
+ MakeIdUseDescriptor(constant_id,
+ MakeInstructionDescriptor(greater_than_instruction,
+ SpvOpFOrdGreaterThan, 0),
+ in_operand_index),
fact_manager.GetUniformDescriptorsForConstant(constant_id)[0],
ir_context->TakeNextId(), ir_context->TakeNextId());
}
@@ -208,21 +204,20 @@ bool ForceRenderRed(
// Make the new exit block
auto new_exit_block_id = ir_context->TakeNextId();
{
- auto label = MakeUnique<opt::Instruction>(
- ir_context.get(), spv::Op::OpLabel, 0, new_exit_block_id,
- opt::Instruction::OperandList());
+ auto label = MakeUnique<opt::Instruction>(ir_context.get(), SpvOpLabel, 0,
+ new_exit_block_id,
+ opt::Instruction::OperandList());
auto new_exit_block = MakeUnique<opt::BasicBlock>(std::move(label));
- new_exit_block->AddInstruction(
- MakeUnique<opt::Instruction>(ir_context.get(), spv::Op::OpReturn, 0, 0,
- opt::Instruction::OperandList()));
+ new_exit_block->AddInstruction(MakeUnique<opt::Instruction>(
+ ir_context.get(), SpvOpReturn, 0, 0, opt::Instruction::OperandList()));
entry_point_function->AddBasicBlock(std::move(new_exit_block));
}
// Make the new entry block
{
- auto label = MakeUnique<opt::Instruction>(
- ir_context.get(), spv::Op::OpLabel, 0, ir_context->TakeNextId(),
- opt::Instruction::OperandList());
+ auto label = MakeUnique<opt::Instruction>(ir_context.get(), SpvOpLabel, 0,
+ ir_context->TakeNextId(),
+ opt::Instruction::OperandList());
auto new_entry_block = MakeUnique<opt::BasicBlock>(std::move(label));
// Make an instruction to construct vec4(1.0, 0.0, 0.0, 1.0), representing
@@ -234,7 +229,7 @@ bool ForceRenderRed(
auto temp_vec4 = opt::analysis::Vector(float_type, 4);
auto vec4_id = ir_context->get_type_mgr()->GetId(&temp_vec4);
auto red = MakeUnique<opt::Instruction>(
- ir_context.get(), spv::Op::OpCompositeConstruct, vec4_id,
+ ir_context.get(), SpvOpCompositeConstruct, vec4_id,
ir_context->TakeNextId(), op_composite_construct_operands);
auto red_id = red->result_id();
new_entry_block->AddInstruction(std::move(red));
@@ -246,7 +241,7 @@ bool ForceRenderRed(
opt::Instruction::OperandList op_store_operands = {variable_to_store_into,
value_to_be_stored};
new_entry_block->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context.get(), spv::Op::OpStore, 0, 0, op_store_operands));
+ ir_context.get(), SpvOpStore, 0, 0, op_store_operands));
// We are going to attempt to construct 'false' as an expression of the form
// 'literal1 > literal2'. If we succeed, we will later replace each literal
@@ -318,7 +313,7 @@ bool ForceRenderRed(
{SPV_OPERAND_TYPE_ID, {smaller_constant}},
{SPV_OPERAND_TYPE_ID, {larger_constant}}};
new_entry_block->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context.get(), spv::Op::OpFOrdGreaterThan,
+ ir_context.get(), SpvOpFOrdGreaterThan,
ir_context->get_type_mgr()->GetId(registered_bool_type),
id_guaranteed_to_be_false, greater_than_operands));
@@ -349,9 +344,9 @@ bool ForceRenderRed(
opt::Operand else_block = {SPV_OPERAND_TYPE_ID, {new_exit_block_id}};
opt::Instruction::OperandList op_branch_conditional_operands = {
false_condition, then_block, else_block};
- new_entry_block->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context.get(), spv::Op::OpBranchConditional, 0, 0,
- op_branch_conditional_operands));
+ new_entry_block->AddInstruction(
+ MakeUnique<opt::Instruction>(ir_context.get(), SpvOpBranchConditional,
+ 0, 0, op_branch_conditional_operands));
entry_point_function->InsertBasicBlockBefore(
std::move(new_entry_block), entry_point_function->entry().get());
diff --git a/source/fuzz/fuzzer_pass.cpp b/source/fuzz/fuzzer_pass.cpp
index 02d8aa1b..6a879851 100644
--- a/source/fuzz/fuzzer_pass.cpp
+++ b/source/fuzz/fuzzer_pass.cpp
@@ -131,15 +131,14 @@ void FuzzerPass::ForEachInstructionWithInstructionDescriptor(
// should skip when searching from 'base' for the desired instruction.
// (An instruction that has a result id is represented by its own opcode,
// itself as 'base', and a skip-count of 0.)
- std::vector<std::tuple<uint32_t, spv::Op, uint32_t>>
- base_opcode_skip_triples;
+ std::vector<std::tuple<uint32_t, SpvOp, uint32_t>> base_opcode_skip_triples;
// The initial base instruction is the block label.
uint32_t base = block->id();
// Counts the number of times we have seen each opcode since we reset the
// base instruction.
- std::map<spv::Op, uint32_t> skip_count;
+ std::map<SpvOp, uint32_t> skip_count;
// Consider every instruction in the block. The label is excluded: it is
// only necessary to consider it as a base in case the first instruction
@@ -152,7 +151,7 @@ void FuzzerPass::ForEachInstructionWithInstructionDescriptor(
base = inst_it->result_id();
skip_count.clear();
}
- const spv::Op opcode = inst_it->opcode();
+ const SpvOp opcode = inst_it->opcode();
// Invoke the provided function, which might apply a transformation.
action(block, inst_it,
@@ -331,7 +330,7 @@ uint32_t FuzzerPass::FindOrCreateStructType(
}
uint32_t FuzzerPass::FindOrCreatePointerType(uint32_t base_type_id,
- spv::StorageClass storage_class) {
+ SpvStorageClass storage_class) {
// We do not use the type manager here, due to problems related to isomorphic
// but distinct structs not being regarded as different.
auto existing_id = fuzzerutil::MaybeGetPointerType(
@@ -346,7 +345,7 @@ uint32_t FuzzerPass::FindOrCreatePointerType(uint32_t base_type_id,
}
uint32_t FuzzerPass::FindOrCreatePointerToIntegerType(
- uint32_t width, bool is_signed, spv::StorageClass storage_class) {
+ uint32_t width, bool is_signed, SpvStorageClass storage_class) {
return FindOrCreatePointerType(FindOrCreateIntegerType(width, is_signed),
storage_class);
}
@@ -433,7 +432,7 @@ uint32_t FuzzerPass::FindOrCreateCompositeConstant(
uint32_t FuzzerPass::FindOrCreateGlobalUndef(uint32_t type_id) {
for (auto& inst : GetIRContext()->types_values()) {
- if (inst.opcode() == spv::Op::OpUndef && inst.type_id() == type_id) {
+ if (inst.opcode() == SpvOpUndef && inst.type_id() == type_id) {
return inst.result_id();
}
}
@@ -465,7 +464,7 @@ uint32_t FuzzerPass::FindOrCreateNullConstant(uint32_t type_id) {
std::pair<std::vector<uint32_t>, std::map<uint32_t, std::vector<uint32_t>>>
FuzzerPass::GetAvailableBasicTypesAndPointers(
- spv::StorageClass storage_class) const {
+ SpvStorageClass storage_class) const {
// Records all of the basic types available in the module.
std::set<uint32_t> basic_types;
@@ -481,23 +480,23 @@ FuzzerPass::GetAvailableBasicTypesAndPointers(
// For pointer types with basic pointee types, associate the pointer type
// with the basic type.
switch (inst.opcode()) {
- case spv::Op::OpTypeBool:
- case spv::Op::OpTypeFloat:
- case spv::Op::OpTypeInt:
- case spv::Op::OpTypeMatrix:
- case spv::Op::OpTypeVector:
+ case SpvOpTypeBool:
+ case SpvOpTypeFloat:
+ case SpvOpTypeInt:
+ case SpvOpTypeMatrix:
+ case SpvOpTypeVector:
// These are all basic types.
basic_types.insert(inst.result_id());
basic_type_to_pointers.insert({inst.result_id(), {}});
break;
- case spv::Op::OpTypeArray:
+ case SpvOpTypeArray:
// An array type is basic if its base type is basic.
if (basic_types.count(inst.GetSingleWordInOperand(0))) {
basic_types.insert(inst.result_id());
basic_type_to_pointers.insert({inst.result_id(), {}});
}
break;
- case spv::Op::OpTypeStruct: {
+ case SpvOpTypeStruct: {
// A struct type is basic if it does not have the Block/BufferBlock
// decoration, and if all of its members are basic.
if (!fuzzerutil::HasBlockOrBufferBlockDecoration(GetIRContext(),
@@ -516,12 +515,11 @@ FuzzerPass::GetAvailableBasicTypesAndPointers(
}
break;
}
- case spv::Op::OpTypePointer: {
+ case SpvOpTypePointer: {
// We are interested in the pointer if its pointee type is basic and it
// has the right storage class.
auto pointee_type = inst.GetSingleWordInOperand(1);
- if (spv::StorageClass(inst.GetSingleWordInOperand(0)) ==
- storage_class &&
+ if (inst.GetSingleWordInOperand(0) == storage_class &&
basic_types.count(pointee_type)) {
// The pointer has the desired storage class, and its pointee type is
// a basic type, so we are interested in it. Associate it with its
@@ -543,22 +541,22 @@ uint32_t FuzzerPass::FindOrCreateZeroConstant(
GetIRContext()->get_def_use_mgr()->GetDef(scalar_or_composite_type_id);
assert(type_instruction && "The type instruction must exist.");
switch (type_instruction->opcode()) {
- case spv::Op::OpTypeBool:
+ case SpvOpTypeBool:
return FindOrCreateBoolConstant(false, is_irrelevant);
- case spv::Op::OpTypeFloat: {
+ case SpvOpTypeFloat: {
auto width = type_instruction->GetSingleWordInOperand(0);
auto num_words = (width + 32 - 1) / 32;
return FindOrCreateFloatConstant(std::vector<uint32_t>(num_words, 0),
width, is_irrelevant);
}
- case spv::Op::OpTypeInt: {
+ case SpvOpTypeInt: {
auto width = type_instruction->GetSingleWordInOperand(0);
auto num_words = (width + 32 - 1) / 32;
return FindOrCreateIntegerConstant(
std::vector<uint32_t>(num_words, 0), width,
type_instruction->GetSingleWordInOperand(1), is_irrelevant);
}
- case spv::Op::OpTypeArray: {
+ case SpvOpTypeArray: {
auto component_type_id = type_instruction->GetSingleWordInOperand(0);
auto num_components =
fuzzerutil::GetArraySize(*type_instruction, GetIRContext());
@@ -568,8 +566,8 @@ uint32_t FuzzerPass::FindOrCreateZeroConstant(
FindOrCreateZeroConstant(component_type_id, is_irrelevant)),
scalar_or_composite_type_id, is_irrelevant);
}
- case spv::Op::OpTypeMatrix:
- case spv::Op::OpTypeVector: {
+ case SpvOpTypeMatrix:
+ case SpvOpTypeVector: {
auto component_type_id = type_instruction->GetSingleWordInOperand(0);
auto num_components = type_instruction->GetSingleWordInOperand(1);
return FindOrCreateCompositeConstant(
@@ -578,7 +576,7 @@ uint32_t FuzzerPass::FindOrCreateZeroConstant(
FindOrCreateZeroConstant(component_type_id, is_irrelevant)),
scalar_or_composite_type_id, is_irrelevant);
}
- case spv::Op::OpTypeStruct: {
+ case SpvOpTypeStruct: {
assert(!fuzzerutil::HasBlockOrBufferBlockDecoration(
GetIRContext(), scalar_or_composite_type_id) &&
"We do not construct constants of struct types decorated with "
@@ -648,7 +646,7 @@ opt::BasicBlock* FuzzerPass::GetOrCreateSimpleLoopPreheader(
// |maybe_preheader| is a preheader if it branches unconditionally to
// the header. We also require it not to be a loop header.
- if (maybe_preheader->terminator()->opcode() == spv::Op::OpBranch &&
+ if (maybe_preheader->terminator()->opcode() == SpvOpBranch &&
!maybe_preheader->IsLoopHeader()) {
return maybe_preheader;
}
@@ -685,8 +683,8 @@ opt::BasicBlock* FuzzerPass::SplitBlockAfterOpPhiOrOpVariable(
// Find the first non-OpPhi and non-OpVariable instruction.
auto non_phi_or_var_inst = &*block->begin();
- while (non_phi_or_var_inst->opcode() == spv::Op::OpPhi ||
- non_phi_or_var_inst->opcode() == spv::Op::OpVariable) {
+ while (non_phi_or_var_inst->opcode() == SpvOpPhi ||
+ non_phi_or_var_inst->opcode() == SpvOpVariable) {
non_phi_or_var_inst = non_phi_or_var_inst->NextNode();
}
@@ -708,7 +706,7 @@ uint32_t FuzzerPass::FindOrCreateLocalVariable(
(void)pointer_type;
assert(pointer_type && pointer_type->AsPointer() &&
pointer_type->AsPointer()->storage_class() ==
- spv::StorageClass::Function &&
+ SpvStorageClassFunction &&
"The pointer_type_id must refer to a defined pointer type with "
"storage class Function");
auto function = fuzzerutil::FindFunction(GetIRContext(), function_id);
@@ -717,7 +715,7 @@ uint32_t FuzzerPass::FindOrCreateLocalVariable(
// First we try to find a suitable existing variable.
// All of the local variable declarations are located in the first block.
for (auto& instruction : *function->begin()) {
- if (instruction.opcode() != spv::Op::OpVariable) {
+ if (instruction.opcode() != SpvOpVariable) {
continue;
}
// The existing OpVariable must have type |pointer_type_id|.
@@ -751,16 +749,15 @@ uint32_t FuzzerPass::FindOrCreateGlobalVariable(
(void)pointer_type;
assert(
pointer_type && pointer_type->AsPointer() &&
- (pointer_type->AsPointer()->storage_class() ==
- spv::StorageClass::Private ||
+ (pointer_type->AsPointer()->storage_class() == SpvStorageClassPrivate ||
pointer_type->AsPointer()->storage_class() ==
- spv::StorageClass::Workgroup) &&
+ SpvStorageClassWorkgroup) &&
"The pointer_type_id must refer to a defined pointer type with storage "
"class Private or Workgroup");
// First we try to find a suitable existing variable.
for (auto& instruction : GetIRContext()->module()->types_values()) {
- if (instruction.opcode() != spv::Op::OpVariable) {
+ if (instruction.opcode() != SpvOpVariable) {
continue;
}
// The existing OpVariable must have type |pointer_type_id|.
@@ -784,13 +781,13 @@ uint32_t FuzzerPass::FindOrCreateGlobalVariable(
uint32_t result_id = GetFuzzerContext()->GetFreshId();
// A variable with storage class Workgroup shouldn't have an initializer.
- if (storage_class == spv::StorageClass::Workgroup) {
+ if (storage_class == SpvStorageClassWorkgroup) {
ApplyTransformation(TransformationAddGlobalVariable(
- result_id, pointer_type_id, spv::StorageClass::Workgroup, 0,
+ result_id, pointer_type_id, SpvStorageClassWorkgroup, 0,
pointee_value_is_irrelevant));
} else {
ApplyTransformation(TransformationAddGlobalVariable(
- result_id, pointer_type_id, spv::StorageClass::Private,
+ result_id, pointer_type_id, SpvStorageClassPrivate,
FindOrCreateZeroConstant(pointee_type_id, pointee_value_is_irrelevant),
pointee_value_is_irrelevant));
}
diff --git a/source/fuzz/fuzzer_pass.h b/source/fuzz/fuzzer_pass.h
index 5c76be1b..2655b540 100644
--- a/source/fuzz/fuzzer_pass.h
+++ b/source/fuzz/fuzzer_pass.h
@@ -159,14 +159,14 @@ class FuzzerPass {
// already exist) and storage class |storage_class|. A transformation is
// applied to add the pointer if it does not already exist.
uint32_t FindOrCreatePointerType(uint32_t base_type_id,
- spv::StorageClass storage_class);
+ SpvStorageClass storage_class);
// Returns the id of an OpTypePointer instruction, with a integer base
// type of width and signedness specified by |width| and |is_signed|,
// respectively. If the pointer type or required integer base type do not
// exist, transformations are applied to add them.
uint32_t FindOrCreatePointerToIntegerType(uint32_t width, bool is_signed,
- spv::StorageClass storage_class);
+ SpvStorageClass storage_class);
// Returns the id of an OpConstant instruction, with a integer type of
// width and signedness specified by |width| and |is_signed|, respectively,
@@ -239,7 +239,7 @@ class FuzzerPass {
// storage class, and the sequence will have multiple elements if there are
// repeated pointer declarations for the same basic type and storage class.
std::pair<std::vector<uint32_t>, std::map<uint32_t, std::vector<uint32_t>>>
- GetAvailableBasicTypesAndPointers(spv::StorageClass storage_class) const;
+ GetAvailableBasicTypesAndPointers(SpvStorageClass storage_class) const;
// Given a type id, |scalar_or_composite_type_id|, which must correspond to
// some scalar or composite type, returns the result id of an instruction
diff --git a/source/fuzz/fuzzer_pass_add_access_chains.cpp b/source/fuzz/fuzzer_pass_add_access_chains.cpp
index 85ca57dc..39f193d9 100644
--- a/source/fuzz/fuzzer_pass_add_access_chains.cpp
+++ b/source/fuzz/fuzzer_pass_add_access_chains.cpp
@@ -34,16 +34,15 @@ void FuzzerPassAddAccessChains::Apply() {
opt::BasicBlock::iterator inst_it,
const protobufs::InstructionDescriptor& instruction_descriptor)
-> void {
- assert(
- inst_it->opcode() ==
- spv::Op(instruction_descriptor.target_instruction_opcode()) &&
- "The opcode of the instruction we might insert before must be "
- "the same as the opcode in the descriptor for the instruction");
+ assert(inst_it->opcode() ==
+ instruction_descriptor.target_instruction_opcode() &&
+ "The opcode of the instruction we might insert before must be "
+ "the same as the opcode in the descriptor for the instruction");
// Check whether it is legitimate to insert an access chain
// instruction before this instruction.
- if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(
- spv::Op::OpAccessChain, inst_it)) {
+ if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(SpvOpAccessChain,
+ inst_it)) {
return;
}
@@ -65,8 +64,8 @@ void FuzzerPassAddAccessChains::Apply() {
return false;
}
switch (instruction->opcode()) {
- case spv::Op::OpConstantNull:
- case spv::Op::OpUndef:
+ case SpvOpConstantNull:
+ case SpvOpUndef:
// Do not allow making an access chain from a null or
// undefined pointer. (We can eliminate these cases
// before actually checking that the instruction is a
@@ -79,7 +78,7 @@ void FuzzerPassAddAccessChains::Apply() {
// make an access chain from it.
return context->get_def_use_mgr()
->GetDef(instruction->type_id())
- ->opcode() == spv::Op::OpTypePointer;
+ ->opcode() == SpvOpTypePointer;
});
// At this point, |relevant_instructions| contains all the pointers
@@ -113,14 +112,14 @@ void FuzzerPassAddAccessChains::Apply() {
}
uint32_t bound;
switch (subobject_type->opcode()) {
- case spv::Op::OpTypeArray:
+ case SpvOpTypeArray:
bound = fuzzerutil::GetArraySize(*subobject_type, GetIRContext());
break;
- case spv::Op::OpTypeMatrix:
- case spv::Op::OpTypeVector:
+ case SpvOpTypeMatrix:
+ case SpvOpTypeVector:
bound = subobject_type->GetSingleWordInOperand(1);
break;
- case spv::Op::OpTypeStruct:
+ case SpvOpTypeStruct:
bound = fuzzerutil::GetNumberOfStructMembers(*subobject_type);
break;
default:
@@ -141,9 +140,9 @@ void FuzzerPassAddAccessChains::Apply() {
GetFuzzerContext()->GetRandomIndexForAccessChain(bound);
switch (subobject_type->opcode()) {
- case spv::Op::OpTypeArray:
- case spv::Op::OpTypeMatrix:
- case spv::Op::OpTypeVector: {
+ case SpvOpTypeArray:
+ case SpvOpTypeMatrix:
+ case SpvOpTypeVector: {
// The index will be clamped
bool is_signed = GetFuzzerContext()->ChooseEven();
@@ -165,7 +164,7 @@ void FuzzerPassAddAccessChains::Apply() {
subobject_type_id = subobject_type->GetSingleWordInOperand(0);
} break;
- case spv::Op::OpTypeStruct:
+ case SpvOpTypeStruct:
index_ids.push_back(FindOrCreateIntegerConstant(
{index_value}, 32, GetFuzzerContext()->ChooseEven(), false));
subobject_type_id =
@@ -179,7 +178,7 @@ void FuzzerPassAddAccessChains::Apply() {
// pointer suitable for the access chain's result type exists, so we
// create one if it does not.
FindOrCreatePointerType(subobject_type_id,
- static_cast<spv::StorageClass>(
+ static_cast<SpvStorageClass>(
pointer_type->GetSingleWordInOperand(0)));
// Apply the transformation to add an access chain.
ApplyTransformation(TransformationAccessChain(
diff --git a/source/fuzz/fuzzer_pass_add_composite_extract.cpp b/source/fuzz/fuzzer_pass_add_composite_extract.cpp
index c33ae44c..dbbec0ca 100644
--- a/source/fuzz/fuzzer_pass_add_composite_extract.cpp
+++ b/source/fuzz/fuzzer_pass_add_composite_extract.cpp
@@ -53,8 +53,8 @@ void FuzzerPassAddCompositeExtract::Apply() {
opt::Function* /*unused*/, opt::BasicBlock* /*unused*/,
opt::BasicBlock::iterator inst_it,
const protobufs::InstructionDescriptor& instruction_descriptor) {
- if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(
- spv::Op::OpCompositeExtract, inst_it)) {
+ if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(SpvOpCompositeExtract,
+ inst_it)) {
return;
}
@@ -97,15 +97,15 @@ void FuzzerPassAddCompositeExtract::Apply() {
assert(type_inst && "Composite instruction has invalid type id");
switch (type_inst->opcode()) {
- case spv::Op::OpTypeArray:
+ case SpvOpTypeArray:
number_of_members =
fuzzerutil::GetArraySize(*type_inst, GetIRContext());
break;
- case spv::Op::OpTypeVector:
- case spv::Op::OpTypeMatrix:
+ case SpvOpTypeVector:
+ case SpvOpTypeMatrix:
number_of_members = type_inst->GetSingleWordInOperand(1);
break;
- case spv::Op::OpTypeStruct:
+ case SpvOpTypeStruct:
number_of_members = type_inst->NumInOperands();
break;
default:
@@ -122,12 +122,12 @@ void FuzzerPassAddCompositeExtract::Apply() {
number_of_members));
switch (type_inst->opcode()) {
- case spv::Op::OpTypeArray:
- case spv::Op::OpTypeVector:
- case spv::Op::OpTypeMatrix:
+ case SpvOpTypeArray:
+ case SpvOpTypeVector:
+ case SpvOpTypeMatrix:
type_id = type_inst->GetSingleWordInOperand(0);
break;
- case spv::Op::OpTypeStruct:
+ case SpvOpTypeStruct:
type_id = type_inst->GetSingleWordInOperand(indices.back());
break;
default:
diff --git a/source/fuzz/fuzzer_pass_add_composite_inserts.cpp b/source/fuzz/fuzzer_pass_add_composite_inserts.cpp
index 048cdfde..2ac12de4 100644
--- a/source/fuzz/fuzzer_pass_add_composite_inserts.cpp
+++ b/source/fuzz/fuzzer_pass_add_composite_inserts.cpp
@@ -36,11 +36,10 @@ void FuzzerPassAddCompositeInserts::Apply() {
opt::BasicBlock::iterator instruction_iterator,
const protobufs::InstructionDescriptor& instruction_descriptor)
-> void {
- assert(
- instruction_iterator->opcode() ==
- spv::Op(instruction_descriptor.target_instruction_opcode()) &&
- "The opcode of the instruction we might insert before must be "
- "the same as the opcode in the descriptor for the instruction");
+ assert(instruction_iterator->opcode() ==
+ instruction_descriptor.target_instruction_opcode() &&
+ "The opcode of the instruction we might insert before must be "
+ "the same as the opcode in the descriptor for the instruction");
// Randomly decide whether to try adding an OpCompositeInsert
// instruction.
@@ -52,7 +51,7 @@ void FuzzerPassAddCompositeInserts::Apply() {
// It must be possible to insert an OpCompositeInsert instruction
// before |instruction_iterator|.
if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(
- spv::Op::OpCompositeInsert, instruction_iterator)) {
+ SpvOpCompositeInsert, instruction_iterator)) {
return;
}
diff --git a/source/fuzz/fuzzer_pass_add_composite_types.cpp b/source/fuzz/fuzzer_pass_add_composite_types.cpp
index bb909913..af36ad06 100644
--- a/source/fuzz/fuzzer_pass_add_composite_types.cpp
+++ b/source/fuzz/fuzzer_pass_add_composite_types.cpp
@@ -114,15 +114,15 @@ uint32_t FuzzerPassAddCompositeTypes::ChooseScalarOrCompositeType() {
std::vector<uint32_t> candidates;
for (auto& inst : GetIRContext()->types_values()) {
switch (inst.opcode()) {
- case spv::Op::OpTypeArray:
- case spv::Op::OpTypeBool:
- case spv::Op::OpTypeFloat:
- case spv::Op::OpTypeInt:
- case spv::Op::OpTypeMatrix:
- case spv::Op::OpTypeVector:
+ case SpvOpTypeArray:
+ case SpvOpTypeBool:
+ case SpvOpTypeFloat:
+ case SpvOpTypeInt:
+ case SpvOpTypeMatrix:
+ case SpvOpTypeVector:
candidates.push_back(inst.result_id());
break;
- case spv::Op::OpTypeStruct: {
+ case SpvOpTypeStruct: {
if (!fuzzerutil::MembersHaveBuiltInDecoration(GetIRContext(),
inst.result_id()) &&
!fuzzerutil::HasBlockOrBufferBlockDecoration(GetIRContext(),
diff --git a/source/fuzz/fuzzer_pass_add_copy_memory.cpp b/source/fuzz/fuzzer_pass_add_copy_memory.cpp
index d54d4ad8..6551f49f 100644
--- a/source/fuzz/fuzzer_pass_add_copy_memory.cpp
+++ b/source/fuzz/fuzzer_pass_add_copy_memory.cpp
@@ -36,7 +36,7 @@ void FuzzerPassAddCopyMemory::Apply() {
opt::BasicBlock::iterator inst_it,
const protobufs::InstructionDescriptor& instruction_descriptor) {
// Check that we can insert an OpCopyMemory before this instruction.
- if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(spv::Op::OpCopyMemory,
+ if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(SpvOpCopyMemory,
inst_it)) {
return;
}
@@ -61,8 +61,8 @@ void FuzzerPassAddCopyMemory::Apply() {
// Decide whether to create global or local variable.
auto storage_class = GetFuzzerContext()->ChooseEven()
- ? spv::StorageClass::Private
- : spv::StorageClass::Function;
+ ? SpvStorageClassPrivate
+ : SpvStorageClassFunction;
auto pointee_type_id = fuzzerutil::GetPointeeTypeIdFromPointerType(
GetIRContext(), inst->type_id());
diff --git a/source/fuzz/fuzzer_pass_add_equation_instructions.cpp b/source/fuzz/fuzzer_pass_add_equation_instructions.cpp
index e720c4ec..4bbded8e 100644
--- a/source/fuzz/fuzzer_pass_add_equation_instructions.cpp
+++ b/source/fuzz/fuzzer_pass_add_equation_instructions.cpp
@@ -29,14 +29,12 @@ bool IsBitWidthSupported(opt::IRContext* ir_context, uint32_t bit_width) {
return true;
case 64:
return ir_context->get_feature_mgr()->HasCapability(
- spv::Capability::Float64) &&
- ir_context->get_feature_mgr()->HasCapability(
- spv::Capability::Int64);
+ SpvCapabilityFloat64) &&
+ ir_context->get_feature_mgr()->HasCapability(SpvCapabilityInt64);
case 16:
return ir_context->get_feature_mgr()->HasCapability(
- spv::Capability::Float16) &&
- ir_context->get_feature_mgr()->HasCapability(
- spv::Capability::Int16);
+ SpvCapabilityFloat16) &&
+ ir_context->get_feature_mgr()->HasCapability(SpvCapabilityInt16);
default:
return false;
}
@@ -68,8 +66,7 @@ void FuzzerPassAddEquationInstructions::Apply() {
// as an example opcode for this check, to be representative of *some*
// opcode that defines an equation, even though we may choose a
// different opcode below.
- if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(spv::Op::OpIAdd,
- inst_it)) {
+ if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(SpvOpIAdd, inst_it)) {
return;
}
@@ -81,7 +78,7 @@ void FuzzerPassAddEquationInstructions::Apply() {
[this](opt::IRContext* /*unused*/,
opt::Instruction* instruction) -> bool {
return instruction->result_id() && instruction->type_id() &&
- instruction->opcode() != spv::Op::OpUndef &&
+ instruction->opcode() != SpvOpUndef &&
!GetTransformationContext()
->GetFactManager()
->IdIsIrrelevant(instruction->result_id());
@@ -89,16 +86,15 @@ void FuzzerPassAddEquationInstructions::Apply() {
// Try the opcodes for which we know how to make ids at random until
// something works.
- std::vector<spv::Op> candidate_opcodes = {
- spv::Op::OpIAdd, spv::Op::OpISub, spv::Op::OpLogicalNot,
- spv::Op::OpSNegate, spv::Op::OpConvertUToF, spv::Op::OpConvertSToF,
- spv::Op::OpBitcast};
+ std::vector<SpvOp> candidate_opcodes = {
+ SpvOpIAdd, SpvOpISub, SpvOpLogicalNot, SpvOpSNegate,
+ SpvOpConvertUToF, SpvOpConvertSToF, SpvOpBitcast};
do {
auto opcode =
GetFuzzerContext()->RemoveAtRandomIndex(&candidate_opcodes);
switch (opcode) {
- case spv::Op::OpConvertSToF:
- case spv::Op::OpConvertUToF: {
+ case SpvOpConvertSToF:
+ case SpvOpConvertUToF: {
std::vector<const opt::Instruction*> candidate_instructions;
for (const auto* inst :
GetIntegerInstructions(available_instructions)) {
@@ -148,7 +144,7 @@ void FuzzerPassAddEquationInstructions::Apply() {
{operand->result_id()}, instruction_descriptor));
return;
}
- case spv::Op::OpBitcast: {
+ case SpvOpBitcast: {
const auto candidate_instructions =
GetNumericalInstructions(available_instructions);
@@ -201,8 +197,8 @@ void FuzzerPassAddEquationInstructions::Apply() {
return;
}
} break;
- case spv::Op::OpIAdd:
- case spv::Op::OpISub: {
+ case SpvOpIAdd:
+ case SpvOpISub: {
// Instructions of integer (scalar or vector) result type are
// suitable for these opcodes.
auto integer_instructions =
@@ -255,7 +251,7 @@ void FuzzerPassAddEquationInstructions::Apply() {
}
break;
}
- case spv::Op::OpLogicalNot: {
+ case SpvOpLogicalNot: {
// Choose any available instruction of boolean scalar/vector
// result type and equate its negation with a fresh id.
auto boolean_instructions =
@@ -272,7 +268,7 @@ void FuzzerPassAddEquationInstructions::Apply() {
}
break;
}
- case spv::Op::OpSNegate: {
+ case SpvOpSNegate: {
// Similar to OpLogicalNot, but for signed integer negation.
auto integer_instructions =
GetIntegerInstructions(available_instructions);
diff --git a/source/fuzz/fuzzer_pass_add_function_calls.cpp b/source/fuzz/fuzzer_pass_add_function_calls.cpp
index 70b86573..033f4a27 100644
--- a/source/fuzz/fuzzer_pass_add_function_calls.cpp
+++ b/source/fuzz/fuzzer_pass_add_function_calls.cpp
@@ -39,8 +39,8 @@ void FuzzerPassAddFunctionCalls::Apply() {
-> void {
// Check whether it is legitimate to insert a function call before the
// instruction.
- if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(
- spv::Op::OpFunctionCall, inst_it)) {
+ if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(SpvOpFunctionCall,
+ inst_it)) {
return;
}
@@ -112,8 +112,8 @@ std::vector<uint32_t> FuzzerPassAddFunctionCalls::ChooseFunctionCallArguments(
auto available_pointers = FindAvailableInstructions(
caller_function, caller_block, caller_inst_it,
[this, caller_block](opt::IRContext* /*unused*/, opt::Instruction* inst) {
- if (inst->opcode() != spv::Op::OpVariable ||
- inst->opcode() != spv::Op::OpFunctionParameter) {
+ if (inst->opcode() != SpvOpVariable ||
+ inst->opcode() != SpvOpFunctionParameter) {
// Function parameters and variables are the only
// kinds of pointer that can be used as actual
// parameters.
@@ -172,15 +172,15 @@ std::vector<uint32_t> FuzzerPassAddFunctionCalls::ChooseFunctionCallArguments(
auto storage_class = param_type->AsPointer()->storage_class();
auto pointee_type_id = fuzzerutil::GetPointeeTypeIdFromPointerType(
GetIRContext(), param->type_id());
- if (storage_class == spv::StorageClass::Function) {
+ if (storage_class == SpvStorageClassFunction) {
// Add a new zero-initialized local variable to the current
// function, noting that its pointee value is irrelevant.
ApplyTransformation(TransformationAddLocalVariable(
fresh_variable_id, param->type_id(), caller_function->result_id(),
FindOrCreateZeroConstant(pointee_type_id, false), true));
} else {
- assert((storage_class == spv::StorageClass::Private ||
- storage_class == spv::StorageClass::Workgroup) &&
+ assert((storage_class == SpvStorageClassPrivate ||
+ storage_class == SpvStorageClassWorkgroup) &&
"Only Function, Private and Workgroup storage classes are "
"supported at present.");
// Add a new global variable to the module, zero-initializing it if
@@ -188,7 +188,7 @@ std::vector<uint32_t> FuzzerPassAddFunctionCalls::ChooseFunctionCallArguments(
// irrelevant.
ApplyTransformation(TransformationAddGlobalVariable(
fresh_variable_id, param->type_id(), storage_class,
- storage_class == spv::StorageClass::Private
+ storage_class == SpvStorageClassPrivate
? FindOrCreateZeroConstant(pointee_type_id, false)
: 0,
true));
diff --git a/source/fuzz/fuzzer_pass_add_global_variables.cpp b/source/fuzz/fuzzer_pass_add_global_variables.cpp
index 41068565..061f44d0 100644
--- a/source/fuzz/fuzzer_pass_add_global_variables.cpp
+++ b/source/fuzz/fuzzer_pass_add_global_variables.cpp
@@ -29,17 +29,16 @@ FuzzerPassAddGlobalVariables::FuzzerPassAddGlobalVariables(
transformations, ignore_inapplicable_transformations) {}
void FuzzerPassAddGlobalVariables::Apply() {
- spv::StorageClass variable_storage_class = spv::StorageClass::Private;
+ SpvStorageClass variable_storage_class = SpvStorageClassPrivate;
for (auto& entry_point : GetIRContext()->module()->entry_points()) {
// If the execution model of some entry point is GLCompute,
// then the variable storage class may be Workgroup.
- if (spv::ExecutionModel(entry_point.GetSingleWordInOperand(0)) ==
- spv::ExecutionModel::GLCompute) {
+ if (entry_point.GetSingleWordInOperand(0) == SpvExecutionModelGLCompute) {
variable_storage_class =
GetFuzzerContext()->ChoosePercentage(
GetFuzzerContext()->GetChanceOfChoosingWorkgroupStorageClass())
- ? spv::StorageClass::Workgroup
- : spv::StorageClass::Private;
+ ? SpvStorageClassWorkgroup
+ : SpvStorageClassPrivate;
break;
}
}
@@ -88,7 +87,7 @@ void FuzzerPassAddGlobalVariables::Apply() {
ApplyTransformation(TransformationAddGlobalVariable(
GetFuzzerContext()->GetFreshId(), pointer_type_id,
variable_storage_class,
- variable_storage_class == spv::StorageClass::Private
+ variable_storage_class == SpvStorageClassPrivate
? FindOrCreateZeroConstant(basic_type, false)
: 0,
true));
diff --git a/source/fuzz/fuzzer_pass_add_loads.cpp b/source/fuzz/fuzzer_pass_add_loads.cpp
index 36603284..ab91543b 100644
--- a/source/fuzz/fuzzer_pass_add_loads.cpp
+++ b/source/fuzz/fuzzer_pass_add_loads.cpp
@@ -34,11 +34,10 @@ void FuzzerPassAddLoads::Apply() {
opt::BasicBlock::iterator inst_it,
const protobufs::InstructionDescriptor& instruction_descriptor)
-> void {
- assert(
- inst_it->opcode() ==
- spv::Op(instruction_descriptor.target_instruction_opcode()) &&
- "The opcode of the instruction we might insert before must be "
- "the same as the opcode in the descriptor for the instruction");
+ assert(inst_it->opcode() ==
+ instruction_descriptor.target_instruction_opcode() &&
+ "The opcode of the instruction we might insert before must be "
+ "the same as the opcode in the descriptor for the instruction");
// Randomly decide whether to try inserting a load here.
if (!GetFuzzerContext()->ChoosePercentage(
@@ -48,11 +47,10 @@ void FuzzerPassAddLoads::Apply() {
// Check whether it is legitimate to insert a load or atomic load before
// this instruction.
- if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(spv::Op::OpLoad,
- inst_it)) {
+ if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(SpvOpLoad, inst_it)) {
return;
}
- if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(spv::Op::OpAtomicLoad,
+ if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(SpvOpAtomicLoad,
inst_it)) {
return;
}
@@ -66,8 +64,8 @@ void FuzzerPassAddLoads::Apply() {
return false;
}
switch (instruction->opcode()) {
- case spv::Op::OpConstantNull:
- case spv::Op::OpUndef:
+ case SpvOpConstantNull:
+ case SpvOpUndef:
// Do not allow loading from a null or undefined pointer;
// this might be OK if the block is dead, but for now we
// conservatively avoid it.
@@ -77,7 +75,7 @@ void FuzzerPassAddLoads::Apply() {
}
return context->get_def_use_mgr()
->GetDef(instruction->type_id())
- ->opcode() == spv::Op::OpTypePointer;
+ ->opcode() == SpvOpTypePointer;
});
// At this point, |relevant_instructions| contains all the pointers
@@ -94,25 +92,25 @@ void FuzzerPassAddLoads::Apply() {
uint32_t memory_scope_id = 0;
uint32_t memory_semantics_id = 0;
- auto storage_class = static_cast<spv::StorageClass>(
+ auto storage_class = static_cast<SpvStorageClass>(
GetIRContext()
->get_def_use_mgr()
->GetDef(chosen_instruction->type_id())
->GetSingleWordInOperand(0));
switch (storage_class) {
- case spv::StorageClass::StorageBuffer:
- case spv::StorageClass::PhysicalStorageBuffer:
- case spv::StorageClass::Workgroup:
- case spv::StorageClass::CrossWorkgroup:
- case spv::StorageClass::AtomicCounter:
- case spv::StorageClass::Image:
+ case SpvStorageClassStorageBuffer:
+ case SpvStorageClassPhysicalStorageBuffer:
+ case SpvStorageClassWorkgroup:
+ case SpvStorageClassCrossWorkgroup:
+ case SpvStorageClassAtomicCounter:
+ case SpvStorageClassImage:
if (GetFuzzerContext()->ChoosePercentage(
GetFuzzerContext()->GetChanceOfAddingAtomicLoad())) {
is_atomic_load = true;
memory_scope_id = FindOrCreateConstant(
- {uint32_t(spv::Scope::Invocation)},
+ {SpvScopeInvocation},
FindOrCreateIntegerType(32, GetFuzzerContext()->ChooseEven()),
false);
diff --git a/source/fuzz/fuzzer_pass_add_local_variables.cpp b/source/fuzz/fuzzer_pass_add_local_variables.cpp
index f467f46b..a4e739f8 100644
--- a/source/fuzz/fuzzer_pass_add_local_variables.cpp
+++ b/source/fuzz/fuzzer_pass_add_local_variables.cpp
@@ -31,7 +31,7 @@ FuzzerPassAddLocalVariables::FuzzerPassAddLocalVariables(
void FuzzerPassAddLocalVariables::Apply() {
auto basic_type_ids_and_pointers =
- GetAvailableBasicTypesAndPointers(spv::StorageClass::Function);
+ GetAvailableBasicTypesAndPointers(SpvStorageClassFunction);
// These are the basic types that are available to this fuzzer pass.
auto& basic_types = basic_type_ids_and_pointers.first;
@@ -64,7 +64,7 @@ void FuzzerPassAddLocalVariables::Apply() {
// use it.
pointer_type = GetFuzzerContext()->GetFreshId();
ApplyTransformation(TransformationAddTypePointer(
- pointer_type, spv::StorageClass::Function, basic_type));
+ pointer_type, SpvStorageClassFunction, basic_type));
available_pointers_to_basic_type.push_back(pointer_type);
} else {
// There is - grab one.
diff --git a/source/fuzz/fuzzer_pass_add_opphi_synonyms.cpp b/source/fuzz/fuzzer_pass_add_opphi_synonyms.cpp
index d0b1275b..73b6b0ac 100644
--- a/source/fuzz/fuzzer_pass_add_opphi_synonyms.cpp
+++ b/source/fuzz/fuzzer_pass_add_opphi_synonyms.cpp
@@ -176,8 +176,8 @@ FuzzerPassAddOpPhiSynonyms::GetIdEquivalenceClasses() {
// - OpFunction does not yield a value;
// - OpUndef yields an undefined value at each use, so it should never be a
// synonym of another id.
- if (pair.second->opcode() == spv::Op::OpFunction ||
- pair.second->opcode() == spv::Op::OpUndef) {
+ if (pair.second->opcode() == SpvOpFunction ||
+ pair.second->opcode() == SpvOpUndef) {
continue;
}
diff --git a/source/fuzz/fuzzer_pass_add_parameters.cpp b/source/fuzz/fuzzer_pass_add_parameters.cpp
index e663d89b..1cb6a79d 100644
--- a/source/fuzz/fuzzer_pass_add_parameters.cpp
+++ b/source/fuzz/fuzzer_pass_add_parameters.cpp
@@ -79,7 +79,7 @@ void FuzzerPassAddParameters::Apply() {
auto storage_class = fuzzerutil::GetStorageClassFromPointerType(
GetIRContext(), current_type_id);
switch (storage_class) {
- case spv::StorageClass::Function: {
+ case SpvStorageClassFunction: {
// In every caller find or create a local variable that has the
// selected type.
for (auto* instr :
@@ -91,8 +91,8 @@ void FuzzerPassAddParameters::Apply() {
call_parameter_ids[instr->result_id()] = variable_id;
}
} break;
- case spv::StorageClass::Private:
- case spv::StorageClass::Workgroup: {
+ case SpvStorageClassPrivate:
+ case SpvStorageClassWorkgroup: {
// If there exists at least one caller, find or create a global
// variable that has the selected type.
std::vector<opt::Instruction*> callers =
diff --git a/source/fuzz/fuzzer_pass_add_stores.cpp b/source/fuzz/fuzzer_pass_add_stores.cpp
index 0de02a5b..606e4a63 100644
--- a/source/fuzz/fuzzer_pass_add_stores.cpp
+++ b/source/fuzz/fuzzer_pass_add_stores.cpp
@@ -34,11 +34,10 @@ void FuzzerPassAddStores::Apply() {
opt::BasicBlock::iterator inst_it,
const protobufs::InstructionDescriptor& instruction_descriptor)
-> void {
- assert(
- inst_it->opcode() ==
- spv::Op(instruction_descriptor.target_instruction_opcode()) &&
- "The opcode of the instruction we might insert before must be "
- "the same as the opcode in the descriptor for the instruction");
+ assert(inst_it->opcode() ==
+ instruction_descriptor.target_instruction_opcode() &&
+ "The opcode of the instruction we might insert before must be "
+ "the same as the opcode in the descriptor for the instruction");
// Randomly decide whether to try inserting a store here.
if (!GetFuzzerContext()->ChoosePercentage(
@@ -48,12 +47,12 @@ void FuzzerPassAddStores::Apply() {
// Check whether it is legitimate to insert a store before this
// instruction.
- if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(spv::Op::OpStore,
+ if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(SpvOpStore,
inst_it)) {
return;
}
- if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(
- spv::Op::OpAtomicStore, inst_it)) {
+ if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(SpvOpAtomicStore,
+ inst_it)) {
return;
}
@@ -68,7 +67,7 @@ void FuzzerPassAddStores::Apply() {
}
auto type_inst = context->get_def_use_mgr()->GetDef(
instruction->type_id());
- if (type_inst->opcode() != spv::Op::OpTypePointer) {
+ if (type_inst->opcode() != SpvOpTypePointer) {
// Not a pointer.
return false;
}
@@ -77,8 +76,8 @@ void FuzzerPassAddStores::Apply() {
return false;
}
switch (instruction->opcode()) {
- case spv::Op::OpConstantNull:
- case spv::Op::OpUndef:
+ case SpvOpConstantNull:
+ case SpvOpUndef:
// Do not allow storing to a null or undefined pointer;
// this might be OK if the block is dead, but for now we
// conservatively avoid it.
@@ -127,24 +126,24 @@ void FuzzerPassAddStores::Apply() {
uint32_t memory_semantics_id = 0;
auto storage_class =
- static_cast<spv::StorageClass>(GetIRContext()
- ->get_def_use_mgr()
- ->GetDef(pointer->type_id())
- ->GetSingleWordInOperand(0));
+ static_cast<SpvStorageClass>(GetIRContext()
+ ->get_def_use_mgr()
+ ->GetDef(pointer->type_id())
+ ->GetSingleWordInOperand(0));
switch (storage_class) {
- case spv::StorageClass::StorageBuffer:
- case spv::StorageClass::PhysicalStorageBuffer:
- case spv::StorageClass::Workgroup:
- case spv::StorageClass::CrossWorkgroup:
- case spv::StorageClass::AtomicCounter:
- case spv::StorageClass::Image:
+ case SpvStorageClassStorageBuffer:
+ case SpvStorageClassPhysicalStorageBuffer:
+ case SpvStorageClassWorkgroup:
+ case SpvStorageClassCrossWorkgroup:
+ case SpvStorageClassAtomicCounter:
+ case SpvStorageClassImage:
if (GetFuzzerContext()->ChoosePercentage(
GetFuzzerContext()->GetChanceOfAddingAtomicStore())) {
is_atomic_store = true;
memory_scope_id = FindOrCreateConstant(
- {uint32_t(spv::Scope::Invocation)},
+ {SpvScopeInvocation},
FindOrCreateIntegerType(32, GetFuzzerContext()->ChooseEven()),
false);
diff --git a/source/fuzz/fuzzer_pass_add_synonyms.cpp b/source/fuzz/fuzzer_pass_add_synonyms.cpp
index 5782732c..1d188deb 100644
--- a/source/fuzz/fuzzer_pass_add_synonyms.cpp
+++ b/source/fuzz/fuzzer_pass_add_synonyms.cpp
@@ -44,8 +44,7 @@ void FuzzerPassAddSynonyms::Apply() {
// Skip |inst_it| if we can't insert anything above it. OpIAdd is just
// a representative of some instruction that might be produced by the
// transformation.
- if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(spv::Op::OpIAdd,
- inst_it)) {
+ if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(SpvOpIAdd, inst_it)) {
return;
}
diff --git a/source/fuzz/fuzzer_pass_add_vector_shuffle_instructions.cpp b/source/fuzz/fuzzer_pass_add_vector_shuffle_instructions.cpp
index 4cddf55e..a29d1d34 100644
--- a/source/fuzz/fuzzer_pass_add_vector_shuffle_instructions.cpp
+++ b/source/fuzz/fuzzer_pass_add_vector_shuffle_instructions.cpp
@@ -35,11 +35,10 @@ void FuzzerPassAddVectorShuffleInstructions::Apply() {
opt::BasicBlock::iterator instruction_iterator,
const protobufs::InstructionDescriptor& instruction_descriptor)
-> void {
- assert(
- instruction_iterator->opcode() ==
- spv::Op(instruction_descriptor.target_instruction_opcode()) &&
- "The opcode of the instruction we might insert before must be "
- "the same as the opcode in the descriptor for the instruction");
+ assert(instruction_iterator->opcode() ==
+ instruction_descriptor.target_instruction_opcode() &&
+ "The opcode of the instruction we might insert before must be "
+ "the same as the opcode in the descriptor for the instruction");
// Randomly decide whether to try adding an OpVectorShuffle instruction.
if (!GetFuzzerContext()->ChoosePercentage(
@@ -50,7 +49,7 @@ void FuzzerPassAddVectorShuffleInstructions::Apply() {
// It must be valid to insert an OpVectorShuffle instruction
// before |instruction_iterator|.
if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(
- spv::Op::OpVectorShuffle, instruction_iterator)) {
+ SpvOpVectorShuffle, instruction_iterator)) {
return;
}
diff --git a/source/fuzz/fuzzer_pass_adjust_branch_weights.cpp b/source/fuzz/fuzzer_pass_adjust_branch_weights.cpp
index 6bf46e1b..94428f72 100644
--- a/source/fuzz/fuzzer_pass_adjust_branch_weights.cpp
+++ b/source/fuzz/fuzzer_pass_adjust_branch_weights.cpp
@@ -33,7 +33,7 @@ void FuzzerPassAdjustBranchWeights::Apply() {
// For all OpBranchConditional instructions,
// randomly applies the transformation.
GetIRContext()->module()->ForEachInst([this](opt::Instruction* instruction) {
- if (instruction->opcode() == spv::Op::OpBranchConditional &&
+ if (instruction->opcode() == SpvOpBranchConditional &&
GetFuzzerContext()->ChoosePercentage(
GetFuzzerContext()->GetChanceOfAdjustingBranchWeights())) {
ApplyTransformation(TransformationAdjustBranchWeights(
diff --git a/source/fuzz/fuzzer_pass_adjust_function_controls.cpp b/source/fuzz/fuzzer_pass_adjust_function_controls.cpp
index 363edc70..1c2bc8cf 100644
--- a/source/fuzz/fuzzer_pass_adjust_function_controls.cpp
+++ b/source/fuzz/fuzzer_pass_adjust_function_controls.cpp
@@ -40,21 +40,21 @@ void FuzzerPassAdjustFunctionControls::Apply() {
// For the new mask, we first randomly select one of three basic masks:
// None, Inline or DontInline. These are always valid (and are mutually
// exclusive).
- std::vector<spv::FunctionControlMask> basic_function_control_masks = {
- spv::FunctionControlMask::MaskNone, spv::FunctionControlMask::Inline,
- spv::FunctionControlMask::DontInline};
+ std::vector<uint32_t> basic_function_control_masks = {
+ SpvFunctionControlMaskNone, SpvFunctionControlInlineMask,
+ SpvFunctionControlDontInlineMask};
uint32_t new_function_control_mask =
- uint32_t(basic_function_control_masks[GetFuzzerContext()->RandomIndex(
- basic_function_control_masks)]);
+ basic_function_control_masks[GetFuzzerContext()->RandomIndex(
+ basic_function_control_masks)];
// We now consider the Pure and Const mask bits. If these are already
// set on the function then it's OK to keep them, but also interesting
// to consider dropping them, so we decide randomly in each case.
for (auto mask_bit :
- {spv::FunctionControlMask::Pure, spv::FunctionControlMask::Const}) {
- if ((existing_function_control_mask & uint32_t(mask_bit)) &&
+ {SpvFunctionControlPureMask, SpvFunctionControlConstMask}) {
+ if ((existing_function_control_mask & mask_bit) &&
GetFuzzerContext()->ChooseEven()) {
- new_function_control_mask |= uint32_t(mask_bit);
+ new_function_control_mask |= mask_bit;
}
}
diff --git a/source/fuzz/fuzzer_pass_adjust_loop_controls.cpp b/source/fuzz/fuzzer_pass_adjust_loop_controls.cpp
index 53dbe540..fe855cad 100644
--- a/source/fuzz/fuzzer_pass_adjust_loop_controls.cpp
+++ b/source/fuzz/fuzzer_pass_adjust_loop_controls.cpp
@@ -34,7 +34,7 @@ void FuzzerPassAdjustLoopControls::Apply() {
for (auto& block : function) {
if (auto merge_inst = block.GetMergeInst()) {
// Ignore the instruction if it is not a loop merge.
- if (merge_inst->opcode() != spv::Op::OpLoopMerge) {
+ if (merge_inst->opcode() != SpvOpLoopMerge) {
continue;
}
@@ -48,10 +48,9 @@ void FuzzerPassAdjustLoopControls::Apply() {
TransformationSetLoopControl::kLoopControlMaskInOperandIndex);
// First, set the new mask to one of None, Unroll or DontUnroll.
- std::vector<uint32_t> basic_masks = {
- uint32_t(spv::LoopControlMask::MaskNone),
- uint32_t(spv::LoopControlMask::Unroll),
- uint32_t(spv::LoopControlMask::DontUnroll)};
+ std::vector<uint32_t> basic_masks = {SpvLoopControlMaskNone,
+ SpvLoopControlUnrollMask,
+ SpvLoopControlDontUnrollMask};
uint32_t new_mask =
basic_masks[GetFuzzerContext()->RandomIndex(basic_masks)];
@@ -59,20 +58,19 @@ void FuzzerPassAdjustLoopControls::Apply() {
// does, check which of these were present in the existing mask and
// randomly decide whether to keep them. They are just hints, so
// removing them should not change the semantics of the module.
- for (auto mask_bit : {spv::LoopControlMask::DependencyInfinite,
- spv::LoopControlMask::DependencyLength,
- spv::LoopControlMask::MinIterations,
- spv::LoopControlMask::MaxIterations,
- spv::LoopControlMask::IterationMultiple}) {
- if ((existing_mask & uint32_t(mask_bit)) &&
- GetFuzzerContext()->ChooseEven()) {
+ for (auto mask_bit :
+ {SpvLoopControlDependencyInfiniteMask,
+ SpvLoopControlDependencyLengthMask,
+ SpvLoopControlMinIterationsMask, SpvLoopControlMaxIterationsMask,
+ SpvLoopControlIterationMultipleMask}) {
+ if ((existing_mask & mask_bit) && GetFuzzerContext()->ChooseEven()) {
// The mask bits we are considering are not available in all SPIR-V
// versions. However, we only include a mask bit if it was present
// in the original loop control mask, and we work under the
// assumption that we are transforming a valid module, thus we don't
// need to actually check whether the SPIR-V version being used
// supports these loop control mask bits.
- new_mask |= uint32_t(mask_bit);
+ new_mask |= mask_bit;
}
}
@@ -83,14 +81,14 @@ void FuzzerPassAdjustLoopControls::Apply() {
// PeelCount and PartialCount are not compatible with DontUnroll, so
// we check whether DontUnroll is set.
- if (!(new_mask & uint32_t(spv::LoopControlMask::DontUnroll))) {
+ if (!(new_mask & SpvLoopControlDontUnrollMask)) {
// If PeelCount is supported by this SPIR-V version, randomly choose
// whether to set it. If it was set in the original mask and is not
// selected for setting here, that amounts to dropping it.
if (TransformationSetLoopControl::PeelCountIsSupported(
GetIRContext()) &&
GetFuzzerContext()->ChooseEven()) {
- new_mask |= uint32_t(spv::LoopControlMask::PeelCount);
+ new_mask |= SpvLoopControlPeelCountMask;
// The peel count is chosen randomly - if PeelCount was already set
// this will overwrite whatever peel count was previously used.
peel_count = GetFuzzerContext()->GetRandomLoopControlPeelCount();
@@ -99,7 +97,7 @@ void FuzzerPassAdjustLoopControls::Apply() {
if (TransformationSetLoopControl::PartialCountIsSupported(
GetIRContext()) &&
GetFuzzerContext()->ChooseEven()) {
- new_mask |= uint32_t(spv::LoopControlMask::PartialCount);
+ new_mask |= SpvLoopControlPartialCountMask;
partial_count =
GetFuzzerContext()->GetRandomLoopControlPartialCount();
}
diff --git a/source/fuzz/fuzzer_pass_adjust_memory_operands_masks.cpp b/source/fuzz/fuzzer_pass_adjust_memory_operands_masks.cpp
index efae7d66..d2ff40e6 100644
--- a/source/fuzz/fuzzer_pass_adjust_memory_operands_masks.cpp
+++ b/source/fuzz/fuzzer_pass_adjust_memory_operands_masks.cpp
@@ -47,8 +47,8 @@ void FuzzerPassAdjustMemoryOperandsMasks::Apply() {
// From SPIR-V 1.4 onwards, OpCopyMemory and OpCopyMemorySized have a
// second mask.
switch (inst_it->opcode()) {
- case spv::Op::OpCopyMemory:
- case spv::Op::OpCopyMemorySized:
+ case SpvOpCopyMemory:
+ case SpvOpCopyMemorySized:
if (TransformationSetMemoryOperandsMask::
MultipleMemoryOperandMasksAreSupported(GetIRContext())) {
indices_of_available_masks_to_adjust.push_back(1);
@@ -75,26 +75,24 @@ void FuzzerPassAdjustMemoryOperandsMasks::Apply() {
existing_mask_in_operand_index < inst_it->NumInOperands()
? inst_it->GetSingleWordInOperand(
existing_mask_in_operand_index)
- : static_cast<uint32_t>(spv::MemoryAccessMask::MaskNone);
+ : static_cast<uint32_t>(SpvMemoryAccessMaskNone);
// There are two things we can do to a mask:
// - add Volatile if not already present
// - toggle Nontemporal
// The following ensures that we do at least one of these
- bool add_volatile =
- !(existing_mask & uint32_t(spv::MemoryAccessMask::Volatile)) &&
- GetFuzzerContext()->ChooseEven();
+ bool add_volatile = !(existing_mask & SpvMemoryAccessVolatileMask) &&
+ GetFuzzerContext()->ChooseEven();
bool toggle_nontemporal =
!add_volatile || GetFuzzerContext()->ChooseEven();
// These bitwise operations use '|' to add Volatile if desired, and
// '^' to toggle Nontemporal if desired.
uint32_t new_mask =
- (existing_mask |
- (add_volatile ? uint32_t(spv::MemoryAccessMask::Volatile)
- : uint32_t(spv::MemoryAccessMask::MaskNone))) ^
- (toggle_nontemporal ? uint32_t(spv::MemoryAccessMask::Nontemporal)
- : uint32_t(spv::MemoryAccessMask::MaskNone));
+ (existing_mask | (add_volatile ? SpvMemoryAccessVolatileMask
+ : SpvMemoryAccessMaskNone)) ^
+ (toggle_nontemporal ? SpvMemoryAccessNontemporalMask
+ : SpvMemoryAccessMaskNone);
TransformationSetMemoryOperandsMask transformation(
MakeInstructionDescriptor(block, inst_it), new_mask, mask_index);
diff --git a/source/fuzz/fuzzer_pass_adjust_selection_controls.cpp b/source/fuzz/fuzzer_pass_adjust_selection_controls.cpp
index fe0cf7af..7d8e6b57 100644
--- a/source/fuzz/fuzzer_pass_adjust_selection_controls.cpp
+++ b/source/fuzz/fuzzer_pass_adjust_selection_controls.cpp
@@ -34,7 +34,7 @@ void FuzzerPassAdjustSelectionControls::Apply() {
for (auto& block : function) {
if (auto merge_inst = block.GetMergeInst()) {
// Ignore the instruction if it is not a selection merge.
- if (merge_inst->opcode() != spv::Op::OpSelectionMerge) {
+ if (merge_inst->opcode() != SpvOpSelectionMerge) {
continue;
}
@@ -48,14 +48,13 @@ void FuzzerPassAdjustSelectionControls::Apply() {
// The choices to change the selection control to are the set of valid
// controls, minus the current control.
std::vector<uint32_t> choices;
- for (auto control : {spv::SelectionControlMask::MaskNone,
- spv::SelectionControlMask::Flatten,
- spv::SelectionControlMask::DontFlatten}) {
- if (control ==
- spv::SelectionControlMask(merge_inst->GetSingleWordOperand(1))) {
+ for (auto control :
+ {SpvSelectionControlMaskNone, SpvSelectionControlFlattenMask,
+ SpvSelectionControlDontFlattenMask}) {
+ if (control == merge_inst->GetSingleWordOperand(1)) {
continue;
}
- choices.push_back(uint32_t(control));
+ choices.push_back(control);
}
// Apply the transformation and add it to the output transformation
diff --git a/source/fuzz/fuzzer_pass_apply_id_synonyms.cpp b/source/fuzz/fuzzer_pass_apply_id_synonyms.cpp
index 0367a26b..5c3b86b9 100644
--- a/source/fuzz/fuzzer_pass_apply_id_synonyms.cpp
+++ b/source/fuzz/fuzzer_pass_apply_id_synonyms.cpp
@@ -107,9 +107,9 @@ void FuzzerPassApplyIdSynonyms::Apply() {
// which case we need to be able to add an extract instruction to get
// that element out.
if (synonym_to_try->index_size() > 0 &&
- !fuzzerutil::CanInsertOpcodeBeforeInstruction(
- spv::Op::OpCompositeExtract, use_inst) &&
- use_inst->opcode() != spv::Op::OpPhi) {
+ !fuzzerutil::CanInsertOpcodeBeforeInstruction(SpvOpCompositeExtract,
+ use_inst) &&
+ use_inst->opcode() != SpvOpPhi) {
// We cannot insert an extract before this instruction, so this
// synonym is no good.
continue;
@@ -132,7 +132,7 @@ void FuzzerPassApplyIdSynonyms::Apply() {
id_with_which_to_replace_use = GetFuzzerContext()->GetFreshId();
opt::Instruction* instruction_to_insert_before = nullptr;
- if (use_inst->opcode() != spv::Op::OpPhi) {
+ if (use_inst->opcode() != SpvOpPhi) {
instruction_to_insert_before = use_inst;
} else {
auto parent_block_id =
@@ -182,7 +182,7 @@ void FuzzerPassApplyIdSynonyms::Apply() {
}
bool FuzzerPassApplyIdSynonyms::DataDescriptorsHaveCompatibleTypes(
- spv::Op opcode, uint32_t use_in_operand_index,
+ SpvOp opcode, uint32_t use_in_operand_index,
const protobufs::DataDescriptor& dd1,
const protobufs::DataDescriptor& dd2) {
auto base_object_type_id_1 =
diff --git a/source/fuzz/fuzzer_pass_apply_id_synonyms.h b/source/fuzz/fuzzer_pass_apply_id_synonyms.h
index d1a0e1aa..3da9c5d6 100644
--- a/source/fuzz/fuzzer_pass_apply_id_synonyms.h
+++ b/source/fuzz/fuzzer_pass_apply_id_synonyms.h
@@ -38,7 +38,7 @@ class FuzzerPassApplyIdSynonyms : public FuzzerPass {
// with respect to the type. Concretely, returns true if |dd1| and |dd2| have
// the same type or both |dd1| and |dd2| are either a numerical or a vector
// type of integral components with possibly different signedness.
- bool DataDescriptorsHaveCompatibleTypes(spv::Op opcode,
+ bool DataDescriptorsHaveCompatibleTypes(SpvOp opcode,
uint32_t use_in_operand_index,
const protobufs::DataDescriptor& dd1,
const protobufs::DataDescriptor& dd2);
diff --git a/source/fuzz/fuzzer_pass_construct_composites.cpp b/source/fuzz/fuzzer_pass_construct_composites.cpp
index 0ad630c1..ff022fcc 100644
--- a/source/fuzz/fuzzer_pass_construct_composites.cpp
+++ b/source/fuzz/fuzzer_pass_construct_composites.cpp
@@ -81,7 +81,7 @@ void FuzzerPassConstructComposites::Apply() {
// Check whether it is legitimate to insert a composite construction
// before the instruction.
if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(
- spv::Op::OpCompositeConstruct, inst_it)) {
+ SpvOpCompositeConstruct, inst_it)) {
return;
}
@@ -121,19 +121,19 @@ void FuzzerPassConstructComposites::Apply() {
auto composite_type_inst =
GetIRContext()->get_def_use_mgr()->GetDef(chosen_composite_type);
switch (composite_type_inst->opcode()) {
- case spv::Op::OpTypeArray:
+ case SpvOpTypeArray:
constructor_arguments = FindComponentsToConstructArray(
*composite_type_inst, type_id_to_available_instructions);
break;
- case spv::Op::OpTypeMatrix:
+ case SpvOpTypeMatrix:
constructor_arguments = FindComponentsToConstructMatrix(
*composite_type_inst, type_id_to_available_instructions);
break;
- case spv::Op::OpTypeStruct:
+ case SpvOpTypeStruct:
constructor_arguments = FindComponentsToConstructStruct(
*composite_type_inst, type_id_to_available_instructions);
break;
- case spv::Op::OpTypeVector:
+ case SpvOpTypeVector:
constructor_arguments = FindComponentsToConstructVector(
*composite_type_inst, type_id_to_available_instructions);
break;
@@ -156,7 +156,7 @@ std::vector<uint32_t>
FuzzerPassConstructComposites::FindComponentsToConstructArray(
const opt::Instruction& array_type_instruction,
const TypeIdToInstructions& type_id_to_available_instructions) {
- assert(array_type_instruction.opcode() == spv::Op::OpTypeArray &&
+ assert(array_type_instruction.opcode() == SpvOpTypeArray &&
"Precondition: instruction must be an array type.");
// Get the element type for the array.
@@ -191,7 +191,7 @@ std::vector<uint32_t>
FuzzerPassConstructComposites::FindComponentsToConstructMatrix(
const opt::Instruction& matrix_type_instruction,
const TypeIdToInstructions& type_id_to_available_instructions) {
- assert(matrix_type_instruction.opcode() == spv::Op::OpTypeMatrix &&
+ assert(matrix_type_instruction.opcode() == SpvOpTypeMatrix &&
"Precondition: instruction must be a matrix type.");
// Get the element type for the matrix.
@@ -221,7 +221,7 @@ std::vector<uint32_t>
FuzzerPassConstructComposites::FindComponentsToConstructStruct(
const opt::Instruction& struct_type_instruction,
const TypeIdToInstructions& type_id_to_available_instructions) {
- assert(struct_type_instruction.opcode() == spv::Op::OpTypeStruct &&
+ assert(struct_type_instruction.opcode() == SpvOpTypeStruct &&
"Precondition: instruction must be a struct type.");
std::vector<uint32_t> result;
// Consider the type of each field of the struct.
@@ -251,7 +251,7 @@ std::vector<uint32_t>
FuzzerPassConstructComposites::FindComponentsToConstructVector(
const opt::Instruction& vector_type_instruction,
const TypeIdToInstructions& type_id_to_available_instructions) {
- assert(vector_type_instruction.opcode() == spv::Op::OpTypeVector &&
+ assert(vector_type_instruction.opcode() == SpvOpTypeVector &&
"Precondition: instruction must be a vector type.");
// Get details of the type underlying the vector, and the width of the vector,
diff --git a/source/fuzz/fuzzer_pass_copy_objects.cpp b/source/fuzz/fuzzer_pass_copy_objects.cpp
index 725c33e5..80cc2a57 100644
--- a/source/fuzz/fuzzer_pass_copy_objects.cpp
+++ b/source/fuzz/fuzzer_pass_copy_objects.cpp
@@ -35,11 +35,10 @@ void FuzzerPassCopyObjects::Apply() {
opt::BasicBlock::iterator inst_it,
const protobufs::InstructionDescriptor& instruction_descriptor)
-> void {
- assert(
- inst_it->opcode() ==
- spv::Op(instruction_descriptor.target_instruction_opcode()) &&
- "The opcode of the instruction we might insert before must be "
- "the same as the opcode in the descriptor for the instruction");
+ assert(inst_it->opcode() ==
+ instruction_descriptor.target_instruction_opcode() &&
+ "The opcode of the instruction we might insert before must be "
+ "the same as the opcode in the descriptor for the instruction");
if (GetTransformationContext()->GetFactManager()->BlockIsDead(
block->id())) {
@@ -49,7 +48,7 @@ void FuzzerPassCopyObjects::Apply() {
// Check whether it is legitimate to insert a copy before this
// instruction.
- if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(spv::Op::OpCopyObject,
+ if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(SpvOpCopyObject,
inst_it)) {
return;
}
diff --git a/source/fuzz/fuzzer_pass_donate_modules.cpp b/source/fuzz/fuzzer_pass_donate_modules.cpp
index 1696c74e..29ede58b 100644
--- a/source/fuzz/fuzzer_pass_donate_modules.cpp
+++ b/source/fuzz/fuzzer_pass_donate_modules.cpp
@@ -88,7 +88,7 @@ void FuzzerPassDonateModules::DonateSingleModule(
// module.
for (const auto& capability_inst : donor_ir_context->capabilities()) {
auto capability =
- static_cast<spv::Capability>(capability_inst.GetSingleWordInOperand(0));
+ static_cast<SpvCapability>(capability_inst.GetSingleWordInOperand(0));
if (!GetIRContext()->get_feature_mgr()->HasCapability(capability)) {
return;
}
@@ -122,27 +122,27 @@ void FuzzerPassDonateModules::DonateSingleModule(
// kinds of decoration.
}
-spv::StorageClass FuzzerPassDonateModules::AdaptStorageClass(
- spv::StorageClass donor_storage_class) {
+SpvStorageClass FuzzerPassDonateModules::AdaptStorageClass(
+ SpvStorageClass donor_storage_class) {
switch (donor_storage_class) {
- case spv::StorageClass::Function:
- case spv::StorageClass::Private:
- case spv::StorageClass::Workgroup:
+ case SpvStorageClassFunction:
+ case SpvStorageClassPrivate:
+ case SpvStorageClassWorkgroup:
// We leave these alone
return donor_storage_class;
- case spv::StorageClass::Input:
- case spv::StorageClass::Output:
- case spv::StorageClass::Uniform:
- case spv::StorageClass::UniformConstant:
- case spv::StorageClass::PushConstant:
- case spv::StorageClass::Image:
- case spv::StorageClass::StorageBuffer:
+ case SpvStorageClassInput:
+ case SpvStorageClassOutput:
+ case SpvStorageClassUniform:
+ case SpvStorageClassUniformConstant:
+ case SpvStorageClassPushConstant:
+ case SpvStorageClassImage:
+ case SpvStorageClassStorageBuffer:
// We change these to Private
- return spv::StorageClass::Private;
+ return SpvStorageClassPrivate;
default:
// Handle other cases on demand.
assert(false && "Currently unsupported storage class.");
- return spv::StorageClass::Max;
+ return SpvStorageClassMax;
}
}
@@ -200,14 +200,14 @@ void FuzzerPassDonateModules::HandleTypeOrValue(
// that its component types will have been considered previously, and that
// |original_id_to_donated_id| will already contain an entry for them.
switch (type_or_value.opcode()) {
- case spv::Op::OpTypeImage:
- case spv::Op::OpTypeSampledImage:
- case spv::Op::OpTypeSampler:
+ case SpvOpTypeImage:
+ case SpvOpTypeSampledImage:
+ case SpvOpTypeSampler:
// We do not donate types and variables that relate to images and
// samplers, so we skip these types and subsequently skip anything that
// depends on them.
return;
- case spv::Op::OpTypeVoid: {
+ case SpvOpTypeVoid: {
// Void has to exist already in order for us to have an entry point.
// Get the existing id of void.
opt::analysis::Void void_type;
@@ -216,7 +216,7 @@ void FuzzerPassDonateModules::HandleTypeOrValue(
"The module being transformed will always have 'void' type "
"declared.");
} break;
- case spv::Op::OpTypeBool: {
+ case SpvOpTypeBool: {
// Bool cannot be declared multiple times, so use its existing id if
// present, or add a declaration of Bool with a fresh id if not.
opt::analysis::Bool bool_type;
@@ -228,7 +228,7 @@ void FuzzerPassDonateModules::HandleTypeOrValue(
ApplyTransformation(TransformationAddTypeBoolean(new_result_id));
}
} break;
- case spv::Op::OpTypeInt: {
+ case SpvOpTypeInt: {
// Int cannot be declared multiple times with the same width and
// signedness, so check whether an existing identical Int type is
// present and use its id if so. Otherwise add a declaration of the
@@ -246,8 +246,8 @@ void FuzzerPassDonateModules::HandleTypeOrValue(
TransformationAddTypeInt(new_result_id, width, is_signed));
}
} break;
- case spv::Op::OpTypeFloat: {
- // Similar to spv::Op::OpTypeInt.
+ case SpvOpTypeFloat: {
+ // Similar to SpvOpTypeInt.
const uint32_t width = type_or_value.GetSingleWordInOperand(0);
opt::analysis::Float float_type(width);
auto float_type_id = GetIRContext()->get_type_mgr()->GetId(&float_type);
@@ -258,7 +258,7 @@ void FuzzerPassDonateModules::HandleTypeOrValue(
ApplyTransformation(TransformationAddTypeFloat(new_result_id, width));
}
} break;
- case spv::Op::OpTypeVector: {
+ case SpvOpTypeVector: {
// It is not legal to have two Vector type declarations with identical
// element types and element counts, so check whether an existing
// identical Vector type is present and use its id if so. Otherwise add
@@ -282,8 +282,8 @@ void FuzzerPassDonateModules::HandleTypeOrValue(
new_result_id, component_type_id, component_count));
}
} break;
- case spv::Op::OpTypeMatrix: {
- // Similar to spv::Op::OpTypeVector.
+ case SpvOpTypeMatrix: {
+ // Similar to SpvOpTypeVector.
uint32_t column_type_id = original_id_to_donated_id->at(
type_or_value.GetSingleWordInOperand(0));
auto column_type =
@@ -302,7 +302,7 @@ void FuzzerPassDonateModules::HandleTypeOrValue(
}
} break;
- case spv::Op::OpTypeArray: {
+ case SpvOpTypeArray: {
// It is OK to have multiple structurally identical array types, so
// we go ahead and add a remapped version of the type declared by the
// donor.
@@ -318,7 +318,7 @@ void FuzzerPassDonateModules::HandleTypeOrValue(
original_id_to_donated_id->at(
type_or_value.GetSingleWordInOperand(1))));
} break;
- case spv::Op::OpTypeRuntimeArray: {
+ case SpvOpTypeRuntimeArray: {
// A runtime array is allowed as the final member of an SSBO. During
// donation we turn runtime arrays into fixed-size arrays. For dead
// code donations this is OK because the array is never indexed into at
@@ -341,8 +341,8 @@ void FuzzerPassDonateModules::HandleTypeOrValue(
{GetFuzzerContext()->GetRandomSizeForNewArray()}, 32, false,
false)));
} break;
- case spv::Op::OpTypeStruct: {
- // Similar to spv::Op::OpTypeArray.
+ case SpvOpTypeStruct: {
+ // Similar to SpvOpTypeArray.
std::vector<uint32_t> member_type_ids;
for (uint32_t i = 0; i < type_or_value.NumInOperands(); i++) {
auto component_type_id = type_or_value.GetSingleWordInOperand(i);
@@ -358,8 +358,8 @@ void FuzzerPassDonateModules::HandleTypeOrValue(
ApplyTransformation(
TransformationAddTypeStruct(new_result_id, member_type_ids));
} break;
- case spv::Op::OpTypePointer: {
- // Similar to spv::Op::OpTypeArray.
+ case SpvOpTypePointer: {
+ // Similar to SpvOpTypeArray.
uint32_t pointee_type_id = type_or_value.GetSingleWordInOperand(1);
if (!original_id_to_donated_id->count(pointee_type_id)) {
// We did not donate the pointee type for this pointer type, so we
@@ -369,11 +369,11 @@ void FuzzerPassDonateModules::HandleTypeOrValue(
new_result_id = GetFuzzerContext()->GetFreshId();
ApplyTransformation(TransformationAddTypePointer(
new_result_id,
- AdaptStorageClass(static_cast<spv::StorageClass>(
+ AdaptStorageClass(static_cast<SpvStorageClass>(
type_or_value.GetSingleWordInOperand(0))),
original_id_to_donated_id->at(pointee_type_id)));
} break;
- case spv::Op::OpTypeFunction: {
+ case SpvOpTypeFunction: {
// It is not OK to have multiple function types that use identical ids
// for their return and parameter types. We thus go through all
// existing function types to look for a match. We do not use the
@@ -425,11 +425,10 @@ void FuzzerPassDonateModules::HandleTypeOrValue(
argument_type_ids));
}
} break;
- case spv::Op::OpSpecConstantOp: {
+ case SpvOpSpecConstantOp: {
new_result_id = GetFuzzerContext()->GetFreshId();
auto type_id = original_id_to_donated_id->at(type_or_value.type_id());
- auto opcode =
- static_cast<spv::Op>(type_or_value.GetSingleWordInOperand(0));
+ auto opcode = static_cast<SpvOp>(type_or_value.GetSingleWordInOperand(0));
// Make sure we take into account |original_id_to_donated_id| when
// computing operands for OpSpecConstantOp.
@@ -448,20 +447,20 @@ void FuzzerPassDonateModules::HandleTypeOrValue(
ApplyTransformation(TransformationAddSpecConstantOp(
new_result_id, type_id, opcode, std::move(operands)));
} break;
- case spv::Op::OpSpecConstantTrue:
- case spv::Op::OpSpecConstantFalse:
- case spv::Op::OpConstantTrue:
- case spv::Op::OpConstantFalse: {
+ case SpvOpSpecConstantTrue:
+ case SpvOpSpecConstantFalse:
+ case SpvOpConstantTrue:
+ case SpvOpConstantFalse: {
// It is OK to have duplicate definitions of True and False, so add
// these to the module, using a remapped Bool type.
new_result_id = GetFuzzerContext()->GetFreshId();
- auto value = type_or_value.opcode() == spv::Op::OpConstantTrue ||
- type_or_value.opcode() == spv::Op::OpSpecConstantTrue;
+ auto value = type_or_value.opcode() == SpvOpConstantTrue ||
+ type_or_value.opcode() == SpvOpSpecConstantTrue;
ApplyTransformation(
TransformationAddConstantBoolean(new_result_id, value, false));
} break;
- case spv::Op::OpSpecConstant:
- case spv::Op::OpConstant: {
+ case SpvOpSpecConstant:
+ case SpvOpConstant: {
// It is OK to have duplicate constant definitions, so add this to the
// module using a remapped result type.
new_result_id = GetFuzzerContext()->GetFreshId();
@@ -473,8 +472,8 @@ void FuzzerPassDonateModules::HandleTypeOrValue(
new_result_id, original_id_to_donated_id->at(type_or_value.type_id()),
data_words, false));
} break;
- case spv::Op::OpSpecConstantComposite:
- case spv::Op::OpConstantComposite: {
+ case SpvOpSpecConstantComposite:
+ case SpvOpConstantComposite: {
assert(original_id_to_donated_id->count(type_or_value.type_id()) &&
"Composite types for which it is possible to create a constant "
"should have been donated.");
@@ -496,7 +495,7 @@ void FuzzerPassDonateModules::HandleTypeOrValue(
new_result_id, original_id_to_donated_id->at(type_or_value.type_id()),
constituent_ids, false));
} break;
- case spv::Op::OpConstantNull: {
+ case SpvOpConstantNull: {
if (!original_id_to_donated_id->count(type_or_value.type_id())) {
// We did not donate the type associated with this null constant, so
// we cannot donate the null constant.
@@ -510,7 +509,7 @@ void FuzzerPassDonateModules::HandleTypeOrValue(
new_result_id,
original_id_to_donated_id->at(type_or_value.type_id())));
} break;
- case spv::Op::OpVariable: {
+ case SpvOpVariable: {
if (!original_id_to_donated_id->count(type_or_value.type_id())) {
// We did not donate the pointer type associated with this variable,
// so we cannot donate the variable.
@@ -537,11 +536,11 @@ void FuzzerPassDonateModules::HandleTypeOrValue(
uint32_t remapped_pointer_type =
original_id_to_donated_id->at(type_or_value.type_id());
uint32_t initializer_id;
- spv::StorageClass storage_class =
- static_cast<spv::StorageClass>(type_or_value.GetSingleWordInOperand(
- 0)) == spv::StorageClass::Workgroup
- ? spv::StorageClass::Workgroup
- : spv::StorageClass::Private;
+ SpvStorageClass storage_class =
+ static_cast<SpvStorageClass>(type_or_value.GetSingleWordInOperand(
+ 0)) == SpvStorageClassWorkgroup
+ ? SpvStorageClassWorkgroup
+ : SpvStorageClassPrivate;
if (type_or_value.NumInOperands() == 1) {
// The variable did not have an initializer. Initialize it to zero
// if it has Private storage class (to limit problems associated with
@@ -552,7 +551,7 @@ void FuzzerPassDonateModules::HandleTypeOrValue(
// could initialize Workgroup variables at the start of an entry
// point, and should do so if their uninitialized nature proves
// problematic.
- initializer_id = storage_class == spv::StorageClass::Workgroup
+ initializer_id = storage_class == SpvStorageClassWorkgroup
? 0
: FindOrCreateZeroConstant(
fuzzerutil::GetPointeeTypeIdFromPointerType(
@@ -567,7 +566,7 @@ void FuzzerPassDonateModules::HandleTypeOrValue(
TransformationAddGlobalVariable(new_result_id, remapped_pointer_type,
storage_class, initializer_id, true));
} break;
- case spv::Op::OpUndef: {
+ case SpvOpUndef: {
if (!original_id_to_donated_id->count(type_or_value.type_id())) {
// We did not donate the type associated with this undef, so we cannot
// donate the undef.
@@ -639,7 +638,7 @@ void FuzzerPassDonateModules::HandleFunctions(
[this, &donated_instructions, donor_ir_context,
&original_id_to_donated_id,
&skipped_instructions](const opt::Instruction* instruction) {
- if (instruction->opcode() == spv::Op::OpArrayLength) {
+ if (instruction->opcode() == SpvOpArrayLength) {
// We treat OpArrayLength specially.
HandleOpArrayLength(*instruction, original_id_to_donated_id,
&donated_instructions);
@@ -683,70 +682,70 @@ bool FuzzerPassDonateModules::CanDonateInstruction(
// Now consider instructions we specifically want to skip because we do not
// yet support them.
switch (instruction.opcode()) {
- case spv::Op::OpAtomicLoad:
- case spv::Op::OpAtomicStore:
- case spv::Op::OpAtomicExchange:
- case spv::Op::OpAtomicCompareExchange:
- case spv::Op::OpAtomicCompareExchangeWeak:
- case spv::Op::OpAtomicIIncrement:
- case spv::Op::OpAtomicIDecrement:
- case spv::Op::OpAtomicIAdd:
- case spv::Op::OpAtomicISub:
- case spv::Op::OpAtomicSMin:
- case spv::Op::OpAtomicUMin:
- case spv::Op::OpAtomicSMax:
- case spv::Op::OpAtomicUMax:
- case spv::Op::OpAtomicAnd:
- case spv::Op::OpAtomicOr:
- case spv::Op::OpAtomicXor:
+ case SpvOpAtomicLoad:
+ case SpvOpAtomicStore:
+ case SpvOpAtomicExchange:
+ case SpvOpAtomicCompareExchange:
+ case SpvOpAtomicCompareExchangeWeak:
+ case SpvOpAtomicIIncrement:
+ case SpvOpAtomicIDecrement:
+ case SpvOpAtomicIAdd:
+ case SpvOpAtomicISub:
+ case SpvOpAtomicSMin:
+ case SpvOpAtomicUMin:
+ case SpvOpAtomicSMax:
+ case SpvOpAtomicUMax:
+ case SpvOpAtomicAnd:
+ case SpvOpAtomicOr:
+ case SpvOpAtomicXor:
// We conservatively ignore all atomic instructions at present.
// TODO(https://github.com/KhronosGroup/SPIRV-Tools/issues/3276): Consider
// being less conservative here.
- case spv::Op::OpImageSampleImplicitLod:
- case spv::Op::OpImageSampleExplicitLod:
- case spv::Op::OpImageSampleDrefImplicitLod:
- case spv::Op::OpImageSampleDrefExplicitLod:
- case spv::Op::OpImageSampleProjImplicitLod:
- case spv::Op::OpImageSampleProjExplicitLod:
- case spv::Op::OpImageSampleProjDrefImplicitLod:
- case spv::Op::OpImageSampleProjDrefExplicitLod:
- case spv::Op::OpImageFetch:
- case spv::Op::OpImageGather:
- case spv::Op::OpImageDrefGather:
- case spv::Op::OpImageRead:
- case spv::Op::OpImageWrite:
- case spv::Op::OpImageSparseSampleImplicitLod:
- case spv::Op::OpImageSparseSampleExplicitLod:
- case spv::Op::OpImageSparseSampleDrefImplicitLod:
- case spv::Op::OpImageSparseSampleDrefExplicitLod:
- case spv::Op::OpImageSparseSampleProjImplicitLod:
- case spv::Op::OpImageSparseSampleProjExplicitLod:
- case spv::Op::OpImageSparseSampleProjDrefImplicitLod:
- case spv::Op::OpImageSparseSampleProjDrefExplicitLod:
- case spv::Op::OpImageSparseFetch:
- case spv::Op::OpImageSparseGather:
- case spv::Op::OpImageSparseDrefGather:
- case spv::Op::OpImageSparseRead:
- case spv::Op::OpImageSampleFootprintNV:
- case spv::Op::OpImage:
- case spv::Op::OpImageQueryFormat:
- case spv::Op::OpImageQueryLevels:
- case spv::Op::OpImageQueryLod:
- case spv::Op::OpImageQueryOrder:
- case spv::Op::OpImageQuerySamples:
- case spv::Op::OpImageQuerySize:
- case spv::Op::OpImageQuerySizeLod:
- case spv::Op::OpSampledImage:
+ case SpvOpImageSampleImplicitLod:
+ case SpvOpImageSampleExplicitLod:
+ case SpvOpImageSampleDrefImplicitLod:
+ case SpvOpImageSampleDrefExplicitLod:
+ case SpvOpImageSampleProjImplicitLod:
+ case SpvOpImageSampleProjExplicitLod:
+ case SpvOpImageSampleProjDrefImplicitLod:
+ case SpvOpImageSampleProjDrefExplicitLod:
+ case SpvOpImageFetch:
+ case SpvOpImageGather:
+ case SpvOpImageDrefGather:
+ case SpvOpImageRead:
+ case SpvOpImageWrite:
+ case SpvOpImageSparseSampleImplicitLod:
+ case SpvOpImageSparseSampleExplicitLod:
+ case SpvOpImageSparseSampleDrefImplicitLod:
+ case SpvOpImageSparseSampleDrefExplicitLod:
+ case SpvOpImageSparseSampleProjImplicitLod:
+ case SpvOpImageSparseSampleProjExplicitLod:
+ case SpvOpImageSparseSampleProjDrefImplicitLod:
+ case SpvOpImageSparseSampleProjDrefExplicitLod:
+ case SpvOpImageSparseFetch:
+ case SpvOpImageSparseGather:
+ case SpvOpImageSparseDrefGather:
+ case SpvOpImageSparseRead:
+ case SpvOpImageSampleFootprintNV:
+ case SpvOpImage:
+ case SpvOpImageQueryFormat:
+ case SpvOpImageQueryLevels:
+ case SpvOpImageQueryLod:
+ case SpvOpImageQueryOrder:
+ case SpvOpImageQuerySamples:
+ case SpvOpImageQuerySize:
+ case SpvOpImageQuerySizeLod:
+ case SpvOpSampledImage:
// We ignore all instructions related to accessing images, since we do not
// donate images.
return false;
- case spv::Op::OpLoad:
+ case SpvOpLoad:
switch (donor_ir_context->get_def_use_mgr()
->GetDef(instruction.type_id())
->opcode()) {
- case spv::Op::OpTypeImage:
- case spv::Op::OpTypeSampledImage:
- case spv::Op::OpTypeSampler:
+ case SpvOpTypeImage:
+ case SpvOpTypeSampledImage:
+ case SpvOpTypeSampler:
// Again, we ignore instructions that relate to accessing images.
return false;
default:
@@ -784,13 +783,13 @@ bool FuzzerPassDonateModules::CanDonateInstruction(
bool FuzzerPassDonateModules::IsBasicType(
const opt::Instruction& instruction) const {
switch (instruction.opcode()) {
- case spv::Op::OpTypeArray:
- case spv::Op::OpTypeBool:
- case spv::Op::OpTypeFloat:
- case spv::Op::OpTypeInt:
- case spv::Op::OpTypeMatrix:
- case spv::Op::OpTypeStruct:
- case spv::Op::OpTypeVector:
+ case SpvOpTypeArray:
+ case SpvOpTypeBool:
+ case SpvOpTypeFloat:
+ case SpvOpTypeInt:
+ case SpvOpTypeMatrix:
+ case SpvOpTypeStruct:
+ case SpvOpTypeVector:
return true;
default:
return false;
@@ -801,7 +800,7 @@ void FuzzerPassDonateModules::HandleOpArrayLength(
const opt::Instruction& instruction,
std::map<uint32_t, uint32_t>* original_id_to_donated_id,
std::vector<protobufs::Instruction>* donated_instructions) const {
- assert(instruction.opcode() == spv::Op::OpArrayLength &&
+ assert(instruction.opcode() == SpvOpArrayLength &&
"Precondition: instruction must be OpArrayLength.");
uint32_t donated_variable_id =
original_id_to_donated_id->at(instruction.GetSingleWordInOperand(0));
@@ -810,12 +809,12 @@ void FuzzerPassDonateModules::HandleOpArrayLength(
auto pointer_to_struct_instruction =
GetIRContext()->get_def_use_mgr()->GetDef(
donated_variable_instruction->type_id());
- assert(pointer_to_struct_instruction->opcode() == spv::Op::OpTypePointer &&
+ assert(pointer_to_struct_instruction->opcode() == SpvOpTypePointer &&
"Type of variable must be pointer.");
auto donated_struct_type_instruction =
GetIRContext()->get_def_use_mgr()->GetDef(
pointer_to_struct_instruction->GetSingleWordInOperand(1));
- assert(donated_struct_type_instruction->opcode() == spv::Op::OpTypeStruct &&
+ assert(donated_struct_type_instruction->opcode() == SpvOpTypeStruct &&
"Pointee type of pointer used by OpArrayLength must be struct.");
assert(donated_struct_type_instruction->NumInOperands() ==
instruction.GetSingleWordInOperand(1) + 1 &&
@@ -826,7 +825,7 @@ void FuzzerPassDonateModules::HandleOpArrayLength(
donated_struct_type_instruction->NumInOperands() - 1);
auto fixed_size_array_type_instruction =
GetIRContext()->get_def_use_mgr()->GetDef(fixed_size_array_type_id);
- assert(fixed_size_array_type_instruction->opcode() == spv::Op::OpTypeArray &&
+ assert(fixed_size_array_type_instruction->opcode() == SpvOpTypeArray &&
"The donated array type must be fixed-size.");
auto array_size_id =
fixed_size_array_type_instruction->GetSingleWordInOperand(1);
@@ -838,8 +837,7 @@ void FuzzerPassDonateModules::HandleOpArrayLength(
}
donated_instructions->push_back(MakeInstructionMessage(
- spv::Op::OpCopyObject,
- original_id_to_donated_id->at(instruction.type_id()),
+ SpvOpCopyObject, original_id_to_donated_id->at(instruction.type_id()),
original_id_to_donated_id->at(instruction.result_id()),
opt::Instruction::OperandList({{SPV_OPERAND_TYPE_ID, {array_size_id}}})));
}
@@ -894,7 +892,7 @@ void FuzzerPassDonateModules::HandleDifficultInstruction(
// more interesting value later.
auto zero_constant = FindOrCreateZeroConstant(remapped_type_id, true);
donated_instructions->push_back(MakeInstructionMessage(
- spv::Op::OpCopyObject, remapped_type_id,
+ SpvOpCopyObject, remapped_type_id,
original_id_to_donated_id->at(instruction.result_id()),
opt::Instruction::OperandList({{SPV_OPERAND_TYPE_ID, {zero_constant}}})));
}
@@ -928,8 +926,8 @@ void FuzzerPassDonateModules::PrepareInstructionForDonation(
(void)(donor_ir_context);
assert((donor_ir_context->get_def_use_mgr()
->GetDef(operand_id)
- ->opcode() == spv::Op::OpLabel ||
- instruction.opcode() == spv::Op::OpPhi) &&
+ ->opcode() == SpvOpLabel ||
+ instruction.opcode() == SpvOpPhi) &&
"Unsupported forward reference.");
original_id_to_donated_id->insert(
{operand_id, GetFuzzerContext()->GetFreshId()});
@@ -944,7 +942,7 @@ void FuzzerPassDonateModules::PrepareInstructionForDonation(
input_operands.push_back({in_operand.type, operand_data});
}
- if (instruction.opcode() == spv::Op::OpVariable &&
+ if (instruction.opcode() == SpvOpVariable &&
instruction.NumInOperands() == 1) {
// This is an uninitialized local variable. Initialize it to zero.
input_operands.push_back(
@@ -1019,7 +1017,7 @@ bool FuzzerPassDonateModules::CreateLoopLimiterInfo(
// Adjust OpPhi instructions in the |merge_block|.
for (const auto& inst : *merge_block) {
- if (inst.opcode() != spv::Op::OpPhi) {
+ if (inst.opcode() != SpvOpPhi) {
break;
}
@@ -1072,8 +1070,7 @@ bool FuzzerPassDonateModules::MaybeAddLivesafeFunction(
// live-safe. Add them if not already present.
FindOrCreateBoolType(); // Needed for comparisons
FindOrCreatePointerToIntegerType(
- 32, false,
- spv::StorageClass::Function); // Needed for adding loop limiters
+ 32, false, SpvStorageClassFunction); // Needed for adding loop limiters
FindOrCreateIntegerConstant({0}, 32, false,
false); // Needed for initializing loop limiters
FindOrCreateIntegerConstant({1}, 32, false,
@@ -1110,8 +1107,8 @@ bool FuzzerPassDonateModules::MaybeAddLivesafeFunction(
for (auto& block : function_to_donate) {
for (auto& inst : block) {
switch (inst.opcode()) {
- case spv::Op::OpAccessChain:
- case spv::Op::OpInBoundsAccessChain: {
+ case SpvOpAccessChain:
+ case SpvOpInBoundsAccessChain: {
protobufs::AccessChainClampingInfo clamping_info;
clamping_info.set_access_chain_id(
original_id_to_donated_id.at(inst.result_id()));
@@ -1121,8 +1118,7 @@ bool FuzzerPassDonateModules::MaybeAddLivesafeFunction(
assert(base_object && "The base object must exist.");
auto pointer_type = donor_ir_context->get_def_use_mgr()->GetDef(
base_object->type_id());
- assert(pointer_type &&
- pointer_type->opcode() == spv::Op::OpTypePointer &&
+ assert(pointer_type && pointer_type->opcode() == SpvOpTypePointer &&
"The base object must have pointer type.");
auto should_be_composite_type =
@@ -1142,8 +1138,7 @@ bool FuzzerPassDonateModules::MaybeAddLivesafeFunction(
// Get the bound for the component being indexed into.
uint32_t bound;
- if (should_be_composite_type->opcode() ==
- spv::Op::OpTypeRuntimeArray) {
+ if (should_be_composite_type->opcode() == SpvOpTypeRuntimeArray) {
// The donor is indexing into a runtime array. We do not
// donate runtime arrays. Instead, we donate a corresponding
// fixed-size array for every runtime array. We should thus
@@ -1153,7 +1148,7 @@ bool FuzzerPassDonateModules::MaybeAddLivesafeFunction(
GetIRContext()->get_def_use_mgr()->GetDef(
original_id_to_donated_id.at(
should_be_composite_type->result_id()));
- assert(fixed_size_array_type->opcode() == spv::Op::OpTypeArray &&
+ assert(fixed_size_array_type->opcode() == SpvOpTypeArray &&
"A runtime array type in the donor should have been "
"replaced by a fixed-sized array in the recipient.");
// The size of this fixed-size array is a suitable bound.
@@ -1168,12 +1163,12 @@ bool FuzzerPassDonateModules::MaybeAddLivesafeFunction(
donor_ir_context->get_def_use_mgr()->GetDef(index_id);
auto index_type_inst = donor_ir_context->get_def_use_mgr()->GetDef(
index_inst->type_id());
- assert(index_type_inst->opcode() == spv::Op::OpTypeInt);
+ assert(index_type_inst->opcode() == SpvOpTypeInt);
opt::analysis::Integer* index_int_type =
donor_ir_context->get_type_mgr()
->GetType(index_type_inst->result_id())
->AsInteger();
- if (index_inst->opcode() != spv::Op::OpConstant) {
+ if (index_inst->opcode() != SpvOpConstant) {
// We will have to clamp this index, so we need a constant
// whose value is one less than the bound, to compare
// against and to use as the clamped value.
@@ -1199,7 +1194,7 @@ bool FuzzerPassDonateModules::MaybeAddLivesafeFunction(
uint32_t kill_unreachable_return_value_id = 0;
auto function_return_type_inst =
donor_ir_context->get_def_use_mgr()->GetDef(function_to_donate.type_id());
- if (function_return_type_inst->opcode() != spv::Op::OpTypeVoid &&
+ if (function_return_type_inst->opcode() != SpvOpTypeVoid &&
fuzzerutil::FunctionContainsOpKillOrUnreachable(function_to_donate)) {
kill_unreachable_return_value_id = FindOrCreateZeroConstant(
original_id_to_donated_id.at(function_return_type_inst->result_id()),
diff --git a/source/fuzz/fuzzer_pass_donate_modules.h b/source/fuzz/fuzzer_pass_donate_modules.h
index 004f1587..924dd358 100644
--- a/source/fuzz/fuzzer_pass_donate_modules.h
+++ b/source/fuzz/fuzzer_pass_donate_modules.h
@@ -45,8 +45,7 @@ class FuzzerPassDonateModules : public FuzzerPass {
private:
// Adapts a storage class coming from a donor module so that it will work
// in a recipient module, e.g. by changing Uniform to Private.
- static spv::StorageClass AdaptStorageClass(
- spv::StorageClass donor_storage_class);
+ static SpvStorageClass AdaptStorageClass(SpvStorageClass donor_storage_class);
// Identifies all external instruction set imports in |donor_ir_context| and
// populates |original_id_to_donated_id| with a mapping from the donor's id
diff --git a/source/fuzz/fuzzer_pass_expand_vector_reductions.cpp b/source/fuzz/fuzzer_pass_expand_vector_reductions.cpp
index fecd82e4..5bf0461d 100644
--- a/source/fuzz/fuzzer_pass_expand_vector_reductions.cpp
+++ b/source/fuzz/fuzzer_pass_expand_vector_reductions.cpp
@@ -40,8 +40,8 @@ void FuzzerPassExpandVectorReductions::Apply() {
}
// |instruction| must be OpAny or OpAll.
- if (instruction.opcode() != spv::Op::OpAny &&
- instruction.opcode() != spv::Op::OpAll) {
+ if (instruction.opcode() != SpvOpAny &&
+ instruction.opcode() != SpvOpAll) {
continue;
}
diff --git a/source/fuzz/fuzzer_pass_flatten_conditional_branches.cpp b/source/fuzz/fuzzer_pass_flatten_conditional_branches.cpp
index 86ffff45..70fa6a12 100644
--- a/source/fuzz/fuzzer_pass_flatten_conditional_branches.cpp
+++ b/source/fuzz/fuzzer_pass_flatten_conditional_branches.cpp
@@ -48,8 +48,8 @@ void FuzzerPassFlattenConditionalBranches::Apply() {
// Only consider this block if it is the header of a conditional, with a
// non-irrelevant condition.
if (block.GetMergeInst() &&
- block.GetMergeInst()->opcode() == spv::Op::OpSelectionMerge &&
- block.terminator()->opcode() == spv::Op::OpBranchConditional &&
+ block.GetMergeInst()->opcode() == SpvOpSelectionMerge &&
+ block.terminator()->opcode() == SpvOpBranchConditional &&
!GetTransformationContext()->GetFactManager()->IdIsIrrelevant(
block.terminator()->GetSingleWordInOperand(0))) {
selection_headers.emplace_back(&block);
@@ -94,11 +94,11 @@ void FuzzerPassFlattenConditionalBranches::Apply() {
->get_def_use_mgr()
->GetDef(phi_instruction->type_id())
->opcode()) {
- case spv::Op::OpTypeBool:
- case spv::Op::OpTypeInt:
- case spv::Op::OpTypeFloat:
- case spv::Op::OpTypePointer:
- case spv::Op::OpTypeVector:
+ case SpvOpTypeBool:
+ case SpvOpTypeInt:
+ case SpvOpTypeFloat:
+ case SpvOpTypePointer:
+ case SpvOpTypeVector:
return true;
default:
return false;
@@ -143,7 +143,7 @@ void FuzzerPassFlattenConditionalBranches::Apply() {
GetIRContext()->get_def_use_mgr()->GetDef(
phi_instruction->type_id());
switch (type_instruction->opcode()) {
- case spv::Op::OpTypeVector: {
+ case SpvOpTypeVector: {
uint32_t dimension =
type_instruction->GetSingleWordInOperand(1);
switch (dimension) {
diff --git a/source/fuzz/fuzzer_pass_inline_functions.cpp b/source/fuzz/fuzzer_pass_inline_functions.cpp
index 6839bbe2..4024096f 100644
--- a/source/fuzz/fuzzer_pass_inline_functions.cpp
+++ b/source/fuzz/fuzzer_pass_inline_functions.cpp
@@ -64,7 +64,7 @@ void FuzzerPassInlineFunctions::Apply() {
auto* function_call_block =
GetIRContext()->get_instr_block(function_call_instruction);
if ((function_call_instruction != &*--function_call_block->tail() ||
- function_call_block->terminator()->opcode() != spv::Op::OpBranch) &&
+ function_call_block->terminator()->opcode() != SpvOpBranch) &&
!MaybeApplyTransformation(TransformationSplitBlock(
MakeInstructionDescriptor(GetIRContext(),
function_call_instruction->NextNode()),
diff --git a/source/fuzz/fuzzer_pass_make_vector_operations_dynamic.cpp b/source/fuzz/fuzzer_pass_make_vector_operations_dynamic.cpp
index ec5fc4b7..b755d235 100644
--- a/source/fuzz/fuzzer_pass_make_vector_operations_dynamic.cpp
+++ b/source/fuzz/fuzzer_pass_make_vector_operations_dynamic.cpp
@@ -47,20 +47,18 @@ void FuzzerPassMakeVectorOperationsDynamic::Apply() {
}
// Make sure |instruction| has only one indexing operand.
- assert(
- instruction.NumInOperands() ==
- (instruction.opcode() == spv::Op::OpCompositeExtract ? 2 : 3) &&
- "FuzzerPassMakeVectorOperationsDynamic: the composite "
- "instruction must have "
- "only one indexing operand.");
+ assert(instruction.NumInOperands() ==
+ (instruction.opcode() == SpvOpCompositeExtract ? 2 : 3) &&
+ "FuzzerPassMakeVectorOperationsDynamic: the composite "
+ "instruction must have "
+ "only one indexing operand.");
// Applies the make vector operation dynamic transformation.
ApplyTransformation(TransformationMakeVectorOperationDynamic(
instruction.result_id(),
FindOrCreateIntegerConstant(
{instruction.GetSingleWordInOperand(
- instruction.opcode() == spv::Op::OpCompositeExtract ? 1
- : 2)},
+ instruction.opcode() == SpvOpCompositeExtract ? 1 : 2)},
32, GetFuzzerContext()->ChooseEven(), false)));
}
}
diff --git a/source/fuzz/fuzzer_pass_merge_function_returns.cpp b/source/fuzz/fuzzer_pass_merge_function_returns.cpp
index 48c18618..220f707b 100644
--- a/source/fuzz/fuzzer_pass_merge_function_returns.cpp
+++ b/source/fuzz/fuzzer_pass_merge_function_returns.cpp
@@ -64,11 +64,11 @@ void FuzzerPassMergeFunctionReturns::Apply() {
[this, function](
opt::BasicBlock* /*unused*/, opt::BasicBlock::iterator inst_it,
const protobufs::InstructionDescriptor& instruction_descriptor) {
- const spv::Op opcode = inst_it->opcode();
+ const SpvOp opcode = inst_it->opcode();
switch (opcode) {
- case spv::Op::OpKill:
- case spv::Op::OpUnreachable:
- case spv::Op::OpTerminateInvocation: {
+ case SpvOpKill:
+ case SpvOpUnreachable:
+ case SpvOpTerminateInvocation: {
// This is an early termination instruction - we need to wrap it
// so that it becomes a return.
if (TransformationWrapEarlyTerminatorInFunction::
@@ -85,7 +85,7 @@ void FuzzerPassMergeFunctionReturns::Apply() {
GetIRContext()->get_def_use_mgr()->GetDef(
function->type_id());
uint32_t returned_value_id;
- if (function_return_type->opcode() == spv::Op::OpTypeVoid) {
+ if (function_return_type->opcode() == SpvOpTypeVoid) {
// No value is needed.
returned_value_id = 0;
} else if (fuzzerutil::CanCreateConstant(
@@ -130,7 +130,7 @@ void FuzzerPassMergeFunctionReturns::Apply() {
// If the entry block does not branch unconditionally to another block,
// split it.
- if (function->entry()->terminator()->opcode() != spv::Op::OpBranch) {
+ if (function->entry()->terminator()->opcode() != SpvOpBranch) {
SplitBlockAfterOpPhiOrOpVariable(function->entry()->id());
}
@@ -149,9 +149,9 @@ void FuzzerPassMergeFunctionReturns::Apply() {
if (GetIRContext()
->get_instr_block(merge_block)
->WhileEachInst([](opt::Instruction* inst) {
- return inst->opcode() == spv::Op::OpLabel ||
- inst->opcode() == spv::Op::OpPhi ||
- inst->opcode() == spv::Op::OpBranch;
+ return inst->opcode() == SpvOpLabel ||
+ inst->opcode() == SpvOpPhi ||
+ inst->opcode() == SpvOpBranch;
})) {
actual_merge_blocks.emplace_back(merge_block);
continue;
@@ -324,8 +324,7 @@ FuzzerPassMergeFunctionReturns::GetInfoNeededForMergeBlocks(
bool FuzzerPassMergeFunctionReturns::IsEarlyTerminatorWrapper(
const opt::Function& function) const {
- for (spv::Op opcode : {spv::Op::OpKill, spv::Op::OpUnreachable,
- spv::Op::OpTerminateInvocation}) {
+ for (SpvOp opcode : {SpvOpKill, SpvOpUnreachable, SpvOpTerminateInvocation}) {
if (TransformationWrapEarlyTerminatorInFunction::MaybeGetWrapperFunction(
GetIRContext(), opcode) == &function) {
return true;
diff --git a/source/fuzz/fuzzer_pass_mutate_pointers.cpp b/source/fuzz/fuzzer_pass_mutate_pointers.cpp
index a7e9fdc3..bbe05409 100644
--- a/source/fuzz/fuzzer_pass_mutate_pointers.cpp
+++ b/source/fuzz/fuzzer_pass_mutate_pointers.cpp
@@ -39,8 +39,7 @@ void FuzzerPassMutatePointers::Apply() {
return;
}
- if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(spv::Op::OpLoad,
- inst_it)) {
+ if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(SpvOpLoad, inst_it)) {
return;
}
diff --git a/source/fuzz/fuzzer_pass_obfuscate_constants.cpp b/source/fuzz/fuzzer_pass_obfuscate_constants.cpp
index 48ac589e..f60c1b4c 100644
--- a/source/fuzz/fuzzer_pass_obfuscate_constants.cpp
+++ b/source/fuzz/fuzzer_pass_obfuscate_constants.cpp
@@ -37,21 +37,21 @@ FuzzerPassObfuscateConstants::FuzzerPassObfuscateConstants(
void FuzzerPassObfuscateConstants::ObfuscateBoolConstantViaConstantPair(
uint32_t depth, const protobufs::IdUseDescriptor& bool_constant_use,
- const std::vector<spv::Op>& greater_than_opcodes,
- const std::vector<spv::Op>& less_than_opcodes, uint32_t constant_id_1,
+ const std::vector<SpvOp>& greater_than_opcodes,
+ const std::vector<SpvOp>& less_than_opcodes, uint32_t constant_id_1,
uint32_t constant_id_2, bool first_constant_is_larger) {
auto bool_constant_opcode = GetIRContext()
->get_def_use_mgr()
->GetDef(bool_constant_use.id_of_interest())
->opcode();
- assert((bool_constant_opcode == spv::Op::OpConstantFalse ||
- bool_constant_opcode == spv::Op::OpConstantTrue) &&
+ assert((bool_constant_opcode == SpvOpConstantFalse ||
+ bool_constant_opcode == SpvOpConstantTrue) &&
"Precondition: this must be a usage of a boolean constant.");
// Pick an opcode at random. First randomly decide whether to generate
// a 'greater than' or 'less than' kind of opcode, and then select a
// random opcode from the resulting subset.
- spv::Op comparison_opcode;
+ SpvOp comparison_opcode;
if (GetFuzzerContext()->ChooseEven()) {
comparison_opcode = greater_than_opcodes[GetFuzzerContext()->RandomIndex(
greater_than_opcodes)];
@@ -68,9 +68,9 @@ void FuzzerPassObfuscateConstants::ObfuscateBoolConstantViaConstantPair(
comparison_opcode) != greater_than_opcodes.end();
uint32_t lhs_id;
uint32_t rhs_id;
- if ((bool_constant_opcode == spv::Op::OpConstantTrue &&
+ if ((bool_constant_opcode == SpvOpConstantTrue &&
first_constant_is_larger == is_greater_than_opcode) ||
- (bool_constant_opcode == spv::Op::OpConstantFalse &&
+ (bool_constant_opcode == SpvOpConstantFalse &&
first_constant_is_larger != is_greater_than_opcode)) {
lhs_id = constant_id_1;
rhs_id = constant_id_2;
@@ -147,12 +147,12 @@ void FuzzerPassObfuscateConstants::ObfuscateBoolConstantViaFloatConstantPair(
first_constant_is_larger =
float_constant_1->GetDouble() > float_constant_2->GetDouble();
}
- std::vector<spv::Op> greater_than_opcodes{
- spv::Op::OpFOrdGreaterThan, spv::Op::OpFOrdGreaterThanEqual,
- spv::Op::OpFUnordGreaterThan, spv::Op::OpFUnordGreaterThanEqual};
- std::vector<spv::Op> less_than_opcodes{
- spv::Op::OpFOrdGreaterThan, spv::Op::OpFOrdGreaterThanEqual,
- spv::Op::OpFUnordGreaterThan, spv::Op::OpFUnordGreaterThanEqual};
+ std::vector<SpvOp> greater_than_opcodes{
+ SpvOpFOrdGreaterThan, SpvOpFOrdGreaterThanEqual, SpvOpFUnordGreaterThan,
+ SpvOpFUnordGreaterThanEqual};
+ std::vector<SpvOp> less_than_opcodes{
+ SpvOpFOrdGreaterThan, SpvOpFOrdGreaterThanEqual, SpvOpFUnordGreaterThan,
+ SpvOpFUnordGreaterThanEqual};
ObfuscateBoolConstantViaConstantPair(
depth, bool_constant_use, greater_than_opcodes, less_than_opcodes,
@@ -190,10 +190,9 @@ void FuzzerPassObfuscateConstants::
first_constant_is_larger =
signed_int_constant_1->GetS64() > signed_int_constant_2->GetS64();
}
- std::vector<spv::Op> greater_than_opcodes{spv::Op::OpSGreaterThan,
- spv::Op::OpSGreaterThanEqual};
- std::vector<spv::Op> less_than_opcodes{spv::Op::OpSLessThan,
- spv::Op::OpSLessThanEqual};
+ std::vector<SpvOp> greater_than_opcodes{SpvOpSGreaterThan,
+ SpvOpSGreaterThanEqual};
+ std::vector<SpvOp> less_than_opcodes{SpvOpSLessThan, SpvOpSLessThanEqual};
ObfuscateBoolConstantViaConstantPair(
depth, bool_constant_use, greater_than_opcodes, less_than_opcodes,
@@ -233,10 +232,9 @@ void FuzzerPassObfuscateConstants::
first_constant_is_larger =
unsigned_int_constant_1->GetU64() > unsigned_int_constant_2->GetU64();
}
- std::vector<spv::Op> greater_than_opcodes{spv::Op::OpUGreaterThan,
- spv::Op::OpUGreaterThanEqual};
- std::vector<spv::Op> less_than_opcodes{spv::Op::OpULessThan,
- spv::Op::OpULessThanEqual};
+ std::vector<SpvOp> greater_than_opcodes{SpvOpUGreaterThan,
+ SpvOpUGreaterThanEqual};
+ std::vector<SpvOp> less_than_opcodes{SpvOpULessThan, SpvOpULessThanEqual};
ObfuscateBoolConstantViaConstantPair(
depth, bool_constant_use, greater_than_opcodes, less_than_opcodes,
@@ -381,7 +379,7 @@ void FuzzerPassObfuscateConstants::ObfuscateScalarConstant(
uniform_descriptor.index());
assert(element_type_id && "Type of uniform variable is invalid");
- FindOrCreatePointerType(element_type_id, spv::StorageClass::Uniform);
+ FindOrCreatePointerType(element_type_id, SpvStorageClassUniform);
// Create, apply and record a transformation to replace the constant use with
// the result of a load from the chosen uniform.
@@ -396,11 +394,11 @@ void FuzzerPassObfuscateConstants::ObfuscateConstant(
->get_def_use_mgr()
->GetDef(constant_use.id_of_interest())
->opcode()) {
- case spv::Op::OpConstantTrue:
- case spv::Op::OpConstantFalse:
+ case SpvOpConstantTrue:
+ case SpvOpConstantFalse:
ObfuscateBoolConstant(depth, constant_use);
break;
- case spv::Op::OpConstant:
+ case SpvOpConstant:
ObfuscateScalarConstant(depth, constant_use);
break;
default:
@@ -412,7 +410,7 @@ void FuzzerPassObfuscateConstants::ObfuscateConstant(
void FuzzerPassObfuscateConstants::MaybeAddConstantIdUse(
const opt::Instruction& inst, uint32_t in_operand_index,
uint32_t base_instruction_result_id,
- const std::map<spv::Op, uint32_t>& skipped_opcode_count,
+ const std::map<SpvOp, uint32_t>& skipped_opcode_count,
std::vector<protobufs::IdUseDescriptor>* constant_uses) {
if (inst.GetInOperand(in_operand_index).type != SPV_OPERAND_TYPE_ID) {
// The operand is not an id, so it cannot be a constant id.
@@ -422,15 +420,15 @@ void FuzzerPassObfuscateConstants::MaybeAddConstantIdUse(
auto operand_definition =
GetIRContext()->get_def_use_mgr()->GetDef(operand_id);
switch (operand_definition->opcode()) {
- case spv::Op::OpConstantFalse:
- case spv::Op::OpConstantTrue:
- case spv::Op::OpConstant: {
+ case SpvOpConstantFalse:
+ case SpvOpConstantTrue:
+ case SpvOpConstant: {
// The operand is a constant id, so make an id use descriptor and record
// it.
protobufs::IdUseDescriptor id_use_descriptor;
id_use_descriptor.set_id_of_interest(operand_id);
id_use_descriptor.mutable_enclosing_instruction()
- ->set_target_instruction_opcode(uint32_t(inst.opcode()));
+ ->set_target_instruction_opcode(inst.opcode());
id_use_descriptor.mutable_enclosing_instruction()
->set_base_instruction_result_id(base_instruction_result_id);
id_use_descriptor.mutable_enclosing_instruction()
@@ -463,7 +461,7 @@ void FuzzerPassObfuscateConstants::Apply() {
// opcode need to be skipped in order to find the instruction of interest
// from the base instruction. We maintain a mapping that records a skip
// count for each relevant opcode.
- std::map<spv::Op, uint32_t> skipped_opcode_count;
+ std::map<SpvOp, uint32_t> skipped_opcode_count;
// Go through each instruction in the block.
for (auto& inst : block) {
@@ -480,7 +478,7 @@ void FuzzerPassObfuscateConstants::Apply() {
// The instruction must not be an OpVariable, the only id that an
// OpVariable uses is an initializer id, which has to remain
// constant.
- if (inst.opcode() != spv::Op::OpVariable) {
+ if (inst.opcode() != SpvOpVariable) {
// Consider each operand of the instruction, and add a constant id
// use for the operand if relevant.
for (uint32_t in_operand_index = 0;
diff --git a/source/fuzz/fuzzer_pass_obfuscate_constants.h b/source/fuzz/fuzzer_pass_obfuscate_constants.h
index bfef597c..30e64d28 100644
--- a/source/fuzz/fuzzer_pass_obfuscate_constants.h
+++ b/source/fuzz/fuzzer_pass_obfuscate_constants.h
@@ -85,8 +85,8 @@ class FuzzerPassObfuscateConstants : public FuzzerPass {
// (similar for |less_than_opcodes|).
void ObfuscateBoolConstantViaConstantPair(
uint32_t depth, const protobufs::IdUseDescriptor& bool_constant_use,
- const std::vector<spv::Op>& greater_than_opcodes,
- const std::vector<spv::Op>& less_than_opcodes, uint32_t constant_id_1,
+ const std::vector<SpvOp>& greater_than_opcodes,
+ const std::vector<SpvOp>& less_than_opcodes, uint32_t constant_id_1,
uint32_t constant_id_2, bool first_constant_is_larger);
// A helper method to determine whether input operand |in_operand_index| of
@@ -96,7 +96,7 @@ class FuzzerPassObfuscateConstants : public FuzzerPass {
void MaybeAddConstantIdUse(
const opt::Instruction& inst, uint32_t in_operand_index,
uint32_t base_instruction_result_id,
- const std::map<spv::Op, uint32_t>& skipped_opcode_count,
+ const std::map<SpvOp, uint32_t>& skipped_opcode_count,
std::vector<protobufs::IdUseDescriptor>* constant_uses);
// Returns a vector of unique words that denote constants. Every such constant
diff --git a/source/fuzz/fuzzer_pass_outline_functions.cpp b/source/fuzz/fuzzer_pass_outline_functions.cpp
index e64373a4..b90c12dc 100644
--- a/source/fuzz/fuzzer_pass_outline_functions.cpp
+++ b/source/fuzz/fuzzer_pass_outline_functions.cpp
@@ -137,12 +137,12 @@ FuzzerPassOutlineFunctions::MaybeGetEntryBlockSuitableForOutlining(
"The entry block cannot be a loop header at this point.");
// If the entry block starts with OpPhi or OpVariable, try to split it.
- if (entry_block->begin()->opcode() == spv::Op::OpPhi ||
- entry_block->begin()->opcode() == spv::Op::OpVariable) {
+ if (entry_block->begin()->opcode() == SpvOpPhi ||
+ entry_block->begin()->opcode() == SpvOpVariable) {
// Find the first non-OpPhi and non-OpVariable instruction.
auto non_phi_or_var_inst = &*entry_block->begin();
- while (non_phi_or_var_inst->opcode() == spv::Op::OpPhi ||
- non_phi_or_var_inst->opcode() == spv::Op::OpVariable) {
+ while (non_phi_or_var_inst->opcode() == SpvOpPhi ||
+ non_phi_or_var_inst->opcode() == SpvOpVariable) {
non_phi_or_var_inst = non_phi_or_var_inst->NextNode();
}
@@ -175,7 +175,7 @@ FuzzerPassOutlineFunctions::MaybeGetExitBlockSuitableForOutlining(
// Find the first non-OpPhi instruction, after which to split.
auto split_before = &*exit_block->begin();
- while (split_before->opcode() == spv::Op::OpPhi) {
+ while (split_before->opcode() == SpvOpPhi) {
split_before = split_before->NextNode();
}
diff --git a/source/fuzz/fuzzer_pass_permute_function_variables.cpp b/source/fuzz/fuzzer_pass_permute_function_variables.cpp
index 2313f420..f8b9b450 100644
--- a/source/fuzz/fuzzer_pass_permute_function_variables.cpp
+++ b/source/fuzz/fuzzer_pass_permute_function_variables.cpp
@@ -47,7 +47,7 @@ void FuzzerPassPermuteFunctionVariables::Apply() {
std::vector<opt::Instruction*> variables;
for (auto& instruction : *first_block) {
- if (instruction.opcode() == spv::Op::OpVariable) {
+ if (instruction.opcode() == SpvOpVariable) {
variables.push_back(&instruction);
}
}
diff --git a/source/fuzz/fuzzer_pass_permute_phi_operands.cpp b/source/fuzz/fuzzer_pass_permute_phi_operands.cpp
index 7fbdd3b2..5fac9816 100644
--- a/source/fuzz/fuzzer_pass_permute_phi_operands.cpp
+++ b/source/fuzz/fuzzer_pass_permute_phi_operands.cpp
@@ -40,7 +40,7 @@ void FuzzerPassPermutePhiOperands::Apply() {
const protobufs::InstructionDescriptor& /*unused*/) {
const auto& inst = *inst_it;
- if (inst.opcode() != spv::Op::OpPhi) {
+ if (inst.opcode() != SpvOpPhi) {
return;
}
diff --git a/source/fuzz/fuzzer_pass_push_ids_through_variables.cpp b/source/fuzz/fuzzer_pass_push_ids_through_variables.cpp
index c0397e18..a6c07b4b 100644
--- a/source/fuzz/fuzzer_pass_push_ids_through_variables.cpp
+++ b/source/fuzz/fuzzer_pass_push_ids_through_variables.cpp
@@ -35,11 +35,10 @@ void FuzzerPassPushIdsThroughVariables::Apply() {
opt::BasicBlock::iterator instruction_iterator,
const protobufs::InstructionDescriptor& instruction_descriptor)
-> void {
- assert(
- instruction_iterator->opcode() ==
- spv::Op(instruction_descriptor.target_instruction_opcode()) &&
- "The opcode of the instruction we might insert before must be "
- "the same as the opcode in the descriptor for the instruction");
+ assert(instruction_iterator->opcode() ==
+ instruction_descriptor.target_instruction_opcode() &&
+ "The opcode of the instruction we might insert before must be "
+ "the same as the opcode in the descriptor for the instruction");
// Randomly decide whether to try pushing an id through a variable.
if (!GetFuzzerContext()->ChoosePercentage(
@@ -56,16 +55,16 @@ void FuzzerPassPushIdsThroughVariables::Apply() {
// It must be valid to insert OpStore and OpLoad instructions
// before the instruction to insert before.
if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(
- spv::Op::OpStore, instruction_iterator) ||
+ SpvOpStore, instruction_iterator) ||
!fuzzerutil::CanInsertOpcodeBeforeInstruction(
- spv::Op::OpLoad, instruction_iterator)) {
+ SpvOpLoad, instruction_iterator)) {
return;
}
// Randomly decides whether a global or local variable will be added.
auto variable_storage_class = GetFuzzerContext()->ChooseEven()
- ? spv::StorageClass::Private
- : spv::StorageClass::Function;
+ ? SpvStorageClassPrivate
+ : SpvStorageClassFunction;
// Gets the available basic and pointer types.
auto basic_type_ids_and_pointers =
@@ -128,13 +127,13 @@ void FuzzerPassPushIdsThroughVariables::Apply() {
GetIRContext()->get_def_use_mgr()->GetDef(basic_type_id);
assert(type_inst);
switch (type_inst->opcode()) {
- case spv::Op::OpTypeBool:
- case spv::Op::OpTypeFloat:
- case spv::Op::OpTypeInt:
- case spv::Op::OpTypeArray:
- case spv::Op::OpTypeMatrix:
- case spv::Op::OpTypeVector:
- case spv::Op::OpTypeStruct:
+ case SpvOpTypeBool:
+ case SpvOpTypeFloat:
+ case SpvOpTypeInt:
+ case SpvOpTypeArray:
+ case SpvOpTypeMatrix:
+ case SpvOpTypeVector:
+ case SpvOpTypeStruct:
break;
default:
return;
@@ -151,8 +150,7 @@ void FuzzerPassPushIdsThroughVariables::Apply() {
value_instructions)]
->result_id(),
GetFuzzerContext()->GetFreshId(), GetFuzzerContext()->GetFreshId(),
- uint32_t(variable_storage_class), initializer_id,
- instruction_descriptor));
+ variable_storage_class, initializer_id, instruction_descriptor));
});
}
diff --git a/source/fuzz/fuzzer_pass_replace_branches_from_dead_blocks_with_exits.cpp b/source/fuzz/fuzzer_pass_replace_branches_from_dead_blocks_with_exits.cpp
index 52c03818..995657cc 100644
--- a/source/fuzz/fuzzer_pass_replace_branches_from_dead_blocks_with_exits.cpp
+++ b/source/fuzz/fuzzer_pass_replace_branches_from_dead_blocks_with_exits.cpp
@@ -38,13 +38,13 @@ void FuzzerPassReplaceBranchesFromDeadBlocksWithExits::Apply() {
// to be executed with the Fragment execution model. We conservatively only
// allow OpKill if every entry point in the module has the Fragment execution
// model.
- auto fragment_execution_model_guaranteed = std::all_of(
- GetIRContext()->module()->entry_points().begin(),
- GetIRContext()->module()->entry_points().end(),
- [](const opt::Instruction& entry_point) -> bool {
- return spv::ExecutionModel(entry_point.GetSingleWordInOperand(0)) ==
- spv::ExecutionModel::Fragment;
- });
+ auto fragment_execution_model_guaranteed =
+ std::all_of(GetIRContext()->module()->entry_points().begin(),
+ GetIRContext()->module()->entry_points().end(),
+ [](const opt::Instruction& entry_point) -> bool {
+ return entry_point.GetSingleWordInOperand(0) ==
+ SpvExecutionModelFragment;
+ });
// Transformations of this type can disable one another. To avoid ordering
// bias, we therefore build a set of candidate transformations to apply, and
@@ -71,20 +71,20 @@ void FuzzerPassReplaceBranchesFromDeadBlocksWithExits::Apply() {
// Whether we can use OpKill depends on the execution model, and which of
// OpReturn and OpReturnValue we can use depends on the return type of the
// enclosing function.
- std::vector<spv::Op> opcodes = {spv::Op::OpUnreachable};
+ std::vector<SpvOp> opcodes = {SpvOpUnreachable};
if (fragment_execution_model_guaranteed) {
- opcodes.emplace_back(spv::Op::OpKill);
+ opcodes.emplace_back(SpvOpKill);
}
auto function_return_type =
GetIRContext()->get_type_mgr()->GetType(function.type_id());
if (function_return_type->AsVoid()) {
- opcodes.emplace_back(spv::Op::OpReturn);
+ opcodes.emplace_back(SpvOpReturn);
} else if (fuzzerutil::CanCreateConstant(GetIRContext(),
function.type_id())) {
// For simplicity we only allow OpReturnValue if the function return
// type is a type for which we can create a constant. This allows us a
// zero of the given type as a default return value.
- opcodes.emplace_back(spv::Op::OpReturnValue);
+ opcodes.emplace_back(SpvOpReturnValue);
}
// Choose one of the available terminator opcodes at random and create a
// candidate transformation.
@@ -92,7 +92,7 @@ void FuzzerPassReplaceBranchesFromDeadBlocksWithExits::Apply() {
candidate_transformations.emplace_back(
TransformationReplaceBranchFromDeadBlockWithExit(
block.id(), opcode,
- opcode == spv::Op::OpReturnValue
+ opcode == SpvOpReturnValue
? FindOrCreateZeroConstant(function.type_id(), true)
: 0));
}
diff --git a/source/fuzz/fuzzer_pass_replace_copy_memories_with_loads_stores.cpp b/source/fuzz/fuzzer_pass_replace_copy_memories_with_loads_stores.cpp
index aabc6bc3..af1aacee 100644
--- a/source/fuzz/fuzzer_pass_replace_copy_memories_with_loads_stores.cpp
+++ b/source/fuzz/fuzzer_pass_replace_copy_memories_with_loads_stores.cpp
@@ -41,7 +41,7 @@ void FuzzerPassReplaceCopyMemoriesWithLoadsStores::Apply() {
}
// The instruction must be OpCopyMemory.
- if (instruction->opcode() != spv::Op::OpCopyMemory) {
+ if (instruction->opcode() != SpvOpCopyMemory) {
return;
}
diff --git a/source/fuzz/fuzzer_pass_replace_copy_objects_with_stores_loads.cpp b/source/fuzz/fuzzer_pass_replace_copy_objects_with_stores_loads.cpp
index c1892be1..d0992a3f 100644
--- a/source/fuzz/fuzzer_pass_replace_copy_objects_with_stores_loads.cpp
+++ b/source/fuzz/fuzzer_pass_replace_copy_objects_with_stores_loads.cpp
@@ -40,7 +40,7 @@ void FuzzerPassReplaceCopyObjectsWithStoresLoads::Apply() {
return;
}
// The instruction must be OpCopyObject.
- if (instruction->opcode() != spv::Op::OpCopyObject) {
+ if (instruction->opcode() != SpvOpCopyObject) {
return;
}
// The opcode of the type_id instruction cannot be a OpTypePointer,
@@ -48,22 +48,21 @@ void FuzzerPassReplaceCopyObjectsWithStoresLoads::Apply() {
if (GetIRContext()
->get_def_use_mgr()
->GetDef(instruction->type_id())
- ->opcode() == spv::Op::OpTypePointer) {
+ ->opcode() == SpvOpTypePointer) {
return;
}
// It must be valid to insert OpStore and OpLoad instructions
// before the instruction OpCopyObject.
- if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(spv::Op::OpStore,
+ if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(SpvOpStore,
instruction) ||
- !fuzzerutil::CanInsertOpcodeBeforeInstruction(spv::Op::OpLoad,
- instruction)) {
+ !fuzzerutil::CanInsertOpcodeBeforeInstruction(SpvOpLoad, instruction)) {
return;
}
// Randomly decides whether a global or local variable will be added.
auto variable_storage_class = GetFuzzerContext()->ChooseEven()
- ? spv::StorageClass::Private
- : spv::StorageClass::Function;
+ ? SpvStorageClassPrivate
+ : SpvStorageClassFunction;
// Find or create a constant to initialize the variable from. The type of
// |instruction| must be such that the function FindOrCreateConstant can be
@@ -80,7 +79,7 @@ void FuzzerPassReplaceCopyObjectsWithStoresLoads::Apply() {
// Apply the transformation replacing OpCopyObject with Store and Load.
ApplyTransformation(TransformationReplaceCopyObjectWithStoreLoad(
instruction->result_id(), GetFuzzerContext()->GetFreshId(),
- uint32_t(variable_storage_class), variable_initializer_id));
+ variable_storage_class, variable_initializer_id));
});
}
diff --git a/source/fuzz/fuzzer_pass_replace_irrelevant_ids.cpp b/source/fuzz/fuzzer_pass_replace_irrelevant_ids.cpp
index 4c0bd859..4d55ae84 100644
--- a/source/fuzz/fuzzer_pass_replace_irrelevant_ids.cpp
+++ b/source/fuzz/fuzzer_pass_replace_irrelevant_ids.cpp
@@ -73,7 +73,7 @@ void FuzzerPassReplaceIrrelevantIds::Apply() {
// we cannot use these as replacements.
for (const auto& pair : GetIRContext()->get_def_use_mgr()->id_to_defs()) {
uint32_t type_id = pair.second->type_id();
- if (pair.second->opcode() != spv::Op::OpFunction && type_id &&
+ if (pair.second->opcode() != SpvOpFunction && type_id &&
types_to_ids.count(type_id)) {
types_to_ids[type_id].push_back(pair.first);
}
diff --git a/source/fuzz/fuzzer_pass_replace_loads_stores_with_copy_memories.cpp b/source/fuzz/fuzzer_pass_replace_loads_stores_with_copy_memories.cpp
index 8d292ac3..38ac048b 100644
--- a/source/fuzz/fuzzer_pass_replace_loads_stores_with_copy_memories.cpp
+++ b/source/fuzz/fuzzer_pass_replace_loads_stores_with_copy_memories.cpp
@@ -50,9 +50,9 @@ void FuzzerPassReplaceLoadsStoresWithCopyMemories::Apply() {
std::unordered_map<uint32_t, opt::Instruction*> current_op_loads;
for (auto& instruction : block) {
// Add a potential OpLoad instruction.
- if (instruction.opcode() == spv::Op::OpLoad) {
+ if (instruction.opcode() == SpvOpLoad) {
current_op_loads[instruction.result_id()] = &instruction;
- } else if (instruction.opcode() == spv::Op::OpStore) {
+ } else if (instruction.opcode() == SpvOpStore) {
if (current_op_loads.find(instruction.GetSingleWordOperand(1)) !=
current_op_loads.end()) {
// We have found the matching OpLoad instruction to the current
@@ -73,7 +73,7 @@ void FuzzerPassReplaceLoadsStoresWithCopyMemories::Apply() {
opt::Instruction* source_id =
GetIRContext()->get_def_use_mgr()->GetDef(
it->second->GetSingleWordOperand(2));
- spv::StorageClass storage_class =
+ SpvStorageClass storage_class =
fuzzerutil::GetStorageClassFromPointerType(
GetIRContext(), source_id->type_id());
if (!TransformationReplaceLoadStoreWithCopyMemory::
diff --git a/source/fuzz/fuzzer_pass_replace_opphi_ids_from_dead_predecessors.cpp b/source/fuzz/fuzzer_pass_replace_opphi_ids_from_dead_predecessors.cpp
index 26475ab2..ea90a7ac 100644
--- a/source/fuzz/fuzzer_pass_replace_opphi_ids_from_dead_predecessors.cpp
+++ b/source/fuzz/fuzzer_pass_replace_opphi_ids_from_dead_predecessors.cpp
@@ -50,7 +50,7 @@ void FuzzerPassReplaceOpPhiIdsFromDeadPredecessors::Apply() {
block->id(), [this, &function, block, &transformations](
opt::Instruction* instruction, uint32_t) {
// Only consider OpPhi instructions.
- if (instruction->opcode() != spv::Op::OpPhi) {
+ if (instruction->opcode() != SpvOpPhi) {
return;
}
diff --git a/source/fuzz/fuzzer_pass_replace_opselects_with_conditional_branches.cpp b/source/fuzz/fuzzer_pass_replace_opselects_with_conditional_branches.cpp
index 4691e0a8..72ed0936 100644
--- a/source/fuzz/fuzzer_pass_replace_opselects_with_conditional_branches.cpp
+++ b/source/fuzz/fuzzer_pass_replace_opselects_with_conditional_branches.cpp
@@ -52,7 +52,7 @@ void FuzzerPassReplaceOpSelectsWithConditionalBranches::Apply() {
for (auto& instruction : block) {
// We only care about OpSelect instructions.
- if (instruction.opcode() != spv::Op::OpSelect) {
+ if (instruction.opcode() != SpvOpSelect) {
continue;
}
@@ -69,7 +69,7 @@ void FuzzerPassReplaceOpSelectsWithConditionalBranches::Apply() {
->get_def_use_mgr()
->GetDef(fuzzerutil::GetTypeId(
GetIRContext(), instruction.GetSingleWordInOperand(0)))
- ->opcode() != spv::Op::OpTypeBool) {
+ ->opcode() != SpvOpTypeBool) {
continue;
}
@@ -136,7 +136,7 @@ void FuzzerPassReplaceOpSelectsWithConditionalBranches::Apply() {
bool FuzzerPassReplaceOpSelectsWithConditionalBranches::
InstructionNeedsSplitBefore(opt::Instruction* instruction) {
- assert(instruction && instruction->opcode() == spv::Op::OpSelect &&
+ assert(instruction && instruction->opcode() == SpvOpSelect &&
"The instruction must be OpSelect.");
auto block = GetIRContext()->get_instr_block(instruction);
@@ -163,7 +163,7 @@ bool FuzzerPassReplaceOpSelectsWithConditionalBranches::
auto predecessor = GetIRContext()->get_instr_block(
GetIRContext()->cfg()->preds(block->id())[0]);
return predecessor->MergeBlockIdIfAny() ||
- predecessor->terminator()->opcode() != spv::Op::OpBranch;
+ predecessor->terminator()->opcode() != SpvOpBranch;
}
} // namespace fuzz
diff --git a/source/fuzz/fuzzer_pass_replace_parameter_with_global.cpp b/source/fuzz/fuzzer_pass_replace_parameter_with_global.cpp
index d7eddca1..7fb7b0d2 100644
--- a/source/fuzz/fuzzer_pass_replace_parameter_with_global.cpp
+++ b/source/fuzz/fuzzer_pass_replace_parameter_with_global.cpp
@@ -72,8 +72,7 @@ void FuzzerPassReplaceParameterWithGlobal::Apply() {
assert(replaced_param && "Unable to find a parameter to replace");
// Make sure type id for the global variable exists in the module.
- FindOrCreatePointerType(replaced_param->type_id(),
- spv::StorageClass::Private);
+ FindOrCreatePointerType(replaced_param->type_id(), SpvStorageClassPrivate);
// Make sure initializer for the global variable exists in the module.
FindOrCreateZeroConstant(replaced_param->type_id(), false);
diff --git a/source/fuzz/fuzzer_pass_split_blocks.cpp b/source/fuzz/fuzzer_pass_split_blocks.cpp
index 5b4afcc5..40a4151d 100644
--- a/source/fuzz/fuzzer_pass_split_blocks.cpp
+++ b/source/fuzz/fuzzer_pass_split_blocks.cpp
@@ -65,7 +65,7 @@ void FuzzerPassSplitBlocks::Apply() {
// Counts the number of times we have seen each opcode since we reset the
// base instruction.
- std::map<spv::Op, uint32_t> skip_count;
+ std::map<SpvOp, uint32_t> skip_count;
// Consider every instruction in the block. The label is excluded: it is
// only necessary to consider it as a base in case the first instruction
@@ -78,7 +78,7 @@ void FuzzerPassSplitBlocks::Apply() {
base = inst.result_id();
skip_count.clear();
}
- const spv::Op opcode = inst.opcode();
+ const SpvOp opcode = inst.opcode();
instruction_descriptors.emplace_back(MakeInstructionDescriptor(
base, opcode, skip_count.count(opcode) ? skip_count.at(opcode) : 0));
if (!inst.HasResultId()) {
diff --git a/source/fuzz/fuzzer_pass_swap_conditional_branch_operands.cpp b/source/fuzz/fuzzer_pass_swap_conditional_branch_operands.cpp
index 72c8358a..f8bf111d 100644
--- a/source/fuzz/fuzzer_pass_swap_conditional_branch_operands.cpp
+++ b/source/fuzz/fuzzer_pass_swap_conditional_branch_operands.cpp
@@ -39,7 +39,7 @@ void FuzzerPassSwapBranchConditionalOperands::Apply() {
const protobufs::InstructionDescriptor& instruction_descriptor) {
const auto& inst = *inst_it;
- if (inst.opcode() != spv::Op::OpBranchConditional) {
+ if (inst.opcode() != SpvOpBranchConditional) {
return;
}
diff --git a/source/fuzz/fuzzer_pass_toggle_access_chain_instruction.cpp b/source/fuzz/fuzzer_pass_toggle_access_chain_instruction.cpp
index 2a1ad6e5..ac2b1565 100644
--- a/source/fuzz/fuzzer_pass_toggle_access_chain_instruction.cpp
+++ b/source/fuzz/fuzzer_pass_toggle_access_chain_instruction.cpp
@@ -36,9 +36,8 @@ void FuzzerPassToggleAccessChainInstruction::Apply() {
// probabilistically applied.
context->module()->ForEachInst([this,
context](opt::Instruction* instruction) {
- spv::Op opcode = instruction->opcode();
- if ((opcode == spv::Op::OpAccessChain ||
- opcode == spv::Op::OpInBoundsAccessChain) &&
+ SpvOp opcode = instruction->opcode();
+ if ((opcode == SpvOpAccessChain || opcode == SpvOpInBoundsAccessChain) &&
GetFuzzerContext()->ChoosePercentage(
GetFuzzerContext()->GetChanceOfTogglingAccessChainInstruction())) {
auto instructionDescriptor =
diff --git a/source/fuzz/fuzzer_pass_wrap_vector_synonym.cpp b/source/fuzz/fuzzer_pass_wrap_vector_synonym.cpp
index 55fbe2c2..35adcfec 100644
--- a/source/fuzz/fuzzer_pass_wrap_vector_synonym.cpp
+++ b/source/fuzz/fuzzer_pass_wrap_vector_synonym.cpp
@@ -52,7 +52,7 @@ void FuzzerPassWrapVectorSynonym::Apply() {
// It must be valid to insert an OpCompositeConstruct instruction
// before |instruction_iterator|.
if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(
- spv::Op::OpCompositeConstruct, instruction_iterator)) {
+ SpvOpCompositeConstruct, instruction_iterator)) {
return;
}
diff --git a/source/fuzz/fuzzer_util.cpp b/source/fuzz/fuzzer_util.cpp
index e85ff2fb..1d368a9f 100644
--- a/source/fuzz/fuzzer_util.cpp
+++ b/source/fuzz/fuzzer_util.cpp
@@ -49,7 +49,7 @@ uint32_t MaybeGetOpConstant(opt::IRContext* ir_context,
const std::vector<uint32_t>& words,
uint32_t type_id, bool is_irrelevant) {
for (const auto& inst : ir_context->types_values()) {
- if (inst.opcode() == spv::Op::OpConstant && inst.type_id() == type_id &&
+ if (inst.opcode() == SpvOpConstant && inst.type_id() == type_id &&
inst.GetInOperand(0).words == words &&
transformation_context.GetFactManager()->IdIsIrrelevant(
inst.result_id()) == is_irrelevant) {
@@ -112,7 +112,7 @@ opt::BasicBlock* MaybeFindBlock(opt::IRContext* context,
// No instruction defining this id was found.
return nullptr;
}
- if (inst->opcode() != spv::Op::OpLabel) {
+ if (inst->opcode() != SpvOpLabel) {
// The instruction defining the id is not a label, so it cannot be a block
// id.
return nullptr;
@@ -138,7 +138,7 @@ bool PhiIdsOkForNewEdge(
// makes sense here because we need to increment |phi_index| for each OpPhi
// instruction.
for (auto& inst : *bb_to) {
- if (inst.opcode() != spv::Op::OpPhi) {
+ if (inst.opcode() != SpvOpPhi) {
// The OpPhi instructions all occur at the start of the block; if we find
// a non-OpPhi then we have seen them all.
break;
@@ -189,24 +189,24 @@ opt::Instruction CreateUnreachableEdgeInstruction(opt::IRContext* ir_context,
const auto* bb_from = MaybeFindBlock(ir_context, bb_from_id);
assert(bb_from && "|bb_from_id| is invalid");
assert(MaybeFindBlock(ir_context, bb_to_id) && "|bb_to_id| is invalid");
- assert(bb_from->terminator()->opcode() == spv::Op::OpBranch &&
+ assert(bb_from->terminator()->opcode() == SpvOpBranch &&
"Precondition on terminator of bb_from is not satisfied");
// Get the id of the boolean constant to be used as the condition.
auto condition_inst = ir_context->get_def_use_mgr()->GetDef(bool_id);
assert(condition_inst &&
- (condition_inst->opcode() == spv::Op::OpConstantTrue ||
- condition_inst->opcode() == spv::Op::OpConstantFalse) &&
+ (condition_inst->opcode() == SpvOpConstantTrue ||
+ condition_inst->opcode() == SpvOpConstantFalse) &&
"|bool_id| is invalid");
- auto condition_value = condition_inst->opcode() == spv::Op::OpConstantTrue;
+ auto condition_value = condition_inst->opcode() == SpvOpConstantTrue;
auto successor_id = bb_from->terminator()->GetSingleWordInOperand(0);
// Add the dead branch, by turning OpBranch into OpBranchConditional, and
// ordering the targets depending on whether the given boolean corresponds to
// true or false.
return opt::Instruction(
- ir_context, spv::Op::OpBranchConditional, 0, 0,
+ ir_context, SpvOpBranchConditional, 0, 0,
{{SPV_OPERAND_TYPE_ID, {bool_id}},
{SPV_OPERAND_TYPE_ID, {condition_value ? successor_id : bb_to_id}},
{SPV_OPERAND_TYPE_ID, {condition_value ? bb_to_id : successor_id}}});
@@ -228,7 +228,7 @@ void AddUnreachableEdgeAndUpdateOpPhis(
if (!from_to_edge_already_exists) {
uint32_t phi_index = 0;
for (auto& inst : *bb_to) {
- if (inst.opcode() != spv::Op::OpPhi) {
+ if (inst.opcode() != SpvOpPhi) {
break;
}
assert(phi_index < static_cast<uint32_t>(phi_ids.size()) &&
@@ -285,30 +285,28 @@ opt::BasicBlock::iterator GetIteratorForInstruction(
}
bool CanInsertOpcodeBeforeInstruction(
- spv::Op opcode, const opt::BasicBlock::iterator& instruction_in_block) {
+ SpvOp opcode, const opt::BasicBlock::iterator& instruction_in_block) {
if (instruction_in_block->PreviousNode() &&
- (instruction_in_block->PreviousNode()->opcode() == spv::Op::OpLoopMerge ||
- instruction_in_block->PreviousNode()->opcode() ==
- spv::Op::OpSelectionMerge)) {
+ (instruction_in_block->PreviousNode()->opcode() == SpvOpLoopMerge ||
+ instruction_in_block->PreviousNode()->opcode() == SpvOpSelectionMerge)) {
// We cannot insert directly after a merge instruction.
return false;
}
- if (opcode != spv::Op::OpVariable &&
- instruction_in_block->opcode() == spv::Op::OpVariable) {
+ if (opcode != SpvOpVariable &&
+ instruction_in_block->opcode() == SpvOpVariable) {
// We cannot insert a non-OpVariable instruction directly before a
// variable; variables in a function must be contiguous in the entry block.
return false;
}
// We cannot insert a non-OpPhi instruction directly before an OpPhi, because
// OpPhi instructions need to be contiguous at the start of a block.
- return opcode == spv::Op::OpPhi ||
- instruction_in_block->opcode() != spv::Op::OpPhi;
+ return opcode == SpvOpPhi || instruction_in_block->opcode() != SpvOpPhi;
}
bool CanMakeSynonymOf(opt::IRContext* ir_context,
const TransformationContext& transformation_context,
const opt::Instruction& inst) {
- if (inst.opcode() == spv::Op::OpSampledImage) {
+ if (inst.opcode() == SpvOpSampledImage) {
// The SPIR-V data rules say that only very specific instructions may
// may consume the result id of an OpSampledImage, and this excludes the
// instructions that are used for making synonyms.
@@ -328,15 +326,15 @@ bool CanMakeSynonymOf(opt::IRContext* ir_context,
return false;
}
auto type_inst = ir_context->get_def_use_mgr()->GetDef(inst.type_id());
- if (type_inst->opcode() == spv::Op::OpTypeVoid) {
+ if (type_inst->opcode() == SpvOpTypeVoid) {
// We only make synonyms of instructions that define objects, and an object
// cannot have void type.
return false;
}
- if (type_inst->opcode() == spv::Op::OpTypePointer) {
+ if (type_inst->opcode() == SpvOpTypePointer) {
switch (inst.opcode()) {
- case spv::Op::OpConstantNull:
- case spv::Op::OpUndef:
+ case SpvOpConstantNull:
+ case SpvOpUndef:
// We disallow making synonyms of null or undefined pointers. This is
// to provide the property that if the original shader exhibited no bad
// pointer accesses, the transformed shader will not either.
@@ -375,22 +373,22 @@ uint32_t WalkOneCompositeTypeIndex(opt::IRContext* context,
context->get_def_use_mgr()->GetDef(base_object_type_id);
assert(should_be_composite_type && "The type should exist.");
switch (should_be_composite_type->opcode()) {
- case spv::Op::OpTypeArray: {
+ case SpvOpTypeArray: {
auto array_length = GetArraySize(*should_be_composite_type, context);
if (array_length == 0 || index >= array_length) {
return 0;
}
return should_be_composite_type->GetSingleWordInOperand(0);
}
- case spv::Op::OpTypeMatrix:
- case spv::Op::OpTypeVector: {
+ case SpvOpTypeMatrix:
+ case SpvOpTypeVector: {
auto count = should_be_composite_type->GetSingleWordInOperand(1);
if (index >= count) {
return 0;
}
return should_be_composite_type->GetSingleWordInOperand(0);
}
- case spv::Op::OpTypeStruct: {
+ case SpvOpTypeStruct: {
if (index >= GetNumberOfStructMembers(*should_be_composite_type)) {
return 0;
}
@@ -417,7 +415,7 @@ uint32_t WalkCompositeTypeIndices(
uint32_t GetNumberOfStructMembers(
const opt::Instruction& struct_type_instruction) {
- assert(struct_type_instruction.opcode() == spv::Op::OpTypeStruct &&
+ assert(struct_type_instruction.opcode() == SpvOpTypeStruct &&
"An OpTypeStruct instruction is required here.");
return struct_type_instruction.NumInOperands();
}
@@ -438,15 +436,15 @@ uint32_t GetArraySize(const opt::Instruction& array_type_instruction,
uint32_t GetBoundForCompositeIndex(const opt::Instruction& composite_type_inst,
opt::IRContext* ir_context) {
switch (composite_type_inst.opcode()) {
- case spv::Op::OpTypeArray:
+ case SpvOpTypeArray:
return fuzzerutil::GetArraySize(composite_type_inst, ir_context);
- case spv::Op::OpTypeMatrix:
- case spv::Op::OpTypeVector:
+ case SpvOpTypeMatrix:
+ case SpvOpTypeVector:
return composite_type_inst.GetSingleWordInOperand(1);
- case spv::Op::OpTypeStruct: {
+ case SpvOpTypeStruct: {
return fuzzerutil::GetNumberOfStructMembers(composite_type_inst);
}
- case spv::Op::OpTypeRuntimeArray:
+ case SpvOpTypeRuntimeArray:
assert(false &&
"GetBoundForCompositeIndex should not be invoked with an "
"OpTypeRuntimeArray, which does not have a static bound.");
@@ -457,27 +455,27 @@ uint32_t GetBoundForCompositeIndex(const opt::Instruction& composite_type_inst,
}
}
-spv::MemorySemanticsMask GetMemorySemanticsForStorageClass(
- spv::StorageClass storage_class) {
+SpvMemorySemanticsMask GetMemorySemanticsForStorageClass(
+ SpvStorageClass storage_class) {
switch (storage_class) {
- case spv::StorageClass::Workgroup:
- return spv::MemorySemanticsMask::WorkgroupMemory;
+ case SpvStorageClassWorkgroup:
+ return SpvMemorySemanticsWorkgroupMemoryMask;
- case spv::StorageClass::StorageBuffer:
- case spv::StorageClass::PhysicalStorageBuffer:
- return spv::MemorySemanticsMask::UniformMemory;
+ case SpvStorageClassStorageBuffer:
+ case SpvStorageClassPhysicalStorageBuffer:
+ return SpvMemorySemanticsUniformMemoryMask;
- case spv::StorageClass::CrossWorkgroup:
- return spv::MemorySemanticsMask::CrossWorkgroupMemory;
+ case SpvStorageClassCrossWorkgroup:
+ return SpvMemorySemanticsCrossWorkgroupMemoryMask;
- case spv::StorageClass::AtomicCounter:
- return spv::MemorySemanticsMask::AtomicCounterMemory;
+ case SpvStorageClassAtomicCounter:
+ return SpvMemorySemanticsAtomicCounterMemoryMask;
- case spv::StorageClass::Image:
- return spv::MemorySemanticsMask::ImageMemory;
+ case SpvStorageClassImage:
+ return SpvMemorySemanticsImageMemoryMask;
default:
- return spv::MemorySemanticsMask::MaskNone;
+ return SpvMemorySemanticsMaskNone;
}
}
@@ -564,8 +562,8 @@ bool IsMergeOrContinue(opt::IRContext* ir_context, uint32_t block_id) {
[&result](const opt::Instruction* use_instruction,
uint32_t /*unused*/) -> bool {
switch (use_instruction->opcode()) {
- case spv::Op::OpLoopMerge:
- case spv::Op::OpSelectionMerge:
+ case SpvOpLoopMerge:
+ case SpvOpSelectionMerge:
result = true;
return false;
default:
@@ -583,7 +581,7 @@ uint32_t GetLoopFromMergeBlock(opt::IRContext* ir_context,
[ir_context, &result](opt::Instruction* use_instruction,
uint32_t use_index) -> bool {
switch (use_instruction->opcode()) {
- case spv::Op::OpLoopMerge:
+ case SpvOpLoopMerge:
// The merge block operand is the first operand in OpLoopMerge.
if (use_index == 0) {
result = ir_context->get_instr_block(use_instruction)->id();
@@ -601,7 +599,7 @@ uint32_t FindFunctionType(opt::IRContext* ir_context,
const std::vector<uint32_t>& type_ids) {
// Look through the existing types for a match.
for (auto& type_or_value : ir_context->types_values()) {
- if (type_or_value.opcode() != spv::Op::OpTypeFunction) {
+ if (type_or_value.opcode() != SpvOpTypeFunction) {
// We are only interested in function types.
continue;
}
@@ -643,8 +641,8 @@ opt::Function* FindFunction(opt::IRContext* ir_context, uint32_t function_id) {
bool FunctionContainsOpKillOrUnreachable(const opt::Function& function) {
for (auto& block : function) {
- if (block.terminator()->opcode() == spv::Op::OpKill ||
- block.terminator()->opcode() == spv::Op::OpUnreachable) {
+ if (block.terminator()->opcode() == SpvOpKill ||
+ block.terminator()->opcode() == SpvOpUnreachable) {
return true;
}
}
@@ -671,7 +669,7 @@ bool IdIsAvailableAtUse(opt::IRContext* context,
context->get_instr_block(use_instruction)->GetParent();
// If the id a function parameter, it needs to be associated with the
// function containing the use.
- if (defining_instruction->opcode() == spv::Op::OpFunctionParameter) {
+ if (defining_instruction->opcode() == SpvOpFunctionParameter) {
return InstructionIsFunctionParameter(defining_instruction,
enclosing_function);
}
@@ -689,7 +687,7 @@ bool IdIsAvailableAtUse(opt::IRContext* context,
return false;
}
auto dominator_analysis = context->GetDominatorAnalysis(enclosing_function);
- if (use_instruction->opcode() == spv::Op::OpPhi) {
+ if (use_instruction->opcode() == SpvOpPhi) {
// In the case where the use is an operand to OpPhi, it is actually the
// *parent* block associated with the operand that must be dominated by
// the synonym.
@@ -712,7 +710,7 @@ bool IdIsAvailableBeforeInstruction(opt::IRContext* context,
context->get_instr_block(instruction)->GetParent();
// If the id a function parameter, it needs to be associated with the
// function containing the instruction.
- if (id_definition->opcode() == spv::Op::OpFunctionParameter) {
+ if (id_definition->opcode() == SpvOpFunctionParameter) {
return InstructionIsFunctionParameter(id_definition,
function_enclosing_instruction);
}
@@ -734,7 +732,7 @@ bool IdIsAvailableBeforeInstruction(opt::IRContext* context,
// the instruction.
return true;
}
- if (id_definition->opcode() == spv::Op::OpVariable &&
+ if (id_definition->opcode() == SpvOpVariable &&
function_enclosing_instruction ==
context->get_instr_block(id)->GetParent()) {
assert(!context->IsReachable(*context->get_instr_block(instruction)) &&
@@ -749,7 +747,7 @@ bool IdIsAvailableBeforeInstruction(opt::IRContext* context,
bool InstructionIsFunctionParameter(opt::Instruction* instruction,
opt::Function* function) {
- if (instruction->opcode() != spv::Op::OpFunctionParameter) {
+ if (instruction->opcode() != SpvOpFunctionParameter) {
return false;
}
bool found_parameter = false;
@@ -769,8 +767,7 @@ uint32_t GetTypeId(opt::IRContext* context, uint32_t result_id) {
}
uint32_t GetPointeeTypeIdFromPointerType(opt::Instruction* pointer_type_inst) {
- assert(pointer_type_inst &&
- pointer_type_inst->opcode() == spv::Op::OpTypePointer &&
+ assert(pointer_type_inst && pointer_type_inst->opcode() == SpvOpTypePointer &&
"Precondition: |pointer_type_inst| must be OpTypePointer.");
return pointer_type_inst->GetSingleWordInOperand(1);
}
@@ -781,28 +778,26 @@ uint32_t GetPointeeTypeIdFromPointerType(opt::IRContext* context,
context->get_def_use_mgr()->GetDef(pointer_type_id));
}
-spv::StorageClass GetStorageClassFromPointerType(
+SpvStorageClass GetStorageClassFromPointerType(
opt::Instruction* pointer_type_inst) {
- assert(pointer_type_inst &&
- pointer_type_inst->opcode() == spv::Op::OpTypePointer &&
+ assert(pointer_type_inst && pointer_type_inst->opcode() == SpvOpTypePointer &&
"Precondition: |pointer_type_inst| must be OpTypePointer.");
- return static_cast<spv::StorageClass>(
+ return static_cast<SpvStorageClass>(
pointer_type_inst->GetSingleWordInOperand(0));
}
-spv::StorageClass GetStorageClassFromPointerType(opt::IRContext* context,
- uint32_t pointer_type_id) {
+SpvStorageClass GetStorageClassFromPointerType(opt::IRContext* context,
+ uint32_t pointer_type_id) {
return GetStorageClassFromPointerType(
context->get_def_use_mgr()->GetDef(pointer_type_id));
}
uint32_t MaybeGetPointerType(opt::IRContext* context, uint32_t pointee_type_id,
- spv::StorageClass storage_class) {
+ SpvStorageClass storage_class) {
for (auto& inst : context->types_values()) {
switch (inst.opcode()) {
- case spv::Op::OpTypePointer:
- if (spv::StorageClass(inst.GetSingleWordInOperand(0)) ==
- storage_class &&
+ case SpvOpTypePointer:
+ if (inst.GetSingleWordInOperand(0) == storage_class &&
inst.GetSingleWordInOperand(1) == pointee_type_id) {
return inst.result_id();
}
@@ -823,30 +818,30 @@ uint32_t InOperandIndexFromOperandIndex(const opt::Instruction& inst,
bool IsNullConstantSupported(opt::IRContext* ir_context,
const opt::Instruction& type_inst) {
switch (type_inst.opcode()) {
- case spv::Op::OpTypeArray:
- case spv::Op::OpTypeBool:
- case spv::Op::OpTypeDeviceEvent:
- case spv::Op::OpTypeEvent:
- case spv::Op::OpTypeFloat:
- case spv::Op::OpTypeInt:
- case spv::Op::OpTypeMatrix:
- case spv::Op::OpTypeQueue:
- case spv::Op::OpTypeReserveId:
- case spv::Op::OpTypeVector:
- case spv::Op::OpTypeStruct:
+ case SpvOpTypeArray:
+ case SpvOpTypeBool:
+ case SpvOpTypeDeviceEvent:
+ case SpvOpTypeEvent:
+ case SpvOpTypeFloat:
+ case SpvOpTypeInt:
+ case SpvOpTypeMatrix:
+ case SpvOpTypeQueue:
+ case SpvOpTypeReserveId:
+ case SpvOpTypeVector:
+ case SpvOpTypeStruct:
return true;
- case spv::Op::OpTypePointer:
+ case SpvOpTypePointer:
// Null pointers are allowed if the VariablePointers capability is
// enabled, or if the VariablePointersStorageBuffer capability is enabled
// and the pointer type has StorageBuffer as its storage class.
if (ir_context->get_feature_mgr()->HasCapability(
- spv::Capability::VariablePointers)) {
+ SpvCapabilityVariablePointers)) {
return true;
}
if (ir_context->get_feature_mgr()->HasCapability(
- spv::Capability::VariablePointersStorageBuffer)) {
- return spv::StorageClass(type_inst.GetSingleWordInOperand(0)) ==
- spv::StorageClass::StorageBuffer;
+ SpvCapabilityVariablePointersStorageBuffer)) {
+ return type_inst.GetSingleWordInOperand(0) ==
+ SpvStorageClassStorageBuffer;
}
return false;
default:
@@ -890,22 +885,22 @@ void AddVariableIdToEntryPointInterfaces(opt::IRContext* context, uint32_t id) {
opt::Instruction* AddGlobalVariable(opt::IRContext* context, uint32_t result_id,
uint32_t type_id,
- spv::StorageClass storage_class,
+ SpvStorageClass storage_class,
uint32_t initializer_id) {
// Check various preconditions.
assert(result_id != 0 && "Result id can't be 0");
- assert((storage_class == spv::StorageClass::Private ||
- storage_class == spv::StorageClass::Workgroup) &&
+ assert((storage_class == SpvStorageClassPrivate ||
+ storage_class == SpvStorageClassWorkgroup) &&
"Variable's storage class must be either Private or Workgroup");
auto* type_inst = context->get_def_use_mgr()->GetDef(type_id);
(void)type_inst; // Variable becomes unused in release mode.
- assert(type_inst && type_inst->opcode() == spv::Op::OpTypePointer &&
+ assert(type_inst && type_inst->opcode() == SpvOpTypePointer &&
GetStorageClassFromPointerType(type_inst) == storage_class &&
"Variable's type is invalid");
- if (storage_class == spv::StorageClass::Workgroup) {
+ if (storage_class == SpvStorageClassWorkgroup) {
assert(initializer_id == 0);
}
@@ -927,7 +922,7 @@ opt::Instruction* AddGlobalVariable(opt::IRContext* context, uint32_t result_id,
}
auto new_instruction = MakeUnique<opt::Instruction>(
- context, spv::Op::OpVariable, type_id, result_id, std::move(operands));
+ context, SpvOpVariable, type_id, result_id, std::move(operands));
auto result = new_instruction.get();
context->module()->AddGlobalValue(std::move(new_instruction));
@@ -945,9 +940,8 @@ opt::Instruction* AddLocalVariable(opt::IRContext* context, uint32_t result_id,
auto* type_inst = context->get_def_use_mgr()->GetDef(type_id);
(void)type_inst; // Variable becomes unused in release mode.
- assert(type_inst && type_inst->opcode() == spv::Op::OpTypePointer &&
- GetStorageClassFromPointerType(type_inst) ==
- spv::StorageClass::Function &&
+ assert(type_inst && type_inst->opcode() == SpvOpTypePointer &&
+ GetStorageClassFromPointerType(type_inst) == SpvStorageClassFunction &&
"Variable's type is invalid");
const auto* constant_inst =
@@ -962,10 +956,10 @@ opt::Instruction* AddLocalVariable(opt::IRContext* context, uint32_t result_id,
assert(function && "Function id is invalid");
auto new_instruction = MakeUnique<opt::Instruction>(
- context, spv::Op::OpVariable, type_id, result_id,
- opt::Instruction::OperandList{{SPV_OPERAND_TYPE_STORAGE_CLASS,
- {uint32_t(spv::StorageClass::Function)}},
- {SPV_OPERAND_TYPE_ID, {initializer_id}}});
+ context, SpvOpVariable, type_id, result_id,
+ opt::Instruction::OperandList{
+ {SPV_OPERAND_TYPE_STORAGE_CLASS, {SpvStorageClassFunction}},
+ {SPV_OPERAND_TYPE_ID, {initializer_id}}});
auto result = new_instruction.get();
function->begin()->begin()->InsertBefore(std::move(new_instruction));
@@ -1028,7 +1022,7 @@ std::vector<opt::Instruction*> GetCallers(opt::IRContext* ir_context,
std::vector<opt::Instruction*> result;
ir_context->get_def_use_mgr()->ForEachUser(
function_id, [&result, function_id](opt::Instruction* inst) {
- if (inst->opcode() == spv::Op::OpFunctionCall &&
+ if (inst->opcode() == SpvOpFunctionCall &&
inst->GetSingleWordInOperand(0) == function_id) {
result.push_back(inst);
}
@@ -1143,7 +1137,7 @@ void AddFunctionType(opt::IRContext* ir_context, uint32_t result_id,
}
ir_context->AddType(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpTypeFunction, 0, result_id, std::move(operands)));
+ ir_context, SpvOpTypeFunction, 0, result_id, std::move(operands)));
UpdateModuleIdBound(ir_context, result_id);
}
@@ -1192,7 +1186,7 @@ uint32_t MaybeGetVectorType(opt::IRContext* ir_context,
uint32_t MaybeGetStructType(opt::IRContext* ir_context,
const std::vector<uint32_t>& component_type_ids) {
for (auto& type_or_value : ir_context->types_values()) {
- if (type_or_value.opcode() != spv::Op::OpTypeStruct ||
+ if (type_or_value.opcode() != SpvOpTypeStruct ||
type_or_value.NumInOperands() !=
static_cast<uint32_t>(component_type_ids.size())) {
continue;
@@ -1225,11 +1219,11 @@ uint32_t MaybeGetZeroConstant(
assert(type_inst && "|scalar_or_composite_type_id| is invalid");
switch (type_inst->opcode()) {
- case spv::Op::OpTypeBool:
+ case SpvOpTypeBool:
return MaybeGetBoolConstant(ir_context, transformation_context, false,
is_irrelevant);
- case spv::Op::OpTypeFloat:
- case spv::Op::OpTypeInt: {
+ case SpvOpTypeFloat:
+ case SpvOpTypeInt: {
const auto width = type_inst->GetSingleWordInOperand(0);
std::vector<uint32_t> words = {0};
if (width > 32) {
@@ -1239,7 +1233,7 @@ uint32_t MaybeGetZeroConstant(
return MaybeGetScalarConstant(ir_context, transformation_context, words,
scalar_or_composite_type_id, is_irrelevant);
}
- case spv::Op::OpTypeStruct: {
+ case SpvOpTypeStruct: {
std::vector<uint32_t> component_ids;
for (uint32_t i = 0; i < type_inst->NumInOperands(); ++i) {
const auto component_type_id = type_inst->GetSingleWordInOperand(i);
@@ -1266,8 +1260,8 @@ uint32_t MaybeGetZeroConstant(
ir_context, transformation_context, component_ids,
scalar_or_composite_type_id, is_irrelevant);
}
- case spv::Op::OpTypeMatrix:
- case spv::Op::OpTypeVector: {
+ case SpvOpTypeMatrix:
+ case SpvOpTypeVector: {
const auto component_type_id = type_inst->GetSingleWordInOperand(0);
auto component_id = MaybeGetZeroConstant(
@@ -1290,7 +1284,7 @@ uint32_t MaybeGetZeroConstant(
std::vector<uint32_t>(component_count, component_id),
scalar_or_composite_type_id, is_irrelevant);
}
- case spv::Op::OpTypeArray: {
+ case SpvOpTypeArray: {
const auto component_type_id = type_inst->GetSingleWordInOperand(0);
auto component_id = MaybeGetZeroConstant(
@@ -1325,16 +1319,16 @@ bool CanCreateConstant(opt::IRContext* ir_context, uint32_t type_id) {
assert(spvOpcodeGeneratesType(type_instr->opcode()) &&
"A type-generating opcode was expected.");
switch (type_instr->opcode()) {
- case spv::Op::OpTypeBool:
- case spv::Op::OpTypeInt:
- case spv::Op::OpTypeFloat:
- case spv::Op::OpTypeMatrix:
- case spv::Op::OpTypeVector:
+ case SpvOpTypeBool:
+ case SpvOpTypeInt:
+ case SpvOpTypeFloat:
+ case SpvOpTypeMatrix:
+ case SpvOpTypeVector:
return true;
- case spv::Op::OpTypeArray:
+ case SpvOpTypeArray:
return CanCreateConstant(ir_context,
type_instr->GetSingleWordInOperand(0));
- case spv::Op::OpTypeStruct:
+ case SpvOpTypeStruct:
if (HasBlockOrBufferBlockDecoration(ir_context, type_id)) {
return false;
}
@@ -1383,7 +1377,7 @@ uint32_t MaybeGetCompositeConstant(
assert(IsCompositeType(type) && "|composite_type_id| is invalid");
for (const auto& inst : ir_context->types_values()) {
- if (inst.opcode() == spv::Op::OpConstantComposite &&
+ if (inst.opcode() == SpvOpConstantComposite &&
inst.type_id() == composite_type_id &&
transformation_context.GetFactManager()->IdIsIrrelevant(
inst.result_id()) == is_irrelevant &&
@@ -1463,8 +1457,7 @@ uint32_t MaybeGetBoolConstant(
bool is_irrelevant) {
if (auto type_id = MaybeGetBoolType(ir_context)) {
for (const auto& inst : ir_context->types_values()) {
- if (inst.opcode() ==
- (value ? spv::Op::OpConstantTrue : spv::Op::OpConstantFalse) &&
+ if (inst.opcode() == (value ? SpvOpConstantTrue : SpvOpConstantFalse) &&
inst.type_id() == type_id &&
transformation_context.GetFactManager()->IdIsIrrelevant(
inst.result_id()) == is_irrelevant) {
@@ -1559,13 +1552,13 @@ MapToRepeatedUInt32Pair(const std::map<uint32_t, uint32_t>& data) {
opt::Instruction* GetLastInsertBeforeInstruction(opt::IRContext* ir_context,
uint32_t block_id,
- spv::Op opcode) {
+ SpvOp opcode) {
// CFG::block uses std::map::at which throws an exception when |block_id| is
// invalid. The error message is unhelpful, though. Thus, we test that
// |block_id| is valid here.
const auto* label_inst = ir_context->get_def_use_mgr()->GetDef(block_id);
(void)label_inst; // Make compilers happy in release mode.
- assert(label_inst && label_inst->opcode() == spv::Op::OpLabel &&
+ assert(label_inst && label_inst->opcode() == SpvOpLabel &&
"|block_id| is invalid");
auto* block = ir_context->cfg()->block(block_id);
@@ -1631,7 +1624,7 @@ bool IdUseCanBeReplaced(opt::IRContext* ir_context,
assert(composite_type_being_accessed->AsStruct());
auto constant_index_instruction = ir_context->get_def_use_mgr()->GetDef(
use_instruction->GetSingleWordInOperand(index_in_operand));
- assert(constant_index_instruction->opcode() == spv::Op::OpConstant);
+ assert(constant_index_instruction->opcode() == SpvOpConstant);
uint32_t member_index =
constant_index_instruction->GetSingleWordInOperand(0);
composite_type_being_accessed =
@@ -1648,7 +1641,7 @@ bool IdUseCanBeReplaced(opt::IRContext* ir_context,
}
}
- if (use_instruction->opcode() == spv::Op::OpFunctionCall &&
+ if (use_instruction->opcode() == SpvOpFunctionCall &&
use_in_operand_index > 0) {
// This is a function call argument. It is not allowed to have pointer
// type.
@@ -1670,7 +1663,7 @@ bool IdUseCanBeReplaced(opt::IRContext* ir_context,
}
}
- if (use_instruction->opcode() == spv::Op::OpImageTexelPointer &&
+ if (use_instruction->opcode() == SpvOpImageTexelPointer &&
use_in_operand_index == 2) {
// The OpImageTexelPointer instruction has a Sample parameter that in some
// situations must be an id for the value 0. To guard against disrupting
@@ -1678,38 +1671,38 @@ bool IdUseCanBeReplaced(opt::IRContext* ir_context,
return false;
}
- if (ir_context->get_feature_mgr()->HasCapability(spv::Capability::Shader)) {
+ if (ir_context->get_feature_mgr()->HasCapability(SpvCapabilityShader)) {
// With the Shader capability, memory scope and memory semantics operands
// are required to be constants, so they cannot be replaced arbitrarily.
switch (use_instruction->opcode()) {
- case spv::Op::OpAtomicLoad:
- case spv::Op::OpAtomicStore:
- case spv::Op::OpAtomicExchange:
- case spv::Op::OpAtomicIIncrement:
- case spv::Op::OpAtomicIDecrement:
- case spv::Op::OpAtomicIAdd:
- case spv::Op::OpAtomicISub:
- case spv::Op::OpAtomicSMin:
- case spv::Op::OpAtomicUMin:
- case spv::Op::OpAtomicSMax:
- case spv::Op::OpAtomicUMax:
- case spv::Op::OpAtomicAnd:
- case spv::Op::OpAtomicOr:
- case spv::Op::OpAtomicXor:
+ case SpvOpAtomicLoad:
+ case SpvOpAtomicStore:
+ case SpvOpAtomicExchange:
+ case SpvOpAtomicIIncrement:
+ case SpvOpAtomicIDecrement:
+ case SpvOpAtomicIAdd:
+ case SpvOpAtomicISub:
+ case SpvOpAtomicSMin:
+ case SpvOpAtomicUMin:
+ case SpvOpAtomicSMax:
+ case SpvOpAtomicUMax:
+ case SpvOpAtomicAnd:
+ case SpvOpAtomicOr:
+ case SpvOpAtomicXor:
if (use_in_operand_index == 1 || use_in_operand_index == 2) {
return false;
}
break;
- case spv::Op::OpAtomicCompareExchange:
+ case SpvOpAtomicCompareExchange:
if (use_in_operand_index == 1 || use_in_operand_index == 2 ||
use_in_operand_index == 3) {
return false;
}
break;
- case spv::Op::OpAtomicCompareExchangeWeak:
- case spv::Op::OpAtomicFlagTestAndSet:
- case spv::Op::OpAtomicFlagClear:
- case spv::Op::OpAtomicFAddEXT:
+ case SpvOpAtomicCompareExchangeWeak:
+ case SpvOpAtomicFlagTestAndSet:
+ case SpvOpAtomicFlagClear:
+ case SpvOpAtomicFAddEXT:
assert(false && "Not allowed with the Shader capability.");
default:
break;
@@ -1722,17 +1715,17 @@ bool IdUseCanBeReplaced(opt::IRContext* ir_context,
bool MembersHaveBuiltInDecoration(opt::IRContext* ir_context,
uint32_t struct_type_id) {
const auto* type_inst = ir_context->get_def_use_mgr()->GetDef(struct_type_id);
- assert(type_inst && type_inst->opcode() == spv::Op::OpTypeStruct &&
+ assert(type_inst && type_inst->opcode() == SpvOpTypeStruct &&
"|struct_type_id| is not a result id of an OpTypeStruct");
uint32_t builtin_count = 0;
ir_context->get_def_use_mgr()->ForEachUser(
type_inst,
[struct_type_id, &builtin_count](const opt::Instruction* user) {
- if (user->opcode() == spv::Op::OpMemberDecorate &&
+ if (user->opcode() == SpvOpMemberDecorate &&
user->GetSingleWordInOperand(0) == struct_type_id &&
- static_cast<spv::Decoration>(user->GetSingleWordInOperand(2)) ==
- spv::Decoration::BuiltIn) {
+ static_cast<SpvDecoration>(user->GetSingleWordInOperand(2)) ==
+ SpvDecorationBuiltIn) {
++builtin_count;
}
});
@@ -1745,11 +1738,9 @@ bool MembersHaveBuiltInDecoration(opt::IRContext* ir_context,
}
bool HasBlockOrBufferBlockDecoration(opt::IRContext* ir_context, uint32_t id) {
- for (auto decoration :
- {spv::Decoration::Block, spv::Decoration::BufferBlock}) {
+ for (auto decoration : {SpvDecorationBlock, SpvDecorationBufferBlock}) {
if (!ir_context->get_decoration_mgr()->WhileEachDecoration(
- id, uint32_t(decoration),
- [](const opt::Instruction & /*unused*/) -> bool {
+ id, decoration, [](const opt::Instruction & /*unused*/) -> bool {
return false;
})) {
return true;
@@ -1771,7 +1762,7 @@ bool SplittingBeforeInstructionSeparatesOpSampledImageDefinitionFromUse(
if (before_split) {
// If the instruction comes before the split and its opcode is
// OpSampledImage, record its result id.
- if (instruction.opcode() == spv::Op::OpSampledImage) {
+ if (instruction.opcode() == SpvOpSampledImage) {
sampled_image_result_ids.insert(instruction.result_id());
}
} else {
@@ -1793,110 +1784,110 @@ bool SplittingBeforeInstructionSeparatesOpSampledImageDefinitionFromUse(
bool InstructionHasNoSideEffects(const opt::Instruction& instruction) {
switch (instruction.opcode()) {
- case spv::Op::OpUndef:
- case spv::Op::OpAccessChain:
- case spv::Op::OpInBoundsAccessChain:
- case spv::Op::OpArrayLength:
- case spv::Op::OpVectorExtractDynamic:
- case spv::Op::OpVectorInsertDynamic:
- case spv::Op::OpVectorShuffle:
- case spv::Op::OpCompositeConstruct:
- case spv::Op::OpCompositeExtract:
- case spv::Op::OpCompositeInsert:
- case spv::Op::OpCopyObject:
- case spv::Op::OpTranspose:
- case spv::Op::OpConvertFToU:
- case spv::Op::OpConvertFToS:
- case spv::Op::OpConvertSToF:
- case spv::Op::OpConvertUToF:
- case spv::Op::OpUConvert:
- case spv::Op::OpSConvert:
- case spv::Op::OpFConvert:
- case spv::Op::OpQuantizeToF16:
- case spv::Op::OpSatConvertSToU:
- case spv::Op::OpSatConvertUToS:
- case spv::Op::OpBitcast:
- case spv::Op::OpSNegate:
- case spv::Op::OpFNegate:
- case spv::Op::OpIAdd:
- case spv::Op::OpFAdd:
- case spv::Op::OpISub:
- case spv::Op::OpFSub:
- case spv::Op::OpIMul:
- case spv::Op::OpFMul:
- case spv::Op::OpUDiv:
- case spv::Op::OpSDiv:
- case spv::Op::OpFDiv:
- case spv::Op::OpUMod:
- case spv::Op::OpSRem:
- case spv::Op::OpSMod:
- case spv::Op::OpFRem:
- case spv::Op::OpFMod:
- case spv::Op::OpVectorTimesScalar:
- case spv::Op::OpMatrixTimesScalar:
- case spv::Op::OpVectorTimesMatrix:
- case spv::Op::OpMatrixTimesVector:
- case spv::Op::OpMatrixTimesMatrix:
- case spv::Op::OpOuterProduct:
- case spv::Op::OpDot:
- case spv::Op::OpIAddCarry:
- case spv::Op::OpISubBorrow:
- case spv::Op::OpUMulExtended:
- case spv::Op::OpSMulExtended:
- case spv::Op::OpAny:
- case spv::Op::OpAll:
- case spv::Op::OpIsNan:
- case spv::Op::OpIsInf:
- case spv::Op::OpIsFinite:
- case spv::Op::OpIsNormal:
- case spv::Op::OpSignBitSet:
- case spv::Op::OpLessOrGreater:
- case spv::Op::OpOrdered:
- case spv::Op::OpUnordered:
- case spv::Op::OpLogicalEqual:
- case spv::Op::OpLogicalNotEqual:
- case spv::Op::OpLogicalOr:
- case spv::Op::OpLogicalAnd:
- case spv::Op::OpLogicalNot:
- case spv::Op::OpSelect:
- case spv::Op::OpIEqual:
- case spv::Op::OpINotEqual:
- case spv::Op::OpUGreaterThan:
- case spv::Op::OpSGreaterThan:
- case spv::Op::OpUGreaterThanEqual:
- case spv::Op::OpSGreaterThanEqual:
- case spv::Op::OpULessThan:
- case spv::Op::OpSLessThan:
- case spv::Op::OpULessThanEqual:
- case spv::Op::OpSLessThanEqual:
- case spv::Op::OpFOrdEqual:
- case spv::Op::OpFUnordEqual:
- case spv::Op::OpFOrdNotEqual:
- case spv::Op::OpFUnordNotEqual:
- case spv::Op::OpFOrdLessThan:
- case spv::Op::OpFUnordLessThan:
- case spv::Op::OpFOrdGreaterThan:
- case spv::Op::OpFUnordGreaterThan:
- case spv::Op::OpFOrdLessThanEqual:
- case spv::Op::OpFUnordLessThanEqual:
- case spv::Op::OpFOrdGreaterThanEqual:
- case spv::Op::OpFUnordGreaterThanEqual:
- case spv::Op::OpShiftRightLogical:
- case spv::Op::OpShiftRightArithmetic:
- case spv::Op::OpShiftLeftLogical:
- case spv::Op::OpBitwiseOr:
- case spv::Op::OpBitwiseXor:
- case spv::Op::OpBitwiseAnd:
- case spv::Op::OpNot:
- case spv::Op::OpBitFieldInsert:
- case spv::Op::OpBitFieldSExtract:
- case spv::Op::OpBitFieldUExtract:
- case spv::Op::OpBitReverse:
- case spv::Op::OpBitCount:
- case spv::Op::OpCopyLogical:
- case spv::Op::OpPhi:
- case spv::Op::OpPtrEqual:
- case spv::Op::OpPtrNotEqual:
+ case SpvOpUndef:
+ case SpvOpAccessChain:
+ case SpvOpInBoundsAccessChain:
+ case SpvOpArrayLength:
+ case SpvOpVectorExtractDynamic:
+ case SpvOpVectorInsertDynamic:
+ case SpvOpVectorShuffle:
+ case SpvOpCompositeConstruct:
+ case SpvOpCompositeExtract:
+ case SpvOpCompositeInsert:
+ case SpvOpCopyObject:
+ case SpvOpTranspose:
+ case SpvOpConvertFToU:
+ case SpvOpConvertFToS:
+ case SpvOpConvertSToF:
+ case SpvOpConvertUToF:
+ case SpvOpUConvert:
+ case SpvOpSConvert:
+ case SpvOpFConvert:
+ case SpvOpQuantizeToF16:
+ case SpvOpSatConvertSToU:
+ case SpvOpSatConvertUToS:
+ case SpvOpBitcast:
+ case SpvOpSNegate:
+ case SpvOpFNegate:
+ case SpvOpIAdd:
+ case SpvOpFAdd:
+ case SpvOpISub:
+ case SpvOpFSub:
+ case SpvOpIMul:
+ case SpvOpFMul:
+ case SpvOpUDiv:
+ case SpvOpSDiv:
+ case SpvOpFDiv:
+ case SpvOpUMod:
+ case SpvOpSRem:
+ case SpvOpSMod:
+ case SpvOpFRem:
+ case SpvOpFMod:
+ case SpvOpVectorTimesScalar:
+ case SpvOpMatrixTimesScalar:
+ case SpvOpVectorTimesMatrix:
+ case SpvOpMatrixTimesVector:
+ case SpvOpMatrixTimesMatrix:
+ case SpvOpOuterProduct:
+ case SpvOpDot:
+ case SpvOpIAddCarry:
+ case SpvOpISubBorrow:
+ case SpvOpUMulExtended:
+ case SpvOpSMulExtended:
+ case SpvOpAny:
+ case SpvOpAll:
+ case SpvOpIsNan:
+ case SpvOpIsInf:
+ case SpvOpIsFinite:
+ case SpvOpIsNormal:
+ case SpvOpSignBitSet:
+ case SpvOpLessOrGreater:
+ case SpvOpOrdered:
+ case SpvOpUnordered:
+ case SpvOpLogicalEqual:
+ case SpvOpLogicalNotEqual:
+ case SpvOpLogicalOr:
+ case SpvOpLogicalAnd:
+ case SpvOpLogicalNot:
+ case SpvOpSelect:
+ case SpvOpIEqual:
+ case SpvOpINotEqual:
+ case SpvOpUGreaterThan:
+ case SpvOpSGreaterThan:
+ case SpvOpUGreaterThanEqual:
+ case SpvOpSGreaterThanEqual:
+ case SpvOpULessThan:
+ case SpvOpSLessThan:
+ case SpvOpULessThanEqual:
+ case SpvOpSLessThanEqual:
+ case SpvOpFOrdEqual:
+ case SpvOpFUnordEqual:
+ case SpvOpFOrdNotEqual:
+ case SpvOpFUnordNotEqual:
+ case SpvOpFOrdLessThan:
+ case SpvOpFUnordLessThan:
+ case SpvOpFOrdGreaterThan:
+ case SpvOpFUnordGreaterThan:
+ case SpvOpFOrdLessThanEqual:
+ case SpvOpFUnordLessThanEqual:
+ case SpvOpFOrdGreaterThanEqual:
+ case SpvOpFUnordGreaterThanEqual:
+ case SpvOpShiftRightLogical:
+ case SpvOpShiftRightArithmetic:
+ case SpvOpShiftLeftLogical:
+ case SpvOpBitwiseOr:
+ case SpvOpBitwiseXor:
+ case SpvOpBitwiseAnd:
+ case SpvOpNot:
+ case SpvOpBitFieldInsert:
+ case SpvOpBitFieldSExtract:
+ case SpvOpBitFieldUExtract:
+ case SpvOpBitReverse:
+ case SpvOpBitCount:
+ case SpvOpCopyLogical:
+ case SpvOpPhi:
+ case SpvOpPtrEqual:
+ case SpvOpPtrNotEqual:
return true;
default:
return false;
@@ -1984,7 +1975,7 @@ bool NewTerminatorPreservesDominationRules(opt::IRContext* ir_context,
for (const auto& inst : block) {
for (uint32_t i = 0; i < inst.NumInOperands();
- i += inst.opcode() == spv::Op::OpPhi ? 2 : 1) {
+ i += inst.opcode() == SpvOpPhi ? 2 : 1) {
const auto& operand = inst.GetInOperand(i);
if (!spvIsInIdType(operand.type)) {
continue;
@@ -2003,7 +1994,7 @@ bool NewTerminatorPreservesDominationRules(opt::IRContext* ir_context,
continue;
}
- auto domination_target_id = inst.opcode() == spv::Op::OpPhi
+ auto domination_target_id = inst.opcode() == SpvOpPhi
? inst.GetSingleWordInOperand(i + 1)
: block.id();
@@ -2030,68 +2021,68 @@ opt::Module::iterator GetFunctionIterator(opt::IRContext* ir_context,
// TODO(https://github.com/KhronosGroup/SPIRV-Tools/issues/3582): Add all
// opcodes that are agnostic to signedness of operands to function.
// This is not exhaustive yet.
-bool IsAgnosticToSignednessOfOperand(spv::Op opcode,
+bool IsAgnosticToSignednessOfOperand(SpvOp opcode,
uint32_t use_in_operand_index) {
switch (opcode) {
- case spv::Op::OpSNegate:
- case spv::Op::OpNot:
- case spv::Op::OpIAdd:
- case spv::Op::OpISub:
- case spv::Op::OpIMul:
- case spv::Op::OpSDiv:
- case spv::Op::OpSRem:
- case spv::Op::OpSMod:
- case spv::Op::OpShiftRightLogical:
- case spv::Op::OpShiftRightArithmetic:
- case spv::Op::OpShiftLeftLogical:
- case spv::Op::OpBitwiseOr:
- case spv::Op::OpBitwiseXor:
- case spv::Op::OpBitwiseAnd:
- case spv::Op::OpIEqual:
- case spv::Op::OpINotEqual:
- case spv::Op::OpULessThan:
- case spv::Op::OpSLessThan:
- case spv::Op::OpUGreaterThan:
- case spv::Op::OpSGreaterThan:
- case spv::Op::OpULessThanEqual:
- case spv::Op::OpSLessThanEqual:
- case spv::Op::OpUGreaterThanEqual:
- case spv::Op::OpSGreaterThanEqual:
+ case SpvOpSNegate:
+ case SpvOpNot:
+ case SpvOpIAdd:
+ case SpvOpISub:
+ case SpvOpIMul:
+ case SpvOpSDiv:
+ case SpvOpSRem:
+ case SpvOpSMod:
+ case SpvOpShiftRightLogical:
+ case SpvOpShiftRightArithmetic:
+ case SpvOpShiftLeftLogical:
+ case SpvOpBitwiseOr:
+ case SpvOpBitwiseXor:
+ case SpvOpBitwiseAnd:
+ case SpvOpIEqual:
+ case SpvOpINotEqual:
+ case SpvOpULessThan:
+ case SpvOpSLessThan:
+ case SpvOpUGreaterThan:
+ case SpvOpSGreaterThan:
+ case SpvOpULessThanEqual:
+ case SpvOpSLessThanEqual:
+ case SpvOpUGreaterThanEqual:
+ case SpvOpSGreaterThanEqual:
return true;
- case spv::Op::OpAtomicStore:
- case spv::Op::OpAtomicExchange:
- case spv::Op::OpAtomicIAdd:
- case spv::Op::OpAtomicISub:
- case spv::Op::OpAtomicSMin:
- case spv::Op::OpAtomicUMin:
- case spv::Op::OpAtomicSMax:
- case spv::Op::OpAtomicUMax:
- case spv::Op::OpAtomicAnd:
- case spv::Op::OpAtomicOr:
- case spv::Op::OpAtomicXor:
- case spv::Op::OpAtomicFAddEXT: // Capability AtomicFloat32AddEXT,
+ case SpvOpAtomicStore:
+ case SpvOpAtomicExchange:
+ case SpvOpAtomicIAdd:
+ case SpvOpAtomicISub:
+ case SpvOpAtomicSMin:
+ case SpvOpAtomicUMin:
+ case SpvOpAtomicSMax:
+ case SpvOpAtomicUMax:
+ case SpvOpAtomicAnd:
+ case SpvOpAtomicOr:
+ case SpvOpAtomicXor:
+ case SpvOpAtomicFAddEXT: // Capability AtomicFloat32AddEXT,
// AtomicFloat64AddEXT.
assert(use_in_operand_index != 0 &&
"Signedness check should not occur on a pointer operand.");
return use_in_operand_index == 1 || use_in_operand_index == 2;
- case spv::Op::OpAtomicCompareExchange:
- case spv::Op::OpAtomicCompareExchangeWeak: // Capability Kernel.
+ case SpvOpAtomicCompareExchange:
+ case SpvOpAtomicCompareExchangeWeak: // Capability Kernel.
assert(use_in_operand_index != 0 &&
"Signedness check should not occur on a pointer operand.");
return use_in_operand_index >= 1 && use_in_operand_index <= 3;
- case spv::Op::OpAtomicLoad:
- case spv::Op::OpAtomicIIncrement:
- case spv::Op::OpAtomicIDecrement:
- case spv::Op::OpAtomicFlagTestAndSet: // Capability Kernel.
- case spv::Op::OpAtomicFlagClear: // Capability Kernel.
+ case SpvOpAtomicLoad:
+ case SpvOpAtomicIIncrement:
+ case SpvOpAtomicIDecrement:
+ case SpvOpAtomicFlagTestAndSet: // Capability Kernel.
+ case SpvOpAtomicFlagClear: // Capability Kernel.
assert(use_in_operand_index != 0 &&
"Signedness check should not occur on a pointer operand.");
return use_in_operand_index >= 1;
- case spv::Op::OpAccessChain:
+ case SpvOpAccessChain:
// The signedness of indices does not matter.
return use_in_operand_index > 0;
@@ -2102,7 +2093,7 @@ bool IsAgnosticToSignednessOfOperand(spv::Op opcode,
}
}
-bool TypesAreCompatible(opt::IRContext* ir_context, spv::Op opcode,
+bool TypesAreCompatible(opt::IRContext* ir_context, SpvOp opcode,
uint32_t use_in_operand_index, uint32_t type_id_1,
uint32_t type_id_2) {
assert(ir_context->get_type_mgr()->GetType(type_id_1) &&
diff --git a/source/fuzz/fuzzer_util.h b/source/fuzz/fuzzer_util.h
index 374e32e1..54aa14a2 100644
--- a/source/fuzz/fuzzer_util.h
+++ b/source/fuzz/fuzzer_util.h
@@ -111,7 +111,7 @@ opt::BasicBlock::iterator GetIteratorForInstruction(
// Determines whether it is OK to insert an instruction with opcode |opcode|
// before |instruction_in_block|.
bool CanInsertOpcodeBeforeInstruction(
- spv::Op opcode, const opt::BasicBlock::iterator& instruction_in_block);
+ SpvOp opcode, const opt::BasicBlock::iterator& instruction_in_block);
// Determines whether it is OK to make a synonym of |inst|.
// |transformation_context| is used to verify that the result id of |inst|
@@ -170,8 +170,8 @@ uint32_t GetBoundForCompositeIndex(const opt::Instruction& composite_type_inst,
opt::IRContext* ir_context);
// Returns memory semantics mask for specific storage class.
-spv::MemorySemanticsMask GetMemorySemanticsForStorageClass(
- spv::StorageClass storage_class);
+SpvMemorySemanticsMask GetMemorySemanticsForStorageClass(
+ SpvStorageClass storage_class);
// Returns true if and only if |context| is valid, according to the validator
// instantiated with |validator_options|. |consumer| is used for error
@@ -258,18 +258,18 @@ uint32_t GetPointeeTypeIdFromPointerType(opt::IRContext* context,
// Given |pointer_type_inst|, which must be an OpTypePointer instruction,
// returns the associated storage class.
-spv::StorageClass GetStorageClassFromPointerType(
+SpvStorageClass GetStorageClassFromPointerType(
opt::Instruction* pointer_type_inst);
// Given |pointer_type_id|, which must be the id of a pointer type, returns the
// associated storage class.
-spv::StorageClass GetStorageClassFromPointerType(opt::IRContext* context,
- uint32_t pointer_type_id);
+SpvStorageClass GetStorageClassFromPointerType(opt::IRContext* context,
+ uint32_t pointer_type_id);
// Returns the id of a pointer with pointee type |pointee_type_id| and storage
// class |storage_class|, if it exists, and 0 otherwise.
uint32_t MaybeGetPointerType(opt::IRContext* context, uint32_t pointee_type_id,
- spv::StorageClass storage_class);
+ SpvStorageClass storage_class);
// Given an instruction |inst| and an operand absolute index |absolute_index|,
// returns the index of the operand restricted to the input operands.
@@ -309,7 +309,7 @@ void AddVariableIdToEntryPointInterfaces(opt::IRContext* context, uint32_t id);
// Returns a pointer to the new global variable instruction.
opt::Instruction* AddGlobalVariable(opt::IRContext* context, uint32_t result_id,
uint32_t type_id,
- spv::StorageClass storage_class,
+ SpvStorageClass storage_class,
uint32_t initializer_id);
// Adds an instruction to the start of |function_id|, of the form:
@@ -541,7 +541,7 @@ MapToRepeatedUInt32Pair(const std::map<uint32_t, uint32_t>& data);
// opcode |opcode| can be inserted, or nullptr if there is no such instruction.
opt::Instruction* GetLastInsertBeforeInstruction(opt::IRContext* ir_context,
uint32_t block_id,
- spv::Op opcode);
+ SpvOp opcode);
// Checks whether various conditions hold related to the acceptability of
// replacing the id use at |use_in_operand_index| of |use_instruction| with a
@@ -608,14 +608,14 @@ opt::Module::iterator GetFunctionIterator(opt::IRContext* ir_context,
// behaviour depending on the signedness of the operand at
// |use_in_operand_index|.
// Assumes that the operand must be the id of an integer scalar or vector.
-bool IsAgnosticToSignednessOfOperand(spv::Op opcode,
+bool IsAgnosticToSignednessOfOperand(SpvOp opcode,
uint32_t use_in_operand_index);
// Returns true if |type_id_1| and |type_id_2| represent compatible types
// given the context of the instruction with |opcode| (i.e. we can replace
// an operand of |opcode| of the first type with an id of the second type
// and vice-versa).
-bool TypesAreCompatible(opt::IRContext* ir_context, spv::Op opcode,
+bool TypesAreCompatible(opt::IRContext* ir_context, SpvOp opcode,
uint32_t use_in_operand_index, uint32_t type_id_1,
uint32_t type_id_2);
diff --git a/source/fuzz/instruction_descriptor.cpp b/source/fuzz/instruction_descriptor.cpp
index 120d8f87..fb1ff765 100644
--- a/source/fuzz/instruction_descriptor.cpp
+++ b/source/fuzz/instruction_descriptor.cpp
@@ -40,9 +40,8 @@ opt::Instruction* FindInstruction(
"The skipped instruction count should only be incremented "
"after the instruction base has been found.");
}
- if (found_base &&
- instruction.opcode() ==
- spv::Op(instruction_descriptor.target_instruction_opcode())) {
+ if (found_base && instruction.opcode() ==
+ instruction_descriptor.target_instruction_opcode()) {
if (num_ignored == instruction_descriptor.num_opcodes_to_ignore()) {
return &instruction;
}
@@ -53,11 +52,11 @@ opt::Instruction* FindInstruction(
}
protobufs::InstructionDescriptor MakeInstructionDescriptor(
- uint32_t base_instruction_result_id, spv::Op target_instruction_opcode,
+ uint32_t base_instruction_result_id, SpvOp target_instruction_opcode,
uint32_t num_opcodes_to_ignore) {
protobufs::InstructionDescriptor result;
result.set_base_instruction_result_id(base_instruction_result_id);
- result.set_target_instruction_opcode(uint32_t(target_instruction_opcode));
+ result.set_target_instruction_opcode(target_instruction_opcode);
result.set_num_opcodes_to_ignore(num_opcodes_to_ignore);
return result;
}
@@ -65,7 +64,7 @@ protobufs::InstructionDescriptor MakeInstructionDescriptor(
protobufs::InstructionDescriptor MakeInstructionDescriptor(
const opt::BasicBlock& block,
const opt::BasicBlock::const_iterator& inst_it) {
- const spv::Op opcode =
+ const SpvOp opcode =
inst_it->opcode(); // The opcode of the instruction being described.
uint32_t skip_count = 0; // The number of these opcodes we have skipped when
// searching backwards.
diff --git a/source/fuzz/instruction_descriptor.h b/source/fuzz/instruction_descriptor.h
index 063cad47..2ccd15a2 100644
--- a/source/fuzz/instruction_descriptor.h
+++ b/source/fuzz/instruction_descriptor.h
@@ -32,7 +32,7 @@ opt::Instruction* FindInstruction(
// components. See the protobuf definition for details of what these
// components mean.
protobufs::InstructionDescriptor MakeInstructionDescriptor(
- uint32_t base_instruction_result_id, spv::Op target_instruction_opcode,
+ uint32_t base_instruction_result_id, SpvOp target_instruction_opcode,
uint32_t num_opcodes_to_ignore);
// Returns an instruction descriptor that describing the instruction at
diff --git a/source/fuzz/instruction_message.cpp b/source/fuzz/instruction_message.cpp
index 7e8ac71b..95039327 100644
--- a/source/fuzz/instruction_message.cpp
+++ b/source/fuzz/instruction_message.cpp
@@ -20,10 +20,10 @@ namespace spvtools {
namespace fuzz {
protobufs::Instruction MakeInstructionMessage(
- spv::Op opcode, uint32_t result_type_id, uint32_t result_id,
+ SpvOp opcode, uint32_t result_type_id, uint32_t result_id,
const opt::Instruction::OperandList& input_operands) {
protobufs::Instruction result;
- result.set_opcode(uint32_t(opcode));
+ result.set_opcode(opcode);
result.set_result_type_id(result_type_id);
result.set_result_id(result_id);
for (auto& operand : input_operands) {
@@ -71,7 +71,7 @@ std::unique_ptr<opt::Instruction> InstructionFromMessage(
}
// Create and return the instruction.
return MakeUnique<opt::Instruction>(
- ir_context, static_cast<spv::Op>(instruction_message.opcode()),
+ ir_context, static_cast<SpvOp>(instruction_message.opcode()),
instruction_message.result_type_id(), instruction_message.result_id(),
in_operands);
}
diff --git a/source/fuzz/instruction_message.h b/source/fuzz/instruction_message.h
index e1312f45..fcbb4c76 100644
--- a/source/fuzz/instruction_message.h
+++ b/source/fuzz/instruction_message.h
@@ -26,7 +26,7 @@ namespace fuzz {
// Creates an Instruction protobuf message from its component parts.
protobufs::Instruction MakeInstructionMessage(
- spv::Op opcode, uint32_t result_type_id, uint32_t result_id,
+ SpvOp opcode, uint32_t result_type_id, uint32_t result_id,
const opt::Instruction::OperandList& input_operands);
// Creates an Instruction protobuf message from a parsed instruction.
diff --git a/source/fuzz/transformation_access_chain.cpp b/source/fuzz/transformation_access_chain.cpp
index 1e7f87bd..3fe9e656 100644
--- a/source/fuzz/transformation_access_chain.cpp
+++ b/source/fuzz/transformation_access_chain.cpp
@@ -63,7 +63,7 @@ bool TransformationAccessChain::IsApplicable(
}
// The type must indeed be a pointer.
auto pointer_type = ir_context->get_def_use_mgr()->GetDef(pointer->type_id());
- if (pointer_type->opcode() != spv::Op::OpTypePointer) {
+ if (pointer_type->opcode() != SpvOpTypePointer) {
return false;
}
@@ -75,7 +75,7 @@ bool TransformationAccessChain::IsApplicable(
return false;
}
if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(
- spv::Op::OpAccessChain, instruction_to_insert_before)) {
+ SpvOpAccessChain, instruction_to_insert_before)) {
return false;
}
@@ -83,8 +83,8 @@ bool TransformationAccessChain::IsApplicable(
// we do not want to allow accessing such pointers. This might be acceptable
// in dead blocks, but we conservatively avoid it.
switch (pointer->opcode()) {
- case spv::Op::OpConstantNull:
- case spv::Op::OpUndef:
+ case SpvOpConstantNull:
+ case SpvOpUndef:
assert(
false &&
"Access chains should not be created from null/undefined pointers");
@@ -117,7 +117,7 @@ bool TransformationAccessChain::IsApplicable(
// Check whether the object is a struct.
if (ir_context->get_def_use_mgr()->GetDef(subobject_type_id)->opcode() ==
- spv::Op::OpTypeStruct) {
+ SpvOpTypeStruct) {
// It is a struct: we need to retrieve the integer value.
bool successful;
@@ -202,7 +202,7 @@ bool TransformationAccessChain::IsApplicable(
// associated with pointers to isomorphic structs being regarded as the same.
return fuzzerutil::MaybeGetPointerType(
ir_context, subobject_type_id,
- static_cast<spv::StorageClass>(
+ static_cast<SpvStorageClass>(
pointer_type->GetSingleWordInOperand(0))) != 0;
}
@@ -243,7 +243,7 @@ void TransformationAccessChain::Apply(
// Check whether the object is a struct.
if (ir_context->get_def_use_mgr()->GetDef(subobject_type_id)->opcode() ==
- spv::Op::OpTypeStruct) {
+ SpvOpTypeStruct) {
// It is a struct: we need to retrieve the integer value.
index_value =
@@ -290,8 +290,7 @@ void TransformationAccessChain::Apply(
// %fresh_ids.first = OpULessThanEqual %bool %int_id %bound_minus_one.
fuzzerutil::UpdateModuleIdBound(ir_context, fresh_ids.first());
auto comparison_instruction = MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpULessThanEqual, bool_type_id,
- fresh_ids.first(),
+ ir_context, SpvOpULessThanEqual, bool_type_id, fresh_ids.first(),
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {index_instruction->result_id()}},
{SPV_OPERAND_TYPE_ID, {bound_minus_one_id}}}));
@@ -307,7 +306,7 @@ void TransformationAccessChain::Apply(
// %bound_minus_one
fuzzerutil::UpdateModuleIdBound(ir_context, fresh_ids.second());
auto select_instruction = MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpSelect, int_type_inst->result_id(),
+ ir_context, SpvOpSelect, int_type_inst->result_id(),
fresh_ids.second(),
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {fresh_ids.first()}},
@@ -335,14 +334,13 @@ void TransformationAccessChain::Apply(
// of the original pointer.
uint32_t result_type = fuzzerutil::MaybeGetPointerType(
ir_context, subobject_type_id,
- static_cast<spv::StorageClass>(pointer_type->GetSingleWordInOperand(0)));
+ static_cast<SpvStorageClass>(pointer_type->GetSingleWordInOperand(0)));
// Add the access chain instruction to the module, and update the module's
// id bound.
fuzzerutil::UpdateModuleIdBound(ir_context, message_.fresh_id());
- auto access_chain_instruction =
- MakeUnique<opt::Instruction>(ir_context, spv::Op::OpAccessChain,
- result_type, message_.fresh_id(), operands);
+ auto access_chain_instruction = MakeUnique<opt::Instruction>(
+ ir_context, SpvOpAccessChain, result_type, message_.fresh_id(), operands);
auto access_chain_instruction_ptr = access_chain_instruction.get();
instruction_to_insert_before->InsertBefore(
std::move(access_chain_instruction));
@@ -369,7 +367,7 @@ std::pair<bool, uint32_t> TransformationAccessChain::GetStructIndexValue(
opt::IRContext* ir_context, uint32_t index_id,
uint32_t object_type_id) const {
assert(ir_context->get_def_use_mgr()->GetDef(object_type_id)->opcode() ==
- spv::Op::OpTypeStruct &&
+ SpvOpTypeStruct &&
"Precondition: the type must be a struct type.");
if (!ValidIndexToComposite(ir_context, index_id, object_type_id)) {
return {false, 0};
@@ -410,14 +408,14 @@ bool TransformationAccessChain::ValidIndexToComposite(
// The index type must be 32-bit integer.
auto index_type =
ir_context->get_def_use_mgr()->GetDef(index_instruction->type_id());
- if (index_type->opcode() != spv::Op::OpTypeInt ||
+ if (index_type->opcode() != SpvOpTypeInt ||
index_type->GetSingleWordInOperand(0) != 32) {
return false;
}
// If the object being traversed is a struct, the id must correspond to an
// in-bound constant.
- if (object_type_def->opcode() == spv::Op::OpTypeStruct) {
+ if (object_type_def->opcode() == SpvOpTypeStruct) {
if (!spvOpcodeIsConstant(index_instruction->opcode())) {
return false;
}
diff --git a/source/fuzz/transformation_add_bit_instruction_synonym.cpp b/source/fuzz/transformation_add_bit_instruction_synonym.cpp
index 4b26c2b5..636c0a38 100644
--- a/source/fuzz/transformation_add_bit_instruction_synonym.cpp
+++ b/source/fuzz/transformation_add_bit_instruction_synonym.cpp
@@ -87,10 +87,10 @@ void TransformationAddBitInstructionSynonym::Apply(
// synonym fact. The helper function should take care of invalidating
// analyses before adding facts.
switch (bit_instruction->opcode()) {
- case spv::Op::OpBitwiseOr:
- case spv::Op::OpBitwiseXor:
- case spv::Op::OpBitwiseAnd:
- case spv::Op::OpNot:
+ case SpvOpBitwiseOr:
+ case SpvOpBitwiseXor:
+ case SpvOpBitwiseAnd:
+ case SpvOpNot:
AddOpBitwiseOrOpNotSynonym(ir_context, transformation_context,
bit_instruction);
break;
@@ -106,10 +106,10 @@ bool TransformationAddBitInstructionSynonym::IsInstructionSupported(
// Right now we only support certain operations. When this issue is addressed
// the following conditional can use the function |spvOpcodeIsBit|.
// |instruction| must be defined and must be a supported bit instruction.
- if (!instruction || (instruction->opcode() != spv::Op::OpBitwiseOr &&
- instruction->opcode() != spv::Op::OpBitwiseXor &&
- instruction->opcode() != spv::Op::OpBitwiseAnd &&
- instruction->opcode() != spv::Op::OpNot)) {
+ if (!instruction || (instruction->opcode() != SpvOpBitwiseOr &&
+ instruction->opcode() != SpvOpBitwiseXor &&
+ instruction->opcode() != SpvOpBitwiseAnd &&
+ instruction->opcode() != SpvOpNot)) {
return false;
}
@@ -119,7 +119,7 @@ bool TransformationAddBitInstructionSynonym::IsInstructionSupported(
return false;
}
- if (instruction->opcode() == spv::Op::OpNot) {
+ if (instruction->opcode() == SpvOpNot) {
auto operand = instruction->GetInOperand(0).words[0];
auto operand_inst = ir_context->get_def_use_mgr()->GetDef(operand);
auto operand_type =
@@ -171,10 +171,10 @@ uint32_t TransformationAddBitInstructionSynonym::GetRequiredFreshIdCount(
// TODO(https://github.com/KhronosGroup/SPIRV-Tools/issues/3557):
// Right now, only certain operations are supported.
switch (bit_instruction->opcode()) {
- case spv::Op::OpBitwiseOr:
- case spv::Op::OpBitwiseXor:
- case spv::Op::OpBitwiseAnd:
- case spv::Op::OpNot:
+ case SpvOpBitwiseOr:
+ case SpvOpBitwiseXor:
+ case SpvOpBitwiseAnd:
+ case SpvOpNot:
return (2 + bit_instruction->NumInOperands()) *
ir_context->get_type_mgr()
->GetType(bit_instruction->type_id())
@@ -220,7 +220,7 @@ void TransformationAddBitInstructionSynonym::AddOpBitwiseOrOpNotSynonym(
for (auto operand = bit_instruction->begin() + 2;
operand != bit_instruction->end(); operand++) {
auto bit_extract =
- opt::Instruction(ir_context, spv::Op::OpBitFieldUExtract,
+ opt::Instruction(ir_context, SpvOpBitFieldUExtract,
bit_instruction->type_id(), *fresh_id++,
{{SPV_OPERAND_TYPE_ID, operand->words},
{SPV_OPERAND_TYPE_ID, {offset}},
@@ -246,13 +246,12 @@ void TransformationAddBitInstructionSynonym::AddOpBitwiseOrOpNotSynonym(
// first two bits of the result.
uint32_t offset = fuzzerutil::MaybeGetIntegerConstant(
ir_context, *transformation_context, {1}, 32, false, false);
- auto bit_insert =
- opt::Instruction(ir_context, spv::Op::OpBitFieldInsert,
- bit_instruction->type_id(), *fresh_id++,
- {{SPV_OPERAND_TYPE_ID, {extracted_bit_instructions[0]}},
- {SPV_OPERAND_TYPE_ID, {extracted_bit_instructions[1]}},
- {SPV_OPERAND_TYPE_ID, {offset}},
- {SPV_OPERAND_TYPE_ID, {count}}});
+ auto bit_insert = opt::Instruction(
+ ir_context, SpvOpBitFieldInsert, bit_instruction->type_id(), *fresh_id++,
+ {{SPV_OPERAND_TYPE_ID, {extracted_bit_instructions[0]}},
+ {SPV_OPERAND_TYPE_ID, {extracted_bit_instructions[1]}},
+ {SPV_OPERAND_TYPE_ID, {offset}},
+ {SPV_OPERAND_TYPE_ID, {count}}});
bit_instruction->InsertBefore(MakeUnique<opt::Instruction>(bit_insert));
fuzzerutil::UpdateModuleIdBound(ir_context, bit_insert.result_id());
@@ -261,7 +260,7 @@ void TransformationAddBitInstructionSynonym::AddOpBitwiseOrOpNotSynonym(
offset = fuzzerutil::MaybeGetIntegerConstant(
ir_context, *transformation_context, {i}, 32, false, false);
bit_insert = opt::Instruction(
- ir_context, spv::Op::OpBitFieldInsert, bit_instruction->type_id(),
+ ir_context, SpvOpBitFieldInsert, bit_instruction->type_id(),
*fresh_id++,
{{SPV_OPERAND_TYPE_ID, {bit_insert.result_id()}},
{SPV_OPERAND_TYPE_ID, {extracted_bit_instructions[i]}},
diff --git a/source/fuzz/transformation_add_constant_boolean.cpp b/source/fuzz/transformation_add_constant_boolean.cpp
index 89c2e579..39354325 100644
--- a/source/fuzz/transformation_add_constant_boolean.cpp
+++ b/source/fuzz/transformation_add_constant_boolean.cpp
@@ -43,8 +43,7 @@ void TransformationAddConstantBoolean::Apply(
// Add the boolean constant to the module, ensuring the module's id bound is
// high enough.
auto new_instruction = MakeUnique<opt::Instruction>(
- ir_context,
- message_.is_true() ? spv::Op::OpConstantTrue : spv::Op::OpConstantFalse,
+ ir_context, message_.is_true() ? SpvOpConstantTrue : SpvOpConstantFalse,
fuzzerutil::MaybeGetBoolType(ir_context), message_.fresh_id(),
opt::Instruction::OperandList());
auto new_instruction_ptr = new_instruction.get();
diff --git a/source/fuzz/transformation_add_constant_composite.cpp b/source/fuzz/transformation_add_constant_composite.cpp
index b8ee8be7..89007ab6 100644
--- a/source/fuzz/transformation_add_constant_composite.cpp
+++ b/source/fuzz/transformation_add_constant_composite.cpp
@@ -53,7 +53,7 @@ bool TransformationAddConstantComposite::IsApplicable(
// struct - whether its decorations are OK.
std::vector<uint32_t> constituent_type_ids;
switch (composite_type_instruction->opcode()) {
- case spv::Op::OpTypeArray:
+ case SpvOpTypeArray:
for (uint32_t index = 0;
index <
fuzzerutil::GetArraySize(*composite_type_instruction, ir_context);
@@ -62,8 +62,8 @@ bool TransformationAddConstantComposite::IsApplicable(
composite_type_instruction->GetSingleWordInOperand(0));
}
break;
- case spv::Op::OpTypeMatrix:
- case spv::Op::OpTypeVector:
+ case SpvOpTypeMatrix:
+ case SpvOpTypeVector:
for (uint32_t index = 0;
index < composite_type_instruction->GetSingleWordInOperand(1);
index++) {
@@ -71,7 +71,7 @@ bool TransformationAddConstantComposite::IsApplicable(
composite_type_instruction->GetSingleWordInOperand(0));
}
break;
- case spv::Op::OpTypeStruct:
+ case SpvOpTypeStruct:
// We do not create constants of structs decorated with Block nor
// BufferBlock. The SPIR-V spec does not explicitly disallow this, but it
// seems like a strange thing to do, so we disallow it to avoid triggering
@@ -120,7 +120,7 @@ void TransformationAddConstantComposite::Apply(
in_operands.push_back({SPV_OPERAND_TYPE_ID, {constituent_id}});
}
auto new_instruction = MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpConstantComposite, message_.type_id(),
+ ir_context, SpvOpConstantComposite, message_.type_id(),
message_.fresh_id(), in_operands);
auto new_instruction_ptr = new_instruction.get();
ir_context->module()->AddGlobalValue(std::move(new_instruction));
diff --git a/source/fuzz/transformation_add_constant_null.cpp b/source/fuzz/transformation_add_constant_null.cpp
index 7b83baea..c0f73670 100644
--- a/source/fuzz/transformation_add_constant_null.cpp
+++ b/source/fuzz/transformation_add_constant_null.cpp
@@ -48,8 +48,8 @@ bool TransformationAddConstantNull::IsApplicable(
void TransformationAddConstantNull::Apply(
opt::IRContext* ir_context, TransformationContext* /*unused*/) const {
auto new_instruction = MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpConstantNull, message_.type_id(),
- message_.fresh_id(), opt::Instruction::OperandList());
+ ir_context, SpvOpConstantNull, message_.type_id(), message_.fresh_id(),
+ opt::Instruction::OperandList());
auto new_instruction_ptr = new_instruction.get();
ir_context->module()->AddGlobalValue(std::move(new_instruction));
fuzzerutil::UpdateModuleIdBound(ir_context, message_.fresh_id());
diff --git a/source/fuzz/transformation_add_constant_scalar.cpp b/source/fuzz/transformation_add_constant_scalar.cpp
index 45989d45..a2d95fb6 100644
--- a/source/fuzz/transformation_add_constant_scalar.cpp
+++ b/source/fuzz/transformation_add_constant_scalar.cpp
@@ -65,7 +65,7 @@ void TransformationAddConstantScalar::Apply(
opt::IRContext* ir_context,
TransformationContext* transformation_context) const {
auto new_instruction = MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpConstant, message_.type_id(), message_.fresh_id(),
+ ir_context, SpvOpConstant, message_.type_id(), message_.fresh_id(),
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_LITERAL_INTEGER,
std::vector<uint32_t>(message_.word().begin(),
diff --git a/source/fuzz/transformation_add_copy_memory.cpp b/source/fuzz/transformation_add_copy_memory.cpp
index 9d1f3256..5eb4bdc0 100644
--- a/source/fuzz/transformation_add_copy_memory.cpp
+++ b/source/fuzz/transformation_add_copy_memory.cpp
@@ -27,12 +27,12 @@ TransformationAddCopyMemory::TransformationAddCopyMemory(
TransformationAddCopyMemory::TransformationAddCopyMemory(
const protobufs::InstructionDescriptor& instruction_descriptor,
- uint32_t fresh_id, uint32_t source_id, spv::StorageClass storage_class,
+ uint32_t fresh_id, uint32_t source_id, SpvStorageClass storage_class,
uint32_t initializer_id) {
*message_.mutable_instruction_descriptor() = instruction_descriptor;
message_.set_fresh_id(fresh_id);
message_.set_source_id(source_id);
- message_.set_storage_class(uint32_t(storage_class));
+ message_.set_storage_class(storage_class);
message_.set_initializer_id(initializer_id);
}
@@ -53,8 +53,7 @@ bool TransformationAddCopyMemory::IsApplicable(
// Check that we can insert OpCopyMemory before |instruction_descriptor|.
auto iter = fuzzerutil::GetIteratorForInstruction(
ir_context->get_instr_block(inst), inst);
- if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(spv::Op::OpCopyMemory,
- iter)) {
+ if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(SpvOpCopyMemory, iter)) {
return false;
}
@@ -66,10 +65,8 @@ bool TransformationAddCopyMemory::IsApplicable(
}
// |storage_class| is either Function or Private.
- if (spv::StorageClass(message_.storage_class()) !=
- spv::StorageClass::Function &&
- spv::StorageClass(message_.storage_class()) !=
- spv::StorageClass::Private) {
+ if (message_.storage_class() != SpvStorageClassFunction &&
+ message_.storage_class() != SpvStorageClassPrivate) {
return false;
}
@@ -79,7 +76,7 @@ bool TransformationAddCopyMemory::IsApplicable(
// OpTypePointer with |message_.storage_class| exists.
if (!fuzzerutil::MaybeGetPointerType(
ir_context, pointee_type_id,
- static_cast<spv::StorageClass>(message_.storage_class()))) {
+ static_cast<SpvStorageClass>(message_.storage_class()))) {
return false;
}
@@ -106,20 +103,20 @@ void TransformationAddCopyMemory::Apply(
ir_context->get_instr_block(insert_before_inst);
// Add global or local variable to copy memory into.
- auto storage_class = static_cast<spv::StorageClass>(message_.storage_class());
+ auto storage_class = static_cast<SpvStorageClass>(message_.storage_class());
auto type_id = fuzzerutil::MaybeGetPointerType(
ir_context,
fuzzerutil::GetPointeeTypeIdFromPointerType(
ir_context, fuzzerutil::GetTypeId(ir_context, message_.source_id())),
storage_class);
- if (storage_class == spv::StorageClass::Private) {
+ if (storage_class == SpvStorageClassPrivate) {
opt::Instruction* new_global =
fuzzerutil::AddGlobalVariable(ir_context, message_.fresh_id(), type_id,
storage_class, message_.initializer_id());
ir_context->get_def_use_mgr()->AnalyzeInstDefUse(new_global);
} else {
- assert(storage_class == spv::StorageClass::Function &&
+ assert(storage_class == SpvStorageClassFunction &&
"Storage class can be either Private or Function");
opt::Function* enclosing_function = enclosing_block->GetParent();
opt::Instruction* new_local = fuzzerutil::AddLocalVariable(
@@ -133,7 +130,7 @@ void TransformationAddCopyMemory::Apply(
enclosing_block, insert_before_inst);
auto new_instruction = MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCopyMemory, 0, 0,
+ ir_context, SpvOpCopyMemory, 0, 0,
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_ID, {message_.fresh_id()}},
{SPV_OPERAND_TYPE_ID, {message_.source_id()}}});
@@ -163,8 +160,7 @@ protobufs::Transformation TransformationAddCopyMemory::ToMessage() const {
bool TransformationAddCopyMemory::IsInstructionSupported(
opt::IRContext* ir_context, opt::Instruction* inst) {
if (!inst->result_id() || !inst->type_id() ||
- inst->opcode() == spv::Op::OpConstantNull ||
- inst->opcode() == spv::Op::OpUndef) {
+ inst->opcode() == SpvOpConstantNull || inst->opcode() == SpvOpUndef) {
return false;
}
diff --git a/source/fuzz/transformation_add_copy_memory.h b/source/fuzz/transformation_add_copy_memory.h
index 053b6291..b25652fd 100644
--- a/source/fuzz/transformation_add_copy_memory.h
+++ b/source/fuzz/transformation_add_copy_memory.h
@@ -30,7 +30,7 @@ class TransformationAddCopyMemory : public Transformation {
TransformationAddCopyMemory(
const protobufs::InstructionDescriptor& instruction_descriptor,
- uint32_t fresh_id, uint32_t source_id, spv::StorageClass storage_class,
+ uint32_t fresh_id, uint32_t source_id, SpvStorageClass storage_class,
uint32_t initializer_id);
// - |instruction_descriptor| must point to a valid instruction in the module.
diff --git a/source/fuzz/transformation_add_dead_block.cpp b/source/fuzz/transformation_add_dead_block.cpp
index 930adc10..df700ce5 100644
--- a/source/fuzz/transformation_add_dead_block.cpp
+++ b/source/fuzz/transformation_add_dead_block.cpp
@@ -61,7 +61,7 @@ bool TransformationAddDeadBlock::IsApplicable(
}
// It must end with OpBranch.
- if (existing_block->terminator()->opcode() != spv::Op::OpBranch) {
+ if (existing_block->terminator()->opcode() != SpvOpBranch) {
return false;
}
@@ -122,27 +122,27 @@ void TransformationAddDeadBlock::Apply(
auto enclosing_function = existing_block->GetParent();
std::unique_ptr<opt::BasicBlock> new_block =
MakeUnique<opt::BasicBlock>(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpLabel, 0, message_.fresh_id(),
+ ir_context, SpvOpLabel, 0, message_.fresh_id(),
opt::Instruction::OperandList()));
new_block->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpBranch, 0, 0,
+ ir_context, SpvOpBranch, 0, 0,
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {successor_block_id}}})));
// Turn the original block into a selection merge, with its original successor
// as the merge block.
existing_block->terminator()->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpSelectionMerge, 0, 0,
+ ir_context, SpvOpSelectionMerge, 0, 0,
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {successor_block_id}},
{SPV_OPERAND_TYPE_SELECTION_CONTROL,
- {uint32_t(spv::SelectionControlMask::MaskNone)}}})));
+ {SpvSelectionControlMaskNone}}})));
// Change the original block's terminator to be a conditional branch on the
// given boolean, with the original successor and the new successor as branch
// targets, and such that at runtime control will always transfer to the
// original successor.
- existing_block->terminator()->SetOpcode(spv::Op::OpBranchConditional);
+ existing_block->terminator()->SetOpcode(SpvOpBranchConditional);
existing_block->terminator()->SetInOperands(
{{SPV_OPERAND_TYPE_ID, {bool_id}},
{SPV_OPERAND_TYPE_ID,
diff --git a/source/fuzz/transformation_add_dead_break.cpp b/source/fuzz/transformation_add_dead_break.cpp
index 07ed4dc5..32080ca4 100644
--- a/source/fuzz/transformation_add_dead_break.cpp
+++ b/source/fuzz/transformation_add_dead_break.cpp
@@ -142,7 +142,7 @@ bool TransformationAddDeadBreak::IsApplicable(
}
// Check that |message_.from_block| ends with an unconditional branch.
- if (bb_from->terminator()->opcode() != spv::Op::OpBranch) {
+ if (bb_from->terminator()->opcode() != SpvOpBranch) {
// The block associated with the id does not end with an unconditional
// branch.
return false;
diff --git a/source/fuzz/transformation_add_dead_continue.cpp b/source/fuzz/transformation_add_dead_continue.cpp
index c534801b..f2b9ab3f 100644
--- a/source/fuzz/transformation_add_dead_continue.cpp
+++ b/source/fuzz/transformation_add_dead_continue.cpp
@@ -55,7 +55,7 @@ bool TransformationAddDeadContinue::IsApplicable(
}
// Check that |message_.from_block| ends with an unconditional branch.
- if (bb_from->terminator()->opcode() != spv::Op::OpBranch) {
+ if (bb_from->terminator()->opcode() != SpvOpBranch) {
// The block associated with the id does not end with an unconditional
// branch.
return false;
diff --git a/source/fuzz/transformation_add_early_terminator_wrapper.cpp b/source/fuzz/transformation_add_early_terminator_wrapper.cpp
index 28e0186d..547398aa 100644
--- a/source/fuzz/transformation_add_early_terminator_wrapper.cpp
+++ b/source/fuzz/transformation_add_early_terminator_wrapper.cpp
@@ -28,17 +28,17 @@ TransformationAddEarlyTerminatorWrapper::
TransformationAddEarlyTerminatorWrapper::
TransformationAddEarlyTerminatorWrapper(uint32_t function_fresh_id,
uint32_t label_fresh_id,
- spv::Op opcode) {
+ SpvOp opcode) {
message_.set_function_fresh_id(function_fresh_id);
message_.set_label_fresh_id(label_fresh_id);
- message_.set_opcode(uint32_t(opcode));
+ message_.set_opcode(opcode);
}
bool TransformationAddEarlyTerminatorWrapper::IsApplicable(
opt::IRContext* ir_context, const TransformationContext& /*unused*/) const {
- assert((spv::Op(message_.opcode()) == spv::Op::OpKill ||
- spv::Op(message_.opcode()) == spv::Op::OpUnreachable ||
- spv::Op(message_.opcode()) == spv::Op::OpTerminateInvocation) &&
+ assert((message_.opcode() == SpvOpKill ||
+ message_.opcode() == SpvOpUnreachable ||
+ message_.opcode() == SpvOpTerminateInvocation) &&
"Invalid opcode.");
if (!fuzzerutil::IsFreshId(ir_context, message_.function_fresh_id())) {
@@ -66,29 +66,26 @@ void TransformationAddEarlyTerminatorWrapper::Apply(
// %label_fresh_id = OpLabel
// OpKill|Unreachable|TerminateInvocation
auto basic_block = MakeUnique<opt::BasicBlock>(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpLabel, 0, message_.label_fresh_id(),
+ ir_context, SpvOpLabel, 0, message_.label_fresh_id(),
opt::Instruction::OperandList()));
basic_block->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context, static_cast<spv::Op>(message_.opcode()), 0, 0,
+ ir_context, static_cast<SpvOp>(message_.opcode()), 0, 0,
opt::Instruction::OperandList()));
// Create a zero-argument void function.
auto void_type_id = fuzzerutil::MaybeGetVoidType(ir_context);
auto function = MakeUnique<opt::Function>(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpFunction, void_type_id,
- message_.function_fresh_id(),
+ ir_context, SpvOpFunction, void_type_id, message_.function_fresh_id(),
opt::Instruction::OperandList(
- {{SPV_OPERAND_TYPE_FUNCTION_CONTROL,
- {uint32_t(spv::FunctionControlMask::MaskNone)}},
+ {{SPV_OPERAND_TYPE_FUNCTION_CONTROL, {SpvFunctionControlMaskNone}},
{SPV_OPERAND_TYPE_TYPE_ID,
{fuzzerutil::FindFunctionType(ir_context, {void_type_id})}}})));
// Add the basic block to the function as the sole block, and add the function
// to the module.
function->AddBasicBlock(std::move(basic_block));
- function->SetFunctionEnd(
- MakeUnique<opt::Instruction>(ir_context, spv::Op::OpFunctionEnd, 0, 0,
- opt::Instruction::OperandList()));
+ function->SetFunctionEnd(MakeUnique<opt::Instruction>(
+ ir_context, SpvOpFunctionEnd, 0, 0, opt::Instruction::OperandList()));
ir_context->module()->AddFunction(std::move(function));
ir_context->InvalidateAnalysesExceptFor(opt::IRContext::kAnalysisNone);
diff --git a/source/fuzz/transformation_add_early_terminator_wrapper.h b/source/fuzz/transformation_add_early_terminator_wrapper.h
index 5d0201dd..97cc527c 100644
--- a/source/fuzz/transformation_add_early_terminator_wrapper.h
+++ b/source/fuzz/transformation_add_early_terminator_wrapper.h
@@ -30,7 +30,7 @@ class TransformationAddEarlyTerminatorWrapper : public Transformation {
TransformationAddEarlyTerminatorWrapper(uint32_t function_fresh_id,
uint32_t label_fresh_id,
- spv::Op opcode);
+ SpvOp opcode);
// - |message_.function_fresh_id| and |message_.label_fresh_id| must be fresh
// and distinct.
diff --git a/source/fuzz/transformation_add_function.cpp b/source/fuzz/transformation_add_function.cpp
index 1f61ede7..06cd6572 100644
--- a/source/fuzz/transformation_add_function.cpp
+++ b/source/fuzz/transformation_add_function.cpp
@@ -178,7 +178,7 @@ void TransformationAddFunction::Apply(
}
ir_context->InvalidateAnalysesExceptFor(opt::IRContext::kAnalysisNone);
- assert(spv::Op(message_.instruction(0).opcode()) == spv::Op::OpFunction &&
+ assert(message_.instruction(0).opcode() == SpvOpFunction &&
"The first instruction of an 'add function' transformation must be "
"OpFunction.");
@@ -189,7 +189,7 @@ void TransformationAddFunction::Apply(
} else {
// Inform the fact manager that all blocks in the function are dead.
for (auto& inst : message_.instruction()) {
- if (spv::Op(inst.opcode()) == spv::Op::OpLabel) {
+ if (inst.opcode() == SpvOpLabel) {
transformation_context->GetFactManager()->AddFactBlockIsDead(
inst.result_id());
}
@@ -202,16 +202,16 @@ void TransformationAddFunction::Apply(
// parameters to other functions knowing that it is OK if they get
// over-written.
for (auto& instruction : message_.instruction()) {
- switch (spv::Op(instruction.opcode())) {
- case spv::Op::OpFunctionParameter:
+ switch (instruction.opcode()) {
+ case SpvOpFunctionParameter:
if (ir_context->get_def_use_mgr()
->GetDef(instruction.result_type_id())
- ->opcode() == spv::Op::OpTypePointer) {
+ ->opcode() == SpvOpTypePointer) {
transformation_context->GetFactManager()
->AddFactValueOfPointeeIsIrrelevant(instruction.result_id());
}
break;
- case spv::Op::OpVariable:
+ case SpvOpVariable:
transformation_context->GetFactManager()
->AddFactValueOfPointeeIsIrrelevant(instruction.result_id());
break;
@@ -239,7 +239,7 @@ bool TransformationAddFunction::TryToAddFunction(
// A function must start with OpFunction.
auto function_begin = message_.instruction(0);
- if (spv::Op(function_begin.opcode()) != spv::Op::OpFunction) {
+ if (function_begin.opcode() != SpvOpFunction) {
return false;
}
@@ -256,8 +256,8 @@ bool TransformationAddFunction::TryToAddFunction(
// Iterate through all function parameter instructions, adding parameters to
// the new function.
while (instruction_index < num_instructions &&
- spv::Op(message_.instruction(instruction_index).opcode()) ==
- spv::Op::OpFunctionParameter) {
+ message_.instruction(instruction_index).opcode() ==
+ SpvOpFunctionParameter) {
new_function->AddParameter(InstructionFromMessage(
ir_context, message_.instruction(instruction_index)));
instruction_index++;
@@ -265,19 +265,16 @@ bool TransformationAddFunction::TryToAddFunction(
// After the parameters, there needs to be a label.
if (instruction_index == num_instructions ||
- spv::Op(message_.instruction(instruction_index).opcode()) !=
- spv::Op::OpLabel) {
+ message_.instruction(instruction_index).opcode() != SpvOpLabel) {
return false;
}
// Iterate through the instructions block by block until the end of the
// function is reached.
while (instruction_index < num_instructions &&
- spv::Op(message_.instruction(instruction_index).opcode()) !=
- spv::Op::OpFunctionEnd) {
+ message_.instruction(instruction_index).opcode() != SpvOpFunctionEnd) {
// Invariant: we should always be at a label instruction at this point.
- assert(spv::Op(message_.instruction(instruction_index).opcode()) ==
- spv::Op::OpLabel);
+ assert(message_.instruction(instruction_index).opcode() == SpvOpLabel);
// Make a basic block using the label instruction.
std::unique_ptr<opt::BasicBlock> block =
@@ -288,10 +285,9 @@ bool TransformationAddFunction::TryToAddFunction(
// of the function, adding each such instruction to the block.
instruction_index++;
while (instruction_index < num_instructions &&
- spv::Op(message_.instruction(instruction_index).opcode()) !=
- spv::Op::OpFunctionEnd &&
- spv::Op(message_.instruction(instruction_index).opcode()) !=
- spv::Op::OpLabel) {
+ message_.instruction(instruction_index).opcode() !=
+ SpvOpFunctionEnd &&
+ message_.instruction(instruction_index).opcode() != SpvOpLabel) {
block->AddInstruction(InstructionFromMessage(
ir_context, message_.instruction(instruction_index)));
instruction_index++;
@@ -302,8 +298,7 @@ bool TransformationAddFunction::TryToAddFunction(
// Having considered all the blocks, we should be at the last instruction and
// it needs to be OpFunctionEnd.
if (instruction_index != num_instructions - 1 ||
- spv::Op(message_.instruction(instruction_index).opcode()) !=
- spv::Op::OpFunctionEnd) {
+ message_.instruction(instruction_index).opcode() != SpvOpFunctionEnd) {
return false;
}
// Set the function's final instruction, add the function to the module and
@@ -344,20 +339,20 @@ bool TransformationAddFunction::TryToMakeFunctionLivesafe(
for (auto& block : *added_function) {
for (auto& inst : block) {
switch (inst.opcode()) {
- case spv::Op::OpKill:
- case spv::Op::OpUnreachable:
+ case SpvOpKill:
+ case SpvOpUnreachable:
if (!TryToTurnKillOrUnreachableIntoReturn(ir_context, added_function,
&inst)) {
return false;
}
break;
- case spv::Op::OpAccessChain:
- case spv::Op::OpInBoundsAccessChain:
+ case SpvOpAccessChain:
+ case SpvOpInBoundsAccessChain:
if (!TryToClampAccessChainIndices(ir_context, &inst)) {
return false;
}
break;
- case spv::Op::OpFunctionCall:
+ case SpvOpFunctionCall:
// A livesafe function my only call other livesafe functions.
if (!transformation_context.GetFactManager()->FunctionIsLivesafe(
inst.GetSingleWordInOperand(0))) {
@@ -409,7 +404,7 @@ bool TransformationAddFunction::TryToAddLoopLimiters(
auto loop_limit_constant_id_instr =
ir_context->get_def_use_mgr()->GetDef(message_.loop_limit_constant_id());
if (!loop_limit_constant_id_instr ||
- loop_limit_constant_id_instr->opcode() != spv::Op::OpConstant) {
+ loop_limit_constant_id_instr->opcode() != SpvOpConstant) {
// The loop limit constant id instruction must exist and have an
// appropriate opcode.
return false;
@@ -417,7 +412,7 @@ bool TransformationAddFunction::TryToAddLoopLimiters(
auto loop_limit_type = ir_context->get_def_use_mgr()->GetDef(
loop_limit_constant_id_instr->type_id());
- if (loop_limit_type->opcode() != spv::Op::OpTypeInt ||
+ if (loop_limit_type->opcode() != SpvOpTypeInt ||
loop_limit_type->GetSingleWordInOperand(0) != 32) {
// The type of the loop limit constant must be 32-bit integer. It
// doesn't actually matter whether the integer is signed or not.
@@ -462,7 +457,7 @@ bool TransformationAddFunction::TryToAddLoopLimiters(
// Look for pointer-to-unsigned int type.
opt::analysis::Pointer pointer_to_unsigned_int_type(
- registered_unsigned_int_type, spv::StorageClass::Function);
+ registered_unsigned_int_type, SpvStorageClassFunction);
uint32_t pointer_to_unsigned_int_type_id =
ir_context->get_type_mgr()->GetId(&pointer_to_unsigned_int_type);
if (!pointer_to_unsigned_int_type_id) {
@@ -482,13 +477,13 @@ bool TransformationAddFunction::TryToAddLoopLimiters(
// Declare the loop limiter variable at the start of the function's entry
// block, via an instruction of the form:
- // %loop_limiter_var = spv::Op::OpVariable %ptr_to_uint Function %zero
+ // %loop_limiter_var = SpvOpVariable %ptr_to_uint Function %zero
added_function->begin()->begin()->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpVariable, pointer_to_unsigned_int_type_id,
+ ir_context, SpvOpVariable, pointer_to_unsigned_int_type_id,
message_.loop_limiter_variable_id(),
- opt::Instruction::OperandList({{SPV_OPERAND_TYPE_STORAGE_CLASS,
- {uint32_t(spv::StorageClass::Function)}},
- {SPV_OPERAND_TYPE_ID, {zero_id}}})));
+ opt::Instruction::OperandList(
+ {{SPV_OPERAND_TYPE_STORAGE_CLASS, {SpvStorageClassFunction}},
+ {SPV_OPERAND_TYPE_ID, {zero_id}}})));
// Update the module's id bound since we have added the loop limiter
// variable id.
fuzzerutil::UpdateModuleIdBound(ir_context,
@@ -594,11 +589,10 @@ bool TransformationAddFunction::TryToAddLoopLimiters(
auto back_edge_block = ir_context->cfg()->block(back_edge_block_id);
auto back_edge_block_terminator = back_edge_block->terminator();
bool compare_using_greater_than_equal;
- if (back_edge_block_terminator->opcode() == spv::Op::OpBranch) {
+ if (back_edge_block_terminator->opcode() == SpvOpBranch) {
compare_using_greater_than_equal = true;
} else {
- assert(back_edge_block_terminator->opcode() ==
- spv::Op::OpBranchConditional);
+ assert(back_edge_block_terminator->opcode() == SpvOpBranchConditional);
assert(((back_edge_block_terminator->GetSingleWordInOperand(1) ==
loop_header->id() &&
back_edge_block_terminator->GetSingleWordInOperand(2) ==
@@ -619,7 +613,7 @@ bool TransformationAddFunction::TryToAddLoopLimiters(
// Add a load from the loop limiter variable, of the form:
// %t1 = OpLoad %uint32 %loop_limiter
new_instructions.push_back(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpLoad, unsigned_int_type_id,
+ ir_context, SpvOpLoad, unsigned_int_type_id,
loop_limiter_info.load_id(),
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {message_.loop_limiter_variable_id()}}})));
@@ -627,7 +621,7 @@ bool TransformationAddFunction::TryToAddLoopLimiters(
// Increment the loaded value:
// %t2 = OpIAdd %uint32 %t1 %one
new_instructions.push_back(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpIAdd, unsigned_int_type_id,
+ ir_context, SpvOpIAdd, unsigned_int_type_id,
loop_limiter_info.increment_id(),
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {loop_limiter_info.load_id()}},
@@ -636,7 +630,7 @@ bool TransformationAddFunction::TryToAddLoopLimiters(
// Store the incremented value back to the loop limiter variable:
// OpStore %loop_limiter %t2
new_instructions.push_back(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpStore, 0, 0,
+ ir_context, SpvOpStore, 0, 0,
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {message_.loop_limiter_variable_id()}},
{SPV_OPERAND_TYPE_ID, {loop_limiter_info.increment_id()}}})));
@@ -647,18 +641,17 @@ bool TransformationAddFunction::TryToAddLoopLimiters(
// %t3 = OpULessThan %bool %t1 %loop_limit
new_instructions.push_back(MakeUnique<opt::Instruction>(
ir_context,
- compare_using_greater_than_equal ? spv::Op::OpUGreaterThanEqual
- : spv::Op::OpULessThan,
+ compare_using_greater_than_equal ? SpvOpUGreaterThanEqual
+ : SpvOpULessThan,
bool_type_id, loop_limiter_info.compare_id(),
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {loop_limiter_info.load_id()}},
{SPV_OPERAND_TYPE_ID, {message_.loop_limit_constant_id()}}})));
- if (back_edge_block_terminator->opcode() == spv::Op::OpBranchConditional) {
+ if (back_edge_block_terminator->opcode() == SpvOpBranchConditional) {
new_instructions.push_back(MakeUnique<opt::Instruction>(
ir_context,
- compare_using_greater_than_equal ? spv::Op::OpLogicalOr
- : spv::Op::OpLogicalAnd,
+ compare_using_greater_than_equal ? SpvOpLogicalOr : SpvOpLogicalAnd,
bool_type_id, loop_limiter_info.logical_op_id(),
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID,
@@ -676,11 +669,11 @@ bool TransformationAddFunction::TryToAddLoopLimiters(
back_edge_block_terminator->InsertBefore(std::move(new_instructions));
}
- if (back_edge_block_terminator->opcode() == spv::Op::OpBranchConditional) {
+ if (back_edge_block_terminator->opcode() == SpvOpBranchConditional) {
back_edge_block_terminator->SetInOperand(
0, {loop_limiter_info.logical_op_id()});
} else {
- assert(back_edge_block_terminator->opcode() == spv::Op::OpBranch &&
+ assert(back_edge_block_terminator->opcode() == SpvOpBranch &&
"Back-edge terminator must be OpBranch or OpBranchConditional");
// Check that, if the merge block starts with OpPhi instructions, suitable
@@ -696,7 +689,7 @@ bool TransformationAddFunction::TryToAddLoopLimiters(
// Augment OpPhi instructions at the loop merge with the given ids.
uint32_t phi_index = 0;
for (auto& inst : *merge_block) {
- if (inst.opcode() != spv::Op::OpPhi) {
+ if (inst.opcode() != SpvOpPhi) {
break;
}
assert(phi_index <
@@ -709,7 +702,7 @@ bool TransformationAddFunction::TryToAddLoopLimiters(
}
// Add the new edge, by changing OpBranch to OpBranchConditional.
- back_edge_block_terminator->SetOpcode(spv::Op::OpBranchConditional);
+ back_edge_block_terminator->SetOpcode(SpvOpBranchConditional);
back_edge_block_terminator->SetInOperands(opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {loop_limiter_info.compare_id()}},
{SPV_OPERAND_TYPE_ID, {loop_header->MergeBlockId()}},
@@ -731,18 +724,18 @@ bool TransformationAddFunction::TryToAddLoopLimiters(
bool TransformationAddFunction::TryToTurnKillOrUnreachableIntoReturn(
opt::IRContext* ir_context, opt::Function* added_function,
opt::Instruction* kill_or_unreachable_inst) const {
- assert((kill_or_unreachable_inst->opcode() == spv::Op::OpKill ||
- kill_or_unreachable_inst->opcode() == spv::Op::OpUnreachable) &&
+ assert((kill_or_unreachable_inst->opcode() == SpvOpKill ||
+ kill_or_unreachable_inst->opcode() == SpvOpUnreachable) &&
"Precondition: instruction must be OpKill or OpUnreachable.");
// Get the function's return type.
auto function_return_type_inst =
ir_context->get_def_use_mgr()->GetDef(added_function->type_id());
- if (function_return_type_inst->opcode() == spv::Op::OpTypeVoid) {
+ if (function_return_type_inst->opcode() == SpvOpTypeVoid) {
// The function has void return type, so change this instruction to
// OpReturn.
- kill_or_unreachable_inst->SetOpcode(spv::Op::OpReturn);
+ kill_or_unreachable_inst->SetOpcode(SpvOpReturn);
} else {
// The function has non-void return type, so change this instruction
// to OpReturnValue, using the value id provided with the
@@ -756,7 +749,7 @@ bool TransformationAddFunction::TryToTurnKillOrUnreachableIntoReturn(
->type_id() != function_return_type_inst->result_id()) {
return false;
}
- kill_or_unreachable_inst->SetOpcode(spv::Op::OpReturnValue);
+ kill_or_unreachable_inst->SetOpcode(SpvOpReturnValue);
kill_or_unreachable_inst->SetInOperands(
{{SPV_OPERAND_TYPE_ID, {message_.kill_unreachable_return_value_id()}}});
}
@@ -765,8 +758,8 @@ bool TransformationAddFunction::TryToTurnKillOrUnreachableIntoReturn(
bool TransformationAddFunction::TryToClampAccessChainIndices(
opt::IRContext* ir_context, opt::Instruction* access_chain_inst) const {
- assert((access_chain_inst->opcode() == spv::Op::OpAccessChain ||
- access_chain_inst->opcode() == spv::Op::OpInBoundsAccessChain) &&
+ assert((access_chain_inst->opcode() == SpvOpAccessChain ||
+ access_chain_inst->opcode() == SpvOpInBoundsAccessChain) &&
"Precondition: instruction must be OpAccessChain or "
"OpInBoundsAccessChain.");
@@ -800,7 +793,7 @@ bool TransformationAddFunction::TryToClampAccessChainIndices(
assert(base_object && "The base object must exist.");
auto pointer_type =
ir_context->get_def_use_mgr()->GetDef(base_object->type_id());
- assert(pointer_type && pointer_type->opcode() == spv::Op::OpTypePointer &&
+ assert(pointer_type && pointer_type->opcode() == SpvOpTypePointer &&
"The base object must have pointer type.");
auto should_be_composite_type = ir_context->get_def_use_mgr()->GetDef(
pointer_type->GetSingleWordInOperand(1));
@@ -831,18 +824,18 @@ bool TransformationAddFunction::TryToClampAccessChainIndices(
auto index_inst = ir_context->get_def_use_mgr()->GetDef(index_id);
auto index_type_inst =
ir_context->get_def_use_mgr()->GetDef(index_inst->type_id());
- assert(index_type_inst->opcode() == spv::Op::OpTypeInt);
+ assert(index_type_inst->opcode() == SpvOpTypeInt);
assert(index_type_inst->GetSingleWordInOperand(0) == 32);
opt::analysis::Integer* index_int_type =
ir_context->get_type_mgr()
->GetType(index_type_inst->result_id())
->AsInteger();
- if (index_inst->opcode() != spv::Op::OpConstant ||
+ if (index_inst->opcode() != SpvOpConstant ||
index_inst->GetSingleWordInOperand(0) >= bound) {
// The index is either non-constant or an out-of-bounds constant, so we
// need to clamp it.
- assert(should_be_composite_type->opcode() != spv::Op::OpTypeStruct &&
+ assert(should_be_composite_type->opcode() != SpvOpTypeStruct &&
"Access chain indices into structures are required to be "
"constants.");
opt::analysis::IntConstant bound_minus_one(index_int_type, {bound - 1});
@@ -873,7 +866,7 @@ bool TransformationAddFunction::TryToClampAccessChainIndices(
// Compare the index with the bound via an instruction of the form:
// %t1 = OpULessThanEqual %bool %index %bound_minus_one
new_instructions.push_back(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpULessThanEqual, bool_type_id, compare_id,
+ ir_context, SpvOpULessThanEqual, bool_type_id, compare_id,
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {index_inst->result_id()}},
{SPV_OPERAND_TYPE_ID, {bound_minus_one_id}}})));
@@ -881,8 +874,7 @@ bool TransformationAddFunction::TryToClampAccessChainIndices(
// Select the index if in-bounds, otherwise one less than the bound:
// %t2 = OpSelect %int_type %t1 %index %bound_minus_one
new_instructions.push_back(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpSelect, index_type_inst->result_id(),
- select_id,
+ ir_context, SpvOpSelect, index_type_inst->result_id(), select_id,
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {compare_id}},
{SPV_OPERAND_TYPE_ID, {index_inst->result_id()}},
@@ -907,20 +899,20 @@ opt::Instruction* TransformationAddFunction::FollowCompositeIndex(
uint32_t index_id) {
uint32_t sub_object_type_id;
switch (composite_type_inst.opcode()) {
- case spv::Op::OpTypeArray:
- case spv::Op::OpTypeRuntimeArray:
+ case SpvOpTypeArray:
+ case SpvOpTypeRuntimeArray:
sub_object_type_id = composite_type_inst.GetSingleWordInOperand(0);
break;
- case spv::Op::OpTypeMatrix:
- case spv::Op::OpTypeVector:
+ case SpvOpTypeMatrix:
+ case SpvOpTypeVector:
sub_object_type_id = composite_type_inst.GetSingleWordInOperand(0);
break;
- case spv::Op::OpTypeStruct: {
+ case SpvOpTypeStruct: {
auto index_inst = ir_context->get_def_use_mgr()->GetDef(index_id);
- assert(index_inst->opcode() == spv::Op::OpConstant);
+ assert(index_inst->opcode() == SpvOpConstant);
assert(ir_context->get_def_use_mgr()
->GetDef(index_inst->type_id())
- ->opcode() == spv::Op::OpTypeInt);
+ ->opcode() == SpvOpTypeInt);
assert(ir_context->get_def_use_mgr()
->GetDef(index_inst->type_id())
->GetSingleWordInOperand(0) == 32);
diff --git a/source/fuzz/transformation_add_global_undef.cpp b/source/fuzz/transformation_add_global_undef.cpp
index 5aca19d9..ec0574a4 100644
--- a/source/fuzz/transformation_add_global_undef.cpp
+++ b/source/fuzz/transformation_add_global_undef.cpp
@@ -39,14 +39,14 @@ bool TransformationAddGlobalUndef::IsApplicable(
auto type = ir_context->get_def_use_mgr()->GetDef(message_.type_id());
// The type must exist, and must not be a function or pointer type.
return type != nullptr && opt::IsTypeInst(type->opcode()) &&
- type->opcode() != spv::Op::OpTypeFunction &&
- type->opcode() != spv::Op::OpTypePointer;
+ type->opcode() != SpvOpTypeFunction &&
+ type->opcode() != SpvOpTypePointer;
}
void TransformationAddGlobalUndef::Apply(
opt::IRContext* ir_context, TransformationContext* /*unused*/) const {
auto new_instruction = MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpUndef, message_.type_id(), message_.fresh_id(),
+ ir_context, SpvOpUndef, message_.type_id(), message_.fresh_id(),
opt::Instruction::OperandList());
auto new_instruction_ptr = new_instruction.get();
ir_context->module()->AddGlobalValue(std::move(new_instruction));
diff --git a/source/fuzz/transformation_add_global_variable.cpp b/source/fuzz/transformation_add_global_variable.cpp
index 6e82d594..814d01b3 100644
--- a/source/fuzz/transformation_add_global_variable.cpp
+++ b/source/fuzz/transformation_add_global_variable.cpp
@@ -24,11 +24,11 @@ TransformationAddGlobalVariable::TransformationAddGlobalVariable(
: message_(std::move(message)) {}
TransformationAddGlobalVariable::TransformationAddGlobalVariable(
- uint32_t fresh_id, uint32_t type_id, spv::StorageClass storage_class,
+ uint32_t fresh_id, uint32_t type_id, SpvStorageClass storage_class,
uint32_t initializer_id, bool value_is_irrelevant) {
message_.set_fresh_id(fresh_id);
message_.set_type_id(type_id);
- message_.set_storage_class(uint32_t(storage_class));
+ message_.set_storage_class(storage_class);
message_.set_initializer_id(initializer_id);
message_.set_value_is_irrelevant(value_is_irrelevant);
}
@@ -41,10 +41,10 @@ bool TransformationAddGlobalVariable::IsApplicable(
}
// The storage class must be Private or Workgroup.
- auto storage_class = static_cast<spv::StorageClass>(message_.storage_class());
+ auto storage_class = static_cast<SpvStorageClass>(message_.storage_class());
switch (storage_class) {
- case spv::StorageClass::Private:
- case spv::StorageClass::Workgroup:
+ case SpvStorageClassPrivate:
+ case SpvStorageClassWorkgroup:
break;
default:
assert(false && "Unsupported storage class.");
@@ -66,7 +66,7 @@ bool TransformationAddGlobalVariable::IsApplicable(
}
if (message_.initializer_id()) {
// An initializer is not allowed if the storage class is Workgroup.
- if (storage_class == spv::StorageClass::Workgroup) {
+ if (storage_class == SpvStorageClassWorkgroup) {
assert(false &&
"By construction this transformation should not have an "
"initializer when Workgroup storage class is used.");
@@ -95,7 +95,7 @@ void TransformationAddGlobalVariable::Apply(
TransformationContext* transformation_context) const {
opt::Instruction* new_instruction = fuzzerutil::AddGlobalVariable(
ir_context, message_.fresh_id(), message_.type_id(),
- static_cast<spv::StorageClass>(message_.storage_class()),
+ static_cast<SpvStorageClass>(message_.storage_class()),
message_.initializer_id());
// Inform the def-use manager about the new instruction.
diff --git a/source/fuzz/transformation_add_global_variable.h b/source/fuzz/transformation_add_global_variable.h
index 01782198..d74d48a2 100644
--- a/source/fuzz/transformation_add_global_variable.h
+++ b/source/fuzz/transformation_add_global_variable.h
@@ -29,7 +29,7 @@ class TransformationAddGlobalVariable : public Transformation {
protobufs::TransformationAddGlobalVariable message);
TransformationAddGlobalVariable(uint32_t fresh_id, uint32_t type_id,
- spv::StorageClass storage_class,
+ SpvStorageClass storage_class,
uint32_t initializer_id,
bool value_is_irrelevant);
diff --git a/source/fuzz/transformation_add_image_sample_unused_components.cpp b/source/fuzz/transformation_add_image_sample_unused_components.cpp
index 018fed4c..1ead82bc 100644
--- a/source/fuzz/transformation_add_image_sample_unused_components.cpp
+++ b/source/fuzz/transformation_add_image_sample_unused_components.cpp
@@ -73,7 +73,7 @@ bool TransformationAddImageSampleUnusedComponents::IsApplicable(
// It must be an OpCompositeConstruct instruction such that it can be checked
// that the original components are present.
if (coordinate_with_unused_components_instruction->opcode() !=
- spv::Op::OpCompositeConstruct) {
+ SpvOpCompositeConstruct) {
return false;
}
diff --git a/source/fuzz/transformation_add_local_variable.cpp b/source/fuzz/transformation_add_local_variable.cpp
index 9ee210cb..21768d22 100644
--- a/source/fuzz/transformation_add_local_variable.cpp
+++ b/source/fuzz/transformation_add_local_variable.cpp
@@ -43,10 +43,8 @@ bool TransformationAddLocalVariable::IsApplicable(
// function storage class.
auto type_instruction =
ir_context->get_def_use_mgr()->GetDef(message_.type_id());
- if (!type_instruction ||
- type_instruction->opcode() != spv::Op::OpTypePointer ||
- spv::StorageClass(type_instruction->GetSingleWordInOperand(0)) !=
- spv::StorageClass::Function) {
+ if (!type_instruction || type_instruction->opcode() != SpvOpTypePointer ||
+ type_instruction->GetSingleWordInOperand(0) != SpvStorageClassFunction) {
return false;
}
// The initializer must...
diff --git a/source/fuzz/transformation_add_loop_preheader.cpp b/source/fuzz/transformation_add_loop_preheader.cpp
index 4b66b69f..71ab18da 100644
--- a/source/fuzz/transformation_add_loop_preheader.cpp
+++ b/source/fuzz/transformation_add_loop_preheader.cpp
@@ -120,8 +120,8 @@ void TransformationAddLoopPreheader::Apply(
// If |use_inst| is not a branch or merge instruction, it should not be
// changed.
if (!use_inst->IsBranch() &&
- use_inst->opcode() != spv::Op::OpSelectionMerge &&
- use_inst->opcode() != spv::Op::OpLoopMerge) {
+ use_inst->opcode() != SpvOpSelectionMerge &&
+ use_inst->opcode() != SpvOpLoopMerge) {
return;
}
@@ -134,7 +134,7 @@ void TransformationAddLoopPreheader::Apply(
// Make a new block for the preheader.
std::unique_ptr<opt::BasicBlock> preheader = MakeUnique<opt::BasicBlock>(
std::unique_ptr<opt::Instruction>(new opt::Instruction(
- ir_context, spv::Op::OpLabel, 0, message_.fresh_id(), {})));
+ ir_context, SpvOpLabel, 0, message_.fresh_id(), {})));
uint32_t phi_ids_used = 0;
@@ -183,7 +183,7 @@ void TransformationAddLoopPreheader::Apply(
fuzzerutil::UpdateModuleIdBound(ir_context, fresh_phi_id);
preheader->AddInstruction(std::unique_ptr<opt::Instruction>(
- new opt::Instruction(ir_context, spv::Op::OpPhi, phi_inst->type_id(),
+ new opt::Instruction(ir_context, SpvOpPhi, phi_inst->type_id(),
fresh_phi_id, preheader_in_operands)));
// Update the OpPhi instruction in the header so that it refers to the
@@ -202,7 +202,7 @@ void TransformationAddLoopPreheader::Apply(
// Add an unconditional branch from the preheader to the header.
preheader->AddInstruction(
std::unique_ptr<opt::Instruction>(new opt::Instruction(
- ir_context, spv::Op::OpBranch, 0, 0,
+ ir_context, SpvOpBranch, 0, 0,
std::initializer_list<opt::Operand>{opt::Operand(
spv_operand_type_t::SPV_OPERAND_TYPE_ID, {loop_header->id()})})));
diff --git a/source/fuzz/transformation_add_loop_to_create_int_constant_synonym.cpp b/source/fuzz/transformation_add_loop_to_create_int_constant_synonym.cpp
index 00030e79..657fafa4 100644
--- a/source/fuzz/transformation_add_loop_to_create_int_constant_synonym.cpp
+++ b/source/fuzz/transformation_add_loop_to_create_int_constant_synonym.cpp
@@ -262,13 +262,13 @@ void TransformationAddLoopToCreateIntConstantSynonym::Apply(
// Create the loop header block.
std::unique_ptr<opt::BasicBlock> loop_block =
MakeUnique<opt::BasicBlock>(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpLabel, 0, message_.loop_id(),
+ ir_context, SpvOpLabel, 0, message_.loop_id(),
opt::Instruction::OperandList{}));
// Add OpPhi instructions to retrieve the current value of the counter and of
// the temporary variable that will be decreased at each operation.
loop_block->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpPhi, const_0_def->type_id(), message_.ctr_id(),
+ ir_context, SpvOpPhi, const_0_def->type_id(), message_.ctr_id(),
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_ID, {const_0_id}},
{SPV_OPERAND_TYPE_ID, {pred_id}},
@@ -276,8 +276,7 @@ void TransformationAddLoopToCreateIntConstantSynonym::Apply(
{SPV_OPERAND_TYPE_ID, {last_loop_block_id}}}));
loop_block->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpPhi, initial_val_def->type_id(),
- message_.temp_id(),
+ ir_context, SpvOpPhi, initial_val_def->type_id(), message_.temp_id(),
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_ID, {message_.initial_val_id()}},
{SPV_OPERAND_TYPE_ID, {pred_id}},
@@ -292,7 +291,7 @@ void TransformationAddLoopToCreateIntConstantSynonym::Apply(
// Add an instruction to subtract the step value from the temporary value.
// The value of this id will converge to the constant in the last iteration.
other_instructions.push_back(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpISub, initial_val_def->type_id(),
+ ir_context, SpvOpISub, initial_val_def->type_id(),
message_.eventual_syn_id(),
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_ID, {message_.temp_id()}},
@@ -300,15 +299,15 @@ void TransformationAddLoopToCreateIntConstantSynonym::Apply(
// Add an instruction to increment the counter.
other_instructions.push_back(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpIAdd, const_0_def->type_id(),
+ ir_context, SpvOpIAdd, const_0_def->type_id(),
message_.incremented_ctr_id(),
opt::Instruction::OperandList{{SPV_OPERAND_TYPE_ID, {message_.ctr_id()}},
{SPV_OPERAND_TYPE_ID, {const_1_id}}}));
// Add an instruction to decide whether the condition holds.
other_instructions.push_back(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpSLessThan,
- fuzzerutil::MaybeGetBoolType(ir_context), message_.cond_id(),
+ ir_context, SpvOpSLessThan, fuzzerutil::MaybeGetBoolType(ir_context),
+ message_.cond_id(),
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_ID, {message_.incremented_ctr_id()}},
{SPV_OPERAND_TYPE_ID, {message_.num_iterations_id()}}}));
@@ -317,19 +316,18 @@ void TransformationAddLoopToCreateIntConstantSynonym::Apply(
// the existing block, the continue block is the last block in the loop
// (either the loop itself or the additional block).
std::unique_ptr<opt::Instruction> merge_inst = MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpLoopMerge, 0, 0,
+ ir_context, SpvOpLoopMerge, 0, 0,
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_ID, {message_.block_after_loop_id()}},
{SPV_OPERAND_TYPE_ID, {last_loop_block_id}},
- {SPV_OPERAND_TYPE_LOOP_CONTROL,
- {uint32_t(spv::LoopControlMask::MaskNone)}}});
+ {SPV_OPERAND_TYPE_LOOP_CONTROL, {SpvLoopControlMaskNone}}});
// Define a conditional branch instruction, branching to the loop header if
// the condition holds, and to the existing block otherwise. This instruction
// will be added to the last block in the loop.
std::unique_ptr<opt::Instruction> conditional_branch =
MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpBranchConditional, 0, 0,
+ ir_context, SpvOpBranchConditional, 0, 0,
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_ID, {message_.cond_id()}},
{SPV_OPERAND_TYPE_ID, {message_.loop_id()}},
@@ -342,7 +340,7 @@ void TransformationAddLoopToCreateIntConstantSynonym::Apply(
std::unique_ptr<opt::BasicBlock> additional_block =
MakeUnique<opt::BasicBlock>(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpLabel, 0, message_.additional_block_id(),
+ ir_context, SpvOpLabel, 0, message_.additional_block_id(),
opt::Instruction::OperandList{}));
for (auto& instruction : other_instructions) {
@@ -356,7 +354,7 @@ void TransformationAddLoopToCreateIntConstantSynonym::Apply(
// Add an unconditional branch from the header to the additional block.
loop_block->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpBranch, 0, 0,
+ ir_context, SpvOpBranch, 0, 0,
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_ID, {message_.additional_block_id()}}}));
@@ -386,14 +384,14 @@ void TransformationAddLoopToCreateIntConstantSynonym::Apply(
ir_context->get_def_use_mgr()->ForEachUse(
message_.block_after_loop_id(),
[this](opt::Instruction* instruction, uint32_t operand_index) {
- assert(instruction->opcode() != spv::Op::OpLoopMerge &&
- instruction->opcode() != spv::Op::OpSelectionMerge &&
+ assert(instruction->opcode() != SpvOpLoopMerge &&
+ instruction->opcode() != SpvOpSelectionMerge &&
"The block should not be referenced by OpLoopMerge or "
"OpSelectionMerge, by construction.");
// Replace all uses of the label inside branch instructions.
- if (instruction->opcode() == spv::Op::OpBranch ||
- instruction->opcode() == spv::Op::OpBranchConditional ||
- instruction->opcode() == spv::Op::OpSwitch) {
+ if (instruction->opcode() == SpvOpBranch ||
+ instruction->opcode() == SpvOpBranchConditional ||
+ instruction->opcode() == SpvOpSwitch) {
instruction->SetOperand(operand_index, {message_.loop_id()});
}
});
@@ -412,7 +410,7 @@ void TransformationAddLoopToCreateIntConstantSynonym::Apply(
// |message_.initial_value_id|, since this is the value that is decremented in
// the loop.
block_after_loop->begin()->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpPhi, initial_val_def->type_id(), message_.syn_id(),
+ ir_context, SpvOpPhi, initial_val_def->type_id(), message_.syn_id(),
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_ID, {message_.eventual_syn_id()}},
{SPV_OPERAND_TYPE_ID, {last_loop_block_id}}}));
diff --git a/source/fuzz/transformation_add_no_contraction_decoration.cpp b/source/fuzz/transformation_add_no_contraction_decoration.cpp
index 07a31e5c..992a216b 100644
--- a/source/fuzz/transformation_add_no_contraction_decoration.cpp
+++ b/source/fuzz/transformation_add_no_contraction_decoration.cpp
@@ -43,8 +43,8 @@ bool TransformationAddNoContractionDecoration::IsApplicable(
void TransformationAddNoContractionDecoration::Apply(
opt::IRContext* ir_context, TransformationContext* /*unused*/) const {
// Add a NoContraction decoration targeting |message_.result_id|.
- ir_context->get_decoration_mgr()->AddDecoration(
- message_.result_id(), uint32_t(spv::Decoration::NoContraction));
+ ir_context->get_decoration_mgr()->AddDecoration(message_.result_id(),
+ SpvDecorationNoContraction);
}
protobufs::Transformation TransformationAddNoContractionDecoration::ToMessage()
@@ -54,50 +54,50 @@ protobufs::Transformation TransformationAddNoContractionDecoration::ToMessage()
return result;
}
-bool TransformationAddNoContractionDecoration::IsArithmetic(spv::Op opcode) {
+bool TransformationAddNoContractionDecoration::IsArithmetic(uint32_t opcode) {
switch (opcode) {
- case spv::Op::OpSNegate:
- case spv::Op::OpFNegate:
- case spv::Op::OpIAdd:
- case spv::Op::OpFAdd:
- case spv::Op::OpISub:
- case spv::Op::OpFSub:
- case spv::Op::OpIMul:
- case spv::Op::OpFMul:
- case spv::Op::OpUDiv:
- case spv::Op::OpSDiv:
- case spv::Op::OpFDiv:
- case spv::Op::OpUMod:
- case spv::Op::OpSRem:
- case spv::Op::OpSMod:
- case spv::Op::OpFRem:
- case spv::Op::OpFMod:
- case spv::Op::OpVectorTimesScalar:
- case spv::Op::OpMatrixTimesScalar:
- case spv::Op::OpVectorTimesMatrix:
- case spv::Op::OpMatrixTimesVector:
- case spv::Op::OpMatrixTimesMatrix:
- case spv::Op::OpOuterProduct:
- case spv::Op::OpDot:
- case spv::Op::OpIAddCarry:
- case spv::Op::OpISubBorrow:
- case spv::Op::OpUMulExtended:
- case spv::Op::OpSMulExtended:
- case spv::Op::OpAny:
- case spv::Op::OpAll:
- case spv::Op::OpIsNan:
- case spv::Op::OpIsInf:
- case spv::Op::OpIsFinite:
- case spv::Op::OpIsNormal:
- case spv::Op::OpSignBitSet:
- case spv::Op::OpLessOrGreater:
- case spv::Op::OpOrdered:
- case spv::Op::OpUnordered:
- case spv::Op::OpLogicalEqual:
- case spv::Op::OpLogicalNotEqual:
- case spv::Op::OpLogicalOr:
- case spv::Op::OpLogicalAnd:
- case spv::Op::OpLogicalNot:
+ case SpvOpSNegate:
+ case SpvOpFNegate:
+ case SpvOpIAdd:
+ case SpvOpFAdd:
+ case SpvOpISub:
+ case SpvOpFSub:
+ case SpvOpIMul:
+ case SpvOpFMul:
+ case SpvOpUDiv:
+ case SpvOpSDiv:
+ case SpvOpFDiv:
+ case SpvOpUMod:
+ case SpvOpSRem:
+ case SpvOpSMod:
+ case SpvOpFRem:
+ case SpvOpFMod:
+ case SpvOpVectorTimesScalar:
+ case SpvOpMatrixTimesScalar:
+ case SpvOpVectorTimesMatrix:
+ case SpvOpMatrixTimesVector:
+ case SpvOpMatrixTimesMatrix:
+ case SpvOpOuterProduct:
+ case SpvOpDot:
+ case SpvOpIAddCarry:
+ case SpvOpISubBorrow:
+ case SpvOpUMulExtended:
+ case SpvOpSMulExtended:
+ case SpvOpAny:
+ case SpvOpAll:
+ case SpvOpIsNan:
+ case SpvOpIsInf:
+ case SpvOpIsFinite:
+ case SpvOpIsNormal:
+ case SpvOpSignBitSet:
+ case SpvOpLessOrGreater:
+ case SpvOpOrdered:
+ case SpvOpUnordered:
+ case SpvOpLogicalEqual:
+ case SpvOpLogicalNotEqual:
+ case SpvOpLogicalOr:
+ case SpvOpLogicalAnd:
+ case SpvOpLogicalNot:
return true;
default:
return false;
diff --git a/source/fuzz/transformation_add_no_contraction_decoration.h b/source/fuzz/transformation_add_no_contraction_decoration.h
index 4235dc10..2f78d429 100644
--- a/source/fuzz/transformation_add_no_contraction_decoration.h
+++ b/source/fuzz/transformation_add_no_contraction_decoration.h
@@ -50,7 +50,7 @@ class TransformationAddNoContractionDecoration : public Transformation {
// Returns true if and only if |opcode| is the opcode of an arithmetic
// instruction, as defined by the SPIR-V specification.
- static bool IsArithmetic(spv::Op opcode);
+ static bool IsArithmetic(uint32_t opcode);
private:
protobufs::TransformationAddNoContractionDecoration message_;
diff --git a/source/fuzz/transformation_add_opphi_synonym.cpp b/source/fuzz/transformation_add_opphi_synonym.cpp
index 31c56b66..3c4698a7 100644
--- a/source/fuzz/transformation_add_opphi_synonym.cpp
+++ b/source/fuzz/transformation_add_opphi_synonym.cpp
@@ -142,8 +142,8 @@ void TransformationAddOpPhiSynonym::Apply(
// Add a new OpPhi instructions at the beginning of the block.
ir_context->get_instr_block(message_.block_id())
->begin()
- .InsertBefore(MakeUnique<opt::Instruction>(ir_context, spv::Op::OpPhi,
- type_id, message_.fresh_id(),
+ .InsertBefore(MakeUnique<opt::Instruction>(ir_context, SpvOpPhi, type_id,
+ message_.fresh_id(),
std::move(operand_list)));
// Update the module id bound.
@@ -186,9 +186,9 @@ bool TransformationAddOpPhiSynonym::CheckTypeIsAllowed(
if (type->AsPointer()) {
auto storage_class = type->AsPointer()->storage_class();
return ir_context->get_feature_mgr()->HasCapability(
- spv::Capability::VariablePointers) &&
- (storage_class == spv::StorageClass::Workgroup ||
- storage_class == spv::StorageClass::StorageBuffer);
+ SpvCapabilityVariablePointers) &&
+ (storage_class == SpvStorageClassWorkgroup ||
+ storage_class == SpvStorageClassStorageBuffer);
}
// We do not allow other types.
diff --git a/source/fuzz/transformation_add_parameter.cpp b/source/fuzz/transformation_add_parameter.cpp
index 8bd2ed78..48de3e83 100644
--- a/source/fuzz/transformation_add_parameter.cpp
+++ b/source/fuzz/transformation_add_parameter.cpp
@@ -112,7 +112,7 @@ void TransformationAddParameter::Apply(
// Add new parameters to the function.
function->AddParameter(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpFunctionParameter, new_parameter_type_id,
+ ir_context, SpvOpFunctionParameter, new_parameter_type_id,
message_.parameter_fresh_id(), opt::Instruction::OperandList()));
fuzzerutil::UpdateModuleIdBound(ir_context, message_.parameter_fresh_id());
@@ -178,16 +178,16 @@ bool TransformationAddParameter::IsParameterTypeSupported(
// Think about other type instructions we can add here.
opt::Instruction* type_inst = ir_context->get_def_use_mgr()->GetDef(type_id);
switch (type_inst->opcode()) {
- case spv::Op::OpTypeBool:
- case spv::Op::OpTypeInt:
- case spv::Op::OpTypeFloat:
- case spv::Op::OpTypeMatrix:
- case spv::Op::OpTypeVector:
+ case SpvOpTypeBool:
+ case SpvOpTypeInt:
+ case SpvOpTypeFloat:
+ case SpvOpTypeMatrix:
+ case SpvOpTypeVector:
return true;
- case spv::Op::OpTypeArray:
+ case SpvOpTypeArray:
return IsParameterTypeSupported(ir_context,
type_inst->GetSingleWordInOperand(0));
- case spv::Op::OpTypeStruct:
+ case SpvOpTypeStruct:
if (fuzzerutil::HasBlockOrBufferBlockDecoration(ir_context, type_id)) {
return false;
}
@@ -198,13 +198,13 @@ bool TransformationAddParameter::IsParameterTypeSupported(
}
}
return true;
- case spv::Op::OpTypePointer: {
- spv::StorageClass storage_class =
- static_cast<spv::StorageClass>(type_inst->GetSingleWordInOperand(0));
+ case SpvOpTypePointer: {
+ SpvStorageClass storage_class =
+ static_cast<SpvStorageClass>(type_inst->GetSingleWordInOperand(0));
switch (storage_class) {
- case spv::StorageClass::Private:
- case spv::StorageClass::Function:
- case spv::StorageClass::Workgroup: {
+ case SpvStorageClassPrivate:
+ case SpvStorageClassFunction:
+ case SpvStorageClassWorkgroup: {
return IsParameterTypeSupported(ir_context,
type_inst->GetSingleWordInOperand(1));
}
diff --git a/source/fuzz/transformation_add_relaxed_decoration.cpp b/source/fuzz/transformation_add_relaxed_decoration.cpp
index 6cd4ecbb..b66a1a83 100644
--- a/source/fuzz/transformation_add_relaxed_decoration.cpp
+++ b/source/fuzz/transformation_add_relaxed_decoration.cpp
@@ -54,7 +54,7 @@ void TransformationAddRelaxedDecoration::Apply(
opt::IRContext* ir_context, TransformationContext* /*unused*/) const {
// Add a RelaxedPrecision decoration targeting |message_.result_id|.
ir_context->get_decoration_mgr()->AddDecoration(
- message_.result_id(), uint32_t(spv::Decoration::RelaxedPrecision));
+ message_.result_id(), SpvDecorationRelaxedPrecision);
}
protobufs::Transformation TransformationAddRelaxedDecoration::ToMessage()
@@ -64,77 +64,77 @@ protobufs::Transformation TransformationAddRelaxedDecoration::ToMessage()
return result;
}
-bool TransformationAddRelaxedDecoration::IsNumeric(spv::Op opcode) {
+bool TransformationAddRelaxedDecoration::IsNumeric(uint32_t opcode) {
switch (opcode) {
- case spv::Op::OpConvertFToU:
- case spv::Op::OpConvertFToS:
- case spv::Op::OpConvertSToF:
- case spv::Op::OpConvertUToF:
- case spv::Op::OpUConvert:
- case spv::Op::OpSConvert:
- case spv::Op::OpFConvert:
- case spv::Op::OpConvertPtrToU:
- case spv::Op::OpSatConvertSToU:
- case spv::Op::OpSatConvertUToS:
- case spv::Op::OpVectorExtractDynamic:
- case spv::Op::OpVectorInsertDynamic:
- case spv::Op::OpVectorShuffle:
- case spv::Op::OpTranspose:
- case spv::Op::OpSNegate:
- case spv::Op::OpFNegate:
- case spv::Op::OpIAdd:
- case spv::Op::OpFAdd:
- case spv::Op::OpISub:
- case spv::Op::OpFSub:
- case spv::Op::OpIMul:
- case spv::Op::OpFMul:
- case spv::Op::OpUDiv:
- case spv::Op::OpSDiv:
- case spv::Op::OpFDiv:
- case spv::Op::OpUMod:
- case spv::Op::OpSRem:
- case spv::Op::OpSMod:
- case spv::Op::OpFRem:
- case spv::Op::OpFMod:
- case spv::Op::OpVectorTimesScalar:
- case spv::Op::OpMatrixTimesScalar:
- case spv::Op::OpVectorTimesMatrix:
- case spv::Op::OpMatrixTimesVector:
- case spv::Op::OpMatrixTimesMatrix:
- case spv::Op::OpOuterProduct:
- case spv::Op::OpDot:
- case spv::Op::OpIAddCarry:
- case spv::Op::OpISubBorrow:
- case spv::Op::OpUMulExtended:
- case spv::Op::OpSMulExtended:
- case spv::Op::OpShiftRightLogical:
- case spv::Op::OpShiftRightArithmetic:
- case spv::Op::OpShiftLeftLogical:
- case spv::Op::OpBitwiseOr:
- case spv::Op::OpBitwiseXor:
- case spv::Op::OpBitwiseAnd:
- case spv::Op::OpNot:
- case spv::Op::OpBitFieldInsert:
- case spv::Op::OpBitFieldSExtract:
- case spv::Op::OpBitFieldUExtract:
- case spv::Op::OpBitReverse:
- case spv::Op::OpBitCount:
- case spv::Op::OpAtomicLoad:
- case spv::Op::OpAtomicStore:
- case spv::Op::OpAtomicExchange:
- case spv::Op::OpAtomicCompareExchange:
- case spv::Op::OpAtomicCompareExchangeWeak:
- case spv::Op::OpAtomicIIncrement:
- case spv::Op::OpAtomicIDecrement:
- case spv::Op::OpAtomicIAdd:
- case spv::Op::OpAtomicISub:
- case spv::Op::OpAtomicSMin:
- case spv::Op::OpAtomicUMin:
- case spv::Op::OpAtomicSMax:
- case spv::Op::OpAtomicUMax:
- case spv::Op::OpAtomicAnd:
- case spv::Op::OpAtomicOr:
- case spv::Op::OpAtomicXor:
+ case SpvOpConvertFToU:
+ case SpvOpConvertFToS:
+ case SpvOpConvertSToF:
+ case SpvOpConvertUToF:
+ case SpvOpUConvert:
+ case SpvOpSConvert:
+ case SpvOpFConvert:
+ case SpvOpConvertPtrToU:
+ case SpvOpSatConvertSToU:
+ case SpvOpSatConvertUToS:
+ case SpvOpVectorExtractDynamic:
+ case SpvOpVectorInsertDynamic:
+ case SpvOpVectorShuffle:
+ case SpvOpTranspose:
+ case SpvOpSNegate:
+ case SpvOpFNegate:
+ case SpvOpIAdd:
+ case SpvOpFAdd:
+ case SpvOpISub:
+ case SpvOpFSub:
+ case SpvOpIMul:
+ case SpvOpFMul:
+ case SpvOpUDiv:
+ case SpvOpSDiv:
+ case SpvOpFDiv:
+ case SpvOpUMod:
+ case SpvOpSRem:
+ case SpvOpSMod:
+ case SpvOpFRem:
+ case SpvOpFMod:
+ case SpvOpVectorTimesScalar:
+ case SpvOpMatrixTimesScalar:
+ case SpvOpVectorTimesMatrix:
+ case SpvOpMatrixTimesVector:
+ case SpvOpMatrixTimesMatrix:
+ case SpvOpOuterProduct:
+ case SpvOpDot:
+ case SpvOpIAddCarry:
+ case SpvOpISubBorrow:
+ case SpvOpUMulExtended:
+ case SpvOpSMulExtended:
+ case SpvOpShiftRightLogical:
+ case SpvOpShiftRightArithmetic:
+ case SpvOpShiftLeftLogical:
+ case SpvOpBitwiseOr:
+ case SpvOpBitwiseXor:
+ case SpvOpBitwiseAnd:
+ case SpvOpNot:
+ case SpvOpBitFieldInsert:
+ case SpvOpBitFieldSExtract:
+ case SpvOpBitFieldUExtract:
+ case SpvOpBitReverse:
+ case SpvOpBitCount:
+ case SpvOpAtomicLoad:
+ case SpvOpAtomicStore:
+ case SpvOpAtomicExchange:
+ case SpvOpAtomicCompareExchange:
+ case SpvOpAtomicCompareExchangeWeak:
+ case SpvOpAtomicIIncrement:
+ case SpvOpAtomicIDecrement:
+ case SpvOpAtomicIAdd:
+ case SpvOpAtomicISub:
+ case SpvOpAtomicSMin:
+ case SpvOpAtomicUMin:
+ case SpvOpAtomicSMax:
+ case SpvOpAtomicUMax:
+ case SpvOpAtomicAnd:
+ case SpvOpAtomicOr:
+ case SpvOpAtomicXor:
return true;
default:
return false;
@@ -147,4 +147,4 @@ std::unordered_set<uint32_t> TransformationAddRelaxedDecoration::GetFreshIds()
}
} // namespace fuzz
-} // namespace spvtools
+} // namespace spvtools \ No newline at end of file
diff --git a/source/fuzz/transformation_add_relaxed_decoration.h b/source/fuzz/transformation_add_relaxed_decoration.h
index e13594e8..c0163497 100644
--- a/source/fuzz/transformation_add_relaxed_decoration.h
+++ b/source/fuzz/transformation_add_relaxed_decoration.h
@@ -52,7 +52,7 @@ class TransformationAddRelaxedDecoration : public Transformation {
// Returns true if and only if |opcode| is the opcode of an instruction
// that operates on 32-bit integers and 32-bit floats
// as defined by the SPIR-V specification.
- static bool IsNumeric(spv::Op opcode);
+ static bool IsNumeric(uint32_t opcode);
private:
protobufs::TransformationAddRelaxedDecoration message_;
diff --git a/source/fuzz/transformation_add_spec_constant_op.cpp b/source/fuzz/transformation_add_spec_constant_op.cpp
index 685f0a4a..19c5e855 100644
--- a/source/fuzz/transformation_add_spec_constant_op.cpp
+++ b/source/fuzz/transformation_add_spec_constant_op.cpp
@@ -26,11 +26,11 @@ TransformationAddSpecConstantOp::TransformationAddSpecConstantOp(
: message_(std::move(message)) {}
TransformationAddSpecConstantOp::TransformationAddSpecConstantOp(
- uint32_t fresh_id, uint32_t type_id, spv::Op opcode,
+ uint32_t fresh_id, uint32_t type_id, SpvOp opcode,
const opt::Instruction::OperandList& operands) {
message_.set_fresh_id(fresh_id);
message_.set_type_id(type_id);
- message_.set_opcode(uint32_t(opcode));
+ message_.set_opcode(opcode);
for (const auto& operand : operands) {
auto* op = message_.add_operand();
op->set_operand_type(operand.type);
@@ -70,8 +70,8 @@ void TransformationAddSpecConstantOp::ApplyImpl(
}
ir_context->AddGlobalValue(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpSpecConstantOp, message_.type_id(),
- message_.fresh_id(), std::move(operands)));
+ ir_context, SpvOpSpecConstantOp, message_.type_id(), message_.fresh_id(),
+ std::move(operands)));
fuzzerutil::UpdateModuleIdBound(ir_context, message_.fresh_id());
}
diff --git a/source/fuzz/transformation_add_spec_constant_op.h b/source/fuzz/transformation_add_spec_constant_op.h
index 665f66a0..29851fde 100644
--- a/source/fuzz/transformation_add_spec_constant_op.h
+++ b/source/fuzz/transformation_add_spec_constant_op.h
@@ -29,7 +29,7 @@ class TransformationAddSpecConstantOp : public Transformation {
protobufs::TransformationAddSpecConstantOp message);
TransformationAddSpecConstantOp(
- uint32_t fresh_id, uint32_t type_id, spv::Op opcode,
+ uint32_t fresh_id, uint32_t type_id, SpvOp opcode,
const opt::Instruction::OperandList& operands);
// - |fresh_id| is a fresh result id in the module.
diff --git a/source/fuzz/transformation_add_synonym.cpp b/source/fuzz/transformation_add_synonym.cpp
index 00df9cf2..69269e5e 100644
--- a/source/fuzz/transformation_add_synonym.cpp
+++ b/source/fuzz/transformation_add_synonym.cpp
@@ -82,7 +82,7 @@ bool TransformationAddSynonym::IsApplicable(
// Check that we can insert |message._synonymous_instruction| before
// |message_.insert_before| instruction. We use OpIAdd to represent some
// instruction that can produce a synonym.
- if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(spv::Op::OpIAdd,
+ if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(SpvOpIAdd,
insert_before_inst)) {
return false;
}
@@ -147,8 +147,7 @@ bool TransformationAddSynonym::IsInstructionValid(
// Instruction must have a result id, type id. We skip OpUndef and
// OpConstantNull.
if (!inst || !inst->result_id() || !inst->type_id() ||
- inst->opcode() == spv::Op::OpUndef ||
- inst->opcode() == spv::Op::OpConstantNull) {
+ inst->opcode() == SpvOpUndef || inst->opcode() == SpvOpConstantNull) {
return false;
}
@@ -209,7 +208,7 @@ TransformationAddSynonym::MakeSynonymousInstruction(
auto synonym_type_id =
fuzzerutil::GetTypeId(ir_context, message_.result_id());
assert(synonym_type_id && "Synonym has invalid type id");
- auto opcode = spv::Op::OpNop;
+ auto opcode = SpvOpNop;
const auto* synonym_type =
ir_context->get_type_mgr()->GetType(synonym_type_id);
assert(synonym_type && "Synonym has invalid type");
@@ -220,30 +219,30 @@ TransformationAddSynonym::MakeSynonymousInstruction(
switch (message_.synonym_type()) {
case protobufs::TransformationAddSynonym::SUB_ZERO:
- opcode = is_integral ? spv::Op::OpISub : spv::Op::OpFSub;
+ opcode = is_integral ? SpvOpISub : SpvOpFSub;
break;
case protobufs::TransformationAddSynonym::MUL_ONE:
- opcode = is_integral ? spv::Op::OpIMul : spv::Op::OpFMul;
+ opcode = is_integral ? SpvOpIMul : SpvOpFMul;
break;
case protobufs::TransformationAddSynonym::ADD_ZERO:
- opcode = is_integral ? spv::Op::OpIAdd : spv::Op::OpFAdd;
+ opcode = is_integral ? SpvOpIAdd : SpvOpFAdd;
break;
case protobufs::TransformationAddSynonym::LOGICAL_OR:
- opcode = spv::Op::OpLogicalOr;
+ opcode = SpvOpLogicalOr;
break;
case protobufs::TransformationAddSynonym::LOGICAL_AND:
- opcode = spv::Op::OpLogicalAnd;
+ opcode = SpvOpLogicalAnd;
break;
case protobufs::TransformationAddSynonym::BITWISE_OR:
- opcode = spv::Op::OpBitwiseOr;
+ opcode = SpvOpBitwiseOr;
break;
case protobufs::TransformationAddSynonym::BITWISE_XOR:
- opcode = spv::Op::OpBitwiseXor;
+ opcode = SpvOpBitwiseXor;
break;
case protobufs::TransformationAddSynonym::COPY_OBJECT:
return MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCopyObject, synonym_type_id,
+ ir_context, SpvOpCopyObject, synonym_type_id,
message_.synonym_fresh_id(),
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_ID, {message_.result_id()}}});
diff --git a/source/fuzz/transformation_add_type_array.cpp b/source/fuzz/transformation_add_type_array.cpp
index d00d0e43..45bc8dfe 100644
--- a/source/fuzz/transformation_add_type_array.cpp
+++ b/source/fuzz/transformation_add_type_array.cpp
@@ -72,7 +72,7 @@ void TransformationAddTypeArray::Apply(
in_operands.push_back({SPV_OPERAND_TYPE_ID, {message_.element_type_id()}});
in_operands.push_back({SPV_OPERAND_TYPE_ID, {message_.size_id()}});
auto type_instruction = MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpTypeArray, 0, message_.fresh_id(), in_operands);
+ ir_context, SpvOpTypeArray, 0, message_.fresh_id(), in_operands);
auto type_instruction_ptr = type_instruction.get();
ir_context->module()->AddType(std::move(type_instruction));
diff --git a/source/fuzz/transformation_add_type_boolean.cpp b/source/fuzz/transformation_add_type_boolean.cpp
index 47fc744f..30ff43e2 100644
--- a/source/fuzz/transformation_add_type_boolean.cpp
+++ b/source/fuzz/transformation_add_type_boolean.cpp
@@ -43,7 +43,7 @@ void TransformationAddTypeBoolean::Apply(
opt::IRContext* ir_context, TransformationContext* /*unused*/) const {
opt::Instruction::OperandList empty_operands;
auto type_instruction = MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpTypeBool, 0, message_.fresh_id(), empty_operands);
+ ir_context, SpvOpTypeBool, 0, message_.fresh_id(), empty_operands);
auto type_instruction_ptr = type_instruction.get();
ir_context->module()->AddType(std::move(type_instruction));
diff --git a/source/fuzz/transformation_add_type_float.cpp b/source/fuzz/transformation_add_type_float.cpp
index 1943ffa5..1b88b25c 100644
--- a/source/fuzz/transformation_add_type_float.cpp
+++ b/source/fuzz/transformation_add_type_float.cpp
@@ -40,8 +40,7 @@ bool TransformationAddTypeFloat::IsApplicable(
switch (message_.width()) {
case 16:
// The Float16 capability must be present.
- if (!ir_context->get_feature_mgr()->HasCapability(
- spv::Capability::Float16)) {
+ if (!ir_context->get_feature_mgr()->HasCapability(SpvCapabilityFloat16)) {
return false;
}
break;
@@ -50,8 +49,7 @@ bool TransformationAddTypeFloat::IsApplicable(
break;
case 64:
// The Float64 capability must be present.
- if (!ir_context->get_feature_mgr()->HasCapability(
- spv::Capability::Float64)) {
+ if (!ir_context->get_feature_mgr()->HasCapability(SpvCapabilityFloat64)) {
return false;
}
break;
@@ -68,7 +66,7 @@ bool TransformationAddTypeFloat::IsApplicable(
void TransformationAddTypeFloat::Apply(
opt::IRContext* ir_context, TransformationContext* /*unused*/) const {
auto type_instruction = MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpTypeFloat, 0, message_.fresh_id(),
+ ir_context, SpvOpTypeFloat, 0, message_.fresh_id(),
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_LITERAL_INTEGER, {message_.width()}}});
auto type_instruction_ptr = type_instruction.get();
diff --git a/source/fuzz/transformation_add_type_int.cpp b/source/fuzz/transformation_add_type_int.cpp
index 35663f96..d4ef9819 100644
--- a/source/fuzz/transformation_add_type_int.cpp
+++ b/source/fuzz/transformation_add_type_int.cpp
@@ -42,15 +42,13 @@ bool TransformationAddTypeInt::IsApplicable(
switch (message_.width()) {
case 8:
// The Int8 capability must be present.
- if (!ir_context->get_feature_mgr()->HasCapability(
- spv::Capability::Int8)) {
+ if (!ir_context->get_feature_mgr()->HasCapability(SpvCapabilityInt8)) {
return false;
}
break;
case 16:
// The Int16 capability must be present.
- if (!ir_context->get_feature_mgr()->HasCapability(
- spv::Capability::Int16)) {
+ if (!ir_context->get_feature_mgr()->HasCapability(SpvCapabilityInt16)) {
return false;
}
break;
@@ -59,8 +57,7 @@ bool TransformationAddTypeInt::IsApplicable(
break;
case 64:
// The Int64 capability must be present.
- if (!ir_context->get_feature_mgr()->HasCapability(
- spv::Capability::Int64)) {
+ if (!ir_context->get_feature_mgr()->HasCapability(SpvCapabilityInt64)) {
return false;
}
break;
@@ -78,7 +75,7 @@ bool TransformationAddTypeInt::IsApplicable(
void TransformationAddTypeInt::Apply(opt::IRContext* ir_context,
TransformationContext* /*unused*/) const {
auto type_instruction = MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpTypeInt, 0, message_.fresh_id(),
+ ir_context, SpvOpTypeInt, 0, message_.fresh_id(),
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_LITERAL_INTEGER, {message_.width()}},
{SPV_OPERAND_TYPE_LITERAL_INTEGER,
diff --git a/source/fuzz/transformation_add_type_matrix.cpp b/source/fuzz/transformation_add_type_matrix.cpp
index e3f1786b..b574b01b 100644
--- a/source/fuzz/transformation_add_type_matrix.cpp
+++ b/source/fuzz/transformation_add_type_matrix.cpp
@@ -53,7 +53,7 @@ void TransformationAddTypeMatrix::Apply(
in_operands.push_back(
{SPV_OPERAND_TYPE_LITERAL_INTEGER, {message_.column_count()}});
auto type_instruction = MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpTypeMatrix, 0, message_.fresh_id(), in_operands);
+ ir_context, SpvOpTypeMatrix, 0, message_.fresh_id(), in_operands);
auto type_instruction_ptr = type_instruction.get();
ir_context->module()->AddType(std::move(type_instruction));
diff --git a/source/fuzz/transformation_add_type_pointer.cpp b/source/fuzz/transformation_add_type_pointer.cpp
index c1126154..c6c3945b 100644
--- a/source/fuzz/transformation_add_type_pointer.cpp
+++ b/source/fuzz/transformation_add_type_pointer.cpp
@@ -24,9 +24,9 @@ TransformationAddTypePointer::TransformationAddTypePointer(
: message_(std::move(message)) {}
TransformationAddTypePointer::TransformationAddTypePointer(
- uint32_t fresh_id, spv::StorageClass storage_class, uint32_t base_type_id) {
+ uint32_t fresh_id, SpvStorageClass storage_class, uint32_t base_type_id) {
message_.set_fresh_id(fresh_id);
- message_.set_storage_class(uint32_t(storage_class));
+ message_.set_storage_class(storage_class);
message_.set_base_type_id(base_type_id);
}
@@ -48,7 +48,7 @@ void TransformationAddTypePointer::Apply(
{SPV_OPERAND_TYPE_STORAGE_CLASS, {message_.storage_class()}},
{SPV_OPERAND_TYPE_ID, {message_.base_type_id()}}};
auto type_instruction = MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpTypePointer, 0, message_.fresh_id(), in_operands);
+ ir_context, SpvOpTypePointer, 0, message_.fresh_id(), in_operands);
auto type_instruction_ptr = type_instruction.get();
ir_context->module()->AddType(std::move(type_instruction));
diff --git a/source/fuzz/transformation_add_type_pointer.h b/source/fuzz/transformation_add_type_pointer.h
index e4ef9d88..8468c14d 100644
--- a/source/fuzz/transformation_add_type_pointer.h
+++ b/source/fuzz/transformation_add_type_pointer.h
@@ -28,8 +28,7 @@ class TransformationAddTypePointer : public Transformation {
explicit TransformationAddTypePointer(
protobufs::TransformationAddTypePointer message);
- TransformationAddTypePointer(uint32_t fresh_id,
- spv::StorageClass storage_class,
+ TransformationAddTypePointer(uint32_t fresh_id, SpvStorageClass storage_class,
uint32_t base_type_id);
// - |message_.fresh_id| must not be used by the module
diff --git a/source/fuzz/transformation_add_type_struct.cpp b/source/fuzz/transformation_add_type_struct.cpp
index 95fbbbab..d7f0711e 100644
--- a/source/fuzz/transformation_add_type_struct.cpp
+++ b/source/fuzz/transformation_add_type_struct.cpp
@@ -79,9 +79,8 @@ void TransformationAddTypeStruct::Apply(
operands.push_back({SPV_OPERAND_TYPE_ID, {type_id}});
}
- auto type_instruction =
- MakeUnique<opt::Instruction>(ir_context, spv::Op::OpTypeStruct, 0,
- message_.fresh_id(), std::move(operands));
+ auto type_instruction = MakeUnique<opt::Instruction>(
+ ir_context, SpvOpTypeStruct, 0, message_.fresh_id(), std::move(operands));
auto type_instruction_ptr = type_instruction.get();
ir_context->AddType(std::move(type_instruction));
diff --git a/source/fuzz/transformation_add_type_vector.cpp b/source/fuzz/transformation_add_type_vector.cpp
index a7b0fa7a..4da0ff01 100644
--- a/source/fuzz/transformation_add_type_vector.cpp
+++ b/source/fuzz/transformation_add_type_vector.cpp
@@ -57,7 +57,7 @@ void TransformationAddTypeVector::Apply(
"Precondition: component count must be in range [2, 4].");
auto type_instruction = MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpTypeVector, 0, message_.fresh_id(),
+ ir_context, SpvOpTypeVector, 0, message_.fresh_id(),
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_ID, {message_.component_type_id()}},
{SPV_OPERAND_TYPE_LITERAL_INTEGER, {message_.component_count()}}});
diff --git a/source/fuzz/transformation_adjust_branch_weights.cpp b/source/fuzz/transformation_adjust_branch_weights.cpp
index 26519389..21fef258 100644
--- a/source/fuzz/transformation_adjust_branch_weights.cpp
+++ b/source/fuzz/transformation_adjust_branch_weights.cpp
@@ -47,7 +47,7 @@ bool TransformationAdjustBranchWeights::IsApplicable(
return false;
}
- spv::Op opcode = static_cast<spv::Op>(
+ SpvOp opcode = static_cast<SpvOp>(
message_.instruction_descriptor().target_instruction_opcode());
assert(instruction->opcode() == opcode &&
@@ -55,7 +55,7 @@ bool TransformationAdjustBranchWeights::IsApplicable(
"descriptor.");
// Must be an OpBranchConditional instruction.
- if (opcode != spv::Op::OpBranchConditional) {
+ if (opcode != SpvOpBranchConditional) {
return false;
}
diff --git a/source/fuzz/transformation_composite_construct.cpp b/source/fuzz/transformation_composite_construct.cpp
index 075b33d4..2d8e5991 100644
--- a/source/fuzz/transformation_composite_construct.cpp
+++ b/source/fuzz/transformation_composite_construct.cpp
@@ -121,7 +121,7 @@ void TransformationCompositeConstruct::Apply(
// Insert an OpCompositeConstruct instruction.
auto new_instruction = MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeConstruct, message_.composite_type_id(),
+ ir_context, SpvOpCompositeConstruct, message_.composite_type_id(),
message_.fresh_id(), in_operands);
auto new_instruction_ptr = new_instruction.get();
insert_before.InsertBefore(std::move(new_instruction));
diff --git a/source/fuzz/transformation_composite_extract.cpp b/source/fuzz/transformation_composite_extract.cpp
index 7118432f..0fbd4e1b 100644
--- a/source/fuzz/transformation_composite_extract.cpp
+++ b/source/fuzz/transformation_composite_extract.cpp
@@ -67,7 +67,7 @@ bool TransformationCompositeExtract::IsApplicable(
}
if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(
- spv::Op::OpCompositeExtract, instruction_to_insert_before)) {
+ SpvOpCompositeExtract, instruction_to_insert_before)) {
return false;
}
@@ -93,7 +93,7 @@ void TransformationCompositeExtract::Apply(
FindInstruction(message_.instruction_to_insert_before(), ir_context);
opt::Instruction* new_instruction =
insert_before->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeExtract, extracted_type,
+ ir_context, SpvOpCompositeExtract, extracted_type,
message_.fresh_id(), extract_operands));
ir_context->get_def_use_mgr()->AnalyzeInstDefUse(new_instruction);
ir_context->set_instr_block(new_instruction,
diff --git a/source/fuzz/transformation_composite_insert.cpp b/source/fuzz/transformation_composite_insert.cpp
index 2f69c959..60fa5628 100644
--- a/source/fuzz/transformation_composite_insert.cpp
+++ b/source/fuzz/transformation_composite_insert.cpp
@@ -102,7 +102,7 @@ bool TransformationCompositeInsert::IsApplicable(
// It must be possible to insert an OpCompositeInsert before this
// instruction.
return fuzzerutil::CanInsertOpcodeBeforeInstruction(
- spv::Op::OpCompositeInsert, instruction_to_insert_before);
+ SpvOpCompositeInsert, instruction_to_insert_before);
}
void TransformationCompositeInsert::Apply(
@@ -126,8 +126,8 @@ void TransformationCompositeInsert::Apply(
auto insert_before =
FindInstruction(message_.instruction_to_insert_before(), ir_context);
auto new_instruction = MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeInsert, composite_type_id,
- message_.fresh_id(), std::move(in_operands));
+ ir_context, SpvOpCompositeInsert, composite_type_id, message_.fresh_id(),
+ std::move(in_operands));
auto new_instruction_ptr = new_instruction.get();
insert_before->InsertBefore(std::move(new_instruction));
diff --git a/source/fuzz/transformation_duplicate_region_with_selection.cpp b/source/fuzz/transformation_duplicate_region_with_selection.cpp
index 9176bf75..db88610f 100644
--- a/source/fuzz/transformation_duplicate_region_with_selection.cpp
+++ b/source/fuzz/transformation_duplicate_region_with_selection.cpp
@@ -77,7 +77,7 @@ bool TransformationDuplicateRegionWithSelection::IsApplicable(
// The entry and exit block ids must refer to blocks.
for (auto block_id : {message_.entry_block_id(), message_.exit_block_id()}) {
auto block_label = ir_context->get_def_use_mgr()->GetDef(block_id);
- if (!block_label || block_label->opcode() != spv::Op::OpLabel) {
+ if (!block_label || block_label->opcode() != SpvOpLabel) {
return false;
}
}
@@ -297,7 +297,7 @@ void TransformationDuplicateRegionWithSelection::Apply(
// in the same function.
std::unique_ptr<opt::BasicBlock> new_entry_block =
MakeUnique<opt::BasicBlock>(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpLabel, 0, message_.new_entry_fresh_id(),
+ ir_context, SpvOpLabel, 0, message_.new_entry_fresh_id(),
opt::Instruction::OperandList()));
auto entry_block = ir_context->cfg()->block(message_.entry_block_id());
auto enclosing_function = entry_block->GetParent();
@@ -310,7 +310,7 @@ void TransformationDuplicateRegionWithSelection::Apply(
// Construct the merge block.
std::unique_ptr<opt::BasicBlock> merge_block =
MakeUnique<opt::BasicBlock>(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpLabel, 0, message_.merge_label_fresh_id(),
+ ir_context, SpvOpLabel, 0, message_.merge_label_fresh_id(),
opt::Instruction::OperandList()));
// Get the maps from the protobuf.
@@ -361,7 +361,7 @@ void TransformationDuplicateRegionWithSelection::Apply(
exit_block->ForEachSuccessorLabel([this, ir_context](uint32_t label_id) {
auto block = ir_context->cfg()->block(label_id);
for (auto& instr : *block) {
- if (instr.opcode() == spv::Op::OpPhi) {
+ if (instr.opcode() == SpvOpPhi) {
instr.ForEachId([this](uint32_t* id) {
if (*id == message_.exit_block_id()) {
*id = message_.merge_label_fresh_id();
@@ -390,7 +390,7 @@ void TransformationDuplicateRegionWithSelection::Apply(
// occurrence of |entry_block_pred_id| to the id of |new_entry|, because we
// will insert |new_entry| before |entry_block|.
for (auto& instr : *entry_block) {
- if (instr.opcode() == spv::Op::OpPhi) {
+ if (instr.opcode() == SpvOpPhi) {
instr.ForEachId([this, entry_block_pred_id](uint32_t* id) {
if (*id == entry_block_pred_id) {
*id = message_.new_entry_fresh_id();
@@ -421,7 +421,7 @@ void TransformationDuplicateRegionWithSelection::Apply(
std::unique_ptr<opt::BasicBlock> duplicated_block =
MakeUnique<opt::BasicBlock>(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpLabel, 0,
+ ir_context, SpvOpLabel, 0,
original_label_to_duplicate_label.at(block->id()),
opt::Instruction::OperandList()));
@@ -430,12 +430,12 @@ void TransformationDuplicateRegionWithSelection::Apply(
// handled separately.
if (block == exit_block && instr.IsBlockTerminator()) {
switch (instr.opcode()) {
- case spv::Op::OpBranch:
- case spv::Op::OpBranchConditional:
- case spv::Op::OpReturn:
- case spv::Op::OpReturnValue:
- case spv::Op::OpUnreachable:
- case spv::Op::OpKill:
+ case SpvOpBranch:
+ case SpvOpBranchConditional:
+ case SpvOpReturn:
+ case SpvOpReturnValue:
+ case SpvOpUnreachable:
+ case SpvOpKill:
continue;
default:
assert(false &&
@@ -497,7 +497,7 @@ void TransformationDuplicateRegionWithSelection::Apply(
// the end of the region, as long as the result id is valid for use
// with OpPhi.
merge_block->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpPhi, instr.type_id(),
+ ir_context, SpvOpPhi, instr.type_id(),
original_id_to_phi_id.at(instr.result_id()),
opt::Instruction::OperandList({
{SPV_OPERAND_TYPE_ID, {instr.result_id()}},
@@ -537,14 +537,14 @@ void TransformationDuplicateRegionWithSelection::Apply(
// false, the execution proceeds in the first block of the
// duplicated region.
new_entry_block->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpSelectionMerge, 0, 0,
+ ir_context, SpvOpSelectionMerge, 0, 0,
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {message_.merge_label_fresh_id()}},
{SPV_OPERAND_TYPE_SELECTION_CONTROL,
- {uint32_t(spv::SelectionControlMask::MaskNone)}}})));
+ {SpvSelectionControlMaskNone}}})));
new_entry_block->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpBranchConditional, 0, 0,
+ ir_context, SpvOpBranchConditional, 0, 0,
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {message_.condition_id()}},
{SPV_OPERAND_TYPE_ID, {message_.entry_block_id()}},
@@ -563,7 +563,7 @@ void TransformationDuplicateRegionWithSelection::Apply(
// |exit_block| and at the end of |duplicated_exit_block|, so that
// the execution proceeds in the |merge_block|.
opt::Instruction merge_branch_instr = opt::Instruction(
- ir_context, spv::Op::OpBranch, 0, 0,
+ ir_context, SpvOpBranch, 0, 0,
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {message_.merge_label_fresh_id()}}}));
exit_block->AddInstruction(MakeUnique<opt::Instruction>(merge_branch_instr));
@@ -584,14 +584,14 @@ void TransformationDuplicateRegionWithSelection::Apply(
return;
}
switch (user->opcode()) {
- case spv::Op::OpSwitch:
- case spv::Op::OpBranch:
- case spv::Op::OpBranchConditional:
- case spv::Op::OpLoopMerge:
- case spv::Op::OpSelectionMerge: {
+ case SpvOpSwitch:
+ case SpvOpBranch:
+ case SpvOpBranchConditional:
+ case SpvOpLoopMerge:
+ case SpvOpSelectionMerge: {
user->SetOperand(operand_index, {message_.new_entry_fresh_id()});
} break;
- case spv::Op::OpName:
+ case SpvOpName:
break;
default:
assert(false &&
@@ -605,8 +605,8 @@ void TransformationDuplicateRegionWithSelection::Apply(
opt::Instruction* merge_block_terminator = merge_block->terminator();
switch (merge_block_terminator->opcode()) {
- case spv::Op::OpReturnValue:
- case spv::Op::OpBranchConditional: {
+ case SpvOpReturnValue:
+ case SpvOpBranchConditional: {
uint32_t operand = merge_block_terminator->GetSingleWordInOperand(0);
if (original_id_to_phi_id.count(operand)) {
merge_block_terminator->SetInOperand(
@@ -699,19 +699,19 @@ bool TransformationDuplicateRegionWithSelection::ValidOpPhiArgument(
ir_context->get_def_use_mgr()->GetDef(instr.type_id());
// It is invalid to apply OpPhi to void-typed values.
- if (instr_type->opcode() == spv::Op::OpTypeVoid) {
+ if (instr_type->opcode() == SpvOpTypeVoid) {
return false;
}
// Using pointers with OpPhi requires capability VariablePointers.
- if (instr_type->opcode() == spv::Op::OpTypePointer &&
+ if (instr_type->opcode() == SpvOpTypePointer &&
!ir_context->get_feature_mgr()->HasCapability(
- spv::Capability::VariablePointers)) {
+ SpvCapabilityVariablePointers)) {
return false;
}
// OpTypeSampledImage cannot be the result type of an OpPhi instruction.
- if (instr_type->opcode() == spv::Op::OpTypeSampledImage) {
+ if (instr_type->opcode() == SpvOpTypeSampledImage) {
return false;
}
return true;
diff --git a/source/fuzz/transformation_equation_instruction.cpp b/source/fuzz/transformation_equation_instruction.cpp
index 72487a8e..1e5dae97 100644
--- a/source/fuzz/transformation_equation_instruction.cpp
+++ b/source/fuzz/transformation_equation_instruction.cpp
@@ -25,11 +25,10 @@ TransformationEquationInstruction::TransformationEquationInstruction(
: message_(std::move(message)) {}
TransformationEquationInstruction::TransformationEquationInstruction(
- uint32_t fresh_id, spv::Op opcode,
- const std::vector<uint32_t>& in_operand_id,
+ uint32_t fresh_id, SpvOp opcode, const std::vector<uint32_t>& in_operand_id,
const protobufs::InstructionDescriptor& instruction_to_insert_before) {
message_.set_fresh_id(fresh_id);
- message_.set_opcode(uint32_t(opcode));
+ message_.set_opcode(opcode);
for (auto id : in_operand_id) {
message_.add_in_operand_id(id);
}
@@ -58,7 +57,7 @@ bool TransformationEquationInstruction::IsApplicable(
if (!inst) {
return false;
}
- if (inst->opcode() == spv::Op::OpUndef) {
+ if (inst->opcode() == SpvOpUndef) {
return false;
}
if (transformation_context.GetFactManager()->IdIsIrrelevant(id)) {
@@ -89,7 +88,7 @@ void TransformationEquationInstruction::Apply(
FindInstruction(message_.instruction_to_insert_before(), ir_context);
opt::Instruction* new_instruction =
insert_before->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, static_cast<spv::Op>(message_.opcode()),
+ ir_context, static_cast<SpvOp>(message_.opcode()),
MaybeGetResultTypeId(ir_context), message_.fresh_id(),
std::move(in_operands)));
@@ -102,7 +101,7 @@ void TransformationEquationInstruction::Apply(
if (!transformation_context->GetFactManager()->IdIsIrrelevant(
message_.fresh_id())) {
transformation_context->GetFactManager()->AddFactIdEquation(
- message_.fresh_id(), static_cast<spv::Op>(message_.opcode()), rhs_id);
+ message_.fresh_id(), static_cast<SpvOp>(message_.opcode()), rhs_id);
}
}
@@ -114,10 +113,10 @@ protobufs::Transformation TransformationEquationInstruction::ToMessage() const {
uint32_t TransformationEquationInstruction::MaybeGetResultTypeId(
opt::IRContext* ir_context) const {
- auto opcode = static_cast<spv::Op>(message_.opcode());
+ auto opcode = static_cast<SpvOp>(message_.opcode());
switch (opcode) {
- case spv::Op::OpConvertUToF:
- case spv::Op::OpConvertSToF: {
+ case SpvOpConvertUToF:
+ case SpvOpConvertSToF: {
if (message_.in_operand_id_size() != 1) {
return 0;
}
@@ -149,7 +148,7 @@ uint32_t TransformationEquationInstruction::MaybeGetResultTypeId(
type->AsInteger()->width());
}
}
- case spv::Op::OpBitcast: {
+ case SpvOpBitcast: {
if (message_.in_operand_id_size() != 1) {
return 0;
}
@@ -211,8 +210,8 @@ uint32_t TransformationEquationInstruction::MaybeGetResultTypeId(
return 0;
}
}
- case spv::Op::OpIAdd:
- case spv::Op::OpISub: {
+ case SpvOpIAdd:
+ case SpvOpISub: {
if (message_.in_operand_id_size() != 2) {
return 0;
}
@@ -250,7 +249,7 @@ uint32_t TransformationEquationInstruction::MaybeGetResultTypeId(
"A type must have been found for the first operand.");
return first_operand_type_id;
}
- case spv::Op::OpLogicalNot: {
+ case SpvOpLogicalNot: {
if (message_.in_operand_id().size() != 1) {
return 0;
}
@@ -268,7 +267,7 @@ uint32_t TransformationEquationInstruction::MaybeGetResultTypeId(
}
return operand_inst->type_id();
}
- case spv::Op::OpSNegate: {
+ case SpvOpSNegate: {
if (message_.in_operand_id().size() != 1) {
return 0;
}
diff --git a/source/fuzz/transformation_equation_instruction.h b/source/fuzz/transformation_equation_instruction.h
index 40118d91..ae32a1a2 100644
--- a/source/fuzz/transformation_equation_instruction.h
+++ b/source/fuzz/transformation_equation_instruction.h
@@ -31,7 +31,7 @@ class TransformationEquationInstruction : public Transformation {
protobufs::TransformationEquationInstruction message);
TransformationEquationInstruction(
- uint32_t fresh_id, spv::Op opcode,
+ uint32_t fresh_id, SpvOp opcode,
const std::vector<uint32_t>& in_operand_id,
const protobufs::InstructionDescriptor& instruction_to_insert_before);
diff --git a/source/fuzz/transformation_expand_vector_reduction.cpp b/source/fuzz/transformation_expand_vector_reduction.cpp
index 4c13ec1f..bafcf929 100644
--- a/source/fuzz/transformation_expand_vector_reduction.cpp
+++ b/source/fuzz/transformation_expand_vector_reduction.cpp
@@ -44,8 +44,7 @@ bool TransformationExpandVectorReduction::IsApplicable(
}
// |instruction| must be OpAny or OpAll.
- if (instruction->opcode() != spv::Op::OpAny &&
- instruction->opcode() != spv::Op::OpAll) {
+ if (instruction->opcode() != SpvOpAny && instruction->opcode() != SpvOpAll) {
return false;
}
@@ -93,11 +92,10 @@ void TransformationExpandVectorReduction::Apply(
for (uint32_t i = 0; i < vector_component_count; i++) {
// Extracts the i-th |vector| component.
- auto vector_component =
- opt::Instruction(ir_context, spv::Op::OpCompositeExtract,
- instruction->type_id(), *fresh_id++,
- {{SPV_OPERAND_TYPE_ID, {vector->result_id()}},
- {SPV_OPERAND_TYPE_LITERAL_INTEGER, {i}}});
+ auto vector_component = opt::Instruction(
+ ir_context, SpvOpCompositeExtract, instruction->type_id(), *fresh_id++,
+ {{SPV_OPERAND_TYPE_ID, {vector->result_id()}},
+ {SPV_OPERAND_TYPE_LITERAL_INTEGER, {i}}});
instruction->InsertBefore(MakeUnique<opt::Instruction>(vector_component));
fuzzerutil::UpdateModuleIdBound(ir_context, vector_component.result_id());
vector_components.push_back(vector_component.result_id());
@@ -106,8 +104,7 @@ void TransformationExpandVectorReduction::Apply(
// The first two |vector| components are used in the first logical operation.
auto logical_instruction = opt::Instruction(
ir_context,
- instruction->opcode() == spv::Op::OpAny ? spv::Op::OpLogicalOr
- : spv::Op::OpLogicalAnd,
+ instruction->opcode() == SpvOpAny ? SpvOpLogicalOr : SpvOpLogicalAnd,
instruction->type_id(), *fresh_id++,
{{SPV_OPERAND_TYPE_ID, {vector_components[0]}},
{SPV_OPERAND_TYPE_ID, {vector_components[1]}}});
diff --git a/source/fuzz/transformation_flatten_conditional_branch.cpp b/source/fuzz/transformation_flatten_conditional_branch.cpp
index f8d1c338..127e7628 100644
--- a/source/fuzz/transformation_flatten_conditional_branch.cpp
+++ b/source/fuzz/transformation_flatten_conditional_branch.cpp
@@ -48,12 +48,12 @@ bool TransformationFlattenConditionalBranch::IsApplicable(
// The block must have been found and it must be a selection header.
if (!header_block || !header_block->GetMergeInst() ||
- header_block->GetMergeInst()->opcode() != spv::Op::OpSelectionMerge) {
+ header_block->GetMergeInst()->opcode() != SpvOpSelectionMerge) {
return false;
}
// The header block must end with an OpBranchConditional instruction.
- if (header_block->terminator()->opcode() != spv::Op::OpBranchConditional) {
+ if (header_block->terminator()->opcode() != SpvOpBranchConditional) {
return false;
}
@@ -164,14 +164,14 @@ bool TransformationFlattenConditionalBranch::IsApplicable(
opt::Instruction* phi_result_type =
ir_context->get_def_use_mgr()->GetDef(inst->type_id());
switch (phi_result_type->opcode()) {
- case spv::Op::OpTypeBool:
- case spv::Op::OpTypeInt:
- case spv::Op::OpTypeFloat:
- case spv::Op::OpTypePointer:
+ case SpvOpTypeBool:
+ case SpvOpTypeInt:
+ case SpvOpTypeFloat:
+ case SpvOpTypePointer:
// Fine: OpSelect can work directly on scalar and pointer
// types.
return true;
- case spv::Op::OpTypeVector: {
+ case SpvOpTypeVector: {
// In its restricted form, OpSelect can only select between
// vectors if the condition of the select is a boolean
// boolean vector. We thus require the appropriate boolean
@@ -288,8 +288,8 @@ void TransformationFlattenConditionalBranch::Apply(
current_block->ForEachInst(
[&problematic_instructions](opt::Instruction* instruction) {
- if (instruction->opcode() != spv::Op::OpLabel &&
- instruction->opcode() != spv::Op::OpBranch &&
+ if (instruction->opcode() != SpvOpLabel &&
+ instruction->opcode() != SpvOpBranch &&
!fuzzerutil::InstructionHasNoSideEffects(*instruction)) {
problematic_instructions.push_back(instruction);
}
@@ -381,7 +381,7 @@ void TransformationFlattenConditionalBranch::Apply(
// Add a new, unconditional, branch instruction from the current header to
// |after_header|.
header_block->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpBranch, 0, 0,
+ ir_context, SpvOpBranch, 0, 0,
opt::Instruction::OperandList{{SPV_OPERAND_TYPE_ID, {after_header}}}));
// If the first branch to be laid out exists, change the branch instruction so
@@ -437,8 +437,8 @@ bool TransformationFlattenConditionalBranch::
std::set<opt::Instruction*>* instructions_that_need_ids) {
uint32_t merge_block_id = header->MergeBlockIdIfAny();
assert(merge_block_id &&
- header->GetMergeInst()->opcode() == spv::Op::OpSelectionMerge &&
- header->terminator()->opcode() == spv::Op::OpBranchConditional &&
+ header->GetMergeInst()->opcode() == SpvOpSelectionMerge &&
+ header->terminator()->opcode() == SpvOpBranchConditional &&
"|header| must be the header of a conditional.");
// |header| must be reachable.
@@ -508,7 +508,7 @@ bool TransformationFlattenConditionalBranch::
}
// The terminator instruction for the block must be OpBranch.
- if (block->terminator()->opcode() != spv::Op::OpBranch) {
+ if (block->terminator()->opcode() != SpvOpBranch) {
return false;
}
@@ -524,7 +524,7 @@ bool TransformationFlattenConditionalBranch::
[ir_context, instructions_that_need_ids,
&synonym_base_objects](opt::Instruction* instruction) {
// We can ignore OpLabel instructions.
- if (instruction->opcode() == spv::Op::OpLabel) {
+ if (instruction->opcode() == SpvOpLabel) {
return true;
}
@@ -539,7 +539,7 @@ bool TransformationFlattenConditionalBranch::
// If the instruction is a branch, it must be an unconditional branch.
if (instruction->IsBranch()) {
- return instruction->opcode() == spv::Op::OpBranch;
+ return instruction->opcode() == SpvOpBranch;
}
// We cannot go ahead if we encounter an instruction that cannot be
@@ -644,7 +644,7 @@ TransformationFlattenConditionalBranch::EncloseInstructionInConditional(
// Add an unconditional branch from |execute_block| to |merge_block|.
execute_block->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpBranch, 0, 0,
+ ir_context, SpvOpBranch, 0, 0,
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_ID, {merge_block->id()}}}));
@@ -668,10 +668,10 @@ TransformationFlattenConditionalBranch::EncloseInstructionInConditional(
}
// Create a new block using |fresh_ids.alternative_block_id| for its label.
- auto alternative_block_temp = MakeUnique<opt::BasicBlock>(
- MakeUnique<opt::Instruction>(ir_context, spv::Op::OpLabel, 0,
- wrapper_info.alternative_block_id(),
- opt::Instruction::OperandList{}));
+ auto alternative_block_temp =
+ MakeUnique<opt::BasicBlock>(MakeUnique<opt::Instruction>(
+ ir_context, SpvOpLabel, 0, wrapper_info.alternative_block_id(),
+ opt::Instruction::OperandList{}));
// Keep the original result id of the instruction in a variable.
uint32_t original_result_id = instruction->result_id();
@@ -685,14 +685,14 @@ TransformationFlattenConditionalBranch::EncloseInstructionInConditional(
// If there is an available id to copy from, the placeholder instruction
// will be %placeholder_result_id = OpCopyObject %type %value_to_copy_id
alternative_block_temp->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCopyObject, instruction->type_id(),
+ ir_context, SpvOpCopyObject, instruction->type_id(),
wrapper_info.placeholder_result_id(),
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_ID, {wrapper_info.value_to_copy_id()}}}));
} else {
// If there is no such id, use an OpUndef instruction.
alternative_block_temp->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpUndef, instruction->type_id(),
+ ir_context, SpvOpUndef, instruction->type_id(),
wrapper_info.placeholder_result_id(),
opt::Instruction::OperandList{}));
}
@@ -702,7 +702,7 @@ TransformationFlattenConditionalBranch::EncloseInstructionInConditional(
// Add an unconditional branch from the new block to the merge block.
alternative_block_temp->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpBranch, 0, 0,
+ ir_context, SpvOpBranch, 0, 0,
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_ID, {merge_block->id()}}}));
@@ -714,7 +714,7 @@ TransformationFlattenConditionalBranch::EncloseInstructionInConditional(
// merge block, which will either take the value of the result of the
// instruction or the placeholder value defined in the alternative block.
merge_block->begin().InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpPhi, instruction->type_id(), original_result_id,
+ ir_context, SpvOpPhi, instruction->type_id(), original_result_id,
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_ID, {instruction->result_id()}},
{SPV_OPERAND_TYPE_ID, {execute_block->id()}},
@@ -738,17 +738,16 @@ TransformationFlattenConditionalBranch::EncloseInstructionInConditional(
// Add an OpSelectionMerge instruction to the block.
block->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpSelectionMerge, 0, 0,
- opt::Instruction::OperandList{
- {SPV_OPERAND_TYPE_ID, {merge_block->id()}},
- {SPV_OPERAND_TYPE_SELECTION_CONTROL,
- {uint32_t(spv::SelectionControlMask::MaskNone)}}}));
+ ir_context, SpvOpSelectionMerge, 0, 0,
+ opt::Instruction::OperandList{{SPV_OPERAND_TYPE_ID, {merge_block->id()}},
+ {SPV_OPERAND_TYPE_SELECTION_CONTROL,
+ {SpvSelectionControlMaskNone}}}));
// Add an OpBranchConditional, to the block, using |condition_id| as the
// condition and branching to |if_block_id| if the condition is true and to
// |else_block_id| if the condition is false.
block->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpBranchConditional, 0, 0,
+ ir_context, SpvOpBranchConditional, 0, 0,
opt::Instruction::OperandList{{SPV_OPERAND_TYPE_ID, {condition_id}},
{SPV_OPERAND_TYPE_ID, {if_block_id}},
{SPV_OPERAND_TYPE_ID, {else_block_id}}}));
@@ -765,26 +764,26 @@ bool TransformationFlattenConditionalBranch::InstructionCanBeHandled(
// We cannot handle barrier instructions, while we should be able to handle
// all other instructions by enclosing them inside a conditional.
- if (instruction.opcode() == spv::Op::OpControlBarrier ||
- instruction.opcode() == spv::Op::OpMemoryBarrier ||
- instruction.opcode() == spv::Op::OpNamedBarrierInitialize ||
- instruction.opcode() == spv::Op::OpMemoryNamedBarrier ||
- instruction.opcode() == spv::Op::OpTypeNamedBarrier) {
+ if (instruction.opcode() == SpvOpControlBarrier ||
+ instruction.opcode() == SpvOpMemoryBarrier ||
+ instruction.opcode() == SpvOpNamedBarrierInitialize ||
+ instruction.opcode() == SpvOpMemoryNamedBarrier ||
+ instruction.opcode() == SpvOpTypeNamedBarrier) {
return false;
}
// We cannot handle OpSampledImage instructions, as they need to be in the
// same block as their use.
- if (instruction.opcode() == spv::Op::OpSampledImage) {
+ if (instruction.opcode() == SpvOpSampledImage) {
return false;
}
// We cannot handle a sampled image load, because we re-work loads using
// conditional branches and OpPhi instructions, and the result type of OpPhi
// cannot be OpTypeSampledImage.
- if (instruction.opcode() == spv::Op::OpLoad &&
+ if (instruction.opcode() == SpvOpLoad &&
ir_context->get_def_use_mgr()->GetDef(instruction.type_id())->opcode() ==
- spv::Op::OpTypeSampledImage) {
+ SpvOpTypeSampledImage) {
return false;
}
@@ -864,7 +863,7 @@ void TransformationFlattenConditionalBranch::AddBooleanVectorConstructorToBlock(
in_operands.emplace_back(branch_condition_operand);
}
block->begin()->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeConstruct,
+ ir_context, SpvOpCompositeConstruct,
fuzzerutil::MaybeGetVectorType(
ir_context, fuzzerutil::MaybeGetBoolType(ir_context), dimension),
fresh_id, in_operands));
@@ -907,7 +906,7 @@ void TransformationFlattenConditionalBranch::
opt::Operand selector_operand = branch_condition_operand;
opt::Instruction* type_inst =
ir_context->get_def_use_mgr()->GetDef(phi_inst->type_id());
- if (type_inst->opcode() == spv::Op::OpTypeVector) {
+ if (type_inst->opcode() == SpvOpTypeVector) {
uint32_t dimension = type_inst->GetSingleWordInOperand(1);
switch (dimension) {
case 2:
@@ -1013,7 +1012,7 @@ void TransformationFlattenConditionalBranch::
operands.emplace_back(phi_inst->GetInOperand(2));
operands.emplace_back(phi_inst->GetInOperand(0));
}
- phi_inst->SetOpcode(spv::Op::OpSelect);
+ phi_inst->SetOpcode(SpvOpSelect);
phi_inst->SetInOperands(std::move(operands));
});
diff --git a/source/fuzz/transformation_function_call.cpp b/source/fuzz/transformation_function_call.cpp
index e96a230c..0f88ce51 100644
--- a/source/fuzz/transformation_function_call.cpp
+++ b/source/fuzz/transformation_function_call.cpp
@@ -49,7 +49,7 @@ bool TransformationFunctionCall::IsApplicable(
// The function must exist
auto callee_inst =
ir_context->get_def_use_mgr()->GetDef(message_.callee_id());
- if (!callee_inst || callee_inst->opcode() != spv::Op::OpFunction) {
+ if (!callee_inst || callee_inst->opcode() != SpvOpFunction) {
return false;
}
@@ -60,7 +60,7 @@ bool TransformationFunctionCall::IsApplicable(
auto callee_type_inst = ir_context->get_def_use_mgr()->GetDef(
callee_inst->GetSingleWordInOperand(1));
- assert(callee_type_inst->opcode() == spv::Op::OpTypeFunction &&
+ assert(callee_type_inst->opcode() == SpvOpTypeFunction &&
"Bad function type.");
// The number of expected function arguments must match the number of given
@@ -78,7 +78,7 @@ bool TransformationFunctionCall::IsApplicable(
if (!insert_before) {
return false;
}
- if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(spv::Op::OpFunctionCall,
+ if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(SpvOpFunctionCall,
insert_before)) {
return false;
}
@@ -116,10 +116,10 @@ bool TransformationFunctionCall::IsApplicable(
}
opt::Instruction* arg_type_inst =
ir_context->get_def_use_mgr()->GetDef(arg_inst->type_id());
- if (arg_type_inst->opcode() == spv::Op::OpTypePointer) {
+ if (arg_type_inst->opcode() == SpvOpTypePointer) {
switch (arg_inst->opcode()) {
- case spv::Op::OpFunctionParameter:
- case spv::Op::OpVariable:
+ case SpvOpFunctionParameter:
+ case SpvOpVariable:
// These are OK
break;
default:
@@ -173,7 +173,7 @@ void TransformationFunctionCall::Apply(
// Insert the function call before the instruction specified in the message.
FindInstruction(message_.instruction_to_insert_before(), ir_context)
->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpFunctionCall, return_type, message_.fresh_id(),
+ ir_context, SpvOpFunctionCall, return_type, message_.fresh_id(),
operands));
// Invalidate all analyses since we have changed the module.
ir_context->InvalidateAnalysesExceptFor(opt::IRContext::kAnalysisNone);
diff --git a/source/fuzz/transformation_inline_function.cpp b/source/fuzz/transformation_inline_function.cpp
index 69e88fd5..a48b8179 100644
--- a/source/fuzz/transformation_inline_function.cpp
+++ b/source/fuzz/transformation_inline_function.cpp
@@ -62,8 +62,7 @@ bool TransformationInlineFunction::IsApplicable(
ir_context->get_instr_block(function_call_instruction);
if (function_call_instruction !=
&*--function_call_instruction_block->tail() ||
- function_call_instruction_block->terminator()->opcode() !=
- spv::Op::OpBranch) {
+ function_call_instruction_block->terminator()->opcode() != SpvOpBranch) {
return false;
}
@@ -144,7 +143,7 @@ void TransformationInlineFunction::Apply(
for (auto& entry_block_instruction : *called_function->entry()) {
opt::Instruction* inlined_instruction;
- if (entry_block_instruction.opcode() == spv::Op::OpVariable) {
+ if (entry_block_instruction.opcode() == SpvOpVariable) {
// All OpVariable instructions in a function must be in the first block
// in the function.
inlined_instruction = caller_function->begin()->begin()->InsertBefore(
@@ -207,7 +206,7 @@ void TransformationInlineFunction::Apply(
block_containing_function_call->id(),
[ir_context, new_return_block_id, successor_block](
opt::Instruction* use_instruction, uint32_t operand_index) {
- if (use_instruction->opcode() == spv::Op::OpPhi &&
+ if (use_instruction->opcode() == SpvOpPhi &&
ir_context->get_instr_block(use_instruction) == successor_block) {
use_instruction->SetOperand(operand_index, {new_return_block_id});
}
@@ -235,7 +234,7 @@ bool TransformationInlineFunction::IsSuitableForInlining(
// |function_call_instruction| must be defined and must be an OpFunctionCall
// instruction.
if (!function_call_instruction ||
- function_call_instruction->opcode() != spv::Op::OpFunctionCall) {
+ function_call_instruction->opcode() != SpvOpFunctionCall) {
return false;
}
@@ -332,14 +331,13 @@ void TransformationInlineFunction::AdaptInlinedInstruction(
->terminator()
->GetSingleWordInOperand(0);
switch (instruction_to_be_inlined->opcode()) {
- case spv::Op::OpReturn:
+ case SpvOpReturn:
instruction_to_be_inlined->AddOperand(
{SPV_OPERAND_TYPE_ID, {successor_block_id}});
break;
- case spv::Op::OpReturnValue: {
+ case SpvOpReturnValue: {
instruction_to_be_inlined->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCopyObject,
- function_call_instruction->type_id(),
+ ir_context, SpvOpCopyObject, function_call_instruction->type_id(),
function_call_instruction->result_id(),
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID,
@@ -350,7 +348,7 @@ void TransformationInlineFunction::AdaptInlinedInstruction(
default:
break;
}
- instruction_to_be_inlined->SetOpcode(spv::Op::OpBranch);
+ instruction_to_be_inlined->SetOpcode(SpvOpBranch);
}
}
diff --git a/source/fuzz/transformation_invert_comparison_operator.cpp b/source/fuzz/transformation_invert_comparison_operator.cpp
index 49801e39..ed7358fa 100644
--- a/source/fuzz/transformation_invert_comparison_operator.cpp
+++ b/source/fuzz/transformation_invert_comparison_operator.cpp
@@ -47,8 +47,7 @@ bool TransformationInvertComparisonOperator::IsApplicable(
auto iter = fuzzerutil::GetIteratorForInstruction(block, inst);
++iter;
assert(iter != block->end() && "Instruction can't be the last in the block");
- assert(fuzzerutil::CanInsertOpcodeBeforeInstruction(spv::Op::OpLogicalNot,
- iter) &&
+ assert(fuzzerutil::CanInsertOpcodeBeforeInstruction(SpvOpLogicalNot, iter) &&
"Can't insert negation after comparison operator");
// |message_.fresh_id| must be fresh.
@@ -66,7 +65,7 @@ void TransformationInvertComparisonOperator::Apply(
++iter;
iter.InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpLogicalNot, inst->type_id(), inst->result_id(),
+ ir_context, SpvOpLogicalNot, inst->type_id(), inst->result_id(),
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_ID, {message_.fresh_id()}}}));
@@ -83,88 +82,88 @@ void TransformationInvertComparisonOperator::Apply(
}
bool TransformationInvertComparisonOperator::IsInversionSupported(
- spv::Op opcode) {
+ SpvOp opcode) {
switch (opcode) {
- case spv::Op::OpSGreaterThan:
- case spv::Op::OpSGreaterThanEqual:
- case spv::Op::OpSLessThan:
- case spv::Op::OpSLessThanEqual:
- case spv::Op::OpUGreaterThan:
- case spv::Op::OpUGreaterThanEqual:
- case spv::Op::OpULessThan:
- case spv::Op::OpULessThanEqual:
- case spv::Op::OpIEqual:
- case spv::Op::OpINotEqual:
- case spv::Op::OpFOrdEqual:
- case spv::Op::OpFUnordEqual:
- case spv::Op::OpFOrdNotEqual:
- case spv::Op::OpFUnordNotEqual:
- case spv::Op::OpFOrdLessThan:
- case spv::Op::OpFUnordLessThan:
- case spv::Op::OpFOrdLessThanEqual:
- case spv::Op::OpFUnordLessThanEqual:
- case spv::Op::OpFOrdGreaterThan:
- case spv::Op::OpFUnordGreaterThan:
- case spv::Op::OpFOrdGreaterThanEqual:
- case spv::Op::OpFUnordGreaterThanEqual:
+ case SpvOpSGreaterThan:
+ case SpvOpSGreaterThanEqual:
+ case SpvOpSLessThan:
+ case SpvOpSLessThanEqual:
+ case SpvOpUGreaterThan:
+ case SpvOpUGreaterThanEqual:
+ case SpvOpULessThan:
+ case SpvOpULessThanEqual:
+ case SpvOpIEqual:
+ case SpvOpINotEqual:
+ case SpvOpFOrdEqual:
+ case SpvOpFUnordEqual:
+ case SpvOpFOrdNotEqual:
+ case SpvOpFUnordNotEqual:
+ case SpvOpFOrdLessThan:
+ case SpvOpFUnordLessThan:
+ case SpvOpFOrdLessThanEqual:
+ case SpvOpFUnordLessThanEqual:
+ case SpvOpFOrdGreaterThan:
+ case SpvOpFUnordGreaterThan:
+ case SpvOpFOrdGreaterThanEqual:
+ case SpvOpFUnordGreaterThanEqual:
return true;
default:
return false;
}
}
-spv::Op TransformationInvertComparisonOperator::InvertOpcode(spv::Op opcode) {
+SpvOp TransformationInvertComparisonOperator::InvertOpcode(SpvOp opcode) {
assert(IsInversionSupported(opcode) && "Inversion must be supported");
switch (opcode) {
- case spv::Op::OpSGreaterThan:
- return spv::Op::OpSLessThanEqual;
- case spv::Op::OpSGreaterThanEqual:
- return spv::Op::OpSLessThan;
- case spv::Op::OpSLessThan:
- return spv::Op::OpSGreaterThanEqual;
- case spv::Op::OpSLessThanEqual:
- return spv::Op::OpSGreaterThan;
- case spv::Op::OpUGreaterThan:
- return spv::Op::OpULessThanEqual;
- case spv::Op::OpUGreaterThanEqual:
- return spv::Op::OpULessThan;
- case spv::Op::OpULessThan:
- return spv::Op::OpUGreaterThanEqual;
- case spv::Op::OpULessThanEqual:
- return spv::Op::OpUGreaterThan;
- case spv::Op::OpIEqual:
- return spv::Op::OpINotEqual;
- case spv::Op::OpINotEqual:
- return spv::Op::OpIEqual;
- case spv::Op::OpFOrdEqual:
- return spv::Op::OpFUnordNotEqual;
- case spv::Op::OpFUnordEqual:
- return spv::Op::OpFOrdNotEqual;
- case spv::Op::OpFOrdNotEqual:
- return spv::Op::OpFUnordEqual;
- case spv::Op::OpFUnordNotEqual:
- return spv::Op::OpFOrdEqual;
- case spv::Op::OpFOrdLessThan:
- return spv::Op::OpFUnordGreaterThanEqual;
- case spv::Op::OpFUnordLessThan:
- return spv::Op::OpFOrdGreaterThanEqual;
- case spv::Op::OpFOrdLessThanEqual:
- return spv::Op::OpFUnordGreaterThan;
- case spv::Op::OpFUnordLessThanEqual:
- return spv::Op::OpFOrdGreaterThan;
- case spv::Op::OpFOrdGreaterThan:
- return spv::Op::OpFUnordLessThanEqual;
- case spv::Op::OpFUnordGreaterThan:
- return spv::Op::OpFOrdLessThanEqual;
- case spv::Op::OpFOrdGreaterThanEqual:
- return spv::Op::OpFUnordLessThan;
- case spv::Op::OpFUnordGreaterThanEqual:
- return spv::Op::OpFOrdLessThan;
+ case SpvOpSGreaterThan:
+ return SpvOpSLessThanEqual;
+ case SpvOpSGreaterThanEqual:
+ return SpvOpSLessThan;
+ case SpvOpSLessThan:
+ return SpvOpSGreaterThanEqual;
+ case SpvOpSLessThanEqual:
+ return SpvOpSGreaterThan;
+ case SpvOpUGreaterThan:
+ return SpvOpULessThanEqual;
+ case SpvOpUGreaterThanEqual:
+ return SpvOpULessThan;
+ case SpvOpULessThan:
+ return SpvOpUGreaterThanEqual;
+ case SpvOpULessThanEqual:
+ return SpvOpUGreaterThan;
+ case SpvOpIEqual:
+ return SpvOpINotEqual;
+ case SpvOpINotEqual:
+ return SpvOpIEqual;
+ case SpvOpFOrdEqual:
+ return SpvOpFUnordNotEqual;
+ case SpvOpFUnordEqual:
+ return SpvOpFOrdNotEqual;
+ case SpvOpFOrdNotEqual:
+ return SpvOpFUnordEqual;
+ case SpvOpFUnordNotEqual:
+ return SpvOpFOrdEqual;
+ case SpvOpFOrdLessThan:
+ return SpvOpFUnordGreaterThanEqual;
+ case SpvOpFUnordLessThan:
+ return SpvOpFOrdGreaterThanEqual;
+ case SpvOpFOrdLessThanEqual:
+ return SpvOpFUnordGreaterThan;
+ case SpvOpFUnordLessThanEqual:
+ return SpvOpFOrdGreaterThan;
+ case SpvOpFOrdGreaterThan:
+ return SpvOpFUnordLessThanEqual;
+ case SpvOpFUnordGreaterThan:
+ return SpvOpFOrdLessThanEqual;
+ case SpvOpFOrdGreaterThanEqual:
+ return SpvOpFUnordLessThan;
+ case SpvOpFUnordGreaterThanEqual:
+ return SpvOpFOrdLessThan;
default:
// The program will fail in the debug mode because of the assertion
// at the beginning of the function.
- return spv::Op::OpNop;
+ return SpvOpNop;
}
}
diff --git a/source/fuzz/transformation_invert_comparison_operator.h b/source/fuzz/transformation_invert_comparison_operator.h
index 39c2fe0f..f00f62b1 100644
--- a/source/fuzz/transformation_invert_comparison_operator.h
+++ b/source/fuzz/transformation_invert_comparison_operator.h
@@ -50,11 +50,11 @@ class TransformationInvertComparisonOperator : public Transformation {
protobufs::Transformation ToMessage() const override;
// Returns true if |opcode| is supported by this transformation.
- static bool IsInversionSupported(spv::Op opcode);
+ static bool IsInversionSupported(SpvOp opcode);
private:
// Returns an inverted |opcode| (e.g. < becomes >=, == becomes != etc.)
- static spv::Op InvertOpcode(spv::Op opcode);
+ static SpvOp InvertOpcode(SpvOp opcode);
protobufs::TransformationInvertComparisonOperator message_;
};
diff --git a/source/fuzz/transformation_load.cpp b/source/fuzz/transformation_load.cpp
index 1cfde770..bf48d996 100644
--- a/source/fuzz/transformation_load.cpp
+++ b/source/fuzz/transformation_load.cpp
@@ -52,15 +52,15 @@ bool TransformationLoad::IsApplicable(
// The type must indeed be a pointer type.
auto pointer_type = ir_context->get_def_use_mgr()->GetDef(pointer->type_id());
assert(pointer_type && "Type id must be defined.");
- if (pointer_type->opcode() != spv::Op::OpTypePointer) {
+ if (pointer_type->opcode() != SpvOpTypePointer) {
return false;
}
// We do not want to allow loading from null or undefined pointers, as it is
// not clear how punishing the consequences of doing so are from a semantics
// point of view.
switch (pointer->opcode()) {
- case spv::Op::OpConstantNull:
- case spv::Op::OpUndef:
+ case SpvOpConstantNull:
+ case SpvOpUndef:
return false;
default:
break;
@@ -74,13 +74,13 @@ bool TransformationLoad::IsApplicable(
return false;
}
// ... and it must be legitimate to insert a load before it.
- if (!message_.is_atomic() && !fuzzerutil::CanInsertOpcodeBeforeInstruction(
- spv::Op::OpLoad, insert_before)) {
+ if (!message_.is_atomic() &&
+ !fuzzerutil::CanInsertOpcodeBeforeInstruction(SpvOpLoad, insert_before)) {
return false;
}
if (message_.is_atomic() && !fuzzerutil::CanInsertOpcodeBeforeInstruction(
- spv::Op::OpAtomicLoad, insert_before)) {
+ SpvOpAtomicLoad, insert_before)) {
return false;
}
@@ -99,10 +99,10 @@ bool TransformationLoad::IsApplicable(
}
// The memory scope and memory semantics instructions must have the
// 'OpConstant' opcode.
- if (memory_scope_instruction->opcode() != spv::Op::OpConstant) {
+ if (memory_scope_instruction->opcode() != SpvOpConstant) {
return false;
}
- if (memory_semantics_instruction->opcode() != spv::Op::OpConstant) {
+ if (memory_semantics_instruction->opcode() != SpvOpConstant) {
return false;
}
// The memory scope and memory semantics need to be available before
@@ -119,12 +119,12 @@ bool TransformationLoad::IsApplicable(
// operand type with signedness does not matters.
if (ir_context->get_def_use_mgr()
->GetDef(memory_scope_instruction->type_id())
- ->opcode() != spv::Op::OpTypeInt) {
+ ->opcode() != SpvOpTypeInt) {
return false;
}
if (ir_context->get_def_use_mgr()
->GetDef(memory_semantics_instruction->type_id())
- ->opcode() != spv::Op::OpTypeInt) {
+ ->opcode() != SpvOpTypeInt) {
return false;
}
@@ -146,20 +146,20 @@ bool TransformationLoad::IsApplicable(
return false;
}
- // The memory scope constant value must be that of spv::Scope::Invocation.
+ // The memory scope constant value must be that of SpvScopeInvocation.
auto memory_scope_const_value =
- spv::Scope(memory_scope_instruction->GetSingleWordInOperand(0));
- if (memory_scope_const_value != spv::Scope::Invocation) {
+ memory_scope_instruction->GetSingleWordInOperand(0);
+ if (memory_scope_const_value != SpvScopeInvocation) {
return false;
}
// The memory semantics constant value must match the storage class of the
// pointer being loaded from.
- auto memory_semantics_const_value = static_cast<spv::MemorySemanticsMask>(
+ auto memory_semantics_const_value = static_cast<SpvMemorySemanticsMask>(
memory_semantics_instruction->GetSingleWordInOperand(0));
if (memory_semantics_const_value !=
fuzzerutil::GetMemorySemanticsForStorageClass(
- static_cast<spv::StorageClass>(
+ static_cast<SpvStorageClass>(
pointer_type->GetSingleWordInOperand(0)))) {
return false;
}
@@ -180,7 +180,7 @@ void TransformationLoad::Apply(opt::IRContext* ir_context,
auto insert_before =
FindInstruction(message_.instruction_to_insert_before(), ir_context);
auto new_instruction = MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpAtomicLoad, result_type, message_.fresh_id(),
+ ir_context, SpvOpAtomicLoad, result_type, message_.fresh_id(),
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {message_.pointer_id()}},
{SPV_OPERAND_TYPE_SCOPE_ID, {message_.memory_scope_id()}},
@@ -201,7 +201,7 @@ void TransformationLoad::Apply(opt::IRContext* ir_context,
auto insert_before =
FindInstruction(message_.instruction_to_insert_before(), ir_context);
auto new_instruction = MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpLoad, result_type, message_.fresh_id(),
+ ir_context, SpvOpLoad, result_type, message_.fresh_id(),
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {message_.pointer_id()}}}));
auto new_instruction_ptr = new_instruction.get();
diff --git a/source/fuzz/transformation_load.h b/source/fuzz/transformation_load.h
index 66229185..57b4a535 100644
--- a/source/fuzz/transformation_load.h
+++ b/source/fuzz/transformation_load.h
@@ -37,7 +37,7 @@ class TransformationLoad : public Transformation {
// - |message_.is_atomic| must be true if want to work with OpAtomicLoad
// - If |is_atomic| is true then |message_memory_scope_id| must be the id of
// an OpConstant 32 bit integer instruction with the value
- // spv::Scope::Invocation.
+ // SpvScopeInvocation.
// - If |is_atomic| is true then |message_.memory_semantics_id| must be the id
// of an OpConstant 32 bit integer instruction with the values
// SpvMemorySemanticsWorkgroupMemoryMask or
diff --git a/source/fuzz/transformation_make_vector_operation_dynamic.cpp b/source/fuzz/transformation_make_vector_operation_dynamic.cpp
index ecc8dcac..bd0664c0 100644
--- a/source/fuzz/transformation_make_vector_operation_dynamic.cpp
+++ b/source/fuzz/transformation_make_vector_operation_dynamic.cpp
@@ -62,19 +62,19 @@ void TransformationMakeVectorOperationDynamic::Apply(
// The OpVectorInsertDynamic instruction has the vector and component operands
// in reverse order in relation to the OpCompositeInsert corresponding
// operands.
- if (instruction->opcode() == spv::Op::OpCompositeInsert) {
+ if (instruction->opcode() == SpvOpCompositeInsert) {
std::swap(instruction->GetInOperand(0), instruction->GetInOperand(1));
}
// Sets the literal operand to the equivalent constant.
instruction->SetInOperand(
- instruction->opcode() == spv::Op::OpCompositeExtract ? 1 : 2,
+ instruction->opcode() == SpvOpCompositeExtract ? 1 : 2,
{message_.constant_index_id()});
// Sets the |instruction| opcode to the corresponding vector dynamic opcode.
- instruction->SetOpcode(instruction->opcode() == spv::Op::OpCompositeExtract
- ? spv::Op::OpVectorExtractDynamic
- : spv::Op::OpVectorInsertDynamic);
+ instruction->SetOpcode(instruction->opcode() == SpvOpCompositeExtract
+ ? SpvOpVectorExtractDynamic
+ : SpvOpVectorInsertDynamic);
}
protobufs::Transformation TransformationMakeVectorOperationDynamic::ToMessage()
@@ -88,15 +88,15 @@ bool TransformationMakeVectorOperationDynamic::IsVectorOperation(
opt::IRContext* ir_context, opt::Instruction* instruction) {
// |instruction| must be defined and must be an OpCompositeExtract/Insert
// instruction.
- if (!instruction || (instruction->opcode() != spv::Op::OpCompositeExtract &&
- instruction->opcode() != spv::Op::OpCompositeInsert)) {
+ if (!instruction || (instruction->opcode() != SpvOpCompositeExtract &&
+ instruction->opcode() != SpvOpCompositeInsert)) {
return false;
}
// The composite must be a vector.
auto composite_instruction =
ir_context->get_def_use_mgr()->GetDef(instruction->GetSingleWordInOperand(
- instruction->opcode() == spv::Op::OpCompositeExtract ? 0 : 1));
+ instruction->opcode() == SpvOpCompositeExtract ? 0 : 1));
if (!ir_context->get_type_mgr()
->GetType(composite_instruction->type_id())
->AsVector()) {
diff --git a/source/fuzz/transformation_merge_function_returns.cpp b/source/fuzz/transformation_merge_function_returns.cpp
index b35e358d..022e1b6d 100644
--- a/source/fuzz/transformation_merge_function_returns.cpp
+++ b/source/fuzz/transformation_merge_function_returns.cpp
@@ -50,7 +50,7 @@ bool TransformationMergeFunctionReturns::IsApplicable(
}
// The entry block must end in an unconditional branch.
- if (function->entry()->terminator()->opcode() != spv::Op::OpBranch) {
+ if (function->entry()->terminator()->opcode() != SpvOpBranch) {
return false;
}
@@ -134,9 +134,9 @@ bool TransformationMergeFunctionReturns::IsApplicable(
bool all_instructions_allowed =
ir_context->get_instr_block(merge_block)
->WhileEachInst([](opt::Instruction* inst) {
- return inst->opcode() == spv::Op::OpLabel ||
- inst->opcode() == spv::Op::OpPhi ||
- inst->opcode() == spv::Op::OpBranch;
+ return inst->opcode() == SpvOpLabel ||
+ inst->opcode() == SpvOpPhi ||
+ inst->opcode() == SpvOpBranch;
});
if (!all_instructions_allowed) {
return false;
@@ -286,7 +286,7 @@ void TransformationMergeFunctionReturns::Apply(
}
// Replace the return instruction with an unconditional branch.
- ret_block->terminator()->SetOpcode(spv::Op::OpBranch);
+ ret_block->terminator()->SetOpcode(SpvOpBranch);
ret_block->terminator()->SetInOperands(
{{SPV_OPERAND_TYPE_ID, {merge_block_id}}});
}
@@ -410,7 +410,7 @@ void TransformationMergeFunctionReturns::Apply(
// Insert the instruction.
merge_block->begin()->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpPhi, function->type_id(), maybe_return_val_id,
+ ir_context, SpvOpPhi, function->type_id(), maybe_return_val_id,
std::move(operand_list)));
fuzzerutil::UpdateModuleIdBound(ir_context, maybe_return_val_id);
@@ -448,14 +448,14 @@ void TransformationMergeFunctionReturns::Apply(
// Insert the instruction.
merge_block->begin()->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpPhi, bool_type, is_returning_id,
+ ir_context, SpvOpPhi, bool_type, is_returning_id,
std::move(operand_list)));
fuzzerutil::UpdateModuleIdBound(ir_context, is_returning_id);
}
// Change the branching instruction of the block.
- assert(merge_block->terminator()->opcode() == spv::Op::OpBranch &&
+ assert(merge_block->terminator()->opcode() == SpvOpBranch &&
"Each block should branch unconditionally to the next.");
// Add a new entry to the map corresponding to the merge block of the
@@ -483,14 +483,14 @@ void TransformationMergeFunctionReturns::Apply(
// The block should branch to |enclosing_merge| if |is_returning_id| is
// true, to |original_succ| otherwise.
- merge_block->terminator()->SetOpcode(spv::Op::OpBranchConditional);
+ merge_block->terminator()->SetOpcode(SpvOpBranchConditional);
merge_block->terminator()->SetInOperands(
{{SPV_OPERAND_TYPE_ID, {is_returning_id}},
{SPV_OPERAND_TYPE_ID, {enclosing_merge}},
{SPV_OPERAND_TYPE_ID, {original_succ}}});
}
- assert(function->entry()->terminator()->opcode() == spv::Op::OpBranch &&
+ assert(function->entry()->terminator()->opcode() == SpvOpBranch &&
"The entry block should branch unconditionally to another block.");
uint32_t block_after_entry =
function->entry()->terminator()->GetSingleWordInOperand(0);
@@ -498,7 +498,7 @@ void TransformationMergeFunctionReturns::Apply(
// Create the header for the new outer loop.
auto outer_loop_header =
MakeUnique<opt::BasicBlock>(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpLabel, 0, message_.outer_header_id(),
+ ir_context, SpvOpLabel, 0, message_.outer_header_id(),
opt::Instruction::OperandList()));
fuzzerutil::UpdateModuleIdBound(ir_context, message_.outer_header_id());
@@ -506,16 +506,15 @@ void TransformationMergeFunctionReturns::Apply(
// Add the instruction:
// OpLoopMerge %outer_return_id %unreachable_continue_id None
outer_loop_header->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpLoopMerge, 0, 0,
+ ir_context, SpvOpLoopMerge, 0, 0,
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_ID, {message_.outer_return_id()}},
{SPV_OPERAND_TYPE_ID, {message_.unreachable_continue_id()}},
- {SPV_OPERAND_TYPE_LOOP_CONTROL,
- {uint32_t(spv::LoopControlMask::MaskNone)}}}));
+ {SPV_OPERAND_TYPE_LOOP_CONTROL, {SpvLoopControlMaskNone}}}));
// Add unconditional branch to %block_after_entry.
outer_loop_header->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpBranch, 0, 0,
+ ir_context, SpvOpBranch, 0, 0,
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_ID, {block_after_entry}}}));
@@ -532,7 +531,7 @@ void TransformationMergeFunctionReturns::Apply(
ir_context->get_def_use_mgr()->ForEachUse(
function->entry()->id(),
[this](opt::Instruction* use_instruction, uint32_t use_operand_index) {
- if (use_instruction->opcode() == spv::Op::OpPhi) {
+ if (use_instruction->opcode() == SpvOpPhi) {
use_instruction->SetOperand(use_operand_index,
{message_.outer_header_id()});
}
@@ -541,7 +540,7 @@ void TransformationMergeFunctionReturns::Apply(
// Create the merge block for the loop (and return block for the function).
auto outer_return_block =
MakeUnique<opt::BasicBlock>(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpLabel, 0, message_.outer_return_id(),
+ ir_context, SpvOpLabel, 0, message_.outer_return_id(),
opt::Instruction::OperandList()));
fuzzerutil::UpdateModuleIdBound(ir_context, message_.outer_return_id());
@@ -562,20 +561,20 @@ void TransformationMergeFunctionReturns::Apply(
// Insert the OpPhi instruction.
outer_return_block->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpPhi, function->type_id(),
- message_.return_val_id(), std::move(operand_list)));
+ ir_context, SpvOpPhi, function->type_id(), message_.return_val_id(),
+ std::move(operand_list)));
fuzzerutil::UpdateModuleIdBound(ir_context, message_.return_val_id());
// Insert the OpReturnValue instruction.
outer_return_block->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpReturnValue, 0, 0,
+ ir_context, SpvOpReturnValue, 0, 0,
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_ID, {message_.return_val_id()}}}));
} else {
// Insert an OpReturn instruction (the function is void).
outer_return_block->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpReturn, 0, 0, opt::Instruction::OperandList{}));
+ ir_context, SpvOpReturn, 0, 0, opt::Instruction::OperandList{}));
}
// Insert the new return block at the end of the function.
@@ -584,7 +583,7 @@ void TransformationMergeFunctionReturns::Apply(
// Create the unreachable continue block associated with the enclosing loop.
auto unreachable_continue_block =
MakeUnique<opt::BasicBlock>(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpLabel, 0, message_.unreachable_continue_id(),
+ ir_context, SpvOpLabel, 0, message_.unreachable_continue_id(),
opt::Instruction::OperandList()));
fuzzerutil::UpdateModuleIdBound(ir_context,
@@ -592,7 +591,7 @@ void TransformationMergeFunctionReturns::Apply(
// Insert an branch back to the loop header, to create a back edge.
unreachable_continue_block->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpBranch, 0, 0,
+ ir_context, SpvOpBranch, 0, 0,
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_ID, {message_.outer_header_id()}}}));
@@ -752,7 +751,7 @@ bool TransformationMergeFunctionReturns::
// The usage is OK if it is inside an OpPhi instruction in the
// merge block.
return block_use == merge_block &&
- inst_use->opcode() == spv::Op::OpPhi;
+ inst_use->opcode() == SpvOpPhi;
});
});
diff --git a/source/fuzz/transformation_move_instruction_down.cpp b/source/fuzz/transformation_move_instruction_down.cpp
index 4d5d9f0c..c8139e72 100644
--- a/source/fuzz/transformation_move_instruction_down.cpp
+++ b/source/fuzz/transformation_move_instruction_down.cpp
@@ -26,7 +26,7 @@ const char* const kExtensionSetName = "GLSL.std.450";
std::string GetExtensionSet(opt::IRContext* ir_context,
const opt::Instruction& op_ext_inst) {
- assert(op_ext_inst.opcode() == spv::Op::OpExtInst && "Wrong opcode");
+ assert(op_ext_inst.opcode() == SpvOpExtInst && "Wrong opcode");
const auto* ext_inst_import = ir_context->get_def_use_mgr()->GetDef(
op_ext_inst.GetSingleWordInOperand(0));
@@ -142,112 +142,112 @@ bool TransformationMoveInstructionDown::IsInstructionSupported(
bool TransformationMoveInstructionDown::IsSimpleInstruction(
opt::IRContext* ir_context, const opt::Instruction& inst) {
switch (inst.opcode()) {
- case spv::Op::OpNop:
- case spv::Op::OpUndef:
- case spv::Op::OpAccessChain:
- case spv::Op::OpInBoundsAccessChain:
+ case SpvOpNop:
+ case SpvOpUndef:
+ case SpvOpAccessChain:
+ case SpvOpInBoundsAccessChain:
// OpAccessChain and OpInBoundsAccessChain are considered simple
// instructions since they result in a pointer to the object in memory,
// not the object itself.
- case spv::Op::OpVectorExtractDynamic:
- case spv::Op::OpVectorInsertDynamic:
- case spv::Op::OpVectorShuffle:
- case spv::Op::OpCompositeConstruct:
- case spv::Op::OpCompositeExtract:
- case spv::Op::OpCompositeInsert:
- case spv::Op::OpCopyObject:
- case spv::Op::OpTranspose:
- case spv::Op::OpConvertFToU:
- case spv::Op::OpConvertFToS:
- case spv::Op::OpConvertSToF:
- case spv::Op::OpConvertUToF:
- case spv::Op::OpUConvert:
- case spv::Op::OpSConvert:
- case spv::Op::OpFConvert:
- case spv::Op::OpQuantizeToF16:
- case spv::Op::OpSatConvertSToU:
- case spv::Op::OpSatConvertUToS:
- case spv::Op::OpBitcast:
- case spv::Op::OpSNegate:
- case spv::Op::OpFNegate:
- case spv::Op::OpIAdd:
- case spv::Op::OpFAdd:
- case spv::Op::OpISub:
- case spv::Op::OpFSub:
- case spv::Op::OpIMul:
- case spv::Op::OpFMul:
- case spv::Op::OpUDiv:
- case spv::Op::OpSDiv:
- case spv::Op::OpFDiv:
- case spv::Op::OpUMod:
- case spv::Op::OpSRem:
- case spv::Op::OpSMod:
- case spv::Op::OpFRem:
- case spv::Op::OpFMod:
- case spv::Op::OpVectorTimesScalar:
- case spv::Op::OpMatrixTimesScalar:
- case spv::Op::OpVectorTimesMatrix:
- case spv::Op::OpMatrixTimesVector:
- case spv::Op::OpMatrixTimesMatrix:
- case spv::Op::OpOuterProduct:
- case spv::Op::OpDot:
- case spv::Op::OpIAddCarry:
- case spv::Op::OpISubBorrow:
- case spv::Op::OpUMulExtended:
- case spv::Op::OpSMulExtended:
- case spv::Op::OpAny:
- case spv::Op::OpAll:
- case spv::Op::OpIsNan:
- case spv::Op::OpIsInf:
- case spv::Op::OpIsFinite:
- case spv::Op::OpIsNormal:
- case spv::Op::OpSignBitSet:
- case spv::Op::OpLessOrGreater:
- case spv::Op::OpOrdered:
- case spv::Op::OpUnordered:
- case spv::Op::OpLogicalEqual:
- case spv::Op::OpLogicalNotEqual:
- case spv::Op::OpLogicalOr:
- case spv::Op::OpLogicalAnd:
- case spv::Op::OpLogicalNot:
- case spv::Op::OpSelect:
- case spv::Op::OpIEqual:
- case spv::Op::OpINotEqual:
- case spv::Op::OpUGreaterThan:
- case spv::Op::OpSGreaterThan:
- case spv::Op::OpUGreaterThanEqual:
- case spv::Op::OpSGreaterThanEqual:
- case spv::Op::OpULessThan:
- case spv::Op::OpSLessThan:
- case spv::Op::OpULessThanEqual:
- case spv::Op::OpSLessThanEqual:
- case spv::Op::OpFOrdEqual:
- case spv::Op::OpFUnordEqual:
- case spv::Op::OpFOrdNotEqual:
- case spv::Op::OpFUnordNotEqual:
- case spv::Op::OpFOrdLessThan:
- case spv::Op::OpFUnordLessThan:
- case spv::Op::OpFOrdGreaterThan:
- case spv::Op::OpFUnordGreaterThan:
- case spv::Op::OpFOrdLessThanEqual:
- case spv::Op::OpFUnordLessThanEqual:
- case spv::Op::OpFOrdGreaterThanEqual:
- case spv::Op::OpFUnordGreaterThanEqual:
- case spv::Op::OpShiftRightLogical:
- case spv::Op::OpShiftRightArithmetic:
- case spv::Op::OpShiftLeftLogical:
- case spv::Op::OpBitwiseOr:
- case spv::Op::OpBitwiseXor:
- case spv::Op::OpBitwiseAnd:
- case spv::Op::OpNot:
- case spv::Op::OpBitFieldInsert:
- case spv::Op::OpBitFieldSExtract:
- case spv::Op::OpBitFieldUExtract:
- case spv::Op::OpBitReverse:
- case spv::Op::OpBitCount:
- case spv::Op::OpCopyLogical:
+ case SpvOpVectorExtractDynamic:
+ case SpvOpVectorInsertDynamic:
+ case SpvOpVectorShuffle:
+ case SpvOpCompositeConstruct:
+ case SpvOpCompositeExtract:
+ case SpvOpCompositeInsert:
+ case SpvOpCopyObject:
+ case SpvOpTranspose:
+ case SpvOpConvertFToU:
+ case SpvOpConvertFToS:
+ case SpvOpConvertSToF:
+ case SpvOpConvertUToF:
+ case SpvOpUConvert:
+ case SpvOpSConvert:
+ case SpvOpFConvert:
+ case SpvOpQuantizeToF16:
+ case SpvOpSatConvertSToU:
+ case SpvOpSatConvertUToS:
+ case SpvOpBitcast:
+ case SpvOpSNegate:
+ case SpvOpFNegate:
+ case SpvOpIAdd:
+ case SpvOpFAdd:
+ case SpvOpISub:
+ case SpvOpFSub:
+ case SpvOpIMul:
+ case SpvOpFMul:
+ case SpvOpUDiv:
+ case SpvOpSDiv:
+ case SpvOpFDiv:
+ case SpvOpUMod:
+ case SpvOpSRem:
+ case SpvOpSMod:
+ case SpvOpFRem:
+ case SpvOpFMod:
+ case SpvOpVectorTimesScalar:
+ case SpvOpMatrixTimesScalar:
+ case SpvOpVectorTimesMatrix:
+ case SpvOpMatrixTimesVector:
+ case SpvOpMatrixTimesMatrix:
+ case SpvOpOuterProduct:
+ case SpvOpDot:
+ case SpvOpIAddCarry:
+ case SpvOpISubBorrow:
+ case SpvOpUMulExtended:
+ case SpvOpSMulExtended:
+ case SpvOpAny:
+ case SpvOpAll:
+ case SpvOpIsNan:
+ case SpvOpIsInf:
+ case SpvOpIsFinite:
+ case SpvOpIsNormal:
+ case SpvOpSignBitSet:
+ case SpvOpLessOrGreater:
+ case SpvOpOrdered:
+ case SpvOpUnordered:
+ case SpvOpLogicalEqual:
+ case SpvOpLogicalNotEqual:
+ case SpvOpLogicalOr:
+ case SpvOpLogicalAnd:
+ case SpvOpLogicalNot:
+ case SpvOpSelect:
+ case SpvOpIEqual:
+ case SpvOpINotEqual:
+ case SpvOpUGreaterThan:
+ case SpvOpSGreaterThan:
+ case SpvOpUGreaterThanEqual:
+ case SpvOpSGreaterThanEqual:
+ case SpvOpULessThan:
+ case SpvOpSLessThan:
+ case SpvOpULessThanEqual:
+ case SpvOpSLessThanEqual:
+ case SpvOpFOrdEqual:
+ case SpvOpFUnordEqual:
+ case SpvOpFOrdNotEqual:
+ case SpvOpFUnordNotEqual:
+ case SpvOpFOrdLessThan:
+ case SpvOpFUnordLessThan:
+ case SpvOpFOrdGreaterThan:
+ case SpvOpFUnordGreaterThan:
+ case SpvOpFOrdLessThanEqual:
+ case SpvOpFUnordLessThanEqual:
+ case SpvOpFOrdGreaterThanEqual:
+ case SpvOpFUnordGreaterThanEqual:
+ case SpvOpShiftRightLogical:
+ case SpvOpShiftRightArithmetic:
+ case SpvOpShiftLeftLogical:
+ case SpvOpBitwiseOr:
+ case SpvOpBitwiseXor:
+ case SpvOpBitwiseAnd:
+ case SpvOpNot:
+ case SpvOpBitFieldInsert:
+ case SpvOpBitFieldSExtract:
+ case SpvOpBitFieldUExtract:
+ case SpvOpBitReverse:
+ case SpvOpBitCount:
+ case SpvOpCopyLogical:
return true;
- case spv::Op::OpExtInst: {
+ case SpvOpExtInst: {
const auto* ext_inst_import =
ir_context->get_def_use_mgr()->GetDef(inst.GetSingleWordInOperand(0));
@@ -346,53 +346,53 @@ bool TransformationMoveInstructionDown::IsMemoryReadInstruction(
opt::IRContext* ir_context, const opt::Instruction& inst) {
switch (inst.opcode()) {
// Some simple instructions.
- case spv::Op::OpLoad:
- case spv::Op::OpCopyMemory:
+ case SpvOpLoad:
+ case SpvOpCopyMemory:
// Image instructions.
- case spv::Op::OpImageSampleImplicitLod:
- case spv::Op::OpImageSampleExplicitLod:
- case spv::Op::OpImageSampleDrefImplicitLod:
- case spv::Op::OpImageSampleDrefExplicitLod:
- case spv::Op::OpImageSampleProjImplicitLod:
- case spv::Op::OpImageSampleProjExplicitLod:
- case spv::Op::OpImageSampleProjDrefImplicitLod:
- case spv::Op::OpImageSampleProjDrefExplicitLod:
- case spv::Op::OpImageFetch:
- case spv::Op::OpImageGather:
- case spv::Op::OpImageDrefGather:
- case spv::Op::OpImageRead:
- case spv::Op::OpImageSparseSampleImplicitLod:
- case spv::Op::OpImageSparseSampleExplicitLod:
- case spv::Op::OpImageSparseSampleDrefImplicitLod:
- case spv::Op::OpImageSparseSampleDrefExplicitLod:
- case spv::Op::OpImageSparseSampleProjImplicitLod:
- case spv::Op::OpImageSparseSampleProjExplicitLod:
- case spv::Op::OpImageSparseSampleProjDrefImplicitLod:
- case spv::Op::OpImageSparseSampleProjDrefExplicitLod:
- case spv::Op::OpImageSparseFetch:
- case spv::Op::OpImageSparseGather:
- case spv::Op::OpImageSparseDrefGather:
- case spv::Op::OpImageSparseRead:
+ case SpvOpImageSampleImplicitLod:
+ case SpvOpImageSampleExplicitLod:
+ case SpvOpImageSampleDrefImplicitLod:
+ case SpvOpImageSampleDrefExplicitLod:
+ case SpvOpImageSampleProjImplicitLod:
+ case SpvOpImageSampleProjExplicitLod:
+ case SpvOpImageSampleProjDrefImplicitLod:
+ case SpvOpImageSampleProjDrefExplicitLod:
+ case SpvOpImageFetch:
+ case SpvOpImageGather:
+ case SpvOpImageDrefGather:
+ case SpvOpImageRead:
+ case SpvOpImageSparseSampleImplicitLod:
+ case SpvOpImageSparseSampleExplicitLod:
+ case SpvOpImageSparseSampleDrefImplicitLod:
+ case SpvOpImageSparseSampleDrefExplicitLod:
+ case SpvOpImageSparseSampleProjImplicitLod:
+ case SpvOpImageSparseSampleProjExplicitLod:
+ case SpvOpImageSparseSampleProjDrefImplicitLod:
+ case SpvOpImageSparseSampleProjDrefExplicitLod:
+ case SpvOpImageSparseFetch:
+ case SpvOpImageSparseGather:
+ case SpvOpImageSparseDrefGather:
+ case SpvOpImageSparseRead:
// Atomic instructions.
- case spv::Op::OpAtomicLoad:
- case spv::Op::OpAtomicExchange:
- case spv::Op::OpAtomicCompareExchange:
- case spv::Op::OpAtomicCompareExchangeWeak:
- case spv::Op::OpAtomicIIncrement:
- case spv::Op::OpAtomicIDecrement:
- case spv::Op::OpAtomicIAdd:
- case spv::Op::OpAtomicISub:
- case spv::Op::OpAtomicSMin:
- case spv::Op::OpAtomicUMin:
- case spv::Op::OpAtomicSMax:
- case spv::Op::OpAtomicUMax:
- case spv::Op::OpAtomicAnd:
- case spv::Op::OpAtomicOr:
- case spv::Op::OpAtomicXor:
- case spv::Op::OpAtomicFlagTestAndSet:
+ case SpvOpAtomicLoad:
+ case SpvOpAtomicExchange:
+ case SpvOpAtomicCompareExchange:
+ case SpvOpAtomicCompareExchangeWeak:
+ case SpvOpAtomicIIncrement:
+ case SpvOpAtomicIDecrement:
+ case SpvOpAtomicIAdd:
+ case SpvOpAtomicISub:
+ case SpvOpAtomicSMin:
+ case SpvOpAtomicUMin:
+ case SpvOpAtomicSMax:
+ case SpvOpAtomicUMax:
+ case SpvOpAtomicAnd:
+ case SpvOpAtomicOr:
+ case SpvOpAtomicXor:
+ case SpvOpAtomicFlagTestAndSet:
return true;
// Extensions.
- case spv::Op::OpExtInst: {
+ case SpvOpExtInst: {
if (GetExtensionSet(ir_context, inst) != kExtensionSetName) {
return false;
}
@@ -419,53 +419,53 @@ uint32_t TransformationMoveInstructionDown::GetMemoryReadTarget(
switch (inst.opcode()) {
// Simple instructions.
- case spv::Op::OpLoad:
+ case SpvOpLoad:
// Image instructions.
- case spv::Op::OpImageSampleImplicitLod:
- case spv::Op::OpImageSampleExplicitLod:
- case spv::Op::OpImageSampleDrefImplicitLod:
- case spv::Op::OpImageSampleDrefExplicitLod:
- case spv::Op::OpImageSampleProjImplicitLod:
- case spv::Op::OpImageSampleProjExplicitLod:
- case spv::Op::OpImageSampleProjDrefImplicitLod:
- case spv::Op::OpImageSampleProjDrefExplicitLod:
- case spv::Op::OpImageFetch:
- case spv::Op::OpImageGather:
- case spv::Op::OpImageDrefGather:
- case spv::Op::OpImageRead:
- case spv::Op::OpImageSparseSampleImplicitLod:
- case spv::Op::OpImageSparseSampleExplicitLod:
- case spv::Op::OpImageSparseSampleDrefImplicitLod:
- case spv::Op::OpImageSparseSampleDrefExplicitLod:
- case spv::Op::OpImageSparseSampleProjImplicitLod:
- case spv::Op::OpImageSparseSampleProjExplicitLod:
- case spv::Op::OpImageSparseSampleProjDrefImplicitLod:
- case spv::Op::OpImageSparseSampleProjDrefExplicitLod:
- case spv::Op::OpImageSparseFetch:
- case spv::Op::OpImageSparseGather:
- case spv::Op::OpImageSparseDrefGather:
- case spv::Op::OpImageSparseRead:
+ case SpvOpImageSampleImplicitLod:
+ case SpvOpImageSampleExplicitLod:
+ case SpvOpImageSampleDrefImplicitLod:
+ case SpvOpImageSampleDrefExplicitLod:
+ case SpvOpImageSampleProjImplicitLod:
+ case SpvOpImageSampleProjExplicitLod:
+ case SpvOpImageSampleProjDrefImplicitLod:
+ case SpvOpImageSampleProjDrefExplicitLod:
+ case SpvOpImageFetch:
+ case SpvOpImageGather:
+ case SpvOpImageDrefGather:
+ case SpvOpImageRead:
+ case SpvOpImageSparseSampleImplicitLod:
+ case SpvOpImageSparseSampleExplicitLod:
+ case SpvOpImageSparseSampleDrefImplicitLod:
+ case SpvOpImageSparseSampleDrefExplicitLod:
+ case SpvOpImageSparseSampleProjImplicitLod:
+ case SpvOpImageSparseSampleProjExplicitLod:
+ case SpvOpImageSparseSampleProjDrefImplicitLod:
+ case SpvOpImageSparseSampleProjDrefExplicitLod:
+ case SpvOpImageSparseFetch:
+ case SpvOpImageSparseGather:
+ case SpvOpImageSparseDrefGather:
+ case SpvOpImageSparseRead:
// Atomic instructions.
- case spv::Op::OpAtomicLoad:
- case spv::Op::OpAtomicExchange:
- case spv::Op::OpAtomicCompareExchange:
- case spv::Op::OpAtomicCompareExchangeWeak:
- case spv::Op::OpAtomicIIncrement:
- case spv::Op::OpAtomicIDecrement:
- case spv::Op::OpAtomicIAdd:
- case spv::Op::OpAtomicISub:
- case spv::Op::OpAtomicSMin:
- case spv::Op::OpAtomicUMin:
- case spv::Op::OpAtomicSMax:
- case spv::Op::OpAtomicUMax:
- case spv::Op::OpAtomicAnd:
- case spv::Op::OpAtomicOr:
- case spv::Op::OpAtomicXor:
- case spv::Op::OpAtomicFlagTestAndSet:
+ case SpvOpAtomicLoad:
+ case SpvOpAtomicExchange:
+ case SpvOpAtomicCompareExchange:
+ case SpvOpAtomicCompareExchangeWeak:
+ case SpvOpAtomicIIncrement:
+ case SpvOpAtomicIDecrement:
+ case SpvOpAtomicIAdd:
+ case SpvOpAtomicISub:
+ case SpvOpAtomicSMin:
+ case SpvOpAtomicUMin:
+ case SpvOpAtomicSMax:
+ case SpvOpAtomicUMax:
+ case SpvOpAtomicAnd:
+ case SpvOpAtomicOr:
+ case SpvOpAtomicXor:
+ case SpvOpAtomicFlagTestAndSet:
return inst.GetSingleWordInOperand(0);
- case spv::Op::OpCopyMemory:
+ case SpvOpCopyMemory:
return inst.GetSingleWordInOperand(1);
- case spv::Op::OpExtInst: {
+ case SpvOpExtInst: {
assert(GetExtensionSet(ir_context, inst) == kExtensionSetName &&
"Extension set is not supported");
@@ -493,31 +493,31 @@ bool TransformationMoveInstructionDown::IsMemoryWriteInstruction(
opt::IRContext* ir_context, const opt::Instruction& inst) {
switch (inst.opcode()) {
// Simple Instructions.
- case spv::Op::OpStore:
- case spv::Op::OpCopyMemory:
+ case SpvOpStore:
+ case SpvOpCopyMemory:
// Image instructions.
- case spv::Op::OpImageWrite:
+ case SpvOpImageWrite:
// Atomic instructions.
- case spv::Op::OpAtomicStore:
- case spv::Op::OpAtomicExchange:
- case spv::Op::OpAtomicCompareExchange:
- case spv::Op::OpAtomicCompareExchangeWeak:
- case spv::Op::OpAtomicIIncrement:
- case spv::Op::OpAtomicIDecrement:
- case spv::Op::OpAtomicIAdd:
- case spv::Op::OpAtomicISub:
- case spv::Op::OpAtomicSMin:
- case spv::Op::OpAtomicUMin:
- case spv::Op::OpAtomicSMax:
- case spv::Op::OpAtomicUMax:
- case spv::Op::OpAtomicAnd:
- case spv::Op::OpAtomicOr:
- case spv::Op::OpAtomicXor:
- case spv::Op::OpAtomicFlagTestAndSet:
- case spv::Op::OpAtomicFlagClear:
+ case SpvOpAtomicStore:
+ case SpvOpAtomicExchange:
+ case SpvOpAtomicCompareExchange:
+ case SpvOpAtomicCompareExchangeWeak:
+ case SpvOpAtomicIIncrement:
+ case SpvOpAtomicIDecrement:
+ case SpvOpAtomicIAdd:
+ case SpvOpAtomicISub:
+ case SpvOpAtomicSMin:
+ case SpvOpAtomicUMin:
+ case SpvOpAtomicSMax:
+ case SpvOpAtomicUMax:
+ case SpvOpAtomicAnd:
+ case SpvOpAtomicOr:
+ case SpvOpAtomicXor:
+ case SpvOpAtomicFlagTestAndSet:
+ case SpvOpAtomicFlagClear:
return true;
// Extensions.
- case spv::Op::OpExtInst: {
+ case SpvOpExtInst: {
if (GetExtensionSet(ir_context, inst) != kExtensionSetName) {
return false;
}
@@ -537,28 +537,28 @@ uint32_t TransformationMoveInstructionDown::GetMemoryWriteTarget(
"|inst| is not a memory write instruction");
switch (inst.opcode()) {
- case spv::Op::OpStore:
- case spv::Op::OpCopyMemory:
- case spv::Op::OpImageWrite:
- case spv::Op::OpAtomicStore:
- case spv::Op::OpAtomicExchange:
- case spv::Op::OpAtomicCompareExchange:
- case spv::Op::OpAtomicCompareExchangeWeak:
- case spv::Op::OpAtomicIIncrement:
- case spv::Op::OpAtomicIDecrement:
- case spv::Op::OpAtomicIAdd:
- case spv::Op::OpAtomicISub:
- case spv::Op::OpAtomicSMin:
- case spv::Op::OpAtomicUMin:
- case spv::Op::OpAtomicSMax:
- case spv::Op::OpAtomicUMax:
- case spv::Op::OpAtomicAnd:
- case spv::Op::OpAtomicOr:
- case spv::Op::OpAtomicXor:
- case spv::Op::OpAtomicFlagTestAndSet:
- case spv::Op::OpAtomicFlagClear:
+ case SpvOpStore:
+ case SpvOpCopyMemory:
+ case SpvOpImageWrite:
+ case SpvOpAtomicStore:
+ case SpvOpAtomicExchange:
+ case SpvOpAtomicCompareExchange:
+ case SpvOpAtomicCompareExchangeWeak:
+ case SpvOpAtomicIIncrement:
+ case SpvOpAtomicIDecrement:
+ case SpvOpAtomicIAdd:
+ case SpvOpAtomicISub:
+ case SpvOpAtomicSMin:
+ case SpvOpAtomicUMin:
+ case SpvOpAtomicSMax:
+ case SpvOpAtomicUMax:
+ case SpvOpAtomicAnd:
+ case SpvOpAtomicOr:
+ case SpvOpAtomicXor:
+ case SpvOpAtomicFlagTestAndSet:
+ case SpvOpAtomicFlagClear:
return inst.GetSingleWordInOperand(0);
- case spv::Op::OpExtInst: {
+ case SpvOpExtInst: {
assert(GetExtensionSet(ir_context, inst) == kExtensionSetName &&
"Extension set is not supported");
@@ -590,9 +590,9 @@ bool TransformationMoveInstructionDown::IsMemoryInstruction(
bool TransformationMoveInstructionDown::IsBarrierInstruction(
const opt::Instruction& inst) {
switch (inst.opcode()) {
- case spv::Op::OpMemoryBarrier:
- case spv::Op::OpControlBarrier:
- case spv::Op::OpMemoryNamedBarrier:
+ case SpvOpMemoryBarrier:
+ case SpvOpControlBarrier:
+ case SpvOpMemoryNamedBarrier:
return true;
default:
return false;
diff --git a/source/fuzz/transformation_mutate_pointer.cpp b/source/fuzz/transformation_mutate_pointer.cpp
index a1620cca..516a0d61 100644
--- a/source/fuzz/transformation_mutate_pointer.cpp
+++ b/source/fuzz/transformation_mutate_pointer.cpp
@@ -51,7 +51,7 @@ bool TransformationMutatePointer::IsApplicable(
// Check that it is possible to insert OpLoad and OpStore before
// |insert_before_inst|. We are only using OpLoad here since the result does
// not depend on the opcode.
- if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(spv::Op::OpLoad,
+ if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(SpvOpLoad,
insert_before_inst)) {
return false;
}
@@ -100,7 +100,7 @@ void TransformationMutatePointer::Apply(
// Back up the original value.
auto backup_instruction = MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpLoad, pointee_type_id, message_.fresh_id(),
+ ir_context, SpvOpLoad, pointee_type_id, message_.fresh_id(),
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_ID, {message_.pointer_id()}}});
auto backup_instruction_ptr = backup_instruction.get();
@@ -110,7 +110,7 @@ void TransformationMutatePointer::Apply(
// Insert a new value.
auto new_value_instruction = MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpStore, 0, 0,
+ ir_context, SpvOpStore, 0, 0,
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_ID, {message_.pointer_id()}},
{SPV_OPERAND_TYPE_ID,
@@ -123,7 +123,7 @@ void TransformationMutatePointer::Apply(
// Restore the original value.
auto restore_instruction = MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpStore, 0, 0,
+ ir_context, SpvOpStore, 0, 0,
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_ID, {message_.pointer_id()}},
{SPV_OPERAND_TYPE_ID, {message_.fresh_id()}}});
@@ -145,9 +145,8 @@ bool TransformationMutatePointer::IsValidPointerInstruction(
opt::IRContext* ir_context, const opt::Instruction& inst) {
// |inst| must have both result id and type id and it may not cause undefined
// behaviour.
- if (!inst.result_id() || !inst.type_id() ||
- inst.opcode() == spv::Op::OpUndef ||
- inst.opcode() == spv::Op::OpConstantNull) {
+ if (!inst.result_id() || !inst.type_id() || inst.opcode() == SpvOpUndef ||
+ inst.opcode() == SpvOpConstantNull) {
return false;
}
@@ -156,16 +155,15 @@ bool TransformationMutatePointer::IsValidPointerInstruction(
assert(type_inst != nullptr && "|inst| has invalid type id");
// |inst| must be a pointer.
- if (type_inst->opcode() != spv::Op::OpTypePointer) {
+ if (type_inst->opcode() != SpvOpTypePointer) {
return false;
}
// |inst| must have a supported storage class.
- switch (
- static_cast<spv::StorageClass>(type_inst->GetSingleWordInOperand(0))) {
- case spv::StorageClass::Function:
- case spv::StorageClass::Private:
- case spv::StorageClass::Workgroup:
+ switch (static_cast<SpvStorageClass>(type_inst->GetSingleWordInOperand(0))) {
+ case SpvStorageClassFunction:
+ case SpvStorageClassPrivate:
+ case SpvStorageClassWorkgroup:
break;
default:
return false;
diff --git a/source/fuzz/transformation_outline_function.cpp b/source/fuzz/transformation_outline_function.cpp
index 4ab68d07..3140fa6b 100644
--- a/source/fuzz/transformation_outline_function.cpp
+++ b/source/fuzz/transformation_outline_function.cpp
@@ -107,7 +107,7 @@ bool TransformationOutlineFunction::IsApplicable(
// The entry and exit block ids must indeed refer to blocks.
for (auto block_id : {message_.entry_block(), message_.exit_block()}) {
auto block_label = ir_context->get_def_use_mgr()->GetDef(block_id);
- if (!block_label || block_label->opcode() != spv::Op::OpLabel) {
+ if (!block_label || block_label->opcode() != SpvOpLabel) {
return false;
}
}
@@ -118,7 +118,7 @@ bool TransformationOutlineFunction::IsApplicable(
// The entry block cannot start with OpVariable - this would mean that
// outlining would remove a variable from the function containing the region
// being outlined.
- if (entry_block->begin()->opcode() == spv::Op::OpVariable) {
+ if (entry_block->begin()->opcode() == SpvOpVariable) {
return false;
}
@@ -136,7 +136,7 @@ bool TransformationOutlineFunction::IsApplicable(
// The entry block cannot start with OpPhi. This is to keep the
// transformation logic simple. (Another transformation to split the OpPhis
// from a block could be applied to avoid this scenario.)
- if (entry_block->begin()->opcode() == spv::Op::OpPhi) {
+ if (entry_block->begin()->opcode() == SpvOpPhi) {
return false;
}
@@ -257,10 +257,10 @@ bool TransformationOutlineFunction::IsApplicable(
auto input_id_inst = ir_context->get_def_use_mgr()->GetDef(id);
if (ir_context->get_def_use_mgr()
->GetDef(input_id_inst->type_id())
- ->opcode() == spv::Op::OpTypePointer) {
+ ->opcode() == SpvOpTypePointer) {
switch (input_id_inst->opcode()) {
- case spv::Op::OpFunctionParameter:
- case spv::Op::OpVariable:
+ case SpvOpFunctionParameter:
+ case SpvOpVariable:
// These are OK.
break;
default:
@@ -286,7 +286,7 @@ bool TransformationOutlineFunction::IsApplicable(
// function)
|| ir_context->get_def_use_mgr()
->GetDef(fuzzerutil::GetTypeId(ir_context, id))
- ->opcode() == spv::Op::OpTypePointer) {
+ ->opcode() == SpvOpTypePointer) {
return false;
}
}
@@ -608,7 +608,7 @@ TransformationOutlineFunction::PrepareFunctionPrototype(
auto output_id_type =
ir_context->get_def_use_mgr()->GetDef(output_id)->type_id();
if (ir_context->get_def_use_mgr()->GetDef(output_id_type)->opcode() ==
- spv::Op::OpTypeVoid) {
+ SpvOpTypeVoid) {
// We cannot add a void field to a struct. We instead use OpUndef to
// handle void output ids.
continue;
@@ -617,7 +617,7 @@ TransformationOutlineFunction::PrepareFunctionPrototype(
}
// Add a new struct type to the module.
ir_context->module()->AddType(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpTypeStruct, 0,
+ ir_context, SpvOpTypeStruct, 0,
message_.new_function_struct_return_type_id(),
std::move(struct_member_types)));
// The return type for the function is the newly-created struct.
@@ -638,7 +638,7 @@ TransformationOutlineFunction::PrepareFunctionPrototype(
// Add a new function type to the module, and record that this is the type
// id for the new function.
ir_context->module()->AddType(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpTypeFunction, 0, message_.new_function_type_id(),
+ ir_context, SpvOpTypeFunction, 0, message_.new_function_type_id(),
function_type_operands));
function_type_id = message_.new_function_type_id();
}
@@ -647,11 +647,10 @@ TransformationOutlineFunction::PrepareFunctionPrototype(
// and the return type and function type prepared above.
std::unique_ptr<opt::Function> outlined_function =
MakeUnique<opt::Function>(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpFunction, return_type_id,
- message_.new_function_id(),
+ ir_context, SpvOpFunction, return_type_id, message_.new_function_id(),
opt::Instruction::OperandList(
{{spv_operand_type_t ::SPV_OPERAND_TYPE_LITERAL_INTEGER,
- {uint32_t(spv::FunctionControlMask::MaskNone)}},
+ {SpvFunctionControlMaskNone}},
{spv_operand_type_t::SPV_OPERAND_TYPE_ID,
{function_type_id}}})));
@@ -660,7 +659,7 @@ TransformationOutlineFunction::PrepareFunctionPrototype(
for (auto id : region_input_ids) {
uint32_t fresh_id = input_id_to_fresh_id_map.at(id);
outlined_function->AddParameter(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpFunctionParameter,
+ ir_context, SpvOpFunctionParameter,
ir_context->get_def_use_mgr()->GetDef(id)->type_id(), fresh_id,
opt::Instruction::OperandList()));
@@ -789,8 +788,7 @@ void TransformationOutlineFunction::PopulateOutlinedFunction(
// |message_.new_function_region_entry_block| as its id.
std::unique_ptr<opt::BasicBlock> outlined_region_entry_block =
MakeUnique<opt::BasicBlock>(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpLabel, 0,
- message_.new_function_region_entry_block(),
+ ir_context, SpvOpLabel, 0, message_.new_function_region_entry_block(),
opt::Instruction::OperandList()));
if (&original_region_entry_block == &original_region_exit_block) {
@@ -856,8 +854,8 @@ void TransformationOutlineFunction::PopulateOutlinedFunction(
// the cloned exit block.
for (auto inst_it = outlined_region_exit_block->begin();
inst_it != outlined_region_exit_block->end();) {
- if (inst_it->opcode() == spv::Op::OpLoopMerge ||
- inst_it->opcode() == spv::Op::OpSelectionMerge) {
+ if (inst_it->opcode() == SpvOpLoopMerge ||
+ inst_it->opcode() == SpvOpSelectionMerge) {
inst_it = inst_it.Erase();
} else if (inst_it->IsBlockTerminator()) {
inst_it = inst_it.Erase();
@@ -872,7 +870,7 @@ void TransformationOutlineFunction::PopulateOutlinedFunction(
// The case where there are no region output ids is simple: we just add
// OpReturn.
outlined_region_exit_block->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpReturn, 0, 0, opt::Instruction::OperandList()));
+ ir_context, SpvOpReturn, 0, 0, opt::Instruction::OperandList()));
} else {
// In the case where there are output ids, we add an OpCompositeConstruct
// instruction to pack all the non-void output values into a struct, and
@@ -881,24 +879,23 @@ void TransformationOutlineFunction::PopulateOutlinedFunction(
for (uint32_t id : region_output_ids) {
if (ir_context->get_def_use_mgr()
->GetDef(output_id_to_type_id.at(id))
- ->opcode() != spv::Op::OpTypeVoid) {
+ ->opcode() != SpvOpTypeVoid) {
struct_member_operands.push_back(
{SPV_OPERAND_TYPE_ID, {output_id_to_fresh_id_map.at(id)}});
}
}
outlined_region_exit_block->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeConstruct,
+ ir_context, SpvOpCompositeConstruct,
message_.new_function_struct_return_type_id(),
message_.new_callee_result_id(), struct_member_operands));
outlined_region_exit_block->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpReturnValue, 0, 0,
+ ir_context, SpvOpReturnValue, 0, 0,
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {message_.new_callee_result_id()}}})));
}
- outlined_function->SetFunctionEnd(
- MakeUnique<opt::Instruction>(ir_context, spv::Op::OpFunctionEnd, 0, 0,
- opt::Instruction::OperandList()));
+ outlined_function->SetFunctionEnd(MakeUnique<opt::Instruction>(
+ ir_context, SpvOpFunctionEnd, 0, 0, opt::Instruction::OperandList()));
}
void TransformationOutlineFunction::ShrinkOriginalRegion(
@@ -966,7 +963,7 @@ void TransformationOutlineFunction::ShrinkOriginalRegion(
}
original_region_entry_block->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpFunctionCall, return_type_id,
+ ir_context, SpvOpFunctionCall, return_type_id,
message_.new_caller_result_id(), function_call_operands));
// If there are output ids, the function call will return a struct. For each
@@ -978,15 +975,15 @@ void TransformationOutlineFunction::ShrinkOriginalRegion(
for (uint32_t output_id : region_output_ids) {
uint32_t output_type_id = output_id_to_type_id.at(output_id);
if (ir_context->get_def_use_mgr()->GetDef(output_type_id)->opcode() ==
- spv::Op::OpTypeVoid) {
+ SpvOpTypeVoid) {
original_region_entry_block->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpUndef, output_type_id, output_id,
+ ir_context, SpvOpUndef, output_type_id, output_id,
opt::Instruction::OperandList()));
// struct_member_index is not incremented since there was no struct member
// associated with this void-typed output id.
} else {
original_region_entry_block->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeExtract, output_type_id, output_id,
+ ir_context, SpvOpCompositeExtract, output_type_id, output_id,
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {message_.new_caller_result_id()}},
{SPV_OPERAND_TYPE_LITERAL_INTEGER, {struct_member_index}}})));
diff --git a/source/fuzz/transformation_permute_function_parameters.cpp b/source/fuzz/transformation_permute_function_parameters.cpp
index b666cdfe..5663d72f 100644
--- a/source/fuzz/transformation_permute_function_parameters.cpp
+++ b/source/fuzz/transformation_permute_function_parameters.cpp
@@ -43,7 +43,7 @@ bool TransformationPermuteFunctionParameters::IsApplicable(
// Check that function exists
const auto* function =
fuzzerutil::FindFunction(ir_context, message_.function_id());
- if (!function || function->DefInst().opcode() != spv::Op::OpFunction ||
+ if (!function || function->DefInst().opcode() != SpvOpFunction ||
fuzzerutil::FunctionIsEntryPoint(ir_context, function->result_id())) {
return false;
}
diff --git a/source/fuzz/transformation_permute_phi_operands.cpp b/source/fuzz/transformation_permute_phi_operands.cpp
index f2f40570..7ee7a82f 100644
--- a/source/fuzz/transformation_permute_phi_operands.cpp
+++ b/source/fuzz/transformation_permute_phi_operands.cpp
@@ -39,7 +39,7 @@ bool TransformationPermutePhiOperands::IsApplicable(
// Check that |message_.result_id| is valid.
const auto* inst =
ir_context->get_def_use_mgr()->GetDef(message_.result_id());
- if (!inst || inst->opcode() != spv::Op::OpPhi) {
+ if (!inst || inst->opcode() != SpvOpPhi) {
return false;
}
diff --git a/source/fuzz/transformation_propagate_instruction_down.cpp b/source/fuzz/transformation_propagate_instruction_down.cpp
index 4b987842..c3b7c4d9 100644
--- a/source/fuzz/transformation_propagate_instruction_down.cpp
+++ b/source/fuzz/transformation_propagate_instruction_down.cpp
@@ -144,7 +144,7 @@ void TransformationPropagateInstructionDown::Apply(
->block(merge_block_id)
->begin()
->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpPhi, inst_to_propagate->type_id(),
+ ir_context, SpvOpPhi, inst_to_propagate->type_id(),
message_.phi_fresh_id(), std::move(in_operands)));
fuzzerutil::UpdateModuleIdBound(ir_context, message_.phi_fresh_id());
@@ -234,115 +234,115 @@ protobufs::Transformation TransformationPropagateInstructionDown::ToMessage()
return result;
}
-bool TransformationPropagateInstructionDown::IsOpcodeSupported(spv::Op opcode) {
+bool TransformationPropagateInstructionDown::IsOpcodeSupported(SpvOp opcode) {
// TODO(https://github.com/KhronosGroup/SPIRV-Tools/issues/3605):
// We only support "simple" instructions that don't work with memory.
// We should extend this so that we support the ones that modify the memory
// too.
switch (opcode) {
- case spv::Op::OpUndef:
- case spv::Op::OpAccessChain:
- case spv::Op::OpInBoundsAccessChain:
- case spv::Op::OpArrayLength:
- case spv::Op::OpVectorExtractDynamic:
- case spv::Op::OpVectorInsertDynamic:
- case spv::Op::OpVectorShuffle:
- case spv::Op::OpCompositeConstruct:
- case spv::Op::OpCompositeExtract:
- case spv::Op::OpCompositeInsert:
- case spv::Op::OpCopyObject:
- case spv::Op::OpTranspose:
- case spv::Op::OpConvertFToU:
- case spv::Op::OpConvertFToS:
- case spv::Op::OpConvertSToF:
- case spv::Op::OpConvertUToF:
- case spv::Op::OpUConvert:
- case spv::Op::OpSConvert:
- case spv::Op::OpFConvert:
- case spv::Op::OpQuantizeToF16:
- case spv::Op::OpSatConvertSToU:
- case spv::Op::OpSatConvertUToS:
- case spv::Op::OpBitcast:
- case spv::Op::OpSNegate:
- case spv::Op::OpFNegate:
- case spv::Op::OpIAdd:
- case spv::Op::OpFAdd:
- case spv::Op::OpISub:
- case spv::Op::OpFSub:
- case spv::Op::OpIMul:
- case spv::Op::OpFMul:
- case spv::Op::OpUDiv:
- case spv::Op::OpSDiv:
- case spv::Op::OpFDiv:
- case spv::Op::OpUMod:
- case spv::Op::OpSRem:
- case spv::Op::OpSMod:
- case spv::Op::OpFRem:
- case spv::Op::OpFMod:
- case spv::Op::OpVectorTimesScalar:
- case spv::Op::OpMatrixTimesScalar:
- case spv::Op::OpVectorTimesMatrix:
- case spv::Op::OpMatrixTimesVector:
- case spv::Op::OpMatrixTimesMatrix:
- case spv::Op::OpOuterProduct:
- case spv::Op::OpDot:
- case spv::Op::OpIAddCarry:
- case spv::Op::OpISubBorrow:
- case spv::Op::OpUMulExtended:
- case spv::Op::OpSMulExtended:
- case spv::Op::OpAny:
- case spv::Op::OpAll:
- case spv::Op::OpIsNan:
- case spv::Op::OpIsInf:
- case spv::Op::OpIsFinite:
- case spv::Op::OpIsNormal:
- case spv::Op::OpSignBitSet:
- case spv::Op::OpLessOrGreater:
- case spv::Op::OpOrdered:
- case spv::Op::OpUnordered:
- case spv::Op::OpLogicalEqual:
- case spv::Op::OpLogicalNotEqual:
- case spv::Op::OpLogicalOr:
- case spv::Op::OpLogicalAnd:
- case spv::Op::OpLogicalNot:
- case spv::Op::OpSelect:
- case spv::Op::OpIEqual:
- case spv::Op::OpINotEqual:
- case spv::Op::OpUGreaterThan:
- case spv::Op::OpSGreaterThan:
- case spv::Op::OpUGreaterThanEqual:
- case spv::Op::OpSGreaterThanEqual:
- case spv::Op::OpULessThan:
- case spv::Op::OpSLessThan:
- case spv::Op::OpULessThanEqual:
- case spv::Op::OpSLessThanEqual:
- case spv::Op::OpFOrdEqual:
- case spv::Op::OpFUnordEqual:
- case spv::Op::OpFOrdNotEqual:
- case spv::Op::OpFUnordNotEqual:
- case spv::Op::OpFOrdLessThan:
- case spv::Op::OpFUnordLessThan:
- case spv::Op::OpFOrdGreaterThan:
- case spv::Op::OpFUnordGreaterThan:
- case spv::Op::OpFOrdLessThanEqual:
- case spv::Op::OpFUnordLessThanEqual:
- case spv::Op::OpFOrdGreaterThanEqual:
- case spv::Op::OpFUnordGreaterThanEqual:
- case spv::Op::OpShiftRightLogical:
- case spv::Op::OpShiftRightArithmetic:
- case spv::Op::OpShiftLeftLogical:
- case spv::Op::OpBitwiseOr:
- case spv::Op::OpBitwiseXor:
- case spv::Op::OpBitwiseAnd:
- case spv::Op::OpNot:
- case spv::Op::OpBitFieldInsert:
- case spv::Op::OpBitFieldSExtract:
- case spv::Op::OpBitFieldUExtract:
- case spv::Op::OpBitReverse:
- case spv::Op::OpBitCount:
- case spv::Op::OpCopyLogical:
- case spv::Op::OpPtrEqual:
- case spv::Op::OpPtrNotEqual:
+ case SpvOpUndef:
+ case SpvOpAccessChain:
+ case SpvOpInBoundsAccessChain:
+ case SpvOpArrayLength:
+ case SpvOpVectorExtractDynamic:
+ case SpvOpVectorInsertDynamic:
+ case SpvOpVectorShuffle:
+ case SpvOpCompositeConstruct:
+ case SpvOpCompositeExtract:
+ case SpvOpCompositeInsert:
+ case SpvOpCopyObject:
+ case SpvOpTranspose:
+ case SpvOpConvertFToU:
+ case SpvOpConvertFToS:
+ case SpvOpConvertSToF:
+ case SpvOpConvertUToF:
+ case SpvOpUConvert:
+ case SpvOpSConvert:
+ case SpvOpFConvert:
+ case SpvOpQuantizeToF16:
+ case SpvOpSatConvertSToU:
+ case SpvOpSatConvertUToS:
+ case SpvOpBitcast:
+ case SpvOpSNegate:
+ case SpvOpFNegate:
+ case SpvOpIAdd:
+ case SpvOpFAdd:
+ case SpvOpISub:
+ case SpvOpFSub:
+ case SpvOpIMul:
+ case SpvOpFMul:
+ case SpvOpUDiv:
+ case SpvOpSDiv:
+ case SpvOpFDiv:
+ case SpvOpUMod:
+ case SpvOpSRem:
+ case SpvOpSMod:
+ case SpvOpFRem:
+ case SpvOpFMod:
+ case SpvOpVectorTimesScalar:
+ case SpvOpMatrixTimesScalar:
+ case SpvOpVectorTimesMatrix:
+ case SpvOpMatrixTimesVector:
+ case SpvOpMatrixTimesMatrix:
+ case SpvOpOuterProduct:
+ case SpvOpDot:
+ case SpvOpIAddCarry:
+ case SpvOpISubBorrow:
+ case SpvOpUMulExtended:
+ case SpvOpSMulExtended:
+ case SpvOpAny:
+ case SpvOpAll:
+ case SpvOpIsNan:
+ case SpvOpIsInf:
+ case SpvOpIsFinite:
+ case SpvOpIsNormal:
+ case SpvOpSignBitSet:
+ case SpvOpLessOrGreater:
+ case SpvOpOrdered:
+ case SpvOpUnordered:
+ case SpvOpLogicalEqual:
+ case SpvOpLogicalNotEqual:
+ case SpvOpLogicalOr:
+ case SpvOpLogicalAnd:
+ case SpvOpLogicalNot:
+ case SpvOpSelect:
+ case SpvOpIEqual:
+ case SpvOpINotEqual:
+ case SpvOpUGreaterThan:
+ case SpvOpSGreaterThan:
+ case SpvOpUGreaterThanEqual:
+ case SpvOpSGreaterThanEqual:
+ case SpvOpULessThan:
+ case SpvOpSLessThan:
+ case SpvOpULessThanEqual:
+ case SpvOpSLessThanEqual:
+ case SpvOpFOrdEqual:
+ case SpvOpFUnordEqual:
+ case SpvOpFOrdNotEqual:
+ case SpvOpFUnordNotEqual:
+ case SpvOpFOrdLessThan:
+ case SpvOpFUnordLessThan:
+ case SpvOpFOrdGreaterThan:
+ case SpvOpFUnordGreaterThan:
+ case SpvOpFOrdLessThanEqual:
+ case SpvOpFUnordLessThanEqual:
+ case SpvOpFOrdGreaterThanEqual:
+ case SpvOpFUnordGreaterThanEqual:
+ case SpvOpShiftRightLogical:
+ case SpvOpShiftRightArithmetic:
+ case SpvOpShiftLeftLogical:
+ case SpvOpBitwiseOr:
+ case SpvOpBitwiseXor:
+ case SpvOpBitwiseAnd:
+ case SpvOpNot:
+ case SpvOpBitFieldInsert:
+ case SpvOpBitFieldSExtract:
+ case SpvOpBitFieldUExtract:
+ case SpvOpBitReverse:
+ case SpvOpBitCount:
+ case SpvOpCopyLogical:
+ case SpvOpPtrEqual:
+ case SpvOpPtrNotEqual:
return true;
default:
return false;
@@ -408,7 +408,7 @@ bool TransformationPropagateInstructionDown::IsApplicableToBlock(
// use |inst|.
for (auto successor_id : successor_ids) {
for (const auto& maybe_phi_inst : *ir_context->cfg()->block(successor_id)) {
- if (maybe_phi_inst.opcode() != spv::Op::OpPhi) {
+ if (maybe_phi_inst.opcode() != SpvOpPhi) {
// OpPhis can be intermixed with OpLine and OpNoLine.
continue;
}
@@ -446,7 +446,7 @@ bool TransformationPropagateInstructionDown::IsApplicableToBlock(
// |phi_block_id| dominates |user|'s block (or its predecessor if the
// user is an OpPhi). We can't use fuzzerutil::IdIsAvailableAtUse since
// the id in question hasn't yet been created in the module.
- auto block_id_to_dominate = user->opcode() == spv::Op::OpPhi
+ auto block_id_to_dominate = user->opcode() == SpvOpPhi
? user->GetSingleWordOperand(index + 1)
: user_block->id();
@@ -465,7 +465,7 @@ bool TransformationPropagateInstructionDown::IsApplicableToBlock(
opt::Instruction*
TransformationPropagateInstructionDown::GetFirstInsertBeforeInstruction(
- opt::IRContext* ir_context, uint32_t block_id, spv::Op opcode) {
+ opt::IRContext* ir_context, uint32_t block_id, SpvOp opcode) {
auto* block = ir_context->cfg()->block(block_id);
auto it = block->begin();
@@ -572,7 +572,7 @@ uint32_t TransformationPropagateInstructionDown::GetOpPhiBlockId(
// OpPhi instructions cannot have operands of pointer types.
if (propagate_type->AsPointer() &&
!ir_context->get_feature_mgr()->HasCapability(
- spv::Capability::VariablePointersStorageBuffer)) {
+ SpvCapabilityVariablePointersStorageBuffer)) {
return 0;
}
diff --git a/source/fuzz/transformation_propagate_instruction_down.h b/source/fuzz/transformation_propagate_instruction_down.h
index 91339285..560d7dc5 100644
--- a/source/fuzz/transformation_propagate_instruction_down.h
+++ b/source/fuzz/transformation_propagate_instruction_down.h
@@ -120,12 +120,12 @@ class TransformationPropagateInstructionDown : public Transformation {
uint32_t block_id);
// Returns true if |opcode| is supported by this transformation.
- static bool IsOpcodeSupported(spv::Op opcode);
+ static bool IsOpcodeSupported(SpvOp opcode);
// Returns the first instruction in the |block| that allows us to insert
// |opcode| above itself. Returns nullptr is no such instruction exists.
static opt::Instruction* GetFirstInsertBeforeInstruction(
- opt::IRContext* ir_context, uint32_t block_id, spv::Op opcode);
+ opt::IRContext* ir_context, uint32_t block_id, SpvOp opcode);
// Returns a result id of a basic block, where an OpPhi instruction can be
// inserted. Returns nullptr if it's not possible to create an OpPhi. The
diff --git a/source/fuzz/transformation_propagate_instruction_up.cpp b/source/fuzz/transformation_propagate_instruction_up.cpp
index f9674fa9..bf0e6630 100644
--- a/source/fuzz/transformation_propagate_instruction_up.cpp
+++ b/source/fuzz/transformation_propagate_instruction_up.cpp
@@ -23,7 +23,7 @@ namespace {
uint32_t GetResultIdFromLabelId(const opt::Instruction& phi_inst,
uint32_t label_id) {
- assert(phi_inst.opcode() == spv::Op::OpPhi && "|phi_inst| is not an OpPhi");
+ assert(phi_inst.opcode() == SpvOpPhi && "|phi_inst| is not an OpPhi");
for (uint32_t i = 1; i < phi_inst.NumInOperands(); i += 2) {
if (phi_inst.GetSingleWordInOperand(i) == label_id) {
@@ -66,7 +66,7 @@ bool HasValidDependencies(opt::IRContext* ir_context, opt::Instruction* inst) {
assert(dependency && "Operand has invalid id");
if (ir_context->get_instr_block(dependency) == inst_block &&
- dependency->opcode() != spv::Op::OpPhi) {
+ dependency->opcode() != SpvOpPhi) {
// |dependency| is "valid" if it's an OpPhi from the same basic block or
// an instruction from a different basic block.
return false;
@@ -173,7 +173,7 @@ void TransformationPropagateInstructionUp::Apply(
continue;
}
- assert(dependency_inst->opcode() == spv::Op::OpPhi &&
+ assert(dependency_inst->opcode() == SpvOpPhi &&
"Propagated instruction can depend only on OpPhis from the same "
"basic block or instructions from different basic blocks");
@@ -191,7 +191,7 @@ void TransformationPropagateInstructionUp::Apply(
// Insert an OpPhi instruction into the basic block of |inst|.
ir_context->get_instr_block(inst)->begin()->InsertBefore(
- MakeUnique<opt::Instruction>(ir_context, spv::Op::OpPhi, inst->type_id(),
+ MakeUnique<opt::Instruction>(ir_context, SpvOpPhi, inst->type_id(),
inst->result_id(),
std::move(op_phi_operands)));
@@ -210,115 +210,115 @@ protobufs::Transformation TransformationPropagateInstructionUp::ToMessage()
return result;
}
-bool TransformationPropagateInstructionUp::IsOpcodeSupported(spv::Op opcode) {
+bool TransformationPropagateInstructionUp::IsOpcodeSupported(SpvOp opcode) {
// TODO(https://github.com/KhronosGroup/SPIRV-Tools/issues/3605):
// We only support "simple" instructions that don't work with memory.
// We should extend this so that we support the ones that modify the memory
// too.
switch (opcode) {
- case spv::Op::OpUndef:
- case spv::Op::OpAccessChain:
- case spv::Op::OpInBoundsAccessChain:
- case spv::Op::OpArrayLength:
- case spv::Op::OpVectorExtractDynamic:
- case spv::Op::OpVectorInsertDynamic:
- case spv::Op::OpVectorShuffle:
- case spv::Op::OpCompositeConstruct:
- case spv::Op::OpCompositeExtract:
- case spv::Op::OpCompositeInsert:
- case spv::Op::OpCopyObject:
- case spv::Op::OpTranspose:
- case spv::Op::OpConvertFToU:
- case spv::Op::OpConvertFToS:
- case spv::Op::OpConvertSToF:
- case spv::Op::OpConvertUToF:
- case spv::Op::OpUConvert:
- case spv::Op::OpSConvert:
- case spv::Op::OpFConvert:
- case spv::Op::OpQuantizeToF16:
- case spv::Op::OpSatConvertSToU:
- case spv::Op::OpSatConvertUToS:
- case spv::Op::OpBitcast:
- case spv::Op::OpSNegate:
- case spv::Op::OpFNegate:
- case spv::Op::OpIAdd:
- case spv::Op::OpFAdd:
- case spv::Op::OpISub:
- case spv::Op::OpFSub:
- case spv::Op::OpIMul:
- case spv::Op::OpFMul:
- case spv::Op::OpUDiv:
- case spv::Op::OpSDiv:
- case spv::Op::OpFDiv:
- case spv::Op::OpUMod:
- case spv::Op::OpSRem:
- case spv::Op::OpSMod:
- case spv::Op::OpFRem:
- case spv::Op::OpFMod:
- case spv::Op::OpVectorTimesScalar:
- case spv::Op::OpMatrixTimesScalar:
- case spv::Op::OpVectorTimesMatrix:
- case spv::Op::OpMatrixTimesVector:
- case spv::Op::OpMatrixTimesMatrix:
- case spv::Op::OpOuterProduct:
- case spv::Op::OpDot:
- case spv::Op::OpIAddCarry:
- case spv::Op::OpISubBorrow:
- case spv::Op::OpUMulExtended:
- case spv::Op::OpSMulExtended:
- case spv::Op::OpAny:
- case spv::Op::OpAll:
- case spv::Op::OpIsNan:
- case spv::Op::OpIsInf:
- case spv::Op::OpIsFinite:
- case spv::Op::OpIsNormal:
- case spv::Op::OpSignBitSet:
- case spv::Op::OpLessOrGreater:
- case spv::Op::OpOrdered:
- case spv::Op::OpUnordered:
- case spv::Op::OpLogicalEqual:
- case spv::Op::OpLogicalNotEqual:
- case spv::Op::OpLogicalOr:
- case spv::Op::OpLogicalAnd:
- case spv::Op::OpLogicalNot:
- case spv::Op::OpSelect:
- case spv::Op::OpIEqual:
- case spv::Op::OpINotEqual:
- case spv::Op::OpUGreaterThan:
- case spv::Op::OpSGreaterThan:
- case spv::Op::OpUGreaterThanEqual:
- case spv::Op::OpSGreaterThanEqual:
- case spv::Op::OpULessThan:
- case spv::Op::OpSLessThan:
- case spv::Op::OpULessThanEqual:
- case spv::Op::OpSLessThanEqual:
- case spv::Op::OpFOrdEqual:
- case spv::Op::OpFUnordEqual:
- case spv::Op::OpFOrdNotEqual:
- case spv::Op::OpFUnordNotEqual:
- case spv::Op::OpFOrdLessThan:
- case spv::Op::OpFUnordLessThan:
- case spv::Op::OpFOrdGreaterThan:
- case spv::Op::OpFUnordGreaterThan:
- case spv::Op::OpFOrdLessThanEqual:
- case spv::Op::OpFUnordLessThanEqual:
- case spv::Op::OpFOrdGreaterThanEqual:
- case spv::Op::OpFUnordGreaterThanEqual:
- case spv::Op::OpShiftRightLogical:
- case spv::Op::OpShiftRightArithmetic:
- case spv::Op::OpShiftLeftLogical:
- case spv::Op::OpBitwiseOr:
- case spv::Op::OpBitwiseXor:
- case spv::Op::OpBitwiseAnd:
- case spv::Op::OpNot:
- case spv::Op::OpBitFieldInsert:
- case spv::Op::OpBitFieldSExtract:
- case spv::Op::OpBitFieldUExtract:
- case spv::Op::OpBitReverse:
- case spv::Op::OpBitCount:
- case spv::Op::OpCopyLogical:
- case spv::Op::OpPtrEqual:
- case spv::Op::OpPtrNotEqual:
+ case SpvOpUndef:
+ case SpvOpAccessChain:
+ case SpvOpInBoundsAccessChain:
+ case SpvOpArrayLength:
+ case SpvOpVectorExtractDynamic:
+ case SpvOpVectorInsertDynamic:
+ case SpvOpVectorShuffle:
+ case SpvOpCompositeConstruct:
+ case SpvOpCompositeExtract:
+ case SpvOpCompositeInsert:
+ case SpvOpCopyObject:
+ case SpvOpTranspose:
+ case SpvOpConvertFToU:
+ case SpvOpConvertFToS:
+ case SpvOpConvertSToF:
+ case SpvOpConvertUToF:
+ case SpvOpUConvert:
+ case SpvOpSConvert:
+ case SpvOpFConvert:
+ case SpvOpQuantizeToF16:
+ case SpvOpSatConvertSToU:
+ case SpvOpSatConvertUToS:
+ case SpvOpBitcast:
+ case SpvOpSNegate:
+ case SpvOpFNegate:
+ case SpvOpIAdd:
+ case SpvOpFAdd:
+ case SpvOpISub:
+ case SpvOpFSub:
+ case SpvOpIMul:
+ case SpvOpFMul:
+ case SpvOpUDiv:
+ case SpvOpSDiv:
+ case SpvOpFDiv:
+ case SpvOpUMod:
+ case SpvOpSRem:
+ case SpvOpSMod:
+ case SpvOpFRem:
+ case SpvOpFMod:
+ case SpvOpVectorTimesScalar:
+ case SpvOpMatrixTimesScalar:
+ case SpvOpVectorTimesMatrix:
+ case SpvOpMatrixTimesVector:
+ case SpvOpMatrixTimesMatrix:
+ case SpvOpOuterProduct:
+ case SpvOpDot:
+ case SpvOpIAddCarry:
+ case SpvOpISubBorrow:
+ case SpvOpUMulExtended:
+ case SpvOpSMulExtended:
+ case SpvOpAny:
+ case SpvOpAll:
+ case SpvOpIsNan:
+ case SpvOpIsInf:
+ case SpvOpIsFinite:
+ case SpvOpIsNormal:
+ case SpvOpSignBitSet:
+ case SpvOpLessOrGreater:
+ case SpvOpOrdered:
+ case SpvOpUnordered:
+ case SpvOpLogicalEqual:
+ case SpvOpLogicalNotEqual:
+ case SpvOpLogicalOr:
+ case SpvOpLogicalAnd:
+ case SpvOpLogicalNot:
+ case SpvOpSelect:
+ case SpvOpIEqual:
+ case SpvOpINotEqual:
+ case SpvOpUGreaterThan:
+ case SpvOpSGreaterThan:
+ case SpvOpUGreaterThanEqual:
+ case SpvOpSGreaterThanEqual:
+ case SpvOpULessThan:
+ case SpvOpSLessThan:
+ case SpvOpULessThanEqual:
+ case SpvOpSLessThanEqual:
+ case SpvOpFOrdEqual:
+ case SpvOpFUnordEqual:
+ case SpvOpFOrdNotEqual:
+ case SpvOpFUnordNotEqual:
+ case SpvOpFOrdLessThan:
+ case SpvOpFUnordLessThan:
+ case SpvOpFOrdGreaterThan:
+ case SpvOpFUnordGreaterThan:
+ case SpvOpFOrdLessThanEqual:
+ case SpvOpFUnordLessThanEqual:
+ case SpvOpFOrdGreaterThanEqual:
+ case SpvOpFUnordGreaterThanEqual:
+ case SpvOpShiftRightLogical:
+ case SpvOpShiftRightArithmetic:
+ case SpvOpShiftLeftLogical:
+ case SpvOpBitwiseOr:
+ case SpvOpBitwiseXor:
+ case SpvOpBitwiseAnd:
+ case SpvOpNot:
+ case SpvOpBitFieldInsert:
+ case SpvOpBitFieldSExtract:
+ case SpvOpBitFieldUExtract:
+ case SpvOpBitReverse:
+ case SpvOpBitCount:
+ case SpvOpCopyLogical:
+ case SpvOpPtrEqual:
+ case SpvOpPtrNotEqual:
return true;
default:
return false;
@@ -338,7 +338,7 @@ TransformationPropagateInstructionUp::GetInstructionToPropagate(
// - it must be supported by this transformation
// - it may depend only on instructions from different basic blocks or on
// OpPhi instructions from the same basic block.
- if (inst.opcode() == spv::Op::OpPhi || !IsOpcodeSupported(inst.opcode()) ||
+ if (inst.opcode() == SpvOpPhi || !IsOpcodeSupported(inst.opcode()) ||
!inst.type_id() || !inst.result_id()) {
continue;
}
@@ -353,7 +353,7 @@ TransformationPropagateInstructionUp::GetInstructionToPropagate(
}
if (!ir_context->get_feature_mgr()->HasCapability(
- spv::Capability::VariablePointersStorageBuffer) &&
+ SpvCapabilityVariablePointersStorageBuffer) &&
ContainsPointers(*inst_type)) {
// OpPhi supports pointer operands only with VariablePointers or
// VariablePointersStorageBuffer capabilities.
@@ -377,7 +377,7 @@ bool TransformationPropagateInstructionUp::IsApplicableToBlock(
opt::IRContext* ir_context, uint32_t block_id) {
// Check that |block_id| is valid.
const auto* label_inst = ir_context->get_def_use_mgr()->GetDef(block_id);
- if (!label_inst || label_inst->opcode() != spv::Op::OpLabel) {
+ if (!label_inst || label_inst->opcode() != SpvOpLabel) {
return false;
}
diff --git a/source/fuzz/transformation_propagate_instruction_up.h b/source/fuzz/transformation_propagate_instruction_up.h
index 93aa365a..0ca051bf 100644
--- a/source/fuzz/transformation_propagate_instruction_up.h
+++ b/source/fuzz/transformation_propagate_instruction_up.h
@@ -80,7 +80,7 @@ class TransformationPropagateInstructionUp : public Transformation {
uint32_t block_id);
// Returns true if |opcode| is supported by this transformation.
- static bool IsOpcodeSupported(spv::Op opcode);
+ static bool IsOpcodeSupported(SpvOp opcode);
protobufs::TransformationPropagateInstructionUp message_;
};
diff --git a/source/fuzz/transformation_push_id_through_variable.cpp b/source/fuzz/transformation_push_id_through_variable.cpp
index 2372d70c..55a57a15 100644
--- a/source/fuzz/transformation_push_id_through_variable.cpp
+++ b/source/fuzz/transformation_push_id_through_variable.cpp
@@ -53,9 +53,9 @@ bool TransformationPushIdThroughVariable::IsApplicable(
// It must be valid to insert the OpStore and OpLoad instruction before it.
if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(
- spv::Op::OpStore, instruction_to_insert_before) ||
+ SpvOpStore, instruction_to_insert_before) ||
!fuzzerutil::CanInsertOpcodeBeforeInstruction(
- spv::Op::OpLoad, instruction_to_insert_before)) {
+ SpvOpLoad, instruction_to_insert_before)) {
return false;
}
@@ -75,16 +75,14 @@ bool TransformationPushIdThroughVariable::IsApplicable(
// A pointer type instruction pointing to the value type must be defined.
auto pointer_type_id = fuzzerutil::MaybeGetPointerType(
ir_context, value_instruction->type_id(),
- static_cast<spv::StorageClass>(message_.variable_storage_class()));
+ static_cast<SpvStorageClass>(message_.variable_storage_class()));
if (!pointer_type_id) {
return false;
}
// |message_.variable_storage_class| must be private or function.
- assert((message_.variable_storage_class() ==
- (uint32_t)spv::StorageClass::Private ||
- message_.variable_storage_class() ==
- (uint32_t)spv::StorageClass::Function) &&
+ assert((message_.variable_storage_class() == SpvStorageClassPrivate ||
+ message_.variable_storage_class() == SpvStorageClassFunction) &&
"The variable storage class must be private or function.");
// Check that initializer is valid.
@@ -113,15 +111,14 @@ void TransformationPushIdThroughVariable::Apply(
// A pointer type instruction pointing to the value type must be defined.
auto pointer_type_id = fuzzerutil::MaybeGetPointerType(
ir_context, value_instruction->type_id(),
- static_cast<spv::StorageClass>(message_.variable_storage_class()));
+ static_cast<SpvStorageClass>(message_.variable_storage_class()));
assert(pointer_type_id && "The required pointer type must be available.");
// Adds whether a global or local variable.
- if (spv::StorageClass(message_.variable_storage_class()) ==
- spv::StorageClass::Private) {
+ if (message_.variable_storage_class() == SpvStorageClassPrivate) {
opt::Instruction* global_variable = fuzzerutil::AddGlobalVariable(
ir_context, message_.variable_id(), pointer_type_id,
- spv::StorageClass::Private, message_.initializer_id());
+ SpvStorageClassPrivate, message_.initializer_id());
ir_context->get_def_use_mgr()->AnalyzeInstDefUse(global_variable);
} else {
opt::Function* function =
@@ -141,13 +138,13 @@ void TransformationPushIdThroughVariable::Apply(
fuzzerutil::UpdateModuleIdBound(ir_context, message_.value_synonym_id());
opt::Instruction* load_instruction =
insert_before->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpLoad, value_instruction->type_id(),
+ ir_context, SpvOpLoad, value_instruction->type_id(),
message_.value_synonym_id(),
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {message_.variable_id()}}})));
opt::Instruction* store_instruction =
load_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpStore, 0, 0,
+ ir_context, SpvOpStore, 0, 0,
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {message_.variable_id()}},
{SPV_OPERAND_TYPE_ID, {message_.value_id()}}})));
diff --git a/source/fuzz/transformation_replace_add_sub_mul_with_carrying_extended.cpp b/source/fuzz/transformation_replace_add_sub_mul_with_carrying_extended.cpp
index 03e97375..e1977a64 100644
--- a/source/fuzz/transformation_replace_add_sub_mul_with_carrying_extended.cpp
+++ b/source/fuzz/transformation_replace_add_sub_mul_with_carrying_extended.cpp
@@ -97,20 +97,20 @@ void TransformationReplaceAddSubMulWithCarryingExtended::Apply(
// Determine the opcode of the new instruction that computes the result into a
// struct.
- spv::Op new_instruction_opcode;
+ SpvOp new_instruction_opcode;
switch (original_instruction->opcode()) {
- case spv::Op::OpIAdd:
- new_instruction_opcode = spv::Op::OpIAddCarry;
+ case SpvOpIAdd:
+ new_instruction_opcode = SpvOpIAddCarry;
break;
- case spv::Op::OpISub:
- new_instruction_opcode = spv::Op::OpISubBorrow;
+ case SpvOpISub:
+ new_instruction_opcode = SpvOpISubBorrow;
break;
- case spv::Op::OpIMul:
+ case SpvOpIMul:
if (!operand_is_signed) {
- new_instruction_opcode = spv::Op::OpUMulExtended;
+ new_instruction_opcode = SpvOpUMulExtended;
} else {
- new_instruction_opcode = spv::Op::OpSMulExtended;
+ new_instruction_opcode = SpvOpSMulExtended;
}
break;
default:
@@ -148,7 +148,7 @@ void TransformationReplaceAddSubMulWithCarryingExtended::Apply(
// takes the first component of the struct which represents low-order bits of
// the operation. This is the original result.
original_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeExtract, original_instruction->type_id(),
+ ir_context, SpvOpCompositeExtract, original_instruction->type_id(),
message_.result_id(),
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {message_.struct_fresh_id()}},
@@ -168,9 +168,9 @@ bool TransformationReplaceAddSubMulWithCarryingExtended::IsInstructionSuitable(
// Only instructions OpIAdd, OpISub, OpIMul are supported.
switch (instruction_opcode) {
- case spv::Op::OpIAdd:
- case spv::Op::OpISub:
- case spv::Op::OpIMul:
+ case SpvOpIAdd:
+ case SpvOpISub:
+ case SpvOpIMul:
break;
default:
return false;
@@ -201,8 +201,8 @@ bool TransformationReplaceAddSubMulWithCarryingExtended::IsInstructionSuitable(
auto type = ir_context->get_type_mgr()->GetType(instruction.type_id());
switch (instruction_opcode) {
- case spv::Op::OpIAdd:
- case spv::Op::OpISub: {
+ case SpvOpIAdd:
+ case SpvOpISub: {
// In case of OpIAdd and OpISub if the operand is a vector, the component
// type must be unsigned. Otherwise (if the operand is an int), the
// operand must be unsigned.
diff --git a/source/fuzz/transformation_replace_boolean_constant_with_constant_binary.cpp b/source/fuzz/transformation_replace_boolean_constant_with_constant_binary.cpp
index efd15551..24293516 100644
--- a/source/fuzz/transformation_replace_boolean_constant_with_constant_binary.cpp
+++ b/source/fuzz/transformation_replace_boolean_constant_with_constant_binary.cpp
@@ -28,8 +28,7 @@ namespace {
// operator |binop|, returns true if it is certain that 'lhs binop rhs'
// evaluates to |required_value|.
template <typename T>
-bool float_binop_evaluates_to(T lhs, T rhs, spv::Op binop,
- bool required_value) {
+bool float_binop_evaluates_to(T lhs, T rhs, SpvOp binop, bool required_value) {
// Infinity and NaN values are conservatively treated as out of scope.
if (!std::isfinite(lhs) || !std::isfinite(rhs)) {
return false;
@@ -38,20 +37,20 @@ bool float_binop_evaluates_to(T lhs, T rhs, spv::Op binop,
// The following captures the binary operators that spirv-fuzz can actually
// generate when turning a boolean constant into a binary expression.
switch (binop) {
- case spv::Op::OpFOrdGreaterThanEqual:
- case spv::Op::OpFUnordGreaterThanEqual:
+ case SpvOpFOrdGreaterThanEqual:
+ case SpvOpFUnordGreaterThanEqual:
binop_result = (lhs >= rhs);
break;
- case spv::Op::OpFOrdGreaterThan:
- case spv::Op::OpFUnordGreaterThan:
+ case SpvOpFOrdGreaterThan:
+ case SpvOpFUnordGreaterThan:
binop_result = (lhs > rhs);
break;
- case spv::Op::OpFOrdLessThanEqual:
- case spv::Op::OpFUnordLessThanEqual:
+ case SpvOpFOrdLessThanEqual:
+ case SpvOpFUnordLessThanEqual:
binop_result = (lhs <= rhs);
break;
- case spv::Op::OpFOrdLessThan:
- case spv::Op::OpFUnordLessThan:
+ case SpvOpFOrdLessThan:
+ case SpvOpFUnordLessThan:
binop_result = (lhs < rhs);
break;
default:
@@ -62,20 +61,20 @@ bool float_binop_evaluates_to(T lhs, T rhs, spv::Op binop,
// Analogous to 'float_binop_evaluates_to', but for signed int values.
template <typename T>
-bool signed_int_binop_evaluates_to(T lhs, T rhs, spv::Op binop,
+bool signed_int_binop_evaluates_to(T lhs, T rhs, SpvOp binop,
bool required_value) {
bool binop_result;
switch (binop) {
- case spv::Op::OpSGreaterThanEqual:
+ case SpvOpSGreaterThanEqual:
binop_result = (lhs >= rhs);
break;
- case spv::Op::OpSGreaterThan:
+ case SpvOpSGreaterThan:
binop_result = (lhs > rhs);
break;
- case spv::Op::OpSLessThanEqual:
+ case SpvOpSLessThanEqual:
binop_result = (lhs <= rhs);
break;
- case spv::Op::OpSLessThan:
+ case SpvOpSLessThan:
binop_result = (lhs < rhs);
break;
default:
@@ -86,20 +85,20 @@ bool signed_int_binop_evaluates_to(T lhs, T rhs, spv::Op binop,
// Analogous to 'float_binop_evaluates_to', but for unsigned int values.
template <typename T>
-bool unsigned_int_binop_evaluates_to(T lhs, T rhs, spv::Op binop,
+bool unsigned_int_binop_evaluates_to(T lhs, T rhs, SpvOp binop,
bool required_value) {
bool binop_result;
switch (binop) {
- case spv::Op::OpUGreaterThanEqual:
+ case SpvOpUGreaterThanEqual:
binop_result = (lhs >= rhs);
break;
- case spv::Op::OpUGreaterThan:
+ case SpvOpUGreaterThan:
binop_result = (lhs > rhs);
break;
- case spv::Op::OpULessThanEqual:
+ case SpvOpULessThanEqual:
binop_result = (lhs <= rhs);
break;
- case spv::Op::OpULessThan:
+ case SpvOpULessThan:
binop_result = (lhs < rhs);
break;
default:
@@ -119,12 +118,12 @@ TransformationReplaceBooleanConstantWithConstantBinary::
TransformationReplaceBooleanConstantWithConstantBinary::
TransformationReplaceBooleanConstantWithConstantBinary(
const protobufs::IdUseDescriptor& id_use_descriptor, uint32_t lhs_id,
- uint32_t rhs_id, spv::Op comparison_opcode,
+ uint32_t rhs_id, SpvOp comparison_opcode,
uint32_t fresh_id_for_binary_operation) {
*message_.mutable_id_use_descriptor() = id_use_descriptor;
message_.set_lhs_id(lhs_id);
message_.set_rhs_id(rhs_id);
- message_.set_opcode(uint32_t(comparison_opcode));
+ message_.set_opcode(comparison_opcode);
message_.set_fresh_id_for_binary_operation(fresh_id_for_binary_operation);
}
@@ -142,8 +141,8 @@ bool TransformationReplaceBooleanConstantWithConstantBinary::IsApplicable(
if (!boolean_constant) {
return false;
}
- if (!(boolean_constant->opcode() == spv::Op::OpConstantFalse ||
- boolean_constant->opcode() == spv::Op::OpConstantTrue)) {
+ if (!(boolean_constant->opcode() == SpvOpConstantFalse ||
+ boolean_constant->opcode() == SpvOpConstantTrue)) {
return false;
}
@@ -153,7 +152,7 @@ bool TransformationReplaceBooleanConstantWithConstantBinary::IsApplicable(
if (!lhs_constant_inst) {
return false;
}
- if (lhs_constant_inst->opcode() != spv::Op::OpConstant) {
+ if (lhs_constant_inst->opcode() != SpvOpConstant) {
return false;
}
@@ -163,7 +162,7 @@ bool TransformationReplaceBooleanConstantWithConstantBinary::IsApplicable(
if (!rhs_constant_inst) {
return false;
}
- if (rhs_constant_inst->opcode() != spv::Op::OpConstant) {
+ if (rhs_constant_inst->opcode() != SpvOpConstant) {
return false;
}
@@ -177,10 +176,9 @@ bool TransformationReplaceBooleanConstantWithConstantBinary::IsApplicable(
ir_context->get_constant_mgr()->FindDeclaredConstant(message_.lhs_id());
auto rhs_constant =
ir_context->get_constant_mgr()->FindDeclaredConstant(message_.rhs_id());
- bool expected_result =
- (boolean_constant->opcode() == spv::Op::OpConstantTrue);
+ bool expected_result = (boolean_constant->opcode() == SpvOpConstantTrue);
- const auto binary_opcode = static_cast<spv::Op>(message_.opcode());
+ const auto binary_opcode = static_cast<SpvOp>(message_.opcode());
// We consider the floating point, signed and unsigned integer cases
// separately. In each case the logic is very similar.
@@ -249,7 +247,7 @@ bool TransformationReplaceBooleanConstantWithConstantBinary::IsApplicable(
// a binary operator before an OpVariable, but in any case (b) the
// constant we would be replacing is the initializer constant of the
// OpVariable, and this cannot be the result of a binary operation.
- if (instruction->opcode() == spv::Op::OpVariable) {
+ if (instruction->opcode() == SpvOpVariable) {
return false;
}
@@ -270,7 +268,7 @@ TransformationReplaceBooleanConstantWithConstantBinary::ApplyWithResult(
{SPV_OPERAND_TYPE_ID, {message_.lhs_id()}},
{SPV_OPERAND_TYPE_ID, {message_.rhs_id()}}};
auto binary_instruction = MakeUnique<opt::Instruction>(
- ir_context, static_cast<spv::Op>(message_.opcode()),
+ ir_context, static_cast<SpvOp>(message_.opcode()),
ir_context->get_type_mgr()->GetId(&bool_type),
message_.fresh_id_for_binary_operation(), operands);
opt::Instruction* result = binary_instruction.get();
@@ -281,7 +279,7 @@ TransformationReplaceBooleanConstantWithConstantBinary::ApplyWithResult(
// If |instruction_before_which_to_insert| is an OpPhi instruction,
// then |binary_instruction| will be inserted into the parent block associated
// with the OpPhi variable operand.
- if (instruction_containing_constant_use->opcode() == spv::Op::OpPhi) {
+ if (instruction_containing_constant_use->opcode() == SpvOpPhi) {
instruction_before_which_to_insert =
ir_context->cfg()
->block(instruction_containing_constant_use->GetSingleWordInOperand(
@@ -295,9 +293,8 @@ TransformationReplaceBooleanConstantWithConstantBinary::ApplyWithResult(
{
opt::Instruction* previous_node =
instruction_before_which_to_insert->PreviousNode();
- if (previous_node &&
- (previous_node->opcode() == spv::Op::OpLoopMerge ||
- previous_node->opcode() == spv::Op::OpSelectionMerge)) {
+ if (previous_node && (previous_node->opcode() == SpvOpLoopMerge ||
+ previous_node->opcode() == SpvOpSelectionMerge)) {
instruction_before_which_to_insert = previous_node;
}
}
diff --git a/source/fuzz/transformation_replace_boolean_constant_with_constant_binary.h b/source/fuzz/transformation_replace_boolean_constant_with_constant_binary.h
index 4d48bf2c..97c66bf9 100644
--- a/source/fuzz/transformation_replace_boolean_constant_with_constant_binary.h
+++ b/source/fuzz/transformation_replace_boolean_constant_with_constant_binary.h
@@ -32,7 +32,7 @@ class TransformationReplaceBooleanConstantWithConstantBinary
TransformationReplaceBooleanConstantWithConstantBinary(
const protobufs::IdUseDescriptor& id_use_descriptor, uint32_t lhs_id,
- uint32_t rhs_id, spv::Op comparison_opcode,
+ uint32_t rhs_id, SpvOp comparison_opcode,
uint32_t fresh_id_for_binary_operation);
// - |message_.fresh_id_for_binary_operation| must not already be used by the
diff --git a/source/fuzz/transformation_replace_branch_from_dead_block_with_exit.cpp b/source/fuzz/transformation_replace_branch_from_dead_block_with_exit.cpp
index 4150bb13..9ea7cb6a 100644
--- a/source/fuzz/transformation_replace_branch_from_dead_block_with_exit.cpp
+++ b/source/fuzz/transformation_replace_branch_from_dead_block_with_exit.cpp
@@ -26,10 +26,10 @@ TransformationReplaceBranchFromDeadBlockWithExit::
TransformationReplaceBranchFromDeadBlockWithExit::
TransformationReplaceBranchFromDeadBlockWithExit(uint32_t block_id,
- spv::Op opcode,
+ SpvOp opcode,
uint32_t return_value_id) {
message_.set_block_id(block_id);
- message_.set_opcode(uint32_t(opcode));
+ message_.set_opcode(opcode);
message_.set_return_value_id(return_value_id);
}
@@ -45,11 +45,11 @@ bool TransformationReplaceBranchFromDeadBlockWithExit::IsApplicable(
return false;
}
auto function_return_type_id = block->GetParent()->type_id();
- switch (spv::Op(message_.opcode())) {
- case spv::Op::OpKill:
+ switch (message_.opcode()) {
+ case SpvOpKill:
for (auto& entry_point : ir_context->module()->entry_points()) {
- if (spv::ExecutionModel(entry_point.GetSingleWordInOperand(0)) !=
- spv::ExecutionModel::Fragment) {
+ if (entry_point.GetSingleWordInOperand(0) !=
+ SpvExecutionModelFragment) {
// OpKill is only allowed in a fragment shader. This is a
// conservative check: if the module contains a non-fragment entry
// point then adding an OpKill might lead to OpKill being used in a
@@ -58,15 +58,15 @@ bool TransformationReplaceBranchFromDeadBlockWithExit::IsApplicable(
}
}
break;
- case spv::Op::OpReturn:
+ case SpvOpReturn:
if (ir_context->get_def_use_mgr()
->GetDef(function_return_type_id)
- ->opcode() != spv::Op::OpTypeVoid) {
+ ->opcode() != SpvOpTypeVoid) {
// OpReturn is only allowed in a function with void return type.
return false;
}
break;
- case spv::Op::OpReturnValue: {
+ case SpvOpReturnValue: {
// If the terminator is to be changed to OpReturnValue, with
// |message_.return_value_id| being the value that will be returned, then
// |message_.return_value_id| must have a compatible type and be available
@@ -83,7 +83,7 @@ bool TransformationReplaceBranchFromDeadBlockWithExit::IsApplicable(
break;
}
default:
- assert(spv::Op(message_.opcode()) == spv::Op::OpUnreachable &&
+ assert(message_.opcode() == SpvOpUnreachable &&
"Invalid early exit opcode.");
break;
}
@@ -95,7 +95,7 @@ void TransformationReplaceBranchFromDeadBlockWithExit::Apply(
// If the successor block has OpPhi instructions then arguments related to
// |message_.block_id| need to be removed from these instruction.
auto block = ir_context->get_instr_block(message_.block_id());
- assert(block->terminator()->opcode() == spv::Op::OpBranch &&
+ assert(block->terminator()->opcode() == SpvOpBranch &&
"Precondition: the block must end with OpBranch.");
auto successor = ir_context->get_instr_block(
block->terminator()->GetSingleWordInOperand(0));
@@ -114,12 +114,12 @@ void TransformationReplaceBranchFromDeadBlockWithExit::Apply(
// Rewrite the terminator of |message_.block_id|.
opt::Instruction::OperandList new_terminator_in_operands;
- if (spv::Op(message_.opcode()) == spv::Op::OpReturnValue) {
+ if (message_.opcode() == SpvOpReturnValue) {
new_terminator_in_operands.push_back(
{SPV_OPERAND_TYPE_ID, {message_.return_value_id()}});
}
auto terminator = block->terminator();
- terminator->SetOpcode(static_cast<spv::Op>(message_.opcode()));
+ terminator->SetOpcode(static_cast<SpvOp>(message_.opcode()));
terminator->SetInOperands(std::move(new_terminator_in_operands));
ir_context->InvalidateAnalysesExceptFor(opt::IRContext::kAnalysisNone);
}
@@ -145,7 +145,7 @@ bool TransformationReplaceBranchFromDeadBlockWithExit::BlockIsSuitable(
return false;
}
// The block's terminator must be OpBranch.
- if (block.terminator()->opcode() != spv::Op::OpBranch) {
+ if (block.terminator()->opcode() != SpvOpBranch) {
return false;
}
if (ir_context->GetStructuredCFGAnalysis()->IsInContinueConstruct(
@@ -164,7 +164,7 @@ bool TransformationReplaceBranchFromDeadBlockWithExit::BlockIsSuitable(
// Make sure that domination rules are satisfied when we remove the branch
// from the |block| to its |successor|.
return fuzzerutil::NewTerminatorPreservesDominationRules(
- ir_context, block.id(), {ir_context, spv::Op::OpUnreachable});
+ ir_context, block.id(), {ir_context, SpvOpUnreachable});
}
} // namespace fuzz
diff --git a/source/fuzz/transformation_replace_branch_from_dead_block_with_exit.h b/source/fuzz/transformation_replace_branch_from_dead_block_with_exit.h
index 9a5d42e2..89667fcd 100644
--- a/source/fuzz/transformation_replace_branch_from_dead_block_with_exit.h
+++ b/source/fuzz/transformation_replace_branch_from_dead_block_with_exit.h
@@ -30,7 +30,7 @@ class TransformationReplaceBranchFromDeadBlockWithExit : public Transformation {
protobufs::TransformationReplaceBranchFromDeadBlockWithExit message);
TransformationReplaceBranchFromDeadBlockWithExit(uint32_t block_id,
- spv::Op opcode,
+ SpvOp opcode,
uint32_t return_value_id);
// - |message_.block_id| must be the id of a dead block that is not part of
diff --git a/source/fuzz/transformation_replace_constant_with_uniform.cpp b/source/fuzz/transformation_replace_constant_with_uniform.cpp
index 7174e6a7..c6698c03 100644
--- a/source/fuzz/transformation_replace_constant_with_uniform.cpp
+++ b/source/fuzz/transformation_replace_constant_with_uniform.cpp
@@ -67,15 +67,15 @@ TransformationReplaceConstantWithUniform::MakeAccessChainInstruction(
// The type id for the access chain is a uniform pointer with base type
// matching the given constant id type.
auto type_and_pointer_type =
- ir_context->get_type_mgr()->GetTypeAndPointerType(
- constant_type_id, spv::StorageClass::Uniform);
+ ir_context->get_type_mgr()->GetTypeAndPointerType(constant_type_id,
+ SpvStorageClassUniform);
assert(type_and_pointer_type.first != nullptr);
assert(type_and_pointer_type.second != nullptr);
auto pointer_to_uniform_constant_type_id =
ir_context->get_type_mgr()->GetId(type_and_pointer_type.second.get());
return MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpAccessChain, pointer_to_uniform_constant_type_id,
+ ir_context, SpvOpAccessChain, pointer_to_uniform_constant_type_id,
message_.fresh_id_for_access_chain(), operands_for_access_chain);
}
@@ -84,9 +84,9 @@ TransformationReplaceConstantWithUniform::MakeLoadInstruction(
spvtools::opt::IRContext* ir_context, uint32_t constant_type_id) const {
opt::Instruction::OperandList operands_for_load = {
{SPV_OPERAND_TYPE_ID, {message_.fresh_id_for_access_chain()}}};
- return MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpLoad, constant_type_id,
- message_.fresh_id_for_load(), operands_for_load);
+ return MakeUnique<opt::Instruction>(ir_context, SpvOpLoad, constant_type_id,
+ message_.fresh_id_for_load(),
+ operands_for_load);
}
opt::Instruction*
@@ -99,7 +99,7 @@ TransformationReplaceConstantWithUniform::GetInsertBeforeInstruction(
}
// The use might be in an OpPhi instruction.
- if (result->opcode() == spv::Op::OpPhi) {
+ if (result->opcode() == SpvOpPhi) {
// OpPhi instructions must be the first instructions in a block. Thus, we
// can't insert above the OpPhi instruction. Given the predecessor block
// that corresponds to the id use, get the last instruction in that block
@@ -108,19 +108,18 @@ TransformationReplaceConstantWithUniform::GetInsertBeforeInstruction(
ir_context,
result->GetSingleWordInOperand(
message_.id_use_descriptor().in_operand_index() + 1),
- spv::Op::OpLoad);
+ SpvOpLoad);
}
// The only operand that we could've replaced in the OpBranchConditional is
// the condition id. But that operand has a boolean type and uniform variables
// can't store booleans (see the spec on OpTypeBool). Thus, |result| can't be
// an OpBranchConditional.
- assert(result->opcode() != spv::Op::OpBranchConditional &&
+ assert(result->opcode() != SpvOpBranchConditional &&
"OpBranchConditional has no operands to replace");
- assert(
- fuzzerutil::CanInsertOpcodeBeforeInstruction(spv::Op::OpLoad, result) &&
- "We should be able to insert OpLoad and OpAccessChain at this point");
+ assert(fuzzerutil::CanInsertOpcodeBeforeInstruction(SpvOpLoad, result) &&
+ "We should be able to insert OpLoad and OpAccessChain at this point");
return result;
}
@@ -192,15 +191,15 @@ bool TransformationReplaceConstantWithUniform::IsApplicable(
// The use must not be a variable initializer; these are required to be
// constants, so it would be illegal to replace one with a uniform access.
- if (instruction_using_constant->opcode() == spv::Op::OpVariable) {
+ if (instruction_using_constant->opcode() == SpvOpVariable) {
return false;
}
// The module needs to have a uniform pointer type suitable for indexing into
// the uniform variable, i.e. matching the type of the constant we wish to
// replace with a uniform.
- opt::analysis::Pointer pointer_to_type_of_constant(
- declared_constant->type(), spv::StorageClass::Uniform);
+ opt::analysis::Pointer pointer_to_type_of_constant(declared_constant->type(),
+ SpvStorageClassUniform);
if (!ir_context->get_type_mgr()->GetId(&pointer_to_type_of_constant)) {
return false;
}
diff --git a/source/fuzz/transformation_replace_copy_memory_with_load_store.cpp b/source/fuzz/transformation_replace_copy_memory_with_load_store.cpp
index 8f141451..de9d1fd3 100644
--- a/source/fuzz/transformation_replace_copy_memory_with_load_store.cpp
+++ b/source/fuzz/transformation_replace_copy_memory_with_load_store.cpp
@@ -45,7 +45,7 @@ bool TransformationReplaceCopyMemoryWithLoadStore::IsApplicable(
auto copy_memory_instruction = FindInstruction(
message_.copy_memory_instruction_descriptor(), ir_context);
if (!copy_memory_instruction ||
- copy_memory_instruction->opcode() != spv::Op::OpCopyMemory) {
+ copy_memory_instruction->opcode() != SpvOpCopyMemory) {
return false;
}
return true;
@@ -57,7 +57,7 @@ void TransformationReplaceCopyMemoryWithLoadStore::Apply(
message_.copy_memory_instruction_descriptor(), ir_context);
// |copy_memory_instruction| must be defined.
assert(copy_memory_instruction &&
- copy_memory_instruction->opcode() == spv::Op::OpCopyMemory &&
+ copy_memory_instruction->opcode() == SpvOpCopyMemory &&
"The required OpCopyMemory instruction must be defined.");
// Integrity check: Both operands must be pointers.
@@ -78,8 +78,8 @@ void TransformationReplaceCopyMemoryWithLoadStore::Apply(
(void)target_type_opcode;
(void)source_type_opcode;
- assert(target_type_opcode == spv::Op::OpTypePointer &&
- source_type_opcode == spv::Op::OpTypePointer &&
+ assert(target_type_opcode == SpvOpTypePointer &&
+ source_type_opcode == SpvOpTypePointer &&
"Operands must be of type OpTypePointer");
// Integrity check: |source| and |target| must point to the same type.
@@ -100,12 +100,12 @@ void TransformationReplaceCopyMemoryWithLoadStore::Apply(
fuzzerutil::UpdateModuleIdBound(ir_context, message_.fresh_id());
FindInstruction(message_.copy_memory_instruction_descriptor(), ir_context)
->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpStore, 0, 0,
+ ir_context, SpvOpStore, 0, 0,
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {target->result_id()}},
{SPV_OPERAND_TYPE_ID, {message_.fresh_id()}}})))
->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpLoad, target_pointee_type, message_.fresh_id(),
+ ir_context, SpvOpLoad, target_pointee_type, message_.fresh_id(),
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {source->result_id()}}})));
diff --git a/source/fuzz/transformation_replace_copy_object_with_store_load.cpp b/source/fuzz/transformation_replace_copy_object_with_store_load.cpp
index f08a7345..e0643bf3 100644
--- a/source/fuzz/transformation_replace_copy_object_with_store_load.cpp
+++ b/source/fuzz/transformation_replace_copy_object_with_store_load.cpp
@@ -46,7 +46,7 @@ bool TransformationReplaceCopyObjectWithStoreLoad::IsApplicable(
// This must be a defined OpCopyObject instruction.
if (!copy_object_instruction ||
- copy_object_instruction->opcode() != spv::Op::OpCopyObject) {
+ copy_object_instruction->opcode() != SpvOpCopyObject) {
return false;
}
@@ -54,14 +54,14 @@ bool TransformationReplaceCopyObjectWithStoreLoad::IsApplicable(
// because we cannot define a pointer to pointer.
if (ir_context->get_def_use_mgr()
->GetDef(copy_object_instruction->type_id())
- ->opcode() == spv::Op::OpTypePointer) {
+ ->opcode() == SpvOpTypePointer) {
return false;
}
// A pointer type instruction pointing to the value type must be defined.
auto pointer_type_id = fuzzerutil::MaybeGetPointerType(
ir_context, copy_object_instruction->type_id(),
- static_cast<spv::StorageClass>(message_.variable_storage_class()));
+ static_cast<SpvStorageClass>(message_.variable_storage_class()));
if (!pointer_type_id) {
return false;
}
@@ -74,10 +74,8 @@ bool TransformationReplaceCopyObjectWithStoreLoad::IsApplicable(
return false;
}
// |message_.variable_storage_class| must be Private or Function.
- return spv::StorageClass(message_.variable_storage_class()) ==
- spv::StorageClass::Private ||
- spv::StorageClass(message_.variable_storage_class()) ==
- spv::StorageClass::Function;
+ return message_.variable_storage_class() == SpvStorageClassPrivate ||
+ message_.variable_storage_class() == SpvStorageClassFunction;
}
void TransformationReplaceCopyObjectWithStoreLoad::Apply(
@@ -87,7 +85,7 @@ void TransformationReplaceCopyObjectWithStoreLoad::Apply(
ir_context->get_def_use_mgr()->GetDef(message_.copy_object_result_id());
// |copy_object_instruction| must be defined.
assert(copy_object_instruction &&
- copy_object_instruction->opcode() == spv::Op::OpCopyObject &&
+ copy_object_instruction->opcode() == SpvOpCopyObject &&
"The required OpCopyObject instruction must be defined.");
opt::BasicBlock* enclosing_block =
@@ -98,15 +96,14 @@ void TransformationReplaceCopyObjectWithStoreLoad::Apply(
// A pointer type instruction pointing to the value type must be defined.
auto pointer_type_id = fuzzerutil::MaybeGetPointerType(
ir_context, copy_object_instruction->type_id(),
- static_cast<spv::StorageClass>(message_.variable_storage_class()));
+ static_cast<SpvStorageClass>(message_.variable_storage_class()));
assert(pointer_type_id && "The required pointer type must be available.");
// Adds a global or local variable (according to the storage class).
- if (spv::StorageClass(message_.variable_storage_class()) ==
- spv::StorageClass::Private) {
+ if (message_.variable_storage_class() == SpvStorageClassPrivate) {
opt::Instruction* new_global = fuzzerutil::AddGlobalVariable(
ir_context, message_.fresh_variable_id(), pointer_type_id,
- spv::StorageClass::Private, message_.variable_initializer_id());
+ SpvStorageClassPrivate, message_.variable_initializer_id());
ir_context->get_def_use_mgr()->AnalyzeInstDefUse(new_global);
} else {
opt::Function* function =
@@ -123,13 +120,13 @@ void TransformationReplaceCopyObjectWithStoreLoad::Apply(
fuzzerutil::UpdateModuleIdBound(ir_context, message_.fresh_variable_id());
opt::Instruction* load_instruction =
copy_object_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpLoad, copy_object_instruction->type_id(),
+ ir_context, SpvOpLoad, copy_object_instruction->type_id(),
message_.copy_object_result_id(),
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {message_.fresh_variable_id()}}})));
opt::Instruction* store_instruction =
load_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpStore, 0, 0,
+ ir_context, SpvOpStore, 0, 0,
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {message_.fresh_variable_id()}},
{SPV_OPERAND_TYPE_ID, {src_operand}}})));
diff --git a/source/fuzz/transformation_replace_irrelevant_id.cpp b/source/fuzz/transformation_replace_irrelevant_id.cpp
index 7f640639..a71f96a8 100644
--- a/source/fuzz/transformation_replace_irrelevant_id.cpp
+++ b/source/fuzz/transformation_replace_irrelevant_id.cpp
@@ -65,7 +65,7 @@ bool TransformationReplaceIrrelevantId::IsApplicable(
}
// The replacement id must not be the result of an OpFunction instruction.
- if (replacement_id_def->opcode() == spv::Op::OpFunction) {
+ if (replacement_id_def->opcode() == SpvOpFunction) {
return false;
}
@@ -130,7 +130,7 @@ bool TransformationReplaceIrrelevantId::
AttemptsToReplaceVariableInitializerWithNonConstant(
const opt::Instruction& use_instruction,
const opt::Instruction& replacement_for_use) {
- return use_instruction.opcode() == spv::Op::OpVariable &&
+ return use_instruction.opcode() == SpvOpVariable &&
!spvOpcodeIsConstant(replacement_for_use.opcode());
}
diff --git a/source/fuzz/transformation_replace_linear_algebra_instruction.cpp b/source/fuzz/transformation_replace_linear_algebra_instruction.cpp
index fb7b2948..2430ccab 100644
--- a/source/fuzz/transformation_replace_linear_algebra_instruction.cpp
+++ b/source/fuzz/transformation_replace_linear_algebra_instruction.cpp
@@ -68,28 +68,28 @@ void TransformationReplaceLinearAlgebraInstruction::Apply(
FindInstruction(message_.instruction_descriptor(), ir_context);
switch (linear_algebra_instruction->opcode()) {
- case spv::Op::OpTranspose:
+ case SpvOpTranspose:
ReplaceOpTranspose(ir_context, linear_algebra_instruction);
break;
- case spv::Op::OpVectorTimesScalar:
+ case SpvOpVectorTimesScalar:
ReplaceOpVectorTimesScalar(ir_context, linear_algebra_instruction);
break;
- case spv::Op::OpMatrixTimesScalar:
+ case SpvOpMatrixTimesScalar:
ReplaceOpMatrixTimesScalar(ir_context, linear_algebra_instruction);
break;
- case spv::Op::OpVectorTimesMatrix:
+ case SpvOpVectorTimesMatrix:
ReplaceOpVectorTimesMatrix(ir_context, linear_algebra_instruction);
break;
- case spv::Op::OpMatrixTimesVector:
+ case SpvOpMatrixTimesVector:
ReplaceOpMatrixTimesVector(ir_context, linear_algebra_instruction);
break;
- case spv::Op::OpMatrixTimesMatrix:
+ case SpvOpMatrixTimesMatrix:
ReplaceOpMatrixTimesMatrix(ir_context, linear_algebra_instruction);
break;
- case spv::Op::OpOuterProduct:
+ case SpvOpOuterProduct:
ReplaceOpOuterProduct(ir_context, linear_algebra_instruction);
break;
- case spv::Op::OpDot:
+ case SpvOpDot:
ReplaceOpDot(ir_context, linear_algebra_instruction);
break;
default:
@@ -112,7 +112,7 @@ uint32_t TransformationReplaceLinearAlgebraInstruction::GetRequiredFreshIdCount(
// TODO(https://github.com/KhronosGroup/SPIRV-Tools/issues/3354):
// Right now we only support certain operations.
switch (instruction->opcode()) {
- case spv::Op::OpTranspose: {
+ case SpvOpTranspose: {
// For each matrix row, |2 * matrix_column_count| OpCompositeExtract and 1
// OpCompositeConstruct will be inserted.
auto matrix_instruction = ir_context->get_def_use_mgr()->GetDef(
@@ -130,7 +130,7 @@ uint32_t TransformationReplaceLinearAlgebraInstruction::GetRequiredFreshIdCount(
->element_count();
return matrix_row_count * (2 * matrix_column_count + 1);
}
- case spv::Op::OpVectorTimesScalar:
+ case SpvOpVectorTimesScalar:
// For each vector component, 1 OpCompositeExtract and 1 OpFMul will be
// inserted.
return 2 *
@@ -140,7 +140,7 @@ uint32_t TransformationReplaceLinearAlgebraInstruction::GetRequiredFreshIdCount(
->type_id())
->AsVector()
->element_count();
- case spv::Op::OpMatrixTimesScalar: {
+ case SpvOpMatrixTimesScalar: {
// For each matrix column, |1 + column.size| OpCompositeExtract,
// |column.size| OpFMul and 1 OpCompositeConstruct instructions will be
// inserted.
@@ -154,7 +154,7 @@ uint32_t TransformationReplaceLinearAlgebraInstruction::GetRequiredFreshIdCount(
->AsVector()
->element_count());
}
- case spv::Op::OpVectorTimesMatrix: {
+ case SpvOpVectorTimesMatrix: {
// For each vector component, 1 OpCompositeExtract instruction will be
// inserted. For each matrix column, |1 + vector_component_count|
// OpCompositeExtract, |vector_component_count| OpFMul and
@@ -175,7 +175,7 @@ uint32_t TransformationReplaceLinearAlgebraInstruction::GetRequiredFreshIdCount(
->element_count();
return vector_component_count * (3 * matrix_column_count + 1);
}
- case spv::Op::OpMatrixTimesVector: {
+ case SpvOpMatrixTimesVector: {
// For each matrix column, |1 + matrix_row_count| OpCompositeExtract
// will be inserted. For each matrix row, |matrix_column_count| OpFMul and
// |matrix_column_count - 1| OpFAdd instructions will be inserted. For
@@ -197,7 +197,7 @@ uint32_t TransformationReplaceLinearAlgebraInstruction::GetRequiredFreshIdCount(
return 3 * matrix_column_count * matrix_row_count +
2 * matrix_column_count - matrix_row_count;
}
- case spv::Op::OpMatrixTimesMatrix: {
+ case SpvOpMatrixTimesMatrix: {
// For each matrix 2 column, 1 OpCompositeExtract, 1 OpCompositeConstruct,
// |3 * matrix_1_row_count * matrix_1_column_count| OpCompositeExtract,
// |matrix_1_row_count * matrix_1_column_count| OpFMul,
@@ -228,7 +228,7 @@ uint32_t TransformationReplaceLinearAlgebraInstruction::GetRequiredFreshIdCount(
return matrix_2_column_count *
(2 + matrix_1_row_count * (5 * matrix_1_column_count - 1));
}
- case spv::Op::OpOuterProduct: {
+ case SpvOpOuterProduct: {
// For each |vector_2| component, |vector_1_component_count + 1|
// OpCompositeExtract, |vector_1_component_count| OpFMul and 1
// OpCompositeConstruct instructions will be inserted.
@@ -248,7 +248,7 @@ uint32_t TransformationReplaceLinearAlgebraInstruction::GetRequiredFreshIdCount(
->element_count();
return 2 * vector_2_component_count * (vector_1_component_count + 1);
}
- case spv::Op::OpDot:
+ case SpvOpDot:
// For each pair of vector components, 2 OpCompositeExtract and 1 OpFMul
// will be inserted. The first two OpFMul instructions will result the
// first OpFAdd instruction to be inserted. For each remaining OpFMul, 1
@@ -299,7 +299,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpTranspose(
// Extracts the matrix column.
uint32_t matrix_column_id = message_.fresh_ids(fresh_id_index++);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeExtract,
+ ir_context, SpvOpCompositeExtract,
ir_context->get_type_mgr()->GetId(matrix_column_type),
matrix_column_id,
opt::Instruction::OperandList(
@@ -309,7 +309,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpTranspose(
// Extracts the matrix column component.
column_component_ids[j] = message_.fresh_ids(fresh_id_index++);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeExtract,
+ ir_context, SpvOpCompositeExtract,
ir_context->get_type_mgr()->GetId(matrix_column_component_type),
column_component_ids[j],
opt::Instruction::OperandList(
@@ -324,14 +324,14 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpTranspose(
}
result_column_ids[i] = message_.fresh_ids(fresh_id_index++);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeConstruct,
+ ir_context, SpvOpCompositeConstruct,
ir_context->get_type_mgr()->GetId(resulting_matrix_column_type),
result_column_ids[i], opt::Instruction::OperandList(in_operands)));
}
// The OpTranspose instruction is changed to an OpCompositeConstruct
// instruction.
- linear_algebra_instruction->SetOpcode(spv::Op::OpCompositeConstruct);
+ linear_algebra_instruction->SetOpcode(SpvOpCompositeConstruct);
linear_algebra_instruction->SetInOperand(0, {result_column_ids[0]});
for (uint32_t i = 1; i < result_column_ids.size(); i++) {
linear_algebra_instruction->AddOperand(
@@ -363,8 +363,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpVectorTimesScalar(
uint32_t vector_extract_id = message_.fresh_ids(fresh_id_index++);
fuzzerutil::UpdateModuleIdBound(ir_context, vector_extract_id);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeExtract, scalar->type_id(),
- vector_extract_id,
+ ir_context, SpvOpCompositeExtract, scalar->type_id(), vector_extract_id,
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {vector->result_id()}},
{SPV_OPERAND_TYPE_LITERAL_INTEGER, {i}}})));
@@ -374,7 +373,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpVectorTimesScalar(
float_multiplication_ids[i] = float_multiplication_id;
fuzzerutil::UpdateModuleIdBound(ir_context, float_multiplication_id);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpFMul, scalar->type_id(), float_multiplication_id,
+ ir_context, SpvOpFMul, scalar->type_id(), float_multiplication_id,
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {vector_extract_id}},
{SPV_OPERAND_TYPE_ID, {scalar->result_id()}}})));
@@ -382,7 +381,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpVectorTimesScalar(
// The OpVectorTimesScalar instruction is changed to an OpCompositeConstruct
// instruction.
- linear_algebra_instruction->SetOpcode(spv::Op::OpCompositeConstruct);
+ linear_algebra_instruction->SetOpcode(SpvOpCompositeConstruct);
linear_algebra_instruction->SetInOperand(0, {float_multiplication_ids[0]});
linear_algebra_instruction->SetInOperand(1, {float_multiplication_ids[1]});
for (uint32_t i = 2; i < float_multiplication_ids.size(); i++) {
@@ -419,7 +418,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpMatrixTimesScalar(
uint32_t matrix_extract_id = message_.fresh_ids(fresh_id_index++);
fuzzerutil::UpdateModuleIdBound(ir_context, matrix_extract_id);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeExtract,
+ ir_context, SpvOpCompositeExtract,
ir_context->get_type_mgr()->GetId(matrix_column_type),
matrix_extract_id,
opt::Instruction::OperandList(
@@ -433,8 +432,8 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpMatrixTimesScalar(
uint32_t column_extract_id = message_.fresh_ids(fresh_id_index++);
fuzzerutil::UpdateModuleIdBound(ir_context, column_extract_id);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeExtract,
- scalar_instruction->type_id(), column_extract_id,
+ ir_context, SpvOpCompositeExtract, scalar_instruction->type_id(),
+ column_extract_id,
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {matrix_extract_id}},
{SPV_OPERAND_TYPE_LITERAL_INTEGER, {j}}})));
@@ -443,7 +442,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpMatrixTimesScalar(
float_multiplication_ids[j] = message_.fresh_ids(fresh_id_index++);
fuzzerutil::UpdateModuleIdBound(ir_context, float_multiplication_ids[j]);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpFMul, scalar_instruction->type_id(),
+ ir_context, SpvOpFMul, scalar_instruction->type_id(),
float_multiplication_ids[j],
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {column_extract_id}},
@@ -459,14 +458,14 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpMatrixTimesScalar(
composite_construct_ids[i] = message_.fresh_ids(fresh_id_index++);
fuzzerutil::UpdateModuleIdBound(ir_context, composite_construct_ids[i]);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeConstruct,
+ ir_context, SpvOpCompositeConstruct,
ir_context->get_type_mgr()->GetId(matrix_column_type),
composite_construct_ids[i], composite_construct_in_operands));
}
// The OpMatrixTimesScalar instruction is changed to an OpCompositeConstruct
// instruction.
- linear_algebra_instruction->SetOpcode(spv::Op::OpCompositeConstruct);
+ linear_algebra_instruction->SetOpcode(SpvOpCompositeConstruct);
linear_algebra_instruction->SetInOperand(0, {composite_construct_ids[0]});
linear_algebra_instruction->SetInOperand(1, {composite_construct_ids[1]});
for (uint32_t i = 2; i < composite_construct_ids.size(); i++) {
@@ -496,7 +495,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpVectorTimesMatrix(
for (uint32_t i = 0; i < vector_component_count; i++) {
vector_component_ids[i] = message_.fresh_ids(fresh_id_index++);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeExtract,
+ ir_context, SpvOpCompositeExtract,
ir_context->get_type_mgr()->GetId(vector_component_type),
vector_component_ids[i],
opt::Instruction::OperandList(
@@ -521,7 +520,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpVectorTimesMatrix(
// Extracts matrix column.
uint32_t matrix_extract_id = message_.fresh_ids(fresh_id_index++);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeExtract,
+ ir_context, SpvOpCompositeExtract,
ir_context->get_type_mgr()->GetId(matrix_column_type),
matrix_extract_id,
opt::Instruction::OperandList(
@@ -533,7 +532,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpVectorTimesMatrix(
// Extracts column component.
uint32_t column_extract_id = message_.fresh_ids(fresh_id_index++);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeExtract,
+ ir_context, SpvOpCompositeExtract,
ir_context->get_type_mgr()->GetId(vector_component_type),
column_extract_id,
opt::Instruction::OperandList(
@@ -543,7 +542,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpVectorTimesMatrix(
// Multiplies corresponding vector and column components.
float_multiplication_ids[j] = message_.fresh_ids(fresh_id_index++);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpFMul,
+ ir_context, SpvOpFMul,
ir_context->get_type_mgr()->GetId(vector_component_type),
float_multiplication_ids[j],
opt::Instruction::OperandList(
@@ -556,7 +555,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpVectorTimesMatrix(
uint32_t float_add_id = message_.fresh_ids(fresh_id_index++);
float_add_ids.push_back(float_add_id);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpFAdd,
+ ir_context, SpvOpFAdd,
ir_context->get_type_mgr()->GetId(vector_component_type), float_add_id,
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {float_multiplication_ids[0]}},
@@ -565,7 +564,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpVectorTimesMatrix(
float_add_id = message_.fresh_ids(fresh_id_index++);
float_add_ids.push_back(float_add_id);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpFAdd,
+ ir_context, SpvOpFAdd,
ir_context->get_type_mgr()->GetId(vector_component_type),
float_add_id,
opt::Instruction::OperandList(
@@ -578,7 +577,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpVectorTimesMatrix(
// The OpVectorTimesMatrix instruction is changed to an OpCompositeConstruct
// instruction.
- linear_algebra_instruction->SetOpcode(spv::Op::OpCompositeConstruct);
+ linear_algebra_instruction->SetOpcode(SpvOpCompositeConstruct);
linear_algebra_instruction->SetInOperand(0, {result_component_ids[0]});
linear_algebra_instruction->SetInOperand(1, {result_component_ids[1]});
for (uint32_t i = 2; i < result_component_ids.size(); i++) {
@@ -612,7 +611,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpMatrixTimesVector(
for (uint32_t i = 0; i < matrix_column_count; i++) {
matrix_column_ids[i] = message_.fresh_ids(fresh_id_index++);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeExtract,
+ ir_context, SpvOpCompositeExtract,
ir_context->get_type_mgr()->GetId(matrix_column_type),
matrix_column_ids[i],
opt::Instruction::OperandList(
@@ -633,7 +632,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpMatrixTimesVector(
for (uint32_t i = 0; i < matrix_column_count; i++) {
vector_component_ids[i] = message_.fresh_ids(fresh_id_index++);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeExtract,
+ ir_context, SpvOpCompositeExtract,
ir_context->get_type_mgr()->GetId(vector_component_type),
vector_component_ids[i],
opt::Instruction::OperandList(
@@ -648,7 +647,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpMatrixTimesVector(
// Extracts column component.
uint32_t column_extract_id = message_.fresh_ids(fresh_id_index++);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeExtract,
+ ir_context, SpvOpCompositeExtract,
ir_context->get_type_mgr()->GetId(vector_component_type),
column_extract_id,
opt::Instruction::OperandList(
@@ -658,7 +657,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpMatrixTimesVector(
// Multiplies corresponding vector and column components.
float_multiplication_ids[j] = message_.fresh_ids(fresh_id_index++);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpFMul,
+ ir_context, SpvOpFMul,
ir_context->get_type_mgr()->GetId(vector_component_type),
float_multiplication_ids[j],
opt::Instruction::OperandList(
@@ -671,7 +670,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpMatrixTimesVector(
uint32_t float_add_id = message_.fresh_ids(fresh_id_index++);
float_add_ids.push_back(float_add_id);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpFAdd,
+ ir_context, SpvOpFAdd,
ir_context->get_type_mgr()->GetId(vector_component_type), float_add_id,
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {float_multiplication_ids[0]}},
@@ -680,7 +679,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpMatrixTimesVector(
float_add_id = message_.fresh_ids(fresh_id_index++);
float_add_ids.push_back(float_add_id);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpFAdd,
+ ir_context, SpvOpFAdd,
ir_context->get_type_mgr()->GetId(vector_component_type),
float_add_id,
opt::Instruction::OperandList(
@@ -693,7 +692,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpMatrixTimesVector(
// The OpMatrixTimesVector instruction is changed to an OpCompositeConstruct
// instruction.
- linear_algebra_instruction->SetOpcode(spv::Op::OpCompositeConstruct);
+ linear_algebra_instruction->SetOpcode(SpvOpCompositeConstruct);
linear_algebra_instruction->SetInOperand(0, {result_component_ids[0]});
linear_algebra_instruction->SetInOperand(1, {result_component_ids[1]});
for (uint32_t i = 2; i < result_component_ids.size(); i++) {
@@ -744,7 +743,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpMatrixTimesMatrix(
// Extracts matrix 2 column.
uint32_t matrix_2_column_id = message_.fresh_ids(fresh_id_index++);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeExtract,
+ ir_context, SpvOpCompositeExtract,
ir_context->get_type_mgr()->GetId(matrix_2_column_type),
matrix_2_column_id,
opt::Instruction::OperandList(
@@ -758,7 +757,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpMatrixTimesMatrix(
// Extracts matrix 1 column.
uint32_t matrix_1_column_id = message_.fresh_ids(fresh_id_index++);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeExtract,
+ ir_context, SpvOpCompositeExtract,
ir_context->get_type_mgr()->GetId(matrix_1_column_type),
matrix_1_column_id,
opt::Instruction::OperandList(
@@ -769,7 +768,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpMatrixTimesMatrix(
uint32_t matrix_1_column_component_id =
message_.fresh_ids(fresh_id_index++);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeExtract,
+ ir_context, SpvOpCompositeExtract,
ir_context->get_type_mgr()->GetId(matrix_1_column_component_type),
matrix_1_column_component_id,
opt::Instruction::OperandList(
@@ -780,7 +779,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpMatrixTimesMatrix(
uint32_t matrix_2_column_component_id =
message_.fresh_ids(fresh_id_index++);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeExtract,
+ ir_context, SpvOpCompositeExtract,
ir_context->get_type_mgr()->GetId(matrix_1_column_component_type),
matrix_2_column_component_id,
opt::Instruction::OperandList(
@@ -790,7 +789,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpMatrixTimesMatrix(
// Multiplies corresponding matrix 1 and matrix 2 column components.
float_multiplication_ids[k] = message_.fresh_ids(fresh_id_index++);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpFMul,
+ ir_context, SpvOpFMul,
ir_context->get_type_mgr()->GetId(matrix_1_column_component_type),
float_multiplication_ids[k],
opt::Instruction::OperandList(
@@ -803,7 +802,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpMatrixTimesMatrix(
uint32_t float_add_id = message_.fresh_ids(fresh_id_index++);
float_add_ids.push_back(float_add_id);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpFAdd,
+ ir_context, SpvOpFAdd,
ir_context->get_type_mgr()->GetId(matrix_1_column_component_type),
float_add_id,
opt::Instruction::OperandList(
@@ -813,7 +812,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpMatrixTimesMatrix(
float_add_id = message_.fresh_ids(fresh_id_index++);
float_add_ids.push_back(float_add_id);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpFAdd,
+ ir_context, SpvOpFAdd,
ir_context->get_type_mgr()->GetId(matrix_1_column_component_type),
float_add_id,
opt::Instruction::OperandList(
@@ -831,14 +830,14 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpMatrixTimesMatrix(
}
result_column_ids[i] = message_.fresh_ids(fresh_id_index++);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeConstruct,
+ ir_context, SpvOpCompositeConstruct,
ir_context->get_type_mgr()->GetId(matrix_1_column_type),
result_column_ids[i], opt::Instruction::OperandList(in_operands)));
}
// The OpMatrixTimesMatrix instruction is changed to an OpCompositeConstruct
// instruction.
- linear_algebra_instruction->SetOpcode(spv::Op::OpCompositeConstruct);
+ linear_algebra_instruction->SetOpcode(SpvOpCompositeConstruct);
linear_algebra_instruction->SetInOperand(0, {result_column_ids[0]});
linear_algebra_instruction->SetInOperand(1, {result_column_ids[1]});
for (uint32_t i = 2; i < result_column_ids.size(); i++) {
@@ -881,7 +880,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpOuterProduct(
// Extracts |vector_2| component.
uint32_t vector_2_component_id = message_.fresh_ids(fresh_id_index++);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeExtract,
+ ir_context, SpvOpCompositeExtract,
ir_context->get_type_mgr()->GetId(vector_1_component_type),
vector_2_component_id,
opt::Instruction::OperandList(
@@ -893,7 +892,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpOuterProduct(
// Extracts |vector_1| component.
uint32_t vector_1_component_id = message_.fresh_ids(fresh_id_index++);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeExtract,
+ ir_context, SpvOpCompositeExtract,
ir_context->get_type_mgr()->GetId(vector_1_component_type),
vector_1_component_id,
opt::Instruction::OperandList(
@@ -903,7 +902,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpOuterProduct(
// Multiplies |vector_1| and |vector_2| components.
column_component_ids[j] = message_.fresh_ids(fresh_id_index++);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpFMul,
+ ir_context, SpvOpFMul,
ir_context->get_type_mgr()->GetId(vector_1_component_type),
column_component_ids[j],
opt::Instruction::OperandList(
@@ -918,13 +917,13 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpOuterProduct(
}
result_column_ids[i] = message_.fresh_ids(fresh_id_index++);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeConstruct,
- vector_1_instruction->type_id(), result_column_ids[i], in_operands));
+ ir_context, SpvOpCompositeConstruct, vector_1_instruction->type_id(),
+ result_column_ids[i], in_operands));
}
// The OpOuterProduct instruction is changed to an OpCompositeConstruct
// instruction.
- linear_algebra_instruction->SetOpcode(spv::Op::OpCompositeConstruct);
+ linear_algebra_instruction->SetOpcode(SpvOpCompositeConstruct);
linear_algebra_instruction->SetInOperand(0, {result_column_ids[0]});
linear_algebra_instruction->SetInOperand(1, {result_column_ids[1]});
for (uint32_t i = 2; i < result_column_ids.size(); i++) {
@@ -957,7 +956,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpDot(
uint32_t vector_1_extract_id = message_.fresh_ids(fresh_id_index++);
fuzzerutil::UpdateModuleIdBound(ir_context, vector_1_extract_id);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeExtract,
+ ir_context, SpvOpCompositeExtract,
linear_algebra_instruction->type_id(), vector_1_extract_id,
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {vector_1->result_id()}},
@@ -967,7 +966,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpDot(
uint32_t vector_2_extract_id = message_.fresh_ids(fresh_id_index++);
fuzzerutil::UpdateModuleIdBound(ir_context, vector_2_extract_id);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeExtract,
+ ir_context, SpvOpCompositeExtract,
linear_algebra_instruction->type_id(), vector_2_extract_id,
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {vector_2->result_id()}},
@@ -977,7 +976,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpDot(
float_multiplication_ids[i] = message_.fresh_ids(fresh_id_index++);
fuzzerutil::UpdateModuleIdBound(ir_context, float_multiplication_ids[i]);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpFMul, linear_algebra_instruction->type_id(),
+ ir_context, SpvOpFMul, linear_algebra_instruction->type_id(),
float_multiplication_ids[i],
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {vector_1_extract_id}},
@@ -987,7 +986,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpDot(
// If the vector has 2 components, then there will be 2 float multiplication
// instructions.
if (vectors_component_count == 2) {
- linear_algebra_instruction->SetOpcode(spv::Op::OpFAdd);
+ linear_algebra_instruction->SetOpcode(SpvOpFAdd);
linear_algebra_instruction->SetInOperand(0, {float_multiplication_ids[0]});
linear_algebra_instruction->SetInOperand(1, {float_multiplication_ids[1]});
} else {
@@ -998,7 +997,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpDot(
float_add_ids.push_back(float_add_id);
fuzzerutil::UpdateModuleIdBound(ir_context, float_add_id);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpFAdd, linear_algebra_instruction->type_id(),
+ ir_context, SpvOpFAdd, linear_algebra_instruction->type_id(),
float_add_id,
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {float_multiplication_ids[0]}},
@@ -1011,7 +1010,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpDot(
fuzzerutil::UpdateModuleIdBound(ir_context, float_add_id);
float_add_ids.push_back(float_add_id);
linear_algebra_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpFAdd, linear_algebra_instruction->type_id(),
+ ir_context, SpvOpFAdd, linear_algebra_instruction->type_id(),
float_add_id,
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {float_multiplication_ids[i]}},
@@ -1020,7 +1019,7 @@ void TransformationReplaceLinearAlgebraInstruction::ReplaceOpDot(
// The last OpFAdd instruction is got by changing some of the OpDot
// instruction attributes.
- linear_algebra_instruction->SetOpcode(spv::Op::OpFAdd);
+ linear_algebra_instruction->SetOpcode(SpvOpFAdd);
linear_algebra_instruction->SetInOperand(
0, {float_multiplication_ids[float_multiplication_ids.size() - 1]});
linear_algebra_instruction->SetInOperand(
diff --git a/source/fuzz/transformation_replace_load_store_with_copy_memory.cpp b/source/fuzz/transformation_replace_load_store_with_copy_memory.cpp
index 36610f2f..e75337f6 100644
--- a/source/fuzz/transformation_replace_load_store_with_copy_memory.cpp
+++ b/source/fuzz/transformation_replace_load_store_with_copy_memory.cpp
@@ -48,14 +48,14 @@ bool TransformationReplaceLoadStoreWithCopyMemory::IsApplicable(
// The OpLoad instruction must be defined.
auto load_instruction =
FindInstruction(message_.load_instruction_descriptor(), ir_context);
- if (!load_instruction || load_instruction->opcode() != spv::Op::OpLoad) {
+ if (!load_instruction || load_instruction->opcode() != SpvOpLoad) {
return false;
}
// The OpStore instruction must be defined.
auto store_instruction =
FindInstruction(message_.store_instruction_descriptor(), ir_context);
- if (!store_instruction || store_instruction->opcode() != spv::Op::OpStore) {
+ if (!store_instruction || store_instruction->opcode() != SpvOpStore) {
return false;
}
@@ -69,7 +69,7 @@ bool TransformationReplaceLoadStoreWithCopyMemory::IsApplicable(
// Get storage class of the variable pointed by the source operand in OpLoad.
opt::Instruction* source_id = ir_context->get_def_use_mgr()->GetDef(
load_instruction->GetSingleWordOperand(2));
- spv::StorageClass storage_class = fuzzerutil::GetStorageClassFromPointerType(
+ SpvStorageClass storage_class = fuzzerutil::GetStorageClassFromPointerType(
ir_context, source_id->type_id());
// Iterate over all instructions between |load_instruction| and
@@ -99,11 +99,11 @@ void TransformationReplaceLoadStoreWithCopyMemory::Apply(
// OpLoad and OpStore instructions must be defined.
auto load_instruction =
FindInstruction(message_.load_instruction_descriptor(), ir_context);
- assert(load_instruction && load_instruction->opcode() == spv::Op::OpLoad &&
+ assert(load_instruction && load_instruction->opcode() == SpvOpLoad &&
"The required OpLoad instruction must be defined.");
auto store_instruction =
FindInstruction(message_.store_instruction_descriptor(), ir_context);
- assert(store_instruction && store_instruction->opcode() == spv::Op::OpStore &&
+ assert(store_instruction && store_instruction->opcode() == SpvOpStore &&
"The required OpStore instruction must be defined.");
// Intermediate values of the OpLoad and the OpStore must match.
@@ -121,7 +121,7 @@ void TransformationReplaceLoadStoreWithCopyMemory::Apply(
// Insert the OpCopyMemory instruction before the OpStore instruction.
store_instruction->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCopyMemory, 0, 0,
+ ir_context, SpvOpCopyMemory, 0, 0,
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {target_variable_id}},
{SPV_OPERAND_TYPE_ID, {source_variable_id}}})));
@@ -133,14 +133,14 @@ void TransformationReplaceLoadStoreWithCopyMemory::Apply(
}
bool TransformationReplaceLoadStoreWithCopyMemory::IsMemoryWritingOpCode(
- spv::Op op_code) {
+ SpvOp op_code) {
if (spvOpcodeIsAtomicOp(op_code)) {
- return op_code != spv::Op::OpAtomicLoad;
+ return op_code != SpvOpAtomicLoad;
}
switch (op_code) {
- case spv::Op::OpStore:
- case spv::Op::OpCopyMemory:
- case spv::Op::OpCopyMemorySized:
+ case SpvOpStore:
+ case SpvOpCopyMemory:
+ case SpvOpCopyMemorySized:
return true;
default:
return false;
@@ -148,10 +148,10 @@ bool TransformationReplaceLoadStoreWithCopyMemory::IsMemoryWritingOpCode(
}
bool TransformationReplaceLoadStoreWithCopyMemory::IsMemoryBarrierOpCode(
- spv::Op op_code) {
+ SpvOp op_code) {
switch (op_code) {
- case spv::Op::OpMemoryBarrier:
- case spv::Op::OpMemoryNamedBarrier:
+ case SpvOpMemoryBarrier:
+ case SpvOpMemoryNamedBarrier:
return true;
default:
return false;
@@ -159,13 +159,13 @@ bool TransformationReplaceLoadStoreWithCopyMemory::IsMemoryBarrierOpCode(
}
bool TransformationReplaceLoadStoreWithCopyMemory::
- IsStorageClassSafeAcrossMemoryBarriers(spv::StorageClass storage_class) {
+ IsStorageClassSafeAcrossMemoryBarriers(SpvStorageClass storage_class) {
switch (storage_class) {
- case spv::StorageClass::UniformConstant:
- case spv::StorageClass::Input:
- case spv::StorageClass::Uniform:
- case spv::StorageClass::Private:
- case spv::StorageClass::Function:
+ case SpvStorageClassUniformConstant:
+ case SpvStorageClassInput:
+ case SpvStorageClassUniform:
+ case SpvStorageClassPrivate:
+ case SpvStorageClassFunction:
return true;
default:
return false;
diff --git a/source/fuzz/transformation_replace_load_store_with_copy_memory.h b/source/fuzz/transformation_replace_load_store_with_copy_memory.h
index 43c754e6..bb4d27ef 100644
--- a/source/fuzz/transformation_replace_load_store_with_copy_memory.h
+++ b/source/fuzz/transformation_replace_load_store_with_copy_memory.h
@@ -52,17 +52,17 @@ class TransformationReplaceLoadStoreWithCopyMemory : public Transformation {
// Checks if the instruction that has an |op_code| might write to
// the source operand of the OpLoad instruction.
- static bool IsMemoryWritingOpCode(spv::Op op_code);
+ static bool IsMemoryWritingOpCode(SpvOp op_code);
// Checks if the instruction that has an |op_code| is a memory barrier that
// could interfere with the source operand of the OpLoad instruction
- static bool IsMemoryBarrierOpCode(spv::Op op_code);
+ static bool IsMemoryBarrierOpCode(SpvOp op_code);
// Checks if the |storage_class| of the source operand of the OpLoad
// instruction implies that this variable cannot change (due to other threads)
// across memory barriers.
static bool IsStorageClassSafeAcrossMemoryBarriers(
- spv::StorageClass storage_class);
+ SpvStorageClass storage_class);
std::unordered_set<uint32_t> GetFreshIds() const override;
diff --git a/source/fuzz/transformation_replace_opphi_id_from_dead_predecessor.cpp b/source/fuzz/transformation_replace_opphi_id_from_dead_predecessor.cpp
index eeda68df..84ca1aba 100644
--- a/source/fuzz/transformation_replace_opphi_id_from_dead_predecessor.cpp
+++ b/source/fuzz/transformation_replace_opphi_id_from_dead_predecessor.cpp
@@ -38,7 +38,7 @@ bool TransformationReplaceOpPhiIdFromDeadPredecessor::IsApplicable(
const TransformationContext& transformation_context) const {
// |opphi_id| must be the id of an OpPhi instruction.
auto opphi_def = ir_context->get_def_use_mgr()->GetDef(message_.opphi_id());
- if (!opphi_def || opphi_def->opcode() != spv::Op::OpPhi) {
+ if (!opphi_def || opphi_def->opcode() != SpvOpPhi) {
return false;
}
diff --git a/source/fuzz/transformation_replace_opselect_with_conditional_branch.cpp b/source/fuzz/transformation_replace_opselect_with_conditional_branch.cpp
index b2010a94..c0e6e449 100644
--- a/source/fuzz/transformation_replace_opselect_with_conditional_branch.cpp
+++ b/source/fuzz/transformation_replace_opselect_with_conditional_branch.cpp
@@ -50,7 +50,7 @@ bool TransformationReplaceOpSelectWithConditionalBranch::IsApplicable(
ir_context->get_def_use_mgr()->GetDef(message_.select_id());
// The instruction must exist and it must be an OpSelect instruction.
- if (!instruction || instruction->opcode() != spv::Op::OpSelect) {
+ if (!instruction || instruction->opcode() != SpvOpSelect) {
return false;
}
@@ -90,7 +90,7 @@ bool TransformationReplaceOpSelectWithConditionalBranch::IsApplicable(
// The predecessor must not be the header of a construct and it must end with
// OpBranch.
if (predecessor->GetMergeInst() != nullptr ||
- predecessor->terminator()->opcode() != spv::Op::OpBranch) {
+ predecessor->terminator()->opcode() != SpvOpBranch) {
return false;
}
@@ -115,14 +115,13 @@ void TransformationReplaceOpSelectWithConditionalBranch::Apply(
fuzzerutil::UpdateModuleIdBound(ir_context, id);
// Create the new block.
- auto new_block = MakeUnique<opt::BasicBlock>(
- MakeUnique<opt::Instruction>(ir_context, spv::Op::OpLabel, 0, id,
- opt::Instruction::OperandList{}));
+ auto new_block = MakeUnique<opt::BasicBlock>(MakeUnique<opt::Instruction>(
+ ir_context, SpvOpLabel, 0, id, opt::Instruction::OperandList{}));
// Add an unconditional branch from the new block to the instruction
// block.
new_block->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpBranch, 0, 0,
+ ir_context, SpvOpBranch, 0, 0,
opt::Instruction::OperandList{{SPV_OPERAND_TYPE_ID, {block->id()}}}));
// Insert the new block right after the predecessor of the instruction
@@ -137,11 +136,10 @@ void TransformationReplaceOpSelectWithConditionalBranch::Apply(
// Add an OpSelectionMerge instruction to the predecessor block, where the
// merge block is the instruction block.
predecessor->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpSelectionMerge, 0, 0,
- opt::Instruction::OperandList{
- {SPV_OPERAND_TYPE_ID, {block->id()}},
- {SPV_OPERAND_TYPE_SELECTION_CONTROL,
- {uint32_t(spv::SelectionControlMask::MaskNone)}}}));
+ ir_context, SpvOpSelectionMerge, 0, 0,
+ opt::Instruction::OperandList{{SPV_OPERAND_TYPE_ID, {block->id()}},
+ {SPV_OPERAND_TYPE_SELECTION_CONTROL,
+ {SpvSelectionControlMaskNone}}}));
// |if_block| will be the true block, if it has been created, the instruction
// block otherwise.
@@ -160,7 +158,7 @@ void TransformationReplaceOpSelectWithConditionalBranch::Apply(
// Add a conditional branching instruction to the predecessor, branching to
// |if_block| if the condition is true and to |if_false| otherwise.
predecessor->AddInstruction(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpBranchConditional, 0, 0,
+ ir_context, SpvOpBranchConditional, 0, 0,
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_ID, {instruction->GetSingleWordInOperand(0)}},
{SPV_OPERAND_TYPE_ID, {if_block}},
@@ -179,7 +177,7 @@ void TransformationReplaceOpSelectWithConditionalBranch::Apply(
// Replace the OpSelect instruction in the merge block with an OpPhi.
// This: OpSelect %type %cond %if %else
// will become: OpPhi %type %if %if_pred %else %else_pred
- instruction->SetOpcode(spv::Op::OpPhi);
+ instruction->SetOpcode(SpvOpPhi);
std::vector<opt::Operand> operands;
operands.emplace_back(instruction->GetInOperand(1));
diff --git a/source/fuzz/transformation_replace_parameter_with_global.cpp b/source/fuzz/transformation_replace_parameter_with_global.cpp
index e80dfe90..caf67168 100644
--- a/source/fuzz/transformation_replace_parameter_with_global.cpp
+++ b/source/fuzz/transformation_replace_parameter_with_global.cpp
@@ -41,7 +41,7 @@ bool TransformationReplaceParameterWithGlobal::IsApplicable(
// Check that |parameter_id| is valid.
const auto* param_inst =
ir_context->get_def_use_mgr()->GetDef(message_.parameter_id());
- if (!param_inst || param_inst->opcode() != spv::Op::OpFunctionParameter) {
+ if (!param_inst || param_inst->opcode() != SpvOpFunctionParameter) {
return false;
}
@@ -69,7 +69,7 @@ bool TransformationReplaceParameterWithGlobal::IsApplicable(
// Check that pointer type for the global variable exists in the module.
if (!fuzzerutil::MaybeGetPointerType(ir_context, param_inst->type_id(),
- spv::StorageClass::Private)) {
+ SpvStorageClassPrivate)) {
return false;
}
@@ -91,8 +91,8 @@ void TransformationReplaceParameterWithGlobal::Apply(
fuzzerutil::AddGlobalVariable(
ir_context, message_.global_variable_fresh_id(),
fuzzerutil::MaybeGetPointerType(ir_context, param_inst->type_id(),
- spv::StorageClass::Private),
- spv::StorageClass::Private,
+ SpvStorageClassPrivate),
+ SpvStorageClassPrivate,
fuzzerutil::MaybeGetZeroConstant(ir_context, *transformation_context,
param_inst->type_id(), false));
@@ -103,17 +103,16 @@ void TransformationReplaceParameterWithGlobal::Apply(
// Insert an OpLoad instruction right after OpVariable instructions.
auto it = function->begin()->begin();
while (it != function->begin()->end() &&
- !fuzzerutil::CanInsertOpcodeBeforeInstruction(spv::Op::OpLoad, it)) {
+ !fuzzerutil::CanInsertOpcodeBeforeInstruction(SpvOpLoad, it)) {
++it;
}
- assert(fuzzerutil::CanInsertOpcodeBeforeInstruction(spv::Op::OpLoad, it) &&
+ assert(fuzzerutil::CanInsertOpcodeBeforeInstruction(SpvOpLoad, it) &&
"Can't insert OpLoad or OpCopyMemory into the first basic block of "
"the function");
it.InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpLoad, param_inst->type_id(),
- param_inst->result_id(),
+ ir_context, SpvOpLoad, param_inst->type_id(), param_inst->result_id(),
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_ID, {message_.global_variable_fresh_id()}}}));
@@ -133,14 +132,13 @@ void TransformationReplaceParameterWithGlobal::Apply(
// Update all relevant OpFunctionCall instructions.
for (auto* inst : fuzzerutil::GetCallers(ir_context, function->result_id())) {
- assert(
- fuzzerutil::CanInsertOpcodeBeforeInstruction(spv::Op::OpStore, inst) &&
- "Can't insert OpStore right before the function call");
+ assert(fuzzerutil::CanInsertOpcodeBeforeInstruction(SpvOpStore, inst) &&
+ "Can't insert OpStore right before the function call");
// Insert an OpStore before the OpFunctionCall. +1 since the first
// operand of OpFunctionCall is an id of the function.
inst->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpStore, 0, 0,
+ ir_context, SpvOpStore, 0, 0,
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_ID, {message_.global_variable_fresh_id()}},
{SPV_OPERAND_TYPE_ID,
diff --git a/source/fuzz/transformation_replace_params_with_struct.cpp b/source/fuzz/transformation_replace_params_with_struct.cpp
index c8af14ae..13eeccb4 100644
--- a/source/fuzz/transformation_replace_params_with_struct.cpp
+++ b/source/fuzz/transformation_replace_params_with_struct.cpp
@@ -142,7 +142,7 @@ void TransformationReplaceParamsWithStruct::Apply(
// Add new parameter to the function.
function->AddParameter(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpFunctionParameter, struct_type_id,
+ ir_context, SpvOpFunctionParameter, struct_type_id,
message_.fresh_parameter_id(), opt::Instruction::OperandList()));
fuzzerutil::UpdateModuleIdBound(ir_context, message_.fresh_parameter_id());
@@ -182,8 +182,8 @@ void TransformationReplaceParamsWithStruct::Apply(
auto fresh_composite_id =
caller_id_to_fresh_composite_id.at(inst->result_id());
inst->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeConstruct, struct_type_id,
- fresh_composite_id, std::move(composite_components)));
+ ir_context, SpvOpCompositeConstruct, struct_type_id, fresh_composite_id,
+ std::move(composite_components)));
// Add a new operand to the OpFunctionCall instruction.
inst->AddOperand({SPV_OPERAND_TYPE_ID, {fresh_composite_id}});
@@ -200,19 +200,19 @@ void TransformationReplaceParamsWithStruct::Apply(
// Skip all OpVariable instructions.
auto iter = function->begin()->begin();
while (iter != function->begin()->end() &&
- !fuzzerutil::CanInsertOpcodeBeforeInstruction(
- spv::Op::OpCompositeExtract, iter)) {
+ !fuzzerutil::CanInsertOpcodeBeforeInstruction(SpvOpCompositeExtract,
+ iter)) {
++iter;
}
- assert(fuzzerutil::CanInsertOpcodeBeforeInstruction(
- spv::Op::OpCompositeExtract, iter) &&
+ assert(fuzzerutil::CanInsertOpcodeBeforeInstruction(SpvOpCompositeExtract,
+ iter) &&
"Can't extract parameter's value from the structure");
// Insert OpCompositeExtract instructions to unpack parameters' values from
// the struct type.
iter.InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpCompositeExtract, param_inst->type_id(),
+ ir_context, SpvOpCompositeExtract, param_inst->type_id(),
param_inst->result_id(),
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_ID, {message_.fresh_parameter_id()}},
diff --git a/source/fuzz/transformation_set_function_control.cpp b/source/fuzz/transformation_set_function_control.cpp
index ef481719..02a8c9fe 100644
--- a/source/fuzz/transformation_set_function_control.cpp
+++ b/source/fuzz/transformation_set_function_control.cpp
@@ -40,9 +40,9 @@ bool TransformationSetFunctionControl::IsApplicable(
// Check (via an assertion) that function control mask doesn't have any bad
// bits set.
- uint32_t acceptable_function_control_bits = uint32_t(
- spv::FunctionControlMask::Inline | spv::FunctionControlMask::DontInline |
- spv::FunctionControlMask::Pure | spv::FunctionControlMask::Const);
+ uint32_t acceptable_function_control_bits =
+ SpvFunctionControlInlineMask | SpvFunctionControlDontInlineMask |
+ SpvFunctionControlPureMask | SpvFunctionControlConstMask;
// The following is to keep release-mode compilers happy as this variable is
// only used in an assertion.
(void)(acceptable_function_control_bits);
@@ -51,19 +51,17 @@ bool TransformationSetFunctionControl::IsApplicable(
// Check (via an assertion) that function control mask does not have both
// Inline and DontInline bits set.
- assert(!((message_.function_control() &
- (uint32_t)spv::FunctionControlMask::Inline) &&
- (message_.function_control() &
- (uint32_t)spv::FunctionControlMask::DontInline)) &&
+ assert(!((message_.function_control() & SpvFunctionControlInlineMask) &&
+ (message_.function_control() & SpvFunctionControlDontInlineMask)) &&
"It is not OK to set both the 'Inline' and 'DontInline' bits of a "
"function control mask");
// Check that Const and Pure are only present if they were present on the
// original function
for (auto mask_bit :
- {spv::FunctionControlMask::Pure, spv::FunctionControlMask::Const}) {
- if ((message_.function_control() & uint32_t(mask_bit)) &&
- !(existing_function_control_mask & uint32_t(mask_bit))) {
+ {SpvFunctionControlPureMask, SpvFunctionControlConstMask}) {
+ if ((message_.function_control() & mask_bit) &&
+ !(existing_function_control_mask & mask_bit)) {
return false;
}
}
diff --git a/source/fuzz/transformation_set_loop_control.cpp b/source/fuzz/transformation_set_loop_control.cpp
index dc9ee7cf..14499606 100644
--- a/source/fuzz/transformation_set_loop_control.cpp
+++ b/source/fuzz/transformation_set_loop_control.cpp
@@ -38,20 +38,18 @@ bool TransformationSetLoopControl::IsApplicable(
return false;
}
auto merge_inst = block->GetMergeInst();
- if (!merge_inst || merge_inst->opcode() != spv::Op::OpLoopMerge) {
+ if (!merge_inst || merge_inst->opcode() != SpvOpLoopMerge) {
return false;
}
// We assert that the transformation does not try to set any meaningless bits
// of the loop control mask.
- uint32_t all_loop_control_mask_bits_set = uint32_t(
- spv::LoopControlMask::Unroll | spv::LoopControlMask::DontUnroll |
- spv::LoopControlMask::DependencyInfinite |
- spv::LoopControlMask::DependencyLength |
- spv::LoopControlMask::MinIterations |
- spv::LoopControlMask::MaxIterations |
- spv::LoopControlMask::IterationMultiple |
- spv::LoopControlMask::PeelCount | spv::LoopControlMask::PartialCount);
+ uint32_t all_loop_control_mask_bits_set =
+ SpvLoopControlUnrollMask | SpvLoopControlDontUnrollMask |
+ SpvLoopControlDependencyInfiniteMask |
+ SpvLoopControlDependencyLengthMask | SpvLoopControlMinIterationsMask |
+ SpvLoopControlMaxIterationsMask | SpvLoopControlIterationMultipleMask |
+ SpvLoopControlPeelCountMask | SpvLoopControlPartialCountMask;
// The variable is only used in an assertion; the following keeps release-mode
// compilers happy.
@@ -67,11 +65,10 @@ bool TransformationSetLoopControl::IsApplicable(
// Check that there is no attempt to set one of the loop controls that
// requires guarantees to hold.
- for (spv::LoopControlMask mask : {spv::LoopControlMask::DependencyInfinite,
- spv::LoopControlMask::DependencyLength,
- spv::LoopControlMask::MinIterations,
- spv::LoopControlMask::MaxIterations,
- spv::LoopControlMask::IterationMultiple}) {
+ for (SpvLoopControlMask mask :
+ {SpvLoopControlDependencyInfiniteMask,
+ SpvLoopControlDependencyLengthMask, SpvLoopControlMinIterationsMask,
+ SpvLoopControlMaxIterationsMask, SpvLoopControlIterationMultipleMask}) {
// We have a problem if this loop control bit was not set in the original
// loop control mask but is set by the transformation.
if (LoopControlBitIsAddedByTransformation(mask,
@@ -81,36 +78,33 @@ bool TransformationSetLoopControl::IsApplicable(
}
// Check that PeelCount and PartialCount are supported if used.
- if ((message_.loop_control() & uint32_t(spv::LoopControlMask::PeelCount)) &&
+ if ((message_.loop_control() & SpvLoopControlPeelCountMask) &&
!PeelCountIsSupported(ir_context)) {
return false;
}
- if ((message_.loop_control() &
- uint32_t(spv::LoopControlMask::PartialCount)) &&
+ if ((message_.loop_control() & SpvLoopControlPartialCountMask) &&
!PartialCountIsSupported(ir_context)) {
return false;
}
if (message_.peel_count() > 0 &&
- !(message_.loop_control() & uint32_t(spv::LoopControlMask::PeelCount))) {
+ !(message_.loop_control() & SpvLoopControlPeelCountMask)) {
// Peel count provided, but peel count mask bit not set.
return false;
}
if (message_.partial_count() > 0 &&
- !(message_.loop_control() &
- uint32_t(spv::LoopControlMask::PartialCount))) {
+ !(message_.loop_control() & SpvLoopControlPartialCountMask)) {
// Partial count provided, but partial count mask bit not set.
return false;
}
// We must not set both 'don't unroll' and one of 'peel count' or 'partial
// count'.
- return !(
- (message_.loop_control() & uint32_t(spv::LoopControlMask::DontUnroll)) &&
- (message_.loop_control() & uint32_t(spv::LoopControlMask::PeelCount |
- spv::LoopControlMask::PartialCount)));
+ return !((message_.loop_control() & SpvLoopControlDontUnrollMask) &&
+ (message_.loop_control() &
+ (SpvLoopControlPeelCountMask | SpvLoopControlPartialCountMask)));
}
void TransformationSetLoopControl::Apply(
@@ -139,14 +133,13 @@ void TransformationSetLoopControl::Apply(
uint32_t literal_index = 0; // Indexes into the literals from the original
// instruction.
- for (spv::LoopControlMask mask : {spv::LoopControlMask::DependencyLength,
- spv::LoopControlMask::MinIterations,
- spv::LoopControlMask::MaxIterations,
- spv::LoopControlMask::IterationMultiple}) {
+ for (SpvLoopControlMask mask :
+ {SpvLoopControlDependencyLengthMask, SpvLoopControlMinIterationsMask,
+ SpvLoopControlMaxIterationsMask, SpvLoopControlIterationMultipleMask}) {
// Check whether the bit was set in the original loop control mask.
- if (existing_loop_control_mask & uint32_t(mask)) {
+ if (existing_loop_control_mask & mask) {
// Check whether the bit is set in the new loop control mask.
- if (message_.loop_control() & uint32_t(mask)) {
+ if (message_.loop_control() & mask) {
// Add the associated literal to our sequence of replacement operands.
new_operands.push_back(
{SPV_OPERAND_TYPE_LITERAL_INTEGER,
@@ -161,13 +154,13 @@ void TransformationSetLoopControl::Apply(
// If PeelCount is set in the new mask, |message_.peel_count| provides the
// associated peel count.
- if (message_.loop_control() & uint32_t(spv::LoopControlMask::PeelCount)) {
+ if (message_.loop_control() & SpvLoopControlPeelCountMask) {
new_operands.push_back(
{SPV_OPERAND_TYPE_LITERAL_INTEGER, {message_.peel_count()}});
}
// Similar, but for PartialCount.
- if (message_.loop_control() & uint32_t(spv::LoopControlMask::PartialCount)) {
+ if (message_.loop_control() & SpvLoopControlPartialCountMask) {
new_operands.push_back(
{SPV_OPERAND_TYPE_LITERAL_INTEGER, {message_.partial_count()}});
}
@@ -184,11 +177,10 @@ protobufs::Transformation TransformationSetLoopControl::ToMessage() const {
}
bool TransformationSetLoopControl::LoopControlBitIsAddedByTransformation(
- spv::LoopControlMask loop_control_single_bit_mask,
+ SpvLoopControlMask loop_control_single_bit_mask,
uint32_t existing_loop_control_mask) const {
- return !(uint32_t(loop_control_single_bit_mask) &
- existing_loop_control_mask) &&
- (uint32_t(loop_control_single_bit_mask) & message_.loop_control());
+ return !(loop_control_single_bit_mask & existing_loop_control_mask) &&
+ (loop_control_single_bit_mask & message_.loop_control());
}
bool TransformationSetLoopControl::PartialCountIsSupported(
diff --git a/source/fuzz/transformation_set_loop_control.h b/source/fuzz/transformation_set_loop_control.h
index d57447be..bc17c8a4 100644
--- a/source/fuzz/transformation_set_loop_control.h
+++ b/source/fuzz/transformation_set_loop_control.h
@@ -71,7 +71,7 @@ class TransformationSetLoopControl : public Transformation {
// Returns true if and only if |loop_single_bit_mask| is *not* set in
// |existing_loop_control| but *is* set in |message_.loop_control|.
bool LoopControlBitIsAddedByTransformation(
- spv::LoopControlMask loop_control_single_bit_mask,
+ SpvLoopControlMask loop_control_single_bit_mask,
uint32_t existing_loop_control_mask) const;
protobufs::TransformationSetLoopControl message_;
diff --git a/source/fuzz/transformation_set_memory_operands_mask.cpp b/source/fuzz/transformation_set_memory_operands_mask.cpp
index 16d591a6..5a986ad2 100644
--- a/source/fuzz/transformation_set_memory_operands_mask.cpp
+++ b/source/fuzz/transformation_set_memory_operands_mask.cpp
@@ -48,13 +48,10 @@ bool TransformationSetMemoryOperandsMask::IsApplicable(
// which they were applied during fuzzing, hence why these are assertions
// rather than applicability checks.
assert(message_.memory_operands_mask_index() == 1);
- assert(
- spv::Op(
- message_.memory_access_instruction().target_instruction_opcode()) ==
- spv::Op::OpCopyMemory ||
- spv::Op(
- message_.memory_access_instruction().target_instruction_opcode()) ==
- spv::Op::OpCopyMemorySized);
+ assert(message_.memory_access_instruction().target_instruction_opcode() ==
+ SpvOpCopyMemory ||
+ message_.memory_access_instruction().target_instruction_opcode() ==
+ SpvOpCopyMemorySized);
assert(MultipleMemoryOperandMasksAreSupported(ir_context) &&
"Multiple memory operand masks are not supported for this SPIR-V "
"version.");
@@ -76,12 +73,12 @@ bool TransformationSetMemoryOperandsMask::IsApplicable(
uint32_t original_mask =
original_mask_in_operand_index < instruction->NumInOperands()
? instruction->GetSingleWordInOperand(original_mask_in_operand_index)
- : static_cast<uint32_t>(spv::MemoryAccessMask::MaskNone);
+ : static_cast<uint32_t>(SpvMemoryAccessMaskNone);
uint32_t new_mask = message_.memory_operands_mask();
// Volatile must not be removed
- if ((original_mask & uint32_t(spv::MemoryAccessMask::Volatile)) &&
- !(new_mask & uint32_t(spv::MemoryAccessMask::Volatile))) {
+ if ((original_mask & SpvMemoryAccessVolatileMask) &&
+ !(new_mask & SpvMemoryAccessVolatileMask)) {
return false;
}
@@ -90,10 +87,10 @@ bool TransformationSetMemoryOperandsMask::IsApplicable(
// their Volatile and Nontemporal flags to the same value (this works
// because valid manipulation of Volatile is checked above, and the manner
// in which Nontemporal is manipulated does not matter).
- return (original_mask | uint32_t(spv::MemoryAccessMask::Volatile) |
- uint32_t(spv::MemoryAccessMask::Nontemporal)) ==
- (new_mask | uint32_t(spv::MemoryAccessMask::Volatile) |
- uint32_t(spv::MemoryAccessMask::Nontemporal));
+ return (original_mask | SpvMemoryAccessVolatileMask |
+ SpvMemoryAccessNontemporalMask) ==
+ (new_mask | SpvMemoryAccessVolatileMask |
+ SpvMemoryAccessNontemporalMask);
}
void TransformationSetMemoryOperandsMask::Apply(
@@ -109,8 +106,8 @@ void TransformationSetMemoryOperandsMask::Apply(
if (message_.memory_operands_mask_index() == 1 &&
GetInOperandIndexForMask(*instruction, 0) >=
instruction->NumInOperands()) {
- instruction->AddOperand({SPV_OPERAND_TYPE_MEMORY_ACCESS,
- {uint32_t(spv::MemoryAccessMask::MaskNone)}});
+ instruction->AddOperand(
+ {SPV_OPERAND_TYPE_MEMORY_ACCESS, {SpvMemoryAccessMaskNone}});
}
instruction->AddOperand(
@@ -132,10 +129,10 @@ protobufs::Transformation TransformationSetMemoryOperandsMask::ToMessage()
bool TransformationSetMemoryOperandsMask::IsMemoryAccess(
const opt::Instruction& instruction) {
switch (instruction.opcode()) {
- case spv::Op::OpLoad:
- case spv::Op::OpStore:
- case spv::Op::OpCopyMemory:
- case spv::Op::OpCopyMemorySized:
+ case SpvOpLoad:
+ case SpvOpStore:
+ case SpvOpCopyMemory:
+ case SpvOpCopyMemorySized:
return true;
default:
return false;
@@ -148,16 +145,16 @@ uint32_t TransformationSetMemoryOperandsMask::GetInOperandIndexForMask(
// for the instruction.
uint32_t first_mask_in_operand_index = 0;
switch (instruction.opcode()) {
- case spv::Op::OpLoad:
+ case SpvOpLoad:
first_mask_in_operand_index = kOpLoadMemoryOperandsMaskIndex;
break;
- case spv::Op::OpStore:
+ case SpvOpStore:
first_mask_in_operand_index = kOpStoreMemoryOperandsMaskIndex;
break;
- case spv::Op::OpCopyMemory:
+ case SpvOpCopyMemory:
first_mask_in_operand_index = kOpCopyMemoryFirstMemoryOperandsMaskIndex;
break;
- case spv::Op::OpCopyMemorySized:
+ case SpvOpCopyMemorySized:
first_mask_in_operand_index =
kOpCopyMemorySizedFirstMemoryOperandsMaskIndex;
break;
@@ -195,12 +192,12 @@ uint32_t TransformationSetMemoryOperandsMask::GetInOperandIndexForMask(
// Consider each bit that might have an associated extra input operand, and
// count how many there are expected to be.
uint32_t first_mask_extra_operand_count = 0;
- for (auto mask_bit : {spv::MemoryAccessMask::Aligned,
- spv::MemoryAccessMask::MakePointerAvailable,
- spv::MemoryAccessMask::MakePointerAvailableKHR,
- spv::MemoryAccessMask::MakePointerVisible,
- spv::MemoryAccessMask::MakePointerVisibleKHR}) {
- if (first_mask & uint32_t(mask_bit)) {
+ for (auto mask_bit :
+ {SpvMemoryAccessAlignedMask, SpvMemoryAccessMakePointerAvailableMask,
+ SpvMemoryAccessMakePointerAvailableKHRMask,
+ SpvMemoryAccessMakePointerVisibleMask,
+ SpvMemoryAccessMakePointerVisibleKHRMask}) {
+ if (first_mask & mask_bit) {
first_mask_extra_operand_count++;
}
}
diff --git a/source/fuzz/transformation_set_selection_control.cpp b/source/fuzz/transformation_set_selection_control.cpp
index c6f68d9c..6dddbdf8 100644
--- a/source/fuzz/transformation_set_selection_control.cpp
+++ b/source/fuzz/transformation_set_selection_control.cpp
@@ -29,17 +29,14 @@ TransformationSetSelectionControl::TransformationSetSelectionControl(
bool TransformationSetSelectionControl::IsApplicable(
opt::IRContext* ir_context, const TransformationContext& /*unused*/) const {
- assert((spv::SelectionControlMask(message_.selection_control()) ==
- spv::SelectionControlMask::MaskNone ||
- spv::SelectionControlMask(message_.selection_control()) ==
- spv::SelectionControlMask::Flatten ||
- spv::SelectionControlMask(message_.selection_control()) ==
- spv::SelectionControlMask::DontFlatten) &&
+ assert((message_.selection_control() == SpvSelectionControlMaskNone ||
+ message_.selection_control() == SpvSelectionControlFlattenMask ||
+ message_.selection_control() == SpvSelectionControlDontFlattenMask) &&
"Selection control should never be set to something other than "
"'None', 'Flatten' or 'DontFlatten'");
if (auto block = ir_context->get_instr_block(message_.block_id())) {
if (auto merge_inst = block->GetMergeInst()) {
- return merge_inst->opcode() == spv::Op::OpSelectionMerge;
+ return merge_inst->opcode() == SpvOpSelectionMerge;
}
}
// Either the block did not exit, or did not end with OpSelectionMerge.
diff --git a/source/fuzz/transformation_split_block.cpp b/source/fuzz/transformation_split_block.cpp
index 959bedcd..e15dffa3 100644
--- a/source/fuzz/transformation_split_block.cpp
+++ b/source/fuzz/transformation_split_block.cpp
@@ -64,19 +64,19 @@ bool TransformationSplitBlock::IsApplicable(
" block split point exists.");
if (split_before->PreviousNode() &&
- split_before->PreviousNode()->opcode() == spv::Op::OpSelectionMerge) {
+ split_before->PreviousNode()->opcode() == SpvOpSelectionMerge) {
// We cannot split directly after a selection merge: this would separate
// the merge from its associated branch or switch operation.
return false;
}
- if (split_before->opcode() == spv::Op::OpVariable) {
+ if (split_before->opcode() == SpvOpVariable) {
// We cannot split directly after a variable; variables in a function
// must be contiguous in the entry block.
return false;
}
// We cannot split before an OpPhi unless the OpPhi has exactly one
// associated incoming edge.
- if (split_before->opcode() == spv::Op::OpPhi &&
+ if (split_before->opcode() == SpvOpPhi &&
split_before->NumInOperands() != 2) {
return false;
}
@@ -110,7 +110,7 @@ void TransformationSplitBlock::Apply(
// The split does not automatically add a branch between the two parts of
// the original block, so we add one.
auto branch_instruction = MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpBranch, 0, 0,
+ ir_context, SpvOpBranch, 0, 0,
std::initializer_list<opt::Operand>{opt::Operand(
spv_operand_type_t::SPV_OPERAND_TYPE_ID, {message_.fresh_id()})});
auto branch_instruction_ptr = branch_instruction.get();
diff --git a/source/fuzz/transformation_store.cpp b/source/fuzz/transformation_store.cpp
index 6ba1c551..c00cd345 100644
--- a/source/fuzz/transformation_store.cpp
+++ b/source/fuzz/transformation_store.cpp
@@ -48,7 +48,7 @@ bool TransformationStore::IsApplicable(
// The pointer type must indeed be a pointer.
auto pointer_type = ir_context->get_def_use_mgr()->GetDef(pointer->type_id());
assert(pointer_type && "Type id must be defined.");
- if (pointer_type->opcode() != spv::Op::OpTypePointer) {
+ if (pointer_type->opcode() != SpvOpTypePointer) {
return false;
}
@@ -59,8 +59,8 @@ bool TransformationStore::IsApplicable(
// We do not want to allow storing to null or undefined pointers.
switch (pointer->opcode()) {
- case spv::Op::OpConstantNull:
- case spv::Op::OpUndef:
+ case SpvOpConstantNull:
+ case SpvOpUndef:
return false;
default:
break;
@@ -75,11 +75,11 @@ bool TransformationStore::IsApplicable(
}
// ... and it must be legitimate to insert a store before it.
if (!message_.is_atomic() && !fuzzerutil::CanInsertOpcodeBeforeInstruction(
- spv::Op::OpStore, insert_before)) {
+ SpvOpStore, insert_before)) {
return false;
}
if (message_.is_atomic() && !fuzzerutil::CanInsertOpcodeBeforeInstruction(
- spv::Op::OpAtomicStore, insert_before)) {
+ SpvOpAtomicStore, insert_before)) {
return false;
}
@@ -125,10 +125,10 @@ bool TransformationStore::IsApplicable(
}
// The memory scope and memory semantics instructions must have the
// 'OpConstant' opcode.
- if (memory_scope_instruction->opcode() != spv::Op::OpConstant) {
+ if (memory_scope_instruction->opcode() != SpvOpConstant) {
return false;
}
- if (memory_semantics_instruction->opcode() != spv::Op::OpConstant) {
+ if (memory_semantics_instruction->opcode() != SpvOpConstant) {
return false;
}
// The memory scope and memory semantics need to be available before
@@ -145,12 +145,12 @@ bool TransformationStore::IsApplicable(
// operand type with signedness does not matters.
if (ir_context->get_def_use_mgr()
->GetDef(memory_scope_instruction->type_id())
- ->opcode() != spv::Op::OpTypeInt) {
+ ->opcode() != SpvOpTypeInt) {
return false;
}
if (ir_context->get_def_use_mgr()
->GetDef(memory_semantics_instruction->type_id())
- ->opcode() != spv::Op::OpTypeInt) {
+ ->opcode() != SpvOpTypeInt) {
return false;
}
@@ -172,20 +172,20 @@ bool TransformationStore::IsApplicable(
return false;
}
- // The memory scope constant value must be that of spv::Scope::Invocation.
+ // The memory scope constant value must be that of SpvScopeInvocation.
auto memory_scope_const_value =
memory_scope_instruction->GetSingleWordInOperand(0);
- if (spv::Scope(memory_scope_const_value) != spv::Scope::Invocation) {
+ if (memory_scope_const_value != SpvScopeInvocation) {
return false;
}
// The memory semantics constant value must match the storage class of the
// pointer being loaded from.
- auto memory_semantics_const_value = static_cast<spv::MemorySemanticsMask>(
+ auto memory_semantics_const_value = static_cast<SpvMemorySemanticsMask>(
memory_semantics_instruction->GetSingleWordInOperand(0));
if (memory_semantics_const_value !=
fuzzerutil::GetMemorySemanticsForStorageClass(
- static_cast<spv::StorageClass>(
+ static_cast<SpvStorageClass>(
pointer_type->GetSingleWordInOperand(0)))) {
return false;
}
@@ -203,7 +203,7 @@ void TransformationStore::Apply(opt::IRContext* ir_context,
auto insert_before =
FindInstruction(message_.instruction_to_insert_before(), ir_context);
auto new_instruction = MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpAtomicStore, 0, 0,
+ ir_context, SpvOpAtomicStore, 0, 0,
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {message_.pointer_id()}},
{SPV_OPERAND_TYPE_SCOPE_ID, {message_.memory_scope_id()}},
@@ -223,7 +223,7 @@ void TransformationStore::Apply(opt::IRContext* ir_context,
auto insert_before =
FindInstruction(message_.instruction_to_insert_before(), ir_context);
auto new_instruction = MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpStore, 0, 0,
+ ir_context, SpvOpStore, 0, 0,
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {message_.pointer_id()}},
{SPV_OPERAND_TYPE_ID, {message_.value_id()}}}));
diff --git a/source/fuzz/transformation_store.h b/source/fuzz/transformation_store.h
index 5b55ce6c..638713bb 100644
--- a/source/fuzz/transformation_store.h
+++ b/source/fuzz/transformation_store.h
@@ -38,7 +38,7 @@ class TransformationStore : public Transformation {
// - |message_.is_atomic| must be true if want to work with OpAtomicStore.
// - If |is_atomic| is true then |message_memory_scope_id| must be the id of
// an OpConstant 32 bit integer instruction with the value
- // spv::Scope::Invocation.
+ // SpvScopeInvocation.
// - If |is_atomic| is true then |message_.memory_semantics_id| must be the id
// of an OpConstant 32 bit integer instruction with the values
// SpvMemorySemanticsWorkgroupMemoryMask or
diff --git a/source/fuzz/transformation_swap_commutable_operands.cpp b/source/fuzz/transformation_swap_commutable_operands.cpp
index 15121443..a02e95a0 100644
--- a/source/fuzz/transformation_swap_commutable_operands.cpp
+++ b/source/fuzz/transformation_swap_commutable_operands.cpp
@@ -35,9 +35,9 @@ bool TransformationSwapCommutableOperands::IsApplicable(
FindInstruction(message_.instruction_descriptor(), ir_context);
if (instruction == nullptr) return false;
- spv::Op opcode = static_cast<spv::Op>(
+ SpvOp opcode = static_cast<SpvOp>(
message_.instruction_descriptor().target_instruction_opcode());
- assert(spv::Op(instruction->opcode()) == opcode &&
+ assert(instruction->opcode() == opcode &&
"The located instruction must have the same opcode as in the "
"descriptor.");
return spvOpcodeIsCommutativeBinaryOperator(opcode);
diff --git a/source/fuzz/transformation_swap_conditional_branch_operands.cpp b/source/fuzz/transformation_swap_conditional_branch_operands.cpp
index 520a6a8e..340836d1 100644
--- a/source/fuzz/transformation_swap_conditional_branch_operands.cpp
+++ b/source/fuzz/transformation_swap_conditional_branch_operands.cpp
@@ -38,7 +38,7 @@ bool TransformationSwapConditionalBranchOperands::IsApplicable(
const auto* inst =
FindInstruction(message_.instruction_descriptor(), ir_context);
return fuzzerutil::IsFreshId(ir_context, message_.fresh_id()) && inst &&
- inst->opcode() == spv::Op::OpBranchConditional;
+ inst->opcode() == SpvOpBranchConditional;
}
void TransformationSwapConditionalBranchOperands::Apply(
@@ -53,15 +53,13 @@ void TransformationSwapConditionalBranchOperands::Apply(
// Compute the last instruction in the |block| that allows us to insert
// OpLogicalNot above it.
auto iter = fuzzerutil::GetIteratorForInstruction(block, branch_inst);
- if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(spv::Op::OpLogicalNot,
- iter)) {
+ if (!fuzzerutil::CanInsertOpcodeBeforeInstruction(SpvOpLogicalNot, iter)) {
// There might be a merge instruction before OpBranchConditional.
--iter;
}
- assert(fuzzerutil::CanInsertOpcodeBeforeInstruction(spv::Op::OpLogicalNot,
- iter) &&
- "We should now be able to insert spv::Op::OpLogicalNot before |iter|");
+ assert(fuzzerutil::CanInsertOpcodeBeforeInstruction(SpvOpLogicalNot, iter) &&
+ "We should now be able to insert SpvOpLogicalNot before |iter|");
// Get the instruction whose result is used as a condition for
// OpBranchConditional.
@@ -72,7 +70,7 @@ void TransformationSwapConditionalBranchOperands::Apply(
// We are swapping the labels in OpBranchConditional. This means that we must
// invert the guard as well. We are using OpLogicalNot for that purpose here.
auto new_instruction = MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpLogicalNot, condition_inst->type_id(),
+ ir_context, SpvOpLogicalNot, condition_inst->type_id(),
message_.fresh_id(),
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_ID, {condition_inst->result_id()}}});
diff --git a/source/fuzz/transformation_swap_function_variables.cpp b/source/fuzz/transformation_swap_function_variables.cpp
index 14ba7bb7..aec32fe1 100644
--- a/source/fuzz/transformation_swap_function_variables.cpp
+++ b/source/fuzz/transformation_swap_function_variables.cpp
@@ -43,8 +43,8 @@ bool TransformationSwapFunctionVariables::IsApplicable(
return false;
}
// Both instructions must be variables.
- if (instruction1->opcode() != spv::Op::OpVariable ||
- instruction2->opcode() != spv::Op::OpVariable) {
+ if (instruction1->opcode() != SpvOpVariable ||
+ instruction2->opcode() != SpvOpVariable) {
return false;
}
diff --git a/source/fuzz/transformation_toggle_access_chain_instruction.cpp b/source/fuzz/transformation_toggle_access_chain_instruction.cpp
index ae6ab9ad..34523fe8 100644
--- a/source/fuzz/transformation_toggle_access_chain_instruction.cpp
+++ b/source/fuzz/transformation_toggle_access_chain_instruction.cpp
@@ -39,15 +39,14 @@ bool TransformationToggleAccessChainInstruction::IsApplicable(
return false;
}
- spv::Op opcode = static_cast<spv::Op>(
+ SpvOp opcode = static_cast<SpvOp>(
message_.instruction_descriptor().target_instruction_opcode());
assert(instruction->opcode() == opcode &&
"The located instruction must have the same opcode as in the "
"descriptor.");
- if (opcode == spv::Op::OpAccessChain ||
- opcode == spv::Op::OpInBoundsAccessChain) {
+ if (opcode == SpvOpAccessChain || opcode == SpvOpInBoundsAccessChain) {
return true;
}
@@ -58,15 +57,15 @@ void TransformationToggleAccessChainInstruction::Apply(
opt::IRContext* ir_context, TransformationContext* /*unused*/) const {
auto instruction =
FindInstruction(message_.instruction_descriptor(), ir_context);
- spv::Op opcode = instruction->opcode();
+ SpvOp opcode = instruction->opcode();
- if (opcode == spv::Op::OpAccessChain) {
- instruction->SetOpcode(spv::Op::OpInBoundsAccessChain);
+ if (opcode == SpvOpAccessChain) {
+ instruction->SetOpcode(SpvOpInBoundsAccessChain);
} else {
- assert(opcode == spv::Op::OpInBoundsAccessChain &&
+ assert(opcode == SpvOpInBoundsAccessChain &&
"The located instruction must be an OpInBoundsAccessChain "
"instruction.");
- instruction->SetOpcode(spv::Op::OpAccessChain);
+ instruction->SetOpcode(SpvOpAccessChain);
}
}
diff --git a/source/fuzz/transformation_vector_shuffle.cpp b/source/fuzz/transformation_vector_shuffle.cpp
index 8ba557c9..742a2c80 100644
--- a/source/fuzz/transformation_vector_shuffle.cpp
+++ b/source/fuzz/transformation_vector_shuffle.cpp
@@ -108,7 +108,7 @@ bool TransformationVectorShuffle::IsApplicable(
// It must be legitimate to insert an OpVectorShuffle before the identified
// instruction.
return fuzzerutil::CanInsertOpcodeBeforeInstruction(
- spv::Op::OpVectorShuffle, instruction_to_insert_before);
+ SpvOpVectorShuffle, instruction_to_insert_before);
}
void TransformationVectorShuffle::Apply(
@@ -134,8 +134,8 @@ void TransformationVectorShuffle::Apply(
FindInstruction(message_.instruction_to_insert_before(), ir_context);
opt::Instruction* new_instruction =
insert_before->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpVectorShuffle, result_type_id,
- message_.fresh_id(), shuffle_operands));
+ ir_context, SpvOpVectorShuffle, result_type_id, message_.fresh_id(),
+ shuffle_operands));
fuzzerutil::UpdateModuleIdBound(ir_context, message_.fresh_id());
// Inform the def-use manager about the new instruction and record its basic
// block.
diff --git a/source/fuzz/transformation_wrap_early_terminator_in_function.cpp b/source/fuzz/transformation_wrap_early_terminator_in_function.cpp
index f59d78ad..468d809f 100644
--- a/source/fuzz/transformation_wrap_early_terminator_in_function.cpp
+++ b/source/fuzz/transformation_wrap_early_terminator_in_function.cpp
@@ -52,9 +52,9 @@ bool TransformationWrapEarlyTerminatorInFunction::IsApplicable(
return false;
}
switch (early_terminator->opcode()) {
- case spv::Op::OpKill:
- case spv::Op::OpUnreachable:
- case spv::Op::OpTerminateInvocation:
+ case SpvOpKill:
+ case SpvOpUnreachable:
+ case SpvOpTerminateInvocation:
break;
default:
return false;
@@ -119,7 +119,7 @@ void TransformationWrapEarlyTerminatorInFunction::Apply(
MaybeGetWrapperFunction(ir_context, early_terminator->opcode());
iterator->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpFunctionCall, wrapper_function->type_id(),
+ ir_context, SpvOpFunctionCall, wrapper_function->type_id(),
message_.fresh_id(),
opt::Instruction::OperandList(
{{SPV_OPERAND_TYPE_ID, {wrapper_function->result_id()}}})));
@@ -130,9 +130,9 @@ void TransformationWrapEarlyTerminatorInFunction::Apply(
->AsVoid()) {
new_in_operands.push_back(
{SPV_OPERAND_TYPE_ID, {message_.returned_value_id()}});
- early_terminator->SetOpcode(spv::Op::OpReturnValue);
+ early_terminator->SetOpcode(SpvOpReturnValue);
} else {
- early_terminator->SetOpcode(spv::Op::OpReturn);
+ early_terminator->SetOpcode(SpvOpReturn);
}
early_terminator->SetInOperands(std::move(new_in_operands));
@@ -153,10 +153,10 @@ TransformationWrapEarlyTerminatorInFunction::ToMessage() const {
opt::Function*
TransformationWrapEarlyTerminatorInFunction::MaybeGetWrapperFunction(
- opt::IRContext* ir_context, spv::Op early_terminator_opcode) {
- assert((early_terminator_opcode == spv::Op::OpKill ||
- early_terminator_opcode == spv::Op::OpUnreachable ||
- early_terminator_opcode == spv::Op::OpTerminateInvocation) &&
+ opt::IRContext* ir_context, SpvOp early_terminator_opcode) {
+ assert((early_terminator_opcode == SpvOpKill ||
+ early_terminator_opcode == SpvOpUnreachable ||
+ early_terminator_opcode == SpvOpTerminateInvocation) &&
"Invalid opcode.");
auto void_type_id = fuzzerutil::MaybeGetVoidType(ir_context);
if (!void_type_id) {
diff --git a/source/fuzz/transformation_wrap_early_terminator_in_function.h b/source/fuzz/transformation_wrap_early_terminator_in_function.h
index d824783b..d6e55517 100644
--- a/source/fuzz/transformation_wrap_early_terminator_in_function.h
+++ b/source/fuzz/transformation_wrap_early_terminator_in_function.h
@@ -60,8 +60,8 @@ class TransformationWrapEarlyTerminatorInFunction : public Transformation {
protobufs::Transformation ToMessage() const override;
- static opt::Function* MaybeGetWrapperFunction(
- opt::IRContext* ir_context, spv::Op early_terminator_opcode);
+ static opt::Function* MaybeGetWrapperFunction(opt::IRContext* ir_context,
+ SpvOp early_terminator_opcode);
private:
protobufs::TransformationWrapEarlyTerminatorInFunction message_;
diff --git a/source/fuzz/transformation_wrap_region_in_selection.cpp b/source/fuzz/transformation_wrap_region_in_selection.cpp
index a63d1ac5..01c98cca 100644
--- a/source/fuzz/transformation_wrap_region_in_selection.cpp
+++ b/source/fuzz/transformation_wrap_region_in_selection.cpp
@@ -53,14 +53,14 @@ void TransformationWrapRegionInSelection::Apply(
TransformationContext* transformation_context) const {
auto* new_header_block =
ir_context->cfg()->block(message_.region_entry_block_id());
- assert(new_header_block->terminator()->opcode() == spv::Op::OpBranch &&
+ assert(new_header_block->terminator()->opcode() == SpvOpBranch &&
"This condition should have been checked in the IsApplicable");
const auto successor_id =
new_header_block->terminator()->GetSingleWordInOperand(0);
// Change |entry_block|'s terminator to |OpBranchConditional|.
- new_header_block->terminator()->SetOpcode(spv::Op::OpBranchConditional);
+ new_header_block->terminator()->SetOpcode(SpvOpBranchConditional);
new_header_block->terminator()->SetInOperands(
{{SPV_OPERAND_TYPE_ID,
{fuzzerutil::MaybeGetBoolConstant(ir_context, *transformation_context,
@@ -70,11 +70,11 @@ void TransformationWrapRegionInSelection::Apply(
// Insert OpSelectionMerge before the terminator.
new_header_block->terminator()->InsertBefore(MakeUnique<opt::Instruction>(
- ir_context, spv::Op::OpSelectionMerge, 0, 0,
+ ir_context, SpvOpSelectionMerge, 0, 0,
opt::Instruction::OperandList{
{SPV_OPERAND_TYPE_ID, {message_.region_exit_block_id()}},
{SPV_OPERAND_TYPE_SELECTION_CONTROL,
- {uint32_t(spv::SelectionControlMask::MaskNone)}}}));
+ {SpvSelectionControlMaskNone}}}));
// We've change the module so we must invalidate analyses.
ir_context->InvalidateAnalysesExceptFor(opt::IRContext::kAnalysisNone);
@@ -130,7 +130,7 @@ bool TransformationWrapRegionInSelection::IsApplicableToBlockRange(
}
// |header_block_candidate| must have an OpBranch terminator.
- if (header_block_candidate->terminator()->opcode() != spv::Op::OpBranch) {
+ if (header_block_candidate->terminator()->opcode() != SpvOpBranch) {
return false;
}
diff --git a/source/fuzz/transformation_wrap_vector_synonym.cpp b/source/fuzz/transformation_wrap_vector_synonym.cpp
index 3b1543dd..490bcd78 100644
--- a/source/fuzz/transformation_wrap_vector_synonym.cpp
+++ b/source/fuzz/transformation_wrap_vector_synonym.cpp
@@ -83,7 +83,7 @@ bool TransformationWrapVectorSynonym::IsApplicable(
}
auto vec1_type = ir_context->get_def_use_mgr()->GetDef(vec1_type_id);
- if (vec1_type->opcode() != spv::Op::OpTypeVector) {
+ if (vec1_type->opcode() != SpvOpTypeVector) {
return false;
}
@@ -178,18 +178,18 @@ bool TransformationWrapVectorSynonym::IsInstructionSupported(
auto type_instruction =
ir_context->get_def_use_mgr()->GetDef(instruction.type_id());
- if ((type_instruction->opcode() != spv::Op::OpTypeInt &&
- type_instruction->opcode() != spv::Op::OpTypeFloat)) {
+ if ((type_instruction->opcode() != SpvOpTypeInt &&
+ type_instruction->opcode() != SpvOpTypeFloat)) {
return false;
}
switch (instruction.opcode()) {
- case spv::Op::OpIAdd:
- case spv::Op::OpISub:
- case spv::Op::OpIMul:
- case spv::Op::OpFAdd:
- case spv::Op::OpFSub:
- case spv::Op::OpFMul:
+ case SpvOpIAdd:
+ case SpvOpISub:
+ case SpvOpIMul:
+ case SpvOpFAdd:
+ case SpvOpFSub:
+ case SpvOpFMul:
return true;
default:
return false;
diff --git a/source/fuzz/uniform_buffer_element_descriptor.cpp b/source/fuzz/uniform_buffer_element_descriptor.cpp
index 55e84de8..90fd85e9 100644
--- a/source/fuzz/uniform_buffer_element_descriptor.cpp
+++ b/source/fuzz/uniform_buffer_element_descriptor.cpp
@@ -49,11 +49,10 @@ opt::Instruction* FindUniformVariable(
for (auto& inst : context->types_values()) {
// Consider all global variables with uniform storage class.
- if (inst.opcode() != spv::Op::OpVariable) {
+ if (inst.opcode() != SpvOpVariable) {
continue;
}
- if (spv::StorageClass(inst.GetSingleWordInOperand(0)) !=
- spv::StorageClass::Uniform) {
+ if (inst.GetSingleWordInOperand(0) != SpvStorageClassUniform) {
continue;
}
@@ -61,7 +60,7 @@ opt::Instruction* FindUniformVariable(
// matching that in |uniform_buffer_element|.
bool descriptor_set_matches = false;
context->get_decoration_mgr()->ForEachDecoration(
- inst.result_id(), uint32_t(spv::Decoration::DescriptorSet),
+ inst.result_id(), SpvDecorationDescriptorSet,
[&descriptor_set_matches, &uniform_buffer_element_descriptor](
const opt::Instruction& decoration_inst) {
const uint32_t kDescriptorSetOperandIndex = 2;
@@ -80,7 +79,7 @@ opt::Instruction* FindUniformVariable(
// in |uniform_buffer_element|.
bool binding_matches = false;
context->get_decoration_mgr()->ForEachDecoration(
- inst.result_id(), uint32_t(spv::Decoration::Binding),
+ inst.result_id(), SpvDecorationBinding,
[&binding_matches, &uniform_buffer_element_descriptor](
const opt::Instruction& decoration_inst) {
const uint32_t kBindingOperandIndex = 2;