Eugene Zelenko | 3b87336 | 2017-09-28 22:27:31 +0000 | [diff] [blame] | 1 | //===- HexagonPacketizer.h - VLIW packetizer --------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONVLIWPACKETIZER_H |
| 11 | #define LLVM_LIB_TARGET_HEXAGON_HEXAGONVLIWPACKETIZER_H |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 12 | |
| 13 | #include "llvm/CodeGen/DFAPacketizer.h" |
Eugene Zelenko | 3b87336 | 2017-09-28 22:27:31 +0000 | [diff] [blame] | 14 | #include "llvm/CodeGen/MachineBasicBlock.h" |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 15 | #include "llvm/CodeGen/ScheduleDAG.h" |
Eugene Zelenko | 3b87336 | 2017-09-28 22:27:31 +0000 | [diff] [blame] | 16 | #include <vector> |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 17 | |
| 18 | namespace llvm { |
Eugene Zelenko | 3b87336 | 2017-09-28 22:27:31 +0000 | [diff] [blame] | 19 | |
Benjamin Kramer | 7356498 | 2017-01-30 14:55:33 +0000 | [diff] [blame] | 20 | class HexagonInstrInfo; |
| 21 | class HexagonRegisterInfo; |
Eugene Zelenko | 3b87336 | 2017-09-28 22:27:31 +0000 | [diff] [blame] | 22 | class MachineBranchProbabilityInfo; |
| 23 | class MachineFunction; |
| 24 | class MachineInstr; |
| 25 | class MachineLoopInfo; |
| 26 | class TargetRegisterClass; |
Benjamin Kramer | 7356498 | 2017-01-30 14:55:33 +0000 | [diff] [blame] | 27 | |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 28 | class HexagonPacketizerList : public VLIWPacketizerList { |
| 29 | // Vector of instructions assigned to the packet that has just been created. |
Eugene Zelenko | 3b87336 | 2017-09-28 22:27:31 +0000 | [diff] [blame] | 30 | std::vector<MachineInstr *> OldPacketMIs; |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 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 | |
Krzysztof Parzyszek | 8f174dd | 2017-10-11 15:51:44 +0000 | [diff] [blame] | 41 | // This holds the offset value, when pruning the dependences. |
| 42 | int64_t ChangedOffset; |
| 43 | |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 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 | // Track MIs with ignored dependence. |
| 53 | std::vector<MachineInstr*> IgnoreDepMIs; |
| 54 | |
Krzysztof Parzyszek | 9aaf923 | 2017-05-02 18:12:19 +0000 | [diff] [blame] | 55 | // Set to true if the packet contains an instruction that stalls with an |
| 56 | // instruction from the previous packet. |
Krzysztof Parzyszek | fca6fae | 2017-05-02 18:29:49 +0000 | [diff] [blame] | 57 | bool PacketStalls = false; |
Krzysztof Parzyszek | 9aaf923 | 2017-05-02 18:12:19 +0000 | [diff] [blame] | 58 | |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 59 | protected: |
| 60 | /// \brief A handle to the branch probability pass. |
| 61 | const MachineBranchProbabilityInfo *MBPI; |
| 62 | const MachineLoopInfo *MLI; |
| 63 | |
| 64 | private: |
| 65 | const HexagonInstrInfo *HII; |
| 66 | const HexagonRegisterInfo *HRI; |
| 67 | |
| 68 | public: |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 69 | HexagonPacketizerList(MachineFunction &MF, MachineLoopInfo &MLI, |
| 70 | AliasAnalysis *AA, |
| 71 | const MachineBranchProbabilityInfo *MBPI); |
| 72 | |
| 73 | // initPacketizerState - initialize some internal flags. |
| 74 | void initPacketizerState() override; |
| 75 | |
| 76 | // ignorePseudoInstruction - Ignore bundling of pseudo instructions. |
Duncan P. N. Exon Smith | 5702287 | 2016-02-27 19:09:00 +0000 | [diff] [blame] | 77 | bool ignorePseudoInstruction(const MachineInstr &MI, |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 78 | const MachineBasicBlock *MBB) override; |
| 79 | |
| 80 | // isSoloInstruction - return true if instruction MI can not be packetized |
| 81 | // 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] | 82 | bool isSoloInstruction(const MachineInstr &MI) override; |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 83 | |
| 84 | // isLegalToPacketizeTogether - Is it legal to packetize SUI and SUJ |
| 85 | // together. |
| 86 | bool isLegalToPacketizeTogether(SUnit *SUI, SUnit *SUJ) override; |
| 87 | |
| 88 | // isLegalToPruneDependencies - Is it legal to prune dependece between SUI |
| 89 | // and SUJ. |
| 90 | bool isLegalToPruneDependencies(SUnit *SUI, SUnit *SUJ) override; |
| 91 | |
Duncan P. N. Exon Smith | 5702287 | 2016-02-27 19:09:00 +0000 | [diff] [blame] | 92 | MachineBasicBlock::iterator addToPacket(MachineInstr &MI) override; |
| 93 | void endPacket(MachineBasicBlock *MBB, |
| 94 | MachineBasicBlock::iterator MI) override; |
| 95 | bool shouldAddToPacket(const MachineInstr &MI) override; |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 96 | |
| 97 | void unpacketizeSoloInstrs(MachineFunction &MF); |
| 98 | |
| 99 | protected: |
Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 100 | bool isCallDependent(const MachineInstr &MI, SDep::Kind DepType, |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 101 | unsigned DepReg); |
Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 102 | bool promoteToDotCur(MachineInstr &MI, SDep::Kind DepType, |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 103 | MachineBasicBlock::iterator &MII, |
Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 104 | const TargetRegisterClass *RC); |
| 105 | bool canPromoteToDotCur(const MachineInstr &MI, const SUnit *PacketSU, |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 106 | unsigned DepReg, MachineBasicBlock::iterator &MII, |
Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 107 | const TargetRegisterClass *RC); |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 108 | void cleanUpDotCur(); |
| 109 | |
Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 110 | bool promoteToDotNew(MachineInstr &MI, SDep::Kind DepType, |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 111 | MachineBasicBlock::iterator &MII, |
Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 112 | const TargetRegisterClass *RC); |
| 113 | bool canPromoteToDotNew(const MachineInstr &MI, const SUnit *PacketSU, |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 114 | unsigned DepReg, MachineBasicBlock::iterator &MII, |
Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 115 | const TargetRegisterClass *RC); |
| 116 | bool canPromoteToNewValue(const MachineInstr &MI, const SUnit *PacketSU, |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 117 | unsigned DepReg, MachineBasicBlock::iterator &MII); |
Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 118 | bool canPromoteToNewValueStore(const MachineInstr &MI, |
| 119 | const MachineInstr &PacketMI, unsigned DepReg); |
| 120 | bool demoteToDotOld(MachineInstr &MI); |
| 121 | bool useCallersSP(MachineInstr &MI); |
| 122 | void useCalleesSP(MachineInstr &MI); |
Krzysztof Parzyszek | 8f174dd | 2017-10-11 15:51:44 +0000 | [diff] [blame] | 123 | bool updateOffset(SUnit *SUI, SUnit *SUJ); |
| 124 | void undoChangedOffset(MachineInstr &MI); |
Duncan P. N. Exon Smith | 6307eb5 | 2016-02-23 02:46:52 +0000 | [diff] [blame] | 125 | bool arePredicatesComplements(MachineInstr &MI1, MachineInstr &MI2); |
Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 126 | bool restrictingDepExistInPacket(MachineInstr&, unsigned); |
| 127 | bool isNewifiable(const MachineInstr &MI, const TargetRegisterClass *NewRC); |
| 128 | bool isCurifiable(MachineInstr &MI); |
| 129 | bool cannotCoexist(const MachineInstr &MI, const MachineInstr &MJ); |
Eugene Zelenko | 3b87336 | 2017-09-28 22:27:31 +0000 | [diff] [blame] | 130 | |
| 131 | bool isPromotedToDotNew() const { |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 132 | return PromotedToDotNew; |
| 133 | } |
Eugene Zelenko | 3b87336 | 2017-09-28 22:27:31 +0000 | [diff] [blame] | 134 | |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 135 | bool tryAllocateResourcesForConstExt(bool Reserve); |
| 136 | bool canReserveResourcesForConstExt(); |
| 137 | void reserveResourcesForConstExt(); |
Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 138 | bool hasDeadDependence(const MachineInstr &I, const MachineInstr &J); |
| 139 | bool hasControlDependence(const MachineInstr &I, const MachineInstr &J); |
Krzysztof Parzyszek | 1aaf41a | 2017-02-17 22:14:51 +0000 | [diff] [blame] | 140 | bool hasRegMaskDependence(const MachineInstr &I, const MachineInstr &J); |
Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 141 | bool hasV4SpecificDependence(const MachineInstr &I, const MachineInstr &J); |
| 142 | bool producesStall(const MachineInstr &MI); |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 143 | }; |
Krzysztof Parzyszek | 56bbf54 | 2015-12-16 19:36:12 +0000 | [diff] [blame] | 144 | |
Eugene Zelenko | 3b87336 | 2017-09-28 22:27:31 +0000 | [diff] [blame] | 145 | } // end namespace llvm |
| 146 | |
| 147 | #endif // LLVM_LIB_TARGET_HEXAGON_HEXAGONVLIWPACKETIZER_H |