• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /freebsd-13-stable/contrib/llvm-project/llvm/lib/Target/AArch64/MCTargetDesc/

Lines Matching refs:Imm

73 static inline AArch64_AM::ShiftExtendType getShiftType(unsigned Imm) {
74 switch ((Imm >> 6) & 0x7) {
85 static inline unsigned getShiftValue(unsigned Imm) {
86 return Imm & 0x3f;
99 unsigned Imm) {
100 assert((Imm & 0x3f) == Imm && "Illegal shifted immedate value!");
110 return (STEnc << 6) | (Imm & 0x3f);
118 static inline unsigned getArithShiftValue(unsigned Imm) {
119 return Imm & 0x7;
123 static inline AArch64_AM::ShiftExtendType getExtendType(unsigned Imm) {
124 assert((Imm & 0x7) == Imm && "invalid immediate!");
125 switch (Imm) {
138 static inline AArch64_AM::ShiftExtendType getArithExtendType(unsigned Imm) {
139 return getExtendType((Imm >> 3) & 0x7);
171 unsigned Imm) {
172 assert((Imm & 0x7) == Imm && "Illegal shifted immedate value!");
173 return (getExtendEncoding(ET) << 3) | (Imm & 0x7);
178 static inline bool getMemDoShift(unsigned Imm) {
179 return (Imm & 0x1) != 0;
184 static inline AArch64_AM::ShiftExtendType getMemExtendType(unsigned Imm) {
185 return getExtendType((Imm >> 1) & 0x7);
213 static inline bool processLogicalImmediate(uint64_t Imm, unsigned RegSize,
215 if (Imm == 0ULL || Imm == ~0ULL ||
217 (Imm >> RegSize != 0 || Imm == (~0ULL >> (64 - RegSize)))))
227 if ((Imm & Mask) != ((Imm >> Size) & Mask)) {
236 Imm &= Mask;
238 if (isShiftedMask_64(Imm)) {
239 I = countTrailingZeros(Imm);
241 CTO = countTrailingOnes(Imm >> I);
243 Imm |= ~Mask;
244 if (!isShiftedMask_64(~Imm))
247 unsigned CLO = countLeadingOnes(Imm);
249 CTO = CLO + countTrailingOnes(Imm) - (64 - Size);
343 static inline float getFPImmFloat(unsigned Imm) {
346 uint8_t Sign = (Imm >> 7) & 0x1;
347 uint8_t Exp = (Imm >> 4) & 0x7;
348 uint8_t Mantissa = Imm & 0xf;
367 static inline int getFP16Imm(const APInt &Imm) {
368 uint32_t Sign = Imm.lshr(15).getZExtValue() & 1;
369 int32_t Exp = (Imm.lshr(10).getSExtValue() & 0x1f) - 15; // -14 to 15
370 int32_t Mantissa = Imm.getZExtValue() & 0x3ff; // 10 bits
393 static inline int getFP32Imm(const APInt &Imm) {
394 uint32_t Sign = Imm.lshr(31).getZExtValue() & 1;
395 int32_t Exp = (Imm.lshr(23).getSExtValue() & 0xff) - 127; // -126 to 127
396 int64_t Mantissa = Imm.getZExtValue() & 0x7fffff; // 23 bits
421 static inline int getFP64Imm(const APInt &Imm) {
422 uint64_t Sign = Imm.lshr(63).getZExtValue() & 1;
423 int64_t Exp = (Imm.lshr(52).getSExtValue() & 0x7ff) - 1023; // -1022 to 1023
424 uint64_t Mantissa = Imm.getZExtValue() & 0xfffffffffffffULL;
451 static inline bool isAdvSIMDModImmType1(uint64_t Imm) {
452 return ((Imm >> 32) == (Imm & 0xffffffffULL)) &&
453 ((Imm & 0xffffff00ffffff00ULL) == 0);
456 static inline uint8_t encodeAdvSIMDModImmType1(uint64_t Imm) {
457 return (Imm & 0xffULL);
460 static inline uint64_t decodeAdvSIMDModImmType1(uint8_t Imm) {
461 uint64_t EncVal = Imm;
466 static inline bool isAdvSIMDModImmType2(uint64_t Imm) {
467 return ((Imm >> 32) == (Imm & 0xffffffffULL)) &&
468 ((Imm & 0xffff00ffffff00ffULL) == 0);
471 static inline uint8_t encodeAdvSIMDModImmType2(uint64_t Imm) {
472 return (Imm & 0xff00ULL) >> 8;
475 static inline uint64_t decodeAdvSIMDModImmType2(uint8_t Imm) {
476 uint64_t EncVal = Imm;
481 static inline bool isAdvSIMDModImmType3(uint64_t Imm) {
482 return ((Imm >> 32) == (Imm & 0xffffffffULL)) &&
483 ((Imm & 0xff00ffffff00ffffULL) == 0);
486 static inline uint8_t encodeAdvSIMDModImmType3(uint64_t Imm) {
487 return (Imm & 0xff0000ULL) >> 16;
490 static inline uint64_t decodeAdvSIMDModImmType3(uint8_t Imm) {
491 uint64_t EncVal = Imm;
496 static inline bool isAdvSIMDModImmType4(uint64_t Imm) {
497 return ((Imm >> 32) == (Imm & 0xffffffffULL)) &&
498 ((Imm & 0x00ffffff00ffffffULL) == 0);
501 static inline uint8_t encodeAdvSIMDModImmType4(uint64_t Imm) {
502 return (Imm & 0xff000000ULL) >> 24;
505 static inline uint64_t decodeAdvSIMDModImmType4(uint8_t Imm) {
506 uint64_t EncVal = Imm;
511 static inline bool isAdvSIMDModImmType5(uint64_t Imm) {
512 return ((Imm >> 32) == (Imm & 0xffffffffULL)) &&
513 (((Imm & 0x00ff0000ULL) >> 16) == (Imm & 0x000000ffULL)) &&
514 ((Imm & 0xff00ff00ff00ff00ULL) == 0);
517 static inline uint8_t encodeAdvSIMDModImmType5(uint64_t Imm) {
518 return (Imm & 0xffULL);
521 static inline uint64_t decodeAdvSIMDModImmType5(uint8_t Imm) {
522 uint64_t EncVal = Imm;
527 static inline bool isAdvSIMDModImmType6(uint64_t Imm) {
528 return ((Imm >> 32) == (Imm & 0xffffffffULL)) &&
529 (((Imm & 0xff000000ULL) >> 16) == (Imm & 0x0000ff00ULL)) &&
530 ((Imm & 0x00ff00ff00ff00ffULL) == 0);
533 static inline uint8_t encodeAdvSIMDModImmType6(uint64_t Imm) {
534 return (Imm & 0xff00ULL) >> 8;
537 static inline uint64_t decodeAdvSIMDModImmType6(uint8_t Imm) {
538 uint64_t EncVal = Imm;
543 static inline bool isAdvSIMDModImmType7(uint64_t Imm) {
544 return ((Imm >> 32) == (Imm & 0xffffffffULL)) &&
545 ((Imm & 0xffff00ffffff00ffULL) == 0x000000ff000000ffULL);
548 static inline uint8_t encodeAdvSIMDModImmType7(uint64_t Imm) {
549 return (Imm & 0xff00ULL) >> 8;
552 static inline uint64_t decodeAdvSIMDModImmType7(uint8_t Imm) {
553 uint64_t EncVal = Imm;
558 static inline bool isAdvSIMDModImmType8(uint64_t Imm) {
559 return ((Imm >> 32) == (Imm & 0xffffffffULL)) &&
560 ((Imm & 0xff00ffffff00ffffULL) == 0x0000ffff0000ffffULL);
563 static inline uint64_t decodeAdvSIMDModImmType8(uint8_t Imm) {
564 uint64_t EncVal = Imm;
568 static inline uint8_t encodeAdvSIMDModImmType8(uint64_t Imm) {
569 return (Imm & 0x00ff0000ULL) >> 16;
573 static inline bool isAdvSIMDModImmType9(uint64_t Imm) {
574 return ((Imm >> 32) == (Imm & 0xffffffffULL)) &&
575 ((Imm >> 48) == (Imm & 0x0000ffffULL)) &&
576 ((Imm >> 56) == (Imm & 0x000000ffULL));
579 static inline uint8_t encodeAdvSIMDModImmType9(uint64_t Imm) {
580 return (Imm & 0xffULL);
583 static inline uint64_t decodeAdvSIMDModImmType9(uint8_t Imm) {
584 uint64_t EncVal = Imm;
593 static inline bool isAdvSIMDModImmType10(uint64_t Imm) {
594 uint64_t ByteA = Imm & 0xff00000000000000ULL;
595 uint64_t ByteB = Imm & 0x00ff000000000000ULL;
596 uint64_t ByteC = Imm & 0x0000ff0000000000ULL;
597 uint64_t ByteD = Imm & 0x000000ff00000000ULL;
598 uint64_t ByteE = Imm & 0x00000000ff000000ULL;
599 uint64_t ByteF = Imm & 0x0000000000ff0000ULL;
600 uint64_t ByteG = Imm & 0x000000000000ff00ULL;
601 uint64_t ByteH = Imm & 0x00000000000000ffULL;
613 static inline uint8_t encodeAdvSIMDModImmType10(uint64_t Imm) {
614 uint8_t BitA = (Imm & 0xff00000000000000ULL) != 0;
615 uint8_t BitB = (Imm & 0x00ff000000000000ULL) != 0;
616 uint8_t BitC = (Imm & 0x0000ff0000000000ULL) != 0;
617 uint8_t BitD = (Imm & 0x000000ff00000000ULL) != 0;
618 uint8_t BitE = (Imm & 0x00000000ff000000ULL) != 0;
619 uint8_t BitF = (Imm & 0x0000000000ff0000ULL) != 0;
620 uint8_t BitG = (Imm & 0x000000000000ff00ULL) != 0;
621 uint8_t BitH = (Imm & 0x00000000000000ffULL) != 0;
641 static inline uint64_t decodeAdvSIMDModImmType10(uint8_t Imm) {
643 if (Imm & 0x80) EncVal |= 0xff00000000000000ULL;
644 if (Imm & 0x40) EncVal |= 0x00ff000000000000ULL;
645 if (Imm & 0x20) EncVal |= 0x0000ff0000000000ULL;
646 if (Imm & 0x10) EncVal |= 0x000000ff00000000ULL;
647 if (Imm & 0x08) EncVal |= 0x00000000ff000000ULL;
648 if (Imm & 0x04) EncVal |= 0x0000000000ff0000ULL;
649 if (Imm & 0x02) EncVal |= 0x000000000000ff00ULL;
650 if (Imm & 0x01) EncVal |= 0x00000000000000ffULL;
655 static inline bool isAdvSIMDModImmType11(uint64_t Imm) {
656 uint64_t BString = (Imm & 0x7E000000ULL) >> 25;
657 return ((Imm >> 32) == (Imm & 0xffffffffULL)) &&
659 ((Imm & 0x0007ffff0007ffffULL) == 0);
662 static inline uint8_t encodeAdvSIMDModImmType11(uint64_t Imm) {
663 uint8_t BitA = (Imm & 0x80000000ULL) != 0;
664 uint8_t BitB = (Imm & 0x20000000ULL) != 0;
665 uint8_t BitC = (Imm & 0x01000000ULL) != 0;
666 uint8_t BitD = (Imm & 0x00800000ULL) != 0;
667 uint8_t BitE = (Imm & 0x00400000ULL) != 0;
668 uint8_t BitF = (Imm & 0x00200000ULL) != 0;
669 uint8_t BitG = (Imm & 0x00100000ULL) != 0;
670 uint8_t BitH = (Imm & 0x00080000ULL) != 0;
690 static inline uint64_t decodeAdvSIMDModImmType11(uint8_t Imm) {
692 if (Imm & 0x80) EncVal |= 0x80000000ULL;
693 if (Imm & 0x40) EncVal |= 0x3e000000ULL;
695 if (Imm & 0x20) EncVal |= 0x01000000ULL;
696 if (Imm & 0x10) EncVal |= 0x00800000ULL;
697 if (Imm & 0x08) EncVal |= 0x00400000ULL;
698 if (Imm & 0x04) EncVal |= 0x00200000ULL;
699 if (Imm & 0x02) EncVal |= 0x00100000ULL;
700 if (Imm & 0x01) EncVal |= 0x00080000ULL;
705 static inline bool isAdvSIMDModImmType12(uint64_t Imm) {
706 uint64_t BString = (Imm & 0x7fc0000000000000ULL) >> 54;
708 ((Imm & 0x0000ffffffffffffULL) == 0));
711 static inline uint8_t encodeAdvSIMDModImmType12(uint64_t Imm) {
712 uint8_t BitA = (Imm & 0x8000000000000000ULL) != 0;
713 uint8_t BitB = (Imm & 0x0040000000000000ULL) != 0;
714 uint8_t BitC = (Imm & 0x0020000000000000ULL) != 0;
715 uint8_t BitD = (Imm & 0x0010000000000000ULL) != 0;
716 uint8_t BitE = (Imm & 0x0008000000000000ULL) != 0;
717 uint8_t BitF = (Imm & 0x0004000000000000ULL) != 0;
718 uint8_t BitG = (Imm & 0x0002000000000000ULL) != 0;
719 uint8_t BitH = (Imm & 0x0001000000000000ULL) != 0;
739 static inline uint64_t decodeAdvSIMDModImmType12(uint8_t Imm) {
741 if (Imm & 0x80) EncVal |= 0x8000000000000000ULL;
742 if (Imm & 0x40) EncVal |= 0x3fc0000000000000ULL;
744 if (Imm & 0x20) EncVal |= 0x0020000000000000ULL;
745 if (Imm & 0x10) EncVal |= 0x0010000000000000ULL;
746 if (Imm & 0x08) EncVal |= 0x0008000000000000ULL;
747 if (Imm & 0x04) EncVal |= 0x0004000000000000ULL;
748 if (Imm & 0x02) EncVal |= 0x0002000000000000ULL;
749 if (Imm & 0x01) EncVal |= 0x0001000000000000ULL;
753 /// Returns true if Imm is the concatenation of a repeating pattern of type T.
755 static inline bool isSVEMaskOfIdenticalElements(int64_t Imm) {
756 auto Parts = bit_cast<std::array<T, sizeof(int64_t) / sizeof(T)>>(Imm);
760 /// Returns true if Imm is valid for CPY/DUP.
762 static inline bool isSVECpyImm(int64_t Imm) {
763 bool IsImm8 = int8_t(Imm) == Imm;
764 bool IsImm16 = int16_t(Imm & ~0xff) == Imm;
767 return IsImm8 || uint8_t(Imm) == Imm;
770 return IsImm8 || IsImm16 || uint16_t(Imm & ~0xff) == Imm;
775 /// Returns true if Imm is valid for ADD/SUB.
777 static inline bool isSVEAddSubImm(int64_t Imm) {
779 return uint8_t(Imm) == Imm || (!IsInt8t && uint16_t(Imm & ~0xff) == Imm);
782 /// Return true if Imm is valid for DUPM and has no single CPY/DUP equivalent.
783 static inline bool isSVEMoveMaskPreferredLogicalImmediate(int64_t Imm) {
784 if (isSVECpyImm<int64_t>(Imm))
787 auto S = bit_cast<std::array<int32_t, 2>>(Imm);
788 auto H = bit_cast<std::array<int16_t, 4>>(Imm);
789 auto B = bit_cast<std::array<int8_t, 8>>(Imm);
791 if (isSVEMaskOfIdenticalElements<int32_t>(Imm) && isSVECpyImm<int32_t>(S[0]))
793 if (isSVEMaskOfIdenticalElements<int16_t>(Imm) && isSVECpyImm<int16_t>(H[0]))
795 if (isSVEMaskOfIdenticalElements<int8_t>(Imm) && isSVECpyImm<int8_t>(B[0]))
797 return isLogicalImmediate(Imm, 64);