1  /* { dg-do compile } */
       2  /* { dg-options "-O2 -march=armv8-a+crypto" } */
       3  
       4  /* Test that pragma option pushing and popping works.
       5     Also that CPP predefines redefinitions on #pragma works.  */
       6  
       7  #pragma GCC push_options
       8  #pragma GCC target ("arch=armv8-a+nofp+nosimd")
       9  #ifdef __ARM_FEATURE_FMA
      10  #error "__ARM_FEATURE_FMA is defined but should not be!"
      11  #endif
      12  
      13  #ifdef __ARM_FP
      14  #error "__ARM_FP is defined but should not be!"
      15  #endif
      16  
      17  #pragma GCC push_options
      18  #pragma GCC target ("arch=armv8-a+fp+nosimd")
      19  #ifndef __ARM_FP
      20  #error "__ARM_FP is not defined but should be!"
      21  #endif
      22  
      23  #ifdef __ARM_NEON
      24  #error "__ARM_NEON is defined but should not be!"
      25  #endif
      26  
      27  #pragma GCC push_options
      28  #pragma GCC target ("arch=armv8-a+fp+simd")
      29  
      30  #ifndef __ARM_NEON
      31  #error "__ARM_NEON is not defined but should be!"
      32  #endif
      33  
      34  #ifdef __ARM_FEATURE_CRYPTO
      35  #error "__ARM_FEATURE_CRYPTO is defined but should not be!"
      36  #endif
      37  
      38  #pragma GCC push_options
      39  #pragma GCC target ("arch=armv8-a+fp+simd+crypto")
      40  
      41  #ifndef __ARM_FEATURE_CRYPTO
      42  #error "__ARM_FEATURE_CRYPTO is not defined but should be!"
      43  #endif
      44  
      45  #pragma GCC pop_options
      46  
      47  #ifndef __ARM_NEON
      48  #error "__ARM_NEON is not defined but should be!"
      49  #endif
      50  
      51  #ifdef __ARM_FEATURE_CRYPTO
      52  #error "__ARM_FEATURE_CRYPTO is defined but should not be!"
      53  #endif
      54  
      55  
      56  #pragma GCC pop_options
      57  
      58  #ifndef __ARM_FP
      59  #error "__ARM_FP is not defined but should be!"
      60  #endif
      61  
      62  #ifdef __ARM_NEON
      63  #error "__ARM_NEON is defined but should not be!"
      64  #endif
      65  
      66  #pragma GCC pop_options
      67  
      68  #ifdef __ARM_FP
      69  #error "__ARM_FP is defined but should not be!"
      70  #endif
      71  
      72  #ifdef __ARM_NEON
      73  #error "__ARM_NEON is defined but should not be!"
      74  #endif
      75  
      76  /* And again, but using cpu=.  */
      77  
      78  #pragma GCC push_options
      79  #pragma GCC target ("cpu=cortex-a53+nofp+nosimd")
      80  #ifdef __ARM_FEATURE_FMA
      81  #error "__ARM_FEATURE_FMA is defined but should not be!"
      82  #endif
      83  
      84  #ifdef __ARM_FP
      85  #error "__ARM_FP is defined but should not be!"
      86  #endif
      87  
      88  #pragma GCC push_options
      89  #pragma GCC target ("cpu=cortex-a53+fp+nosimd")
      90  #ifndef __ARM_FP
      91  #error "__ARM_FP is not defined but should be!"
      92  #endif
      93  
      94  #ifdef __ARM_NEON
      95  #error "__ARM_NEON is defined but should not be!"
      96  #endif
      97  
      98  #pragma GCC push_options
      99  #pragma GCC target ("cpu=cortex-a53+fp+simd+nocrypto")
     100  
     101  #ifndef __ARM_NEON
     102  #error "__ARM_NEON is not defined but should be!"
     103  #endif
     104  
     105  #ifdef __ARM_FEATURE_CRYPTO
     106  #error "__ARM_FEATURE_CRYPTO is defined but should not be!"
     107  #endif
     108  
     109  #pragma GCC push_options
     110  #pragma GCC target ("cpu=cortex-a53+fp+simd+crypto")
     111  
     112  #ifndef __ARM_FEATURE_CRYPTO
     113  #error "__ARM_FEATURE_CRYPTO is not defined but should be!"
     114  #endif
     115  
     116  
     117  #pragma GCC pop_options
     118  
     119  #ifndef __ARM_NEON
     120  #error "__ARM_NEON is not defined but should be!"
     121  #endif
     122  
     123  #ifdef __ARM_FEATURE_CRYPTO
     124  #error "__ARM_FEATURE_CRYPTO is defined but should not be!"
     125  #endif
     126  
     127  
     128  #pragma GCC pop_options
     129  
     130  #ifndef __ARM_FP
     131  #error "__ARM_FP is not defined but should be!"
     132  #endif
     133  
     134  #ifdef __ARM_NEON
     135  #error "__ARM_NEON is defined but should not be!"
     136  #endif
     137  
     138  #pragma GCC pop_options
     139  
     140  #ifdef __ARM_FP
     141  #error "__ARM_FP is defined but should not be!"
     142  #endif
     143  
     144  #ifdef __ARM_NEON
     145  #error "__ARM_NEON is defined but should not be!"
     146  #endif
     147  
     148  /* And again, but using just the ISA extensions.  */
     149  
     150  #pragma GCC push_options
     151  #pragma GCC target ("+nofp")
     152  #ifdef __ARM_FEATURE_FMA
     153  #error "__ARM_FEATURE_FMA is defined but should not be!"
     154  #endif
     155  
     156  #ifdef __ARM_FP
     157  #error "__ARM_FP is defined but should not be!"
     158  #endif
     159  
     160  #pragma GCC push_options
     161  #pragma GCC target ("+fp+nosimd")
     162  #ifndef __ARM_FP
     163  #error "__ARM_FP is not defined but should be!"
     164  #endif
     165  
     166  #ifdef __ARM_NEON
     167  #error "__ARM_NEON is defined but should not be!"
     168  #endif
     169  
     170  #pragma GCC push_options
     171  #pragma GCC target ("+fp+simd+nocrypto")
     172  
     173  #ifndef __ARM_NEON
     174  #error "__ARM_NEON is not defined but should be!"
     175  #endif
     176  
     177  #ifdef __ARM_FEATURE_CRYPTO
     178  #error "__ARM_FEATURE_CRYPTO is defined but should not be!"
     179  #endif
     180  
     181  #pragma GCC push_options
     182  #pragma GCC target ("+fp+simd+crypto")
     183  
     184  #ifndef __ARM_FEATURE_CRYPTO
     185  #error "__ARM_FEATURE_CRYPTO is not defined but should be!"
     186  #endif
     187  
     188  #pragma GCC pop_options
     189  
     190  #ifndef __ARM_NEON
     191  #error "__ARM_NEON is not defined but should be!"
     192  #endif
     193  
     194  #ifdef __ARM_FEATURE_CRYPTO
     195  #error "__ARM_FEATURE_CRYPTO is defined but should not be!"
     196  #endif
     197  
     198  
     199  #pragma GCC pop_options
     200  
     201  #ifndef __ARM_FP
     202  #error "__ARM_FP is not defined but should be!"
     203  #endif
     204  
     205  #ifdef __ARM_NEON
     206  #error "__ARM_NEON is defined but should not be!"
     207  #endif
     208  
     209  #pragma GCC pop_options
     210  
     211  #ifdef __ARM_FP
     212  #error "__ARM_FP is defined but should not be!"
     213  #endif
     214  
     215  #ifdef __ARM_NEON
     216  #error "__ARM_NEON is defined but should not be!"
     217  #endif
     218  
     219  /* Make sure that general-regs-only works too.  */
     220  #pragma GCC push_options
     221  #pragma GCC target ("general-regs-only")
     222  #ifdef __ARM_FEATURE_FMA
     223  #error "__ARM_FEATURE_FMA is defined but should not be!"
     224  #endif
     225  
     226  #ifdef __ARM_FP
     227  #error "__ARM_FP is defined but should not be!"
     228  #endif
     229  
     230  #ifdef __ARM_NEON
     231  #error "__ARM_NEON is defined but should not be!"
     232  #endif
     233  
     234  #ifdef __ARM_FEATURE_CRYPTO
     235  #error "__ARM_FEATURE_CRYPTO is defined but should not be!"
     236  #endif
     237  
     238  #pragma GCC pop_options
     239  
     240  /* Also check that crc re-defines work.  */
     241  #pragma GCC target ("+nocrc")
     242  #ifdef __ARM_FEATURE_CRC32
     243  #error "__ARM_FEATURE_CRC32 is defined but should not be!"
     244  #endif
     245  
     246  #pragma GCC target ("+crc")
     247  #ifndef __ARM_FEATURE_CRC32
     248  #error "__ARM_FEATURE_CRC32 is not defined but should be!"
     249  #endif
     250  
     251  #pragma GCC target ("arch=armv8.2-a")
     252  #ifdef __ARM_FEATURE_RCPC
     253  #error "__ARM_FEATURE_RCPC is defined but should not be!"
     254  #endif
     255  
     256  #pragma GCC target ("arch=armv8.2-a+rcpc")
     257  #ifndef __ARM_FEATURE_RCPC
     258  #error "__ARM_FEATURE_RCPC is not defined but should be!"
     259  #endif
     260  
     261  #pragma GCC target ("+norcpc")
     262  #ifdef __ARM_FEATURE_RCPC
     263  #error "__ARM_FEATURE_RCPC is defined but should not be!"
     264  #endif
     265  
     266  #pragma GCC target ("arch=armv8.3-a")
     267  #ifndef __ARM_FEATURE_RCPC
     268  #error "__ARM_FEATURE_RCPC is not defined but should be!"
     269  #endif
     270  
     271  int
     272  foo (int a)
     273  {
     274    return a;
     275  }