annotate llvm/lib/Target/Hexagon/RDFDeadCode.h @ 252:1f2b6ac9f198 llvm-original

LLVM16-1
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Fri, 18 Aug 2023 09:04:13 +0900
parents 0572611fdcc8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 //===--- RDFDeadCode.h ----------------------------------------------------===//
anatofuz
parents:
diff changeset
2 //
anatofuz
parents:
diff changeset
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
anatofuz
parents:
diff changeset
4 // See https://llvm.org/LICENSE.txt for license information.
anatofuz
parents:
diff changeset
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
anatofuz
parents:
diff changeset
6 //
anatofuz
parents:
diff changeset
7 //===----------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
8 //
anatofuz
parents:
diff changeset
9 // RDF-based generic dead code elimination.
anatofuz
parents:
diff changeset
10 //
anatofuz
parents:
diff changeset
11 // The main interface of this class are functions "collect" and "erase".
anatofuz
parents:
diff changeset
12 // This allows custom processing of the function being optimized by a
anatofuz
parents:
diff changeset
13 // particular consumer. The simplest way to use this class would be to
anatofuz
parents:
diff changeset
14 // instantiate an object, and then simply call "collect" and "erase",
anatofuz
parents:
diff changeset
15 // passing the result of "getDeadInstrs()" to it.
anatofuz
parents:
diff changeset
16 // A more complex scenario would be to call "collect" first, then visit
anatofuz
parents:
diff changeset
17 // all post-increment instructions to see if the address update is dead
anatofuz
parents:
diff changeset
18 // or not, and if it is, convert the instruction to a non-updating form.
anatofuz
parents:
diff changeset
19 // After that "erase" can be called with the set of nodes including both,
anatofuz
parents:
diff changeset
20 // dead defs from the updating instructions and the nodes corresponding
anatofuz
parents:
diff changeset
21 // to the dead instructions.
anatofuz
parents:
diff changeset
22
anatofuz
parents:
diff changeset
23 #ifndef RDF_DEADCODE_H
anatofuz
parents:
diff changeset
24 #define RDF_DEADCODE_H
anatofuz
parents:
diff changeset
25
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
26 #include "llvm/CodeGen/RDFGraph.h"
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
27 #include "llvm/CodeGen/RDFLiveness.h"
150
anatofuz
parents:
diff changeset
28 #include "llvm/ADT/SetVector.h"
anatofuz
parents:
diff changeset
29
anatofuz
parents:
diff changeset
30 namespace llvm {
anatofuz
parents:
diff changeset
31 class MachineRegisterInfo;
anatofuz
parents:
diff changeset
32
anatofuz
parents:
diff changeset
33 namespace rdf {
anatofuz
parents:
diff changeset
34 struct DeadCodeElimination {
anatofuz
parents:
diff changeset
35 DeadCodeElimination(DataFlowGraph &dfg, MachineRegisterInfo &mri)
anatofuz
parents:
diff changeset
36 : Trace(false), DFG(dfg), MRI(mri), LV(mri, dfg) {}
anatofuz
parents:
diff changeset
37
anatofuz
parents:
diff changeset
38 bool collect();
anatofuz
parents:
diff changeset
39 bool erase(const SetVector<NodeId> &Nodes);
anatofuz
parents:
diff changeset
40 void trace(bool On) { Trace = On; }
anatofuz
parents:
diff changeset
41 bool trace() const { return Trace; }
anatofuz
parents:
diff changeset
42
anatofuz
parents:
diff changeset
43 SetVector<NodeId> getDeadNodes() { return DeadNodes; }
anatofuz
parents:
diff changeset
44 SetVector<NodeId> getDeadInstrs() { return DeadInstrs; }
anatofuz
parents:
diff changeset
45 DataFlowGraph &getDFG() { return DFG; }
anatofuz
parents:
diff changeset
46
anatofuz
parents:
diff changeset
47 private:
anatofuz
parents:
diff changeset
48 bool Trace;
anatofuz
parents:
diff changeset
49 SetVector<NodeId> LiveNodes;
anatofuz
parents:
diff changeset
50 SetVector<NodeId> DeadNodes;
anatofuz
parents:
diff changeset
51 SetVector<NodeId> DeadInstrs;
anatofuz
parents:
diff changeset
52 DataFlowGraph &DFG;
anatofuz
parents:
diff changeset
53 MachineRegisterInfo &MRI;
anatofuz
parents:
diff changeset
54 Liveness LV;
anatofuz
parents:
diff changeset
55
anatofuz
parents:
diff changeset
56 template<typename T> struct SetQueue;
anatofuz
parents:
diff changeset
57
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
58 bool isLiveInstr(NodeAddr<StmtNode*> S) const;
150
anatofuz
parents:
diff changeset
59 void scanInstr(NodeAddr<InstrNode*> IA, SetQueue<NodeId> &WorkQ);
anatofuz
parents:
diff changeset
60 void processDef(NodeAddr<DefNode*> DA, SetQueue<NodeId> &WorkQ);
anatofuz
parents:
diff changeset
61 void processUse(NodeAddr<UseNode*> UA, SetQueue<NodeId> &WorkQ);
anatofuz
parents:
diff changeset
62 };
anatofuz
parents:
diff changeset
63 } // namespace rdf
anatofuz
parents:
diff changeset
64 } // namespace llvm
anatofuz
parents:
diff changeset
65
anatofuz
parents:
diff changeset
66 #endif