/src/spirv-tools/source/opt/analyze_live_input_pass.h
Line | Count | Source |
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: |
29 | | explicit AnalyzeLiveInputPass(std::unordered_set<uint32_t>* live_locs, |
30 | | std::unordered_set<uint32_t>* live_builtins) |
31 | 0 | : live_locs_(live_locs), live_builtins_(live_builtins) {} |
32 | | |
33 | 0 | const char* name() const override { return "analyze-live-input"; } |
34 | | Status Process() override; |
35 | | |
36 | | // Return the mask of preserved Analyses. |
37 | 0 | IRContext::Analysis GetPreservedAnalyses() override { |
38 | 0 | return IRContext::kAnalysisDefUse | |
39 | 0 | IRContext::kAnalysisInstrToBlockMapping | |
40 | 0 | IRContext::kAnalysisCombinators | IRContext::kAnalysisCFG | |
41 | 0 | IRContext::kAnalysisDominatorAnalysis | |
42 | 0 | IRContext::kAnalysisLoopAnalysis | IRContext::kAnalysisNameMap | |
43 | 0 | IRContext::kAnalysisConstants | IRContext::kAnalysisTypes; |
44 | 0 | } |
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_ |