[Alignment][NFC] Support compile time constants
[llvm-core.git] / include / llvm / CodeGen / MachinePostDominators.h
blobcb258b5e7b2170afb2e12d135ca5886828c73fbb
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.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CODEGEN_MACHINEPOSTDOMINATORS_H
15 #define LLVM_CODEGEN_MACHINEPOSTDOMINATORS_H
17 #include "llvm/CodeGen/MachineDominators.h"
18 #include "llvm/CodeGen/MachineFunctionPass.h"
19 #include <memory>
21 namespace llvm {
23 ///
24 /// MachinePostDominatorTree - an analysis pass wrapper for DominatorTree
25 /// used to compute the post-dominator tree for MachineFunctions.
26 ///
27 class MachinePostDominatorTree : public MachineFunctionPass {
28 using PostDomTreeT = PostDomTreeBase<MachineBasicBlock>;
29 std::unique_ptr<PostDomTreeT> PDT;
31 public:
32 static char ID;
34 MachinePostDominatorTree();
36 FunctionPass *createMachinePostDominatorTreePass();
38 const SmallVectorImpl<MachineBasicBlock *> &getRoots() const {
39 return PDT->getRoots();
42 MachineDomTreeNode *getRootNode() const { return PDT->getRootNode(); }
44 MachineDomTreeNode *operator[](MachineBasicBlock *BB) const {
45 return PDT->getNode(BB);
48 MachineDomTreeNode *getNode(MachineBasicBlock *BB) const {
49 return PDT->getNode(BB);
52 bool dominates(const MachineDomTreeNode *A,
53 const MachineDomTreeNode *B) const {
54 return PDT->dominates(A, B);
57 bool dominates(const MachineBasicBlock *A, const MachineBasicBlock *B) const {
58 return PDT->dominates(A, B);
61 bool properlyDominates(const MachineDomTreeNode *A,
62 const MachineDomTreeNode *B) const {
63 return PDT->properlyDominates(A, B);
66 bool properlyDominates(const MachineBasicBlock *A,
67 const MachineBasicBlock *B) const {
68 return PDT->properlyDominates(A, B);
71 bool isVirtualRoot(const MachineDomTreeNode *Node) const {
72 return PDT->isVirtualRoot(Node);
75 MachineBasicBlock *findNearestCommonDominator(MachineBasicBlock *A,
76 MachineBasicBlock *B) const {
77 return PDT->findNearestCommonDominator(A, B);
80 /// Returns the nearest common dominator of the given blocks.
81 /// If that tree node is a virtual root, a nullptr will be returned.
82 MachineBasicBlock *
83 findNearestCommonDominator(ArrayRef<MachineBasicBlock *> Blocks) const;
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;
91 } //end of namespace llvm
93 #endif