[llvm] [AMDGPU] Generate waterfall for calls with SGPR(inreg) argument (PR #146997)
Shilei Tian via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 23 08:17:54 PDT 2025
================
@@ -7312,6 +7311,43 @@ void SIInstrInfo::legalizeOperandsVALUt16(MachineInstr &MI,
legalizeOperandsVALUt16(MI, OpIdx, MRI);
}
+void SIInstrInfo::createWaterFall(MachineInstr *MI, MachineDominatorTree *MDT,
+ ArrayRef<MachineOperand *> ScalarOps,
+ ArrayRef<Register> PhySGPRs) const {
+
+ MachineBasicBlock *MBB = MI->getParent();
+ if (!MBB)
+ return;
+ MachineRegisterInfo &MRI = MBB->getParent()->getRegInfo();
+ const TargetRegisterInfo *TRI = MRI.getTargetRegisterInfo();
+
+ if (MI->getOpcode() == AMDGPU::SI_CALL_ISEL) {
+ // Move everything between ADJCALLSTACKUP and ADJCALLSTACKDOWN and
+ // following copies, we also need to move copies from and to physical
+ // registers into the loop block.
+ unsigned FrameSetupOpcode = this->getCallFrameSetupOpcode();
+ unsigned FrameDestroyOpcode = this->getCallFrameDestroyOpcode();
+
+ // Also move the copies to physical registers into the loop block
+ MachineBasicBlock &MBB = *MI->getParent();
+ MachineBasicBlock::iterator Start(MI);
+ while (Start->getOpcode() != FrameSetupOpcode)
+ --Start;
+ MachineBasicBlock::iterator End(MI);
+ while (End->getOpcode() != FrameDestroyOpcode)
----------------
shiltian wrote:
I suppose frame destroy is always after setup?
https://github.com/llvm/llvm-project/pull/146997
More information about the llvm-commits
mailing list