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"
|
|
|
|
#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-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();
|
|
|
|
|
|
|
|
if (!MI->isDebugValue()) {
|
|
|
|
// 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();
|
2013-06-07 13:54:19 +08:00
|
|
|
const TargetMachine &TM =
|
|
|
|
MI->getParent()->getParent()->getTarget();
|
|
|
|
const ARMBaseInstrInfo &TII =
|
|
|
|
*static_cast<const ARMBaseInstrInfo*>(TM.getInstrInfo());
|
|
|
|
|
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() &&
|
2011-04-20 02:11:57 +08:00
|
|
|
// On A9, AGU and NEON/FPU are muxed.
|
2013-06-07 13:54:19 +08:00
|
|
|
!(TII.getSubtarget().isLikeA9() &&
|
|
|
|
(LastMI->mayLoad() || LastMI->mayStore())) &&
|
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()) {
|
|
|
|
I = llvm::prior(I);
|
|
|
|
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() {
|
|
|
|
LastMI = 0;
|
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();
|
|
|
|
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.
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.
|
|
|
|
LastMI = 0;
|
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
|
|
|
}
|