LLVM  4.0.0
HexagonHazardRecognizer.h
Go to the documentation of this file.
1 //===--- HexagonHazardRecognizer.h - Hexagon Post RA Hazard Recognizer ----===//
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 // This file defines the hazard recognizer for scheduling on Hexagon.
10 //===----------------------------------------------------------------------===//
11 
12 #ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONPROFITRECOGNIZER_H
13 #define LLVM_LIB_TARGET_HEXAGON_HEXAGONPROFITRECOGNIZER_H
14 
15 #include "HexagonInstrInfo.h"
16 #include "HexagonSubtarget.h"
17 #include "llvm/ADT/SmallSet.h"
20 
21 namespace llvm {
22 
24  DFAPacketizer *Resources;
25  const HexagonInstrInfo *TII;
26  unsigned PacketNum;
27  // If the packet contains a potential dot cur instruction. This is
28  // used for the scheduling priority function.
29  SUnit *UsesDotCur;
30  // The packet number when a dor cur is emitted. If its use is not generated
31  // in the same packet, then try to wait another cycle before emitting.
32  int DotCurPNum;
33  // The set of registers defined by instructions in the current packet.
34  SmallSet<unsigned, 8> RegDefs;
35 
36 public:
38  const HexagonInstrInfo *HII,
39  const HexagonSubtarget &ST)
40  : Resources(ST.createDFAPacketizer(II)), TII(HII), PacketNum(0),
41  UsesDotCur(nullptr), DotCurPNum(-1) { }
42 
44  if (Resources)
45  delete Resources;
46  }
47 
48  /// This callback is invoked when a new block of instructions is about to be
49  /// scheduled. The hazard state is set to an initialized state.
50  void Reset() override;
51 
52  /// Return the hazard type of emitting this node. There are three
53  /// possible results. Either:
54  /// * NoHazard: it is legal to issue this instruction on this cycle.
55  /// * Hazard: issuing this instruction would stall the machine. If some
56  /// other instruction is available, issue it first.
57  HazardType getHazardType(SUnit *SU, int stalls) override;
58 
59  /// This callback is invoked when an instruction is emitted to be scheduled,
60  /// to advance the hazard state.
61  void EmitInstruction(SUnit *) override;
62 
63  /// This callback may be invoked if getHazardType returns NoHazard. If, even
64  /// though there is no hazard, it would be better to schedule another
65  /// available instruction, this callback should return true.
66  bool ShouldPreferAnother(SUnit *) override;
67 
68  /// This callback is invoked whenever the next top-down instruction to be
69  /// scheduled cannot issue in the current cycle, either because of latency
70  /// or resource conflicts. This should increment the internal state of the
71  /// hazard recognizer so that previously "Hazard" instructions will now not
72  /// be hazards.
73  void AdvanceCycle() override;
74 };
75 
76 } // end namespace llvm
77 
78 #endif // LLVM_LIB_TARGET_HEXAGON_HEXAGONPROFITRECOGNIZER_H
bool ShouldPreferAnother(SUnit *) override
This callback may be invoked if getHazardType returns NoHazard.
void EmitInstruction(SUnit *) override
This callback is invoked when an instruction is emitted to be scheduled, to advance the hazard state...
void AdvanceCycle() override
This callback is invoked whenever the next top-down instruction to be scheduled cannot issue in the c...
HazardType getHazardType(SUnit *SU, int stalls) override
Return the hazard type of emitting this node.
void Reset() override
This callback is invoked when a new block of instructions is about to be scheduled.
Itinerary data supplied by a subtarget to be used by a target.
HazardRecognizer - This determines whether or not an instruction can be issued this cycle...
HexagonHazardRecognizer(const InstrItineraryData *II, const HexagonInstrInfo *HII, const HexagonSubtarget &ST)
SUnit - Scheduling unit. This is a node in the scheduling DAG.
Definition: ScheduleDAG.h:244