LLVM  8.0.1
HexagonVLIWPacketizer.h
Go to the documentation of this file.
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
12 
16 #include <vector>
17 
18 namespace llvm {
19 
20 class HexagonInstrInfo;
21 class HexagonRegisterInfo;
22 class MachineBranchProbabilityInfo;
23 class MachineFunction;
24 class MachineInstr;
25 class MachineLoopInfo;
26 class TargetRegisterClass;
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 
61 protected:
62  /// A handle to the branch probability pass.
65 
66 private:
67  const HexagonInstrInfo *HII;
68  const HexagonRegisterInfo *HRI;
69  const bool Minimal;
70 
71 public:
74  const MachineBranchProbabilityInfo *MBPI,
75  bool Minimal);
76 
77  // initPacketizerState - initialize some internal flags.
78  void initPacketizerState() override;
79 
80  // ignorePseudoInstruction - Ignore bundling of pseudo instructions.
82  const MachineBasicBlock *MBB) override;
83 
84  // isSoloInstruction - return true if instruction MI can not be packetized
85  // with any other instruction, which means that MI itself is a packet.
86  bool isSoloInstruction(const MachineInstr &MI) override;
87 
88  // isLegalToPacketizeTogether - Is it legal to packetize SUI and SUJ
89  // together.
90  bool isLegalToPacketizeTogether(SUnit *SUI, SUnit *SUJ) override;
91 
92  // isLegalToPruneDependencies - Is it legal to prune dependece between SUI
93  // and SUJ.
94  bool isLegalToPruneDependencies(SUnit *SUI, SUnit *SUJ) override;
95 
96  bool foundLSInPacket();
98  void endPacket(MachineBasicBlock *MBB,
100  bool shouldAddToPacket(const MachineInstr &MI) override;
101 
103 
104 protected:
106  return MemShufDisabled;
107  };
108  void setmemShufDisabled(bool val) {
109  MemShufDisabled = val;
110  };
111  bool isCallDependent(const MachineInstr &MI, SDep::Kind DepType,
112  unsigned DepReg);
113  bool promoteToDotCur(MachineInstr &MI, SDep::Kind DepType,
115  const TargetRegisterClass *RC);
116  bool canPromoteToDotCur(const MachineInstr &MI, const SUnit *PacketSU,
117  unsigned DepReg, MachineBasicBlock::iterator &MII,
118  const TargetRegisterClass *RC);
119  void cleanUpDotCur();
120 
121  bool promoteToDotNew(MachineInstr &MI, SDep::Kind DepType,
123  const TargetRegisterClass *RC);
124  bool canPromoteToDotNew(const MachineInstr &MI, const SUnit *PacketSU,
125  unsigned DepReg, MachineBasicBlock::iterator &MII,
126  const TargetRegisterClass *RC);
127  bool canPromoteToNewValue(const MachineInstr &MI, const SUnit *PacketSU,
128  unsigned DepReg, MachineBasicBlock::iterator &MII);
130  const MachineInstr &PacketMI, unsigned DepReg);
131  bool demoteToDotOld(MachineInstr &MI);
132  bool useCallersSP(MachineInstr &MI);
133  void useCalleesSP(MachineInstr &MI);
134  bool updateOffset(SUnit *SUI, SUnit *SUJ);
137  bool restrictingDepExistInPacket(MachineInstr&, unsigned);
138  bool isNewifiable(const MachineInstr &MI, const TargetRegisterClass *NewRC);
139  bool isCurifiable(MachineInstr &MI);
140  bool cannotCoexist(const MachineInstr &MI, const MachineInstr &MJ);
141 
142  bool isPromotedToDotNew() const {
143  return PromotedToDotNew;
144  }
145 
146  bool tryAllocateResourcesForConstExt(bool Reserve);
149  bool hasDeadDependence(const MachineInstr &I, const MachineInstr &J);
150  bool hasControlDependence(const MachineInstr &I, const MachineInstr &J);
151  bool hasRegMaskDependence(const MachineInstr &I, const MachineInstr &J);
152  bool hasDualStoreDependence(const MachineInstr &I, const MachineInstr &J);
153  bool producesStall(const MachineInstr &MI);
154 };
155 
156 } // end namespace llvm
157 
158 #endif // LLVM_LIB_TARGET_HEXAGON_HEXAGONVLIWPACKETIZER_H
bool canPromoteToNewValueStore(const MachineInstr &MI, const MachineInstr &PacketMI, unsigned DepReg)
This class represents lattice values for constants.
Definition: AllocatorList.h:24
bool canPromoteToDotNew(const MachineInstr &MI, const SUnit *PacketSU, unsigned DepReg, MachineBasicBlock::iterator &MII, const TargetRegisterClass *RC)
const MachineLoopInfo * MLI
bool demoteToDotOld(MachineInstr &MI)
bool isCurifiable(MachineInstr &MI)
void undoChangedOffset(MachineInstr &MI)
Undo the changed offset.
Kind
These are the different kinds of scheduling dependencies.
Definition: ScheduleDAG.h:53
bool restrictingDepExistInPacket(MachineInstr &, unsigned)
bool canPromoteToDotCur(const MachineInstr &MI, const SUnit *PacketSU, unsigned DepReg, MachineBasicBlock::iterator &MII, const TargetRegisterClass *RC)
bool shouldAddToPacket(const MachineInstr &MI) override
MachineFunction & MF
void endPacket(MachineBasicBlock *MBB, MachineBasicBlock::iterator MI) override
bool arePredicatesComplements(MachineInstr &MI1, MachineInstr &MI2)
const MachineBranchProbabilityInfo * MBPI
A handle to the branch probability pass.
bool hasDualStoreDependence(const MachineInstr &I, const MachineInstr &J)
bool isSoloInstruction(const MachineInstr &MI) override
bool tryAllocateResourcesForConstExt(bool Reserve)
bool isLegalToPacketizeTogether(SUnit *SUI, SUnit *SUJ) override
HexagonPacketizerList(MachineFunction &MF, MachineLoopInfo &MLI, AliasAnalysis *AA, const MachineBranchProbabilityInfo *MBPI, bool Minimal)
MachineBasicBlock::iterator addToPacket(MachineInstr &MI) override
Representation of each machine instruction.
Definition: MachineInstr.h:64
bool promoteToDotCur(MachineInstr &MI, SDep::Kind DepType, MachineBasicBlock::iterator &MII, const TargetRegisterClass *RC)
bool isCallDependent(const MachineInstr &MI, SDep::Kind DepType, unsigned DepReg)
bool ignorePseudoInstruction(const MachineInstr &MI, const MachineBasicBlock *MBB) override
bool isNewifiable(const MachineInstr &MI, const TargetRegisterClass *NewRC)
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...
#define I(x, y, z)
Definition: MD5.cpp:58
bool hasControlDependence(const MachineInstr &I, const MachineInstr &J)
bool useCallersSP(MachineInstr &MI)
bool promoteToDotNew(MachineInstr &MI, SDep::Kind DepType, MachineBasicBlock::iterator &MII, const TargetRegisterClass *RC)
bool hasDeadDependence(const MachineInstr &I, const MachineInstr &J)
bool cannotCoexist(const MachineInstr &MI, const MachineInstr &MJ)
bool isLegalToPruneDependencies(SUnit *SUI, SUnit *SUJ) override
void useCalleesSP(MachineInstr &MI)
bool hasRegMaskDependence(const MachineInstr &I, const MachineInstr &J)
IRTranslator LLVM IR MI
void unpacketizeSoloInstrs(MachineFunction &MF)
Dependence - This class represents a dependence between two memory memory references in a function...
bool canPromoteToNewValue(const MachineInstr &MI, const SUnit *PacketSU, unsigned DepReg, MachineBasicBlock::iterator &MII)
bool producesStall(const MachineInstr &MI)
Scheduling unit. This is a node in the scheduling DAG.
Definition: ScheduleDAG.h:246