Path: blob/main/contrib/llvm-project/llvm/lib/Target/Hexagon/HexagonHazardRecognizer.h
35269 views
//===--- HexagonHazardRecognizer.h - Hexagon Post RA Hazard Recognizer ----===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7// This file defines the hazard recognizer for scheduling on Hexagon.8//===----------------------------------------------------------------------===//910#ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONPROFITRECOGNIZER_H11#define LLVM_LIB_TARGET_HEXAGON_HEXAGONPROFITRECOGNIZER_H1213#include "HexagonInstrInfo.h"14#include "HexagonSubtarget.h"15#include "llvm/ADT/SmallSet.h"16#include "llvm/CodeGen/DFAPacketizer.h"17#include "llvm/CodeGen/ScheduleHazardRecognizer.h"1819namespace llvm {2021class HexagonHazardRecognizer : public ScheduleHazardRecognizer {22DFAPacketizer *Resources;23const HexagonInstrInfo *TII;24unsigned PacketNum = 0;25// If the packet contains a potential dot cur instruction. This is26// used for the scheduling priority function.27SUnit *UsesDotCur = nullptr;28// The packet number when a dor cur is emitted. If its use is not generated29// in the same packet, then try to wait another cycle before emitting.30int DotCurPNum = -1;31// Does the packet contain a load. Used to restrict another load, if possible.32bool UsesLoad = false;33// Check if we should prefer a vector store that will become a .new version.34// The .new store uses different resources than a normal store, and the35// packetizer will not generate the .new if the regular store does not have36// resources available (even if the .new version does). To help, the schedule37// attempts to schedule the .new as soon as possible in the packet.38SUnit *PrefVectorStoreNew = nullptr;39// The set of registers defined by instructions in the current packet.40SmallSet<unsigned, 8> RegDefs;4142// Return true if the instruction is a store that is converted to a new value43// store because its value is defined in the same packet.44bool isNewStore(MachineInstr &MI);4546public:47HexagonHazardRecognizer(const InstrItineraryData *II,48const HexagonInstrInfo *HII,49const HexagonSubtarget &ST)50: Resources(ST.createDFAPacketizer(II)), TII(HII) { }5152~HexagonHazardRecognizer() override {53if (Resources)54delete Resources;55}5657/// This callback is invoked when a new block of instructions is about to be58/// scheduled. The hazard state is set to an initialized state.59void Reset() override;6061/// Return the hazard type of emitting this node. There are three62/// possible results. Either:63/// * NoHazard: it is legal to issue this instruction on this cycle.64/// * Hazard: issuing this instruction would stall the machine. If some65/// other instruction is available, issue it first.66HazardType getHazardType(SUnit *SU, int stalls) override;6768/// This callback is invoked when an instruction is emitted to be scheduled,69/// to advance the hazard state.70void EmitInstruction(SUnit *) override;7172/// This callback may be invoked if getHazardType returns NoHazard. If, even73/// though there is no hazard, it would be better to schedule another74/// available instruction, this callback should return true.75bool ShouldPreferAnother(SUnit *) override;7677/// This callback is invoked whenever the next top-down instruction to be78/// scheduled cannot issue in the current cycle, either because of latency79/// or resource conflicts. This should increment the internal state of the80/// hazard recognizer so that previously "Hazard" instructions will now not81/// be hazards.82void AdvanceCycle() override;83};8485} // end namespace llvm8687#endif // LLVM_LIB_TARGET_HEXAGON_HEXAGONPROFITRECOGNIZER_H888990