@@ -38,6 +38,70 @@ typedef struct ffiTestBiggerStruct {
3838 long long t ;
3939 long long u ;
4040} ffiTestBiggerStruct ;
41+
42+ // testing of ARM64 homogenous floating-point aggregate argument passing
43+ typedef struct ffiSmallFloatStruct2 {
44+ float a ;
45+ float b ;
46+ } ffiSmallFloatStruct2 ;
47+
48+ typedef struct ffiSmallDoubleStruct2 {
49+ double a ;
50+ double b ;
51+ } ffiSmallDoubleStruct2 ;
52+
53+ typedef struct ffiMediumFloatStruct4 {
54+ float a ;
55+ float b ;
56+ float c ;
57+ float d ;
58+ } ffiMediumFloatStruct4 ;
59+
60+ typedef struct ffiMediumDoubleStruct4 {
61+ double a ;
62+ double b ;
63+ double c ;
64+ double d ;
65+ } ffiMediumDoubleStruct4 ;
66+
67+ typedef struct ffiLargeFloatStruct16 {
68+ float a ;
69+ float b ;
70+ float c ;
71+ float d ;
72+ float e ;
73+ float f ;
74+ float g ;
75+ float h ;
76+ float i ;
77+ float j ;
78+ float k ;
79+ float l ;
80+ float m ;
81+ float n ;
82+ float o ;
83+ float p ;
84+ } ffiLargeFloatStruct16 ;
85+
86+ typedef struct ffiLargeDoubleStruct16 {
87+ double a ;
88+ double b ;
89+ double c ;
90+ double d ;
91+ double e ;
92+ double f ;
93+ double g ;
94+ double h ;
95+ double i ;
96+ double j ;
97+ double k ;
98+ double l ;
99+ double m ;
100+ double n ;
101+ double o ;
102+ double p ;
103+ } ffiLargeDoubleStruct16 ;
104+
41105/*
42106 * test returning struct by value
43107 * clang --shared -Os -o libalientest.dylib alientest.c
@@ -483,7 +547,37 @@ EXPORT(ffiTestBiggerStruct) ffiTestStructBigger(ffiTestPoint4 pt1, ffiTestPoint4
483547 result .t = pt2 .z ;
484548 result .u = pt2 .w ;
485549
486- return ( result );
550+ return result ;
551+ }
552+
553+ EXPORT (float ) ffiTestPassSmallFloatStruct (ffiSmallFloatStruct2 s )
554+ {
555+ return s .a + s .b ;
556+ }
557+
558+ EXPORT (float ) ffiTestPassMediumFloatStruct (ffiMediumFloatStruct4 s )
559+ {
560+ return s .a + s .b + s .c + s .d ;
561+ }
562+
563+ EXPORT (float ) ffiTestPassLargeFloatStruct (ffiLargeFloatStruct16 s )
564+ {
565+ return s .a + s .b + s .c + s .d + s .e + s .f + s .g + s .h + s .i + s .j + s .k + s .l + s .m + s .n + s .o + s .p ;
566+ }
567+
568+ EXPORT (double ) ffiTestPassSmallDoubleStruct (ffiSmallDoubleStruct2 s )
569+ {
570+ return s .a + s .b ;
571+ }
572+
573+ EXPORT (double ) ffiTestPassMediumDoubleStruct (ffiMediumDoubleStruct4 s )
574+ {
575+ return s .a + s .b + s .c + s .d ;
576+ }
577+
578+ EXPORT (double ) ffiTestPassLargeDoubleStruct (ffiLargeDoubleStruct16 s )
579+ {
580+ return s .a + s .b + s .c + s .d + s .e + s .f + s .g + s .h + s .i + s .j + s .k + s .l + s .m + s .n + s .o + s .p ;
487581}
488582
489583/* test passing and returning pointers */
0 commit comments