[compiler-rt] Add extendhfxf2 into compiler rt (PR #113897)

Alexander Richardson via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 5 11:18:12 PST 2024


================
@@ -0,0 +1,18 @@
+//===-- lib/extendhfxf2.c - half -> long double 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_DOUBLE
+#include "fp_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.
+// Long double are expected to be as precise as double.
+COMPILER_RT_ABI NOINLINE long double __extendhfxf2(src_t a) {
+  return (long double)__extendXfYf2__(a);
+}
----------------
arichardson wrote:

```suggestion
#if HAS_80_BIT_LONG_DOUBLE
#include "fp_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.
// Long double are expected to be as precise as double.
COMPILER_RT_ABI long double __extendhfxf2(src_t a) {
  return __extendXfYf2__(a);
}
#endif
```
I don't see why this needs to be noinline, none of the others are.

https://github.com/llvm/llvm-project/pull/113897


More information about the llvm-commits mailing list