1/*
2 * RISC-V translation routines for the RVB Standard Extension.
3 *
4 * Copyright (c) 2020 Kito Cheng, kito.cheng@sifive.com
5 * Copyright (c) 2020 Frank Chang, frank.chang@sifive.com
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2 or later, as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20static bool trans_clz(DisasContext *ctx, arg_clz *a)
21{
22    REQUIRE_EXT(ctx, RVB);
23    return gen_unary(ctx, a, gen_clz);
24}
25
26static bool trans_ctz(DisasContext *ctx, arg_ctz *a)
27{
28    REQUIRE_EXT(ctx, RVB);
29    return gen_unary(ctx, a, gen_ctz);
30}
31
32static bool trans_cpop(DisasContext *ctx, arg_cpop *a)
33{
34    REQUIRE_EXT(ctx, RVB);
35    return gen_unary(ctx, a, tcg_gen_ctpop_tl);
36}
37
38static bool trans_andn(DisasContext *ctx, arg_andn *a)
39{
40    REQUIRE_EXT(ctx, RVB);
41    return gen_arith(ctx, a, tcg_gen_andc_tl);
42}
43
44static bool trans_orn(DisasContext *ctx, arg_orn *a)
45{
46    REQUIRE_EXT(ctx, RVB);
47    return gen_arith(ctx, a, tcg_gen_orc_tl);
48}
49
50static bool trans_xnor(DisasContext *ctx, arg_xnor *a)
51{
52    REQUIRE_EXT(ctx, RVB);
53    return gen_arith(ctx, a, tcg_gen_eqv_tl);
54}
55
56static bool trans_pack(DisasContext *ctx, arg_pack *a)
57{
58    REQUIRE_EXT(ctx, RVB);
59    return gen_arith(ctx, a, gen_pack);
60}
61
62static bool trans_packu(DisasContext *ctx, arg_packu *a)
63{
64    REQUIRE_EXT(ctx, RVB);
65    return gen_arith(ctx, a, gen_packu);
66}
67
68static bool trans_packh(DisasContext *ctx, arg_packh *a)
69{
70    REQUIRE_EXT(ctx, RVB);
71    return gen_arith(ctx, a, gen_packh);
72}
73
74static bool trans_min(DisasContext *ctx, arg_min *a)
75{
76    REQUIRE_EXT(ctx, RVB);
77    return gen_arith(ctx, a, tcg_gen_smin_tl);
78}
79
80static bool trans_max(DisasContext *ctx, arg_max *a)
81{
82    REQUIRE_EXT(ctx, RVB);
83    return gen_arith(ctx, a, tcg_gen_smax_tl);
84}
85
86static bool trans_minu(DisasContext *ctx, arg_minu *a)
87{
88    REQUIRE_EXT(ctx, RVB);
89    return gen_arith(ctx, a, tcg_gen_umin_tl);
90}
91
92static bool trans_maxu(DisasContext *ctx, arg_maxu *a)
93{
94    REQUIRE_EXT(ctx, RVB);
95    return gen_arith(ctx, a, tcg_gen_umax_tl);
96}
97
98static bool trans_sext_b(DisasContext *ctx, arg_sext_b *a)
99{
100    REQUIRE_EXT(ctx, RVB);
101    return gen_unary(ctx, a, tcg_gen_ext8s_tl);
102}
103
104static bool trans_sext_h(DisasContext *ctx, arg_sext_h *a)
105{
106    REQUIRE_EXT(ctx, RVB);
107    return gen_unary(ctx, a, tcg_gen_ext16s_tl);
108}
109
110static bool trans_clzw(DisasContext *ctx, arg_clzw *a)
111{
112    REQUIRE_64BIT(ctx);
113    REQUIRE_EXT(ctx, RVB);
114    return gen_unary(ctx, a, gen_clzw);
115}
116
117static bool trans_ctzw(DisasContext *ctx, arg_ctzw *a)
118{
119    REQUIRE_64BIT(ctx);
120    REQUIRE_EXT(ctx, RVB);
121    return gen_unary(ctx, a, gen_ctzw);
122}
123
124static bool trans_cpopw(DisasContext *ctx, arg_cpopw *a)
125{
126    REQUIRE_64BIT(ctx);
127    REQUIRE_EXT(ctx, RVB);
128    return gen_unary(ctx, a, gen_cpopw);
129}
130
131static bool trans_packw(DisasContext *ctx, arg_packw *a)
132{
133    REQUIRE_64BIT(ctx);
134    REQUIRE_EXT(ctx, RVB);
135    return gen_arith(ctx, a, gen_packw);
136}
137
138static bool trans_packuw(DisasContext *ctx, arg_packuw *a)
139{
140    REQUIRE_64BIT(ctx);
141    REQUIRE_EXT(ctx, RVB);
142    return gen_arith(ctx, a, gen_packuw);
143}
144