14 #ifndef LLVM_TARGET_ARM_ARMADDRESSINGMODES_H
15 #define LLVM_TARGET_ARM_ARMADDRESSINGMODES_H
42 return Op ==
sub ?
"-" :
"";
86 static inline unsigned rotr32(
unsigned Val,
unsigned Amt) {
87 assert(Amt < 32 &&
"Invalid rotate amount");
88 return (Val >> Amt) | (Val << ((32-Amt)&31));
93 static 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);
130 return (Imm >> 8) * 2;
140 if ((Imm & ~255U) == 0)
return 0;
147 unsigned RotAmt = TZ & ~1;
150 if ((
rotr32(Imm, RotAmt) & ~255U) == 0)
151 return (32-RotAmt)&31;
157 unsigned RotAmt2 = TZ2 & ~1;
158 if ((
rotr32(Imm, RotAmt2) & ~255U) == 0)
159 return (32-RotAmt2)&31;
165 return (32-RotAmt)&31;
174 if ((Arg & ~255U) == 0)
return Arg;
179 if (
rotr32(~255U, RotAmt) & Arg)
183 return rotl32(Arg, RotAmt) | ((RotAmt>>1) << 8);
221 if ((Imm & ~255U) == 0)
return 0;
240 if ((Imm & ~65535U) == 0)
return 0;
273 if ((V & 0xffffff00) == 0)
277 Vs = ((V & 0xff) == 0) ? V >> 8 : V;
281 u = Imm | (Imm << 16);
285 return (((Vs == V) ? 1 : 2) << 8) | Imm;
288 if (Vs == (u | (u << 8)))
289 return (3 << 8) | Imm;
304 if ((
rotr32(0xff000000U, RotAmt) & V) == V)
305 return (
rotr32(V, 24 - RotAmt) & 0x7f) | ((RotAmt + 8) << 7);
329 if ((V & ~255U) == 0)
return 0;
332 return (32 - RotAmt) & 31;
364 "Immedate cannot be encoded as two part immediate!");
372 return Imm & 0xff00ff00U;
376 return Imm & 0x00ff00ffU;
384 "Unable to encode second part of T2 two part SO immediate");
408 unsigned IdxMode = 0) {
409 assert(Imm12 < (1 << 12) &&
"Imm too large!");
410 bool isSub = Opc ==
sub;
411 return Imm12 | ((int)isSub << 12) | (SO << 13) | (IdxMode << 16) ;
414 return AM2Opc & ((1 << 12)-1);
417 return ((AM2Opc >> 12) & 1) ?
sub :
add;
420 return (
ShiftOpc)((AM2Opc >> 13) & 7);
423 return (AM2Opc >> 16);
443 unsigned IdxMode = 0) {
444 bool isSub = Opc ==
sub;
445 return ((
int)isSub << 8) | Offset | (IdxMode << 9);
448 return AM3Opc & 0xFF;
451 return ((AM3Opc >> 8) & 1) ?
sub :
add;
454 return (AM3Opc >> 9);
493 bool isSub = Opc ==
sub;
494 return ((
int)isSub << 8) | Offset;
497 return AM5Opc & 0xFF;
500 return ((AM5Opc >> 8) & 1) ?
sub :
add;
529 return (OpCmode << 8) | Val;
532 return (ModImm >> 8) & 0x1f;
535 return ModImm & 0xff;
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);
590 uint8_t Sign = (Imm >> 7) & 0x1;
591 uint8_t Exp = (Imm >> 4) & 0x7;
592 uint8_t Mantissa = Imm & 0xf;
600 FPUnion.I |= Sign << 31;
601 FPUnion.I |= ((Exp & 0x4) != 0 ? 0 : 1) << 30;
602 FPUnion.I |= ((Exp & 0x4) != 0 ? 0x1f : 0) << 25;
603 FPUnion.I |= (Exp & 0x3) << 23;
604 FPUnion.I |= Mantissa << 19;
618 if (Mantissa & 0x7ffff)
621 if ((Mantissa & 0xf) != Mantissa)
625 if (Exp < -3 || Exp > 4)
627 Exp = ((Exp+3) & 0x7) ^ 4;
629 return ((
int)Sign << 7) | (Exp << 4) | Mantissa;
642 uint64_t Mantissa = Imm.
getZExtValue() & 0xfffffffffffffULL;
646 if (Mantissa & 0xffffffffffffULL)
649 if ((Mantissa & 0xf) != Mantissa)
653 if (Exp < -3 || Exp > 4)
655 Exp = ((Exp+3) & 0x7) ^ 4;
657 return ((
int)Sign << 7) | (Exp << 4) | Mantissa;
AMSubMode getLoadStoreMultipleSubMode(int Opcode)
uint64_t getZExtValue() const
Get zero extended value.
static unsigned char getAM3Offset(unsigned AM3Opc)
static unsigned getSORegOpc(ShiftOpc ShOp, unsigned Imm)
static unsigned getNEONModImmOpCmode(unsigned ModImm)
static unsigned getAM5Opc(AddrOpc Opc, unsigned char Offset)
getAM5Opc - This function encodes the addrmode5 opc field.
static const char * getShiftOpcStr(ShiftOpc Op)
static unsigned getThumbImmNonShiftedVal(unsigned V)
static unsigned getT2SOImmValRotate(unsigned V)
static unsigned rotl32(unsigned Val, unsigned Amt)
static unsigned getSOImmValRotate(unsigned Imm)
static unsigned rotr32(unsigned Val, unsigned Amt)
static unsigned getAM3IdxMode(unsigned AM3Opc)
#define llvm_unreachable(msg)
static int getT2SOImmValSplatVal(unsigned V)
APInt LLVM_ATTRIBUTE_UNUSED_RESULT lshr(unsigned shiftAmt) const
Logical right-shift function.
static AMSubMode getAM4SubMode(unsigned Mode)
enable_if_c< std::numeric_limits< T >::is_integer &&!std::numeric_limits< T >::is_signed, std::size_t >::type 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...
This file implements a class to represent arbitrary precision integral constant values and operations...
static unsigned getT2SOImmTwoPartFirst(unsigned Imm)
static unsigned createNEONModImm(unsigned OpCmode, unsigned Val)
enable_if_c< std::numeric_limits< T >::is_integer &&!std::numeric_limits< T >::is_signed, std::size_t >::type 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...
static int getT2SOImmVal(unsigned Arg)
static unsigned getAM4ModeImm(AMSubMode SubMode)
static int getFP32Imm(const APInt &Imm)
static bool isThumbImmShiftedVal(unsigned V)
static unsigned getAM2IdxMode(unsigned AM2Opc)
static unsigned getSOImmValRot(unsigned Imm)
A self-contained host- and target-independent arbitrary-precision floating-point software implementat...
static unsigned getAM2Opc(AddrOpc Opc, unsigned Imm12, ShiftOpc SO, unsigned IdxMode=0)
static unsigned char getAM5Offset(unsigned AM5Opc)
static unsigned getSOImmTwoPartSecond(unsigned V)
int64_t getSExtValue() const
Get sign extended value.
static unsigned getSOImmValImm(unsigned Imm)
static unsigned getT2SOImmTwoPartSecond(unsigned Imm)
This file declares a class to represent arbitrary precision floating point values and provide a varie...
static int getT2SOImmValRotateVal(unsigned V)
static const char * getAddrOpcStr(AddrOpc Op)
static AddrOpc getAM2Op(unsigned AM2Opc)
static int getFP64Imm(const APInt &Imm)
static unsigned getThumbImm16ValShift(unsigned Imm)
static unsigned getAM2Offset(unsigned AM2Opc)
static unsigned getNEONModImmVal(unsigned ModImm)
static unsigned getShiftOpcEncoding(ShiftOpc Op)
static bool isSOImmTwoPartVal(unsigned V)
Class for arbitrary precision integers.
static bool isThumbImm16ShiftedVal(unsigned V)
static AddrOpc getAM3Op(unsigned AM3Opc)
APInt bitcastToAPInt() const
static unsigned getAM3Opc(AddrOpc Opc, unsigned char Offset, unsigned IdxMode=0)
getAM3Opc - This function encodes the addrmode3 opc field.
static int getSOImmVal(unsigned Arg)
static const char * getAMSubModeStr(AMSubMode Mode)
static AddrOpc getAM5Op(unsigned AM5Opc)
static ShiftOpc getAM2ShiftOpc(unsigned AM2Opc)
static unsigned getSORegOffset(unsigned Op)
static unsigned getThumbImmValShift(unsigned Imm)
static bool isT2SOImmTwoPartVal(unsigned Imm)
static unsigned getSOImmTwoPartFirst(unsigned V)
static float getFPImmFloat(unsigned Imm)
static ShiftOpc getSORegShOp(unsigned Op)
static uint64_t decodeNEONModImm(unsigned ModImm, unsigned &EltBits)