|
1 | 1 | /* |
2 | | - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
@@ -300,87 +300,74 @@ class VM_Version : public Abstract_VM_Version { |
300 | 300 | static address _cpuinfo_cont_addr; // address of instruction after the one which causes SEGV |
301 | 301 |
|
302 | 302 | enum Feature_Flag : uint64_t { |
303 | | - CPU_CX8 = (1ULL << 0), // next bits are from cpuid 1 (EDX) |
304 | | - CPU_CMOV = (1ULL << 1), |
305 | | - CPU_FXSR = (1ULL << 2), |
306 | | - CPU_HT = (1ULL << 3), |
307 | | - |
308 | | - CPU_MMX = (1ULL << 4), |
309 | | - CPU_3DNOW_PREFETCH = (1ULL << 5), // Processor supports 3dnow prefetch and prefetchw instructions |
310 | | - // may not necessarily support other 3dnow instructions |
311 | | - CPU_SSE = (1ULL << 6), |
312 | | - CPU_SSE2 = (1ULL << 7), |
313 | | - |
314 | | - CPU_SSE3 = (1ULL << 8), // SSE3 comes from cpuid 1 (ECX) |
315 | | - CPU_SSSE3 = (1ULL << 9), |
316 | | - CPU_SSE4A = (1ULL << 10), |
317 | | - CPU_SSE4_1 = (1ULL << 11), |
318 | | - |
319 | | - CPU_SSE4_2 = (1ULL << 12), |
320 | | - CPU_POPCNT = (1ULL << 13), |
321 | | - CPU_LZCNT = (1ULL << 14), |
322 | | - CPU_TSC = (1ULL << 15), |
323 | | - |
324 | | - CPU_TSCINV_BIT = (1ULL << 16), |
325 | | - CPU_TSCINV = (1ULL << 17), |
326 | | - CPU_AVX = (1ULL << 18), |
327 | | - CPU_AVX2 = (1ULL << 19), |
328 | | - |
329 | | - CPU_AES = (1ULL << 20), |
330 | | - CPU_ERMS = (1ULL << 21), // enhanced 'rep movsb/stosb' instructions |
331 | | - CPU_CLMUL = (1ULL << 22), // carryless multiply for CRC |
332 | | - CPU_BMI1 = (1ULL << 23), |
333 | | - |
334 | | - CPU_BMI2 = (1ULL << 24), |
335 | | - CPU_RTM = (1ULL << 25), // Restricted Transactional Memory instructions |
336 | | - CPU_ADX = (1ULL << 26), |
337 | | - CPU_AVX512F = (1ULL << 27), // AVX 512bit foundation instructions |
338 | | - |
339 | | - CPU_AVX512DQ = (1ULL << 28), |
340 | | - CPU_AVX512PF = (1ULL << 29), |
341 | | - CPU_AVX512ER = (1ULL << 30), |
342 | | - CPU_AVX512CD = (1ULL << 31), |
343 | | - |
344 | | - CPU_AVX512BW = (1ULL << 32), // Byte and word vector instructions |
345 | | - CPU_AVX512VL = (1ULL << 33), // EVEX instructions with smaller vector length |
346 | | - CPU_SHA = (1ULL << 34), // SHA instructions |
347 | | - CPU_FMA = (1ULL << 35), // FMA instructions |
348 | | - |
349 | | - CPU_VZEROUPPER = (1ULL << 36), // Vzeroupper instruction |
350 | | - CPU_AVX512_VPOPCNTDQ = (1ULL << 37), // Vector popcount |
351 | | - CPU_AVX512_VPCLMULQDQ = (1ULL << 38), // Vector carryless multiplication |
352 | | - CPU_AVX512_VAES = (1ULL << 39), // Vector AES instruction |
353 | | - |
354 | | - CPU_AVX512_VNNI = (1ULL << 40), // Vector Neural Network Instructions |
355 | | - CPU_FLUSH = (1ULL << 41), // flush instruction |
356 | | - CPU_FLUSHOPT = (1ULL << 42), // flusopth instruction |
357 | | - CPU_CLWB = (1ULL << 43), // clwb instruction |
358 | | - |
359 | | - CPU_AVX512_VBMI2 = (1ULL << 44), // VBMI2 shift left double instructions |
360 | | - CPU_AVX512_VBMI = (1ULL << 45), // Vector BMI instructions |
361 | | - CPU_HV = (1ULL << 46), // Hypervisor instructions |
362 | | - |
363 | | - CPU_MAX_FEATURE = CPU_HV |
| 303 | +#define CPU_FEATURE_FLAGS(decl) \ |
| 304 | + decl(CX8, "cx8", 0) /* next bits are from cpuid 1 (EDX) */ \ |
| 305 | + decl(CMOV, "cmov", 1) \ |
| 306 | + decl(FXSR, "fxsr", 2) \ |
| 307 | + decl(HT, "ht", 3) \ |
| 308 | + \ |
| 309 | + decl(MMX, "mmx", 4) \ |
| 310 | + decl(3DNOW_PREFETCH, "3dnowpref", 5) /* Processor supports 3dnow prefetch and prefetchw instructions */ \ |
| 311 | + /* may not necessarily support other 3dnow instructions */ \ |
| 312 | + decl(SSE, "sse", 6) \ |
| 313 | + decl(SSE2, "sse2", 7) \ |
| 314 | + \ |
| 315 | + decl(SSE3, "sse3", 8 ) /* SSE3 comes from cpuid 1 (ECX) */ \ |
| 316 | + decl(SSSE3, "ssse3", 9 ) \ |
| 317 | + decl(SSE4A, "sse4a", 10) \ |
| 318 | + decl(SSE4_1, "sse4.1", 11) \ |
| 319 | + \ |
| 320 | + decl(SSE4_2, "sse4.2", 12) \ |
| 321 | + decl(POPCNT, "popcnt", 13) \ |
| 322 | + decl(LZCNT, "lzcnt", 14) \ |
| 323 | + decl(TSC, "tsc", 15) \ |
| 324 | + \ |
| 325 | + decl(TSCINV_BIT, "tscinvbit", 16) \ |
| 326 | + decl(TSCINV, "tscinv", 17) \ |
| 327 | + decl(AVX, "avx", 18) \ |
| 328 | + decl(AVX2, "avx2", 19) \ |
| 329 | + \ |
| 330 | + decl(AES, "aes", 20) \ |
| 331 | + decl(ERMS, "erms", 21) /* enhanced 'rep movsb/stosb' instructions */ \ |
| 332 | + decl(CLMUL, "clmul", 22) /* carryless multiply for CRC */ \ |
| 333 | + decl(BMI1, "bmi1", 23) \ |
| 334 | + \ |
| 335 | + decl(BMI2, "bmi2", 24) \ |
| 336 | + decl(RTM, "rtm", 25) /* Restricted Transactional Memory instructions */ \ |
| 337 | + decl(ADX, "adx", 26) \ |
| 338 | + decl(AVX512F, "avx512f", 27) /* AVX 512bit foundation instructions */ \ |
| 339 | + \ |
| 340 | + decl(AVX512DQ, "avx512dq", 28) \ |
| 341 | + decl(AVX512PF, "avx512pf", 29) \ |
| 342 | + decl(AVX512ER, "avx512er", 30) \ |
| 343 | + decl(AVX512CD, "avx512cd", 31) \ |
| 344 | + \ |
| 345 | + decl(AVX512BW, "avx512bw", 32) /* Byte and word vector instructions */ \ |
| 346 | + decl(AVX512VL, "avx512vl", 33) /* EVEX instructions with smaller vector length */ \ |
| 347 | + decl(SHA, "sha", 34) /* SHA instructions */ \ |
| 348 | + decl(FMA, "fma", 35) /* FMA instructions */ \ |
| 349 | + \ |
| 350 | + decl(VZEROUPPER, "vzeroupper", 36) /* Vzeroupper instruction */ \ |
| 351 | + decl(AVX512_VPOPCNTDQ, "avx512_vpopcntdq", 37) /* Vector popcount */ \ |
| 352 | + decl(AVX512_VPCLMULQDQ, "avx512_vpclmulqdq", 38) /* Vector carryless multiplication */ \ |
| 353 | + decl(AVX512_VAES, "avx512_vaes", 39) /* Vector AES instruction */ \ |
| 354 | + \ |
| 355 | + decl(AVX512_VNNI, "avx512_vnni", 40) /* Vector Neural Network Instructions */ \ |
| 356 | + decl(FLUSH, "clflush", 41) /* flush instruction */ \ |
| 357 | + decl(FLUSHOPT, "clflushopt", 42) /* flusopth instruction */ \ |
| 358 | + decl(CLWB, "clwb", 43) /* clwb instruction */ \ |
| 359 | + \ |
| 360 | + decl(AVX512_VBMI2, "avx512_vbmi2", 44) /* VBMI2 shift left double instructions */ \ |
| 361 | + decl(AVX512_VBMI, "avx512_vbmi", 45) /* Vector BMI instructions */ \ |
| 362 | + decl(HV, "hv", 46) /* Hypervisor instructions */ |
| 363 | + |
| 364 | +#define DECLARE_CPU_FEATURE_FLAG(id, name, bit) CPU_##id = (1ULL << bit), |
| 365 | + CPU_FEATURE_FLAGS(DECLARE_CPU_FEATURE_FLAG) |
| 366 | +#undef DECLARE_CPU_FEATURE_FLAG |
364 | 367 | }; |
365 | 368 |
|
366 | | -#define FEATURES_NAMES \ |
367 | | - "cx8", "cmov", "fxsr", "ht", \ |
368 | | - "mmx", "3dnowpref", "sse", "sse2", \ |
369 | | - "sse3", "ssse3", "sse4a", "sse4.1", \ |
370 | | - "sse4.2", "popcnt", "lzcnt", "tsc", \ |
371 | | - "tscinvbit", "tscinv", "avx", "avx2", \ |
372 | | - "aes", "erms", "clmul", "bmi1", \ |
373 | | - "bmi2", "rtm", "adx", "avx512f", \ |
374 | | - "avx512dq", "avx512pf", "avx512er", "avx512cd", \ |
375 | | - "avx512bw", "avx512vl", "sha", "fma", \ |
376 | | - "vzeroupper", "avx512_vpopcntdq", "avx512_vpclmulqdq", "avx512_vaes", \ |
377 | | - "avx512_vnni", "clflush", "clflushopt", "clwb", \ |
378 | | - "avx512_vmbi2", "avx512_vmbi", "hv" |
379 | | - |
380 | 369 | static const char* _features_names[]; |
381 | 370 |
|
382 | | - // NB! When adding new CPU feature detection consider updating vmStructs_x86.hpp, vmStructs_jvmci.hpp, and VM_Version::get_processor_features(). |
383 | | - |
384 | 371 | enum Extended_Family { |
385 | 372 | // AMD |
386 | 373 | CPU_FAMILY_AMD_11H = 0x11, |
|
0 commit comments