remove_function_reduction_opportunity.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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_FUNCTION_REDUCTION_OPPORTUNITY_H_
  15. #define SOURCE_REDUCE_REMOVE_FUNCTION_REDUCTION_OPPORTUNITY_H_
  16. #include "source/opt/function.h"
  17. #include "source/reduce/reduction_opportunity.h"
  18. namespace spvtools {
  19. namespace reduce {
  20. // An opportunity to remove an unreferenced function.
  21. class RemoveFunctionReductionOpportunity : public ReductionOpportunity {
  22. public:
  23. // Creates an opportunity to remove |function| from the module represented by
  24. // |context|.
  25. RemoveFunctionReductionOpportunity(opt::IRContext* context,
  26. opt::Function* function)
  27. : context_(context), function_(function) {}
  28. bool PreconditionHolds() override;
  29. protected:
  30. void Apply() override;
  31. private:
  32. // The IR context for the module under analysis.
  33. opt::IRContext* context_;
  34. // The function that can be removed.
  35. opt::Function* function_;
  36. };
  37. } // namespace reduce
  38. } // namespace spvtools
  39. #endif // SOURCE_REDUCE_REMOVE_FUNCTION_REDUCTION_OPPORTUNITY_H_