Lines Matching full:hi

35   bool detectFoldable(MachineInstr &Hi, MachineInstr *&Lo);
37 bool detectAndFoldOffset(MachineInstr &Hi, MachineInstr &Lo);
38 void foldOffset(MachineInstr &Hi, MachineInstr &Lo, MachineInstr &Tail,
40 bool foldLargeOffset(MachineInstr &Hi, MachineInstr &Lo,
42 bool foldShiftedOffset(MachineInstr &Hi, MachineInstr &Lo,
45 bool foldIntoMemoryOps(MachineInstr &Hi, MachineInstr &Lo);
72 // lui vreg1, %hi(s)
85 bool RISCVMergeBaseOffsetOpt::detectFoldable(MachineInstr &Hi,
87 if (Hi.getOpcode() != RISCV::LUI && Hi.getOpcode() != RISCV::AUIPC &&
88 Hi.getOpcode() != RISCV::PseudoMovAddr)
91 const MachineOperand &HiOp1 = Hi.getOperand(1);
93 Hi.getOpcode() == RISCV::AUIPC ? RISCVII::MO_PCREL_HI : RISCVII::MO_HI;
101 if (Hi.getOpcode() == RISCV::PseudoMovAddr) {
103 // setting Lo and Hi both point to PseudoMovAddr
104 Lo = &Hi;
106 Register HiDestReg = Hi.getOperand(0).getReg();
116 if (Hi.getOpcode() == RISCV::LUI || Hi.getOpcode() == RISCV::PseudoMovAddr) {
122 assert(Hi.getOpcode() == RISCV::AUIPC);
142 // Update the offset in Hi and Lo instructions.
145 void RISCVMergeBaseOffsetOpt::foldOffset(MachineInstr &Hi, MachineInstr &Lo,
148 // Put the offset back in Hi and the Lo
149 Hi.getOperand(1).setOffset(Offset);
150 if (Hi.getOpcode() != RISCV::AUIPC)
158 << " " << Hi << " " << Lo;);
162 // If the pattern is found, updates the offset in Hi and Lo instructions
166 // Hi: lui vreg1, %hi(s)
181 bool RISCVMergeBaseOffsetOpt::foldLargeOffset(MachineInstr &Hi,
197 // The offset value has non zero bits in both %hi and %lo parts.
208 foldOffset(Hi, Lo, TailAdd, OffLo);
229 foldOffset(Hi, Lo, TailAdd, Offset);
238 foldOffset(Hi, Lo, TailAdd, Offset);
249 // If the pattern is found, updates the offset in Hi and Lo instructions
252 // Hi: lui vreg1, %hi(s)
256 bool RISCVMergeBaseOffsetOpt::foldShiftedOffset(MachineInstr &Hi,
297 foldOffset(Hi, Lo, TailShXAdd, Offset);
302 bool RISCVMergeBaseOffsetOpt::detectAndFoldOffset(MachineInstr &Hi,
330 foldOffset(Hi, Lo, TailTail, Offset);
337 foldOffset(Hi, Lo, Tail, Offset);
346 // both hi 20 and lo 12 bits.
349 return foldLargeOffset(Hi, Lo, Tail, DestReg);
356 return foldShiftedOffset(Hi, Lo, Tail, DestReg);
362 bool RISCVMergeBaseOffsetOpt::foldIntoMemoryOps(MachineInstr &Hi,
369 // Hi: lui vreg1, %hi(foo) ---> lui vreg1, %hi(foo+8)
374 // Hi: 1:auipc vreg1, %pcrel_hi(s) ---> auipc vreg1, %pcrel_hi(foo+8)
474 int64_t NewOffset = Hi.getOperand(1).getOffset() + *CommonOffset;
482 Hi.getOperand(1).setOffset(NewOffset);
485 if (Hi.getOpcode() == RISCV::PseudoMovAddr) {
487 Hi.setDesc(TII->get(RISCV::LUI));
488 Hi.removeOperand(2);
491 if (Hi.getOpcode() != RISCV::AUIPC)
526 // Prevent Lo (originally PseudoMovAddr, which is also pointed by Hi) from
528 if (&Lo == &Hi)
531 MRI->replaceRegWith(Lo.getOperand(0).getReg(), Hi.getOperand(0).getReg());
546 for (MachineInstr &Hi : MBB) {
548 if (!detectFoldable(Hi, Lo))
550 MadeChange |= detectAndFoldOffset(Hi, *Lo);
551 MadeChange |= foldIntoMemoryOps(Hi, *Lo);