#include "ScheduleDAGSDNodes.h"
#include "InstrEmitter.h"
#include "SDNodeDbgValue.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/SelectionDAG.h"
#include "llvm/CodeGen/TargetInstrInfo.h"
#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/IR/MemoryModelRelaxationAnnotations.h"
#include "llvm/MC/MCInstrItineraries.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
usingnamespacellvm;
#define DEBUG_TYPE …
STATISTIC(LoadsClustered, "Number of loads clustered together");
static cl::opt<int> HighLatencyCycles(
"sched-high-latency-cycles", cl::Hidden, cl::init(10),
cl::desc("Roughly estimate the number of cycles that 'long latency'"
"instructions take for targets with no itinerary"));
ScheduleDAGSDNodes::ScheduleDAGSDNodes(MachineFunction &mf)
: … { … }
void ScheduleDAGSDNodes::Run(SelectionDAG *dag, MachineBasicBlock *bb) { … }
SUnit *ScheduleDAGSDNodes::newSUnit(SDNode *N) { … }
SUnit *ScheduleDAGSDNodes::Clone(SUnit *Old) { … }
static void CheckForPhysRegDependency(SDNode *Def, SDNode *User, unsigned Op,
const TargetRegisterInfo *TRI,
const TargetInstrInfo *TII,
const TargetLowering &TLI,
unsigned &PhysReg, int &Cost) { … }
static void CloneNodeWithValues(SDNode *N, SelectionDAG *DAG, ArrayRef<EVT> VTs,
SDValue ExtraOper = SDValue()) { … }
static bool AddGlue(SDNode *N, SDValue Glue, bool AddGlue, SelectionDAG *DAG) { … }
static void RemoveUnusedGlue(SDNode *N, SelectionDAG *DAG) { … }
void ScheduleDAGSDNodes::ClusterNeighboringLoads(SDNode *Node) { … }
void ScheduleDAGSDNodes::ClusterNodes() { … }
void ScheduleDAGSDNodes::BuildSchedUnits() { … }
void ScheduleDAGSDNodes::AddSchedEdges() { … }
void ScheduleDAGSDNodes::BuildSchedGraph(AAResults *AA) { … }
void ScheduleDAGSDNodes::RegDefIter::InitNodeNumDefs() { … }
ScheduleDAGSDNodes::RegDefIter::RegDefIter(const SUnit *SU,
const ScheduleDAGSDNodes *SD)
: … { … }
void ScheduleDAGSDNodes::RegDefIter::Advance() { … }
void ScheduleDAGSDNodes::InitNumRegDefsLeft(SUnit *SU) { … }
void ScheduleDAGSDNodes::computeLatency(SUnit *SU) { … }
void ScheduleDAGSDNodes::computeOperandLatency(SDNode *Def, SDNode *Use,
unsigned OpIdx, SDep& dep) const{ … }
void ScheduleDAGSDNodes::dumpNode(const SUnit &SU) const { … }
void ScheduleDAGSDNodes::dump() const { … }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void ScheduleDAGSDNodes::dumpSchedule() const {
for (const SUnit *SU : Sequence) {
if (SU)
dumpNode(*SU);
else
dbgs() << "**** NOOP ****\n";
}
}
#endif
#ifndef NDEBUG
void ScheduleDAGSDNodes::VerifyScheduledSequence(bool isBottomUp) {
unsigned ScheduledNodes = ScheduleDAG::VerifyScheduledDAG(isBottomUp);
unsigned Noops = llvm::count(Sequence, nullptr);
assert(Sequence.size() - Noops == ScheduledNodes &&
"The number of nodes scheduled doesn't match the expected number!");
}
#endif
static void
ProcessSDDbgValues(SDNode *N, SelectionDAG *DAG, InstrEmitter &Emitter,
SmallVectorImpl<std::pair<unsigned, MachineInstr*> > &Orders,
DenseMap<SDValue, Register> &VRBaseMap, unsigned Order) { … }
static void
ProcessSourceNode(SDNode *N, SelectionDAG *DAG, InstrEmitter &Emitter,
DenseMap<SDValue, Register> &VRBaseMap,
SmallVectorImpl<std::pair<unsigned, MachineInstr *>> &Orders,
SmallSet<Register, 8> &Seen, MachineInstr *NewInsn) { … }
void ScheduleDAGSDNodes::
EmitPhysRegCopy(SUnit *SU, DenseMap<SUnit*, Register> &VRBaseMap,
MachineBasicBlock::iterator InsertPos) { … }
MachineBasicBlock *ScheduleDAGSDNodes::
EmitSchedule(MachineBasicBlock::iterator &InsertPos) { … }
std::string ScheduleDAGSDNodes::getDAGName() const { … }