#include "llvm/CodeGen/ScheduleDAGInstrs.h"
#include "llvm/ADT/IntEqClasses.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/SparseSet.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/CodeGen/LiveIntervals.h"
#include "llvm/CodeGen/LivePhysRegs.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBundle.h"
#include "llvm/CodeGen/MachineMemOperand.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/PseudoSourceValue.h"
#include "llvm/CodeGen/RegisterPressure.h"
#include "llvm/CodeGen/ScheduleDAG.h"
#include "llvm/CodeGen/ScheduleDFS.h"
#include "llvm/CodeGen/SlotIndexes.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Value.h"
#include "llvm/MC/LaneBitmask.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
#include <iterator>
#include <utility>
#include <vector>
usingnamespacellvm;
#define DEBUG_TYPE …
static cl::opt<bool>
EnableAASchedMI("enable-aa-sched-mi", cl::Hidden,
cl::desc("Enable use of AA during MI DAG construction"));
static cl::opt<bool> UseTBAA("use-tbaa-in-sched-mi", cl::Hidden,
cl::init(true), cl::desc("Enable use of TBAA during MI DAG construction"));
static cl::opt<unsigned> HugeRegion("dag-maps-huge-region", cl::Hidden,
cl::init(1000), cl::desc("The limit to use while constructing the DAG "
"prior to scheduling, at which point a trade-off "
"is made to avoid excessive compile time."));
static cl::opt<unsigned> ReductionSize(
"dag-maps-reduction-size", cl::Hidden,
cl::desc("A huge scheduling region will have maps reduced by this many "
"nodes at a time. Defaults to HugeRegion / 2."));
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
static cl::opt<bool> SchedPrintCycles(
"sched-print-cycles", cl::Hidden, cl::init(false),
cl::desc("Report top/bottom cycles when dumping SUnit instances"));
#endif
static unsigned getReductionSize() { … }
static void dumpSUList(const ScheduleDAGInstrs::SUList &L) { … }
ScheduleDAGInstrs::ScheduleDAGInstrs(MachineFunction &mf,
const MachineLoopInfo *mli,
bool RemoveKillFlags)
: … { … }
static bool getUnderlyingObjectsForInstr(const MachineInstr *MI,
const MachineFrameInfo &MFI,
UnderlyingObjectsVector &Objects,
const DataLayout &DL) { … }
void ScheduleDAGInstrs::startBlock(MachineBasicBlock *bb) { … }
void ScheduleDAGInstrs::finishBlock() { … }
void ScheduleDAGInstrs::enterRegion(MachineBasicBlock *bb,
MachineBasicBlock::iterator begin,
MachineBasicBlock::iterator end,
unsigned regioninstrs) { … }
void ScheduleDAGInstrs::exitRegion() { … }
void ScheduleDAGInstrs::addSchedBarrierDeps() { … }
void ScheduleDAGInstrs::addPhysRegDataDeps(SUnit *SU, unsigned OperIdx) { … }
void ScheduleDAGInstrs::addPhysRegDeps(SUnit *SU, unsigned OperIdx) { … }
LaneBitmask ScheduleDAGInstrs::getLaneMaskForMO(const MachineOperand &MO) const
{ … }
bool ScheduleDAGInstrs::deadDefHasNoUse(const MachineOperand &MO) { … }
void ScheduleDAGInstrs::addVRegDefDeps(SUnit *SU, unsigned OperIdx) { … }
void ScheduleDAGInstrs::addVRegUseDeps(SUnit *SU, unsigned OperIdx) { … }
static inline bool isGlobalMemoryObject(MachineInstr *MI) { … }
void ScheduleDAGInstrs::addChainDependency (SUnit *SUa, SUnit *SUb,
unsigned Latency) { … }
void ScheduleDAGInstrs::initSUnits() { … }
class ScheduleDAGInstrs::Value2SUsMap
: public SmallMapVector<ValueType, SUList, 4> { … };
void ScheduleDAGInstrs::addChainDependencies(SUnit *SU,
Value2SUsMap &Val2SUsMap) { … }
void ScheduleDAGInstrs::addChainDependencies(SUnit *SU,
Value2SUsMap &Val2SUsMap,
ValueType V) { … }
void ScheduleDAGInstrs::addBarrierChain(Value2SUsMap &map) { … }
void ScheduleDAGInstrs::insertBarrierChain(Value2SUsMap &map) { … }
void ScheduleDAGInstrs::buildSchedGraph(AAResults *AA,
RegPressureTracker *RPTracker,
PressureDiffs *PDiffs,
LiveIntervals *LIS,
bool TrackLaneMasks) { … }
raw_ostream &llvm::operator<<(raw_ostream &OS, const PseudoSourceValue* PSV) { … }
void ScheduleDAGInstrs::Value2SUsMap::dump() { … }
void ScheduleDAGInstrs::reduceHugeMemNodeMaps(Value2SUsMap &stores,
Value2SUsMap &loads, unsigned N) { … }
static void toggleKills(const MachineRegisterInfo &MRI, LiveRegUnits &LiveRegs,
MachineInstr &MI, bool addToLiveRegs) { … }
void ScheduleDAGInstrs::fixupKills(MachineBasicBlock &MBB) { … }
void ScheduleDAGInstrs::dumpNode(const SUnit &SU) const { … }
void ScheduleDAGInstrs::dump() const { … }
std::string ScheduleDAGInstrs::getGraphNodeLabel(const SUnit *SU) const { … }
std::string ScheduleDAGInstrs::getDAGName() const { … }
bool ScheduleDAGInstrs::canAddEdge(SUnit *SuccSU, SUnit *PredSU) { … }
bool ScheduleDAGInstrs::addEdge(SUnit *SuccSU, const SDep &PredDep) { … }
namespace llvm {
class SchedDFSImpl { … };
}
namespace {
class SchedDAGReverseDFS { … };
}
static bool hasDataSucc(const SUnit *SU) { … }
void SchedDFSResult::compute(ArrayRef<SUnit> SUnits) { … }
void SchedDFSResult::scheduleTree(unsigned SubtreeID) { … }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void ILPValue::print(raw_ostream &OS) const {
OS << InstrCount << " / " << Length << " = ";
if (!Length)
OS << "BADILP";
else
OS << format("%g", ((double)InstrCount / Length));
}
LLVM_DUMP_METHOD void ILPValue::dump() const {
dbgs() << *this << '\n';
}
namespace llvm {
LLVM_ATTRIBUTE_UNUSED
raw_ostream &operator<<(raw_ostream &OS, const ILPValue &Val) {
Val.print(OS);
return OS;
}
}
#endif