• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2024 Huawei Technologies Co., Ltd
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 MINDSPORE_PI_JIT_GRAPH_CAPTURE_LOCAL_LIVENESS_H
17 #define MINDSPORE_PI_JIT_GRAPH_CAPTURE_LOCAL_LIVENESS_H
18 
19 #include <vector>
20 #include "pipeline/jit/pi/utils/bitmap.h"
21 #include "utils/convert_utils_base.h"
22 
23 namespace mindspore {
24 namespace pijit {
25 
26 class Instr;
27 class Block;
28 class CFG;
29 
30 class Liveness {
31  public:
Liveness(const CFG * cfg)32   explicit Liveness(const CFG *cfg) : cfg_(cfg) {}
33 
34   void Init();
35 
36   // collect alive local index map
37   BitMap CollectAlive(int start_bci) const;
38 
39   static void BuildRW(const Instr &instr, BitMap *read, BitMap *write);
40 
41  private:
42   void Propagate(Block *cur, std::vector<Block *> *list);
43   const CFG *const cfg_;
44 
45   std::vector<BitMap> read_;
46   std::vector<BitMap> write_;
47   std::vector<BitMap> alive_;
48   std::vector<BitMap> alive_effect_;
49 };
50 
51 }  // namespace pijit
52 }  // namespace mindspore
53 
54 #endif
55