Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1md1wx-0001HV-FN for mharc-qemu-riscv@gnu.org; Tue, 19 Oct 2021 23:07:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45390) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1md1ws-0001Cj-D6 for qemu-riscv@nongnu.org; Tue, 19 Oct 2021 23:07:26 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]:43777) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1md1wq-0002oT-JY for qemu-riscv@nongnu.org; Tue, 19 Oct 2021 23:07:26 -0400 Received: by mail-pf1-x430.google.com with SMTP id 187so1689199pfc.10 for ; Tue, 19 Oct 2021 20:07:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fgFROQocXZ7y4KffuZM26+g2jcGFqpk2OVZuAODchdg=; b=ijj2ywgFo2vHXdbCyHrNA6zI9Peh3/fgnwEMJQS+XdfXbhL3D4phxxPBIjD7xRToOk CbR+oA7ie0z0f2v1oUpyS8/YvHNhTk9fuFFt2rAxpbvTg4XDlpdyBDXmTKgjxPyug8FT SCFvX90Jp4lsKrwaxF/b03zpBTEpwVHScu5zXf6Uqsc419fArwG2bZQjJwZoigzjn6Ya PzA/5X88MihPILdz7u+ht9gYbjQDRgaSP/Ci1mKzUVpgjGExNOPeV/WP7R186fut0NmH fFLZk1UoSyZfaGBRmkPSbmFSw8RMQ616TvEPk2MbAFmxid/u4zXy3l09uKS6Q2ZrddIf eykg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fgFROQocXZ7y4KffuZM26+g2jcGFqpk2OVZuAODchdg=; b=e1+2jYfPup7DI+TxLoU68YGU/wo6gwxhcfp3AdKBcwh7sKPZgdQI/OXR1s1OAnqzG2 1FqkyUAIWZ8emRajiQXbEOO2q+HPeX7oEt80+gjxHytOVq49KSjBpJmdgit5iPa/E4lp cTEovpzCrwSA42JvvBzhBTqvRNAKiA+MI8mzdELXNchmN031KhCpMJ36p+2HIFDGTDU7 Uf+S3Q61nucaukdPqdrKlwzyqqXnMaAiZwIVyI0+9DG5diIx5Np7url98yma7sjyZKWD xHhRaQlHW8LqWj7gm/HQ6kZ260/aFojLXYyB4t5MXdOL3IeGFQSTYHCQXDmPSJhRrZR1 0O+g== X-Gm-Message-State: AOAM530gGfVzzldAuE0GbRHcwMGT5np+aCf4ITcijdcl7mY/o1b8GmfD Gh/Ui1WN/OoJw7ekOjNYXN2t7p1wEYu8kg== X-Google-Smtp-Source: ABdhPJzjhuqt5c0pmBINS+2fK7g2EZxcCpOeeacoppfs6W3E0OJAOxphQ97IHrdgwi2HMVRLOugswA== X-Received: by 2002:a63:5453:: with SMTP id e19mr31435941pgm.178.1634699243085; Tue, 19 Oct 2021 20:07:23 -0700 (PDT) Received: from localhost.localdomain (123-193-74-252.dynamic.kbronet.com.tw. [123.193.74.252]) by smtp.gmail.com with ESMTPSA id y18sm574443pfb.106.2021.10.19.20.07.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Oct 2021 20:07:22 -0700 (PDT) From: frank.chang@sifive.com To: qemu-riscv@nongnu.org Cc: Kito Cheng , Chih-Min Chao , Frank Chang , Richard Henderson , Alistair Francis , Palmer Dabbelt , Bin Meng , qemu-devel@nongnu.org Subject: [PATCH v4 5/8] target/riscv: zfh: half-precision floating-point classify Date: Wed, 20 Oct 2021 11:06:48 +0800 Message-Id: <20211020030653.213565-6-frank.chang@sifive.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211020030653.213565-1-frank.chang@sifive.com> References: <20211020030653.213565-1-frank.chang@sifive.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=frank.chang@sifive.com; helo=mail-pf1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-riscv@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Oct 2021 03:07:26 -0000 From: Kito Cheng Signed-off-by: Kito Cheng Signed-off-by: Chih-Min Chao Signed-off-by: Frank Chang Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis --- target/riscv/fpu_helper.c | 6 ++++++ target/riscv/helper.h | 1 + target/riscv/insn32.decode | 1 + target/riscv/insn_trans/trans_rvzfh.c.inc | 12 ++++++++++++ 4 files changed, 20 insertions(+) diff --git a/target/riscv/fpu_helper.c b/target/riscv/fpu_helper.c index ec2009ee65b..388e23ca670 100644 --- a/target/riscv/fpu_helper.c +++ b/target/riscv/fpu_helper.c @@ -482,6 +482,12 @@ target_ulong helper_feq_h(CPURISCVState *env, uint64_t rs1, uint64_t rs2) return float16_eq_quiet(frs1, frs2, &env->fp_status); } +target_ulong helper_fclass_h(uint64_t rs1) +{ + float16 frs1 = check_nanbox_h(rs1); + return fclass_h(frs1); +} + target_ulong helper_fcvt_w_h(CPURISCVState *env, uint64_t rs1) { float16 frs1 = check_nanbox_h(rs1); diff --git a/target/riscv/helper.h b/target/riscv/helper.h index 9c89521d4ad..d25cf725c57 100644 --- a/target/riscv/helper.h +++ b/target/riscv/helper.h @@ -89,6 +89,7 @@ DEF_HELPER_FLAGS_2(fcvt_h_w, TCG_CALL_NO_RWG, i64, env, tl) DEF_HELPER_FLAGS_2(fcvt_h_wu, TCG_CALL_NO_RWG, i64, env, tl) DEF_HELPER_FLAGS_2(fcvt_h_l, TCG_CALL_NO_RWG, i64, env, tl) DEF_HELPER_FLAGS_2(fcvt_h_lu, TCG_CALL_NO_RWG, i64, env, tl) +DEF_HELPER_FLAGS_1(fclass_h, TCG_CALL_NO_RWG_SE, tl, i64) /* Special functions */ DEF_HELPER_2(csrr, tl, env, int) diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode index 3906c9fb201..6c4cde216bc 100644 --- a/target/riscv/insn32.decode +++ b/target/riscv/insn32.decode @@ -754,6 +754,7 @@ fmv_x_h 1110010 00000 ..... 000 ..... 1010011 @r2 feq_h 1010010 ..... ..... 010 ..... 1010011 @r flt_h 1010010 ..... ..... 001 ..... 1010011 @r fle_h 1010010 ..... ..... 000 ..... 1010011 @r +fclass_h 1110010 00000 ..... 001 ..... 1010011 @r2 fcvt_h_w 1101010 00000 ..... ... ..... 1010011 @r2_rm fcvt_h_wu 1101010 00001 ..... ... ..... 1010011 @r2_rm fmv_h_x 1111010 00000 ..... 000 ..... 1010011 @r2 diff --git a/target/riscv/insn_trans/trans_rvzfh.c.inc b/target/riscv/insn_trans/trans_rvzfh.c.inc index 8d0959a6671..0549e25fb45 100644 --- a/target/riscv/insn_trans/trans_rvzfh.c.inc +++ b/target/riscv/insn_trans/trans_rvzfh.c.inc @@ -372,6 +372,18 @@ static bool trans_fle_h(DisasContext *ctx, arg_fle_h *a) return true; } +static bool trans_fclass_h(DisasContext *ctx, arg_fclass_h *a) +{ + REQUIRE_FPU; + REQUIRE_ZFH(ctx); + + TCGv dest = dest_gpr(ctx, a->rd); + + gen_helper_fclass_h(dest, cpu_fpr[a->rs1]); + gen_set_gpr(ctx, a->rd, dest); + return true; +} + static bool trans_fcvt_w_h(DisasContext *ctx, arg_fcvt_w_h *a) { REQUIRE_FPU; -- 2.25.1