LLVM  8.0.1
EdgeBundles.h
Go to the documentation of this file.
1 //===-------- EdgeBundles.h - Bundles of CFG edges --------------*- c++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // The EdgeBundles analysis forms equivalence classes of CFG edges such that all
11 // edges leaving a machine basic block are in the same bundle, and all edges
12 // leaving a basic block are in the same bundle.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_CODEGEN_EDGEBUNDLES_H
17 #define LLVM_CODEGEN_EDGEBUNDLES_H
18 
19 #include "llvm/ADT/ArrayRef.h"
20 #include "llvm/ADT/IntEqClasses.h"
21 #include "llvm/ADT/Twine.h"
23 
24 namespace llvm {
25 
27  const MachineFunction *MF;
28 
29  /// EC - Each edge bundle is an equivalence class. The keys are:
30  /// 2*BB->getNumber() -> Ingoing bundle.
31  /// 2*BB->getNumber()+1 -> Outgoing bundle.
32  IntEqClasses EC;
33 
34  /// Blocks - Map each bundle to a list of basic block numbers.
36 
37 public:
38  static char ID;
40 
41  /// getBundle - Return the ingoing (Out = false) or outgoing (Out = true)
42  /// bundle number for basic block #N
43  unsigned getBundle(unsigned N, bool Out) const { return EC[2 * N + Out]; }
44 
45  /// getNumBundles - Return the total number of bundles in the CFG.
46  unsigned getNumBundles() const { return EC.getNumClasses(); }
47 
48  /// getBlocks - Return an array of blocks that are connected to Bundle.
49  ArrayRef<unsigned> getBlocks(unsigned Bundle) const { return Blocks[Bundle]; }
50 
51  /// getMachineFunction - Return the last machine function computed.
52  const MachineFunction *getMachineFunction() const { return MF; }
53 
54  /// view - Visualize the annotated bipartite CFG with Graphviz.
55  void view() const;
56 
57 private:
58  bool runOnMachineFunction(MachineFunction&) override;
59  void getAnalysisUsage(AnalysisUsage&) const override;
60 };
61 
62 } // end namespace llvm
63 
64 #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:43
This class represents lattice values for constants.
Definition: AllocatorList.h:24
ArrayRef< unsigned > getBlocks(unsigned Bundle) const
getBlocks - Return an array of blocks that are connected to Bundle.
Definition: EdgeBundles.h:49
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
static char ID
Definition: EdgeBundles.h:38
unsigned getNumClasses() const
getNumClasses - Return the number of equivalence classes after compress() was called.
Definition: IntEqClasses.h:72
Represent the analysis usage information of a pass.
void view() const
view - Visualize the annotated bipartite CFG with Graphviz.
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:847
const MachineFunction * getMachineFunction() const
getMachineFunction - Return the last machine function computed.
Definition: EdgeBundles.h:52
unsigned getNumBundles() const
getNumBundles - Return the total number of bundles in the CFG.
Definition: EdgeBundles.h:46
#define N