[clang] [llvm] [ARM64EC] Implement `-mlong-double-{64,80,128}` options (PR #237057)
LIU Hao via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 5 22:48:53 PST 2026
https://github.com/lhmouse updated https://github.com/llvm/llvm-project/pull/237057
>From 1a64c1b926c67f9dbc9a82d2fb9e3ff19c75d97a Mon Sep 17 00:00:00 2001
From: LIU Hao <lh_mouse at 126.com>
Date: Thu, 29 Oct 2026 13:18:23 +0800
Subject: [PATCH 01/10] [ARM64EC] Implement `-mlong-double-{64,80,128}` options
This commit implements the three options for arm64ec-w64-mingw32. `-mlong-double-80`
is made default to fix the interoperability bug with x86_64-w64-mingw32. This also
introduces an ABI break with old ARM64EC binaries.
`-mlong-double-64` is the old behavior that is compatible with aarch64-w64-mingw32
and MSVC. `-mlong-double-128` enables float128 in software, same as x86-64.
Operations of 80-bit `long double` will be implemented in the ARM64EC backend. Its
ABI, including its calling convention, is the same as a 128-bit structure: For ARM64
code it's passed and returned in an integer register pair; for x86-64 it's passed
and returned in memory. The difference is handled in entry/exit thunks.
Assisted-by: DeepSeek V4.1 Flash
---
clang/lib/Basic/Targets/AArch64.cpp | 17 ++
clang/lib/CodeGen/Targets/AArch64.cpp | 14 ++
clang/lib/Driver/ToolChains/Clang.cpp | 3 +
clang/test/CodeGen/arm64ec-long-double-abi.c | 126 +++++++++++
.../test/CodeGen/arm64ec-long-double-modes.c | 37 ++++
.../arm64ec-soft-x87-long-double-atomic.c | 27 +++
.../arm64ec-soft-x87-long-double-builtin.c | 64 ++++++
...arm64ec-soft-x87-long-double-fixed-point.c | 38 ++++
.../arm64ec-soft-x87-long-double-matrix.c | 68 ++++++
...64ec-soft-x87-long-double-vector-builtin.c | 24 +++
...ec-soft-x87-long-double-vector-logical.cpp | 22 ++
.../arm64ec-soft-x87-long-double-vector.c | 63 ++++++
.../CodeGen/arm64ec-soft-x87-long-double.c | 195 ++++++++++++++++++
clang/test/Driver/arm64ec-long-double.c | 21 ++
14 files changed, 719 insertions(+)
create mode 100644 clang/test/CodeGen/arm64ec-long-double-abi.c
create mode 100644 clang/test/CodeGen/arm64ec-long-double-modes.c
create mode 100644 clang/test/CodeGen/arm64ec-soft-x87-long-double-atomic.c
create mode 100644 clang/test/CodeGen/arm64ec-soft-x87-long-double-builtin.c
create mode 100644 clang/test/CodeGen/arm64ec-soft-x87-long-double-fixed-point.c
create mode 100644 clang/test/CodeGen/arm64ec-soft-x87-long-double-matrix.c
create mode 100644 clang/test/CodeGen/arm64ec-soft-x87-long-double-vector-builtin.c
create mode 100644 clang/test/CodeGen/arm64ec-soft-x87-long-double-vector-logical.cpp
create mode 100644 clang/test/CodeGen/arm64ec-soft-x87-long-double-vector.c
create mode 100644 clang/test/CodeGen/arm64ec-soft-x87-long-double.c
create mode 100644 clang/test/Driver/arm64ec-long-double.c
diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp
index 7ddf9d87ad163e..01da8b879df053 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -206,6 +206,10 @@ AArch64TargetInfo::AArch64TargetInfo(const llvm::Triple &Triple,
this->MCountName = "\01_mcount";
else if (Triple.getOS() == llvm::Triple::UnknownOS)
this->MCountName = Triple.isGNUEnvironment() ? "\01_mcount" : "mcount";
+
+ // This should be compatible with x86-64.
+ if (Triple.isWindowsArm64EC() && !Triple.isWindowsMSVCEnvironment())
+ HasFloat128 = true;
}
StringRef AArch64TargetInfo::getABI() const { return ABI; }
@@ -450,6 +454,11 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts,
if (T.isLFI())
Builder.defineMacro("__LFI__");
+ if (HasFloat128) {
+ Builder.defineMacro("__FLOAT128__");
+ Builder.defineMacro("__SIZEOF_FLOAT128__", "16");
+ }
+
// Inline assembly supports AArch64 flag outputs.
Builder.defineMacro("__GCC_ASM_FLAG_OUTPUTS__");
@@ -1831,6 +1840,14 @@ WindowsARM64TargetInfo::WindowsARM64TargetInfo(const llvm::Triple &Triple,
SizeType = UnsignedLongLong;
PtrDiffType = SignedLongLong;
IntPtrType = SignedLongLong;
+
+ if (Triple.isWindowsArm64EC() && !Triple.isWindowsMSVCEnvironment()) {
+ // arm64ec-w64-mingw32 should be interoperable with x86_64-w64-mingw32,
+ // which by default has `long double` as the x87-specific extended
+ // precision format.
+ LongDoubleWidth = LongDoubleAlign = SuitableAlign = 128;
+ LongDoubleFormat = &llvm::APFloat::x87DoubleExtended();
+ }
}
TargetInfo::BuiltinVaListKind
diff --git a/clang/lib/CodeGen/Targets/AArch64.cpp b/clang/lib/CodeGen/Targets/AArch64.cpp
index e493f717af581d..1003a0fd7c845c 100644
--- a/clang/lib/CodeGen/Targets/AArch64.cpp
+++ b/clang/lib/CodeGen/Targets/AArch64.cpp
@@ -383,6 +383,13 @@ ABIArgInfo AArch64ABIInfo::classifyArgumentType(QualType Ty, bool IsVariadicFn,
Ty, IsNamedArg);
}
+ // ARM64EC supports the x87 `long double` type, which is passed as a 128-bit
+ // integer image.
+ if (getTarget().getTriple().isWindowsArm64EC() &&
+ Ty->isSpecificBuiltinType(BuiltinType::LongDouble) &&
+ &getTarget().getLongDoubleFormat() == &llvm::APFloat::x87DoubleExtended())
+ return ABIArgInfo::getDirect(llvm::IntegerType::get(getVMContext(), 128));
+
// Handle illegal vector types here.
if (isIllegalVectorType(Ty))
return coerceIllegalVector(Ty, NSRN, NPRN);
@@ -557,6 +564,13 @@ ABIArgInfo AArch64ABIInfo::classifyReturnType(QualType RetTy,
if (RetTy->isVoidType())
return ABIArgInfo::getIgnore();
+ // ARM64EC supports the x87 `long double` type, which is returned as a
+ // 128-bit integer image.
+ if (getTarget().getTriple().isWindowsArm64EC() &&
+ RetTy->isSpecificBuiltinType(BuiltinType::LongDouble) &&
+ &getTarget().getLongDoubleFormat() == &llvm::APFloat::x87DoubleExtended())
+ return ABIArgInfo::getDirect(llvm::IntegerType::get(getVMContext(), 128));
+
if (const auto *VT = RetTy->getAs<VectorType>()) {
if (VT->getVectorKind() == VectorKind::SveFixedLengthData ||
VT->getVectorKind() == VectorKind::SveFixedLengthPredicate) {
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 1bce61d2cfbeaa..b97e1faf3635b1 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6347,6 +6347,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
else if (TC.getTriple().isPPC() &&
(A->getOption().getID() != options::OPT_mlong_double_80))
A->render(Args, CmdArgs);
+ else if (TC.getTriple().isWindowsArm64EC() &&
+ !TC.getTriple().isWindowsMSVCEnvironment())
+ A->render(Args, CmdArgs);
else
D.Diag(diag::err_drv_unsupported_opt_for_target)
<< A->getAsString(Args) << TripleStr;
diff --git a/clang/test/CodeGen/arm64ec-long-double-abi.c b/clang/test/CodeGen/arm64ec-long-double-abi.c
new file mode 100644
index 00000000000000..18468b159fba27
--- /dev/null
+++ b/clang/test/CodeGen/arm64ec-long-double-abi.c
@@ -0,0 +1,126 @@
+// RUN: %clang_cc1 -triple arm64ec-w64-windows-gnu -mlong-double-64 \
+// RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=ARM64EC_LD64
+// RUN: %clang_cc1 -triple arm64ec-w64-windows-gnu -mlong-double-80 \
+// RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=ARM64EC_LD80
+// RUN: %clang_cc1 -triple x86_64-w64-windows-gnu -mlong-double-64 \
+// RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=X64_LD64
+// RUN: %clang_cc1 -triple x86_64-w64-windows-gnu -mlong-double-80 \
+// RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=X64_LD80
+
+// The calling convention of a `long double` argument depends on the format
+// that `-mlong-double-*` selects, and on the machine. On ARM64EC, named
+// parameters and return values follow the ARM64 convention: a `double`
+// occupies a single floating-point register, and the 80-bit image occupies a
+// pair of integer registers. On x86_64 they follow the x64 convention: a
+// `double` occupies an XMM register, while the 80-bit image does not fit in
+// a register and goes through memory as a reference to a copy and a hidden
+// return pointer. A call across the ARM64EC boundary is translated by an
+// entry or an exit thunk, and the two halves below are what such a thunk
+// has to translate between.
+//
+// Variadic arguments follow the x86_64 convention on both machines, where
+// anything that is not 1, 2, 4 or 8 bytes is passed by reference: a `double`
+// is read back from an 8-byte slot, and the 16-byte image from a reference
+// that is 16-byte aligned.
+//
+// Neither format ever sees the other format's representation.
+// ARM64EC_LD64-NOT: alloca i128
+// ARM64EC_LD80-NOT: alloca double
+// X64_LD64-NOT: alloca x86_fp80
+// X64_LD80-NOT: alloca double
+
+typedef __builtin_va_list va_list;
+
+// A named parameter is received in a floating-point register as a `double`,
+// or as the 16-byte image in a pair of integer registers; an x86_64 callee
+// receives the `double` in an XMM register, and the image through a
+// reference.
+// ARM64EC_LD64-LABEL: define {{.*}}double @named_receive(double noundef %x)
+// ARM64EC_LD80-LABEL: define {{.*}}i128 @named_receive(i128 {{.*}}%x.coerce)
+// X64_LD64-LABEL: define {{.*}}double @named_receive(double noundef %x)
+// X64_LD80-LABEL: define {{.*}}void @named_receive(ptr dead_on_unwind noalias writable sret(x86_fp80) align 16 %agg.result, ptr {{.*}}align 16{{.*}}%0)
+long double named_receive(long double x) { return x; }
+
+// A caller passes a named parameter and receives the return value the same
+// way: through a floating-point register, an integer register pair, an XMM
+// register, or a reference to a copy of the argument together with a hidden
+// return pointer.
+// ARM64EC_LD64-LABEL: define {{.*}}double @named_call(double noundef %x)
+// ARM64EC_LD64: call double @named_receive(double noundef
+// ARM64EC_LD64: ret double
+// ARM64EC_LD80-LABEL: define {{.*}}i128 @named_call(i128 {{.*}}%x.coerce)
+// ARM64EC_LD80: call i128 @named_receive(i128
+// ARM64EC_LD80: ret i128
+// X64_LD64-LABEL: define {{.*}}double @named_call(double noundef %x)
+// X64_LD64: call double @named_receive(double noundef
+// X64_LD64: ret double
+// X64_LD80-LABEL: define {{.*}}void @named_call(ptr dead_on_unwind noalias writable sret(x86_fp80) align 16 %agg.result, ptr
+// X64_LD80: alloca x86_fp80, align 16
+// X64_LD80: store x86_fp80 {{.*}}, ptr {{.*}}, align 16
+// X64_LD80: call void @named_receive(ptr dead_on_unwind writable sret(x86_fp80) align 16 {{%.*}}, ptr {{.*}}align 16{{.*}})
+long double named_call(long double x) { return named_receive(x); }
+
+int varfmt(const char *fmt, ...);
+
+// A variadic `double` is passed directly, and `va_arg` reads it back from the
+// spill slot with 8-byte alignment ...
+// ARM64EC_LD64-LABEL: define {{.*}}i32 @vararg_pass(double noundef %x)
+// ARM64EC_LD64-NOT: i128
+// ARM64EC_LD64: call i32 (ptr, ...) @varfmt(ptr noundef @.str, double noundef
+// ARM64EC_LD64-LABEL: define {{.*}}double @vararg_take(ptr noundef %ap)
+// ARM64EC_LD64-NOT: i128
+// ARM64EC_LD64: load double, ptr %argp.cur, align 8
+// X64_LD64-LABEL: define {{.*}}i32 @vararg_pass(double noundef %x)
+// X64_LD64-NOT: x86_fp80
+// X64_LD64: call i32 (ptr, ...) @varfmt(ptr noundef @.str, double noundef
+// X64_LD64-LABEL: define {{.*}}double @vararg_take(ptr noundef %ap)
+// X64_LD64-NOT: x86_fp80
+// X64_LD64: load double, ptr %argp.cur, align 8
+// ... while the 16-byte image is passed by reference to a 16-byte aligned
+// temporary, through which `va_arg` loads it.
+// ARM64EC_LD80-LABEL: define {{.*}}i32 @vararg_pass(i128 {{.*}}%x.coerce)
+// ARM64EC_LD80-NOT: double
+// ARM64EC_LD80: alloca x86_fp80, align 16
+// ARM64EC_LD80: store x86_fp80 {{.*}}, ptr {{.*}}, align 16
+// ARM64EC_LD80: call i32 (ptr, ...) @varfmt(ptr noundef @.str, ptr {{.*}}align 16{{.*}})
+// ARM64EC_LD80-LABEL: define {{.*}}i128 @vararg_take(ptr noundef %ap)
+// ARM64EC_LD80-NOT: double
+// ARM64EC_LD80: load ptr, ptr %argp.cur, align 8
+// ARM64EC_LD80: load x86_fp80, ptr {{.*}}, align 16
+// ARM64EC_LD80: load i128, ptr %retval, align 16
+// X64_LD80-LABEL: define {{.*}}i32 @vararg_pass(ptr {{.*}}align 16{{.*}})
+// X64_LD80-NOT: alloca double
+// X64_LD80: alloca x86_fp80, align 16
+// X64_LD80: store x86_fp80 {{.*}}, ptr {{.*}}, align 16
+// X64_LD80: call i32 (ptr, ...) @varfmt(ptr noundef @.str, ptr {{.*}}align 16{{.*}})
+// X64_LD80-LABEL: define {{.*}}void @vararg_take(ptr dead_on_unwind noalias writable sret(x86_fp80) align 16 %agg.result, ptr noundef %ap)
+// X64_LD80-NOT: alloca double
+// X64_LD80: load ptr, ptr %argp.cur, align 8
+// X64_LD80: load x86_fp80, ptr {{.*}}, align 16
+int vararg_pass(long double x) { return varfmt("%Lg", x); }
+long double vararg_take(va_list ap) {
+ return __builtin_va_arg(ap, long double);
+}
+
+// A return value leaves and enters in a floating-point register, or in a
+// pair of integer registers; an x86_64 callee returns the 80-bit image
+// through a hidden pointer.
+// ARM64EC_LD64-LABEL: define {{.*}}double @ret_out()
+// ARM64EC_LD64: ret double 1.000000e+00
+// ARM64EC_LD64-LABEL: define {{.*}}double @ret_in()
+// ARM64EC_LD64: call double @ret_out()
+// ARM64EC_LD80-LABEL: define {{.*}}i128 @ret_out()
+// ARM64EC_LD80: store x86_fp80 1.000000e+00, ptr %retval, align 16
+// ARM64EC_LD80: load i128, ptr %retval, align 16
+// ARM64EC_LD80-LABEL: define {{.*}}i128 @ret_in()
+// ARM64EC_LD80: call i128 @ret_out()
+// X64_LD64-LABEL: define {{.*}}double @ret_out()
+// X64_LD64: ret double 1.000000e+00
+// X64_LD64-LABEL: define {{.*}}double @ret_in()
+// X64_LD64: call double @ret_out()
+// X64_LD80-LABEL: define {{.*}}void @ret_out(ptr dead_on_unwind noalias writable sret(x86_fp80) align 16 %agg.result)
+// X64_LD80: store x86_fp80 1.000000e+00, ptr %agg.result, align 16
+// X64_LD80-LABEL: define {{.*}}void @ret_in(ptr dead_on_unwind noalias writable sret(x86_fp80) align 16 %agg.result)
+// X64_LD80: call void @ret_out(ptr dead_on_unwind writable sret(x86_fp80) align 16
+long double ret_out(void) { return 1.0L; }
+long double ret_in(void) { return ret_out(); }
diff --git a/clang/test/CodeGen/arm64ec-long-double-modes.c b/clang/test/CodeGen/arm64ec-long-double-modes.c
new file mode 100644
index 00000000000000..fae0446a69b35d
--- /dev/null
+++ b/clang/test/CodeGen/arm64ec-long-double-modes.c
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple arm64ec-w64-windows-gnu -mlong-double-64 \
+// RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=LD64
+// RUN: %clang_cc1 -triple arm64ec-w64-windows-gnu -mlong-double-80 \
+// RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=LD80
+// RUN: %clang_cc1 -triple arm64ec-w64-windows-gnu -mlong-double-128 \
+// RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=LD128
+
+// The three widths select the format of `long double`; only the 80-bit one is
+// the software x87 format that goes through the ARM64EC runtime helpers.
+
+long double g = 1.0L;
+long double add(long double a, long double b) { return a + b; }
+int cmp(long double a, long double b) { return a < b; }
+
+// LD64: @g = {{.*}}global double 1.000000e+00
+// LD64-LABEL: define {{.*}}double @add(double noundef %a, double noundef %b)
+// LD64: fadd double
+// LD64-LABEL: define {{.*}}i32 @cmp(double noundef %a, double noundef %b)
+// LD64: fcmp olt double
+// LD64-NOT: __arm64ec_
+
+// The 80-bit format stays a real `x86_fp80` in the IR so that the middle-end
+// can optimize it; the ABI passes and returns it as a 16-byte image, and the
+// backend softens every operation to a compiler-rt helper. The padding after
+// the 80 bits of the slot is not represented by the IR type.
+// LD80: @g = {{.*}}global x86_fp80 1.000000e+00, align 16
+// LD80-LABEL: define {{.*}}i128 @add(i128 {{.*}}%a.coerce, i128 {{.*}}%b.coerce)
+// LD80: fadd x86_fp80
+// LD80-NOT: __arm64ec_
+// LD80-LABEL: define {{.*}}i32 @cmp(i128 {{.*}}%a.coerce, i128 {{.*}}%b.coerce)
+// LD80: fcmp olt x86_fp80
+// LD80-NOT: __arm64ec_
+
+// LD128: @g = {{.*}}global fp128
+// LD128-LABEL: define {{.*}}fp128 @add(fp128 noundef %a, fp128 noundef %b)
+// LD128-LABEL: define {{.*}}i32 @cmp(fp128 noundef %a, fp128 noundef %b)
+// LD128-NOT: __arm64ec_
diff --git a/clang/test/CodeGen/arm64ec-soft-x87-long-double-atomic.c b/clang/test/CodeGen/arm64ec-soft-x87-long-double-atomic.c
new file mode 100644
index 00000000000000..1a699adbbdf451
--- /dev/null
+++ b/clang/test/CodeGen/arm64ec-soft-x87-long-double-atomic.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple arm64ec-w64-windows-gnu -emit-llvm -o - %s | FileCheck %s
+
+// The ABI moves a `long double` as a 16-byte integer image, but the value
+// itself is a real `x86_fp80`; the read-modify-write therefore loads and
+// stores the image and performs the increment as a floating-point operation.
+_Atomic long double g;
+
+long double pre_inc(void) { return ++g; }
+// CHECK-LABEL: define {{.*}} @pre_inc(
+// CHECK-NOT: atomicrmw
+// CHECK: load atomic i128, ptr @g seq_cst
+// CHECK: [[TMP:%.*]] = load x86_fp80, ptr %atomic-temp
+// CHECK: [[OLD:%.*]] = phi x86_fp80 [ [[TMP]], %entry ]
+// CHECK: fadd x86_fp80 [[OLD]], 1.000000e+00
+// CHECK: cmpxchg ptr @g, i128 {{.*}}, i128 {{.*}} seq_cst seq_cst, align 16
+
+long double post_dec(void) { return g--; }
+// CHECK-LABEL: define {{.*}} @post_dec(
+// CHECK-NOT: atomicrmw
+// CHECK: load atomic i128, ptr @g seq_cst
+// CHECK: fadd x86_fp80 {{.*}}, -1.000000e+00
+// CHECK: cmpxchg ptr @g, i128 {{.*}}, i128 {{.*}} seq_cst seq_cst, align 16
+
+void add_assign(void) { g += 1.0L; }
+// CHECK-LABEL: define {{.*}} @add_assign(
+// CHECK-NOT: atomicrmw
+// CHECK: cmpxchg ptr @g, i128 {{.*}}, i128 {{.*}} seq_cst seq_cst, align 16
diff --git a/clang/test/CodeGen/arm64ec-soft-x87-long-double-builtin.c b/clang/test/CodeGen/arm64ec-soft-x87-long-double-builtin.c
new file mode 100644
index 00000000000000..102f9afb0b23be
--- /dev/null
+++ b/clang/test/CodeGen/arm64ec-soft-x87-long-double-builtin.c
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -triple arm64ec-w64-windows-gnu -emit-llvm -o - %s | FileCheck %s
+
+// The value itself is a real `x86_fp80`, so every builtin that takes or
+// returns a floating-point value is emitted as the ordinary floating-point
+// intrinsic and softened by the backend; the frontend does not lower the
+// operation on the integer image.
+
+// `__builtin_elementwise_abs` is `fabsl`.
+// CHECK-LABEL: define dso_local i128 @elementwise_abs(
+// CHECK: call x86_fp80 @llvm.fabs.f80
+long double elementwise_abs(long double x) { return __builtin_elementwise_abs(x); }
+
+// `__builtin_elementwise_copysign` is `copysignl`.
+// CHECK-LABEL: define dso_local i128 @elementwise_copysign(
+// CHECK: call x86_fp80 @llvm.copysign.f80
+long double elementwise_copysign(long double x, long double y) {
+ return __builtin_elementwise_copysign(x, y);
+}
+
+// `__builtin_canonicalizel` is a real floating-point canonicalization.
+// CHECK-LABEL: define dso_local i128 @canonical(
+// CHECK: call x86_fp80 @llvm.canonicalize.f80
+long double canonical(long double x) { return __builtin_canonicalizel(x); }
+
+// The constants stay `x86_fp80` constants and are widened to the 16-byte
+// image by the backend, where the sign and the payload are preserved.
+// CHECK-LABEL: define dso_local i128 @canonical_signalling(
+// CHECK: call x86_fp80 @llvm.canonicalize.f80(x86_fp80 +snan(
+long double canonical_signalling(void) {
+ return __builtin_canonicalizel(__builtin_nansl(""));
+}
+
+// CHECK-LABEL: define dso_local i128 @canonical_negative_signalling(
+// CHECK: call x86_fp80 @llvm.canonicalize.f80(x86_fp80 -snan(
+long double canonical_negative_signalling(void) {
+ return __builtin_canonicalizel(-__builtin_nansl(""));
+}
+
+// CHECK-LABEL: define dso_local i128 @canonical_quiet(
+// CHECK: call x86_fp80 @llvm.canonicalize.f80(x86_fp80 +qnan)
+long double canonical_quiet(void) {
+ return __builtin_canonicalizel(__builtin_nanl(""));
+}
+
+// CHECK-LABEL: define dso_local i128 @canonical_infinity(
+// CHECK: call x86_fp80 @llvm.canonicalize.f80(x86_fp80 +inf)
+long double canonical_infinity(void) {
+ return __builtin_canonicalizel(__builtin_infl());
+}
+
+// `__builtin_iszero`, `__builtin_issubnormal` and `__builtin_issignaling`
+// classify the floating-point value with the generic FP-class intrinsic; the
+// masks are the ones defined by the LangRef.
+// CHECK-LABEL: define dso_local i32 @is_zero(
+// CHECK: call i1 @llvm.is.fpclass.f80({{.*}}i32 96)
+int is_zero(long double x) { return __builtin_iszero(x); }
+
+// CHECK-LABEL: define dso_local i32 @is_subnormal(
+// CHECK: call i1 @llvm.is.fpclass.f80({{.*}}i32 144)
+int is_subnormal(long double x) { return __builtin_issubnormal(x); }
+
+// CHECK-LABEL: define dso_local i32 @is_signaling(
+// CHECK: call i1 @llvm.is.fpclass.f80({{.*}}i32 1)
+int is_signaling(long double x) { return __builtin_issignaling(x); }
diff --git a/clang/test/CodeGen/arm64ec-soft-x87-long-double-fixed-point.c b/clang/test/CodeGen/arm64ec-soft-x87-long-double-fixed-point.c
new file mode 100644
index 00000000000000..75d0a1e40e67bd
--- /dev/null
+++ b/clang/test/CodeGen/arm64ec-soft-x87-long-double-fixed-point.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple arm64ec-w64-windows-gnu -ffixed-point -emit-llvm -o - %s | FileCheck %s
+
+// A conversion to `bool` tests the `x86_fp80` value directly against zero,
+// so a magnitude below the smallest `double` is still nonzero.
+// CHECK-LABEL: define dso_local i32 @to_bool(
+// CHECK-NOT: x87ld.to.double
+// CHECK: fcmp une x86_fp80 {{%.*}}, 0.000000e+00
+int to_bool(long double x) { return x ? 1 : 0; }
+
+// CHECK-LABEL: define dso_local i32 @not_ld(
+// CHECK-NOT: x87ld.to.double
+// CHECK: fcmp une x86_fp80 {{%.*}}, 0.000000e+00
+int not_ld(long double x) { return !x; }
+
+// A conversion between `long double` and a fixed-point type is an ordinary
+// floating-point conversion, which the backend softens.
+// CHECK-LABEL: define dso_local i128 @from_accum(
+// CHECK: sitofp i16 {{%.*}} to x86_fp80
+long double from_accum(short _Accum a) { return a; }
+
+// CHECK-LABEL: define dso_local i16 @to_accum(
+// CHECK: fptosi x86_fp80 {{%.*}} to i16
+short _Accum to_accum(long double x) { return x; }
+
+// CHECK-LABEL: define dso_local i128 @from_fract(
+// CHECK: sitofp i8 {{%.*}} to x86_fp80
+long double from_fract(short _Fract a) { return a; }
+
+// CHECK-LABEL: define dso_local i8 @to_fract(
+// CHECK: fptosi x86_fp80 {{%.*}} to i8
+short _Fract to_fract(long double x) { return x; }
+
+// A fixed-point to `bool` conversion does not arrive here at all, and it must
+// not be routed through `double` either.
+// CHECK-LABEL: define dso_local i32 @accum_to_bool(
+// CHECK-NOT: x87ld
+// CHECK: icmp ne i16 {{%.*}}, 0
+int accum_to_bool(short _Accum a) { return a ? 1 : 0; }
diff --git a/clang/test/CodeGen/arm64ec-soft-x87-long-double-matrix.c b/clang/test/CodeGen/arm64ec-soft-x87-long-double-matrix.c
new file mode 100644
index 00000000000000..94de49438e15b2
--- /dev/null
+++ b/clang/test/CodeGen/arm64ec-soft-x87-long-double-matrix.c
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -triple arm64ec-w64-windows-gnu -fenable-matrix -emit-llvm -O0 -o - %s | FileCheck %s
+
+// A matrix is lowered to a flat vector of the element type, so a matrix of
+// `long double` is a vector of real `x86_fp80` values; the backend splits the
+// vector and softens every lane.
+typedef long double m2x2 __attribute__((matrix_type(2, 2)));
+typedef long double m2x3 __attribute__((matrix_type(2, 3)));
+typedef long double m3x2 __attribute__((matrix_type(3, 2)));
+typedef float f2x3 __attribute__((matrix_type(2, 3)));
+
+// Whole vectors move around as they are.
+m2x3 copy(m2x3 a) { return a; }
+// CHECK-LABEL: define {{.*}} @copy(
+// CHECK-NOT: call
+// CHECK: ret <6 x x86_fp80>
+
+m2x3 add(m2x3 a, m2x3 b) { return a + b; }
+// CHECK-LABEL: define {{.*}} @add(
+// CHECK: fadd <6 x x86_fp80>
+// CHECK-NOT: __arm64ec_
+
+m2x3 sub(m2x3 a, m2x3 b) { return a - b; }
+// CHECK-LABEL: define {{.*}} @sub(
+// CHECK: fsub <6 x x86_fp80>
+// CHECK-NOT: __arm64ec_
+
+// A scalar operand of a matrix is splatted into every lane.
+m2x3 mul_scalar(m2x3 a, long double s) { return a * s; }
+// CHECK-LABEL: define {{.*}} @mul_scalar(
+// CHECK: fmul <6 x x86_fp80> {{.*}}, %scalar.splat.splat
+// CHECK-NOT: __arm64ec_
+
+m2x3 scalar_mul(long double s, m2x3 a) { return s * a; }
+// CHECK-LABEL: define {{.*}} @scalar_mul(
+// CHECK: fmul <6 x x86_fp80> %scalar.splat.splat, {{.*}}
+// CHECK-NOT: __arm64ec_
+
+m2x3 div_scalar(m2x3 a, long double s) { return a / s; }
+// CHECK-LABEL: define {{.*}} @div_scalar(
+// CHECK: fdiv <6 x x86_fp80> {{.*}}, %scalar.splat.splat
+// CHECK-NOT: __arm64ec_
+
+// Matrix multiplication stays a vector-of-f80 operation.
+m2x2 mul_matrix(m2x3 a, m3x2 b) { return a * b; }
+// CHECK-LABEL: define {{.*}} @mul_matrix(
+// CHECK: %[[P:.*]] = call <4 x x86_fp80> @llvm.matrix.multiply.v4f80.v6f80.v6f80(<6 x x86_fp80> {{.*}}, <6 x x86_fp80> {{.*}}, i32 2, i32 3, i32 2)
+// CHECK: ret <4 x x86_fp80> %[[P]]
+
+void mul_assign(m2x2 *a, m2x2 b) { *a *= b; }
+// CHECK-LABEL: define {{.*}} @mul_assign(
+// CHECK: call <4 x x86_fp80> @llvm.matrix.multiply.v4f80.v4f80.v4f80(<4 x x86_fp80> {{.*}}, <4 x x86_fp80> {{.*}}, i32 2, i32 2, i32 2)
+// CHECK: store <4 x x86_fp80>
+
+// Conversions stay vector conversions.
+f2x3 truncate(m2x3 a) { return (f2x3)a; }
+// CHECK-LABEL: define {{.*}} @truncate(
+// CHECK: fptrunc <6 x x86_fp80> {{.*}} to <6 x float>
+
+m2x3 extend(f2x3 a) { return (m2x3)a; }
+// CHECK-LABEL: define {{.*}} @extend(
+// CHECK: fpext <6 x float> {{.*}} to <6 x x86_fp80>
+
+// Transposing only moves whole values around.
+m3x2 transpose(m2x3 a) { return __builtin_matrix_transpose(a); }
+// CHECK-LABEL: define {{.*}} @transpose(
+// CHECK-NOT: call double
+// CHECK: %[[T:.*]] = call <6 x x86_fp80> @llvm.matrix.transpose.v6f80(<6 x x86_fp80>
+// CHECK: ret <6 x x86_fp80> %[[T]]
diff --git a/clang/test/CodeGen/arm64ec-soft-x87-long-double-vector-builtin.c b/clang/test/CodeGen/arm64ec-soft-x87-long-double-vector-builtin.c
new file mode 100644
index 00000000000000..52a2870186e7b9
--- /dev/null
+++ b/clang/test/CodeGen/arm64ec-soft-x87-long-double-vector-builtin.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -triple arm64ec-w64-windows-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple arm64ec-w64-windows-gnu -emit-llvm -o - %s -DOPTNONE | FileCheck %s --check-prefix=OPTNONE
+
+// Element-wise floating-point builtins work on the vector values themselves,
+// which stay real `<2 x x86_fp80>` in the IR; the backend splits and softens
+// the lanes.
+typedef long double V __attribute__((vector_size(32)));
+
+#ifdef OPTNONE
+// `optnone` does not change the representation.
+__attribute__((optnone)) V reject(V a) {
+ return __builtin_elementwise_abs(a);
+}
+// OPTNONE-LABEL: define {{.*}} @reject(
+// OPTNONE: call <2 x x86_fp80> @llvm.fabs.v2f80
+#else
+V reject(V a, V b, V c) {
+ V abs_a = __builtin_elementwise_abs(a);
+ return __builtin_elementwise_fma(abs_a, b, c);
+}
+// CHECK-LABEL: define {{.*}} @reject(
+// CHECK: call <2 x x86_fp80> @llvm.fabs.v2f80
+// CHECK: call <2 x x86_fp80> @llvm.fma.v2f80
+#endif
diff --git a/clang/test/CodeGen/arm64ec-soft-x87-long-double-vector-logical.cpp b/clang/test/CodeGen/arm64ec-soft-x87-long-double-vector-logical.cpp
new file mode 100644
index 00000000000000..fae184e95ee023
--- /dev/null
+++ b/clang/test/CodeGen/arm64ec-soft-x87-long-double-vector-logical.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple arm64ec-w64-windows-gnu -emit-llvm -o - %s | FileCheck %s
+
+// C++ is the only language that accepts the logical operators on vector
+// operands. A lane is true when its value is not zero, which is an ordinary
+// floating-point comparison; `-0.0` compares equal to zero and a NaN is true.
+typedef long double V __attribute__((vector_size(32)));
+
+extern "C" int not_(V a) { return (!a)[0]; }
+// CHECK-LABEL: define {{.*}} @not_(
+// CHECK: fcmp oeq <2 x x86_fp80> {{.*}}, zeroinitializer
+
+extern "C" int land_(V a, V b) { return (a && b)[0]; }
+// CHECK-LABEL: define {{.*}} @land_(
+// CHECK: fcmp une <2 x x86_fp80> {{.*}}, zeroinitializer
+// CHECK: fcmp une <2 x x86_fp80> {{.*}}, zeroinitializer
+// CHECK: and <2 x i1>
+
+extern "C" int lor_(V a, V b) { return (a || b)[0]; }
+// CHECK-LABEL: define {{.*}} @lor_(
+// CHECK: fcmp une <2 x x86_fp80> {{.*}}, zeroinitializer
+// CHECK: fcmp une <2 x x86_fp80> {{.*}}, zeroinitializer
+// CHECK: or <2 x i1>
diff --git a/clang/test/CodeGen/arm64ec-soft-x87-long-double-vector.c b/clang/test/CodeGen/arm64ec-soft-x87-long-double-vector.c
new file mode 100644
index 00000000000000..3aab8433dd2d3e
--- /dev/null
+++ b/clang/test/CodeGen/arm64ec-soft-x87-long-double-vector.c
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -triple arm64ec-w64-windows-gnu -emit-llvm -o - %s | FileCheck %s
+
+// The elements of a `long double` vector are real `x86_fp80` values. The IR
+// keeps the vector operations intact; the AArch64 backend splits the vector
+// and softens every lane to a compiler-rt helper.
+typedef long double V __attribute__((vector_size(32)));
+typedef double D2 __attribute__((vector_size(16)));
+
+// Whole vectors move around as they are.
+V copy(V a) { return a; }
+// CHECK-LABEL: define {{.*}} @copy(
+// CHECK-NOT: call
+// CHECK: ret void
+
+V add(V a, V b) { return a + b; }
+// CHECK-LABEL: define {{.*}} @add(
+// CHECK: fadd <2 x x86_fp80>
+// CHECK-NOT: __arm64ec_
+
+V div(V a, V b) { return a / b; }
+// CHECK-LABEL: define {{.*}} @div(
+// CHECK: fdiv <2 x x86_fp80>
+// CHECK-NOT: __arm64ec_
+
+// Negation stays a floating-point operation on the vector.
+V neg(V a) { return -a; }
+// CHECK-LABEL: define {{.*}} @neg(
+// CHECK: fneg <2 x x86_fp80>
+// CHECK-NOT: __arm64ec_
+
+// A compound assignment takes the same path.
+V compound(V a, V b) {
+ a += b;
+ return a;
+}
+// CHECK-LABEL: define {{.*}} @compound(
+// CHECK: fadd <2 x x86_fp80>
+// CHECK-NOT: __arm64ec_
+
+// A scalar operand is splatted at the IR level.
+V splat(V a) { return a + 1.0L; }
+// CHECK-LABEL: define {{.*}} @splat(
+// CHECK: fadd <2 x x86_fp80> {{.*}}, splat (x86_fp80 1.000000e+00)
+// CHECK-NOT: __arm64ec_
+
+// Comparison stays a vector compare.
+int lt(V a, V b) { return (a < b)[0]; }
+// CHECK-LABEL: define {{.*}} @lt(
+// CHECK: fcmp olt <2 x x86_fp80>
+// CHECK-NOT: __arm64ec_
+
+// Conversions stay vector conversions.
+D2 convert(V a) { return __builtin_convertvector(a, D2); }
+// CHECK-LABEL: define {{.*}} @convert(
+// CHECK: fptrunc <2 x x86_fp80> {{.*}} to <2 x double>
+// CHECK-NOT: __arm64ec_
+
+// The reverse conversion goes the other way.
+V back(D2 a) { return __builtin_convertvector(a, V); }
+// CHECK-LABEL: define {{.*}} @back(
+// CHECK: fpext <2 x double> {{.*}} to <2 x x86_fp80>
+// CHECK-NOT: __arm64ec_
+
diff --git a/clang/test/CodeGen/arm64ec-soft-x87-long-double.c b/clang/test/CodeGen/arm64ec-soft-x87-long-double.c
new file mode 100644
index 00000000000000..6e4dc8f05976e8
--- /dev/null
+++ b/clang/test/CodeGen/arm64ec-soft-x87-long-double.c
@@ -0,0 +1,195 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-globals --include-generated-funcs --global-value-regex "g"
+// RUN: %clang_cc1 -triple arm64ec-w64-windows-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple arm64ec-w64-windows-gnu -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=OPT
+
+// ARM64EC keeps the x86_64 80-bit x87 format, in a 16-byte slot, but has no
+// x87 hardware: the value is an integer image that only ever goes through
+// `double` for computation.
+_Static_assert(sizeof(long double) == 16, "the slot is 16 bytes");
+_Static_assert(_Alignof(long double) == 16, "the slot is 16-byte aligned");
+_Static_assert(__LDBL_MANT_DIG__ == 64, "80-bit x87 significand");
+_Static_assert(__LDBL_MAX_EXP__ == 16384, "80-bit x87 exponent range");
+
+long double g = 1.0L;
+// The tag of a NaN fills the 63 significand bits below the explicit integer
+// bit, so the same expression has to give the same image whether it is folded
+// into a global initializer or emitted in a function body.
+long double g_nan = __builtin_nanl("0x5B3C9A7E1D46F2CD");
+
+long double add(long double a, long double b) { return a + b; }
+long double neg(long double a) { return -a; }
+
+int cmp(long double a, long double b) { return a < b; }
+int cmp_eq(long double a, long double b) { return a == b; }
+
+int isinf_(long double a) { return __builtin_isinf(a); }
+int isnan_(long double a) { return __builtin_isnan(a); }
+int isfinite_(long double a) { return __builtin_isfinite(a); }
+int signbit_(long double a) { return __builtin_signbitl(a); }
+int fpclass(long double a) {
+ return __builtin_fpclassify(1, 2, 4, 8, 16, a);
+}
+long double ilogb_(long double a) { return (long double)__builtin_ilogbl(a); }
+long double powi_(long double a, int n) { return __builtin_powil(a, n); }
+int pred(long double a, long double b) {
+ return __builtin_isgreater(a, b) || __builtin_islessequal(a, b) ||
+ __builtin_isunordered(a, b);
+}
+int fpclassify_mask(long double a) { return __builtin_isfpclass(a, 0x200); }
+
+long double nanl(const char *);
+long double nan_q(void) { return __builtin_nanl("0x5B3C9A7E1D46F2CD"); }
+long double nan_s(void) { return __builtin_nansl("0x5B3C9A7E1D46F2CD"); }
+long double nan_rt(const char *tag) { return nanl(tag); }
+
+long double _Complex conj_(long double _Complex z) { return ~z; }
+long double _Complex conj_b(long double _Complex z) {
+ return __builtin_conjl(z);
+}
+long double creal_b(long double _Complex z) { return __builtin_creall(z); }
+long double cimag_b(long double _Complex z) { return __builtin_cimagl(z); }
+long double cabs_b(long double _Complex z) { return __builtin_cabsl(z); }
+long double _Complex cadd(long double _Complex a, long double _Complex b) {
+ return a + b;
+}
+long double _Complex cinc(long double _Complex z) { return ++z; }
+
+int varargs(const char *fmt, ...);
+int callv(void) {
+ // A 16-byte `long double` is passed by reference, exactly as on x86_64.
+ return varargs("%Lg", 1.0L);
+}
+
+// The 80-bit value remains a real `x86_fp80` in the IR, in a 16-byte slot;
+// the ABI around it is the 16-byte integer image.
+// CHECK: @g = {{.*}}global x86_fp80 1.000000e+00, align 16
+// CHECK: @g_nan = {{.*}}global x86_fp80 +nan(0x1B3C9A7E1D46F2CD), align 16
+
+// Arithmetic stays a real floating-point operation, which the AArch64 backend
+// softens to a compiler-rt helper. Nothing is lowered in the frontend.
+// CHECK-LABEL: define {{.*}}i128 @add(i128 {{.*}}%a.coerce, i128 {{.*}}%b.coerce)
+// CHECK: fadd x86_fp80
+// CHECK-NOT: __arm64ec_
+
+// Negation is a single floating-point operation too.
+// CHECK-LABEL: define {{.*}}i128 @neg(i128 {{.*}}%a.coerce)
+// CHECK: fneg x86_fp80
+// CHECK-NOT: __arm64ec_
+
+// Comparisons stay `fcmp` on the value.
+// CHECK-LABEL: define {{.*}}i32 @cmp(i128 {{.*}}%a.coerce, i128 {{.*}}%b.coerce)
+// CHECK: fcmp olt x86_fp80
+// CHECK-LABEL: define {{.*}}i32 @cmp_eq(
+// CHECK: fcmp oeq x86_fp80
+
+// Classification builtins are the generic floating-point intrinsic; the
+// backend lowers them without going through the frontend.
+// CHECK-LABEL: define {{.*}}i32 @isinf_(
+// CHECK: call i1 @llvm.is.fpclass.f80({{.*}}i32 516)
+// CHECK-LABEL: define {{.*}}i32 @isnan_(
+// CHECK: call i1 @llvm.is.fpclass.f80({{.*}}i32 3)
+// CHECK-LABEL: define {{.*}}i32 @isfinite_(
+// CHECK: call i1 @llvm.is.fpclass.f80({{.*}}i32 504)
+
+// The sign is taken from the 80-bit value directly, not through a CRT call.
+// CHECK-LABEL: define {{.*}}i32 @signbit_(
+// CHECK: [[BITS:%.*]] = bitcast x86_fp80 {{.*}} to i80
+// CHECK: icmp slt i80 [[BITS]], 0
+// CHECK-NOT: call i32 @signbit
+
+// CHECK-LABEL: define {{.*}}i32 @fpclass(
+// CHECK: fcmp oeq x86_fp80
+// CHECK: fcmp uno x86_fp80
+// CHECK: call x86_fp80 @llvm.fabs.f80
+// CHECK: fcmp oeq x86_fp80
+// CHECK: fcmp uge x86_fp80
+// CHECK-NOT: __arm64ec_
+
+// `ilogbl` takes and returns the 16-byte image at its ABI boundary.
+// CHECK-LABEL: define {{.*}}i128 @ilogb_(
+// CHECK: call i32 @ilogbl(i128
+// CHECK-NOT: call i32 @ilogb(
+
+// `__builtin_powil` is a real `llvm.powi.f80`, softened by the backend.
+// CHECK-LABEL: define {{.*}}i128 @powi_(
+// CHECK: call x86_fp80 @llvm.powi.f80.i32
+// CHECK-NOT: __arm64ec_
+
+// The comparison predicates are `fcmp` on the value.
+// CHECK-LABEL: define {{.*}}i32 @pred(
+// CHECK: fcmp ogt x86_fp80
+// CHECK: fcmp ole x86_fp80
+// CHECK: fcmp uno x86_fp80
+// CHECK-NOT: call i32 @isgreater
+// CHECK-NOT: call i32 @islessequal
+// CHECK-NOT: call i32 @isunordered
+// CHECK: ret i32
+
+// CHECK-LABEL: define {{.*}}i32 @fpclassify_mask(
+// CHECK: call i1 @llvm.is.fpclass.f80({{.*}}i32 512)
+// CHECK-NOT: call i32 @isfpclass
+
+// A string literal tag is folded into an `x86_fp80` constant, which the
+// backend widens to the 16-byte image.
+// CHECK-LABEL: define {{.*}}i128 @nan_q(
+// CHECK: store x86_fp80 +nan(0x1B3C9A7E1D46F2CD)
+// CHECK: load i128
+
+// The signalling NaN keeps the payload but has the quiet bit clear.
+// CHECK-LABEL: define {{.*}}i128 @nan_s(
+// CHECK: store x86_fp80 +snan(0x1B3C9A7E1D46F2CD)
+// CHECK: load i128
+
+// A tag that is not a string literal is parsed by the library at run time,
+// rather than replaced with a default payload.
+// CHECK-LABEL: define {{.*}}i128 @nan_rt(
+// CHECK: call i128 @nanl(
+
+// Conjugation only negates the imaginary component.
+// CHECK-LABEL: define {{.*}}@conj_(
+// CHECK: fneg x86_fp80 {{.*}}%z.imag
+// CHECK-NOT: __arm64ec_
+
+// The `conjl` builtin is the same operation, not a call to a CRT entry point.
+// CHECK-LABEL: define {{.*}}@conj_b(
+// CHECK: fneg x86_fp80 {{.*}}%z.imag
+// CHECK-NOT: call {{.*}}@conjl
+
+// `creall` and `cimagl` only pick a component of the pair.
+// CHECK-LABEL: define {{.*}}i128 @creal_b(
+// CHECK-NOT: call {{.*}}@creall
+// CHECK: load i128
+
+// CHECK-LABEL: define {{.*}}i128 @cimag_b(
+// CHECK-NOT: call {{.*}}@cimagl
+// CHECK: load i128
+
+// A complex magnitude is real mathematics, so it stays a library call.
+// CHECK-LABEL: define {{.*}}i128 @cabs_b(
+// CHECK: call i128 @cabsl(
+
+// CHECK-LABEL: define {{.*}}@cadd(
+// CHECK: fadd x86_fp80
+// CHECK: fadd x86_fp80
+// CHECK-NOT: __arm64ec_
+
+// `++z` increments the value, not the integer image.
+// CHECK-LABEL: define {{.*}}@cinc(
+// CHECK: fadd x86_fp80 {{.*}}, 1.000000e+00
+// CHECK-NOT: __arm64ec_
+
+// A variadic `long double` is passed by reference to a 16-byte-aligned
+// temporary, exactly as on x86-64.
+// CHECK-LABEL: define {{.*}}i32 @callv(
+// CHECK: [[TMP:%.*]] = alloca x86_fp80, align 16
+// CHECK: store x86_fp80 1.000000e+00, ptr [[TMP]], align 16
+// CHECK: call i32 (ptr, ...) @varargs(ptr {{.*}}, ptr {{.*}}align 16{{.*}}[[TMP]])
+
+// The optimized pipeline keeps `fneg` as a floating-point operation as well.
+// OPT-LABEL: define {{.*}}i128 @neg(i128 {{.*}}%a.coerce)
+// OPT: [[BITS:%.*]] = trunc i128 %a.coerce to i80
+// OPT: [[VAL:%.*]] = bitcast i80 [[BITS]] to x86_fp80
+// OPT: [[NEG:%.*]] = fneg x86_fp80 [[VAL]]
+// OPT: [[NEGBITS:%.*]] = bitcast x86_fp80 [[NEG]] to i80
+// OPT: [[EXT:%.*]] = zext i80 [[NEGBITS]] to i128
+// OPT: ret i128 [[EXT]]
diff --git a/clang/test/Driver/arm64ec-long-double.c b/clang/test/Driver/arm64ec-long-double.c
new file mode 100644
index 00000000000000..18df2a1858e1d1
--- /dev/null
+++ b/clang/test/Driver/arm64ec-long-double.c
@@ -0,0 +1,21 @@
+// RUN: %clang -### --target=arm64ec-w64-mingw32 -mlong-double-64 -c %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=LD64
+// RUN: %clang -### --target=arm64ec-w64-mingw32 -mlong-double-80 -c %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=LD80
+// RUN: %clang -### --target=arm64ec-w64-mingw32 -mlong-double-128 -c %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=LD128
+// RUN: not %clang --target=arm64ec-pc-windows-msvc -mlong-double-64 \
+// RUN: -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix=MSVC
+// RUN: not %clang --target=aarch64-w64-mingw32 -mlong-double-80 \
+// RUN: -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix=AARCH64
+
+// ARM64EC with a non-MSVC ABI defaults to the x87 80-bit format of x86_64, so
+// all three widths are accepted and forwarded to the frontend.
+// LD64: "-mlong-double-64"
+// LD80: "-mlong-double-80"
+// LD128: "-mlong-double-128"
+
+// The MSVC ABI keeps its binary64 `long double` for compatibility, and plain
+// AArch64 has no reason to support the x87 format at all.
+// MSVC: error: unsupported option '-mlong-double-64' for target 'arm64ec-pc-windows-msvc{{.*}}'
+// AARCH64: error: unsupported option '-mlong-double-80' for target 'aarch64-w64-windows-gnu'
>From 60294c7938fb32c9a5aa4ed78cd2f968ad76a667 Mon Sep 17 00:00:00 2001
From: LIU Hao <lh_mouse at 126.com>
Date: Mon, 2 Nov 2026 03:18:21 +0800
Subject: [PATCH 02/10] add Clang test for `-mlong-double-64` on ARM64EC
Assisted-by: DeepSeek V4.1 Flash
---
.../CodeGen/arm64ec-long-double-64-thunks.c | 35 +++++++++++++++++++
1 file changed, 35 insertions(+)
create mode 100644 clang/test/CodeGen/arm64ec-long-double-64-thunks.c
diff --git a/clang/test/CodeGen/arm64ec-long-double-64-thunks.c b/clang/test/CodeGen/arm64ec-long-double-64-thunks.c
new file mode 100644
index 00000000000000..a09e7b0b4835a8
--- /dev/null
+++ b/clang/test/CodeGen/arm64ec-long-double-64-thunks.c
@@ -0,0 +1,35 @@
+// The same boundary crossings as arm64ec-fp80-thunks.ll, with `long double` in
+// its 64-bit form. It is then an ordinary `double`, which the x64 side passes
+// in an XMM register and the ARM64EC side in the very same physical register,
+// so the thunks carry the value through untouched and none of the x87 helpers
+// takes part.
+//
+// RUN: %clang_cc1 -triple arm64ec-w64-windows-gnu -mlong-double-64 -O2 -S -o - %s | FileCheck %s
+
+static long double ec_helper(long double x) { return x + 1.0L; }
+
+long double ec_identity(long double x) { return ec_helper(x); }
+
+extern long double x64_callee(void);
+long double ec_forward(void) { return x64_callee(); }
+
+extern void x64_take(long double);
+void ec_hand_off(long double x) { x64_take(x); }
+
+// An ARM64EC call runs on hardware double precision, so the helper folds into
+// a plain addition on `d` registers; no 80-bit arithmetic is involved.
+// CHECK-LABEL: "#ec_identity":
+// CHECK: fmov d1, #1.00000000
+// CHECK-NEXT: fadd d0, d0, d1
+// CHECK-NEXT: ret
+
+// The entry thunk receives the value in xmm0, which is the register the
+// ARM64EC side expects it in, so it is neither loaded nor stored.
+// CHECK-LABEL: $ientry_thunk$cdecl$d$d:
+// CHECK-NOT: ldr
+// CHECK: blr x9
+
+// The exit thunk returns the value the same way, again moving nothing.
+// CHECK-LABEL: $iexit_thunk$cdecl$d$v:
+// CHECK-NOT: str
+// CHECK: blr x16
>From bb5a78801d191471cb3e5fe8bfd30ed6a7b53e31 Mon Sep 17 00:00:00 2001
From: LIU Hao <lh_mouse at 126.com>
Date: Sun, 1 Nov 2026 20:57:16 +0800
Subject: [PATCH 03/10] add implementation in ARM64EC backend
Assisted-by: DeepSeek V4.1 Flash
---
llvm/include/llvm/IR/RuntimeLibcalls.td | 112 +++++-
.../SelectionDAG/LegalizeFloatTypes.cpp | 134 ++++---
llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h | 1 +
.../CodeGen/SelectionDAG/TargetLowering.cpp | 7 +-
llvm/lib/CodeGen/TargetLoweringBase.cpp | 21 +-
.../AArch64/AArch64Arm64ECCallLowering.cpp | 41 ++-
.../CodeGen/AArch64/arm64ec-entry-thunks.ll | 60 +++
.../CodeGen/AArch64/arm64ec-fp80-libcalls.ll | 345 ++++++++++++++++++
.../AArch64/arm64ec-fp80-soften-bitcast.ll | 41 +++
.../CodeGen/AArch64/arm64ec-fp80-thunks.ll | 129 +++++++
.../arm64ec-varargs-indirect-return.ll | 44 +++
.../AArch64/unsupported-fpext-x86-fp80.ll | 6 +-
.../Util/DeclareRuntimeLibcalls/arm64ec.ll | 89 +++++
.../Util/DeclareRuntimeLibcalls/bsd.ll | 27 ++
.../Util/DeclareRuntimeLibcalls/windows.ll | 27 ++
llvm/unittests/IR/RuntimeLibcallsTest.cpp | 12 +-
16 files changed, 1021 insertions(+), 75 deletions(-)
create mode 100644 llvm/test/CodeGen/AArch64/arm64ec-fp80-libcalls.ll
create mode 100644 llvm/test/CodeGen/AArch64/arm64ec-fp80-soften-bitcast.ll
create mode 100644 llvm/test/CodeGen/AArch64/arm64ec-fp80-thunks.ll
create mode 100644 llvm/test/CodeGen/AArch64/arm64ec-varargs-indirect-return.ll
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.td b/llvm/include/llvm/IR/RuntimeLibcalls.td
index d6ce4adef7d5b0..41de157ac144d1 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.td
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.td
@@ -494,6 +494,8 @@ def FPEXT_F64_F128 : RuntimeLibcall<FP128, [Dbl]>;
def FPEXT_F32_F128 : RuntimeLibcall<FP128, [Flt]>;
def FPEXT_F16_F128 : RuntimeLibcall;
def FPEXT_F16_F80 : RuntimeLibcall;
+def FPEXT_F32_F80 : RuntimeLibcall;
+def FPEXT_F64_F80 : RuntimeLibcall;
def FPEXT_F32_F64 : RuntimeLibcall<Dbl, [Flt]>;
def FPEXT_F16_F64 : RuntimeLibcall;
def FPEXT_F16_F32 : RuntimeLibcall;
@@ -598,7 +600,7 @@ def CONVERT_PPCF128_F128 : RuntimeLibcall;
// The FCMP3_PRED_*_F* libcalls return a three-way (-1/0/1) result, one symbol
// per predicate. FCMP3_F* is a generic three-way compare for ABIs with one
// symbol serving every predicate (e.g. MSP430's __mspabi_cmpd).
-foreach FPTy = ["F32", "F64", "F128", "PPCF128"] in {
+foreach FPTy = ["F32", "F64", "F80", "F128", "PPCF128"] in {
def OEQ_#FPTy : RuntimeLibcall;
def UNE_#FPTy : RuntimeLibcall;
def OGE_#FPTy : RuntimeLibcall;
@@ -1284,6 +1286,8 @@ def __extenddftf2 : RuntimeLibcallImpl<FPEXT_F64_F128>;
def __extendsftf2 : RuntimeLibcallImpl<FPEXT_F32_F128>;
def __extendhftf2 : RuntimeLibcallImpl<FPEXT_F16_F128>;
def __extendhfxf2 : RuntimeLibcallImpl<FPEXT_F16_F80>;
+def __extendsfxf2 : RuntimeLibcallImpl<FPEXT_F32_F80>;
+def __extenddfxf2 : RuntimeLibcallImpl<FPEXT_F64_F80>;
def __extendsfdf2 : RuntimeLibcallImpl<FPEXT_F32_F64>;
def __extendhfdf2 : RuntimeLibcallImpl<FPEXT_F16_F64>;
def __extendhfsf2 : RuntimeLibcallImpl<FPEXT_F16_F32>;
@@ -1385,30 +1389,37 @@ def __trunctfkf2 : RuntimeLibcallImpl<CONVERT_PPCF128_F128>;
// boolean.
def __eqsf2 : RuntimeLibcallImpl<FCMP3_PRED_OEQ_F32>;
def __eqdf2 : RuntimeLibcallImpl<FCMP3_PRED_OEQ_F64>;
+def __eqxf2 : RuntimeLibcallImpl<FCMP3_PRED_OEQ_F80>;
def __eqtf2 : RuntimeLibcallImpl<FCMP3_PRED_OEQ_F128>;
def __gcc_qeq : RuntimeLibcallImpl<FCMP3_PRED_OEQ_PPCF128>;
def __nesf2 : RuntimeLibcallImpl<FCMP3_PRED_UNE_F32>;
def __nedf2 : RuntimeLibcallImpl<FCMP3_PRED_UNE_F64>;
+def __nexf2 : RuntimeLibcallImpl<FCMP3_PRED_UNE_F80>;
def __netf2 : RuntimeLibcallImpl<FCMP3_PRED_UNE_F128>;
def __gcc_qne : RuntimeLibcallImpl<FCMP3_PRED_UNE_PPCF128>;
def __gesf2 : RuntimeLibcallImpl<FCMP3_PRED_OGE_F32>;
def __gedf2 : RuntimeLibcallImpl<FCMP3_PRED_OGE_F64>;
+def __gexf2 : RuntimeLibcallImpl<FCMP3_PRED_OGE_F80>;
def __getf2 : RuntimeLibcallImpl<FCMP3_PRED_OGE_F128>;
def __gcc_qge : RuntimeLibcallImpl<FCMP3_PRED_OGE_PPCF128>;
def __ltsf2 : RuntimeLibcallImpl<FCMP3_PRED_OLT_F32>;
def __ltdf2 : RuntimeLibcallImpl<FCMP3_PRED_OLT_F64>;
+def __ltxf2 : RuntimeLibcallImpl<FCMP3_PRED_OLT_F80>;
def __lttf2 : RuntimeLibcallImpl<FCMP3_PRED_OLT_F128>;
def __gcc_qlt : RuntimeLibcallImpl<FCMP3_PRED_OLT_PPCF128>;
def __lesf2 : RuntimeLibcallImpl<FCMP3_PRED_OLE_F32>;
def __ledf2 : RuntimeLibcallImpl<FCMP3_PRED_OLE_F64>;
+def __lexf2 : RuntimeLibcallImpl<FCMP3_PRED_OLE_F80>;
def __letf2 : RuntimeLibcallImpl<FCMP3_PRED_OLE_F128>;
def __gcc_qle : RuntimeLibcallImpl<FCMP3_PRED_OLE_PPCF128>;
def __gtsf2 : RuntimeLibcallImpl<FCMP3_PRED_OGT_F32>;
def __gtdf2 : RuntimeLibcallImpl<FCMP3_PRED_OGT_F64>;
+def __gtxf2 : RuntimeLibcallImpl<FCMP3_PRED_OGT_F80>;
def __gttf2 : RuntimeLibcallImpl<FCMP3_PRED_OGT_F128>;
def __gcc_qgt : RuntimeLibcallImpl<FCMP3_PRED_OGT_PPCF128>;
def __unordsf2 : RuntimeLibcallImpl<UO_F32>;
def __unorddf2 : RuntimeLibcallImpl<UO_F64>;
+def __unordxf2 : RuntimeLibcallImpl<UO_F80>;
def __unordtf2 : RuntimeLibcallImpl<UO_F128>;
def __gcc_qunord : RuntimeLibcallImpl<UO_PPCF128>;
@@ -2381,11 +2392,104 @@ def AArch64SystemLibrary : SystemRuntimeLibrary<isAArch64_ExceptArm64EC,
["compiler-rt", "libatomic", "llvm-client-runtime", "libm", "libc", "unwind",
"sme"]>;
+//===----------------------------------------------------------------------===//
+// ARM64EC helpers for the x87 `long double` format
+//===----------------------------------------------------------------------===//
+
+// These are not the exact x87 soft-float helpers of libgcc: The value stays
+// an 80-bit x87 image in a 16-byte slot, but every operation on it is carried
+// out in `double`. These are named with an `__arm64ec_` prefix so they will
+// not be confused with, or silently bound to, an exact implementation of the
+// same format.
+defset list<RuntimeLibcallImpl> Arm64ECF80Impls = {
+ def arm64ec___addxf3 : RuntimeLibcallImpl<ADD_F80, "__arm64ec_addxf3">;
+ def arm64ec___subxf3 : RuntimeLibcallImpl<SUB_F80, "__arm64ec_subxf3">;
+ def arm64ec___mulxf3 : RuntimeLibcallImpl<MUL_F80, "__arm64ec_mulxf3">;
+ def arm64ec___divxf3 : RuntimeLibcallImpl<DIV_F80, "__arm64ec_divxf3">;
+ def arm64ec___fmaxf3 : RuntimeLibcallImpl<FMA_F80, "__arm64ec_fmaxf3">;
+ def arm64ec___fmaxxf3 : RuntimeLibcallImpl<FMAX_F80, "__arm64ec_fmaxxf3">;
+ def arm64ec___fminxf3 : RuntimeLibcallImpl<FMIN_F80, "__arm64ec_fminxf3">;
+ def arm64ec___powixf2 : RuntimeLibcallImpl<POWI_F80, "__arm64ec_powixf2">;
+
+ def arm64ec___eqxf2
+ : RuntimeLibcallImpl<FCMP3_PRED_OEQ_F80, "__arm64ec_eqxf2">;
+ def arm64ec___nexf2
+ : RuntimeLibcallImpl<FCMP3_PRED_UNE_F80, "__arm64ec_nexf2">;
+ def arm64ec___gexf2
+ : RuntimeLibcallImpl<FCMP3_PRED_OGE_F80, "__arm64ec_gexf2">;
+ def arm64ec___ltxf2
+ : RuntimeLibcallImpl<FCMP3_PRED_OLT_F80, "__arm64ec_ltxf2">;
+ def arm64ec___lexf2
+ : RuntimeLibcallImpl<FCMP3_PRED_OLE_F80, "__arm64ec_lexf2">;
+ def arm64ec___gtxf2
+ : RuntimeLibcallImpl<FCMP3_PRED_OGT_F80, "__arm64ec_gtxf2">;
+ def arm64ec___unordxf2 : RuntimeLibcallImpl<UO_F80, "__arm64ec_unordxf2">;
+
+ def arm64ec___extendhfxf2
+ : RuntimeLibcallImpl<FPEXT_F16_F80, "__arm64ec_extendhfxf2">;
+ def arm64ec___extendsfxf2
+ : RuntimeLibcallImpl<FPEXT_F32_F80, "__arm64ec_extendsfxf2">;
+ def arm64ec___extenddfxf2
+ : RuntimeLibcallImpl<FPEXT_F64_F80, "__arm64ec_extenddfxf2">;
+ def arm64ec___extendxftf2
+ : RuntimeLibcallImpl<FPEXT_F80_F128, "__arm64ec_extendxftf2">;
+ def arm64ec___truncxfhf2
+ : RuntimeLibcallImpl<FPROUND_F80_F16, "__arm64ec_truncxfhf2">;
+ def arm64ec___truncxfbf2
+ : RuntimeLibcallImpl<FPROUND_F80_BF16, "__arm64ec_truncxfbf2">;
+ def arm64ec___truncxfsf2
+ : RuntimeLibcallImpl<FPROUND_F80_F32, "__arm64ec_truncxfsf2">;
+ def arm64ec___truncxfdf2
+ : RuntimeLibcallImpl<FPROUND_F80_F64, "__arm64ec_truncxfdf2">;
+ def arm64ec___trunctfxf2
+ : RuntimeLibcallImpl<FPROUND_F128_F80, "__arm64ec_trunctfxf2">;
+ def arm64ec___fixxfsi
+ : RuntimeLibcallImpl<FPTOSINT_F80_I32, "__arm64ec_fixxfsi">;
+ def arm64ec___fixxfdi
+ : RuntimeLibcallImpl<FPTOSINT_F80_I64, "__arm64ec_fixxfdi">;
+ def arm64ec___fixxfti
+ : RuntimeLibcallImpl<FPTOSINT_F80_I128, "__arm64ec_fixxfti">;
+ def arm64ec___fixunsxfsi
+ : RuntimeLibcallImpl<FPTOUINT_F80_I32, "__arm64ec_fixunsxfsi">;
+ def arm64ec___fixunsxfdi
+ : RuntimeLibcallImpl<FPTOUINT_F80_I64, "__arm64ec_fixunsxfdi">;
+ def arm64ec___fixunsxfti
+ : RuntimeLibcallImpl<FPTOUINT_F80_I128, "__arm64ec_fixunsxfti">;
+ def arm64ec___floatsixf
+ : RuntimeLibcallImpl<SINTTOFP_I32_F80, "__arm64ec_floatsixf">;
+ def arm64ec___floatdixf
+ : RuntimeLibcallImpl<SINTTOFP_I64_F80, "__arm64ec_floatdixf">;
+ def arm64ec___floattixf
+ : RuntimeLibcallImpl<SINTTOFP_I128_F80, "__arm64ec_floattixf">;
+ def arm64ec___floatunsixf
+ : RuntimeLibcallImpl<UINTTOFP_I32_F80, "__arm64ec_floatunsixf">;
+ def arm64ec___floatundixf
+ : RuntimeLibcallImpl<UINTTOFP_I64_F80, "__arm64ec_floatundixf">;
+ def arm64ec___floatuntixf
+ : RuntimeLibcallImpl<UINTTOFP_I128_F80, "__arm64ec_floatuntixf">;
+} // Arm64ECF80Impls
+
+// The x87 forms of the C library math functions. `LibmLibcallImpls` describes
+// them as `long double` implementations, which `DuplicateLibcallImplWithPrefix`
+// cannot copy (their `Provides` is left open until the module's `long double`
+// format is known), so they are spelled out as plain implementations of the F80
+// libcall each of them provides. `fma` is left out: the fused multiply-add is
+// one of the compiler-rt helpers above.
+defset list<RuntimeLibcallImpl> Arm64ECX87LibmImpls = {
+ foreach entry = !listremove(LibmCoreImpls_ldbl_noFrexpLdexp, [fmal]) in {
+ defvar ldbl = !cast<LongDoubleLibcallImpl>(entry);
+ def arm64ec_ldbl_#entry
+ : RuntimeLibcallImpl<ldbl.ProvidesF80, ldbl.LibCallFuncName>;
+ }
+}
+
// The Windows runtime lacks the f32 and f64 powi helpers, and frexpf/ldexpf.
+// ARM64EC still uses the x87 `long double` format, whose helpers are part of
+// compiler-rt as well.
defvar Arm64ECCompilerRtImpls =
- !listremove(CompilerRtLibgccImpls_core,
- !listremove(PowiLibcallImpls, [__powitf2_f128, __powitf2_ppc128]));
-defvar Arm64ECLibmImpls = !listremove(LibmCoreImpls_core, LibmFrexpLdexpF32);
+ !listconcat(CompilerRtLibgccImpls_core_noPowi, Arm64ECF80Impls);
+defvar Arm64ECLibmImpls = !listconcat(
+ !listremove(LibmCoreImpls_core, LibmFrexpLdexpF32), Arm64ECX87LibmImpls);
// Prepend a # to every name
defset list<RuntimeLibcallImpl> WinArm64ECDefaultRuntimeLibcallImpls = {
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
index acbefd8dcedf2e..cc49dd096fb753 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
@@ -50,6 +50,19 @@ static RTLIB::Libcall GetFPLibCall(EVT VT,
RTLIB::UNKNOWN_LIBCALL;
}
+/// Return the position of the sign bit in the integer image `NVT` of a
+/// softened floating-point value of type `VT`. This is necessary when there
+/// are padding bits, so the sign bit of the integer image does not match the
+/// sign bit of the floating-point value.
+static unsigned getSoftenedFloatSignBit(EVT VT, EVT NVT) {
+ if (VT == MVT::f80) {
+ assert(NVT.getSizeInBits() >= 80 &&
+ "x86_fp80 must be softened to an integer of at least 80 bits");
+ return 79;
+ }
+ return NVT.getSizeInBits() - 1;
+}
+
//===----------------------------------------------------------------------===//
// Convert Float Results to Integer
//===----------------------------------------------------------------------===//
@@ -251,7 +264,16 @@ SDValue DAGTypeLegalizer::SoftenFloatRes_Binary(SDNode *N, RTLIB::Libcall LC) {
}
SDValue DAGTypeLegalizer::SoftenFloatRes_BITCAST(SDNode *N) {
- return BitConvertToInteger(N->getOperand(0));
+ SDValue Op = BitConvertToInteger(N->getOperand(0));
+ // The operand has the same size as the floating-point value, which may be
+ // narrower than the type the value is softened to: An 80-bit x86_fp80, for
+ // instance, is softened to a 16-byte image. The bits that the widening
+ // exposes are padding and are not part of the value, so leave them
+ // indeterminate.
+ EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), N->getValueType(0));
+ if (Op.getValueType() != NVT)
+ Op = DAG.getAnyExtOrTrunc(Op, SDLoc(N), NVT);
+ return Op;
}
SDValue DAGTypeLegalizer::SoftenFloatRes_FREEZE(SDNode *N) {
@@ -300,9 +322,13 @@ SDValue DAGTypeLegalizer::SoftenFloatRes_ConstantFP(SDNode *N) {
TLI.getTypeToTransformTo(*DAG.getContext(),
CN->getValueType(0)));
} else {
- return DAG.getConstant(CN->getValueAPF().bitcastToAPInt(), SDLoc(CN),
- TLI.getTypeToTransformTo(*DAG.getContext(),
- CN->getValueType(0)));
+ APInt Val = CN->getValueAPF().bitcastToAPInt();
+ EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), CN->getValueType(0));
+ // The transform type may be wider than the floating-point type, such as
+ // x86_fp80 -> i128, and the extra bits are padding for the value.
+ if (Val.getBitWidth() < NVT.getSizeInBits())
+ Val = Val.zext(NVT.getSizeInBits());
+ return DAG.getConstant(Val, SDLoc(CN), NVT);
}
}
@@ -323,12 +349,13 @@ SDValue DAGTypeLegalizer::SoftenFloatRes_EXTRACT_VECTOR_ELT(SDNode *N, unsigned
}
SDValue DAGTypeLegalizer::SoftenFloatRes_FABS(SDNode *N) {
- EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), N->getValueType(0));
+ EVT VT = N->getValueType(0);
+ EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
unsigned Size = NVT.getSizeInBits();
- // Mask = ~(1 << (Size-1))
+ // Mask = ~(1 << SignBit)
APInt API = APInt::getAllOnes(Size);
- API.clearBit(Size - 1);
+ API.clearBit(getSoftenedFloatSignBit(VT, NVT));
SDValue Mask = DAG.getConstant(API, SDLoc(N), NVT);
SDValue Op = GetSoftenedFloat(N->getOperand(0));
return DAG.getNode(ISD::AND, SDLoc(N), NVT, Op, Mask);
@@ -425,47 +452,24 @@ SDValue DAGTypeLegalizer::SoftenFloatRes_FCOPYSIGN(SDNode *N) {
SDValue RHS = BitConvertToInteger(N->getOperand(1));
SDLoc dl(N);
+ EVT VT = N->getValueType(0);
EVT LVT = LHS.getValueType();
- EVT RVT = RHS.getValueType();
+ unsigned SignBit = getSoftenedFloatSignBit(VT, LVT);
- unsigned LSize = LVT.getSizeInBits();
- unsigned RSize = RVT.getSizeInBits();
+ // The right-hand side is as wide as the floating-point value itself, which
+ // may be narrower than the image the value is softened to. The sign bit sits
+ // at the same position in both, so only padding is added, and none of it
+ // survives the mask below.
+ if (RHS.getValueType() != LVT)
+ RHS = DAG.getAnyExtOrTrunc(RHS, dl, LVT);
- // First get the sign bit of second operand.
- SDValue SignBit = DAG.getNode(
- ISD::SHL, dl, RVT, DAG.getConstant(1, dl, RVT),
- DAG.getConstant(RSize - 1, dl,
- TLI.getShiftAmountTy(RVT, DAG.getDataLayout())));
- SignBit = DAG.getNode(ISD::AND, dl, RVT, RHS, SignBit);
-
- // Shift right or sign-extend it if the two operands have different types.
- int SizeDiff = RVT.getSizeInBits() - LVT.getSizeInBits();
- if (SizeDiff > 0) {
- SignBit =
- DAG.getNode(ISD::SRL, dl, RVT, SignBit,
- DAG.getConstant(SizeDiff, dl,
- TLI.getShiftAmountTy(SignBit.getValueType(),
- DAG.getDataLayout())));
- SignBit = DAG.getNode(ISD::TRUNCATE, dl, LVT, SignBit);
- } else if (SizeDiff < 0) {
- SignBit = DAG.getNode(ISD::ANY_EXTEND, dl, LVT, SignBit);
- SignBit =
- DAG.getNode(ISD::SHL, dl, LVT, SignBit,
- DAG.getConstant(-SizeDiff, dl,
- TLI.getShiftAmountTy(SignBit.getValueType(),
- DAG.getDataLayout())));
- }
-
- // Clear the sign bit of the first operand.
- SDValue Mask = DAG.getNode(
- ISD::SHL, dl, LVT, DAG.getConstant(1, dl, LVT),
- DAG.getConstant(LSize - 1, dl,
- TLI.getShiftAmountTy(LVT, DAG.getDataLayout())));
- Mask = DAG.getNode(ISD::SUB, dl, LVT, Mask, DAG.getConstant(1, dl, LVT));
- LHS = DAG.getNode(ISD::AND, dl, LVT, LHS, Mask);
-
- // Or the value with the sign bit.
- return DAG.getNode(ISD::OR, dl, LVT, LHS, SignBit);
+ // Result = (LHS & ~SignMask) | (RHS & SignMask)
+ APInt SignMask = APInt::getOneBitSet(LVT.getSizeInBits(), SignBit);
+ SDValue LHSBits =
+ DAG.getNode(ISD::AND, dl, LVT, LHS, DAG.getConstant(~SignMask, dl, LVT));
+ SDValue RHSBits =
+ DAG.getNode(ISD::AND, dl, LVT, RHS, DAG.getConstant(SignMask, dl, LVT));
+ return DAG.getNode(ISD::OR, dl, LVT, LHSBits, RHSBits);
}
SDValue DAGTypeLegalizer::SoftenFloatRes_FCOS(SDNode *N) {
@@ -551,11 +555,13 @@ SDValue DAGTypeLegalizer::SoftenFloatRes_FNEARBYINT(SDNode *N) {
}
SDValue DAGTypeLegalizer::SoftenFloatRes_FNEG(SDNode *N) {
- EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), N->getValueType(0));
+ EVT VT = N->getValueType(0);
+ EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
SDLoc dl(N);
// Expand Y = FNEG(X) -> Y = X ^ sign mask
- APInt SignMask = APInt::getSignMask(NVT.getSizeInBits());
+ APInt SignMask = APInt::getOneBitSet(NVT.getSizeInBits(),
+ getSoftenedFloatSignBit(VT, NVT));
return DAG.getNode(ISD::XOR, dl, NVT, GetSoftenedFloat(N->getOperand(0)),
DAG.getConstant(SignMask, dl, NVT));
}
@@ -570,9 +576,13 @@ SDValue DAGTypeLegalizer::SoftenFloatRes_FP_EXTEND(SDNode *N) {
// There's only a libcall for f16 -> f32 and shifting is only valid for bf16
// -> f32, so proceed in two stages. Also, it's entirely possible for both
// f16 and f32 to be legal, so use the fully hard-float FP_EXTEND rather
- // than FP16_TO_FP.
+ // than FP16_TO_FP. The 80-bit x87 format is an exception, as its helper
+ // takes f16 directly.
if ((Op.getValueType() == MVT::f16 || Op.getValueType() == MVT::bf16) &&
- N->getValueType(0) != MVT::f32) {
+ N->getValueType(0) != MVT::f32 &&
+ !(Op.getValueType() == MVT::f16 && N->getValueType(0) == MVT::f80 &&
+ DAG.getLibcalls().getLibcallImpl(RTLIB::getFPEXT(MVT::f16, MVT::f80)) !=
+ RTLIB::Unsupported)) {
if (IsStrict) {
Op = DAG.getNode(ISD::STRICT_FP_EXTEND, SDLoc(N),
{ MVT::f32, MVT::Other }, { Chain, Op });
@@ -1081,6 +1091,10 @@ bool DAGTypeLegalizer::SoftenFloatOperand(SDNode *N, unsigned OpNo) {
case ISD::STRICT_FP_TO_BF16:
case ISD::STRICT_FP_ROUND:
case ISD::FP_ROUND: Res = SoftenFloatOp_FP_ROUND(N); break;
+ case ISD::STRICT_FP_EXTEND:
+ case ISD::FP_EXTEND:
+ Res = SoftenFloatOp_FP_EXTEND(N);
+ break;
case ISD::STRICT_FP_TO_SINT:
case ISD::STRICT_FP_TO_UINT:
case ISD::FP_TO_SINT:
@@ -1132,9 +1146,29 @@ bool DAGTypeLegalizer::SoftenFloatOperand(SDNode *N, unsigned OpNo) {
}
SDValue DAGTypeLegalizer::SoftenFloatOp_BITCAST(SDNode *N) {
+ EVT VT = N->getValueType(0);
SDValue Op0 = GetSoftenedFloat(N->getOperand(0));
+ // The result is narrower than the softened image when the float type
+ // occupies a wider slot than its own representation; take the low bits.
+ if (Op0.getValueType() != VT)
+ return DAG.getAnyExtOrTrunc(Op0, SDLoc(N), VT);
+ return DAG.getNode(ISD::BITCAST, SDLoc(N), VT, Op0);
+}
- return DAG.getNode(ISD::BITCAST, SDLoc(N), N->getValueType(0), Op0);
+SDValue DAGTypeLegalizer::SoftenFloatOp_FP_EXTEND(SDNode *N) {
+ // Extend a softened value to a legal type, as in x86_fp80 -> fp128: the
+ // operand is the integer image and the helper extends from there. As the
+ // result type is legal, the transform type in the shared helper resolves to
+ // it, so the helper returns the extended value directly.
+ assert(N->getOpcode() == ISD::FP_EXTEND ||
+ N->getOpcode() == ISD::STRICT_FP_EXTEND);
+
+ bool IsStrict = N->isStrictFPOpcode();
+ EVT SVT = N->getOperand(IsStrict ? 1 : 0).getValueType();
+ RTLIB::Libcall LC = RTLIB::getFPEXT(SVT, N->getValueType(0));
+ assert(LC != RTLIB::UNKNOWN_LIBCALL && "Unsupported FP_EXTEND libcall");
+
+ return SoftenFloatOp_Unary(N, LC);
}
SDValue DAGTypeLegalizer::SoftenFloatOp_FP_ROUND(SDNode *N) {
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h b/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
index a7f1a476d03e21..e44c58b8c037de 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
@@ -639,6 +639,7 @@ class LLVM_LIBRARY_VISIBILITY DAGTypeLegalizer {
SDValue SoftenFloatOp_Unary(SDNode *N, RTLIB::Libcall LC);
SDValue SoftenFloatOp_BITCAST(SDNode *N);
SDValue SoftenFloatOp_BR_CC(SDNode *N);
+ SDValue SoftenFloatOp_FP_EXTEND(SDNode *N);
SDValue SoftenFloatOp_FP_ROUND(SDNode *N);
SDValue SoftenFloatOp_FP_TO_XINT(SDNode *N);
SDValue SoftenFloatOp_FP_TO_XINT_SAT(SDNode *N);
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 8aa79b5b8eacfb..efbcb25400d8f1 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -423,8 +423,9 @@ void TargetLowering::softenSetCCOperands(SelectionDAG &DAG, EVT VT,
// not supporting it. We can update this code when libgcc provides such
// functions.
- assert((VT == MVT::f32 || VT == MVT::f64 || VT == MVT::f128 || VT == MVT::ppcf128)
- && "Unsupported setcc type!");
+ assert((VT == MVT::f32 || VT == MVT::f64 || VT == MVT::f80 ||
+ VT == MVT::f128 || VT == MVT::ppcf128) &&
+ "Unsupported setcc type!");
// Expand into one or more soft-fp libcall(s).
ISD::CondCode OrigCCCode = CCCode;
@@ -436,7 +437,7 @@ void TargetLowering::softenSetCCOperands(SelectionDAG &DAG, EVT VT,
// RTLIB::Libcall for VT.
#define FP_CMP_LIBCALL(BASE) \
RTLIB::getFPLibCall(VT, RTLIB::BASE##_F32, RTLIB::BASE##_F64, \
- RTLIB::UNKNOWN_LIBCALL, RTLIB::BASE##_F128, \
+ RTLIB::BASE##_F80, RTLIB::BASE##_F128, \
RTLIB::BASE##_PPCF128)
switch (CCCode) {
diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp
index ff918d982b1d9d..1f8023fb3daef9 100644
--- a/llvm/lib/CodeGen/TargetLoweringBase.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp
@@ -271,11 +271,15 @@ RTLIB::Libcall RTLIB::getFPEXT(EVT OpVT, EVT RetVT) {
} else if (OpVT == MVT::f32) {
if (RetVT == MVT::f64)
return FPEXT_F32_F64;
+ if (RetVT == MVT::f80)
+ return FPEXT_F32_F80;
if (RetVT == MVT::f128)
return FPEXT_F32_F128;
if (RetVT == MVT::ppcf128)
return FPEXT_F32_PPCF128;
} else if (OpVT == MVT::f64) {
+ if (RetVT == MVT::f80)
+ return FPEXT_F64_F80;
if (RetVT == MVT::f128)
return FPEXT_F64_F128;
else if (RetVT == MVT::ppcf128)
@@ -1492,11 +1496,20 @@ void TargetLoweringBase::computeRegisterProperties(
}
// Decide how to handle f80. If the target does not have native f80 support,
- // expand it to i96 and we will be generating soft float library calls.
+ // soften it and we will be generating soft float library calls. For x86-64
+ // `long double` has a size of 16 and an alignment of 16, so it is softened
+ // as one 128-bit integer. For x86-32 it has a size of 12 and alignment of 4,
+ // so it is softened as three 32-bit integers.
if (!isTypeLegal(MVT::f80)) {
- NumRegistersForVT[MVT::f80] = 3*NumRegistersForVT[MVT::i32];
- RegisterTypeForVT[MVT::f80] = RegisterTypeForVT[MVT::i32];
- TransformToType[MVT::f80] = MVT::i32;
+ if (isTypeLegal(MVT::i64)) {
+ NumRegistersForVT[MVT::f80] = NumRegistersForVT[MVT::i128];
+ RegisterTypeForVT[MVT::f80] = RegisterTypeForVT[MVT::i128];
+ TransformToType[MVT::f80] = MVT::i128;
+ } else {
+ NumRegistersForVT[MVT::f80] = 3 * NumRegistersForVT[MVT::i32];
+ RegisterTypeForVT[MVT::f80] = RegisterTypeForVT[MVT::i32];
+ TransformToType[MVT::f80] = MVT::i32;
+ }
ValueTypeActions.setTypeAction(MVT::f80, TypeSoftenFloat);
}
diff --git a/llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp b/llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp
index 115ab144f3c15e..840b58b2fbc56c 100644
--- a/llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp
@@ -343,9 +343,17 @@ ThunkArgInfo AArch64Arm64ECCallLowering::canonicalizeThunkType(
return pointerIndirection(T);
}
+ if (T->isX86_FP80Ty()) {
+ // Prefix with `llvm` since MSVC doesn't have x87 `long double`. This is a
+ // 10-bytes value that is stored in a 16-byte, 16-byte-aligned slot, and
+ // it's always passed and returned in memory.
+ Out << "__llvm_x__";
+ return pointerIndirection(T);
+ }
+
if (T->isFloatingPointTy()) {
report_fatal_error(
- "Only half, bfloat16, float, double, and fp128 are supported "
+ "Only half, bfloat16, float, double, fp128 and x86_fp80 are supported "
"for ARM64EC thunks");
}
@@ -362,7 +370,7 @@ ThunkArgInfo AArch64Arm64ECCallLowering::canonicalizeThunkType(
uint64_t TotalSizeBytes = ElementCnt * ElementSizePerBytes;
if (ElementTy->isHalfTy() || ElementTy->isBFloatTy() ||
ElementTy->isFloatTy() || ElementTy->isDoubleTy() ||
- ElementTy->isFP128Ty()) {
+ ElementTy->isFP128Ty() || ElementTy->isX86_FP80Ty()) {
if (ElementTy->isHalfTy())
// Prefix with `llvm` since MSVC doesn't specify `_Float16`
Out << "__llvm_H__";
@@ -376,6 +384,9 @@ ThunkArgInfo AArch64Arm64ECCallLowering::canonicalizeThunkType(
else if (ElementTy->isFP128Ty())
// Prefix with `llvm` since MSVC doesn't specify `_Float128`
Out << "__llvm_Q__";
+ else if (ElementTy->isX86_FP80Ty())
+ // An array of 80-bit `long double` is always in memory.
+ Out << "__llvm_X__";
Out << TotalSizeBytes;
if (Alignment.value() >= 16 && !Ret)
Out << "a" << Alignment.value();
@@ -389,8 +400,8 @@ ThunkArgInfo AArch64Arm64ECCallLowering::canonicalizeThunkType(
}
} else if (ElementTy->isFloatingPointTy()) {
report_fatal_error(
- "Only half, bfloat16, float, double, and fp128 are supported "
- "for ARM64EC thunks");
+ "Only half, bfloat16, float, double, fp128 and x86_fp80 are "
+ "supported for ARM64EC thunks");
}
}
@@ -592,16 +603,28 @@ Function *AArch64Arm64ECCallLowering::buildEntryThunk(Function *F) {
}
if (F->isVarArg()) {
- // The 5th argument to variadic entry thunks is used to model the x64 sp
+ // The last argument to variadic entry thunks is used to model the x64 sp
// which is passed to the thunk in x4, this can be passed to the callee as
// the variadic argument start address after skipping over the 32 byte
// shadow store.
// The EC thunk CC will assign any argument marked as InReg to x4.
- Thunk->addParamAttr(5, Attribute::InReg);
- Value *Arg = Thunk->getArg(5);
- Arg = IRB.CreatePtrAdd(Arg, IRB.getInt64(0x20));
- Args.push_back(Arg);
+ Thunk->addParamAttr(Thunk->arg_size() - 1, Attribute::InReg);
+ Value *StackArgs = Thunk->getArg(Thunk->arg_size() - 1);
+
+ // x4 points at the 32 byte shadow store, so the first stack argument is
+ // 32 bytes further up. When the hidden return pointer took the first
+ // integer argument register, the x64 caller can only pass three of the
+ // four arguments in registers, and the fourth one, which is the first one
+ // on the stack, fills the last slot of the callee's register save area.
+ uint64_t StackOffset = 0x20;
+ if (TransformDirectToSRet) {
+ Args.push_back(IRB.CreateAlignedLoad(
+ IRB.getInt64Ty(),
+ IRB.CreatePtrAdd(StackArgs, IRB.getInt64(StackOffset)), Align(8)));
+ StackOffset += 8;
+ }
+ Args.push_back(IRB.CreatePtrAdd(StackArgs, IRB.getInt64(StackOffset)));
// Pass in a zero variadic argument size (in x5).
Args.push_back(IRB.getInt64(0));
diff --git a/llvm/test/CodeGen/AArch64/arm64ec-entry-thunks.ll b/llvm/test/CodeGen/AArch64/arm64ec-entry-thunks.ll
index eafb401a1f705f..1b2b0cda36f60b 100644
--- a/llvm/test/CodeGen/AArch64/arm64ec-entry-thunks.ll
+++ b/llvm/test/CodeGen/AArch64/arm64ec-entry-thunks.ll
@@ -831,6 +831,63 @@ start:
ret <8 x i16> %0
}
+%T16Byte = type { i64, i64 }
+; A 16-byte struct returned by value is returned in x0:x1 on the ARM64EC side,
+; but indirectly through a hidden pointer on the x64 side, so the thunk is the
+; mirror image of @has_aligned_sret: the first integer argument register holds
+; the hidden pointer, and the result is written through it on return.
+define %T16Byte @large_struct(i64 %0, i64 %1) nounwind {
+; CHECK-LABEL: .def $ientry_thunk$cdecl$m16$i8i8;
+; CHECK: .section .wowthk$aa,"xr",discard,$ientry_thunk$cdecl$m16$i8i8
+; CHECK: // %bb.0:
+; CHECK-NEXT: stp q6, q7, [sp, #-192]! // 32-byte Folded Spill
+; CHECK-NEXT: .seh_save_any_reg_px q6, 192
+; CHECK-NEXT: stp q8, q9, [sp, #32] // 32-byte Folded Spill
+; CHECK-NEXT: .seh_save_any_reg_p q8, 32
+; CHECK-NEXT: stp q10, q11, [sp, #64] // 32-byte Folded Spill
+; CHECK-NEXT: .seh_save_any_reg_p q10, 64
+; CHECK-NEXT: stp q12, q13, [sp, #96] // 32-byte Folded Spill
+; CHECK-NEXT: .seh_save_any_reg_p q12, 96
+; CHECK-NEXT: stp q14, q15, [sp, #128] // 32-byte Folded Spill
+; CHECK-NEXT: .seh_save_any_reg_p q14, 128
+; CHECK-NEXT: str x19, [sp, #160] // 8-byte Spill
+; CHECK-NEXT: .seh_save_reg x19, 160
+; CHECK-NEXT: stp x29, x30, [sp, #168] // 16-byte Folded Spill
+; CHECK-NEXT: .seh_save_fplr 168
+; CHECK-NEXT: add x29, sp, #168
+; CHECK-NEXT: .seh_add_fp 168
+; CHECK-NEXT: .seh_endprologue
+; CHECK-NEXT: mov x19, x0
+; CHECK-NEXT: mov x0, x1
+; CHECK-NEXT: mov x1, x2
+; CHECK-NEXT: blr x9
+; CHECK-NEXT: adrp x8, __os_arm64x_dispatch_ret
+; CHECK-NEXT: stp x0, x1, [x19]
+; CHECK-NEXT: ldr x0, [x8, :lo12:__os_arm64x_dispatch_ret]
+; CHECK-NEXT: mov x8, x19
+; CHECK-NEXT: .seh_startepilogue
+; CHECK-NEXT: ldp x29, x30, [sp, #168] // 16-byte Folded Reload
+; CHECK-NEXT: .seh_save_fplr 168
+; CHECK-NEXT: ldr x19, [sp, #160] // 8-byte Reload
+; CHECK-NEXT: .seh_save_reg x19, 160
+; CHECK-NEXT: ldp q14, q15, [sp, #128] // 32-byte Folded Reload
+; CHECK-NEXT: .seh_save_any_reg_p q14, 128
+; CHECK-NEXT: ldp q12, q13, [sp, #96] // 32-byte Folded Reload
+; CHECK-NEXT: .seh_save_any_reg_p q12, 96
+; CHECK-NEXT: ldp q10, q11, [sp, #64] // 32-byte Folded Reload
+; CHECK-NEXT: .seh_save_any_reg_p q10, 64
+; CHECK-NEXT: ldp q8, q9, [sp, #32] // 32-byte Folded Reload
+; CHECK-NEXT: .seh_save_any_reg_p q8, 32
+; CHECK-NEXT: ldp q6, q7, [sp], #192 // 32-byte Folded Reload
+; CHECK-NEXT: .seh_save_any_reg_px q6, 192
+; CHECK-NEXT: .seh_endepilogue
+; CHECK-NEXT: br x0
+; CHECK-NEXT: .seh_endfunclet
+; CHECK-NEXT: .seh_endproc
+start:
+ ret %T16Byte zeroinitializer
+}
+
; Verify the hybrid bitmap
; CHECK-LABEL: .section .hybmp$x,"yi"
; CHECK-NEXT: .symidx "#no_op"
@@ -887,3 +944,6 @@ start:
; CHECK-NEXT: .symidx "#large_vector"
; CHECK-NEXT: .symidx $ientry_thunk$cdecl$m16$m16
; CHECK-NEXT: .word 1
+; CHECK-NEXT: .symidx "#large_struct"
+; CHECK-NEXT: .symidx $ientry_thunk$cdecl$m16$i8i8
+; CHECK-NEXT: .word 1
diff --git a/llvm/test/CodeGen/AArch64/arm64ec-fp80-libcalls.ll b/llvm/test/CodeGen/AArch64/arm64ec-fp80-libcalls.ll
new file mode 100644
index 00000000000000..5759cd93c192f4
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/arm64ec-fp80-libcalls.ll
@@ -0,0 +1,345 @@
+; RUN: llc < %s -mtriple=arm64ec-pc-windows-msvc -O0 -o - | FileCheck %s
+
+; On ARM64EC, x86_fp80 is not a legal type: it is softened to i128 holding the
+; 16-byte x87 register image, and every operation on it is performed by a
+; helper from compiler-rt. This test makes sure each of those helpers is
+; actually reachable from IR, so that a missing or misnamed libcall cannot slip
+; through unnoticed.
+
+target triple = "arm64ec-pc-windows-msvc"
+
+declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80)
+declare x86_fp80 @llvm.maxnum.f80(x86_fp80, x86_fp80)
+declare x86_fp80 @llvm.minnum.f80(x86_fp80, x86_fp80)
+declare x86_fp80 @llvm.powi.f80.i32(x86_fp80, i32)
+declare x86_fp80 @llvm.sqrt.f80(x86_fp80)
+declare x86_fp80 @llvm.sin.f80(x86_fp80)
+declare x86_fp80 @llvm.pow.f80(x86_fp80, x86_fp80)
+declare x86_fp80 @llvm.floor.f80(x86_fp80)
+declare x86_fp80 @llvm.experimental.constrained.fadd.f80(x86_fp80, x86_fp80, metadata, metadata)
+declare fp128 @llvm.experimental.constrained.fpext.f128.f80(x86_fp80, metadata)
+declare double @llvm.experimental.constrained.fptrunc.f64.f80(x86_fp80, metadata, metadata)
+
+; Basic arithmetic.
+; CHECK-LABEL: "#f_add":
+; CHECK: bl "#__arm64ec_addxf3"
+define x86_fp80 @f_add(x86_fp80 %a, x86_fp80 %b) {
+ %r = fadd x86_fp80 %a, %b
+ ret x86_fp80 %r
+}
+
+; CHECK-LABEL: "#f_sub":
+; CHECK: bl "#__arm64ec_subxf3"
+define x86_fp80 @f_sub(x86_fp80 %a, x86_fp80 %b) {
+ %r = fsub x86_fp80 %a, %b
+ ret x86_fp80 %r
+}
+
+; CHECK-LABEL: "#f_mul":
+; CHECK: bl "#__arm64ec_mulxf3"
+define x86_fp80 @f_mul(x86_fp80 %a, x86_fp80 %b) {
+ %r = fmul x86_fp80 %a, %b
+ ret x86_fp80 %r
+}
+
+; CHECK-LABEL: "#f_div":
+; CHECK: bl "#__arm64ec_divxf3"
+define x86_fp80 @f_div(x86_fp80 %a, x86_fp80 %b) {
+ %r = fdiv x86_fp80 %a, %b
+ ret x86_fp80 %r
+}
+
+; Three-operand helpers: the fused multiply-add lives in the "fmax" family of
+; libgcc, the minimum and maximum in the "fmaxx"/"fminx" ones.
+; CHECK-LABEL: "#f_fma":
+; CHECK: bl "#__arm64ec_fmaxf3"
+define x86_fp80 @f_fma(x86_fp80 %a, x86_fp80 %b, x86_fp80 %c) {
+ %r = call x86_fp80 @llvm.fma.f80(x86_fp80 %a, x86_fp80 %b, x86_fp80 %c)
+ ret x86_fp80 %r
+}
+
+; CHECK-LABEL: "#f_maxnum":
+; CHECK: bl "#__arm64ec_fmaxxf3"
+define x86_fp80 @f_maxnum(x86_fp80 %a, x86_fp80 %b) {
+ %r = call x86_fp80 @llvm.maxnum.f80(x86_fp80 %a, x86_fp80 %b)
+ ret x86_fp80 %r
+}
+
+; CHECK-LABEL: "#f_minnum":
+; CHECK: bl "#__arm64ec_fminxf3"
+define x86_fp80 @f_minnum(x86_fp80 %a, x86_fp80 %b) {
+ %r = call x86_fp80 @llvm.minnum.f80(x86_fp80 %a, x86_fp80 %b)
+ ret x86_fp80 %r
+}
+
+; CHECK-LABEL: "#f_powi":
+; CHECK: bl "#__arm64ec_powixf2"
+define x86_fp80 @f_powi(x86_fp80 %a, i32 %n) {
+ %r = call x86_fp80 @llvm.powi.f80.i32(x86_fp80 %a, i32 %n)
+ ret x86_fp80 %r
+}
+
+; The libm functions of the format come from the C runtime rather than from
+; compiler-rt, and keep their unsuffixed names.
+; CHECK-LABEL: "#libm_sqrt":
+; CHECK: bl "#sqrtl"
+define x86_fp80 @libm_sqrt(x86_fp80 %a) {
+ %r = call x86_fp80 @llvm.sqrt.f80(x86_fp80 %a)
+ ret x86_fp80 %r
+}
+
+; CHECK-LABEL: "#libm_sin":
+; CHECK: bl "#sinl"
+define x86_fp80 @libm_sin(x86_fp80 %a) {
+ %r = call x86_fp80 @llvm.sin.f80(x86_fp80 %a)
+ ret x86_fp80 %r
+}
+
+; CHECK-LABEL: "#libm_pow":
+; CHECK: bl "#powl"
+define x86_fp80 @libm_pow(x86_fp80 %a, x86_fp80 %b) {
+ %r = call x86_fp80 @llvm.pow.f80(x86_fp80 %a, x86_fp80 %b)
+ ret x86_fp80 %r
+}
+
+; CHECK-LABEL: "#libm_floor":
+; CHECK: bl "#floorl"
+define x86_fp80 @libm_floor(x86_fp80 %a) {
+ %r = call x86_fp80 @llvm.floor.f80(x86_fp80 %a)
+ ret x86_fp80 %r
+}
+
+; CHECK-LABEL: "#libm_fmod":
+; CHECK: bl "#fmodl"
+define x86_fp80 @libm_fmod(x86_fp80 %a, x86_fp80 %b) {
+ %r = frem x86_fp80 %a, %b
+ ret x86_fp80 %r
+}
+
+; Conversions from narrower and wider formats. f16 has a helper that takes
+; it directly, while bf16 has none and goes through f32.
+; CHECK-LABEL: "#c_ext_half":
+; CHECK: bl "#__arm64ec_extendhfxf2"
+define x86_fp80 @c_ext_half(half %a) {
+ %r = fpext half %a to x86_fp80
+ ret x86_fp80 %r
+}
+
+; CHECK-LABEL: "#c_ext_float":
+; CHECK: bl "#__arm64ec_extendsfxf2"
+define x86_fp80 @c_ext_float(float %a) {
+ %r = fpext float %a to x86_fp80
+ ret x86_fp80 %r
+}
+
+; CHECK-LABEL: "#c_ext_double":
+; CHECK: bl "#__arm64ec_extenddfxf2"
+define x86_fp80 @c_ext_double(double %a) {
+ %r = fpext double %a to x86_fp80
+ ret x86_fp80 %r
+}
+
+; The source is softened here, not the destination.
+; CHECK-LABEL: "#c_ext_f128":
+; CHECK: bl "#__arm64ec_extendxftf2"
+define fp128 @c_ext_f128(x86_fp80 %a) {
+ %r = fpext x86_fp80 %a to fp128
+ ret fp128 %r
+}
+
+; CHECK-LABEL: "#c_trunc_half":
+; CHECK: bl "#__arm64ec_truncxfhf2"
+define half @c_trunc_half(x86_fp80 %a) {
+ %r = fptrunc x86_fp80 %a to half
+ ret half %r
+}
+
+; CHECK-LABEL: "#c_trunc_bf16":
+; CHECK: bl "#__arm64ec_truncxfbf2"
+define bfloat @c_trunc_bf16(x86_fp80 %a) {
+ %r = fptrunc x86_fp80 %a to bfloat
+ ret bfloat %r
+}
+
+; CHECK-LABEL: "#c_trunc_float":
+; CHECK: bl "#__arm64ec_truncxfsf2"
+define float @c_trunc_float(x86_fp80 %a) {
+ %r = fptrunc x86_fp80 %a to float
+ ret float %r
+}
+
+; CHECK-LABEL: "#c_trunc_double":
+; CHECK: bl "#__arm64ec_truncxfdf2"
+define double @c_trunc_double(x86_fp80 %a) {
+ %r = fptrunc x86_fp80 %a to double
+ ret double %r
+}
+
+; CHECK-LABEL: "#c_trunc_f128":
+; CHECK: bl "#__arm64ec_trunctfxf2"
+define x86_fp80 @c_trunc_f128(fp128 %a) {
+ %r = fptrunc fp128 %a to x86_fp80
+ ret x86_fp80 %r
+}
+
+; Conversions to and from integers.
+; CHECK-LABEL: "#i_fix_i32":
+; CHECK: bl "#__arm64ec_fixxfsi"
+define i32 @i_fix_i32(x86_fp80 %a) {
+ %r = fptosi x86_fp80 %a to i32
+ ret i32 %r
+}
+
+; CHECK-LABEL: "#i_fix_i64":
+; CHECK: bl "#__arm64ec_fixxfdi"
+define i64 @i_fix_i64(x86_fp80 %a) {
+ %r = fptosi x86_fp80 %a to i64
+ ret i64 %r
+}
+
+; CHECK-LABEL: "#i_fix_i128":
+; CHECK: bl "#__arm64ec_fixxfti"
+define i128 @i_fix_i128(x86_fp80 %a) {
+ %r = fptosi x86_fp80 %a to i128
+ ret i128 %r
+}
+
+; CHECK-LABEL: "#i_fixuns_i32":
+; CHECK: bl "#__arm64ec_fixunsxfsi"
+define i32 @i_fixuns_i32(x86_fp80 %a) {
+ %r = fptoui x86_fp80 %a to i32
+ ret i32 %r
+}
+
+; CHECK-LABEL: "#i_fixuns_i64":
+; CHECK: bl "#__arm64ec_fixunsxfdi"
+define i64 @i_fixuns_i64(x86_fp80 %a) {
+ %r = fptoui x86_fp80 %a to i64
+ ret i64 %r
+}
+
+; CHECK-LABEL: "#i_fixuns_i128":
+; CHECK: bl "#__arm64ec_fixunsxfti"
+define i128 @i_fixuns_i128(x86_fp80 %a) {
+ %r = fptoui x86_fp80 %a to i128
+ ret i128 %r
+}
+
+; CHECK-LABEL: "#i_float_i32":
+; CHECK: bl "#__arm64ec_floatsixf"
+define x86_fp80 @i_float_i32(i32 %a) {
+ %r = sitofp i32 %a to x86_fp80
+ ret x86_fp80 %r
+}
+
+; CHECK-LABEL: "#i_float_i64":
+; CHECK: bl "#__arm64ec_floatdixf"
+define x86_fp80 @i_float_i64(i64 %a) {
+ %r = sitofp i64 %a to x86_fp80
+ ret x86_fp80 %r
+}
+
+; CHECK-LABEL: "#i_float_i128":
+; CHECK: bl "#__arm64ec_floattixf"
+define x86_fp80 @i_float_i128(i128 %a) {
+ %r = sitofp i128 %a to x86_fp80
+ ret x86_fp80 %r
+}
+
+; CHECK-LABEL: "#i_floatuns_i32":
+; CHECK: bl "#__arm64ec_floatunsixf"
+define x86_fp80 @i_floatuns_i32(i32 %a) {
+ %r = uitofp i32 %a to x86_fp80
+ ret x86_fp80 %r
+}
+
+; CHECK-LABEL: "#i_floatuns_i64":
+; CHECK: bl "#__arm64ec_floatundixf"
+define x86_fp80 @i_floatuns_i64(i64 %a) {
+ %r = uitofp i64 %a to x86_fp80
+ ret x86_fp80 %r
+}
+
+; CHECK-LABEL: "#i_floatuns_i128":
+; CHECK: bl "#__arm64ec_floatuntixf"
+define x86_fp80 @i_floatuns_i128(i128 %a) {
+ %r = uitofp i128 %a to x86_fp80
+ ret x86_fp80 %r
+}
+
+; Every comparison predicate has its own helper.
+; CHECK-LABEL: "#cmp_oeq":
+; CHECK: bl "#__arm64ec_eqxf2"
+define i1 @cmp_oeq(x86_fp80 %a, x86_fp80 %b) {
+ %r = fcmp oeq x86_fp80 %a, %b
+ ret i1 %r
+}
+
+; CHECK-LABEL: "#cmp_une":
+; CHECK: bl "#__arm64ec_nexf2"
+define i1 @cmp_une(x86_fp80 %a, x86_fp80 %b) {
+ %r = fcmp une x86_fp80 %a, %b
+ ret i1 %r
+}
+
+; CHECK-LABEL: "#cmp_oge":
+; CHECK: bl "#__arm64ec_gexf2"
+define i1 @cmp_oge(x86_fp80 %a, x86_fp80 %b) {
+ %r = fcmp oge x86_fp80 %a, %b
+ ret i1 %r
+}
+
+; CHECK-LABEL: "#cmp_olt":
+; CHECK: bl "#__arm64ec_ltxf2"
+define i1 @cmp_olt(x86_fp80 %a, x86_fp80 %b) {
+ %r = fcmp olt x86_fp80 %a, %b
+ ret i1 %r
+}
+
+; CHECK-LABEL: "#cmp_ole":
+; CHECK: bl "#__arm64ec_lexf2"
+define i1 @cmp_ole(x86_fp80 %a, x86_fp80 %b) {
+ %r = fcmp ole x86_fp80 %a, %b
+ ret i1 %r
+}
+
+; CHECK-LABEL: "#cmp_ogt":
+; CHECK: bl "#__arm64ec_gtxf2"
+define i1 @cmp_ogt(x86_fp80 %a, x86_fp80 %b) {
+ %r = fcmp ogt x86_fp80 %a, %b
+ ret i1 %r
+}
+
+; CHECK-LABEL: "#cmp_uno":
+; CHECK: bl "#__arm64ec_unordxf2"
+define i1 @cmp_uno(x86_fp80 %a, x86_fp80 %b) {
+ %r = fcmp uno x86_fp80 %a, %b
+ ret i1 %r
+}
+
+; The constrained intrinsics go through the same helpers.
+; CHECK-LABEL: "#strict_fadd":
+; CHECK: bl "#__arm64ec_addxf3"
+define x86_fp80 @strict_fadd(x86_fp80 %a, x86_fp80 %b) strictfp {
+ %r = call x86_fp80 @llvm.experimental.constrained.fadd.f80(
+ x86_fp80 %a, x86_fp80 %b,
+ metadata !"round.dynamic", metadata !"fpexcept.strict")
+ ret x86_fp80 %r
+}
+
+; CHECK-LABEL: "#strict_fpext":
+; CHECK: bl "#__arm64ec_extendxftf2"
+define fp128 @strict_fpext(x86_fp80 %a) strictfp {
+ %r = call fp128 @llvm.experimental.constrained.fpext.f128.f80(
+ x86_fp80 %a, metadata !"fpexcept.strict")
+ ret fp128 %r
+}
+
+; CHECK-LABEL: "#strict_fptrunc":
+; CHECK: bl "#__arm64ec_truncxfdf2"
+define double @strict_fptrunc(x86_fp80 %a) strictfp {
+ %r = call double @llvm.experimental.constrained.fptrunc.f64.f80(
+ x86_fp80 %a, metadata !"round.dynamic", metadata !"fpexcept.strict")
+ ret double %r
+}
+
diff --git a/llvm/test/CodeGen/AArch64/arm64ec-fp80-soften-bitcast.ll b/llvm/test/CodeGen/AArch64/arm64ec-fp80-soften-bitcast.ll
new file mode 100644
index 00000000000000..e7b0d00031a66f
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/arm64ec-fp80-soften-bitcast.ll
@@ -0,0 +1,41 @@
+; RUN: llc < %s -mtriple=arm64ec-pc-windows-msvc -O0 -o - | FileCheck %s
+
+;; The x87 `long double` is an 80-bit value that occupies a 16-byte slot with
+;; 16-byte alignment, and the backend softens it to a 16-byte integer image.
+;; The frontend converts between that image and the value with `trunc` and
+;; `bitcast` pairs, so a bitcast has to produce and consume the whole slot
+;; rather than just the 80 value bits; otherwise the image is an i80 and the
+;; operations on it no longer agree on their type.
+;;
+;; The helpers are the ARM64EC ones, which are named apart from the exact x87
+;; soft-float helpers of libgcc, and are `#`-prefixed at the object level.
+
+target triple = "arm64ec-pc-windows-msvc"
+
+define x86_fp80 @bitcast_select(i128 %bits, i1 %c) {
+entry:
+ %trunc = trunc i128 %bits to i80
+ %value = bitcast i80 %trunc to x86_fp80
+ %neg = fneg x86_fp80 %value
+ %sel = select i1 %c, x86_fp80 %value, x86_fp80 %neg
+ ret x86_fp80 %sel
+}
+
+; CHECK-LABEL: "#bitcast_select":
+;; The sign is flipped with an exclusive or of the image, with no helper call.
+; CHECK: eor
+; CHECK-NOT: bl
+; CHECK: ret
+
+define x86_fp80 @bitcast_arithmetic(i128 %a, i128 %b) {
+entry:
+ %at = trunc i128 %a to i80
+ %x = bitcast i80 %at to x86_fp80
+ %bt = trunc i128 %b to i80
+ %y = bitcast i80 %bt to x86_fp80
+ %sum = fadd x86_fp80 %x, %y
+ ret x86_fp80 %sum
+}
+
+; CHECK-LABEL: "#bitcast_arithmetic":
+; CHECK: bl "#__arm64ec_addxf3"
diff --git a/llvm/test/CodeGen/AArch64/arm64ec-fp80-thunks.ll b/llvm/test/CodeGen/AArch64/arm64ec-fp80-thunks.ll
new file mode 100644
index 00000000000000..a391ee0e3a33fa
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/arm64ec-fp80-thunks.ll
@@ -0,0 +1,129 @@
+; RUN: llc < %s -mtriple=arm64ec-pc-windows-msvc -o - | FileCheck %s
+;
+;; The 80-bit x87 `long double` occupies a 16-byte slot, but the ARM64EC side
+;; passes and returns it as a pair of integer registers holding the 80-bit
+;; image, while the x64 side passes it in memory (by reference) and returns it
+;; through a hidden pointer. The thunks convert between the two, moving only
+;; the ten bytes that make up the value and leaving the padding alone.
+;;
+;; entry thunk: x64 memory slot -> ARM64EC register pair
+;; exit thunk: ARM64EC register pair -> x64 memory slot
+
+target triple = "arm64ec-pc-windows-msvc"
+
+declare x86_fp80 @ext_ret()
+declare void @ext_take(x86_fp80)
+
+; The value is an i128 in an even-aligned register pair, so having a 32-bit
+; argument in x0 puts it in x2:x3, and it is returned in x1:x0.
+define dso_local x86_fp80 @use_f80(i32 %x, x86_fp80 %v) {
+ ret x86_fp80 %v
+}
+
+define dso_local x86_fp80 @pass_f80(x86_fp80 %v) {
+ ret x86_fp80 %v
+}
+
+define dso_local void @take_f80(i32 %x, x86_fp80 %v) {
+ ret void
+}
+
+; With seven integer arguments the pair no longer fits in the argument
+; registers and is passed on the stack, by value on the ARM64EC side and by
+; reference on the x64 side.
+define dso_local void @stack_f80(i64 %a, i64 %b, i64 %c, i64 %d, i64 %e,
+ i64 %f, i64 %g, x86_fp80 %v) {
+ ret void
+}
+
+define dso_local x86_fp80 @ec_caller_ret() {
+ %r = call x86_fp80 @ext_ret()
+ ret x86_fp80 %r
+}
+
+define dso_local void @ec_caller_take(x86_fp80 %v) {
+ call void @ext_take(x86_fp80 %v)
+ ret void
+}
+
+; -----------------------------------------------------------------------------
+; ARM64EC side: the argument arrives in x2:x3 and the result is returned in
+; x1:x0.
+; CHECK-LABEL: "#use_f80":
+; CHECK: mov x1, x3
+; CHECK-NEXT: mov x0, x2
+; CHECK-NEXT: ret
+
+; -----------------------------------------------------------------------------
+; Entry thunk for @use_f80: x0 is the hidden return pointer, x1 the 32-bit
+; argument and x2 the pointer to the memory slot, which is loaded into the
+; register pair. The returned pair is written through the return pointer.
+; CHECK-LABEL: $ientry_thunk$cdecl$__llvm_x__$i8__llvm_x__:
+; CHECK: ldr x8, [x2]
+; CHECK-NEXT: ldrh w3, [x2, #8]
+; CHECK-NEXT: mov x19, x0
+; CHECK-NEXT: mov x0, x1
+; CHECK-NEXT: mov x2, x8
+; CHECK-NEXT: blr x9
+; CHECK: str x0, [x19]
+; CHECK-NEXT: strh w1, [x19, #8]
+
+; -----------------------------------------------------------------------------
+; Entry thunk for @pass_f80: the slot pointer is in x1 and the pair fills the
+; first two argument registers.
+; CHECK-LABEL: $ientry_thunk$cdecl$__llvm_x__$__llvm_x__:
+; CHECK: mov x19, x0
+; CHECK-NEXT: ldr x0, [x1]
+; CHECK-NEXT: ldrh w1, [x1, #8]
+; CHECK-NEXT: blr x9
+; CHECK: str x0, [x19]
+; CHECK-NEXT: strh w1, [x19, #8]
+
+; -----------------------------------------------------------------------------
+; Entry thunk for @take_f80: the 32-bit argument stays in x0, so the pair goes
+; into x2:x3.
+; CHECK-LABEL: $ientry_thunk$cdecl$v$i8__llvm_x__:
+; CHECK: ldr x2, [x1]
+; CHECK-NEXT: ldrh w3, [x1, #8]
+; CHECK-NEXT: blr x9
+
+; -----------------------------------------------------------------------------
+; Entry thunk for @stack_f80: x4 points at the x64 stack arguments, from which
+; the pair is copied onto the outgoing stack, dereferencing the pointer to the
+; slot that the x64 side stores there.
+; CHECK-LABEL: $ientry_thunk$cdecl$v$i8i8i8i8i8i8i8__llvm_x__:
+; CHECK: ldp x8, x5, [x4, #32]
+; CHECK-NEXT: ldr x11, [x10]
+; CHECK-NEXT: ldrh w10, [x10, #8]
+; CHECK-NEXT: mov x4, x8
+; CHECK-NEXT: stp x11, x10, [sp]
+; CHECK-NEXT: blr x9
+
+; -----------------------------------------------------------------------------
+; Exit thunk for @ec_caller_ret: the x64 function returns through the hidden
+; pointer in x0, and the slot is loaded back into the register pair.
+; CHECK-LABEL: $iexit_thunk$cdecl$__llvm_x__$v:
+; CHECK: sub x0, x29, #16
+; CHECK-NEXT: ldr x16, [x8, :lo12:__os_arm64x_dispatch_call_no_redirect]
+; CHECK-NEXT: blr x16
+; CHECK-NEXT: ldurh w1, [x29, #-8]
+; CHECK-NEXT: ldur x0, [x29, #-16]
+; CHECK: ret
+
+; -----------------------------------------------------------------------------
+; Exit thunk for @ec_caller_take: the incoming pair is stored to a slot whose
+; address is passed to the x64 function.
+; CHECK-LABEL: $iexit_thunk$cdecl$v$__llvm_x__:
+; CHECK: stur x0, [x29, #-16]
+; CHECK-NEXT: sub x0, x29, #16
+; CHECK-NEXT: ldr x16, [x8, :lo12:__os_arm64x_dispatch_call_no_redirect]
+; CHECK-NEXT: sturh w1, [x29, #-8]
+; CHECK-NEXT: blr x16
+; CHECK: ret
+
+; -----------------------------------------------------------------------------
+; The thunks are attached to their functions in the hybrid map.
+; CHECK: .symidx "#pass_f80"
+; CHECK-NEXT: .symidx $ientry_thunk$cdecl$__llvm_x__$__llvm_x__
+; CHECK: .symidx ext_take
+; CHECK-NEXT: .symidx $iexit_thunk$cdecl$v$__llvm_x__
diff --git a/llvm/test/CodeGen/AArch64/arm64ec-varargs-indirect-return.ll b/llvm/test/CodeGen/AArch64/arm64ec-varargs-indirect-return.ll
new file mode 100644
index 00000000000000..c66765adb52c03
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/arm64ec-varargs-indirect-return.ll
@@ -0,0 +1,44 @@
+; RUN: llc < %s -mtriple=arm64ec-pc-windows-msvc -o - | FileCheck %s
+
+;; A variadic function whose value the x64 side returns indirectly still
+;; receives three of the four integer arguments in registers, because the
+;; hidden return pointer takes the first one. The fourth argument has to be
+;; loaded from the stack, and the callee's view of the stack arguments has to
+;; start above it.
+
+target triple = "arm64ec-pc-windows-msvc"
+
+define i128 @ret_i128_vararg(i32 %a, ...) {
+ ret i128 0
+}
+
+; CHECK: .def $ientry_thunk$cdecl$m16$varargs;
+; CHECK-LABEL: $ientry_thunk$cdecl$m16$varargs:
+; CHECK: mov x8, x3
+;; The first stack argument fills the last register slot...
+; CHECK-NEXT: ldr x3, [x4, #32]
+; CHECK-NEXT: mov x19, x0
+;; ...and the remaining stack arguments start after it.
+; CHECK-NEXT: add x4, x4, #40
+; CHECK-NEXT: mov x0, x1
+; CHECK-NEXT: mov x1, x2
+; CHECK-NEXT: mov x2, x8
+; CHECK-NEXT: mov x5, xzr
+; CHECK-NEXT: blr x9
+;; The result is written through the hidden return pointer, which is also
+;; returned in x8, as the x64 calling convention requires.
+; CHECK: stp x0, x1, [x19]
+; CHECK: mov x8, x19
+
+;; A function that returns nothing passes all four integer arguments in
+;; registers and only skips over the shadow store.
+define void @ret_void_vararg(i32 %a, ...) {
+ ret void
+}
+
+; CHECK: .def $ientry_thunk$cdecl$v$varargs;
+; CHECK-LABEL: $ientry_thunk$cdecl$v$varargs:
+; CHECK-NOT: ldr x3, [x4
+; CHECK: add x4, x4, #32
+; CHECK-NEXT: mov x5, xzr
+; CHECK-NEXT: blr x9
diff --git a/llvm/test/CodeGen/AArch64/unsupported-fpext-x86-fp80.ll b/llvm/test/CodeGen/AArch64/unsupported-fpext-x86-fp80.ll
index 83e397825dfc79..b43b319e395ee6 100644
--- a/llvm/test/CodeGen/AArch64/unsupported-fpext-x86-fp80.ll
+++ b/llvm/test/CodeGen/AArch64/unsupported-fpext-x86-fp80.ll
@@ -3,8 +3,12 @@
; Verify that we get a user-friendly error instead of an assertion failure
; when trying to fpext to x86_fp80 on AArch64 (which has no libcall for it).
; See: https://github.com/llvm/llvm-project/issues/182449
+;
+; Targets that support the x87 format define the `FPEXT_*_F80` libcalls, so the
+; pair above is known and the error comes from the missing implementation
+; rather than from the missing libcall.
-; CHECK: error: do not know how to soften fp_extend
+; CHECK: error: no libcall available for fp_extend with type f80
define x86_fp80 @test_fpext_double_to_x86_fp80(double %x) {
%ext = fpext double %x to x86_fp80
diff --git a/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/arm64ec.ll b/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/arm64ec.ll
index d659751498889a..1f5c3e0f4d8d9b 100644
--- a/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/arm64ec.ll
+++ b/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/arm64ec.ll
@@ -108,6 +108,42 @@
; CHECK-NEXT: declare double @"#__adddf3"(double, double)
; CHECK-NEXT: declare float @"#__addsf3"(float, float)
; CHECK-NEXT: declare fp128 @"#__addtf3"(fp128, fp128)
+; CHECK-NEXT: declare x86_fp80 @"#__arm64ec_addxf3"(x86_fp80, x86_fp80)
+; CHECK-NEXT: declare x86_fp80 @"#__arm64ec_divxf3"(x86_fp80, x86_fp80)
+; CHECK-NEXT: declare void @"#__arm64ec_eqxf2"(...)
+; CHECK-NEXT: declare void @"#__arm64ec_extenddfxf2"(...)
+; CHECK-NEXT: declare void @"#__arm64ec_extendhfxf2"(...)
+; CHECK-NEXT: declare void @"#__arm64ec_extendsfxf2"(...)
+; CHECK-NEXT: declare fp128 @"#__arm64ec_extendxftf2"(x86_fp80)
+; CHECK-NEXT: declare i64 @"#__arm64ec_fixunsxfdi"(x86_fp80)
+; CHECK-NEXT: declare i32 @"#__arm64ec_fixunsxfsi"(x86_fp80)
+; CHECK-NEXT: declare void @"#__arm64ec_fixunsxfti"(...)
+; CHECK-NEXT: declare i64 @"#__arm64ec_fixxfdi"(x86_fp80)
+; CHECK-NEXT: declare i32 @"#__arm64ec_fixxfsi"(x86_fp80)
+; CHECK-NEXT: declare void @"#__arm64ec_fixxfti"(...)
+; CHECK-NEXT: declare x86_fp80 @"#__arm64ec_floatdixf"(i64)
+; CHECK-NEXT: declare x86_fp80 @"#__arm64ec_floatsixf"(i32)
+; CHECK-NEXT: declare void @"#__arm64ec_floattixf"(...)
+; CHECK-NEXT: declare x86_fp80 @"#__arm64ec_floatundixf"(i64)
+; CHECK-NEXT: declare x86_fp80 @"#__arm64ec_floatunsixf"(i32)
+; CHECK-NEXT: declare void @"#__arm64ec_floatuntixf"(...)
+; CHECK-NEXT: declare x86_fp80 @"#__arm64ec_fmaxf3"(x86_fp80, x86_fp80, x86_fp80)
+; CHECK-NEXT: declare x86_fp80 @"#__arm64ec_fmaxxf3"(x86_fp80, x86_fp80)
+; CHECK-NEXT: declare x86_fp80 @"#__arm64ec_fminxf3"(x86_fp80, x86_fp80)
+; CHECK-NEXT: declare void @"#__arm64ec_gexf2"(...)
+; CHECK-NEXT: declare void @"#__arm64ec_gtxf2"(...)
+; CHECK-NEXT: declare void @"#__arm64ec_lexf2"(...)
+; CHECK-NEXT: declare void @"#__arm64ec_ltxf2"(...)
+; CHECK-NEXT: declare x86_fp80 @"#__arm64ec_mulxf3"(x86_fp80, x86_fp80)
+; CHECK-NEXT: declare void @"#__arm64ec_nexf2"(...)
+; CHECK-NEXT: declare x86_fp80 @"#__arm64ec_powixf2"(x86_fp80, i32)
+; CHECK-NEXT: declare x86_fp80 @"#__arm64ec_subxf3"(x86_fp80, x86_fp80)
+; CHECK-NEXT: declare x86_fp80 @"#__arm64ec_trunctfxf2"(fp128)
+; CHECK-NEXT: declare void @"#__arm64ec_truncxfbf2"(...)
+; CHECK-NEXT: declare double @"#__arm64ec_truncxfdf2"(x86_fp80)
+; CHECK-NEXT: declare void @"#__arm64ec_truncxfhf2"(...)
+; CHECK-NEXT: declare float @"#__arm64ec_truncxfsf2"(x86_fp80)
+; CHECK-NEXT: declare void @"#__arm64ec_unordxf2"(...)
; CHECK-NEXT: declare void @"#__arm_sc_memchr"(...)
; CHECK-NEXT: declare void @"#__arm_sc_memcpy"(...)
; CHECK-NEXT: declare void @"#__arm_sc_memmove"(...)
@@ -191,8 +227,10 @@
; CHECK-NEXT: declare void @"#__eqtf2"(...)
; CHECK-NEXT: declare double @"#__exp2_finite"(double)
; CHECK-NEXT: declare float @"#__exp2f_finite"(float)
+; CHECK-NEXT: declare x86_fp80 @"#__exp2l_finite"(x86_fp80)
; CHECK-NEXT: declare double @"#__exp_finite"(double)
; CHECK-NEXT: declare float @"#__expf_finite"(float)
+; CHECK-NEXT: declare x86_fp80 @"#__expl_finite"(x86_fp80)
; CHECK-NEXT: declare void @"#__extendbfsf2"(...)
; CHECK-NEXT: declare fp128 @"#__extenddftf2"(double)
; CHECK-NEXT: declare void @"#__extendhfdf2"(...)
@@ -277,10 +315,13 @@
; CHECK-NEXT: declare void @"#__llvm_memset_element_unordered_atomic_8"(...)
; CHECK-NEXT: declare double @"#__log10_finite"(double)
; CHECK-NEXT: declare float @"#__log10f_finite"(float)
+; CHECK-NEXT: declare x86_fp80 @"#__log10l_finite"(x86_fp80)
; CHECK-NEXT: declare double @"#__log2_finite"(double)
; CHECK-NEXT: declare float @"#__log2f_finite"(float)
+; CHECK-NEXT: declare x86_fp80 @"#__log2l_finite"(x86_fp80)
; CHECK-NEXT: declare double @"#__log_finite"(double)
; CHECK-NEXT: declare float @"#__logf_finite"(float)
+; CHECK-NEXT: declare x86_fp80 @"#__logl_finite"(x86_fp80)
; CHECK-NEXT: declare void @"#__lshrdi3"(...)
; CHECK-NEXT: declare void @"#__lshrhi3"(...)
; CHECK-NEXT: declare void @"#__lshrsi3"(...)
@@ -314,6 +355,7 @@
; CHECK-NEXT: declare double @"#__pow_finite"(double, double)
; CHECK-NEXT: declare float @"#__powf_finite"(float, float)
; CHECK-NEXT: declare fp128 @"#__powitf2"(fp128, i32)
+; CHECK-NEXT: declare x86_fp80 @"#__powl_finite"(x86_fp80, x86_fp80)
; CHECK-NEXT: declare void @"#__security_check_cookie_arm64ec"(...)
; CHECK-NEXT: declare double @"#__subdf3"(double, double)
; CHECK-NEXT: declare float @"#__subsf3"(float, float)
@@ -402,39 +444,53 @@
; CHECK-NEXT: declare void @"#__unordtf2"(...)
; CHECK-NEXT: declare double @"#acos"(double)
; CHECK-NEXT: declare float @"#acosf"(float)
+; CHECK-NEXT: declare x86_fp80 @"#acosl"(x86_fp80)
; CHECK-NEXT: declare double @"#asin"(double)
; CHECK-NEXT: declare float @"#asinf"(float)
+; CHECK-NEXT: declare x86_fp80 @"#asinl"(x86_fp80)
; CHECK-NEXT: declare double @"#atan"(double)
; CHECK-NEXT: declare double @"#atan2"(double, double)
; CHECK-NEXT: declare float @"#atan2f"(float, float)
+; CHECK-NEXT: declare x86_fp80 @"#atan2l"(x86_fp80, x86_fp80)
; CHECK-NEXT: declare float @"#atanf"(float)
+; CHECK-NEXT: declare x86_fp80 @"#atanl"(x86_fp80)
; CHECK-NEXT: declare void @"#cabs"(...)
; CHECK-NEXT: declare void @"#cabsf"(...)
+; CHECK-NEXT: declare void @"#cabsl"(...)
; CHECK-NEXT: declare ptr @"#calloc"(i64, i64)
; CHECK-NEXT: declare double @"#cbrt"(double)
; CHECK-NEXT: declare float @"#cbrtf"(float)
+; CHECK-NEXT: declare x86_fp80 @"#cbrtl"(x86_fp80)
; CHECK-NEXT: declare double @"#ceil"(double)
; CHECK-NEXT: declare float @"#ceilf"(float)
+; CHECK-NEXT: declare x86_fp80 @"#ceill"(x86_fp80)
; CHECK-NEXT: declare double @"#copysign"(double, double)
; CHECK-NEXT: declare float @"#copysignf"(float, float)
+; CHECK-NEXT: declare x86_fp80 @"#copysignl"(x86_fp80, x86_fp80)
; CHECK-NEXT: declare double @"#cos"(double)
; CHECK-NEXT: declare float @"#cosf"(float)
; CHECK-NEXT: declare double @"#cosh"(double)
; CHECK-NEXT: declare float @"#coshf"(float)
+; CHECK-NEXT: declare x86_fp80 @"#coshl"(x86_fp80)
+; CHECK-NEXT: declare x86_fp80 @"#cosl"(x86_fp80)
; CHECK-NEXT: declare double @"#exp"(double)
; CHECK-NEXT: declare double @"#exp10"(double)
; CHECK-NEXT: declare float @"#exp10f"(float)
; CHECK-NEXT: declare double @"#exp2"(double)
; CHECK-NEXT: declare float @"#exp2f"(float)
+; CHECK-NEXT: declare x86_fp80 @"#exp2l"(x86_fp80)
; CHECK-NEXT: declare float @"#expf"(float)
+; CHECK-NEXT: declare x86_fp80 @"#expl"(x86_fp80)
; CHECK-NEXT: declare double @"#fdim"(double, double)
; CHECK-NEXT: declare float @"#fdimf"(float, float)
+; CHECK-NEXT: declare x86_fp80 @"#fdiml"(x86_fp80, x86_fp80)
; CHECK-NEXT: declare void @"#fegetenv"(...)
; CHECK-NEXT: declare void @"#fegetmode"(...)
; CHECK-NEXT: declare void @"#fesetenv"(...)
; CHECK-NEXT: declare void @"#fesetmode"(...)
; CHECK-NEXT: declare double @"#floor"(double)
; CHECK-NEXT: declare float @"#floorf"(float)
+; CHECK-NEXT: declare x86_fp80 @"#floorl"(x86_fp80)
; CHECK-NEXT: declare double @"#fma"(double, double, double)
; CHECK-NEXT: declare float @"#fmaf"(float, float, float)
; CHECK-NEXT: declare double @"#fmax"(double, double)
@@ -442,72 +498,105 @@
; CHECK-NEXT: declare double @"#fmaximum"(double, double)
; CHECK-NEXT: declare double @"#fmaximum_num"(double, double)
; CHECK-NEXT: declare float @"#fmaximum_numf"(float, float)
+; CHECK-NEXT: declare x86_fp80 @"#fmaximum_numl"(x86_fp80, x86_fp80)
; CHECK-NEXT: declare float @"#fmaximumf"(float, float)
+; CHECK-NEXT: declare x86_fp80 @"#fmaximuml"(x86_fp80, x86_fp80)
+; CHECK-NEXT: declare x86_fp80 @"#fmaxl"(x86_fp80, x86_fp80)
; CHECK-NEXT: declare double @"#fmin"(double, double)
; CHECK-NEXT: declare float @"#fminf"(float, float)
; CHECK-NEXT: declare double @"#fminimum"(double, double)
; CHECK-NEXT: declare double @"#fminimum_num"(double, double)
; CHECK-NEXT: declare float @"#fminimum_numf"(float, float)
+; CHECK-NEXT: declare x86_fp80 @"#fminimum_numl"(x86_fp80, x86_fp80)
; CHECK-NEXT: declare float @"#fminimumf"(float, float)
+; CHECK-NEXT: declare x86_fp80 @"#fminimuml"(x86_fp80, x86_fp80)
+; CHECK-NEXT: declare x86_fp80 @"#fminl"(x86_fp80, x86_fp80)
; CHECK-NEXT: declare double @"#fmod"(double, double)
; CHECK-NEXT: declare float @"#fmodf"(float, float)
+; CHECK-NEXT: declare x86_fp80 @"#fmodl"(x86_fp80, x86_fp80)
; CHECK-NEXT: declare void @"#free"(ptr)
; CHECK-NEXT: declare double @"#frexp"(double, ptr)
; CHECK-NEXT: declare double @"#ldexp"(double, i32)
; CHECK-NEXT: declare void @"#llrint"(...)
; CHECK-NEXT: declare void @"#llrintf"(...)
+; CHECK-NEXT: declare void @"#llrintl"(...)
; CHECK-NEXT: declare void @"#llround"(...)
; CHECK-NEXT: declare void @"#llroundf"(...)
+; CHECK-NEXT: declare void @"#llroundl"(...)
; CHECK-NEXT: declare double @"#log"(double)
; CHECK-NEXT: declare double @"#log10"(double)
; CHECK-NEXT: declare float @"#log10f"(float)
+; CHECK-NEXT: declare x86_fp80 @"#log10l"(x86_fp80)
; CHECK-NEXT: declare double @"#log2"(double)
; CHECK-NEXT: declare float @"#log2f"(float)
+; CHECK-NEXT: declare x86_fp80 @"#log2l"(x86_fp80)
; CHECK-NEXT: declare float @"#logf"(float)
+; CHECK-NEXT: declare x86_fp80 @"#logl"(x86_fp80)
; CHECK-NEXT: declare void @"#lrint"(...)
; CHECK-NEXT: declare void @"#lrintf"(...)
+; CHECK-NEXT: declare void @"#lrintl"(...)
; CHECK-NEXT: declare void @"#lround"(...)
; CHECK-NEXT: declare void @"#lroundf"(...)
+; CHECK-NEXT: declare void @"#lroundl"(...)
; CHECK-NEXT: declare ptr @"#malloc"(i64)
; CHECK-NEXT: declare ptr @"#memcpy"(ptr, ptr, i64)
; CHECK-NEXT: declare ptr @"#memmove"(ptr, ptr, i64)
; CHECK-NEXT: declare ptr @"#memset"(ptr, i32, i64)
; CHECK-NEXT: declare double @"#modf"(double, ptr)
; CHECK-NEXT: declare float @"#modff"(float, ptr)
+; CHECK-NEXT: declare x86_fp80 @"#modfl"(x86_fp80, ptr)
; CHECK-NEXT: declare double @"#nan"(ptr)
; CHECK-NEXT: declare float @"#nanf"(ptr)
+; CHECK-NEXT: declare x86_fp80 @"#nanl"(ptr)
; CHECK-NEXT: declare double @"#nearbyint"(double)
; CHECK-NEXT: declare float @"#nearbyintf"(float)
+; CHECK-NEXT: declare x86_fp80 @"#nearbyintl"(x86_fp80)
; CHECK-NEXT: declare double @"#nexttoward"(double, double)
; CHECK-NEXT: declare float @"#nexttowardf"(float, double)
+; CHECK-NEXT: declare x86_fp80 @"#nexttowardl"(x86_fp80, double)
; CHECK-NEXT: declare double @"#pow"(double, double)
; CHECK-NEXT: declare float @"#powf"(float, float)
+; CHECK-NEXT: declare x86_fp80 @"#powl"(x86_fp80, x86_fp80)
; CHECK-NEXT: declare double @"#remainder"(double, double)
; CHECK-NEXT: declare float @"#remainderf"(float, float)
+; CHECK-NEXT: declare x86_fp80 @"#remainderl"(x86_fp80, x86_fp80)
; CHECK-NEXT: declare double @"#remquo"(double, double, ptr)
; CHECK-NEXT: declare float @"#remquof"(float, float, ptr)
+; CHECK-NEXT: declare x86_fp80 @"#remquol"(x86_fp80, x86_fp80, ptr)
; CHECK-NEXT: declare double @"#rint"(double)
; CHECK-NEXT: declare float @"#rintf"(float)
+; CHECK-NEXT: declare x86_fp80 @"#rintl"(x86_fp80)
; CHECK-NEXT: declare double @"#round"(double)
; CHECK-NEXT: declare double @"#roundeven"(double)
; CHECK-NEXT: declare float @"#roundevenf"(float)
+; CHECK-NEXT: declare x86_fp80 @"#roundevenl"(x86_fp80)
; CHECK-NEXT: declare float @"#roundf"(float)
+; CHECK-NEXT: declare x86_fp80 @"#roundl"(x86_fp80)
; CHECK-NEXT: declare double @"#scalbln"(double, i32)
; CHECK-NEXT: declare float @"#scalblnf"(float, i32)
+; CHECK-NEXT: declare x86_fp80 @"#scalblnl"(x86_fp80, i32)
; CHECK-NEXT: declare double @"#scalbn"(double, i32)
; CHECK-NEXT: declare float @"#scalbnf"(float, i32)
+; CHECK-NEXT: declare x86_fp80 @"#scalbnl"(x86_fp80, i32)
; CHECK-NEXT: declare double @"#sin"(double)
; CHECK-NEXT: declare float @"#sinf"(float)
; CHECK-NEXT: declare double @"#sinh"(double)
; CHECK-NEXT: declare float @"#sinhf"(float)
+; CHECK-NEXT: declare x86_fp80 @"#sinhl"(x86_fp80)
+; CHECK-NEXT: declare x86_fp80 @"#sinl"(x86_fp80)
; CHECK-NEXT: declare double @"#sqrt"(double)
; CHECK-NEXT: declare float @"#sqrtf"(float)
+; CHECK-NEXT: declare x86_fp80 @"#sqrtl"(x86_fp80)
; CHECK-NEXT: declare double @"#tan"(double)
; CHECK-NEXT: declare float @"#tanf"(float)
; CHECK-NEXT: declare double @"#tanh"(double)
; CHECK-NEXT: declare float @"#tanhf"(float)
+; CHECK-NEXT: declare x86_fp80 @"#tanhl"(x86_fp80)
+; CHECK-NEXT: declare x86_fp80 @"#tanl"(x86_fp80)
; CHECK-NEXT: declare double @"#tgamma"(double)
; CHECK-NEXT: declare float @"#tgammaf"(float)
+; CHECK-NEXT: declare x86_fp80 @"#tgammal"(x86_fp80)
; CHECK-NEXT: declare double @"#trunc"(double)
; CHECK-NEXT: declare float @"#truncf"(float)
+; CHECK-NEXT: declare x86_fp80 @"#truncl"(x86_fp80)
; CHECK-NEXT: declare void @__security_cookie(...)
diff --git a/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/bsd.ll b/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/bsd.ll
index ce3e1ce67cf010..e583ebf05c3469 100644
--- a/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/bsd.ll
+++ b/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/bsd.ll
@@ -89,6 +89,7 @@
; LINUX-NEXT: declare void @__eqdf2(...)
; LINUX-NEXT: declare void @__eqsf2(...)
; LINUX-NEXT: declare void @__eqtf2(...)
+; LINUX-NEXT: declare void @__eqxf2(...)
; LINUX-NEXT: declare fp128 @__exp10f128_finite(fp128)
; LINUX-NEXT: declare double @__exp2_finite(double)
; LINUX-NEXT: declare fp128 @__exp2f128_finite(fp128)
@@ -100,12 +101,14 @@
; LINUX-NEXT: declare x86_fp80 @__expl_finite(x86_fp80)
; LINUX-NEXT: declare void @__extendbfsf2(...)
; LINUX-NEXT: declare fp128 @__extenddftf2(double)
+; LINUX-NEXT: declare void @__extenddfxf2(...)
; LINUX-NEXT: declare void @__extendhfdf2(...)
; LINUX-NEXT: declare void @__extendhfsf2(...)
; LINUX-NEXT: declare void @__extendhftf2(...)
; LINUX-NEXT: declare void @__extendhfxf2(...)
; LINUX-NEXT: declare double @__extendsfdf2(float)
; LINUX-NEXT: declare fp128 @__extendsftf2(float)
+; LINUX-NEXT: declare void @__extendsfxf2(...)
; LINUX-NEXT: declare fp128 @__extendxftf2(x86_fp80)
; LINUX-NEXT: declare i64 @__fixdfdi(double)
; LINUX-NEXT: declare i32 @__fixdfsi(double)
@@ -172,12 +175,15 @@
; LINUX-NEXT: declare void @__gedf2(...)
; LINUX-NEXT: declare void @__gesf2(...)
; LINUX-NEXT: declare void @__getf2(...)
+; LINUX-NEXT: declare void @__gexf2(...)
; LINUX-NEXT: declare void @__gtdf2(...)
; LINUX-NEXT: declare void @__gtsf2(...)
; LINUX-NEXT: declare void @__gttf2(...)
+; LINUX-NEXT: declare void @__gtxf2(...)
; LINUX-NEXT: declare void @__ledf2(...)
; LINUX-NEXT: declare void @__lesf2(...)
; LINUX-NEXT: declare void @__letf2(...)
+; LINUX-NEXT: declare void @__lexf2(...)
; LINUX-NEXT: declare void @__llvm_deoptimize(...)
; LINUX-NEXT: declare void @__llvm_memcpy_element_unordered_atomic_1(...)
; LINUX-NEXT: declare void @__llvm_memcpy_element_unordered_atomic_16(...)
@@ -213,6 +219,7 @@
; LINUX-NEXT: declare void @__ltdf2(...)
; LINUX-NEXT: declare void @__ltsf2(...)
; LINUX-NEXT: declare void @__lttf2(...)
+; LINUX-NEXT: declare void @__ltxf2(...)
; LINUX-NEXT: declare ptr @__memcpy_chk(ptr, ptr, i64, i64)
; LINUX-NEXT: declare ptr @__memmove_chk(ptr, ptr, i64, i64)
; LINUX-NEXT: declare ptr @__memset_chk(ptr, i32, i64, i64)
@@ -234,6 +241,7 @@
; LINUX-NEXT: declare void @__negsi2(...)
; LINUX-NEXT: declare void @__nesf2(...)
; LINUX-NEXT: declare void @__netf2(...)
+; LINUX-NEXT: declare void @__nexf2(...)
; LINUX-NEXT: declare void @__popcountdi2(...)
; LINUX-NEXT: declare void @__popcountsi2(...)
; LINUX-NEXT: declare void @__popcountti2(...)
@@ -337,6 +345,7 @@
; LINUX-NEXT: declare void @__unorddf2(...)
; LINUX-NEXT: declare void @__unordsf2(...)
; LINUX-NEXT: declare void @__unordtf2(...)
+; LINUX-NEXT: declare void @__unordxf2(...)
; LINUX-NEXT: declare double @acos(double)
; LINUX-NEXT: declare float @acosf(float)
; LINUX-NEXT: declare fp128 @acosf128(fp128)
@@ -634,6 +643,7 @@
; FREEBSD-NEXT: declare void @__eqdf2(...)
; FREEBSD-NEXT: declare void @__eqsf2(...)
; FREEBSD-NEXT: declare void @__eqtf2(...)
+; FREEBSD-NEXT: declare void @__eqxf2(...)
; FREEBSD-NEXT: declare double @__exp2_finite(double)
; FREEBSD-NEXT: declare float @__exp2f_finite(float)
; FREEBSD-NEXT: declare x86_fp80 @__exp2l_finite(x86_fp80)
@@ -642,12 +652,14 @@
; FREEBSD-NEXT: declare x86_fp80 @__expl_finite(x86_fp80)
; FREEBSD-NEXT: declare void @__extendbfsf2(...)
; FREEBSD-NEXT: declare fp128 @__extenddftf2(double)
+; FREEBSD-NEXT: declare void @__extenddfxf2(...)
; FREEBSD-NEXT: declare void @__extendhfdf2(...)
; FREEBSD-NEXT: declare void @__extendhfsf2(...)
; FREEBSD-NEXT: declare void @__extendhftf2(...)
; FREEBSD-NEXT: declare void @__extendhfxf2(...)
; FREEBSD-NEXT: declare double @__extendsfdf2(float)
; FREEBSD-NEXT: declare fp128 @__extendsftf2(float)
+; FREEBSD-NEXT: declare void @__extendsfxf2(...)
; FREEBSD-NEXT: declare fp128 @__extendxftf2(x86_fp80)
; FREEBSD-NEXT: declare i64 @__fixdfdi(double)
; FREEBSD-NEXT: declare i32 @__fixdfsi(double)
@@ -714,12 +726,15 @@
; FREEBSD-NEXT: declare void @__gedf2(...)
; FREEBSD-NEXT: declare void @__gesf2(...)
; FREEBSD-NEXT: declare void @__getf2(...)
+; FREEBSD-NEXT: declare void @__gexf2(...)
; FREEBSD-NEXT: declare void @__gtdf2(...)
; FREEBSD-NEXT: declare void @__gtsf2(...)
; FREEBSD-NEXT: declare void @__gttf2(...)
+; FREEBSD-NEXT: declare void @__gtxf2(...)
; FREEBSD-NEXT: declare void @__ledf2(...)
; FREEBSD-NEXT: declare void @__lesf2(...)
; FREEBSD-NEXT: declare void @__letf2(...)
+; FREEBSD-NEXT: declare void @__lexf2(...)
; FREEBSD-NEXT: declare void @__llvm_deoptimize(...)
; FREEBSD-NEXT: declare void @__llvm_memcpy_element_unordered_atomic_1(...)
; FREEBSD-NEXT: declare void @__llvm_memcpy_element_unordered_atomic_16(...)
@@ -752,6 +767,7 @@
; FREEBSD-NEXT: declare void @__ltdf2(...)
; FREEBSD-NEXT: declare void @__ltsf2(...)
; FREEBSD-NEXT: declare void @__lttf2(...)
+; FREEBSD-NEXT: declare void @__ltxf2(...)
; FREEBSD-NEXT: declare ptr @__memcpy_chk(ptr, ptr, i64, i64)
; FREEBSD-NEXT: declare ptr @__memmove_chk(ptr, ptr, i64, i64)
; FREEBSD-NEXT: declare ptr @__memset_chk(ptr, i32, i64, i64)
@@ -773,6 +789,7 @@
; FREEBSD-NEXT: declare void @__negsi2(...)
; FREEBSD-NEXT: declare void @__nesf2(...)
; FREEBSD-NEXT: declare void @__netf2(...)
+; FREEBSD-NEXT: declare void @__nexf2(...)
; FREEBSD-NEXT: declare void @__popcountdi2(...)
; FREEBSD-NEXT: declare void @__popcountsi2(...)
; FREEBSD-NEXT: declare void @__popcountti2(...)
@@ -875,6 +892,7 @@
; FREEBSD-NEXT: declare void @__unorddf2(...)
; FREEBSD-NEXT: declare void @__unordsf2(...)
; FREEBSD-NEXT: declare void @__unordtf2(...)
+; FREEBSD-NEXT: declare void @__unordxf2(...)
; FREEBSD-NEXT: declare double @acos(double)
; FREEBSD-NEXT: declare float @acosf(float)
; FREEBSD-NEXT: declare x86_fp80 @acosl(x86_fp80)
@@ -1126,6 +1144,7 @@
; OPENBSD-NEXT: declare void @__eqdf2(...)
; OPENBSD-NEXT: declare void @__eqsf2(...)
; OPENBSD-NEXT: declare void @__eqtf2(...)
+; OPENBSD-NEXT: declare void @__eqxf2(...)
; OPENBSD-NEXT: declare double @__exp2_finite(double)
; OPENBSD-NEXT: declare float @__exp2f_finite(float)
; OPENBSD-NEXT: declare x86_fp80 @__exp2l_finite(x86_fp80)
@@ -1134,12 +1153,14 @@
; OPENBSD-NEXT: declare x86_fp80 @__expl_finite(x86_fp80)
; OPENBSD-NEXT: declare void @__extendbfsf2(...)
; OPENBSD-NEXT: declare fp128 @__extenddftf2(double)
+; OPENBSD-NEXT: declare void @__extenddfxf2(...)
; OPENBSD-NEXT: declare void @__extendhfdf2(...)
; OPENBSD-NEXT: declare void @__extendhfsf2(...)
; OPENBSD-NEXT: declare void @__extendhftf2(...)
; OPENBSD-NEXT: declare void @__extendhfxf2(...)
; OPENBSD-NEXT: declare double @__extendsfdf2(float)
; OPENBSD-NEXT: declare fp128 @__extendsftf2(float)
+; OPENBSD-NEXT: declare void @__extendsfxf2(...)
; OPENBSD-NEXT: declare fp128 @__extendxftf2(x86_fp80)
; OPENBSD-NEXT: declare i64 @__fixdfdi(double)
; OPENBSD-NEXT: declare i32 @__fixdfsi(double)
@@ -1206,13 +1227,16 @@
; OPENBSD-NEXT: declare void @__gedf2(...)
; OPENBSD-NEXT: declare void @__gesf2(...)
; OPENBSD-NEXT: declare void @__getf2(...)
+; OPENBSD-NEXT: declare void @__gexf2(...)
; OPENBSD-NEXT: declare void @__gtdf2(...)
; OPENBSD-NEXT: declare void @__gtsf2(...)
; OPENBSD-NEXT: declare void @__gttf2(...)
+; OPENBSD-NEXT: declare void @__gtxf2(...)
; OPENBSD-NEXT: declare void @__guard_local(...)
; OPENBSD-NEXT: declare void @__ledf2(...)
; OPENBSD-NEXT: declare void @__lesf2(...)
; OPENBSD-NEXT: declare void @__letf2(...)
+; OPENBSD-NEXT: declare void @__lexf2(...)
; OPENBSD-NEXT: declare void @__llvm_deoptimize(...)
; OPENBSD-NEXT: declare void @__llvm_memcpy_element_unordered_atomic_1(...)
; OPENBSD-NEXT: declare void @__llvm_memcpy_element_unordered_atomic_16(...)
@@ -1245,6 +1269,7 @@
; OPENBSD-NEXT: declare void @__ltdf2(...)
; OPENBSD-NEXT: declare void @__ltsf2(...)
; OPENBSD-NEXT: declare void @__lttf2(...)
+; OPENBSD-NEXT: declare void @__ltxf2(...)
; OPENBSD-NEXT: declare ptr @__memcpy_chk(ptr, ptr, i64, i64)
; OPENBSD-NEXT: declare ptr @__memmove_chk(ptr, ptr, i64, i64)
; OPENBSD-NEXT: declare ptr @__memset_chk(ptr, i32, i64, i64)
@@ -1266,6 +1291,7 @@
; OPENBSD-NEXT: declare void @__negsi2(...)
; OPENBSD-NEXT: declare void @__nesf2(...)
; OPENBSD-NEXT: declare void @__netf2(...)
+; OPENBSD-NEXT: declare void @__nexf2(...)
; OPENBSD-NEXT: declare void @__popcountdi2(...)
; OPENBSD-NEXT: declare void @__popcountsi2(...)
; OPENBSD-NEXT: declare void @__popcountti2(...)
@@ -1367,6 +1393,7 @@
; OPENBSD-NEXT: declare void @__unorddf2(...)
; OPENBSD-NEXT: declare void @__unordsf2(...)
; OPENBSD-NEXT: declare void @__unordtf2(...)
+; OPENBSD-NEXT: declare void @__unordxf2(...)
; OPENBSD-NEXT: declare double @acos(double)
; OPENBSD-NEXT: declare float @acosf(float)
; OPENBSD-NEXT: declare x86_fp80 @acosl(x86_fp80)
diff --git a/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/windows.ll b/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/windows.ll
index 8ce84ccb7a6b3e..b8cbac5875e09f 100644
--- a/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/windows.ll
+++ b/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/windows.ll
@@ -90,18 +90,21 @@
; MSVC-NEXT: declare void @__eqdf2(...)
; MSVC-NEXT: declare void @__eqsf2(...)
; MSVC-NEXT: declare void @__eqtf2(...)
+; MSVC-NEXT: declare void @__eqxf2(...)
; MSVC-NEXT: declare double @__exp2_finite(double)
; MSVC-NEXT: declare float @__exp2f_finite(float)
; MSVC-NEXT: declare double @__exp_finite(double)
; MSVC-NEXT: declare float @__expf_finite(float)
; MSVC-NEXT: declare void @__extendbfsf2(...)
; MSVC-NEXT: declare fp128 @__extenddftf2(double)
+; MSVC-NEXT: declare void @__extenddfxf2(...)
; MSVC-NEXT: declare void @__extendhfdf2(...)
; MSVC-NEXT: declare void @__extendhfsf2(...)
; MSVC-NEXT: declare void @__extendhftf2(...)
; MSVC-NEXT: declare void @__extendhfxf2(...)
; MSVC-NEXT: declare double @__extendsfdf2(float)
; MSVC-NEXT: declare fp128 @__extendsftf2(float)
+; MSVC-NEXT: declare void @__extendsfxf2(...)
; MSVC-NEXT: declare fp128 @__extendxftf2(x86_fp80)
; MSVC-NEXT: declare i64 @__fixdfdi(double)
; MSVC-NEXT: declare i32 @__fixdfsi(double)
@@ -168,12 +171,15 @@
; MSVC-NEXT: declare void @__gedf2(...)
; MSVC-NEXT: declare void @__gesf2(...)
; MSVC-NEXT: declare void @__getf2(...)
+; MSVC-NEXT: declare void @__gexf2(...)
; MSVC-NEXT: declare void @__gtdf2(...)
; MSVC-NEXT: declare void @__gtsf2(...)
; MSVC-NEXT: declare void @__gttf2(...)
+; MSVC-NEXT: declare void @__gtxf2(...)
; MSVC-NEXT: declare void @__ledf2(...)
; MSVC-NEXT: declare void @__lesf2(...)
; MSVC-NEXT: declare void @__letf2(...)
+; MSVC-NEXT: declare void @__lexf2(...)
; MSVC-NEXT: declare void @__llvm_deoptimize(...)
; MSVC-NEXT: declare void @__llvm_memcpy_element_unordered_atomic_1(...)
; MSVC-NEXT: declare void @__llvm_memcpy_element_unordered_atomic_16(...)
@@ -203,6 +209,7 @@
; MSVC-NEXT: declare void @__ltdf2(...)
; MSVC-NEXT: declare void @__ltsf2(...)
; MSVC-NEXT: declare void @__lttf2(...)
+; MSVC-NEXT: declare void @__ltxf2(...)
; MSVC-NEXT: declare ptr @__memcpy_chk(ptr, ptr, i64, i64)
; MSVC-NEXT: declare ptr @__memmove_chk(ptr, ptr, i64, i64)
; MSVC-NEXT: declare ptr @__memset_chk(ptr, i32, i64, i64)
@@ -224,6 +231,7 @@
; MSVC-NEXT: declare void @__negsi2(...)
; MSVC-NEXT: declare void @__nesf2(...)
; MSVC-NEXT: declare void @__netf2(...)
+; MSVC-NEXT: declare void @__nexf2(...)
; MSVC-NEXT: declare void @__popcountdi2(...)
; MSVC-NEXT: declare void @__popcountsi2(...)
; MSVC-NEXT: declare void @__popcountti2(...)
@@ -322,6 +330,7 @@
; MSVC-NEXT: declare void @__unorddf2(...)
; MSVC-NEXT: declare void @__unordsf2(...)
; MSVC-NEXT: declare void @__unordtf2(...)
+; MSVC-NEXT: declare void @__unordxf2(...)
; MSVC-NEXT: declare double @acos(double)
; MSVC-NEXT: declare float @acosf(float)
; MSVC-NEXT: declare double @asin(double)
@@ -521,6 +530,7 @@
; MINGW-NEXT: declare void @__eqdf2(...)
; MINGW-NEXT: declare void @__eqsf2(...)
; MINGW-NEXT: declare void @__eqtf2(...)
+; MINGW-NEXT: declare void @__eqxf2(...)
; MINGW-NEXT: declare fp128 @__exp10f128_finite(fp128)
; MINGW-NEXT: declare double @__exp2_finite(double)
; MINGW-NEXT: declare fp128 @__exp2f128_finite(fp128)
@@ -532,12 +542,14 @@
; MINGW-NEXT: declare x86_fp80 @__expl_finite(x86_fp80)
; MINGW-NEXT: declare void @__extendbfsf2(...)
; MINGW-NEXT: declare fp128 @__extenddftf2(double)
+; MINGW-NEXT: declare void @__extenddfxf2(...)
; MINGW-NEXT: declare void @__extendhfdf2(...)
; MINGW-NEXT: declare void @__extendhfsf2(...)
; MINGW-NEXT: declare void @__extendhftf2(...)
; MINGW-NEXT: declare void @__extendhfxf2(...)
; MINGW-NEXT: declare double @__extendsfdf2(float)
; MINGW-NEXT: declare fp128 @__extendsftf2(float)
+; MINGW-NEXT: declare void @__extendsfxf2(...)
; MINGW-NEXT: declare fp128 @__extendxftf2(x86_fp80)
; MINGW-NEXT: declare i64 @__fixdfdi(double)
; MINGW-NEXT: declare i32 @__fixdfsi(double)
@@ -604,12 +616,15 @@
; MINGW-NEXT: declare void @__gedf2(...)
; MINGW-NEXT: declare void @__gesf2(...)
; MINGW-NEXT: declare void @__getf2(...)
+; MINGW-NEXT: declare void @__gexf2(...)
; MINGW-NEXT: declare void @__gtdf2(...)
; MINGW-NEXT: declare void @__gtsf2(...)
; MINGW-NEXT: declare void @__gttf2(...)
+; MINGW-NEXT: declare void @__gtxf2(...)
; MINGW-NEXT: declare void @__ledf2(...)
; MINGW-NEXT: declare void @__lesf2(...)
; MINGW-NEXT: declare void @__letf2(...)
+; MINGW-NEXT: declare void @__lexf2(...)
; MINGW-NEXT: declare void @__llvm_deoptimize(...)
; MINGW-NEXT: declare void @__llvm_memcpy_element_unordered_atomic_1(...)
; MINGW-NEXT: declare void @__llvm_memcpy_element_unordered_atomic_16(...)
@@ -645,6 +660,7 @@
; MINGW-NEXT: declare void @__ltdf2(...)
; MINGW-NEXT: declare void @__ltsf2(...)
; MINGW-NEXT: declare void @__lttf2(...)
+; MINGW-NEXT: declare void @__ltxf2(...)
; MINGW-NEXT: declare ptr @__memcpy_chk(ptr, ptr, i64, i64)
; MINGW-NEXT: declare ptr @__memmove_chk(ptr, ptr, i64, i64)
; MINGW-NEXT: declare ptr @__memset_chk(ptr, i32, i64, i64)
@@ -666,6 +682,7 @@
; MINGW-NEXT: declare void @__negsi2(...)
; MINGW-NEXT: declare void @__nesf2(...)
; MINGW-NEXT: declare void @__netf2(...)
+; MINGW-NEXT: declare void @__nexf2(...)
; MINGW-NEXT: declare void @__popcountdi2(...)
; MINGW-NEXT: declare void @__popcountsi2(...)
; MINGW-NEXT: declare void @__popcountti2(...)
@@ -766,6 +783,7 @@
; MINGW-NEXT: declare void @__unorddf2(...)
; MINGW-NEXT: declare void @__unordsf2(...)
; MINGW-NEXT: declare void @__unordtf2(...)
+; MINGW-NEXT: declare void @__unordxf2(...)
; MINGW-NEXT: declare double @acos(double)
; MINGW-NEXT: declare float @acosf(float)
; MINGW-NEXT: declare fp128 @acosf128(fp128)
@@ -1064,6 +1082,7 @@
; CYGWIN-NEXT: declare void @__eqdf2(...)
; CYGWIN-NEXT: declare void @__eqsf2(...)
; CYGWIN-NEXT: declare void @__eqtf2(...)
+; CYGWIN-NEXT: declare void @__eqxf2(...)
; CYGWIN-NEXT: declare double @__exp2_finite(double)
; CYGWIN-NEXT: declare float @__exp2f_finite(float)
; CYGWIN-NEXT: declare x86_fp80 @__exp2l_finite(x86_fp80)
@@ -1072,12 +1091,14 @@
; CYGWIN-NEXT: declare x86_fp80 @__expl_finite(x86_fp80)
; CYGWIN-NEXT: declare void @__extendbfsf2(...)
; CYGWIN-NEXT: declare fp128 @__extenddftf2(double)
+; CYGWIN-NEXT: declare void @__extenddfxf2(...)
; CYGWIN-NEXT: declare void @__extendhfdf2(...)
; CYGWIN-NEXT: declare void @__extendhfsf2(...)
; CYGWIN-NEXT: declare void @__extendhftf2(...)
; CYGWIN-NEXT: declare void @__extendhfxf2(...)
; CYGWIN-NEXT: declare double @__extendsfdf2(float)
; CYGWIN-NEXT: declare fp128 @__extendsftf2(float)
+; CYGWIN-NEXT: declare void @__extendsfxf2(...)
; CYGWIN-NEXT: declare fp128 @__extendxftf2(x86_fp80)
; CYGWIN-NEXT: declare i64 @__fixdfdi(double)
; CYGWIN-NEXT: declare i32 @__fixdfsi(double)
@@ -1144,12 +1165,15 @@
; CYGWIN-NEXT: declare void @__gedf2(...)
; CYGWIN-NEXT: declare void @__gesf2(...)
; CYGWIN-NEXT: declare void @__getf2(...)
+; CYGWIN-NEXT: declare void @__gexf2(...)
; CYGWIN-NEXT: declare void @__gtdf2(...)
; CYGWIN-NEXT: declare void @__gtsf2(...)
; CYGWIN-NEXT: declare void @__gttf2(...)
+; CYGWIN-NEXT: declare void @__gtxf2(...)
; CYGWIN-NEXT: declare void @__ledf2(...)
; CYGWIN-NEXT: declare void @__lesf2(...)
; CYGWIN-NEXT: declare void @__letf2(...)
+; CYGWIN-NEXT: declare void @__lexf2(...)
; CYGWIN-NEXT: declare void @__llvm_deoptimize(...)
; CYGWIN-NEXT: declare void @__llvm_memcpy_element_unordered_atomic_1(...)
; CYGWIN-NEXT: declare void @__llvm_memcpy_element_unordered_atomic_16(...)
@@ -1182,6 +1206,7 @@
; CYGWIN-NEXT: declare void @__ltdf2(...)
; CYGWIN-NEXT: declare void @__ltsf2(...)
; CYGWIN-NEXT: declare void @__lttf2(...)
+; CYGWIN-NEXT: declare void @__ltxf2(...)
; CYGWIN-NEXT: declare ptr @__memcpy_chk(ptr, ptr, i64, i64)
; CYGWIN-NEXT: declare ptr @__memmove_chk(ptr, ptr, i64, i64)
; CYGWIN-NEXT: declare ptr @__memset_chk(ptr, i32, i64, i64)
@@ -1203,6 +1228,7 @@
; CYGWIN-NEXT: declare void @__negsi2(...)
; CYGWIN-NEXT: declare void @__nesf2(...)
; CYGWIN-NEXT: declare void @__netf2(...)
+; CYGWIN-NEXT: declare void @__nexf2(...)
; CYGWIN-NEXT: declare void @__popcountdi2(...)
; CYGWIN-NEXT: declare void @__popcountsi2(...)
; CYGWIN-NEXT: declare void @__popcountti2(...)
@@ -1305,6 +1331,7 @@
; CYGWIN-NEXT: declare void @__unorddf2(...)
; CYGWIN-NEXT: declare void @__unordsf2(...)
; CYGWIN-NEXT: declare void @__unordtf2(...)
+; CYGWIN-NEXT: declare void @__unordxf2(...)
; CYGWIN-NEXT: declare double @acos(double)
; CYGWIN-NEXT: declare float @acosf(float)
; CYGWIN-NEXT: declare x86_fp80 @acosl(x86_fp80)
diff --git a/llvm/unittests/IR/RuntimeLibcallsTest.cpp b/llvm/unittests/IR/RuntimeLibcallsTest.cpp
index 50ace4277127fc..027fe6c1d96afe 100644
--- a/llvm/unittests/IR/RuntimeLibcallsTest.cpp
+++ b/llvm/unittests/IR/RuntimeLibcallsTest.cpp
@@ -46,15 +46,19 @@ TEST(RuntimeLibcallsTest, LibcallImplByName) {
{
auto SquirtleSquad =
RTLIB::RuntimeLibcallsInfo::lookupLibcallImplName("sqrtl");
- ASSERT_EQ(size(SquirtleSquad), 1);
- EXPECT_EQ(*SquirtleSquad.begin(), RTLIB::impl_sqrtl);
+ // ARM64EC spells out the x87 flavour of each `long double` libm function
+ // under the same name, so that the module-wide duplication can give it the
+ // `#` prefix; that record itself is not part of any library.
+ ASSERT_EQ(size(SquirtleSquad), 2);
+ EXPECT_TRUE(is_contained(SquirtleSquad, RTLIB::impl_sqrtl));
+ EXPECT_TRUE(is_contained(SquirtleSquad, RTLIB::impl_arm64ec_ldbl_sqrtl));
}
// Last libcall
{
auto Truncs = RTLIB::RuntimeLibcallsInfo::lookupLibcallImplName("truncl");
- ASSERT_EQ(size(Truncs), 1);
- EXPECT_EQ(*Truncs.begin(), RTLIB::impl_truncl);
+ ASSERT_EQ(size(Truncs), 2);
+ EXPECT_TRUE(is_contained(Truncs, RTLIB::impl_truncl));
}
}
>From c5aaaadf5075da223c4c6679a60f1ef38fc5c42a Mon Sep 17 00:00:00 2001
From: LIU Hao <lh_mouse at 126.com>
Date: Mon, 2 Nov 2026 03:23:48 +0800
Subject: [PATCH 04/10] revise Clang test for soft x87
Assisted-by: DeepSeek V4.1 Flash
---
llvm/test/CodeGen/X86/no-ret-in-x87-reg.ll | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/llvm/test/CodeGen/X86/no-ret-in-x87-reg.ll b/llvm/test/CodeGen/X86/no-ret-in-x87-reg.ll
index 19554e652e4ccc..2efae21a3e56e8 100644
--- a/llvm/test/CodeGen/X86/no-ret-in-x87-reg.ll
+++ b/llvm/test/CodeGen/X86/no-ret-in-x87-reg.ll
@@ -127,14 +127,12 @@ define x86_fp80 @f6(x86_fp80 %a, x86_fp80 %b) nounwind {
;
; NOX87-LABEL: f6:
; NOX87: # %bb.0: # %entry
-; NOX87-NEXT: movzwl {{[0-9]+}}(%esp), %eax
-; NOX87-NEXT: movzwl {{[0-9]+}}(%esp), %ecx
-; NOX87-NEXT: pushl %ecx
-; NOX87-NEXT: pushl {{[0-9]+}}(%esp)
-; NOX87-NEXT: pushl {{[0-9]+}}(%esp)
-; NOX87-NEXT: pushl %eax
-; NOX87-NEXT: pushl {{[0-9]+}}(%esp)
-; NOX87-NEXT: pushl {{[0-9]+}}(%esp)
+; NOX87-NEXT: pushl 24(%esp)
+; NOX87-NEXT: pushl 24(%esp)
+; NOX87-NEXT: pushl 24(%esp)
+; NOX87-NEXT: pushl 24(%esp)
+; NOX87-NEXT: pushl 24(%esp)
+; NOX87-NEXT: pushl 24(%esp)
; NOX87-NEXT: calll __addxf3
; NOX87-NEXT: addl $24, %esp
; NOX87-NEXT: movzwl %cx, %ecx
@@ -214,10 +212,9 @@ define i32 @f9(x86_fp80 %a) nounwind {
;
; NOX87-LABEL: f9:
; NOX87: # %bb.0: # %entry
-; NOX87-NEXT: movzwl {{[0-9]+}}(%esp), %eax
-; NOX87-NEXT: pushl %eax
-; NOX87-NEXT: pushl {{[0-9]+}}(%esp)
-; NOX87-NEXT: pushl {{[0-9]+}}(%esp)
+; NOX87-NEXT: pushl 12(%esp)
+; NOX87-NEXT: pushl 12(%esp)
+; NOX87-NEXT: pushl 12(%esp)
; NOX87-NEXT: calll __fixxfsi
; NOX87-NEXT: addl $12, %esp
; NOX87-NEXT: retl
>From 769eb3bf7014758c3af9d7a987a8281a55a3206b Mon Sep 17 00:00:00 2001
From: LIU Hao <lh_mouse at 126.com>
Date: Mon, 2 Nov 2026 04:08:25 +0800
Subject: [PATCH 05/10] drop `__FLOAT128__` and `__SIZEOF_FLOAT128__` target
macros
Neither is defined for x86_64-w64-mingw32, which `arm64ec-w64-mingw32` aims to stay compatible with. The `__float128` type itself remains available through `HasFloat128`.
Assisted-by: DeepSeek V4.1 Flash
---
clang/lib/Basic/Targets/AArch64.cpp | 5 -----
1 file changed, 5 deletions(-)
diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp
index 01da8b879df053..44feef75ee0376 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -454,11 +454,6 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts,
if (T.isLFI())
Builder.defineMacro("__LFI__");
- if (HasFloat128) {
- Builder.defineMacro("__FLOAT128__");
- Builder.defineMacro("__SIZEOF_FLOAT128__", "16");
- }
-
// Inline assembly supports AArch64 flag outputs.
Builder.defineMacro("__GCC_ASM_FLAG_OUTPUTS__");
>From 814814ff6dc112db3ad7b2a0b08c4b7fbe456e9c Mon Sep 17 00:00:00 2001
From: LIU Hao <lh_mouse at 126.com>
Date: Mon, 2 Nov 2026 04:19:55 +0800
Subject: [PATCH 06/10] no! restore `__SIZEOF_FLOAT128__` which is indeed a
target macro
---
clang/lib/Basic/Targets/AArch64.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp
index 44feef75ee0376..f5006a23935f94 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -454,6 +454,9 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts,
if (T.isLFI())
Builder.defineMacro("__LFI__");
+ if (HasFloat128)
+ Builder.defineMacro("__SIZEOF_FLOAT128__", "16");
+
// Inline assembly supports AArch64 flag outputs.
Builder.defineMacro("__GCC_ASM_FLAG_OUTPUTS__");
>From 7a2808d9ac8b8c8eccc8469a41f2dc8f091e24c0 Mon Sep 17 00:00:00 2001
From: LIU Hao <lh_mouse at 126.com>
Date: Tue, 3 Nov 2026 11:41:30 +0800
Subject: [PATCH 07/10] make all `__arm64ec_*` routines ARM64EC-only; not
callable from x86-64
---
llvm/include/llvm/IR/RuntimeLibcalls.td | 101 +++++++++---------
.../CodeGen/AArch64/arm64ec-fp80-libcalls.ll | 10 +-
.../Util/DeclareRuntimeLibcalls/arm64ec.ll | 7 +-
3 files changed, 57 insertions(+), 61 deletions(-)
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.td b/llvm/include/llvm/IR/RuntimeLibcalls.td
index 41de157ac144d1..5a22282af15a27 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.td
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.td
@@ -2398,98 +2398,92 @@ def AArch64SystemLibrary : SystemRuntimeLibrary<isAArch64_ExceptArm64EC,
// These are not the exact x87 soft-float helpers of libgcc: The value stays
// an 80-bit x87 image in a 16-byte slot, but every operation on it is carried
-// out in `double`. These are named with an `__arm64ec_` prefix so they will
-// not be confused with, or silently bound to, an exact implementation of the
-// same format.
+// out in `double`. These are ARM64EC-only, so they already carry the `#`
+// decoration. An additional `__arm64ec_` keeps them from being confused with,
+// or silently bound to, an exact implementation of the same format.
defset list<RuntimeLibcallImpl> Arm64ECF80Impls = {
- def arm64ec___addxf3 : RuntimeLibcallImpl<ADD_F80, "__arm64ec_addxf3">;
- def arm64ec___subxf3 : RuntimeLibcallImpl<SUB_F80, "__arm64ec_subxf3">;
- def arm64ec___mulxf3 : RuntimeLibcallImpl<MUL_F80, "__arm64ec_mulxf3">;
- def arm64ec___divxf3 : RuntimeLibcallImpl<DIV_F80, "__arm64ec_divxf3">;
- def arm64ec___fmaxf3 : RuntimeLibcallImpl<FMA_F80, "__arm64ec_fmaxf3">;
- def arm64ec___fmaxxf3 : RuntimeLibcallImpl<FMAX_F80, "__arm64ec_fmaxxf3">;
- def arm64ec___fminxf3 : RuntimeLibcallImpl<FMIN_F80, "__arm64ec_fminxf3">;
- def arm64ec___powixf2 : RuntimeLibcallImpl<POWI_F80, "__arm64ec_powixf2">;
+ def arm64ec___addxf3 : RuntimeLibcallImpl<ADD_F80, "#__arm64ec_addxf3">;
+ def arm64ec___subxf3 : RuntimeLibcallImpl<SUB_F80, "#__arm64ec_subxf3">;
+ def arm64ec___mulxf3 : RuntimeLibcallImpl<MUL_F80, "#__arm64ec_mulxf3">;
+ def arm64ec___divxf3 : RuntimeLibcallImpl<DIV_F80, "#__arm64ec_divxf3">;
+ def arm64ec___powixf2 : RuntimeLibcallImpl<POWI_F80, "#__arm64ec_powixf2">;
def arm64ec___eqxf2
- : RuntimeLibcallImpl<FCMP3_PRED_OEQ_F80, "__arm64ec_eqxf2">;
+ : RuntimeLibcallImpl<FCMP3_PRED_OEQ_F80, "#__arm64ec_eqxf2">;
def arm64ec___nexf2
- : RuntimeLibcallImpl<FCMP3_PRED_UNE_F80, "__arm64ec_nexf2">;
+ : RuntimeLibcallImpl<FCMP3_PRED_UNE_F80, "#__arm64ec_nexf2">;
def arm64ec___gexf2
- : RuntimeLibcallImpl<FCMP3_PRED_OGE_F80, "__arm64ec_gexf2">;
+ : RuntimeLibcallImpl<FCMP3_PRED_OGE_F80, "#__arm64ec_gexf2">;
def arm64ec___ltxf2
- : RuntimeLibcallImpl<FCMP3_PRED_OLT_F80, "__arm64ec_ltxf2">;
+ : RuntimeLibcallImpl<FCMP3_PRED_OLT_F80, "#__arm64ec_ltxf2">;
def arm64ec___lexf2
- : RuntimeLibcallImpl<FCMP3_PRED_OLE_F80, "__arm64ec_lexf2">;
+ : RuntimeLibcallImpl<FCMP3_PRED_OLE_F80, "#__arm64ec_lexf2">;
def arm64ec___gtxf2
- : RuntimeLibcallImpl<FCMP3_PRED_OGT_F80, "__arm64ec_gtxf2">;
- def arm64ec___unordxf2 : RuntimeLibcallImpl<UO_F80, "__arm64ec_unordxf2">;
+ : RuntimeLibcallImpl<FCMP3_PRED_OGT_F80, "#__arm64ec_gtxf2">;
+ def arm64ec___unordxf2
+ : RuntimeLibcallImpl<UO_F80, "#__arm64ec_unordxf2">;
def arm64ec___extendhfxf2
- : RuntimeLibcallImpl<FPEXT_F16_F80, "__arm64ec_extendhfxf2">;
+ : RuntimeLibcallImpl<FPEXT_F16_F80, "#__arm64ec_extendhfxf2">;
def arm64ec___extendsfxf2
- : RuntimeLibcallImpl<FPEXT_F32_F80, "__arm64ec_extendsfxf2">;
+ : RuntimeLibcallImpl<FPEXT_F32_F80, "#__arm64ec_extendsfxf2">;
def arm64ec___extenddfxf2
- : RuntimeLibcallImpl<FPEXT_F64_F80, "__arm64ec_extenddfxf2">;
+ : RuntimeLibcallImpl<FPEXT_F64_F80, "#__arm64ec_extenddfxf2">;
def arm64ec___extendxftf2
- : RuntimeLibcallImpl<FPEXT_F80_F128, "__arm64ec_extendxftf2">;
+ : RuntimeLibcallImpl<FPEXT_F80_F128, "#__arm64ec_extendxftf2">;
def arm64ec___truncxfhf2
- : RuntimeLibcallImpl<FPROUND_F80_F16, "__arm64ec_truncxfhf2">;
+ : RuntimeLibcallImpl<FPROUND_F80_F16, "#__arm64ec_truncxfhf2">;
def arm64ec___truncxfbf2
- : RuntimeLibcallImpl<FPROUND_F80_BF16, "__arm64ec_truncxfbf2">;
+ : RuntimeLibcallImpl<FPROUND_F80_BF16, "#__arm64ec_truncxfbf2">;
def arm64ec___truncxfsf2
- : RuntimeLibcallImpl<FPROUND_F80_F32, "__arm64ec_truncxfsf2">;
+ : RuntimeLibcallImpl<FPROUND_F80_F32, "#__arm64ec_truncxfsf2">;
def arm64ec___truncxfdf2
- : RuntimeLibcallImpl<FPROUND_F80_F64, "__arm64ec_truncxfdf2">;
+ : RuntimeLibcallImpl<FPROUND_F80_F64, "#__arm64ec_truncxfdf2">;
def arm64ec___trunctfxf2
- : RuntimeLibcallImpl<FPROUND_F128_F80, "__arm64ec_trunctfxf2">;
+ : RuntimeLibcallImpl<FPROUND_F128_F80, "#__arm64ec_trunctfxf2">;
def arm64ec___fixxfsi
- : RuntimeLibcallImpl<FPTOSINT_F80_I32, "__arm64ec_fixxfsi">;
+ : RuntimeLibcallImpl<FPTOSINT_F80_I32, "#__arm64ec_fixxfsi">;
def arm64ec___fixxfdi
- : RuntimeLibcallImpl<FPTOSINT_F80_I64, "__arm64ec_fixxfdi">;
+ : RuntimeLibcallImpl<FPTOSINT_F80_I64, "#__arm64ec_fixxfdi">;
def arm64ec___fixxfti
- : RuntimeLibcallImpl<FPTOSINT_F80_I128, "__arm64ec_fixxfti">;
+ : RuntimeLibcallImpl<FPTOSINT_F80_I128, "#__arm64ec_fixxfti">;
def arm64ec___fixunsxfsi
- : RuntimeLibcallImpl<FPTOUINT_F80_I32, "__arm64ec_fixunsxfsi">;
+ : RuntimeLibcallImpl<FPTOUINT_F80_I32, "#__arm64ec_fixunsxfsi">;
def arm64ec___fixunsxfdi
- : RuntimeLibcallImpl<FPTOUINT_F80_I64, "__arm64ec_fixunsxfdi">;
+ : RuntimeLibcallImpl<FPTOUINT_F80_I64, "#__arm64ec_fixunsxfdi">;
def arm64ec___fixunsxfti
- : RuntimeLibcallImpl<FPTOUINT_F80_I128, "__arm64ec_fixunsxfti">;
+ : RuntimeLibcallImpl<FPTOUINT_F80_I128, "#__arm64ec_fixunsxfti">;
def arm64ec___floatsixf
- : RuntimeLibcallImpl<SINTTOFP_I32_F80, "__arm64ec_floatsixf">;
+ : RuntimeLibcallImpl<SINTTOFP_I32_F80, "#__arm64ec_floatsixf">;
def arm64ec___floatdixf
- : RuntimeLibcallImpl<SINTTOFP_I64_F80, "__arm64ec_floatdixf">;
+ : RuntimeLibcallImpl<SINTTOFP_I64_F80, "#__arm64ec_floatdixf">;
def arm64ec___floattixf
- : RuntimeLibcallImpl<SINTTOFP_I128_F80, "__arm64ec_floattixf">;
+ : RuntimeLibcallImpl<SINTTOFP_I128_F80, "#__arm64ec_floattixf">;
def arm64ec___floatunsixf
- : RuntimeLibcallImpl<UINTTOFP_I32_F80, "__arm64ec_floatunsixf">;
+ : RuntimeLibcallImpl<UINTTOFP_I32_F80, "#__arm64ec_floatunsixf">;
def arm64ec___floatundixf
- : RuntimeLibcallImpl<UINTTOFP_I64_F80, "__arm64ec_floatundixf">;
+ : RuntimeLibcallImpl<UINTTOFP_I64_F80, "#__arm64ec_floatundixf">;
def arm64ec___floatuntixf
- : RuntimeLibcallImpl<UINTTOFP_I128_F80, "__arm64ec_floatuntixf">;
+ : RuntimeLibcallImpl<UINTTOFP_I128_F80, "#__arm64ec_floatuntixf">;
} // Arm64ECF80Impls
-// The x87 forms of the C library math functions. `LibmLibcallImpls` describes
-// them as `long double` implementations, which `DuplicateLibcallImplWithPrefix`
-// cannot copy (their `Provides` is left open until the module's `long double`
-// format is known), so they are spelled out as plain implementations of the F80
-// libcall each of them provides. `fma` is left out: the fused multiply-add is
-// one of the compiler-rt helpers above.
+// These are C library math functions. The goal is that an operation which
+// results in a call to mingw-w64 CRT for x86_64-w64-mingw32 must also result
+// in a call to mingw-w64 CRT for arm64ec-w64-mingw32. These are ARM64EC-only,
+// so they already carry the `#` decoration.
defset list<RuntimeLibcallImpl> Arm64ECX87LibmImpls = {
- foreach entry = !listremove(LibmCoreImpls_ldbl_noFrexpLdexp, [fmal]) in {
+ foreach entry = LibmCoreImpls_ldbl in {
defvar ldbl = !cast<LongDoubleLibcallImpl>(entry);
def arm64ec_ldbl_#entry
- : RuntimeLibcallImpl<ldbl.ProvidesF80, ldbl.LibCallFuncName>;
+ : RuntimeLibcallImpl<ldbl.ProvidesF80, "#"#ldbl.LibCallFuncName>;
}
}
// The Windows runtime lacks the f32 and f64 powi helpers, and frexpf/ldexpf.
-// ARM64EC still uses the x87 `long double` format, whose helpers are part of
-// compiler-rt as well.
defvar Arm64ECCompilerRtImpls =
- !listconcat(CompilerRtLibgccImpls_core_noPowi, Arm64ECF80Impls);
-defvar Arm64ECLibmImpls = !listconcat(
- !listremove(LibmCoreImpls_core, LibmFrexpLdexpF32), Arm64ECX87LibmImpls);
+ !listremove(CompilerRtLibgccImpls_core,
+ !listremove(PowiLibcallImpls, [__powitf2_f128, __powitf2_ppc128]));
+defvar Arm64ECLibmImpls = !listremove(LibmCoreImpls_core, LibmFrexpLdexpF32);
// Prepend a # to every name
defset list<RuntimeLibcallImpl> WinArm64ECDefaultRuntimeLibcallImpls = {
@@ -2558,7 +2552,8 @@ def Arm64ECExceptionRuntime : LibcallLibrary<"unwind",
// '#'-prefixed compiler-rt builtins and AArch64 outline atomics.
def Arm64ECRuntime : LibcallLibrary<"compiler-rt",
- (add WinArm64ECDefaultRuntimeLibcallImpls), isWindowsArm64EC> {
+ (add WinArm64ECDefaultRuntimeLibcallImpls, Arm64ECF80Impls,
+ Arm64ECX87LibmImpls), isWindowsArm64EC> {
let Isolated = true;
}
diff --git a/llvm/test/CodeGen/AArch64/arm64ec-fp80-libcalls.ll b/llvm/test/CodeGen/AArch64/arm64ec-fp80-libcalls.ll
index 5759cd93c192f4..ace5ed728d7d52 100644
--- a/llvm/test/CodeGen/AArch64/arm64ec-fp80-libcalls.ll
+++ b/llvm/test/CodeGen/AArch64/arm64ec-fp80-libcalls.ll
@@ -49,24 +49,24 @@ define x86_fp80 @f_div(x86_fp80 %a, x86_fp80 %b) {
ret x86_fp80 %r
}
-; Three-operand helpers: the fused multiply-add lives in the "fmax" family of
-; libgcc, the minimum and maximum in the "fmaxx"/"fminx" ones.
+; `sqrt`, `fma`, `maxnum` and `minnum` are library calls on x86 as well, so they
+; stay libm calls rather than gaining helpers.
; CHECK-LABEL: "#f_fma":
-; CHECK: bl "#__arm64ec_fmaxf3"
+; CHECK: bl "#fmal"
define x86_fp80 @f_fma(x86_fp80 %a, x86_fp80 %b, x86_fp80 %c) {
%r = call x86_fp80 @llvm.fma.f80(x86_fp80 %a, x86_fp80 %b, x86_fp80 %c)
ret x86_fp80 %r
}
; CHECK-LABEL: "#f_maxnum":
-; CHECK: bl "#__arm64ec_fmaxxf3"
+; CHECK: bl "#fmaxl"
define x86_fp80 @f_maxnum(x86_fp80 %a, x86_fp80 %b) {
%r = call x86_fp80 @llvm.maxnum.f80(x86_fp80 %a, x86_fp80 %b)
ret x86_fp80 %r
}
; CHECK-LABEL: "#f_minnum":
-; CHECK: bl "#__arm64ec_fminxf3"
+; CHECK: bl "#fminl"
define x86_fp80 @f_minnum(x86_fp80 %a, x86_fp80 %b) {
%r = call x86_fp80 @llvm.minnum.f80(x86_fp80 %a, x86_fp80 %b)
ret x86_fp80 %r
diff --git a/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/arm64ec.ll b/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/arm64ec.ll
index 1f5c3e0f4d8d9b..e2e790b6c2876d 100644
--- a/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/arm64ec.ll
+++ b/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/arm64ec.ll
@@ -127,9 +127,6 @@
; CHECK-NEXT: declare x86_fp80 @"#__arm64ec_floatundixf"(i64)
; CHECK-NEXT: declare x86_fp80 @"#__arm64ec_floatunsixf"(i32)
; CHECK-NEXT: declare void @"#__arm64ec_floatuntixf"(...)
-; CHECK-NEXT: declare x86_fp80 @"#__arm64ec_fmaxf3"(x86_fp80, x86_fp80, x86_fp80)
-; CHECK-NEXT: declare x86_fp80 @"#__arm64ec_fmaxxf3"(x86_fp80, x86_fp80)
-; CHECK-NEXT: declare x86_fp80 @"#__arm64ec_fminxf3"(x86_fp80, x86_fp80)
; CHECK-NEXT: declare void @"#__arm64ec_gexf2"(...)
; CHECK-NEXT: declare void @"#__arm64ec_gtxf2"(...)
; CHECK-NEXT: declare void @"#__arm64ec_lexf2"(...)
@@ -476,6 +473,7 @@
; CHECK-NEXT: declare double @"#exp"(double)
; CHECK-NEXT: declare double @"#exp10"(double)
; CHECK-NEXT: declare float @"#exp10f"(float)
+; CHECK-NEXT: declare x86_fp80 @"#exp10l"(x86_fp80)
; CHECK-NEXT: declare double @"#exp2"(double)
; CHECK-NEXT: declare float @"#exp2f"(float)
; CHECK-NEXT: declare x86_fp80 @"#exp2l"(x86_fp80)
@@ -493,6 +491,7 @@
; CHECK-NEXT: declare x86_fp80 @"#floorl"(x86_fp80)
; CHECK-NEXT: declare double @"#fma"(double, double, double)
; CHECK-NEXT: declare float @"#fmaf"(float, float, float)
+; CHECK-NEXT: declare x86_fp80 @"#fmal"(x86_fp80, x86_fp80, x86_fp80)
; CHECK-NEXT: declare double @"#fmax"(double, double)
; CHECK-NEXT: declare float @"#fmaxf"(float, float)
; CHECK-NEXT: declare double @"#fmaximum"(double, double)
@@ -516,7 +515,9 @@
; CHECK-NEXT: declare x86_fp80 @"#fmodl"(x86_fp80, x86_fp80)
; CHECK-NEXT: declare void @"#free"(ptr)
; CHECK-NEXT: declare double @"#frexp"(double, ptr)
+; CHECK-NEXT: declare x86_fp80 @"#frexpl"(x86_fp80, ptr)
; CHECK-NEXT: declare double @"#ldexp"(double, i32)
+; CHECK-NEXT: declare x86_fp80 @"#ldexpl"(x86_fp80, i32)
; CHECK-NEXT: declare void @"#llrint"(...)
; CHECK-NEXT: declare void @"#llrintf"(...)
; CHECK-NEXT: declare void @"#llrintl"(...)
>From 296ebcfd612e77810420c14dbc3fec5d995290d3 Mon Sep 17 00:00:00 2001
From: LIU Hao <lh_mouse at 126.com>
Date: Tue, 3 Nov 2026 14:23:01 +0800
Subject: [PATCH 08/10] restore llvm/unittests/IR/RuntimeLibcallsTest.cpp
---
llvm/unittests/IR/RuntimeLibcallsTest.cpp | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/llvm/unittests/IR/RuntimeLibcallsTest.cpp b/llvm/unittests/IR/RuntimeLibcallsTest.cpp
index 027fe6c1d96afe..50ace4277127fc 100644
--- a/llvm/unittests/IR/RuntimeLibcallsTest.cpp
+++ b/llvm/unittests/IR/RuntimeLibcallsTest.cpp
@@ -46,19 +46,15 @@ TEST(RuntimeLibcallsTest, LibcallImplByName) {
{
auto SquirtleSquad =
RTLIB::RuntimeLibcallsInfo::lookupLibcallImplName("sqrtl");
- // ARM64EC spells out the x87 flavour of each `long double` libm function
- // under the same name, so that the module-wide duplication can give it the
- // `#` prefix; that record itself is not part of any library.
- ASSERT_EQ(size(SquirtleSquad), 2);
- EXPECT_TRUE(is_contained(SquirtleSquad, RTLIB::impl_sqrtl));
- EXPECT_TRUE(is_contained(SquirtleSquad, RTLIB::impl_arm64ec_ldbl_sqrtl));
+ ASSERT_EQ(size(SquirtleSquad), 1);
+ EXPECT_EQ(*SquirtleSquad.begin(), RTLIB::impl_sqrtl);
}
// Last libcall
{
auto Truncs = RTLIB::RuntimeLibcallsInfo::lookupLibcallImplName("truncl");
- ASSERT_EQ(size(Truncs), 2);
- EXPECT_TRUE(is_contained(Truncs, RTLIB::impl_truncl));
+ ASSERT_EQ(size(Truncs), 1);
+ EXPECT_EQ(*Truncs.begin(), RTLIB::impl_truncl);
}
}
>From 426e79429f1d6e865b37439e7b820b2632e65bd3 Mon Sep 17 00:00:00 2001
From: LIU Hao <lh_mouse at 126.com>
Date: Fri, 6 Nov 2026 14:36:28 +0800
Subject: [PATCH 09/10] remove unnecessary `target triple =`
---
llvm/test/CodeGen/AArch64/arm64ec-fp80-libcalls.ll | 2 --
llvm/test/CodeGen/AArch64/arm64ec-fp80-soften-bitcast.ll | 2 --
llvm/test/CodeGen/AArch64/arm64ec-fp80-thunks.ll | 2 --
llvm/test/CodeGen/AArch64/arm64ec-varargs-indirect-return.ll | 2 --
4 files changed, 8 deletions(-)
diff --git a/llvm/test/CodeGen/AArch64/arm64ec-fp80-libcalls.ll b/llvm/test/CodeGen/AArch64/arm64ec-fp80-libcalls.ll
index ace5ed728d7d52..0ae15979e1fcee 100644
--- a/llvm/test/CodeGen/AArch64/arm64ec-fp80-libcalls.ll
+++ b/llvm/test/CodeGen/AArch64/arm64ec-fp80-libcalls.ll
@@ -6,8 +6,6 @@
; actually reachable from IR, so that a missing or misnamed libcall cannot slip
; through unnoticed.
-target triple = "arm64ec-pc-windows-msvc"
-
declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80)
declare x86_fp80 @llvm.maxnum.f80(x86_fp80, x86_fp80)
declare x86_fp80 @llvm.minnum.f80(x86_fp80, x86_fp80)
diff --git a/llvm/test/CodeGen/AArch64/arm64ec-fp80-soften-bitcast.ll b/llvm/test/CodeGen/AArch64/arm64ec-fp80-soften-bitcast.ll
index e7b0d00031a66f..39122db46c97b4 100644
--- a/llvm/test/CodeGen/AArch64/arm64ec-fp80-soften-bitcast.ll
+++ b/llvm/test/CodeGen/AArch64/arm64ec-fp80-soften-bitcast.ll
@@ -10,8 +10,6 @@
;; The helpers are the ARM64EC ones, which are named apart from the exact x87
;; soft-float helpers of libgcc, and are `#`-prefixed at the object level.
-target triple = "arm64ec-pc-windows-msvc"
-
define x86_fp80 @bitcast_select(i128 %bits, i1 %c) {
entry:
%trunc = trunc i128 %bits to i80
diff --git a/llvm/test/CodeGen/AArch64/arm64ec-fp80-thunks.ll b/llvm/test/CodeGen/AArch64/arm64ec-fp80-thunks.ll
index a391ee0e3a33fa..9ab45f706276ee 100644
--- a/llvm/test/CodeGen/AArch64/arm64ec-fp80-thunks.ll
+++ b/llvm/test/CodeGen/AArch64/arm64ec-fp80-thunks.ll
@@ -9,8 +9,6 @@
;; entry thunk: x64 memory slot -> ARM64EC register pair
;; exit thunk: ARM64EC register pair -> x64 memory slot
-target triple = "arm64ec-pc-windows-msvc"
-
declare x86_fp80 @ext_ret()
declare void @ext_take(x86_fp80)
diff --git a/llvm/test/CodeGen/AArch64/arm64ec-varargs-indirect-return.ll b/llvm/test/CodeGen/AArch64/arm64ec-varargs-indirect-return.ll
index c66765adb52c03..944e1963796b69 100644
--- a/llvm/test/CodeGen/AArch64/arm64ec-varargs-indirect-return.ll
+++ b/llvm/test/CodeGen/AArch64/arm64ec-varargs-indirect-return.ll
@@ -6,8 +6,6 @@
;; loaded from the stack, and the callee's view of the stack arguments has to
;; start above it.
-target triple = "arm64ec-pc-windows-msvc"
-
define i128 @ret_i128_vararg(i32 %a, ...) {
ret i128 0
}
>From 7c111774a777b8f012927a0fbc6e74fc4cdcb144 Mon Sep 17 00:00:00 2001
From: LIU Hao <lh_mouse at 126.com>
Date: Fri, 6 Nov 2026 14:38:31 +0800
Subject: [PATCH 10/10] drop `dso_local` from tests
---
llvm/test/CodeGen/AArch64/arm64ec-fp80-thunks.ll | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/llvm/test/CodeGen/AArch64/arm64ec-fp80-thunks.ll b/llvm/test/CodeGen/AArch64/arm64ec-fp80-thunks.ll
index 9ab45f706276ee..eba363edbc8b0a 100644
--- a/llvm/test/CodeGen/AArch64/arm64ec-fp80-thunks.ll
+++ b/llvm/test/CodeGen/AArch64/arm64ec-fp80-thunks.ll
@@ -14,32 +14,31 @@ declare void @ext_take(x86_fp80)
; The value is an i128 in an even-aligned register pair, so having a 32-bit
; argument in x0 puts it in x2:x3, and it is returned in x1:x0.
-define dso_local x86_fp80 @use_f80(i32 %x, x86_fp80 %v) {
+define x86_fp80 @use_f80(i32 %x, x86_fp80 %v) {
ret x86_fp80 %v
}
-define dso_local x86_fp80 @pass_f80(x86_fp80 %v) {
+define x86_fp80 @pass_f80(x86_fp80 %v) {
ret x86_fp80 %v
}
-define dso_local void @take_f80(i32 %x, x86_fp80 %v) {
+define void @take_f80(i32 %x, x86_fp80 %v) {
ret void
}
; With seven integer arguments the pair no longer fits in the argument
; registers and is passed on the stack, by value on the ARM64EC side and by
; reference on the x64 side.
-define dso_local void @stack_f80(i64 %a, i64 %b, i64 %c, i64 %d, i64 %e,
- i64 %f, i64 %g, x86_fp80 %v) {
+define void @stack_f80(i64 %a, i64 %b, i64 %c, i64 %d, i64 %e, i64 %f, i64 %g, x86_fp80 %v) {
ret void
}
-define dso_local x86_fp80 @ec_caller_ret() {
+define x86_fp80 @ec_caller_ret() {
%r = call x86_fp80 @ext_ret()
ret x86_fp80 %r
}
-define dso_local void @ec_caller_take(x86_fp80 %v) {
+define void @ec_caller_take(x86_fp80 %v) {
call void @ext_take(x86_fp80 %v)
ret void
}
More information about the cfe-commits
mailing list