* [RFC PATCH 0/8] Alternative softfloat 128-bit integer support
@ 2022-03-30 17:59 matheus.ferst
2022-03-30 17:59 ` [RFC PATCH 1/8] qemu/int128: avoid undefined behavior in int128_lshift matheus.ferst
` (8 more replies)
0 siblings, 9 replies; 18+ messages in thread
From: matheus.ferst @ 2022-03-30 17:59 UTC (permalink / raw)
To: qemu-devel, qemu-ppc
Cc: danielhb413, richard.henderson, groug, clg, Matheus Ferst, david
From: Matheus Ferst <matheus.ferst@eldorado.org.br>
This RFC is an alternative to [1] using Int128 types to implement the
128-bit integer conversion routines in softfloat required by the
xscv[su]qqp and xscvqp[su]qz instructions of PowerISA v3.1.
Some improvements to int128.h are made in patches 1 and 2. Patches 3-6
implement the conversion routines, and patches 7 and 8 implement the new
instructions.
RFC: Int128 vs. pair of 64-bit values.
- Returning unsigned values through Int128 is not ideal, but creating
an "UInt128" just for this case seems excessive.
- OTOH, there are fewer cases to handle, especially in float->int.
[1] https://lists.gnu.org/archive/html/qemu-ppc/2022-03/msg00520.html
Matheus Ferst (8):
qemu/int128: avoid undefined behavior in int128_lshift
qemu/int128: add int128_urshift
softfloat: add uint128_to_float128
softfloat: add int128_to_float128
softfloat: add float128_to_uint128
softfloat: add float128_to_int128
target/ppc: implement xscv[su]qqp
target/ppc: implement xscvqp[su]qz
fpu/softfloat.c | 183 ++++++++++++++++++++++++++++
include/fpu/softfloat.h | 7 ++
include/qemu/int128.h | 25 +++-
target/ppc/fpu_helper.c | 33 +++++
target/ppc/helper.h | 4 +
target/ppc/insn32.decode | 7 ++
target/ppc/translate/vsx-impl.c.inc | 22 ++++
tests/unit/test-int128.c | 32 +++++
8 files changed, 311 insertions(+), 2 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 18+ messages in thread
* [RFC PATCH 1/8] qemu/int128: avoid undefined behavior in int128_lshift
2022-03-30 17:59 [RFC PATCH 0/8] Alternative softfloat 128-bit integer support matheus.ferst
@ 2022-03-30 17:59 ` matheus.ferst
2022-03-30 18:07 ` Richard Henderson
2022-03-30 17:59 ` [RFC PATCH 2/8] qemu/int128: add int128_urshift matheus.ferst
` (7 subsequent siblings)
8 siblings, 1 reply; 18+ messages in thread
From: matheus.ferst @ 2022-03-30 17:59 UTC (permalink / raw)
To: qemu-devel, qemu-ppc
Cc: danielhb413, richard.henderson, groug, clg, Matheus Ferst, david
From: Matheus Ferst <matheus.ferst@eldorado.org.br>
Avoid the left shift of negative values in int128_lshift by casting
a/a.hi to unsigned.
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
---
include/qemu/int128.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/qemu/int128.h b/include/qemu/int128.h
index 2c4064256c..2a19558ac6 100644
--- a/include/qemu/int128.h
+++ b/include/qemu/int128.h
@@ -85,7 +85,7 @@ static inline Int128 int128_rshift(Int128 a, int n)
static inline Int128 int128_lshift(Int128 a, int n)
{
- return a << n;
+ return (__uint128_t)a << n;
}
static inline Int128 int128_add(Int128 a, Int128 b)
@@ -305,7 +305,7 @@ static inline Int128 int128_lshift(Int128 a, int n)
if (n >= 64) {
return int128_make128(0, l);
} else if (n > 0) {
- return int128_make128(l, (a.hi << n) | (a.lo >> (64 - n)));
+ return int128_make128(l, ((uint64_t)a.hi << n) | (a.lo >> (64 - n)));
}
return a;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [RFC PATCH 2/8] qemu/int128: add int128_urshift
2022-03-30 17:59 [RFC PATCH 0/8] Alternative softfloat 128-bit integer support matheus.ferst
2022-03-30 17:59 ` [RFC PATCH 1/8] qemu/int128: avoid undefined behavior in int128_lshift matheus.ferst
@ 2022-03-30 17:59 ` matheus.ferst
2022-03-30 18:08 ` Richard Henderson
2022-03-30 17:59 ` [RFC PATCH 3/8] softfloat: add uint128_to_float128 matheus.ferst
` (6 subsequent siblings)
8 siblings, 1 reply; 18+ messages in thread
From: matheus.ferst @ 2022-03-30 17:59 UTC (permalink / raw)
To: qemu-devel, qemu-ppc
Cc: danielhb413, richard.henderson, groug, clg, Matheus Ferst, david
From: Matheus Ferst <matheus.ferst@eldorado.org.br>
Implement an unsigned right shift for Int128 values and add the same
tests cases of int128_rshift in the unit test.
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
---
include/qemu/int128.h | 19 +++++++++++++++++++
tests/unit/test-int128.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+)
diff --git a/include/qemu/int128.h b/include/qemu/int128.h
index 2a19558ac6..ca32b0b276 100644
--- a/include/qemu/int128.h
+++ b/include/qemu/int128.h
@@ -83,6 +83,11 @@ static inline Int128 int128_rshift(Int128 a, int n)
return a >> n;
}
+static inline Int128 int128_urshift(Int128 a, int n)
+{
+ return (__uint128_t)a >> n;
+}
+
static inline Int128 int128_lshift(Int128 a, int n)
{
return (__uint128_t)a << n;
@@ -299,6 +304,20 @@ static inline Int128 int128_rshift(Int128 a, int n)
}
}
+static inline Int128 int128_urshift(Int128 a, int n)
+{
+ uint64_t h = a.hi;
+ if (!n) {
+ return a;
+ }
+ h = h >> (n & 63);
+ if (n >= 64) {
+ return int128_make64(h);
+ } else {
+ return int128_make128((a.lo >> n) | ((uint64_t)a.hi << (64 - n)), h);
+ }
+}
+
static inline Int128 int128_lshift(Int128 a, int n)
{
uint64_t l = a.lo << (n & 63);
diff --git a/tests/unit/test-int128.c b/tests/unit/test-int128.c
index b86a3c76e6..ae0f552193 100644
--- a/tests/unit/test-int128.c
+++ b/tests/unit/test-int128.c
@@ -206,6 +206,37 @@ static void test_rshift(void)
test_rshift_one(0xFFFE8000U, 0, 0xFFFFFFFFFFFFFFFEULL, 0x8000000000000000ULL);
}
+static void __attribute__((__noinline__)) ATTRIBUTE_NOCLONE
+test_urshift_one(uint32_t x, int n, uint64_t h, uint64_t l)
+{
+ Int128 a = expand(x);
+ Int128 r = int128_urshift(a, n);
+ g_assert_cmpuint(int128_getlo(r), ==, l);
+ g_assert_cmpuint(int128_gethi(r), ==, h);
+}
+
+static void test_urshift(void)
+{
+ test_urshift_one(0x00010000U, 64, 0x0000000000000000ULL, 0x0000000000000001ULL);
+ test_urshift_one(0x80010000U, 64, 0x0000000000000000ULL, 0x8000000000000001ULL);
+ test_urshift_one(0x7FFE0000U, 64, 0x0000000000000000ULL, 0x7FFFFFFFFFFFFFFEULL);
+ test_urshift_one(0xFFFE0000U, 64, 0x0000000000000000ULL, 0xFFFFFFFFFFFFFFFEULL);
+ test_urshift_one(0x00010000U, 60, 0x0000000000000000ULL, 0x0000000000000010ULL);
+ test_urshift_one(0x80010000U, 60, 0x0000000000000008ULL, 0x0000000000000010ULL);
+ test_urshift_one(0x00018000U, 60, 0x0000000000000000ULL, 0x0000000000000018ULL);
+ test_urshift_one(0x80018000U, 60, 0x0000000000000008ULL, 0x0000000000000018ULL);
+ test_urshift_one(0x7FFE0000U, 60, 0x0000000000000007ULL, 0xFFFFFFFFFFFFFFE0ULL);
+ test_urshift_one(0xFFFE0000U, 60, 0x000000000000000FULL, 0xFFFFFFFFFFFFFFE0ULL);
+ test_urshift_one(0x7FFE8000U, 60, 0x0000000000000007ULL, 0xFFFFFFFFFFFFFFE8ULL);
+ test_urshift_one(0xFFFE8000U, 60, 0x000000000000000FULL, 0xFFFFFFFFFFFFFFE8ULL);
+ test_urshift_one(0x00018000U, 0, 0x0000000000000001ULL, 0x8000000000000000ULL);
+ test_urshift_one(0x80018000U, 0, 0x8000000000000001ULL, 0x8000000000000000ULL);
+ test_urshift_one(0x7FFE0000U, 0, 0x7FFFFFFFFFFFFFFEULL, 0x0000000000000000ULL);
+ test_urshift_one(0xFFFE0000U, 0, 0xFFFFFFFFFFFFFFFEULL, 0x0000000000000000ULL);
+ test_urshift_one(0x7FFE8000U, 0, 0x7FFFFFFFFFFFFFFEULL, 0x8000000000000000ULL);
+ test_urshift_one(0xFFFE8000U, 0, 0xFFFFFFFFFFFFFFFEULL, 0x8000000000000000ULL);
+}
+
int main(int argc, char **argv)
{
g_test_init(&argc, &argv, NULL);
@@ -219,5 +250,6 @@ int main(int argc, char **argv)
g_test_add_func("/int128/int128_ge", test_ge);
g_test_add_func("/int128/int128_gt", test_gt);
g_test_add_func("/int128/int128_rshift", test_rshift);
+ g_test_add_func("/int128/int128_urshift", test_urshift);
return g_test_run();
}
--
2.25.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [RFC PATCH 3/8] softfloat: add uint128_to_float128
2022-03-30 17:59 [RFC PATCH 0/8] Alternative softfloat 128-bit integer support matheus.ferst
2022-03-30 17:59 ` [RFC PATCH 1/8] qemu/int128: avoid undefined behavior in int128_lshift matheus.ferst
2022-03-30 17:59 ` [RFC PATCH 2/8] qemu/int128: add int128_urshift matheus.ferst
@ 2022-03-30 17:59 ` matheus.ferst
2022-03-30 18:10 ` Richard Henderson
2022-03-30 17:59 ` [RFC PATCH 4/8] softfloat: add int128_to_float128 matheus.ferst
` (5 subsequent siblings)
8 siblings, 1 reply; 18+ messages in thread
From: matheus.ferst @ 2022-03-30 17:59 UTC (permalink / raw)
To: qemu-devel, qemu-ppc
Cc: Peter Maydell, Alex Bennée, danielhb413, richard.henderson,
groug, clg, Matheus Ferst, Aurelien Jarno, david
From: Matheus Ferst <matheus.ferst@eldorado.org.br>
Based on parts_uint_to_float, implements uint128_to_float128 to convert
an unsigned 128-bit value received through an Int128 argument.
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
---
fpu/softfloat.c | 25 +++++++++++++++++++++++++
include/fpu/softfloat.h | 2 ++
2 files changed, 27 insertions(+)
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 7f524d4377..57445b36e7 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -3969,6 +3969,31 @@ float128 uint64_to_float128(uint64_t a, float_status *status)
return float128_round_pack_canonical(&p, status);
}
+float128 uint128_to_float128(Int128 a, float_status *status)
+{
+ FloatParts128 p = { };
+ int shift;
+
+ if (int128_nz(a)) {
+ p.cls = float_class_normal;
+
+ shift = clz64(int128_gethi(a));
+ if (shift == 64) {
+ shift += clz64(int128_getlo(a));
+ }
+
+ p.exp = 127 - shift;
+ a = int128_lshift(a, shift);
+
+ p.frac_hi = int128_gethi(a);
+ p.frac_lo = int128_getlo(a);
+ } else {
+ p.cls = float_class_zero;
+ }
+
+ return float128_round_pack_canonical(&p, status);
+}
+
/*
* Minimum and maximum
*/
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
index d34b2c44d2..8e026e5610 100644
--- a/include/fpu/softfloat.h
+++ b/include/fpu/softfloat.h
@@ -95,6 +95,7 @@ typedef enum {
#include "fpu/softfloat-types.h"
#include "fpu/softfloat-helpers.h"
+#include "qemu/int128.h"
/*----------------------------------------------------------------------------
| Routine to raise any or all of the software IEC/IEEE floating-point
@@ -183,6 +184,7 @@ floatx80 int64_to_floatx80(int64_t, float_status *status);
float128 int32_to_float128(int32_t, float_status *status);
float128 int64_to_float128(int64_t, float_status *status);
float128 uint64_to_float128(uint64_t, float_status *status);
+float128 uint128_to_float128(Int128, float_status *status);
/*----------------------------------------------------------------------------
| Software half-precision conversion routines.
--
2.25.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [RFC PATCH 4/8] softfloat: add int128_to_float128
2022-03-30 17:59 [RFC PATCH 0/8] Alternative softfloat 128-bit integer support matheus.ferst
` (2 preceding siblings ...)
2022-03-30 17:59 ` [RFC PATCH 3/8] softfloat: add uint128_to_float128 matheus.ferst
@ 2022-03-30 17:59 ` matheus.ferst
2022-03-30 18:11 ` Richard Henderson
2022-03-30 17:59 ` [RFC PATCH 5/8] softfloat: add float128_to_uint128 matheus.ferst
` (4 subsequent siblings)
8 siblings, 1 reply; 18+ messages in thread
From: matheus.ferst @ 2022-03-30 17:59 UTC (permalink / raw)
To: qemu-devel, qemu-ppc
Cc: Peter Maydell, Alex Bennée, danielhb413, richard.henderson,
groug, clg, Matheus Ferst, Aurelien Jarno, david
From: Matheus Ferst <matheus.ferst@eldorado.org.br>
Based on parts_sint_to_float, implements int128_to_float128 to convert a
signed 128-bit value received through an Int128 argument.
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
---
fpu/softfloat.c | 29 +++++++++++++++++++++++++++++
include/fpu/softfloat.h | 1 +
2 files changed, 30 insertions(+)
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 57445b36e7..60b4702945 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -3780,6 +3780,35 @@ bfloat16 int16_to_bfloat16(int16_t a, float_status *status)
return int64_to_bfloat16_scalbn(a, 0, status);
}
+float128 int128_to_float128(Int128 a, float_status *status)
+{
+ FloatParts128 p = { };
+ int shift;
+
+ if (int128_nz(a)) {
+ p.cls = float_class_normal;
+ if (!int128_nonneg(a)) {
+ p.sign = true;
+ a = int128_neg(a);
+ }
+
+ shift = clz64(int128_gethi(a));
+ if (shift == 64) {
+ shift += clz64(int128_getlo(a));
+ }
+
+ p.exp = 127 - shift;
+ a = int128_lshift(a, shift);
+
+ p.frac_hi = int128_gethi(a);
+ p.frac_lo = int128_getlo(a);
+ } else {
+ p.cls = float_class_zero;
+ }
+
+ return float128_round_pack_canonical(&p, status);
+}
+
float128 int64_to_float128(int64_t a, float_status *status)
{
FloatParts128 p;
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
index 8e026e5610..3994b7235d 100644
--- a/include/fpu/softfloat.h
+++ b/include/fpu/softfloat.h
@@ -183,6 +183,7 @@ floatx80 int64_to_floatx80(int64_t, float_status *status);
float128 int32_to_float128(int32_t, float_status *status);
float128 int64_to_float128(int64_t, float_status *status);
+float128 int128_to_float128(Int128, float_status *status);
float128 uint64_to_float128(uint64_t, float_status *status);
float128 uint128_to_float128(Int128, float_status *status);
--
2.25.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [RFC PATCH 5/8] softfloat: add float128_to_uint128
2022-03-30 17:59 [RFC PATCH 0/8] Alternative softfloat 128-bit integer support matheus.ferst
` (3 preceding siblings ...)
2022-03-30 17:59 ` [RFC PATCH 4/8] softfloat: add int128_to_float128 matheus.ferst
@ 2022-03-30 17:59 ` matheus.ferst
2022-03-30 18:13 ` Richard Henderson
2022-03-30 17:59 ` [RFC PATCH 6/8] softfloat: add float128_to_int128 matheus.ferst
` (3 subsequent siblings)
8 siblings, 1 reply; 18+ messages in thread
From: matheus.ferst @ 2022-03-30 17:59 UTC (permalink / raw)
To: qemu-devel, qemu-ppc
Cc: Peter Maydell, Alex Bennée, danielhb413, richard.henderson,
groug, clg, Matheus Ferst, Aurelien Jarno, david
From: Matheus Ferst <matheus.ferst@eldorado.org.br>
Implements float128_to_uint128 based on parts_float_to_uint logic.
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
---
fpu/softfloat.c | 65 +++++++++++++++++++++++++++++++++++++++++
include/fpu/softfloat.h | 2 ++
2 files changed, 67 insertions(+)
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 60b4702945..ce21b64e4f 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -3480,6 +3480,61 @@ static uint64_t float128_to_uint64_scalbn(float128 a, FloatRoundMode rmode,
return parts_float_to_uint(&p, rmode, scale, UINT64_MAX, s);
}
+static Int128 float128_to_uint128_scalbn(float128 a, FloatRoundMode rmode,
+ int scale, float_status *s)
+{
+ int flags = 0;
+ Int128 r;
+ FloatParts128 p;
+
+ float128_unpack_canonical(&p, a, s);
+
+ switch (p.cls) {
+ case float_class_snan:
+ flags |= float_flag_invalid_snan;
+ /* fall through */
+ case float_class_qnan:
+ flags |= float_flag_invalid;
+ r = UINT128_MAX;
+ break;
+
+ case float_class_inf:
+ flags = float_flag_invalid | float_flag_invalid_cvti;
+ r = p.sign ? int128_zero() : UINT128_MAX;
+ break;
+
+ case float_class_zero:
+ return int128_zero();
+
+ case float_class_normal:
+ if (parts_round_to_int_normal(&p, rmode, scale, 128 - 2)) {
+ flags = float_flag_inexact;
+ if (p.cls == float_class_zero) {
+ r = int128_zero();
+ break;
+ }
+ }
+
+ if (p.sign) {
+ flags = float_flag_invalid | float_flag_invalid_cvti;
+ r = int128_zero();
+ } else if (p.exp <= 127) {
+ int shift = 127 - p.exp;
+ r = int128_urshift(int128_make128(p.frac_lo, p.frac_hi), shift);
+ } else {
+ flags = float_flag_invalid | float_flag_invalid_cvti;
+ r = UINT128_MAX;
+ }
+ break;
+
+ default:
+ g_assert_not_reached();
+ }
+
+ float_raise(flags, s);
+ return r;
+}
+
uint8_t float16_to_uint8(float16 a, float_status *s)
{
return float16_to_uint8_scalbn(a, s->float_rounding_mode, 0, s);
@@ -3540,6 +3595,11 @@ uint64_t float128_to_uint64(float128 a, float_status *s)
return float128_to_uint64_scalbn(a, s->float_rounding_mode, 0, s);
}
+Int128 float128_to_uint128(float128 a, float_status *s)
+{
+ return float128_to_uint128_scalbn(a, s->float_rounding_mode, 0, s);
+}
+
uint16_t float16_to_uint16_round_to_zero(float16 a, float_status *s)
{
return float16_to_uint16_scalbn(a, float_round_to_zero, 0, s);
@@ -3595,6 +3655,11 @@ uint64_t float128_to_uint64_round_to_zero(float128 a, float_status *s)
return float128_to_uint64_scalbn(a, float_round_to_zero, 0, s);
}
+Int128 float128_to_uint128_round_to_zero(float128 a, float_status *s)
+{
+ return float128_to_uint128_scalbn(a, float_round_to_zero, 0, s);
+}
+
uint16_t bfloat16_to_uint16(bfloat16 a, float_status *s)
{
return bfloat16_to_uint16_scalbn(a, s->float_rounding_mode, 0, s);
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
index 3994b7235d..6cfe9ee474 100644
--- a/include/fpu/softfloat.h
+++ b/include/fpu/softfloat.h
@@ -1206,7 +1206,9 @@ int32_t float128_to_int32_round_to_zero(float128, float_status *status);
int64_t float128_to_int64(float128, float_status *status);
int64_t float128_to_int64_round_to_zero(float128, float_status *status);
uint64_t float128_to_uint64(float128, float_status *status);
+Int128 float128_to_uint128(float128, float_status *status);
uint64_t float128_to_uint64_round_to_zero(float128, float_status *status);
+Int128 float128_to_uint128_round_to_zero(float128, float_status *status);
uint32_t float128_to_uint32(float128, float_status *status);
uint32_t float128_to_uint32_round_to_zero(float128, float_status *status);
float32 float128_to_float32(float128, float_status *status);
--
2.25.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [RFC PATCH 6/8] softfloat: add float128_to_int128
2022-03-30 17:59 [RFC PATCH 0/8] Alternative softfloat 128-bit integer support matheus.ferst
` (4 preceding siblings ...)
2022-03-30 17:59 ` [RFC PATCH 5/8] softfloat: add float128_to_uint128 matheus.ferst
@ 2022-03-30 17:59 ` matheus.ferst
2022-03-30 18:14 ` Richard Henderson
2022-03-30 17:59 ` [RFC PATCH 7/8] target/ppc: implement xscv[su]qqp matheus.ferst
` (2 subsequent siblings)
8 siblings, 1 reply; 18+ messages in thread
From: matheus.ferst @ 2022-03-30 17:59 UTC (permalink / raw)
To: qemu-devel, qemu-ppc
Cc: Peter Maydell, Alex Bennée, danielhb413, richard.henderson,
groug, clg, Matheus Ferst, Aurelien Jarno, david
From: Matheus Ferst <matheus.ferst@eldorado.org.br>
Implements float128_to_int128 based on parts_float_to_int logic.
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
---
fpu/softfloat.c | 64 +++++++++++++++++++++++++++++++++++++++++
include/fpu/softfloat.h | 2 ++
include/qemu/int128.h | 2 ++
3 files changed, 68 insertions(+)
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index ce21b64e4f..5e2cf20448 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -3154,6 +3154,60 @@ static int64_t float128_to_int64_scalbn(float128 a, FloatRoundMode rmode,
return parts_float_to_sint(&p, rmode, scale, INT64_MIN, INT64_MAX, s);
}
+static Int128 float128_to_int128_scalbn(float128 a, FloatRoundMode rmode,
+ int scale, float_status *s)
+{
+ int flags = 0;
+ Int128 r;
+ FloatParts128 p;
+
+ float128_unpack_canonical(&p, a, s);
+
+ switch (p.cls) {
+ case float_class_snan:
+ flags |= float_flag_invalid_snan;
+ /* fall through */
+ case float_class_qnan:
+ flags |= float_flag_invalid;
+ r = UINT128_MAX;
+ break;
+
+ case float_class_inf:
+ flags = float_flag_invalid | float_flag_invalid_cvti;
+ r = p.sign ? INT128_MIN : INT128_MAX;
+ break;
+
+ case float_class_zero:
+ return int128_zero();
+
+ case float_class_normal:
+ if (parts_round_to_int_normal(&p, rmode, scale, 128 - 2)) {
+ flags = float_flag_inexact;
+ }
+
+ if (p.exp < 127) {
+ int shift = 127 - p.exp;
+ r = int128_urshift(int128_make128(p.frac_lo, p.frac_hi), shift);
+ if (p.sign) {
+ r = int128_neg(r);
+ }
+ } else if (p.exp == 127 && p.sign && p.frac_lo == 0 &&
+ p.frac_hi == DECOMPOSED_IMPLICIT_BIT) {
+ r = INT128_MIN;
+ } else {
+ flags = float_flag_invalid | float_flag_invalid_cvti;
+ r = p.sign ? INT128_MIN : INT128_MAX;
+ }
+ break;
+
+ default:
+ g_assert_not_reached();
+ }
+
+ float_raise(flags, s);
+ return r;
+}
+
static int32_t floatx80_to_int32_scalbn(floatx80 a, FloatRoundMode rmode,
int scale, float_status *s)
{
@@ -3236,6 +3290,11 @@ int64_t float128_to_int64(float128 a, float_status *s)
return float128_to_int64_scalbn(a, s->float_rounding_mode, 0, s);
}
+Int128 float128_to_int128(float128 a, float_status *s)
+{
+ return float128_to_int128_scalbn(a, s->float_rounding_mode, 0, s);
+}
+
int32_t floatx80_to_int32(floatx80 a, float_status *s)
{
return floatx80_to_int32_scalbn(a, s->float_rounding_mode, 0, s);
@@ -3301,6 +3360,11 @@ int64_t float128_to_int64_round_to_zero(float128 a, float_status *s)
return float128_to_int64_scalbn(a, float_round_to_zero, 0, s);
}
+Int128 float128_to_int128_round_to_zero(float128 a, float_status *s)
+{
+ return float128_to_int128_scalbn(a, float_round_to_zero, 0, s);
+}
+
int32_t floatx80_to_int32_round_to_zero(floatx80 a, float_status *s)
{
return floatx80_to_int32_scalbn(a, float_round_to_zero, 0, s);
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
index 6cfe9ee474..3dcf20e3a2 100644
--- a/include/fpu/softfloat.h
+++ b/include/fpu/softfloat.h
@@ -1204,7 +1204,9 @@ floatx80 floatx80_default_nan(float_status *status);
int32_t float128_to_int32(float128, float_status *status);
int32_t float128_to_int32_round_to_zero(float128, float_status *status);
int64_t float128_to_int64(float128, float_status *status);
+Int128 float128_to_int128(float128, float_status *status);
int64_t float128_to_int64_round_to_zero(float128, float_status *status);
+Int128 float128_to_int128_round_to_zero(float128, float_status *status);
uint64_t float128_to_uint64(float128, float_status *status);
Int128 float128_to_uint128(float128, float_status *status);
uint64_t float128_to_uint64_round_to_zero(float128, float_status *status);
diff --git a/include/qemu/int128.h b/include/qemu/int128.h
index ca32b0b276..17ea5f1372 100644
--- a/include/qemu/int128.h
+++ b/include/qemu/int128.h
@@ -431,5 +431,7 @@ static inline void bswap128s(Int128 *s)
}
#define UINT128_MAX int128_make128(~0LL, ~0LL)
+#define INT128_MAX int128_make128(UINT64_MAX, INT64_MAX)
+#define INT128_MIN int128_make128(0, INT64_MIN)
#endif /* INT128_H */
--
2.25.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [RFC PATCH 7/8] target/ppc: implement xscv[su]qqp
2022-03-30 17:59 [RFC PATCH 0/8] Alternative softfloat 128-bit integer support matheus.ferst
` (5 preceding siblings ...)
2022-03-30 17:59 ` [RFC PATCH 6/8] softfloat: add float128_to_int128 matheus.ferst
@ 2022-03-30 17:59 ` matheus.ferst
2022-03-30 18:15 ` Richard Henderson
2022-03-30 17:59 ` [RFC PATCH 8/8] target/ppc: implement xscvqp[su]qz matheus.ferst
2022-04-20 19:14 ` [RFC PATCH 0/8] Alternative softfloat 128-bit integer support Daniel Henrique Barboza
8 siblings, 1 reply; 18+ messages in thread
From: matheus.ferst @ 2022-03-30 17:59 UTC (permalink / raw)
To: qemu-devel, qemu-ppc
Cc: danielhb413, richard.henderson, groug, clg, Matheus Ferst, david
From: Matheus Ferst <matheus.ferst@eldorado.org.br>
Implement the following PowerISA v3.1 instructions:
xscvsqqp: VSX Scalar Convert with round Signed Quadword to
Quad-Precision
xscvuqqp: VSX Scalar Convert with round Unsigned Quadword to
Quad-Precision format
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
---
target/ppc/fpu_helper.c | 12 ++++++++++++
target/ppc/helper.h | 2 ++
target/ppc/insn32.decode | 5 +++++
target/ppc/translate/vsx-impl.c.inc | 20 ++++++++++++++++++++
4 files changed, 39 insertions(+)
diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c
index 7e8be99cc0..97892afa95 100644
--- a/target/ppc/fpu_helper.c
+++ b/target/ppc/fpu_helper.c
@@ -3058,6 +3058,18 @@ void helper_##op(CPUPPCState *env, ppc_vsr_t *xt, ppc_vsr_t *xb) \
VSX_CVT_INT_TO_FP2(xvcvsxdsp, int64, float32)
VSX_CVT_INT_TO_FP2(xvcvuxdsp, uint64, float32)
+#define VSX_CVT_INT128_TO_FP(op, tp) \
+void helper_##op(CPUPPCState *env, ppc_vsr_t *xt, ppc_vsr_t *xb)\
+{ \
+ helper_reset_fpstatus(env); \
+ xt->f128 = tp##_to_float128(xb->s128, &env->fp_status); \
+ helper_compute_fprf_float128(env, xt->f128); \
+ do_float_check_status(env, GETPC()); \
+}
+
+VSX_CVT_INT128_TO_FP(XSCVUQQP, uint128);
+VSX_CVT_INT128_TO_FP(XSCVSQQP, int128);
+
/*
* VSX_CVT_INT_TO_FP_VECTOR - VSX integer to floating point conversion
* op - instruction mnemonic
diff --git a/target/ppc/helper.h b/target/ppc/helper.h
index 57da11c77e..7df0c01819 100644
--- a/target/ppc/helper.h
+++ b/target/ppc/helper.h
@@ -388,6 +388,8 @@ DEF_HELPER_4(xscvqpsdz, void, env, i32, vsr, vsr)
DEF_HELPER_4(xscvqpswz, void, env, i32, vsr, vsr)
DEF_HELPER_4(xscvqpudz, void, env, i32, vsr, vsr)
DEF_HELPER_4(xscvqpuwz, void, env, i32, vsr, vsr)
+DEF_HELPER_3(XSCVUQQP, void, env, vsr, vsr)
+DEF_HELPER_3(XSCVSQQP, void, env, vsr, vsr)
DEF_HELPER_3(xscvhpdp, void, env, vsr, vsr)
DEF_HELPER_4(xscvsdqp, void, env, i32, vsr, vsr)
DEF_HELPER_3(xscvspdp, void, env, vsr, vsr)
diff --git a/target/ppc/insn32.decode b/target/ppc/insn32.decode
index ac2d3da9a7..6fb568c1fe 100644
--- a/target/ppc/insn32.decode
+++ b/target/ppc/insn32.decode
@@ -91,6 +91,9 @@
@X_tp_a_bp_rc ...... ....0 ra:5 ....0 .......... rc:1 &X_rc rt=%x_frtp rb=%x_frbp
+&X_tb rt rb
+@X_tb ...... rt:5 ..... rb:5 .......... . &X_tb
+
&X_tb_rc rt rb rc:bool
@X_tb_rc ...... rt:5 ..... rb:5 .......... rc:1 &X_tb_rc
@@ -692,6 +695,8 @@ XSCMPGTQP 111111 ..... ..... ..... 0011100100 - @X
## VSX Binary Floating-Point Convert Instructions
XSCVQPDP 111111 ..... 10100 ..... 1101000100 . @X_tb_rc
+XSCVUQQP 111111 ..... 00011 ..... 1101000100 - @X_tb
+XSCVSQQP 111111 ..... 01011 ..... 1101000100 - @X_tb
XVCVBF16SPN 111100 ..... 10000 ..... 111011011 .. @XX2
XVCVSPBF16 111100 ..... 10001 ..... 111011011 .. @XX2
diff --git a/target/ppc/translate/vsx-impl.c.inc b/target/ppc/translate/vsx-impl.c.inc
index d1f6333314..a305579ecc 100644
--- a/target/ppc/translate/vsx-impl.c.inc
+++ b/target/ppc/translate/vsx-impl.c.inc
@@ -838,6 +838,26 @@ static bool trans_XSCVQPDP(DisasContext *ctx, arg_X_tb_rc *a)
return true;
}
+static bool do_helper_env_X_tb(DisasContext *ctx, arg_X_tb *a,
+ void (*gen_helper)(TCGv_ptr, TCGv_ptr, TCGv_ptr))
+{
+ TCGv_ptr xt, xb;
+
+ REQUIRE_INSNS_FLAGS2(ctx, ISA310);
+ REQUIRE_VSX(ctx);
+
+ xt = gen_avr_ptr(a->rt);
+ xb = gen_avr_ptr(a->rb);
+ gen_helper(cpu_env, xt, xb);
+ tcg_temp_free_ptr(xt);
+ tcg_temp_free_ptr(xb);
+
+ return true;
+}
+
+TRANS(XSCVUQQP, do_helper_env_X_tb, gen_helper_XSCVUQQP)
+TRANS(XSCVSQQP, do_helper_env_X_tb, gen_helper_XSCVSQQP)
+
#define GEN_VSX_HELPER_2(name, op1, op2, inval, type) \
static void gen_##name(DisasContext *ctx) \
{ \
--
2.25.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [RFC PATCH 8/8] target/ppc: implement xscvqp[su]qz
2022-03-30 17:59 [RFC PATCH 0/8] Alternative softfloat 128-bit integer support matheus.ferst
` (6 preceding siblings ...)
2022-03-30 17:59 ` [RFC PATCH 7/8] target/ppc: implement xscv[su]qqp matheus.ferst
@ 2022-03-30 17:59 ` matheus.ferst
2022-03-30 18:16 ` Richard Henderson
2022-04-20 19:14 ` [RFC PATCH 0/8] Alternative softfloat 128-bit integer support Daniel Henrique Barboza
8 siblings, 1 reply; 18+ messages in thread
From: matheus.ferst @ 2022-03-30 17:59 UTC (permalink / raw)
To: qemu-devel, qemu-ppc
Cc: danielhb413, richard.henderson, groug, clg, Matheus Ferst, david
From: Matheus Ferst <matheus.ferst@eldorado.org.br>
Implement the following PowerISA v3.1 instructions:
xscvqpsqz: VSX Scalar Convert with round to zero Quad-Precision to
Signed Quadword
xscvqpuqz: VSX Scalar Convert with round to zero Quad-Precision to
Unsigned Quadword
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
---
target/ppc/fpu_helper.c | 21 +++++++++++++++++++++
target/ppc/helper.h | 2 ++
target/ppc/insn32.decode | 2 ++
target/ppc/translate/vsx-impl.c.inc | 2 ++
4 files changed, 27 insertions(+)
diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c
index 97892afa95..99281cc37a 100644
--- a/target/ppc/fpu_helper.c
+++ b/target/ppc/fpu_helper.c
@@ -2925,6 +2925,27 @@ VSX_CVT_FP_TO_INT(xvcvspsxws, 4, float32, int32, VsrW(i), VsrW(i), 0x80000000U)
VSX_CVT_FP_TO_INT(xvcvspuxds, 2, float32, uint64, VsrW(2 * i), VsrD(i), 0ULL)
VSX_CVT_FP_TO_INT(xvcvspuxws, 4, float32, uint32, VsrW(i), VsrW(i), 0U)
+#define VSX_CVT_FP_TO_INT128(op, tp, rnan) \
+void helper_##op(CPUPPCState *env, ppc_vsr_t *xt, ppc_vsr_t *xb) \
+{ \
+ ppc_vsr_t t; \
+ int flags; \
+ \
+ helper_reset_fpstatus(env); \
+ t.s128 = float128_to_##tp##_round_to_zero(xb->f128, &env->fp_status); \
+ flags = get_float_exception_flags(&env->fp_status); \
+ if (unlikely(flags & float_flag_invalid)) { \
+ t.VsrD(0) = float_invalid_cvt(env, flags, t.VsrD(0), rnan, 0, GETPC());\
+ t.VsrD(1) = -(t.VsrD(0) & 1); \
+ } \
+ \
+ *xt = t; \
+ do_float_check_status(env, GETPC()); \
+}
+
+VSX_CVT_FP_TO_INT128(XSCVQPUQZ, uint128, 0)
+VSX_CVT_FP_TO_INT128(XSCVQPSQZ, int128, 0x8000000000000000ULL);
+
/*
* Likewise, except that the result is duplicated into both subwords.
* Power ISA v3.1 has Programming Notes for these insns:
diff --git a/target/ppc/helper.h b/target/ppc/helper.h
index 7df0c01819..aa6773c4a5 100644
--- a/target/ppc/helper.h
+++ b/target/ppc/helper.h
@@ -388,6 +388,8 @@ DEF_HELPER_4(xscvqpsdz, void, env, i32, vsr, vsr)
DEF_HELPER_4(xscvqpswz, void, env, i32, vsr, vsr)
DEF_HELPER_4(xscvqpudz, void, env, i32, vsr, vsr)
DEF_HELPER_4(xscvqpuwz, void, env, i32, vsr, vsr)
+DEF_HELPER_3(XSCVQPUQZ, void, env, vsr, vsr)
+DEF_HELPER_3(XSCVQPSQZ, void, env, vsr, vsr)
DEF_HELPER_3(XSCVUQQP, void, env, vsr, vsr)
DEF_HELPER_3(XSCVSQQP, void, env, vsr, vsr)
DEF_HELPER_3(xscvhpdp, void, env, vsr, vsr)
diff --git a/target/ppc/insn32.decode b/target/ppc/insn32.decode
index 6fb568c1fe..39372fe673 100644
--- a/target/ppc/insn32.decode
+++ b/target/ppc/insn32.decode
@@ -695,6 +695,8 @@ XSCMPGTQP 111111 ..... ..... ..... 0011100100 - @X
## VSX Binary Floating-Point Convert Instructions
XSCVQPDP 111111 ..... 10100 ..... 1101000100 . @X_tb_rc
+XSCVQPUQZ 111111 ..... 00000 ..... 1101000100 - @X_tb
+XSCVQPSQZ 111111 ..... 01000 ..... 1101000100 - @X_tb
XSCVUQQP 111111 ..... 00011 ..... 1101000100 - @X_tb
XSCVSQQP 111111 ..... 01011 ..... 1101000100 - @X_tb
XVCVBF16SPN 111100 ..... 10000 ..... 111011011 .. @XX2
diff --git a/target/ppc/translate/vsx-impl.c.inc b/target/ppc/translate/vsx-impl.c.inc
index a305579ecc..6e8a3342dc 100644
--- a/target/ppc/translate/vsx-impl.c.inc
+++ b/target/ppc/translate/vsx-impl.c.inc
@@ -857,6 +857,8 @@ static bool do_helper_env_X_tb(DisasContext *ctx, arg_X_tb *a,
TRANS(XSCVUQQP, do_helper_env_X_tb, gen_helper_XSCVUQQP)
TRANS(XSCVSQQP, do_helper_env_X_tb, gen_helper_XSCVSQQP)
+TRANS(XSCVQPUQZ, do_helper_env_X_tb, gen_helper_XSCVQPUQZ)
+TRANS(XSCVQPSQZ, do_helper_env_X_tb, gen_helper_XSCVQPSQZ)
#define GEN_VSX_HELPER_2(name, op1, op2, inval, type) \
static void gen_##name(DisasContext *ctx) \
--
2.25.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [RFC PATCH 1/8] qemu/int128: avoid undefined behavior in int128_lshift
2022-03-30 17:59 ` [RFC PATCH 1/8] qemu/int128: avoid undefined behavior in int128_lshift matheus.ferst
@ 2022-03-30 18:07 ` Richard Henderson
0 siblings, 0 replies; 18+ messages in thread
From: Richard Henderson @ 2022-03-30 18:07 UTC (permalink / raw)
To: matheus.ferst, qemu-devel, qemu-ppc; +Cc: groug, danielhb413, clg, david
On 3/30/22 11:59, matheus.ferst@eldorado.org.br wrote:
> From: Matheus Ferst <matheus.ferst@eldorado.org.br>
>
> Avoid the left shift of negative values in int128_lshift by casting
> a/a.hi to unsigned.
>
> Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
Eh, maybe. We do this all over qemu, and I think any undefinedness you're thinking of in
the base C standard is removed by the -fwrapv with which all files are compiled.
r~
> ---
> include/qemu/int128.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/qemu/int128.h b/include/qemu/int128.h
> index 2c4064256c..2a19558ac6 100644
> --- a/include/qemu/int128.h
> +++ b/include/qemu/int128.h
> @@ -85,7 +85,7 @@ static inline Int128 int128_rshift(Int128 a, int n)
>
> static inline Int128 int128_lshift(Int128 a, int n)
> {
> - return a << n;
> + return (__uint128_t)a << n;
> }
>
> static inline Int128 int128_add(Int128 a, Int128 b)
> @@ -305,7 +305,7 @@ static inline Int128 int128_lshift(Int128 a, int n)
> if (n >= 64) {
> return int128_make128(0, l);
> } else if (n > 0) {
> - return int128_make128(l, (a.hi << n) | (a.lo >> (64 - n)));
> + return int128_make128(l, ((uint64_t)a.hi << n) | (a.lo >> (64 - n)));
> }
> return a;
> }
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFC PATCH 2/8] qemu/int128: add int128_urshift
2022-03-30 17:59 ` [RFC PATCH 2/8] qemu/int128: add int128_urshift matheus.ferst
@ 2022-03-30 18:08 ` Richard Henderson
0 siblings, 0 replies; 18+ messages in thread
From: Richard Henderson @ 2022-03-30 18:08 UTC (permalink / raw)
To: matheus.ferst, qemu-devel, qemu-ppc; +Cc: groug, danielhb413, clg, david
On 3/30/22 11:59, matheus.ferst@eldorado.org.br wrote:
> From: Matheus Ferst<matheus.ferst@eldorado.org.br>
>
> Implement an unsigned right shift for Int128 values and add the same
> tests cases of int128_rshift in the unit test.
>
> Signed-off-by: Matheus Ferst<matheus.ferst@eldorado.org.br>
> ---
> include/qemu/int128.h | 19 +++++++++++++++++++
> tests/unit/test-int128.c | 32 ++++++++++++++++++++++++++++++++
> 2 files changed, 51 insertions(+)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFC PATCH 3/8] softfloat: add uint128_to_float128
2022-03-30 17:59 ` [RFC PATCH 3/8] softfloat: add uint128_to_float128 matheus.ferst
@ 2022-03-30 18:10 ` Richard Henderson
0 siblings, 0 replies; 18+ messages in thread
From: Richard Henderson @ 2022-03-30 18:10 UTC (permalink / raw)
To: matheus.ferst, qemu-devel, qemu-ppc
Cc: Peter Maydell, danielhb413, groug, clg, Alex Bennée,
Aurelien Jarno, david
On 3/30/22 11:59, matheus.ferst@eldorado.org.br wrote:
> From: Matheus Ferst<matheus.ferst@eldorado.org.br>
>
> Based on parts_uint_to_float, implements uint128_to_float128 to convert
> an unsigned 128-bit value received through an Int128 argument.
>
> Signed-off-by: Matheus Ferst<matheus.ferst@eldorado.org.br>
> ---
> fpu/softfloat.c | 25 +++++++++++++++++++++++++
> include/fpu/softfloat.h | 2 ++
> 2 files changed, 27 insertions(+)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFC PATCH 4/8] softfloat: add int128_to_float128
2022-03-30 17:59 ` [RFC PATCH 4/8] softfloat: add int128_to_float128 matheus.ferst
@ 2022-03-30 18:11 ` Richard Henderson
0 siblings, 0 replies; 18+ messages in thread
From: Richard Henderson @ 2022-03-30 18:11 UTC (permalink / raw)
To: matheus.ferst, qemu-devel, qemu-ppc
Cc: Peter Maydell, danielhb413, groug, clg, Alex Bennée,
Aurelien Jarno, david
On 3/30/22 11:59, matheus.ferst@eldorado.org.br wrote:
> From: Matheus Ferst<matheus.ferst@eldorado.org.br>
>
> Based on parts_sint_to_float, implements int128_to_float128 to convert a
> signed 128-bit value received through an Int128 argument.
>
> Signed-off-by: Matheus Ferst<matheus.ferst@eldorado.org.br>
> ---
> fpu/softfloat.c | 29 +++++++++++++++++++++++++++++
> include/fpu/softfloat.h | 1 +
> 2 files changed, 30 insertions(+)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFC PATCH 5/8] softfloat: add float128_to_uint128
2022-03-30 17:59 ` [RFC PATCH 5/8] softfloat: add float128_to_uint128 matheus.ferst
@ 2022-03-30 18:13 ` Richard Henderson
0 siblings, 0 replies; 18+ messages in thread
From: Richard Henderson @ 2022-03-30 18:13 UTC (permalink / raw)
To: matheus.ferst, qemu-devel, qemu-ppc
Cc: Peter Maydell, danielhb413, groug, clg, Alex Bennée,
Aurelien Jarno, david
On 3/30/22 11:59, matheus.ferst@eldorado.org.br wrote:
> From: Matheus Ferst<matheus.ferst@eldorado.org.br>
>
> Implements float128_to_uint128 based on parts_float_to_uint logic.
>
> Signed-off-by: Matheus Ferst<matheus.ferst@eldorado.org.br>
> ---
> fpu/softfloat.c | 65 +++++++++++++++++++++++++++++++++++++++++
> include/fpu/softfloat.h | 2 ++
> 2 files changed, 67 insertions(+)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFC PATCH 6/8] softfloat: add float128_to_int128
2022-03-30 17:59 ` [RFC PATCH 6/8] softfloat: add float128_to_int128 matheus.ferst
@ 2022-03-30 18:14 ` Richard Henderson
0 siblings, 0 replies; 18+ messages in thread
From: Richard Henderson @ 2022-03-30 18:14 UTC (permalink / raw)
To: matheus.ferst, qemu-devel, qemu-ppc
Cc: Peter Maydell, danielhb413, groug, clg, Alex Bennée,
Aurelien Jarno, david
On 3/30/22 11:59, matheus.ferst@eldorado.org.br wrote:
> From: Matheus Ferst<matheus.ferst@eldorado.org.br>
>
> Implements float128_to_int128 based on parts_float_to_int logic.
>
> Signed-off-by: Matheus Ferst<matheus.ferst@eldorado.org.br>
> ---
> fpu/softfloat.c | 64 +++++++++++++++++++++++++++++++++++++++++
> include/fpu/softfloat.h | 2 ++
> include/qemu/int128.h | 2 ++
> 3 files changed, 68 insertions(+)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFC PATCH 7/8] target/ppc: implement xscv[su]qqp
2022-03-30 17:59 ` [RFC PATCH 7/8] target/ppc: implement xscv[su]qqp matheus.ferst
@ 2022-03-30 18:15 ` Richard Henderson
0 siblings, 0 replies; 18+ messages in thread
From: Richard Henderson @ 2022-03-30 18:15 UTC (permalink / raw)
To: matheus.ferst, qemu-devel, qemu-ppc; +Cc: groug, danielhb413, clg, david
On 3/30/22 11:59, matheus.ferst@eldorado.org.br wrote:
> From: Matheus Ferst<matheus.ferst@eldorado.org.br>
>
> Implement the following PowerISA v3.1 instructions:
> xscvsqqp: VSX Scalar Convert with round Signed Quadword to
> Quad-Precision
> xscvuqqp: VSX Scalar Convert with round Unsigned Quadword to
> Quad-Precision format
>
> Signed-off-by: Matheus Ferst<matheus.ferst@eldorado.org.br>
> ---
> target/ppc/fpu_helper.c | 12 ++++++++++++
> target/ppc/helper.h | 2 ++
> target/ppc/insn32.decode | 5 +++++
> target/ppc/translate/vsx-impl.c.inc | 20 ++++++++++++++++++++
> 4 files changed, 39 insertions(+)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFC PATCH 8/8] target/ppc: implement xscvqp[su]qz
2022-03-30 17:59 ` [RFC PATCH 8/8] target/ppc: implement xscvqp[su]qz matheus.ferst
@ 2022-03-30 18:16 ` Richard Henderson
0 siblings, 0 replies; 18+ messages in thread
From: Richard Henderson @ 2022-03-30 18:16 UTC (permalink / raw)
To: matheus.ferst, qemu-devel, qemu-ppc; +Cc: groug, danielhb413, clg, david
On 3/30/22 11:59, matheus.ferst@eldorado.org.br wrote:
> From: Matheus Ferst<matheus.ferst@eldorado.org.br>
>
> Implement the following PowerISA v3.1 instructions:
> xscvqpsqz: VSX Scalar Convert with round to zero Quad-Precision to
> Signed Quadword
> xscvqpuqz: VSX Scalar Convert with round to zero Quad-Precision to
> Unsigned Quadword
>
> Signed-off-by: Matheus Ferst<matheus.ferst@eldorado.org.br>
> ---
> target/ppc/fpu_helper.c | 21 +++++++++++++++++++++
> target/ppc/helper.h | 2 ++
> target/ppc/insn32.decode | 2 ++
> target/ppc/translate/vsx-impl.c.inc | 2 ++
> 4 files changed, 27 insertions(+)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFC PATCH 0/8] Alternative softfloat 128-bit integer support
2022-03-30 17:59 [RFC PATCH 0/8] Alternative softfloat 128-bit integer support matheus.ferst
` (7 preceding siblings ...)
2022-03-30 17:59 ` [RFC PATCH 8/8] target/ppc: implement xscvqp[su]qz matheus.ferst
@ 2022-04-20 19:14 ` Daniel Henrique Barboza
8 siblings, 0 replies; 18+ messages in thread
From: Daniel Henrique Barboza @ 2022-04-20 19:14 UTC (permalink / raw)
To: matheus.ferst, qemu-devel, qemu-ppc; +Cc: groug, richard.henderson, clg, david
All patches but patch 01 queued in gitlab.com/danielhb/qemu/tree/ppc-next.
Thanks,
Daniel
On 3/30/22 14:59, matheus.ferst@eldorado.org.br wrote:
> From: Matheus Ferst <matheus.ferst@eldorado.org.br>
>
> This RFC is an alternative to [1] using Int128 types to implement the
> 128-bit integer conversion routines in softfloat required by the
> xscv[su]qqp and xscvqp[su]qz instructions of PowerISA v3.1.
>
> Some improvements to int128.h are made in patches 1 and 2. Patches 3-6
> implement the conversion routines, and patches 7 and 8 implement the new
> instructions.
>
> RFC: Int128 vs. pair of 64-bit values.
> - Returning unsigned values through Int128 is not ideal, but creating
> an "UInt128" just for this case seems excessive.
> - OTOH, there are fewer cases to handle, especially in float->int.
>
> [1] https://lists.gnu.org/archive/html/qemu-ppc/2022-03/msg00520.html
>
> Matheus Ferst (8):
> qemu/int128: avoid undefined behavior in int128_lshift
> qemu/int128: add int128_urshift
> softfloat: add uint128_to_float128
> softfloat: add int128_to_float128
> softfloat: add float128_to_uint128
> softfloat: add float128_to_int128
> target/ppc: implement xscv[su]qqp
> target/ppc: implement xscvqp[su]qz
>
> fpu/softfloat.c | 183 ++++++++++++++++++++++++++++
> include/fpu/softfloat.h | 7 ++
> include/qemu/int128.h | 25 +++-
> target/ppc/fpu_helper.c | 33 +++++
> target/ppc/helper.h | 4 +
> target/ppc/insn32.decode | 7 ++
> target/ppc/translate/vsx-impl.c.inc | 22 ++++
> tests/unit/test-int128.c | 32 +++++
> 8 files changed, 311 insertions(+), 2 deletions(-)
>
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2022-04-20 19:41 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-30 17:59 [RFC PATCH 0/8] Alternative softfloat 128-bit integer support matheus.ferst
2022-03-30 17:59 ` [RFC PATCH 1/8] qemu/int128: avoid undefined behavior in int128_lshift matheus.ferst
2022-03-30 18:07 ` Richard Henderson
2022-03-30 17:59 ` [RFC PATCH 2/8] qemu/int128: add int128_urshift matheus.ferst
2022-03-30 18:08 ` Richard Henderson
2022-03-30 17:59 ` [RFC PATCH 3/8] softfloat: add uint128_to_float128 matheus.ferst
2022-03-30 18:10 ` Richard Henderson
2022-03-30 17:59 ` [RFC PATCH 4/8] softfloat: add int128_to_float128 matheus.ferst
2022-03-30 18:11 ` Richard Henderson
2022-03-30 17:59 ` [RFC PATCH 5/8] softfloat: add float128_to_uint128 matheus.ferst
2022-03-30 18:13 ` Richard Henderson
2022-03-30 17:59 ` [RFC PATCH 6/8] softfloat: add float128_to_int128 matheus.ferst
2022-03-30 18:14 ` Richard Henderson
2022-03-30 17:59 ` [RFC PATCH 7/8] target/ppc: implement xscv[su]qqp matheus.ferst
2022-03-30 18:15 ` Richard Henderson
2022-03-30 17:59 ` [RFC PATCH 8/8] target/ppc: implement xscvqp[su]qz matheus.ferst
2022-03-30 18:16 ` Richard Henderson
2022-04-20 19:14 ` [RFC PATCH 0/8] Alternative softfloat 128-bit integer support Daniel Henrique Barboza
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).