@@ -25,94 +25,161 @@ class SDNode;
25
25
class Value ;
26
26
class raw_ostream ;
27
27
28
- // / Holds the information from a dbg_value node through SDISel.
29
- // / We do not use SDValue here to avoid including its header .
30
- class SDDbgValue {
28
+ // / Holds the information for a single machine location through SDISel; either
29
+ // / an SDNode, a constant, a stack location, or a virtual register .
30
+ class SDDbgOperand {
31
31
public:
32
- enum DbgValueKind {
33
- SDNODE = 0 , // /< Value is the result of an expression.
34
- CONST = 1 , // /< Value is a constant.
35
- FRAMEIX = 2 , // /< Value is contents of a stack location.
36
- VREG = 3 // /< Value is a virtual register.
32
+ enum Kind {
33
+ SDNODE = 0 , // /< Value is the result of an expression.
34
+ CONST = 1 , // /< Value is a constant.
35
+ FRAMEIX = 2 , // /< Value is contents of a stack location.
36
+ VREG = 3 // /< Value is a virtual register.
37
37
};
38
+ Kind getKind () const { return kind; }
39
+
40
+ // / Returns the SDNode* for a register ref
41
+ SDNode *getSDNode () const {
42
+ assert (kind == SDNODE);
43
+ return u.s .Node ;
44
+ }
45
+
46
+ // / Returns the ResNo for a register ref
47
+ unsigned getResNo () const {
48
+ assert (kind == SDNODE);
49
+ return u.s .ResNo ;
50
+ }
51
+
52
+ // / Returns the Value* for a constant
53
+ const Value *getConst () const {
54
+ assert (kind == CONST);
55
+ return u.Const ;
56
+ }
57
+
58
+ // / Returns the FrameIx for a stack object
59
+ unsigned getFrameIx () const {
60
+ assert (kind == FRAMEIX);
61
+ return u.FrameIx ;
62
+ }
63
+
64
+ // / Returns the Virtual Register for a VReg
65
+ unsigned getVReg () const {
66
+ assert (kind == VREG);
67
+ return u.VReg ;
68
+ }
69
+
70
+ static SDDbgOperand fromNode (SDNode *Node, unsigned ResNo) {
71
+ return SDDbgOperand (Node, ResNo);
72
+ }
73
+ static SDDbgOperand fromFrameIdx (unsigned FrameIdx) {
74
+ return SDDbgOperand (FrameIdx, FRAMEIX);
75
+ }
76
+ static SDDbgOperand fromVReg (unsigned VReg) {
77
+ return SDDbgOperand (VReg, VREG);
78
+ }
79
+ static SDDbgOperand fromConst (const Value *Const) {
80
+ return SDDbgOperand (Const);
81
+ }
82
+
83
+ bool operator !=(const SDDbgOperand &Other) const { return !(*this == Other); }
84
+ bool operator ==(const SDDbgOperand &Other) const {
85
+ if (kind != Other.kind )
86
+ return false ;
87
+ switch (kind) {
88
+ case SDNODE:
89
+ return getSDNode () == Other.getSDNode () && getResNo () == Other.getResNo ();
90
+ case CONST:
91
+ return getConst () == Other.getConst ();
92
+ case VREG:
93
+ return getVReg () == Other.getVReg ();
94
+ case FRAMEIX:
95
+ return getFrameIx () == Other.getFrameIx ();
96
+ default :
97
+ llvm_unreachable (" unknown kind" );
98
+ }
99
+ }
100
+
38
101
private:
102
+ Kind kind;
39
103
union {
40
104
struct {
41
- SDNode *Node; // /< Valid for expressions.
42
- unsigned ResNo; // /< Valid for expressions.
105
+ SDNode *Node; // /< Valid for expressions.
106
+ unsigned ResNo; // /< Valid for expressions.
43
107
} s;
44
- const Value *Const; // /< Valid for constants.
45
- unsigned FrameIx; // /< Valid for stack objects.
46
- unsigned VReg; // /< Valid for registers.
108
+ const Value *Const; // /< Valid for constants.
109
+ unsigned FrameIx; // /< Valid for stack objects.
110
+ unsigned VReg; // /< Valid for registers.
47
111
} u;
48
- DIVariable *Var;
49
- DIExpression *Expr;
50
- DebugLoc DL;
51
- unsigned Order;
52
- enum DbgValueKind kind;
53
- bool IsIndirect;
54
- bool Invalid = false ;
55
- bool Emitted = false ;
56
112
57
- public:
58
113
// / Constructor for non-constants.
59
- SDDbgValue (DIVariable *Var, DIExpression *Expr, SDNode *N, unsigned R,
60
- bool indir, DebugLoc dl, unsigned O)
61
- : Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(indir) {
62
- kind = SDNODE;
114
+ SDDbgOperand (SDNode *N, unsigned R) : kind(SDNODE) {
63
115
u.s .Node = N;
64
116
u.s .ResNo = R;
65
117
}
66
-
67
118
// / Constructor for constants.
68
- SDDbgValue (DIVariable *Var, DIExpression *Expr, const Value *C, DebugLoc dl,
69
- unsigned O)
70
- : Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(false ) {
71
- kind = CONST;
72
- u.Const = C;
73
- }
74
-
119
+ SDDbgOperand (const Value *C) : kind(CONST) { u.Const = C; }
75
120
// / Constructor for virtual registers and frame indices.
76
- SDDbgValue (DIVariable *Var, DIExpression *Expr, unsigned VRegOrFrameIdx,
77
- bool IsIndirect, DebugLoc DL, unsigned Order,
78
- enum DbgValueKind Kind)
79
- : Var(Var), Expr(Expr), DL(DL), Order(Order), IsIndirect(IsIndirect) {
121
+ SDDbgOperand (unsigned VRegOrFrameIdx, Kind Kind) : kind(Kind) {
80
122
assert ((Kind == VREG || Kind == FRAMEIX) &&
81
123
" Invalid SDDbgValue constructor" );
82
- kind = Kind;
83
124
if (kind == VREG)
84
125
u.VReg = VRegOrFrameIdx;
85
126
else
86
127
u.FrameIx = VRegOrFrameIdx;
87
128
}
129
+ };
130
+
131
+ // / Holds the information from a dbg_value node through SDISel.
132
+ // / We do not use SDValue here to avoid including its header.
133
+ class SDDbgValue {
134
+ public:
135
+ // FIXME: These SmallVector sizes were chosen without any kind of performance
136
+ // testing.
137
+ using LocOpVector = SmallVector<SDDbgOperand, 2 >;
138
+ using SDNodeVector = SmallVector<SDNode *, 2 >;
139
+
140
+ private:
141
+ LocOpVector LocationOps;
142
+ SDNodeVector SDNodes;
143
+ DIVariable *Var;
144
+ DIExpression *Expr;
145
+ DebugLoc DL;
146
+ unsigned Order;
147
+ bool IsIndirect;
148
+ bool IsVariadic;
149
+ bool Invalid = false ;
150
+ bool Emitted = false ;
88
151
89
- // / Returns the kind.
90
- DbgValueKind getKind () const { return kind; }
152
+ public:
153
+ SDDbgValue (DIVariable *Var, DIExpression *Expr, ArrayRef<SDDbgOperand> L,
154
+ ArrayRef<SDNode *> Dependencies, bool IsIndirect, DebugLoc DL,
155
+ unsigned O, bool IsVariadic)
156
+ : LocationOps(L.begin(), L.end()),
157
+ SDNodes (Dependencies.begin(), Dependencies.end()), Var(Var), Expr(Expr),
158
+ DL(DL), Order(O), IsIndirect(IsIndirect), IsVariadic(IsVariadic) {
159
+ assert (IsVariadic || L.size () == 1 );
160
+ assert (!(IsVariadic && IsIndirect));
161
+ }
91
162
92
163
// / Returns the DIVariable pointer for the variable.
93
164
DIVariable *getVariable () const { return Var; }
94
165
95
166
// / Returns the DIExpression pointer for the expression.
96
167
DIExpression *getExpression () const { return Expr; }
97
168
98
- // / Returns the SDNode* for a register ref
99
- SDNode *getSDNode () const { assert (kind==SDNODE); return u.s .Node ; }
169
+ ArrayRef<SDDbgOperand> getLocationOps () const { return LocationOps; }
100
170
101
- // / Returns the ResNo for a register ref
102
- unsigned getResNo () const { assert (kind==SDNODE); return u.s .ResNo ; }
171
+ LocOpVector copyLocationOps () const { return LocationOps; }
103
172
104
- // / Returns the Value* for a constant
105
- const Value * getConst () const { assert (kind==CONST); return u. Const ; }
173
+ // Returns the SDNodes which this SDDbgValue depends on.
174
+ ArrayRef<SDNode *> getSDNodes () const { return SDNodes ; }
106
175
107
- // / Returns the FrameIx for a stack object
108
- unsigned getFrameIx () const { assert (kind==FRAMEIX); return u.FrameIx ; }
109
-
110
- // / Returns the Virtual Register for a VReg
111
- unsigned getVReg () const { assert (kind==VREG); return u.VReg ; }
176
+ SDNodeVector copySDNodes () const { return SDNodes; }
112
177
113
178
// / Returns whether this is an indirect value.
114
179
bool isIndirect () const { return IsIndirect; }
115
180
181
+ bool isVariadic () const { return IsVariadic; }
182
+
116
183
// / Returns the DebugLoc.
117
184
DebugLoc getDebugLoc () const { return DL; }
118
185
0 commit comments