1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright (c) 2021 Loongson Technology Corporation Limited
6 /* bit0(signaling/quiet) bit1(lt) bit2(eq) bit3(un) bit4(neq) */
7 static uint32_t get_fcmp_flags(int cond)
21 flags |= FCMP_GT | FCMP_LT;
26 static bool trans_fcmp_cond_s(DisasContext *ctx, arg_fcmp_cond_s *a)
28 TCGv var = tcg_temp_new();
30 void (*fn)(TCGv, TCGv_env, TCGv, TCGv, TCGv_i32);
32 fn = (a->fcond & 1 ? gen_helper_fcmp_s_s : gen_helper_fcmp_c_s);
33 flags = get_fcmp_flags(a->fcond >> 1);
35 fn(var, cpu_env, cpu_fpr[a->fj], cpu_fpr[a->fk], tcg_constant_i32(flags));
37 tcg_gen_st8_tl(var, cpu_env, offsetof(CPULoongArchState, cf[a->cd]));
42 static bool trans_fcmp_cond_d(DisasContext *ctx, arg_fcmp_cond_d *a)
44 TCGv var = tcg_temp_new();
46 void (*fn)(TCGv, TCGv_env, TCGv, TCGv, TCGv_i32);
47 fn = (a->fcond & 1 ? gen_helper_fcmp_s_d : gen_helper_fcmp_c_d);
48 flags = get_fcmp_flags(a->fcond >> 1);
50 fn(var, cpu_env, cpu_fpr[a->fj], cpu_fpr[a->fk], tcg_constant_i32(flags));
52 tcg_gen_st8_tl(var, cpu_env, offsetof(CPULoongArchState, cf[a->cd]));