LLVM  14.0.0git
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  if (!PDT)
38  PDT.reset(new PostDomTreeT());
39  return *PDT;
40  }
41 
43 
44  MachineDomTreeNode *getRootNode() const { return PDT->getRootNode(); }
45 
47  return PDT->getNode(BB);
48  }
49 
51  return PDT->getNode(BB);
52  }
53 
55  const MachineDomTreeNode *B) const {
56  return PDT->dominates(A, B);
57  }
58 
59  bool dominates(const MachineBasicBlock *A, const MachineBasicBlock *B) const {
60  return PDT->dominates(A, B);
61  }
62 
64  const MachineDomTreeNode *B) const {
65  return PDT->properlyDominates(A, B);
66  }
67 
69  const MachineBasicBlock *B) const {
70  return PDT->properlyDominates(A, B);
71  }
72 
73  bool isVirtualRoot(const MachineDomTreeNode *Node) const {
74  return PDT->isVirtualRoot(Node);
75  }
76 
78  MachineBasicBlock *B) const {
79  return PDT->findNearestCommonDominator(A, B);
80  }
81 
82  /// Returns the nearest common dominator of the given blocks.
83  /// If that tree node is a virtual root, a nullptr will be returned.
86 
87  bool runOnMachineFunction(MachineFunction &MF) override;
88  void getAnalysisUsage(AnalysisUsage &AU) const override;
89  void releaseMemory() override { PDT.reset(nullptr); }
90  void verifyAnalysis() const override;
91  void print(llvm::raw_ostream &OS, const Module *M = nullptr) const override;
92 };
93 } //end of namespace llvm
94 
95 #endif
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::MachinePostDominatorTree::properlyDominates
bool properlyDominates(const MachineDomTreeNode *A, const MachineDomTreeNode *B) const
Definition: MachinePostDominators.h:63
llvm::MachinePostDominatorTree::properlyDominates
bool properlyDominates(const MachineBasicBlock *A, const MachineBasicBlock *B) const
Definition: MachinePostDominators.h:68
llvm::MachineFunctionPass
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
Definition: MachineFunctionPass.h:30
llvm::MachinePostDominatorTree::getRootNode
MachineDomTreeNode * getRootNode() const
Definition: MachinePostDominators.h:44
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition: PassAnalysisSupport.h:47
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::MachinePostDominatorTree::getNode
MachineDomTreeNode * getNode(MachineBasicBlock *BB) const
Definition: MachinePostDominators.h:50
llvm::MachineBasicBlock
Definition: MachineBasicBlock.h:95
llvm::MachinePostDominatorTree::operator[]
MachineDomTreeNode * operator[](MachineBasicBlock *BB) const
Definition: MachinePostDominators.h:46
llvm::MachinePostDominatorTree::releaseMemory
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
Definition: MachinePostDominators.h:89
MachineFunctionPass.h
llvm::MachinePostDominatorTree::createMachinePostDominatorTreePass
FunctionPass * createMachinePostDominatorTreePass()
Definition: MachinePostDominators.cpp:36
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
llvm::MachinePostDominatorTree::print
void print(llvm::raw_ostream &OS, const Module *M=nullptr) const override
print - Print out the internal state of the pass.
Definition: MachinePostDominators.cpp:76
llvm::MachineFunction
Definition: MachineFunction.h:230
llvm::DominatorTreeBase::reset
void reset()
Definition: GenericDomTree.h:806
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::MachinePostDominatorTree::ID
static char ID
Definition: MachinePostDominators.h:32
llvm::DominatorTreeBase
Core dominator tree base class.
Definition: LoopInfo.h:65
llvm::MachinePostDominatorTree::verifyAnalysis
void verifyAnalysis() const override
verifyAnalysis() - This member can be implemented by a analysis pass to check state of analysis infor...
Definition: MachinePostDominators.cpp:67
Node
Definition: ItaniumDemangle.h:235
llvm::MachinePostDominatorTree::getAnalysisUsage
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Definition: MachinePostDominators.cpp:46
llvm::DomTreeNodeBase
Base class for the actual dominator tree node.
Definition: LiveIntervalCalc.h:24
llvm::MachinePostDominatorTree
MachinePostDominatorTree - an analysis pass wrapper for DominatorTree used to compute the post-domina...
Definition: MachinePostDominators.h:27
llvm::MachinePostDominatorTree::dominates
bool dominates(const MachineDomTreeNode *A, const MachineDomTreeNode *B) const
Definition: MachinePostDominators.h:54
llvm::MachinePostDominatorTree::getBase
PostDomTreeT & getBase()
Definition: MachinePostDominators.h:36
llvm::MachinePostDominatorTree::MachinePostDominatorTree
MachinePostDominatorTree()
llvm::MachinePostDominatorTree::runOnMachineFunction
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
Definition: MachinePostDominators.cpp:40
llvm::FunctionPass
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:298
BB
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
Definition: README.txt:39
llvm::MachinePostDominatorTree::findNearestCommonDominator
MachineBasicBlock * findNearestCommonDominator(MachineBasicBlock *A, MachineBasicBlock *B) const
Definition: MachinePostDominators.h:77
llvm::MachinePostDominatorTree::isVirtualRoot
bool isVirtualRoot(const MachineDomTreeNode *Node) const
Definition: MachinePostDominators.h:73
llvm::MachinePostDominatorTree::dominates
bool dominates(const MachineBasicBlock *A, const MachineBasicBlock *B) const
Definition: MachinePostDominators.h:59
MachineDominators.h