@samitouri / QOSamiQemu / commits / ffbb6bbca5

target/hexagon: add GVec overrides for HVX vector average

Reviewed-by: Marco Liebel <marco.liebel@oss.qualcomm.com> Link: https://lore.kernel.org/qemu-devel/20260807152241.1576334-6-brian.cain@oss.qualcomm.com Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>

Brian Cain committed Aug 7, 2026 at 08:22 UTC ffbb6bbca5d0b74fb24ece36356963267f8b34ab
1 file changed +62
target/hexagon/gen_tcg_hvx.h
+62
@@ -342,6 +342,68 @@ static inline void assert_vhist_tmp(DisasContext *ctx)
342 gen_gvec_sabsdiff(MO_32, VdV_off, VuV_off, VvV_off, \
343 VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE)
344
345 +#define fGEN_TCG_VEC_AVG(VECE, SHIFT_FN) \
346 + do { \
347 + intptr_t tmpoff = offsetof(CPUHexagonState, vtmp); \
348 + tcg_gen_gvec_and(MO_64, tmpoff, VuV_off, VvV_off, \
349 + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE); \
350 + tcg_gen_gvec_xor(MO_64, VdV_off, VuV_off, VvV_off, \
351 + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE); \
352 + SHIFT_FN(VECE, VdV_off, VdV_off, 1, \
353 + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE); \
354 + tcg_gen_gvec_add(VECE, VdV_off, tmpoff, VdV_off, \
355 + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE); \
356 + } while (0)
357 +
358 +#define fGEN_TCG_V6_vavgub(SHORTCODE) \
359 + fGEN_TCG_VEC_AVG(MO_8, tcg_gen_gvec_shri)
360 +
361 +#define fGEN_TCG_V6_vavguh(SHORTCODE) \
362 + fGEN_TCG_VEC_AVG(MO_16, tcg_gen_gvec_shri)
363 +
364 +#define fGEN_TCG_V6_vavguw(SHORTCODE) \
365 + fGEN_TCG_VEC_AVG(MO_32, tcg_gen_gvec_shri)
366 +
367 +#define fGEN_TCG_V6_vavgb(SHORTCODE) \
368 + fGEN_TCG_VEC_AVG(MO_8, tcg_gen_gvec_sari)
369 +
370 +#define fGEN_TCG_V6_vavgh(SHORTCODE) \
371 + fGEN_TCG_VEC_AVG(MO_16, tcg_gen_gvec_sari)
372 +
373 +#define fGEN_TCG_V6_vavgw(SHORTCODE) \
374 + fGEN_TCG_VEC_AVG(MO_32, tcg_gen_gvec_sari)
375 +
376 +#define fGEN_TCG_VEC_AVGRND(VECE, SHIFT_FN) \
377 + do { \
378 + intptr_t tmpoff = offsetof(CPUHexagonState, vtmp); \
379 + tcg_gen_gvec_or(MO_64, tmpoff, VuV_off, VvV_off, \
380 + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE); \
381 + tcg_gen_gvec_xor(MO_64, VdV_off, VuV_off, VvV_off, \
382 + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE); \
383 + SHIFT_FN(VECE, VdV_off, VdV_off, 1, \
384 + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE); \
385 + tcg_gen_gvec_sub(VECE, VdV_off, tmpoff, VdV_off, \
386 + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE); \
387 + } while (0)
388 +
389 +#define fGEN_TCG_V6_vavgubrnd(SHORTCODE) \
390 + fGEN_TCG_VEC_AVGRND(MO_8, tcg_gen_gvec_shri)
391 +
392 +#define fGEN_TCG_V6_vavguhrnd(SHORTCODE) \
393 + fGEN_TCG_VEC_AVGRND(MO_16, tcg_gen_gvec_shri)
394 +
395 +#define fGEN_TCG_V6_vavguwrnd(SHORTCODE) \
396 + fGEN_TCG_VEC_AVGRND(MO_32, tcg_gen_gvec_shri)
397 +
398 +#define fGEN_TCG_V6_vavgbrnd(SHORTCODE) \
399 + fGEN_TCG_VEC_AVGRND(MO_8, tcg_gen_gvec_sari)
400 +
401 +#define fGEN_TCG_V6_vavghrnd(SHORTCODE) \
402 + fGEN_TCG_VEC_AVGRND(MO_16, tcg_gen_gvec_sari)
403 +
404 +#define fGEN_TCG_V6_vavgwrnd(SHORTCODE) \
405 + fGEN_TCG_VEC_AVGRND(MO_32, tcg_gen_gvec_sari)
406 +
407 /* Vector shift right - various forms */
408 #define fGEN_TCG_V6_vasrh(SHORTCODE) \
409 do { \