-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AArch64] Add soft-float ABI (#74460)
This adds support for the AArch64 soft-float ABI. The specification for this ABI was added by ARM-software/abi-aa#232. Because all existing AArch64 hardware has floating-point hardware, we expect this to be a niche option, only used for embedded systems on R-profile systems. We are going to document that SysV-like systems should only ever use the base (hard-float) PCS variant: ARM-software/abi-aa#233. For that reason, I've not added an option to select the ABI independently of the FPU hardware, instead the new ABI is enabled iff the target architecture does not have an FPU. For testing, I have run this through an ABI fuzzer, but since this is the first implementation it can only test for internal consistency (callers and callees agree on the PCS), not for conformance to the ABI spec.
- Loading branch information
Showing
17 changed files
with
404 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// RUN: %clang_cc1 -triple aarch64 -target-feature +fp-armv8 -target-abi aapcs -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,HARD | ||
// RUN: %clang_cc1 -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,SOFT | ||
|
||
// See also llvm/test/CodeGen/AArch64/soft-float-abi.ll, which checks the LLVM | ||
// backend parts of the soft-float ABI. | ||
|
||
// The va_list type does not change between the ABIs | ||
// CHECK: %struct.__va_list = type { ptr, ptr, ptr, i32, i32 } | ||
|
||
// Floats are passed in integer registers, this will be handled by the backend. | ||
// CHECK: define dso_local half @test0(half noundef %a) | ||
// CHECK: define dso_local bfloat @test1(bfloat noundef %a) | ||
// CHECK: define dso_local float @test2(float noundef %a) | ||
// CHECK: define dso_local double @test3(double noundef %a) | ||
// CHECK: define dso_local fp128 @test4(fp128 noundef %a) | ||
__fp16 test0(__fp16 a) { return a; } | ||
__bf16 test1(__bf16 a) { return a; } | ||
float test2(float a) { return a; } | ||
double test3(double a) { return a; } | ||
long double test4(long double a) { return a; } | ||
|
||
// No types are considered to be HFAs or HVAs by the soft-float PCS, so these | ||
// are converted to integer types. | ||
struct A { | ||
float x; | ||
}; | ||
// SOFT: define dso_local i32 @test10(i64 %a.coerce) | ||
// HARD: define dso_local %struct.A @test10([1 x float] alignstack(8) %a.coerce) | ||
struct A test10(struct A a) { return a; } | ||
|
||
struct B { | ||
double x; | ||
double y; | ||
}; | ||
// SOFT: define dso_local [2 x i64] @test11([2 x i64] %a.coerce) | ||
// HARD: define dso_local %struct.B @test11([2 x double] alignstack(8) %a.coerce) | ||
struct B test11(struct B a) { return a; } | ||
|
||
#include <stdarg.h> | ||
|
||
// For variadic arguments, va_arg will always retreive | ||
// CHECK-LABEL: define dso_local double @test20(i32 noundef %a, ...) | ||
// CHECK: %vl = alloca %struct.__va_list, align 8 | ||
// SOFT: %gr_offs_p = getelementptr inbounds %struct.__va_list, ptr %vl, i32 0, i32 3 | ||
// SOFT: %reg_top_p = getelementptr inbounds %struct.__va_list, ptr %vl, i32 0, i32 1 | ||
// HARD: %vr_offs_p = getelementptr inbounds %struct.__va_list, ptr %vl, i32 0, i32 4 | ||
// HARD: %reg_top_p = getelementptr inbounds %struct.__va_list, ptr %vl, i32 0, i32 2 | ||
double test20(int a, ...) { | ||
va_list vl; | ||
va_start(vl, a); | ||
return va_arg(vl, double); | ||
} | ||
|
||
// Vector types are only available for targets with the correct hardware, and | ||
// their calling-convention is left undefined by the soft-float ABI, so they | ||
// aren't tested here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.