1//===-- llvm/ADT/APInt.h - For Arbitrary Precision Integer -----*- C++ -*--===// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7//===----------------------------------------------------------------------===// 10/// This file implements a class to represent arbitrary precision 11/// integral constant values and operations on them. 13//===----------------------------------------------------------------------===// 15#ifndef LLVM_ADT_APINT_H 16#define LLVM_ADT_APINT_H 35template <
typename T>
classSmallVectorImpl;
37template <
typename T,
typename Enable>
structDenseMapInfo;
43//===----------------------------------------------------------------------===// 45//===----------------------------------------------------------------------===// 47/// Class for arbitrary precision integers. 49/// APInt is a functional replacement for common case unsigned integer type like 50/// "unsigned", "unsigned long" or "uint64_t", but also allows non-byte-width 51/// integer sizes and large integer value types such as 3-bits, 15-bits, or more 52/// than 64-bits of precision. APInt provides a variety of arithmetic operators 53/// and methods to manipulate integer values of any bit-width. It supports both 54/// the typical integer arithmetic and comparison operations as well as bitwise 57/// The class has several invariants worth noting: 58/// * All bit, byte, and word positions are zero-based. 59/// * Once the bit width is set, it doesn't change except by the Truncate, 60/// SignExtend, or ZeroExtend operations. 61/// * All binary operators must be on APInt instances of the same bit width. 62/// Attempting to use these operators on instances with different bit 63/// widths will yield an assertion. 64/// * The value is stored canonically as an unsigned value. For operations 65/// where it makes a difference, there are both signed and unsigned variants 66/// of the operation. For example, sdiv and udiv. However, because the bit 67/// widths must be the same, operations such as Mul and Add produce the same 68/// results regardless of whether the values are interpreted as signed or 70/// * In general, the class tries to follow the style of computation that LLVM 71/// uses in its IR. This simplifies its use for LLVM. 72/// * APInt supports zero-bit-width values, but operations that require bits 73/// are not defined on it (e.g. you cannot ask for the sign of a zero-bit 74/// integer). This means that operations like zero extension and logical 75/// shifts are defined, but sign extension and ashr is not. Zero bit values 76/// compare and hash equal to themselves, and countLeadingZeros returns 0. 82 /// Byte size of a word. 83staticconstexprunsigned APINT_WORD_SIZE =
sizeof(
WordType);
86staticconstexprunsigned APINT_BITS_PER_WORD = APINT_WORD_SIZE * CHAR_BIT;
96 /// \name Constructors 99 /// Create a new APInt of numBits width, initialized as val. 101 /// If isSigned is true then val is treated as if it were a signed value 102 /// (i.e. as an int64_t) and the appropriate sign extension to the bit width 103 /// will be done. Otherwise, no sign extension occurs (high order bits beyond 104 /// the range of val are zero filled). 106 /// \param numBits the bit width of the constructed APInt 107 /// \param val the initial value of the APInt 108 /// \param isSigned how to treat signedness of val 109 /// \param implicitTrunc allow implicit truncation of non-zero/sign bits of 110 /// val beyond the range of numBits 112bool implicitTrunc =
false)
118"Value must be 0 or -1 for signed 0-bit APInt");
121"Value is not an N-bit signed value");
125assert(val == 0 &&
"Value must be zero for unsigned 0-bit APInt");
128"Value is not an N-bit unsigned value");
141 /// Construct an APInt of numBits width, initialized as bigVal[]. 143 /// Note that bigVal.size() can be smaller or larger than the corresponding 144 /// bit width but any extraneous bits will be dropped. 146 /// \param numBits the bit width of the constructed APInt 147 /// \param bigVal a sequence of words to form the initial value of the APInt 150 /// Equivalent to APInt(numBits, ArrayRef<uint64_t>(bigVal, numWords)), but 151 /// deprecated because this constructor is prone to ambiguity with the 152 /// APInt(unsigned, uint64_t, bool) constructor. 154 /// If this overload is ever deleted, care should be taken to prevent calls 155 /// from being incorrectly captured by the APInt(unsigned, uint64_t, bool) 157APInt(
unsigned numBits,
unsigned numWords,
constuint64_t bigVal[]);
159 /// Construct an APInt from a string representation. 161 /// This constructor interprets the string \p str in the given radix. The 162 /// interpretation stops when the first character that is not suitable for the 163 /// radix is encountered, or the end of the string. Acceptable radix values 164 /// are 2, 8, 10, 16, and 36. It is an error for the value implied by the 165 /// string to require more bits than numBits. 167 /// \param numBits the bit width of the constructed APInt 168 /// \param str the string to be interpreted 169 /// \param radix the radix to use for the conversion 172 /// Default constructor that creates an APInt with a 1-bit zero value. 175 /// Copy Constructor. 183 /// Move Constructor. 185 memcpy(&U, &that.U,
sizeof(U));
196 /// \name Value Generators 199 /// Get the '0' value for the specified bit-width. 202 /// Return an APInt zero bits wide. 205 /// Gets maximum unsigned value of APInt for specific bit width. 208 /// Gets maximum signed value of APInt for a specific bit width. 210APInt API = getAllOnes(numBits);
215 /// Gets minimum unsigned value of APInt for a specific bit width. 218 /// Gets minimum signed value of APInt for a specific bit width. 220APInt API(numBits, 0);
225 /// Get the SignMask for a specific bit width. 227 /// This is just a wrapper function of getSignedMinValue(), and it helps code 228 /// readability when we want to get a SignMask. 233 /// Return an APInt of a specified width with all bits set. 235returnAPInt(numBits, WORDTYPE_MAX,
true);
238 /// Return an APInt with exactly one bit set in the result. 240APInt Res(numBits, 0);
245 /// Get a value with a block of bits set. 247 /// Constructs an APInt value that has a contiguous range of bits set. The 248 /// bits from loBit (inclusive) to hiBit (exclusive) will be set. All other 249 /// bits will be zero. For example, with parameters(32, 0, 16) you would get 250 /// 0x0000FFFF. Please call getBitsSetWithWrap if \p loBit may be greater than 253 /// \param numBits the intended bit width of the result 254 /// \param loBit the index of the lowest bit set. 255 /// \param hiBit the index of the highest bit set. 257 /// \returns An APInt value with the requested bits set. 259APInt Res(numBits, 0);
264 /// Wrap version of getBitsSet. 265 /// If \p hiBit is bigger than \p loBit, this is same with getBitsSet. 266 /// If \p hiBit is not bigger than \p loBit, the set bits "wrap". For example, 267 /// with parameters (32, 28, 4), you would get 0xF000000F. 268 /// If \p hiBit is equal to \p loBit, you would get a result with all bits 272APInt Res(numBits, 0);
277 /// Constructs an APInt value that has a contiguous range of bits set. The 278 /// bits from loBit (inclusive) to numBits (exclusive) will be set. All other 279 /// bits will be zero. For example, with parameters(32, 12) you would get 282 /// \param numBits the intended bit width of the result 283 /// \param loBit the index of the lowest bit to set. 285 /// \returns An APInt value with the requested bits set. 287APInt Res(numBits, 0);
292 /// Constructs an APInt value that has the top hiBitsSet bits set. 294 /// \param numBits the bitwidth of the result 295 /// \param hiBitsSet the number of high-order bits set in the result. 297APInt Res(numBits, 0);
302 /// Constructs an APInt value that has the bottom loBitsSet bits set. 304 /// \param numBits the bitwidth of the result 305 /// \param loBitsSet the number of low-order bits set in the result. 307APInt Res(numBits, 0);
312 /// Return a value containing V broadcasted over NewLen bits. 313staticAPInt getSplat(
unsigned NewLen,
constAPInt &V);
316 /// \name Value Tests 319 /// Determine if this APInt just has one word to store value. 321 /// \returns true if the number of bits <= 64, false otherwise. 324 /// Determine sign of this APInt. 326 /// This tests the high bit of this APInt to determine if it is set. 328 /// \returns true if this APInt is negative, false otherwise 331 /// Determine if this APInt Value is non-negative (>= 0) 333 /// This tests the high bit of the APInt to determine if it is unset. 336 /// Determine if sign bit of this APInt is set. 338 /// This tests the high bit of this APInt to determine if it is set. 340 /// \returns true if this APInt has its sign bit set, false otherwise. 343 /// Determine if sign bit of this APInt is clear. 345 /// This tests the high bit of this APInt to determine if it is clear. 347 /// \returns true if this APInt has its sign bit clear, false otherwise. 350 /// Determine if this APInt Value is positive. 352 /// This tests if the value of this APInt is positive (> 0). Note 353 /// that 0 is not a positive value. 355 /// \returns true if this APInt is positive. 358 /// Determine if this APInt Value is non-positive (<= 0). 360 /// \returns true if this APInt is non-positive. 363 /// Determine if this APInt Value only has the specified bit set. 365 /// \returns true if this APInt only has the specified bit set. 367return (*
this)[BitNo] &&
popcount() == 1;
370 /// Determine if all bits are set. This is true for zero-width values. 375return U.VAL == WORDTYPE_MAX >> (APINT_BITS_PER_WORD -
BitWidth);
376return countTrailingOnesSlowCase() ==
BitWidth;
379 /// Determine if this value is zero, i.e. all bits are clear. 383return countLeadingZerosSlowCase() ==
BitWidth;
386 /// Determine if this is a value of 1. 388 /// This checks to see if the value of this APInt is one. 392return countLeadingZerosSlowCase() ==
BitWidth - 1;
395 /// Determine if this is the largest unsigned value. 397 /// This checks to see if the value of this APInt is the maximum unsigned 398 /// value for the APInt's bit width. 401 /// Determine if this is the largest signed value. 403 /// This checks to see if the value of this APInt is the maximum signed 404 /// value for the APInt's bit width. 410return !isNegative() && countTrailingOnesSlowCase() ==
BitWidth - 1;
413 /// Determine if this is the smallest unsigned value. 415 /// This checks to see if the value of this APInt is the minimum unsigned 416 /// value for the APInt's bit width. 419 /// Determine if this is the smallest signed value. 421 /// This checks to see if the value of this APInt is the minimum signed 422 /// value for the APInt's bit width. 428return isNegative() && countTrailingZerosSlowCase() ==
BitWidth - 1;
431 /// Check if this APInt has an N-bits unsigned integer value. 432boolisIntN(
unsignedN)
const{
return getActiveBits() <=
N; }
434 /// Check if this APInt has an N-bits signed integer value. 437 /// Check if this APInt's value is a power of two greater than zero. 439 /// \returns true if the argument APInt value is a power of two > 0. 445return countPopulationSlowCase() == 1;
448 /// Check if this APInt's negated value is a power of two greater than zero. 453// NegatedPowerOf2 - shifted mask in the top bits. 459 /// Checks if this APInt -interpreted as an address- is aligned to the 463 /// Check if the APInt's value is returned by getSignMask. 465 /// \returns true if this is the value returned by getSignMask. 468 /// Convert APInt to a boolean value. 470 /// This converts the APInt to a boolean value as a test against zero. 473 /// If this value is smaller than the specified limit, return it, otherwise 474 /// return the limit value. This causes the value to saturate to the limit. 476return ugt(Limit) ? Limit : getZExtValue();
479 /// Check if the APInt consists of a repeated bit pattern. 481 /// e.g. 0x01010101 satisfies isSplat(8). 482 /// \param SplatSizeInBits The size of the pattern in bits. Must divide bit 483 /// width without remainder. 484boolisSplat(
unsigned SplatSizeInBits)
const;
486 /// \returns true if this APInt value is a sequence of \param numBits ones 487 /// starting at the least significant bit with the remainder zero. 489assert(numBits != 0 &&
"numBits must be non-zero");
492return U.VAL == (WORDTYPE_MAX >> (APINT_BITS_PER_WORD - numBits));
493unsigned Ones = countTrailingOnesSlowCase();
494return (numBits == Ones) &&
495 ((Ones + countLeadingZerosSlowCase()) ==
BitWidth);
498 /// \returns true if this APInt is a non-empty sequence of ones starting at 499 /// the least significant bit with the remainder zero. 500 /// Ex. isMask(0x0000FFFFU) == true. 504unsigned Ones = countTrailingOnesSlowCase();
505return (Ones > 0) && ((Ones + countLeadingZerosSlowCase()) ==
BitWidth);
508 /// Return true if this APInt value contains a non-empty sequence of ones with 509 /// the remainder zero. 513unsigned Ones = countPopulationSlowCase();
514unsigned LeadZ = countLeadingZerosSlowCase();
515return (Ones + LeadZ + countTrailingZerosSlowCase()) ==
BitWidth;
518 /// Return true if this APInt value contains a non-empty sequence of ones with 519 /// the remainder zero. If true, \p MaskIdx will specify the index of the 520 /// lowest set bit and \p MaskLen is updated to specify the length of the 521 /// mask, else neither are updated. 525unsigned Ones = countPopulationSlowCase();
526unsigned LeadZ = countLeadingZerosSlowCase();
527unsigned TrailZ = countTrailingZerosSlowCase();
528if ((Ones + LeadZ + TrailZ) !=
BitWidth)
535 /// Compute an APInt containing numBits highbits from this APInt. 537 /// Get an APInt with the same BitWidth as this APInt, just zero mask the low 538 /// bits and right shift to the least significant bit. 540 /// \returns the high "numBits" bits of this APInt. 541APInt getHiBits(
unsigned numBits)
const;
543 /// Compute an APInt containing numBits lowbits from this APInt. 545 /// Get an APInt with the same BitWidth as this APInt, just zero mask the high 548 /// \returns the low "numBits" bits of this APInt. 549APInt getLoBits(
unsigned numBits)
const;
551 /// Determine if two APInts have the same value, after zero-extending 552 /// one of them (if needed!) to ensure that the bit-widths match. 558return I1 == I2.
zext(I1.getBitWidth());
563 /// Overload to compute a hash_code for an APInt value. 566 /// This function returns a pointer to the internal storage of the APInt. 567 /// This is useful for writing out the APInt in binary form without any 576 /// \name Unary Operators 579 /// Postfix increment operator. Increment *this by 1. 581 /// \returns a new APInt value representing the original value of *this. 588 /// Prefix increment operator. 590 /// \returns *this incremented by one 593 /// Postfix decrement operator. Decrement *this by 1. 595 /// \returns a new APInt value representing the original value of *this. 602 /// Prefix decrement operator. 604 /// \returns *this decremented by one. 607 /// Logical negation operation on this APInt returns true if zero, like normal 612 /// \name Assignment Operators 615 /// Copy assignment operator. 617 /// \returns *this after assignment of RHS. 619// The common case (both source or dest being inline) doesn't require 620// allocation or deallocation. 621if (isSingleWord() &&
RHS.isSingleWord()) {
631 /// Move assignment operator. 633#ifdef EXPENSIVE_CHECKS 634// Some std::shuffle implementations still do self-assignment. 638assert(
this != &that &&
"Self-move not supported");
642// Use memcpy so that type based alias analysis sees both VAL and pVal 644 memcpy(&U, &that.U,
sizeof(U));
651 /// Assignment operator. 653 /// The RHS value is assigned to *this. If the significant bits in RHS exceed 654 /// the bit width, the excess bits are truncated. If the bit width is larger 655 /// than 64, the value is zero filled in the unspecified high order bits. 657 /// \returns *this after assignment of RHS value. 664 memset(U.pVal + 1, 0, (getNumWords() - 1) * APINT_WORD_SIZE);
668 /// Bitwise AND assignment operator. 670 /// Performs a bitwise AND operation on this APInt and RHS. The result is 671 /// assigned to *this. 673 /// \returns *this after ANDing with RHS. 679 andAssignSlowCase(
RHS);
683 /// Bitwise AND assignment operator. 685 /// Performs a bitwise AND operation on this APInt and RHS. RHS is 686 /// logically zero-extended or truncated to match the bit-width of 694 memset(U.pVal + 1, 0, (getNumWords() - 1) * APINT_WORD_SIZE);
698 /// Bitwise OR assignment operator. 700 /// Performs a bitwise OR operation on this APInt and RHS. The result is 703 /// \returns *this after ORing with RHS. 709 orAssignSlowCase(
RHS);
713 /// Bitwise OR assignment operator. 715 /// Performs a bitwise OR operation on this APInt and RHS. RHS is 716 /// logically zero-extended or truncated to match the bit-width of 727 /// Bitwise XOR assignment operator. 729 /// Performs a bitwise XOR operation on this APInt and RHS. The result is 730 /// assigned to *this. 732 /// \returns *this after XORing with RHS. 738 xorAssignSlowCase(
RHS);
742 /// Bitwise XOR assignment operator. 744 /// Performs a bitwise XOR operation on this APInt and RHS. RHS is 745 /// logically zero-extended or truncated to match the bit-width of 756 /// Multiplication assignment operator. 758 /// Multiplies this APInt by RHS and assigns the result to *this. 764 /// Addition assignment operator. 766 /// Adds RHS to *this and assigns the result to *this. 772 /// Subtraction assignment operator. 774 /// Subtracts RHS from *this and assigns the result to *this. 780 /// Left-shift assignment function. 782 /// Shifts *this left by shiftAmt and assigns the result to *this. 784 /// \returns *this after shifting left by ShiftAmt 794 shlSlowCase(ShiftAmt);
798 /// Left-shift assignment function. 800 /// Shifts *this left by shiftAmt and assigns the result to *this. 802 /// \returns *this after shifting left by ShiftAmt 806 /// \name Binary Operators 809 /// Multiplication operator. 811 /// Multiplies this APInt by RHS and returns the result. 814 /// Left logical shift operator. 816 /// Shifts this APInt left by \p Bits and returns the result. 819 /// Left logical shift operator. 821 /// Shifts this APInt left by \p Bits and returns the result. 824 /// Arithmetic right-shift function. 826 /// Arithmetic right-shift this APInt by shiftAmt. 829 R.ashrInPlace(ShiftAmt);
833 /// Arithmetic right-shift this APInt by ShiftAmt in place. 839 U.VAL = SExtVAL >> (APINT_BITS_PER_WORD - 1);
// Fill with sign bit. 841 U.VAL = SExtVAL >> ShiftAmt;
845 ashrSlowCase(ShiftAmt);
848 /// Logical right-shift function. 850 /// Logical right-shift this APInt by shiftAmt. 853 R.lshrInPlace(shiftAmt);
857 /// Logical right-shift this APInt by ShiftAmt in place. 867 lshrSlowCase(ShiftAmt);
870 /// Left-shift function. 872 /// Left-shift this APInt by shiftAmt. 879 /// relative logical shift right 881return RelativeShift > 0 ? lshr(RelativeShift) : shl(-RelativeShift);
884 /// relative logical shift left 886return relativeLShr(-RelativeShift);
889 /// relative arithmetic shift right 891return RelativeShift > 0 ? ashr(RelativeShift) : shl(-RelativeShift);
894 /// relative arithmetic shift left 896return relativeAShr(-RelativeShift);
899 /// Rotate left by rotateAmt. 902 /// Rotate right by rotateAmt. 905 /// Arithmetic right-shift function. 907 /// Arithmetic right-shift this APInt by shiftAmt. 910 R.ashrInPlace(ShiftAmt);
914 /// Arithmetic right-shift this APInt by shiftAmt in place. 915void ashrInPlace(
constAPInt &shiftAmt);
917 /// Logical right-shift function. 919 /// Logical right-shift this APInt by shiftAmt. 922 R.lshrInPlace(ShiftAmt);
926 /// Logical right-shift this APInt by ShiftAmt in place. 927void lshrInPlace(
constAPInt &ShiftAmt);
929 /// Left-shift function. 931 /// Left-shift this APInt by shiftAmt. 938 /// Rotate left by rotateAmt. 941 /// Rotate right by rotateAmt. 944 /// Concatenate the bits from "NewLSB" onto the bottom of *this. This is 946 /// (this->zext(NewWidth) << NewLSB.getBitWidth()) | NewLSB.zext(NewWidth) 948 /// If the result will be small, then both the merged values are small. 950if (NewWidth <= APINT_BITS_PER_WORD)
952return concatSlowCase(NewLSB);
955 /// Unsigned division operation. 957 /// Perform an unsigned divide operation on this APInt by RHS. Both this and 958 /// RHS are treated as unsigned quantities for purposes of this division. 960 /// \returns a new APInt value containing the division result, rounded towards 965 /// Signed division function for APInt. 967 /// Signed divide this APInt by APInt RHS. 969 /// The result is rounded towards zero. 973 /// Unsigned remainder operation. 975 /// Perform an unsigned remainder operation on this APInt with RHS being the 976 /// divisor. Both this and RHS are treated as unsigned quantities for purposes 977 /// of this operation. 979 /// \returns a new APInt value containing the remainder result 983 /// Function for signed remainder operation. 985 /// Signed remainder operation on APInt. 987 /// Note that this is a true remainder operation and not a modulo operation 988 /// because the sign follows the sign of the dividend which is *this. 990 int64_t srem(int64_t
RHS)
const;
992 /// Dual division/remainder interface. 994 /// Sometimes it is convenient to divide two APInt values and obtain both the 995 /// quotient and remainder. This function does both operations in the same 996 /// computation making it a little more efficient. The pair of input arguments 997 /// may overlap with the pair of output arguments. It is safe to call 998 /// udivrem(X, Y, X, Y), for example. 1007 int64_t &Remainder);
1009// Operations that return overflow indicators. 1017APInt sshl_ov(
constAPInt &Amt,
bool &Overflow)
const;
1018APInt sshl_ov(
unsigned Amt,
bool &Overflow)
const;
1019APInt ushl_ov(
constAPInt &Amt,
bool &Overflow)
const;
1020APInt ushl_ov(
unsigned Amt,
bool &Overflow)
const;
1022 /// Signed integer floor division operation. 1024 /// Rounds towards negative infinity, i.e. 5 / -2 = -3. Iff minimum value 1025 /// divided by -1 set Overflow to true. 1028// Operations that saturate 1040 /// Array-indexing support. 1042 /// \returns the bit value at bitPosition 1045return (maskBit(bitPosition) & getWord(bitPosition)) != 0;
1049 /// \name Comparison Operators 1052 /// Equality operator. 1054 /// Compares this APInt with RHS for the validity of the equality 1059return U.VAL ==
RHS.U.VAL;
1060return equalSlowCase(
RHS);
1063 /// Equality operator. 1065 /// Compares this APInt with a uint64_t for the validity of the equality 1068 /// \returns true if *this == Val 1070return (isSingleWord() || getActiveBits() <= 64) && getZExtValue() == Val;
1073 /// Equality comparison. 1075 /// Compares this APInt with RHS for the validity of the equality 1078 /// \returns true if *this == Val 1081 /// Inequality operator. 1083 /// Compares this APInt with RHS for the validity of the inequality 1086 /// \returns true if *this != Val 1089 /// Inequality operator. 1091 /// Compares this APInt with a uint64_t for the validity of the inequality 1094 /// \returns true if *this != Val 1097 /// Inequality comparison 1099 /// Compares this APInt with RHS for the validity of the inequality 1102 /// \returns true if *this != Val 1105 /// Unsigned less than comparison 1107 /// Regards both *this and RHS as unsigned quantities and compares them for 1108 /// the validity of the less-than relationship. 1110 /// \returns true if *this < RHS when both are considered unsigned. 1113 /// Unsigned less than comparison 1115 /// Regards both *this as an unsigned quantity and compares it with RHS for 1116 /// the validity of the less-than relationship. 1118 /// \returns true if *this < RHS when considered unsigned. 1120// Only need to check active bits if not a single word. 1121return (isSingleWord() || getActiveBits() <= 64) && getZExtValue() <
RHS;
1124 /// Signed less than comparison 1126 /// Regards both *this and RHS as signed quantities and compares them for 1127 /// validity of the less-than relationship. 1129 /// \returns true if *this < RHS when both are considered signed. 1132 /// Signed less than comparison 1134 /// Regards both *this as a signed quantity and compares it with RHS for 1135 /// the validity of the less-than relationship. 1137 /// \returns true if *this < RHS when considered signed. 1139return (!isSingleWord() && getSignificantBits() > 64)
1141 : getSExtValue() <
RHS;
1144 /// Unsigned less or equal comparison 1146 /// Regards both *this and RHS as unsigned quantities and compares them for 1147 /// validity of the less-or-equal relationship. 1149 /// \returns true if *this <= RHS when both are considered unsigned. 1152 /// Unsigned less or equal comparison 1154 /// Regards both *this as an unsigned quantity and compares it with RHS for 1155 /// the validity of the less-or-equal relationship. 1157 /// \returns true if *this <= RHS when considered unsigned. 1160 /// Signed less or equal comparison 1162 /// Regards both *this and RHS as signed quantities and compares them for 1163 /// validity of the less-or-equal relationship. 1165 /// \returns true if *this <= RHS when both are considered signed. 1168 /// Signed less or equal comparison 1170 /// Regards both *this as a signed quantity and compares it with RHS for the 1171 /// validity of the less-or-equal relationship. 1173 /// \returns true if *this <= RHS when considered signed. 1176 /// Unsigned greater than comparison 1178 /// Regards both *this and RHS as unsigned quantities and compares them for 1179 /// the validity of the greater-than relationship. 1181 /// \returns true if *this > RHS when both are considered unsigned. 1184 /// Unsigned greater than comparison 1186 /// Regards both *this as an unsigned quantity and compares it with RHS for 1187 /// the validity of the greater-than relationship. 1189 /// \returns true if *this > RHS when considered unsigned. 1191// Only need to check active bits if not a single word. 1192return (!isSingleWord() && getActiveBits() > 64) || getZExtValue() >
RHS;
1195 /// Signed greater than comparison 1197 /// Regards both *this and RHS as signed quantities and compares them for the 1198 /// validity of the greater-than relationship. 1200 /// \returns true if *this > RHS when both are considered signed. 1203 /// Signed greater than comparison 1205 /// Regards both *this as a signed quantity and compares it with RHS for 1206 /// the validity of the greater-than relationship. 1208 /// \returns true if *this > RHS when considered signed. 1210return (!isSingleWord() && getSignificantBits() > 64)
1212 : getSExtValue() >
RHS;
1215 /// Unsigned greater or equal comparison 1217 /// Regards both *this and RHS as unsigned quantities and compares them for 1218 /// validity of the greater-or-equal relationship. 1220 /// \returns true if *this >= RHS when both are considered unsigned. 1223 /// Unsigned greater or equal comparison 1225 /// Regards both *this as an unsigned quantity and compares it with RHS for 1226 /// the validity of the greater-or-equal relationship. 1228 /// \returns true if *this >= RHS when considered unsigned. 1231 /// Signed greater or equal comparison 1233 /// Regards both *this and RHS as signed quantities and compares them for 1234 /// validity of the greater-or-equal relationship. 1236 /// \returns true if *this >= RHS when both are considered signed. 1239 /// Signed greater or equal comparison 1241 /// Regards both *this as a signed quantity and compares it with RHS for 1242 /// the validity of the greater-or-equal relationship. 1244 /// \returns true if *this >= RHS when considered signed. 1247 /// This operation tests if there are any pairs of corresponding bits 1248 /// between this APInt and RHS that are both set. 1252return (U.VAL &
RHS.U.VAL) != 0;
1253return intersectsSlowCase(
RHS);
1256 /// This operation checks that all bits set in this APInt are also set in RHS. 1260return (U.VAL & ~
RHS.U.VAL) == 0;
1261return isSubsetOfSlowCase(
RHS);
1265 /// \name Resizing Operators 1268 /// Truncate to new width. 1270 /// Truncate the APInt to a specified width. It is an error to specify a width 1271 /// that is greater than the current width. 1272APInt trunc(
unsigned width)
const;
1274 /// Truncate to new width with unsigned saturation. 1276 /// If the APInt, treated as unsigned integer, can be losslessly truncated to 1277 /// the new bitwidth, then return truncated APInt. Else, return max value. 1278APInt truncUSat(
unsigned width)
const;
1280 /// Truncate to new width with signed saturation. 1282 /// If this APInt, treated as signed integer, can be losslessly truncated to 1283 /// the new bitwidth, then return truncated APInt. Else, return either 1284 /// signed min value if the APInt was negative, or signed max value. 1285APInt truncSSat(
unsigned width)
const;
1287 /// Sign extend to a new width. 1289 /// This operation sign extends the APInt to a new width. If the high order 1290 /// bit is set, the fill on the left will be done with 1 bits, otherwise zero. 1291 /// It is an error to specify a width that is less than the 1293APInt sext(
unsigned width)
const;
1295 /// Zero extend to a new width. 1297 /// This operation zero extends the APInt to a new width. The high order bits 1298 /// are filled with 0 bits. It is an error to specify a width that is less 1299 /// than the current width. 1300APInt zext(
unsigned width)
const;
1302 /// Sign extend or truncate to width 1304 /// Make this APInt have the bit width given by \p width. The value is sign 1305 /// extended, truncated, or left alone to make it that width. 1306APInt sextOrTrunc(
unsigned width)
const;
1308 /// Zero extend or truncate to width 1310 /// Make this APInt have the bit width given by \p width. The value is zero 1311 /// extended, truncated, or left alone to make it that width. 1312APInt zextOrTrunc(
unsigned width)
const;
1315 /// \name Bit Manipulation Operators 1318 /// Set every bit to 1. 1321 U.VAL = WORDTYPE_MAX;
1323// Set all the bits in all the words. 1324 memset(U.pVal, -1, getNumWords() * APINT_WORD_SIZE);
1325// Clear the unused ones 1329 /// Set the given bit to 1 whose position is given as "bitPosition". 1332WordType Mask = maskBit(BitPosition);
1336 U.pVal[whichWord(BitPosition)] |= Mask;
1339 /// Set the sign bit to 1. 1342 /// Set a given bit to a given value. 1345 setBit(BitPosition);
1347 clearBit(BitPosition);
1350 /// Set the bits from loBit (inclusive) to hiBit (exclusive) to 1. 1351 /// This function handles "wrap" case when \p loBit >= \p hiBit, and calls 1352 /// setBits when \p loBit < \p hiBit. 1353 /// For \p loBit == \p hiBit wrap case, set every bit to 1. 1358 setBits(loBit, hiBit);
1365 /// Set the bits from loBit (inclusive) to hiBit (exclusive) to 1. 1366 /// This function handles case when \p loBit <= \p hiBit. 1370assert(loBit <= hiBit &&
"loBit greater than hiBit");
1373if (loBit < APINT_BITS_PER_WORD && hiBit <= APINT_BITS_PER_WORD) {
1374uint64_t mask = WORDTYPE_MAX >> (APINT_BITS_PER_WORD - (hiBit - loBit));
1381 setBitsSlowCase(loBit, hiBit);
1385 /// Set the top bits starting from loBit. 1388 /// Set the bottom loBits bits. 1391 /// Set the top hiBits bits. 1396 /// Set every bit to 0. 1401 memset(U.pVal, 0, getNumWords() * APINT_WORD_SIZE);
1404 /// Set a given bit to 0. 1406 /// Set the given bit to 0 whose position is given as "bitPosition". 1409WordType Mask = ~maskBit(BitPosition);
1413 U.pVal[whichWord(BitPosition)] &= Mask;
1416 /// Set bottom loBits bits to 0. 1423 /// Set top hiBits bits to 0. 1430 /// Set the sign bit to 0. 1433 /// Toggle every bit to its opposite value. 1435if (isSingleWord()) {
1436 U.VAL ^= WORDTYPE_MAX;
1439 flipAllBitsSlowCase();
1443 /// Toggles a given bit to its opposite value. 1445 /// Toggle a given bit to its opposite value whose position is given 1446 /// as "bitPosition". 1447void flipBit(
unsigned bitPosition);
1449 /// Negate this APInt in place. 1455 /// Insert the bits from a smaller APInt starting at bitPosition. 1456void insertBits(
constAPInt &SubBits,
unsigned bitPosition);
1457void insertBits(
uint64_t SubBits,
unsigned bitPosition,
unsigned numBits);
1459 /// Return an APInt with the extracted bits [bitPosition,bitPosition+numBits). 1461uint64_t extractBitsAsZExtValue(
unsigned numBits,
unsigned bitPosition)
const;
1464 /// \name Value Characterization Functions 1467 /// Return the number of bits in the APInt. 1470 /// Get the number of words. 1472 /// Here one word's bitwidth equals to that of uint64_t. 1474 /// \returns the number of words to hold the integer value of this APInt. 1477 /// Get the number of words. 1479 /// *NOTE* Here one word's bitwidth equals to that of uint64_t. 1481 /// \returns the number of words to hold the integer value with a given bit 1484return ((
uint64_t)
BitWidth + APINT_BITS_PER_WORD - 1) / APINT_BITS_PER_WORD;
1487 /// Compute the number of active bits in the value 1489 /// This function returns the number of active bits which is defined as the 1490 /// bit width minus the number of leading zeros. This is used in several 1491 /// computations to see how "wide" the value is. 1494 /// Compute the number of active words in the value of this APInt. 1496 /// This is used in conjunction with getActiveData to extract the raw value of 1499unsigned numActiveBits = getActiveBits();
1500return numActiveBits ? whichWord(numActiveBits - 1) + 1 : 1;
1503 /// Get the minimum bit size for this signed APInt 1505 /// Computes the minimum bit width for this APInt while considering it to be a 1506 /// signed (and probably negative) value. If the value is not negative, this 1507 /// function returns the same value as getActiveBits()+1. Otherwise, it 1508 /// returns the smallest bit width that will retain the negative value. For 1509 /// example, -1 can be written as 0b1 or 0xFFFFFFFFFF. 0b1 is shorter and so 1510 /// for -1, this function will always return 1. 1512returnBitWidth - getNumSignBits() + 1;
1515 /// Get zero extended value 1517 /// This method attempts to return the value of this APInt as a zero extended 1518 /// uint64_t. The bitwidth must be <= 64 or the value must fit within a 1519 /// uint64_t. Otherwise an assertion will result. 1523assert(getActiveBits() <= 64 &&
"Too many bits for uint64_t");
1527 /// Get zero extended value if possible 1529 /// This method attempts to return the value of this APInt as a zero extended 1530 /// uint64_t. The bitwidth must be <= 64 or the value must fit within a 1531 /// uint64_t. Otherwise no value is returned. 1533return (getActiveBits() <= 64) ? std::optional<uint64_t>(getZExtValue())
1537 /// Get sign extended value 1539 /// This method attempts to return the value of this APInt as a sign extended 1540 /// int64_t. The bit width must be <= 64 or the value must fit within an 1541 /// int64_t. Otherwise an assertion will result. 1545assert(getSignificantBits() <= 64 &&
"Too many bits for int64_t");
1546return int64_t(U.pVal[0]);
1549 /// Get sign extended value if possible 1551 /// This method attempts to return the value of this APInt as a sign extended 1552 /// int64_t. The bitwidth must be <= 64 or the value must fit within an 1553 /// int64_t. Otherwise no value is returned. 1555return (getSignificantBits() <= 64) ? std::optional<int64_t>(getSExtValue())
1559 /// Get bits required for string value. 1561 /// This method determines how many bits are required to hold the APInt 1562 /// equivalent of the string given by \p str. 1565 /// Get the bits that are sufficient to represent the string value. This may 1566 /// over estimate the amount of bits required, but it does not require 1567 /// parsing the value in the string. 1570 /// The APInt version of std::countl_zero. 1572 /// It counts the number of zeros from the most significant bit to the first 1575 /// \returns BitWidth if the value is zero, otherwise returns the number of 1576 /// zeros from the most significant bit to the first one bits. 1578if (isSingleWord()) {
1579unsigned unusedBits = APINT_BITS_PER_WORD -
BitWidth;
1582return countLeadingZerosSlowCase();
1587 /// Count the number of leading one bits. 1589 /// This function is an APInt version of std::countl_one. It counts the number 1590 /// of ones from the most significant bit to the first zero bit. 1592 /// \returns 0 if the high order bit is not set, otherwise returns the number 1593 /// of 1 bits from the most significant to the least 1595if (isSingleWord()) {
1600return countLeadingOnesSlowCase();
1605 /// Computes the number of leading bits of this APInt that are equal to its 1611 /// Count the number of trailing zero bits. 1613 /// This function is an APInt version of std::countr_zero. It counts the 1614 /// number of zeros from the least significant bit to the first set bit. 1616 /// \returns BitWidth if the value is zero, otherwise returns the number of 1617 /// zeros from the least significant bit to the first one bit. 1619if (isSingleWord()) {
1623return countTrailingZerosSlowCase();
1628 /// Count the number of trailing one bits. 1630 /// This function is an APInt version of std::countr_one. It counts the number 1631 /// of ones from the least significant bit to the first zero bit. 1633 /// \returns BitWidth if the value is all ones, otherwise returns the number 1634 /// of ones from the least significant bit to the first zero bit. 1638return countTrailingOnesSlowCase();
1643 /// Count the number of bits set. 1645 /// This function is an APInt version of std::popcount. It counts the number 1646 /// of 1 bits in the APInt value. 1648 /// \returns 0 if the value is zero, otherwise returns the number of set bits. 1652return countPopulationSlowCase();
1656 /// \name Conversion Functions 1660 /// Converts an APInt to a string and append it to Str. Str is commonly a 1661 /// SmallString. If Radix > 10, UpperCase determine the case of letter 1664bool formatAsCLiteral =
false,
bool UpperCase =
true,
1665bool InsertSeparators =
false)
const;
1667 /// Considers the APInt to be unsigned and converts it into a string in the 1668 /// radix given. The radix can be 2, 8, 10 16, or 36. 1673 /// Considers the APInt to be signed and converts it into a string in the 1674 /// radix given. The radix can be 2, 8, 10, 16, or 36. 1679 /// \returns a byte-swapped representation of this APInt Value. 1680APInt byteSwap()
const;
1682 /// \returns the value with the bit representation reversed of this APInt 1686 /// Converts this APInt to a double value. 1687double roundToDouble(
boolisSigned)
const;
1689 /// Converts this unsigned APInt to a double value. 1692 /// Converts this signed APInt to a double value. 1695 /// Converts APInt bits to a double 1697 /// The conversion does not do a translation from integer to double, it just 1698 /// re-interprets the bits as a double. Note that it is valid to do this on 1699 /// any bit width. Exactly 64 bits will be translated. 1702#ifdef HAS_IEE754_FLOAT128 1703 float128 bitsToQuad()
const{
1704 __uint128_t ul = ((__uint128_t)U.pVal[1] << 64) + U.pVal[0];
1705return llvm::bit_cast<float128>(ul);
1709 /// Converts APInt bits to a float 1711 /// The conversion does not do a translation from integer to float, it just 1712 /// re-interprets the bits as a float. Note that it is valid to do this on 1713 /// any bit width. Exactly 32 bits will be translated. 1715return llvm::bit_cast<float>(
static_cast<uint32_t>(getWord(0)));
1718 /// Converts a double to APInt bits. 1720 /// The conversion does not do a translation from double to integer, it just 1721 /// re-interprets the bits of the double. 1723returnAPInt(
sizeof(
double) * CHAR_BIT, llvm::bit_cast<uint64_t>(V));
1726 /// Converts a float to APInt bits. 1728 /// The conversion does not do a translation from float to integer, it just 1729 /// re-interprets the bits of the float. 1731returnAPInt(
sizeof(
float) * CHAR_BIT, llvm::bit_cast<uint32_t>(V));
1735 /// \name Mathematics Operations 1738 /// \returns the floor log base 2 of this APInt. 1741 /// \returns the ceil log base 2 of this APInt. 1748 /// \returns the nearest log base 2 of this APInt. Ties round up. 1750 /// NOTE: When we have a BitWidth of 1, we define: 1752 /// log2(0) = UINT32_MAX 1755 /// to get around any mathematical concerns resulting from 1756 /// referencing 2 in a space where 2 does no exist. 1757unsigned nearestLogBase2()
const;
1759 /// \returns the log base 2 of this APInt if its an exact power of two, -1 1767 /// Compute the square root. 1770 /// Get the absolute value. If *this is < 0 then return -(*this), otherwise 1771 /// *this. Note that the "most negative" signed number (e.g. -128 for 8 bit 1772 /// wide APInt) is unchanged due to how negation works. 1779 /// \returns the multiplicative inverse of an odd APInt modulo 2^BitWidth. 1780APInt multiplicativeInverse()
const;
1783 /// \name Building-block Operations for APInt and APFloat 1786// These building block operations operate on a representation of arbitrary 1787// precision, two's-complement, bignum integer values. They should be 1788// sufficient to implement APInt and APFloat bignum requirements. Inputs are 1789// generally a pointer to the base of an array of integer parts, representing 1790// an unsigned bignum, and a count of how many parts there are. 1792 /// Sets the least significant part of a bignum to the input value, and zeroes 1793 /// out higher parts. 1794staticvoid tcSet(WordType *, WordType,
unsigned);
1796 /// Assign one bignum to another. 1797staticvoid tcAssign(WordType *,
const WordType *,
unsigned);
1799 /// Returns true if a bignum is zero, false otherwise. 1800staticbool tcIsZero(
const WordType *,
unsigned);
1802 /// Extract the given bit of a bignum; returns 0 or 1. Zero-based. 1803staticint tcExtractBit(
const WordType *,
unsigned bit);
1805 /// Copy the bit vector of width srcBITS from SRC, starting at bit srcLSB, to 1806 /// DST, of dstCOUNT parts, such that the bit srcLSB becomes the least 1807 /// significant bit of DST. All high bits above srcBITS in DST are 1809staticvoid tcExtract(WordType *,
unsigned dstCount,
const WordType *,
1810unsigned srcBits,
unsigned srcLSB);
1812 /// Set the given bit of a bignum. Zero-based. 1813staticvoid tcSetBit(WordType *,
unsigned bit);
1815 /// Clear the given bit of a bignum. Zero-based. 1816staticvoid tcClearBit(WordType *,
unsigned bit);
1818 /// Returns the bit number of the least or most significant set bit of a 1819 /// number. If the input number has no bits set -1U is returned. 1820staticunsigned tcLSB(
const WordType *,
unsigned n);
1821staticunsigned tcMSB(
const WordType *parts,
unsigned n);
1823 /// Negate a bignum in-place. 1824staticvoid tcNegate(WordType *,
unsigned);
1826 /// DST += RHS + CARRY where CARRY is zero or one. Returns the carry flag. 1827static WordType tcAdd(WordType *,
const WordType *, WordType carry,
unsigned);
1828 /// DST += RHS. Returns the carry flag. 1829static WordType tcAddPart(WordType *, WordType,
unsigned);
1831 /// DST -= RHS + CARRY where CARRY is zero or one. Returns the carry flag. 1832static WordType tcSubtract(WordType *,
const WordType *, WordType carry,
1834 /// DST -= RHS. Returns the carry flag. 1835static WordType tcSubtractPart(WordType *, WordType,
unsigned);
1837 /// DST += SRC * MULTIPLIER + PART if add is true 1838 /// DST = SRC * MULTIPLIER + PART if add is false 1840 /// Requires 0 <= DSTPARTS <= SRCPARTS + 1. If DST overlaps SRC they must 1841 /// start at the same point, i.e. DST == SRC. 1843 /// If DSTPARTS == SRC_PARTS + 1 no overflow occurs and zero is returned. 1844 /// Otherwise DST is filled with the least significant DSTPARTS parts of the 1845 /// result, and if all of the omitted higher parts were zero return zero, 1846 /// otherwise overflow occurred and return one. 1847staticint tcMultiplyPart(WordType *dst,
const WordType *src,
1848 WordType multiplier, WordType carry,
1849unsigned srcParts,
unsigned dstParts,
bool add);
1851 /// DST = LHS * RHS, where DST has the same width as the operands and is 1852 /// filled with the least significant parts of the result. Returns one if 1853 /// overflow occurred, otherwise zero. DST must be disjoint from both 1855staticint tcMultiply(WordType *,
const WordType *,
const WordType *,
1858 /// DST = LHS * RHS, where DST has width the sum of the widths of the 1859 /// operands. No overflow occurs. DST must be disjoint from both operands. 1860staticvoid tcFullMultiply(WordType *,
const WordType *,
const WordType *,
1863 /// If RHS is zero LHS and REMAINDER are left unchanged, return one. 1864 /// Otherwise set LHS to LHS / RHS with the fractional part discarded, set 1865 /// REMAINDER to the remainder, return zero. i.e. 1867 /// OLD_LHS = RHS * LHS + REMAINDER 1869 /// SCRATCH is a bignum of the same size as the operands and result for use by 1870 /// the routine; its contents need not be initialized and are destroyed. LHS, 1871 /// REMAINDER and SCRATCH must be distinct. 1872staticint tcDivide(WordType *lhs,
const WordType *rhs, WordType *remainder,
1873 WordType *scratch,
unsigned parts);
1875 /// Shift a bignum left Count bits. Shifted in bits are zero. There are no 1876 /// restrictions on Count. 1877staticvoid tcShiftLeft(WordType *,
unsigned Words,
unsigned Count);
1879 /// Shift a bignum right Count bits. Shifted in bits are zero. There are no 1880 /// restrictions on Count. 1881staticvoid tcShiftRight(WordType *,
unsigned Words,
unsigned Count);
1883 /// Comparison (unsigned) of two bignums. 1884staticint tcCompare(
const WordType *,
const WordType *,
unsigned);
1886 /// Increment a bignum in-place. Return the carry flag. 1888return tcAddPart(dst, 1, parts);
1891 /// Decrement a bignum in-place. Return the borrow flag. 1893return tcSubtractPart(dst, 1, parts);
1896 /// Used to insert APInt objects, or objects that contain APInt objects, into 1903 /// Returns whether this instance allocated memory. 1907 /// This union is used to store the integer value. When the 1908 /// integer bit-width <= 64, it uses VAL, otherwise it uses pVal. 1914unsignedBitWidth = 1;
///< The number of bits in this APInt. 1919// Make DynamicAPInt a friend so it can access BitWidth directly. 1922 /// This constructor is used only internally for speed of construction of 1923 /// temporaries. It is unsafe since it takes ownership of the pointer, so it 1927 /// Determine which word a bit is in. 1929 /// \returns the word position for the specified bit position. 1930staticunsigned whichWord(
unsigned bitPosition) {
1931return bitPosition / APINT_BITS_PER_WORD;
1934 /// Determine which bit in a word the specified bit position is in. 1935staticunsigned whichBit(
unsigned bitPosition) {
1936return bitPosition % APINT_BITS_PER_WORD;
1939 /// Get a single bit mask. 1941 /// \returns a uint64_t with only bit at "whichBit(bitPosition)" set 1942 /// This method generates and returns a uint64_t (word) mask for a single 1943 /// bit at a specific bit position. This is used to mask the bit in the 1944 /// corresponding word. 1945staticuint64_t maskBit(
unsigned bitPosition) {
1946return 1ULL << whichBit(bitPosition);
1949 /// Clear unused high order bits 1951 /// This method is used internally to clear the top "N" bits in the high order 1952 /// word that are not used by the APInt. This is needed after the most 1953 /// significant word is assigned a value to ensure that those bits are 1956// Compute how many bits are used in the final word. 1957unsigned WordBits = ((
BitWidth - 1) % APINT_BITS_PER_WORD) + 1;
1959// Mask out the high bits. 1960uint64_tmask = WORDTYPE_MAX >> (APINT_BITS_PER_WORD - WordBits);
1967U.pVal[getNumWords() - 1] &=
mask;
1971 /// Get the word corresponding to a bit position 1972 /// \returns the corresponding word for the specified bit position. 1973uint64_t getWord(
unsigned bitPosition)
const{
1974return isSingleWord() ?
U.VAL :
U.pVal[whichWord(bitPosition)];
1977 /// Utility method to change the bit width of this APInt to new bit width, 1978 /// allocating and/or deallocating as necessary. There is no guarantee on the 1979 /// value of any bits upon return. Caller should populate the bits after. 1980void reallocate(
unsigned NewBitWidth);
1982 /// Convert a char array into an APInt 1984 /// \param radix 2, 8, 10, 16, or 36 1985 /// Converts a string into a number. The string must be non-empty 1986 /// and well-formed as a number of the given base. The bit-width 1987 /// must be sufficient to hold the result. 1989 /// This is used by the constructors that take string arguments. 1991 /// StringRef::getAsInteger is superficially similar but (1) does 1992 /// not assume that the string is well-formed and (2) grows the 1993 /// result to hold the input. 1996 /// An internal division function for dividing APInts. 1998 /// This is used by the toString method to divide by the radix. It simply 1999 /// provides a more convenient form of divide for internal use since KnuthDiv 2000 /// has specific constraints on its inputs. If those constraints are not met 2001 /// then it provides a simpler form of divide. 2002staticvoid divide(
const WordType *
LHS,
unsigned lhsWords,
2003const WordType *
RHS,
unsigned rhsWords, WordType *Quotient,
2004 WordType *Remainder);
2006 /// out-of-line slow case for inline constructor 2009 /// shared code between two array constructors 2010void initFromArray(ArrayRef<uint64_t> array);
2012 /// out-of-line slow case for inline copy constructor 2013void initSlowCase(
const APInt &that);
2015 /// out-of-line slow case for shl 2016void shlSlowCase(
unsigned ShiftAmt);
2018 /// out-of-line slow case for lshr. 2019void lshrSlowCase(
unsigned ShiftAmt);
2021 /// out-of-line slow case for ashr. 2022void ashrSlowCase(
unsigned ShiftAmt);
2024 /// out-of-line slow case for operator= 2025void assignSlowCase(
const APInt &
RHS);
2027 /// out-of-line slow case for operator== 2030 /// out-of-line slow case for countLeadingZeros 2033 /// out-of-line slow case for countLeadingOnes. 2036 /// out-of-line slow case for countTrailingZeros. 2039 /// out-of-line slow case for countTrailingOnes 2042 /// out-of-line slow case for countPopulation 2045 /// out-of-line slow case for intersects. 2048 /// out-of-line slow case for isSubsetOf. 2051 /// out-of-line slow case for setBits. 2052void setBitsSlowCase(
unsigned loBit,
unsigned hiBit);
2054 /// out-of-line slow case for flipAllBits. 2055void flipAllBitsSlowCase();
2057 /// out-of-line slow case for concat. 2058 APInt concatSlowCase(
const APInt &NewLSB)
const;
2060 /// out-of-line slow case for operator&=. 2061void andAssignSlowCase(
const APInt &
RHS);
2063 /// out-of-line slow case for operator|=. 2064void orAssignSlowCase(
const APInt &
RHS);
2066 /// out-of-line slow case for operator^=. 2067void xorAssignSlowCase(
const APInt &
RHS);
2069 /// Unsigned comparison. Returns -1, 0, or 1 if this APInt is less than, equal 2070 /// to, or greater than RHS. 2073 /// Signed comparison. Returns -1, 0, or 1 if this APInt is less than, equal 2074 /// to, or greater than RHS. 2084/// Unary bitwise complement operator. 2086/// \returns an APInt that is the bitwise complement of \p v. 2216/// Determine the smaller of two APInts considered to be signed. 2218returnA.slt(
B) ?
A :
B;
2221/// Determine the larger of two APInts considered to be signed. 2223returnA.sgt(
B) ?
A :
B;
2226/// Determine the smaller of two APInts considered to be unsigned. 2228returnA.ult(
B) ?
A :
B;
2231/// Determine the larger of two APInts considered to be unsigned. 2233returnA.ugt(
B) ?
A :
B;
2236/// Determine the absolute difference of two APInts considered to be signed. 2238returnA.sge(
B) ? (
A -
B) : (
B -
A);
2241/// Determine the absolute difference of two APInts considered to be unsigned. 2243returnA.uge(
B) ? (
A -
B) : (
B -
A);
2246/// Compute the floor of the signed average of C1 and C2 2249/// Compute the floor of the unsigned average of C1 and C2 2252/// Compute the ceil of the signed average of C1 and C2 2255/// Compute the ceil of the unsigned average of C1 and C2 2258/// Performs (2*N)-bit multiplication on sign-extended operands. 2259/// Returns the high N bits of the multiplication result. 2262/// Performs (2*N)-bit multiplication on zero-extended operands. 2263/// Returns the high N bits of the multiplication result. 2266/// Compute X^N for N>=0. 2267/// 0^0 is supported and returns 1. 2270/// Compute GCD of two unsigned APInt values. 2272/// This function returns the greatest common divisor of the two APInt values 2273/// using Stein's algorithm. 2275/// \returns the greatest common divisor of A and B. 2278/// Converts the given APInt to a double value. 2280/// Treats the APInt as an unsigned value for conversion purposes. 2285/// Converts the given APInt to a double value. 2287/// Treats the APInt as a signed value for conversion purposes. 2292/// Converts the given APInt to a float value. 2297/// Converts the given APInt to a float value. 2299/// Treats the APInt as a signed value for conversion purposes. 2304/// Converts the given double value into a APInt. 2306/// This function convert a double value to an APInt value. 2307APInt RoundDoubleToAPInt(
double Double,
unsigned width);
2309/// Converts a float value into a APInt. 2311/// Converts a float value into an APInt value. 2316/// Return A unsign-divided by B, rounded by the given rounding mode. 2319/// Return A sign-divided by B, rounded by the given rounding mode. 2322/// Let q(n) = An^2 + Bn + C, and BW = bit width of the value range 2323/// (e.g. 32 for i32). 2324/// This function finds the smallest number n, such that 2325/// (a) n >= 0 and q(n) = 0, or 2326/// (b) n >= 1 and q(n-1) and q(n), when evaluated in the set of all 2327/// integers, belong to two different intervals [Rk, Rk+R), 2328/// where R = 2^BW, and k is an integer. 2329/// The idea here is to find when q(n) "overflows" 2^BW, while at the 2330/// same time "allowing" subtraction. In unsigned modulo arithmetic a 2331/// subtraction (treated as addition of negated numbers) would always 2332/// count as an overflow, but here we want to allow values to decrease 2333/// and increase as long as they are within the same interval. 2334/// Specifically, adding of two negative numbers should not cause an 2335/// overflow (as long as the magnitude does not exceed the bit width). 2336/// On the other hand, given a positive number, adding a negative 2337/// number to it can give a negative result, which would cause the 2338/// value to go from [-2^BW, 0) to [0, 2^BW). In that sense, zero is 2339/// treated as a special case of an overflow. 2341/// This function returns std::nullopt if after finding k that minimizes the 2342/// positive solution to q(n) = kR, both solutions are contained between 2343/// two consecutive integers. 2345/// There are cases where q(n) > T, and q(n+1) < T (assuming evaluation 2346/// in arithmetic modulo 2^BW, and treating the values as signed) by the 2347/// virtue of *signed* overflow. This function will *not* find such an n, 2348/// however it may find a value of n satisfying the inequalities due to 2349/// an *unsigned* overflow (if the values are treated as unsigned). 2350/// To find a solution for a signed overflow, treat it as a problem of 2351/// finding an unsigned overflow with a range with of BW-1. 2353/// The returned value may have a different bit width from the input 2356unsigned RangeWidth);
2358/// Compare two values, and if they are different, return the position of the 2359/// most significant bit that is different in the values. 2360std::optional<unsigned> GetMostSignificantDifferentBit(
constAPInt &
A,
2363/// Splat/Merge neighboring bits to widen/narrow the bitmask represented 2364/// by \param A to \param NewBitWidth bits. 2366/// MatchAnyBits: (Default) 2367/// e.g. ScaleBitMask(0b0101, 8) -> 0b00110011 2368/// e.g. ScaleBitMask(0b00011011, 4) -> 0b0111 2371/// e.g. ScaleBitMask(0b0101, 8) -> 0b00110011 2372/// e.g. ScaleBitMask(0b00011011, 4) -> 0b0001 2373/// A.getBitwidth() or NewBitWidth must be a whole multiples of the other. 2374APInt ScaleBitMask(
constAPInt &
A,
unsigned NewBitWidth,
2375bool MatchAllBits =
false);
2376}
// namespace APIntOps 2378// See friend declaration above. This additional declaration is required in 2379// order to compile LLVM with IBM xlC compiler. 2380hash_code hash_value(
const APInt &Arg);
2382/// StoreIntToMemory - Fills the StoreBytes bytes of memory starting from Dst 2383/// with the integer held in IntVal. 2384void StoreIntToMemory(
const APInt &IntVal,
uint8_t *Dst,
unsigned StoreBytes);
2386/// LoadIntFromMemory - Loads the integer stored in the LoadBytes bytes starting 2387/// from Src into IntVal, which is assumed to be wide enough and to hold zero. 2388void LoadIntFromMemory(APInt &IntVal,
constuint8_t *Src,
unsigned LoadBytes);
2390/// Provide DenseMapInfo for APInt. 2407returnLHS.getBitWidth() ==
RHS.getBitWidth() &&
LHS ==
RHS;
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
raw_ostream & operator<<(raw_ostream &OS, const binary_le_impl< value_type > &BLE)
#define LLVM_UNLIKELY(EXPR)
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
static bool isSigned(unsigned int Opcode)
static KnownBits extractBits(unsigned BitWidth, const KnownBits &SrcOpKnown, const KnownBits &OffsetKnown, const KnownBits &WidthKnown)
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
static bool isAligned(const Value *Base, Align Alignment, const DataLayout &DL)
static bool isSplat(Value *V)
Return true if V is a splat of a value (which is used when multiplying a matrix with a scalar).
static const char * toString(MIToken::TokenKind TokenKind)
static uint64_t clearUnusedBits(uint64_t Val, unsigned Size)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static uint64_t umul_ov(uint64_t i, uint64_t j, bool &Overflow)
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type.
Class for arbitrary precision integers.
std::optional< uint64_t > tryZExtValue() const
Get zero extended value if possible.
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
bool slt(int64_t RHS) const
Signed less than comparison.
void clearBit(unsigned BitPosition)
Set a given bit to 0.
APInt relativeLShr(int RelativeShift) const
relative logical shift right
bool isNegatedPowerOf2() const
Check if this APInt's negated value is a power of two greater than zero.
APInt zext(unsigned width) const
Zero extend to a new width.
static APInt getSignMask(unsigned BitWidth)
Get the SignMask for a specific bit width.
bool isMinSignedValue() const
Determine if this is the smallest signed value.
APInt operator--(int)
Postfix decrement operator.
uint64_t getZExtValue() const
Get zero extended value.
uint64_t * pVal
Used to store the >64 bits integer value.
void setHighBits(unsigned hiBits)
Set the top hiBits bits.
unsigned popcount() const
Count the number of bits set.
void setBitsFrom(unsigned loBit)
Set the top bits starting from loBit.
APInt operator<<(const APInt &Bits) const
Left logical shift operator.
APInt operator<<(unsigned Bits) const
Left logical shift operator.
unsigned getActiveBits() const
Compute the number of active bits in the value.
bool sgt(int64_t RHS) const
Signed greater than comparison.
static APInt getMaxValue(unsigned numBits)
Gets maximum unsigned value of APInt for specific bit width.
void setBit(unsigned BitPosition)
Set the given bit to 1 whose position is given as "bitPosition".
bool operator[](unsigned bitPosition) const
Array-indexing support.
bool operator!=(const APInt &RHS) const
Inequality operator.
void toStringUnsigned(SmallVectorImpl< char > &Str, unsigned Radix=10) const
Considers the APInt to be unsigned and converts it into a string in the radix given.
APInt & operator&=(const APInt &RHS)
Bitwise AND assignment operator.
APInt abs() const
Get the absolute value.
unsigned ceilLogBase2() const
unsigned countLeadingOnes() const
APInt relativeLShl(int RelativeShift) const
relative logical shift left
APInt & operator=(const APInt &RHS)
Copy assignment operator.
bool sgt(const APInt &RHS) const
Signed greater than comparison.
bool isAllOnes() const
Determine if all bits are set. This is true for zero-width values.
APInt(unsigned numBits, uint64_t val, bool isSigned=false, bool implicitTrunc=false)
Create a new APInt of numBits width, initialized as val.
APInt & operator^=(uint64_t RHS)
Bitwise XOR assignment operator.
bool ugt(const APInt &RHS) const
Unsigned greater than comparison.
static APInt getBitsSet(unsigned numBits, unsigned loBit, unsigned hiBit)
Get a value with a block of bits set.
bool isZero() const
Determine if this value is zero, i.e. all bits are clear.
APInt & operator|=(uint64_t RHS)
Bitwise OR assignment operator.
bool isSignMask() const
Check if the APInt's value is returned by getSignMask.
static APInt floatToBits(float V)
Converts a float to APInt bits.
void setSignBit()
Set the sign bit to 1.
unsigned getBitWidth() const
Return the number of bits in the APInt.
bool sle(uint64_t RHS) const
Signed less or equal comparison.
bool ult(const APInt &RHS) const
Unsigned less than comparison.
bool uge(uint64_t RHS) const
Unsigned greater or equal comparison.
bool operator!() const
Logical negation operation on this APInt returns true if zero, like normal integers.
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
APInt & operator=(uint64_t RHS)
Assignment operator.
APInt relativeAShr(int RelativeShift) const
relative arithmetic shift right
friend hash_code hash_value(const APInt &Arg)
Overload to compute a hash_code for an APInt value.
APInt(const APInt &that)
Copy Constructor.
APInt & operator|=(const APInt &RHS)
Bitwise OR assignment operator.
bool isSingleWord() const
Determine if this APInt just has one word to store value.
bool operator==(uint64_t Val) const
Equality operator.
APInt operator++(int)
Postfix increment operator.
unsigned getNumWords() const
Get the number of words.
bool isMinValue() const
Determine if this is the smallest unsigned value.
APInt ashr(const APInt &ShiftAmt) const
Arithmetic right-shift function.
APInt()
Default constructor that creates an APInt with a 1-bit zero value.
static APInt getMinValue(unsigned numBits)
Gets minimum unsigned value of APInt for a specific bit width.
APInt(APInt &&that)
Move Constructor.
bool isNegative() const
Determine sign of this APInt.
APInt concat(const APInt &NewLSB) const
Concatenate the bits from "NewLSB" onto the bottom of *this.
bool intersects(const APInt &RHS) const
This operation tests if there are any pairs of corresponding bits between this APInt and RHS that are...
bool eq(const APInt &RHS) const
Equality comparison.
int32_t exactLogBase2() const
APInt & operator<<=(unsigned ShiftAmt)
Left-shift assignment function.
double roundToDouble() const
Converts this unsigned APInt to a double value.
void clearAllBits()
Set every bit to 0.
APInt relativeAShl(int RelativeShift) const
relative arithmetic shift left
void ashrInPlace(unsigned ShiftAmt)
Arithmetic right-shift this APInt by ShiftAmt in place.
bool sle(const APInt &RHS) const
Signed less or equal comparison.
void negate()
Negate this APInt in place.
static WordType tcDecrement(WordType *dst, unsigned parts)
Decrement a bignum in-place. Return the borrow flag.
unsigned countr_zero() const
Count the number of trailing zero bits.
bool isSignedIntN(unsigned N) const
Check if this APInt has an N-bits signed integer value.
unsigned getNumSignBits() const
Computes the number of leading bits of this APInt that are equal to its sign bit.
bool isOneBitSet(unsigned BitNo) const
Determine if this APInt Value only has the specified bit set.
unsigned countl_zero() const
The APInt version of std::countl_zero.
bool operator==(const APInt &RHS) const
Equality operator.
APInt shl(const APInt &ShiftAmt) const
Left-shift function.
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
bool isShiftedMask(unsigned &MaskIdx, unsigned &MaskLen) const
Return true if this APInt value contains a non-empty sequence of ones with the remainder zero.
void setBitsWithWrap(unsigned loBit, unsigned hiBit)
Set the bits from loBit (inclusive) to hiBit (exclusive) to 1.
APInt lshr(const APInt &ShiftAmt) const
Logical right-shift function.
bool isNonPositive() const
Determine if this APInt Value is non-positive (<= 0).
unsigned countTrailingZeros() const
unsigned getSignificantBits() const
Get the minimum bit size for this signed APInt.
unsigned countLeadingZeros() const
bool isStrictlyPositive() const
Determine if this APInt Value is positive.
void flipAllBits()
Toggle every bit to its opposite value.
static unsigned getNumWords(unsigned BitWidth)
Get the number of words.
bool needsCleanup() const
Returns whether this instance allocated memory.
unsigned countl_one() const
Count the number of leading one bits.
void clearLowBits(unsigned loBits)
Set bottom loBits bits to 0.
unsigned logBase2() const
static APInt getZeroWidth()
Return an APInt zero bits wide.
double signedRoundToDouble() const
Converts this signed APInt to a double value.
bool isShiftedMask() const
Return true if this APInt value contains a non-empty sequence of ones with the remainder zero.
float bitsToFloat() const
Converts APInt bits to a float.
uint64_t getLimitedValue(uint64_t Limit=UINT64_MAX) const
If this value is smaller than the specified limit, return it, otherwise return the limit value.
bool ule(uint64_t RHS) const
Unsigned less or equal comparison.
APInt ashr(unsigned ShiftAmt) const
Arithmetic right-shift function.
void setAllBits()
Set every bit to 1.
uint64_t VAL
Used to store the <= 64 bits integer value.
bool ugt(uint64_t RHS) const
Unsigned greater than comparison.
bool sge(int64_t RHS) const
Signed greater or equal comparison.
bool getBoolValue() const
Convert APInt to a boolean value.
static APInt doubleToBits(double V)
Converts a double to APInt bits.
bool isMask(unsigned numBits) const
APInt & operator=(APInt &&that)
Move assignment operator.
static WordType tcIncrement(WordType *dst, unsigned parts)
Increment a bignum in-place. Return the carry flag.
APInt & operator^=(const APInt &RHS)
Bitwise XOR assignment operator.
bool isMaxSignedValue() const
Determine if this is the largest signed value.
bool isNonNegative() const
Determine if this APInt Value is non-negative (>= 0)
bool ule(const APInt &RHS) const
Unsigned less or equal comparison.
void setBits(unsigned loBit, unsigned hiBit)
Set the bits from loBit (inclusive) to hiBit (exclusive) to 1.
APInt shl(unsigned shiftAmt) const
Left-shift function.
double bitsToDouble() const
Converts APInt bits to a double.
bool isSubsetOf(const APInt &RHS) const
This operation checks that all bits set in this APInt are also set in RHS.
bool isPowerOf2() const
Check if this APInt's value is a power of two greater than zero.
unsigned getActiveWords() const
Compute the number of active words in the value of this APInt.
bool ne(const APInt &RHS) const
Inequality comparison.
static bool isSameValue(const APInt &I1, const APInt &I2)
Determine if two APInts have the same value, after zero-extending one of them (if needed!...
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Constructs an APInt value that has the bottom loBitsSet bits set.
bool isSignBitSet() const
Determine if sign bit of this APInt is set.
const uint64_t * getRawData() const
This function returns a pointer to the internal storage of the APInt.
bool slt(const APInt &RHS) const
Signed less than comparison.
static APInt getHighBitsSet(unsigned numBits, unsigned hiBitsSet)
Constructs an APInt value that has the top hiBitsSet bits set.
static APInt getZero(unsigned numBits)
Get the '0' value for the specified bit-width.
void setLowBits(unsigned loBits)
Set the bottom loBits bits.
bool isIntN(unsigned N) const
Check if this APInt has an N-bits unsigned integer value.
unsigned countTrailingOnes() const
bool sge(const APInt &RHS) const
Signed greater or equal comparison.
std::optional< int64_t > trySExtValue() const
Get sign extended value if possible.
APInt & operator&=(uint64_t RHS)
Bitwise AND assignment operator.
double roundToDouble(bool isSigned) const
Converts this APInt to a double value.
bool isOne() const
Determine if this is a value of 1.
static APInt getBitsSetFrom(unsigned numBits, unsigned loBit)
Constructs an APInt value that has a contiguous range of bits set.
static APInt getOneBitSet(unsigned numBits, unsigned BitNo)
Return an APInt with exactly one bit set in the result.
void clearHighBits(unsigned hiBits)
Set top hiBits bits to 0.
int64_t getSExtValue() const
Get sign extended value.
void lshrInPlace(unsigned ShiftAmt)
Logical right-shift this APInt by ShiftAmt in place.
APInt lshr(unsigned shiftAmt) const
Logical right-shift function.
unsigned countr_one() const
Count the number of trailing one bits.
static APInt getBitsSetWithWrap(unsigned numBits, unsigned loBit, unsigned hiBit)
Wrap version of getBitsSet.
bool isSignBitClear() const
Determine if sign bit of this APInt is clear.
bool uge(const APInt &RHS) const
Unsigned greater or equal comparison.
void setBitVal(unsigned BitPosition, bool BitValue)
Set a given bit to a given value.
void clearSignBit()
Set the sign bit to 0.
bool isMaxValue() const
Determine if this is the largest unsigned value.
void toStringSigned(SmallVectorImpl< char > &Str, unsigned Radix=10) const
Considers the APInt to be signed and converts it into a string in the radix given.
bool ult(uint64_t RHS) const
Unsigned less than comparison.
bool operator!=(uint64_t Val) const
Inequality operator.
An arbitrary precision integer that knows its signedness.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
This class provides support for dynamic arbitrary-precision arithmetic.
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
StringRef - Represent a constant reference to a string, i.e.
An opaque object representing a hash code.
This class implements an extremely fast bulk output stream that can only output to a stream.
std::error_code fromString(StringRef String, Metadata &HSAMetadata)
Converts String to HSAMetadata.
float RoundAPIntToFloat(const APInt &APIVal)
Converts the given APInt to a float value.
const APInt abdu(const APInt &A, const APInt &B)
Determine the absolute difference of two APInts considered to be unsigned.
const APInt abds(const APInt &A, const APInt &B)
Determine the absolute difference of two APInts considered to be signed.
double RoundAPIntToDouble(const APInt &APIVal)
Converts the given APInt to a double value.
const APInt & smin(const APInt &A, const APInt &B)
Determine the smaller of two APInts considered to be signed.
const APInt & smax(const APInt &A, const APInt &B)
Determine the larger of two APInts considered to be signed.
const APInt & umin(const APInt &A, const APInt &B)
Determine the smaller of two APInts considered to be unsigned.
APInt RoundFloatToAPInt(float Float, unsigned width)
Converts a float value into a APInt.
APInt RoundDoubleToAPInt(double Double, unsigned width)
Converts the given double value into a APInt.
double RoundSignedAPIntToDouble(const APInt &APIVal)
Converts the given APInt to a double value.
float RoundSignedAPIntToFloat(const APInt &APIVal)
Converts the given APInt to a float value.
const APInt & umax(const APInt &A, const APInt &B)
Determine the larger of two APInts considered to be unsigned.
This is an optimization pass for GlobalISel generic memory operations.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
constexpr T rotr(T V, int R)
int popcount(T Value) noexcept
Count the number of set bits in a value.
bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
APInt operator&(APInt a, const APInt &b)
APInt operator*(APInt a, uint64_t RHS)
int countr_one(T Value)
Count the number of ones from the least significant bit to the first zero bit.
bool operator!=(uint64_t V1, const APInt &V2)
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt & operator+=(DynamicAPInt &A, int64_t B)
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt & operator-=(DynamicAPInt &A, int64_t B)
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
APInt operator~(APInt v)
Unary bitwise complement operator.
int countr_zero(T Val)
Count number of 0's from the least significant bit to the most stopping at the first 1.
constexpr bool isShiftedMask_64(uint64_t Value)
Return true if the argument contains a non-empty sequence of ones with the remainder zero (64 bit ver...
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt & operator*=(DynamicAPInt &A, int64_t B)
int countl_zero(T Val)
Count number of 0's from the most significant bit to the least stopping at the first 1.
APInt operator^(APInt a, const APInt &b)
constexpr bool isMask_64(uint64_t Value)
Return true if the argument is a non-empty sequence of ones starting at the least significant bit wit...
int countl_one(T Value)
Count the number of ones from the most significant bit to the first zero bit.
bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
ArrayRef(const T &OneElt) -> ArrayRef< T >
constexpr int64_t SignExtend64(uint64_t x)
Sign-extend the number in the bottom B bits of X to a 64-bit integer.
APInt operator+(APInt a, const APInt &b)
APInt operator|(APInt a, const APInt &b)
T reverseBits(T Val)
Reverse the bits in Val.
constexpr T rotl(T V, int R)
@ Keep
No function return thunk.
auto mask(ShuffFunc S, unsigned Length, OptArgs... args) -> MaskT
This struct is a compact representation of a valid (non-zero power of two) alignment.
static APInt getEmptyKey()
static APInt getTombstoneKey()
static bool isEqual(const APInt &LHS, const APInt &RHS)
static unsigned getHashValue(const APInt &Key)
An information struct used to provide DenseMap with the various necessary components for a given valu...