Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:32

0001 //===- llvm/CodeGen/MachinePostDominators.h ----------------------*- C++ -*-==//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file exposes interfaces to post dominance information for
0010 // target-specific code.
0011 //
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_CODEGEN_MACHINEPOSTDOMINATORS_H
0015 #define LLVM_CODEGEN_MACHINEPOSTDOMINATORS_H
0016 
0017 #include "llvm/CodeGen/MachineDominators.h"
0018 
0019 namespace llvm {
0020 
0021 extern template class DominatorTreeBase<MachineBasicBlock, true>; // PostDomTree
0022 
0023 namespace DomTreeBuilder {
0024 using MBBPostDomTree = PostDomTreeBase<MachineBasicBlock>;
0025 using MBBPostDomTreeGraphDiff = GraphDiff<MachineBasicBlock *, true>;
0026 
0027 extern template void Calculate<MBBPostDomTree>(MBBPostDomTree &DT);
0028 extern template void InsertEdge<MBBPostDomTree>(MBBPostDomTree &DT,
0029                                                 MachineBasicBlock *From,
0030                                                 MachineBasicBlock *To);
0031 extern template void DeleteEdge<MBBPostDomTree>(MBBPostDomTree &DT,
0032                                                 MachineBasicBlock *From,
0033                                                 MachineBasicBlock *To);
0034 extern template void ApplyUpdates<MBBPostDomTree>(MBBPostDomTree &DT,
0035                                                   MBBPostDomTreeGraphDiff &,
0036                                                   MBBPostDomTreeGraphDiff *);
0037 extern template bool
0038 Verify<MBBPostDomTree>(const MBBPostDomTree &DT,
0039                        MBBPostDomTree::VerificationLevel VL);
0040 } // namespace DomTreeBuilder
0041 
0042 ///
0043 /// MachinePostDominatorTree - an analysis pass wrapper for DominatorTree
0044 /// used to compute the post-dominator tree for MachineFunctions.
0045 ///
0046 class MachinePostDominatorTree : public PostDomTreeBase<MachineBasicBlock> {
0047   using Base = PostDomTreeBase<MachineBasicBlock>;
0048 
0049 public:
0050   MachinePostDominatorTree() = default;
0051 
0052   explicit MachinePostDominatorTree(MachineFunction &MF) { recalculate(MF); }
0053 
0054   /// Handle invalidation explicitly.
0055   bool invalidate(MachineFunction &, const PreservedAnalyses &PA,
0056                   MachineFunctionAnalysisManager::Invalidator &);
0057 
0058   /// Make findNearestCommonDominator(const NodeT *A, const NodeT *B) available.
0059   using Base::findNearestCommonDominator;
0060 
0061   /// Returns the nearest common dominator of the given blocks.
0062   /// If that tree node is a virtual root, a nullptr will be returned.
0063   MachineBasicBlock *
0064   findNearestCommonDominator(ArrayRef<MachineBasicBlock *> Blocks) const;
0065 };
0066 
0067 class MachinePostDominatorTreeAnalysis
0068     : public AnalysisInfoMixin<MachinePostDominatorTreeAnalysis> {
0069   friend AnalysisInfoMixin<MachinePostDominatorTreeAnalysis>;
0070 
0071   static AnalysisKey Key;
0072 
0073 public:
0074   using Result = MachinePostDominatorTree;
0075 
0076   Result run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM);
0077 };
0078 
0079 class MachinePostDominatorTreePrinterPass
0080     : public PassInfoMixin<MachinePostDominatorTreePrinterPass> {
0081   raw_ostream &OS;
0082 
0083 public:
0084   explicit MachinePostDominatorTreePrinterPass(raw_ostream &OS) : OS(OS) {}
0085   PreservedAnalyses run(MachineFunction &MF,
0086                         MachineFunctionAnalysisManager &MFAM);
0087   static bool isRequired() { return true; }
0088 };
0089 
0090 class MachinePostDominatorTreeWrapperPass : public MachineFunctionPass {
0091   std::optional<MachinePostDominatorTree> PDT;
0092 
0093 public:
0094   static char ID;
0095 
0096   MachinePostDominatorTreeWrapperPass();
0097 
0098   MachinePostDominatorTree &getPostDomTree() { return *PDT; }
0099   const MachinePostDominatorTree &getPostDomTree() const { return *PDT; }
0100 
0101   bool runOnMachineFunction(MachineFunction &MF) override;
0102   void getAnalysisUsage(AnalysisUsage &AU) const override;
0103   void releaseMemory() override { PDT.reset(); }
0104   void verifyAnalysis() const override;
0105   void print(llvm::raw_ostream &OS, const Module *M = nullptr) const override;
0106 };
0107 } //end of namespace llvm
0108 
0109 #endif