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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21#ifndef LLVM_CODEGEN_REACHINGDEFANALYSIS_H

22#define LLVM_CODEGEN_REACHINGDEFANALYSIS_H

23

30

31namespace llvm {

32

33class MachineBasicBlock;

34class MachineInstr;

35

36

37

38

39

41 uintptr_t Encoded;

43 explicit ReachingDef(uintptr_t Encoded) : Encoded(Encoded) {}

44

45public:

47 ReachingDef(int Instr) : Encoded(((uintptr_t) Instr << 2) | 2) {}

48 operator int() const { return ((int) Encoded) >> 2; }

49};

50

51template<>

53 static constexpr int NumLowBitsAvailable = 1;

54

56 return reinterpret_cast<void *>(RD.Encoded);

57 }

58

60 return ReachingDef(reinterpret_cast<uintptr_t>(P));

61 }

62

64 return ReachingDef(reinterpret_cast<uintptr_t>(P));

65 }

66};

67

68

70public:

71 void init(unsigned NumBlockIDs) { AllReachingDefs.resize(NumBlockIDs); }

72

74

76 AllReachingDefs[MBBNumber].resize(NumRegUnits);

77 }

78

79 void append(unsigned MBBNumber, unsigned Unit, int Def) {

80 AllReachingDefs[MBBNumber][Unit].push_back(Def);

81 }

82

83 void prepend(unsigned MBBNumber, unsigned Unit, int Def) {

84 auto &Defs = AllReachingDefs[MBBNumber][Unit];

85 Defs.insert(Defs.begin(), Def);

86 }

87

88 void replaceFront(unsigned MBBNumber, unsigned Unit, int Def) {

89 assert(!AllReachingDefs[MBBNumber][Unit].empty());

90 *AllReachingDefs[MBBNumber][Unit].begin() = Def;

91 }

92

94

96 if (AllReachingDefs[MBBNumber].empty())

97

99 return AllReachingDefs[MBBNumber][Unit];

100 }

101

102private:

103

105

106 using MBBDefsInfo = std::vector;

107

108

110};

111

112

114private:

118 unsigned NumRegUnits = 0;

119

120

121

122

123 using LiveRegsDefInfo = std::vector;

124 LiveRegsDefInfo LiveRegs;

125

126

127

128

131

132

133

134 int CurInstr = -1;

135

136

137

139

141

142

143 const int ReachingDefDefaultVal = -(1 << 21);

144

147

148public:

149 static char ID;

150

153 }

155

159 }

160

162

167 }

168

169

171

172

174

175

177

178

179

181

182

184

185

186

188

189

190

193

194

195

197

198

199

201

202

203

205

206

207

209

210

211

213

214

216

217

218

220

221

222

224 InstSet &Uses) const;

225

226

227

229 BlockSet &VisitedBBs) const;

231

232

233

234

236

237

238

240

241

242

244 InstSet &Defs) const;

245

246

248

249

251

252

253

255

256

257

259

260

261

262

264 InstSet &Ignore) const;

265

266

267

269

270

271

272

274

275private:

276

278

279

281

282

284

285

287

288

289

291

292

293 template

295

296

297

298

301

302

303

305

306

307

309};

310

311}

312

313#endif

ReachingDefAnalysis InstSet & ToRemove

ReachingDefAnalysis InstSet InstSet & Ignore

BlockVerifier::State From

static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")

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

Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx

This file defines the DenseMap class.

Remove Loads Into Fake Uses

assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())

This file defines the SmallVector class.

Represent the analysis usage information of a pass.

void setPreservesAll()

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

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

void append(unsigned MBBNumber, unsigned Unit, int Def)

ArrayRef< ReachingDef > defs(unsigned MBBNumber, unsigned Unit) const

void replaceFront(unsigned MBBNumber, unsigned Unit, int Def)

void init(unsigned NumBlockIDs)

void prepend(unsigned MBBNumber, unsigned Unit, int Def)

void startBasicBlock(unsigned MBBNumber, unsigned NumRegUnits)

unsigned numBlockIDs() 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.

Properties which a MachineFunction may have at a given point in time.

MachineFunctionProperties & set(Property P)

Representation of each machine instruction.

MachineOperand class - Representation of each machine instruction operand.

static PassRegistry * getPassRegistry()

getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...

This class provides the reaching def analysis.

MachineInstr * getLocalLiveOutMIDef(MachineBasicBlock *MBB, Register Reg) const

Return the local MI that produces the live out value for Reg, or nullptr for a non-live out or non-lo...

void traverse()

Traverse the machine function, mapping definitions.

bool isSafeToMoveForwards(MachineInstr *From, MachineInstr *To) const

Return whether From can be moved forwards to just before To.

bool isRegUsedAfter(MachineInstr *MI, Register Reg) const

Return whether the given register is used after MI, whether it's a local use or a live out.

void releaseMemory() override

releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...

bool isSafeToRemove(MachineInstr *MI, InstSet &ToRemove) const

Return whether removing this instruction will have no effect on the program, returning the redundant ...

MachineInstr * getMIOperand(MachineInstr *MI, unsigned Idx) const

If a single MachineInstr creates the reaching definition, for MIs operand at Idx, then return it.

void reset()

Re-run the analysis.

int getReachingDef(MachineInstr *MI, Register Reg) const

Provides the instruction id of the closest reaching def instruction of Reg that reaches MI,...

void init()

Initialize data structures.

void getGlobalUses(MachineInstr *MI, Register Reg, InstSet &Uses) const

Collect the users of the value stored in Reg, which is defined by MI.

void getAnalysisUsage(AnalysisUsage &AU) const override

getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.

void collectKilledOperands(MachineInstr *MI, InstSet &Dead) const

Assuming MI is dead, recursively search the incoming operands which are killed by MI and collect thos...

bool isSafeToMoveBackwards(MachineInstr *From, MachineInstr *To) const

Return whether From can be moved backwards to just after To.

void getLiveOuts(MachineBasicBlock *MBB, Register Reg, InstSet &Defs, BlockSet &VisitedBBs) const

Search MBB for a definition of Reg and insert it into Defs.

int getClearance(MachineInstr *MI, Register Reg) const

Provides the clearance - the number of instructions since the closest reaching def instuction of Reg ...

bool hasLocalDefBefore(MachineInstr *MI, Register Reg) const

Provide whether the register has been defined in the same basic block as, and before,...

bool isReachingDefLiveOut(MachineInstr *MI, Register Reg) const

Return whether the reaching def for MI also is live out of its parent block.

bool getLiveInUses(MachineBasicBlock *MBB, Register Reg, InstSet &Uses) const

For the given block, collect the instructions that use the live-in value of the provided register.

bool isSafeToDefRegAt(MachineInstr *MI, Register Reg) const

Return whether a MachineInstr could be inserted at MI and safely define the given register without af...

bool hasSameReachingDef(MachineInstr *A, MachineInstr *B, Register Reg) const

Return whether A and B use the same def of Reg.

void getReachingLocalUses(MachineInstr *MI, Register Reg, InstSet &Uses) const

Provides the uses, in the same block as MI, of register that MI defines.

bool isRegDefinedAfter(MachineInstr *MI, Register Reg) const

Return whether the given register is defined after MI.

MachineFunctionProperties getRequiredProperties() const override

MachineInstr * getUniqueReachingMIDef(MachineInstr *MI, Register Reg) const

If a single MachineInstr creates the reaching definition, then return it.

void getGlobalReachingDefs(MachineInstr *MI, Register Reg, InstSet &Defs) const

Collect all possible definitions of the value stored in Reg, which is used by MI.

bool runOnMachineFunction(MachineFunction &MF) override

runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...

Thin wrapper around "int" used to store reaching definitions, using an encoding that makes it compati...

ReachingDef(std::nullptr_t)

Wrapper class representing virtual and physical registers.

A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...

iterator insert(iterator I, T &&Elt)

void push_back(const T &Elt)

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

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

TinyPtrVector - This class is specialized for cases where there are normally 0 or 1 element in a vect...

This is an optimization pass for GlobalISel generic memory operations.

void initializeReachingDefAnalysisPass(PassRegistry &)

static ReachingDef getFromVoidPointer(const void *P)

static ReachingDef getFromVoidPointer(void *P)

static void * getAsVoidPointer(const ReachingDef &RD)

A traits type that is used to handle pointer types and things that are just wrappers for pointers as ...