1 | The following changes since commit 17e1e49814096a3daaa8e5a73acd56a0f30bdc18: | 1 | The following changes since commit 1cbd2d914939ee6028e9688d4ba859a528c28405: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging (2020-04-09 19:00:41 +0100) | 3 | Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging (2021-06-04 13:38:49 +0100) |
4 | 4 | ||
5 | are available in the Git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | https://github.com/rth7680/qemu.git tags/pull-tcg-20200412 | 7 | https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20210604 |
8 | 8 | ||
9 | for you to fetch changes up to a4e57084c16d5b0eff3651693fba04f26b30b551: | 9 | for you to fetch changes up to 0006039e29b9e6118beab300146f7c4931f7a217: |
10 | 10 | ||
11 | tcg/mips: mips sync* encode error (2020-04-12 14:07:07 -0700) | 11 | tcg/arm: Implement TCG_TARGET_HAS_rotv_vec (2021-06-04 11:50:11 -0700) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Fix tcg/mips barrier encoding | 14 | Host vector support for arm neon. |
15 | 15 | ||
16 | ---------------------------------------------------------------- | 16 | ---------------------------------------------------------------- |
17 | lixinyu (1): | 17 | Richard Henderson (15): |
18 | tcg/mips: mips sync* encode error | 18 | tcg: Change parameters for tcg_target_const_match |
19 | tcg/arm: Add host vector framework | ||
20 | tcg/arm: Implement tcg_out_ld/st for vector types | ||
21 | tcg/arm: Implement tcg_out_mov for vector types | ||
22 | tcg/arm: Implement tcg_out_dup*_vec | ||
23 | tcg/arm: Implement minimal vector operations | ||
24 | tcg/arm: Implement andc, orc, abs, neg, not vector operations | ||
25 | tcg/arm: Implement TCG_TARGET_HAS_shi_vec | ||
26 | tcg/arm: Implement TCG_TARGET_HAS_mul_vec | ||
27 | tcg/arm: Implement TCG_TARGET_HAS_sat_vec | ||
28 | tcg/arm: Implement TCG_TARGET_HAS_minmax_vec | ||
29 | tcg/arm: Implement TCG_TARGET_HAS_bitsel_vec | ||
30 | tcg/arm: Implement TCG_TARGET_HAS_shv_vec | ||
31 | tcg/arm: Implement TCG_TARGET_HAS_roti_vec | ||
32 | tcg/arm: Implement TCG_TARGET_HAS_rotv_vec | ||
19 | 33 | ||
20 | tcg/mips/tcg-target.inc.c | 10 +++++----- | 34 | tcg/arm/tcg-target-con-set.h | 10 + |
21 | 1 file changed, 5 insertions(+), 5 deletions(-) | 35 | tcg/arm/tcg-target-con-str.h | 3 + |
36 | tcg/arm/tcg-target.h | 52 ++- | ||
37 | tcg/arm/tcg-target.opc.h | 16 + | ||
38 | tcg/tcg.c | 5 +- | ||
39 | tcg/aarch64/tcg-target.c.inc | 5 +- | ||
40 | tcg/arm/tcg-target.c.inc | 956 +++++++++++++++++++++++++++++++++++++++++-- | ||
41 | tcg/i386/tcg-target.c.inc | 4 +- | ||
42 | tcg/mips/tcg-target.c.inc | 5 +- | ||
43 | tcg/ppc/tcg-target.c.inc | 4 +- | ||
44 | tcg/riscv/tcg-target.c.inc | 4 +- | ||
45 | tcg/s390/tcg-target.c.inc | 5 +- | ||
46 | tcg/sparc/tcg-target.c.inc | 5 +- | ||
47 | tcg/tci/tcg-target.c.inc | 6 +- | ||
48 | 14 files changed, 1001 insertions(+), 79 deletions(-) | ||
49 | create mode 100644 tcg/arm/tcg-target.opc.h | ||
22 | 50 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | Change the return value to bool, because that's what is should | |
2 | have been from the start. Pass the ct mask instead of the whole | ||
3 | TCGArgConstraint, as that's the only part that's relevant. | ||
4 | |||
5 | Change the value argument to int64_t. We will need the extra | ||
6 | width for 32-bit hosts wanting to match vector constants. | ||
7 | |||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | --- | ||
11 | tcg/tcg.c | 5 ++--- | ||
12 | tcg/aarch64/tcg-target.c.inc | 5 +---- | ||
13 | tcg/arm/tcg-target.c.inc | 5 +---- | ||
14 | tcg/i386/tcg-target.c.inc | 4 +--- | ||
15 | tcg/mips/tcg-target.c.inc | 5 +---- | ||
16 | tcg/ppc/tcg-target.c.inc | 4 +--- | ||
17 | tcg/riscv/tcg-target.c.inc | 4 +--- | ||
18 | tcg/s390/tcg-target.c.inc | 5 +---- | ||
19 | tcg/sparc/tcg-target.c.inc | 5 +---- | ||
20 | tcg/tci/tcg-target.c.inc | 6 ++---- | ||
21 | 10 files changed, 12 insertions(+), 36 deletions(-) | ||
22 | |||
23 | diff --git a/tcg/tcg.c b/tcg/tcg.c | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/tcg/tcg.c | ||
26 | +++ b/tcg/tcg.c | ||
27 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg, TCGReg arg1, | ||
28 | static bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val, | ||
29 | TCGReg base, intptr_t ofs); | ||
30 | static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target); | ||
31 | -static int tcg_target_const_match(tcg_target_long val, TCGType type, | ||
32 | - const TCGArgConstraint *arg_ct); | ||
33 | +static bool tcg_target_const_match(int64_t val, TCGType type, int ct); | ||
34 | #ifdef TCG_TARGET_NEED_LDST_LABELS | ||
35 | static int tcg_out_ldst_finalize(TCGContext *s); | ||
36 | #endif | ||
37 | @@ -XXX,XX +XXX,XX @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) | ||
38 | ts = arg_temp(arg); | ||
39 | |||
40 | if (ts->val_type == TEMP_VAL_CONST | ||
41 | - && tcg_target_const_match(ts->val, ts->type, arg_ct)) { | ||
42 | + && tcg_target_const_match(ts->val, ts->type, arg_ct->ct)) { | ||
43 | /* constant is OK for instruction */ | ||
44 | const_args[i] = 1; | ||
45 | new_args[i] = ts->val; | ||
46 | diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/tcg/aarch64/tcg-target.c.inc | ||
49 | +++ b/tcg/aarch64/tcg-target.c.inc | ||
50 | @@ -XXX,XX +XXX,XX @@ static bool is_shimm1632(uint32_t v32, int *cmode, int *imm8) | ||
51 | } | ||
52 | } | ||
53 | |||
54 | -static int tcg_target_const_match(tcg_target_long val, TCGType type, | ||
55 | - const TCGArgConstraint *arg_ct) | ||
56 | +static bool tcg_target_const_match(int64_t val, TCGType type, int ct) | ||
57 | { | ||
58 | - int ct = arg_ct->ct; | ||
59 | - | ||
60 | if (ct & TCG_CT_CONST) { | ||
61 | return 1; | ||
62 | } | ||
63 | diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc | ||
64 | index XXXXXXX..XXXXXXX 100644 | ||
65 | --- a/tcg/arm/tcg-target.c.inc | ||
66 | +++ b/tcg/arm/tcg-target.c.inc | ||
67 | @@ -XXX,XX +XXX,XX @@ static inline int check_fit_imm(uint32_t imm) | ||
68 | * mov operand2: values represented with x << (2 * y), x < 0x100 | ||
69 | * add, sub, eor...: ditto | ||
70 | */ | ||
71 | -static inline int tcg_target_const_match(tcg_target_long val, TCGType type, | ||
72 | - const TCGArgConstraint *arg_ct) | ||
73 | +static bool tcg_target_const_match(int64_t val, TCGType type, int ct) | ||
74 | { | ||
75 | - int ct; | ||
76 | - ct = arg_ct->ct; | ||
77 | if (ct & TCG_CT_CONST) { | ||
78 | return 1; | ||
79 | } else if ((ct & TCG_CT_CONST_ARM) && check_fit_imm(val)) { | ||
80 | diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc | ||
81 | index XXXXXXX..XXXXXXX 100644 | ||
82 | --- a/tcg/i386/tcg-target.c.inc | ||
83 | +++ b/tcg/i386/tcg-target.c.inc | ||
84 | @@ -XXX,XX +XXX,XX @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
85 | } | ||
86 | |||
87 | /* test if a constant matches the constraint */ | ||
88 | -static inline int tcg_target_const_match(tcg_target_long val, TCGType type, | ||
89 | - const TCGArgConstraint *arg_ct) | ||
90 | +static bool tcg_target_const_match(int64_t val, TCGType type, int ct) | ||
91 | { | ||
92 | - int ct = arg_ct->ct; | ||
93 | if (ct & TCG_CT_CONST) { | ||
94 | return 1; | ||
95 | } | ||
96 | diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc | ||
97 | index XXXXXXX..XXXXXXX 100644 | ||
98 | --- a/tcg/mips/tcg-target.c.inc | ||
99 | +++ b/tcg/mips/tcg-target.c.inc | ||
100 | @@ -XXX,XX +XXX,XX @@ static inline bool is_p2m1(tcg_target_long val) | ||
101 | } | ||
102 | |||
103 | /* test if a constant matches the constraint */ | ||
104 | -static inline int tcg_target_const_match(tcg_target_long val, TCGType type, | ||
105 | - const TCGArgConstraint *arg_ct) | ||
106 | +static bool tcg_target_const_match(int64_t val, TCGType type, int ct) | ||
107 | { | ||
108 | - int ct; | ||
109 | - ct = arg_ct->ct; | ||
110 | if (ct & TCG_CT_CONST) { | ||
111 | return 1; | ||
112 | } else if ((ct & TCG_CT_CONST_ZERO) && val == 0) { | ||
113 | diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc | ||
114 | index XXXXXXX..XXXXXXX 100644 | ||
115 | --- a/tcg/ppc/tcg-target.c.inc | ||
116 | +++ b/tcg/ppc/tcg-target.c.inc | ||
117 | @@ -XXX,XX +XXX,XX @@ static bool reloc_pc14(tcg_insn_unit *src_rw, const tcg_insn_unit *target) | ||
118 | } | ||
119 | |||
120 | /* test if a constant matches the constraint */ | ||
121 | -static int tcg_target_const_match(tcg_target_long val, TCGType type, | ||
122 | - const TCGArgConstraint *arg_ct) | ||
123 | +static bool tcg_target_const_match(int64_t val, TCGType type, int ct) | ||
124 | { | ||
125 | - int ct = arg_ct->ct; | ||
126 | if (ct & TCG_CT_CONST) { | ||
127 | return 1; | ||
128 | } | ||
129 | diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc | ||
130 | index XXXXXXX..XXXXXXX 100644 | ||
131 | --- a/tcg/riscv/tcg-target.c.inc | ||
132 | +++ b/tcg/riscv/tcg-target.c.inc | ||
133 | @@ -XXX,XX +XXX,XX @@ static inline tcg_target_long sextreg(tcg_target_long val, int pos, int len) | ||
134 | } | ||
135 | |||
136 | /* test if a constant matches the constraint */ | ||
137 | -static int tcg_target_const_match(tcg_target_long val, TCGType type, | ||
138 | - const TCGArgConstraint *arg_ct) | ||
139 | +static bool tcg_target_const_match(int64_t val, TCGType type, int ct) | ||
140 | { | ||
141 | - int ct = arg_ct->ct; | ||
142 | if (ct & TCG_CT_CONST) { | ||
143 | return 1; | ||
144 | } | ||
145 | diff --git a/tcg/s390/tcg-target.c.inc b/tcg/s390/tcg-target.c.inc | ||
146 | index XXXXXXX..XXXXXXX 100644 | ||
147 | --- a/tcg/s390/tcg-target.c.inc | ||
148 | +++ b/tcg/s390/tcg-target.c.inc | ||
149 | @@ -XXX,XX +XXX,XX @@ static bool patch_reloc(tcg_insn_unit *src_rw, int type, | ||
150 | } | ||
151 | |||
152 | /* Test if a constant matches the constraint. */ | ||
153 | -static int tcg_target_const_match(tcg_target_long val, TCGType type, | ||
154 | - const TCGArgConstraint *arg_ct) | ||
155 | +static bool tcg_target_const_match(int64_t val, TCGType type, int ct) | ||
156 | { | ||
157 | - int ct = arg_ct->ct; | ||
158 | - | ||
159 | if (ct & TCG_CT_CONST) { | ||
160 | return 1; | ||
161 | } | ||
162 | diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc | ||
163 | index XXXXXXX..XXXXXXX 100644 | ||
164 | --- a/tcg/sparc/tcg-target.c.inc | ||
165 | +++ b/tcg/sparc/tcg-target.c.inc | ||
166 | @@ -XXX,XX +XXX,XX @@ static bool patch_reloc(tcg_insn_unit *src_rw, int type, | ||
167 | } | ||
168 | |||
169 | /* test if a constant matches the constraint */ | ||
170 | -static inline int tcg_target_const_match(tcg_target_long val, TCGType type, | ||
171 | - const TCGArgConstraint *arg_ct) | ||
172 | +static bool tcg_target_const_match(int64_t val, TCGType type, int ct) | ||
173 | { | ||
174 | - int ct = arg_ct->ct; | ||
175 | - | ||
176 | if (ct & TCG_CT_CONST) { | ||
177 | return 1; | ||
178 | } | ||
179 | diff --git a/tcg/tci/tcg-target.c.inc b/tcg/tci/tcg-target.c.inc | ||
180 | index XXXXXXX..XXXXXXX 100644 | ||
181 | --- a/tcg/tci/tcg-target.c.inc | ||
182 | +++ b/tcg/tci/tcg-target.c.inc | ||
183 | @@ -XXX,XX +XXX,XX @@ static inline bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val, | ||
184 | } | ||
185 | |||
186 | /* Test if a constant matches the constraint. */ | ||
187 | -static int tcg_target_const_match(tcg_target_long val, TCGType type, | ||
188 | - const TCGArgConstraint *arg_ct) | ||
189 | +static bool tcg_target_const_match(int64_t val, TCGType type, int ct) | ||
190 | { | ||
191 | - /* No need to return 0 or 1, 0 or != 0 is good enough. */ | ||
192 | - return arg_ct->ct & TCG_CT_CONST; | ||
193 | + return ct & TCG_CT_CONST; | ||
194 | } | ||
195 | |||
196 | static void tcg_target_init(TCGContext *s) | ||
197 | -- | ||
198 | 2.25.1 | ||
199 | |||
200 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | Add registers and function stubs. The functionality | |
2 | is disabled via use_neon_instructions defined to 0. | ||
3 | |||
4 | We must still include results for the mandatory opcodes in | ||
5 | tcg_target_op_def, as all opcodes are checked during tcg init. | ||
6 | |||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | --- | ||
10 | tcg/arm/tcg-target-con-set.h | 4 ++ | ||
11 | tcg/arm/tcg-target-con-str.h | 1 + | ||
12 | tcg/arm/tcg-target.h | 48 ++++++++++++-- | ||
13 | tcg/arm/tcg-target.opc.h | 12 ++++ | ||
14 | tcg/arm/tcg-target.c.inc | 117 +++++++++++++++++++++++++++++------ | ||
15 | 5 files changed, 158 insertions(+), 24 deletions(-) | ||
16 | create mode 100644 tcg/arm/tcg-target.opc.h | ||
17 | |||
18 | diff --git a/tcg/arm/tcg-target-con-set.h b/tcg/arm/tcg-target-con-set.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/tcg/arm/tcg-target-con-set.h | ||
21 | +++ b/tcg/arm/tcg-target-con-set.h | ||
22 | @@ -XXX,XX +XXX,XX @@ C_O0_I1(r) | ||
23 | C_O0_I2(r, r) | ||
24 | C_O0_I2(r, rIN) | ||
25 | C_O0_I2(s, s) | ||
26 | +C_O0_I2(w, r) | ||
27 | C_O0_I3(s, s, s) | ||
28 | C_O0_I4(r, r, rI, rI) | ||
29 | C_O0_I4(s, s, s, s) | ||
30 | C_O1_I1(r, l) | ||
31 | C_O1_I1(r, r) | ||
32 | +C_O1_I1(w, r) | ||
33 | +C_O1_I1(w, wr) | ||
34 | C_O1_I2(r, 0, rZ) | ||
35 | C_O1_I2(r, l, l) | ||
36 | C_O1_I2(r, r, r) | ||
37 | @@ -XXX,XX +XXX,XX @@ C_O1_I2(r, r, rIK) | ||
38 | C_O1_I2(r, r, rIN) | ||
39 | C_O1_I2(r, r, ri) | ||
40 | C_O1_I2(r, rZ, rZ) | ||
41 | +C_O1_I2(w, w, w) | ||
42 | C_O1_I4(r, r, r, rI, rI) | ||
43 | C_O1_I4(r, r, rIN, rIK, 0) | ||
44 | C_O2_I1(r, r, l) | ||
45 | diff --git a/tcg/arm/tcg-target-con-str.h b/tcg/arm/tcg-target-con-str.h | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/tcg/arm/tcg-target-con-str.h | ||
48 | +++ b/tcg/arm/tcg-target-con-str.h | ||
49 | @@ -XXX,XX +XXX,XX @@ | ||
50 | REGS('r', ALL_GENERAL_REGS) | ||
51 | REGS('l', ALL_QLOAD_REGS) | ||
52 | REGS('s', ALL_QSTORE_REGS) | ||
53 | +REGS('w', ALL_VECTOR_REGS) | ||
54 | |||
55 | /* | ||
56 | * Define constraint letters for constants: | ||
57 | diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h | ||
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/tcg/arm/tcg-target.h | ||
60 | +++ b/tcg/arm/tcg-target.h | ||
61 | @@ -XXX,XX +XXX,XX @@ typedef enum { | ||
62 | TCG_REG_R13, | ||
63 | TCG_REG_R14, | ||
64 | TCG_REG_PC, | ||
65 | + | ||
66 | + TCG_REG_Q0, | ||
67 | + TCG_REG_Q1, | ||
68 | + TCG_REG_Q2, | ||
69 | + TCG_REG_Q3, | ||
70 | + TCG_REG_Q4, | ||
71 | + TCG_REG_Q5, | ||
72 | + TCG_REG_Q6, | ||
73 | + TCG_REG_Q7, | ||
74 | + TCG_REG_Q8, | ||
75 | + TCG_REG_Q9, | ||
76 | + TCG_REG_Q10, | ||
77 | + TCG_REG_Q11, | ||
78 | + TCG_REG_Q12, | ||
79 | + TCG_REG_Q13, | ||
80 | + TCG_REG_Q14, | ||
81 | + TCG_REG_Q15, | ||
82 | + | ||
83 | + TCG_AREG0 = TCG_REG_R6, | ||
84 | + TCG_REG_CALL_STACK = TCG_REG_R13, | ||
85 | } TCGReg; | ||
86 | |||
87 | -#define TCG_TARGET_NB_REGS 16 | ||
88 | +#define TCG_TARGET_NB_REGS 32 | ||
89 | |||
90 | #ifdef __ARM_ARCH_EXT_IDIV__ | ||
91 | #define use_idiv_instructions 1 | ||
92 | #else | ||
93 | extern bool use_idiv_instructions; | ||
94 | #endif | ||
95 | - | ||
96 | +#define use_neon_instructions 0 | ||
97 | |||
98 | /* used for function call generation */ | ||
99 | -#define TCG_REG_CALL_STACK TCG_REG_R13 | ||
100 | #define TCG_TARGET_STACK_ALIGN 8 | ||
101 | #define TCG_TARGET_CALL_ALIGN_ARGS 1 | ||
102 | #define TCG_TARGET_CALL_STACK_OFFSET 0 | ||
103 | @@ -XXX,XX +XXX,XX @@ extern bool use_idiv_instructions; | ||
104 | #define TCG_TARGET_HAS_direct_jump 0 | ||
105 | #define TCG_TARGET_HAS_qemu_st8_i32 0 | ||
106 | |||
107 | -enum { | ||
108 | - TCG_AREG0 = TCG_REG_R6, | ||
109 | -}; | ||
110 | +#define TCG_TARGET_HAS_v64 use_neon_instructions | ||
111 | +#define TCG_TARGET_HAS_v128 use_neon_instructions | ||
112 | +#define TCG_TARGET_HAS_v256 0 | ||
113 | + | ||
114 | +#define TCG_TARGET_HAS_andc_vec 0 | ||
115 | +#define TCG_TARGET_HAS_orc_vec 0 | ||
116 | +#define TCG_TARGET_HAS_not_vec 0 | ||
117 | +#define TCG_TARGET_HAS_neg_vec 0 | ||
118 | +#define TCG_TARGET_HAS_abs_vec 0 | ||
119 | +#define TCG_TARGET_HAS_roti_vec 0 | ||
120 | +#define TCG_TARGET_HAS_rots_vec 0 | ||
121 | +#define TCG_TARGET_HAS_rotv_vec 0 | ||
122 | +#define TCG_TARGET_HAS_shi_vec 0 | ||
123 | +#define TCG_TARGET_HAS_shs_vec 0 | ||
124 | +#define TCG_TARGET_HAS_shv_vec 0 | ||
125 | +#define TCG_TARGET_HAS_mul_vec 0 | ||
126 | +#define TCG_TARGET_HAS_sat_vec 0 | ||
127 | +#define TCG_TARGET_HAS_minmax_vec 0 | ||
128 | +#define TCG_TARGET_HAS_bitsel_vec 0 | ||
129 | +#define TCG_TARGET_HAS_cmpsel_vec 0 | ||
130 | |||
131 | #define TCG_TARGET_DEFAULT_MO (0) | ||
132 | #define TCG_TARGET_HAS_MEMORY_BSWAP 1 | ||
133 | diff --git a/tcg/arm/tcg-target.opc.h b/tcg/arm/tcg-target.opc.h | ||
134 | new file mode 100644 | ||
135 | index XXXXXXX..XXXXXXX | ||
136 | --- /dev/null | ||
137 | +++ b/tcg/arm/tcg-target.opc.h | ||
138 | @@ -XXX,XX +XXX,XX @@ | ||
139 | +/* | ||
140 | + * Copyright (c) 2019 Linaro | ||
141 | + * | ||
142 | + * This work is licensed under the terms of the GNU GPL, version 2 or | ||
143 | + * (at your option) any later version. | ||
144 | + * | ||
145 | + * See the COPYING file in the top-level directory for details. | ||
146 | + * | ||
147 | + * Target-specific opcodes for host vector expansion. These will be | ||
148 | + * emitted by tcg_expand_vec_op. For those familiar with GCC internals, | ||
149 | + * consider these to be UNSPEC with names. | ||
150 | + */ | ||
151 | diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc | ||
152 | index XXXXXXX..XXXXXXX 100644 | ||
153 | --- a/tcg/arm/tcg-target.c.inc | ||
154 | +++ b/tcg/arm/tcg-target.c.inc | ||
155 | @@ -XXX,XX +XXX,XX @@ bool use_idiv_instructions; | ||
156 | |||
157 | #ifdef CONFIG_DEBUG_TCG | ||
158 | static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = { | ||
159 | - "%r0", | ||
160 | - "%r1", | ||
161 | - "%r2", | ||
162 | - "%r3", | ||
163 | - "%r4", | ||
164 | - "%r5", | ||
165 | - "%r6", | ||
166 | - "%r7", | ||
167 | - "%r8", | ||
168 | - "%r9", | ||
169 | - "%r10", | ||
170 | - "%r11", | ||
171 | - "%r12", | ||
172 | - "%r13", | ||
173 | - "%r14", | ||
174 | - "%pc", | ||
175 | + "%r0", "%r1", "%r2", "%r3", "%r4", "%r5", "%r6", "%r7", | ||
176 | + "%r8", "%r9", "%r10", "%r11", "%r12", "%sp", "%r14", "%pc", | ||
177 | + "%q0", "%q1", "%q2", "%q3", "%q4", "%q5", "%q6", "%q7", | ||
178 | + "%q8", "%q9", "%q10", "%q11", "%q12", "%q13", "%q14", "%q15", | ||
179 | }; | ||
180 | #endif | ||
181 | |||
182 | @@ -XXX,XX +XXX,XX @@ static const int tcg_target_reg_alloc_order[] = { | ||
183 | TCG_REG_R3, | ||
184 | TCG_REG_R12, | ||
185 | TCG_REG_R14, | ||
186 | + | ||
187 | + TCG_REG_Q0, | ||
188 | + TCG_REG_Q1, | ||
189 | + TCG_REG_Q2, | ||
190 | + TCG_REG_Q3, | ||
191 | + /* Q4 - Q7 are call-saved, and skipped. */ | ||
192 | + TCG_REG_Q8, | ||
193 | + TCG_REG_Q9, | ||
194 | + TCG_REG_Q10, | ||
195 | + TCG_REG_Q11, | ||
196 | + TCG_REG_Q12, | ||
197 | + TCG_REG_Q13, | ||
198 | + TCG_REG_Q14, | ||
199 | + TCG_REG_Q15, | ||
200 | }; | ||
201 | |||
202 | static const int tcg_target_call_iarg_regs[4] = { | ||
203 | @@ -XXX,XX +XXX,XX @@ static const int tcg_target_call_oarg_regs[2] = { | ||
204 | }; | ||
205 | |||
206 | #define TCG_REG_TMP TCG_REG_R12 | ||
207 | +#define TCG_VEC_TMP TCG_REG_Q15 | ||
208 | |||
209 | enum arm_cond_code_e { | ||
210 | COND_EQ = 0x0, | ||
211 | @@ -XXX,XX +XXX,XX @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
212 | #define TCG_CT_CONST_ZERO 0x800 | ||
213 | |||
214 | #define ALL_GENERAL_REGS 0xffffu | ||
215 | +#define ALL_VECTOR_REGS 0xffff0000u | ||
216 | |||
217 | /* | ||
218 | * r0-r2 will be overwritten when reading the tlb entry (softmmu only) | ||
219 | @@ -XXX,XX +XXX,XX @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) | ||
220 | case INDEX_op_qemu_st_i64: | ||
221 | return TARGET_LONG_BITS == 32 ? C_O0_I3(s, s, s) : C_O0_I4(s, s, s, s); | ||
222 | |||
223 | + case INDEX_op_st_vec: | ||
224 | + return C_O0_I2(w, r); | ||
225 | + case INDEX_op_ld_vec: | ||
226 | + case INDEX_op_dupm_vec: | ||
227 | + return C_O1_I1(w, r); | ||
228 | + case INDEX_op_dup_vec: | ||
229 | + return C_O1_I1(w, wr); | ||
230 | + case INDEX_op_dup2_vec: | ||
231 | + case INDEX_op_add_vec: | ||
232 | + case INDEX_op_sub_vec: | ||
233 | + case INDEX_op_xor_vec: | ||
234 | + case INDEX_op_or_vec: | ||
235 | + case INDEX_op_and_vec: | ||
236 | + case INDEX_op_cmp_vec: | ||
237 | + return C_O1_I2(w, w, w); | ||
238 | + | ||
239 | default: | ||
240 | g_assert_not_reached(); | ||
241 | } | ||
242 | @@ -XXX,XX +XXX,XX @@ static void tcg_target_init(TCGContext *s) | ||
243 | { | ||
244 | /* Only probe for the platform and capabilities if we havn't already | ||
245 | determined maximum values at compile time. */ | ||
246 | -#ifndef use_idiv_instructions | ||
247 | +#if !defined(use_idiv_instructions) || !defined(use_neon_instructions) | ||
248 | { | ||
249 | unsigned long hwcap = qemu_getauxval(AT_HWCAP); | ||
250 | +#ifndef use_idiv_instructions | ||
251 | use_idiv_instructions = (hwcap & HWCAP_ARM_IDIVA) != 0; | ||
252 | +#endif | ||
253 | +#ifndef use_neon_instructions | ||
254 | + use_neon_instructions = (hwcap & HWCAP_ARM_NEON) != 0; | ||
255 | +#endif | ||
256 | } | ||
257 | #endif | ||
258 | + | ||
259 | if (__ARM_ARCH < 7) { | ||
260 | const char *pl = (const char *)qemu_getauxval(AT_PLATFORM); | ||
261 | if (pl != NULL && pl[0] == 'v' && pl[1] >= '4' && pl[1] <= '9') { | ||
262 | @@ -XXX,XX +XXX,XX @@ static void tcg_target_init(TCGContext *s) | ||
263 | } | ||
264 | } | ||
265 | |||
266 | - tcg_target_available_regs[TCG_TYPE_I32] = 0xffff; | ||
267 | + tcg_target_available_regs[TCG_TYPE_I32] = ALL_GENERAL_REGS; | ||
268 | |||
269 | tcg_target_call_clobber_regs = 0; | ||
270 | tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R0); | ||
271 | @@ -XXX,XX +XXX,XX @@ static void tcg_target_init(TCGContext *s) | ||
272 | tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R12); | ||
273 | tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R14); | ||
274 | |||
275 | + if (use_neon_instructions) { | ||
276 | + tcg_target_available_regs[TCG_TYPE_V64] = ALL_VECTOR_REGS; | ||
277 | + tcg_target_available_regs[TCG_TYPE_V128] = ALL_VECTOR_REGS; | ||
278 | + | ||
279 | + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_Q0); | ||
280 | + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_Q1); | ||
281 | + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_Q2); | ||
282 | + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_Q3); | ||
283 | + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_Q8); | ||
284 | + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_Q9); | ||
285 | + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_Q10); | ||
286 | + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_Q11); | ||
287 | + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_Q12); | ||
288 | + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_Q13); | ||
289 | + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_Q14); | ||
290 | + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_Q15); | ||
291 | + } | ||
292 | + | ||
293 | s->reserved_regs = 0; | ||
294 | tcg_regset_set_reg(s->reserved_regs, TCG_REG_CALL_STACK); | ||
295 | tcg_regset_set_reg(s->reserved_regs, TCG_REG_TMP); | ||
296 | tcg_regset_set_reg(s->reserved_regs, TCG_REG_PC); | ||
297 | + tcg_regset_set_reg(s->reserved_regs, TCG_VEC_TMP); | ||
298 | } | ||
299 | |||
300 | static inline void tcg_out_ld(TCGContext *s, TCGType type, TCGReg arg, | ||
301 | @@ -XXX,XX +XXX,XX @@ static inline void tcg_out_movi(TCGContext *s, TCGType type, | ||
302 | tcg_out_movi32(s, COND_AL, ret, arg); | ||
303 | } | ||
304 | |||
305 | +static bool tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, | ||
306 | + TCGReg rd, TCGReg rs) | ||
307 | +{ | ||
308 | + g_assert_not_reached(); | ||
309 | +} | ||
310 | + | ||
311 | +static bool tcg_out_dupm_vec(TCGContext *s, TCGType type, unsigned vece, | ||
312 | + TCGReg rd, TCGReg base, intptr_t offset) | ||
313 | +{ | ||
314 | + g_assert_not_reached(); | ||
315 | +} | ||
316 | + | ||
317 | +static void tcg_out_dupi_vec(TCGContext *s, TCGType type, unsigned vece, | ||
318 | + TCGReg rd, int64_t v64) | ||
319 | +{ | ||
320 | + g_assert_not_reached(); | ||
321 | +} | ||
322 | + | ||
323 | +static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, | ||
324 | + unsigned vecl, unsigned vece, | ||
325 | + const TCGArg *args, const int *const_args) | ||
326 | +{ | ||
327 | + g_assert_not_reached(); | ||
328 | +} | ||
329 | + | ||
330 | +int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) | ||
331 | +{ | ||
332 | + return 0; | ||
333 | +} | ||
334 | + | ||
335 | +void tcg_expand_vec_op(TCGOpcode opc, TCGType type, unsigned vece, | ||
336 | + TCGArg a0, ...) | ||
337 | +{ | ||
338 | + g_assert_not_reached(); | ||
339 | +} | ||
340 | + | ||
341 | static void tcg_out_nop_fill(tcg_insn_unit *p, int count) | ||
342 | { | ||
343 | int i; | ||
344 | -- | ||
345 | 2.25.1 | ||
346 | |||
347 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
2 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | --- | ||
4 | tcg/arm/tcg-target.c.inc | 70 ++++++++++++++++++++++++++++++++++++---- | ||
5 | 1 file changed, 64 insertions(+), 6 deletions(-) | ||
1 | 6 | ||
7 | diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc | ||
8 | index XXXXXXX..XXXXXXX 100644 | ||
9 | --- a/tcg/arm/tcg-target.c.inc | ||
10 | +++ b/tcg/arm/tcg-target.c.inc | ||
11 | @@ -XXX,XX +XXX,XX @@ typedef enum { | ||
12 | INSN_NOP_v6k = 0xe320f000, | ||
13 | /* Otherwise the assembler uses mov r0,r0 */ | ||
14 | INSN_NOP_v4 = (COND_AL << 28) | ARITH_MOV, | ||
15 | + | ||
16 | + INSN_VLD1 = 0xf4200000, /* VLD1 (multiple single elements) */ | ||
17 | + INSN_VST1 = 0xf4000000, /* VST1 (multiple single elements) */ | ||
18 | } ARMInsn; | ||
19 | |||
20 | #define INSN_NOP (use_armv7_instructions ? INSN_NOP_v6k : INSN_NOP_v4) | ||
21 | @@ -XXX,XX +XXX,XX @@ static TCGCond tcg_out_cmp2(TCGContext *s, const TCGArg *args, | ||
22 | } | ||
23 | } | ||
24 | |||
25 | +/* | ||
26 | + * Note that TCGReg references Q-registers. | ||
27 | + * Q-regno = 2 * D-regno, so shift left by 1 whlie inserting. | ||
28 | + */ | ||
29 | +static uint32_t encode_vd(TCGReg rd) | ||
30 | +{ | ||
31 | + tcg_debug_assert(rd >= TCG_REG_Q0); | ||
32 | + return (extract32(rd, 3, 1) << 22) | (extract32(rd, 0, 3) << 13); | ||
33 | +} | ||
34 | + | ||
35 | +static void tcg_out_vldst(TCGContext *s, ARMInsn insn, | ||
36 | + TCGReg rd, TCGReg rn, int offset) | ||
37 | +{ | ||
38 | + if (offset != 0) { | ||
39 | + if (check_fit_imm(offset) || check_fit_imm(-offset)) { | ||
40 | + tcg_out_dat_rIN(s, COND_AL, ARITH_ADD, ARITH_SUB, | ||
41 | + TCG_REG_TMP, rn, offset, true); | ||
42 | + } else { | ||
43 | + tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_TMP, offset); | ||
44 | + tcg_out_dat_reg(s, COND_AL, ARITH_ADD, | ||
45 | + TCG_REG_TMP, TCG_REG_TMP, rn, 0); | ||
46 | + } | ||
47 | + rn = TCG_REG_TMP; | ||
48 | + } | ||
49 | + tcg_out32(s, insn | (rn << 16) | encode_vd(rd) | 0xf); | ||
50 | +} | ||
51 | + | ||
52 | #ifdef CONFIG_SOFTMMU | ||
53 | #include "../tcg-ldst.c.inc" | ||
54 | |||
55 | @@ -XXX,XX +XXX,XX @@ static void tcg_target_init(TCGContext *s) | ||
56 | tcg_regset_set_reg(s->reserved_regs, TCG_VEC_TMP); | ||
57 | } | ||
58 | |||
59 | -static inline void tcg_out_ld(TCGContext *s, TCGType type, TCGReg arg, | ||
60 | - TCGReg arg1, intptr_t arg2) | ||
61 | +static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg arg, | ||
62 | + TCGReg arg1, intptr_t arg2) | ||
63 | { | ||
64 | - tcg_out_ld32u(s, COND_AL, arg, arg1, arg2); | ||
65 | + switch (type) { | ||
66 | + case TCG_TYPE_I32: | ||
67 | + tcg_out_ld32u(s, COND_AL, arg, arg1, arg2); | ||
68 | + return; | ||
69 | + case TCG_TYPE_V64: | ||
70 | + /* regs 1; size 8; align 8 */ | ||
71 | + tcg_out_vldst(s, INSN_VLD1 | 0x7d0, arg, arg1, arg2); | ||
72 | + return; | ||
73 | + case TCG_TYPE_V128: | ||
74 | + /* regs 2; size 8; align 16 */ | ||
75 | + tcg_out_vldst(s, INSN_VLD1 | 0xae0, arg, arg1, arg2); | ||
76 | + return; | ||
77 | + default: | ||
78 | + g_assert_not_reached(); | ||
79 | + } | ||
80 | } | ||
81 | |||
82 | -static inline void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg, | ||
83 | - TCGReg arg1, intptr_t arg2) | ||
84 | +static void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg, | ||
85 | + TCGReg arg1, intptr_t arg2) | ||
86 | { | ||
87 | - tcg_out_st32(s, COND_AL, arg, arg1, arg2); | ||
88 | + switch (type) { | ||
89 | + case TCG_TYPE_I32: | ||
90 | + tcg_out_st32(s, COND_AL, arg, arg1, arg2); | ||
91 | + return; | ||
92 | + case TCG_TYPE_V64: | ||
93 | + /* regs 1; size 8; align 8 */ | ||
94 | + tcg_out_vldst(s, INSN_VST1 | 0x7d0, arg, arg1, arg2); | ||
95 | + return; | ||
96 | + case TCG_TYPE_V128: | ||
97 | + /* regs 2; size 8; align 16 */ | ||
98 | + tcg_out_vldst(s, INSN_VST1 | 0xae0, arg, arg1, arg2); | ||
99 | + return; | ||
100 | + default: | ||
101 | + g_assert_not_reached(); | ||
102 | + } | ||
103 | } | ||
104 | |||
105 | static inline bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val, | ||
106 | -- | ||
107 | 2.25.1 | ||
108 | |||
109 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
2 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | --- | ||
4 | tcg/arm/tcg-target.c.inc | 52 +++++++++++++++++++++++++++++++++++----- | ||
5 | 1 file changed, 46 insertions(+), 6 deletions(-) | ||
1 | 6 | ||
7 | diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc | ||
8 | index XXXXXXX..XXXXXXX 100644 | ||
9 | --- a/tcg/arm/tcg-target.c.inc | ||
10 | +++ b/tcg/arm/tcg-target.c.inc | ||
11 | @@ -XXX,XX +XXX,XX @@ typedef enum { | ||
12 | /* Otherwise the assembler uses mov r0,r0 */ | ||
13 | INSN_NOP_v4 = (COND_AL << 28) | ARITH_MOV, | ||
14 | |||
15 | + INSN_VORR = 0xf2200110, | ||
16 | + | ||
17 | INSN_VLD1 = 0xf4200000, /* VLD1 (multiple single elements) */ | ||
18 | INSN_VST1 = 0xf4000000, /* VST1 (multiple single elements) */ | ||
19 | } ARMInsn; | ||
20 | @@ -XXX,XX +XXX,XX @@ static uint32_t encode_vd(TCGReg rd) | ||
21 | return (extract32(rd, 3, 1) << 22) | (extract32(rd, 0, 3) << 13); | ||
22 | } | ||
23 | |||
24 | +static uint32_t encode_vn(TCGReg rn) | ||
25 | +{ | ||
26 | + tcg_debug_assert(rn >= TCG_REG_Q0); | ||
27 | + return (extract32(rn, 3, 1) << 7) | (extract32(rn, 0, 3) << 17); | ||
28 | +} | ||
29 | + | ||
30 | +static uint32_t encode_vm(TCGReg rm) | ||
31 | +{ | ||
32 | + tcg_debug_assert(rm >= TCG_REG_Q0); | ||
33 | + return (extract32(rm, 3, 1) << 5) | (extract32(rm, 0, 3) << 1); | ||
34 | +} | ||
35 | + | ||
36 | +static void tcg_out_vreg3(TCGContext *s, ARMInsn insn, int q, int vece, | ||
37 | + TCGReg d, TCGReg n, TCGReg m) | ||
38 | +{ | ||
39 | + tcg_out32(s, insn | (vece << 20) | (q << 6) | | ||
40 | + encode_vd(d) | encode_vn(n) | encode_vm(m)); | ||
41 | +} | ||
42 | + | ||
43 | static void tcg_out_vldst(TCGContext *s, ARMInsn insn, | ||
44 | TCGReg rd, TCGReg rn, int offset) | ||
45 | { | ||
46 | @@ -XXX,XX +XXX,XX @@ static inline bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val, | ||
47 | return false; | ||
48 | } | ||
49 | |||
50 | -static inline bool tcg_out_mov(TCGContext *s, TCGType type, | ||
51 | - TCGReg ret, TCGReg arg) | ||
52 | +static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) | ||
53 | { | ||
54 | - tcg_out_mov_reg(s, COND_AL, ret, arg); | ||
55 | - return true; | ||
56 | + if (ret == arg) { | ||
57 | + return true; | ||
58 | + } | ||
59 | + switch (type) { | ||
60 | + case TCG_TYPE_I32: | ||
61 | + if (ret < TCG_REG_Q0 && arg < TCG_REG_Q0) { | ||
62 | + tcg_out_mov_reg(s, COND_AL, ret, arg); | ||
63 | + return true; | ||
64 | + } | ||
65 | + return false; | ||
66 | + | ||
67 | + case TCG_TYPE_V64: | ||
68 | + case TCG_TYPE_V128: | ||
69 | + /* "VMOV D,N" is an alias for "VORR D,N,N". */ | ||
70 | + tcg_out_vreg3(s, INSN_VORR, type - TCG_TYPE_V64, 0, ret, arg, arg); | ||
71 | + return true; | ||
72 | + | ||
73 | + default: | ||
74 | + g_assert_not_reached(); | ||
75 | + } | ||
76 | } | ||
77 | |||
78 | -static inline void tcg_out_movi(TCGContext *s, TCGType type, | ||
79 | - TCGReg ret, tcg_target_long arg) | ||
80 | +static void tcg_out_movi(TCGContext *s, TCGType type, | ||
81 | + TCGReg ret, tcg_target_long arg) | ||
82 | { | ||
83 | + tcg_debug_assert(type == TCG_TYPE_I32); | ||
84 | + tcg_debug_assert(ret < TCG_REG_Q0); | ||
85 | tcg_out_movi32(s, COND_AL, ret, arg); | ||
86 | } | ||
87 | |||
88 | -- | ||
89 | 2.25.1 | ||
90 | |||
91 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Most of dupi is copied from tcg/aarch64, which has the same | ||
2 | encoding for AdvSimdExpandImm. | ||
1 | 3 | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | tcg/arm/tcg-target.c.inc | 283 +++++++++++++++++++++++++++++++++++++-- | ||
8 | 1 file changed, 275 insertions(+), 8 deletions(-) | ||
9 | |||
10 | diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/tcg/arm/tcg-target.c.inc | ||
13 | +++ b/tcg/arm/tcg-target.c.inc | ||
14 | @@ -XXX,XX +XXX,XX @@ typedef enum { | ||
15 | |||
16 | INSN_VORR = 0xf2200110, | ||
17 | |||
18 | + INSN_VDUP_G = 0xee800b10, /* VDUP (ARM core register) */ | ||
19 | + INSN_VDUP_S = 0xf3b00c00, /* VDUP (scalar) */ | ||
20 | + INSN_VLDR_D = 0xed100b00, /* VLDR.64 */ | ||
21 | INSN_VLD1 = 0xf4200000, /* VLD1 (multiple single elements) */ | ||
22 | + INSN_VLD1R = 0xf4a00c00, /* VLD1 (single element to all lanes) */ | ||
23 | INSN_VST1 = 0xf4000000, /* VST1 (multiple single elements) */ | ||
24 | + INSN_VMOVI = 0xf2800010, /* VMOV (immediate) */ | ||
25 | } ARMInsn; | ||
26 | |||
27 | #define INSN_NOP (use_armv7_instructions ? INSN_NOP_v6k : INSN_NOP_v4) | ||
28 | @@ -XXX,XX +XXX,XX @@ static const uint8_t tcg_cond_to_arm_cond[] = { | ||
29 | [TCG_COND_GTU] = COND_HI, | ||
30 | }; | ||
31 | |||
32 | +static int encode_imm(uint32_t imm); | ||
33 | + | ||
34 | +/* TCG private relocation type: add with pc+imm8 */ | ||
35 | +#define R_ARM_PC8 11 | ||
36 | + | ||
37 | +/* TCG private relocation type: vldr with imm8 << 2 */ | ||
38 | +#define R_ARM_PC11 12 | ||
39 | + | ||
40 | static bool reloc_pc24(tcg_insn_unit *src_rw, const tcg_insn_unit *target) | ||
41 | { | ||
42 | const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); | ||
43 | @@ -XXX,XX +XXX,XX @@ static bool reloc_pc13(tcg_insn_unit *src_rw, const tcg_insn_unit *target) | ||
44 | return false; | ||
45 | } | ||
46 | |||
47 | +static bool reloc_pc11(tcg_insn_unit *src_rw, const tcg_insn_unit *target) | ||
48 | +{ | ||
49 | + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); | ||
50 | + ptrdiff_t offset = (tcg_ptr_byte_diff(target, src_rx) - 8) / 4; | ||
51 | + | ||
52 | + if (offset >= -0xff && offset <= 0xff) { | ||
53 | + tcg_insn_unit insn = *src_rw; | ||
54 | + bool u = (offset >= 0); | ||
55 | + if (!u) { | ||
56 | + offset = -offset; | ||
57 | + } | ||
58 | + insn = deposit32(insn, 23, 1, u); | ||
59 | + insn = deposit32(insn, 0, 8, offset); | ||
60 | + *src_rw = insn; | ||
61 | + return true; | ||
62 | + } | ||
63 | + return false; | ||
64 | +} | ||
65 | + | ||
66 | +static bool reloc_pc8(tcg_insn_unit *src_rw, const tcg_insn_unit *target) | ||
67 | +{ | ||
68 | + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); | ||
69 | + ptrdiff_t offset = tcg_ptr_byte_diff(target, src_rx) - 8; | ||
70 | + int rot = encode_imm(offset); | ||
71 | + | ||
72 | + if (rot >= 0) { | ||
73 | + *src_rw = deposit32(*src_rw, 0, 12, rol32(offset, rot) | (rot << 7)); | ||
74 | + return true; | ||
75 | + } | ||
76 | + return false; | ||
77 | +} | ||
78 | + | ||
79 | static bool patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
80 | intptr_t value, intptr_t addend) | ||
81 | { | ||
82 | tcg_debug_assert(addend == 0); | ||
83 | - | ||
84 | - if (type == R_ARM_PC24) { | ||
85 | + switch (type) { | ||
86 | + case R_ARM_PC24: | ||
87 | return reloc_pc24(code_ptr, (const tcg_insn_unit *)value); | ||
88 | - } else if (type == R_ARM_PC13) { | ||
89 | + case R_ARM_PC13: | ||
90 | return reloc_pc13(code_ptr, (const tcg_insn_unit *)value); | ||
91 | - } else { | ||
92 | + case R_ARM_PC11: | ||
93 | + return reloc_pc11(code_ptr, (const tcg_insn_unit *)value); | ||
94 | + case R_ARM_PC8: | ||
95 | + return reloc_pc8(code_ptr, (const tcg_insn_unit *)value); | ||
96 | + default: | ||
97 | g_assert_not_reached(); | ||
98 | } | ||
99 | } | ||
100 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t rotl(uint32_t val, int n) | ||
101 | |||
102 | /* ARM immediates for ALU instructions are made of an unsigned 8-bit | ||
103 | right-rotated by an even amount between 0 and 30. */ | ||
104 | -static inline int encode_imm(uint32_t imm) | ||
105 | +static int encode_imm(uint32_t imm) | ||
106 | { | ||
107 | int shift; | ||
108 | |||
109 | @@ -XXX,XX +XXX,XX @@ static inline int check_fit_imm(uint32_t imm) | ||
110 | return encode_imm(imm) >= 0; | ||
111 | } | ||
112 | |||
113 | +/* Return true if v16 is a valid 16-bit shifted immediate. */ | ||
114 | +static bool is_shimm16(uint16_t v16, int *cmode, int *imm8) | ||
115 | +{ | ||
116 | + if (v16 == (v16 & 0xff)) { | ||
117 | + *cmode = 0x8; | ||
118 | + *imm8 = v16 & 0xff; | ||
119 | + return true; | ||
120 | + } else if (v16 == (v16 & 0xff00)) { | ||
121 | + *cmode = 0xa; | ||
122 | + *imm8 = v16 >> 8; | ||
123 | + return true; | ||
124 | + } | ||
125 | + return false; | ||
126 | +} | ||
127 | + | ||
128 | +/* Return true if v32 is a valid 32-bit shifted immediate. */ | ||
129 | +static bool is_shimm32(uint32_t v32, int *cmode, int *imm8) | ||
130 | +{ | ||
131 | + if (v32 == (v32 & 0xff)) { | ||
132 | + *cmode = 0x0; | ||
133 | + *imm8 = v32 & 0xff; | ||
134 | + return true; | ||
135 | + } else if (v32 == (v32 & 0xff00)) { | ||
136 | + *cmode = 0x2; | ||
137 | + *imm8 = (v32 >> 8) & 0xff; | ||
138 | + return true; | ||
139 | + } else if (v32 == (v32 & 0xff0000)) { | ||
140 | + *cmode = 0x4; | ||
141 | + *imm8 = (v32 >> 16) & 0xff; | ||
142 | + return true; | ||
143 | + } else if (v32 == (v32 & 0xff000000)) { | ||
144 | + *cmode = 0x6; | ||
145 | + *imm8 = v32 >> 24; | ||
146 | + return true; | ||
147 | + } | ||
148 | + return false; | ||
149 | +} | ||
150 | + | ||
151 | +/* Return true if v32 is a valid 32-bit shifting ones immediate. */ | ||
152 | +static bool is_soimm32(uint32_t v32, int *cmode, int *imm8) | ||
153 | +{ | ||
154 | + if ((v32 & 0xffff00ff) == 0xff) { | ||
155 | + *cmode = 0xc; | ||
156 | + *imm8 = (v32 >> 8) & 0xff; | ||
157 | + return true; | ||
158 | + } else if ((v32 & 0xff00ffff) == 0xffff) { | ||
159 | + *cmode = 0xd; | ||
160 | + *imm8 = (v32 >> 16) & 0xff; | ||
161 | + return true; | ||
162 | + } | ||
163 | + return false; | ||
164 | +} | ||
165 | + | ||
166 | +/* | ||
167 | + * Return non-zero if v32 can be formed by MOVI+ORR. | ||
168 | + * Place the parameters for MOVI in (cmode, imm8). | ||
169 | + * Return the cmode for ORR; the imm8 can be had via extraction from v32. | ||
170 | + */ | ||
171 | +static int is_shimm32_pair(uint32_t v32, int *cmode, int *imm8) | ||
172 | +{ | ||
173 | + int i; | ||
174 | + | ||
175 | + for (i = 6; i > 0; i -= 2) { | ||
176 | + /* Mask out one byte we can add with ORR. */ | ||
177 | + uint32_t tmp = v32 & ~(0xffu << (i * 4)); | ||
178 | + if (is_shimm32(tmp, cmode, imm8) || | ||
179 | + is_soimm32(tmp, cmode, imm8)) { | ||
180 | + break; | ||
181 | + } | ||
182 | + } | ||
183 | + return i; | ||
184 | +} | ||
185 | + | ||
186 | /* Test if a constant matches the constraint. | ||
187 | * TODO: define constraints for: | ||
188 | * | ||
189 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_vreg3(TCGContext *s, ARMInsn insn, int q, int vece, | ||
190 | encode_vd(d) | encode_vn(n) | encode_vm(m)); | ||
191 | } | ||
192 | |||
193 | +static void tcg_out_vmovi(TCGContext *s, TCGReg rd, | ||
194 | + int q, int op, int cmode, uint8_t imm8) | ||
195 | +{ | ||
196 | + tcg_out32(s, INSN_VMOVI | encode_vd(rd) | (q << 6) | (op << 5) | ||
197 | + | (cmode << 8) | extract32(imm8, 0, 4) | ||
198 | + | (extract32(imm8, 4, 3) << 16) | ||
199 | + | (extract32(imm8, 7, 1) << 24)); | ||
200 | +} | ||
201 | + | ||
202 | static void tcg_out_vldst(TCGContext *s, ARMInsn insn, | ||
203 | TCGReg rd, TCGReg rn, int offset) | ||
204 | { | ||
205 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_movi(TCGContext *s, TCGType type, | ||
206 | tcg_out_movi32(s, COND_AL, ret, arg); | ||
207 | } | ||
208 | |||
209 | +/* Type is always V128, with I64 elements. */ | ||
210 | +static void tcg_out_dup2_vec(TCGContext *s, TCGReg rd, TCGReg rl, TCGReg rh) | ||
211 | +{ | ||
212 | + /* Move high element into place first. */ | ||
213 | + /* VMOV Dd+1, Ds */ | ||
214 | + tcg_out_vreg3(s, INSN_VORR | (1 << 12), 0, 0, rd, rh, rh); | ||
215 | + /* Move low element into place; tcg_out_mov will check for nop. */ | ||
216 | + tcg_out_mov(s, TCG_TYPE_V64, rd, rl); | ||
217 | +} | ||
218 | + | ||
219 | static bool tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, | ||
220 | TCGReg rd, TCGReg rs) | ||
221 | { | ||
222 | - g_assert_not_reached(); | ||
223 | + int q = type - TCG_TYPE_V64; | ||
224 | + | ||
225 | + if (vece == MO_64) { | ||
226 | + if (type == TCG_TYPE_V128) { | ||
227 | + tcg_out_dup2_vec(s, rd, rs, rs); | ||
228 | + } else { | ||
229 | + tcg_out_mov(s, TCG_TYPE_V64, rd, rs); | ||
230 | + } | ||
231 | + } else if (rs < TCG_REG_Q0) { | ||
232 | + int b = (vece == MO_8); | ||
233 | + int e = (vece == MO_16); | ||
234 | + tcg_out32(s, INSN_VDUP_G | (b << 22) | (q << 21) | (e << 5) | | ||
235 | + encode_vn(rd) | (rs << 12)); | ||
236 | + } else { | ||
237 | + int imm4 = 1 << vece; | ||
238 | + tcg_out32(s, INSN_VDUP_S | (imm4 << 16) | (q << 6) | | ||
239 | + encode_vd(rd) | encode_vm(rs)); | ||
240 | + } | ||
241 | + return true; | ||
242 | } | ||
243 | |||
244 | static bool tcg_out_dupm_vec(TCGContext *s, TCGType type, unsigned vece, | ||
245 | TCGReg rd, TCGReg base, intptr_t offset) | ||
246 | { | ||
247 | - g_assert_not_reached(); | ||
248 | + if (vece == MO_64) { | ||
249 | + tcg_out_ld(s, TCG_TYPE_V64, rd, base, offset); | ||
250 | + if (type == TCG_TYPE_V128) { | ||
251 | + tcg_out_dup2_vec(s, rd, rd, rd); | ||
252 | + } | ||
253 | + } else { | ||
254 | + int q = type - TCG_TYPE_V64; | ||
255 | + tcg_out_vldst(s, INSN_VLD1R | (vece << 6) | (q << 5), | ||
256 | + rd, base, offset); | ||
257 | + } | ||
258 | + return true; | ||
259 | } | ||
260 | |||
261 | static void tcg_out_dupi_vec(TCGContext *s, TCGType type, unsigned vece, | ||
262 | TCGReg rd, int64_t v64) | ||
263 | { | ||
264 | - g_assert_not_reached(); | ||
265 | + int q = type - TCG_TYPE_V64; | ||
266 | + int cmode, imm8, i; | ||
267 | + | ||
268 | + /* Test all bytes equal first. */ | ||
269 | + if (vece == MO_8) { | ||
270 | + tcg_out_vmovi(s, rd, q, 0, 0xe, v64); | ||
271 | + return; | ||
272 | + } | ||
273 | + | ||
274 | + /* | ||
275 | + * Test all bytes 0x00 or 0xff second. This can match cases that | ||
276 | + * might otherwise take 2 or 3 insns for MO_16 or MO_32 below. | ||
277 | + */ | ||
278 | + for (i = imm8 = 0; i < 8; i++) { | ||
279 | + uint8_t byte = v64 >> (i * 8); | ||
280 | + if (byte == 0xff) { | ||
281 | + imm8 |= 1 << i; | ||
282 | + } else if (byte != 0) { | ||
283 | + goto fail_bytes; | ||
284 | + } | ||
285 | + } | ||
286 | + tcg_out_vmovi(s, rd, q, 1, 0xe, imm8); | ||
287 | + return; | ||
288 | + fail_bytes: | ||
289 | + | ||
290 | + /* | ||
291 | + * Tests for various replications. For each element width, if we | ||
292 | + * cannot find an expansion there's no point checking a larger | ||
293 | + * width because we already know by replication it cannot match. | ||
294 | + */ | ||
295 | + if (vece == MO_16) { | ||
296 | + uint16_t v16 = v64; | ||
297 | + | ||
298 | + if (is_shimm16(v16, &cmode, &imm8)) { | ||
299 | + tcg_out_vmovi(s, rd, q, 0, cmode, imm8); | ||
300 | + return; | ||
301 | + } | ||
302 | + if (is_shimm16(~v16, &cmode, &imm8)) { | ||
303 | + tcg_out_vmovi(s, rd, q, 1, cmode, imm8); | ||
304 | + return; | ||
305 | + } | ||
306 | + | ||
307 | + /* | ||
308 | + * Otherwise, all remaining constants can be loaded in two insns: | ||
309 | + * rd = v16 & 0xff, rd |= v16 & 0xff00. | ||
310 | + */ | ||
311 | + tcg_out_vmovi(s, rd, q, 0, 0x8, v16 & 0xff); | ||
312 | + tcg_out_vmovi(s, rd, q, 0, 0xb, v16 >> 8); /* VORRI */ | ||
313 | + return; | ||
314 | + } | ||
315 | + | ||
316 | + if (vece == MO_32) { | ||
317 | + uint32_t v32 = v64; | ||
318 | + | ||
319 | + if (is_shimm32(v32, &cmode, &imm8) || | ||
320 | + is_soimm32(v32, &cmode, &imm8)) { | ||
321 | + tcg_out_vmovi(s, rd, q, 0, cmode, imm8); | ||
322 | + return; | ||
323 | + } | ||
324 | + if (is_shimm32(~v32, &cmode, &imm8) || | ||
325 | + is_soimm32(~v32, &cmode, &imm8)) { | ||
326 | + tcg_out_vmovi(s, rd, q, 1, cmode, imm8); | ||
327 | + return; | ||
328 | + } | ||
329 | + | ||
330 | + /* | ||
331 | + * Restrict the set of constants to those we can load with | ||
332 | + * two instructions. Others we load from the pool. | ||
333 | + */ | ||
334 | + i = is_shimm32_pair(v32, &cmode, &imm8); | ||
335 | + if (i) { | ||
336 | + tcg_out_vmovi(s, rd, q, 0, cmode, imm8); | ||
337 | + tcg_out_vmovi(s, rd, q, 0, i | 1, extract32(v32, i * 4, 8)); | ||
338 | + return; | ||
339 | + } | ||
340 | + i = is_shimm32_pair(~v32, &cmode, &imm8); | ||
341 | + if (i) { | ||
342 | + tcg_out_vmovi(s, rd, q, 1, cmode, imm8); | ||
343 | + tcg_out_vmovi(s, rd, q, 1, i | 1, extract32(~v32, i * 4, 8)); | ||
344 | + return; | ||
345 | + } | ||
346 | + } | ||
347 | + | ||
348 | + /* | ||
349 | + * As a last resort, load from the constant pool. | ||
350 | + */ | ||
351 | + if (!q || vece == MO_64) { | ||
352 | + new_pool_l2(s, R_ARM_PC11, s->code_ptr, 0, v64, v64 >> 32); | ||
353 | + /* VLDR Dd, [pc + offset] */ | ||
354 | + tcg_out32(s, INSN_VLDR_D | encode_vd(rd) | (0xf << 16)); | ||
355 | + if (q) { | ||
356 | + tcg_out_dup2_vec(s, rd, rd, rd); | ||
357 | + } | ||
358 | + } else { | ||
359 | + new_pool_label(s, (uint32_t)v64, R_ARM_PC8, s->code_ptr, 0); | ||
360 | + /* add tmp, pc, offset */ | ||
361 | + tcg_out_dat_imm(s, COND_AL, ARITH_ADD, TCG_REG_TMP, TCG_REG_PC, 0); | ||
362 | + tcg_out_dupm_vec(s, type, MO_32, rd, TCG_REG_TMP, 0); | ||
363 | + } | ||
364 | } | ||
365 | |||
366 | static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, | ||
367 | -- | ||
368 | 2.25.1 | ||
369 | |||
370 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Implementing dup2, add, sub, and, or, xor as the minimal set. | ||
2 | This allows us to actually enable neon in the header file. | ||
1 | 3 | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | tcg/arm/tcg-target-con-set.h | 3 + | ||
8 | tcg/arm/tcg-target-con-str.h | 2 + | ||
9 | tcg/arm/tcg-target.h | 6 +- | ||
10 | tcg/arm/tcg-target.c.inc | 201 +++++++++++++++++++++++++++++++++-- | ||
11 | 4 files changed, 204 insertions(+), 8 deletions(-) | ||
12 | |||
13 | diff --git a/tcg/arm/tcg-target-con-set.h b/tcg/arm/tcg-target-con-set.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/tcg/arm/tcg-target-con-set.h | ||
16 | +++ b/tcg/arm/tcg-target-con-set.h | ||
17 | @@ -XXX,XX +XXX,XX @@ C_O1_I2(r, r, rIN) | ||
18 | C_O1_I2(r, r, ri) | ||
19 | C_O1_I2(r, rZ, rZ) | ||
20 | C_O1_I2(w, w, w) | ||
21 | +C_O1_I2(w, w, wO) | ||
22 | +C_O1_I2(w, w, wV) | ||
23 | +C_O1_I2(w, w, wZ) | ||
24 | C_O1_I4(r, r, r, rI, rI) | ||
25 | C_O1_I4(r, r, rIN, rIK, 0) | ||
26 | C_O2_I1(r, r, l) | ||
27 | diff --git a/tcg/arm/tcg-target-con-str.h b/tcg/arm/tcg-target-con-str.h | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/tcg/arm/tcg-target-con-str.h | ||
30 | +++ b/tcg/arm/tcg-target-con-str.h | ||
31 | @@ -XXX,XX +XXX,XX @@ REGS('w', ALL_VECTOR_REGS) | ||
32 | CONST('I', TCG_CT_CONST_ARM) | ||
33 | CONST('K', TCG_CT_CONST_INV) | ||
34 | CONST('N', TCG_CT_CONST_NEG) | ||
35 | +CONST('O', TCG_CT_CONST_ORRI) | ||
36 | +CONST('V', TCG_CT_CONST_ANDI) | ||
37 | CONST('Z', TCG_CT_CONST_ZERO) | ||
38 | diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/tcg/arm/tcg-target.h | ||
41 | +++ b/tcg/arm/tcg-target.h | ||
42 | @@ -XXX,XX +XXX,XX @@ typedef enum { | ||
43 | #else | ||
44 | extern bool use_idiv_instructions; | ||
45 | #endif | ||
46 | -#define use_neon_instructions 0 | ||
47 | +#ifdef __ARM_NEON__ | ||
48 | +#define use_neon_instructions 1 | ||
49 | +#else | ||
50 | +extern bool use_neon_instructions; | ||
51 | +#endif | ||
52 | |||
53 | /* used for function call generation */ | ||
54 | #define TCG_TARGET_STACK_ALIGN 8 | ||
55 | diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/tcg/arm/tcg-target.c.inc | ||
58 | +++ b/tcg/arm/tcg-target.c.inc | ||
59 | @@ -XXX,XX +XXX,XX @@ int arm_arch = __ARM_ARCH; | ||
60 | #ifndef use_idiv_instructions | ||
61 | bool use_idiv_instructions; | ||
62 | #endif | ||
63 | +#ifndef use_neon_instructions | ||
64 | +bool use_neon_instructions; | ||
65 | +#endif | ||
66 | |||
67 | /* ??? Ought to think about changing CONFIG_SOFTMMU to always defined. */ | ||
68 | #ifdef CONFIG_SOFTMMU | ||
69 | @@ -XXX,XX +XXX,XX @@ typedef enum { | ||
70 | /* Otherwise the assembler uses mov r0,r0 */ | ||
71 | INSN_NOP_v4 = (COND_AL << 28) | ARITH_MOV, | ||
72 | |||
73 | + INSN_VADD = 0xf2000800, | ||
74 | + INSN_VAND = 0xf2000110, | ||
75 | + INSN_VEOR = 0xf3000110, | ||
76 | INSN_VORR = 0xf2200110, | ||
77 | + INSN_VSUB = 0xf3000800, | ||
78 | + | ||
79 | + INSN_VMVN = 0xf3b00580, | ||
80 | + | ||
81 | + INSN_VCEQ0 = 0xf3b10100, | ||
82 | + INSN_VCGT0 = 0xf3b10000, | ||
83 | + INSN_VCGE0 = 0xf3b10080, | ||
84 | + INSN_VCLE0 = 0xf3b10180, | ||
85 | + INSN_VCLT0 = 0xf3b10200, | ||
86 | + | ||
87 | + INSN_VCEQ = 0xf3000810, | ||
88 | + INSN_VCGE = 0xf2000310, | ||
89 | + INSN_VCGT = 0xf2000300, | ||
90 | + INSN_VCGE_U = 0xf3000310, | ||
91 | + INSN_VCGT_U = 0xf3000300, | ||
92 | + | ||
93 | + INSN_VTST = 0xf2000810, | ||
94 | |||
95 | INSN_VDUP_G = 0xee800b10, /* VDUP (ARM core register) */ | ||
96 | INSN_VDUP_S = 0xf3b00c00, /* VDUP (scalar) */ | ||
97 | @@ -XXX,XX +XXX,XX @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
98 | #define TCG_CT_CONST_INV 0x200 | ||
99 | #define TCG_CT_CONST_NEG 0x400 | ||
100 | #define TCG_CT_CONST_ZERO 0x800 | ||
101 | +#define TCG_CT_CONST_ORRI 0x1000 | ||
102 | +#define TCG_CT_CONST_ANDI 0x2000 | ||
103 | |||
104 | #define ALL_GENERAL_REGS 0xffffu | ||
105 | #define ALL_VECTOR_REGS 0xffff0000u | ||
106 | @@ -XXX,XX +XXX,XX @@ static int is_shimm32_pair(uint32_t v32, int *cmode, int *imm8) | ||
107 | return i; | ||
108 | } | ||
109 | |||
110 | +/* Return true if V is a valid 16-bit or 32-bit shifted immediate. */ | ||
111 | +static bool is_shimm1632(uint32_t v32, int *cmode, int *imm8) | ||
112 | +{ | ||
113 | + if (v32 == deposit32(v32, 16, 16, v32)) { | ||
114 | + return is_shimm16(v32, cmode, imm8); | ||
115 | + } else { | ||
116 | + return is_shimm32(v32, cmode, imm8); | ||
117 | + } | ||
118 | +} | ||
119 | + | ||
120 | /* Test if a constant matches the constraint. | ||
121 | * TODO: define constraints for: | ||
122 | * | ||
123 | @@ -XXX,XX +XXX,XX @@ static bool tcg_target_const_match(int64_t val, TCGType type, int ct) | ||
124 | return 1; | ||
125 | } else if ((ct & TCG_CT_CONST_ZERO) && val == 0) { | ||
126 | return 1; | ||
127 | - } else { | ||
128 | - return 0; | ||
129 | } | ||
130 | + | ||
131 | + switch (ct & (TCG_CT_CONST_ORRI | TCG_CT_CONST_ANDI)) { | ||
132 | + case 0: | ||
133 | + break; | ||
134 | + case TCG_CT_CONST_ANDI: | ||
135 | + val = ~val; | ||
136 | + /* fallthru */ | ||
137 | + case TCG_CT_CONST_ORRI: | ||
138 | + if (val == deposit64(val, 32, 32, val)) { | ||
139 | + int cmode, imm8; | ||
140 | + return is_shimm1632(val, &cmode, &imm8); | ||
141 | + } | ||
142 | + break; | ||
143 | + default: | ||
144 | + /* Both bits should not be set for the same insn. */ | ||
145 | + g_assert_not_reached(); | ||
146 | + } | ||
147 | + | ||
148 | + return 0; | ||
149 | } | ||
150 | |||
151 | static inline void tcg_out_b(TCGContext *s, int cond, int32_t offset) | ||
152 | @@ -XXX,XX +XXX,XX @@ static uint32_t encode_vm(TCGReg rm) | ||
153 | return (extract32(rm, 3, 1) << 5) | (extract32(rm, 0, 3) << 1); | ||
154 | } | ||
155 | |||
156 | +static void tcg_out_vreg2(TCGContext *s, ARMInsn insn, int q, int vece, | ||
157 | + TCGReg d, TCGReg m) | ||
158 | +{ | ||
159 | + tcg_out32(s, insn | (vece << 18) | (q << 6) | | ||
160 | + encode_vd(d) | encode_vm(m)); | ||
161 | +} | ||
162 | + | ||
163 | static void tcg_out_vreg3(TCGContext *s, ARMInsn insn, int q, int vece, | ||
164 | TCGReg d, TCGReg n, TCGReg m) | ||
165 | { | ||
166 | @@ -XXX,XX +XXX,XX @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) | ||
167 | case INDEX_op_add_vec: | ||
168 | case INDEX_op_sub_vec: | ||
169 | case INDEX_op_xor_vec: | ||
170 | - case INDEX_op_or_vec: | ||
171 | - case INDEX_op_and_vec: | ||
172 | - case INDEX_op_cmp_vec: | ||
173 | return C_O1_I2(w, w, w); | ||
174 | + case INDEX_op_or_vec: | ||
175 | + return C_O1_I2(w, w, wO); | ||
176 | + case INDEX_op_and_vec: | ||
177 | + return C_O1_I2(w, w, wV); | ||
178 | + case INDEX_op_cmp_vec: | ||
179 | + return C_O1_I2(w, w, wZ); | ||
180 | |||
181 | default: | ||
182 | g_assert_not_reached(); | ||
183 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_dupi_vec(TCGContext *s, TCGType type, unsigned vece, | ||
184 | } | ||
185 | } | ||
186 | |||
187 | +static const ARMInsn vec_cmp_insn[16] = { | ||
188 | + [TCG_COND_EQ] = INSN_VCEQ, | ||
189 | + [TCG_COND_GT] = INSN_VCGT, | ||
190 | + [TCG_COND_GE] = INSN_VCGE, | ||
191 | + [TCG_COND_GTU] = INSN_VCGT_U, | ||
192 | + [TCG_COND_GEU] = INSN_VCGE_U, | ||
193 | +}; | ||
194 | + | ||
195 | +static const ARMInsn vec_cmp0_insn[16] = { | ||
196 | + [TCG_COND_EQ] = INSN_VCEQ0, | ||
197 | + [TCG_COND_GT] = INSN_VCGT0, | ||
198 | + [TCG_COND_GE] = INSN_VCGE0, | ||
199 | + [TCG_COND_LT] = INSN_VCLT0, | ||
200 | + [TCG_COND_LE] = INSN_VCLE0, | ||
201 | +}; | ||
202 | + | ||
203 | static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, | ||
204 | unsigned vecl, unsigned vece, | ||
205 | const TCGArg *args, const int *const_args) | ||
206 | { | ||
207 | - g_assert_not_reached(); | ||
208 | + TCGType type = vecl + TCG_TYPE_V64; | ||
209 | + unsigned q = vecl; | ||
210 | + TCGArg a0, a1, a2; | ||
211 | + int cmode, imm8; | ||
212 | + | ||
213 | + a0 = args[0]; | ||
214 | + a1 = args[1]; | ||
215 | + a2 = args[2]; | ||
216 | + | ||
217 | + switch (opc) { | ||
218 | + case INDEX_op_ld_vec: | ||
219 | + tcg_out_ld(s, type, a0, a1, a2); | ||
220 | + return; | ||
221 | + case INDEX_op_st_vec: | ||
222 | + tcg_out_st(s, type, a0, a1, a2); | ||
223 | + return; | ||
224 | + case INDEX_op_dupm_vec: | ||
225 | + tcg_out_dupm_vec(s, type, vece, a0, a1, a2); | ||
226 | + return; | ||
227 | + case INDEX_op_dup2_vec: | ||
228 | + tcg_out_dup2_vec(s, a0, a1, a2); | ||
229 | + return; | ||
230 | + case INDEX_op_add_vec: | ||
231 | + tcg_out_vreg3(s, INSN_VADD, q, vece, a0, a1, a2); | ||
232 | + return; | ||
233 | + case INDEX_op_sub_vec: | ||
234 | + tcg_out_vreg3(s, INSN_VSUB, q, vece, a0, a1, a2); | ||
235 | + return; | ||
236 | + case INDEX_op_xor_vec: | ||
237 | + tcg_out_vreg3(s, INSN_VEOR, q, 0, a0, a1, a2); | ||
238 | + return; | ||
239 | + | ||
240 | + case INDEX_op_and_vec: | ||
241 | + if (const_args[2]) { | ||
242 | + is_shimm1632(~a2, &cmode, &imm8); | ||
243 | + if (a0 == a1) { | ||
244 | + tcg_out_vmovi(s, a0, q, 1, cmode | 1, imm8); /* VBICI */ | ||
245 | + return; | ||
246 | + } | ||
247 | + tcg_out_vmovi(s, a0, q, 1, cmode, imm8); /* VMVNI */ | ||
248 | + a2 = a0; | ||
249 | + } | ||
250 | + tcg_out_vreg3(s, INSN_VAND, q, 0, a0, a1, a2); | ||
251 | + return; | ||
252 | + | ||
253 | + case INDEX_op_or_vec: | ||
254 | + if (const_args[2]) { | ||
255 | + is_shimm1632(a2, &cmode, &imm8); | ||
256 | + if (a0 == a1) { | ||
257 | + tcg_out_vmovi(s, a0, q, 0, cmode | 1, imm8); /* VORRI */ | ||
258 | + return; | ||
259 | + } | ||
260 | + tcg_out_vmovi(s, a0, q, 0, cmode, imm8); /* VMOVI */ | ||
261 | + a2 = a0; | ||
262 | + } | ||
263 | + tcg_out_vreg3(s, INSN_VORR, q, 0, a0, a1, a2); | ||
264 | + return; | ||
265 | + | ||
266 | + case INDEX_op_cmp_vec: | ||
267 | + { | ||
268 | + TCGCond cond = args[3]; | ||
269 | + | ||
270 | + if (cond == TCG_COND_NE) { | ||
271 | + if (const_args[2]) { | ||
272 | + tcg_out_vreg3(s, INSN_VTST, q, vece, a0, a1, a1); | ||
273 | + } else { | ||
274 | + tcg_out_vreg3(s, INSN_VCEQ, q, vece, a0, a1, a2); | ||
275 | + tcg_out_vreg2(s, INSN_VMVN, q, 0, a0, a0); | ||
276 | + } | ||
277 | + } else { | ||
278 | + ARMInsn insn; | ||
279 | + | ||
280 | + if (const_args[2]) { | ||
281 | + insn = vec_cmp0_insn[cond]; | ||
282 | + if (insn) { | ||
283 | + tcg_out_vreg2(s, insn, q, vece, a0, a1); | ||
284 | + return; | ||
285 | + } | ||
286 | + tcg_out_dupi_vec(s, type, MO_8, TCG_VEC_TMP, 0); | ||
287 | + a2 = TCG_VEC_TMP; | ||
288 | + } | ||
289 | + insn = vec_cmp_insn[cond]; | ||
290 | + if (insn == 0) { | ||
291 | + TCGArg t; | ||
292 | + t = a1, a1 = a2, a2 = t; | ||
293 | + cond = tcg_swap_cond(cond); | ||
294 | + insn = vec_cmp_insn[cond]; | ||
295 | + tcg_debug_assert(insn != 0); | ||
296 | + } | ||
297 | + tcg_out_vreg3(s, insn, q, vece, a0, a1, a2); | ||
298 | + } | ||
299 | + } | ||
300 | + return; | ||
301 | + | ||
302 | + case INDEX_op_mov_vec: /* Always emitted via tcg_out_mov. */ | ||
303 | + case INDEX_op_dup_vec: /* Always emitted via tcg_out_dup_vec. */ | ||
304 | + default: | ||
305 | + g_assert_not_reached(); | ||
306 | + } | ||
307 | } | ||
308 | |||
309 | int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) | ||
310 | { | ||
311 | - return 0; | ||
312 | + switch (opc) { | ||
313 | + case INDEX_op_add_vec: | ||
314 | + case INDEX_op_sub_vec: | ||
315 | + case INDEX_op_and_vec: | ||
316 | + case INDEX_op_or_vec: | ||
317 | + case INDEX_op_xor_vec: | ||
318 | + return 1; | ||
319 | + case INDEX_op_cmp_vec: | ||
320 | + return vece < MO_64; | ||
321 | + default: | ||
322 | + return 0; | ||
323 | + } | ||
324 | } | ||
325 | |||
326 | void tcg_expand_vec_op(TCGOpcode opc, TCGType type, unsigned vece, | ||
327 | -- | ||
328 | 2.25.1 | ||
329 | |||
330 | diff view generated by jsdifflib |
1 | From: lixinyu <precinct@mail.ustc.edu.cn> | 1 | These logical and arithmetic operations are optional, but are |
---|---|---|---|
2 | trivial to accomplish with the existing infrastructure. | ||
2 | 3 | ||
3 | OPC_SYNC_WMB, OPC_SYNC_MB, OPC_SYNC_ACQUIRE, OPC_SYNC_RELEASE and | 4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
4 | OPC_SYNC_RMB have wrong encode. According to the mips manual, | ||
5 | their encode should be 'OPC_SYNC | 0x?? << 6' rather than | ||
6 | 'OPC_SYNC | 0x?? << 5'. Wrong encode can lead illegal instruction | ||
7 | errors. These instructions often appear with multi-threaded | ||
8 | simulation. | ||
9 | |||
10 | Fixes: 6f0b99104a3 ("tcg/mips: Add support for fence") | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Reviewed-by: Aleksandar Markovic <aleksandar.qemu.devel@gmail.com> | ||
13 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
14 | Signed-off-by: lixinyu <precinct@mail.ustc.edu.cn> | ||
15 | Message-Id: <20200411124612.12560-1-precinct@mail.ustc.edu.cn> | ||
16 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
17 | --- | 6 | --- |
18 | tcg/mips/tcg-target.inc.c | 10 +++++----- | 7 | tcg/arm/tcg-target-con-set.h | 1 + |
19 | 1 file changed, 5 insertions(+), 5 deletions(-) | 8 | tcg/arm/tcg-target.h | 10 +++++----- |
9 | tcg/arm/tcg-target.c.inc | 38 ++++++++++++++++++++++++++++++++++++ | ||
10 | 3 files changed, 44 insertions(+), 5 deletions(-) | ||
20 | 11 | ||
21 | diff --git a/tcg/mips/tcg-target.inc.c b/tcg/mips/tcg-target.inc.c | 12 | diff --git a/tcg/arm/tcg-target-con-set.h b/tcg/arm/tcg-target-con-set.h |
22 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/tcg/mips/tcg-target.inc.c | 14 | --- a/tcg/arm/tcg-target-con-set.h |
24 | +++ b/tcg/mips/tcg-target.inc.c | 15 | +++ b/tcg/arm/tcg-target-con-set.h |
16 | @@ -XXX,XX +XXX,XX @@ C_O0_I4(s, s, s, s) | ||
17 | C_O1_I1(r, l) | ||
18 | C_O1_I1(r, r) | ||
19 | C_O1_I1(w, r) | ||
20 | +C_O1_I1(w, w) | ||
21 | C_O1_I1(w, wr) | ||
22 | C_O1_I2(r, 0, rZ) | ||
23 | C_O1_I2(r, l, l) | ||
24 | diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/tcg/arm/tcg-target.h | ||
27 | +++ b/tcg/arm/tcg-target.h | ||
28 | @@ -XXX,XX +XXX,XX @@ extern bool use_neon_instructions; | ||
29 | #define TCG_TARGET_HAS_v128 use_neon_instructions | ||
30 | #define TCG_TARGET_HAS_v256 0 | ||
31 | |||
32 | -#define TCG_TARGET_HAS_andc_vec 0 | ||
33 | -#define TCG_TARGET_HAS_orc_vec 0 | ||
34 | -#define TCG_TARGET_HAS_not_vec 0 | ||
35 | -#define TCG_TARGET_HAS_neg_vec 0 | ||
36 | -#define TCG_TARGET_HAS_abs_vec 0 | ||
37 | +#define TCG_TARGET_HAS_andc_vec 1 | ||
38 | +#define TCG_TARGET_HAS_orc_vec 1 | ||
39 | +#define TCG_TARGET_HAS_not_vec 1 | ||
40 | +#define TCG_TARGET_HAS_neg_vec 1 | ||
41 | +#define TCG_TARGET_HAS_abs_vec 1 | ||
42 | #define TCG_TARGET_HAS_roti_vec 0 | ||
43 | #define TCG_TARGET_HAS_rots_vec 0 | ||
44 | #define TCG_TARGET_HAS_rotv_vec 0 | ||
45 | diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/tcg/arm/tcg-target.c.inc | ||
48 | +++ b/tcg/arm/tcg-target.c.inc | ||
25 | @@ -XXX,XX +XXX,XX @@ typedef enum { | 49 | @@ -XXX,XX +XXX,XX @@ typedef enum { |
26 | 50 | ||
27 | /* MIPS r6 introduced names for weaker variants of SYNC. These are | 51 | INSN_VADD = 0xf2000800, |
28 | backward compatible to previous architecture revisions. */ | 52 | INSN_VAND = 0xf2000110, |
29 | - OPC_SYNC_WMB = OPC_SYNC | 0x04 << 5, | 53 | + INSN_VBIC = 0xf2100110, |
30 | - OPC_SYNC_MB = OPC_SYNC | 0x10 << 5, | 54 | INSN_VEOR = 0xf3000110, |
31 | - OPC_SYNC_ACQUIRE = OPC_SYNC | 0x11 << 5, | 55 | + INSN_VORN = 0xf2300110, |
32 | - OPC_SYNC_RELEASE = OPC_SYNC | 0x12 << 5, | 56 | INSN_VORR = 0xf2200110, |
33 | - OPC_SYNC_RMB = OPC_SYNC | 0x13 << 5, | 57 | INSN_VSUB = 0xf3000800, |
34 | + OPC_SYNC_WMB = OPC_SYNC | 0x04 << 6, | 58 | |
35 | + OPC_SYNC_MB = OPC_SYNC | 0x10 << 6, | 59 | + INSN_VABS = 0xf3b10300, |
36 | + OPC_SYNC_ACQUIRE = OPC_SYNC | 0x11 << 6, | 60 | INSN_VMVN = 0xf3b00580, |
37 | + OPC_SYNC_RELEASE = OPC_SYNC | 0x12 << 6, | 61 | + INSN_VNEG = 0xf3b10380, |
38 | + OPC_SYNC_RMB = OPC_SYNC | 0x13 << 6, | 62 | |
39 | 63 | INSN_VCEQ0 = 0xf3b10100, | |
40 | /* Aliases for convenience. */ | 64 | INSN_VCGT0 = 0xf3b10000, |
41 | ALIAS_PADD = sizeof(void *) == 4 ? OPC_ADDU : OPC_DADDU, | 65 | @@ -XXX,XX +XXX,XX @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) |
66 | return C_O1_I1(w, r); | ||
67 | case INDEX_op_dup_vec: | ||
68 | return C_O1_I1(w, wr); | ||
69 | + case INDEX_op_abs_vec: | ||
70 | + case INDEX_op_neg_vec: | ||
71 | + case INDEX_op_not_vec: | ||
72 | + return C_O1_I1(w, w); | ||
73 | case INDEX_op_dup2_vec: | ||
74 | case INDEX_op_add_vec: | ||
75 | case INDEX_op_sub_vec: | ||
76 | case INDEX_op_xor_vec: | ||
77 | return C_O1_I2(w, w, w); | ||
78 | case INDEX_op_or_vec: | ||
79 | + case INDEX_op_andc_vec: | ||
80 | return C_O1_I2(w, w, wO); | ||
81 | case INDEX_op_and_vec: | ||
82 | + case INDEX_op_orc_vec: | ||
83 | return C_O1_I2(w, w, wV); | ||
84 | case INDEX_op_cmp_vec: | ||
85 | return C_O1_I2(w, w, wZ); | ||
86 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, | ||
87 | case INDEX_op_dup2_vec: | ||
88 | tcg_out_dup2_vec(s, a0, a1, a2); | ||
89 | return; | ||
90 | + case INDEX_op_abs_vec: | ||
91 | + tcg_out_vreg2(s, INSN_VABS, q, vece, a0, a1); | ||
92 | + return; | ||
93 | + case INDEX_op_neg_vec: | ||
94 | + tcg_out_vreg2(s, INSN_VNEG, q, vece, a0, a1); | ||
95 | + return; | ||
96 | + case INDEX_op_not_vec: | ||
97 | + tcg_out_vreg2(s, INSN_VMVN, q, 0, a0, a1); | ||
98 | + return; | ||
99 | case INDEX_op_add_vec: | ||
100 | tcg_out_vreg3(s, INSN_VADD, q, vece, a0, a1, a2); | ||
101 | return; | ||
102 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, | ||
103 | tcg_out_vreg3(s, INSN_VEOR, q, 0, a0, a1, a2); | ||
104 | return; | ||
105 | |||
106 | + case INDEX_op_andc_vec: | ||
107 | + if (!const_args[2]) { | ||
108 | + tcg_out_vreg3(s, INSN_VBIC, q, 0, a0, a1, a2); | ||
109 | + return; | ||
110 | + } | ||
111 | + a2 = ~a2; | ||
112 | + /* fall through */ | ||
113 | case INDEX_op_and_vec: | ||
114 | if (const_args[2]) { | ||
115 | is_shimm1632(~a2, &cmode, &imm8); | ||
116 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, | ||
117 | tcg_out_vreg3(s, INSN_VAND, q, 0, a0, a1, a2); | ||
118 | return; | ||
119 | |||
120 | + case INDEX_op_orc_vec: | ||
121 | + if (!const_args[2]) { | ||
122 | + tcg_out_vreg3(s, INSN_VORN, q, 0, a0, a1, a2); | ||
123 | + return; | ||
124 | + } | ||
125 | + a2 = ~a2; | ||
126 | + /* fall through */ | ||
127 | case INDEX_op_or_vec: | ||
128 | if (const_args[2]) { | ||
129 | is_shimm1632(a2, &cmode, &imm8); | ||
130 | @@ -XXX,XX +XXX,XX @@ int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) | ||
131 | case INDEX_op_add_vec: | ||
132 | case INDEX_op_sub_vec: | ||
133 | case INDEX_op_and_vec: | ||
134 | + case INDEX_op_andc_vec: | ||
135 | case INDEX_op_or_vec: | ||
136 | + case INDEX_op_orc_vec: | ||
137 | case INDEX_op_xor_vec: | ||
138 | + case INDEX_op_not_vec: | ||
139 | return 1; | ||
140 | + case INDEX_op_abs_vec: | ||
141 | case INDEX_op_cmp_vec: | ||
142 | + case INDEX_op_neg_vec: | ||
143 | return vece < MO_64; | ||
144 | default: | ||
145 | return 0; | ||
42 | -- | 146 | -- |
43 | 2.20.1 | 147 | 2.25.1 |
44 | 148 | ||
45 | 149 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | This consists of the three immediate shifts: shli, shri, sari. | ||
1 | 2 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | --- | ||
6 | tcg/arm/tcg-target.h | 2 +- | ||
7 | tcg/arm/tcg-target.c.inc | 27 +++++++++++++++++++++++++++ | ||
8 | 2 files changed, 28 insertions(+), 1 deletion(-) | ||
9 | |||
10 | diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/tcg/arm/tcg-target.h | ||
13 | +++ b/tcg/arm/tcg-target.h | ||
14 | @@ -XXX,XX +XXX,XX @@ extern bool use_neon_instructions; | ||
15 | #define TCG_TARGET_HAS_roti_vec 0 | ||
16 | #define TCG_TARGET_HAS_rots_vec 0 | ||
17 | #define TCG_TARGET_HAS_rotv_vec 0 | ||
18 | -#define TCG_TARGET_HAS_shi_vec 0 | ||
19 | +#define TCG_TARGET_HAS_shi_vec 1 | ||
20 | #define TCG_TARGET_HAS_shs_vec 0 | ||
21 | #define TCG_TARGET_HAS_shv_vec 0 | ||
22 | #define TCG_TARGET_HAS_mul_vec 0 | ||
23 | diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/tcg/arm/tcg-target.c.inc | ||
26 | +++ b/tcg/arm/tcg-target.c.inc | ||
27 | @@ -XXX,XX +XXX,XX @@ typedef enum { | ||
28 | INSN_VCGE_U = 0xf3000310, | ||
29 | INSN_VCGT_U = 0xf3000300, | ||
30 | |||
31 | + INSN_VSHLI = 0xf2800510, /* VSHL (immediate) */ | ||
32 | + INSN_VSARI = 0xf2800010, /* VSHR.S */ | ||
33 | + INSN_VSHRI = 0xf3800010, /* VSHR.U */ | ||
34 | + | ||
35 | INSN_VTST = 0xf2000810, | ||
36 | |||
37 | INSN_VDUP_G = 0xee800b10, /* VDUP (ARM core register) */ | ||
38 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_vmovi(TCGContext *s, TCGReg rd, | ||
39 | | (extract32(imm8, 7, 1) << 24)); | ||
40 | } | ||
41 | |||
42 | +static void tcg_out_vshifti(TCGContext *s, ARMInsn insn, int q, | ||
43 | + TCGReg rd, TCGReg rm, int l_imm6) | ||
44 | +{ | ||
45 | + tcg_out32(s, insn | (q << 6) | encode_vd(rd) | encode_vm(rm) | | ||
46 | + (extract32(l_imm6, 6, 1) << 7) | | ||
47 | + (extract32(l_imm6, 0, 6) << 16)); | ||
48 | +} | ||
49 | + | ||
50 | static void tcg_out_vldst(TCGContext *s, ARMInsn insn, | ||
51 | TCGReg rd, TCGReg rn, int offset) | ||
52 | { | ||
53 | @@ -XXX,XX +XXX,XX @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) | ||
54 | case INDEX_op_abs_vec: | ||
55 | case INDEX_op_neg_vec: | ||
56 | case INDEX_op_not_vec: | ||
57 | + case INDEX_op_shli_vec: | ||
58 | + case INDEX_op_shri_vec: | ||
59 | + case INDEX_op_sari_vec: | ||
60 | return C_O1_I1(w, w); | ||
61 | case INDEX_op_dup2_vec: | ||
62 | case INDEX_op_add_vec: | ||
63 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, | ||
64 | case INDEX_op_xor_vec: | ||
65 | tcg_out_vreg3(s, INSN_VEOR, q, 0, a0, a1, a2); | ||
66 | return; | ||
67 | + case INDEX_op_shli_vec: | ||
68 | + tcg_out_vshifti(s, INSN_VSHLI, q, a0, a1, a2 + (8 << vece)); | ||
69 | + return; | ||
70 | + case INDEX_op_shri_vec: | ||
71 | + tcg_out_vshifti(s, INSN_VSHRI, q, a0, a1, (16 << vece) - a2); | ||
72 | + return; | ||
73 | + case INDEX_op_sari_vec: | ||
74 | + tcg_out_vshifti(s, INSN_VSARI, q, a0, a1, (16 << vece) - a2); | ||
75 | + return; | ||
76 | |||
77 | case INDEX_op_andc_vec: | ||
78 | if (!const_args[2]) { | ||
79 | @@ -XXX,XX +XXX,XX @@ int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) | ||
80 | case INDEX_op_orc_vec: | ||
81 | case INDEX_op_xor_vec: | ||
82 | case INDEX_op_not_vec: | ||
83 | + case INDEX_op_shli_vec: | ||
84 | + case INDEX_op_shri_vec: | ||
85 | + case INDEX_op_sari_vec: | ||
86 | return 1; | ||
87 | case INDEX_op_abs_vec: | ||
88 | case INDEX_op_cmp_vec: | ||
89 | -- | ||
90 | 2.25.1 | ||
91 | |||
92 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
2 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | --- | ||
4 | tcg/arm/tcg-target.h | 2 +- | ||
5 | tcg/arm/tcg-target.c.inc | 6 ++++++ | ||
6 | 2 files changed, 7 insertions(+), 1 deletion(-) | ||
1 | 7 | ||
8 | diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h | ||
9 | index XXXXXXX..XXXXXXX 100644 | ||
10 | --- a/tcg/arm/tcg-target.h | ||
11 | +++ b/tcg/arm/tcg-target.h | ||
12 | @@ -XXX,XX +XXX,XX @@ extern bool use_neon_instructions; | ||
13 | #define TCG_TARGET_HAS_shi_vec 1 | ||
14 | #define TCG_TARGET_HAS_shs_vec 0 | ||
15 | #define TCG_TARGET_HAS_shv_vec 0 | ||
16 | -#define TCG_TARGET_HAS_mul_vec 0 | ||
17 | +#define TCG_TARGET_HAS_mul_vec 1 | ||
18 | #define TCG_TARGET_HAS_sat_vec 0 | ||
19 | #define TCG_TARGET_HAS_minmax_vec 0 | ||
20 | #define TCG_TARGET_HAS_bitsel_vec 0 | ||
21 | diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/tcg/arm/tcg-target.c.inc | ||
24 | +++ b/tcg/arm/tcg-target.c.inc | ||
25 | @@ -XXX,XX +XXX,XX @@ typedef enum { | ||
26 | INSN_VORN = 0xf2300110, | ||
27 | INSN_VORR = 0xf2200110, | ||
28 | INSN_VSUB = 0xf3000800, | ||
29 | + INSN_VMUL = 0xf2000910, | ||
30 | |||
31 | INSN_VABS = 0xf3b10300, | ||
32 | INSN_VMVN = 0xf3b00580, | ||
33 | @@ -XXX,XX +XXX,XX @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) | ||
34 | return C_O1_I1(w, w); | ||
35 | case INDEX_op_dup2_vec: | ||
36 | case INDEX_op_add_vec: | ||
37 | + case INDEX_op_mul_vec: | ||
38 | case INDEX_op_sub_vec: | ||
39 | case INDEX_op_xor_vec: | ||
40 | return C_O1_I2(w, w, w); | ||
41 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, | ||
42 | case INDEX_op_add_vec: | ||
43 | tcg_out_vreg3(s, INSN_VADD, q, vece, a0, a1, a2); | ||
44 | return; | ||
45 | + case INDEX_op_mul_vec: | ||
46 | + tcg_out_vreg3(s, INSN_VMUL, q, vece, a0, a1, a2); | ||
47 | + return; | ||
48 | case INDEX_op_sub_vec: | ||
49 | tcg_out_vreg3(s, INSN_VSUB, q, vece, a0, a1, a2); | ||
50 | return; | ||
51 | @@ -XXX,XX +XXX,XX @@ int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) | ||
52 | return 1; | ||
53 | case INDEX_op_abs_vec: | ||
54 | case INDEX_op_cmp_vec: | ||
55 | + case INDEX_op_mul_vec: | ||
56 | case INDEX_op_neg_vec: | ||
57 | return vece < MO_64; | ||
58 | default: | ||
59 | -- | ||
60 | 2.25.1 | ||
61 | |||
62 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | This is saturating add and subtract, signed and unsigned. | ||
1 | 2 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | --- | ||
6 | tcg/arm/tcg-target.h | 2 +- | ||
7 | tcg/arm/tcg-target.c.inc | 24 ++++++++++++++++++++++++ | ||
8 | 2 files changed, 25 insertions(+), 1 deletion(-) | ||
9 | |||
10 | diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/tcg/arm/tcg-target.h | ||
13 | +++ b/tcg/arm/tcg-target.h | ||
14 | @@ -XXX,XX +XXX,XX @@ extern bool use_neon_instructions; | ||
15 | #define TCG_TARGET_HAS_shs_vec 0 | ||
16 | #define TCG_TARGET_HAS_shv_vec 0 | ||
17 | #define TCG_TARGET_HAS_mul_vec 1 | ||
18 | -#define TCG_TARGET_HAS_sat_vec 0 | ||
19 | +#define TCG_TARGET_HAS_sat_vec 1 | ||
20 | #define TCG_TARGET_HAS_minmax_vec 0 | ||
21 | #define TCG_TARGET_HAS_bitsel_vec 0 | ||
22 | #define TCG_TARGET_HAS_cmpsel_vec 0 | ||
23 | diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/tcg/arm/tcg-target.c.inc | ||
26 | +++ b/tcg/arm/tcg-target.c.inc | ||
27 | @@ -XXX,XX +XXX,XX @@ typedef enum { | ||
28 | INSN_VORR = 0xf2200110, | ||
29 | INSN_VSUB = 0xf3000800, | ||
30 | INSN_VMUL = 0xf2000910, | ||
31 | + INSN_VQADD = 0xf2000010, | ||
32 | + INSN_VQADD_U = 0xf3000010, | ||
33 | + INSN_VQSUB = 0xf2000210, | ||
34 | + INSN_VQSUB_U = 0xf3000210, | ||
35 | |||
36 | INSN_VABS = 0xf3b10300, | ||
37 | INSN_VMVN = 0xf3b00580, | ||
38 | @@ -XXX,XX +XXX,XX @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) | ||
39 | case INDEX_op_dup2_vec: | ||
40 | case INDEX_op_add_vec: | ||
41 | case INDEX_op_mul_vec: | ||
42 | + case INDEX_op_ssadd_vec: | ||
43 | + case INDEX_op_sssub_vec: | ||
44 | case INDEX_op_sub_vec: | ||
45 | + case INDEX_op_usadd_vec: | ||
46 | + case INDEX_op_ussub_vec: | ||
47 | case INDEX_op_xor_vec: | ||
48 | return C_O1_I2(w, w, w); | ||
49 | case INDEX_op_or_vec: | ||
50 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, | ||
51 | case INDEX_op_sub_vec: | ||
52 | tcg_out_vreg3(s, INSN_VSUB, q, vece, a0, a1, a2); | ||
53 | return; | ||
54 | + case INDEX_op_ssadd_vec: | ||
55 | + tcg_out_vreg3(s, INSN_VQADD, q, vece, a0, a1, a2); | ||
56 | + return; | ||
57 | + case INDEX_op_sssub_vec: | ||
58 | + tcg_out_vreg3(s, INSN_VQSUB, q, vece, a0, a1, a2); | ||
59 | + return; | ||
60 | + case INDEX_op_usadd_vec: | ||
61 | + tcg_out_vreg3(s, INSN_VQADD_U, q, vece, a0, a1, a2); | ||
62 | + return; | ||
63 | + case INDEX_op_ussub_vec: | ||
64 | + tcg_out_vreg3(s, INSN_VQSUB_U, q, vece, a0, a1, a2); | ||
65 | + return; | ||
66 | case INDEX_op_xor_vec: | ||
67 | tcg_out_vreg3(s, INSN_VEOR, q, 0, a0, a1, a2); | ||
68 | return; | ||
69 | @@ -XXX,XX +XXX,XX @@ int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) | ||
70 | case INDEX_op_shli_vec: | ||
71 | case INDEX_op_shri_vec: | ||
72 | case INDEX_op_sari_vec: | ||
73 | + case INDEX_op_ssadd_vec: | ||
74 | + case INDEX_op_sssub_vec: | ||
75 | + case INDEX_op_usadd_vec: | ||
76 | + case INDEX_op_ussub_vec: | ||
77 | return 1; | ||
78 | case INDEX_op_abs_vec: | ||
79 | case INDEX_op_cmp_vec: | ||
80 | -- | ||
81 | 2.25.1 | ||
82 | |||
83 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | This is minimum and maximum, signed and unsigned. | ||
1 | 2 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | --- | ||
6 | tcg/arm/tcg-target.h | 2 +- | ||
7 | tcg/arm/tcg-target.c.inc | 24 ++++++++++++++++++++++++ | ||
8 | 2 files changed, 25 insertions(+), 1 deletion(-) | ||
9 | |||
10 | diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/tcg/arm/tcg-target.h | ||
13 | +++ b/tcg/arm/tcg-target.h | ||
14 | @@ -XXX,XX +XXX,XX @@ extern bool use_neon_instructions; | ||
15 | #define TCG_TARGET_HAS_shv_vec 0 | ||
16 | #define TCG_TARGET_HAS_mul_vec 1 | ||
17 | #define TCG_TARGET_HAS_sat_vec 1 | ||
18 | -#define TCG_TARGET_HAS_minmax_vec 0 | ||
19 | +#define TCG_TARGET_HAS_minmax_vec 1 | ||
20 | #define TCG_TARGET_HAS_bitsel_vec 0 | ||
21 | #define TCG_TARGET_HAS_cmpsel_vec 0 | ||
22 | |||
23 | diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/tcg/arm/tcg-target.c.inc | ||
26 | +++ b/tcg/arm/tcg-target.c.inc | ||
27 | @@ -XXX,XX +XXX,XX @@ typedef enum { | ||
28 | INSN_VQADD_U = 0xf3000010, | ||
29 | INSN_VQSUB = 0xf2000210, | ||
30 | INSN_VQSUB_U = 0xf3000210, | ||
31 | + INSN_VMAX = 0xf2000600, | ||
32 | + INSN_VMAX_U = 0xf3000600, | ||
33 | + INSN_VMIN = 0xf2000610, | ||
34 | + INSN_VMIN_U = 0xf3000610, | ||
35 | |||
36 | INSN_VABS = 0xf3b10300, | ||
37 | INSN_VMVN = 0xf3b00580, | ||
38 | @@ -XXX,XX +XXX,XX @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) | ||
39 | case INDEX_op_dup2_vec: | ||
40 | case INDEX_op_add_vec: | ||
41 | case INDEX_op_mul_vec: | ||
42 | + case INDEX_op_smax_vec: | ||
43 | + case INDEX_op_smin_vec: | ||
44 | case INDEX_op_ssadd_vec: | ||
45 | case INDEX_op_sssub_vec: | ||
46 | case INDEX_op_sub_vec: | ||
47 | + case INDEX_op_umax_vec: | ||
48 | + case INDEX_op_umin_vec: | ||
49 | case INDEX_op_usadd_vec: | ||
50 | case INDEX_op_ussub_vec: | ||
51 | case INDEX_op_xor_vec: | ||
52 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, | ||
53 | case INDEX_op_mul_vec: | ||
54 | tcg_out_vreg3(s, INSN_VMUL, q, vece, a0, a1, a2); | ||
55 | return; | ||
56 | + case INDEX_op_smax_vec: | ||
57 | + tcg_out_vreg3(s, INSN_VMAX, q, vece, a0, a1, a2); | ||
58 | + return; | ||
59 | + case INDEX_op_smin_vec: | ||
60 | + tcg_out_vreg3(s, INSN_VMIN, q, vece, a0, a1, a2); | ||
61 | + return; | ||
62 | case INDEX_op_sub_vec: | ||
63 | tcg_out_vreg3(s, INSN_VSUB, q, vece, a0, a1, a2); | ||
64 | return; | ||
65 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, | ||
66 | case INDEX_op_sssub_vec: | ||
67 | tcg_out_vreg3(s, INSN_VQSUB, q, vece, a0, a1, a2); | ||
68 | return; | ||
69 | + case INDEX_op_umax_vec: | ||
70 | + tcg_out_vreg3(s, INSN_VMAX_U, q, vece, a0, a1, a2); | ||
71 | + return; | ||
72 | + case INDEX_op_umin_vec: | ||
73 | + tcg_out_vreg3(s, INSN_VMIN_U, q, vece, a0, a1, a2); | ||
74 | + return; | ||
75 | case INDEX_op_usadd_vec: | ||
76 | tcg_out_vreg3(s, INSN_VQADD_U, q, vece, a0, a1, a2); | ||
77 | return; | ||
78 | @@ -XXX,XX +XXX,XX @@ int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) | ||
79 | case INDEX_op_cmp_vec: | ||
80 | case INDEX_op_mul_vec: | ||
81 | case INDEX_op_neg_vec: | ||
82 | + case INDEX_op_smax_vec: | ||
83 | + case INDEX_op_smin_vec: | ||
84 | + case INDEX_op_umax_vec: | ||
85 | + case INDEX_op_umin_vec: | ||
86 | return vece < MO_64; | ||
87 | default: | ||
88 | return 0; | ||
89 | -- | ||
90 | 2.25.1 | ||
91 | |||
92 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | NEON has 3 instructions implementing this 4 argument operation, | ||
2 | with each insn overlapping a different logical input onto the | ||
3 | destination register. | ||
1 | 4 | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | --- | ||
8 | tcg/arm/tcg-target-con-set.h | 1 + | ||
9 | tcg/arm/tcg-target.h | 2 +- | ||
10 | tcg/arm/tcg-target.c.inc | 22 ++++++++++++++++++++-- | ||
11 | 3 files changed, 22 insertions(+), 3 deletions(-) | ||
12 | |||
13 | diff --git a/tcg/arm/tcg-target-con-set.h b/tcg/arm/tcg-target-con-set.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/tcg/arm/tcg-target-con-set.h | ||
16 | +++ b/tcg/arm/tcg-target-con-set.h | ||
17 | @@ -XXX,XX +XXX,XX @@ C_O1_I2(w, w, w) | ||
18 | C_O1_I2(w, w, wO) | ||
19 | C_O1_I2(w, w, wV) | ||
20 | C_O1_I2(w, w, wZ) | ||
21 | +C_O1_I3(w, w, w, w) | ||
22 | C_O1_I4(r, r, r, rI, rI) | ||
23 | C_O1_I4(r, r, rIN, rIK, 0) | ||
24 | C_O2_I1(r, r, l) | ||
25 | diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/tcg/arm/tcg-target.h | ||
28 | +++ b/tcg/arm/tcg-target.h | ||
29 | @@ -XXX,XX +XXX,XX @@ extern bool use_neon_instructions; | ||
30 | #define TCG_TARGET_HAS_mul_vec 1 | ||
31 | #define TCG_TARGET_HAS_sat_vec 1 | ||
32 | #define TCG_TARGET_HAS_minmax_vec 1 | ||
33 | -#define TCG_TARGET_HAS_bitsel_vec 0 | ||
34 | +#define TCG_TARGET_HAS_bitsel_vec 1 | ||
35 | #define TCG_TARGET_HAS_cmpsel_vec 0 | ||
36 | |||
37 | #define TCG_TARGET_DEFAULT_MO (0) | ||
38 | diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/tcg/arm/tcg-target.c.inc | ||
41 | +++ b/tcg/arm/tcg-target.c.inc | ||
42 | @@ -XXX,XX +XXX,XX @@ typedef enum { | ||
43 | INSN_VSARI = 0xf2800010, /* VSHR.S */ | ||
44 | INSN_VSHRI = 0xf3800010, /* VSHR.U */ | ||
45 | |||
46 | + INSN_VBSL = 0xf3100110, | ||
47 | + INSN_VBIT = 0xf3200110, | ||
48 | + INSN_VBIF = 0xf3300110, | ||
49 | + | ||
50 | INSN_VTST = 0xf2000810, | ||
51 | |||
52 | INSN_VDUP_G = 0xee800b10, /* VDUP (ARM core register) */ | ||
53 | @@ -XXX,XX +XXX,XX @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) | ||
54 | return C_O1_I2(w, w, wV); | ||
55 | case INDEX_op_cmp_vec: | ||
56 | return C_O1_I2(w, w, wZ); | ||
57 | - | ||
58 | + case INDEX_op_bitsel_vec: | ||
59 | + return C_O1_I3(w, w, w, w); | ||
60 | default: | ||
61 | g_assert_not_reached(); | ||
62 | } | ||
63 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, | ||
64 | { | ||
65 | TCGType type = vecl + TCG_TYPE_V64; | ||
66 | unsigned q = vecl; | ||
67 | - TCGArg a0, a1, a2; | ||
68 | + TCGArg a0, a1, a2, a3; | ||
69 | int cmode, imm8; | ||
70 | |||
71 | a0 = args[0]; | ||
72 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, | ||
73 | } | ||
74 | return; | ||
75 | |||
76 | + case INDEX_op_bitsel_vec: | ||
77 | + a3 = args[3]; | ||
78 | + if (a0 == a3) { | ||
79 | + tcg_out_vreg3(s, INSN_VBIT, q, 0, a0, a2, a1); | ||
80 | + } else if (a0 == a2) { | ||
81 | + tcg_out_vreg3(s, INSN_VBIF, q, 0, a0, a3, a1); | ||
82 | + } else { | ||
83 | + tcg_out_mov(s, type, a0, a1); | ||
84 | + tcg_out_vreg3(s, INSN_VBSL, q, 0, a0, a2, a3); | ||
85 | + } | ||
86 | + return; | ||
87 | + | ||
88 | case INDEX_op_mov_vec: /* Always emitted via tcg_out_mov. */ | ||
89 | case INDEX_op_dup_vec: /* Always emitted via tcg_out_dup_vec. */ | ||
90 | default: | ||
91 | @@ -XXX,XX +XXX,XX @@ int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) | ||
92 | case INDEX_op_sssub_vec: | ||
93 | case INDEX_op_usadd_vec: | ||
94 | case INDEX_op_ussub_vec: | ||
95 | + case INDEX_op_bitsel_vec: | ||
96 | return 1; | ||
97 | case INDEX_op_abs_vec: | ||
98 | case INDEX_op_cmp_vec: | ||
99 | -- | ||
100 | 2.25.1 | ||
101 | |||
102 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The three vector shift by vector operations are all implemented via | ||
2 | expansion. Therefore do not actually set TCG_TARGET_HAS_shv_vec, | ||
3 | as none of shlv_vec, shrv_vec, sarv_vec may actually appear in the | ||
4 | instruction stream, and therefore also do not appear in tcg_target_op_def. | ||
1 | 5 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | --- | ||
9 | tcg/arm/tcg-target.opc.h | 3 ++ | ||
10 | tcg/arm/tcg-target.c.inc | 61 +++++++++++++++++++++++++++++++++++++++- | ||
11 | 2 files changed, 63 insertions(+), 1 deletion(-) | ||
12 | |||
13 | diff --git a/tcg/arm/tcg-target.opc.h b/tcg/arm/tcg-target.opc.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/tcg/arm/tcg-target.opc.h | ||
16 | +++ b/tcg/arm/tcg-target.opc.h | ||
17 | @@ -XXX,XX +XXX,XX @@ | ||
18 | * emitted by tcg_expand_vec_op. For those familiar with GCC internals, | ||
19 | * consider these to be UNSPEC with names. | ||
20 | */ | ||
21 | + | ||
22 | +DEF(arm_sshl_vec, 1, 2, 0, IMPLVEC) | ||
23 | +DEF(arm_ushl_vec, 1, 2, 0, IMPLVEC) | ||
24 | diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/tcg/arm/tcg-target.c.inc | ||
27 | +++ b/tcg/arm/tcg-target.c.inc | ||
28 | @@ -XXX,XX +XXX,XX @@ typedef enum { | ||
29 | INSN_VSHLI = 0xf2800510, /* VSHL (immediate) */ | ||
30 | INSN_VSARI = 0xf2800010, /* VSHR.S */ | ||
31 | INSN_VSHRI = 0xf3800010, /* VSHR.U */ | ||
32 | + INSN_VSHL_S = 0xf2000400, /* VSHL.S (register) */ | ||
33 | + INSN_VSHL_U = 0xf3000400, /* VSHL.U (register) */ | ||
34 | |||
35 | INSN_VBSL = 0xf3100110, | ||
36 | INSN_VBIT = 0xf3200110, | ||
37 | @@ -XXX,XX +XXX,XX @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) | ||
38 | case INDEX_op_usadd_vec: | ||
39 | case INDEX_op_ussub_vec: | ||
40 | case INDEX_op_xor_vec: | ||
41 | + case INDEX_op_arm_sshl_vec: | ||
42 | + case INDEX_op_arm_ushl_vec: | ||
43 | return C_O1_I2(w, w, w); | ||
44 | case INDEX_op_or_vec: | ||
45 | case INDEX_op_andc_vec: | ||
46 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, | ||
47 | case INDEX_op_xor_vec: | ||
48 | tcg_out_vreg3(s, INSN_VEOR, q, 0, a0, a1, a2); | ||
49 | return; | ||
50 | + case INDEX_op_arm_sshl_vec: | ||
51 | + /* | ||
52 | + * Note that Vm is the data and Vn is the shift count, | ||
53 | + * therefore the arguments appear reversed. | ||
54 | + */ | ||
55 | + tcg_out_vreg3(s, INSN_VSHL_S, q, vece, a0, a2, a1); | ||
56 | + return; | ||
57 | + case INDEX_op_arm_ushl_vec: | ||
58 | + /* See above. */ | ||
59 | + tcg_out_vreg3(s, INSN_VSHL_U, q, vece, a0, a2, a1); | ||
60 | + return; | ||
61 | case INDEX_op_shli_vec: | ||
62 | tcg_out_vshifti(s, INSN_VSHLI, q, a0, a1, a2 + (8 << vece)); | ||
63 | return; | ||
64 | @@ -XXX,XX +XXX,XX @@ int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) | ||
65 | case INDEX_op_umax_vec: | ||
66 | case INDEX_op_umin_vec: | ||
67 | return vece < MO_64; | ||
68 | + case INDEX_op_shlv_vec: | ||
69 | + case INDEX_op_shrv_vec: | ||
70 | + case INDEX_op_sarv_vec: | ||
71 | + return -1; | ||
72 | default: | ||
73 | return 0; | ||
74 | } | ||
75 | @@ -XXX,XX +XXX,XX @@ int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) | ||
76 | void tcg_expand_vec_op(TCGOpcode opc, TCGType type, unsigned vece, | ||
77 | TCGArg a0, ...) | ||
78 | { | ||
79 | - g_assert_not_reached(); | ||
80 | + va_list va; | ||
81 | + TCGv_vec v0, v1, v2, t1; | ||
82 | + TCGArg a2; | ||
83 | + | ||
84 | + va_start(va, a0); | ||
85 | + v0 = temp_tcgv_vec(arg_temp(a0)); | ||
86 | + v1 = temp_tcgv_vec(arg_temp(va_arg(va, TCGArg))); | ||
87 | + a2 = va_arg(va, TCGArg); | ||
88 | + va_end(va); | ||
89 | + | ||
90 | + switch (opc) { | ||
91 | + case INDEX_op_shlv_vec: | ||
92 | + /* | ||
93 | + * Merely propagate shlv_vec to arm_ushl_vec. | ||
94 | + * In this way we don't set TCG_TARGET_HAS_shv_vec | ||
95 | + * because everything is done via expansion. | ||
96 | + */ | ||
97 | + v2 = temp_tcgv_vec(arg_temp(a2)); | ||
98 | + vec_gen_3(INDEX_op_arm_ushl_vec, type, vece, tcgv_vec_arg(v0), | ||
99 | + tcgv_vec_arg(v1), tcgv_vec_arg(v2)); | ||
100 | + break; | ||
101 | + | ||
102 | + case INDEX_op_shrv_vec: | ||
103 | + case INDEX_op_sarv_vec: | ||
104 | + /* Right shifts are negative left shifts for NEON. */ | ||
105 | + v2 = temp_tcgv_vec(arg_temp(a2)); | ||
106 | + t1 = tcg_temp_new_vec(type); | ||
107 | + tcg_gen_neg_vec(vece, t1, v2); | ||
108 | + if (opc == INDEX_op_shrv_vec) { | ||
109 | + opc = INDEX_op_arm_ushl_vec; | ||
110 | + } else { | ||
111 | + opc = INDEX_op_arm_sshl_vec; | ||
112 | + } | ||
113 | + vec_gen_3(opc, type, vece, tcgv_vec_arg(v0), | ||
114 | + tcgv_vec_arg(v1), tcgv_vec_arg(t1)); | ||
115 | + tcg_temp_free_vec(t1); | ||
116 | + break; | ||
117 | + | ||
118 | + default: | ||
119 | + g_assert_not_reached(); | ||
120 | + } | ||
121 | } | ||
122 | |||
123 | static void tcg_out_nop_fill(tcg_insn_unit *p, int count) | ||
124 | -- | ||
125 | 2.25.1 | ||
126 | |||
127 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Implement via expansion, so don't actually set TCG_TARGET_HAS_roti_vec. | ||
2 | For NEON, this is shift-right followed by shift-left-and-insert. | ||
1 | 3 | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | tcg/arm/tcg-target-con-set.h | 1 + | ||
8 | tcg/arm/tcg-target.opc.h | 1 + | ||
9 | tcg/arm/tcg-target.c.inc | 15 +++++++++++++++ | ||
10 | 3 files changed, 17 insertions(+) | ||
11 | |||
12 | diff --git a/tcg/arm/tcg-target-con-set.h b/tcg/arm/tcg-target-con-set.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/tcg/arm/tcg-target-con-set.h | ||
15 | +++ b/tcg/arm/tcg-target-con-set.h | ||
16 | @@ -XXX,XX +XXX,XX @@ C_O1_I2(r, r, rIK) | ||
17 | C_O1_I2(r, r, rIN) | ||
18 | C_O1_I2(r, r, ri) | ||
19 | C_O1_I2(r, rZ, rZ) | ||
20 | +C_O1_I2(w, 0, w) | ||
21 | C_O1_I2(w, w, w) | ||
22 | C_O1_I2(w, w, wO) | ||
23 | C_O1_I2(w, w, wV) | ||
24 | diff --git a/tcg/arm/tcg-target.opc.h b/tcg/arm/tcg-target.opc.h | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/tcg/arm/tcg-target.opc.h | ||
27 | +++ b/tcg/arm/tcg-target.opc.h | ||
28 | @@ -XXX,XX +XXX,XX @@ | ||
29 | * consider these to be UNSPEC with names. | ||
30 | */ | ||
31 | |||
32 | +DEF(arm_sli_vec, 1, 2, 1, IMPLVEC) | ||
33 | DEF(arm_sshl_vec, 1, 2, 0, IMPLVEC) | ||
34 | DEF(arm_ushl_vec, 1, 2, 0, IMPLVEC) | ||
35 | diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/tcg/arm/tcg-target.c.inc | ||
38 | +++ b/tcg/arm/tcg-target.c.inc | ||
39 | @@ -XXX,XX +XXX,XX @@ typedef enum { | ||
40 | INSN_VSHLI = 0xf2800510, /* VSHL (immediate) */ | ||
41 | INSN_VSARI = 0xf2800010, /* VSHR.S */ | ||
42 | INSN_VSHRI = 0xf3800010, /* VSHR.U */ | ||
43 | + INSN_VSLI = 0xf3800510, | ||
44 | INSN_VSHL_S = 0xf2000400, /* VSHL.S (register) */ | ||
45 | INSN_VSHL_U = 0xf3000400, /* VSHL.U (register) */ | ||
46 | |||
47 | @@ -XXX,XX +XXX,XX @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) | ||
48 | case INDEX_op_arm_sshl_vec: | ||
49 | case INDEX_op_arm_ushl_vec: | ||
50 | return C_O1_I2(w, w, w); | ||
51 | + case INDEX_op_arm_sli_vec: | ||
52 | + return C_O1_I2(w, 0, w); | ||
53 | case INDEX_op_or_vec: | ||
54 | case INDEX_op_andc_vec: | ||
55 | return C_O1_I2(w, w, wO); | ||
56 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, | ||
57 | case INDEX_op_sari_vec: | ||
58 | tcg_out_vshifti(s, INSN_VSARI, q, a0, a1, (16 << vece) - a2); | ||
59 | return; | ||
60 | + case INDEX_op_arm_sli_vec: | ||
61 | + tcg_out_vshifti(s, INSN_VSLI, q, a0, a2, args[3] + (8 << vece)); | ||
62 | + return; | ||
63 | |||
64 | case INDEX_op_andc_vec: | ||
65 | if (!const_args[2]) { | ||
66 | @@ -XXX,XX +XXX,XX @@ int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) | ||
67 | case INDEX_op_shlv_vec: | ||
68 | case INDEX_op_shrv_vec: | ||
69 | case INDEX_op_sarv_vec: | ||
70 | + case INDEX_op_rotli_vec: | ||
71 | return -1; | ||
72 | default: | ||
73 | return 0; | ||
74 | @@ -XXX,XX +XXX,XX @@ void tcg_expand_vec_op(TCGOpcode opc, TCGType type, unsigned vece, | ||
75 | tcg_temp_free_vec(t1); | ||
76 | break; | ||
77 | |||
78 | + case INDEX_op_rotli_vec: | ||
79 | + t1 = tcg_temp_new_vec(type); | ||
80 | + tcg_gen_shri_vec(vece, t1, v1, -a2 & ((8 << vece) - 1)); | ||
81 | + vec_gen_4(INDEX_op_arm_sli_vec, type, vece, | ||
82 | + tcgv_vec_arg(v0), tcgv_vec_arg(t1), tcgv_vec_arg(v1), a2); | ||
83 | + tcg_temp_free_vec(t1); | ||
84 | + break; | ||
85 | + | ||
86 | default: | ||
87 | g_assert_not_reached(); | ||
88 | } | ||
89 | -- | ||
90 | 2.25.1 | ||
91 | |||
92 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Implement via expansion, so don't actually set TCG_TARGET_HAS_rotv_vec. | ||
1 | 2 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | --- | ||
6 | tcg/arm/tcg-target.c.inc | 35 ++++++++++++++++++++++++++++++++++- | ||
7 | 1 file changed, 34 insertions(+), 1 deletion(-) | ||
8 | |||
9 | diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc | ||
10 | index XXXXXXX..XXXXXXX 100644 | ||
11 | --- a/tcg/arm/tcg-target.c.inc | ||
12 | +++ b/tcg/arm/tcg-target.c.inc | ||
13 | @@ -XXX,XX +XXX,XX @@ int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) | ||
14 | case INDEX_op_shrv_vec: | ||
15 | case INDEX_op_sarv_vec: | ||
16 | case INDEX_op_rotli_vec: | ||
17 | + case INDEX_op_rotlv_vec: | ||
18 | + case INDEX_op_rotrv_vec: | ||
19 | return -1; | ||
20 | default: | ||
21 | return 0; | ||
22 | @@ -XXX,XX +XXX,XX @@ void tcg_expand_vec_op(TCGOpcode opc, TCGType type, unsigned vece, | ||
23 | TCGArg a0, ...) | ||
24 | { | ||
25 | va_list va; | ||
26 | - TCGv_vec v0, v1, v2, t1; | ||
27 | + TCGv_vec v0, v1, v2, t1, t2, c1; | ||
28 | TCGArg a2; | ||
29 | |||
30 | va_start(va, a0); | ||
31 | @@ -XXX,XX +XXX,XX @@ void tcg_expand_vec_op(TCGOpcode opc, TCGType type, unsigned vece, | ||
32 | tcg_temp_free_vec(t1); | ||
33 | break; | ||
34 | |||
35 | + case INDEX_op_rotlv_vec: | ||
36 | + v2 = temp_tcgv_vec(arg_temp(a2)); | ||
37 | + t1 = tcg_temp_new_vec(type); | ||
38 | + c1 = tcg_constant_vec(type, vece, 8 << vece); | ||
39 | + tcg_gen_sub_vec(vece, t1, v2, c1); | ||
40 | + /* Right shifts are negative left shifts for NEON. */ | ||
41 | + vec_gen_3(INDEX_op_arm_ushl_vec, type, vece, tcgv_vec_arg(t1), | ||
42 | + tcgv_vec_arg(v1), tcgv_vec_arg(t1)); | ||
43 | + vec_gen_3(INDEX_op_arm_ushl_vec, type, vece, tcgv_vec_arg(v0), | ||
44 | + tcgv_vec_arg(v1), tcgv_vec_arg(v2)); | ||
45 | + tcg_gen_or_vec(vece, v0, v0, t1); | ||
46 | + tcg_temp_free_vec(t1); | ||
47 | + break; | ||
48 | + | ||
49 | + case INDEX_op_rotrv_vec: | ||
50 | + v2 = temp_tcgv_vec(arg_temp(a2)); | ||
51 | + t1 = tcg_temp_new_vec(type); | ||
52 | + t2 = tcg_temp_new_vec(type); | ||
53 | + c1 = tcg_constant_vec(type, vece, 8 << vece); | ||
54 | + tcg_gen_neg_vec(vece, t1, v2); | ||
55 | + tcg_gen_sub_vec(vece, t2, c1, v2); | ||
56 | + /* Right shifts are negative left shifts for NEON. */ | ||
57 | + vec_gen_3(INDEX_op_arm_ushl_vec, type, vece, tcgv_vec_arg(t1), | ||
58 | + tcgv_vec_arg(v1), tcgv_vec_arg(t1)); | ||
59 | + vec_gen_3(INDEX_op_arm_ushl_vec, type, vece, tcgv_vec_arg(t2), | ||
60 | + tcgv_vec_arg(v1), tcgv_vec_arg(t2)); | ||
61 | + tcg_gen_or_vec(vece, v0, t1, t2); | ||
62 | + tcg_temp_free_vec(t1); | ||
63 | + tcg_temp_free_vec(t2); | ||
64 | + break; | ||
65 | + | ||
66 | default: | ||
67 | g_assert_not_reached(); | ||
68 | } | ||
69 | -- | ||
70 | 2.25.1 | ||
71 | |||
72 | diff view generated by jsdifflib |