]> git.proxmox.com Git - mirror_qemu.git/blame - target/riscv/insn_trans/trans_rvv.inc.c
target/riscv: add an internals.h header
[mirror_qemu.git] / target / riscv / insn_trans / trans_rvv.inc.c
CommitLineData
2b7168fc
LZ
1/*
2 * RISC-V translation routines for the RVV Standard Extension.
3 *
4 * Copyright (c) 2020 T-Head Semiconductor Co., Ltd. All rights reserved.
5 *
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.
9 *
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
13 * more details.
14 *
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/>.
17 */
18
19static bool trans_vsetvl(DisasContext *ctx, arg_vsetvl *a)
20{
21 TCGv s1, s2, dst;
22
23 if (!has_ext(ctx, RVV)) {
24 return false;
25 }
26
27 s2 = tcg_temp_new();
28 dst = tcg_temp_new();
29
30 /* Using x0 as the rs1 register specifier, encodes an infinite AVL */
31 if (a->rs1 == 0) {
32 /* As the mask is at least one bit, RV_VLEN_MAX is >= VLMAX */
33 s1 = tcg_const_tl(RV_VLEN_MAX);
34 } else {
35 s1 = tcg_temp_new();
36 gen_get_gpr(s1, a->rs1);
37 }
38 gen_get_gpr(s2, a->rs2);
39 gen_helper_vsetvl(dst, cpu_env, s1, s2);
40 gen_set_gpr(a->rd, dst);
41 tcg_gen_movi_tl(cpu_pc, ctx->pc_succ_insn);
42 lookup_and_goto_ptr(ctx);
43 ctx->base.is_jmp = DISAS_NORETURN;
44
45 tcg_temp_free(s1);
46 tcg_temp_free(s2);
47 tcg_temp_free(dst);
48 return true;
49}
50
51static bool trans_vsetvli(DisasContext *ctx, arg_vsetvli *a)
52{
53 TCGv s1, s2, dst;
54
55 if (!has_ext(ctx, RVV)) {
56 return false;
57 }
58
59 s2 = tcg_const_tl(a->zimm);
60 dst = tcg_temp_new();
61
62 /* Using x0 as the rs1 register specifier, encodes an infinite AVL */
63 if (a->rs1 == 0) {
64 /* As the mask is at least one bit, RV_VLEN_MAX is >= VLMAX */
65 s1 = tcg_const_tl(RV_VLEN_MAX);
66 } else {
67 s1 = tcg_temp_new();
68 gen_get_gpr(s1, a->rs1);
69 }
70 gen_helper_vsetvl(dst, cpu_env, s1, s2);
71 gen_set_gpr(a->rd, dst);
72 gen_goto_tb(ctx, 0, ctx->pc_succ_insn);
73 ctx->base.is_jmp = DISAS_NORETURN;
74
75 tcg_temp_free(s1);
76 tcg_temp_free(s2);
77 tcg_temp_free(dst);
78 return true;
79}