| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2 -mbmi -mbmi2 -mcldemote -mclflushopt -mclwb -mclzero -mcrc32 -menqcmd -mfsgsbase -mfxsr -mhreset -mlzcnt -mlwp -mmovdir64b -mmovdiri -mmwaitx -mpconfig -mpku -mpopcnt -mptwrite -mrdpid -mrdrnd -mrdseed -mrtm -msgx -mshstk -mtbm -mtsxldtrk -mxsave -mxsavec -mxsaveopt -mxsaves -mwaitpkg -mwbnoinvd" } */ |
| 3 |
/* { dg-additional-options "-muintr" { target { ! ia32 } } } */ |
| 4 |
|
| 5 |
/* Test calling GPR intrinsics from functions with general-regs-only |
| 6 |
target attribute. */ |
| 7 |
|
| 8 |
#include <x86gprintrin.h> |
| 9 |
|
| 10 |
#define _CONCAT(x,y) x ## y |
| 11 |
|
| 12 |
#define test_0(func, type) \ |
| 13 |
__attribute__ ((target("general-regs-only"))) \ |
| 14 |
type _CONCAT(do_,func) (void) \ |
| 15 |
{ return func (); } |
| 16 |
|
| 17 |
#define test_0_i1(func, type, imm) \ |
| 18 |
__attribute__ ((target("general-regs-only"))) \ |
| 19 |
type _CONCAT(do_,func) (void) \ |
| 20 |
{ return func (imm); } |
| 21 |
|
| 22 |
#define test_1(func, type, op1_type) \ |
| 23 |
__attribute__ ((target("general-regs-only"))) \ |
| 24 |
type _CONCAT(do_,func) (op1_type A) \ |
| 25 |
{ return func (A); } |
| 26 |
|
| 27 |
#define test_1_i1(func, type, op1_type, imm) \ |
| 28 |
__attribute__ ((target("general-regs-only"))) \ |
| 29 |
type _CONCAT(do_,func) (op1_type A) \ |
| 30 |
{ return func (A, imm); } |
| 31 |
|
| 32 |
#define test_2(func, type, op1_type, op2_type) \ |
| 33 |
__attribute__ ((target("general-regs-only"))) \ |
| 34 |
type _CONCAT(do_,func) (op1_type A, op2_type B) \ |
| 35 |
{ return func (A, B); } |
| 36 |
|
| 37 |
#define test_2_i1(func, type, op1_type, op2_type, imm) \ |
| 38 |
__attribute__ ((target("general-regs-only"))) \ |
| 39 |
type _CONCAT(do_,func) (op1_type A, op2_type B) \ |
| 40 |
{ return func (A, B, imm); } |
| 41 |
|
| 42 |
#define test_3(func, type, op1_type, op2_type, op3_type) \ |
| 43 |
__attribute__ ((target("general-regs-only"))) \ |
| 44 |
type _CONCAT(do_,func) (op1_type A, op2_type B, op3_type C) \ |
| 45 |
{ return func (A, B, C); } |
| 46 |
|
| 47 |
#define test_4(func, type, op1_type, op2_type, op3_type, op4_type) \ |
| 48 |
__attribute__ ((target("general-regs-only"))) \ |
| 49 |
type _CONCAT(do_,func) (op1_type A, op2_type B, op3_type C, \ |
| 50 |
op4_type D) \ |
| 51 |
{ return func (A, B, C, D); } |
| 52 |
|
| 53 |
/* ia32intrin.h */ |
| 54 |
test_1 (__bsfd, int, int) |
| 55 |
test_1 (__bsrd, int, int) |
| 56 |
test_1 (__bswapd, int, int) |
| 57 |
test_1 (__popcntd, int, unsigned int) |
| 58 |
test_2 (__rolb, unsigned char, unsigned char, int) |
| 59 |
test_2 (__rolw, unsigned short, unsigned short, int) |
| 60 |
test_2 (__rold, unsigned int, unsigned int, int) |
| 61 |
test_2 (__rorb, unsigned char, unsigned char, int) |
| 62 |
test_2 (__rorw, unsigned short, unsigned short, int) |
| 63 |
test_2 (__rord, unsigned int, unsigned int, int) |
| 64 |
|
| 65 |
#ifndef __iamcu__ |
| 66 |
/* adxintrin.h */ |
| 67 |
test_4 (_subborrow_u32, unsigned char, unsigned char, unsigned int, |
| 68 |
unsigned int, unsigned int *) |
| 69 |
test_4 (_addcarry_u32, unsigned char, unsigned char, unsigned int, |
| 70 |
unsigned int, unsigned int *) |
| 71 |
test_4 (_addcarryx_u32, unsigned char, unsigned char, unsigned int, |
| 72 |
unsigned int, unsigned int *) |
| 73 |
|
| 74 |
/* bmiintrin.h */ |
| 75 |
test_1 (__tzcnt_u16, unsigned short, unsigned short) |
| 76 |
test_2 (__andn_u32, unsigned int, unsigned int, unsigned int) |
| 77 |
test_2 (__bextr_u32, unsigned int, unsigned int, unsigned int) |
| 78 |
test_3 (_bextr_u32, unsigned int, unsigned int, unsigned int, |
| 79 |
unsigned int) |
| 80 |
test_1 (__blsi_u32, unsigned int, unsigned int) |
| 81 |
test_1 (_blsi_u32, unsigned int, unsigned int) |
| 82 |
test_1 (__blsmsk_u32, unsigned int, unsigned int) |
| 83 |
test_1 (_blsmsk_u32, unsigned int, unsigned int) |
| 84 |
test_1 (__blsr_u32, unsigned int, unsigned int) |
| 85 |
test_1 (_blsr_u32, unsigned int, unsigned int) |
| 86 |
test_1 (__tzcnt_u32, unsigned int, unsigned int) |
| 87 |
test_1 (_tzcnt_u32, unsigned int, unsigned int) |
| 88 |
|
| 89 |
/* bmi2intrin.h */ |
| 90 |
test_2 (_bzhi_u32, unsigned int, unsigned int, unsigned int) |
| 91 |
test_2 (_pdep_u32, unsigned int, unsigned int, unsigned int) |
| 92 |
test_2 (_pext_u32, unsigned int, unsigned int, unsigned int) |
| 93 |
|
| 94 |
/* cetintrin.h */ |
| 95 |
test_1 (_inc_ssp, void, unsigned int) |
| 96 |
test_0 (_saveprevssp, void) |
| 97 |
test_1 (_rstorssp, void, void *) |
| 98 |
test_2 (_wrssd, void, unsigned int, void *) |
| 99 |
test_2 (_wrussd, void, unsigned int, void *) |
| 100 |
test_0 (_setssbsy, void) |
| 101 |
test_1 (_clrssbsy, void, void *) |
| 102 |
|
| 103 |
/* cldemoteintrin.h */ |
| 104 |
test_1 (_cldemote, void, void *) |
| 105 |
|
| 106 |
/* clflushoptintrin.h */ |
| 107 |
test_1 (_mm_clflushopt, void, void *) |
| 108 |
|
| 109 |
/* clwbintrin.h */ |
| 110 |
test_1 (_mm_clwb, void, void *) |
| 111 |
|
| 112 |
/* clzerointrin.h */ |
| 113 |
test_1 (_mm_clzero, void, void *) |
| 114 |
|
| 115 |
/* enqcmdintrin.h */ |
| 116 |
test_2 (_enqcmd, int, void *, const void *) |
| 117 |
test_2 (_enqcmds, int, void *, const void *) |
| 118 |
|
| 119 |
/* fxsrintrin.h */ |
| 120 |
test_1 (_fxsave, void, void *) |
| 121 |
test_1 (_fxrstor, void, void *) |
| 122 |
|
| 123 |
/* hresetintrin.h */ |
| 124 |
test_1 (_hreset, void, unsigned int) |
| 125 |
|
| 126 |
/* ia32intrin.h */ |
| 127 |
test_2 (__crc32b, unsigned int, unsigned char, unsigned char) |
| 128 |
test_2 (__crc32w, unsigned int, unsigned short, unsigned short) |
| 129 |
test_2 (__crc32d, unsigned int, unsigned int, unsigned int) |
| 130 |
test_1 (__rdpmc, unsigned long long, int) |
| 131 |
test_0 (__rdtsc, unsigned long long) |
| 132 |
test_1 (__rdtscp, unsigned long long, unsigned int *) |
| 133 |
test_0 (__pause, void) |
| 134 |
|
| 135 |
/* lzcntintrin.h */ |
| 136 |
test_1 (__lzcnt16, unsigned short, unsigned short) |
| 137 |
test_1 (__lzcnt32, unsigned int, unsigned int) |
| 138 |
test_1 (_lzcnt_u32, unsigned int, unsigned int) |
| 139 |
|
| 140 |
/* lwpintrin.h */ |
| 141 |
test_1 (__llwpcb, void, void *) |
| 142 |
test_0 (__slwpcb, void *) |
| 143 |
test_2_i1 (__lwpval32, void, unsigned int, unsigned int, 1) |
| 144 |
test_2_i1 (__lwpins32, unsigned char, unsigned int, unsigned int, 1) |
| 145 |
|
| 146 |
/* movdirintrin.h */ |
| 147 |
test_2 (_directstoreu_u32, void, void *, unsigned int) |
| 148 |
test_2 (_movdir64b, void, void *, const void *) |
| 149 |
|
| 150 |
/* mwaitxintrin.h */ |
| 151 |
test_3 (_mm_monitorx, void, void const *, unsigned int, unsigned int) |
| 152 |
test_3 (_mm_mwaitx, void, unsigned int, unsigned int, unsigned int) |
| 153 |
|
| 154 |
/* pconfigintrin.h */ |
| 155 |
test_2 (_pconfig_u32, unsigned int, const unsigned int, size_t *) |
| 156 |
|
| 157 |
/* pkuintrin.h */ |
| 158 |
test_0 (_rdpkru_u32, unsigned int) |
| 159 |
test_1 (_wrpkru, void, unsigned int) |
| 160 |
|
| 161 |
/* popcntintrin.h */ |
| 162 |
test_1 (_mm_popcnt_u32, int, unsigned int) |
| 163 |
|
| 164 |
/* rdseedintrin.h */ |
| 165 |
test_1 (_rdseed16_step, int, unsigned short *) |
| 166 |
test_1 (_rdseed32_step, int, unsigned int *) |
| 167 |
|
| 168 |
/* rtmintrin.h */ |
| 169 |
test_0 (_xbegin, unsigned int) |
| 170 |
test_0 (_xend, void) |
| 171 |
test_0_i1 (_xabort, void, 1) |
| 172 |
|
| 173 |
/* sgxintrin.h */ |
| 174 |
test_2 (_encls_u32, unsigned int, const unsigned int, size_t *) |
| 175 |
test_2 (_enclu_u32, unsigned int, const unsigned int, size_t *) |
| 176 |
test_2 (_enclv_u32, unsigned int, const unsigned int, size_t *) |
| 177 |
|
| 178 |
/* tbmintrin.h */ |
| 179 |
test_1_i1 (__bextri_u32, unsigned int, unsigned int, 1) |
| 180 |
test_1 (__blcfill_u32, unsigned int, unsigned int) |
| 181 |
test_1 (__blci_u32, unsigned int, unsigned int) |
| 182 |
test_1 (__blcic_u32, unsigned int, unsigned int) |
| 183 |
test_1 (__blcmsk_u32, unsigned int, unsigned int) |
| 184 |
test_1 (__blcs_u32, unsigned int, unsigned int) |
| 185 |
test_1 (__blsfill_u32, unsigned int, unsigned int) |
| 186 |
test_1 (__blsic_u32, unsigned int, unsigned int) |
| 187 |
test_1 (__t1mskc_u32, unsigned int, unsigned int) |
| 188 |
test_1 (__tzmsk_u32, unsigned int, unsigned int) |
| 189 |
|
| 190 |
/* tsxldtrkintrin.h */ |
| 191 |
test_0 (_xsusldtrk, void) |
| 192 |
test_0 (_xresldtrk, void) |
| 193 |
|
| 194 |
/* x86gprintrin.h */ |
| 195 |
test_1 (_ptwrite32, void, unsigned int) |
| 196 |
test_1 (_rdrand16_step, int, unsigned short *) |
| 197 |
test_1 (_rdrand32_step, int, unsigned int *) |
| 198 |
test_0 (_wbinvd, void) |
| 199 |
|
| 200 |
/* xtestintrin.h */ |
| 201 |
test_0 (_xtest, int) |
| 202 |
|
| 203 |
/* xsaveintrin.h */ |
| 204 |
test_2 (_xsave, void, void *, long long) |
| 205 |
test_2 (_xrstor, void, void *, long long) |
| 206 |
test_2 (_xsetbv, void, unsigned int, long long) |
| 207 |
test_1 (_xgetbv, long long, unsigned int) |
| 208 |
|
| 209 |
/* xsavecintrin.h */ |
| 210 |
test_2 (_xsavec, void, void *, long long) |
| 211 |
|
| 212 |
/* xsaveoptintrin.h */ |
| 213 |
test_2 (_xsaveopt, void, void *, long long) |
| 214 |
|
| 215 |
/* xsavesintrin.h */ |
| 216 |
test_2 (_xsaves, void, void *, long long) |
| 217 |
test_2 (_xrstors, void, void *, long long) |
| 218 |
|
| 219 |
/* wbnoinvdintrin.h */ |
| 220 |
test_0 (_wbnoinvd, void) |
| 221 |
|
| 222 |
#ifdef __x86_64__ |
| 223 |
/* adxintrin.h */ |
| 224 |
test_4 (_subborrow_u64, unsigned char, unsigned char, |
| 225 |
unsigned long long, unsigned long long, |
| 226 |
unsigned long long *) |
| 227 |
test_4 (_addcarry_u64, unsigned char, unsigned char, |
| 228 |
unsigned long long, unsigned long long, |
| 229 |
unsigned long long *) |
| 230 |
test_4 (_addcarryx_u64, unsigned char, unsigned char, |
| 231 |
unsigned long long, unsigned long long, |
| 232 |
unsigned long long *) |
| 233 |
|
| 234 |
/* bmiintrin.h */ |
| 235 |
test_2 (__andn_u64, unsigned long long, unsigned long long, |
| 236 |
unsigned long long) |
| 237 |
test_2 (__bextr_u64, unsigned long long, unsigned long long, |
| 238 |
unsigned long long) |
| 239 |
test_3 (_bextr_u64, unsigned long long, unsigned long long, |
| 240 |
unsigned long long, unsigned long long) |
| 241 |
test_1 (__blsi_u64, unsigned long long, unsigned long long) |
| 242 |
test_1 (_blsi_u64, unsigned long long, unsigned long long) |
| 243 |
test_1 (__blsmsk_u64, unsigned long long, unsigned long long) |
| 244 |
test_1 (_blsmsk_u64, unsigned long long, unsigned long long) |
| 245 |
test_1 (__blsr_u64, unsigned long long, unsigned long long) |
| 246 |
test_1 (_blsr_u64, unsigned long long, unsigned long long) |
| 247 |
test_1 (__tzcnt_u64, unsigned long long, unsigned long long) |
| 248 |
test_1 (_tzcnt_u64, unsigned long long, unsigned long long) |
| 249 |
|
| 250 |
/* bmi2intrin.h */ |
| 251 |
test_2 (_bzhi_u64, unsigned long long, unsigned long long, |
| 252 |
unsigned long long) |
| 253 |
test_2 (_pdep_u64, unsigned long long, unsigned long long, |
| 254 |
unsigned long long) |
| 255 |
test_2 (_pext_u64, unsigned long long, unsigned long long, |
| 256 |
unsigned long long) |
| 257 |
test_3 (_mulx_u64, unsigned long long, unsigned long long, |
| 258 |
unsigned long long, unsigned long long *) |
| 259 |
|
| 260 |
/* cetintrin.h */ |
| 261 |
test_0 (_get_ssp, unsigned long long) |
| 262 |
test_2 (_wrssq, void, unsigned long long, void *) |
| 263 |
test_2 (_wrussq, void, unsigned long long, void *) |
| 264 |
|
| 265 |
/* fxsrintrin.h */ |
| 266 |
test_1 (_fxsave64, void, void *) |
| 267 |
test_1 (_fxrstor64, void, void *) |
| 268 |
|
| 269 |
/* ia32intrin.h */ |
| 270 |
test_1 (__bsfq, int, long long) |
| 271 |
test_1 (__bsrq, int, long long) |
| 272 |
test_1 (__bswapq, long long, long long) |
| 273 |
test_2 (__crc32q, unsigned long long, unsigned long long, |
| 274 |
unsigned long long) |
| 275 |
test_1 (__popcntq, long long, unsigned long long) |
| 276 |
test_2 (__rolq, unsigned long long, unsigned long long, int) |
| 277 |
test_2 (__rorq, unsigned long long, unsigned long long, int) |
| 278 |
test_0 (__readeflags, unsigned long long) |
| 279 |
test_1 (__writeeflags, void, unsigned int) |
| 280 |
|
| 281 |
/* lzcntintrin.h */ |
| 282 |
test_1 (__lzcnt64, unsigned long long, unsigned long long) |
| 283 |
test_1 (_lzcnt_u64, unsigned long long, unsigned long long) |
| 284 |
|
| 285 |
/* lwpintrin.h */ |
| 286 |
test_2_i1 (__lwpval64, void, unsigned long long, unsigned int, 1) |
| 287 |
test_2_i1 (__lwpins64, unsigned char, unsigned long long, |
| 288 |
unsigned int, 1) |
| 289 |
|
| 290 |
/* movdirintrin.h */ |
| 291 |
test_2 (_directstoreu_u64, void, void *, unsigned long long) |
| 292 |
|
| 293 |
/* popcntintrin.h */ |
| 294 |
test_1 (_mm_popcnt_u64, long long, unsigned long long) |
| 295 |
|
| 296 |
/* rdseedintrin.h */ |
| 297 |
test_1 (_rdseed64_step, int, unsigned long long *) |
| 298 |
|
| 299 |
/* tbmintrin.h */ |
| 300 |
test_1_i1 (__bextri_u64, unsigned long long, unsigned long long, 1) |
| 301 |
test_1 (__blcfill_u64, unsigned long long, unsigned long long) |
| 302 |
test_1 (__blci_u64, unsigned long long, unsigned long long) |
| 303 |
test_1 (__blcic_u64, unsigned long long, unsigned long long) |
| 304 |
test_1 (__blcmsk_u64, unsigned long long, unsigned long long) |
| 305 |
test_1 (__blcs_u64, unsigned long long, unsigned long long) |
| 306 |
test_1 (__blsfill_u64, unsigned long long, unsigned long long) |
| 307 |
test_1 (__blsic_u64, unsigned long long, unsigned long long) |
| 308 |
test_1 (__t1mskc_u64, unsigned long long, unsigned long long) |
| 309 |
test_1 (__tzmsk_u64, unsigned long long, unsigned long long) |
| 310 |
|
| 311 |
/* uintrintrin.h */ |
| 312 |
test_0 (_clui, void) |
| 313 |
test_1 (_senduipi, void, unsigned long long) |
| 314 |
test_0 (_stui, void) |
| 315 |
test_0 (_testui, unsigned char) |
| 316 |
|
| 317 |
/* x86gprintrin.h */ |
| 318 |
test_1 (_ptwrite64, void, unsigned long long) |
| 319 |
test_0 (_readfsbase_u32, unsigned int) |
| 320 |
test_0 (_readfsbase_u64, unsigned long long) |
| 321 |
test_0 (_readgsbase_u32, unsigned int) |
| 322 |
test_0 (_readgsbase_u64, unsigned long long) |
| 323 |
test_1 (_rdrand64_step, int, unsigned long long *) |
| 324 |
test_1 (_writefsbase_u32, void, unsigned int) |
| 325 |
test_1 (_writefsbase_u64, void, unsigned long long) |
| 326 |
test_1 (_writegsbase_u32, void, unsigned int) |
| 327 |
test_1 (_writegsbase_u64, void, unsigned long long) |
| 328 |
|
| 329 |
/* xsaveintrin.h */ |
| 330 |
test_2 (_xsave64, void, void *, long long) |
| 331 |
test_2 (_xrstor64, void, void *, long long) |
| 332 |
|
| 333 |
/* xsavecintrin.h */ |
| 334 |
test_2 (_xsavec64, void, void *, long long) |
| 335 |
|
| 336 |
/* xsaveoptintrin.h */ |
| 337 |
test_2 (_xsaveopt64, void, void *, long long) |
| 338 |
|
| 339 |
/* xsavesintrin.h */ |
| 340 |
test_2 (_xsaves64, void, void *, long long) |
| 341 |
test_2 (_xrstors64, void, void *, long long) |
| 342 |
|
| 343 |
/* waitpkgintrin.h */ |
| 344 |
test_1 (_umonitor, void, void *) |
| 345 |
test_2 (_umwait, unsigned char, unsigned int, unsigned long long) |
| 346 |
test_2 (_tpause, unsigned char, unsigned int, unsigned long long) |
| 347 |
|
| 348 |
#else /* !__x86_64__ */ |
| 349 |
/* bmi2intrin.h */ |
| 350 |
test_3 (_mulx_u32, unsigned int, unsigned int, unsigned int, |
| 351 |
unsigned int *) |
| 352 |
|
| 353 |
/* cetintrin.h */ |
| 354 |
test_0 (_get_ssp, unsigned int) |
| 355 |
#endif /* __x86_64__ */ |
| 356 |
|
| 357 |
#endif |