[PATCH] D129291: [NVPTX] Promote i24, i40, i48 and i56 to next power-of-two register when passing

Kjetil Kjeka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 7 07:29:07 PDT 2022


kjetilkjeka created this revision.
kjetilkjeka added a reviewer: jholewinski.
Herald added subscribers: mattd, gchakrabarti, asavonic, JDevlieghere, hiraditya.
Herald added a project: All.
kjetilkjeka requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Today llc will crash when attempting to use non-power-of-two integer types as function arguments or returns. This patch enables passing non standard integer values in functions by promoting them before store and truncating after load.

The main motivation of implementing this change is that rust casts small structs (less than pointer size) into an integer of the same size. As an example, if a struct contains three u8 then it will be passed as an i24. This patch is a step towards enabling rust compilation to ptx while retaining the target independent optimizations.

The tests reflects that it is mostly the multiple of 8 integers less than 64 that is of interest. I have locally tested some non-multiple-of-eight integers but decided against writing tests for them as nothing should really rely on them. Let me know if you want a few of those in addition.

More context can be found in my original github issue <https://github.com/llvm/llvm-project/issues/55764>

---

This is my first LLVM contribution and I hope I have done everything by your contribution guide. Let me know if I should fix anything and I will do my best to get it done. I'm also not very familiar with the LLVM codebase yet and I have not received any external input on the content of this patch beyond the test passing. If anything looks fishy it is probably something I have misunderstood.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129291

Files:
  llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
  llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
  llvm/test/CodeGen/NVPTX/i24-param.ll
  llvm/test/CodeGen/NVPTX/i40-param.ll
  llvm/test/CodeGen/NVPTX/i48-param.ll
  llvm/test/CodeGen/NVPTX/i56-param.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129291.442901.patch
Type: text/x-patch
Size: 11910 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220707/a37264b8/attachment.bin>


More information about the llvm-commits mailing list