LLVM 20.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
19class HexagonInstrInfo;
20class HexagonRegisterInfo;
21class MachineBranchProbabilityInfo;
22class MachineFunction;
23class MachineInstr;
24class MachineLoopInfo;
25class TargetRegisterClass;
26
28 // Vector of instructions assigned to the packet that has just been created.
29 std::vector<MachineInstr *> OldPacketMIs;
30
31 // Has the instruction been promoted to a dot-new instruction.
32 bool PromotedToDotNew;
33
34 // Has the instruction been glued to allocframe.
35 bool GlueAllocframeStore;
36
37 // Has the feeder instruction been glued to new value jump.
38 bool GlueToNewValueJump;
39
40 // This holds the offset value, when pruning the dependences.
41 int64_t ChangedOffset;
42
43 // Check if there is a dependence between some instruction already in this
44 // packet and this instruction.
45 bool Dependence;
46
47 // Only check for dependence if there are resources available to
48 // schedule this instruction.
49 bool FoundSequentialDependence;
50
51 bool MemShufDisabled = false;
52
53 // Track MIs with ignored dependence.
54 std::vector<MachineInstr*> IgnoreDepMIs;
55
56 // Set to true if the packet contains an instruction that stalls with an
57 // instruction from the previous packet.
58 bool PacketStalls = false;
59 // Set to the number of cycles of stall a given instruction will incur
60 // because of dependence on instruction in previous packet.
61 unsigned int PacketStallCycles = 0;
62
63 // Set to true if the packet has a duplex pair of sub-instructions.
64 bool PacketHasDuplex = false;
65
66 // Set to true if the packet has a instruction that can only be executed
67 // in SLOT0.
68 bool PacketHasSLOT0OnlyInsn = false;
69
70protected:
71 /// A handle to the branch probability pass.
74
75private:
76 const HexagonInstrInfo *HII;
77 const HexagonRegisterInfo *HRI;
78 const bool Minimal;
79
80public:
83 bool Minimal);
84
85 // initPacketizerState - initialize some internal flags.
86 void initPacketizerState() override;
87
88 // ignorePseudoInstruction - Ignore bundling of pseudo instructions.
90 const MachineBasicBlock *MBB) override;
91
92 // isSoloInstruction - return true if instruction MI can not be packetized
93 // with any other instruction, which means that MI itself is a packet.
94 bool isSoloInstruction(const MachineInstr &MI) override;
95
96 // isLegalToPacketizeTogether - Is it legal to packetize SUI and SUJ
97 // together.
98 bool isLegalToPacketizeTogether(SUnit *SUI, SUnit *SUJ) override;
99
100 // isLegalToPruneDependencies - Is it legal to prune dependece between SUI
101 // and SUJ.
102 bool isLegalToPruneDependencies(SUnit *SUI, SUnit *SUJ) override;
103
104 bool foundLSInPacket();
108 bool shouldAddToPacket(const MachineInstr &MI) override;
109
111
112protected:
114 return MemShufDisabled;
115 };
116 void setmemShufDisabled(bool val) {
117 MemShufDisabled = val;
118 };
119 bool isCallDependent(const MachineInstr &MI, SDep::Kind DepType,
120 unsigned DepReg);
123 const TargetRegisterClass *RC);
124 bool canPromoteToDotCur(const MachineInstr &MI, const SUnit *PacketSU,
125 unsigned DepReg, MachineBasicBlock::iterator &MII,
126 const TargetRegisterClass *RC);
127 void cleanUpDotCur();
128
131 const TargetRegisterClass *RC);
132 bool canPromoteToDotNew(const MachineInstr &MI, const SUnit *PacketSU,
133 unsigned DepReg, MachineBasicBlock::iterator &MII,
134 const TargetRegisterClass *RC);
135 bool canPromoteToNewValue(const MachineInstr &MI, const SUnit *PacketSU,
136 unsigned DepReg, MachineBasicBlock::iterator &MII);
138 const MachineInstr &PacketMI, unsigned DepReg);
142 bool updateOffset(SUnit *SUI, SUnit *SUJ);
146 bool isNewifiable(const MachineInstr &MI, const TargetRegisterClass *NewRC);
148 bool cannotCoexist(const MachineInstr &MI, const MachineInstr &MJ);
149
150 bool isPromotedToDotNew() const {
151 return PromotedToDotNew;
152 }
153
154 bool tryAllocateResourcesForConstExt(bool Reserve);
157 bool hasDeadDependence(const MachineInstr &I, const MachineInstr &J);
158 bool hasControlDependence(const MachineInstr &I, const MachineInstr &J);
159 bool hasRegMaskDependence(const MachineInstr &I, const MachineInstr &J);
160 bool hasDualStoreDependence(const MachineInstr &I, const MachineInstr &J);
161 bool producesStall(const MachineInstr &MI);
162 unsigned int calcStall(const MachineInstr &MI);
163};
164
165} // end namespace llvm
166
167#endif // LLVM_LIB_TARGET_HEXAGON_HEXAGONVLIWPACKETIZER_H
MachineBasicBlock & MBB
IRTranslator LLVM IR MI
#define I(x, y, z)
Definition: MD5.cpp:58
Dependence - This class represents a dependence between two memory memory references in a function.
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
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)
void useCalleesSP(MachineInstr &MI)
bool demoteToDotOld(MachineInstr &MI)
bool cannotCoexist(const MachineInstr &MI, const MachineInstr &MJ)
const MachineLoopInfo * MLI
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 useCallersSP(MachineInstr &MI)
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)
Representation of each machine instruction.
Definition: MachineInstr.h:69
Kind
These are the different kinds of scheduling dependencies.
Definition: ScheduleDAG.h:52
Scheduling unit. This is a node in the scheduling DAG.
Definition: ScheduleDAG.h:242
MachineFunction & MF
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18