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
31static bool trans_cbo_clean(DisasContext *ctx, arg_cbo_clean *a)
32{
33    REQUIRE_ZICBOM(ctx);
34    gen_helper_cbo_clean_flush(tcg_env, cpu_gpr[a->rs1]);
35    return true;
36}
37
38static bool trans_cbo_flush(DisasContext *ctx, arg_cbo_flush *a)
39{
40    REQUIRE_ZICBOM(ctx);
41    gen_helper_cbo_clean_flush(tcg_env, cpu_gpr[a->rs1]);
42    return true;
43}
44
45static bool trans_cbo_inval(DisasContext *ctx, arg_cbo_inval *a)
46{
47    REQUIRE_ZICBOM(ctx);
48    gen_helper_cbo_inval(tcg_env, cpu_gpr[a->rs1]);
49    return true;
50}
51
52static bool trans_cbo_zero(DisasContext *ctx, arg_cbo_zero *a)
53{
54    REQUIRE_ZICBOZ(ctx);
55    gen_helper_cbo_zero(tcg_env, cpu_gpr[a->rs1]);
56    return true;
57}
58