2010-12-06 06:04:16 +08:00
|
|
|
//===-- ARMHazardRecognizer.cpp - ARM postra hazard recognizer ------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "ARMHazardRecognizer.h"
|
|
|
|
#include "ARMBaseInstrInfo.h"
|
2011-01-12 05:46:47 +08:00
|
|
|
#include "ARMBaseRegisterInfo.h"
|
2010-12-06 06:04:16 +08:00
|
|
|
#include "ARMSubtarget.h"
|
|
|
|
#include "llvm/CodeGen/MachineInstr.h"
|
|
|
|
#include "llvm/CodeGen/ScheduleDAG.h"
|
2017-11-17 09:07:10 +08:00
|
|
|
#include "llvm/CodeGen/TargetRegisterInfo.h"
|
2010-12-06 06:04:16 +08:00
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
static bool hasRAWHazard(MachineInstr *DefMI, MachineInstr *MI,
|
|
|
|
const TargetRegisterInfo &TRI) {
|
|
|
|
// FIXME: Detect integer instructions properly.
|
2011-06-29 03:10:37 +08:00
|
|
|
const MCInstrDesc &MCID = MI->getDesc();
|
|
|
|
unsigned Domain = MCID.TSFlags & ARMII::DomainMask;
|
2011-12-07 15:15:52 +08:00
|
|
|
if (MI->mayStore())
|
2010-12-06 06:04:16 +08:00
|
|
|
return false;
|
2011-06-29 03:10:37 +08:00
|
|
|
unsigned Opcode = MCID.getOpcode();
|
2011-02-23 03:53:14 +08:00
|
|
|
if (Opcode == ARM::VMOVRS || Opcode == ARM::VMOVRRD)
|
|
|
|
return false;
|
|
|
|
if ((Domain & ARMII::DomainVFP) || (Domain & ARMII::DomainNEON))
|
|
|
|
return MI->readsRegister(DefMI->getOperand(0).getReg(), &TRI);
|
|
|
|
return false;
|
2010-12-06 06:04:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ScheduleHazardRecognizer::HazardType
|
Various bits of framework needed for precise machine-level selection
DAG scheduling during isel. Most new functionality is currently
guarded by -enable-sched-cycles and -enable-sched-hazard.
Added InstrItineraryData::IssueWidth field, currently derived from
ARM itineraries, but could be initialized differently on other targets.
Added ScheduleHazardRecognizer::MaxLookAhead to indicate whether it is
active, and if so how many cycles of state it holds.
Added SchedulingPriorityQueue::HasReadyFilter to allowing gating entry
into the scheduler's available queue.
ScoreboardHazardRecognizer now accesses the ScheduleDAG in order to
get information about it's SUnits, provides RecedeCycle for bottom-up
scheduling, correctly computes scoreboard depth, tracks IssueCount, and
considers potential stall cycles when checking for hazards.
ScheduleDAGRRList now models machine cycles and hazards (under
flags). It tracks MinAvailableCycle, drives the hazard recognizer and
priority queue's ready filter, manages a new PendingQueue, properly
accounts for stall cycles, etc.
llvm-svn: 122541
2010-12-24 13:03:26 +08:00
|
|
|
ARMHazardRecognizer::getHazardType(SUnit *SU, int Stalls) {
|
|
|
|
assert(Stalls == 0 && "ARM hazards don't support scoreboard lookahead");
|
|
|
|
|
2010-12-06 06:04:16 +08:00
|
|
|
MachineInstr *MI = SU->getInstr();
|
|
|
|
|
2018-05-09 10:42:00 +08:00
|
|
|
if (!MI->isDebugInstr()) {
|
2010-12-06 06:04:16 +08:00
|
|
|
// Look for special VMLA / VMLS hazards. A VMUL / VADD / VSUB following
|
|
|
|
// a VMLA / VMLS will cause 4 cycle stall.
|
2011-06-29 03:10:37 +08:00
|
|
|
const MCInstrDesc &MCID = MI->getDesc();
|
|
|
|
if (LastMI && (MCID.TSFlags & ARMII::DomainMask) != ARMII::DomainGeneral) {
|
2010-12-06 06:04:16 +08:00
|
|
|
MachineInstr *DefMI = LastMI;
|
2011-06-29 03:10:37 +08:00
|
|
|
const MCInstrDesc &LastMCID = LastMI->getDesc();
|
2015-01-29 08:19:33 +08:00
|
|
|
const MachineFunction *MF = MI->getParent()->getParent();
|
2014-08-05 05:25:23 +08:00
|
|
|
const ARMBaseInstrInfo &TII = *static_cast<const ARMBaseInstrInfo *>(
|
2015-01-29 08:19:33 +08:00
|
|
|
MF->getSubtarget().getInstrInfo());
|
2013-06-07 13:54:19 +08:00
|
|
|
|
2010-12-06 06:04:16 +08:00
|
|
|
// Skip over one non-VFP / NEON instruction.
|
2011-12-07 15:15:52 +08:00
|
|
|
if (!LastMI->isBarrier() &&
|
2016-07-06 17:22:23 +08:00
|
|
|
!(TII.getSubtarget().hasMuxedUnits() && LastMI->mayLoadOrStore()) &&
|
2011-06-29 03:10:37 +08:00
|
|
|
(LastMCID.TSFlags & ARMII::DomainMask) == ARMII::DomainGeneral) {
|
2010-12-06 06:04:16 +08:00
|
|
|
MachineBasicBlock::iterator I = LastMI;
|
|
|
|
if (I != LastMI->getParent()->begin()) {
|
2014-03-02 20:27:27 +08:00
|
|
|
I = std::prev(I);
|
2010-12-06 06:04:16 +08:00
|
|
|
DefMI = &*I;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TII.isFpMLxInstruction(DefMI->getOpcode()) &&
|
|
|
|
(TII.canCauseFpMLxStall(MI->getOpcode()) ||
|
2013-06-07 13:54:19 +08:00
|
|
|
hasRAWHazard(DefMI, MI, TII.getRegisterInfo()))) {
|
2010-12-06 06:04:16 +08:00
|
|
|
// Try to schedule another instruction for the next 4 cycles.
|
Various bits of framework needed for precise machine-level selection
DAG scheduling during isel. Most new functionality is currently
guarded by -enable-sched-cycles and -enable-sched-hazard.
Added InstrItineraryData::IssueWidth field, currently derived from
ARM itineraries, but could be initialized differently on other targets.
Added ScheduleHazardRecognizer::MaxLookAhead to indicate whether it is
active, and if so how many cycles of state it holds.
Added SchedulingPriorityQueue::HasReadyFilter to allowing gating entry
into the scheduler's available queue.
ScoreboardHazardRecognizer now accesses the ScheduleDAG in order to
get information about it's SUnits, provides RecedeCycle for bottom-up
scheduling, correctly computes scoreboard depth, tracks IssueCount, and
considers potential stall cycles when checking for hazards.
ScheduleDAGRRList now models machine cycles and hazards (under
flags). It tracks MinAvailableCycle, drives the hazard recognizer and
priority queue's ready filter, manages a new PendingQueue, properly
accounts for stall cycles, etc.
llvm-svn: 122541
2010-12-24 13:03:26 +08:00
|
|
|
if (FpMLxStalls == 0)
|
|
|
|
FpMLxStalls = 4;
|
2010-12-06 06:04:16 +08:00
|
|
|
return Hazard;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Various bits of framework needed for precise machine-level selection
DAG scheduling during isel. Most new functionality is currently
guarded by -enable-sched-cycles and -enable-sched-hazard.
Added InstrItineraryData::IssueWidth field, currently derived from
ARM itineraries, but could be initialized differently on other targets.
Added ScheduleHazardRecognizer::MaxLookAhead to indicate whether it is
active, and if so how many cycles of state it holds.
Added SchedulingPriorityQueue::HasReadyFilter to allowing gating entry
into the scheduler's available queue.
ScoreboardHazardRecognizer now accesses the ScheduleDAG in order to
get information about it's SUnits, provides RecedeCycle for bottom-up
scheduling, correctly computes scoreboard depth, tracks IssueCount, and
considers potential stall cycles when checking for hazards.
ScheduleDAGRRList now models machine cycles and hazards (under
flags). It tracks MinAvailableCycle, drives the hazard recognizer and
priority queue's ready filter, manages a new PendingQueue, properly
accounts for stall cycles, etc.
llvm-svn: 122541
2010-12-24 13:03:26 +08:00
|
|
|
return ScoreboardHazardRecognizer::getHazardType(SU, Stalls);
|
2010-12-06 06:04:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ARMHazardRecognizer::Reset() {
|
2014-04-25 13:30:21 +08:00
|
|
|
LastMI = nullptr;
|
Various bits of framework needed for precise machine-level selection
DAG scheduling during isel. Most new functionality is currently
guarded by -enable-sched-cycles and -enable-sched-hazard.
Added InstrItineraryData::IssueWidth field, currently derived from
ARM itineraries, but could be initialized differently on other targets.
Added ScheduleHazardRecognizer::MaxLookAhead to indicate whether it is
active, and if so how many cycles of state it holds.
Added SchedulingPriorityQueue::HasReadyFilter to allowing gating entry
into the scheduler's available queue.
ScoreboardHazardRecognizer now accesses the ScheduleDAG in order to
get information about it's SUnits, provides RecedeCycle for bottom-up
scheduling, correctly computes scoreboard depth, tracks IssueCount, and
considers potential stall cycles when checking for hazards.
ScheduleDAGRRList now models machine cycles and hazards (under
flags). It tracks MinAvailableCycle, drives the hazard recognizer and
priority queue's ready filter, manages a new PendingQueue, properly
accounts for stall cycles, etc.
llvm-svn: 122541
2010-12-24 13:03:26 +08:00
|
|
|
FpMLxStalls = 0;
|
2010-12-09 04:04:29 +08:00
|
|
|
ScoreboardHazardRecognizer::Reset();
|
2010-12-06 06:04:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ARMHazardRecognizer::EmitInstruction(SUnit *SU) {
|
|
|
|
MachineInstr *MI = SU->getInstr();
|
2018-05-09 10:42:00 +08:00
|
|
|
if (!MI->isDebugInstr()) {
|
2010-12-06 06:04:16 +08:00
|
|
|
LastMI = MI;
|
Various bits of framework needed for precise machine-level selection
DAG scheduling during isel. Most new functionality is currently
guarded by -enable-sched-cycles and -enable-sched-hazard.
Added InstrItineraryData::IssueWidth field, currently derived from
ARM itineraries, but could be initialized differently on other targets.
Added ScheduleHazardRecognizer::MaxLookAhead to indicate whether it is
active, and if so how many cycles of state it holds.
Added SchedulingPriorityQueue::HasReadyFilter to allowing gating entry
into the scheduler's available queue.
ScoreboardHazardRecognizer now accesses the ScheduleDAG in order to
get information about it's SUnits, provides RecedeCycle for bottom-up
scheduling, correctly computes scoreboard depth, tracks IssueCount, and
considers potential stall cycles when checking for hazards.
ScheduleDAGRRList now models machine cycles and hazards (under
flags). It tracks MinAvailableCycle, drives the hazard recognizer and
priority queue's ready filter, manages a new PendingQueue, properly
accounts for stall cycles, etc.
llvm-svn: 122541
2010-12-24 13:03:26 +08:00
|
|
|
FpMLxStalls = 0;
|
2010-12-06 06:04:16 +08:00
|
|
|
}
|
|
|
|
|
2010-12-09 04:04:29 +08:00
|
|
|
ScoreboardHazardRecognizer::EmitInstruction(SU);
|
2010-12-06 06:04:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ARMHazardRecognizer::AdvanceCycle() {
|
Various bits of framework needed for precise machine-level selection
DAG scheduling during isel. Most new functionality is currently
guarded by -enable-sched-cycles and -enable-sched-hazard.
Added InstrItineraryData::IssueWidth field, currently derived from
ARM itineraries, but could be initialized differently on other targets.
Added ScheduleHazardRecognizer::MaxLookAhead to indicate whether it is
active, and if so how many cycles of state it holds.
Added SchedulingPriorityQueue::HasReadyFilter to allowing gating entry
into the scheduler's available queue.
ScoreboardHazardRecognizer now accesses the ScheduleDAG in order to
get information about it's SUnits, provides RecedeCycle for bottom-up
scheduling, correctly computes scoreboard depth, tracks IssueCount, and
considers potential stall cycles when checking for hazards.
ScheduleDAGRRList now models machine cycles and hazards (under
flags). It tracks MinAvailableCycle, drives the hazard recognizer and
priority queue's ready filter, manages a new PendingQueue, properly
accounts for stall cycles, etc.
llvm-svn: 122541
2010-12-24 13:03:26 +08:00
|
|
|
if (FpMLxStalls && --FpMLxStalls == 0)
|
2010-12-06 06:04:16 +08:00
|
|
|
// Stalled for 4 cycles but still can't schedule any other instructions.
|
2014-04-25 13:30:21 +08:00
|
|
|
LastMI = nullptr;
|
2010-12-09 04:04:29 +08:00
|
|
|
ScoreboardHazardRecognizer::AdvanceCycle();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ARMHazardRecognizer::RecedeCycle() {
|
|
|
|
llvm_unreachable("reverse ARM hazard checking unsupported");
|
2010-12-06 06:04:16 +08:00
|
|
|
}
|