MachineDominanceFrontier.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. //===- llvm/CodeGen/MachineDominanceFrontier.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. #ifndef LLVM_CODEGEN_MACHINEDOMINANCEFRONTIER_H
  9. #define LLVM_CODEGEN_MACHINEDOMINANCEFRONTIER_H
  10. #include "llvm/Analysis/DominanceFrontier.h"
  11. #include "llvm/Analysis/DominanceFrontierImpl.h"
  12. #include "llvm/CodeGen/MachineBasicBlock.h"
  13. #include "llvm/CodeGen/MachineFunctionPass.h"
  14. #include "llvm/Support/GenericDomTree.h"
  15. namespace llvm {
  16. class MachineDominanceFrontier : public MachineFunctionPass {
  17. ForwardDominanceFrontierBase<MachineBasicBlock> Base;
  18. public:
  19. using DomTreeT = DomTreeBase<MachineBasicBlock>;
  20. using DomTreeNodeT = DomTreeNodeBase<MachineBasicBlock>;
  21. using DomSetType = DominanceFrontierBase<MachineBasicBlock, false>::DomSetType;
  22. using iterator = DominanceFrontierBase<MachineBasicBlock, false>::iterator;
  23. using const_iterator =
  24. DominanceFrontierBase<MachineBasicBlock, false>::const_iterator;
  25. MachineDominanceFrontier(const MachineDominanceFrontier &) = delete;
  26. MachineDominanceFrontier &operator=(const MachineDominanceFrontier &) = delete;
  27. static char ID;
  28. MachineDominanceFrontier();
  29. ForwardDominanceFrontierBase<MachineBasicBlock> &getBase() { return Base; }
  30. const SmallVectorImpl<MachineBasicBlock *> &getRoots() const {
  31. return Base.getRoots();
  32. }
  33. MachineBasicBlock *getRoot() const {
  34. return Base.getRoot();
  35. }
  36. bool isPostDominator() const {
  37. return Base.isPostDominator();
  38. }
  39. iterator begin() {
  40. return Base.begin();
  41. }
  42. const_iterator begin() const {
  43. return Base.begin();
  44. }
  45. iterator end() {
  46. return Base.end();
  47. }
  48. const_iterator end() const {
  49. return Base.end();
  50. }
  51. iterator find(MachineBasicBlock *B) {
  52. return Base.find(B);
  53. }
  54. const_iterator find(MachineBasicBlock *B) const {
  55. return Base.find(B);
  56. }
  57. iterator addBasicBlock(MachineBasicBlock *BB, const DomSetType &frontier) {
  58. return Base.addBasicBlock(BB, frontier);
  59. }
  60. void removeBlock(MachineBasicBlock *BB) {
  61. return Base.removeBlock(BB);
  62. }
  63. void addToFrontier(iterator I, MachineBasicBlock *Node) {
  64. return Base.addToFrontier(I, Node);
  65. }
  66. void removeFromFrontier(iterator I, MachineBasicBlock *Node) {
  67. return Base.removeFromFrontier(I, Node);
  68. }
  69. bool compareDomSet(DomSetType &DS1, const DomSetType &DS2) const {
  70. return Base.compareDomSet(DS1, DS2);
  71. }
  72. bool compare(DominanceFrontierBase<MachineBasicBlock, false> &Other) const {
  73. return Base.compare(Other);
  74. }
  75. bool runOnMachineFunction(MachineFunction &F) override;
  76. void releaseMemory() override;
  77. void getAnalysisUsage(AnalysisUsage &AU) const override;
  78. };
  79. } // end namespace llvm
  80. #endif // LLVM_CODEGEN_MACHINEDOMINANCEFRONTIER_H