@@ -47,15 +47,28 @@ class FixedPoint final {
4747 void print (llvm::raw_ostream &OS) const { OS << V; }
4848
4949 APValue toAPValue (const ASTContext &) const { return APValue (V); }
50- APSInt toAPSInt (unsigned BitWidth) const { return V.getValue (); }
50+ APSInt toAPSInt (unsigned BitWidth = 0 ) const { return V.getValue (); }
5151
5252 unsigned bitWidth () const { return V.getWidth (); }
5353 bool isSigned () const { return V.isSigned (); }
54+ bool isZero () const { return V.getValue ().isZero (); }
55+ bool isNegative () const { return V.getValue ().isNegative (); }
56+ bool isPositive () const { return V.getValue ().isNonNegative (); }
57+ bool isMin () const {
58+ return V.getValue () == APSInt::getMinValue (V.getSemantics ().getWidth (),
59+ !V.getSemantics ().isSigned ());
60+ }
61+
62+ FixedPoint truncate (unsigned BitWidth) const { return *this ; }
5463
5564 llvm::APFloat toFloat (const llvm::fltSemantics *Sem) const {
5665 return V.convertToFloat (*Sem);
5766 }
5867
68+ std::string toDiagnosticString (const ASTContext &Ctx) const {
69+ return V.toString ();
70+ }
71+
5972 ComparisonCategoryResult compare (const FixedPoint &Other) const {
6073 if (Other.V == V)
6174 return ComparisonCategoryResult::Equal;
@@ -67,6 +80,27 @@ class FixedPoint final {
6780 *R = FixedPoint (A.V .negate (&Overflow));
6881 return Overflow;
6982 }
83+
84+ static bool add (const FixedPoint A, const FixedPoint B, unsigned Bits,
85+ FixedPoint *R) {
86+ bool Overflow = false ;
87+ *R = FixedPoint (A.V .add (B.V , &Overflow));
88+ return Overflow;
89+ }
90+ static bool sub (const FixedPoint A, const FixedPoint B, unsigned Bits,
91+ FixedPoint *R) {
92+ return true ;
93+ }
94+ static bool mul (const FixedPoint A, const FixedPoint B, unsigned Bits,
95+ FixedPoint *R) {
96+ return true ;
97+ }
98+ static bool div (const FixedPoint A, const FixedPoint B, unsigned Bits,
99+ FixedPoint *R) {
100+ return true ;
101+ }
102+ static bool increment (const FixedPoint &A, FixedPoint *R) { return true ; }
103+ static bool decrement (const FixedPoint &A, FixedPoint *R) { return true ; }
70104};
71105
72106inline FixedPoint getSwappedBytes (FixedPoint F) { return F; }
0 commit comments