Lines Matching defs:APSInt

1 //===-- llvm/ADT/APSInt.h - Arbitrary Precision Signed Int -----*- C++ -*--===//
10 // This file implements the APSInt class, which is a simple class that
22 class APSInt : public APInt {
26 explicit APSInt() : IsUnsigned(false) {}
28 /// APSInt ctor - Create an APSInt with the specified width, default to
30 explicit APSInt(uint32_t BitWidth, bool isUnsigned = true)
33 explicit APSInt(APInt I, bool isUnsigned = true)
36 APSInt &operator=(APInt RHS) {
42 APSInt &operator=(uint64_t RHS) {
54 /// toString - Append this APSInt to the specified SmallString.
65 APSInt LLVM_ATTRIBUTE_UNUSED_RESULT trunc(uint32_t width) const {
66 return APSInt(APInt::trunc(width), IsUnsigned);
69 APSInt LLVM_ATTRIBUTE_UNUSED_RESULT extend(uint32_t width) const {
71 return APSInt(zext(width), IsUnsigned);
73 return APSInt(sext(width), IsUnsigned);
76 APSInt LLVM_ATTRIBUTE_UNUSED_RESULT extOrTrunc(uint32_t width) const {
78 return APSInt(zextOrTrunc(width), IsUnsigned);
80 return APSInt(sextOrTrunc(width), IsUnsigned);
83 const APSInt &operator%=(const APSInt &RHS) {
91 const APSInt &operator/=(const APSInt &RHS) {
99 APSInt operator%(const APSInt &RHS) const {
101 return IsUnsigned ? APSInt(urem(RHS), true) : APSInt(srem(RHS), false);
103 APSInt operator/(const APSInt &RHS) const {
105 return IsUnsigned ? APSInt(udiv(RHS), true) : APSInt(sdiv(RHS), false);
108 APSInt operator>>(unsigned Amt) const {
109 return IsUnsigned ? APSInt(lshr(Amt), true) : APSInt(ashr(Amt), false);
111 APSInt& operator>>=(unsigned Amt) {
116 inline bool operator<(const APSInt& RHS) const {
120 inline bool operator>(const APSInt& RHS) const {
124 inline bool operator<=(const APSInt& RHS) const {
128 inline bool operator>=(const APSInt& RHS) const {
132 inline bool operator==(const APSInt& RHS) const {
137 return isSameValue(*this, APSInt(APInt(64, RHS), true));
139 inline bool operator!=(const APSInt& RHS) const {
149 APSInt operator<<(unsigned Bits) const {
150 return APSInt(static_cast<const APInt&>(*this) << Bits, IsUnsigned);
152 APSInt& operator<<=(unsigned Amt) {
157 APSInt& operator++() {
161 APSInt& operator--() {
165 APSInt operator++(int) {
166 return APSInt(++static_cast<APInt&>(*this), IsUnsigned);
168 APSInt operator--(int) {
169 return APSInt(--static_cast<APInt&>(*this), IsUnsigned);
171 APSInt operator-() const {
172 return APSInt(-static_cast<const APInt&>(*this), IsUnsigned);
174 APSInt& operator+=(const APSInt& RHS) {
179 APSInt& operator-=(const APSInt& RHS) {
184 APSInt& operator*=(const APSInt& RHS) {
189 APSInt& operator&=(const APSInt& RHS) {
194 APSInt& operator|=(const APSInt& RHS) {
199 APSInt& operator^=(const APSInt& RHS) {
205 APSInt operator&(const APSInt& RHS) const {
207 return APSInt(static_cast<const APInt&>(*this) & RHS, IsUnsigned);
209 APSInt LLVM_ATTRIBUTE_UNUSED_RESULT And(const APSInt& RHS) const {
213 APSInt operator|(const APSInt& RHS) const {
215 return APSInt(static_cast<const APInt&>(*this) | RHS, IsUnsigned);
217 APSInt LLVM_ATTRIBUTE_UNUSED_RESULT Or(const APSInt& RHS) const {
222 APSInt operator^(const APSInt& RHS) const {
224 return APSInt(static_cast<const APInt&>(*this) ^ RHS, IsUnsigned);
226 APSInt LLVM_ATTRIBUTE_UNUSED_RESULT Xor(const APSInt& RHS) const {
230 APSInt operator*(const APSInt& RHS) const {
232 return APSInt(static_cast<const APInt&>(*this) * RHS, IsUnsigned);
234 APSInt operator+(const APSInt& RHS) const {
236 return APSInt(static_cast<const APInt&>(*this) + RHS, IsUnsigned);
238 APSInt operator-(const APSInt& RHS) const {
240 return APSInt(static_cast<const APInt&>(*this) - RHS, IsUnsigned);
242 APSInt operator~() const {
243 return APSInt(~static_cast<const APInt&>(*this), IsUnsigned);
246 /// getMaxValue - Return the APSInt representing the maximum integer value
248 static APSInt getMaxValue(uint32_t numBits, bool Unsigned) {
249 return APSInt(Unsigned ? APInt::getMaxValue(numBits)
253 /// getMinValue - Return the APSInt representing the minimum integer value
255 static APSInt getMinValue(uint32_t numBits, bool Unsigned) {
256 return APSInt(Unsigned ? APInt::getMinValue(numBits)
262 static bool isSameValue(const APSInt &I1, const APSInt &I2) {
278 return APSInt(I1, true) == I2;
284 return I1 == APSInt(I2, true);
287 /// Profile - Used to insert APSInt objects, or objects that contain APSInt
292 inline bool operator==(int64_t V1, const APSInt& V2) {
295 inline bool operator!=(int64_t V1, const APSInt& V2) {
299 inline raw_ostream &operator<<(raw_ostream &OS, const APSInt &I) {