2016-07-29 15:59:55 +02:00
|
|
|
//===--- HexagonHazardRecognizer.h - Hexagon Post RA Hazard Recognizer ----===//
|
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2016-07-29 15:59:55 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2016-07-29 16:04:17 +02:00
|
|
|
// This file defines the hazard recognizer for scheduling on Hexagon.
|
|
|
|
//===----------------------------------------------------------------------===//
|
2016-07-29 15:59:55 +02:00
|
|
|
|
2016-12-17 02:09:05 +01:00
|
|
|
#ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONPROFITRECOGNIZER_H
|
|
|
|
#define LLVM_LIB_TARGET_HEXAGON_HEXAGONPROFITRECOGNIZER_H
|
2016-07-29 15:59:55 +02:00
|
|
|
|
|
|
|
#include "HexagonInstrInfo.h"
|
|
|
|
#include "HexagonSubtarget.h"
|
|
|
|
#include "llvm/ADT/SmallSet.h"
|
|
|
|
#include "llvm/CodeGen/DFAPacketizer.h"
|
|
|
|
#include "llvm/CodeGen/ScheduleHazardRecognizer.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class HexagonHazardRecognizer : public ScheduleHazardRecognizer {
|
|
|
|
DFAPacketizer *Resources;
|
|
|
|
const HexagonInstrInfo *TII;
|
2018-03-20 15:54:01 +01:00
|
|
|
unsigned PacketNum = 0;
|
2016-07-29 15:59:55 +02:00
|
|
|
// If the packet contains a potential dot cur instruction. This is
|
|
|
|
// used for the scheduling priority function.
|
2018-03-20 15:54:01 +01:00
|
|
|
SUnit *UsesDotCur = nullptr;
|
2016-07-29 15:59:55 +02:00
|
|
|
// The packet number when a dor cur is emitted. If its use is not generated
|
|
|
|
// in the same packet, then try to wait another cycle before emitting.
|
2018-03-20 15:54:01 +01:00
|
|
|
int DotCurPNum = -1;
|
2018-03-16 21:55:49 +01:00
|
|
|
// Does the packet contain a load. Used to restrict another load, if possible.
|
|
|
|
bool UsesLoad = false;
|
2018-03-20 15:54:01 +01:00
|
|
|
// Check if we should prefer a vector store that will become a .new version.
|
|
|
|
// The .new store uses different resources than a normal store, and the
|
|
|
|
// packetizer will not generate the .new if the regular store does not have
|
|
|
|
// resources available (even if the .new version does). To help, the schedule
|
|
|
|
// attempts to schedule the .new as soon as possible in the packet.
|
|
|
|
SUnit *PrefVectorStoreNew = nullptr;
|
2016-07-29 15:59:55 +02:00
|
|
|
// The set of registers defined by instructions in the current packet.
|
|
|
|
SmallSet<unsigned, 8> RegDefs;
|
|
|
|
|
|
|
|
public:
|
|
|
|
HexagonHazardRecognizer(const InstrItineraryData *II,
|
|
|
|
const HexagonInstrInfo *HII,
|
|
|
|
const HexagonSubtarget &ST)
|
2018-03-20 15:54:01 +01:00
|
|
|
: Resources(ST.createDFAPacketizer(II)), TII(HII) { }
|
2016-07-29 15:59:55 +02:00
|
|
|
|
2016-12-17 02:09:05 +01:00
|
|
|
~HexagonHazardRecognizer() override {
|
2016-07-29 15:59:55 +02:00
|
|
|
if (Resources)
|
|
|
|
delete Resources;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// This callback is invoked when a new block of instructions is about to be
|
|
|
|
/// scheduled. The hazard state is set to an initialized state.
|
2016-12-17 02:09:05 +01:00
|
|
|
void Reset() override;
|
2016-07-29 15:59:55 +02:00
|
|
|
|
|
|
|
/// Return the hazard type of emitting this node. There are three
|
|
|
|
/// possible results. Either:
|
|
|
|
/// * NoHazard: it is legal to issue this instruction on this cycle.
|
|
|
|
/// * Hazard: issuing this instruction would stall the machine. If some
|
|
|
|
/// other instruction is available, issue it first.
|
2016-12-17 02:09:05 +01:00
|
|
|
HazardType getHazardType(SUnit *SU, int stalls) override;
|
2016-07-29 15:59:55 +02:00
|
|
|
|
|
|
|
/// This callback is invoked when an instruction is emitted to be scheduled,
|
|
|
|
/// to advance the hazard state.
|
2016-12-17 02:09:05 +01:00
|
|
|
void EmitInstruction(SUnit *) override;
|
2016-07-29 15:59:55 +02:00
|
|
|
|
|
|
|
/// This callback may be invoked if getHazardType returns NoHazard. If, even
|
|
|
|
/// though there is no hazard, it would be better to schedule another
|
|
|
|
/// available instruction, this callback should return true.
|
2016-12-17 02:09:05 +01:00
|
|
|
bool ShouldPreferAnother(SUnit *) override;
|
2016-07-29 15:59:55 +02:00
|
|
|
|
|
|
|
/// This callback is invoked whenever the next top-down instruction to be
|
|
|
|
/// scheduled cannot issue in the current cycle, either because of latency
|
|
|
|
/// or resource conflicts. This should increment the internal state of the
|
|
|
|
/// hazard recognizer so that previously "Hazard" instructions will now not
|
|
|
|
/// be hazards.
|
2016-12-17 02:09:05 +01:00
|
|
|
void AdvanceCycle() override;
|
2016-07-29 15:59:55 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
2016-12-17 02:09:05 +01:00
|
|
|
#endif // LLVM_LIB_TARGET_HEXAGON_HEXAGONPROFITRECOGNIZER_H
|