analyze_live_input_pass.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright (c) 2022 The Khronos Group Inc.
  2. // Copyright (c) 2022 LunarG Inc.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. #ifndef SOURCE_OPT_ANALYZE_LIVE_INPUT_H_
  16. #define SOURCE_OPT_ANALYZE_LIVE_INPUT_H_
  17. #include <unordered_set>
  18. #include "source/opt/pass.h"
  19. namespace spvtools {
  20. namespace opt {
  21. // See optimizer.hpp for documentation.
  22. class AnalyzeLiveInputPass : public Pass {
  23. public:
  24. explicit AnalyzeLiveInputPass(std::unordered_set<uint32_t>* live_locs,
  25. std::unordered_set<uint32_t>* live_builtins)
  26. : live_locs_(live_locs), live_builtins_(live_builtins) {}
  27. const char* name() const override { return "analyze-live-input"; }
  28. Status Process() override;
  29. // Return the mask of preserved Analyses.
  30. IRContext::Analysis GetPreservedAnalyses() override {
  31. return IRContext::kAnalysisDefUse |
  32. IRContext::kAnalysisInstrToBlockMapping |
  33. IRContext::kAnalysisCombinators | IRContext::kAnalysisCFG |
  34. IRContext::kAnalysisDominatorAnalysis |
  35. IRContext::kAnalysisLoopAnalysis | IRContext::kAnalysisNameMap |
  36. IRContext::kAnalysisConstants | IRContext::kAnalysisTypes;
  37. }
  38. private:
  39. // Do live input analysis
  40. Status DoLiveInputAnalysis();
  41. std::unordered_set<uint32_t>* live_locs_;
  42. std::unordered_set<uint32_t>* live_builtins_;
  43. };
  44. } // namespace opt
  45. } // namespace spvtools
  46. #endif // SOURCE_OPT_ANALYZE_LIVE_INPUT_H_