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.

100 lines
2.9 KiB

  1. //===---- LatencyPriorityQueue.h - A latency-oriented priority queue ------===//
  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. // This file declares the LatencyPriorityQueue class, which is a
  11. // SchedulingPriorityQueue that schedules using latency information to
  12. // reduce the length of the critical path through the basic block.
  13. //
  14. //===----------------------------------------------------------------------===//
  15. #ifndef LLVM_CODEGEN_LATENCYPRIORITYQUEUE_H
  16. #define LLVM_CODEGEN_LATENCYPRIORITYQUEUE_H
  17. #include "llvm/CodeGen/ScheduleDAG.h"
  18. namespace llvm {
  19. class LatencyPriorityQueue;
  20. /// Sorting functions for the Available queue.
  21. struct latency_sort : public std::binary_function<SUnit*, SUnit*, bool> {
  22. LatencyPriorityQueue *PQ;
  23. explicit latency_sort(LatencyPriorityQueue *pq) : PQ(pq) {}
  24. bool operator()(const SUnit* left, const SUnit* right) const;
  25. };
  26. class LatencyPriorityQueue : public SchedulingPriorityQueue {
  27. // SUnits - The SUnits for the current graph.
  28. std::vector<SUnit> *SUnits;
  29. /// NumNodesSolelyBlocking - This vector contains, for every node in the
  30. /// Queue, the number of nodes that the node is the sole unscheduled
  31. /// predecessor for. This is used as a tie-breaker heuristic for better
  32. /// mobility.
  33. std::vector<unsigned> NumNodesSolelyBlocking;
  34. /// Queue - The queue.
  35. std::vector<SUnit*> Queue;
  36. latency_sort Picker;
  37. public:
  38. LatencyPriorityQueue() : Picker(this) {
  39. }
  40. bool isBottomUp() const { return false; }
  41. void initNodes(std::vector<SUnit> &sunits) {
  42. SUnits = &sunits;
  43. NumNodesSolelyBlocking.resize(SUnits->size(), 0);
  44. }
  45. void addNode(const SUnit *SU) {
  46. NumNodesSolelyBlocking.resize(SUnits->size(), 0);
  47. }
  48. void updateNode(const SUnit *SU) {
  49. }
  50. void releaseState() {
  51. SUnits = 0;
  52. }
  53. unsigned getLatency(unsigned NodeNum) const {
  54. assert(NodeNum < (*SUnits).size());
  55. return (*SUnits)[NodeNum].getHeight();
  56. }
  57. unsigned getNumSolelyBlockNodes(unsigned NodeNum) const {
  58. assert(NodeNum < NumNodesSolelyBlocking.size());
  59. return NumNodesSolelyBlocking[NodeNum];
  60. }
  61. bool empty() const { return Queue.empty(); }
  62. virtual void push(SUnit *U);
  63. virtual SUnit *pop();
  64. virtual void remove(SUnit *SU);
  65. virtual void dump(ScheduleDAG* DAG) const;
  66. // scheduledNode - As nodes are scheduled, we look to see if there are any
  67. // successor nodes that have a single unscheduled predecessor. If so, that
  68. // single predecessor has a higher priority, since scheduling it will make
  69. // the node available.
  70. void scheduledNode(SUnit *Node);
  71. private:
  72. void AdjustPriorityOfUnscheduledPreds(SUnit *SU);
  73. SUnit *getSingleUnscheduledPred(SUnit *SU);
  74. };
  75. }
  76. #endif