Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.4 KiB

  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. #ifndef LLVM_CODEGEN_EDGEBUNDLES_H
  16. #define LLVM_CODEGEN_EDGEBUNDLES_H
  17. #include "llvm/ADT/ArrayRef.h"
  18. #include "llvm/ADT/IntEqClasses.h"
  19. #include "llvm/ADT/Twine.h"
  20. #include "llvm/CodeGen/MachineFunctionPass.h"
  21. namespace llvm {
  22. class EdgeBundles : public MachineFunctionPass {
  23. const MachineFunction *MF;
  24. /// EC - Each edge bundle is an equivalence class. The keys are:
  25. /// 2*BB->getNumber() -> Ingoing bundle.
  26. /// 2*BB->getNumber()+1 -> Outgoing bundle.
  27. IntEqClasses EC;
  28. /// Blocks - Map each bundle to a list of basic block numbers.
  29. SmallVector<SmallVector<unsigned, 8>, 4> Blocks;
  30. public:
  31. static char ID;
  32. EdgeBundles() : MachineFunctionPass(ID) {}
  33. /// getBundle - Return the ingoing (Out = false) or outgoing (Out = true)
  34. /// bundle number for basic block #N
  35. unsigned getBundle(unsigned N, bool Out) const { return EC[2 * N + Out]; }
  36. /// getNumBundles - Return the total number of bundles in the CFG.
  37. unsigned getNumBundles() const { return EC.getNumClasses(); }
  38. /// getBlocks - Return an array of blocks that are connected to Bundle.
  39. ArrayRef<unsigned> getBlocks(unsigned Bundle) const { return Blocks[Bundle]; }
  40. /// getMachineFunction - Return the last machine function computed.
  41. const MachineFunction *getMachineFunction() const { return MF; }
  42. /// view - Visualize the annotated bipartite CFG with Graphviz.
  43. void view() const;
  44. private:
  45. virtual bool runOnMachineFunction(MachineFunction&);
  46. virtual void getAnalysisUsage(AnalysisUsage&) const;
  47. };
  48. /// Specialize WriteGraph, the standard implementation won't work.
  49. raw_ostream &WriteGraph(raw_ostream &O, const EdgeBundles &G,
  50. bool ShortNames = false,
  51. const Twine &Title = "");
  52. } // end namespace llvm
  53. #endif