[llvm] [AMDGPU] Add support for preloading implicit kernel arguments (PR #83817)

Austin Kerbow via llvm-commits llvm-commits at lists.llvm.org
Sun May 5 22:55:25 PDT 2024


================
@@ -5495,6 +5495,34 @@ bool AMDGPULegalizerInfo::legalizeLDSKernelId(MachineInstr &MI,
   return true;
 }
 
+bool AMDGPULegalizerInfo::legalizePreloadImplicitarg(
+    MachineInstr &MI, MachineRegisterInfo &MRI, MachineIRBuilder &B) const {
+  assert(ST.hasKernargPreload());
+  MachineFunction &MF = B.getMF();
+  Register OrigReg = MI.getOperand(0).getReg();
+  const SIMachineFunctionInfo *MFI = MF.getInfo<SIMachineFunctionInfo>();
+  // A unique identifier defined as the offset from start of implicit args added
+  // to the number of formal args.
+  unsigned ImplictArgIdx =
+      MI.getOperand(2).getImm() + MF.getFunction().arg_size();
+  auto &ArgDesc =
+      MFI->getArgInfo().PreloadKernArgs.find(ImplictArgIdx)->getSecond();
----------------
kerbowa wrote:

Here, it is a byte offset from the start of the implicit arg ptr plus the index of the last explicit argument so that there are no overlaps.  I've changed it to be the raw offset into the kernarg segment.

https://github.com/llvm/llvm-project/pull/83817


More information about the llvm-commits mailing list