2016-04-30 08:23:06 +08:00
|
|
|
//===-- GCNHazardRecognizers.h - GCN Hazard Recognizers ---------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines hazard recognizers for scheduling on GCN processors.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_LIB_TARGET_AMDGPUHAZARDRECOGNIZERS_H
|
|
|
|
#define LLVM_LIB_TARGET_AMDGPUHAZARDRECOGNIZERS_H
|
|
|
|
|
2016-06-13 00:13:55 +08:00
|
|
|
#include "llvm/ADT/STLExtras.h"
|
2016-04-30 08:23:06 +08:00
|
|
|
#include "llvm/CodeGen/ScheduleHazardRecognizer.h"
|
|
|
|
#include <list>
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class MachineFunction;
|
|
|
|
class MachineInstr;
|
|
|
|
class ScheduleDAG;
|
|
|
|
class SIInstrInfo;
|
2016-06-24 14:30:11 +08:00
|
|
|
class SISubtarget;
|
2016-04-30 08:23:06 +08:00
|
|
|
|
|
|
|
class GCNHazardRecognizer final : public ScheduleHazardRecognizer {
|
2016-06-24 14:30:11 +08:00
|
|
|
// This variable stores the instruction that has been emitted this cycle. It
|
|
|
|
// will be added to EmittedInstrs, when AdvanceCycle() or RecedeCycle() is
|
2016-04-30 08:23:06 +08:00
|
|
|
// called.
|
|
|
|
MachineInstr *CurrCycleInstr;
|
|
|
|
std::list<MachineInstr*> EmittedInstrs;
|
|
|
|
const MachineFunction &MF;
|
2016-06-24 14:30:11 +08:00
|
|
|
const SISubtarget &ST;
|
2017-03-18 05:36:28 +08:00
|
|
|
const SIInstrInfo &TII;
|
2016-04-30 08:23:06 +08:00
|
|
|
|
2016-10-28 07:05:31 +08:00
|
|
|
int getWaitStatesSince(function_ref<bool(MachineInstr *)> IsHazard);
|
2016-04-30 08:23:06 +08:00
|
|
|
int getWaitStatesSinceDef(unsigned Reg,
|
2016-06-13 00:13:55 +08:00
|
|
|
function_ref<bool(MachineInstr *)> IsHazardDef =
|
|
|
|
[](MachineInstr *) { return true; });
|
2016-10-15 08:58:14 +08:00
|
|
|
int getWaitStatesSinceSetReg(function_ref<bool(MachineInstr *)> IsHazard);
|
2016-04-30 08:23:06 +08:00
|
|
|
|
2016-05-03 01:39:06 +08:00
|
|
|
int checkSMEMSoftClauseHazards(MachineInstr *SMEM);
|
2016-04-30 08:23:06 +08:00
|
|
|
int checkSMRDHazards(MachineInstr *SMRD);
|
|
|
|
int checkVMEMHazards(MachineInstr* VMEM);
|
2016-05-03 00:23:09 +08:00
|
|
|
int checkDPPHazards(MachineInstr *DPP);
|
2016-10-08 07:42:48 +08:00
|
|
|
int checkDivFMasHazards(MachineInstr *DivFMas);
|
2016-10-15 08:58:14 +08:00
|
|
|
int checkGetRegHazards(MachineInstr *GetRegInstr);
|
2016-10-28 04:39:09 +08:00
|
|
|
int checkSetRegHazards(MachineInstr *SetRegInstr);
|
2016-10-28 07:05:31 +08:00
|
|
|
int createsVALUHazard(const MachineInstr &MI);
|
|
|
|
int checkVALUHazards(MachineInstr *VALU);
|
2016-10-28 07:42:29 +08:00
|
|
|
int checkRWLaneHazards(MachineInstr *RWLane);
|
2016-10-28 07:50:21 +08:00
|
|
|
int checkRFEHazards(MachineInstr *RFE);
|
2017-02-19 02:29:53 +08:00
|
|
|
int checkAnyInstHazards(MachineInstr *MI);
|
|
|
|
int checkReadM0Hazards(MachineInstr *SMovRel);
|
2016-04-30 08:23:06 +08:00
|
|
|
public:
|
|
|
|
GCNHazardRecognizer(const MachineFunction &MF);
|
|
|
|
// We can only issue one instruction per cycle.
|
|
|
|
bool atIssueLimit() const override { return true; }
|
|
|
|
void EmitInstruction(SUnit *SU) override;
|
|
|
|
void EmitInstruction(MachineInstr *MI) override;
|
|
|
|
HazardType getHazardType(SUnit *SU, int Stalls) override;
|
|
|
|
void EmitNoop() override;
|
|
|
|
unsigned PreEmitNoops(SUnit *SU) override;
|
|
|
|
unsigned PreEmitNoops(MachineInstr *) override;
|
|
|
|
void AdvanceCycle() override;
|
|
|
|
void RecedeCycle() override;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif //LLVM_LIB_TARGET_AMDGPUHAZARDRECOGNIZERS_H
|