@@ -43,12 +43,10 @@ template <bool Signed> class IntegralAP final {
43
43
44
44
IntegralAP (APInt V) : V(V) {}
45
45
IntegralAP (APSInt V) : V(V) {}
46
- IntegralAP (bool b) : V(APInt(8 , b, Signed)) {}
47
- // / Bullshit value for initialized variables.
46
+ // / Arbitrary value for initialized variables.
48
47
IntegralAP () : V(APSInt::getMaxValue(1024 , Signed)) {}
49
48
50
49
IntegralAP operator -() const { return IntegralAP (-V); }
51
- // bool operator <=> (const IntegralAP &RHS) const = default;
52
50
bool operator >(IntegralAP RHS) const { return V > RHS.V ; }
53
51
bool operator >=(IntegralAP RHS) const { return V >= RHS.V ; }
54
52
bool operator <(IntegralAP RHS) const { return V < RHS.V ; }
@@ -85,7 +83,7 @@ template <bool Signed> class IntegralAP final {
85
83
template <unsigned Bits, bool InputSigned>
86
84
static IntegralAP from (Integral<Bits, InputSigned> I) {
87
85
assert (InputSigned);
88
- // / TODO : Take bits parameter.
86
+ // / FIXME : Take bits parameter.
89
87
APSInt Copy =
90
88
APSInt (APInt (128 , static_cast <int64_t >(I), InputSigned), !Signed);
91
89
Copy.setIsSigned (Signed);
@@ -108,13 +106,13 @@ template <bool Signed> class IntegralAP final {
108
106
APSInt toAPSInt (unsigned Bits = 0 ) const { return V; }
109
107
APValue toAPValue () const { return APValue (V); }
110
108
111
- bool isZero () const { return false ; }
112
- bool isPositive () const { return true ; }
113
- bool isNegative () const { return false ; }
114
- bool isMin () const { return false ; }
115
- bool isMax () const { return false ; }
109
+ bool isZero () const { return V. isZero () ; }
110
+ bool isPositive () const { return V. isNonNegative () ; }
111
+ bool isNegative () const { return !V. isNonNegative () ; }
112
+ bool isMin () const { return V. isMinValue () ; }
113
+ bool isMax () const { return V. isMaxValue () ; }
116
114
static bool isSigned () { return Signed; }
117
- bool isMinusOne () const { return false ; }
115
+ bool isMinusOne () const { return Signed && V == - 1 ; }
118
116
119
117
unsigned countLeadingZeros () const { return V.countl_zero (); }
120
118
@@ -142,12 +140,11 @@ template <bool Signed> class IntegralAP final {
142
140
}
143
141
144
142
static bool add (IntegralAP A, IntegralAP B, unsigned OpBits, IntegralAP *R) {
145
- // / TODO: Gotta check if the result fits into OpBits bits.
146
143
return CheckAddUB (A, B, OpBits, R);
147
144
}
148
145
149
146
static bool sub (IntegralAP A, IntegralAP B, unsigned OpBits, IntegralAP *R) {
150
- // / TODO : Gotta check if the result fits into OpBits bits.
147
+ // / FIXME : Gotta check if the result fits into OpBits bits.
151
148
return CheckSubUB (A, B, R);
152
149
}
153
150
0 commit comments