master
inc 73 lines 2.22 KB
Raw
1 /*
2 * RISC-V translation routines for the RISC-V CBO Extension.
3 *
4 * Copyright (c) 2021 Philipp Tomsich, philipp.tomsich@vrull.eu
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
19 #define REQUIRE_ZICBOM(ctx) do { \
20 if (!ctx->cfg_ptr->ext_zicbom) { \
21 return false; \
22 } \
23 } while (0)
24
25 #define REQUIRE_ZICBOZ(ctx) do { \
26 if (!ctx->cfg_ptr->ext_zicboz) { \
27 return false; \
28 } \
29 } while (0)
30
31 static bool trans_cbo_clean(DisasContext *ctx, arg_cbo_clean *a)
32 {
33 REQUIRE_ZICBOM(ctx);
34 TCGv src = get_address(ctx, a->rs1, 0);
35
36 /* The helper may raise ILLEGAL_INSN -- record binv for unwind. */
37 decode_save_opc(ctx, 0);
38 gen_helper_cbo_clean_flush(tcg_env, src);
39 return true;
40 }
41
42 static bool trans_cbo_flush(DisasContext *ctx, arg_cbo_flush *a)
43 {
44 REQUIRE_ZICBOM(ctx);
45 TCGv src = get_address(ctx, a->rs1, 0);
46
47 /* The helper may raise ILLEGAL_INSN -- record binv for unwind. */
48 decode_save_opc(ctx, 0);
49 gen_helper_cbo_clean_flush(tcg_env, src);
50 return true;
51 }
52
53 static bool trans_cbo_inval(DisasContext *ctx, arg_cbo_inval *a)
54 {
55 REQUIRE_ZICBOM(ctx);
56 TCGv src = get_address(ctx, a->rs1, 0);
57
58 /* The helper may raise ILLEGAL_INSN -- record binv for unwind. */
59 decode_save_opc(ctx, 0);
60 gen_helper_cbo_inval(tcg_env, src);
61 return true;
62 }
63
64 static bool trans_cbo_zero(DisasContext *ctx, arg_cbo_zero *a)
65 {
66 REQUIRE_ZICBOZ(ctx);
67 TCGv src = get_address(ctx, a->rs1, 0);
68
69 /* The helper may raise ILLEGAL_INSN -- record binv for unwind. */
70 decode_save_opc(ctx, 0);
71 gen_helper_cbo_zero(tcg_env, src);
72 return true;
73 }