13#ifndef LLVM_LIB_TARGET_AARCH64_MCTARGETDESC_AARCH64ADDRESSINGMODES_H
14#define LLVM_LIB_TARGET_AARCH64_MCTARGETDESC_AARCH64ADDRESSINGMODES_H
87 switch ((Imm >> 6) & 0x7) {
113 assert((Imm & 0x3f) == Imm &&
"Illegal shifted immediate value!");
123 return (STEnc << 6) | (Imm & 0x3f);
137 assert((Imm & 0x7) == Imm &&
"invalid immediate!");
185 assert((Imm & 0x7) == Imm &&
"Illegal shifted immediate value!");
192 return (Imm & 0x1) != 0;
219 return ((elt & 1) << (
size-1)) | (elt >> 1);
228 if (Imm == 0ULL || Imm == ~0ULL ||
240 if ((Imm & Mask) != ((Imm >>
Size) & Mask)) {
253 assert(
I < 64 &&
"undefined behavior");
268 assert(
Size >
I &&
"I should be smaller than element size");
280 unsigned N = ((NImms >> 6) & 1) ^ 1;
282 Encoding = (
N << 12) | (Immr << 6) | (NImms & 0x3f);
298 assert(res &&
"invalid logical immediate");
308 unsigned N = (val >> 12) & 1;
309 unsigned immr = (val >> 6) & 0x3f;
310 unsigned imms = val & 0x3f;
312 assert((regSize == 64 ||
N == 0) &&
"undefined logical immediate encoding");
314 assert(len >= 0 &&
"undefined logical immediate encoding");
315 unsigned size = (1 << len);
316 unsigned R = immr & (
size - 1);
317 unsigned S = imms & (
size - 1);
318 assert(S !=
size - 1 &&
"undefined logical immediate encoding");
319 uint64_t pattern = (1ULL << (S + 1)) - 1;
320 for (
unsigned i = 0; i < R; ++i)
324 while (
size != regSize) {
325 pattern |= (pattern <<
size);
337 unsigned N = (val >> 12) & 1;
338 unsigned imms = val & 0x3f;
340 if (regSize == 32 &&
N != 0)
345 unsigned size = (1 << len);
346 unsigned S = imms & (
size - 1);
359 uint8_t Sign = (Imm >> 7) & 0x1;
360 uint8_t Exp = (Imm >> 4) & 0x7;
370 I |= ((Exp & 0x4) != 0 ? 0 : 1) << 30;
371 I |= ((Exp & 0x4) != 0 ? 0x1f : 0) << 25;
372 I |= (Exp & 0x3) << 23;
381 uint32_t Sign = Imm.lshr(15).getZExtValue() & 1;
382 int32_t Exp = (Imm.lshr(10).getSExtValue() & 0x1f) - 15;
383 int32_t Mantissa = Imm.getZExtValue() & 0x3ff;
392 if (Exp < -3 || Exp > 4)
394 Exp = ((Exp+3) & 0x7) ^ 4;
396 return ((
int)Sign << 7) | (Exp << 4) | Mantissa;
407 uint32_t Sign = Imm.lshr(31).getZExtValue() & 1;
408 int32_t Exp = (Imm.lshr(23).getSExtValue() & 0xff) - 127;
409 int64_t Mantissa = Imm.getZExtValue() & 0x7fffff;
413 if (Mantissa & 0x7ffff)
416 if ((Mantissa & 0xf) != Mantissa)
420 if (Exp < -3 || Exp > 4)
422 Exp = ((Exp+3) & 0x7) ^ 4;
424 return ((
int)Sign << 7) | (Exp << 4) | Mantissa;
435 uint64_t Sign = Imm.lshr(63).getZExtValue() & 1;
436 int64_t Exp = (Imm.lshr(52).getSExtValue() & 0x7ff) - 1023;
437 uint64_t Mantissa = Imm.getZExtValue() & 0xfffffffffffffULL;
441 if (Mantissa & 0xffffffffffffULL)
444 if ((Mantissa & 0xf) != Mantissa)
448 if (Exp < -3 || Exp > 4)
450 Exp = ((Exp+3) & 0x7) ^ 4;
452 return ((
int)Sign << 7) | (Exp << 4) | Mantissa;
465 return ((Imm >> 32) == (Imm & 0xffffffffULL)) &&
466 ((Imm & 0xffffff00ffffff00ULL) == 0);
470 return (Imm & 0xffULL);
475 return (EncVal << 32) | EncVal;
480 return ((Imm >> 32) == (Imm & 0xffffffffULL)) &&
481 ((Imm & 0xffff00ffffff00ffULL) == 0);
485 return (Imm & 0xff00ULL) >> 8;
490 return (EncVal << 40) | (EncVal << 8);
495 return ((Imm >> 32) == (Imm & 0xffffffffULL)) &&
496 ((Imm & 0xff00ffffff00ffffULL) == 0);
500 return (Imm & 0xff0000ULL) >> 16;
505 return (EncVal << 48) | (EncVal << 16);
510 return ((Imm >> 32) == (Imm & 0xffffffffULL)) &&
511 ((Imm & 0x00ffffff00ffffffULL) == 0);
515 return (Imm & 0xff000000ULL) >> 24;
520 return (EncVal << 56) | (EncVal << 24);
525 return ((Imm >> 32) == (Imm & 0xffffffffULL)) &&
526 (((Imm & 0x00ff0000ULL) >> 16) == (Imm & 0x000000ffULL)) &&
527 ((Imm & 0xff00ff00ff00ff00ULL) == 0);
531 return (Imm & 0xffULL);
536 return (EncVal << 48) | (EncVal << 32) | (EncVal << 16) | EncVal;
541 return ((Imm >> 32) == (Imm & 0xffffffffULL)) &&
542 (((Imm & 0xff000000ULL) >> 16) == (Imm & 0x0000ff00ULL)) &&
543 ((Imm & 0x00ff00ff00ff00ffULL) == 0);
547 return (Imm & 0xff00ULL) >> 8;
552 return (EncVal << 56) | (EncVal << 40) | (EncVal << 24) | (EncVal << 8);
557 return ((Imm >> 32) == (Imm & 0xffffffffULL)) &&
558 ((Imm & 0xffff00ffffff00ffULL) == 0x000000ff000000ffULL);
562 return (Imm & 0xff00ULL) >> 8;
567 return (EncVal << 40) | (EncVal << 8) | 0x000000ff000000ffULL;
572 return ((Imm >> 32) == (Imm & 0xffffffffULL)) &&
573 ((Imm & 0xff00ffffff00ffffULL) == 0x0000ffff0000ffffULL);
578 return (EncVal << 48) | (EncVal << 16) | 0x0000ffff0000ffffULL;
582 return (Imm & 0x00ff0000ULL) >> 16;
587 return ((Imm >> 32) == (Imm & 0xffffffffULL)) &&
588 ((Imm >> 48) == (Imm & 0x0000ffffULL)) &&
589 ((Imm >> 56) == (Imm & 0x000000ffULL));
593 return (Imm & 0xffULL);
598 EncVal |= (EncVal << 8);
599 EncVal |= (EncVal << 16);
600 EncVal |= (EncVal << 32);
607#if defined(_MSC_VER) && _MSC_VER == 1937 && !defined(__clang__) && \
614 uint64_t ByteA = (Imm >> 56) & Mask;
615 uint64_t ByteB = (Imm >> 48) & Mask;
616 uint64_t ByteC = (Imm >> 40) & Mask;
617 uint64_t ByteD = (Imm >> 32) & Mask;
618 uint64_t ByteE = (Imm >> 24) & Mask;
619 uint64_t ByteF = (Imm >> 16) & Mask;
623 return (ByteA == 0ULL || ByteA == Mask) && (ByteB == 0ULL || ByteB == Mask) &&
624 (ByteC == 0ULL || ByteC == Mask) && (ByteD == 0ULL || ByteD == Mask) &&
625 (ByteE == 0ULL || ByteE == Mask) && (ByteF == 0ULL || ByteF == Mask) &&
626 (ByteG == 0ULL || ByteG == Mask) && (ByteH == 0ULL || ByteH == Mask);
628 uint64_t ByteA = Imm & 0xff00000000000000ULL;
629 uint64_t ByteB = Imm & 0x00ff000000000000ULL;
630 uint64_t ByteC = Imm & 0x0000ff0000000000ULL;
631 uint64_t ByteD = Imm & 0x000000ff00000000ULL;
632 uint64_t ByteE = Imm & 0x00000000ff000000ULL;
633 uint64_t ByteF = Imm & 0x0000000000ff0000ULL;
634 uint64_t ByteG = Imm & 0x000000000000ff00ULL;
635 uint64_t ByteH = Imm & 0x00000000000000ffULL;
637 return (ByteA == 0ULL || ByteA == 0xff00000000000000ULL) &&
638 (ByteB == 0ULL || ByteB == 0x00ff000000000000ULL) &&
639 (ByteC == 0ULL || ByteC == 0x0000ff0000000000ULL) &&
640 (ByteD == 0ULL || ByteD == 0x000000ff00000000ULL) &&
641 (ByteE == 0ULL || ByteE == 0x00000000ff000000ULL) &&
642 (ByteF == 0ULL || ByteF == 0x0000000000ff0000ULL) &&
643 (ByteG == 0ULL || ByteG == 0x000000000000ff00ULL) &&
644 (ByteH == 0ULL || ByteH == 0x00000000000000ffULL);
649 uint8_t BitA = (Imm & 0xff00000000000000ULL) != 0;
650 uint8_t BitB = (Imm & 0x00ff000000000000ULL) != 0;
651 uint8_t BitC = (Imm & 0x0000ff0000000000ULL) != 0;
652 uint8_t BitD = (Imm & 0x000000ff00000000ULL) != 0;
653 uint8_t BitE = (Imm & 0x00000000ff000000ULL) != 0;
654 uint8_t BitF = (Imm & 0x0000000000ff0000ULL) != 0;
655 uint8_t BitG = (Imm & 0x000000000000ff00ULL) != 0;
656 uint8_t BitH = (Imm & 0x00000000000000ffULL) != 0;
678 if (Imm & 0x80) EncVal |= 0xff00000000000000ULL;
679 if (Imm & 0x40) EncVal |= 0x00ff000000000000ULL;
680 if (Imm & 0x20) EncVal |= 0x0000ff0000000000ULL;
681 if (Imm & 0x10) EncVal |= 0x000000ff00000000ULL;
682 if (Imm & 0x08) EncVal |= 0x00000000ff000000ULL;
683 if (Imm & 0x04) EncVal |= 0x0000000000ff0000ULL;
684 if (Imm & 0x02) EncVal |= 0x000000000000ff00ULL;
685 if (Imm & 0x01) EncVal |= 0x00000000000000ffULL;
691 uint64_t BString = (Imm & 0x7E000000ULL) >> 25;
692 return ((Imm >> 32) == (Imm & 0xffffffffULL)) &&
693 (BString == 0x1f || BString == 0x20) &&
694 ((Imm & 0x0007ffff0007ffffULL) == 0);
698 uint8_t BitA = (Imm & 0x80000000ULL) != 0;
699 uint8_t BitB = (Imm & 0x20000000ULL) != 0;
700 uint8_t BitC = (Imm & 0x01000000ULL) != 0;
701 uint8_t BitD = (Imm & 0x00800000ULL) != 0;
702 uint8_t BitE = (Imm & 0x00400000ULL) != 0;
703 uint8_t BitF = (Imm & 0x00200000ULL) != 0;
704 uint8_t BitG = (Imm & 0x00100000ULL) != 0;
705 uint8_t BitH = (Imm & 0x00080000ULL) != 0;
727 if (Imm & 0x80) EncVal |= 0x80000000ULL;
728 if (Imm & 0x40) EncVal |= 0x3e000000ULL;
729 else EncVal |= 0x40000000ULL;
730 if (Imm & 0x20) EncVal |= 0x01000000ULL;
731 if (Imm & 0x10) EncVal |= 0x00800000ULL;
732 if (Imm & 0x08) EncVal |= 0x00400000ULL;
733 if (Imm & 0x04) EncVal |= 0x00200000ULL;
734 if (Imm & 0x02) EncVal |= 0x00100000ULL;
735 if (Imm & 0x01) EncVal |= 0x00080000ULL;
736 return (EncVal << 32) | EncVal;
741 uint64_t BString = (Imm & 0x7fc0000000000000ULL) >> 54;
742 return ((BString == 0xff || BString == 0x100) &&
743 ((Imm & 0x0000ffffffffffffULL) == 0));
747 uint8_t BitA = (Imm & 0x8000000000000000ULL) != 0;
748 uint8_t BitB = (Imm & 0x0040000000000000ULL) != 0;
749 uint8_t BitC = (Imm & 0x0020000000000000ULL) != 0;
750 uint8_t BitD = (Imm & 0x0010000000000000ULL) != 0;
751 uint8_t BitE = (Imm & 0x0008000000000000ULL) != 0;
752 uint8_t BitF = (Imm & 0x0004000000000000ULL) != 0;
753 uint8_t BitG = (Imm & 0x0002000000000000ULL) != 0;
754 uint8_t BitH = (Imm & 0x0001000000000000ULL) != 0;
776 if (Imm & 0x80) EncVal |= 0x8000000000000000ULL;
777 if (Imm & 0x40) EncVal |= 0x3fc0000000000000ULL;
778 else EncVal |= 0x4000000000000000ULL;
779 if (Imm & 0x20) EncVal |= 0x0020000000000000ULL;
780 if (Imm & 0x10) EncVal |= 0x0010000000000000ULL;
781 if (Imm & 0x08) EncVal |= 0x0008000000000000ULL;
782 if (Imm & 0x04) EncVal |= 0x0004000000000000ULL;
783 if (Imm & 0x02) EncVal |= 0x0002000000000000ULL;
784 if (Imm & 0x01) EncVal |= 0x0001000000000000ULL;
791 auto Parts =
bit_cast<std::array<
T,
sizeof(int64_t) /
sizeof(
T)>>(Imm);
801 int64_t Mask = ~int64_t(std::numeric_limits<std::make_unsigned_t<T>>
::max());
802 if ((Imm & Mask) != 0 && (Imm & Mask) != Mask)
808 return int8_t(Imm) ==
T(Imm);
813 return int16_t(Imm) ==
T(Imm);
821 bool IsInt8t = std::is_same<int8_t, std::make_signed_t<T>>::value ||
822 std::is_same<int8_t, T>::value;
823 return uint8_t(Imm) == Imm || (!IsInt8t &&
uint16_t(Imm & ~0xff) == Imm);
845 for (
int Shift = 0; Shift <= RegWidth - 16; Shift += 16)
846 if ((
Value & ~(0xffffULL << Shift)) == 0)
854 Value &= 0xffffffffULL;
857 if (
Value == 0 && Shift != 0)
860 return (
Value & ~(0xffffULL << Shift)) == 0;
870 Value &= 0xffffffffULL;
882 Value &= 0xffffffffULL;
889 switch (SizeInBits) {
899 if (Val >= -128 && Val <= 127) {
905 if (Val >= -32768 && Val <= 32512 && Val % 256 == 0) {
907 Imm = (Val >> 8) & 0xFF;
920 switch (SizeInBits) {
923 ImmVal |= ImmVal << 8;
924 ImmVal |= ImmVal << 16;
925 ImmVal |= ImmVal << 32;
929 ImmVal |= ImmVal << 16;
930 ImmVal |= ImmVal << 32;
933 ImmVal &= 0xFFFFFFFF;
934 ImmVal |= ImmVal << 32;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file declares a class to represent arbitrary precision floating point values and provide a varie...
This file implements a class to represent arbitrary precision integral constant values and operations...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file implements the C++20 <bit> header.
APInt bitcastToAPInt() const
Class for arbitrary precision integers.
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
AArch64_AM - AArch64 Addressing Mode Stuff.
static bool isValidDecodeLogicalImmediate(uint64_t val, unsigned regSize)
isValidDecodeLogicalImmediate - Check to see if the logical immediate value in the form "N:immr:imms"...
static bool isSVEMoveMaskPreferredLogicalImmediate(int64_t Imm)
Return true if Imm is valid for DUPM and has no single CPY/DUP equivalent.
static bool isAnyMOVZMovAlias(uint64_t Value, int RegWidth)
static bool isMOVNMovAlias(uint64_t Value, int Shift, int RegWidth)
static uint64_t decodeLogicalImmediate(uint64_t val, unsigned regSize)
decodeLogicalImmediate - Decode a logical immediate value in the form "N:immr:imms" (where the immr a...
static unsigned getMemExtendImm(AArch64_AM::ShiftExtendType ET, bool DoShift)
getExtendImm - Encode the extend type and amount for a load/store inst: doshift: should the offset be...
static unsigned getShiftValue(unsigned Imm)
getShiftValue - Extract the shift value.
static uint64_t decodeAdvSIMDModImmType4(uint8_t Imm)
static bool isLogicalImmediate(uint64_t imm, unsigned regSize)
isLogicalImmediate - Return true if the immediate is valid for a logical immediate instruction of the...
static uint8_t encodeAdvSIMDModImmType2(uint64_t Imm)
static bool isSVEAddSubImm(int64_t Imm)
Returns true if Imm is valid for ADD/SUB.
static bool processLogicalImmediate(uint64_t Imm, unsigned RegSize, uint64_t &Encoding)
processLogicalImmediate - Determine if an immediate value can be encoded as the immediate operand of ...
static bool isAdvSIMDModImmType9(uint64_t Imm)
static uint64_t decodeAdvSIMDModImmType2(uint8_t Imm)
static bool isAdvSIMDModImmType4(uint64_t Imm)
static unsigned getArithExtendImm(AArch64_AM::ShiftExtendType ET, unsigned Imm)
getArithExtendImm - Encode the extend type and shift amount for an arithmetic instruction: imm: 3-bit...
static uint64_t decodeAdvSIMDModImmType12(uint8_t Imm)
static bool isAdvSIMDModImmType5(uint64_t Imm)
static bool isAnyMOVWMovAlias(uint64_t Value, int RegWidth)
static unsigned getArithShiftValue(unsigned Imm)
getArithShiftValue - get the arithmetic shift value.
static uint64_t decodeAdvSIMDModImmType11(uint8_t Imm)
static int getFP32Imm(const APInt &Imm)
getFP32Imm - Return an 8-bit floating-point version of the 32-bit floating-point value.
static float getFPImmFloat(unsigned Imm)
static AArch64_AM::ShiftExtendType getMemExtendType(unsigned Imm)
getExtendType - Extract the extend type for the offset operand of loads/stores.
static uint8_t encodeAdvSIMDModImmType7(uint64_t Imm)
static uint64_t decodeAdvSIMDModImmType1(uint8_t Imm)
static uint8_t encodeAdvSIMDModImmType12(uint64_t Imm)
static uint8_t encodeAdvSIMDModImmType10(uint64_t Imm)
static uint8_t encodeAdvSIMDModImmType9(uint64_t Imm)
static bool isSVEMaskOfIdenticalElements(int64_t Imm)
Returns true if Imm is the concatenation of a repeating pattern of type T.
static bool isMOVZMovAlias(uint64_t Value, int Shift, int RegWidth)
static uint64_t encodeLogicalImmediate(uint64_t imm, unsigned regSize)
encodeLogicalImmediate - Return the encoded immediate value for a logical immediate instruction of th...
static const char * getShiftExtendName(AArch64_AM::ShiftExtendType ST)
getShiftName - Get the string encoding for the shift type.
static bool isAdvSIMDModImmType7(uint64_t Imm)
static uint64_t decodeAdvSIMDModImmType3(uint8_t Imm)
static uint64_t decodeAdvSIMDModImmType7(uint8_t Imm)
unsigned getExtendEncoding(AArch64_AM::ShiftExtendType ET)
Mapping from extend bits to required operation: shifter: 000 ==> uxtb 001 ==> uxth 010 ==> uxtw 011 =...
static bool isSVECpyImm(int64_t Imm)
Returns true if Imm is valid for CPY/DUP.
static uint8_t encodeAdvSIMDModImmType5(uint64_t Imm)
static int getFP64Imm(const APInt &Imm)
getFP64Imm - Return an 8-bit floating-point version of the 64-bit floating-point value.
static uint64_t ror(uint64_t elt, unsigned size)
static bool isAdvSIMDModImmType10(uint64_t Imm)
static AArch64_AM::ShiftExtendType getExtendType(unsigned Imm)
getExtendType - Extract the extend type for operands of arithmetic ops.
static int getFP16Imm(const APInt &Imm)
getFP16Imm - Return an 8-bit floating-point version of the 16-bit floating-point value.
static uint64_t decodeAdvSIMDModImmType9(uint8_t Imm)
static uint64_t decodeAdvSIMDModImmType10(uint8_t Imm)
static uint64_t decodeAdvSIMDModImmType5(uint8_t Imm)
static uint64_t decodeAdvSIMDModImmType8(uint8_t Imm)
static uint8_t encodeAdvSIMDModImmType8(uint64_t Imm)
static bool isAdvSIMDModImmType12(uint64_t Imm)
static bool isSVELogicalImm(unsigned SizeInBits, uint64_t ImmVal, uint64_t &Encoding)
static uint8_t encodeAdvSIMDModImmType11(uint64_t Imm)
static AArch64_AM::ShiftExtendType getArithExtendType(unsigned Imm)
static bool isSVECpyDupImm(int SizeInBits, int64_t Val, int32_t &Imm, int32_t &Shift)
static bool isAdvSIMDModImmType11(uint64_t Imm)
static uint8_t encodeAdvSIMDModImmType6(uint64_t Imm)
static AArch64_AM::ShiftExtendType getShiftType(unsigned Imm)
getShiftType - Extract the shift type.
static bool isAdvSIMDModImmType8(uint64_t Imm)
static uint8_t encodeAdvSIMDModImmType4(uint64_t Imm)
static unsigned getShifterImm(AArch64_AM::ShiftExtendType ST, unsigned Imm)
getShifterImm - Encode the shift type and amount: imm: 6-bit shift amount shifter: 000 ==> lsl 001 ==...
static bool isAdvSIMDModImmType6(uint64_t Imm)
static bool getMemDoShift(unsigned Imm)
getMemDoShift - Extract the "do shift" flag value for load/store instructions.
static uint8_t encodeAdvSIMDModImmType1(uint64_t Imm)
static uint8_t encodeAdvSIMDModImmType3(uint64_t Imm)
static bool isAdvSIMDModImmType2(uint64_t Imm)
static uint64_t decodeAdvSIMDModImmType6(uint8_t Imm)
static bool isAdvSIMDModImmType3(uint64_t Imm)
static bool isSignExtendShiftType(AArch64_AM::ShiftExtendType Type)
isSignExtendShiftType - Returns true if Type is sign extending.
static bool isAdvSIMDModImmType1(uint64_t Imm)
This is an optimization pass for GlobalISel generic memory operations.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
int countr_one(T Value)
Count the number of ones from the least significant bit to the first zero bit.
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...
int countl_zero(T Val)
Count number of 0's from the most significant bit to the least stopping at the first 1.
int countl_one(T Value)
Count the number of ones from the most significant bit to the first zero bit.
To bit_cast(const From &from) noexcept
bool all_equal(std::initializer_list< T > Values)
Returns true if all Values in the initializer lists are equal or the list.