Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //===- llvm/CodeGen/MachineDomTreeUpdater.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_MACHINEDOMTREEUPDATER_H
0015 #define LLVM_CODEGEN_MACHINEDOMTREEUPDATER_H
0016 
0017 #include "llvm/Analysis/GenericDomTreeUpdater.h"
0018 #include "llvm/CodeGen/MachineDominators.h"
0019 
0020 namespace llvm {
0021 
0022 class MachinePostDominatorTree;
0023 
0024 class MachineDomTreeUpdater
0025     : public GenericDomTreeUpdater<MachineDomTreeUpdater, MachineDominatorTree,
0026                                    MachinePostDominatorTree> {
0027   friend GenericDomTreeUpdater<MachineDomTreeUpdater, MachineDominatorTree,
0028                                MachinePostDominatorTree>;
0029 
0030 public:
0031   using Base =
0032       GenericDomTreeUpdater<MachineDomTreeUpdater, MachineDominatorTree,
0033                             MachinePostDominatorTree>;
0034   using Base::Base;
0035 
0036   ~MachineDomTreeUpdater() { flush(); }
0037 
0038   ///@{
0039   /// \name Mutation APIs
0040   ///
0041 
0042   /// Delete DelBB. DelBB will be removed from its Parent and
0043   /// erased from available trees if it exists and finally get deleted.
0044   /// Under Eager UpdateStrategy, DelBB will be processed immediately.
0045   /// Under Lazy UpdateStrategy, DelBB will be queued until a flush event and
0046   /// all available trees are up-to-date. Assert if any instruction of DelBB is
0047   /// modified while awaiting deletion. When both DT and PDT are nullptrs, DelBB
0048   /// will be queued until flush() is called.
0049   void deleteBB(MachineBasicBlock *DelBB);
0050 
0051   ///@}
0052 
0053 private:
0054   /// First remove all the instructions of DelBB and then make sure DelBB has a
0055   /// valid terminator instruction which is necessary to have when DelBB still
0056   /// has to be inside of its parent Function while awaiting deletion under Lazy
0057   /// UpdateStrategy to prevent other routines from asserting the state of the
0058   /// IR is inconsistent. Assert if DelBB is nullptr or has predecessors.
0059   void validateDeleteBB(MachineBasicBlock *DelBB);
0060 
0061   /// Returns true if at least one MachineBasicBlock is deleted.
0062   bool forceFlushDeletedBB();
0063 };
0064 
0065 extern template class GenericDomTreeUpdater<
0066     MachineDomTreeUpdater, MachineDominatorTree, MachinePostDominatorTree>;
0067 
0068 extern template void
0069 GenericDomTreeUpdater<MachineDomTreeUpdater, MachineDominatorTree,
0070                       MachinePostDominatorTree>::recalculate(MachineFunction
0071                                                                  &MF);
0072 
0073 extern template void GenericDomTreeUpdater<
0074     MachineDomTreeUpdater, MachineDominatorTree,
0075     MachinePostDominatorTree>::applyUpdatesImpl</*IsForward=*/true>();
0076 extern template void GenericDomTreeUpdater<
0077     MachineDomTreeUpdater, MachineDominatorTree,
0078     MachinePostDominatorTree>::applyUpdatesImpl</*IsForward=*/false>();
0079 } // namespace llvm
0080 #endif // LLVM_CODEGEN_MACHINEDOMTREEUPDATER_H