@@ -94,6 +94,9 @@ class OverflowingBinaryOperator : public Operator {
94
94
}
95
95
96
96
public:
97
+ // / Transparently provide more efficient getOperand methods.
98
+ DECLARE_TRANSPARENT_OPERAND_ACCESSORS (Value);
99
+
97
100
// / Test whether this operation is known to never
98
101
// / undergo unsigned overflow, aka the nuw property.
99
102
bool hasNoUnsignedWrap () const {
@@ -124,6 +127,12 @@ class OverflowingBinaryOperator : public Operator {
124
127
}
125
128
};
126
129
130
+ template <>
131
+ struct OperandTraits <OverflowingBinaryOperator>
132
+ : public FixedNumOperandTraits<OverflowingBinaryOperator, 2 > {};
133
+
134
+ DEFINE_TRANSPARENT_OPERAND_ACCESSORS (OverflowingBinaryOperator, Value)
135
+
127
136
// / A udiv or sdiv instruction, which can be marked as "exact",
128
137
// / indicating that no bits are destroyed.
129
138
class PossiblyExactOperator : public Operator {
@@ -141,6 +150,9 @@ class PossiblyExactOperator : public Operator {
141
150
}
142
151
143
152
public:
153
+ // / Transparently provide more efficient getOperand methods.
154
+ DECLARE_TRANSPARENT_OPERAND_ACCESSORS (Value);
155
+
144
156
// / Test whether this division is known to be exact, with zero remainder.
145
157
bool isExact () const {
146
158
return SubclassOptionalData & IsExact;
@@ -165,6 +177,12 @@ class PossiblyExactOperator : public Operator {
165
177
}
166
178
};
167
179
180
+ template <>
181
+ struct OperandTraits <PossiblyExactOperator>
182
+ : public FixedNumOperandTraits<PossiblyExactOperator, 2 > {};
183
+
184
+ DEFINE_TRANSPARENT_OPERAND_ACCESSORS (PossiblyExactOperator, Value)
185
+
168
186
// / Utility class for floating point operations which can have
169
187
// / information about relaxed accuracy requirements attached to them.
170
188
class FPMathOperator : public Operator {
@@ -383,6 +401,9 @@ class GEPOperator
383
401
}
384
402
385
403
public:
404
+ // / Transparently provide more efficient getOperand methods.
405
+ DECLARE_TRANSPARENT_OPERAND_ACCESSORS (Value);
406
+
386
407
// / Test whether this is an inbounds GEP, as defined by LangRef.html.
387
408
bool isInBounds () const {
388
409
return SubclassOptionalData & IsInBounds;
@@ -506,12 +527,21 @@ class GEPOperator
506
527
APInt &ConstantOffset) const ;
507
528
};
508
529
530
+ template <>
531
+ struct OperandTraits <GEPOperator>
532
+ : public VariadicOperandTraits<GEPOperator, 1 > {};
533
+
534
+ DEFINE_TRANSPARENT_OPERAND_ACCESSORS (GEPOperator, Value)
535
+
509
536
class PtrToIntOperator
510
537
: public ConcreteOperator<Operator, Instruction::PtrToInt> {
511
538
friend class PtrToInt ;
512
539
friend class ConstantExpr ;
513
540
514
541
public:
542
+ // / Transparently provide more efficient getOperand methods.
543
+ DECLARE_TRANSPARENT_OPERAND_ACCESSORS (Value);
544
+
515
545
Value *getPointerOperand () {
516
546
return getOperand (0 );
517
547
}
@@ -534,12 +564,21 @@ class PtrToIntOperator
534
564
}
535
565
};
536
566
567
+ template <>
568
+ struct OperandTraits <PtrToIntOperator>
569
+ : public FixedNumOperandTraits<PtrToIntOperator, 1 > {};
570
+
571
+ DEFINE_TRANSPARENT_OPERAND_ACCESSORS (PtrToIntOperator, Value)
572
+
537
573
class BitCastOperator
538
574
: public ConcreteOperator<Operator, Instruction::BitCast> {
539
575
friend class BitCastInst ;
540
576
friend class ConstantExpr ;
541
577
542
578
public:
579
+ // / Transparently provide more efficient getOperand methods.
580
+ DECLARE_TRANSPARENT_OPERAND_ACCESSORS (Value);
581
+
543
582
Type *getSrcTy () const {
544
583
return getOperand (0 )->getType ();
545
584
}
@@ -549,12 +588,21 @@ class BitCastOperator
549
588
}
550
589
};
551
590
591
+ template <>
592
+ struct OperandTraits <BitCastOperator>
593
+ : public FixedNumOperandTraits<BitCastOperator, 1 > {};
594
+
595
+ DEFINE_TRANSPARENT_OPERAND_ACCESSORS (BitCastOperator, Value)
596
+
552
597
class AddrSpaceCastOperator
553
598
: public ConcreteOperator<Operator, Instruction::AddrSpaceCast> {
554
599
friend class AddrSpaceCastInst ;
555
600
friend class ConstantExpr ;
556
601
557
602
public:
603
+ // / Transparently provide more efficient getOperand methods.
604
+ DECLARE_TRANSPARENT_OPERAND_ACCESSORS (Value);
605
+
558
606
Value *getPointerOperand () { return getOperand (0 ); }
559
607
560
608
const Value *getPointerOperand () const { return getOperand (0 ); }
@@ -568,6 +616,12 @@ class AddrSpaceCastOperator
568
616
}
569
617
};
570
618
619
+ template <>
620
+ struct OperandTraits <AddrSpaceCastOperator>
621
+ : public FixedNumOperandTraits<AddrSpaceCastOperator, 1 > {};
622
+
623
+ DEFINE_TRANSPARENT_OPERAND_ACCESSORS (AddrSpaceCastOperator, Value)
624
+
571
625
} // end namespace llvm
572
626
573
627
#endif // LLVM_IR_OPERATOR_H
0 commit comments