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
22namespace llvm {
23
25 const MachineFunction *MF = nullptr;
26
27 /// EC - Each edge bundle is an equivalence class. The keys are:
28 /// 2*BB->getNumber() -> Ingoing bundle.
29 /// 2*BB->getNumber()+1 -> Outgoing bundle.
30 IntEqClasses EC;
31
32 /// Blocks - Map each bundle to a list of basic block numbers.
34
35public:
36 static char ID;
38
39 /// getBundle - Return the ingoing (Out = false) or outgoing (Out = true)
40 /// bundle number for basic block #N
41 unsigned getBundle(unsigned N, bool Out) const { return EC[2 * N + Out]; }
42
43 /// getNumBundles - Return the total number of bundles in the CFG.
44 unsigned getNumBundles() const { return EC.getNumClasses(); }
45
46 /// getBlocks - Return an array of blocks that are connected to Bundle.
47 ArrayRef<unsigned> getBlocks(unsigned Bundle) const { return Blocks[Bundle]; }
48
49 /// getMachineFunction - Return the last machine function computed.
50 const MachineFunction *getMachineFunction() const { return MF; }
51
52 /// view - Visualize the annotated bipartite CFG with Graphviz.
53 void view() const;
54
55private:
56 bool runOnMachineFunction(MachineFunction&) override;
57 void getAnalysisUsage(AnalysisUsage&) const override;
58};
59
60} // end namespace llvm
61
62#endif
DenseMap< Block *, BlockRelaxAux > Blocks
Definition: ELF_riscv.cpp:507
Equivalence classes for small integers.
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
ArrayRef< unsigned > getBlocks(unsigned Bundle) const
getBlocks - Return an array of blocks that are connected to Bundle.
Definition: EdgeBundles.h:47
const MachineFunction * getMachineFunction() const
getMachineFunction - Return the last machine function computed.
Definition: EdgeBundles.h:50
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:41
unsigned getNumBundles() const
getNumBundles - Return the total number of bundles in the CFG.
Definition: EdgeBundles.h:44
void view() const
view - Visualize the annotated bipartite CFG with Graphviz.
Definition: EdgeBundles.cpp:99
static char ID
Definition: EdgeBundles.h:36
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1209
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
#define N