LLVM  9.0.0svn
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 // leaving a 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"
19 #include "llvm/ADT/IntEqClasses.h"
20 #include "llvm/ADT/Twine.h"
22 
23 namespace llvm {
24 
26  const MachineFunction *MF;
27 
28  /// EC - Each edge bundle is an equivalence class. The keys are:
29  /// 2*BB->getNumber() -> Ingoing bundle.
30  /// 2*BB->getNumber()+1 -> Outgoing bundle.
31  IntEqClasses EC;
32 
33  /// Blocks - Map each bundle to a list of basic block numbers.
35 
36 public:
37  static char ID;
39 
40  /// getBundle - Return the ingoing (Out = false) or outgoing (Out = true)
41  /// bundle number for basic block #N
42  unsigned getBundle(unsigned N, bool Out) const { return EC[2 * N + Out]; }
43 
44  /// getNumBundles - Return the total number of bundles in the CFG.
45  unsigned getNumBundles() const { return EC.getNumClasses(); }
46 
47  /// getBlocks - Return an array of blocks that are connected to Bundle.
48  ArrayRef<unsigned> getBlocks(unsigned Bundle) const { return Blocks[Bundle]; }
49 
50  /// getMachineFunction - Return the last machine function computed.
51  const MachineFunction *getMachineFunction() const { return MF; }
52 
53  /// view - Visualize the annotated bipartite CFG with Graphviz.
54  void view() const;
55 
56 private:
57  bool runOnMachineFunction(MachineFunction&) override;
58  void getAnalysisUsage(AnalysisUsage&) const override;
59 };
60 
61 } // end namespace llvm
62 
63 #endif
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:42
This class represents lattice values for constants.
Definition: AllocatorList.h:23
ArrayRef< unsigned > getBlocks(unsigned Bundle) const
getBlocks - Return an array of blocks that are connected to Bundle.
Definition: EdgeBundles.h:48
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
static char ID
Definition: EdgeBundles.h:37
unsigned getNumClasses() const
getNumClasses - Return the number of equivalence classes after compress() was called.
Definition: IntEqClasses.h:71
Represent the analysis usage information of a pass.
void view() const
view - Visualize the annotated bipartite CFG with Graphviz.
Definition: EdgeBundles.cpp:99
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:845
const MachineFunction * getMachineFunction() const
getMachineFunction - Return the last machine function computed.
Definition: EdgeBundles.h:51
unsigned getNumBundles() const
getNumBundles - Return the total number of bundles in the CFG.
Definition: EdgeBundles.h:45
#define N