LLVM 17.0.0git
llvm::ScheduleHazardRecognizer Class Reference

HazardRecognizer - This determines whether or not an instruction can be issued this cycle, and whether or not a noop needs to be inserted to handle the hazard. More...

#include "llvm/CodeGen/ScheduleHazardRecognizer.h"

Inheritance diagram for llvm::ScheduleHazardRecognizer:
[legend]
Collaboration diagram for llvm::ScheduleHazardRecognizer:
[legend]

## Public Types

enum  HazardType { NoHazard , Hazard , NoopHazard }

## Public Member Functions

ScheduleHazardRecognizer ()=default

virtual ~ScheduleHazardRecognizer ()

bool isEnabled () const

virtual bool atIssueLimit () const
atIssueLimit - Return true if no more instructions may be issued in this cycle.

virtual HazardType getHazardType (SUnit *, int Stalls=0)
getHazardType - Return the hazard type of emitting this node.

virtual void Reset ()
Reset - This callback is invoked when a new block of instructions is about to be schedule.

virtual void EmitInstruction (SUnit *)
EmitInstruction - This callback is invoked when an instruction is emitted, to advance the hazard state.

virtual void EmitInstruction (MachineInstr *)
This overload will be used when the hazard recognizer is being used by a non-scheduling pass, which does not use SUnits.

virtual unsigned PreEmitNoops (SUnit *)
PreEmitNoops - This callback is invoked prior to emitting an instruction.

virtual unsigned PreEmitNoops (MachineInstr *)
This overload will be used when the hazard recognizer is being used by a non-scheduling pass, which does not use SUnits.

virtual bool ShouldPreferAnother (SUnit *)
ShouldPreferAnother - This callback may be invoked if getHazardType returns NoHazard.

AdvanceCycle - 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.

virtual void RecedeCycle ()
RecedeCycle - This callback is invoked whenever the next bottom-up instruction to be scheduled cannot issue in the current cycle, either because of latency or resource conflicts.

virtual void EmitNoop ()
EmitNoop - This callback is invoked when a noop was added to the instruction stream.

virtual void EmitNoops (unsigned Quantity)
EmitNoops - This callback is invoked when noops were added to the instruction stream.

## Protected Attributes

MaxLookAhead - Indicate the number of cycles in the scoreboard state.

## Detailed Description

HazardRecognizer - This determines whether or not an instruction can be issued this cycle, and whether or not a noop needs to be inserted to handle the hazard.

Definition at line 25 of file ScheduleHazardRecognizer.h.

## ◆ HazardType

Enumerator
NoHazard
Hazard
NoopHazard

Definition at line 37 of file ScheduleHazardRecognizer.h.

## ◆ ScheduleHazardRecognizer()

 llvm::ScheduleHazardRecognizer::ScheduleHazardRecognizer ( )
default

## ◆ ~ScheduleHazardRecognizer()

 ScheduleHazardRecognizer::~ScheduleHazardRecognizer ( )
virtualdefault

## Member Function Documentation

inlinevirtual

AdvanceCycle - 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.

Definition at line 104 of file ScheduleHazardRecognizer.h.

Referenced by llvm::SchedBoundary::bumpCycle(), and EmitNoop().

## ◆ atIssueLimit()

 virtual bool llvm::ScheduleHazardRecognizer::atIssueLimit ( ) const
inlinevirtual

atIssueLimit - Return true if no more instructions may be issued in this cycle.

FIXME: remove this once MachineScheduler is the only client.

Reimplemented in llvm::MultiHazardRecognizer, llvm::ScoreboardHazardRecognizer, and llvm::GCNHazardRecognizer.

Definition at line 51 of file ScheduleHazardRecognizer.h.

Referenced by llvm::MultiHazardRecognizer::atIssueLimit().

## ◆ EmitInstruction() [1/2]

 virtual void llvm::ScheduleHazardRecognizer::EmitInstruction ( MachineInstr * )
inlinevirtual

This overload will be used when the hazard recognizer is being used by a non-scheduling pass, which does not use SUnits.

Reimplemented in llvm::MultiHazardRecognizer, and llvm::GCNHazardRecognizer.

Definition at line 75 of file ScheduleHazardRecognizer.h.

## ◆ EmitInstruction() [2/2]

 virtual void llvm::ScheduleHazardRecognizer::EmitInstruction ( SUnit * )
inlinevirtual

EmitInstruction - This callback is invoked when an instruction is emitted, to advance the hazard state.

Definition at line 71 of file ScheduleHazardRecognizer.h.

Referenced by llvm::SchedBoundary::bumpNode().

## ◆ EmitNoop()

 virtual void llvm::ScheduleHazardRecognizer::EmitNoop ( )
inlinevirtual

EmitNoop - This callback is invoked when a noop was added to the instruction stream.

Reimplemented in llvm::MultiHazardRecognizer, llvm::GCNHazardRecognizer, and llvm::PPCDispatchGroupSBHazardRecognizer.

Definition at line 113 of file ScheduleHazardRecognizer.h.

Referenced by EmitNoops().

## ◆ EmitNoops()

 virtual void llvm::ScheduleHazardRecognizer::EmitNoops ( unsigned Quantity )
inlinevirtual

EmitNoops - This callback is invoked when noops were added to the instruction stream.

Definition at line 120 of file ScheduleHazardRecognizer.h.

References EmitNoop().

## ◆ getHazardType()

 virtual HazardType llvm::ScheduleHazardRecognizer::getHazardType ( SUnit * , int Stalls = 0 )
inlinevirtual

getHazardType - 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.
• NoopHazard: issuing this instruction would break the program. If some other instruction can be issued, do so, otherwise issue a noop.

Definition at line 60 of file ScheduleHazardRecognizer.h.

References NoHazard.

Referenced by llvm::SchedBoundary::checkHazard().

inline

Definition at line 43 of file ScheduleHazardRecognizer.h.

## ◆ isEnabled()

 bool llvm::ScheduleHazardRecognizer::isEnabled ( ) const
inline

Definition at line 45 of file ScheduleHazardRecognizer.h.

## ◆ PreEmitNoops() [1/2]

 virtual unsigned llvm::ScheduleHazardRecognizer::PreEmitNoops ( MachineInstr * )
inlinevirtual

This overload will be used when the hazard recognizer is being used by a non-scheduling pass, which does not use SUnits.

Reimplemented in llvm::MultiHazardRecognizer, and llvm::GCNHazardRecognizer.

Definition at line 88 of file ScheduleHazardRecognizer.h.

## ◆ PreEmitNoops() [2/2]

 virtual unsigned llvm::ScheduleHazardRecognizer::PreEmitNoops ( SUnit * )
inlinevirtual

PreEmitNoops - This callback is invoked prior to emitting an instruction.

It should return the number of noops to emit prior to the provided instruction. Note: This is only used during PostRA scheduling. EmitNoop is not called for these noops.

Reimplemented in llvm::MultiHazardRecognizer, and llvm::PPCDispatchGroupSBHazardRecognizer.

Definition at line 82 of file ScheduleHazardRecognizer.h.

Referenced by llvm::PPCDispatchGroupSBHazardRecognizer::PreEmitNoops().

## ◆ RecedeCycle()

 virtual void llvm::ScheduleHazardRecognizer::RecedeCycle ( )
inlinevirtual

RecedeCycle - This callback is invoked whenever the next bottom-up instruction to be scheduled cannot issue in the current cycle, either because of latency or resource conflicts.

Definition at line 109 of file ScheduleHazardRecognizer.h.

Referenced by llvm::SchedBoundary::bumpCycle().

## ◆ Reset()

 virtual void llvm::ScheduleHazardRecognizer::Reset ( )
inlinevirtual

Reset - This callback is invoked when a new block of instructions is about to be schedule.

The hazard state should be set to an initialized state.

Definition at line 67 of file ScheduleHazardRecognizer.h.

Referenced by llvm::SchedBoundary::bumpNode().

## ◆ ShouldPreferAnother()

 virtual bool llvm::ScheduleHazardRecognizer::ShouldPreferAnother ( SUnit * )
inlinevirtual

ShouldPreferAnother - 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.

Definition at line 95 of file ScheduleHazardRecognizer.h.