Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 1 | #ifndef HEXAGONVLIWPACKETIZER_H |
| 2 | #define HEXAGONVLIWPACKETIZER_H |
| 3 | |
| 4 | #include "llvm/CodeGen/DFAPacketizer.h" |
| 5 | #include "llvm/CodeGen/MachineBranchProbabilityInfo.h" |
| 6 | #include "llvm/CodeGen/ScheduleDAG.h" |
| 7 | #include "llvm/CodeGen/ScheduleDAGInstrs.h" |
| 8 | |
| 9 | namespace llvm { |
Benjamin Kramer | 7356498 | 2017-01-30 14:55:33 +0000 | [diff] [blame^] | 10 | class HexagonInstrInfo; |
| 11 | class HexagonRegisterInfo; |
| 12 | |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 13 | class HexagonPacketizerList : public VLIWPacketizerList { |
| 14 | // Vector of instructions assigned to the packet that has just been created. |
| 15 | std::vector<MachineInstr*> OldPacketMIs; |
| 16 | |
| 17 | // Has the instruction been promoted to a dot-new instruction. |
| 18 | bool PromotedToDotNew; |
| 19 | |
| 20 | // Has the instruction been glued to allocframe. |
| 21 | bool GlueAllocframeStore; |
| 22 | |
| 23 | // Has the feeder instruction been glued to new value jump. |
| 24 | bool GlueToNewValueJump; |
| 25 | |
| 26 | // Check if there is a dependence between some instruction already in this |
| 27 | // packet and this instruction. |
| 28 | bool Dependence; |
| 29 | |
| 30 | // Only check for dependence if there are resources available to |
| 31 | // schedule this instruction. |
| 32 | bool FoundSequentialDependence; |
| 33 | |
| 34 | // Track MIs with ignored dependence. |
| 35 | std::vector<MachineInstr*> IgnoreDepMIs; |
| 36 | |
| 37 | protected: |
| 38 | /// \brief A handle to the branch probability pass. |
| 39 | const MachineBranchProbabilityInfo *MBPI; |
| 40 | const MachineLoopInfo *MLI; |
| 41 | |
| 42 | private: |
| 43 | const HexagonInstrInfo *HII; |
| 44 | const HexagonRegisterInfo *HRI; |
| 45 | |
| 46 | public: |
| 47 | // Ctor. |
| 48 | HexagonPacketizerList(MachineFunction &MF, MachineLoopInfo &MLI, |
| 49 | AliasAnalysis *AA, |
| 50 | const MachineBranchProbabilityInfo *MBPI); |
| 51 | |
| 52 | // initPacketizerState - initialize some internal flags. |
| 53 | void initPacketizerState() override; |
| 54 | |
| 55 | // ignorePseudoInstruction - Ignore bundling of pseudo instructions. |
Duncan P. N. Exon Smith | 5702287 | 2016-02-27 19:09:00 +0000 | [diff] [blame] | 56 | bool ignorePseudoInstruction(const MachineInstr &MI, |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 57 | const MachineBasicBlock *MBB) override; |
| 58 | |
| 59 | // isSoloInstruction - return true if instruction MI can not be packetized |
| 60 | // with any other instruction, which means that MI itself is a packet. |
Duncan P. N. Exon Smith | 5702287 | 2016-02-27 19:09:00 +0000 | [diff] [blame] | 61 | bool isSoloInstruction(const MachineInstr &MI) override; |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 62 | |
| 63 | // isLegalToPacketizeTogether - Is it legal to packetize SUI and SUJ |
| 64 | // together. |
| 65 | bool isLegalToPacketizeTogether(SUnit *SUI, SUnit *SUJ) override; |
| 66 | |
| 67 | // isLegalToPruneDependencies - Is it legal to prune dependece between SUI |
| 68 | // and SUJ. |
| 69 | bool isLegalToPruneDependencies(SUnit *SUI, SUnit *SUJ) override; |
| 70 | |
Duncan P. N. Exon Smith | 5702287 | 2016-02-27 19:09:00 +0000 | [diff] [blame] | 71 | MachineBasicBlock::iterator addToPacket(MachineInstr &MI) override; |
| 72 | void endPacket(MachineBasicBlock *MBB, |
| 73 | MachineBasicBlock::iterator MI) override; |
| 74 | bool shouldAddToPacket(const MachineInstr &MI) override; |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 75 | |
| 76 | void unpacketizeSoloInstrs(MachineFunction &MF); |
| 77 | |
| 78 | protected: |
Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 79 | bool isCallDependent(const MachineInstr &MI, SDep::Kind DepType, |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 80 | unsigned DepReg); |
Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 81 | bool promoteToDotCur(MachineInstr &MI, SDep::Kind DepType, |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 82 | MachineBasicBlock::iterator &MII, |
Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 83 | const TargetRegisterClass *RC); |
| 84 | bool canPromoteToDotCur(const MachineInstr &MI, const SUnit *PacketSU, |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 85 | unsigned DepReg, MachineBasicBlock::iterator &MII, |
Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 86 | const TargetRegisterClass *RC); |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 87 | void cleanUpDotCur(); |
| 88 | |
Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 89 | bool promoteToDotNew(MachineInstr &MI, SDep::Kind DepType, |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 90 | MachineBasicBlock::iterator &MII, |
Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 91 | const TargetRegisterClass *RC); |
| 92 | bool canPromoteToDotNew(const MachineInstr &MI, const SUnit *PacketSU, |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 93 | unsigned DepReg, MachineBasicBlock::iterator &MII, |
Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 94 | const TargetRegisterClass *RC); |
| 95 | bool canPromoteToNewValue(const MachineInstr &MI, const SUnit *PacketSU, |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 96 | unsigned DepReg, MachineBasicBlock::iterator &MII); |
Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 97 | bool canPromoteToNewValueStore(const MachineInstr &MI, |
| 98 | const MachineInstr &PacketMI, unsigned DepReg); |
| 99 | bool demoteToDotOld(MachineInstr &MI); |
| 100 | bool useCallersSP(MachineInstr &MI); |
| 101 | void useCalleesSP(MachineInstr &MI); |
Duncan P. N. Exon Smith | 6307eb5 | 2016-02-23 02:46:52 +0000 | [diff] [blame] | 102 | bool arePredicatesComplements(MachineInstr &MI1, MachineInstr &MI2); |
Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 103 | bool restrictingDepExistInPacket(MachineInstr&, unsigned); |
| 104 | bool isNewifiable(const MachineInstr &MI, const TargetRegisterClass *NewRC); |
| 105 | bool isCurifiable(MachineInstr &MI); |
| 106 | bool cannotCoexist(const MachineInstr &MI, const MachineInstr &MJ); |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 107 | inline bool isPromotedToDotNew() const { |
| 108 | return PromotedToDotNew; |
| 109 | } |
| 110 | bool tryAllocateResourcesForConstExt(bool Reserve); |
| 111 | bool canReserveResourcesForConstExt(); |
| 112 | void reserveResourcesForConstExt(); |
Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 113 | bool hasDeadDependence(const MachineInstr &I, const MachineInstr &J); |
| 114 | bool hasControlDependence(const MachineInstr &I, const MachineInstr &J); |
| 115 | bool hasV4SpecificDependence(const MachineInstr &I, const MachineInstr &J); |
| 116 | bool producesStall(const MachineInstr &MI); |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 117 | }; |
| 118 | } // namespace llvm |
| 119 | #endif // HEXAGONVLIWPACKETIZER_H |
| 120 | |