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

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46#ifndef LLVM_CODEGEN_MACHINETRACEMETRICS_H

47#define LLVM_CODEGEN_MACHINETRACEMETRICS_H

48

57

58namespace llvm {

59

60class AnalysisUsage;

61class MachineFunction;

62class MachineInstr;

63class MachineLoop;

64class MachineLoopInfo;

65class MachineRegisterInfo;

66struct MCSchedClassDesc;

67class raw_ostream;

68class TargetInstrInfo;

69class TargetRegisterInfo;

70

71

72

73

74

79 unsigned Op = 0;

80

82

84};

85

86

88

90

91

92

95};

96

104

105public:

109

111

112

114

116 init(MF, LI);

117 }

118

120

122

125

126

127

129

130

132

133

135

137

138

140

141

143 };

144

145

147

148

149

150

151

152

154

155

156

158

160

161

162

164

166 };

167

168

169

170

172

173

175

176

177

179

180

182

183

185

186

187

189

190

191

193

195

196

197

199

200

201

203

204

206

207

209

210

211

212

213

214

215

217

219 return false;

220

222 return false;

223

224

225

226

227

229 }

230

231

232

233

234

235

237

238

240

241

242

243

245

246

247

248

249

251

254 };

255

256

257

259

260

261

263

264

265

267 };

268

269

270

271

275

276 unsigned getBlockNum() const { return &TBI - &TE.BlockInfo[0]; }

277

278 public:

280

283

284

287 }

288

289

290

291

292

293

295

296

297

298

299

300

301

302

303

307 ArrayRef<const MCSchedClassDesc *> RemoveInstrs = {}) const;

308

309

310

312

313

314

315

317 return TE.Cycles.lookup(&MI);

318 }

319

320

321

322

324

325

326

328

329

330

331

334 };

335

336

337

338

341

346

350 unsigned computeCrossBlockCriticalPath(const TraceBlockInfo&);

355

356 protected:

358

360

368

369 public:

371

372 virtual const char *getName() const = 0;

377

378

379

381

382

387

388

392

393 };

394

395

396

397

399

400

401

402

403

404

405

406

407

409

410

413

415

416private:

417

419

420

421

422

423

424

426

427

428 std::unique_ptr

430

431

432

433 unsigned getCycles(unsigned Scaled) {

435 return (Scaled + Factor - 1) / Factor;

436 }

437};

438

442 return OS;

443}

444

448 return OS;

449}

450

455

456public:

459};

460

461

463 : PassInfoMixin {

467};

468

470public:

473

475

481};

482

483}

484

485#endif

MachineInstrBuilder & UseMI

MachineInstrBuilder MachineInstrBuilder & DefMI

This file defines the DenseMap class.

LiveInRegUnits addLiveIns(MBB)

This file defines the SmallVector class.

This file defines the SparseSet class derived from the version described in Briggs,...

API to communicate dependencies between analyses during invalidation.

A container for analyses that lazily runs them and caches their results.

Represent the analysis usage information of a pass.

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

This class represents an Operation in the Expression.

A possibly irreducible generalization of a Loop.

MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...

Representation of each machine instruction.

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

Result run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)

void getAnalysisUsage(AnalysisUsage &) const override

getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.

bool runOnMachineFunction(MachineFunction &) override

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

void verifyAnalysis() const override

verifyAnalysis() - This member can be implemented by a analysis pass to check state of analysis infor...

void releaseMemory() override

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

MachineTraceMetrics & getMTM()

MachineTraceMetricsWrapperPass()

A trace ensemble is a collection of traces selected using the same strategy, for example 'minimum res...

void invalidate(const MachineBasicBlock *MBB)

Invalidate traces through BadMBB.

ArrayRef< unsigned > getProcResourceHeights(unsigned MBBNum) const

Get an array of processor resource heights for MBB.

virtual const MachineBasicBlock * pickTracePred(const MachineBasicBlock *)=0

void updateDepth(TraceBlockInfo &TBI, const MachineInstr &, SparseSet< LiveRegUnit > &RegUnits)

Updates the depth of an machine instruction, given RegUnits.

const MachineLoop * getLoopFor(const MachineBasicBlock *) const

const TraceBlockInfo * getHeightResources(const MachineBasicBlock *) const

void updateDepths(MachineBasicBlock::iterator Start, MachineBasicBlock::iterator End, SparseSet< LiveRegUnit > &RegUnits)

Updates the depth of the instructions from Start to End.

const TraceBlockInfo * getDepthResources(const MachineBasicBlock *) const

virtual const char * getName() const =0

ArrayRef< unsigned > getProcResourceDepths(unsigned MBBNum) const

Get an array of processor resource depths for MBB.

MachineTraceMetrics & MTM

virtual const MachineBasicBlock * pickTraceSucc(const MachineBasicBlock *)=0

void print(raw_ostream &) const

Trace getTrace(const MachineBasicBlock *MBB)

Get the trace that passes through MBB.

A trace represents a plausible sequence of executed basic blocks that passes through the current basi...

unsigned getInstrCount() const

Compute the total number of instructions in the trace.

unsigned getResourceLength(ArrayRef< const MachineBasicBlock * > Extrablocks={}, ArrayRef< const MCSchedClassDesc * > ExtraInstrs={}, ArrayRef< const MCSchedClassDesc * > RemoveInstrs={}) const

Return the resource length of the trace.

InstrCycles getInstrCycles(const MachineInstr &MI) const

Return the depth and height of MI.

unsigned getInstrSlack(const MachineInstr &MI) const

Return the slack of MI.

bool isDepInTrace(const MachineInstr &DefMI, const MachineInstr &UseMI) const

A dependence is useful if the basic block of the defining instruction is part of the trace of the use...

Trace(Ensemble &te, TraceBlockInfo &tbi)

unsigned getCriticalPath() const

Return the length of the (data dependency) critical path through the trace.

unsigned getPHIDepth(const MachineInstr &PHI) const

Return the Depth of a PHI instruction in a trace center block successor.

void print(raw_ostream &) const

unsigned getResourceDepth(bool Bottom) const

Return the resource depth of the top/bottom of the trace center block.

MachineTraceMetrics(MachineTraceMetrics &&)=default

MachineTraceMetrics()=default

Ensemble * getEnsemble(MachineTraceStrategy)

Get the trace ensemble representing the given trace selection strategy.

void verifyAnalysis() const

void invalidate(const MachineBasicBlock *MBB)

Invalidate cached information about MBB.

const FixedBlockInfo * getResources(const MachineBasicBlock *)

Get the fixed resource information about MBB. Compute it on demand.

ArrayRef< unsigned > getProcReleaseAtCycles(unsigned MBBNum) const

Get the scaled number of cycles used per processor resource in MBB.

void init(MachineFunction &Func, const MachineLoopInfo &LI)

MachineTraceMetrics(MachineFunction &MF, const MachineLoopInfo &LI)

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

Wrapper class representing virtual and physical registers.

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

SparseSet - Fast set implementation for objects that can be identified by small unsigned keys.

TargetInstrInfo - Interface to description of machine instruction set.

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

Provide an instruction scheduling machine model to CodeGen passes.

unsigned getLatencyFactor() const

Multiply cycle count by this factor to normalize it relative to other resources.

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.

MachineTraceStrategy

Strategies for selecting traces.

@ TS_MinInstrCount

Select the trace through a block that has the fewest instructions.

@ TS_Local

Select the trace that contains only the current basic block.

raw_ostream & dbgs()

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

raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)

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...

unsigned getSparseSetIndex() const

Verifier pass for MachineTraceMetrics.

PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)

Per-basic block information that doesn't depend on the trace through the block.

bool hasResources() const

Returns true when resource information for this block has been computed.

unsigned InstrCount

The number of non-trivial instructions in the block.

void invalidate()

Invalidate resource information.

bool HasCalls

True when the block contains calls.

InstrCycles represents the cycle height and depth of an instruction in a trace.

unsigned Height

Minimum number of cycles from this instruction is issued to the of the trace, as determined by data d...

unsigned Depth

Earliest issue cycle as determined by data dependencies and instruction latencies from the beginning ...

A virtual register or regunit required by a basic block or its trace successors.

unsigned Height

For virtual registers: Minimum height of the defining instruction.

Register Reg

The virtual register required, or a register unit.

LiveInReg(Register Reg, unsigned Height=0)

Per-basic block information that relates to a specific trace through the block.

unsigned InstrDepth

Accumulated number of instructions in the trace above this block.

void invalidateDepth()

Invalidate depth resources when some block above this one has changed.

const MachineBasicBlock * Pred

Trace predecessor, or NULL for the first block in the trace.

unsigned InstrHeight

Accumulated number of instructions in the trace below this block.

SmallVector< LiveInReg, 4 > LiveIns

Live-in registers.

const MachineBasicBlock * Succ

Trace successor, or NULL for the last block in the trace.

bool hasValidDepth() const

Returns true if the depth resources have been computed from the trace above this block.

bool isUsefulDominator(const TraceBlockInfo &TBI) const

Assuming that this is a dominator of TBI, determine if it contains useful instruction depths.

void invalidateHeight()

Invalidate height resources when a block below this one has changed.

unsigned CriticalPath

Critical path length.

void print(raw_ostream &) const

unsigned Head

The block number of the head of the trace. (When hasValidDepth()).

bool HasValidInstrDepths

Instruction depths have been computed. This implies hasValidDepth().

bool hasValidHeight() const

Returns true if the height resources have been computed from the trace below this block.

unsigned Tail

The block number of the tail of the trace. (When hasValidHeight()).

bool HasValidInstrHeights

Instruction heights have been computed. This implies hasValidHeight().

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