]> Git Repo - qemu.git/blob - target/loongarch/insn_trans/trans_fcmp.c.inc
target/loongarch: Add floating point comparison instruction translation
[qemu.git] / target / loongarch / insn_trans / trans_fcmp.c.inc
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Copyright (c) 2021 Loongson Technology Corporation Limited
4  */
5
6 /* bit0(signaling/quiet) bit1(lt) bit2(eq) bit3(un) bit4(neq) */
7 static uint32_t get_fcmp_flags(int cond)
8 {
9     uint32_t flags = 0;
10
11     if (cond & 0x1) {
12         flags |= FCMP_LT;
13     }
14     if (cond & 0x2) {
15         flags |= FCMP_EQ;
16     }
17     if (cond & 0x4) {
18         flags |= FCMP_UN;
19     }
20     if (cond & 0x8) {
21         flags |= FCMP_GT | FCMP_LT;
22     }
23     return flags;
24 }
25
26 static bool trans_fcmp_cond_s(DisasContext *ctx, arg_fcmp_cond_s *a)
27 {
28     TCGv var = tcg_temp_new();
29     uint32_t flags;
30     void (*fn)(TCGv, TCGv_env, TCGv, TCGv, TCGv_i32);
31
32     fn = (a->fcond & 1 ? gen_helper_fcmp_s_s : gen_helper_fcmp_c_s);
33     flags = get_fcmp_flags(a->fcond >> 1);
34
35     fn(var, cpu_env, cpu_fpr[a->fj], cpu_fpr[a->fk], tcg_constant_i32(flags));
36
37     tcg_gen_st8_tl(var, cpu_env, offsetof(CPULoongArchState, cf[a->cd]));
38     tcg_temp_free(var);
39     return true;
40 }
41
42 static bool trans_fcmp_cond_d(DisasContext *ctx, arg_fcmp_cond_d *a)
43 {
44     TCGv var = tcg_temp_new();
45     uint32_t flags;
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);
49
50     fn(var, cpu_env, cpu_fpr[a->fj], cpu_fpr[a->fk], tcg_constant_i32(flags));
51
52     tcg_gen_st8_tl(var, cpu_env, offsetof(CPULoongArchState, cf[a->cd]));
53
54     tcg_temp_free(var);
55     return true;
56 }
This page took 0.024023 seconds and 4 git commands to generate.