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