MachinePostDominators.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. //=- llvm/CodeGen/MachineDominators.h ----------------------------*- C++ -*-==//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // This file exposes interfaces to post dominance information for
  11. // target-specific code.
  12. //
  13. //===----------------------------------------------------------------------===//
  14. #ifndef LLVM_CODEGEN_MACHINEPOSTDOMINATORS_H
  15. #define LLVM_CODEGEN_MACHINEPOSTDOMINATORS_H
  16. #include "llvm/CodeGen/MachineDominators.h"
  17. #include "llvm/CodeGen/MachineFunctionPass.h"
  18. namespace llvm {
  19. ///
  20. /// PostDominatorTree Class - Concrete subclass of DominatorTree that is used
  21. /// to compute the post-dominator tree.
  22. ///
  23. struct MachinePostDominatorTree : public MachineFunctionPass {
  24. private:
  25. DominatorTreeBase<MachineBasicBlock> *DT;
  26. public:
  27. static char ID;
  28. MachinePostDominatorTree();
  29. ~MachinePostDominatorTree() override;
  30. FunctionPass *createMachinePostDominatorTreePass();
  31. const std::vector<MachineBasicBlock *> &getRoots() const {
  32. return DT->getRoots();
  33. }
  34. MachineDomTreeNode *getRootNode() const {
  35. return DT->getRootNode();
  36. }
  37. MachineDomTreeNode *operator[](MachineBasicBlock *BB) const {
  38. return DT->getNode(BB);
  39. }
  40. MachineDomTreeNode *getNode(MachineBasicBlock *BB) const {
  41. return DT->getNode(BB);
  42. }
  43. bool dominates(const MachineDomTreeNode *A,
  44. const MachineDomTreeNode *B) const {
  45. return DT->dominates(A, B);
  46. }
  47. bool dominates(const MachineBasicBlock *A, const MachineBasicBlock *B) const {
  48. return DT->dominates(A, B);
  49. }
  50. bool properlyDominates(const MachineDomTreeNode *A,
  51. const MachineDomTreeNode *B) const {
  52. return DT->properlyDominates(A, B);
  53. }
  54. bool properlyDominates(const MachineBasicBlock *A,
  55. const MachineBasicBlock *B) const {
  56. return DT->properlyDominates(A, B);
  57. }
  58. MachineBasicBlock *findNearestCommonDominator(MachineBasicBlock *A,
  59. MachineBasicBlock *B) {
  60. return DT->findNearestCommonDominator(A, B);
  61. }
  62. bool runOnMachineFunction(MachineFunction &MF) override;
  63. void getAnalysisUsage(AnalysisUsage &AU) const override;
  64. void print(llvm::raw_ostream &OS, const Module *M = nullptr) const override;
  65. };
  66. } //end of namespace llvm
  67. #endif