35 cl::desc(
"Use TargetSchedModel for latency lookup"));
38 cl::desc(
"Use InstrItineraryData for latency lookup"));
48 static unsigned gcd(
unsigned Dividend,
unsigned Divisor) {
51 unsigned Rem = Dividend % Divisor;
58 static unsigned lcm(
unsigned A,
unsigned B) {
59 unsigned LCM = (uint64_t(A) *
B) /
gcd(A, B);
60 assert((LCM >= A && LCM >= B) &&
"LCM overflow");
73 ResourceFactors.
resize(NumRes);
75 for (
unsigned Idx = 0; Idx < NumRes; ++Idx) {
78 ResourceLCM =
lcm(ResourceLCM, NumUnits);
80 MicroOpFactor = ResourceLCM / SchedModel.
IssueWidth;
81 for (
unsigned Idx = 0; Idx < NumRes; ++Idx) {
83 ResourceFactors[Idx] = NumUnits ? (ResourceLCM / NumUnits) : 0;
114 return (UOps >= 0) ? UOps : TII->
getNumMicroOps(&InstrItins, *MI);
130 return Cycles >= 0 ? Cycles : 1000;
147 assert(++NIter < 6 &&
"Variants are nested deeper than the magic number");
162 for (
unsigned i = 0; i != DefOperIdx; ++i) {
178 for (
unsigned i = 0; i != UseOperIdx; ++i) {
204 if (OperLatency >= 0)
221 unsigned DefIdx =
findDefIdx(DefMI, DefOperIdx);
222 if (DefIdx < SCDesc->NumWriteLatencyEntries) {
235 unsigned UseIdx =
findUseIdx(UseMI, UseOperIdx);
237 if (Advance > 0 && (
unsigned)Advance > Latency)
239 return Latency - Advance;
247 errs() <<
"DefIdx " << DefIdx <<
" exceeds machine model writes for "
248 << *DefMI <<
" (Try with MCSchedModel.CompleteModel set to false)";
262 DefIdx != DefEnd; ++DefIdx) {
271 unsigned TargetSchedModel::computeInstrLatency(
unsigned Opcode)
const {
278 return computeInstrLatency(*SCDesc);
281 assert (!SCDesc->
isVariant() &&
"No MI sched latency: SCDesc->isVariant()");
282 return computeInstrLatency(*SCDesc);
289 bool UseDefaultDefLatency)
const {
299 return computeInstrLatency(*SCDesc);
322 return computeInstrLatency(DefMI);
342 double Unknown = std::numeric_limits<double>::infinity();
343 double Throughput = Unknown;
348 unsigned Cycles = IS->getCycles();
355 return 1 / Throughput;
362 double Unknown = std::numeric_limits<double>::infinity();
363 double Throughput = Unknown;
367 WPR != WEnd; ++WPR) {
368 unsigned Cycles = WPR->Cycles;
374 Throughput =
std::min(Throughput, NumUnits * 1.0 / Cycles);
377 return 1 / Throughput;
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
const MCSchedClassDesc * resolveSchedClass(const MachineInstr *MI) const
Return the MCSchedClassDesc for this instruction.
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
bool hasInstrItineraries() const
Return true if this machine model includes cycle-to-cycle itinerary data.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
virtual unsigned getInstrLatency(const InstrItineraryData *ItinData, const MachineInstr &MI, unsigned *PredCost=nullptr) const
Compute the instruction latency of a given instruction.
bool mustEndGroup(const MachineInstr *MI, const MCSchedClassDesc *SC=nullptr) const
Return true if current group must end.
static unsigned lcm(unsigned A, unsigned B)
int getNumMicroOps(unsigned ItinClassIndx) const
Return the number of micro-ops that the given class decodes to.
const MCWriteProcResEntry * getWriteProcResBegin(const MCSchedClassDesc *SC) const
Return an iterator at the first process resource consumed by the given scheduling class...
unsigned computeOutputLatency(const MachineInstr *DefMI, unsigned DefIdx, const MachineInstr *DepMI) const
Output dependency latency of a pair of defs of the same register.
Maximum length of the test input libFuzzer tries to guess a good value based on the corpus and reports it always prefer smaller inputs during the corpus shuffle When libFuzzer itself reports a bug this exit code will be used If indicates the maximal total time in seconds to run the fuzzer minimizes the provided crash input Use with tries to cleanse the provided crash input to make it contain fewer original bytes Use with exact_artifact_path to specify the output Experimental Use value profile to guide fuzzing Number of jobs to run If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
bool mustBeginGroup(const MachineInstr *MI, const MCSchedClassDesc *SC=nullptr) const
Return true if new group must begin.
unsigned short NumMicroOps
unsigned defaultDefLatency(const MCSchedModel &SchedModel, const MachineInstr &DefMI) const
Return the default expected latency for a def based on its opcode.
void init(const MCSchedModel &sm, const TargetSubtargetInfo *sti, const TargetInstrInfo *tii)
Initialize the machine model for instruction scheduling.
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
const MCProcResourceDesc * getProcResource(unsigned ProcResourceIdx) const
static unsigned gcd(unsigned Dividend, unsigned Divisor)
int getOperandCycle(unsigned ItinClassIndx, unsigned OperandIdx) const
Return the cycle for the given class and operand.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void initInstrItins(InstrItineraryData &InstrItins) const
Initialize an InstrItineraryData instance.
const MCWriteProcResEntry * getWriteProcResEnd(const MCSchedClassDesc *SC) const
static cl::opt< bool > EnableSchedItins("scheditins", cl::Hidden, cl::init(true), cl::desc("Use InstrItineraryData for latency lookup"))
const InstrStage * beginStage(unsigned ItinClassIndx) const
Return the first stage of the itinerary.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
int getReadAdvanceCycles(const MCSchedClassDesc *SC, unsigned UseIdx, unsigned WriteResID) const
Reg
All possible values of the reg field in the ModR/M byte.
INITIALIZE_PASS(AArch64VectorByElementOpt,"aarch64-vectorbyelement-opt", AARCH64_VECTOR_BY_ELEMENT_OPT_NAME, false, false) bool AArch64VectorByElementOpt unsigned SCIdx
Based only on latency of instructions, determine if it is cost efficient to replace the instruction I...
static Optional< double > getRThroughputFromInstrSchedModel(const MCSchedClassDesc *SCDesc, const TargetSubtargetInfo *STI, const MCSchedModel &SchedModel)
Itinerary data supplied by a subtarget to be used by a target.
unsigned NumReadAdvanceEntries
const MachineBasicBlock * getParent() const
TargetInstrInfo - Interface to description of machine instruction set.
static Optional< double > getRThroughputFromItineraries(unsigned schedClass, const InstrItineraryData *IID)
unsigned getNumProcResourceKinds() const
initializer< Ty > init(const Ty &Val)
unsigned NumWriteLatencyEntries
const InstrItineraryData * getInstrItineraries() const
Identify one of the processor resource kinds consumed by a particular scheduling class for the specif...
bool isOptionalDef() const
Set if this operand is a optional def.
MachineInstrBuilder & UseMI
const MachineOperand & getOperand(unsigned i) const
Summarize the scheduling resources required for an instruction of a particular scheduling class...
const MCWriteLatencyEntry * getWriteLatencyEntry(const MCSchedClassDesc *SC, unsigned DefIdx) const
bool hasInstrSchedModel() const
Does this machine model include instruction-level scheduling.
Optional< double > computeInstrRThroughput(const MachineInstr *MI) const
Compute the reciprocal throughput of the given instruction.
const MCSchedClassDesc * getSchedClassDesc(unsigned SchedClassIdx) const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
const InstrStage * endStage(unsigned ItinClassIndx) const
Return the last+1 stage of the itinerary.
bool hasInstrSchedModel() const
Return true if this machine model includes an instruction-level scheduling model. ...
bool readsRegister(unsigned Reg, const TargetRegisterInfo *TRI=nullptr) const
Return true if the MachineInstr reads the specified register.
unsigned countPopulation(T Value)
Count the number of set bits in a value.
Specify the latency in cpu cycles for a particular scheduling class and def index.
MachineOperand class - Representation of each machine instruction operand.
virtual unsigned resolveSchedClass(unsigned SchedClass, const MachineInstr *MI, const TargetSchedModel *SchedModel) const
Resolve a SchedClass at runtime, where SchedClass identifies an MCSchedClassDesc with the isVariant p...
CHAIN = SC CHAIN, Imm128 - System call.
bool isTransient() const
Return true if this is a transient instruction that is either very likely to be eliminated during reg...
static unsigned findUseIdx(const MachineInstr *MI, unsigned UseOperIdx)
Find the use index of this operand.
llvm_unreachable("Unknown RegBank!")
TargetSubtargetInfo - Generic base class for all target subtargets.
unsigned getNumMicroOps(const MachineInstr *MI, const MCSchedClassDesc *SC=nullptr) const
Return the number of issue slots required for this MI.
Representation of each machine instruction.
unsigned getSchedClass() const
Return the scheduling class for this instruction.
These values represent a non-pipelined step in the execution of an instruction.
virtual bool isPredicated(const MachineInstr &MI) const
Returns true if the instruction is already predicated.
static cl::opt< bool > EnableSchedModel("schedmodel", cl::Hidden, cl::init(true), cl::desc("Use TargetSchedModel for latency lookup"))
bool isComplete() const
Return true if this machine model data for all instructions with a scheduling class (itinerary class ...
virtual int getOperandLatency(const InstrItineraryData *ItinData, SDNode *DefNode, unsigned DefIdx, SDNode *UseNode, unsigned UseIdx) const
unsigned computeOperandLatency(const MachineInstr *DefMI, unsigned DefOperIdx, const MachineInstr *UseMI, unsigned UseOperIdx) const
Compute operand latency based on the available machine model.
virtual unsigned getNumMicroOps(const InstrItineraryData *ItinData, const MachineInstr &MI) const
Return the number of u-operations the given machine instruction will be decoded to on the target cpu...
unsigned getReg() const
getReg - Returns the register number.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool isOutOfOrder() const
Return true if machine supports out of order execution.
const MCOperandInfo * OpInfo
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
bool readsReg() const
readsReg - Returns true if this operand reads the previous value of its register. ...
static unsigned findDefIdx(const MachineInstr *MI, unsigned DefOperIdx)
Find the def index of this operand.
Machine model for scheduling, bundling, and heuristics.
bool isEmpty() const
Returns true if there are no itineraries.
static unsigned capLatency(int Cycles)
const MCSchedClassDesc * SCDesc