1  /* Test AAPCS64 function result return.
       2  
       3     This test covers homogeneous floating-point aggregate types as described
       4     in AAPCS64 \S 4.3.5.  */
       5  
       6  /* { dg-do run { target aarch64-*-* } } */
       7  /* { dg-additional-sources "abitest.S" } */
       8  /* { dg-require-effective-target aarch64_big_endian } */
       9  
      10  #ifndef IN_FRAMEWORK
      11  #define TESTFILE "func-ret-3.c"
      12  #include "type-def.h"
      13  
      14  struct hfa_fx1_t hfa_fx1 = {12.345f};
      15  struct hfa_fx2_t hfa_fx2 = {123.456f, 234.456f};
      16  struct hfa_dx2_t hfa_dx2 = {234.567, 345.678};
      17  struct hfa_dx4_t hfa_dx4 = {1234.123, 2345.234, 3456.345, 4567.456};
      18  struct hfa_ldx3_t hfa_ldx3 = {123456.7890, 234567.8901, 345678.9012};
      19  struct non_hfa_fx5_t non_hfa_fx5 = {456.789f, 567.890f, 678.901f, 789.012f, 890.123f};
      20  struct hfa_ffs_t hfa_ffs;
      21  struct non_hfa_ffs_t non_hfa_ffs;
      22  struct non_hfa_ffs_2_t non_hfa_ffs_2;
      23  struct hva_vf2x1_t hva_vf2x1;
      24  struct hva_vi4x1_t hva_vi4x1;
      25  struct non_hfa_ffd_t non_hfa_ffd = {23.f, 24.f, 25.0};
      26  struct non_hfa_ii_t non_hfa_ii = {26, 27};
      27  struct non_hfa_c_t non_hfa_c = {28};
      28  struct non_hfa_ffvf2_t non_hfa_ffvf2;
      29  struct non_hfa_fffd_t non_hfa_fffd = {33.f, 34.f, 35.f, 36.0};
      30  union hfa_union_t hfa_union;
      31  union non_hfa_union_t non_hfa_union;
      32  
      33  /* Decimal Floating-point.  */
      34  struct hfa_dfx1_t hfa_dfx1 = {12.345df};
      35  struct hfa_dfx2_t hfa_dfx2 = {123.456df, 234.456df};
      36  struct hfa_ddx2_t hfa_ddx2 = {234.567dd, 345.678dd};
      37  struct hfa_ddx4_t hfa_ddx4 = {1234.123dd, 2345.234dd, 3456.345dd, 4567.456dd};
      38  struct hfa_dldx3_t hfa_dldx3 = {123456.7890dl, 234567.8901dl, 345678.9012dl};
      39  struct non_hfa_dfx5_t non_hfa_dfx5 = {456.789df, 567.890df, 678.901df, 789.012df, 890.123df};
      40  struct hfa_dffs_t hfa_dffs;
      41  struct non_hfa_dffs_t non_hfa_dffs;
      42  struct non_hfa_dffs_2_t non_hfa_dffs_2;
      43  struct hva_vdf2x1_t hva_vdf2x1;
      44  struct non_hfa_dffd_t non_hfa_dffd = {23.df, 24.df, 25.0dd};
      45  struct non_hfa_dffvf2_t non_hfa_dffvf2;
      46  struct non_hfa_dfffd_t non_hfa_dfffd = {33.df, 34.df, 35.df, 36.0dd};
      47  union hfa_dunion_t hfa_dunion;
      48  union non_hfa_dunion_t non_hfa_dunion;
      49  
      50  #define HAS_DATA_INIT_FUNC
      51  void init_data ()
      52  {
      53    hva_vf2x1.a = (vf2_t){17.f, 18.f};
      54    hva_vi4x1.a = (vi4_t){19, 20, 21, 22};
      55  
      56    non_hfa_ffvf2.a = 29.f;
      57    non_hfa_ffvf2.b = 30.f;
      58    non_hfa_ffvf2.c = (vf2_t){31.f, 32.f};
      59  
      60    hfa_union.s.a = 37.f;
      61    hfa_union.s.b = 38.f;
      62    hfa_union.c   = 39.f;
      63  
      64    non_hfa_union.a = 40.0;
      65    non_hfa_union.b = 41.f;
      66  
      67    hfa_ffs.a = 42.f;
      68    hfa_ffs.b = 43.f;
      69    hfa_ffs.c.a = 44.f;
      70    hfa_ffs.c.b = 45.f;
      71  
      72    non_hfa_ffs.a = 46.f;
      73    non_hfa_ffs.b = 47.f;
      74    non_hfa_ffs.c.a = 48.0;
      75    non_hfa_ffs.c.b = 49.0;
      76  
      77    non_hfa_ffs_2.s.a = 50;
      78    non_hfa_ffs_2.s.b = 51;
      79    non_hfa_ffs_2.c = 52.f;
      80    non_hfa_ffs_2.d = 53.f;
      81  
      82    /* Decimal floating-point.  */
      83    hva_vdf2x1.a = (vdf2_t){17.df, 18.df};
      84  
      85    non_hfa_dffvf2.a = 29.df;
      86    non_hfa_dffvf2.b = 30.df;
      87    non_hfa_dffvf2.c = (vdf2_t){31.df, 32.df};
      88  
      89    hfa_dunion.s.a = 37.df;
      90    hfa_dunion.s.b = 38.df;
      91    hfa_dunion.c   = 39.df;
      92  
      93    non_hfa_dunion.a = 40.0dd;
      94    non_hfa_dunion.b = 41.df;
      95  
      96    hfa_dffs.a = 42.df;
      97    hfa_dffs.b = 43.df;
      98    hfa_dffs.c.a = 44.df;
      99    hfa_dffs.c.b = 45.df;
     100  
     101    non_hfa_dffs.a = 46.df;
     102    non_hfa_dffs.b = 47.df;
     103    non_hfa_dffs.c.a = 48.0dd;
     104    non_hfa_dffs.c.b = 49.0dd;
     105  
     106    non_hfa_dffs_2.s.a = 50;
     107    non_hfa_dffs_2.s.b = 51;
     108    non_hfa_dffs_2.c = 52.df;
     109    non_hfa_dffs_2.d = 53.df;
     110  
     111  }
     112  
     113  #include "abitest-2.h"
     114  #else
     115    /* HFA returned in fp/simd registers.  */
     116  
     117  FUNC_VAL_CHECK ( 0, struct hfa_fx1_t , hfa_fx1  , S0, flat)
     118  FUNC_VAL_CHECK ( 1, struct hfa_fx2_t , hfa_fx2  , S0, flat)
     119  FUNC_VAL_CHECK ( 2, struct hfa_dx2_t , hfa_dx2  , D0, flat)
     120  
     121  FUNC_VAL_CHECK ( 3, struct hfa_dx4_t , hfa_dx4  , D0, flat)
     122  FUNC_VAL_CHECK ( 4, struct hfa_ldx3_t, hfa_ldx3 , Q0, flat)
     123  FUNC_VAL_CHECK ( 5, struct hfa_ffs_t , hfa_ffs  , S0, flat)
     124  FUNC_VAL_CHECK ( 6, union hfa_union_t, hfa_union, S0, flat)
     125  
     126  FUNC_VAL_CHECK ( 7, struct hva_vf2x1_t, hva_vf2x1, D0, flat)
     127  FUNC_VAL_CHECK ( 8, struct hva_vi4x1_t, hva_vi4x1, Q0, flat)
     128  
     129    /* Non-HFA returned in general registers or via a pointer in X8.  */
     130  FUNC_VAL_CHECK (10, struct non_hfa_fx5_t  , non_hfa_fx5  , X8, flat)
     131  FUNC_VAL_CHECK (13, struct non_hfa_ffd_t  , non_hfa_ffd  , X0, flat)
     132  FUNC_VAL_CHECK (14, struct non_hfa_ii_t   , non_hfa_ii   , X0, flat)
     133  FUNC_VAL_CHECK (15, struct non_hfa_c_t    , non_hfa_c    , X0, flat)
     134  FUNC_VAL_CHECK (16, struct non_hfa_ffvf2_t, non_hfa_ffvf2, X0, flat)
     135  FUNC_VAL_CHECK (17, struct non_hfa_fffd_t , non_hfa_fffd , X8, flat)
     136  FUNC_VAL_CHECK (18, struct non_hfa_ffs_t  , non_hfa_ffs  , X8, flat)
     137  FUNC_VAL_CHECK (19, struct non_hfa_ffs_2_t, non_hfa_ffs_2, X0, flat)
     138  FUNC_VAL_CHECK (20, union  non_hfa_union_t, non_hfa_union, X0, flat)
     139  
     140  /* Decimal floating-point.  */
     141  FUNC_VAL_CHECK (21, struct hfa_dfx1_t , hfa_dfx1  , S0, flat)
     142  FUNC_VAL_CHECK (22, struct hfa_dfx2_t , hfa_dfx2  , S0, flat)
     143  FUNC_VAL_CHECK (23, struct hfa_ddx2_t , hfa_ddx2  , D0, flat)
     144  
     145  FUNC_VAL_CHECK (24, struct hfa_ddx4_t , hfa_ddx4  , D0, flat)
     146  FUNC_VAL_CHECK (25, struct hfa_dldx3_t, hfa_dldx3 , Q0, flat)
     147  FUNC_VAL_CHECK (26, struct hfa_dffs_t , hfa_dffs  , S0, flat)
     148  FUNC_VAL_CHECK (27, union hfa_dunion_t, hfa_dunion, S0, flat)
     149  
     150  FUNC_VAL_CHECK (28, struct hva_vdf2x1_t, hva_vdf2x1, D0, flat)
     151  
     152  FUNC_VAL_CHECK (29, struct non_hfa_dfx5_t  , non_hfa_dfx5  , X8, flat)
     153  FUNC_VAL_CHECK (30, struct non_hfa_dffd_t  , non_hfa_dffd  , X0, flat)
     154  FUNC_VAL_CHECK (31, struct non_hfa_dffvf2_t, non_hfa_dffvf2, X0, flat)
     155  FUNC_VAL_CHECK (32, struct non_hfa_dfffd_t , non_hfa_dfffd , X8, flat)
     156  FUNC_VAL_CHECK (33, struct non_hfa_dffs_t  , non_hfa_dffs  , X8, flat)
     157  FUNC_VAL_CHECK (34, struct non_hfa_dffs_2_t, non_hfa_dffs_2, X0, flat)
     158  FUNC_VAL_CHECK (35, union  non_hfa_dunion_t, non_hfa_dunion, X0, flat)
     159  
     160  #endif