1/*
2 * RISC-V translation routines for the XVentanaCondOps extension.
3 *
4 * Copyright (c) 2021-2022 VRULL GmbH.
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 gen_vt_condmask(DisasContext *ctx, arg_r *a, TCGCond cond)
20{
21    TCGv dest = dest_gpr(ctx, a->rd);
22    TCGv src1 = get_gpr(ctx, a->rs1, EXT_NONE);
23    TCGv src2 = get_gpr(ctx, a->rs2, EXT_NONE);
24
25    tcg_gen_movcond_tl(cond, dest, src2, ctx->zero, src1, ctx->zero);
26
27    gen_set_gpr(ctx, a->rd, dest);
28    return true;
29}
30
31static bool trans_vt_maskc(DisasContext *ctx, arg_r *a)
32{
33    return gen_vt_condmask(ctx, a, TCG_COND_NE);
34}
35
36static bool trans_vt_maskcn(DisasContext *ctx, arg_r *a)
37{
38    return gen_vt_condmask(ctx, a, TCG_COND_EQ);
39}
40