Implement more bf16/fp16 compiler runtimes

Fixes #1259
This commit is contained in:
Justine Tunney 2024-09-13 05:06:34 -07:00
parent 6b10f4d0b6
commit b5fcb59a85
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
11 changed files with 209 additions and 178 deletions

View file

@ -1,17 +0,0 @@
//===-- lib/extendhfdf2.c - half -> dubble conversion -------------*- C -*-===//
//
// The Cosmopolitan Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
#define SRC_HALF
#define DST_DOUBLE
#include "third_party/compiler_rt/fp16_extend_impl.inc"
COMPILER_RT_ABI dst_t __extendhfdf2(src_t a) {
return __extendXfYf2__(a);
}

View file

@ -1,27 +0,0 @@
//===-- lib/extendhfsf2.c - half -> single conversion -------------*- C -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#define SRC_HALF
#define DST_SINGLE
#include "fp16_extend_impl.inc"
// Use a forwarding definition and noinline to implement a poor man's alias,
// as there isn't a good cross-platform way of defining one.
COMPILER_RT_ABI NOINLINE float __extendhfsf2(src_t a) {
return __extendXfYf2__(a);
}
COMPILER_RT_ABI float __gnu_h2f_ieee(src_t a) { return __extendhfsf2(a); }
#if defined(__ARM_EABI__)
#if defined(COMPILER_RT_ARMHF_TARGET)
AEABI_RTABI float __aeabi_h2f(src_t a) { return __extendhfsf2(a); }
#else
COMPILER_RT_ALIAS(__extendhfsf2, __aeabi_h2f)
#endif
#endif

View file

@ -1,25 +0,0 @@
//===-- lib/extendsftf2.c - single -> quad conversion -------------*- C -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
__static_yoink("huge_compiler_rt_license");
#define QUAD_PRECISION
#include "third_party/compiler_rt/fp_lib.inc"
#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT)
#define SRC_SINGLE
#define DST_QUAD
#include "third_party/compiler_rt/fp_extend_impl.inc"
COMPILER_RT_ABI long double __extendsftf2(float a) {
return __extendXfYf2__(a);
}
#endif

View file

@ -1,21 +0,0 @@
//===-- lib/truncdfhf2.c - double -> half conversion --------------*- C -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#define SRC_DOUBLE
#define DST_HALF
#include "fp16_trunc_impl.inc"
COMPILER_RT_ABI dst_t __truncdfhf2(double a) { return __truncXfYf2__(a); }
#if defined(__ARM_EABI__)
#if defined(COMPILER_RT_ARMHF_TARGET)
AEABI_RTABI dst_t __aeabi_d2h(double a) { return __truncdfhf2(a); }
#else
COMPILER_RT_ALIAS(__truncdfhf2, __aeabi_d2h)
#endif
#endif

View file

@ -1,27 +0,0 @@
//===-- lib/truncsfhf2.c - single -> half conversion --------------*- C -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#define SRC_SINGLE
#define DST_HALF
#include "fp16_trunc_impl.inc"
// Use a forwarding definition and noinline to implement a poor man's alias,
// as there isn't a good cross-platform way of defining one.
COMPILER_RT_ABI NOINLINE dst_t __truncsfhf2(float a) {
return __truncXfYf2__(a);
}
COMPILER_RT_ABI dst_t __gnu_f2h_ieee(float a) { return __truncsfhf2(a); }
#if defined(__ARM_EABI__)
#if defined(COMPILER_RT_ARMHF_TARGET)
AEABI_RTABI dst_t __aeabi_f2h(float a) { return __truncsfhf2(a); }
#else
COMPILER_RT_ALIAS(__truncsfhf2, __aeabi_f2h)
#endif
#endif

View file

@ -1,24 +0,0 @@
//===-- lib/trunctfsf2.c - quad -> single conversion --------------*- C -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
__static_yoink("huge_compiler_rt_license");
#define QUAD_PRECISION
#include "third_party/compiler_rt/fp_lib.inc"
#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT)
#define SRC_QUAD
#define DST_SINGLE
#include "third_party/compiler_rt/fp_trunc_impl.inc"
COMPILER_RT_ABI float __trunctfsf2(long double a) {
return __truncXfYf2__(a);
}
#endif