xref: /openbmc/qemu/target/riscv/insn_trans/trans_rvzicbo.c.inc (revision d67a6e054b92e5e1cbb7b0bd5782a670cc7f0df7)
1a939c500SChristoph Muellner/*
2a939c500SChristoph Muellner * RISC-V translation routines for the RISC-V CBO Extension.
3a939c500SChristoph Muellner *
4a939c500SChristoph Muellner * Copyright (c) 2021 Philipp Tomsich, philipp.tomsich@vrull.eu
5a939c500SChristoph Muellner *
6a939c500SChristoph Muellner * This program is free software; you can redistribute it and/or modify it
7a939c500SChristoph Muellner * under the terms and conditions of the GNU General Public License,
8a939c500SChristoph Muellner * version 2 or later, as published by the Free Software Foundation.
9a939c500SChristoph Muellner *
10a939c500SChristoph Muellner * This program is distributed in the hope it will be useful, but WITHOUT
11a939c500SChristoph Muellner * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12a939c500SChristoph Muellner * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13a939c500SChristoph Muellner * more details.
14a939c500SChristoph Muellner *
15a939c500SChristoph Muellner * You should have received a copy of the GNU General Public License along with
16a939c500SChristoph Muellner * this program.  If not, see <http://www.gnu.org/licenses/>.
17a939c500SChristoph Muellner */
18a939c500SChristoph Muellner
19e05da09bSChristoph Muellner#define REQUIRE_ZICBOM(ctx) do {     \
20a326a2b0SDaniel Henrique Barboza    if (!ctx->cfg_ptr->ext_zicbom) { \
21e05da09bSChristoph Muellner        return false;                \
22e05da09bSChristoph Muellner    }                                \
23e05da09bSChristoph Muellner} while (0)
24e05da09bSChristoph Muellner
25a939c500SChristoph Muellner#define REQUIRE_ZICBOZ(ctx) do {     \
26e57039ddSDaniel Henrique Barboza    if (!ctx->cfg_ptr->ext_zicboz) { \
27a939c500SChristoph Muellner        return false;                \
28a939c500SChristoph Muellner    }                                \
29a939c500SChristoph Muellner} while (0)
30a939c500SChristoph Muellner
31e05da09bSChristoph Muellnerstatic bool trans_cbo_clean(DisasContext *ctx, arg_cbo_clean *a)
32e05da09bSChristoph Muellner{
33e05da09bSChristoph Muellner    REQUIRE_ZICBOM(ctx);
34*c5eb8d63SAlistair Francis    TCGv src = get_address(ctx, a->rs1, 0);
35*c5eb8d63SAlistair Francis
36*c5eb8d63SAlistair Francis    gen_helper_cbo_clean_flush(tcg_env, src);
37e05da09bSChristoph Muellner    return true;
38e05da09bSChristoph Muellner}
39e05da09bSChristoph Muellner
40e05da09bSChristoph Muellnerstatic bool trans_cbo_flush(DisasContext *ctx, arg_cbo_flush *a)
41e05da09bSChristoph Muellner{
42e05da09bSChristoph Muellner    REQUIRE_ZICBOM(ctx);
43*c5eb8d63SAlistair Francis    TCGv src = get_address(ctx, a->rs1, 0);
44*c5eb8d63SAlistair Francis
45*c5eb8d63SAlistair Francis    gen_helper_cbo_clean_flush(tcg_env, src);
46e05da09bSChristoph Muellner    return true;
47e05da09bSChristoph Muellner}
48e05da09bSChristoph Muellner
49e05da09bSChristoph Muellnerstatic bool trans_cbo_inval(DisasContext *ctx, arg_cbo_inval *a)
50e05da09bSChristoph Muellner{
51e05da09bSChristoph Muellner    REQUIRE_ZICBOM(ctx);
52*c5eb8d63SAlistair Francis    TCGv src = get_address(ctx, a->rs1, 0);
53*c5eb8d63SAlistair Francis
54*c5eb8d63SAlistair Francis    gen_helper_cbo_inval(tcg_env, src);
55e05da09bSChristoph Muellner    return true;
56e05da09bSChristoph Muellner}
57e05da09bSChristoph Muellner
58a939c500SChristoph Muellnerstatic bool trans_cbo_zero(DisasContext *ctx, arg_cbo_zero *a)
59a939c500SChristoph Muellner{
60a939c500SChristoph Muellner    REQUIRE_ZICBOZ(ctx);
61*c5eb8d63SAlistair Francis    TCGv src = get_address(ctx, a->rs1, 0);
62*c5eb8d63SAlistair Francis
63*c5eb8d63SAlistair Francis    gen_helper_cbo_zero(tcg_env, src);
64a939c500SChristoph Muellner    return true;
65a939c500SChristoph Muellner}
66