2 * RISC-V Vector Extension Internals
4 * Copyright (c) 2020 T-Head Semiconductor Co., Ltd. All rights reserved.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2 or later, as published by the Free Software Foundation.
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along with
16 * this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "qemu/osdep.h"
20 #include "vector_internals.h"
22 /* set agnostic elements to 1s */
23 void vext_set_elems_1s(void *base
, uint32_t is_agnostic
, uint32_t cnt
,
26 if (is_agnostic
== 0) {
27 /* policy undisturbed */
33 memset(base
+ cnt
, -1, tot
- cnt
);
36 void do_vext_vv(void *vd
, void *v0
, void *vs1
, void *vs2
,
37 CPURISCVState
*env
, uint32_t desc
,
38 opivv2_fn
*fn
, uint32_t esz
)
40 uint32_t vm
= vext_vm(desc
);
41 uint32_t vl
= env
->vl
;
42 uint32_t total_elems
= vext_get_total_elems(env
, desc
, esz
);
43 uint32_t vta
= vext_vta(desc
);
44 uint32_t vma
= vext_vma(desc
);
47 VSTART_CHECK_EARLY_EXIT(env
);
49 for (i
= env
->vstart
; i
< vl
; i
++) {
50 if (!vm
&& !vext_elem_mask(v0
, i
)) {
51 /* set masked-off elements to 1s */
52 vext_set_elems_1s(vd
, vma
, i
* esz
, (i
+ 1) * esz
);
58 /* set tail elements to 1s */
59 vext_set_elems_1s(vd
, vta
, vl
* esz
, total_elems
* esz
);
62 void do_vext_vx(void *vd
, void *v0
, target_long s1
, void *vs2
,
63 CPURISCVState
*env
, uint32_t desc
,
64 opivx2_fn fn
, uint32_t esz
)
66 uint32_t vm
= vext_vm(desc
);
67 uint32_t vl
= env
->vl
;
68 uint32_t total_elems
= vext_get_total_elems(env
, desc
, esz
);
69 uint32_t vta
= vext_vta(desc
);
70 uint32_t vma
= vext_vma(desc
);
73 VSTART_CHECK_EARLY_EXIT(env
);
75 for (i
= env
->vstart
; i
< vl
; i
++) {
76 if (!vm
&& !vext_elem_mask(v0
, i
)) {
77 /* set masked-off elements to 1s */
78 vext_set_elems_1s(vd
, vma
, i
* esz
, (i
+ 1) * esz
);
84 /* set tail elements to 1s */
85 vext_set_elems_1s(vd
, vta
, vl
* esz
, total_elems
* esz
);