LLVM: lib/Target/AMDGPU/AMDGPUMarkLastScratchLoad.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
21
22using namespace llvm;
23
24#define DEBUG_TYPE "amdgpu-mark-last-scratch-load"
25
26namespace {
27
29private:
34
35public:
36 static char ID;
37
40 }
41
43
50 }
51
53 return "AMDGPU Mark Last Scratch Load";
54 }
55};
56
57}
58
59bool AMDGPUMarkLastScratchLoad::runOnMachineFunction(MachineFunction &MF) {
61 return false;
62
65 return false;
66
67 LS = &getAnalysis().getLS();
68 LIS = &getAnalysis().getLIS();
69 SI = &getAnalysis().getSI();
70 SII = ST.getInstrInfo();
71 SlotIndexes &Slots = *LIS->getSlotIndexes();
72
73 const unsigned NumSlots = LS->getNumIntervals();
74 if (NumSlots == 0) {
76 return false;
77 }
78
79 LLVM_DEBUG(dbgs() << LS->getNumIntervals() << " intervals\n");
80
81 bool Changed = false;
82
83 for (auto &[SS, LI] : *LS) {
85
86
87
89 continue;
90
93
94 MachineInstr *MISegmentEnd = SI->getInstructionFromIndex(Segment.end);
95
96
97
98 if (!MISegmentEnd) {
100 MISegmentEnd = SI->getInstructionFromIndex(NextSlot);
101 }
102
103 MachineInstr *MISegmentStart = SI->getInstructionFromIndex(Segment.start);
105
106
107
109 if (MISegmentStart && MISegmentStart->getParent() == BB)
111
113 int LoadFI = 0;
114
115 if (SII->isLoadFromStackSlot(*MI, LoadFI) && LoadFI == FrameIndex) {
116 LastLoad = &*MI;
117 break;
118 }
119 }
120
124 Changed = true;
125 LLVM_DEBUG(dbgs() << " Found last load: " << *LastLoad);
126 }
127 }
128 }
129
130 return Changed;
131}
132
133char AMDGPUMarkLastScratchLoad::ID = 0;
134
136
138 "AMDGPU Mark last scratch load", false, false)
AMDGPU Mark last scratch load
AMD GCN specific subclass of TargetSubtarget.
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
void setPreservesAll()
Set by analyses that do not transform their input at all.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Function & getFunction()
Return the LLVM function that this machine code represents.
Representation of each machine instruction.
const MachineBasicBlock * getParent() const
bool memoperands_empty() const
Return true if we don't have any memory operands which described the memory access done by this instr...
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.
A description of a memory reference used in the backend.
void setFlags(Flags f)
Bitwise OR the current flags with the given flags.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
static int stackSlot2Index(Register Reg)
Compute the frame index from a register value representing a stack slot.
SlotIndex - An opaque wrapper around machine indexes.
bool isBlock() const
isBlock - Returns true if this is a block boundary slot.
SlotIndex getNextNonNullIndex(SlotIndex Index)
Returns the next non-null index, if one exists.
StringRef - Represent a constant reference to a string, i.e.
reverse_self_iterator getReverseIterator()
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void initializeAMDGPUMarkLastScratchLoadPass(PassRegistry &)
static const MachineMemOperand::Flags MOLastUse
Mark the MMO of a load as the last use.
char & AMDGPUMarkLastScratchLoadID
This represents a simple continuous liveness interval for a value.