xref: /freebsd/contrib/llvm-project/compiler-rt/lib/builtins/truncsfhf2.c (revision 0b57cec536236d46e3dba9bd041533462f33dbb7)
1*0b57cec5SDimitry Andric //===-- lib/truncsfhf2.c - single -> half conversion --------------*- C -*-===//
2*0b57cec5SDimitry Andric //
3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*0b57cec5SDimitry Andric //
7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
8*0b57cec5SDimitry Andric 
9*0b57cec5SDimitry Andric #define SRC_SINGLE
10*0b57cec5SDimitry Andric #define DST_HALF
11*0b57cec5SDimitry Andric #include "fp_trunc_impl.inc"
12*0b57cec5SDimitry Andric 
13*0b57cec5SDimitry Andric // Use a forwarding definition and noinline to implement a poor man's alias,
14*0b57cec5SDimitry Andric // as there isn't a good cross-platform way of defining one.
15*0b57cec5SDimitry Andric COMPILER_RT_ABI NOINLINE uint16_t __truncsfhf2(float a) {
16*0b57cec5SDimitry Andric   return __truncXfYf2__(a);
17*0b57cec5SDimitry Andric }
18*0b57cec5SDimitry Andric 
19*0b57cec5SDimitry Andric COMPILER_RT_ABI uint16_t __gnu_f2h_ieee(float a) { return __truncsfhf2(a); }
20*0b57cec5SDimitry Andric 
21*0b57cec5SDimitry Andric #if defined(__ARM_EABI__)
22*0b57cec5SDimitry Andric #if defined(COMPILER_RT_ARMHF_TARGET)
23*0b57cec5SDimitry Andric AEABI_RTABI uint16_t __aeabi_f2h(float a) { return __truncsfhf2(a); }
24*0b57cec5SDimitry Andric #else
25*0b57cec5SDimitry Andric COMPILER_RT_ALIAS(__truncsfhf2, __aeabi_f2h)
26*0b57cec5SDimitry Andric #endif
27*0b57cec5SDimitry Andric #endif
28