123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- #pragma once
- #ifdef __GNUC__
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wunused-parameter"
- #endif
- #ifndef LLVM_CODEGEN_TARGETSCHEDULE_H
- #define LLVM_CODEGEN_TARGETSCHEDULE_H
- #include "llvm/ADT/SmallVector.h"
- #include "llvm/CodeGen/TargetSubtargetInfo.h"
- #include "llvm/Config/llvm-config.h"
- #include "llvm/MC/MCInstrItineraries.h"
- #include "llvm/MC/MCSchedule.h"
- namespace llvm {
- class MachineInstr;
- class TargetInstrInfo;
- class TargetSchedModel {
-
-
- MCSchedModel SchedModel;
- InstrItineraryData InstrItins;
- const TargetSubtargetInfo *STI = nullptr;
- const TargetInstrInfo *TII = nullptr;
- SmallVector<unsigned, 16> ResourceFactors;
-
- unsigned MicroOpFactor = 0;
-
- unsigned ResourceLCM = 0;
- unsigned computeInstrLatency(const MCSchedClassDesc &SCDesc) const;
- public:
- TargetSchedModel() : SchedModel(MCSchedModel::GetDefaultSchedModel()) {}
-
-
-
-
-
- void init(const TargetSubtargetInfo *TSInfo);
-
- const MCSchedClassDesc *resolveSchedClass(const MachineInstr *MI) const;
-
- const TargetSubtargetInfo *getSubtargetInfo() const { return STI; }
-
- const TargetInstrInfo *getInstrInfo() const { return TII; }
-
-
-
-
-
- bool hasInstrSchedModel() const;
- const MCSchedModel *getMCSchedModel() const { return &SchedModel; }
-
-
-
-
- bool hasInstrItineraries() const;
- const InstrItineraryData *getInstrItineraries() const {
- if (hasInstrItineraries())
- return &InstrItins;
- return nullptr;
- }
-
-
- bool hasInstrSchedModelOrItineraries() const {
- return hasInstrSchedModel() || hasInstrItineraries();
- }
-
- unsigned getProcessorID() const { return SchedModel.getProcessorID(); }
-
- unsigned getIssueWidth() const { return SchedModel.IssueWidth; }
-
- bool mustBeginGroup(const MachineInstr *MI,
- const MCSchedClassDesc *SC = nullptr) const;
-
- bool mustEndGroup(const MachineInstr *MI,
- const MCSchedClassDesc *SC = nullptr) const;
-
- unsigned getNumMicroOps(const MachineInstr *MI,
- const MCSchedClassDesc *SC = nullptr) const;
-
- unsigned getNumProcResourceKinds() const {
- return SchedModel.getNumProcResourceKinds();
- }
-
- const MCProcResourceDesc *getProcResource(unsigned PIdx) const {
- return SchedModel.getProcResource(PIdx);
- }
- #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- const char *getResourceName(unsigned PIdx) const {
- if (!PIdx)
- return "MOps";
- return SchedModel.getProcResource(PIdx)->Name;
- }
- #endif
- using ProcResIter = const MCWriteProcResEntry *;
-
-
- ProcResIter getWriteProcResBegin(const MCSchedClassDesc *SC) const {
-
- return STI->getWriteProcResBegin(SC);
- }
- ProcResIter getWriteProcResEnd(const MCSchedClassDesc *SC) const {
- return STI->getWriteProcResEnd(SC);
- }
-
-
- unsigned getResourceFactor(unsigned ResIdx) const {
- return ResourceFactors[ResIdx];
- }
-
-
- unsigned getMicroOpFactor() const {
- return MicroOpFactor;
- }
-
-
- unsigned getLatencyFactor() const {
- return ResourceLCM;
- }
-
- unsigned getMicroOpBufferSize() const { return SchedModel.MicroOpBufferSize; }
-
-
- int getResourceBufferSize(unsigned PIdx) const {
- return SchedModel.getProcResource(PIdx)->BufferSize;
- }
-
-
-
-
-
- unsigned computeOperandLatency(const MachineInstr *DefMI, unsigned DefOperIdx,
- const MachineInstr *UseMI, unsigned UseOperIdx)
- const;
-
-
-
-
-
-
-
-
-
-
-
- unsigned computeInstrLatency(const MachineInstr *MI,
- bool UseDefaultDefLatency = true) const;
- unsigned computeInstrLatency(const MCInst &Inst) const;
- unsigned computeInstrLatency(unsigned Opcode) const;
-
-
-
- unsigned computeOutputLatency(const MachineInstr *DefMI, unsigned DefOperIdx,
- const MachineInstr *DepMI) const;
-
- double computeReciprocalThroughput(const MachineInstr *MI) const;
- double computeReciprocalThroughput(const MCInst &MI) const;
- double computeReciprocalThroughput(unsigned Opcode) const;
- };
- }
- #endif
- #ifdef __GNUC__
- #pragma GCC diagnostic pop
- #endif
|