• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #ifndef SOURCE_OPT_ANALYZE_LIVE_INPUT_H_
17 #define SOURCE_OPT_ANALYZE_LIVE_INPUT_H_
18 
19 #include <unordered_set>
20 
21 #include "source/opt/pass.h"
22 
23 namespace spvtools {
24 namespace opt {
25 
26 // See optimizer.hpp for documentation.
27 class AnalyzeLiveInputPass : public Pass {
28  public:
AnalyzeLiveInputPass(std::unordered_set<uint32_t> * live_locs,std::unordered_set<uint32_t> * live_builtins)29   explicit AnalyzeLiveInputPass(std::unordered_set<uint32_t>* live_locs,
30                                 std::unordered_set<uint32_t>* live_builtins)
31       : live_locs_(live_locs), live_builtins_(live_builtins) {}
32 
name()33   const char* name() const override { return "analyze-live-input"; }
34   Status Process() override;
35 
36   // Return the mask of preserved Analyses.
GetPreservedAnalyses()37   IRContext::Analysis GetPreservedAnalyses() override {
38     return IRContext::kAnalysisDefUse |
39            IRContext::kAnalysisInstrToBlockMapping |
40            IRContext::kAnalysisCombinators | IRContext::kAnalysisCFG |
41            IRContext::kAnalysisDominatorAnalysis |
42            IRContext::kAnalysisLoopAnalysis | IRContext::kAnalysisNameMap |
43            IRContext::kAnalysisConstants | IRContext::kAnalysisTypes;
44   }
45 
46  private:
47   // Do live input analysis
48   Status DoLiveInputAnalysis();
49 
50   std::unordered_set<uint32_t>* live_locs_;
51   std::unordered_set<uint32_t>* live_builtins_;
52 };
53 
54 }  // namespace opt
55 }  // namespace spvtools
56 
57 #endif  // SOURCE_OPT_ANALYZE_LIVE_INPUT_H_
58