[PATCH] D110413: [X86] Fix handling of i128<->fp on Windows

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 24 06:28:28 PDT 2021


mstorsjo created this revision.
mstorsjo added a reviewer: rnk.
Herald added subscribers: pengfei, hiraditya.
mstorsjo requested review of this revision.
Herald added a project: LLVM.

On Windows, i128 arguments are passed as indirect arguments, and
they are returned in xmm0.

This is mostly fixed up by `WinX86_64ABIInfo::classify` in Clang, making
the IR functions return v2i64 instead of i128, and making the arguments
indirect. However for cases where libcalls are generated in the target
lowering, the lowering uses the default x86_64 calling convention for
i128, where they are passed/returned as a register pair.

Add custom lowering logic, similar to the existing logic for i128
div/mod (added in 4a406d32e97b1748c4eed6674a2c1819b9cf98ea),
manually making the libcall (while overriding the return type to
v2i64 or passing the arguments as pointers to arguments on the stack).

X86CallingConv.td doesn't seem to handle i128 at all, otherwise
the windows specific behaviours would ideally be implemented as
overrides there, in generic code, handling these cases automatically.

This fixes https://bugs.llvm.org/show_bug.cgi?id=48940.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110413

Files:
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.h
  llvm/test/CodeGen/X86/i128-fpconv-win64-strict.ll
  llvm/test/CodeGen/X86/i128-fpconv-win64.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110413.374826.patch
Type: text/x-patch
Size: 20913 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210924/7c761198/attachment.bin>


More information about the llvm-commits mailing list