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 bool invalidate(MachineFunction &F, const PreservedAnalyses &PA,
34 MachineFunctionAnalysisManager::Invalidator &);
35};
36
37class MachineDominanceFrontierWrapperPass : public MachineFunctionPass {
38private:
39 MachineDominanceFrontier MDF;
40
41public:
42 MachineDominanceFrontierWrapperPass();
43
44 MachineDominanceFrontierWrapperPass(
45 const MachineDominanceFrontierWrapperPass &) = delete;
46 MachineDominanceFrontierWrapperPass &
47 operator=(const MachineDominanceFrontierWrapperPass &) = delete;
48
49 static char ID;
50
51 bool runOnMachineFunction(MachineFunction &F) override;
52
53 void getAnalysisUsage(AnalysisUsage &AU) const override;
54
55 void releaseMemory() override;
56
57 MachineDominanceFrontier &getMDF() { return MDF; }
58};
59
60class MachineDominanceFrontierAnalysis
61 : public AnalysisInfoMixin<MachineDominanceFrontierAnalysis> {
62 friend AnalysisInfoMixin<MachineDominanceFrontierAnalysis>;
63 static AnalysisKey Key;
64
65public:
66 using Result = MachineDominanceFrontier;
67
68 Result run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM);
69};
70
71} // end namespace llvm
72
73#endif // LLVM_CODEGEN_MACHINEDOMINANCEFRONTIER_H
74