aboutsummaryrefslogtreecommitdiff
path: root/target/riscv/insn_trans/trans_rvzawrs.c.inc
blob: 32efbff4d5a567728a56aae63fef1874a9693659 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 * RISC-V translation routines for the RISC-V Zawrs Extension.
 *
 * Copyright (c) 2022 Christoph Muellner, christoph.muellner@vrull.io
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2 or later, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 */

static bool trans_wrs(DisasContext *ctx)
{
    if (!ctx->cfg_ptr->ext_zawrs) {
        return false;
    }

    /*
     * The specification says:
     * While stalled, an implementation is permitted to occasionally
     * terminate the stall and complete execution for any reason.
     *
     * So let's just exit TB and return to the main loop.
     */

    /* Clear the load reservation  (if any).  */
    tcg_gen_movi_tl(load_res, -1);

    gen_update_pc(ctx, ctx->cur_insn_len);
    tcg_gen_exit_tb(NULL, 0);
    ctx->base.is_jmp = DISAS_NORETURN;

    return true;
}

#define GEN_TRANS_WRS(insn)                                     \
static bool trans_ ## insn(DisasContext *ctx, arg_ ## insn *a)  \
{                                                               \
    (void)a;                                                    \
    return trans_wrs(ctx);                                      \
}

GEN_TRANS_WRS(wrs_nto)
GEN_TRANS_WRS(wrs_sto)