| 672 | } |
| 673 | |
| 674 | APInt APInt::byteSwap() const { |
| 675 | assert(BitWidth >= 16 && BitWidth % 8 == 0 && "Cannot byteswap!"); |
| 676 | if (BitWidth == 16) |
| 677 | return APInt(BitWidth, ByteSwap_16(uint16_t(U.VAL))); |
| 678 | if (BitWidth == 32) |
| 679 | return APInt(BitWidth, ByteSwap_32(unsigned(U.VAL))); |
| 680 | if (BitWidth <= 64) { |
| 681 | uint64_t Tmp1 = ByteSwap_64(U.VAL); |
| 682 | Tmp1 >>= (64 - BitWidth); |
| 683 | return APInt(BitWidth, Tmp1); |
| 684 | } |
| 685 | |
| 686 | APInt Result(getNumWords() * APINT_BITS_PER_WORD, 0); |
| 687 | for (unsigned I = 0, N = getNumWords(); I != N; ++I) |
| 688 | Result.U.pVal[I] = ByteSwap_64(U.pVal[N - I - 1]); |
| 689 | if (Result.BitWidth != BitWidth) { |
| 690 | Result.lshrInPlace(Result.BitWidth - BitWidth); |
| 691 | Result.BitWidth = BitWidth; |
| 692 | } |
| 693 | return Result; |
| 694 | } |
| 695 | |
| 696 | APInt APInt::reverseBits() const { |
| 697 | switch (BitWidth) { |
nothing calls this directly
no test coverage detected