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

28class AMDGPUMarkLastScratchLoad {

29private:

34

35public:

37 : LS(LS), LIS(LIS), SI(SI) {}

39};

40

42public:

43 static char ID;

44

46

48

49 void getAnalysisUsage(AnalysisUsage &AU) const override {

55 }

56

57 StringRef getPassName() const override {

58 return "AMDGPU Mark Last Scratch Load";

59 }

60};

61

62}

63

64bool AMDGPUMarkLastScratchLoadLegacy::runOnMachineFunction(

67 return false;

68

69 auto &LS = getAnalysis().getLS();

70 auto &LIS = getAnalysis().getLIS();

71 auto &SI = getAnalysis().getSI();

72

73 return AMDGPUMarkLastScratchLoad(&LS, &LIS, &SI).run(MF);

74}

75

76PreservedAnalyses

82

83 AMDGPUMarkLastScratchLoad(&LS, &LIS, &SI).run(MF);

85}

86

90 return false;

91

92 SII = ST.getInstrInfo();

94

96 if (NumSlots == 0) {

98 return false;

99 }

100

102

104

105 for (auto &[SS, LI] : *LS) {

107

108

109

111 continue;

112

113 const int FrameIndex = LI.reg().stackSlotIndex();

115

116 MachineInstr *MISegmentEnd = SI->getInstructionFromIndex(Segment.end);

117

118

119

120 if (!MISegmentEnd) {

122 MISegmentEnd = SI->getInstructionFromIndex(NextSlot);

123 }

124

126 MachineBasicBlock *BB = MISegmentEnd->getParent();

127

128

129

130 auto End = BB->rend();

131 if (MISegmentStart && MISegmentStart->getParent() == BB)

133

135 int LoadFI = 0;

136

138 LastLoad = &*MI;

139 break;

140 }

141 }

142

147 LLVM_DEBUG(dbgs() << " Found last load: " << *LastLoad);

148 }

149 }

150 }

151

153}

154

155char AMDGPUMarkLastScratchLoadLegacy::ID = 0;

156

158

160 "AMDGPU Mark last scratch load", false, false)

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)

PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &AM)

Definition AMDGPUMarkLastScratchLoad.cpp:77

PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)

Get the result of an analysis pass for a given IR unit.

Represent the analysis usage information of a pass.

AnalysisUsage & addRequired()

void setPreservesAll()

Set by analyses that do not transform their input at all.

SlotIndexes * getSlotIndexes() const

unsigned getNumIntervals() const

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.

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.

void setFlags(Flags f)

Bitwise OR the current flags with the given flags.

static PreservedAnalyses all()

Construct a special preserved set that preserves all passes.

Register isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override

SlotIndex - An opaque wrapper around machine indexes.

bool isBlock() const

isBlock - Returns true if this is a block boundary slot.

LLVM_ABI Result run(MachineFunction &MF, MachineFunctionAnalysisManager &)

SlotIndex getNextNonNullIndex(SlotIndex Index)

Returns the next non-null index, if one exists.

MachineInstr * getInstructionFromIndex(SlotIndex index) const

Returns the instruction for the given index, or null if the given index has no instruction associated...

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.

AnalysisManager< MachineFunction > MachineFunctionAnalysisManager

LLVM_ABI raw_ostream & dbgs()

dbgs() - This returns a reference to a raw_ostream for debugging messages.

static const MachineMemOperand::Flags MOLastUse

Mark the MMO of a load as the last use.

char & AMDGPUMarkLastScratchLoadID

Definition AMDGPUMarkLastScratchLoad.cpp:157

This represents a simple continuous liveness interval for a value.