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    TCGv src = get_address(ctx, a->rs1, 0);
35
36    gen_helper_cbo_clean_flush(tcg_env, src);
37    return true;
38}
39
40static bool trans_cbo_flush(DisasContext *ctx, arg_cbo_flush *a)
41{
42    REQUIRE_ZICBOM(ctx);
43    TCGv src = get_address(ctx, a->rs1, 0);
44
45    gen_helper_cbo_clean_flush(tcg_env, src);
46    return true;
47}
48
49static bool trans_cbo_inval(DisasContext *ctx, arg_cbo_inval *a)
50{
51    REQUIRE_ZICBOM(ctx);
52    TCGv src = get_address(ctx, a->rs1, 0);
53
54    gen_helper_cbo_inval(tcg_env, src);
55    return true;
56}
57
58static bool trans_cbo_zero(DisasContext *ctx, arg_cbo_zero *a)
59{
60    REQUIRE_ZICBOZ(ctx);
61    TCGv src = get_address(ctx, a->rs1, 0);
62
63    gen_helper_cbo_zero(tcg_env, src);
64    return true;
65}
66