Trevor Gross 8b6a18ecaf x86-64: mingw: Pass and return _Float16 in vector registers [PR115054]
For MinGW on x86-64, GCC currently passes and returns `_Float16` in
GPRs. Microsoft does not specify an ABI for the type so this is purely
an extension; however, there are a few reasons the current ABI is not
ideal:

1. `float` and `double` are both passed and returned in xmm registers
   under the MSVC ABI, there isn't any reason for `_Float16` to deviate.
2. `_Float16` is returned in xmm0 on Windows x86-32 by both GCC and
   Clang.
3. There is a platform-natural ABI with AVX512-FP16, which requires
   half-precision operands to be in vector registers.
4. System V uses vector registers for `_Float16`.

Thus, update the `HFmode` ABI to both pass and return in vector
registers, meaning its ABI is now identical to `float` and `double`.
This is already Clang's behavior on both its x64 MSVC and MinGW targets,
so the change here also resolves an ABI incompatibility (originally
reported in linked issue).

The results can be verified by evaluating the change in assembly output
with this source:

    void pass_f16(_Float16 x, _Float16 *dst) {
        *dst = x;
    }

    void callee_f16(_Float16);
    void call_f16() {
        callee_f16(1.0);
    }

    _Float16 ret_f16(_Float16 *x) {
        return *x;
    }

    /* Check libcall ABI */

    void extend_f16(_Float16 *x, _Float32 *dst) {
        *dst = (_Float32)*x;
    }

    void trunc_f16(_Float32 *x, _Float16 *dst) {
        *dst = (_Float16)*x;
    }

    /* Float varargs should be in vregs with a zeroed shadow GPR */

    void va(_Float16, ...);
    void va_f16() {
        va(1.0f16, 2.0f16, 3.0f16, 4.0f16, 5.0f16);
    }

While modifying the `function_value_ms_64` `switch` statement, a
redundant condition and trailing whitespace in the 16-byte case is
cleaned up.

2025-09-13  Trevor Gross  <tmgross@umich.edu>

gcc:
	PR target/115054
	* config/i386/i386.cc (function_arg_ms_64,
	function_value_ms_64): Pass and return _Float16 in vector
	registers on Windows.

Signed-off-by: Trevor Gross <tmgross@umich.edu>
Signed-off-by: Jonathan Yong <10walls@gmail.com>
2025-10-08 12:17:30 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-08-29 00:19:55 +00:00
2025-06-23 00:16:33 +00:00
2025-08-17 00:19:17 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-09-24 00:21:37 +00:00
2025-10-05 16:50:51 +00:00
2025-10-08 00:20:55 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-10-08 00:20:55 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-09-02 00:19:26 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.
Description
No description provided
Readme 2.7 GiB
Languages
C++ 30.7%
C 30.1%
Ada 14.4%
D 6.1%
Go 5.7%
Other 12.5%