1 #ifndef HEXAGONVLIWPACKETIZER_H
2 #define HEXAGONVLIWPACKETIZER_H
4 #include "llvm/CodeGen/DFAPacketizer.h"
5 #include "llvm/CodeGen/MachineBranchProbabilityInfo.h"
6 #include "llvm/CodeGen/ScheduleDAG.h"
7 #include "llvm/CodeGen/ScheduleDAGInstrs.h"
10 class HexagonPacketizerList : public VLIWPacketizerList {
11 // Vector of instructions assigned to the packet that has just been created.
12 std::vector<MachineInstr*> OldPacketMIs;
14 // Has the instruction been promoted to a dot-new instruction.
15 bool PromotedToDotNew;
17 // Has the instruction been glued to allocframe.
18 bool GlueAllocframeStore;
20 // Has the feeder instruction been glued to new value jump.
21 bool GlueToNewValueJump;
23 // Check if there is a dependence between some instruction already in this
24 // packet and this instruction.
27 // Only check for dependence if there are resources available to
28 // schedule this instruction.
29 bool FoundSequentialDependence;
31 // Track MIs with ignored dependence.
32 std::vector<MachineInstr*> IgnoreDepMIs;
35 /// \brief A handle to the branch probability pass.
36 const MachineBranchProbabilityInfo *MBPI;
37 const MachineLoopInfo *MLI;
40 const HexagonInstrInfo *HII;
41 const HexagonRegisterInfo *HRI;
45 HexagonPacketizerList(MachineFunction &MF, MachineLoopInfo &MLI,
47 const MachineBranchProbabilityInfo *MBPI);
49 // initPacketizerState - initialize some internal flags.
50 void initPacketizerState() override;
52 // ignorePseudoInstruction - Ignore bundling of pseudo instructions.
53 bool ignorePseudoInstruction(const MachineInstr *MI,
54 const MachineBasicBlock *MBB) override;
56 // isSoloInstruction - return true if instruction MI can not be packetized
57 // with any other instruction, which means that MI itself is a packet.
58 bool isSoloInstruction(const MachineInstr *MI) override;
60 // isLegalToPacketizeTogether - Is it legal to packetize SUI and SUJ
62 bool isLegalToPacketizeTogether(SUnit *SUI, SUnit *SUJ) override;
64 // isLegalToPruneDependencies - Is it legal to prune dependece between SUI
66 bool isLegalToPruneDependencies(SUnit *SUI, SUnit *SUJ) override;
68 MachineBasicBlock::iterator addToPacket(MachineInstr *MI) override;
69 void endPacket(MachineBasicBlock *MBB, MachineInstr *MI) override;
70 bool shouldAddToPacket(const MachineInstr *MI) override;
72 void unpacketizeSoloInstrs(MachineFunction &MF);
75 bool isCallDependent(const MachineInstr* MI, SDep::Kind DepType,
77 bool promoteToDotCur(MachineInstr* MI, SDep::Kind DepType,
78 MachineBasicBlock::iterator &MII,
79 const TargetRegisterClass* RC);
80 bool canPromoteToDotCur(const MachineInstr* MI, const SUnit* PacketSU,
81 unsigned DepReg, MachineBasicBlock::iterator &MII,
82 const TargetRegisterClass* RC);
85 bool promoteToDotNew(MachineInstr* MI, SDep::Kind DepType,
86 MachineBasicBlock::iterator &MII,
87 const TargetRegisterClass* RC);
88 bool canPromoteToDotNew(const MachineInstr* MI, const SUnit* PacketSU,
89 unsigned DepReg, MachineBasicBlock::iterator &MII,
90 const TargetRegisterClass* RC);
91 bool canPromoteToNewValue(const MachineInstr* MI, const SUnit* PacketSU,
92 unsigned DepReg, MachineBasicBlock::iterator &MII);
93 bool canPromoteToNewValueStore(const MachineInstr* MI,
94 const MachineInstr* PacketMI, unsigned DepReg);
95 bool demoteToDotOld(MachineInstr* MI);
96 bool arePredicatesComplements(MachineInstr* MI1, MachineInstr* MI2);
97 bool restrictingDepExistInPacket(MachineInstr*, unsigned);
98 bool isNewifiable(const MachineInstr *MI);
99 bool isCurifiable(MachineInstr* MI);
100 bool cannotCoexist(const MachineInstr *MI, const MachineInstr *MJ);
101 inline bool isPromotedToDotNew() const {
102 return PromotedToDotNew;
104 bool tryAllocateResourcesForConstExt(bool Reserve);
105 bool canReserveResourcesForConstExt();
106 void reserveResourcesForConstExt();
107 bool hasDeadDependence(const MachineInstr *I, const MachineInstr *J);
108 bool hasControlDependence(const MachineInstr *I, const MachineInstr *J);
109 bool hasV4SpecificDependence(const MachineInstr *I, const MachineInstr *J);
110 bool producesStall(const MachineInstr *MI);
113 #endif // HEXAGONVLIWPACKETIZER_H