[PATCH] D143515: [AsmPrinter] Add hook to override constant folding for printing.

Krzysztof Drewniak via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 7 09:50:28 PST 2023


krzysz00 created this revision.
Herald added subscribers: kosarev, foad, kerbowa, hiraditya, arichardson, tpr, jvesely, arsenm.
Herald added a project: All.
krzysz00 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Instead of calling ConstantFoldConstant inside the asm printer, use
foldConstantForPrint(), which can be customized per-target.

(Also, fix printing null pointers of size > 64 bits.)

The motivating example for this change is the expression
ptr addrspace(7) addrcast(ptr null to ptr addrspace(7)) on AMDGPU once
address space 7 has been set to an accurate 128-bit length, which is a
change that will occur in a future commit.

The null pointer will be cast to a 128-bit "null descriptor", that is,
`i128 0`. However, 128-bit values do not fit into MCExpr, and cause
crashes when passed to emitIntValue(). Therefore, we add this constant
folding hook to allow the AMDGPU target to fix up the relevant address
space cast.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143515

Files:
  llvm/include/llvm/CodeGen/AsmPrinter.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.h
  llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143515.495581.patch
Type: text/x-patch
Size: 4663 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230207/51188e28/attachment.bin>


More information about the llvm-commits mailing list