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