On Tue, Jul 13, 2021 at 9:24 AM H.J. Lu <hjl.to...@gmail.com> wrote:
>
> On Tue, Jul 13, 2021 at 8:41 AM Joseph Myers <jos...@codesourcery.com> wrote:
> >
> > On Tue, 13 Jul 2021, H.J. Lu wrote:
> >
> > > On Mon, Jul 12, 2021 at 8:59 PM Wang, Pengfei <pengfei.w...@intel.com> 
> > > wrote:
> > > >
> > > > > Return _Float16 and _Complex _Float16 values in %xmm0/%xmm1 registers.
> > > >
> > > > Can you please explain the behavior here? Is there difference between 
> > > > _Float16 and _Complex _Float16 when return? I.e.,
> > > > 1, In which case will _Float16 values return in both %xmm0 and %xmm1?
> > > > 2, For a single _Float16 value, are both real part and imaginary part 
> > > > returned in %xmm0? Or returned in %xmm0 and %xmm1 respectively?
> > >
> > > Here is the v2 patch to add the missing _Float16 bits.   The PDF file is 
> > > at
> > >
> > > https://gitlab.com/x86-psABIs/i386-ABI/-/wikis/Intel386-psABI
> >
> > This PDF shows _Complex _Float16 as having a size of 2 bytes (should be
> > 4-byte size, 2-byte alignment).
> >
> > It also seems to change double from 4-byte to 8-byte alignment, which is
> > wrong.  And it's inconsistent about whether it covers the long double =
> > double (Android) case - it shows that case for _Complex long double but
> > not for long double itself.
>
> Here is the v3 patch with the fixes.  I also updated the PDF file.

Here is the final patch I checked in.   _Complex _Float16 is changed to return
in XMM0 register.   The new PDF file is at

https://gitlab.com/x86-psABIs/i386-ABI/-/wikis/Intel386-psABI

-- 
H.J.
From 4ce1007486d28b13da36bbf216b2e470818d7ee1 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.to...@gmail.com>
Date: Thu, 1 Jul 2021 13:58:00 -0700
Subject: [PATCH] Add optional _Float16 support

1. Pass _Float16 and _Complex _Float16 values on stack.
2. Return _Float16 and _Complex _Float16 values in XMM0 register.
---
 low-level-sys-info.tex | 70 +++++++++++++++++++++++++++++-------------
 1 file changed, 49 insertions(+), 21 deletions(-)

diff --git a/low-level-sys-info.tex b/low-level-sys-info.tex
index acaf30e..860ff66 100644
--- a/low-level-sys-info.tex
+++ b/low-level-sys-info.tex
@@ -30,7 +30,8 @@ object, and the term \emph{\textindex{\sixteenbyte{}}} refers to a
 \subsubsection{Fundamental Types}
 
 Table~\ref{basic-types} shows the correspondence between ISO C
-scalar types and the processor scalar types.  \code{__float80},
+scalar types and the processor scalar types.  \code{_Float16},
+\code{__float80},
 \code{__float128}, \code{__m64}, \code{__m128}, \code{__m256} and
 \code{__m512} types are optional.
 
@@ -79,23 +80,28 @@ scalar types and the processor scalar types.  \code{__float80},
     & \texttt{\textit{any-type} *} & 4 & 4 & unsigned \fourbyte \\
     & \texttt{\textit{any-type} (*)()} & & \\
     \hline
-    Floating-& \texttt{float} & 4 & 4 & single (IEEE-754) \\
     \cline{2-5}
-    point & \texttt{double} & 8 & 4 & double (IEEE-754) \\
-    & \texttt{long double}$^{\dagger\dagger\dagger\dagger}$  & & & \\
+    & \texttt{_Float16}$^{\dagger\dagger\dagger\dagger\dagger}$ & 2 & 2 & 16-bit (IEEE-754) \\
+    \cline{2-5}
+    & \texttt{float} & 4 & 4 & single (IEEE-754) \\
+    \cline{2-5}
+    Floating- & \texttt{double} & 8 & 4 & double (IEEE-754) \\
+    point & \texttt{long double}$^{\dagger\dagger\dagger\dagger}$ & & & \\
     \cline{2-5}
     & \texttt{__float80}$^{\dagger\dagger}$  & 12 & 4 & 80-bit extended (IEEE-754) \\
     & \texttt{long double}$^{\dagger\dagger\dagger\dagger}$  & & & \\
     \cline{2-5}
     & \texttt{__float128}$^{\dagger\dagger}$ & 16 & 16 & 128-bit extended (IEEE-754) \\
     \hline
-    Complex& \texttt{_Complex float} & 8 & 4 & complex single (IEEE-754) \\
+    & \texttt{_Complex _Float16} $^{\dagger\dagger\dagger\dagger\dagger}$ & 4 & 2 & complex 16-bit (IEEE-754) \\
+    \cline{2-5}
+    & \texttt{_Complex float} & 8 & 4 & complex single (IEEE-754) \\
     \cline{2-5}
-    Floating-& \texttt{_Complex double} & 16 & 4 & complex double (IEEE-754) \\
-    point & \texttt{_Complex long double}$^{\dagger\dagger\dagger\dagger}$ & & & \\
+    Complex& \texttt{_Complex double} & 16 & 4 & complex double (IEEE-754) \\
+    Floating-& \texttt{_Complex long double}$^{\dagger\dagger\dagger\dagger}$ & & & \\
     \cline{2-5}
-    & \texttt{_Complex __float80}$^{\dagger\dagger}$  & 24 & 4 & complex 80-bit extended (IEEE-754) \\
-    & \texttt{_Complex long double}$^{\dagger\dagger\dagger\dagger}$  & & & \\
+    point & \texttt{_Complex __float80}$^{\dagger\dagger}$ & 24 & 4 & complex 80-bit extended (IEEE-754) \\
+    & \texttt{_Complex long double}$^{\dagger\dagger\dagger\dagger}$ & & & \\
     \cline{2-5}
     & \texttt{_Complex __float128}$^{\dagger\dagger}$ & 32 & 16 & complex 128-bit extended (IEEE-754) \\
     \hline
@@ -125,6 +131,8 @@ The \texttt{long double} type is 64-bit, the same as the \texttt{double}
 type, on the Android{\texttrademark} platform.  More information on the
 Android{\texttrademark} platform is available from
 \url{http://www.android.com/}.}\\
+\multicolumn{5}{p{13cm}}{\myfontsize $^{\dagger\dagger\dagger\dagger\dagger}$
+The \texttt{_Float16} type, from ISO/IEC TS 18661-3:2015, is optional.}\\
   \end{tabular}
 }
 \end{table}
@@ -323,6 +331,7 @@ at the time of the call.
 \begin{table}
 \Hrule
   \caption{Register Usage}
+  \myfontsize
   \label{fig-reg-usage}
   \begin{center}
     \begin{tabular}{l|p{8.35cm}|l}
@@ -346,13 +355,28 @@ of some 64bit return types & No \\
 \EBP & callee-saved register; optionally used as frame pointer & Yes \\
 \ESI & callee-saved register & yes \\
 \EDI & callee-saved register & yes \\
-\reg{xmm0}, \reg{ymm0} & scratch registers; also used to pass and return
-\code{__m128}, \code{__m256} parameters & No\\
-\reg{xmm1}--\reg{xmm2},& scratch registers; also used to pass
-\code{__m128}, & No \\
-\reg{ymm1}--\reg{ymm2} & \code{__m256} parameters & \\
-\reg{xmm3}--\reg{xmm7},& scratch registers & No \\
-\reg{ymm3}--\reg{ymm7} & & \\
+\reg{xmm0} & scratch register; also used to pass the first \code{__m128}
+             parameter and return \code{__m128}, \code{_Float16},
+	     \code{_Complex _Float16} & No \\
+\reg{ymm0} & scratch register; also used to pass the first \code{__m256}
+             parameter and return \code{__m256} & No \\
+\reg{zmm0} & scratch register; also used to pass the first \code{__m512}
+             parameter and return \code{__m512} & No \\
+\reg{xmm1} & scratch register; also used to pass the second \code{__m128}
+             parameter & No \\
+\reg{ymm1} & scratch register; also used to pass the second \code{__m256}
+             parameters & No \\
+\reg{zmm1} & scratch register; also used to pass the second \code{__m512}
+             parameters & No \\
+\reg{xmm2} & scratch register; also used to pass the third \code{__m128}
+             parameters & No \\
+\reg{ymm2} & scratch register; also used to pass the third \code{__m256}
+             parameters & No \\
+\reg{zmm2} & scratch register; also used to pass the third \code{__m512}
+             parameters & No \\
+\reg{xmm3}--\reg{xmm7} & scratch registers & No \\
+\reg{ymm3}--\reg{ymm7} & scratch registers & No \\
+\reg{zmm3}--\reg{zmm7} & scratch registers & No \\
 \reg{mm0} & scratch register; also used to pass and return
 \code{__m64} parameter & No\\
 \reg{mm1}--\reg{mm2} & used to pass \code{__m64} parameters & No\\
@@ -420,6 +444,8 @@ and \texttt{unions}) are always returned in memory.
     & \texttt{\textit{any-type} *} & \EAX \\
     & \texttt{\textit{any-type} (*)()} & \\
     \hline
+    & \texttt{_Float16} & \reg{xmm0} \\
+    \cline{2-3}
     & \texttt{float} & \reg{st0} \\
     \cline{2-3}
     Floating- & \texttt{double} & \reg{st0} \\
@@ -430,14 +456,16 @@ and \texttt{unions}) are always returned in memory.
     \cline{2-3}
     & \texttt{__float128} & memory \\
     \hline
-    & \texttt{_Complex float} & \EDX:\EAX \\
-    & & The real part is returned in \EAX. The imaginary part is
+    & \texttt{_Complex _Float16} & \reg{xmm0} \\
+    \cline{2-3}
+    Complex & \texttt{_Complex float} & \EDX:\EAX \\
+    floating- & & The real part is returned in \EAX. The imaginary part is
         returned \\
-    Complex & & in \EDX.\\
+    point & & in \EDX.\\
     \cline{2-3}
-    floating- & \texttt{_Complex double} & memory \\
+    & \texttt{_Complex double} & memory \\
     \cline{2-3}
-    point & \texttt{_Complex long double} & memory \\
+    & \texttt{_Complex long double} & memory \\
     \cline{2-3}
     & \texttt{_Complex __float80} & memory \\
     \cline{2-3}
-- 
2.31.1

Reply via email to