Lines Matching defs: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);
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,
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);
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)
478 int64_t NewOffset = Hi.getOperand(1).getOffset() + *CommonOffset;
486 Hi.getOperand(1).setOffset(NewOffset);
489 if (Hi.getOpcode() == RISCV::PseudoMovAddr) {
491 Hi.setDesc(TII->get(RISCV::LUI));
492 Hi.removeOperand(2);
495 if (Hi.getOpcode() != RISCV::AUIPC)
530 // Prevent Lo (originally PseudoMovAddr, which is also pointed by Hi) from
532 if (&Lo == &Hi)
535 MRI->replaceRegWith(Lo.getOperand(0).getReg(), Hi.getOperand(0).getReg());
550 for (MachineInstr &Hi : MBB) {
552 if (!detectFoldable(Hi, Lo))
554 MadeChange |= detectAndFoldOffset(Hi, *Lo);
555 MadeChange |= foldIntoMemoryOps(Hi, *Lo);