LLVM 24.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 class 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(user_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 (user_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 bool user_empty() const { return Users.empty(); } // NOLINT
162
163 /// Returns true if the value has more than one unique user.
165 if (user_empty())
166 return false;
167
168 // Check if all users match the first user.
169 auto Current = std::next(user_begin());
170 while (Current != user_end() && *user_begin() == *Current)
171 Current++;
172 return Current != user_end();
173 }
174
175 bool hasOneUse() const { return getNumUsers() == 1; }
176
177 /// Return the single user of this value, or nullptr if there is not exactly
178 /// one user.
179 VPUser *getSingleUser() { return hasOneUse() ? *user_begin() : nullptr; }
180 const VPUser *getSingleUser() const {
181 return hasOneUse() ? *user_begin() : nullptr;
182 }
183
184 void replaceAllUsesWith(VPValue *New);
185
186 /// Go through the uses list for this VPValue and make each use point to \p
187 /// New if the callback ShouldReplace returns true for the given use specified
188 /// by a pair of (VPUser, the use index).
189 void replaceUsesWithIf(
190 VPValue *New,
191 llvm::function_ref<bool(VPUser &U, unsigned Idx)> ShouldReplace);
192
193 /// Returns the recipe defining this VPValue or nullptr if it is not defined
194 /// by a recipe, i.e. is a live-in.
195 VPRecipeBase *getDefiningRecipe();
196 const VPRecipeBase *getDefiningRecipe() const;
197
198 /// Returns the scalar type of this VPValue, dispatching based on the
199 /// concrete subclass.
200 Type *getScalarType() const;
201
202 /// Returns true if the VPValue is defined outside any loop.
203 bool isDefinedOutsideLoopRegions() const;
204
205 // Set \p Val as the underlying Value of this VPValue.
207 assert(!UnderlyingVal && "Underlying Value is already set.");
208 UnderlyingVal = Val;
209 }
210};
211
212/// A symbolic live-in VPValue, used for values like vector trip count, VF, and
213/// VFxUF.
214class VPSymbolicValue : public VPValue {
215 /// The scalar type of this symbolic value.
216 Type *Ty;
217
218 /// Track whether this value has been materialized (replaced). After
219 /// materialization, accessing users should trigger an assertion.
220 bool Materialized = false;
221
222protected:
223 VPSymbolicValue(unsigned char SC, Type *Ty) : VPValue(SC, nullptr), Ty(Ty) {}
224
225public:
227
228 /// Returns the scalar type of this symbolic value.
229 Type *getType() const { return Ty; }
230
231 /// Returns true if this value has been materialized.
232 bool isMaterialized() const { return Materialized; }
233
234 /// Mark this value as materialized.
236 assert(!Materialized && "VPSymbolicValue already materialized");
237 Materialized = true;
238 }
239
240 static bool classof(const VPValue *V) {
241 return V->getVPValueID() == VPVSymbolicSC ||
242 V->getVPValueID() == VPRegionValueSC;
243 }
244};
245
246/// VPValues are defined by a VPRegionBlock, like the canonical IV. They must
247/// be materialized when the containing region is dissolved, before VPlan
248/// execution.
250 VPRegionBlock *DefiningRegion;
251 DebugLoc DL;
252
253public:
255 : VPSymbolicValue(VPValue::VPRegionValueSC, Ty), DefiningRegion(Region),
256 DL(DL) {}
257
258 ~VPRegionValue() override = default;
259
260 /// Returns the region that defines this value.
261 VPRegionBlock *getDefiningRegion() const { return DefiningRegion; }
262
263 /// Returns the debug location of the VPRegionValue.
264 DebugLoc getDebugLoc() const { return DL; }
265
266 static inline bool classof(const VPValue *V) {
267 return V->getVPValueID() == VPValue::VPRegionValueSC;
268 }
269};
270
271LLVM_ABI_FOR_TEST raw_ostream &operator<<(raw_ostream &OS,
272 const VPRecipeBase &R);
273
274/// A VPValue representing a live-in from the input IR or a constant. It wraps
275/// an underlying IR Value.
276struct VPIRValue : public VPValue {
277 VPIRValue(Value *UV) : VPValue(VPVIRValueSC, UV) {
278 assert(UV && "VPIRValue requires an underlying IR value");
279 }
280
281 /// Returns the underlying IR value.
282 Value *getValue() const { return getUnderlyingValue(); }
283
284 /// Returns the type of the underlying IR value.
285 Type *getType() const;
286
287 static bool classof(const VPValue *V) {
288 return V->getVPValueID() == VPVIRValueSC;
289 }
290};
291
292/// An overlay on VPIRValue for VPValues that wrap a Constant. May be an
293/// integer, floating-point, or a vector constant.
294struct VPConstant : public VPIRValue {
296
297 static bool classof(const VPValue *V) {
298 auto *IRV = dyn_cast<VPIRValue>(V);
299 return IRV && isa<Constant>(IRV->getValue());
300 }
301
302 const Constant *getConstant() const { return cast<Constant>(getValue()); }
303};
304
305/// An overlay on VPConstant for VPValues that wrap a ConstantInt. Provides
306/// convenient accessors for the underlying APInt.
307struct VPConstantInt : public VPConstant {
309
310 static bool classof(const VPValue *V) {
311 auto *VPC = dyn_cast<VPConstant>(V);
312 return VPC && isa<ConstantInt>(VPC->getConstant());
313 }
314
315 bool isOne() const { return getAPInt().isOne(); }
316
317 bool isZero() const { return getAPInt().isZero(); }
318
319 const APInt &getAPInt() const {
320 return cast<ConstantInt>(getValue())->getValue();
321 }
322
323 unsigned getBitWidth() const { return getAPInt().getBitWidth(); }
324
326};
327
328/// Abstract base class for VPValues defined by a VPRecipeBase.
329class VPRecipeValue : public VPValue {
330 friend class VPValue;
331 friend class VPDef;
332
333 /// The scalar type of the value produced by this recipe.
334 Type *Ty = nullptr;
335
336#if !defined(NDEBUG)
337 /// Returns true if this VPRecipeValue is defined by \p D.
338 /// NOTE: Only used by VPDef to assert that VPRecipeValues added/removed from
339 /// /p D are associated with its VPRecipeBase.
340 bool isDefinedBy(const VPDef *D) const;
341#endif
342
343protected:
344 VPRecipeValue(unsigned char SC, Value *UV, Type *Ty = nullptr)
345 : VPValue(SC, UV), Ty(Ty) {}
346
347public:
348 LLVM_ABI_FOR_TEST virtual ~VPRecipeValue() = 0;
349
350 /// Returns the scalar type of this VPRecipeValue.
351 Type *getScalarType() const { return Ty; }
352
353 static bool classof(const VPValue *V) {
354 return V->getVPValueID() == VPVMultiDefValueSC ||
355 V->getVPValueID() == VPVSingleDefValueSC;
356 }
357};
358
359/// A VPRecipeValue defined by a VPSingleDefRecipe.
361 friend class VPDef;
362 friend class VPSingleDefRecipe;
363
364protected:
365 /// Construct a VPSingleDefValue. Must only be used by VPSingleDefRecipe.
367 Value *UV = nullptr, Type *Ty = nullptr);
368
369public:
370 ~VPSingleDefValue() override;
371
372 static bool classof(const VPValue *V) {
373 return V->getVPValueID() == VPVSingleDefValueSC;
374 }
375};
376
377/// A VPRecipeValue defined by a multi-def recipe, stores a pointer to it.
379 friend class VPDef;
380
381 /// Pointer to the multi-def recipe that defines this VPValue, among others.
382 VPRecipeBase *Def;
383
384public:
386
387 ~VPMultiDefValue() override;
388
389 VPRecipeBase *getDef() const { return Def; }
390
391 static bool classof(const VPValue *V) {
392 return V->getVPValueID() == VPVMultiDefValueSC;
393 }
394};
395
396/// This class augments VPValue with operands which provide the inverse def-use
397/// edges from VPValue's users to their defs.
399 /// Grant access to removeOperand for VPPhiAccessors, the only supported user.
400 friend class VPPhiAccessors;
401 /// Grant access to addOperand for VPWidenMemoryRecipe.
403
405
406 /// Removes the operand at index \p Idx. This also removes the VPUser from the
407 /// use-list of the operand.
408 void removeOperand(unsigned Idx) {
409 getOperand(Idx)->removeUser(*this);
410 Operands.erase(Operands.begin() + Idx);
411 }
412
413protected:
414#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
415 /// Print the operands to \p O.
416 void printOperands(raw_ostream &O, VPSlotTracker &SlotTracker) const;
417#endif
418
420 for (VPValue *Operand : Operands)
421 addOperand(Operand);
422 }
423
424 void addOperand(VPValue *Operand) {
425 Operands.push_back(Operand);
426 Operand->addUser(*this);
427 }
428
429public:
430 VPUser() = delete;
431 VPUser(const VPUser &) = delete;
432 VPUser &operator=(const VPUser &) = delete;
433 virtual ~VPUser() {
434 for (VPValue *Op : operands())
435 Op->removeUser(*this);
436 }
437
438 unsigned getNumOperands() const { return Operands.size(); }
439 inline VPValue *getOperand(unsigned N) const {
440 assert(N < Operands.size() && "Operand index out of bounds");
441 return Operands[N];
442 }
443
444 void setOperand(unsigned I, VPValue *New) {
445 assert((!Operands[I]->getScalarType() || !New->getScalarType() ||
446 Operands[I]->getScalarType() == New->getScalarType()) &&
447 "scalar type of new operand must match the old operand");
448 Operands[I]->removeUser(*this);
449 Operands[I] = New;
450 New->addUser(*this);
451 }
452
453 /// Swap operands of the VPUser. It must have exactly 2 operands.
455 assert(Operands.size() == 2 && "must have 2 operands to swap");
456 std::swap(Operands[0], Operands[1]);
457 }
458
459 /// Replaces all uses of \p From in the VPUser with \p To.
460 void replaceUsesOfWith(VPValue *From, VPValue *To);
461
466
467 operand_iterator op_begin() { return Operands.begin(); }
468 const_operand_iterator op_begin() const { return Operands.begin(); }
469 operand_iterator op_end() { return Operands.end(); }
470 const_operand_iterator op_end() const { return Operands.end(); }
475 bool operands_empty() const { return Operands.empty(); } // NOLINT
476
477 /// Returns true if the VPUser uses scalars of operand \p Op. Conservatively
478 /// returns if only first (scalar) lane is used, as default.
479 virtual bool usesScalars(const VPValue *Op) const {
481 "Op must be an operand of the recipe");
482 return usesFirstLaneOnly(Op);
483 }
484
485 /// Returns true if the VPUser only uses the first lane of operand \p Op.
486 /// Conservatively returns false.
487 virtual bool usesFirstLaneOnly(const VPValue *Op) const {
489 "Op must be an operand of the recipe");
490 return false;
491 }
492
493 /// Returns true if the VPUser only uses the first part of operand \p Op.
494 /// Conservatively returns false.
495 virtual bool usesFirstPartOnly(const VPValue *Op) const {
497 "Op must be an operand of the recipe");
498 return false;
499 }
500};
501
502/// This class augments a recipe with a set of VPValues defined by the recipe.
503/// It allows recipes to define zero, one or multiple VPValues. A VPDef owns
504/// the VPValues it defines and is responsible for deleting its defined values.
505/// Single-value VPDefs that also inherit from VPValue must make sure to inherit
506/// from VPDef before VPValue.
507class VPDef {
508 friend class VPRecipeValue;
509 friend class VPSingleDefValue;
510 friend class VPMultiDefValue;
511
512 /// The VPValues defined by this VPDef.
513 TinyPtrVector<VPRecipeValue *> DefinedValues;
514
515 /// Add \p V as a defined value by this VPDef.
516 void addDefinedValue(VPRecipeValue *V) {
517 assert(V->isDefinedBy(this) &&
518 "can only add VPValue already linked with this VPDef");
519 DefinedValues.push_back(V);
520 }
521
522 /// Remove \p V from the values defined by this VPDef. \p V must be a defined
523 /// value of this VPDef.
524 void removeDefinedValue(VPRecipeValue *V) {
525 assert(V->isDefinedBy(this) &&
526 "can only remove VPValue linked with this VPDef");
527 assert(is_contained(DefinedValues, V) &&
528 "VPValue to remove must be in DefinedValues");
529 llvm::erase(DefinedValues, V);
530 if (auto *SV = dyn_cast<VPMultiDefValue>(V))
531 SV->Def = nullptr;
532 }
533
534public:
535 VPDef() {}
536
537 virtual ~VPDef() {
538 for (VPRecipeValue *D : to_vector(DefinedValues)) {
539 assert(D->isDefinedBy(this) &&
540 "all defined VPValues should point to the containing VPDef");
541 assert(D->user_empty() &&
542 "all defined VPValues should have no more users");
543 delete D;
544 }
545 }
546
547 /// Returns the only VPValue defined by the VPDef. Can only be called for
548 /// VPDefs with a single defined value.
550 assert(DefinedValues.size() == 1 && "must have exactly one defined value");
551 assert(DefinedValues[0] && "defined value must be non-null");
552 return DefinedValues[0];
553 }
554 const VPValue *getVPSingleValue() const {
555 assert(DefinedValues.size() == 1 && "must have exactly one defined value");
556 assert(DefinedValues[0] && "defined value must be non-null");
557 return DefinedValues[0];
558 }
559
560 /// Returns the VPValue with index \p I defined by the VPDef.
561 VPValue *getVPValue(unsigned I) {
562 assert(DefinedValues[I] && "defined value must be non-null");
563 return DefinedValues[I];
564 }
565 const VPValue *getVPValue(unsigned I) const {
566 assert(DefinedValues[I] && "defined value must be non-null");
567 return DefinedValues[I];
568 }
569
570 /// Returns an ArrayRef of the values defined by the VPDef.
571 ArrayRef<VPRecipeValue *> definedValues() { return DefinedValues; }
572 /// Returns an ArrayRef of the values defined by the VPDef.
573 ArrayRef<VPRecipeValue *> definedValues() const { return DefinedValues; }
574
575 /// Returns the number of values defined by the VPDef.
576 unsigned getNumDefinedValues() const { return DefinedValues.size(); }
577};
578
581 !cast<VPSymbolicValue>(this)->isMaterialized()) &&
582 "accessing materialized symbolic value");
583}
584
585} // namespace llvm
586
587#endif // LLVM_TRANSFORMS_VECTORIZE_VPLAN_VALUE_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
unsigned uint64_t
static MCDisassembler::DecodeStatus addOperand(MCInst &Inst, const MCOperand &Opnd)
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
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:220
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:1560
bool isZero() const
Determine if this value is zero, i.e. all bits are clear.
Definition APInt.h:376
unsigned getBitWidth() const
Return the number of bits in the APInt.
Definition APInt.h:1508
bool isOne() const
Determine if this is a value of 1.
Definition APInt.h:385
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
This is an important base class in LLVM.
Definition Constant.h:43
A debug info location.
Definition DebugLoc.h:126
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:507
friend class VPSingleDefValue
Definition VPlanValue.h:509
friend class VPMultiDefValue
Definition VPlanValue.h:510
unsigned getNumDefinedValues() const
Returns the number of values defined by the VPDef.
Definition VPlanValue.h:576
virtual ~VPDef()
Definition VPlanValue.h:537
friend class VPRecipeValue
Definition VPlanValue.h:508
VPValue * getVPSingleValue()
Returns the only VPValue defined by the VPDef.
Definition VPlanValue.h:549
const VPValue * getVPSingleValue() const
Definition VPlanValue.h:554
VPValue * getVPValue(unsigned I)
Returns the VPValue with index I defined by the VPDef.
Definition VPlanValue.h:561
ArrayRef< VPRecipeValue * > definedValues() const
Returns an ArrayRef of the values defined by the VPDef.
Definition VPlanValue.h:573
ArrayRef< VPRecipeValue * > definedValues()
Returns an ArrayRef of the values defined by the VPDef.
Definition VPlanValue.h:571
const VPValue * getVPValue(unsigned I) const
Definition VPlanValue.h:565
VPRecipeBase * getDef() const
Definition VPlanValue.h:389
LLVM_ABI_FOR_TEST VPMultiDefValue(VPRecipeBase *Def, Value *UV, Type *Ty)
Definition VPlan.cpp:177
~VPMultiDefValue() override
Definition VPlan.cpp:183
static bool classof(const VPValue *V)
Definition VPlanValue.h:391
Helper type to provide functions to access incoming values and blocks for phi-like recipes.
Definition VPlan.h:1599
VPRecipeBase is a base class modeling a sequence of one or more output IR instructions.
Definition VPlan.h:403
Abstract base class for VPValues defined by a VPRecipeBase.
Definition VPlanValue.h:329
Type * getScalarType() const
Returns the scalar type of this VPRecipeValue.
Definition VPlanValue.h:351
virtual LLVM_ABI_FOR_TEST ~VPRecipeValue()=0
Definition VPlan.cpp:162
friend class VPDef
Definition VPlanValue.h:331
friend class VPValue
Definition VPlanValue.h:330
static bool classof(const VPValue *V)
Definition VPlanValue.h:353
VPRecipeValue(unsigned char SC, Value *UV, Type *Ty=nullptr)
Definition VPlanValue.h:344
VPRegionBlock represents a collection of VPBasicBlocks and VPRegionBlocks which form a Single-Entry-S...
Definition VPlan.h:4630
VPValues are defined by a VPRegionBlock, like the canonical IV.
Definition VPlanValue.h:249
static bool classof(const VPValue *V)
Definition VPlanValue.h:266
~VPRegionValue() override=default
VPRegionValue(Type *Ty, DebugLoc DL, VPRegionBlock *Region)
Definition VPlanValue.h:254
DebugLoc getDebugLoc() const
Returns the debug location of the VPRegionValue.
Definition VPlanValue.h:264
VPRegionBlock * getDefiningRegion() const
Returns the region that defines this value.
Definition VPlanValue.h:261
VPSingleDefRecipe is a base class for recipes that model a sequence of one or more output IR that def...
Definition VPlan.h:611
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:167
friend class VPSingleDefRecipe
Definition VPlanValue.h:362
static bool classof(const VPValue *V)
Definition VPlanValue.h:372
This class can be used to assign names to VPValues.
VPSymbolicValue(Type *Ty)
Definition VPlanValue.h:226
void markMaterialized()
Mark this value as materialized.
Definition VPlanValue.h:235
Type * getType() const
Returns the scalar type of this symbolic value.
Definition VPlanValue.h:229
static bool classof(const VPValue *V)
Definition VPlanValue.h:240
bool isMaterialized() const
Returns true if this value has been materialized.
Definition VPlanValue.h:232
VPSymbolicValue(unsigned char SC, Type *Ty)
Definition VPlanValue.h:223
This class augments VPValue with operands which provide the inverse def-use edges from VPValue's user...
Definition VPlanValue.h:398
operand_range operands()
Definition VPlanValue.h:471
void setOperand(unsigned I, VPValue *New)
Definition VPlanValue.h:444
VPUser & operator=(const VPUser &)=delete
friend class VPPhiAccessors
Grant access to removeOperand for VPPhiAccessors, the only supported user.
Definition VPlanValue.h:400
unsigned getNumOperands() const
Definition VPlanValue.h:438
SmallVectorImpl< VPValue * >::const_iterator const_operand_iterator
Definition VPlanValue.h:463
friend class VPWidenMemoryRecipe
Grant access to addOperand for VPWidenMemoryRecipe.
Definition VPlanValue.h:402
const_operand_iterator op_begin() const
Definition VPlanValue.h:468
operand_iterator op_end()
Definition VPlanValue.h:469
const_operand_range operands() const
Definition VPlanValue.h:472
operand_iterator op_begin()
Definition VPlanValue.h:467
VPValue * getOperand(unsigned N) const
Definition VPlanValue.h:439
VPUser(ArrayRef< VPValue * > Operands)
Definition VPlanValue.h:419
VPUser(const VPUser &)=delete
VPUser()=delete
bool operands_empty() const
Definition VPlanValue.h:475
iterator_range< const_operand_iterator > const_operand_range
Definition VPlanValue.h:465
virtual bool usesFirstPartOnly(const VPValue *Op) const
Returns true if the VPUser only uses the first part of operand Op.
Definition VPlanValue.h:495
void swapOperands()
Swap operands of the VPUser. It must have exactly 2 operands.
Definition VPlanValue.h:454
SmallVectorImpl< VPValue * >::iterator operand_iterator
Definition VPlanValue.h:462
virtual ~VPUser()
Definition VPlanValue.h:433
virtual bool usesFirstLaneOnly(const VPValue *Op) const
Returns true if the VPUser only uses the first lane of operand Op.
Definition VPlanValue.h:487
const_operand_iterator op_end() const
Definition VPlanValue.h:470
virtual bool usesScalars(const VPValue *Op) const
Returns true if the VPUser uses scalars of operand Op.
Definition VPlanValue.h:479
iterator_range< operand_iterator > operand_range
Definition VPlanValue.h:464
void addOperand(VPValue *Operand)
Definition VPlanValue.h:424
This is the base class of the VPlan Def/Use graph, used for modeling the data flow into,...
Definition VPlanValue.h:50
virtual ~VPValue()
Definition VPlanValue.h:94
unsigned getVPValueID() const
Definition VPlanValue.h:101
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 VPSymbolicValue
Definition VPlanValue.h:52
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:579
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:164
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
bool user_empty() const
Definition VPlanValue.h:161
@ 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:175
const VPUser * getSingleUser() const
Definition VPlanValue.h:180
void setUnderlyingValue(Value *Val)
Definition VPlanValue.h:206
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:179
user_iterator user_begin()
Definition VPlanValue.h:141
unsigned getNumUsers() const
Definition VPlanValue.h:115
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:2216
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:1963
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition BitVector.h:880
#define N
VPConstantInt(ConstantInt *CI)
Definition VPlanValue.h:308
static bool classof(const VPValue *V)
Definition VPlanValue.h:310
bool isZero() const
Definition VPlanValue.h:317
const APInt & getAPInt() const
Definition VPlanValue.h:319
uint64_t getZExtValue() const
Definition VPlanValue.h:325
unsigned getBitWidth() const
Definition VPlanValue.h:323
bool isOne() const
Definition VPlanValue.h:315
VPConstant(Constant *C)
Definition VPlanValue.h:295
const Constant * getConstant() const
Definition VPlanValue.h:302
static bool classof(const VPValue *V)
Definition VPlanValue.h:297
VPIRValue(Value *UV)
Definition VPlanValue.h:277
Value * getValue() const
Returns the underlying IR value.
Definition VPlanValue.h:282
static bool classof(const VPValue *V)
Definition VPlanValue.h:287
Type * getType() const
Returns the type of the underlying IR value.
Definition VPlan.cpp:145