003 File Manager
Current Path:
/usr/src/contrib/llvm-project/llvm/lib/Target/SystemZ
usr
/
src
/
contrib
/
llvm-project
/
llvm
/
lib
/
Target
/
SystemZ
/
📁
..
📁
AsmParser
📁
Disassembler
📁
MCTargetDesc
📄
README.txt
(3.94 KB)
📄
SystemZ.h
(8.19 KB)
📄
SystemZ.td
(2.86 KB)
📄
SystemZAsmPrinter.cpp
(23.49 KB)
📄
SystemZAsmPrinter.h
(1.88 KB)
📄
SystemZCallingConv.cpp
(710 B)
📄
SystemZCallingConv.h
(4.89 KB)
📄
SystemZCallingConv.td
(6.99 KB)
📄
SystemZConstantPoolValue.cpp
(1.78 KB)
📄
SystemZConstantPoolValue.h
(1.75 KB)
📄
SystemZCopyPhysRegs.cpp
(3.82 KB)
📄
SystemZElimCompare.cpp
(26.21 KB)
📄
SystemZFeatures.td
(12.3 KB)
📄
SystemZFrameLowering.cpp
(29.88 KB)
📄
SystemZFrameLowering.h
(3.02 KB)
📄
SystemZHazardRecognizer.cpp
(14.75 KB)
📄
SystemZHazardRecognizer.h
(5.86 KB)
📄
SystemZISelDAGToDAG.cpp
(68.74 KB)
📄
SystemZISelLowering.cpp
(321.22 KB)
📄
SystemZISelLowering.h
(28.44 KB)
📄
SystemZInstrBuilder.h
(1.63 KB)
📄
SystemZInstrDFP.td
(9.3 KB)
📄
SystemZInstrFP.td
(26.21 KB)
📄
SystemZInstrFormats.td
(182.82 KB)
📄
SystemZInstrHFP.td
(9.46 KB)
📄
SystemZInstrInfo.cpp
(69.75 KB)
📄
SystemZInstrInfo.h
(14.6 KB)
📄
SystemZInstrInfo.td
(103.17 KB)
📄
SystemZInstrSystem.td
(17.18 KB)
📄
SystemZInstrVector.td
(84.36 KB)
📄
SystemZLDCleanup.cpp
(4.91 KB)
📄
SystemZLongBranch.cpp
(16.04 KB)
📄
SystemZMCInstLower.cpp
(3.16 KB)
📄
SystemZMCInstLower.h
(1.28 KB)
📄
SystemZMachineFunctionInfo.cpp
(508 B)
📄
SystemZMachineFunctionInfo.h
(3.77 KB)
📄
SystemZMachineScheduler.cpp
(8.76 KB)
📄
SystemZMachineScheduler.h
(5.05 KB)
📄
SystemZOperands.td
(24.89 KB)
📄
SystemZOperators.td
(48.97 KB)
📄
SystemZPatterns.td
(8.52 KB)
📄
SystemZPostRewrite.cpp
(10.33 KB)
📄
SystemZProcessors.td
(1.78 KB)
📄
SystemZRegisterInfo.cpp
(16.27 KB)
📄
SystemZRegisterInfo.h
(3.52 KB)
📄
SystemZRegisterInfo.td
(12.04 KB)
📄
SystemZSchedule.td
(2.1 KB)
📄
SystemZScheduleZ13.td
(72.43 KB)
📄
SystemZScheduleZ14.td
(78.06 KB)
📄
SystemZScheduleZ15.td
(80.69 KB)
📄
SystemZScheduleZ196.td
(55.68 KB)
📄
SystemZScheduleZEC12.td
(57.44 KB)
📄
SystemZSelectionDAGInfo.cpp
(12.92 KB)
📄
SystemZSelectionDAGInfo.h
(3.15 KB)
📄
SystemZShortenInst.cpp
(12 KB)
📄
SystemZSubtarget.cpp
(3.67 KB)
📄
SystemZSubtarget.h
(9.14 KB)
📄
SystemZTDC.cpp
(13.52 KB)
📄
SystemZTargetMachine.cpp
(11.58 KB)
📄
SystemZTargetMachine.h
(2.09 KB)
📄
SystemZTargetTransformInfo.cpp
(43.51 KB)
📄
SystemZTargetTransformInfo.h
(4.88 KB)
📁
TargetInfo
Editing: SystemZMachineScheduler.cpp
//-- SystemZMachineScheduler.cpp - SystemZ Scheduler Interface -*- C++ -*---==// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // -------------------------- Post RA scheduling ---------------------------- // // SystemZPostRASchedStrategy is a scheduling strategy which is plugged into // the MachineScheduler. It has a sorted Available set of SUs and a pickNode() // implementation that looks to optimize decoder grouping and balance the // usage of processor resources. Scheduler states are saved for the end // region of each MBB, so that a successor block can learn from it. //===----------------------------------------------------------------------===// #include "SystemZMachineScheduler.h" #include "llvm/CodeGen/MachineLoopInfo.h" using namespace llvm; #define DEBUG_TYPE "machine-scheduler" #ifndef NDEBUG // Print the set of SUs void SystemZPostRASchedStrategy::SUSet:: dump(SystemZHazardRecognizer &HazardRec) const { dbgs() << "{"; for (auto &SU : *this) { HazardRec.dumpSU(SU, dbgs()); if (SU != *rbegin()) dbgs() << ", "; } dbgs() << "}\n"; } #endif // Try to find a single predecessor that would be interesting for the // scheduler in the top-most region of MBB. static MachineBasicBlock *getSingleSchedPred(MachineBasicBlock *MBB, const MachineLoop *Loop) { MachineBasicBlock *PredMBB = nullptr; if (MBB->pred_size() == 1) PredMBB = *MBB->pred_begin(); // The loop header has two predecessors, return the latch, but not for a // single block loop. if (MBB->pred_size() == 2 && Loop != nullptr && Loop->getHeader() == MBB) { for (auto I = MBB->pred_begin(); I != MBB->pred_end(); ++I) if (Loop->contains(*I)) PredMBB = (*I == MBB ? nullptr : *I); } assert ((PredMBB == nullptr || !Loop || Loop->contains(PredMBB)) && "Loop MBB should not consider predecessor outside of loop."); return PredMBB; } void SystemZPostRASchedStrategy:: advanceTo(MachineBasicBlock::iterator NextBegin) { MachineBasicBlock::iterator LastEmittedMI = HazardRec->getLastEmittedMI(); MachineBasicBlock::iterator I = ((LastEmittedMI != nullptr && LastEmittedMI->getParent() == MBB) ? std::next(LastEmittedMI) : MBB->begin()); for (; I != NextBegin; ++I) { if (I->isPosition() || I->isDebugInstr()) continue; HazardRec->emitInstruction(&*I); } } void SystemZPostRASchedStrategy::initialize(ScheduleDAGMI *dag) { LLVM_DEBUG(HazardRec->dumpState();); } void SystemZPostRASchedStrategy::enterMBB(MachineBasicBlock *NextMBB) { assert ((SchedStates.find(NextMBB) == SchedStates.end()) && "Entering MBB twice?"); LLVM_DEBUG(dbgs() << "** Entering " << printMBBReference(*NextMBB)); MBB = NextMBB; /// Create a HazardRec for MBB, save it in SchedStates and set HazardRec to /// point to it. HazardRec = SchedStates[MBB] = new SystemZHazardRecognizer(TII, &SchedModel); LLVM_DEBUG(const MachineLoop *Loop = MLI->getLoopFor(MBB); if (Loop && Loop->getHeader() == MBB) dbgs() << " (Loop header)"; dbgs() << ":\n";); // Try to take over the state from a single predecessor, if it has been // scheduled. If this is not possible, we are done. MachineBasicBlock *SinglePredMBB = getSingleSchedPred(MBB, MLI->getLoopFor(MBB)); if (SinglePredMBB == nullptr || SchedStates.find(SinglePredMBB) == SchedStates.end()) return; LLVM_DEBUG(dbgs() << "** Continued scheduling from " << printMBBReference(*SinglePredMBB) << "\n";); HazardRec->copyState(SchedStates[SinglePredMBB]); LLVM_DEBUG(HazardRec->dumpState();); // Emit incoming terminator(s). Be optimistic and assume that branch // prediction will generally do "the right thing". for (MachineBasicBlock::iterator I = SinglePredMBB->getFirstTerminator(); I != SinglePredMBB->end(); I++) { LLVM_DEBUG(dbgs() << "** Emitting incoming branch: "; I->dump();); bool TakenBranch = (I->isBranch() && (TII->getBranchInfo(*I).isIndirect() || TII->getBranchInfo(*I).getMBBTarget() == MBB)); HazardRec->emitInstruction(&*I, TakenBranch); if (TakenBranch) break; } } void SystemZPostRASchedStrategy::leaveMBB() { LLVM_DEBUG(dbgs() << "** Leaving " << printMBBReference(*MBB) << "\n";); // Advance to first terminator. The successor block will handle terminators // dependent on CFG layout (T/NT branch etc). advanceTo(MBB->getFirstTerminator()); } SystemZPostRASchedStrategy:: SystemZPostRASchedStrategy(const MachineSchedContext *C) : MLI(C->MLI), TII(static_cast<const SystemZInstrInfo *> (C->MF->getSubtarget().getInstrInfo())), MBB(nullptr), HazardRec(nullptr) { const TargetSubtargetInfo *ST = &C->MF->getSubtarget(); SchedModel.init(ST); } SystemZPostRASchedStrategy::~SystemZPostRASchedStrategy() { // Delete hazard recognizers kept around for each MBB. for (auto I : SchedStates) { SystemZHazardRecognizer *hazrec = I.second; delete hazrec; } } void SystemZPostRASchedStrategy::initPolicy(MachineBasicBlock::iterator Begin, MachineBasicBlock::iterator End, unsigned NumRegionInstrs) { // Don't emit the terminators. if (Begin->isTerminator()) return; // Emit any instructions before start of region. advanceTo(Begin); } // Pick the next node to schedule. SUnit *SystemZPostRASchedStrategy::pickNode(bool &IsTopNode) { // Only scheduling top-down. IsTopNode = true; if (Available.empty()) return nullptr; // If only one choice, return it. if (Available.size() == 1) { LLVM_DEBUG(dbgs() << "** Only one: "; HazardRec->dumpSU(*Available.begin(), dbgs()); dbgs() << "\n";); return *Available.begin(); } // All nodes that are possible to schedule are stored in the Available set. LLVM_DEBUG(dbgs() << "** Available: "; Available.dump(*HazardRec);); Candidate Best; for (auto *SU : Available) { // SU is the next candidate to be compared against current Best. Candidate c(SU, *HazardRec); // Remeber which SU is the best candidate. if (Best.SU == nullptr || c < Best) { Best = c; LLVM_DEBUG(dbgs() << "** Best so far: ";); } else LLVM_DEBUG(dbgs() << "** Tried : ";); LLVM_DEBUG(HazardRec->dumpSU(c.SU, dbgs()); c.dumpCosts(); dbgs() << " Height:" << c.SU->getHeight(); dbgs() << "\n";); // Once we know we have seen all SUs that affect grouping or use unbuffered // resources, we can stop iterating if Best looks good. if (!SU->isScheduleHigh && Best.noCost()) break; } assert (Best.SU != nullptr); return Best.SU; } SystemZPostRASchedStrategy::Candidate:: Candidate(SUnit *SU_, SystemZHazardRecognizer &HazardRec) : Candidate() { SU = SU_; // Check the grouping cost. For a node that must begin / end a // group, it is positive if it would do so prematurely, or negative // if it would fit naturally into the schedule. GroupingCost = HazardRec.groupingCost(SU); // Check the resources cost for this SU. ResourcesCost = HazardRec.resourcesCost(SU); } bool SystemZPostRASchedStrategy::Candidate:: operator<(const Candidate &other) { // Check decoder grouping. if (GroupingCost < other.GroupingCost) return true; if (GroupingCost > other.GroupingCost) return false; // Compare the use of resources. if (ResourcesCost < other.ResourcesCost) return true; if (ResourcesCost > other.ResourcesCost) return false; // Higher SU is otherwise generally better. if (SU->getHeight() > other.SU->getHeight()) return true; if (SU->getHeight() < other.SU->getHeight()) return false; // If all same, fall back to original order. if (SU->NodeNum < other.SU->NodeNum) return true; return false; } void SystemZPostRASchedStrategy::schedNode(SUnit *SU, bool IsTopNode) { LLVM_DEBUG(dbgs() << "** Scheduling SU(" << SU->NodeNum << ") "; if (Available.size() == 1) dbgs() << "(only one) "; Candidate c(SU, *HazardRec); c.dumpCosts(); dbgs() << "\n";); // Remove SU from Available set and update HazardRec. Available.erase(SU); HazardRec->EmitInstruction(SU); } void SystemZPostRASchedStrategy::releaseTopNode(SUnit *SU) { // Set isScheduleHigh flag on all SUs that we want to consider first in // pickNode(). const MCSchedClassDesc *SC = HazardRec->getSchedClass(SU); bool AffectsGrouping = (SC->isValid() && (SC->BeginGroup || SC->EndGroup)); SU->isScheduleHigh = (AffectsGrouping || SU->isUnbuffered); // Put all released SUs in the Available set. Available.insert(SU); }
Upload File
Create Folder