1 //=- llvm/CodeGen/PostRAHazardRecognizer.h - Scheduling Support -*- C++ -*-=//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the PostRAHazardRecognizer class, which
11 // implements hazard-avoidance heuristics for scheduling, based on the
12 // scheduling itineraries specified for the target.
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_CODEGEN_EXACTHAZARDRECOGNIZER_H
17 #define LLVM_CODEGEN_EXACTHAZARDRECOGNIZER_H
19 #include "llvm/CodeGen/ScheduleHazardRecognizer.h"
20 #include "llvm/System/DataTypes.h"
28 class InstrItineraryData;
31 class PostRAHazardRecognizer : public ScheduleHazardRecognizer {
32 // ScoreBoard to track function unit usage. ScoreBoard[0] is a
33 // mask of the FUs in use in the cycle currently being
34 // schedule. ScoreBoard[1] is a mask for the next cycle. The
35 // ScoreBoard is used as a circular buffer with the current cycle
40 // The maximum number of cycles monitored by the Scoreboard. This
41 // value is determined based on the target itineraries to ensure
42 // that all hazards can be tracked.
44 // Indices into the Scoreboard that represent the current cycle.
47 ScoreBoard():Data(NULL), Depth(0), Head(0) { }
52 size_t getDepth() const { return Depth; }
53 unsigned& operator[](size_t idx) const {
54 assert(Depth && "ScoreBoard was not initialized properly!");
56 return Data[(Head + idx) % Depth];
59 void reset(size_t d = 1) {
62 Data = new unsigned[Depth];
65 memset(Data, 0, Depth * sizeof(Data[0]));
70 Head = (Head + 1) % Depth;
73 // Print the scoreboard.
77 // Itinerary data for the target.
78 const InstrItineraryData *ItinData;
80 ScoreBoard ReservedScoreboard;
81 ScoreBoard RequiredScoreboard;
84 PostRAHazardRecognizer(const InstrItineraryData *ItinData);
86 virtual HazardType getHazardType(SUnit *SU);
88 virtual void EmitInstruction(SUnit *SU);
89 virtual void AdvanceCycle();