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_bset(DisasContext *ctx, arg_bset *a) 111{ 112 REQUIRE_EXT(ctx, RVB); 113 return gen_shift(ctx, a, gen_bset); 114} 115 116static bool trans_bseti(DisasContext *ctx, arg_bseti *a) 117{ 118 REQUIRE_EXT(ctx, RVB); 119 return gen_shifti(ctx, a, gen_bset); 120} 121 122static bool trans_bclr(DisasContext *ctx, arg_bclr *a) 123{ 124 REQUIRE_EXT(ctx, RVB); 125 return gen_shift(ctx, a, gen_bclr); 126} 127 128static bool trans_bclri(DisasContext *ctx, arg_bclri *a) 129{ 130 REQUIRE_EXT(ctx, RVB); 131 return gen_shifti(ctx, a, gen_bclr); 132} 133 134static bool trans_binv(DisasContext *ctx, arg_binv *a) 135{ 136 REQUIRE_EXT(ctx, RVB); 137 return gen_shift(ctx, a, gen_binv); 138} 139 140static bool trans_binvi(DisasContext *ctx, arg_binvi *a) 141{ 142 REQUIRE_EXT(ctx, RVB); 143 return gen_shifti(ctx, a, gen_binv); 144} 145 146static bool trans_bext(DisasContext *ctx, arg_bext *a) 147{ 148 REQUIRE_EXT(ctx, RVB); 149 return gen_shift(ctx, a, gen_bext); 150} 151 152static bool trans_bexti(DisasContext *ctx, arg_bexti *a) 153{ 154 REQUIRE_EXT(ctx, RVB); 155 return gen_shifti(ctx, a, gen_bext); 156} 157 158static bool trans_slo(DisasContext *ctx, arg_slo *a) 159{ 160 REQUIRE_EXT(ctx, RVB); 161 return gen_shift(ctx, a, gen_slo); 162} 163 164static bool trans_sloi(DisasContext *ctx, arg_sloi *a) 165{ 166 REQUIRE_EXT(ctx, RVB); 167 return gen_shifti(ctx, a, gen_slo); 168} 169 170static bool trans_sro(DisasContext *ctx, arg_sro *a) 171{ 172 REQUIRE_EXT(ctx, RVB); 173 return gen_shift(ctx, a, gen_sro); 174} 175 176static bool trans_sroi(DisasContext *ctx, arg_sroi *a) 177{ 178 REQUIRE_EXT(ctx, RVB); 179 return gen_shifti(ctx, a, gen_sro); 180} 181 182static bool trans_clzw(DisasContext *ctx, arg_clzw *a) 183{ 184 REQUIRE_64BIT(ctx); 185 REQUIRE_EXT(ctx, RVB); 186 return gen_unary(ctx, a, gen_clzw); 187} 188 189static bool trans_ctzw(DisasContext *ctx, arg_ctzw *a) 190{ 191 REQUIRE_64BIT(ctx); 192 REQUIRE_EXT(ctx, RVB); 193 return gen_unary(ctx, a, gen_ctzw); 194} 195 196static bool trans_cpopw(DisasContext *ctx, arg_cpopw *a) 197{ 198 REQUIRE_64BIT(ctx); 199 REQUIRE_EXT(ctx, RVB); 200 return gen_unary(ctx, a, gen_cpopw); 201} 202 203static bool trans_packw(DisasContext *ctx, arg_packw *a) 204{ 205 REQUIRE_64BIT(ctx); 206 REQUIRE_EXT(ctx, RVB); 207 return gen_arith(ctx, a, gen_packw); 208} 209 210static bool trans_packuw(DisasContext *ctx, arg_packuw *a) 211{ 212 REQUIRE_64BIT(ctx); 213 REQUIRE_EXT(ctx, RVB); 214 return gen_arith(ctx, a, gen_packuw); 215} 216 217static bool trans_bsetw(DisasContext *ctx, arg_bsetw *a) 218{ 219 REQUIRE_64BIT(ctx); 220 REQUIRE_EXT(ctx, RVB); 221 return gen_shiftw(ctx, a, gen_bset); 222} 223 224static bool trans_bsetiw(DisasContext *ctx, arg_bsetiw *a) 225{ 226 REQUIRE_64BIT(ctx); 227 REQUIRE_EXT(ctx, RVB); 228 return gen_shiftiw(ctx, a, gen_bset); 229} 230 231static bool trans_bclrw(DisasContext *ctx, arg_bclrw *a) 232{ 233 REQUIRE_64BIT(ctx); 234 REQUIRE_EXT(ctx, RVB); 235 return gen_shiftw(ctx, a, gen_bclr); 236} 237 238static bool trans_bclriw(DisasContext *ctx, arg_bclriw *a) 239{ 240 REQUIRE_64BIT(ctx); 241 REQUIRE_EXT(ctx, RVB); 242 return gen_shiftiw(ctx, a, gen_bclr); 243} 244 245static bool trans_binvw(DisasContext *ctx, arg_binvw *a) 246{ 247 REQUIRE_64BIT(ctx); 248 REQUIRE_EXT(ctx, RVB); 249 return gen_shiftw(ctx, a, gen_binv); 250} 251 252static bool trans_binviw(DisasContext *ctx, arg_binviw *a) 253{ 254 REQUIRE_64BIT(ctx); 255 REQUIRE_EXT(ctx, RVB); 256 return gen_shiftiw(ctx, a, gen_binv); 257} 258 259static bool trans_bextw(DisasContext *ctx, arg_bextw *a) 260{ 261 REQUIRE_64BIT(ctx); 262 REQUIRE_EXT(ctx, RVB); 263 return gen_shiftw(ctx, a, gen_bext); 264} 265 266static bool trans_slow(DisasContext *ctx, arg_slow *a) 267{ 268 REQUIRE_64BIT(ctx); 269 REQUIRE_EXT(ctx, RVB); 270 return gen_shiftw(ctx, a, gen_slo); 271} 272 273static bool trans_sloiw(DisasContext *ctx, arg_sloiw *a) 274{ 275 REQUIRE_64BIT(ctx); 276 REQUIRE_EXT(ctx, RVB); 277 return gen_shiftiw(ctx, a, gen_slo); 278} 279 280static bool trans_srow(DisasContext *ctx, arg_srow *a) 281{ 282 REQUIRE_64BIT(ctx); 283 REQUIRE_EXT(ctx, RVB); 284 return gen_shiftw(ctx, a, gen_sro); 285} 286 287static bool trans_sroiw(DisasContext *ctx, arg_sroiw *a) 288{ 289 REQUIRE_64BIT(ctx); 290 REQUIRE_EXT(ctx, RVB); 291 return gen_shiftiw(ctx, a, gen_sro); 292} 293