[llvm] [AMDGPU] Add pal metadata 3.0 support to callable pal funcs (PR #67104)

Carl Ritson via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 4 03:57:28 PDT 2023


================
@@ -1098,10 +1098,30 @@ void AMDGPUAsmPrinter::emitPALFunctionMetadata(const MachineFunction &MF) {
   StringRef FnName = MF.getFunction().getName();
   MD->setFunctionScratchSize(FnName, MFI.getStackSize());
 
-  // Set compute registers
-  MD->setRsrc1(CallingConv::AMDGPU_CS,
-               CurrentProgramInfo.getPGMRSrc1(CallingConv::AMDGPU_CS));
-  MD->setRsrc2(CallingConv::AMDGPU_CS, CurrentProgramInfo.getComputePGMRSrc2());
+  if (MD->getPALMajorVersion() < 3) {
+    // Set compute registers
+    MD->setRsrc1(CallingConv::AMDGPU_CS,
+                 CurrentProgramInfo.getPGMRSrc1(CallingConv::AMDGPU_CS));
+    MD->setRsrc2(CallingConv::AMDGPU_CS,
+                 CurrentProgramInfo.getComputePGMRSrc2());
+  } else {
+    MD->setHwStage(CallingConv::AMDGPU_CS, ".ieee_mode",
+                   (bool)CurrentProgramInfo.IEEEMode);
+    MD->setHwStage(CallingConv::AMDGPU_CS, ".wgp_mode",
+                   (bool)CurrentProgramInfo.WgpMode);
+    MD->setHwStage(CallingConv::AMDGPU_CS, ".mem_ordered",
+                   (bool)CurrentProgramInfo.MemOrdered);
+
+    MD->setHwStage(CallingConv::AMDGPU_CS, ".trap_present",
+                   (bool)CurrentProgramInfo.TrapHandlerEnable);
+    MD->setHwStage(CallingConv::AMDGPU_CS, ".excp_en",
+                   CurrentProgramInfo.EXCPEnable);
+
+    const unsigned LdsDwGranularity = 128;
----------------
perlfu wrote:

Is this constant defined anywhere else that we could reuse?

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


More information about the llvm-commits mailing list