Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / CodeGen / AArch64 / soft-float-abi.c
blob0e1188117c21c51fe1391b31cbdf17f303551590
1 // RUN: %clang_cc1 -triple aarch64 -target-feature +fp-armv8 -target-abi aapcs -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,HARD
2 // RUN: %clang_cc1 -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,SOFT
4 // See also llvm/test/CodeGen/AArch64/soft-float-abi.ll, which checks the LLVM
5 // backend parts of the soft-float ABI.
7 // The va_list type does not change between the ABIs
8 // CHECK: %struct.__va_list = type { ptr, ptr, ptr, i32, i32 }
10 // Floats are passed in integer registers, this will be handled by the backend.
11 // CHECK: define dso_local half @test0(half noundef %a)
12 // CHECK: define dso_local bfloat @test1(bfloat noundef %a)
13 // CHECK: define dso_local float @test2(float noundef %a)
14 // CHECK: define dso_local double @test3(double noundef %a)
15 // CHECK: define dso_local fp128 @test4(fp128 noundef %a)
16 __fp16 test0(__fp16 a) { return a; }
17 __bf16 test1(__bf16 a) { return a; }
18 float test2(float a) { return a; }
19 double test3(double a) { return a; }
20 long double test4(long double a) { return a; }
22 // No types are considered to be HFAs or HVAs by the soft-float PCS, so these
23 // are converted to integer types.
24 struct A {
25 float x;
27 // SOFT: define dso_local i32 @test10(i64 %a.coerce)
28 // HARD: define dso_local %struct.A @test10([1 x float] alignstack(8) %a.coerce)
29 struct A test10(struct A a) { return a; }
31 struct B {
32 double x;
33 double y;
35 // SOFT: define dso_local [2 x i64] @test11([2 x i64] %a.coerce)
36 // HARD: define dso_local %struct.B @test11([2 x double] alignstack(8) %a.coerce)
37 struct B test11(struct B a) { return a; }
39 #include <stdarg.h>
41 // The layout of the va_list struct is unchanged between the ABIs, but for
42 // aapcs-soft, floating-point arguments will be retreived from the GPR save
43 // area, as if they were an integer type of the same size.
44 // CHECK-LABEL: define dso_local double @test20(i32 noundef %a, ...)
45 // CHECK: %vl = alloca %struct.__va_list, align 8
46 // SOFT: %gr_offs_p = getelementptr inbounds nuw %struct.__va_list, ptr %vl, i32 0, i32 3
47 // SOFT: %reg_top_p = getelementptr inbounds nuw %struct.__va_list, ptr %vl, i32 0, i32 1
48 // HARD: %vr_offs_p = getelementptr inbounds nuw %struct.__va_list, ptr %vl, i32 0, i32 4
49 // HARD: %reg_top_p = getelementptr inbounds nuw %struct.__va_list, ptr %vl, i32 0, i32 2
50 double test20(int a, ...) {
51 va_list vl;
52 va_start(vl, a);
53 return va_arg(vl, double);
56 // Vector types are only available for targets with the correct hardware, and
57 // their calling-convention is left undefined by the soft-float ABI, so they
58 // aren't tested here.