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.

95 lines
3.5 KiB

  1. //=- llvm/CodeGen/ScheduleHazardRecognizer.h - Scheduling Support -*- 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. // This file implements the ScheduleHazardRecognizer class, which implements
  11. // hazard-avoidance heuristics for scheduling.
  12. //
  13. //===----------------------------------------------------------------------===//
  14. #ifndef LLVM_CODEGEN_SCHEDULEHAZARDRECOGNIZER_H
  15. #define LLVM_CODEGEN_SCHEDULEHAZARDRECOGNIZER_H
  16. namespace llvm {
  17. class SUnit;
  18. /// HazardRecognizer - This determines whether or not an instruction can be
  19. /// issued this cycle, and whether or not a noop needs to be inserted to handle
  20. /// the hazard.
  21. class ScheduleHazardRecognizer {
  22. protected:
  23. /// MaxLookAhead - Indicate the number of cycles in the scoreboard
  24. /// state. Important to restore the state after backtracking. Additionally,
  25. /// MaxLookAhead=0 identifies a fake recognizer, allowing the client to
  26. /// bypass virtual calls. Currently the PostRA scheduler ignores it.
  27. unsigned MaxLookAhead;
  28. public:
  29. ScheduleHazardRecognizer(): MaxLookAhead(0) {}
  30. virtual ~ScheduleHazardRecognizer();
  31. enum HazardType {
  32. NoHazard, // This instruction can be emitted at this cycle.
  33. Hazard, // This instruction can't be emitted at this cycle.
  34. NoopHazard // This instruction can't be emitted, and needs noops.
  35. };
  36. unsigned getMaxLookAhead() const { return MaxLookAhead; }
  37. bool isEnabled() const { return MaxLookAhead != 0; }
  38. /// atIssueLimit - Return true if no more instructions may be issued in this
  39. /// cycle.
  40. ///
  41. /// FIXME: remove this once MachineScheduler is the only client.
  42. virtual bool atIssueLimit() const { return false; }
  43. /// getHazardType - Return the hazard type of emitting this node. There are
  44. /// three possible results. Either:
  45. /// * NoHazard: it is legal to issue this instruction on this cycle.
  46. /// * Hazard: issuing this instruction would stall the machine. If some
  47. /// other instruction is available, issue it first.
  48. /// * NoopHazard: issuing this instruction would break the program. If
  49. /// some other instruction can be issued, do so, otherwise issue a noop.
  50. virtual HazardType getHazardType(SUnit *m, int Stalls = 0) {
  51. return NoHazard;
  52. }
  53. /// Reset - This callback is invoked when a new block of
  54. /// instructions is about to be schedule. The hazard state should be
  55. /// set to an initialized state.
  56. virtual void Reset() {}
  57. /// EmitInstruction - This callback is invoked when an instruction is
  58. /// emitted, to advance the hazard state.
  59. virtual void EmitInstruction(SUnit *) {}
  60. /// AdvanceCycle - This callback is invoked whenever the next top-down
  61. /// instruction to be scheduled cannot issue in the current cycle, either
  62. /// because of latency or resource conflicts. This should increment the
  63. /// internal state of the hazard recognizer so that previously "Hazard"
  64. /// instructions will now not be hazards.
  65. virtual void AdvanceCycle() {}
  66. /// RecedeCycle - This callback is invoked whenever the next bottom-up
  67. /// instruction to be scheduled cannot issue in the current cycle, either
  68. /// because of latency or resource conflicts.
  69. virtual void RecedeCycle() {}
  70. /// EmitNoop - This callback is invoked when a noop was added to the
  71. /// instruction stream.
  72. virtual void EmitNoop() {
  73. // Default implementation: count it as a cycle.
  74. AdvanceCycle();
  75. }
  76. };
  77. }
  78. #endif