/src/qemu/tcg/x86_64/tcg-target-has.h
Line | Count | Source |
1 | | /* SPDX-License-Identifier: MIT */ |
2 | | /* |
3 | | * Define target-specific opcode support |
4 | | * Copyright (c) 2008 Fabrice Bellard |
5 | | */ |
6 | | |
7 | | #ifndef TCG_TARGET_HAS_H |
8 | | #define TCG_TARGET_HAS_H |
9 | | |
10 | | #include "host/cpuinfo.h" |
11 | | |
12 | 0 | #define have_bmi1 (cpuinfo & CPUINFO_BMI1) |
13 | 0 | #define have_popcnt (cpuinfo & CPUINFO_POPCNT) |
14 | 0 | #define have_avx1 (cpuinfo & CPUINFO_AVX1) |
15 | 0 | #define have_avx2 (cpuinfo & CPUINFO_AVX2) |
16 | 0 | #define have_movbe (cpuinfo & CPUINFO_MOVBE) |
17 | | |
18 | | /* |
19 | | * There are interesting instructions in AVX512, so long as we have AVX512VL, |
20 | | * which indicates support for EVEX on sizes smaller than 512 bits. |
21 | | */ |
22 | 0 | #define have_avx512vl ((cpuinfo & CPUINFO_AVX512VL) && \ |
23 | 0 | (cpuinfo & CPUINFO_AVX512F)) |
24 | 0 | #define have_avx512bw ((cpuinfo & CPUINFO_AVX512BW) && have_avx512vl) |
25 | 0 | #define have_avx512dq ((cpuinfo & CPUINFO_AVX512DQ) && have_avx512vl) |
26 | 0 | #define have_avx512vbmi2 ((cpuinfo & CPUINFO_AVX512VBMI2) && have_avx512vl) |
27 | | |
28 | | /* optional instructions */ |
29 | | /* Keep 32-bit values zero-extended in a register. */ |
30 | 0 | #define TCG_TARGET_HAS_extr_i64_i32 1 |
31 | | |
32 | 0 | #define TCG_TARGET_HAS_qemu_ldst_i128 (cpuinfo & CPUINFO_ATOMIC_VMOVDQA) |
33 | | |
34 | 0 | #define TCG_TARGET_HAS_tst 1 |
35 | | |
36 | | /* We do not support older SSE systems, only beginning with AVX1. */ |
37 | 0 | #define TCG_TARGET_HAS_v64 have_avx1 |
38 | 0 | #define TCG_TARGET_HAS_v128 have_avx1 |
39 | 0 | #define TCG_TARGET_HAS_v256 have_avx2 |
40 | | |
41 | 0 | #define TCG_TARGET_HAS_andc_vec 1 |
42 | 0 | #define TCG_TARGET_HAS_orc_vec have_avx512vl |
43 | 0 | #define TCG_TARGET_HAS_nand_vec have_avx512vl |
44 | 0 | #define TCG_TARGET_HAS_nor_vec have_avx512vl |
45 | 0 | #define TCG_TARGET_HAS_eqv_vec have_avx512vl |
46 | 0 | #define TCG_TARGET_HAS_not_vec have_avx512vl |
47 | 0 | #define TCG_TARGET_HAS_neg_vec 0 |
48 | 0 | #define TCG_TARGET_HAS_abs_vec 1 |
49 | 0 | #define TCG_TARGET_HAS_roti_vec have_avx512vl |
50 | 0 | #define TCG_TARGET_HAS_rots_vec 0 |
51 | 0 | #define TCG_TARGET_HAS_rotv_vec have_avx512vl |
52 | 0 | #define TCG_TARGET_HAS_shi_vec 1 |
53 | 0 | #define TCG_TARGET_HAS_shs_vec 1 |
54 | 0 | #define TCG_TARGET_HAS_shv_vec have_avx2 |
55 | 0 | #define TCG_TARGET_HAS_mul_vec 1 |
56 | 0 | #define TCG_TARGET_HAS_sat_vec 1 |
57 | 0 | #define TCG_TARGET_HAS_minmax_vec 1 |
58 | 0 | #define TCG_TARGET_HAS_bitsel_vec have_avx512vl |
59 | 0 | #define TCG_TARGET_HAS_cmpsel_vec 1 |
60 | 0 | #define TCG_TARGET_HAS_tst_vec have_avx512bw |
61 | | |
62 | | #define TCG_TARGET_deposit_valid(type, ofs, len) \ |
63 | 0 | ((ofs) == 0 && ((len) == 8 || (len) == 16)) |
64 | | |
65 | | /* |
66 | | * Check for the possibility of low byte/word extraction, high-byte extraction |
67 | | * and zero-extending 32-bit right-shift. |
68 | | * |
69 | | * We cannot sign-extend from high byte to 64-bits without using the |
70 | | * REX prefix that explicitly excludes access to the high-byte registers. |
71 | | */ |
72 | | static inline bool |
73 | | tcg_target_sextract_valid(TCGType type, unsigned ofs, unsigned len) |
74 | 0 | { |
75 | 0 | switch (ofs) { |
76 | 0 | case 0: |
77 | 0 | switch (len) { |
78 | 0 | case 8: |
79 | 0 | case 16: |
80 | 0 | return true; |
81 | 0 | case 32: |
82 | 0 | return type == TCG_TYPE_I64; |
83 | 0 | } |
84 | 0 | return false; |
85 | 0 | case 8: |
86 | 0 | return len == 8 && type == TCG_TYPE_I32; |
87 | 0 | } |
88 | 0 | return false; |
89 | 0 | } Unexecuted instantiation: optimize.c:tcg_target_sextract_valid Unexecuted instantiation: tcg.c:tcg_target_sextract_valid Unexecuted instantiation: tcg-common.c:tcg_target_sextract_valid Unexecuted instantiation: tcg-op.c:tcg_target_sextract_valid Unexecuted instantiation: tcg-op-ldst.c:tcg_target_sextract_valid Unexecuted instantiation: tcg-op-gvec.c:tcg_target_sextract_valid Unexecuted instantiation: tcg-op-vec.c:tcg_target_sextract_valid |
90 | 0 | #define TCG_TARGET_sextract_valid tcg_target_sextract_valid |
91 | | |
92 | | static inline bool |
93 | | tcg_target_extract_valid(TCGType type, unsigned ofs, unsigned len) |
94 | 0 | { |
95 | 0 | if (type == TCG_TYPE_I64 && ofs + len == 32) { |
96 | 0 | return true; |
97 | 0 | } |
98 | 0 | switch (ofs) { |
99 | 0 | case 0: |
100 | 0 | return len == 8 || len == 16; |
101 | 0 | case 8: |
102 | 0 | return len == 8; |
103 | 0 | } |
104 | 0 | return false; |
105 | 0 | } Unexecuted instantiation: optimize.c:tcg_target_extract_valid Unexecuted instantiation: tcg.c:tcg_target_extract_valid Unexecuted instantiation: tcg-common.c:tcg_target_extract_valid Unexecuted instantiation: tcg-op.c:tcg_target_extract_valid Unexecuted instantiation: tcg-op-ldst.c:tcg_target_extract_valid Unexecuted instantiation: tcg-op-gvec.c:tcg_target_extract_valid Unexecuted instantiation: tcg-op-vec.c:tcg_target_extract_valid |
106 | 0 | #define TCG_TARGET_extract_valid tcg_target_extract_valid |
107 | | |
108 | 0 | #define TCG_TARGET_lea_sh_valid(type, sh) ((sh) <= 3) |
109 | 0 | #define TCG_TARGET_lea_imm_valid(type, imm) ((imm) == (int32_t)(imm)) |
110 | | |
111 | | #endif |