2006-03-07 14:32:48 +08:00
|
|
|
//===-- PPCHazardRecognizers.h - PowerPC Hazard Recognizers -----*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 04:36:04 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2006-03-07 14:32:48 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines hazard recognizers for scheduling on PowerPC processors.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef PPCHAZRECS_H
|
|
|
|
#define PPCHAZRECS_H
|
|
|
|
|
2012-03-18 02:46:09 +08:00
|
|
|
#include "PPCInstrInfo.h"
|
2009-01-16 06:18:12 +08:00
|
|
|
#include "llvm/CodeGen/ScheduleHazardRecognizer.h"
|
2011-10-17 12:03:49 +08:00
|
|
|
#include "llvm/CodeGen/ScoreboardHazardRecognizer.h"
|
2009-01-16 06:18:12 +08:00
|
|
|
#include "llvm/CodeGen/SelectionDAGNodes.h"
|
2006-03-07 14:32:48 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
2010-12-24 12:28:06 +08:00
|
|
|
|
2013-12-12 08:19:11 +08:00
|
|
|
/// PPCDispatchGroupSBHazardRecognizer - This class implements a scoreboard-based
|
|
|
|
/// hazard recognizer for PPC ooo processors with dispatch-group hazards.
|
|
|
|
class PPCDispatchGroupSBHazardRecognizer : public ScoreboardHazardRecognizer {
|
|
|
|
const ScheduleDAG *DAG;
|
|
|
|
SmallVector<SUnit *, 7> CurGroup;
|
|
|
|
unsigned CurSlots, CurBranches;
|
|
|
|
|
|
|
|
bool isLoadAfterStore(SUnit *SU);
|
|
|
|
bool isBCTRAfterSet(SUnit *SU);
|
|
|
|
bool mustComeFirst(const MCInstrDesc *MCID, unsigned &NSlots);
|
|
|
|
public:
|
|
|
|
PPCDispatchGroupSBHazardRecognizer(const InstrItineraryData *ItinData,
|
|
|
|
const ScheduleDAG *DAG_) :
|
|
|
|
ScoreboardHazardRecognizer(ItinData, DAG_), DAG(DAG_),
|
|
|
|
CurSlots(0), CurBranches(0) {}
|
|
|
|
|
|
|
|
virtual HazardType getHazardType(SUnit *SU, int Stalls);
|
|
|
|
virtual bool ShouldPreferAnother(SUnit* SU);
|
|
|
|
virtual unsigned PreEmitNoops(SUnit *SU);
|
|
|
|
virtual void EmitInstruction(SUnit *SU);
|
|
|
|
virtual void AdvanceCycle();
|
|
|
|
virtual void RecedeCycle();
|
|
|
|
virtual void Reset();
|
|
|
|
virtual void EmitNoop();
|
|
|
|
};
|
|
|
|
|
2006-03-07 14:32:48 +08:00
|
|
|
/// PPCHazardRecognizer970 - This class defines a finite state automata that
|
|
|
|
/// models the dispatch logic on the PowerPC 970 (aka G5) processor. This
|
|
|
|
/// promotes good dispatch group formation and implements noop insertion to
|
|
|
|
/// avoid structural hazards that cause significant performance penalties (e.g.
|
|
|
|
/// setting the CTR register then branching through it within a dispatch group),
|
|
|
|
/// or storing then loading from the same address within a dispatch group.
|
2009-01-16 06:18:12 +08:00
|
|
|
class PPCHazardRecognizer970 : public ScheduleHazardRecognizer {
|
2013-06-07 15:55:53 +08:00
|
|
|
const TargetMachine &TM;
|
2010-12-24 12:28:06 +08:00
|
|
|
|
2006-03-12 17:13:49 +08:00
|
|
|
unsigned NumIssued; // Number of insts issued, including advanced cycles.
|
2010-12-24 12:28:06 +08:00
|
|
|
|
2006-03-07 14:32:48 +08:00
|
|
|
// Various things that can cause a structural hazard.
|
2010-12-24 12:28:06 +08:00
|
|
|
|
2006-03-07 14:32:48 +08:00
|
|
|
// HasCTRSet - If the CTR register is set in this group, disallow BCTRL.
|
|
|
|
bool HasCTRSet;
|
2010-12-24 12:28:06 +08:00
|
|
|
|
2006-03-07 14:32:48 +08:00
|
|
|
// StoredPtr - Keep track of the address of any store. If we see a load from
|
2006-03-12 17:13:49 +08:00
|
|
|
// the same address (or one that aliases it), disallow the store. We can have
|
|
|
|
// up to four stores in one dispatch group, hence we track up to 4.
|
2006-03-07 14:32:48 +08:00
|
|
|
//
|
|
|
|
// This is null if we haven't seen a store yet. We keep track of both
|
|
|
|
// operands of the store here, since we support [r+r] and [r+i] addressing.
|
2011-12-02 12:58:02 +08:00
|
|
|
const Value *StoreValue[4];
|
|
|
|
int64_t StoreOffset[4];
|
|
|
|
uint64_t StoreSize[4];
|
2006-03-12 17:13:49 +08:00
|
|
|
unsigned NumStores;
|
2010-12-24 12:28:06 +08:00
|
|
|
|
2006-03-07 14:32:48 +08:00
|
|
|
public:
|
2013-06-07 15:55:53 +08:00
|
|
|
PPCHazardRecognizer970(const TargetMachine &TM);
|
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
|
|
|
virtual HazardType getHazardType(SUnit *SU, int Stalls);
|
2009-01-16 06:18:12 +08:00
|
|
|
virtual void EmitInstruction(SUnit *SU);
|
2006-03-07 14:32:48 +08:00
|
|
|
virtual void AdvanceCycle();
|
2011-12-02 12:58:02 +08:00
|
|
|
virtual void Reset();
|
2010-12-24 12:28:06 +08:00
|
|
|
|
2006-03-07 14:32:48 +08:00
|
|
|
private:
|
|
|
|
/// EndDispatchGroup - Called when we are finishing a new dispatch group.
|
|
|
|
///
|
|
|
|
void EndDispatchGroup();
|
2010-12-24 12:28:06 +08:00
|
|
|
|
2006-03-07 14:32:48 +08:00
|
|
|
/// GetInstrType - Classify the specified powerpc opcode according to its
|
|
|
|
/// pipeline.
|
2006-03-12 17:13:49 +08:00
|
|
|
PPCII::PPC970_Unit GetInstrType(unsigned Opcode,
|
2006-03-13 13:20:04 +08:00
|
|
|
bool &isFirst, bool &isSingle,bool &isCracked,
|
2006-03-12 17:13:49 +08:00
|
|
|
bool &isLoad, bool &isStore);
|
2010-12-24 12:28:06 +08:00
|
|
|
|
2011-12-02 12:58:02 +08:00
|
|
|
bool isLoadOfStoredAddress(uint64_t LoadSize, int64_t LoadOffset,
|
|
|
|
const Value *LoadValue) const;
|
2006-03-07 14:32:48 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
2006-03-08 00:19:46 +08:00
|
|
|
#endif
|
|
|
|
|