13 #ifndef LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMADDRESSINGMODES_H 14 #define LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMADDRESSINGMODES_H 86 inline unsigned rotr32(
unsigned Val,
unsigned Amt) {
87 assert(Amt < 32 &&
"Invalid rotate amount");
88 return (Val >> Amt) | (Val << ((32-Amt)&31));
93 inline unsigned rotl32(
unsigned Val,
unsigned Amt) {
94 assert(Amt < 32 &&
"Invalid rotate amount");
95 return (Val << Amt) | (Val >> ((32-Amt)&31));
113 return ShOp | (Imm << 3);
132 if ((Imm & ~255U) == 0)
return 0;
139 unsigned RotAmt = TZ & ~1;
142 if ((
rotr32(Imm, RotAmt) & ~255U) == 0)
143 return (32-RotAmt)&31;
149 unsigned RotAmt2 = TZ2 & ~1;
150 if ((
rotr32(Imm, RotAmt2) & ~255U) == 0)
151 return (32-RotAmt2)&31;
157 return (32-RotAmt)&31;
166 if ((Arg & ~255U) == 0)
return Arg;
171 if (
rotr32(~255U, RotAmt) & Arg)
175 return rotl32(Arg, RotAmt) | ((RotAmt>>1) << 8);
213 if ((Imm & ~255U) == 0)
return 0;
232 if ((Imm & ~65535U) == 0)
return 0;
265 if ((V & 0xffffff00) == 0)
269 Vs = ((V & 0xff) == 0) ? V >> 8 : V;
273 u = Imm | (Imm << 16);
277 return (((Vs == V) ? 1 : 2) << 8) | Imm;
280 if (Vs == (u | (u << 8)))
281 return (3 << 8) | Imm;
296 if ((
rotr32(0xff000000U, RotAmt) & V) == V)
297 return (
rotr32(V, 24 - RotAmt) & 0x7f) | ((RotAmt + 8) << 7);
321 if ((V & ~255U) == 0)
return 0;
324 return (32 - RotAmt) & 31;
356 "Immedate cannot be encoded as two part immediate!");
364 return Imm & 0xff00ff00U;
368 return Imm & 0x00ff00ffU;
376 "Unable to encode second part of T2 two part SO immediate");
400 unsigned IdxMode = 0) {
401 assert(Imm12 < (1 << 12) &&
"Imm too large!");
402 bool isSub = Opc ==
sub;
403 return Imm12 | ((int)isSub << 12) | (SO << 13) | (IdxMode << 16) ;
406 return AM2Opc & ((1 << 12)-1);
409 return ((AM2Opc >> 12) & 1) ?
sub :
add;
412 return (
ShiftOpc)((AM2Opc >> 13) & 7);
432 unsigned IdxMode = 0) {
433 bool isSub = Opc ==
sub;
434 return ((
int)isSub << 8) | Offset | (IdxMode << 9);
436 inline unsigned char getAM3Offset(
unsigned AM3Opc) {
return AM3Opc & 0xFF; }
438 return ((AM3Opc >> 8) & 1) ?
sub :
add;
476 bool isSub = Opc ==
sub;
477 return ((
int)isSub << 8) |
Offset;
479 inline unsigned char getAM5Offset(
unsigned AM5Opc) {
return AM5Opc & 0xFF; }
481 return ((AM5Opc >> 8) & 1) ?
sub :
add;
497 bool isSub = Opc ==
sub;
498 return ((
int)isSub << 8) |
Offset;
501 return AM5Opc & 0xFF;
504 return ((AM5Opc >> 8) & 1) ?
sub :
add;
533 return (OpCmode << 8) | Val;
536 return (ModImm >> 8) & 0x1f;
548 if (OpCmode == 0xe) {
552 }
else if ((OpCmode & 0xc) == 0x8) {
554 unsigned ByteNum = (OpCmode & 0x6) >> 1;
555 Val = Imm8 << (8 * ByteNum);
557 }
else if ((OpCmode & 0x8) == 0) {
559 unsigned ByteNum = (OpCmode & 0x6) >> 1;
560 Val = Imm8 << (8 * ByteNum);
562 }
else if ((OpCmode & 0xe) == 0xc) {
564 unsigned ByteNum = 1 + (OpCmode & 0x1);
565 Val = (Imm8 << (8 * ByteNum)) | (0xffff >> (8 * (2 - ByteNum)));
567 }
else if (OpCmode == 0x1e) {
569 for (
unsigned ByteNum = 0; ByteNum < 8; ++ByteNum) {
570 if ((ModImm >> ByteNum) & 1)
571 Val |= (uint64_t)0xff << (8 * ByteNum);
582 assert(Size >= 1 && Size <= 4 &&
"Invalid size");
584 for (
unsigned i = 0; i <
Size; ++i) {
585 if (Value & 0xff) count++;
603 Value = (Value >> 8) | 0xa00;
618 if (Value >= 0x100 && Value <= 0xff00)
619 Value = (Value >> 8) | 0x200;
620 else if (Value > 0xffff && Value <= 0xff0000)
621 Value = (Value >> 16) | 0x400;
622 else if (Value > 0xffffff)
623 Value = (Value >> 24) | 0x600;
633 uint8_t Sign = (Imm >> 7) & 0x1;
634 uint8_t Exp = (Imm >> 4) & 0x7;
635 uint8_t Mantissa = Imm & 0xf;
643 I |= ((Exp & 0x4) != 0 ? 0 : 1) << 30;
644 I |= ((Exp & 0x4) != 0 ? 0x1f : 0) << 25;
645 I |= (Exp & 0x3) << 23;
665 if (Exp < -3 || Exp > 4)
667 Exp = ((Exp+3) & 0x7) ^ 4;
669 return ((
int)Sign << 7) | (Exp << 4) | Mantissa;
686 if (Mantissa & 0x7ffff)
689 if ((Mantissa & 0xf) != Mantissa)
693 if (Exp < -3 || Exp > 4)
695 Exp = ((Exp+3) & 0x7) ^ 4;
697 return ((
int)Sign << 7) | (Exp << 4) | Mantissa;
710 uint64_t Mantissa = Imm.
getZExtValue() & 0xfffffffffffffULL;
714 if (Mantissa & 0xffffffffffffULL)
717 if ((Mantissa & 0xf) != Mantissa)
721 if (Exp < -3 || Exp > 4)
723 Exp = ((Exp+3) & 0x7) ^ 4;
725 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 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 getSOImmTwoPartSecond(unsigned V)
getSOImmTwoPartSecond - If V is a value that satisfies isSOImmTwoPartVal, return the second chunk of ...
unsigned getVMOVModImmVal(unsigned ModImm)
unsigned 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...
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)
uint64_t decodeVMOVModImm(unsigned ModImm, unsigned &EltBits)
decodeVMOVModImm - Decode a NEON/MVE modified immediate value into the element value and the element ...
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)
unsigned createVMOVModImm(unsigned OpCmode, unsigned Val)
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)
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...
This file declares a class to represent arbitrary precision floating point values and provide a varie...
unsigned getVMOVModImmOpCmode(unsigned ModImm)
int getT2SOImmVal(unsigned Arg)
getT2SOImmVal - Given a 32-bit immediate, if it is something that can fit into a Thumb-2 shifter_oper...
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
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)
unsigned 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...
#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)
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...