LLVM  10.0.0svn
MachinePostDominators.h
Go to the documentation of this file.
1 //===- llvm/CodeGen/MachinePostDominators.h ----------------------*- C++ -*-==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file exposes interfaces to post dominance information for
10 // target-specific code.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CODEGEN_MACHINEPOSTDOMINATORS_H
15 #define LLVM_CODEGEN_MACHINEPOSTDOMINATORS_H
16 
19 #include <memory>
20 
21 namespace llvm {
22 
23 ///
24 /// MachinePostDominatorTree - an analysis pass wrapper for DominatorTree
25 /// used to compute the post-dominator tree for MachineFunctions.
26 ///
29  std::unique_ptr<PostDomTreeT> PDT;
30 
31 public:
32  static char ID;
33 
35 
37 
39  return PDT->getRoots();
40  }
41 
42  MachineDomTreeNode *getRootNode() const { return PDT->getRootNode(); }
43 
45  return PDT->getNode(BB);
46  }
47 
49  return PDT->getNode(BB);
50  }
51 
53  const MachineDomTreeNode *B) const {
54  return PDT->dominates(A, B);
55  }
56 
57  bool dominates(const MachineBasicBlock *A, const MachineBasicBlock *B) const {
58  return PDT->dominates(A, B);
59  }
60 
62  const MachineDomTreeNode *B) const {
63  return PDT->properlyDominates(A, B);
64  }
65 
67  const MachineBasicBlock *B) const {
68  return PDT->properlyDominates(A, B);
69  }
70 
71  bool isVirtualRoot(const MachineDomTreeNode *Node) const {
72  return PDT->isVirtualRoot(Node);
73  }
74 
76  MachineBasicBlock *B) const {
77  return PDT->findNearestCommonDominator(A, B);
78  }
79 
80  /// Returns the nearest common dominator of the given blocks.
81  /// If that tree node is a virtual root, a nullptr will be returned.
84 
85  bool runOnMachineFunction(MachineFunction &MF) override;
86  void getAnalysisUsage(AnalysisUsage &AU) const override;
87  void releaseMemory() override { PDT.reset(nullptr); }
88  void verifyAnalysis() const override;
89  void print(llvm::raw_ostream &OS, const Module *M = nullptr) const override;
90 };
91 } //end of namespace llvm
92 
93 #endif
void print(llvm::raw_ostream &OS, const Module *M=nullptr) const override
print - Print out the internal state of the pass.
const SmallVectorImpl< MachineBasicBlock * > & getRoots() const
bool dominates(const MachineDomTreeNode *A, const MachineDomTreeNode *B) const
This class represents lattice values for constants.
Definition: AllocatorList.h:23
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:65
MachineDomTreeNode * operator[](MachineBasicBlock *BB) const
MachineDomTreeNode * getNode(MachineBasicBlock *BB) const
FunctionPass * createMachinePostDominatorTreePass()
void verifyAnalysis() const override
verifyAnalysis() - This member can be implemented by a analysis pass to check state of analysis infor...
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:41
Base class for the actual dominator tree node.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:32
MachineBasicBlock * findNearestCommonDominator(MachineBasicBlock *A, MachineBasicBlock *B) const
bool dominates(const MachineBasicBlock *A, const MachineBasicBlock *B) const
Core dominator tree base class.
Definition: LoopInfo.h:66
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
bool properlyDominates(const MachineBasicBlock *A, const MachineBasicBlock *B) const
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:284
MachineDomTreeNode * getRootNode() const
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
bool properlyDominates(const MachineDomTreeNode *A, const MachineDomTreeNode *B) const
MachinePostDominatorTree - an analysis pass wrapper for DominatorTree used to compute the post-domina...
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
bool isVirtualRoot(const MachineDomTreeNode *Node) const