From dfcb11ca9d70335242e84d4b8d8b96fb24600ccf Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Thu, 16 Mar 2023 12:08:24 -0700 Subject: [PATCH] clarify java/saturating only refers to java's fp->int for long/int we specifically don't mean java's float -> byte/short/etc. that saturates to int then truncates --- openpower/sv/int_fp_mv.mdwn | 21 ++++++++++----------- openpower/sv/rfc/ls006.mdwn | 8 ++++---- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/openpower/sv/int_fp_mv.mdwn b/openpower/sv/int_fp_mv.mdwn index 1778e9400..8b21bac42 100644 --- a/openpower/sv/int_fp_mv.mdwn +++ b/openpower/sv/int_fp_mv.mdwn @@ -78,11 +78,13 @@ If adding new Integer <-> FP conversion instructions, the opportunity may be taken to modernise the instructions and make them well-suited for common/important conversion sequences: -* **standard IEEE754** - used by most languages and CPUs -* **standard OpenPOWER** - saturation with NaN - converted to minimum valid integer -* **Java** - saturation with NaN converted to 0 -* **JavaScript** - modulo wrapping with Inf/NaN converted to 0 +* Int -> Float + * **standard IEEE754** - used by most languages and CPUs +* Float -> Int + * **standard OpenPOWER** - saturation with NaN + converted to minimum valid integer + * **Java/Saturating** - saturation with NaN converted to 0 + * **JavaScript** - modulo wrapping with Inf/NaN converted to 0 The assembly listings in the [[int_fp_mv/appendix]] show how costly some of these language-specific conversions are: Javascript, the @@ -455,7 +457,7 @@ For the sake of simplicity, the FP -> Integer conversion semantics generalized f Those same semantics are used in some way by all of the following languages (not necessarily for the default conversion method): * Java's - [FP -> Integer conversion](https://docs.oracle.com/javase/specs/jls/se16/html/jls-5.html#jls-5.1.3) + [FP -> Integer conversion](https://docs.oracle.com/javase/specs/jls/se16/html/jls-5.html#jls-5.1.3) (only for long/int results) * Rust's FP -> Integer conversion using the [`as` operator](https://doc.rust-lang.org/reference/expressions/operator-expr.html#semantics) * LLVM's @@ -520,12 +522,12 @@ def fp_to_int_open_power(v: fp) -> int:
[Java/Saturating conversion semantics](https://docs.oracle.com/javase/specs/jls/se16/html/jls-5.html#jls-5.1.3) -/ +(only for long/int results)/ [Rust semantics](https://doc.rust-lang.org/reference/expressions/operator-expr.html#semantics) (with adjustment to add non-truncate rounding modes): ``` -def fp_to_int_java(v: fp) -> int: +def fp_to_int_java_saturating(v: fp) -> int: if v is NaN: return 0 if v >= int::MAX_VALUE: @@ -710,6 +712,3 @@ For brevity, `[o]` is used to mean `o` is optional there. | `fcvttgud[o]. RT, FRB, CVM` | `fcvttg[o] RT, FRB, CVM, 3, 1` | | `fcvtstgud[o] RT, FRB, CVM` | `fcvttg[o] RT, FRB, CVM, 3, 2` | | `fcvtstgud[o]. RT, FRB, CVM` | `fcvttg[o] RT, FRB, CVM, 3, 3` | - -[mode `Mode`]: #fpr-to-gpr-conversion-mode - diff --git a/openpower/sv/rfc/ls006.mdwn b/openpower/sv/rfc/ls006.mdwn index 92413f870..b1203ec9d 100644 --- a/openpower/sv/rfc/ls006.mdwn +++ b/openpower/sv/rfc/ls006.mdwn @@ -81,7 +81,7 @@ For the sake of simplicity, the FP -> Integer conversion semantics generalized f Those same semantics are used in some way by all of the following languages (not necessarily for the default conversion method): * Java's - [FP -> Integer conversion](https://docs.oracle.com/javase/specs/jls/se16/html/jls-5.html#jls-5.1.3) + [FP -> Integer conversion](https://docs.oracle.com/javase/specs/jls/se16/html/jls-5.html#jls-5.1.3) (only for long/int results) * Rust's FP -> Integer conversion using the [`as` operator](https://doc.rust-lang.org/reference/expressions/operator-expr.html#semantics) * LLVM's @@ -337,7 +337,7 @@ For the sake of simplicity, the FP -> Integer conversion semantics generalized f Those same semantics are used in some way by all of the following languages (not necessarily for the default conversion method): * Java's - [FP -> Integer conversion](https://docs.oracle.com/javase/specs/jls/se16/html/jls-5.html#jls-5.1.3) + [FP -> Integer conversion](https://docs.oracle.com/javase/specs/jls/se16/html/jls-5.html#jls-5.1.3) (only for ling/int results) * Rust's FP -> Integer conversion using the [`as` operator](https://doc.rust-lang.org/reference/expressions/operator-expr.html#semantics) * LLVM's @@ -402,12 +402,12 @@ def fp_to_int_open_power(v: fp) -> int:
[Java/Saturating conversion semantics](https://docs.oracle.com/javase/specs/jls/se16/html/jls-5.html#jls-5.1.3) -/ + (only for long/int results)/ [Rust semantics](https://doc.rust-lang.org/reference/expressions/operator-expr.html#semantics) (with adjustment to add non-truncate rounding modes): ``` -def fp_to_int_java(v: fp) -> int: +def fp_to_int_java_saturating(v: fp) -> int: if v is NaN: return 0 if v >= int::MAX_VALUE: -- 2.30.2