xref: /openbmc/qemu/target/riscv/insn_trans/trans_rvzawrs.c.inc (revision d67a6e054b92e5e1cbb7b0bd5782a670cc7f0df7)
1260b594dSChristoph Muellner/*
2260b594dSChristoph Muellner * RISC-V translation routines for the RISC-V Zawrs Extension.
3260b594dSChristoph Muellner *
4260b594dSChristoph Muellner * Copyright (c) 2022 Christoph Muellner, christoph.muellner@vrull.io
5260b594dSChristoph Muellner *
6260b594dSChristoph Muellner * This program is free software; you can redistribute it and/or modify it
7260b594dSChristoph Muellner * under the terms and conditions of the GNU General Public License,
8260b594dSChristoph Muellner * version 2 or later, as published by the Free Software Foundation.
9260b594dSChristoph Muellner *
10260b594dSChristoph Muellner * This program is distributed in the hope it will be useful, but WITHOUT
11260b594dSChristoph Muellner * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12260b594dSChristoph Muellner * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13260b594dSChristoph Muellner * more details.
14260b594dSChristoph Muellner *
15260b594dSChristoph Muellner * You should have received a copy of the GNU General Public License along with
16260b594dSChristoph Muellner * this program.  If not, see <http://www.gnu.org/licenses/>.
17260b594dSChristoph Muellner */
18260b594dSChristoph Muellner
19*b62e0ce7SAndrew Jonesstatic bool trans_wrs_sto(DisasContext *ctx, arg_wrs_sto *a)
20260b594dSChristoph Muellner{
21260b594dSChristoph Muellner    if (!ctx->cfg_ptr->ext_zawrs) {
22260b594dSChristoph Muellner        return false;
23260b594dSChristoph Muellner    }
24260b594dSChristoph Muellner
25260b594dSChristoph Muellner    /*
26260b594dSChristoph Muellner     * The specification says:
27260b594dSChristoph Muellner     * While stalled, an implementation is permitted to occasionally
28260b594dSChristoph Muellner     * terminate the stall and complete execution for any reason.
29260b594dSChristoph Muellner     *
30260b594dSChristoph Muellner     * So let's just exit TB and return to the main loop.
31260b594dSChristoph Muellner     */
32260b594dSChristoph Muellner
33260b594dSChristoph Muellner    /* Clear the load reservation  (if any).  */
34260b594dSChristoph Muellner    tcg_gen_movi_tl(load_res, -1);
35260b594dSChristoph Muellner
36022c7550SWeiwei Li    gen_update_pc(ctx, ctx->cur_insn_len);
37260b594dSChristoph Muellner    tcg_gen_exit_tb(NULL, 0);
38260b594dSChristoph Muellner    ctx->base.is_jmp = DISAS_NORETURN;
39260b594dSChristoph Muellner
40260b594dSChristoph Muellner    return true;
41260b594dSChristoph Muellner}
42260b594dSChristoph Muellner
43*b62e0ce7SAndrew Jonesstatic bool trans_wrs_nto(DisasContext *ctx, arg_wrs_nto *a)
44*b62e0ce7SAndrew Jones{
45*b62e0ce7SAndrew Jones    if (!ctx->cfg_ptr->ext_zawrs) {
46*b62e0ce7SAndrew Jones        return false;
47260b594dSChristoph Muellner    }
48260b594dSChristoph Muellner
49*b62e0ce7SAndrew Jones    /*
50*b62e0ce7SAndrew Jones     * Depending on the mode of execution, mstatus.TW and hstatus.VTW, wrs.nto
51*b62e0ce7SAndrew Jones     * should raise an exception when the implementation-specific bounded time
52*b62e0ce7SAndrew Jones     * limit has expired. Our time limit is zero, so we either return
53*b62e0ce7SAndrew Jones     * immediately, as does our implementation of wrs.sto, or raise an
54*b62e0ce7SAndrew Jones     * exception, as handled by the wrs.nto helper.
55*b62e0ce7SAndrew Jones     */
56*b62e0ce7SAndrew Jones#ifndef CONFIG_USER_ONLY
57*b62e0ce7SAndrew Jones    gen_helper_wrs_nto(tcg_env);
58*b62e0ce7SAndrew Jones#endif
59*b62e0ce7SAndrew Jones
60*b62e0ce7SAndrew Jones    /* We only get here when helper_wrs_nto() doesn't raise an exception. */
61*b62e0ce7SAndrew Jones    return trans_wrs_sto(ctx, NULL);
62*b62e0ce7SAndrew Jones}
63