Skip to content

Commit 65cd9e4

Browse files
committed
[VPlan] Make VPValue constructors protected. (NFC)
Tighten access to constructors similar to ef1260a. VPValues should either be constructed by constructors of recipes defining them or should be live-ins created by VPlan (via getOrAddLiveIn).
1 parent 18eec97 commit 65cd9e4

File tree

2 files changed

+160
-141
lines changed

2 files changed

+160
-141
lines changed

llvm/lib/Transforms/Vectorize/VPlanValue.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ namespace llvm {
3333
class raw_ostream;
3434
class Value;
3535
class VPDef;
36+
struct VPDoubleValueDef;
3637
class VPSlotTracker;
3738
class VPUser;
3839
class VPRecipeBase;
40+
class VPInterleaveRecipe;
3941

4042
// This is the base class of the VPlan Def/Use graph, used for modeling the data
4143
// flow into, within and out of the VPlan. VPValues can stand for live-ins
@@ -44,12 +46,15 @@ class VPRecipeBase;
4446
class VPValue {
4547
friend class VPBuilder;
4648
friend class VPDef;
49+
friend struct VPDoubleValueDef;
4750
friend class VPInstruction;
51+
friend class VPInterleaveRecipe;
4852
friend struct VPlanTransforms;
4953
friend class VPBasicBlock;
5054
friend class VPInterleavedAccessInfo;
5155
friend class VPSlotTracker;
5256
friend class VPRecipeBase;
57+
friend class VPlan;
5358

5459
const unsigned char SubclassID; ///< Subclass identifier (for isa/dyn_cast).
5560

@@ -65,6 +70,13 @@ class VPValue {
6570

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

73+
/// Create a live-in VPValue.
74+
VPValue(Value *UV = nullptr) : VPValue(VPValueSC, UV, nullptr) {}
75+
/// Create a VPValue for a \p Def which is a subclass of VPValue.
76+
VPValue(VPDef *Def, Value *UV = nullptr) : VPValue(VPVRecipeSC, UV, Def) {}
77+
/// Create a VPValue for a \p Def which defines multiple values.
78+
VPValue(Value *UV, VPDef *Def) : VPValue(VPValueSC, UV, Def) {}
79+
6880
// DESIGN PRINCIPLE: Access to the underlying IR must be strictly limited to
6981
// the front-end and back-end of VPlan so that the middle-end is as
7082
// independent as possible of the underlying IR. We grant access to the
@@ -84,12 +96,6 @@ class VPValue {
8496
VPVRecipeSC /// A VPValue sub-class that is a VPRecipeBase.
8597
};
8698

87-
/// Create a live-in VPValue.
88-
VPValue(Value *UV = nullptr) : VPValue(VPValueSC, UV, nullptr) {}
89-
/// Create a VPValue for a \p Def which is a subclass of VPValue.
90-
VPValue(VPDef *Def, Value *UV = nullptr) : VPValue(VPVRecipeSC, UV, Def) {}
91-
/// Create a VPValue for a \p Def which defines multiple values.
92-
VPValue(Value *UV, VPDef *Def) : VPValue(VPValueSC, UV, Def) {}
9399
VPValue(const VPValue &) = delete;
94100
VPValue &operator=(const VPValue &) = delete;
95101

0 commit comments

Comments
 (0)