LLVM 23.0.0git
VPlanValue.h
Go to the documentation of this file.
1//===- VPlanValue.h - Represent Values in Vectorizer Plan -----------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// This file contains the declarations of the entities induced by Vectorization
11/// Plans, e.g. the instructions the VPlan intends to generate if executed.
12/// VPlan models the following entities:
13/// VPValue VPUser VPDef
14/// | |
15/// VPInstruction
16/// These are documented in docs/VectorizationPlan.rst.
17///
18//===----------------------------------------------------------------------===//
19
20#ifndef LLVM_TRANSFORMS_VECTORIZE_VPLAN_VALUE_H
21#define LLVM_TRANSFORMS_VECTORIZE_VPLAN_VALUE_H
22
23#include "llvm/ADT/STLExtras.h"
27#include "llvm/IR/Constants.h"
28#include "llvm/IR/DebugLoc.h"
31
32namespace llvm {
33
34// Forward declarations.
35class raw_ostream;
36class Type;
37class Value;
38class VPDef;
39class VPSlotTracker;
40class VPUser;
41class VPRecipeBase;
42class VPPhiAccessors;
43class VPRegionValue;
44class VPRegionBlock;
46
47/// This is the base class of the VPlan Def/Use graph, used for modeling the
48/// data flow into, within and out of the VPlan. VPValues can stand for live-ins
49/// coming from the input IR, symbolic values and values defined by recipes.
50class LLVM_ABI_FOR_TEST VPValue {
51 friend struct VPIRValue;
52 friend struct VPSymbolicValue;
53 friend class VPRecipeValue;
54 friend class VPRegionValue;
55
56 const unsigned char SubclassID; ///< Subclass identifier (for isa/dyn_cast).
57
59
60 /// Hold the underlying Value, if any, attached to this VPValue.
61 Value *UnderlyingVal;
62
63 VPValue(const unsigned char SC, Value *UV = nullptr)
64 : SubclassID(SC), UnderlyingVal(UV) {}
65
66 // DESIGN PRINCIPLE: Access to the underlying IR must be strictly limited to
67 // the front-end and back-end of VPlan so that the middle-end is as
68 // independent as possible of the underlying IR. We grant access to the
69 // underlying IR using friendship. In that way, we should be able to use VPlan
70 // for multiple underlying IRs (Polly?) by providing a new VPlan front-end,
71 // back-end and analysis information for the new IR.
72
73public:
74 /// Return the underlying Value attached to this VPValue.
75 Value *getUnderlyingValue() const { return UnderlyingVal; }
76
77 /// Return the underlying IR value for a VPIRValue.
78 Value *getLiveInIRValue() const;
79
80 /// An enumeration for keeping track of the concrete subclass of VPValue that
81 /// are actually instantiated.
82 enum {
83 VPVIRValueSC, /// A live-in VPValue wrapping an IR Value.
84 VPVSymbolicSC, /// A symbolic live-in VPValue without IR backing.
85 VPVSingleDefValueSC, /// A VPValue defined by a VPSingleDefRecipe.
86 VPVMultiDefValueSC, /// A VPValue defined by a multi-def recipe.
87 VPRegionValueSC, /// A VPValue sub-class that is defined by a
88 /// region, like a loop region canonical IV.
89 };
90
91 VPValue(const VPValue &) = delete;
92 VPValue &operator=(const VPValue &) = delete;
93
94 virtual ~VPValue() {
95 assert(Users.empty() && "trying to delete a VPValue with remaining users");
96 }
97
98 /// \return an ID for the concrete type of this object.
99 /// This is used to implement the classof checks. This should not be used
100 /// for any other purpose, as the values may change as LLVM evolves.
101 unsigned getVPValueID() const { return SubclassID; }
102
103#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
104 void printAsOperand(raw_ostream &OS, VPSlotTracker &Tracker) const;
105 void print(raw_ostream &OS, VPSlotTracker &Tracker) const;
106
107 /// Dump the value to stderr (for debugging).
108 void dump() const;
109#endif
110
111 /// Assert that this VPValue has not been materialized, if it is a
112 /// VPSymbolicValue.
113 void assertNotMaterialized() const;
114
115 unsigned getNumUsers() const {
116 if (Users.empty())
117 return 0;
119 return Users.size();
120 }
123 Users.push_back(&User);
124 }
125
126 /// Remove a single \p User from the list of users.
129 // The same user can be added multiple times, e.g. because the same VPValue
130 // is used twice by the same VPUser. Remove a single one.
131 auto *I = find(Users, &User);
132 if (I != Users.end())
133 Users.erase(I);
134 }
135
140
143 return Users.begin();
144 }
147 return Users.begin();
148 }
151 return Users.end();
152 }
155 return Users.end();
156 }
160 }
161
162 /// Returns true if the value has more than one unique user.
164 if (getNumUsers() == 0)
165 return false;
166
167 // Check if all users match the first user.
168 auto Current = std::next(user_begin());
169 while (Current != user_end() && *user_begin() == *Current)
170 Current++;
171 return Current != user_end();
172 }
173
174 bool hasOneUse() const { return getNumUsers() == 1; }
175
176 /// Return the single user of this value, or nullptr if there is not exactly
177 /// one user.
178 VPUser *getSingleUser() { return hasOneUse() ? *user_begin() : nullptr; }
179 const VPUser *getSingleUser() const {
180 return hasOneUse() ? *user_begin() : nullptr;
181 }
182
183 void replaceAllUsesWith(VPValue *New);
184
185 /// Go through the uses list for this VPValue and make each use point to \p
186 /// New if the callback ShouldReplace returns true for the given use specified
187 /// by a pair of (VPUser, the use index).
188 void replaceUsesWithIf(
189 VPValue *New,
190 llvm::function_ref<bool(VPUser &U, unsigned Idx)> ShouldReplace);
191
192 /// Returns the recipe defining this VPValue or nullptr if it is not defined
193 /// by a recipe, i.e. is a live-in.
194 VPRecipeBase *getDefiningRecipe();
195 const VPRecipeBase *getDefiningRecipe() const;
196
197 /// Returns the scalar type of this VPValue, dispatching based on the
198 /// concrete subclass.
199 Type *getScalarType() const;
200
201 /// Returns true if this VPValue is defined by a recipe.
202 bool hasDefiningRecipe() const { return getDefiningRecipe(); }
203
204 /// Returns true if the VPValue is defined outside any loop.
205 bool isDefinedOutsideLoopRegions() const;
206
207 // Set \p Val as the underlying Value of this VPValue.
209 assert(!UnderlyingVal && "Underlying Value is already set.");
210 UnderlyingVal = Val;
211 }
212};
213
214/// VPValues defined by a VPRegionBlock, like the canonical IV.
215class VPRegionValue : public VPValue {
216 VPRegionBlock *DefiningRegion;
217 Type *Ty;
218 DebugLoc DL;
219
220public:
222 : VPValue(VPValue::VPRegionValueSC), DefiningRegion(Region), Ty(Ty),
223 DL(DL) {}
224
225 ~VPRegionValue() override = default;
226
227 /// Returns the region that defines this value.
228 VPRegionBlock *getDefiningRegion() const { return DefiningRegion; }
229
230 /// Returns the type of the VPRegionValue.
231 Type *getType() const { return Ty; }
232
233 /// Returns the debug location of the VPRegionValue.
234 DebugLoc getDebugLoc() const { return DL; }
235
236 static inline bool classof(const VPValue *V) {
237 return V->getVPValueID() == VPValue::VPRegionValueSC;
238 }
239};
240
241LLVM_ABI_FOR_TEST raw_ostream &operator<<(raw_ostream &OS,
242 const VPRecipeBase &R);
243
244/// A VPValue representing a live-in from the input IR or a constant. It wraps
245/// an underlying IR Value.
246struct VPIRValue : public VPValue {
247 VPIRValue(Value *UV) : VPValue(VPVIRValueSC, UV) {
248 assert(UV && "VPIRValue requires an underlying IR value");
249 }
250
251 /// Returns the underlying IR value.
252 Value *getValue() const { return getUnderlyingValue(); }
253
254 /// Returns the type of the underlying IR value.
255 Type *getType() const;
256
257 static bool classof(const VPValue *V) {
258 return V->getVPValueID() == VPVIRValueSC;
259 }
260};
261
262/// An overlay on VPIRValue for VPValues that wrap a ConstantInt. Provides
263/// convenient accessors for the underlying constant.
264struct VPConstantInt : public VPIRValue {
266
267 static bool classof(const VPValue *V) {
268 return isa<VPIRValue>(V) && isa<ConstantInt>(V->getUnderlyingValue());
269 }
270
271 bool isOne() const { return getAPInt().isOne(); }
272
273 bool isZero() const { return getAPInt().isZero(); }
274
275 const APInt &getAPInt() const {
276 return cast<ConstantInt>(getValue())->getValue();
277 }
278
279 unsigned getBitWidth() const { return getAPInt().getBitWidth(); }
280
282};
283
284/// A symbolic live-in VPValue, used for values like vector trip count, VF, and
285/// VFxUF.
286struct VPSymbolicValue : public VPValue {
287 VPSymbolicValue(Type *Ty) : VPValue(VPVSymbolicSC, nullptr), Ty(Ty) {}
288
289 static bool classof(const VPValue *V) {
290 return V->getVPValueID() == VPVSymbolicSC;
291 }
292
293 /// Returns the scalar type of this symbolic value.
294 Type *getType() const { return Ty; }
295
296 /// Returns true if this symbolic value has been materialized.
297 bool isMaterialized() const { return Materialized; }
298
299 /// Mark this symbolic value as materialized.
301 assert(!Materialized && "VPSymbolicValue already materialized");
302 Materialized = true;
303 }
304
305private:
306 /// The scalar type of this symbolic value.
307 Type *Ty;
308
309 /// Track whether this symbolic value has been materialized (replaced).
310 /// After materialization, accessing users should trigger an assertion.
311 bool Materialized = false;
312};
313
314/// Abstract base class for VPValues defined by a VPRecipeBase.
315class VPRecipeValue : public VPValue {
316 friend class VPValue;
317 friend class VPDef;
318
319 /// The scalar type of the value produced by this recipe.
320 Type *Ty = nullptr;
321
322#if !defined(NDEBUG)
323 /// Returns true if this VPRecipeValue is defined by \p D.
324 /// NOTE: Only used by VPDef to assert that VPRecipeValues added/removed from
325 /// /p D are associated with its VPRecipeBase.
326 bool isDefinedBy(const VPDef *D) const;
327#endif
328
329protected:
330 VPRecipeValue(unsigned char SC, Value *UV, Type *Ty = nullptr)
331 : VPValue(SC, UV), Ty(Ty) {}
332
333public:
334 LLVM_ABI_FOR_TEST virtual ~VPRecipeValue() = 0;
335
336 /// Returns the scalar type of this VPRecipeValue.
337 Type *getScalarType() const { return Ty; }
338
339 static bool classof(const VPValue *V) {
340 return V->getVPValueID() == VPVMultiDefValueSC ||
341 V->getVPValueID() == VPVSingleDefValueSC;
342 }
343};
344
345/// A VPRecipeValue defined by a VPSingleDefRecipe.
347 friend class VPDef;
348 friend class VPSingleDefRecipe;
349
350protected:
351 /// Construct a VPSingleDefValue. Must only be used by VPSingleDefRecipe.
353 Value *UV = nullptr, Type *Ty = nullptr);
354
355public:
356 ~VPSingleDefValue() override;
357
358 static bool classof(const VPValue *V) {
359 return V->getVPValueID() == VPVSingleDefValueSC;
360 }
361};
362
363/// A VPRecipeValue defined by a multi-def recipe, stores a pointer to it.
365 friend class VPDef;
366
367 /// Pointer to the multi-def recipe that defines this VPValue, among others.
368 VPRecipeBase *Def;
369
370public:
372
373 ~VPMultiDefValue() override;
374
375 VPRecipeBase *getDef() const { return Def; }
376
377 static bool classof(const VPValue *V) {
378 return V->getVPValueID() == VPVMultiDefValueSC;
379 }
380};
381
382/// This class augments VPValue with operands which provide the inverse def-use
383/// edges from VPValue's users to their defs.
384class VPUser {
385 /// Grant access to removeOperand for VPPhiAccessors, the only supported user.
386 friend class VPPhiAccessors;
387
389
390 /// Removes the operand at index \p Idx. This also removes the VPUser from the
391 /// use-list of the operand.
392 void removeOperand(unsigned Idx) {
393 getOperand(Idx)->removeUser(*this);
394 Operands.erase(Operands.begin() + Idx);
395 }
396
397protected:
398#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
399 /// Print the operands to \p O.
401#endif
402
404 for (VPValue *Operand : Operands)
405 addOperand(Operand);
406 }
407
408public:
409 VPUser() = delete;
410 VPUser(const VPUser &) = delete;
411 VPUser &operator=(const VPUser &) = delete;
412 virtual ~VPUser() {
413 for (VPValue *Op : operands())
414 Op->removeUser(*this);
415 }
416
417 void addOperand(VPValue *Operand) {
418 Operands.push_back(Operand);
419 Operand->addUser(*this);
420 }
421
422 unsigned getNumOperands() const { return Operands.size(); }
423 inline VPValue *getOperand(unsigned N) const {
424 assert(N < Operands.size() && "Operand index out of bounds");
425 return Operands[N];
426 }
427
428 void setOperand(unsigned I, VPValue *New) {
429 assert((!Operands[I]->getScalarType() || !New->getScalarType() ||
430 Operands[I]->getScalarType() == New->getScalarType()) &&
431 "scalar type of new operand must match the old operand");
432 Operands[I]->removeUser(*this);
433 Operands[I] = New;
434 New->addUser(*this);
435 }
436
437 /// Swap operands of the VPUser. It must have exactly 2 operands.
439 assert(Operands.size() == 2 && "must have 2 operands to swap");
440 std::swap(Operands[0], Operands[1]);
441 }
442
443 /// Replaces all uses of \p From in the VPUser with \p To.
444 void replaceUsesOfWith(VPValue *From, VPValue *To);
445
450
451 operand_iterator op_begin() { return Operands.begin(); }
452 const_operand_iterator op_begin() const { return Operands.begin(); }
453 operand_iterator op_end() { return Operands.end(); }
454 const_operand_iterator op_end() const { return Operands.end(); }
459
460 /// Returns true if the VPUser uses scalars of operand \p Op. Conservatively
461 /// returns if only first (scalar) lane is used, as default.
462 virtual bool usesScalars(const VPValue *Op) const {
464 "Op must be an operand of the recipe");
465 return usesFirstLaneOnly(Op);
466 }
467
468 /// Returns true if the VPUser only uses the first lane of operand \p Op.
469 /// Conservatively returns false.
470 virtual bool usesFirstLaneOnly(const VPValue *Op) const {
472 "Op must be an operand of the recipe");
473 return false;
474 }
475
476 /// Returns true if the VPUser only uses the first part of operand \p Op.
477 /// Conservatively returns false.
478 virtual bool usesFirstPartOnly(const VPValue *Op) const {
480 "Op must be an operand of the recipe");
481 return false;
482 }
483};
484
485/// This class augments a recipe with a set of VPValues defined by the recipe.
486/// It allows recipes to define zero, one or multiple VPValues. A VPDef owns
487/// the VPValues it defines and is responsible for deleting its defined values.
488/// Single-value VPDefs that also inherit from VPValue must make sure to inherit
489/// from VPDef before VPValue.
490class VPDef {
491 friend class VPRecipeValue;
492 friend class VPSingleDefValue;
493 friend class VPMultiDefValue;
494
495 /// The VPValues defined by this VPDef.
496 TinyPtrVector<VPRecipeValue *> DefinedValues;
497
498 /// Add \p V as a defined value by this VPDef.
499 void addDefinedValue(VPRecipeValue *V) {
500 assert(V->isDefinedBy(this) &&
501 "can only add VPValue already linked with this VPDef");
502 DefinedValues.push_back(V);
503 }
504
505 /// Remove \p V from the values defined by this VPDef. \p V must be a defined
506 /// value of this VPDef.
507 void removeDefinedValue(VPRecipeValue *V) {
508 assert(V->isDefinedBy(this) &&
509 "can only remove VPValue linked with this VPDef");
510 assert(is_contained(DefinedValues, V) &&
511 "VPValue to remove must be in DefinedValues");
512 llvm::erase(DefinedValues, V);
513 if (auto *SV = dyn_cast<VPMultiDefValue>(V))
514 SV->Def = nullptr;
515 }
516
517public:
518 VPDef() {}
519
520 virtual ~VPDef() {
521 for (VPRecipeValue *D : to_vector(DefinedValues)) {
522 assert(D->isDefinedBy(this) &&
523 "all defined VPValues should point to the containing VPDef");
524 assert(D->getNumUsers() == 0 &&
525 "all defined VPValues should have no more users");
526 delete D;
527 }
528 }
529
530 /// Returns the only VPValue defined by the VPDef. Can only be called for
531 /// VPDefs with a single defined value.
533 assert(DefinedValues.size() == 1 && "must have exactly one defined value");
534 assert(DefinedValues[0] && "defined value must be non-null");
535 return DefinedValues[0];
536 }
537 const VPValue *getVPSingleValue() const {
538 assert(DefinedValues.size() == 1 && "must have exactly one defined value");
539 assert(DefinedValues[0] && "defined value must be non-null");
540 return DefinedValues[0];
541 }
542
543 /// Returns the VPValue with index \p I defined by the VPDef.
544 VPValue *getVPValue(unsigned I) {
545 assert(DefinedValues[I] && "defined value must be non-null");
546 return DefinedValues[I];
547 }
548 const VPValue *getVPValue(unsigned I) const {
549 assert(DefinedValues[I] && "defined value must be non-null");
550 return DefinedValues[I];
551 }
552
553 /// Returns an ArrayRef of the values defined by the VPDef.
554 ArrayRef<VPRecipeValue *> definedValues() { return DefinedValues; }
555 /// Returns an ArrayRef of the values defined by the VPDef.
556 ArrayRef<VPRecipeValue *> definedValues() const { return DefinedValues; }
557
558 /// Returns the number of values defined by the VPDef.
559 unsigned getNumDefinedValues() const { return DefinedValues.size(); }
560};
561
564 !cast<VPSymbolicValue>(this)->isMaterialized()) &&
565 "accessing materialized symbolic value");
566}
567
568} // namespace llvm
569
570#endif // LLVM_TRANSFORMS_VECTORIZE_VPLAN_VALUE_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
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
Definition Compiler.h:218
This file contains the declarations for the subclasses of Constant, which represent the different fla...
#define I(x, y, z)
Definition MD5.cpp:57
This file contains some templates that are useful if you are working with the STL at all.
This file defines the SmallVector class.
static const BasicSubtargetSubTypeKV * find(StringRef S, ArrayRef< BasicSubtargetSubTypeKV > A)
Find KV in array using binary search.
Class for arbitrary precision integers.
Definition APInt.h:78
uint64_t getZExtValue() const
Get zero extended value.
Definition APInt.h:1563
bool isZero() const
Determine if this value is zero, i.e. all bits are clear.
Definition APInt.h:381
unsigned getBitWidth() const
Return the number of bits in the APInt.
Definition APInt.h:1511
bool isOne() const
Determine if this is a value of 1.
Definition APInt.h:390
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
This is the shared class of boolean and integer constants.
Definition Constants.h:87
A debug info location.
Definition DebugLoc.h:123
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...
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
This class augments a recipe with a set of VPValues defined by the recipe.
Definition VPlanValue.h:490
friend class VPSingleDefValue
Definition VPlanValue.h:492
friend class VPMultiDefValue
Definition VPlanValue.h:493
unsigned getNumDefinedValues() const
Returns the number of values defined by the VPDef.
Definition VPlanValue.h:559
virtual ~VPDef()
Definition VPlanValue.h:520
friend class VPRecipeValue
Definition VPlanValue.h:491
VPValue * getVPSingleValue()
Returns the only VPValue defined by the VPDef.
Definition VPlanValue.h:532
const VPValue * getVPSingleValue() const
Definition VPlanValue.h:537
VPValue * getVPValue(unsigned I)
Returns the VPValue with index I defined by the VPDef.
Definition VPlanValue.h:544
ArrayRef< VPRecipeValue * > definedValues() const
Returns an ArrayRef of the values defined by the VPDef.
Definition VPlanValue.h:556
ArrayRef< VPRecipeValue * > definedValues()
Returns an ArrayRef of the values defined by the VPDef.
Definition VPlanValue.h:554
const VPValue * getVPValue(unsigned I) const
Definition VPlanValue.h:548
VPRecipeBase * getDef() const
Definition VPlanValue.h:375
LLVM_ABI_FOR_TEST VPMultiDefValue(VPRecipeBase *Def, Value *UV, Type *Ty)
Definition VPlan.cpp:179
~VPMultiDefValue() override
Definition VPlan.cpp:185
static bool classof(const VPValue *V)
Definition VPlanValue.h:377
Helper type to provide functions to access incoming values and blocks for phi-like recipes.
Definition VPlan.h:1590
VPRecipeBase is a base class modeling a sequence of one or more output IR instructions.
Definition VPlan.h:401
Abstract base class for VPValues defined by a VPRecipeBase.
Definition VPlanValue.h:315
Type * getScalarType() const
Returns the scalar type of this VPRecipeValue.
Definition VPlanValue.h:337
virtual LLVM_ABI_FOR_TEST ~VPRecipeValue()=0
Definition VPlan.cpp:164
friend class VPDef
Definition VPlanValue.h:317
friend class VPValue
Definition VPlanValue.h:316
static bool classof(const VPValue *V)
Definition VPlanValue.h:339
VPRecipeValue(unsigned char SC, Value *UV, Type *Ty=nullptr)
Definition VPlanValue.h:330
VPRegionBlock represents a collection of VPBasicBlocks and VPRegionBlocks which form a Single-Entry-S...
Definition VPlan.h:4473
VPValues defined by a VPRegionBlock, like the canonical IV.
Definition VPlanValue.h:215
Type * getType() const
Returns the type of the VPRegionValue.
Definition VPlanValue.h:231
static bool classof(const VPValue *V)
Definition VPlanValue.h:236
~VPRegionValue() override=default
VPRegionValue(Type *Ty, DebugLoc DL, VPRegionBlock *Region)
Definition VPlanValue.h:221
DebugLoc getDebugLoc() const
Returns the debug location of the VPRegionValue.
Definition VPlanValue.h:234
VPRegionBlock * getDefiningRegion() const
Returns the region that defines this value.
Definition VPlanValue.h:228
VPSingleDefRecipe is a base class for recipes that model a sequence of one or more output IR that def...
Definition VPlan.h:610
LLVM_ABI_FOR_TEST VPSingleDefValue(VPSingleDefRecipe *Def, Value *UV=nullptr, Type *Ty=nullptr)
Construct a VPSingleDefValue. Must only be used by VPSingleDefRecipe.
Definition VPlan.cpp:169
~VPSingleDefValue() override
Definition VPlan.cpp:175
friend class VPSingleDefRecipe
Definition VPlanValue.h:348
static bool classof(const VPValue *V)
Definition VPlanValue.h:358
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:384
void replaceUsesOfWith(VPValue *From, VPValue *To)
Replaces all uses of From in the VPUser with To.
Definition VPlan.cpp:1545
void printOperands(raw_ostream &O, VPSlotTracker &SlotTracker) const
Print the operands to O.
Definition VPlan.cpp:1557
operand_range operands()
Definition VPlanValue.h:455
void setOperand(unsigned I, VPValue *New)
Definition VPlanValue.h:428
VPUser & operator=(const VPUser &)=delete
friend class VPPhiAccessors
Grant access to removeOperand for VPPhiAccessors, the only supported user.
Definition VPlanValue.h:386
unsigned getNumOperands() const
Definition VPlanValue.h:422
SmallVectorImpl< VPValue * >::const_iterator const_operand_iterator
Definition VPlanValue.h:447
const_operand_iterator op_begin() const
Definition VPlanValue.h:452
operand_iterator op_end()
Definition VPlanValue.h:453
const_operand_range operands() const
Definition VPlanValue.h:456
operand_iterator op_begin()
Definition VPlanValue.h:451
VPValue * getOperand(unsigned N) const
Definition VPlanValue.h:423
VPUser(ArrayRef< VPValue * > Operands)
Definition VPlanValue.h:403
VPUser(const VPUser &)=delete
VPUser()=delete
iterator_range< const_operand_iterator > const_operand_range
Definition VPlanValue.h:449
virtual bool usesFirstPartOnly(const VPValue *Op) const
Returns true if the VPUser only uses the first part of operand Op.
Definition VPlanValue.h:478
void swapOperands()
Swap operands of the VPUser. It must have exactly 2 operands.
Definition VPlanValue.h:438
SmallVectorImpl< VPValue * >::iterator operand_iterator
Definition VPlanValue.h:446
virtual ~VPUser()
Definition VPlanValue.h:412
virtual bool usesFirstLaneOnly(const VPValue *Op) const
Returns true if the VPUser only uses the first lane of operand Op.
Definition VPlanValue.h:470
const_operand_iterator op_end() const
Definition VPlanValue.h:454
virtual bool usesScalars(const VPValue *Op) const
Returns true if the VPUser uses scalars of operand Op.
Definition VPlanValue.h:462
iterator_range< operand_iterator > operand_range
Definition VPlanValue.h:448
void addOperand(VPValue *Operand)
Definition VPlanValue.h:417
This is the base class of the VPlan Def/Use graph, used for modeling the data flow into,...
Definition VPlanValue.h:50
bool hasDefiningRecipe() const
Returns true if this VPValue is defined by a recipe.
Definition VPlanValue.h:202
virtual ~VPValue()
Definition VPlanValue.h:94
unsigned getVPValueID() const
Definition VPlanValue.h:101
VPRecipeBase * getDefiningRecipe()
Returns the recipe defining this VPValue or nullptr if it is not defined by a recipe,...
Definition VPlan.cpp:130
void removeUser(VPUser &User)
Remove a single User from the list of users.
Definition VPlanValue.h:127
SmallVectorImpl< VPUser * >::const_iterator const_user_iterator
Definition VPlanValue.h:137
friend class VPRecipeValue
Definition VPlanValue.h:53
const_user_iterator user_begin() const
Definition VPlanValue.h:145
void assertNotMaterialized() const
Assert that this VPValue has not been materialized, if it is a VPSymbolicValue.
Definition VPlanValue.h:562
friend struct VPIRValue
Definition VPlanValue.h:51
void addUser(VPUser &User)
Definition VPlanValue.h:121
bool hasMoreThanOneUniqueUser() const
Returns true if the value has more than one unique user.
Definition VPlanValue.h:163
Value * getUnderlyingValue() const
Return the underlying Value attached to this VPValue.
Definition VPlanValue.h:75
const_user_range users() const
Definition VPlanValue.h:158
VPValue(const VPValue &)=delete
VPValue & operator=(const VPValue &)=delete
@ VPVSingleDefValueSC
A symbolic live-in VPValue without IR backing.
Definition VPlanValue.h:85
@ VPVSymbolicSC
A live-in VPValue wrapping an IR Value.
Definition VPlanValue.h:84
@ VPRegionValueSC
A VPValue defined by a multi-def recipe.
Definition VPlanValue.h:87
@ VPVMultiDefValueSC
A VPValue defined by a VPSingleDefRecipe.
Definition VPlanValue.h:86
bool hasOneUse() const
Definition VPlanValue.h:174
const VPUser * getSingleUser() const
Definition VPlanValue.h:179
void setUnderlyingValue(Value *Val)
Definition VPlanValue.h:208
SmallVectorImpl< VPUser * >::iterator user_iterator
Definition VPlanValue.h:136
iterator_range< user_iterator > user_range
Definition VPlanValue.h:138
const_user_iterator user_end() const
Definition VPlanValue.h:153
VPUser * getSingleUser()
Return the single user of this value, or nullptr if there is not exactly one user.
Definition VPlanValue.h:178
user_iterator user_begin()
Definition VPlanValue.h:141
unsigned getNumUsers() const
Definition VPlanValue.h:115
friend struct VPSymbolicValue
Definition VPlanValue.h:52
friend class VPRegionValue
Definition VPlanValue.h:54
user_iterator user_end()
Definition VPlanValue.h:149
user_range users()
Definition VPlanValue.h:157
iterator_range< const_user_iterator > const_user_range
Definition VPlanValue.h:139
LLVM Value Representation.
Definition Value.h:75
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.
Definition raw_ostream.h:53
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)
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
void erase(Container &C, ValueType V)
Wrapper function to remove a value from a container:
Definition STLExtras.h:2199
SmallVector< ValueTypeFromRangeType< R >, Size > to_vector(R &&Range)
Given a range of type R, iterate the entire range and return a SmallVector with elements of the vecto...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
DWARFExpression::Operation Op
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Definition STLExtras.h:1946
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition BitVector.h:876
#define N
VPConstantInt(ConstantInt *CI)
Definition VPlanValue.h:265
static bool classof(const VPValue *V)
Definition VPlanValue.h:267
bool isZero() const
Definition VPlanValue.h:273
const APInt & getAPInt() const
Definition VPlanValue.h:275
uint64_t getZExtValue() const
Definition VPlanValue.h:281
unsigned getBitWidth() const
Definition VPlanValue.h:279
bool isOne() const
Definition VPlanValue.h:271
VPIRValue(Value *UV)
Definition VPlanValue.h:247
Value * getValue() const
Returns the underlying IR value.
Definition VPlanValue.h:252
static bool classof(const VPValue *V)
Definition VPlanValue.h:257
Type * getType() const
Returns the type of the underlying IR value.
Definition VPlan.cpp:147
VPSymbolicValue(Type *Ty)
Definition VPlanValue.h:287
void markMaterialized()
Mark this symbolic value as materialized.
Definition VPlanValue.h:300
Type * getType() const
Returns the scalar type of this symbolic value.
Definition VPlanValue.h:294
static bool classof(const VPValue *V)
Definition VPlanValue.h:289
bool isMaterialized() const
Returns true if this symbolic value has been materialized.
Definition VPlanValue.h:297