23 const int64_t Highest12 = Val >> 52 & 0xFFF;
24 const int64_t Higher20 = Val >> 32 & 0xFFFFF;
25 const int64_t Hi20 = Val >> 12 & 0xFFFFF;
26 const int64_t Lo12 = Val & 0xFFF;
30 if (Highest12 != 0 && SignExtend64<52>(Val) == 0) {
31 Insts.
push_back(
Inst(LoongArch::LU52I_D, SignExtend64<12>(Highest12)));
38 else if (SignExtend32<1>(Lo12 >> 11) == SignExtend32<20>(Hi20))
39 Insts.
push_back(
Inst(LoongArch::ADDI_W, SignExtend64<12>(Lo12)));
41 Insts.
push_back(
Inst(LoongArch::LU12I_W, SignExtend64<20>(Hi20)));
48 if (SignExtend32<1>(Hi20 >> 19) != SignExtend32<20>(Higher20))
49 Insts.
push_back(
Inst(LoongArch::LU32I_D, SignExtend64<20>(Higher20)));
52 if (SignExtend32<1>(Higher20 >> 19) != SignExtend32<12>(Highest12))
53 Insts.
push_back(
Inst(LoongArch::LU52I_D, SignExtend64<12>(Highest12)));
55 size_t N = Insts.
size();
76 switch (Insts[0].Opc) {
80 case LoongArch::LU12I_W:
81 if (Insts[1].Opc == LoongArch::ORI) {
82 TmpVal1 = Insts[1].Imm;
85 TmpVal2 =
static_cast<uint64_t>(Insts[3].Imm) << 52 | TmpVal1;
87 TmpVal1 |=
static_cast<uint64_t>(Insts[0].Imm) << 12;
90 case LoongArch::ADDI_W:
91 TmpVal1 = Insts[0].Imm;
96 uint64_t HighMask = ~((1ULL << (Msb + 1)) - 1);
97 for (; Msb < 64; ++Msb, HighMask = HighMask << 1) {
98 for (
uint64_t Lsb = Msb; Lsb > 0; --Lsb) {
99 uint64_t LowMask = (1ULL << Lsb) - 1;
101 uint64_t LsbToZero = TmpVal1 & ((1ULL << (Msb - Lsb + 1)) - 1);
102 uint64_t MsbToLsb = LsbToZero << Lsb;
103 if ((MsbToLsb | (TmpVal1 & Mask)) == (
uint64_t)Val) {
104 if (Insts[1].Opc == LoongArch::ORI &&
N == 3)
107 Insts.
push_back(
Inst(LoongArch::BSTRINS_D, Msb << 32 | Lsb));
111 LsbToZero = TmpVal2 & ((1ULL << (Msb - Lsb + 1)) - 1);
112 MsbToLsb = LsbToZero << Lsb;
113 if ((MsbToLsb | (TmpVal2 & Mask)) == (
uint64_t)Val) {
117 Insts.
push_back(
Inst(LoongArch::BSTRINS_D, Msb << 32 | Lsb));
void pop_back_n(size_type NumItems)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
InstSeq generateInstSeq(int64_t Val)
This is an optimization pass for GlobalISel generic memory operations.