14 #ifndef LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMADDRESSINGMODES_H 15 #define LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMADDRESSINGMODES_H 84 inline unsigned rotr32(
unsigned Val,
unsigned Amt) {
85 assert(Amt < 32 &&
"Invalid rotate amount");
86 return (Val >> Amt) | (Val << ((32-Amt)&31));
91 inline unsigned rotl32(
unsigned Val,
unsigned Amt) {
92 assert(Amt < 32 &&
"Invalid rotate amount");
93 return (Val << Amt) | (Val >> ((32-Amt)&31));
111 return ShOp | (Imm << 3);
130 if ((Imm & ~255U) == 0)
return 0;
137 unsigned RotAmt = TZ & ~1;
140 if ((
rotr32(Imm, RotAmt) & ~255U) == 0)
141 return (32-RotAmt)&31;
147 unsigned RotAmt2 = TZ2 & ~1;
148 if ((
rotr32(Imm, RotAmt2) & ~255U) == 0)
149 return (32-RotAmt2)&31;
155 return (32-RotAmt)&31;
164 if ((Arg & ~255U) == 0)
return Arg;
169 if (
rotr32(~255U, RotAmt) & Arg)
173 return rotl32(Arg, RotAmt) | ((RotAmt>>1) << 8);
211 if ((Imm & ~255U) == 0)
return 0;
230 if ((Imm & ~65535U) == 0)
return 0;
263 if ((V & 0xffffff00) == 0)
267 Vs = ((V & 0xff) == 0) ? V >> 8 : V;
271 u = Imm | (Imm << 16);
275 return (((Vs == V) ? 1 : 2) << 8) | Imm;
278 if (Vs == (u | (u << 8)))
279 return (3 << 8) | Imm;
294 if ((
rotr32(0xff000000U, RotAmt) & V) == V)
295 return (
rotr32(V, 24 - RotAmt) & 0x7f) | ((RotAmt + 8) << 7);
319 if ((V & ~255U) == 0)
return 0;
322 return (32 - RotAmt) & 31;
354 "Immedate cannot be encoded as two part immediate!");
362 return Imm & 0xff00ff00U;
366 return Imm & 0x00ff00ffU;
374 "Unable to encode second part of T2 two part SO immediate");
398 unsigned IdxMode = 0) {
399 assert(Imm12 < (1 << 12) &&
"Imm too large!");
400 bool isSub = Opc ==
sub;
401 return Imm12 | ((int)isSub << 12) | (SO << 13) | (IdxMode << 16) ;
404 return AM2Opc & ((1 << 12)-1);
407 return ((AM2Opc >> 12) & 1) ?
sub :
add;
410 return (
ShiftOpc)((AM2Opc >> 13) & 7);
430 unsigned IdxMode = 0) {
431 bool isSub = Opc ==
sub;
432 return ((
int)isSub << 8) | Offset | (IdxMode << 9);
434 inline unsigned char getAM3Offset(
unsigned AM3Opc) {
return AM3Opc & 0xFF; }
436 return ((AM3Opc >> 8) & 1) ?
sub :
add;
474 bool isSub = Opc ==
sub;
475 return ((
int)isSub << 8) |
Offset;
477 inline unsigned char getAM5Offset(
unsigned AM5Opc) {
return AM5Opc & 0xFF; }
479 return ((AM5Opc >> 8) & 1) ?
sub :
add;
495 bool isSub = Opc ==
sub;
496 return ((
int)isSub << 8) |
Offset;
499 return AM5Opc & 0xFF;
502 return ((AM5Opc >> 8) & 1) ?
sub :
add;
531 return (OpCmode << 8) | Val;
534 return (ModImm >> 8) & 0x1f;
546 if (OpCmode == 0xe) {
550 }
else if ((OpCmode & 0xc) == 0x8) {
552 unsigned ByteNum = (OpCmode & 0x6) >> 1;
553 Val = Imm8 << (8 * ByteNum);
555 }
else if ((OpCmode & 0x8) == 0) {
557 unsigned ByteNum = (OpCmode & 0x6) >> 1;
558 Val = Imm8 << (8 * ByteNum);
560 }
else if ((OpCmode & 0xe) == 0xc) {
562 unsigned ByteNum = 1 + (OpCmode & 0x1);
563 Val = (Imm8 << (8 * ByteNum)) | (0xffff >> (8 * (2 - ByteNum)));
565 }
else if (OpCmode == 0x1e) {
567 for (
unsigned ByteNum = 0; ByteNum < 8; ++ByteNum) {
568 if ((ModImm >> ByteNum) & 1)
569 Val |= (uint64_t)0xff << (8 * ByteNum);
580 assert(Size >= 1 && Size <= 4 &&
"Invalid size");
582 for (
unsigned i = 0; i <
Size; ++i) {
583 if (Value & 0xff) count++;
601 Value = (Value >> 8) | 0xa00;
616 if (Value >= 0x100 && Value <= 0xff00)
617 Value = (Value >> 8) | 0x200;
618 else if (Value > 0xffff && Value <= 0xff0000)
619 Value = (Value >> 16) | 0x400;
620 else if (Value > 0xffffff)
621 Value = (Value >> 24) | 0x600;
635 uint8_t Sign = (Imm >> 7) & 0x1;
636 uint8_t Exp = (Imm >> 4) & 0x7;
637 uint8_t Mantissa = Imm & 0xf;
645 FPUnion.I |= Sign << 31;
646 FPUnion.I |= ((Exp & 0x4) != 0 ? 0 : 1) << 30;
647 FPUnion.I |= ((Exp & 0x4) != 0 ? 0x1f : 0) << 25;
648 FPUnion.I |= (Exp & 0x3) << 23;
649 FPUnion.I |= Mantissa << 19;
668 if (Exp < -3 || Exp > 4)
670 Exp = ((Exp+3) & 0x7) ^ 4;
672 return ((
int)Sign << 7) | (Exp << 4) | Mantissa;
689 if (Mantissa & 0x7ffff)
692 if ((Mantissa & 0xf) != Mantissa)
696 if (Exp < -3 || Exp > 4)
698 Exp = ((Exp+3) & 0x7) ^ 4;
700 return ((
int)Sign << 7) | (Exp << 4) | Mantissa;
713 uint64_t Mantissa = Imm.
getZExtValue() & 0xfffffffffffffULL;
717 if (Mantissa & 0xffffffffffffULL)
720 if ((Mantissa & 0xf) != Mantissa)
724 if (Exp < -3 || Exp > 4)
726 Exp = ((Exp+3) & 0x7) ^ 4;
728 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)
Compute iterated dominance frontiers using a linear time algorithm.
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)
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.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
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...