@@ -17,16 +17,16 @@ namespace clang {
1717namespace interp {
1818
1919using APInt = llvm::APInt;
20+ using APSInt = llvm::APSInt;
2021
2122// / Wrapper around fixed point types.
2223class FixedPoint final {
2324private:
2425 llvm::APFixedPoint V;
26+ FixedPoint (llvm::APFixedPoint &&V) : V(std::move(V)) {}
2527
2628public:
27- FixedPoint (APInt V)
28- : V(V,
29- llvm::FixedPointSemantics (V.getBitWidth(), 0, false, false, false)) {}
29+ FixedPoint (APInt V, llvm::FixedPointSemantics Sem) : V(V, Sem) {}
3030 // This needs to be default-constructible so llvm::endian::read works.
3131 FixedPoint ()
3232 : V(APInt(0 , 0ULL , false ),
@@ -42,12 +42,22 @@ class FixedPoint final {
4242 void print (llvm::raw_ostream &OS) const { OS << V; }
4343
4444 APValue toAPValue (const ASTContext &) const { return APValue (V); }
45+ APSInt toAPSInt (unsigned BitWidth) const { return V.getValue (); }
46+
47+ unsigned bitWidth () const { return V.getWidth (); }
48+ bool isSigned () const { return V.isSigned (); }
4549
4650 ComparisonCategoryResult compare (const FixedPoint &Other) const {
4751 if (Other.V == V)
4852 return ComparisonCategoryResult::Equal;
4953 return ComparisonCategoryResult::Unordered;
5054 }
55+
56+ static bool neg (const FixedPoint &A, FixedPoint *R) {
57+ bool Overflow = false ;
58+ *R = FixedPoint (A.V .negate (&Overflow));
59+ return Overflow;
60+ }
5161};
5262
5363inline FixedPoint getSwappedBytes (FixedPoint F) { return F; }
0 commit comments