14 #ifndef LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMADDRESSINGMODES_H 15 #define LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMADDRESSINGMODES_H 85 inline unsigned rotr32(
unsigned Val,
unsigned Amt) {
86 assert(Amt < 32 &&
"Invalid rotate amount");
87 return (Val >> Amt) | (Val << ((32-Amt)&31));
92 inline unsigned rotl32(
unsigned Val,
unsigned Amt) {
93 assert(Amt < 32 &&
"Invalid rotate amount");
94 return (Val << Amt) | (Val >> ((32-Amt)&31));
112 return ShOp | (Imm << 3);
131 if ((Imm & ~255U) == 0)
return 0;
138 unsigned RotAmt = TZ & ~1;
141 if ((
rotr32(Imm, RotAmt) & ~255U) == 0)
142 return (32-RotAmt)&31;
148 unsigned RotAmt2 = TZ2 & ~1;
149 if ((
rotr32(Imm, RotAmt2) & ~255U) == 0)
150 return (32-RotAmt2)&31;
156 return (32-RotAmt)&31;
165 if ((Arg & ~255U) == 0)
return Arg;
170 if (
rotr32(~255U, RotAmt) & Arg)
174 return rotl32(Arg, RotAmt) | ((RotAmt>>1) << 8);
212 if ((Imm & ~255U) == 0)
return 0;
231 if ((Imm & ~65535U) == 0)
return 0;
264 if ((V & 0xffffff00) == 0)
268 Vs = ((V & 0xff) == 0) ? V >> 8 : V;
272 u = Imm | (Imm << 16);
276 return (((Vs == V) ? 1 : 2) << 8) | Imm;
279 if (Vs == (u | (u << 8)))
280 return (3 << 8) | Imm;
295 if ((
rotr32(0xff000000U, RotAmt) & V) == V)
296 return (
rotr32(V, 24 - RotAmt) & 0x7f) | ((RotAmt + 8) << 7);
320 if ((V & ~255U) == 0)
return 0;
323 return (32 - RotAmt) & 31;
355 "Immedate cannot be encoded as two part immediate!");
363 return Imm & 0xff00ff00U;
367 return Imm & 0x00ff00ffU;
375 "Unable to encode second part of T2 two part SO immediate");
399 unsigned IdxMode = 0) {
400 assert(Imm12 < (1 << 12) &&
"Imm too large!");
401 bool isSub = Opc ==
sub;
402 return Imm12 | ((int)isSub << 12) | (SO << 13) | (IdxMode << 16) ;
405 return AM2Opc & ((1 << 12)-1);
408 return ((AM2Opc >> 12) & 1) ?
sub :
add;
411 return (
ShiftOpc)((AM2Opc >> 13) & 7);
431 unsigned IdxMode = 0) {
432 bool isSub = Opc ==
sub;
433 return ((
int)isSub << 8) | Offset | (IdxMode << 9);
435 inline unsigned char getAM3Offset(
unsigned AM3Opc) {
return AM3Opc & 0xFF; }
437 return ((AM3Opc >> 8) & 1) ?
sub :
add;
475 bool isSub = Opc ==
sub;
476 return ((
int)isSub << 8) |
Offset;
478 inline unsigned char getAM5Offset(
unsigned AM5Opc) {
return AM5Opc & 0xFF; }
480 return ((AM5Opc >> 8) & 1) ?
sub :
add;
496 bool isSub = Opc ==
sub;
497 return ((
int)isSub << 8) |
Offset;
500 return AM5Opc & 0xFF;
503 return ((AM5Opc >> 8) & 1) ?
sub :
add;
532 return (OpCmode << 8) | Val;
535 return (ModImm >> 8) & 0x1f;
547 if (OpCmode == 0xe) {
551 }
else if ((OpCmode & 0xc) == 0x8) {
553 unsigned ByteNum = (OpCmode & 0x6) >> 1;
554 Val = Imm8 << (8 * ByteNum);
556 }
else if ((OpCmode & 0x8) == 0) {
558 unsigned ByteNum = (OpCmode & 0x6) >> 1;
559 Val = Imm8 << (8 * ByteNum);
561 }
else if ((OpCmode & 0xe) == 0xc) {
563 unsigned ByteNum = 1 + (OpCmode & 0x1);
564 Val = (Imm8 << (8 * ByteNum)) | (0xffff >> (8 * (2 - ByteNum)));
566 }
else if (OpCmode == 0x1e) {
568 for (
unsigned ByteNum = 0; ByteNum < 8; ++ByteNum) {
569 if ((ModImm >> ByteNum) & 1)
570 Val |= (uint64_t)0xff << (8 * ByteNum);
581 assert(Size >= 1 && Size <= 4 &&
"Invalid size");
583 for (
unsigned i = 0; i <
Size; ++i) {
584 if (Value & 0xff) count++;
602 Value = (Value >> 8) | 0xa00;
617 if (Value >= 0x100 && Value <= 0xff00)
618 Value = (Value >> 8) | 0x200;
619 else if (Value > 0xffff && Value <= 0xff0000)
620 Value = (Value >> 16) | 0x400;
621 else if (Value > 0xffffff)
622 Value = (Value >> 24) | 0x600;
632 uint8_t Sign = (Imm >> 7) & 0x1;
633 uint8_t Exp = (Imm >> 4) & 0x7;
634 uint8_t Mantissa = Imm & 0xf;
642 I |= ((Exp & 0x4) != 0 ? 0 : 1) << 30;
643 I |= ((Exp & 0x4) != 0 ? 0x1f : 0) << 25;
644 I |= (Exp & 0x3) << 23;
664 if (Exp < -3 || Exp > 4)
666 Exp = ((Exp+3) & 0x7) ^ 4;
668 return ((
int)Sign << 7) | (Exp << 4) | Mantissa;
685 if (Mantissa & 0x7ffff)
688 if ((Mantissa & 0xf) != Mantissa)
692 if (Exp < -3 || Exp > 4)
694 Exp = ((Exp+3) & 0x7) ^ 4;
696 return ((
int)Sign << 7) | (Exp << 4) | Mantissa;
709 uint64_t Mantissa = Imm.
getZExtValue() & 0xfffffffffffffULL;
713 if (Mantissa & 0xffffffffffffULL)
716 if ((Mantissa & 0xf) != Mantissa)
720 if (Exp < -3 || Exp > 4)
722 Exp = ((Exp+3) & 0x7) ^ 4;
724 return ((
int)Sign << 7) | (Exp << 4) | Mantissa;
bool isNEONBytesplat(unsigned Value, unsigned Size)
unsigned encodeNEONi16splat(unsigned Value)
uint64_t getZExtValue() const
Get zero extended value.
bool isNEONi32splat(unsigned Value)
Checks if Value is a correct immediate for instructions like VBIC/VORR.
unsigned getSOImmValImm(unsigned Imm)
getSOImmValImm - Given an encoded imm field for the reg/imm form, return the 8-bit imm value...
unsigned getT2SOImmTwoPartFirst(unsigned Imm)
This class represents lattice values for constants.
int getFP16Imm(const APInt &Imm)
getFP16Imm - Return an 8-bit floating-point version of the 16-bit floating-point value.
unsigned getNEONModImmVal(unsigned ModImm)
unsigned encodeNEONi32splat(unsigned Value)
Encode NEON 32 bits Splat immediate for instructions like VBIC/VORR.
unsigned getAM2IdxMode(unsigned AM2Opc)
const char * getAMSubModeStr(AMSubMode Mode)
int getFP64Imm(const APInt &Imm)
getFP64Imm - Return an 8-bit floating-point version of the 64-bit floating-point value.
bool isSOImmTwoPartVal(unsigned V)
isSOImmTwoPartVal - Return true if the specified value can be obtained by or'ing together two SOImmVa...
unsigned getAM3Opc(AddrOpc Opc, unsigned char Offset, unsigned IdxMode=0)
getAM3Opc - This function encodes the addrmode3 opc field.
unsigned createNEONModImm(unsigned OpCmode, unsigned Val)
unsigned getSOImmTwoPartSecond(unsigned V)
getSOImmTwoPartSecond - If V is a value that satisfies isSOImmTwoPartVal, return the second chunk of ...
std::size_t countLeadingZeros(T Val, ZeroBehavior ZB=ZB_Width)
Count number of 0's from the most significant bit to the least stopping at the first 1...
uint64_t decodeNEONModImm(unsigned ModImm, unsigned &EltBits)
decodeNEONModImm - Decode a NEON modified immediate value into the element value and the element size...
const char * getShiftOpcStr(ShiftOpc Op)
ShiftOpc getAM2ShiftOpc(unsigned AM2Opc)
unsigned getSOImmValRotate(unsigned Imm)
getSOImmValRotate - Try to handle Imm with an immediate shifter operand, computing the rotate amount ...
AMSubMode getAM4SubMode(unsigned Mode)
This file implements a class to represent arbitrary precision integral constant values and operations...
int64_t getSExtValue() const
Get sign extended value.
unsigned char getAM3Offset(unsigned AM3Opc)
unsigned getAM3IdxMode(unsigned AM3Opc)
float getFPImmFloat(unsigned Imm)
auto count(R &&Range, const E &Element) -> typename std::iterator_traits< decltype(adl_begin(Range))>::difference_type
Wrapper function around std::count to count the number of times an element Element occurs in the give...
AddrOpc getAM2Op(unsigned AM2Opc)
unsigned char getAM5Offset(unsigned AM5Opc)
unsigned getAM5Opc(AddrOpc Opc, unsigned char Offset)
getAM5Opc - This function encodes the addrmode5 opc field.
int getT2SOImmValRotateVal(unsigned V)
getT2SOImmValRotateVal - Return the 12-bit encoded representation if the specified value is a rotated...
AddrOpc getAM3Op(unsigned AM3Opc)
std::size_t countTrailingZeros(T Val, ZeroBehavior ZB=ZB_Width)
Count number of 0's from the least significant bit to the most stopping at the first 1...
unsigned getSORegOffset(unsigned Op)
bool isThumbImmShiftedVal(unsigned V)
isThumbImmShiftedVal - Return true if the specified value can be obtained by left shifting a 8-bit im...
unsigned getNEONModImmOpCmode(unsigned ModImm)
This file declares a class to represent arbitrary precision floating point values and provide a varie...
int getT2SOImmVal(unsigned Arg)
getT2SOImmVal - Given a 32-bit immediate, if it is something that can fit into a Thumb-2 shifter_oper...
int getT2SOImmValSplatVal(unsigned V)
getT2SOImmValSplat - Return the 12-bit encoded representation if the specified value can be obtained ...
unsigned getSOImmValRot(unsigned Imm)
getSOImmValRot - Given an encoded imm field for the reg/imm form, return the rotate amount...
unsigned rotr32(unsigned Val, unsigned Amt)
rotr32 - Rotate a 32-bit unsigned value right by a specified # bits.
unsigned getT2SOImmValRotate(unsigned V)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
APInt lshr(unsigned shiftAmt) const
Logical right-shift function.
bool isNEONi16splat(unsigned Value)
Checks if Value is a correct immediate for instructions like VBIC/VORR.
const char * getAddrOpcStr(AddrOpc Op)
bool isT2SOImmTwoPartVal(unsigned Imm)
int getSOImmVal(unsigned Arg)
getSOImmVal - Given a 32-bit immediate, if it is something that can fit into an shifter_operand immed...
unsigned getAM5FP16Opc(AddrOpc Opc, unsigned char Offset)
getAM5FP16Opc - This function encodes the addrmode5fp16 opc field.
unsigned getAM2Opc(AddrOpc Opc, unsigned Imm12, ShiftOpc SO, unsigned IdxMode=0)
unsigned getThumbImmNonShiftedVal(unsigned V)
getThumbImmNonShiftedVal - If V is a value that satisfies isThumbImmShiftedVal, return the non-shiftd...
unsigned getSORegOpc(ShiftOpc ShOp, unsigned Imm)
unsigned getAM2Offset(unsigned AM2Opc)
AddrOpc getAM5FP16Op(unsigned AM5Opc)
Class for arbitrary precision integers.
unsigned getThumbImmValShift(unsigned Imm)
getThumbImmValShift - Try to handle Imm with a 8-bit immediate followed by a left shift...
unsigned getThumbImm16ValShift(unsigned Imm)
getThumbImm16ValShift - Try to handle Imm with a 16-bit immediate followed by a left shift...
ShiftOpc getSORegShOp(unsigned Op)
amdgpu Simplify well known AMD library false Value Value * Arg
bool isThumbImm16ShiftedVal(unsigned V)
isThumbImm16ShiftedVal - Return true if the specified value can be obtained by left shifting a 16-bit...
unsigned getShiftOpcEncoding(ShiftOpc Op)
To bit_cast(const From &from) noexcept
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned getT2SOImmTwoPartSecond(unsigned Imm)
int getFP32Imm(const APInt &Imm)
getFP32Imm - Return an 8-bit floating-point version of the 32-bit floating-point value.
unsigned getAM4ModeImm(AMSubMode SubMode)
LLVM Value Representation.
unsigned rotl32(unsigned Val, unsigned Amt)
rotl32 - Rotate a 32-bit unsigned value left by a specified # bits.
APInt bitcastToAPInt() const
unsigned char getAM5FP16Offset(unsigned AM5Opc)
AddrOpc getAM5Op(unsigned AM5Opc)
unsigned getSOImmTwoPartFirst(unsigned V)
getSOImmTwoPartFirst - If V is a value that satisfies isSOImmTwoPartVal, return the first chunk of it...