LLVM: include/llvm/CodeGen/RegisterScavenging.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17#ifndef LLVM_CODEGEN_REGISTERSCAVENGING_H

18#define LLVM_CODEGEN_REGISTERSCAVENGING_H

19

26

27namespace llvm {

28

33

40

41

42 struct ScavengedInfo {

43 ScavengedInfo(int FI = -1) : FrameIndex(FI) {}

44

45

46 int FrameIndex;

47

48

49

51

52

54 };

55

56

58

60

61public:

63

64

65

66

67

68

69

72 for (ScavengedInfo &Slot : Scavenged) {

73 if (Slot.FrameIndex == FI) {

74 assert(!Slot.Reg || Slot.Reg == Reg);

75 Slot.Reg = Reg;

76 Slot.Restore = Restore;

77 return;

78 }

79 }

80

82 }

83

84

86

87

88

90

91

92

94

95

97 while (MBBI != I)

99 }

100

101

103

104

106

107

108

110

111

113 Scavenged.push_back(ScavengedInfo(FI));

114 }

115

116

118 for (const ScavengedInfo &SI : Scavenged)

119 if (SI.FrameIndex == FI)

120 return true;

121

122 return false;

123 }

124

125

127 for (const ScavengedInfo &I : Scavenged)

128 if (I.FrameIndex >= 0)

129 A.push_back(I.FrameIndex);

130 }

131

132

133

134

135

136

137

138

139

140

143 bool RestoreAfter, int SPAdj,

144 bool AllowSpill = true);

145

146

148

149private:

150

151 bool isReserved(Register Reg) const { return MRI->isReserved(Reg); }

152

153

154 void init(MachineBasicBlock &MBB);

155

156

157

158 ScavengedInfo &spill(Register Reg, const TargetRegisterClass &RC, int SPAdj,

161};

162

163

164

166

167}

168

169#endif

unsigned const MachineRegisterInfo * MRI

MachineInstrBuilder & UseMI

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

This file implements the BitVector class.

static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")

A common definition of LaneBitmask for use in TableGen and CodeGen.

Promote Memory to Register

This file defines the SmallVector class.

A set of register units used to track register liveness.

MachineInstrBundleIterator< MachineInstr > iterator

Representation of each machine instruction.

MachineRegisterInfo - Keep track of information for virtual and physical registers,...

void backward(MachineBasicBlock::iterator I)

Call backward() to update internal register state to just before *I.

Definition RegisterScavenging.h:96

void enterBasicBlockEnd(MachineBasicBlock &MBB)

Start tracking liveness from the end of basic block MBB.

bool isRegUsed(Register Reg, bool includeReserved=true) const

Return if a specific register is currently used.

Register FindUnusedReg(const TargetRegisterClass *RC) const

Find an unused register of the specified register class.

void setRegUsed(Register Reg, LaneBitmask LaneMask=LaneBitmask::getAll())

Tell the scavenger a register is used.

void assignRegToScavengingIndex(int FI, Register Reg, MachineInstr *Restore=nullptr)

Record that Reg is in use at scavenging index FI.

Definition RegisterScavenging.h:70

void backward()

Update internal register state and move MBB iterator backwards.

void enterBasicBlock(MachineBasicBlock &MBB)

Start tracking liveness from the begin of basic block MBB.

Register scavengeRegisterBackwards(const TargetRegisterClass &RC, MachineBasicBlock::iterator To, bool RestoreAfter, int SPAdj, bool AllowSpill=true)

Make a register of the specific register class available from the current position backwards to the p...

void getScavengingFrameIndices(SmallVectorImpl< int > &A) const

Get an array of scavenging frame indices.

Definition RegisterScavenging.h:126

bool isScavengingFrameIndex(int FI) const

Query whether a frame index is a scavenging frame index.

Definition RegisterScavenging.h:117

void addScavengingFrameIndex(int FI)

Add a scavenging frame index.

Definition RegisterScavenging.h:112

BitVector getRegsAvailable(const TargetRegisterClass *RC)

Return all available registers in the register class in Mask.

Wrapper class representing virtual and physical registers.

This class consists of common code factored out of the SmallVector class to reduce code duplication b...

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

TargetInstrInfo - Interface to description of machine instruction set.

TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

This is an optimization pass for GlobalISel generic memory operations.

void scavengeFrameVirtualRegs(MachineFunction &MF, RegScavenger &RS)

Replaces all frame index virtual registers with physical registers.

static constexpr LaneBitmask getAll()