2016-04-30 08:23:06 +08:00
|
|
|
//===-- GCNHazardRecognizers.h - GCN Hazard Recognizers ---------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08: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-04-30 08:23:06 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines hazard recognizers for scheduling on GCN processors.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_LIB_TARGET_AMDGPUHAZARDRECOGNIZERS_H
|
|
|
|
#define LLVM_LIB_TARGET_AMDGPUHAZARDRECOGNIZERS_H
|
|
|
|
|
2017-11-17 12:18:24 +08:00
|
|
|
#include "llvm/ADT/BitVector.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"
|
2019-07-12 05:30:34 +08:00
|
|
|
#include "llvm/CodeGen/TargetSchedule.h"
|
2016-04-30 08:23:06 +08:00
|
|
|
#include <list>
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class MachineFunction;
|
|
|
|
class MachineInstr;
|
2017-12-08 04:34:25 +08:00
|
|
|
class MachineOperand;
|
|
|
|
class MachineRegisterInfo;
|
2016-04-30 08:23:06 +08:00
|
|
|
class ScheduleDAG;
|
|
|
|
class SIInstrInfo;
|
2017-11-17 12:18:24 +08:00
|
|
|
class SIRegisterInfo;
|
2018-07-12 04:59:01 +08:00
|
|
|
class GCNSubtarget;
|
2016-04-30 08:23:06 +08:00
|
|
|
|
|
|
|
class GCNHazardRecognizer final : public ScheduleHazardRecognizer {
|
2019-01-22 03:11:26 +08:00
|
|
|
public:
|
2021-04-30 08:01:10 +08:00
|
|
|
typedef function_ref<bool(const MachineInstr &)> IsHazardFn;
|
2019-01-22 03:11:26 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Distinguish if we are called from scheduler or hazard recognizer
|
|
|
|
bool IsHazardRecognizerMode;
|
|
|
|
|
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;
|
2018-07-12 04:59:01 +08:00
|
|
|
const GCNSubtarget &ST;
|
2017-03-18 05:36:28 +08:00
|
|
|
const SIInstrInfo &TII;
|
2017-11-17 12:18:24 +08:00
|
|
|
const SIRegisterInfo &TRI;
|
2019-07-12 05:30:34 +08:00
|
|
|
TargetSchedModel TSchedModel;
|
2021-06-14 18:17:35 +08:00
|
|
|
bool RunLdsBranchVmemWARHazardFixup;
|
2017-11-17 12:18:24 +08:00
|
|
|
|
|
|
|
/// RegUnits of uses in the current soft memory clause.
|
|
|
|
BitVector ClauseUses;
|
|
|
|
|
|
|
|
/// RegUnits of defs in the current soft memory clause.
|
|
|
|
BitVector ClauseDefs;
|
|
|
|
|
|
|
|
void resetClause() {
|
|
|
|
ClauseUses.reset();
|
|
|
|
ClauseDefs.reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
void addClauseInst(const MachineInstr &MI);
|
2016-04-30 08:23:06 +08:00
|
|
|
|
[AMDGPU] Check MI bundles for hazards
Summary: GCNHazardRecognizer fails to identify hazards that are in and around bundles. This patch allows the hazard recognizer to consider bundled instructions in both scheduler and hazard recognizer mode. We ignore “bundledness” for the purpose of detecting hazards and examine the instructions individually.
Reviewers: arsenm, msearles, rampitec
Reviewed By: rampitec
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D61564
llvm-svn: 360199
2019-05-08 06:12:15 +08:00
|
|
|
// Advance over a MachineInstr bundle. Look for hazards in the bundled
|
|
|
|
// instructions.
|
|
|
|
void processBundle();
|
|
|
|
|
2019-01-22 03:11:26 +08:00
|
|
|
int getWaitStatesSince(IsHazardFn IsHazard, int Limit);
|
|
|
|
int getWaitStatesSinceDef(unsigned Reg, IsHazardFn IsHazardDef, int Limit);
|
|
|
|
int getWaitStatesSinceSetReg(IsHazardFn IsHazard, int Limit);
|
2016-04-30 08:23:06 +08:00
|
|
|
|
2017-11-18 05:35:32 +08:00
|
|
|
int checkSoftClauseHazards(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);
|
2017-12-08 04:34:25 +08:00
|
|
|
int checkVALUHazardsHelper(const MachineOperand &Def, const MachineRegisterInfo &MRI);
|
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-12-08 04:34:25 +08:00
|
|
|
int checkInlineAsmHazards(MachineInstr *IA);
|
2017-02-19 02:29:53 +08:00
|
|
|
int checkReadM0Hazards(MachineInstr *SMovRel);
|
2019-05-04 12:30:57 +08:00
|
|
|
int checkNSAtoVMEMHazard(MachineInstr *MI);
|
2019-06-22 00:30:14 +08:00
|
|
|
int checkFPAtomicToDenormModeHazard(MachineInstr *MI);
|
[AMDGPU] Check MI bundles for hazards
Summary: GCNHazardRecognizer fails to identify hazards that are in and around bundles. This patch allows the hazard recognizer to consider bundled instructions in both scheduler and hazard recognizer mode. We ignore “bundledness” for the purpose of detecting hazards and examine the instructions individually.
Reviewers: arsenm, msearles, rampitec
Reviewed By: rampitec
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D61564
llvm-svn: 360199
2019-05-08 06:12:15 +08:00
|
|
|
void fixHazards(MachineInstr *MI);
|
2019-06-13 01:52:51 +08:00
|
|
|
bool fixVcmpxPermlaneHazards(MachineInstr *MI);
|
2019-05-04 12:30:57 +08:00
|
|
|
bool fixVMEMtoScalarWriteHazards(MachineInstr *MI);
|
|
|
|
bool fixSMEMtoVectorWriteHazards(MachineInstr *MI);
|
|
|
|
bool fixVcmpxExecWARHazard(MachineInstr *MI);
|
|
|
|
bool fixLdsBranchVmemWARHazard(MachineInstr *MI);
|
|
|
|
|
2019-07-12 05:30:34 +08:00
|
|
|
int checkMAIHazards(MachineInstr *MI);
|
2021-02-18 05:37:46 +08:00
|
|
|
int checkMAIHazards908(MachineInstr *MI);
|
|
|
|
int checkMAIHazards90A(MachineInstr *MI);
|
|
|
|
int checkMAIVALUHazards(MachineInstr *MI);
|
2019-07-12 05:30:34 +08:00
|
|
|
int checkMAILdStHazards(MachineInstr *MI);
|
|
|
|
|
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(MachineInstr *) override;
|
2019-01-22 03:11:26 +08:00
|
|
|
unsigned PreEmitNoopsCommon(MachineInstr *);
|
2016-04-30 08:23:06 +08:00
|
|
|
void AdvanceCycle() override;
|
|
|
|
void RecedeCycle() override;
|
2020-07-30 02:47:18 +08:00
|
|
|
bool ShouldPreferAnother(SUnit *SU) override;
|
2020-10-29 05:38:41 +08:00
|
|
|
void Reset() override;
|
2016-04-30 08:23:06 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif //LLVM_LIB_TARGET_AMDGPUHAZARDRECOGNIZERS_H
|