35 #define DEBUG_TYPE "hexagon-subtarget"
37 #define GET_SUBTARGETINFO_CTOR
38 #define GET_SUBTARGETINFO_TARGET_DESC
39 #include "HexagonGenSubtargetInfo.inc"
43 cl::desc(
"Generate V4 MEMOP in code generation for Hexagon target"));
47 cl::desc(
"Do not generate V4 MEMOP in code generation for Hexagon target"));
51 cl::desc(
"Generate non-chopped conversion from fp to int."));
58 cl::desc(
"Enable Hexagon Double Vector eXtensions"));
62 cl::desc(
"Enable Hexagon Vector eXtensions"));
69 cl::desc(
"Enable the scheduler to generate .cur"));
76 cl::desc(
"Disable Hexagon MI Scheduling"));
80 cl::desc(
"Enable subregister liveness tracking for Hexagon"));
84 cl::desc(
"If present, forces/disables the use of long calls"));
88 cl::desc(
"Consider calls to be predicable"));
90 void HexagonSubtarget::initializeEnvironment() {
92 ModeIEEERndNear =
false;
100 static std::map<StringRef, HexagonArchEnum> CpuTable {
103 {
"hexagonv55",
V55 },
104 {
"hexagonv60",
V60 },
105 {
"hexagonv62",
V62 },
108 auto foundIt = CpuTable.find(CPUString);
109 if (foundIt != CpuTable.end())
115 UseHVXDblOps =
false;
116 UseLongCalls =
false;
132 InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this) {
133 initializeEnvironment();
136 InstrItins = getInstrItineraryForCPU(CPUString);
147 ModeIEEERndNear =
true;
149 ModeIEEERndNear =
false;
169 isBestZeroLatency(Src, Dst, QII, ExclSrc, ExclDst)) {
182 unsigned UseIdx = -1;
183 for (
unsigned OpNum = 0; OpNum < RSeqDst->
getNumOperands(); OpNum++) {
191 0, *RSeqDst, UseIdx));
199 isBestZeroLatency(Src, Dst, QII, ExclSrc, ExclDst)) {
204 updateLatency(*SrcInst, *DstInst, Dep);
208 for (
auto &SU : DAG->
SUnits) {
212 for (
auto &
D : SU.Preds)
213 if (
D.getKind() ==
SDep::Output &&
D.getReg() == Hexagon::USR_OVF)
215 for (
auto &
E : Erase)
219 for (
auto &SU : DAG->
SUnits) {
226 bool IsLoadMI1 = MI1.
mayLoad();
227 if (!QII->isHVXVec(MI1) || !(IsStoreMI1 || IsLoadMI1))
229 for (
auto &
SI : SU.Succs) {
233 if (!QII->isHVXVec(MI2))
239 for (
auto &PI :
SI.getSUnit()->Preds) {
240 if (PI.getSUnit() != &SU || PI.getKind() !=
SDep::Order)
243 SI.getSUnit()->setDepthDirty();
251 std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations)
const {
253 llvm::make_unique<HexagonSubtarget::HexagonDAGMutation>());
257 std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations)
const {
259 llvm::make_unique<HexagonSubtarget::HexagonDAGMutation>());
263 void HexagonSubtarget::anchor() {}
275 void HexagonSubtarget::updateLatency(
MachineInstr &SrcInst,
292 void HexagonSubtarget::restoreLatency(
SUnit *Src,
SUnit *Dst)
const {
294 for (
auto &
I : Src->
Succs) {
295 if (!
I.isAssignedRegDep() ||
I.getSUnit() != Dst)
297 unsigned DepR =
I.getReg();
299 for (
unsigned OpNum = 0; OpNum < SrcI->
getNumOperands(); OpNum++) {
304 assert(DefIdx >= 0 &&
"Def Reg not found in Src MI");
306 for (
unsigned OpNum = 0; OpNum < DstI->
getNumOperands(); OpNum++) {
310 DefIdx, *DstI, OpNum));
317 I.setLatency(Latency);
318 updateLatency(*SrcI, *DstI,
I);
323 for (
auto &J : Dst->
Preds) {
324 if (J.getSUnit() != Src)
326 J.setLatency(
I.getLatency());
332 void HexagonSubtarget::changeLatency(
SUnit *Src,
SUnit *Dst,
unsigned Lat)
334 for (
auto &
I : Src->
Succs) {
335 if (
I.getSUnit() != Dst)
344 F->setLatency(
I.getLatency());
351 if (
I.isAssignedRegDep() &&
I.getLatency() == 0 &&
352 !
I.getSUnit()->getInstr()->isPseudo())
361 bool HexagonSubtarget::isBestZeroLatency(
SUnit *Src,
SUnit *Dst,
385 SUnit *Best =
nullptr;
386 SUnit *DstBest =
nullptr;
399 if ((Src == SrcBest && Dst == DstBest ) ||
400 (SrcBest ==
nullptr && Dst == DstBest) ||
401 (Src == SrcBest && Dst ==
nullptr))
406 if (SrcBest !=
nullptr) {
408 changeLatency(SrcBest, Dst, 1);
410 restoreLatency(SrcBest, Dst);
412 if (DstBest !=
nullptr) {
414 changeLatency(Src, DstBest, 1);
416 restoreLatency(Src, DstBest);
421 if (SrcBest && DstBest)
424 changeLatency(SrcBest, DstBest, 0);
429 for (
auto &
I : DstBest->
Preds)
430 if (ExclSrc.
count(
I.getSUnit()) == 0 &&
431 isBestZeroLatency(
I.getSUnit(), DstBest,
TII, ExclSrc, ExclDst))
432 changeLatency(
I.getSUnit(), DstBest, 0);
433 }
else if (SrcBest) {
437 for (
auto &
I : SrcBest->
Succs)
438 if (ExclDst.
count(
I.getSUnit()) == 0 &&
439 isBestZeroLatency(SrcBest,
I.getSUnit(),
TII, ExclSrc, ExclDst))
440 changeLatency(SrcBest,
I.getSUnit(), 0);
void push_back(const T &Elt)
static SUnit * getZeroLatency(SUnit *N, SmallVector< SDep, 4 > &Deps)
If the SUnit has a zero latency edge, return the other SUnit.
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
MachineInstr * getInstr() const
Returns the representative MachineInstr for this SUnit.
StringRef selectHexagonCPU(const Triple &TT, StringRef CPU)
bool isInstr() const
Returns true if this SUnit refers to a machine instruction as opposed to an SDNode.
static cl::opt< bool > EnableHexagonHVXDouble("enable-hexagon-hvx-double", cl::Hidden, cl::ZeroOrMore, cl::init(false), cl::desc("Enable Hexagon Double Vector eXtensions"))
void getSMSMutations(std::vector< std::unique_ptr< ScheduleDAGMutation >> &Mutations) const override
bool usePredicatedCalls() const
static cl::opt< bool > EnableIEEERndNear("enable-hexagon-ieee-rnd-near", cl::Hidden, cl::ZeroOrMore, cl::init(false), cl::desc("Generate non-chopped conversion from fp to int."))
HexagonSubtarget & initializeSubtargetDependencies(StringRef CPU, StringRef FS)
bool isArtificial() const
Tests if this is an Order dependence that is marked as "artificial", meaning it isn't necessary for...
SmallVector< SDep, 4 > Preds
All sunit predecessors.
static cl::opt< bool > EnableTCLatencySched("enable-tc-latency-sched", cl::Hidden, cl::ZeroOrMore, cl::init(false))
unsigned NumSuccs
of SDep::Data sucss.
const HexagonInstrInfo * TII
unsigned getL1CacheLineSize() const
static cl::opt< bool > OverrideLongCalls("hexagon-long-calls", cl::Hidden, cl::ZeroOrMore, cl::init(false), cl::desc("If present, forces/disables the use of long calls"))
bool isReg() const
isReg - Tests if this is a MO_Register operand.
bool mayLoad(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read memory.
unsigned getNumOperands() const
Access to explicit operands of the instruction.
A register output-dependence (aka WAW).
HexagonSubtarget(const Triple &TT, StringRef CPU, StringRef FS, const TargetMachine &TM)
bool canExecuteInBundle(const MachineInstr &First, const MachineInstr &Second) const
Can these instructions execute at the same time in a bundle.
static cl::opt< bool > DisableMemOps("disable-hexagon-memops", cl::Hidden, cl::ZeroOrMore, cl::ValueDisallowed, cl::init(false), cl::desc("Do not generate V4 MEMOP in code generation for Hexagon target"))
static cl::opt< bool > EnableMemOps("enable-hexagon-memops", cl::Hidden, cl::ZeroOrMore, cl::ValueDisallowed, cl::init(true), cl::desc("Generate V4 MEMOP in code generation for Hexagon target"))
initializer< Ty > init(const Ty &Val)
HexagonArchEnum HexagonArchVersion
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
const MachineOperand & getOperand(unsigned i) const
static cl::opt< bool > EnableHexagonHVX("enable-hexagon-hvx", cl::Hidden, cl::ZeroOrMore, cl::init(false), cl::desc("Enable Hexagon Vector eXtensions"))
unsigned getLatency() const
Returns the latency value for this edge, which roughly means the minimum number of cycles that must e...
static cl::opt< bool > EnableSubregLiveness("hexagon-subreg-liveness", cl::Hidden, cl::ZeroOrMore, cl::init(true), cl::desc("Enable subregister liveness tracking for Hexagon"))
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
static cl::opt< bool > EnablePredicatedCalls("hexagon-pred-calls", cl::Hidden, cl::ZeroOrMore, cl::init(false), cl::desc("Consider calls to be predicable"))
bool isToBeScheduledASAP(const MachineInstr &MI1, const MachineInstr &MI2) const
Any other ordering dependency.
unsigned getL1PrefetchDistance() const
Triple - Helper class for working with autoconf configuration names.
void apply(ScheduleDAGInstrs *DAG) override
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.
bool useBSBScheduling() const
auto find(R &&Range, const T &Val) -> decltype(std::begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
bool enableMachineScheduler() const override
void getPostRAMutations(std::vector< std::unique_ptr< ScheduleDAGMutation >> &Mutations) const override
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
bool UseBSBScheduling
True if the target should use Back-Skip-Back scheduling.
bool enableSubRegLiveness() const override
void adjustSchedDependency(SUnit *def, SUnit *use, SDep &dep) const override
Perform target specific adjustments to the latency of a schedule dependency.
bool isBoundaryNode() const
Boundary nodes are placeholders for the boundary of the scheduling region.
llvm_unreachable("Unknown RegBank!")
void setLatency(unsigned Lat)
Sets the latency for this edge.
A ScheduleDAG for scheduling lists of MachineInstr.
Representation of each machine instruction.
void ParseSubtargetFeatures(StringRef CPU, StringRef FS)
ParseSubtargetFeatures - Parses features string setting specified subtarget options.
static cl::opt< bool > EnableVecFrwdSched("enable-evec-frwd-sched", cl::Hidden, cl::ZeroOrMore, cl::init(true))
const TargetInstrInfo * TII
Target instruction information.
int getOperandLatency(const InstrItineraryData *ItinData, const MachineInstr &DefMI, unsigned DefIdx, const MachineInstr &UseMI, unsigned UseIdx) const override
getOperandLatency - Compute and return the use operand latency of a given pair of def and use...
unsigned NodeNum
Entry # of node in the node vector.
unsigned getReg() const
getReg - Returns the register number.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const HexagonInstrInfo * getInstrInfo() const override
SmallVector< SDep, 4 > Succs
All sunit successors.
Primary interface to the complete machine description for the target machine.
static cl::opt< bool > EnableBSBSched("enable-bsb-sched", cl::Hidden, cl::ZeroOrMore, cl::init(true))
StringRef - Represent a constant reference to a string, i.e.
static cl::opt< bool > DisableHexagonMISched("disable-hexagon-misched", cl::Hidden, cl::ZeroOrMore, cl::init(false), cl::desc("Disable Hexagon MI Scheduling"))
bool isRegSequence() const
std::vector< SUnit > SUnits
The scheduling units.
Scheduling unit. This is a node in the scheduling DAG.
static cl::opt< bool > EnableDotCurSched("enable-cur-sched", cl::Hidden, cl::ZeroOrMore, cl::init(true), cl::desc("Enable the scheduler to generate .cur"))