diff options
Diffstat (limited to 'source/fuzz/transformation_set_loop_control.cpp')
-rw-r--r-- | source/fuzz/transformation_set_loop_control.cpp | 64 |
1 files changed, 36 insertions, 28 deletions
diff --git a/source/fuzz/transformation_set_loop_control.cpp b/source/fuzz/transformation_set_loop_control.cpp index 144996065..dc9ee7cff 100644 --- a/source/fuzz/transformation_set_loop_control.cpp +++ b/source/fuzz/transformation_set_loop_control.cpp @@ -38,18 +38,20 @@ bool TransformationSetLoopControl::IsApplicable( return false; } auto merge_inst = block->GetMergeInst(); - if (!merge_inst || merge_inst->opcode() != SpvOpLoopMerge) { + if (!merge_inst || merge_inst->opcode() != spv::Op::OpLoopMerge) { 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 = - SpvLoopControlUnrollMask | SpvLoopControlDontUnrollMask | - SpvLoopControlDependencyInfiniteMask | - SpvLoopControlDependencyLengthMask | SpvLoopControlMinIterationsMask | - SpvLoopControlMaxIterationsMask | SpvLoopControlIterationMultipleMask | - SpvLoopControlPeelCountMask | SpvLoopControlPartialCountMask; + 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); // The variable is only used in an assertion; the following keeps release-mode // compilers happy. @@ -65,10 +67,11 @@ bool TransformationSetLoopControl::IsApplicable( // Check that there is no attempt to set one of the loop controls that // requires guarantees to hold. - for (SpvLoopControlMask mask : - {SpvLoopControlDependencyInfiniteMask, - SpvLoopControlDependencyLengthMask, SpvLoopControlMinIterationsMask, - SpvLoopControlMaxIterationsMask, SpvLoopControlIterationMultipleMask}) { + for (spv::LoopControlMask mask : {spv::LoopControlMask::DependencyInfinite, + spv::LoopControlMask::DependencyLength, + spv::LoopControlMask::MinIterations, + spv::LoopControlMask::MaxIterations, + spv::LoopControlMask::IterationMultiple}) { // 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, @@ -78,33 +81,36 @@ bool TransformationSetLoopControl::IsApplicable( } // Check that PeelCount and PartialCount are supported if used. - if ((message_.loop_control() & SpvLoopControlPeelCountMask) && + if ((message_.loop_control() & uint32_t(spv::LoopControlMask::PeelCount)) && !PeelCountIsSupported(ir_context)) { return false; } - if ((message_.loop_control() & SpvLoopControlPartialCountMask) && + if ((message_.loop_control() & + uint32_t(spv::LoopControlMask::PartialCount)) && !PartialCountIsSupported(ir_context)) { return false; } if (message_.peel_count() > 0 && - !(message_.loop_control() & SpvLoopControlPeelCountMask)) { + !(message_.loop_control() & uint32_t(spv::LoopControlMask::PeelCount))) { // Peel count provided, but peel count mask bit not set. return false; } if (message_.partial_count() > 0 && - !(message_.loop_control() & SpvLoopControlPartialCountMask)) { + !(message_.loop_control() & + uint32_t(spv::LoopControlMask::PartialCount))) { // 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() & SpvLoopControlDontUnrollMask) && - (message_.loop_control() & - (SpvLoopControlPeelCountMask | SpvLoopControlPartialCountMask))); + return !( + (message_.loop_control() & uint32_t(spv::LoopControlMask::DontUnroll)) && + (message_.loop_control() & uint32_t(spv::LoopControlMask::PeelCount | + spv::LoopControlMask::PartialCount))); } void TransformationSetLoopControl::Apply( @@ -133,13 +139,14 @@ void TransformationSetLoopControl::Apply( uint32_t literal_index = 0; // Indexes into the literals from the original // instruction. - for (SpvLoopControlMask mask : - {SpvLoopControlDependencyLengthMask, SpvLoopControlMinIterationsMask, - SpvLoopControlMaxIterationsMask, SpvLoopControlIterationMultipleMask}) { + for (spv::LoopControlMask mask : {spv::LoopControlMask::DependencyLength, + spv::LoopControlMask::MinIterations, + spv::LoopControlMask::MaxIterations, + spv::LoopControlMask::IterationMultiple}) { // Check whether the bit was set in the original loop control mask. - if (existing_loop_control_mask & mask) { + if (existing_loop_control_mask & uint32_t(mask)) { // Check whether the bit is set in the new loop control mask. - if (message_.loop_control() & mask) { + if (message_.loop_control() & uint32_t(mask)) { // Add the associated literal to our sequence of replacement operands. new_operands.push_back( {SPV_OPERAND_TYPE_LITERAL_INTEGER, @@ -154,13 +161,13 @@ void TransformationSetLoopControl::Apply( // If PeelCount is set in the new mask, |message_.peel_count| provides the // associated peel count. - if (message_.loop_control() & SpvLoopControlPeelCountMask) { + if (message_.loop_control() & uint32_t(spv::LoopControlMask::PeelCount)) { new_operands.push_back( {SPV_OPERAND_TYPE_LITERAL_INTEGER, {message_.peel_count()}}); } // Similar, but for PartialCount. - if (message_.loop_control() & SpvLoopControlPartialCountMask) { + if (message_.loop_control() & uint32_t(spv::LoopControlMask::PartialCount)) { new_operands.push_back( {SPV_OPERAND_TYPE_LITERAL_INTEGER, {message_.partial_count()}}); } @@ -177,10 +184,11 @@ protobufs::Transformation TransformationSetLoopControl::ToMessage() const { } bool TransformationSetLoopControl::LoopControlBitIsAddedByTransformation( - SpvLoopControlMask loop_control_single_bit_mask, + spv::LoopControlMask loop_control_single_bit_mask, uint32_t existing_loop_control_mask) const { - return !(loop_control_single_bit_mask & existing_loop_control_mask) && - (loop_control_single_bit_mask & message_.loop_control()); + return !(uint32_t(loop_control_single_bit_mask) & + existing_loop_control_mask) && + (uint32_t(loop_control_single_bit_mask) & message_.loop_control()); } bool TransformationSetLoopControl::PartialCountIsSupported( |