LLVM 20.0.0git
EdgeBundles.h
Go to the documentation of this file.
1//===-------- EdgeBundles.h - Bundles of CFG edges --------------*- 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// The EdgeBundles analysis forms equivalence classes of CFG edges such that all
10// edges leaving a machine basic block are in the same bundle, and all edges
11// entering a machine basic block are in the same bundle.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CODEGEN_EDGEBUNDLES_H
16#define LLVM_CODEGEN_EDGEBUNDLES_H
17
18#include "llvm/ADT/ArrayRef.h"
21#include "llvm/IR/PassManager.h"
22
23namespace llvm {
24class EdgeBundlesWrapperLegacy;
25class EdgeBundlesAnalysis;
26
29 friend class EdgeBundlesAnalysis;
30
31 const MachineFunction *MF = nullptr;
32
33 /// EC - Each edge bundle is an equivalence class. The keys are:
34 /// 2*BB->getNumber() -> Ingoing bundle.
35 /// 2*BB->getNumber()+1 -> Outgoing bundle.
36 IntEqClasses EC;
37
38 /// Blocks - Map each bundle to a list of basic block numbers.
40
41 void init();
43
44public:
45 /// getBundle - Return the ingoing (Out = false) or outgoing (Out = true)
46 /// bundle number for basic block #N
47 unsigned getBundle(unsigned N, bool Out) const { return EC[2 * N + Out]; }
48
49 /// getNumBundles - Return the total number of bundles in the CFG.
50 unsigned getNumBundles() const { return EC.getNumClasses(); }
51
52 /// getBlocks - Return an array of blocks that are connected to Bundle.
53 ArrayRef<unsigned> getBlocks(unsigned Bundle) const { return Blocks[Bundle]; }
54
55 /// getMachineFunction - Return the last machine function computed.
56 const MachineFunction *getMachineFunction() const { return MF; }
57
58 /// view - Visualize the annotated bipartite CFG with Graphviz.
59 void view() const;
60
61 // Handle invalidation for the new pass manager
64};
65
67public:
68 static char ID;
70
71 EdgeBundles &getEdgeBundles() { return *Impl; }
72 const EdgeBundles &getEdgeBundles() const { return *Impl; }
73
74private:
75 std::unique_ptr<EdgeBundles> Impl;
76 bool runOnMachineFunction(MachineFunction &MF) override;
77 void getAnalysisUsage(AnalysisUsage&) const override;
78};
79
80class EdgeBundlesAnalysis : public AnalysisInfoMixin<EdgeBundlesAnalysis> {
82 static AnalysisKey Key;
83
84public:
87};
88
89} // end namespace llvm
90
91#endif
DenseMap< Block *, BlockRelaxAux > Blocks
Definition: ELF_riscv.cpp:507
This header defines various interfaces for pass management in LLVM.
Equivalence classes for small integers.
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:292
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:253
Represent the analysis usage information of a pass.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
EdgeBundles run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Definition: EdgeBundles.cpp:44
EdgeBundles & getEdgeBundles()
Definition: EdgeBundles.h:71
const EdgeBundles & getEdgeBundles() const
Definition: EdgeBundles.h:72
bool invalidate(MachineFunction &MF, const PreservedAnalyses &PA, MachineFunctionAnalysisManager::Invalidator &Inv)
ArrayRef< unsigned > getBlocks(unsigned Bundle) const
getBlocks - Return an array of blocks that are connected to Bundle.
Definition: EdgeBundles.h:53
const MachineFunction * getMachineFunction() const
getMachineFunction - Return the last machine function computed.
Definition: EdgeBundles.h:56
unsigned getBundle(unsigned N, bool Out) const
getBundle - Return the ingoing (Out = false) or outgoing (Out = true) bundle number for basic block N
Definition: EdgeBundles.h:47
unsigned getNumBundles() const
getNumBundles - Return the total number of bundles in the CFG.
Definition: EdgeBundles.h:50
void view() const
view - Visualize the annotated bipartite CFG with Graphviz.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
A set of analyses that are preserved following a run of a transformation pass.
Definition: Analysis.h:111
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1196
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
#define N
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:92
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: Analysis.h:28