diff options
author | Phoebe Wang <phoebe.wang@intel.com> | 2024-01-05 21:53:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-05 21:53:47 +0800 |
commit | f07aba4bc1fbd8301b09e2114ebc4149d2439cac (patch) | |
tree | 8e849ca1663b96501241c067dfba8d46d71486a9 | |
parent | 06f1e10908e624c1e90a0c647e9f74826ad3f011 (diff) |
[X86] Add ABI handling for __float128 to match with GCC (#75156)
Fixes #74601
-rw-r--r-- | clang/docs/ReleaseNotes.rst | 1 | ||||
-rw-r--r-- | clang/lib/CodeGen/Targets/X86.cpp | 3 | ||||
-rw-r--r-- | clang/test/CodeGen/X86/fp128-abi.c | 36 |
3 files changed, 40 insertions, 0 deletions
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 3c63ad96ca2e..f5159cdc8a3b 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -926,6 +926,7 @@ X86 Support * Support intrinsic of ``_uwrmsr``. - Support ISA of ``AVX10.1``. - ``-march=pantherlake`` and ``-march=clearwaterforest`` are now supported. +- Added ABI handling for ``__float128`` to match with GCC. Arm and AArch64 Support ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/CodeGen/Targets/X86.cpp b/clang/lib/CodeGen/Targets/X86.cpp index 2af240350438..d053f41ab168 100644 --- a/clang/lib/CodeGen/Targets/X86.cpp +++ b/clang/lib/CodeGen/Targets/X86.cpp @@ -1797,6 +1797,9 @@ void X86_64ABIInfo::classify(QualType Ty, uint64_t OffsetBase, Class &Lo, } else if (k == BuiltinType::Float || k == BuiltinType::Double || k == BuiltinType::Float16 || k == BuiltinType::BFloat16) { Current = SSE; + } else if (k == BuiltinType::Float128) { + Lo = SSE; + Hi = SSEUp; } else if (k == BuiltinType::LongDouble) { const llvm::fltSemantics *LDF = &getTarget().getLongDoubleFormat(); if (LDF == &llvm::APFloat::IEEEquad()) { diff --git a/clang/test/CodeGen/X86/fp128-abi.c b/clang/test/CodeGen/X86/fp128-abi.c new file mode 100644 index 000000000000..2a0ae5009338 --- /dev/null +++ b/clang/test/CodeGen/X86/fp128-abi.c @@ -0,0 +1,36 @@ +// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -target-feature +sse2 < %s | FileCheck %s --check-prefixes=CHECK +// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -target-feature -sse2 < %s | FileCheck %s --check-prefixes=CHECK + +struct st1 { + __float128 a; +}; + +struct st1 h1(__float128 a) { + // CHECK: define{{.*}}fp128 @h1(fp128 + struct st1 x; + x.a = a; + return x; +} + +__float128 h2(struct st1 x) { + // CHECK: define{{.*}}fp128 @h2(fp128 + return x.a; +} + +struct st2 { + __float128 a; + int b; +}; + +struct st2 h3(__float128 a, int b) { + // CHECK: define{{.*}}void @h3(ptr {{.*}}sret(%struct.st2) + struct st2 x; + x.a = a; + x.b = b; + return x; +} + +__float128 h4(struct st2 x) { + // CHECK: define{{.*}}fp128 @h4(ptr {{.*}}byval(%struct.st2) + return x.a; +} |