Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 14 | pmbaty | 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" |
||
| 19 | #include "llvm/ADT/IntEqClasses.h" |
||
| 20 | #include "llvm/CodeGen/MachineFunctionPass.h" |
||
| 21 | |||
| 22 | namespace llvm { |
||
| 23 | |||
| 24 | class 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 | |||
| 32 | /// Blocks - Map each bundle to a list of basic block numbers. |
||
| 33 | SmallVector<SmallVector<unsigned, 8>, 4> Blocks; |
||
| 34 | |||
| 35 | public: |
||
| 36 | static char ID; |
||
| 37 | EdgeBundles() : MachineFunctionPass(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 | |||
| 55 | private: |
||
| 56 | bool runOnMachineFunction(MachineFunction&) override; |
||
| 57 | void getAnalysisUsage(AnalysisUsage&) const override; |
||
| 58 | }; |
||
| 59 | |||
| 60 | } // end namespace llvm |
||
| 61 | |||
| 62 | #endif |