1532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -triple s390x-linux-gnu -emit-llvm -x c++ -o - %s | FileCheck %s
2532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -triple s390x-linux-gnu -emit-llvm -x c++ -o - %s -mfloat-abi soft \
3057e6bb5SAbhina Sreeskantharajan // RUN: | FileCheck %s --check-prefix=SOFT-FLOAT
4057e6bb5SAbhina Sreeskantharajan
5057e6bb5SAbhina Sreeskantharajan // Verify that class types are also recognized as float-like aggregate types
6057e6bb5SAbhina Sreeskantharajan
7057e6bb5SAbhina Sreeskantharajan class agg_float_class { float a; };
pass_agg_float_class(class agg_float_class arg)8057e6bb5SAbhina Sreeskantharajan class agg_float_class pass_agg_float_class(class agg_float_class arg) { return arg; }
9fd739804SFangrui Song // CHECK-LABEL: define{{.*}} void @_Z20pass_agg_float_class15agg_float_class(%class.agg_float_class* noalias sret(%class.agg_float_class) align 4 %{{.*}}, float %{{.*}})
10fd739804SFangrui Song // SOFT-FLOAT-LABEL: define{{.*}} void @_Z20pass_agg_float_class15agg_float_class(%class.agg_float_class* noalias sret(%class.agg_float_class) align 4 %{{.*}}, i32 %{{.*}})
11057e6bb5SAbhina Sreeskantharajan
12057e6bb5SAbhina Sreeskantharajan class agg_double_class { double a; };
pass_agg_double_class(class agg_double_class arg)13057e6bb5SAbhina Sreeskantharajan class agg_double_class pass_agg_double_class(class agg_double_class arg) { return arg; }
14fd739804SFangrui Song // CHECK-LABEL: define{{.*}} void @_Z21pass_agg_double_class16agg_double_class(%class.agg_double_class* noalias sret(%class.agg_double_class) align 8 %{{.*}}, double %{{.*}})
15fd739804SFangrui Song // SOFT-FLOAT-LABEL: define{{.*}} void @_Z21pass_agg_double_class16agg_double_class(%class.agg_double_class* noalias sret(%class.agg_double_class) align 8 %{{.*}}, i64 %{{.*}})
16057e6bb5SAbhina Sreeskantharajan
17057e6bb5SAbhina Sreeskantharajan
18*9b38e2efSJonas Paulsson // This structure is passed in a GPR in C++ (and C, checked in systemz-abi.c).
19057e6bb5SAbhina Sreeskantharajan struct agg_float_cpp { float a; int : 0; };
pass_agg_float_cpp(struct agg_float_cpp arg)20057e6bb5SAbhina Sreeskantharajan struct agg_float_cpp pass_agg_float_cpp(struct agg_float_cpp arg) { return arg; }
21*9b38e2efSJonas Paulsson // CHECK-LABEL: define{{.*}} void @_Z18pass_agg_float_cpp13agg_float_cpp(%struct.agg_float_cpp* noalias sret(%struct.agg_float_cpp) align 4 %{{.*}}, i32 %{{.*}})
22fd739804SFangrui Song // SOFT-FLOAT-LABEL: define{{.*}} void @_Z18pass_agg_float_cpp13agg_float_cpp(%struct.agg_float_cpp* noalias sret(%struct.agg_float_cpp) align 4 %{{.*}}, i32 %{{.*}})
23057e6bb5SAbhina Sreeskantharajan
24057e6bb5SAbhina Sreeskantharajan
25057e6bb5SAbhina Sreeskantharajan // A field member of empty class type in C++ makes the record nonhomogeneous,
26057e6bb5SAbhina Sreeskantharajan // unless it is marked as [[no_unique_address]]. This does not apply to arrays.
27057e6bb5SAbhina Sreeskantharajan struct empty { };
28057e6bb5SAbhina Sreeskantharajan struct agg_nofloat_empty { float a; empty dummy; };
pass_agg_nofloat_empty(struct agg_nofloat_empty arg)29057e6bb5SAbhina Sreeskantharajan struct agg_nofloat_empty pass_agg_nofloat_empty(struct agg_nofloat_empty arg) { return arg; }
30fd739804SFangrui Song // CHECK-LABEL: define{{.*}} void @_Z22pass_agg_nofloat_empty17agg_nofloat_empty(%struct.agg_nofloat_empty* noalias sret(%struct.agg_nofloat_empty) align 4 %{{.*}}, i64 %{{.*}})
31fd739804SFangrui Song // SOFT-FLOAT-LABEL: define{{.*}} void @_Z22pass_agg_nofloat_empty17agg_nofloat_empty(%struct.agg_nofloat_empty* noalias sret(%struct.agg_nofloat_empty) align 4 %{{.*}}, i64 %{{.*}})
32057e6bb5SAbhina Sreeskantharajan struct agg_float_empty { float a; [[no_unique_address]] empty dummy; };
pass_agg_float_empty(struct agg_float_empty arg)33057e6bb5SAbhina Sreeskantharajan struct agg_float_empty pass_agg_float_empty(struct agg_float_empty arg) { return arg; }
34fd739804SFangrui Song // CHECK-LABEL: define{{.*}} void @_Z20pass_agg_float_empty15agg_float_empty(%struct.agg_float_empty* noalias sret(%struct.agg_float_empty) align 4 %{{.*}}, float %{{.*}})
35fd739804SFangrui Song // SOFT-FLOAT-LABEL: define{{.*}} void @_Z20pass_agg_float_empty15agg_float_empty(%struct.agg_float_empty* noalias sret(%struct.agg_float_empty) align 4 %{{.*}}, i32 %{{.*}})
36057e6bb5SAbhina Sreeskantharajan struct agg_nofloat_emptyarray { float a; [[no_unique_address]] empty dummy[3]; };
pass_agg_nofloat_emptyarray(struct agg_nofloat_emptyarray arg)37057e6bb5SAbhina Sreeskantharajan struct agg_nofloat_emptyarray pass_agg_nofloat_emptyarray(struct agg_nofloat_emptyarray arg) { return arg; }
38fd739804SFangrui Song // CHECK-LABEL: define{{.*}} void @_Z27pass_agg_nofloat_emptyarray22agg_nofloat_emptyarray(%struct.agg_nofloat_emptyarray* noalias sret(%struct.agg_nofloat_emptyarray) align 4 %{{.*}}, i64 %{{.*}})
39fd739804SFangrui Song // SOFT-FLOAT-LABEL: define{{.*}} void @_Z27pass_agg_nofloat_emptyarray22agg_nofloat_emptyarray(%struct.agg_nofloat_emptyarray* noalias sret(%struct.agg_nofloat_emptyarray) align 4 %{{.*}}, i64 %{{.*}})
40057e6bb5SAbhina Sreeskantharajan
41057e6bb5SAbhina Sreeskantharajan // And likewise for members of base classes.
42057e6bb5SAbhina Sreeskantharajan struct noemptybase { empty dummy; };
43057e6bb5SAbhina Sreeskantharajan struct agg_nofloat_emptybase : noemptybase { float a; };
pass_agg_nofloat_emptybase(struct agg_nofloat_emptybase arg)44057e6bb5SAbhina Sreeskantharajan struct agg_nofloat_emptybase pass_agg_nofloat_emptybase(struct agg_nofloat_emptybase arg) { return arg; }
45fd739804SFangrui Song // CHECK-LABEL: define{{.*}} void @_Z26pass_agg_nofloat_emptybase21agg_nofloat_emptybase(%struct.agg_nofloat_emptybase* noalias sret(%struct.agg_nofloat_emptybase) align 4 %{{.*}}, i64 %{{.*}})
46fd739804SFangrui Song // SOFT-FLOAT-LABEL: define{{.*}} void @_Z26pass_agg_nofloat_emptybase21agg_nofloat_emptybase(%struct.agg_nofloat_emptybase* noalias sret(%struct.agg_nofloat_emptybase) align 4 %{{.*}}, i64 %{{.*}})
47057e6bb5SAbhina Sreeskantharajan struct emptybase { [[no_unique_address]] empty dummy; };
48057e6bb5SAbhina Sreeskantharajan struct agg_float_emptybase : emptybase { float a; };
pass_agg_float_emptybase(struct agg_float_emptybase arg)49057e6bb5SAbhina Sreeskantharajan struct agg_float_emptybase pass_agg_float_emptybase(struct agg_float_emptybase arg) { return arg; }
50fd739804SFangrui Song // CHECK-LABEL: define{{.*}} void @_Z24pass_agg_float_emptybase19agg_float_emptybase(%struct.agg_float_emptybase* noalias sret(%struct.agg_float_emptybase) align 4 %{{.*}}, float %{{.*}})
51fd739804SFangrui Song // SOFT-FLOAT-LABEL: define{{.*}} void @_Z24pass_agg_float_emptybase19agg_float_emptybase(%struct.agg_float_emptybase* noalias sret(%struct.agg_float_emptybase) align 4 %{{.*}}, i32 %{{.*}})
52057e6bb5SAbhina Sreeskantharajan struct noemptybasearray { [[no_unique_address]] empty dummy[3]; };
53057e6bb5SAbhina Sreeskantharajan struct agg_nofloat_emptybasearray : noemptybasearray { float a; };
pass_agg_nofloat_emptybasearray(struct agg_nofloat_emptybasearray arg)54057e6bb5SAbhina Sreeskantharajan struct agg_nofloat_emptybasearray pass_agg_nofloat_emptybasearray(struct agg_nofloat_emptybasearray arg) { return arg; }
55fd739804SFangrui Song // CHECK-LABEL: define{{.*}} void @_Z31pass_agg_nofloat_emptybasearray26agg_nofloat_emptybasearray(%struct.agg_nofloat_emptybasearray* noalias sret(%struct.agg_nofloat_emptybasearray) align 4 %{{.*}}, i64 %{{.*}})
56fd739804SFangrui Song // SOFT-FLOAT-LABEL: define{{.*}} void @_Z31pass_agg_nofloat_emptybasearray26agg_nofloat_emptybasearray(%struct.agg_nofloat_emptybasearray* noalias sret(%struct.agg_nofloat_emptybasearray) align 4 %{{.*}}, i64 %{{.*}})
57057e6bb5SAbhina Sreeskantharajan
58