|
From: | Lucas Mateus Martins Araujo e Castro |
Subject: | Re: [PATCH 03/10] target/ppc: Implemented vector divide instructions |
Date: | Thu, 31 Mar 2022 15:28:53 -0300 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 |
Ok, I'll set VECE based on which function is NULL
On 3/30/22 14:25, Lucas Mateus Castro(alqotel) wrote:
+#define TRANS_VDIV_VMOD(FLAGS, NAME, VECE, FNI4_FUNC, FNI8_FUNC) \
+static bool trans_##NAME(DisasContext *ctx, arg_VX *a) \
+{ \
+ static const GVecGen3 op[2] = { \
+ { \
+ .fni4 = FNI4_FUNC, \
+ .fni8 = FNI8_FUNC, \
+ .vece = MO_32 \
+ }, \
+ { \
+ .fni4 = FNI4_FUNC, \
+ .fni8 = FNI8_FUNC, \
+ .vece = MO_64 \
+ }, \
+ }; \
There is zero point in having a two element array here:
(1) VECE is a constant
(2) The unused array element is actively wrong.
My idea here was mostly to mimic the hardware behavior, testing on a Power9 both divw and divd result in 0 when N/0 and mambo results in 0 in vdiv* and vmod* when N/0, but yeah the PowerISA just said that it's undefined. I'll just set b = 1 if N/0 or int_min/-1 in v2 then.
+#define DIV_VEC(NAME, SZ, DIV) \
+static void do_vx_##NAME(TCGv_##SZ t, TCGv_##SZ a, TCGv_##SZ b) \
+{ \
+ TCGv_##SZ zero = tcg_constant_##SZ(0), _one_ = tcg_constant_##SZ(1); \
+ /* \
+ * If N/0 the instruction used by the backend might deliver \
+ * a signal to the process and the hardware returns 0 when \
+ * N/0, so if b = 0 return 0/1 \
+ */ \
+ tcg_gen_movcond_##SZ(TCG_COND_EQ, a, b, zero, zero, a); \
+ tcg_gen_movcond_##SZ(TCG_COND_EQ, b, b, zero, one, b); \
+ DIV(t, a, b); \
+}
The manual says N/0 = undefined. I don't think it's important to require 0.
My mistake, I'll add this check in v2
The signed versions still need to check for int_min / -1, which will fault on x86.
Compare vs gen_op_arith_div{w,d}.
r~
[Prev in Thread] | Current Thread | [Next in Thread] |