[PATCH] D74527: AMDGPU/GlobalISel: Support llvm.trap intrinsic

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 13 09:19:47 PST 2020


arsenm added inline comments.


================
Comment at: llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp:1114-1131
+  } else {
+    // Pass queue pointer to trap handler as input
+    // Reference: https://llvm.org/docs/AMDGPUUsage.html#trap-handler-abi
+    unsigned RegNo =
+        MF->getInfo<SIMachineFunctionInfo>()->getQueuePtrUserSGPR();
+    assert(RegNo != AMDGPU::NoRegister);
+    Register SrcReg = Register(RegNo);
----------------
hsmhsm wrote:
> arsenm wrote:
> > I would factor all of this into a helper function. This is also basically identical to AMDGPULegalizerInfo::loadInputValue, so you could just move this handling into the legalizer
> I think, there is no straightforward way to use Legalizer within IRTranslator? 
> 
> I can do STI.getLegalizerInfo(), but it won't help to call AMDGPULegalizerInfo::loadInputValue() as it is not a general virtually callable API, but, it is a kind of helper function specific to AMDGPU. 
> 
> I again need to explicitly cast STI.getLegalizerInfo() into AMDGPULegalizerInfo*, in order to loadInputValue(). I am not sure, if it is something worth doing it here.
The IRTranslator isn't involved. The decision to put this in the legalizer or in selection is somewhat arbitrary. We handle the other intrinsics in the legalizer now, so you might as well put this there as well.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74527/new/

https://reviews.llvm.org/D74527





More information about the llvm-commits mailing list