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

30

31namespace llvm {

32

33

37struct VPDoubleValueDef;

43

44

45

46

47

54

55 const unsigned char SubclassID;

56

58

59protected:

60

62

63

64

66

68

69

71

73

75

76

77

78

79

80

81

82

83public:

84

86

87

88

89 enum {

90 VPValueSC,

91

92 VPVRecipeSC

93 };

94

97

99

100

101

102

104

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

108

109

110 void dump() const;

111#endif

112

113 unsigned getNumUsers() const { return Users.size(); }

115

116

118

119

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

122 Users.erase(I);

123 }

124

129

138

139

142 return false;

143

144

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

147 Current++;

148 return Current != user_end();

149 }

150

152

153

154

159

161

162

163

164

165 void replaceUsesWithIf(

168

169

170

172 const VPRecipeBase *getDefiningRecipe() const;

173

174

176

177

179

180

181

182

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

187 }

188

189

190 bool isDefinedOutsideLoopRegions() const;

191

192

197};

198

201

204

205

206

208

210

212

213

214

215 void removeOperand(unsigned Idx) {

217 Operands.erase(Operands.begin() + Idx);

218 }

219

220protected:

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

222

224#endif

225

227 for (VPValue *Operand : Operands)

229 }

230

231public:

237 Op->removeUser(*this);

238 }

239

241 Operands.push_back(Operand);

243 }

244

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

248 return Operands[N];

249 }

250

252 Operands[I]->removeUser(*this);

253 Operands[I] = New;

254 New->addUser(*this);

255 }

256

257

259 assert(Operands.size() == 2 && "must have 2 operands to swap");

260 std::swap(Operands[0], Operands[1]);

261 }

262

263

265

270

279

280

281

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

286 }

287

288

289

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

293 return false;

294 }

295

296

297

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

301 return false;

302 }

303};

304

305

306

307

308

309

312

313

314 const unsigned char SubclassID;

315

316

318

319

320 void addDefinedValue(VPValue *V) {

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

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

323 DefinedValues.push_back(V);

324 }

325

326

327

328 void removeDefinedValue(VPValue *V) {

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

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

333 V->Def = nullptr;

334 }

335

336public:

337

338

339

340

342 VPBranchOnMaskSC,

343 VPDerivedIVSC,

344 VPExpandSCEVSC,

345 VPExpressionSC,

346 VPIRInstructionSC,

347 VPInstructionSC,

348 VPInterleaveEVLSC,

349 VPInterleaveSC,

350 VPReductionEVLSC,

351 VPReductionSC,

352 VPReplicateSC,

353 VPScalarIVStepsSC,

354 VPVectorPointerSC,

355 VPVectorEndPointerSC,

356 VPWidenCallSC,

357 VPWidenCanonicalIVSC,

358 VPWidenCastSC,

359 VPWidenGEPSC,

360 VPWidenIntrinsicSC,

361 VPWidenLoadEVLSC,

362 VPWidenLoadSC,

363 VPWidenStoreEVLSC,

364 VPWidenStoreSC,

365 VPWidenSC,

366 VPWidenSelectSC,

367 VPBlendSC,

368 VPHistogramSC,

369

370 VPWidenPHISC,

371 VPPredInstPHISC,

372

373

374 VPCanonicalIVPHISC,

375 VPActiveLaneMaskPHISC,

376 VPEVLBasedIVPHISC,

377 VPFirstOrderRecurrencePHISC,

378 VPWidenIntOrFpInductionSC,

379 VPWidenPointerInductionSC,

380 VPReductionPHISC,

381

382

383 VPFirstPHISC = VPWidenPHISC,

384 VPFirstHeaderPHISC = VPCanonicalIVPHISC,

385 VPLastHeaderPHISC = VPReductionPHISC,

386 VPLastPHISC = VPReductionPHISC,

387 };

388

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

390

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

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

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

397 D->Def = nullptr;

398 delete D;

399 }

400 }

401

402

403

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

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

407 return DefinedValues[0];

408 }

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

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

412 return DefinedValues[0];

413 }

414

415

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

418 return DefinedValues[I];

419 }

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

422 return DefinedValues[I];

423 }

424

425

427

429

430

432

433

434

435

436 unsigned getVPDefID() const { return SubclassID; }

437

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

439

441

442

445#endif

446};

447

448}

449

450#endif

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

This file defines the StringMap class.

static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)

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

static void replaceAllUsesWith(Value *Old, Value *New, SmallPtrSet< BasicBlock *, 32 > &FreshBBs, bool IsHuge)

Replace all old uses with new ones, and push the updated BBs into FreshBBs.

#define LLVM_ABI_FOR_TEST

This file defines the DenseMap class.

This file defines the SmallVector class.

static const BasicSubtargetSubTypeKV * find(StringRef S, ArrayRef< BasicSubtargetSubTypeKV > A)

Find KV in array using binary search.

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

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.

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

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

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

Definition VPlanValue.h:310

LLVM_ABI_FOR_TEST void dump() const

Dump the VPDef to stderr (for debugging).

unsigned getNumDefinedValues() const

Returns the number of values defined by the VPDef.

Definition VPlanValue.h:431

enum { VPBranchOnMaskSC, VPDerivedIVSC, VPExpandSCEVSC, VPExpressionSC, VPIRInstructionSC, VPInstructionSC, VPInterleaveEVLSC, VPInterleaveSC, VPReductionEVLSC, VPReductionSC, VPReplicateSC, VPScalarIVStepsSC, VPVectorPointerSC, VPVectorEndPointerSC, VPWidenCallSC, VPWidenCanonicalIVSC, VPWidenCastSC, VPWidenGEPSC, VPWidenIntrinsicSC, VPWidenLoadEVLSC, VPWidenLoadSC, VPWidenStoreEVLSC, VPWidenStoreSC, VPWidenSC, VPWidenSelectSC, VPBlendSC, VPHistogramSC, VPWidenPHISC, VPPredInstPHISC, VPCanonicalIVPHISC, VPActiveLaneMaskPHISC, VPEVLBasedIVPHISC, VPFirstOrderRecurrencePHISC, VPWidenIntOrFpInductionSC, VPWidenPointerInductionSC, 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...

Definition VPlanValue.h:341

virtual ~VPDef()

Definition VPlanValue.h:391

ArrayRef< VPValue * > definedValues()

Returns an ArrayRef of the values defined by the VPDef.

Definition VPlanValue.h:426

VPValue * getVPSingleValue()

Returns the only VPValue defined by the VPDef.

Definition VPlanValue.h:404

const VPValue * getVPSingleValue() const

Definition VPlanValue.h:409

ArrayRef< VPValue * > definedValues() const

Returns an ArrayRef of the values defined by the VPDef.

Definition VPlanValue.h:428

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.

Definition VPlanValue.h:416

friend class VPValue

Definition VPlanValue.h:311

unsigned getVPDefID() const

Definition VPlanValue.h:436

VPDef(const unsigned char SC)

Definition VPlanValue.h:389

const VPValue * getVPValue(unsigned I) const

Definition VPlanValue.h:420

A common base class for interleaved memory operations.

Helper type to provide functions to access incoming values and blocks for phi-like recipes.

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.

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

Definition VPlanValue.h:207

void replaceUsesOfWith(VPValue *From, VPValue *To)

Replaces all uses of From in the VPUser with To.

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

Print the operands to O.

operand_range operands()

Definition VPlanValue.h:275

void setOperand(unsigned I, VPValue *New)

Definition VPlanValue.h:251

VPUser & operator=(const VPUser &)=delete

friend class VPPhiAccessors

Grant access to removeOperand for VPPhiAccessors, the only supported user.

Definition VPlanValue.h:209

unsigned getNumOperands() const

Definition VPlanValue.h:245

SmallVectorImpl< VPValue * >::const_iterator const_operand_iterator

Definition VPlanValue.h:267

const_operand_iterator op_begin() const

Definition VPlanValue.h:272

operand_iterator op_end()

Definition VPlanValue.h:273

const_operand_range operands() const

Definition VPlanValue.h:276

operand_iterator op_begin()

Definition VPlanValue.h:271

VPValue * getOperand(unsigned N) const

Definition VPlanValue.h:246

VPUser(ArrayRef< VPValue * > Operands)

Definition VPlanValue.h:226

VPUser(const VPUser &)=delete

iterator_range< const_operand_iterator > const_operand_range

Definition VPlanValue.h:269

virtual bool usesFirstPartOnly(const VPValue *Op) const

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

Definition VPlanValue.h:298

void swapOperands()

Swap operands of the VPUser. It must have exactly 2 operands.

Definition VPlanValue.h:258

SmallVectorImpl< VPValue * >::iterator operand_iterator

Definition VPlanValue.h:266

virtual ~VPUser()

Definition VPlanValue.h:235

virtual bool usesFirstLaneOnly(const VPValue *Op) const

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

Definition VPlanValue.h:290

const_operand_iterator op_end() const

Definition VPlanValue.h:274

virtual bool usesScalars(const VPValue *Op) const

Returns true if the VPUser uses scalars of operand Op.

Definition VPlanValue.h:282

iterator_range< operand_iterator > operand_range

Definition VPlanValue.h:268

void addOperand(VPValue *Operand)

Definition VPlanValue.h:240

This is the base class of the VPlan Def/Use graph, used for modeling the data flow into,...

Definition VPlanValue.h:48

bool hasDefiningRecipe() const

Returns true if this VPValue is defined by a recipe.

Definition VPlanValue.h:175

VPValue(Value *UV=nullptr)

Create a live-in VPValue.

Definition VPlanValue.h:70

unsigned getVPValueID() const

Definition VPlanValue.h:103

VPRecipeBase * getDefiningRecipe()

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

friend class VPExpressionRecipe

Definition VPlanValue.h:53

void removeUser(VPUser &User)

Remove a single User from the list of users.

Definition VPlanValue.h:117

SmallVectorImpl< VPUser * >::const_iterator const_user_iterator

Definition VPlanValue.h:126

const_user_iterator user_begin() const

Definition VPlanValue.h:131

void addUser(VPUser &User)

Definition VPlanValue.h:114

bool hasMoreThanOneUniqueUser() const

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

Definition VPlanValue.h:140

Value * getLiveInIRValue() const

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

Definition VPlanValue.h:183

friend class VPDef

Definition VPlanValue.h:49

Value * getUnderlyingValue() const

Return the underlying Value attached to this VPValue.

Definition VPlanValue.h:85

Value * UnderlyingVal

Hold the underlying Value, if any, attached to this VPValue.

Definition VPlanValue.h:61

VPValue(Value *UV, VPDef *Def)

Create a VPValue for a Def which defines multiple values.

Definition VPlanValue.h:74

const_user_range users() const

Definition VPlanValue.h:135

VPValue(const VPValue &)=delete

VPValue & operator=(const VPValue &)=delete

@ VPVRecipeSC

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

Definition VPlanValue.h:92

@ VPValueSC

Definition VPlanValue.h:90

bool hasOneUse() const

Definition VPlanValue.h:151

const VPUser * getSingleUser() const

Definition VPlanValue.h:156

VPValue(const unsigned char SC, Value *UV=nullptr, VPDef *Def=nullptr)

void setUnderlyingValue(Value *Val)

Definition VPlanValue.h:193

SmallVectorImpl< VPUser * >::iterator user_iterator

Definition VPlanValue.h:125

iterator_range< user_iterator > user_range

Definition VPlanValue.h:127

const_user_iterator user_end() const

Definition VPlanValue.h:133

VPUser * getSingleUser()

Return the single user of this value, or nullptr if there is not exactly one user.

Definition VPlanValue.h:155

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

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

Definition VPlanValue.h:72

user_iterator user_begin()

Definition VPlanValue.h:130

friend class VPInterleaveBase

Definition VPlanValue.h:51

unsigned getNumUsers() const

Definition VPlanValue.h:113

user_iterator user_end()

Definition VPlanValue.h:132

bool isLiveIn() const

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

Definition VPlanValue.h:178

friend struct VPDoubleValueDef

Definition VPlanValue.h:50

user_range users()

Definition VPlanValue.h:134

VPDef * Def

Pointer to the VPDef that defines this VPValue.

Definition VPlanValue.h:65

iterator_range< const_user_iterator > const_user_range

Definition VPlanValue.h:128

friend class VPlan

Definition VPlanValue.h:52

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.

void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)

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

Definition VPlanValue.h:200

DWARFExpression::Operation Op

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

Definition VPlanValue.h:199

void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)

Implement std::swap in terms of BitVector swap.