• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
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  */
15 
16 #ifndef PANDA_OBJECT_TYPE_PROPAGATION_H
17 #define PANDA_OBJECT_TYPE_PROPAGATION_H
18 
19 #include "optimizer/pass.h"
20 #include "optimizer/ir/graph.h"
21 #include "optimizer/ir/graph_visitor.h"
22 
23 namespace panda::compiler {
24 // NOLINTNEXTLINE(fuchsia-multiple-inheritance)
25 class ObjectTypePropagation final : public Analysis, public GraphVisitor {
26 public:
ObjectTypePropagation(Graph * graph)27     explicit ObjectTypePropagation(Graph *graph) : Analysis(graph) {}
28     NO_MOVE_SEMANTIC(ObjectTypePropagation);
29     NO_COPY_SEMANTIC(ObjectTypePropagation);
30     ~ObjectTypePropagation() override = default;
31 
GetBlocksToVisit()32     const ArenaVector<BasicBlock *> &GetBlocksToVisit() const override
33     {
34         return GetGraph()->GetBlocksRPO();
35     }
36 
GetPassName()37     const char *GetPassName() const override
38     {
39         return "ObjectTypePropagation";
40     }
41 
42     bool RunImpl() override;
43 
44 protected:
45     static void VisitNewObject(GraphVisitor *v, Inst *inst);
46     static void VisitNewArray(GraphVisitor *v, Inst *inst);
47     static void VisitLoadArray(GraphVisitor *v, Inst *inst);
48     static void VisitLoadString(GraphVisitor *v, Inst *inst);
49 
50 #include "optimizer/ir/visitor.inc"
51 };
52 }  // namespace panda::compiler
53 
54 #endif  // PANDA_OBJECT_TYPE_PROPAGATION_H
55