Skip to content

Commit f07aba4

Browse files
authored
[X86] Add ABI handling for __float128 to match with GCC (#75156)
Fixes #74601
1 parent 06f1e10 commit f07aba4

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,7 @@ X86 Support
926926
* Support intrinsic of ``_uwrmsr``.
927927
- Support ISA of ``AVX10.1``.
928928
- ``-march=pantherlake`` and ``-march=clearwaterforest`` are now supported.
929+
- Added ABI handling for ``__float128`` to match with GCC.
929930

930931
Arm and AArch64 Support
931932
^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/CodeGen/Targets/X86.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,6 +1797,9 @@ void X86_64ABIInfo::classify(QualType Ty, uint64_t OffsetBase, Class &Lo,
17971797
} else if (k == BuiltinType::Float || k == BuiltinType::Double ||
17981798
k == BuiltinType::Float16 || k == BuiltinType::BFloat16) {
17991799
Current = SSE;
1800+
} else if (k == BuiltinType::Float128) {
1801+
Lo = SSE;
1802+
Hi = SSEUp;
18001803
} else if (k == BuiltinType::LongDouble) {
18011804
const llvm::fltSemantics *LDF = &getTarget().getLongDoubleFormat();
18021805
if (LDF == &llvm::APFloat::IEEEquad()) {

clang/test/CodeGen/X86/fp128-abi.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -target-feature +sse2 < %s | FileCheck %s --check-prefixes=CHECK
2+
// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -target-feature -sse2 < %s | FileCheck %s --check-prefixes=CHECK
3+
4+
struct st1 {
5+
__float128 a;
6+
};
7+
8+
struct st1 h1(__float128 a) {
9+
// CHECK: define{{.*}}fp128 @h1(fp128
10+
struct st1 x;
11+
x.a = a;
12+
return x;
13+
}
14+
15+
__float128 h2(struct st1 x) {
16+
// CHECK: define{{.*}}fp128 @h2(fp128
17+
return x.a;
18+
}
19+
20+
struct st2 {
21+
__float128 a;
22+
int b;
23+
};
24+
25+
struct st2 h3(__float128 a, int b) {
26+
// CHECK: define{{.*}}void @h3(ptr {{.*}}sret(%struct.st2)
27+
struct st2 x;
28+
x.a = a;
29+
x.b = b;
30+
return x;
31+
}
32+
33+
__float128 h4(struct st2 x) {
34+
// CHECK: define{{.*}}fp128 @h4(ptr {{.*}}byval(%struct.st2)
35+
return x.a;
36+
}

0 commit comments

Comments
 (0)