remove_block_reduction_opportunity.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright (c) 2019 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #ifndef SOURCE_REDUCE_REMOVE_BLOCK_REDUCTION_OPPORTUNITY_H_
  15. #define SOURCE_REDUCE_REMOVE_BLOCK_REDUCTION_OPPORTUNITY_H_
  16. #include "source/opt/basic_block.h"
  17. #include "source/opt/function.h"
  18. #include "source/reduce/reduction_opportunity.h"
  19. namespace spvtools {
  20. namespace reduce {
  21. // An opportunity to remove an unreferenced block.
  22. // See RemoveBlockReductionOpportunityFinder.
  23. class RemoveBlockReductionOpportunity : public ReductionOpportunity {
  24. public:
  25. // Creates the opportunity to remove |block| in |function| in |context|.
  26. RemoveBlockReductionOpportunity(opt::IRContext* context,
  27. opt::Function* function,
  28. opt::BasicBlock* block);
  29. bool PreconditionHolds() override;
  30. protected:
  31. void Apply() override;
  32. private:
  33. opt::IRContext* context_;
  34. opt::Function* function_;
  35. opt::BasicBlock* block_;
  36. };
  37. } // namespace reduce
  38. } // namespace spvtools
  39. #endif // SOURCE_REDUCE_REMOVE_BLOCK_REDUCTION_OPPORTUNITY_H_