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
9#ifndef LLVM_CODEGEN_MACHINEDOMINANCEFRONTIER_H
10#define LLVM_CODEGEN_MACHINEDOMINANCEFRONTIER_H
11
12#include "llvm/Analysis/DominanceFrontier.h"
13#include "llvm/Analysis/DominanceFrontierImpl.h"
14#include "llvm/CodeGen/MachineBasicBlock.h"
15#include "llvm/CodeGen/MachineDominators.h"
16#include "llvm/CodeGen/MachineFunctionPass.h"
17#include "llvm/CodeGen/MachinePassManager.h"
18#include "llvm/Support/GenericDomTree.h"
19
20namespace llvm {
21
22class MachineDominanceFrontier
23 : public DominanceFrontierBase<MachineBasicBlock, false> {
24public:
25 using DomTreeT = DomTreeBase<MachineBasicBlock>;
26 using DomTreeNodeT = DomTreeNodeBase<MachineBasicBlock>;
27 using DomSetType = MachineDominanceFrontier::DomSetType;
28 using iterator = MachineDominanceFrontier::iterator;
29 using const_iterator = MachineDominanceFrontier ::const_iterator;
30
31 MachineDominanceFrontier() = default;
32
33 LLVM_ABI bool invalidate(MachineFunction &F, const PreservedAnalyses &PA,
34 MachineFunctionAnalysisManager::Invalidator &);
35};
36
37class LLVM_ABI MachineDominanceFrontierWrapperPass
38 : public MachineFunctionPass {
39private:
40 MachineDominanceFrontier MDF;
41
42 // TODO: This is to make the computation lazy and is unnecessary after the
43 // switch to new pass manager.
44 const MachineDominatorTree *PendingMDT = nullptr;
45
46public:
47 MachineDominanceFrontierWrapperPass();
48
49 MachineDominanceFrontierWrapperPass(
50 const MachineDominanceFrontierWrapperPass &) = delete;
51 MachineDominanceFrontierWrapperPass &
52 operator=(const MachineDominanceFrontierWrapperPass &) = delete;
53
54 static char ID;
55
56 bool runOnMachineFunction(MachineFunction &F) override;
57
58 void getAnalysisUsage(AnalysisUsage &AU) const override;
59
60 void releaseMemory() override;
61
62 MachineDominanceFrontier &getMDF();
63};
64
65class MachineDominanceFrontierAnalysis
66 : public AnalysisInfoMixin<MachineDominanceFrontierAnalysis> {
67 friend AnalysisInfoMixin<MachineDominanceFrontierAnalysis>;
68 static AnalysisKey Key;
69
70public:
71 using Result = MachineDominanceFrontier;
72
73 LLVM_ABI Result run(MachineFunction &MF,
74 MachineFunctionAnalysisManager &MFAM);
75};
76
77} // end namespace llvm
78
79#endif // LLVM_CODEGEN_MACHINEDOMINANCEFRONTIER_H
80