@@ -82,6 +82,16 @@ class Type;
82
82
83
83
public:
84
84
const SCEV *getOperand () const { return Op; }
85
+ const SCEV *getOperand (unsigned i) const {
86
+ assert (i == 0 && " Operand index out of range!" );
87
+ return Op;
88
+ }
89
+ using op_iterator = const SCEV *const *;
90
+ using op_range = iterator_range<op_iterator>;
91
+ op_range operands () const {
92
+ return make_range (&Op, &Op + 1 );
93
+ }
94
+ size_t getNumOperands () const { return 1 ; }
85
95
Type *getType () const { return Ty; }
86
96
87
97
// / Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -263,16 +273,28 @@ class Type;
263
273
class SCEVUDivExpr : public SCEV {
264
274
friend class ScalarEvolution ;
265
275
266
- const SCEV *LHS;
267
- const SCEV *RHS;
276
+ std::array<const SCEV*, 2 > Operands;
268
277
269
278
SCEVUDivExpr (const FoldingSetNodeIDRef ID, const SCEV *lhs, const SCEV *rhs)
270
- : SCEV(ID, scUDivExpr, computeExpressionSize({lhs, rhs})), LHS(lhs),
271
- RHS (rhs) {}
279
+ : SCEV(ID, scUDivExpr, computeExpressionSize({lhs, rhs})) {
280
+ Operands[0 ] = lhs;
281
+ Operands[1 ] = rhs;
282
+ }
272
283
273
284
public:
274
- const SCEV *getLHS () const { return LHS; }
275
- const SCEV *getRHS () const { return RHS; }
285
+ const SCEV *getLHS () const { return Operands[0 ]; }
286
+ const SCEV *getRHS () const { return Operands[1 ]; }
287
+ size_t getNumOperands () const { return 2 ; }
288
+ const SCEV *getOperand (unsigned i) const {
289
+ assert ((i == 0 || i == 1 ) && " Operand index out of range!" );
290
+ return i == 0 ? getLHS () : getRHS ();
291
+ }
292
+
293
+ using op_iterator = const SCEV *const *;
294
+ using op_range = iterator_range<op_iterator>;
295
+ op_range operands () const {
296
+ return make_range (Operands.begin (), Operands.end ());
297
+ }
276
298
277
299
Type *getType () const {
278
300
// In most cases the types of LHS and RHS will be the same, but in some
0 commit comments