2010-12-05 22:04:16 +00: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-11 21:46:47 +00:00
|
|
|
#include "ARMBaseRegisterInfo.h"
|
2010-12-05 22:04:16 +00:00
|
|
|
#include "ARMSubtarget.h"
|
|
|
|
#include "llvm/CodeGen/MachineInstr.h"
|
|
|
|
#include "llvm/CodeGen/ScheduleDAG.h"
|
|
|
|
#include "llvm/Target/TargetRegisterInfo.h"
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
static bool hasRAWHazard(MachineInstr *DefMI, MachineInstr *MI,
|
|
|
|
const TargetRegisterInfo &TRI) {
|
|
|
|
// FIXME: Detect integer instructions properly.
|
2011-06-28 19:10:37 +00:00
|
|
|
const MCInstrDesc &MCID = MI->getDesc();
|
|
|
|
unsigned Domain = MCID.TSFlags & ARMII::DomainMask;
|
2011-12-07 07:15:52 +00:00
|
|
|
if (MI->mayStore())
|
2010-12-05 22:04:16 +00:00
|
|
|
return false;
|
2011-06-28 19:10:37 +00:00
|
|
|
unsigned Opcode = MCID.getOpcode();
|
2011-02-22 19:53:14 +00: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-05 22:04:16 +00: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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
ARMHazardRecognizer::getHazardType(SUnit *SU, int Stalls) {
|
|
|
|
assert(Stalls == 0 && "ARM hazards don't support scoreboard lookahead");
|
|
|
|
|
2010-12-05 22:04:16 +00:00
|
|
|
MachineInstr *MI = SU->getInstr();
|
|
|
|
|
|
|
|
if (!MI->isDebugValue()) {
|
|
|
|
// Look for special VMLA / VMLS hazards. A VMUL / VADD / VSUB following
|
|
|
|
// a VMLA / VMLS will cause 4 cycle stall.
|
2011-06-28 19:10:37 +00:00
|
|
|
const MCInstrDesc &MCID = MI->getDesc();
|
|
|
|
if (LastMI && (MCID.TSFlags & ARMII::DomainMask) != ARMII::DomainGeneral) {
|
2010-12-05 22:04:16 +00:00
|
|
|
MachineInstr *DefMI = LastMI;
|
2011-06-28 19:10:37 +00:00
|
|
|
const MCInstrDesc &LastMCID = LastMI->getDesc();
|
2013-06-07 05:54:19 +00:00
|
|
|
const TargetMachine &TM =
|
|
|
|
MI->getParent()->getParent()->getTarget();
|
2014-08-04 21:25:23 +00:00
|
|
|
const ARMBaseInstrInfo &TII = *static_cast<const ARMBaseInstrInfo *>(
|
|
|
|
TM.getSubtargetImpl()->getInstrInfo());
|
2013-06-07 05:54:19 +00:00
|
|
|
|
2010-12-05 22:04:16 +00:00
|
|
|
// Skip over one non-VFP / NEON instruction.
|
2011-12-07 07:15:52 +00:00
|
|
|
if (!LastMI->isBarrier() &&
|
2011-04-19 18:11:57 +00:00
|
|
|
// On A9, AGU and NEON/FPU are muxed.
|
2013-06-07 05:54:19 +00:00
|
|
|
!(TII.getSubtarget().isLikeA9() &&
|
|
|
|
(LastMI->mayLoad() || LastMI->mayStore())) &&
|
2011-06-28 19:10:37 +00:00
|
|
|
(LastMCID.TSFlags & ARMII::DomainMask) == ARMII::DomainGeneral) {
|
2010-12-05 22:04:16 +00:00
|
|
|
MachineBasicBlock::iterator I = LastMI;
|
|
|
|
if (I != LastMI->getParent()->begin()) {
|
2014-03-02 12:27:27 +00:00
|
|
|
I = std::prev(I);
|
2010-12-05 22:04:16 +00:00
|
|
|
DefMI = &*I;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TII.isFpMLxInstruction(DefMI->getOpcode()) &&
|
|
|
|
(TII.canCauseFpMLxStall(MI->getOpcode()) ||
|
2013-06-07 05:54:19 +00:00
|
|
|
hasRAWHazard(DefMI, MI, TII.getRegisterInfo()))) {
|
2010-12-05 22:04:16 +00: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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
if (FpMLxStalls == 0)
|
|
|
|
FpMLxStalls = 4;
|
2010-12-05 22:04:16 +00: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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
return ScoreboardHazardRecognizer::getHazardType(SU, Stalls);
|
2010-12-05 22:04:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ARMHazardRecognizer::Reset() {
|
2014-04-25 05:30:21 +00: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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
FpMLxStalls = 0;
|
2010-12-08 20:04:29 +00:00
|
|
|
ScoreboardHazardRecognizer::Reset();
|
2010-12-05 22:04:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ARMHazardRecognizer::EmitInstruction(SUnit *SU) {
|
|
|
|
MachineInstr *MI = SU->getInstr();
|
|
|
|
if (!MI->isDebugValue()) {
|
|
|
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
FpMLxStalls = 0;
|
2010-12-05 22:04:16 +00:00
|
|
|
}
|
|
|
|
|
2010-12-08 20:04:29 +00:00
|
|
|
ScoreboardHazardRecognizer::EmitInstruction(SU);
|
2010-12-05 22:04:16 +00: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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
if (FpMLxStalls && --FpMLxStalls == 0)
|
2010-12-05 22:04:16 +00:00
|
|
|
// Stalled for 4 cycles but still can't schedule any other instructions.
|
2014-04-25 05:30:21 +00:00
|
|
|
LastMI = nullptr;
|
2010-12-08 20:04:29 +00:00
|
|
|
ScoreboardHazardRecognizer::AdvanceCycle();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ARMHazardRecognizer::RecedeCycle() {
|
|
|
|
llvm_unreachable("reverse ARM hazard checking unsupported");
|
2010-12-05 22:04:16 +00:00
|
|
|
}
|