MachinePostDominators.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //===- MachinePostDominators.cpp -Machine Post Dominator Calculation ------===//
  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 implements simple dominator construction algorithms for finding
  10. // post dominators on machine functions.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #include "llvm/CodeGen/MachinePostDominators.h"
  14. using namespace llvm;
  15. namespace llvm {
  16. template class DominatorTreeBase<MachineBasicBlock, true>; // PostDomTreeBase
  17. }
  18. char MachinePostDominatorTree::ID = 0;
  19. //declare initializeMachinePostDominatorTreePass
  20. INITIALIZE_PASS(MachinePostDominatorTree, "machinepostdomtree",
  21. "MachinePostDominator Tree Construction", true, true)
  22. MachinePostDominatorTree::MachinePostDominatorTree() : MachineFunctionPass(ID) {
  23. initializeMachinePostDominatorTreePass(*PassRegistry::getPassRegistry());
  24. DT = new PostDomTreeBase<MachineBasicBlock>();
  25. }
  26. FunctionPass *
  27. MachinePostDominatorTree::createMachinePostDominatorTreePass() {
  28. return new MachinePostDominatorTree();
  29. }
  30. bool
  31. MachinePostDominatorTree::runOnMachineFunction(MachineFunction &F) {
  32. DT->recalculate(F);
  33. return false;
  34. }
  35. MachinePostDominatorTree::~MachinePostDominatorTree() {
  36. delete DT;
  37. }
  38. void
  39. MachinePostDominatorTree::getAnalysisUsage(AnalysisUsage &AU) const {
  40. AU.setPreservesAll();
  41. MachineFunctionPass::getAnalysisUsage(AU);
  42. }
  43. void
  44. MachinePostDominatorTree::print(llvm::raw_ostream &OS, const Module *M) const {
  45. DT->print(OS);
  46. }