1*b8e1f32cSWeiwei Li/* 2*b8e1f32cSWeiwei Li * RISC-V translation routines for the Zicond Standard Extension. 3*b8e1f32cSWeiwei Li * 4*b8e1f32cSWeiwei Li * Copyright (c) 2020-2023 PLCT Lab 5*b8e1f32cSWeiwei Li * 6*b8e1f32cSWeiwei Li * This program is free software; you can redistribute it and/or modify it 7*b8e1f32cSWeiwei Li * under the terms and conditions of the GNU General Public License, 8*b8e1f32cSWeiwei Li * version 2 or later, as published by the Free Software Foundation. 9*b8e1f32cSWeiwei Li * 10*b8e1f32cSWeiwei Li * This program is distributed in the hope it will be useful, but WITHOUT 11*b8e1f32cSWeiwei Li * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12*b8e1f32cSWeiwei Li * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13*b8e1f32cSWeiwei Li * more details. 14*b8e1f32cSWeiwei Li * 15*b8e1f32cSWeiwei Li * You should have received a copy of the GNU General Public License along with 16*b8e1f32cSWeiwei Li * this program. If not, see <http://www.gnu.org/licenses/>. 17*b8e1f32cSWeiwei Li */ 18*b8e1f32cSWeiwei Li 19*b8e1f32cSWeiwei Li#define REQUIRE_ZICOND(ctx) do { \ 20*b8e1f32cSWeiwei Li if (!ctx->cfg_ptr->ext_zicond) { \ 21*b8e1f32cSWeiwei Li return false; \ 22*b8e1f32cSWeiwei Li } \ 23*b8e1f32cSWeiwei Li} while (0) 24*b8e1f32cSWeiwei Li 25*b8e1f32cSWeiwei Listatic bool trans_czero_eqz(DisasContext *ctx, arg_czero_eqz *a) 26*b8e1f32cSWeiwei Li{ 27*b8e1f32cSWeiwei Li REQUIRE_ZICOND(ctx); 28*b8e1f32cSWeiwei Li 29*b8e1f32cSWeiwei Li TCGv dest = dest_gpr(ctx, a->rd); 30*b8e1f32cSWeiwei Li TCGv src1 = get_gpr(ctx, a->rs1, EXT_NONE); 31*b8e1f32cSWeiwei Li TCGv src2 = get_gpr(ctx, a->rs2, EXT_NONE); 32*b8e1f32cSWeiwei Li 33*b8e1f32cSWeiwei Li tcg_gen_movcond_tl(TCG_COND_EQ, dest, src2, ctx->zero, ctx->zero, src1); 34*b8e1f32cSWeiwei Li gen_set_gpr(ctx, a->rd, dest); 35*b8e1f32cSWeiwei Li return true; 36*b8e1f32cSWeiwei Li} 37*b8e1f32cSWeiwei Li 38*b8e1f32cSWeiwei Listatic bool trans_czero_nez(DisasContext *ctx, arg_czero_nez *a) 39*b8e1f32cSWeiwei Li{ 40*b8e1f32cSWeiwei Li REQUIRE_ZICOND(ctx); 41*b8e1f32cSWeiwei Li 42*b8e1f32cSWeiwei Li TCGv dest = dest_gpr(ctx, a->rd); 43*b8e1f32cSWeiwei Li TCGv src1 = get_gpr(ctx, a->rs1, EXT_NONE); 44*b8e1f32cSWeiwei Li TCGv src2 = get_gpr(ctx, a->rs2, EXT_NONE); 45*b8e1f32cSWeiwei Li 46*b8e1f32cSWeiwei Li tcg_gen_movcond_tl(TCG_COND_NE, dest, src2, ctx->zero, ctx->zero, src1); 47*b8e1f32cSWeiwei Li gen_set_gpr(ctx, a->rd, dest); 48*b8e1f32cSWeiwei Li return true; 49*b8e1f32cSWeiwei Li} 50