@@ -58,9 +58,9 @@ class FixedPoint final {
5858 bool isNegative () const { return V.getValue ().isNegative (); }
5959 bool isPositive () const { return V.getValue ().isNonNegative (); }
6060 bool isMin () const {
61- return V.getValue () == APSInt::getMinValue (V.getSemantics ().getWidth (),
62- !V.getSemantics ().isSigned ());
61+ return V == llvm::APFixedPoint::getMin (V.getSemantics ());
6362 }
63+ bool isMinusOne () const { return V.isSigned () && V.getValue () == -1 ; }
6464
6565 FixedPoint truncate (unsigned BitWidth) const { return *this ; }
6666
@@ -82,9 +82,12 @@ class FixedPoint final {
8282 }
8383
8484 ComparisonCategoryResult compare (const FixedPoint &Other) const {
85- if (Other.V == V)
85+ int c = V.compare (Other.V );
86+ if (c == 0 )
8687 return ComparisonCategoryResult::Equal;
87- return ComparisonCategoryResult::Unordered;
88+ else if (c < 0 )
89+ return ComparisonCategoryResult::Less;
90+ return ComparisonCategoryResult::Greater;
8891 }
8992
9093 static bool neg (const FixedPoint &A, FixedPoint *R) {
@@ -101,16 +104,40 @@ class FixedPoint final {
101104 }
102105 static bool sub (const FixedPoint A, const FixedPoint B, unsigned Bits,
103106 FixedPoint *R) {
104- return true ;
107+ bool Overflow = false ;
108+ *R = FixedPoint (A.V .sub (B.V , &Overflow));
109+ return Overflow;
105110 }
106111 static bool mul (const FixedPoint A, const FixedPoint B, unsigned Bits,
107112 FixedPoint *R) {
108- return true ;
113+ bool Overflow = false ;
114+ *R = FixedPoint (A.V .mul (B.V , &Overflow));
115+ return Overflow;
109116 }
110117 static bool div (const FixedPoint A, const FixedPoint B, unsigned Bits,
111118 FixedPoint *R) {
119+ bool Overflow = false ;
120+ *R = FixedPoint (A.V .div (B.V , &Overflow));
121+ return Overflow;
122+ }
123+ static bool rem (const FixedPoint A, const FixedPoint B, unsigned Bits,
124+ FixedPoint *R) {
125+ llvm_unreachable (" Rem doesn't exist for fixed point values" );
126+ return true ;
127+ }
128+ static bool bitAnd (const FixedPoint A, const FixedPoint B, unsigned Bits,
129+ FixedPoint *R) {
130+ return true ;
131+ }
132+ static bool bitOr (const FixedPoint A, const FixedPoint B, unsigned Bits,
133+ FixedPoint *R) {
134+ return true ;
135+ }
136+ static bool bitXor (const FixedPoint A, const FixedPoint B, unsigned Bits,
137+ FixedPoint *R) {
112138 return true ;
113139 }
140+
114141 static bool increment (const FixedPoint &A, FixedPoint *R) { return true ; }
115142 static bool decrement (const FixedPoint &A, FixedPoint *R) { return true ; }
116143};
0 commit comments