xref: /netbsd-src/external/gpl3/gcc.old/dist/libgcc/soft-fp/trunctfhf2.c (revision 4c3eb207d36f67d31994830c0a694161fc1ca39b)
13ad841b2Smrg /* Software floating-point emulation.
23ad841b2Smrg    Truncate IEEE quad into IEEE half.
3*4c3eb207Smrg    Copyright (C) 1997-2019 Free Software Foundation, Inc.
43ad841b2Smrg    This file is part of the GNU C Library.
53ad841b2Smrg 
63ad841b2Smrg    The GNU C Library is free software; you can redistribute it and/or
73ad841b2Smrg    modify it under the terms of the GNU Lesser General Public
83ad841b2Smrg    License as published by the Free Software Foundation; either
93ad841b2Smrg    version 2.1 of the License, or (at your option) any later version.
103ad841b2Smrg 
113ad841b2Smrg    In addition to the permissions in the GNU Lesser General Public
123ad841b2Smrg    License, the Free Software Foundation gives you unlimited
133ad841b2Smrg    permission to link the compiled version of this file into
143ad841b2Smrg    combinations with other programs, and to distribute those
153ad841b2Smrg    combinations without any restriction coming from the use of this
163ad841b2Smrg    file.  (The Lesser General Public License restrictions do apply in
173ad841b2Smrg    other respects; for example, they cover modification of the file,
183ad841b2Smrg    and distribution when not linked into a combine executable.)
193ad841b2Smrg 
203ad841b2Smrg    The GNU C Library is distributed in the hope that it will be useful,
213ad841b2Smrg    but WITHOUT ANY WARRANTY; without even the implied warranty of
223ad841b2Smrg    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
233ad841b2Smrg    Lesser General Public License for more details.
243ad841b2Smrg 
253ad841b2Smrg    You should have received a copy of the GNU Lesser General Public
263ad841b2Smrg    License along with the GNU C Library; if not, see
273ad841b2Smrg    <http://www.gnu.org/licenses/>.  */
283ad841b2Smrg 
293ad841b2Smrg #include "soft-fp.h"
303ad841b2Smrg #include "half.h"
313ad841b2Smrg #include "quad.h"
323ad841b2Smrg 
333ad841b2Smrg HFtype
__trunctfhf2(TFtype a)343ad841b2Smrg __trunctfhf2 (TFtype a)
353ad841b2Smrg {
363ad841b2Smrg   FP_DECL_EX;
373ad841b2Smrg   FP_DECL_Q (A);
383ad841b2Smrg   FP_DECL_H (R);
393ad841b2Smrg   HFtype r;
403ad841b2Smrg 
413ad841b2Smrg   FP_INIT_ROUNDMODE;
423ad841b2Smrg   FP_UNPACK_SEMIRAW_Q (A, a);
43*4c3eb207Smrg #if _FP_W_TYPE_SIZE < 64
443ad841b2Smrg   FP_TRUNC (H, Q, 1, 4, R, A);
453ad841b2Smrg #else
463ad841b2Smrg   FP_TRUNC (H, Q, 1, 2, R, A);
473ad841b2Smrg #endif
483ad841b2Smrg   FP_PACK_SEMIRAW_H (r, R);
493ad841b2Smrg   FP_HANDLE_EXCEPTIONS;
503ad841b2Smrg 
513ad841b2Smrg   return r;
523ad841b2Smrg }
53