LLVM 23.0.0git
HexagonVLIWPacketizer.h
Go to the documentation of this file.
1//===- HexagonPacketizer.h - VLIW packetizer --------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONVLIWPACKETIZER_H
10#define LLVM_LIB_TARGET_HEXAGON_HEXAGONVLIWPACKETIZER_H
11
15#include <vector>
16
17namespace llvm {
18
22class MachineFunction;
23class MachineInstr;
24class MachineLoopInfo;
25class MCRegisterClass;
27
29 // Vector of instructions assigned to the packet that has just been created.
30 std::vector<MachineInstr *> OldPacketMIs;
31
32 // Has the instruction been promoted to a dot-new instruction.
33 bool PromotedToDotNew;
34
35 // Has the instruction been glued to allocframe.
36 bool GlueAllocframeStore;
37
38 // Has the feeder instruction been glued to new value jump.
39 bool GlueToNewValueJump;
40
41 // This holds the offset value, when pruning the dependences.
42 int64_t ChangedOffset;
43
44 // Check if there is a dependence between some instruction already in this
45 // packet and this instruction.
46 bool Dependence;
47
48 // Only check for dependence if there are resources available to
49 // schedule this instruction.
50 bool FoundSequentialDependence;
51
52 bool MemShufDisabled = false;
53
54 // Track MIs with ignored dependence.
55 std::vector<MachineInstr*> IgnoreDepMIs;
56
57 // Set to true if the packet contains an instruction that stalls with an
58 // instruction from the previous packet.
59 bool PacketStalls = false;
60 // Set to the number of cycles of stall a given instruction will incur
61 // because of dependence on instruction in previous packet.
62 unsigned int PacketStallCycles = 0;
63
64 // Set to true if the packet has a duplex pair of sub-instructions.
65 bool PacketHasDuplex = false;
66
67 // Set to true if the packet has a instruction that can only be executed
68 // in SLOT0.
69 bool PacketHasSLOT0OnlyInsn = false;
70
71protected:
72 /// A handle to the branch probability pass.
75
76private:
77 const HexagonInstrInfo *HII;
78 const HexagonRegisterInfo *HRI;
79 const bool Minimal;
80
81public:
84 bool Minimal);
85
86 // initPacketizerState - initialize some internal flags.
87 void initPacketizerState() override;
88
89 // ignorePseudoInstruction - Ignore bundling of pseudo instructions.
91 const MachineBasicBlock *MBB) override;
92
93 // isSoloInstruction - return true if instruction MI can not be packetized
94 // with any other instruction, which means that MI itself is a packet.
95 bool isSoloInstruction(const MachineInstr &MI) override;
96
97 // isLegalToPacketizeTogether - Is it legal to packetize SUI and SUJ
98 // together.
99 bool isLegalToPacketizeTogether(SUnit *SUI, SUnit *SUJ) override;
100
101 // isLegalToPruneDependencies - Is it legal to prune dependence between SUI
102 // and SUJ.
103 bool isLegalToPruneDependencies(SUnit *SUI, SUnit *SUJ) override;
104
105 bool foundLSInPacket();
109 bool shouldAddToPacket(const MachineInstr &MI) override;
110
112
113protected:
115 return MemShufDisabled;
116 };
117 void setmemShufDisabled(bool val) {
118 MemShufDisabled = val;
119 };
120 bool isCallDependent(const MachineInstr &MI, SDep::Kind DepType,
121 unsigned DepReg);
124 const TargetRegisterClass *RC);
125 bool canPromoteToDotCur(const MachineInstr &MI, const SUnit *PacketSU,
126 unsigned DepReg, MachineBasicBlock::iterator &MII,
127 const TargetRegisterClass *RC);
128 void cleanUpDotCur();
129
132 const TargetRegisterClass *RC);
133 bool canPromoteToDotNew(const MachineInstr &MI, const SUnit *PacketSU,
134 unsigned DepReg, MachineBasicBlock::iterator &MII,
135 const TargetRegisterClass *RC);
136 bool canPromoteToNewValue(const MachineInstr &MI, const SUnit *PacketSU,
137 unsigned DepReg, MachineBasicBlock::iterator &MII);
139 const MachineInstr &PacketMI, unsigned DepReg);
143 bool updateOffset(SUnit *SUI, SUnit *SUJ);
147 bool isNewifiable(const MachineInstr &MI, const TargetRegisterClass *NewRC);
149 bool cannotCoexist(const MachineInstr &MI, const MachineInstr &MJ);
150
151 bool isPromotedToDotNew() const {
152 return PromotedToDotNew;
153 }
154
155 bool tryAllocateResourcesForConstExt(bool Reserve);
158 bool hasDeadDependence(const MachineInstr &I, const MachineInstr &J);
159 bool hasControlDependence(const MachineInstr &I, const MachineInstr &J);
160 bool hasRegMaskDependence(const MachineInstr &I, const MachineInstr &J);
161 bool hasDualStoreDependence(const MachineInstr &I, const MachineInstr &J);
162 bool producesStall(const MachineInstr &MI);
163 unsigned int calcStall(const MachineInstr &MI);
164};
165
166} // end namespace llvm
167
168#endif // LLVM_LIB_TARGET_HEXAGON_HEXAGONVLIWPACKETIZER_H
MachineBasicBlock & MBB
IRTranslator LLVM IR MI
#define I(x, y, z)
Definition MD5.cpp:57
bool arePredicatesComplements(MachineInstr &MI1, MachineInstr &MI2)
bool updateOffset(SUnit *SUI, SUnit *SUJ)
Return true if we can update the offset in MI so that MI and MJ can be packetized together.
void endPacket(MachineBasicBlock *MBB, MachineBasicBlock::iterator MI) override
HexagonPacketizerList(MachineFunction &MF, MachineLoopInfo &MLI, AAResults *AA, const MachineBranchProbabilityInfo *MBPI, bool Minimal)
bool isCallDependent(const MachineInstr &MI, SDep::Kind DepType, unsigned DepReg)
bool promoteToDotCur(MachineInstr &MI, SDep::Kind DepType, MachineBasicBlock::iterator &MII, const TargetRegisterClass *RC)
bool promoteToDotNew(MachineInstr &MI, SDep::Kind DepType, MachineBasicBlock::iterator &MII, const TargetRegisterClass *RC)
bool isLegalToPacketizeTogether(SUnit *SUI, SUnit *SUJ) override
bool canPromoteToDotCur(const MachineInstr &MI, const SUnit *PacketSU, unsigned DepReg, MachineBasicBlock::iterator &MII, const TargetRegisterClass *RC)
bool demoteToDotOld(MachineInstr &MI)
bool cannotCoexist(const MachineInstr &MI, const MachineInstr &MJ)
bool isSoloInstruction(const MachineInstr &MI) override
bool isCurifiable(MachineInstr &MI)
bool isLegalToPruneDependencies(SUnit *SUI, SUnit *SUJ) override
bool hasControlDependence(const MachineInstr &I, const MachineInstr &J)
bool restrictingDepExistInPacket(MachineInstr &, unsigned)
bool producesStall(const MachineInstr &MI)
void undoChangedOffset(MachineInstr &MI)
Undo the changed offset.
bool hasDualStoreDependence(const MachineInstr &I, const MachineInstr &J)
unsigned int calcStall(const MachineInstr &MI)
bool canPromoteToDotNew(const MachineInstr &MI, const SUnit *PacketSU, unsigned DepReg, MachineBasicBlock::iterator &MII, const TargetRegisterClass *RC)
bool canPromoteToNewValue(const MachineInstr &MI, const SUnit *PacketSU, unsigned DepReg, MachineBasicBlock::iterator &MII)
bool ignorePseudoInstruction(const MachineInstr &MI, const MachineBasicBlock *MBB) override
void unpacketizeSoloInstrs(MachineFunction &MF)
const MachineBranchProbabilityInfo * MBPI
A handle to the branch probability pass.
bool shouldAddToPacket(const MachineInstr &MI) override
bool canPromoteToNewValueStore(const MachineInstr &MI, const MachineInstr &PacketMI, unsigned DepReg)
bool tryAllocateResourcesForConstExt(bool Reserve)
MachineBasicBlock::iterator addToPacket(MachineInstr &MI) override
bool hasDeadDependence(const MachineInstr &I, const MachineInstr &J)
bool isNewifiable(const MachineInstr &MI, const TargetRegisterClass *NewRC)
bool hasRegMaskDependence(const MachineInstr &I, const MachineInstr &J)
MCRegisterClass - Base class of TargetRegisterClass.
MachineInstrBundleIterator< MachineInstr > iterator
Representation of each machine instruction.
Kind
These are the different kinds of scheduling dependencies.
Definition ScheduleDAG.h:55
Scheduling unit. This is a node in the scheduling DAG.
VLIWPacketizerList(MachineFunction &MF, MachineLoopInfo &MLI, AAResults *AA)
This is an optimization pass for GlobalISel generic memory operations.
MCRegisterClass TargetRegisterClass
Definition FastISel.h:58