LLVM: include/llvm/CodeGen/LiveVariables.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

22

23

24

25

26

27

28#ifndef LLVM_CODEGEN_LIVEVARIABLES_H

29#define LLVM_CODEGEN_LIVEVARIABLES_H

30

43

44namespace llvm {

45

48

49class LiveVariables {

51

52public:

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

80

81

82

83

85

86

87

88

89 std::vector<MachineInstr*> Kills;

90

91

92

93

95 std::vector<MachineInstr *>::iterator I = find(Kills, &MI);

97 return false;

99 return true;

100 }

101

102

104

105

106

107

110

112

114 };

115

116private:

117

118

119

121

122private:

124

126

128

129

130

131

132 std::vector<MachineInstr *> PhysRegDef;

133

134

135

136

137 std::vector<MachineInstr *> PhysRegUse;

138

139 std::vector<SmallVector<Register, 4>> PHIVarInfo;

140

141

142

144

145

147

149

150

151

152

154

155

156 void HandleRegMask(const MachineOperand &, unsigned);

157

162

163

164

166

167

168

170

171

172

173

174

176

178 unsigned NumRegs);

179

181

182public:

184

186

187

188

189

190

191

192

193

195

196

197

200

201

202

203

204

206 bool AddIfNotFound = false) {

207 if (MI.addRegisterKilled(IncomingReg, TRI, AddIfNotFound))

209 }

210

211

212

213

214

217 return false;

218

219 bool Removed = false;

221 if (MO.isReg() && MO.isKill() && MO.getReg() == Reg) {

222 MO.setIsKill(false);

223 Removed = true;

224 break;

225 }

226 }

227

228 assert(Removed && "Register is not used by this instruction!");

229 (void)Removed;

230 return true;

231 }

232

233

234

236

237

238

239

241 bool AddIfNotFound = false) {

242 if (MI.addRegisterDead(IncomingReg, TRI, AddIfNotFound))

244 }

245

246

247

248

249

252 return false;

253

254 bool Removed = false;

256 if (MO.getReg() == Reg) {

257 MO.setIsDead(false);

258 Removed = true;

259 break;

260 }

261 }

262 assert(Removed && "Register is not defined by this instruction!");

263 (void)Removed;

264 return true;

265 }

266

267

268

270

278

282

286

287

288

289

291

292

293

294

295

298

302};

303

312

314 : public PassInfoMixin {

316

317public:

322};

323

326

327public:

328 static char ID;

329

333

335 LV.analyze(MF);

336 return false;

337 }

338

339 void getAnalysisUsage(AnalysisUsage &AU) const override;

340

342

344};

345

346}

347

348#endif

unsigned const MachineRegisterInfo * MRI

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

This file defines the DenseMap class.

This file implements an indexed map.

Register const TargetRegisterInfo * TRI

This file defines the SmallSet class.

This file defines the SmallVector class.

This file defines the SparseBitVector class.

Represent the analysis usage information of a pass.

Definition LiveVariables.h:304

LLVM_ABI Result run(MachineFunction &MF, MachineFunctionAnalysisManager &)

LiveVariables Result

Definition LiveVariables.h:309

static bool isRequired()

Definition LiveVariables.h:321

LLVM_ABI PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)

LiveVariablesPrinterPass(raw_ostream &OS)

Definition LiveVariables.h:318

bool runOnMachineFunction(MachineFunction &MF) override

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

Definition LiveVariables.h:334

LiveVariablesWrapperPass()

Definition LiveVariables.h:330

void releaseMemory() override

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

Definition LiveVariables.h:341

static char ID

Definition LiveVariables.h:328

LiveVariables & getLV()

Definition LiveVariables.h:343

Definition LiveVariables.h:49

LLVM_ABI void replaceKillInstruction(Register Reg, MachineInstr &OldMI, MachineInstr &NewMI)

replaceKillInstruction - Update register kill info by replacing a kill instruction with a new one.

LLVM_ABI void MarkVirtRegAliveInBlock(VarInfo &VRInfo, MachineBasicBlock *DefBlock, MachineBasicBlock *BB)

bool removeVirtualRegisterDead(Register Reg, MachineInstr &MI)

removeVirtualRegisterDead - Remove the specified kill of the virtual register from the live variable ...

Definition LiveVariables.h:250

bool removeVirtualRegisterKilled(Register Reg, MachineInstr &MI)

removeVirtualRegisterKilled - Remove the specified kill of the virtual register from the live variabl...

Definition LiveVariables.h:215

LLVM_ABI void removeVirtualRegistersKilled(MachineInstr &MI)

removeVirtualRegistersKilled - Remove all killed info for the specified instruction.

void addVirtualRegisterDead(Register IncomingReg, MachineInstr &MI, bool AddIfNotFound=false)

addVirtualRegisterDead - Add information about the fact that the specified register is dead after bei...

Definition LiveVariables.h:240

LLVM_ABI bool isLiveOut(Register Reg, const MachineBasicBlock &MBB)

isLiveOut - Determine if Reg is live out from MBB, when not considering PHI nodes.

LLVM_ABI void HandleVirtRegDef(Register reg, MachineInstr &MI)

LLVM_ABI void print(raw_ostream &OS) const

bool isLiveIn(Register Reg, const MachineBasicBlock &MBB)

Definition LiveVariables.h:283

LLVM_ABI void recomputeForSingleDefVirtReg(Register Reg)

Recompute liveness from scratch for a virtual register Reg that is known to have a single def that do...

LLVM_ABI void HandleVirtRegUse(Register reg, MachineBasicBlock *MBB, MachineInstr &MI)

void addVirtualRegisterKilled(Register IncomingReg, MachineInstr &MI, bool AddIfNotFound=false)

addVirtualRegisterKilled - Add information about the fact that the specified register is killed after...

Definition LiveVariables.h:205

friend class LiveVariablesWrapperPass

Definition LiveVariables.h:50

LLVM_ABI VarInfo & getVarInfo(Register Reg)

getVarInfo - Return the VarInfo structure for the specified VIRTUAL register.

LLVM_ABI void addNewBlock(MachineBasicBlock *BB, MachineBasicBlock *DomBB, MachineBasicBlock *SuccBB)

addNewBlock - Add a new basic block BB between DomBB and SuccBB.

MachineFunctionPass(char &ID)

Representation of each machine instruction.

MachineOperand class - Representation of each machine instruction operand.

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

static LLVM_ABI PassRegistry * getPassRegistry()

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

A set of analyses that are preserved following a run of a transformation pass.

Wrapper class representing virtual and physical registers.

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

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

This class implements an extremely fast bulk output stream that can only output to a stream.

This is an optimization pass for GlobalISel generic memory operations.

auto find(R &&Range, const T &Val)

Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.

AnalysisManager< MachineFunction > MachineFunctionAnalysisManager

LLVM_ABI void initializeLiveVariablesWrapperPassPass(PassRegistry &)

A CRTP mix-in that provides informational APIs needed for analysis passes.

A special type used by analysis passes to provide an address that identifies that particular analysis...

VarInfo - This represents the regions where a virtual register is live in the program.

Definition LiveVariables.h:79

bool removeKill(MachineInstr &MI)

removeKill - Delete a kill corresponding to the specified machine instruction.

Definition LiveVariables.h:94

LLVM_ABI void dump() const

std::vector< MachineInstr * > Kills

Kills - List of MachineInstruction's which are the last use of this virtual register (kill it) in the...

Definition LiveVariables.h:89

SparseBitVector AliveBlocks

AliveBlocks - Set of blocks in which this value is alive completely through.

Definition LiveVariables.h:84

LLVM_ABI MachineInstr * findKill(const MachineBasicBlock *MBB) const

findKill - Find a kill instruction in MBB. Return NULL if none is found.

LLVM_ABI void print(raw_ostream &OS) const

LLVM_ABI bool isLiveIn(const MachineBasicBlock &MBB, Register Reg, MachineRegisterInfo &MRI)

isLiveIn - Is Reg live in to MBB?

A CRTP mix-in to automatically provide informational APIs needed for passes.

VirtRegInfo - Information about a virtual register used by a set of operands.