LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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  virtual bool runOnMachineFunction(MachineFunction&);
59  virtual void getAnalysisUsage(AnalysisUsage&) const;
60 };
61 
62 /// Specialize WriteGraph, the standard implementation won't work.
63 raw_ostream &WriteGraph(raw_ostream &O, const EdgeBundles &G,
64  bool ShortNames = false,
65  const Twine &Title = "");
66 
67 } // end namespace llvm
68 
69 #endif
raw_ostream & WriteGraph(raw_ostream &O, const EdgeBundles &G, bool ShortNames=false, const Twine &Title="")
Specialize WriteGraph, the standard implementation won't work.
Definition: EdgeBundles.cpp:78
void view() const
view - Visualize the annotated bipartite CFG with Graphviz.
Definition: EdgeBundles.cpp:73
unsigned getNumBundles() const
getNumBundles - Return the total number of bundles in the CFG.
Definition: EdgeBundles.h:46
const MachineFunction * getMachineFunction() const
getMachineFunction - Return the last machine function computed.
Definition: EdgeBundles.h:52
#define G(x, y, z)
Definition: MD5.cpp:52
static char ID
Definition: EdgeBundles.h:38
ArrayRef< unsigned > getBlocks(unsigned Bundle) const
getBlocks - Return an array of blocks that are connected to Bundle.
Definition: EdgeBundles.h:49
#define N
unsigned getBundle(unsigned N, bool Out) const
Definition: EdgeBundles.h:43
unsigned getNumClasses() const
Definition: IntEqClasses.h:72