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, 28 insertions, 36 deletions
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( |