xref: /qemu/target/s390x/tcg/vec_int_helper.c (revision c1a81d4b12b8f519863db6d7a0048b5cd0a802f0)
1*c1a81d4bSDavid Hildenbrand /*
2*c1a81d4bSDavid Hildenbrand  * QEMU TCG support -- s390x vector integer instruction support
3*c1a81d4bSDavid Hildenbrand  *
4*c1a81d4bSDavid Hildenbrand  * Copyright (C) 2019 Red Hat Inc
5*c1a81d4bSDavid Hildenbrand  *
6*c1a81d4bSDavid Hildenbrand  * Authors:
7*c1a81d4bSDavid Hildenbrand  *   David Hildenbrand <david@redhat.com>
8*c1a81d4bSDavid Hildenbrand  *
9*c1a81d4bSDavid Hildenbrand  * This work is licensed under the terms of the GNU GPL, version 2 or later.
10*c1a81d4bSDavid Hildenbrand  * See the COPYING file in the top-level directory.
11*c1a81d4bSDavid Hildenbrand  */
12*c1a81d4bSDavid Hildenbrand #include "qemu/osdep.h"
13*c1a81d4bSDavid Hildenbrand #include "qemu-common.h"
14*c1a81d4bSDavid Hildenbrand #include "cpu.h"
15*c1a81d4bSDavid Hildenbrand #include "vec.h"
16*c1a81d4bSDavid Hildenbrand #include "exec/helper-proto.h"
17*c1a81d4bSDavid Hildenbrand 
18*c1a81d4bSDavid Hildenbrand #define DEF_VAVG(BITS)                                                         \
19*c1a81d4bSDavid Hildenbrand void HELPER(gvec_vavg##BITS)(void *v1, const void *v2, const void *v3,         \
20*c1a81d4bSDavid Hildenbrand                              uint32_t desc)                                    \
21*c1a81d4bSDavid Hildenbrand {                                                                              \
22*c1a81d4bSDavid Hildenbrand     int i;                                                                     \
23*c1a81d4bSDavid Hildenbrand                                                                                \
24*c1a81d4bSDavid Hildenbrand     for (i = 0; i < (128 / BITS); i++) {                                       \
25*c1a81d4bSDavid Hildenbrand         const int32_t a = (int##BITS##_t)s390_vec_read_element##BITS(v2, i);   \
26*c1a81d4bSDavid Hildenbrand         const int32_t b = (int##BITS##_t)s390_vec_read_element##BITS(v3, i);   \
27*c1a81d4bSDavid Hildenbrand                                                                                \
28*c1a81d4bSDavid Hildenbrand         s390_vec_write_element##BITS(v1, i, (a + b + 1) >> 1);                 \
29*c1a81d4bSDavid Hildenbrand     }                                                                          \
30*c1a81d4bSDavid Hildenbrand }
31*c1a81d4bSDavid Hildenbrand DEF_VAVG(8)
32*c1a81d4bSDavid Hildenbrand DEF_VAVG(16)
33