LLVM: lib/Transforms/Vectorize/VPlanValue.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#ifndef LLVM_TRANSFORMS_VECTORIZE_VPLAN_VALUE_H

21#define LLVM_TRANSFORMS_VECTORIZE_VPLAN_VALUE_H

22

29

30namespace llvm {

31

32

33class raw_ostream;

35class VPDef;

36struct VPDoubleValueDef;

37class VPSlotTracker;

38class VPUser;

39class VPRecipeBase;

40class VPInterleaveRecipe;

41

42

43

44

45

58

59 const unsigned char SubclassID;

60

62

63protected:

64

66

67

68

70

72

73

75

77

79

80

81

82

83

84

85

86

87public:

88

90

91

92

93 enum {

94 VPValueSC,

95

96 VPVRecipeSC

98

101

103

104

105

106

108

109#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)

112

113

114 void dump() const;

115#endif

116

119

120

122

123

125 if (I != Users.end())

127 }

128

133

141 }

142

143

146 return false;

147

148

149 auto Current = std::next(user_begin());

151 Current++;

152 return Current != user_end();

153 }

154

156

157

158

159

163

164

165

168

169

171

172

174

175

176

177

180 "VPValue is not a live-in; it is defined by a VPDef inside a VPlan");

182 }

185 "VPValue is not a live-in; it is defined by a VPDef inside a VPlan");

187 }

188

189

191

192

196 }

197};

198

201

203

204

205

208

209protected:

210#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)

211

213#endif

214

218 }

219

220 VPUser(std::initializer_list<VPValue *> Operands)

222

226 }

227

228public:

234 Op->removeUser(*this);

235 }

236

240 }

241

244 assert(N < Operands.size() && "Operand index out of bounds");

246 }

247

251 New->addUser(*this);

252 }

253

258

266 }

267

268

269

272 "Op must be an operand of the recipe");

274 }

275

276

277

280 "Op must be an operand of the recipe");

281 return false;

282 }

283

284

285

288 "Op must be an operand of the recipe");

289 return false;

290 }

291};

292

293

294

295

296

297

300

301

302 const unsigned char SubclassID;

303

304

306

307

308 void addDefinedValue(VPValue *V) {

309 assert(V->Def == this &&

310 "can only add VPValue already linked with this VPDef");

312 }

313

314

315

316 void removeDefinedValue(VPValue *V) {

317 assert(V->Def == this && "can only remove VPValue linked with this VPDef");

319 "VPValue to remove must be in DefinedValues");

321 V->Def = nullptr;

322 }

323

324public:

325

326

327

328

330 VPBranchOnMaskSC,

331 VPDerivedIVSC,

332 VPExpandSCEVSC,

333 VPIRInstructionSC,

334 VPInstructionSC,

335 VPInterleaveSC,

336 VPReductionEVLSC,

337 VPReductionSC,

338 VPPartialReductionSC,

339 VPReplicateSC,

340 VPScalarCastSC,

341 VPScalarIVStepsSC,

342 VPVectorPointerSC,

343 VPReverseVectorPointerSC,

344 VPWidenCallSC,

345 VPWidenCanonicalIVSC,

346 VPWidenCastSC,

347 VPWidenGEPSC,

348 VPWidenIntrinsicSC,

349 VPWidenLoadEVLSC,

350 VPWidenLoadSC,

351 VPWidenStoreEVLSC,

352 VPWidenStoreSC,

353 VPWidenSC,

354 VPWidenEVLSC,

355 VPWidenSelectSC,

356 VPBlendSC,

357 VPHistogramSC,

358

359 VPWidenPHISC,

360 VPPredInstPHISC,

361

362

363 VPCanonicalIVPHISC,

364 VPActiveLaneMaskPHISC,

365 VPEVLBasedIVPHISC,

366 VPFirstOrderRecurrencePHISC,

367 VPWidenIntOrFpInductionSC,

368 VPWidenPointerInductionSC,

369 VPScalarPHISC,

370 VPReductionPHISC,

371

372

373 VPFirstPHISC = VPWidenPHISC,

374 VPFirstHeaderPHISC = VPCanonicalIVPHISC,

375 VPLastHeaderPHISC = VPReductionPHISC,

376 VPLastPHISC = VPReductionPHISC,

377 };

378

379 VPDef(const unsigned char SC) : SubclassID(SC) {}

380

384 "all defined VPValues should point to the containing VPDef");

385 assert(D->getNumUsers() == 0 &&

386 "all defined VPValues should have no more users");

387 D->Def = nullptr;

388 delete D;

389 }

390 }

391

392

393

395 assert(DefinedValues.size() == 1 && "must have exactly one defined value");

396 assert(DefinedValues[0] && "defined value must be non-null");

397 return DefinedValues[0];

398 }

400 assert(DefinedValues.size() == 1 && "must have exactly one defined value");

401 assert(DefinedValues[0] && "defined value must be non-null");

402 return DefinedValues[0];

403 }

404

405

407 assert(DefinedValues[I] && "defined value must be non-null");

408 return DefinedValues[I];

409 }

411 assert(DefinedValues[I] && "defined value must be non-null");

412 return DefinedValues[I];

413 }

414

415

417

419

420

422

423

424

425

426 unsigned getVPDefID() const { return SubclassID; }

427

428#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)

429

430 void dump() const;

431

432

435#endif

436};

437

440

441

442

443

444

445

446

448

449

451

453

454

455 unsigned NextSlot = 0;

456

457 void assignName(const VPValue *V);

458 void assignNames(const VPlan &Plan);

460

461public:

463 if (Plan)

464 assignNames(*Plan);

465 }

466

467

468

469

471};

472

473}

474

475#endif

This file defines the StringMap class.

static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")

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.

iv Induction Variable Users

mir Rename Register Operands

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

This file defines the SmallVector class.

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

This class represents an Operation in the Expression.

This class provides computation of slot numbers for LLVM Assembly writing.

typename SuperClass::const_iterator const_iterator

typename SuperClass::iterator iterator

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

StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...

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

void push_back(EltTy NewVal)

Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...

VPBasicBlock serves as the leaf of the Hierarchical Control-Flow Graph.

VPlan-based builder utility analogous to IRBuilder.

This class augments a recipe with a set of VPValues defined by the recipe.

enum { VPBranchOnMaskSC, VPDerivedIVSC, VPExpandSCEVSC, VPIRInstructionSC, VPInstructionSC, VPInterleaveSC, VPReductionEVLSC, VPReductionSC, VPPartialReductionSC, VPReplicateSC, VPScalarCastSC, VPScalarIVStepsSC, VPVectorPointerSC, VPReverseVectorPointerSC, VPWidenCallSC, VPWidenCanonicalIVSC, VPWidenCastSC, VPWidenGEPSC, VPWidenIntrinsicSC, VPWidenLoadEVLSC, VPWidenLoadSC, VPWidenStoreEVLSC, VPWidenStoreSC, VPWidenSC, VPWidenEVLSC, VPWidenSelectSC, VPBlendSC, VPHistogramSC, VPWidenPHISC, VPPredInstPHISC, VPCanonicalIVPHISC, VPActiveLaneMaskPHISC, VPEVLBasedIVPHISC, VPFirstOrderRecurrencePHISC, VPWidenIntOrFpInductionSC, VPWidenPointerInductionSC, VPScalarPHISC, VPReductionPHISC, VPFirstPHISC=VPWidenPHISC, VPFirstHeaderPHISC=VPCanonicalIVPHISC, VPLastHeaderPHISC=VPReductionPHISC, VPLastPHISC=VPReductionPHISC, } VPRecipeTy

An enumeration for keeping track of the concrete subclass of VPRecipeBase that is actually instantiat...

void dump() const

Dump the VPDef to stderr (for debugging).

unsigned getNumDefinedValues() const

Returns the number of values defined by the VPDef.

ArrayRef< VPValue * > definedValues()

Returns an ArrayRef of the values defined by the VPDef.

VPValue * getVPSingleValue()

Returns the only VPValue defined by the VPDef.

const VPValue * getVPSingleValue() const

ArrayRef< VPValue * > definedValues() const

Returns an ArrayRef of the values defined by the VPDef.

virtual void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const =0

Each concrete VPDef prints itself.

VPValue * getVPValue(unsigned I)

Returns the VPValue with index I defined by the VPDef.

unsigned getVPDefID() const

VPDef(const unsigned char SC)

const VPValue * getVPValue(unsigned I) const

This is a concrete Recipe that models a single VPlan-level instruction.

VPInterleaveRecipe is a recipe for transforming an interleave group of load or stores into one wide l...

VPRecipeBase is a base class modeling a sequence of one or more output IR instructions.

This class can be used to assign names to VPValues.

std::string getOrCreateName(const VPValue *V) const

Returns the name assigned to V, if there is one, otherwise try to construct one from the underlying v...

VPSlotTracker(const VPlan *Plan=nullptr)

This class augments VPValue with operands which provide the inverse def-use edges from VPValue's user...

void printOperands(raw_ostream &O, VPSlotTracker &SlotTracker) const

Print the operands to O.

VPUser(std::initializer_list< VPValue * > Operands)

void setOperand(unsigned I, VPValue *New)

VPUser & operator=(const VPUser &)=delete

unsigned getNumOperands() const

SmallVectorImpl< VPValue * >::const_iterator const_operand_iterator

const_operand_iterator op_begin() const

operand_iterator op_end()

const_operand_range operands() const

operand_iterator op_begin()

VPValue * getOperand(unsigned N) const

VPUser(ArrayRef< VPValue * > Operands)

VPUser(const VPUser &)=delete

virtual bool onlyFirstLaneUsed(const VPValue *Op) const

Returns true if the VPUser only uses the first lane of operand Op.

VPUser(iterator_range< IterT > Operands)

iterator_range< const_operand_iterator > const_operand_range

SmallVectorImpl< VPValue * >::iterator operand_iterator

virtual bool onlyFirstPartUsed(const VPValue *Op) const

Returns true if the VPUser only uses the first part of operand Op.

const_operand_iterator op_end() const

virtual bool usesScalars(const VPValue *Op) const

Returns true if the VPUser uses scalars of operand Op.

iterator_range< operand_iterator > operand_range

void addOperand(VPValue *Operand)

bool hasDefiningRecipe() const

Returns true if this VPValue is defined by a recipe.

VPValue(Value *UV=nullptr)

Create a live-in VPValue.

@ VPVRecipeSC

A generic VPValue, like live-in values or defined by a recipe that defines multiple values.

bool isDefinedOutsideLoopRegions() const

Returns true if the VPValue is defined outside any loop region.

unsigned getVPValueID() const

VPRecipeBase * getDefiningRecipe()

Returns the recipe defining this VPValue or nullptr if it is not defined by a recipe,...

void printAsOperand(raw_ostream &OS, VPSlotTracker &Tracker) const

void removeUser(VPUser &User)

Remove a single User from the list of users.

SmallVectorImpl< VPUser * >::const_iterator const_user_iterator

const_user_iterator user_begin() const

const Value * getLiveInIRValue() const

void addUser(VPUser &User)

bool hasMoreThanOneUniqueUser() const

Returns true if the value has more than one unique user.

Value * getUnderlyingValue() const

Return the underlying Value attached to this VPValue.

VPValue(Value *UV, VPDef *Def)

Create a VPValue for a Def which defines multiple values.

const_user_range users() const

VPValue(const VPValue &)=delete

VPValue & operator=(const VPValue &)=delete

void dump() const

Dump the value to stderr (for debugging).

void setUnderlyingValue(Value *Val)

SmallVectorImpl< VPUser * >::iterator user_iterator

iterator_range< user_iterator > user_range

const_user_iterator user_end() const

void print(raw_ostream &OS, VPSlotTracker &Tracker) const

void replaceAllUsesWith(VPValue *New)

VPValue(VPDef *Def, Value *UV=nullptr)

Create a VPValue for a Def which is a subclass of VPValue.

user_iterator user_begin()

unsigned getNumUsers() const

Value * getLiveInIRValue()

Returns the underlying IR value, if this VPValue is defined outside the scope of VPlan.

bool isLiveIn() const

Returns true if this VPValue is a live-in, i.e. defined outside the VPlan.

friend struct VPDoubleValueDef

void replaceUsesWithIf(VPValue *New, llvm::function_ref< bool(VPUser &U, unsigned Idx)> ShouldReplace)

Go through the uses list for this VPValue and make each use point to New if the callback ShouldReplac...

VPDef * Def

Pointer to the VPDef that defines this VPValue.

iterator_range< const_user_iterator > const_user_range

VPlan models a candidate for vectorization, encoding various decisions take to produce efficient outp...

LLVM Value Representation.

An efficient, type-erasing, non-owning reference to a callable.

A range adaptor for a pair of iterators.

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

This provides a very simple, boring adaptor for a begin and end iterator into a range type.

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.

iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)

Make a range that does early increment to allow mutation of the underlying range without disrupting i...

void erase(Container &C, ValueType V)

Wrapper function to remove a value from a container:

DenseMap< VPValue *, Value * > VPValue2ValueTy

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

bool is_contained(R &&Range, const E &Element)

Returns true if Element is found in Range.

DenseMap< Value *, VPValue * > Value2VPValueTy