Deleted Added
full compact
EdgeBundles.h (218893) EdgeBundles.h (221345)
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
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"
19#include "llvm/ADT/IntEqClasses.h"
20#include "llvm/CodeGen/MachineFunctionPass.h"
21
22namespace llvm {
23
24class EdgeBundles : public MachineFunctionPass {
25 const MachineFunction *MF;
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
20#include "llvm/ADT/IntEqClasses.h"
21#include "llvm/CodeGen/MachineFunctionPass.h"
22
23namespace llvm {
24
25class EdgeBundles : public MachineFunctionPass {
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.
34 SmallVector<SmallVector<unsigned, 8>, 4> Blocks;
35
32public:
33 static char ID;
34 EdgeBundles() : MachineFunctionPass(ID) {}
35
36 /// getBundle - Return the ingoing (Out = false) or outgoing (Out = true)
37 /// bundle number for basic block #N
38 unsigned getBundle(unsigned N, bool Out) const { return EC[2 * N + Out]; }
39
40 /// getNumBundles - Return the total number of bundles in the CFG.
41 unsigned getNumBundles() const { return EC.getNumClasses(); }
42
36public:
37 static char ID;
38 EdgeBundles() : MachineFunctionPass(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) { return Blocks[Bundle]; }
49
43 /// getMachineFunction - Return the last machine function computed.
44 const MachineFunction *getMachineFunction() const { return MF; }
45
46 /// view - Visualize the annotated bipartite CFG with Graphviz.
47 void view() const;
48
49private:
50 virtual bool runOnMachineFunction(MachineFunction&);
51 virtual void getAnalysisUsage(AnalysisUsage&) const;
52};
53
54/// Specialize WriteGraph, the standard implementation won't work.
55raw_ostream &WriteGraph(raw_ostream &O, const EdgeBundles &G,
56 bool ShortNames = false,
57 const std::string &Title = "");
58
59} // end namespace llvm
60
61#endif
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
56private:
57 virtual bool runOnMachineFunction(MachineFunction&);
58 virtual void getAnalysisUsage(AnalysisUsage&) const;
59};
60
61/// Specialize WriteGraph, the standard implementation won't work.
62raw_ostream &WriteGraph(raw_ostream &O, const EdgeBundles &G,
63 bool ShortNames = false,
64 const std::string &Title = "");
65
66} // end namespace llvm
67
68#endif