]> Git Repo - qemu.git/blame - target/s390x/vec_int_helper.c
s390x/tcg: Implement VECTOR EXCLUSIVE OR
[qemu.git] / target / s390x / vec_int_helper.c
CommitLineData
c1a81d4b
DH
1/*
2 * QEMU TCG support -- s390x vector integer instruction support
3 *
4 * Copyright (C) 2019 Red Hat Inc
5 *
6 * Authors:
7 * David Hildenbrand <[email protected]>
8 *
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
11 */
12#include "qemu/osdep.h"
13#include "qemu-common.h"
14#include "cpu.h"
15#include "vec.h"
16#include "exec/helper-proto.h"
17
18#define DEF_VAVG(BITS) \
19void HELPER(gvec_vavg##BITS)(void *v1, const void *v2, const void *v3, \
20 uint32_t desc) \
21{ \
22 int i; \
23 \
24 for (i = 0; i < (128 / BITS); i++) { \
25 const int32_t a = (int##BITS##_t)s390_vec_read_element##BITS(v2, i); \
26 const int32_t b = (int##BITS##_t)s390_vec_read_element##BITS(v3, i); \
27 \
28 s390_vec_write_element##BITS(v1, i, (a + b + 1) >> 1); \
29 } \
30}
31DEF_VAVG(8)
32DEF_VAVG(16)
801aa78b
DH
33
34#define DEF_VAVGL(BITS) \
35void HELPER(gvec_vavgl##BITS)(void *v1, const void *v2, const void *v3, \
36 uint32_t desc) \
37{ \
38 int i; \
39 \
40 for (i = 0; i < (128 / BITS); i++) { \
41 const uint##BITS##_t a = s390_vec_read_element##BITS(v2, i); \
42 const uint##BITS##_t b = s390_vec_read_element##BITS(v3, i); \
43 \
44 s390_vec_write_element##BITS(v1, i, (a + b + 1) >> 1); \
45 } \
46}
47DEF_VAVGL(8)
48DEF_VAVGL(16)
28863f1d
DH
49
50#define DEF_VCLZ(BITS) \
51void HELPER(gvec_vclz##BITS)(void *v1, const void *v2, uint32_t desc) \
52{ \
53 int i; \
54 \
55 for (i = 0; i < (128 / BITS); i++) { \
56 const uint##BITS##_t a = s390_vec_read_element##BITS(v2, i); \
57 \
58 s390_vec_write_element##BITS(v1, i, clz32(a) - 32 + BITS); \
59 } \
60}
61DEF_VCLZ(8)
62DEF_VCLZ(16)
449a8ac2
DH
63
64#define DEF_VCTZ(BITS) \
65void HELPER(gvec_vctz##BITS)(void *v1, const void *v2, uint32_t desc) \
66{ \
67 int i; \
68 \
69 for (i = 0; i < (128 / BITS); i++) { \
70 const uint##BITS##_t a = s390_vec_read_element##BITS(v2, i); \
71 \
72 s390_vec_write_element##BITS(v1, i, a ? ctz32(a) : BITS); \
73 } \
74}
75DEF_VCTZ(8)
76DEF_VCTZ(16)
This page took 0.027388 seconds and 4 git commands to generate.