s390: Add missing BFP rounding mode conversions

Function decode_bfp_rounding_mode:
- Irrm_NEAREST_TIE_AWAY_0 --> S390_BFP_ROUND_NEAREST_AWAY
- Irrm_PREPARE_SHORTER    --> S390_BFP_ROUND_PREPARE_SHORT

Macros S390_CC_FOR_BFP_CONVERT, S390_CC_FOR_BFP_UCONVERT
- add S390_BFP_ROUND_NEAREST_AWAY
- add S390_BFP_ROUND_PREPARE_SHORT

Macros S390_CC_FOR_BFP128_CONVERT, S390_CC_FOR_BFP128_UCONVERT
- add S390_BFP_ROUND_NEAREST_AWAY
- add S390_BFP_ROUND_PREPARE_SHORT

Fix more out-of-date comments related to rounding.
This commit is contained in:
Florian Krohm
2025-09-23 20:29:19 +00:00
parent e5cd167a57
commit d8cf0a84b2
2 changed files with 28 additions and 4 deletions

View File

@@ -628,7 +628,7 @@ s390_do_cu12_cu14_helper2(UInt byte1, UInt byte2, UInt byte3, UInt byte4,
UInt ij = (byte3 >> 4) & 0x3;
UInt klmn = byte3 & 0xf;
UInt opqrst = byte4 & 0x3f;
if (is_cu12) {
UInt abcd = (uvwxy - 1) & 0xf;
UInt high_surrogate = (0xd8 << 8) | (abcd << 6) | (efgh << 2) | ij;
@@ -782,6 +782,8 @@ decode_bfp_rounding_mode(UInt irrm)
case Irrm_NegINF: return S390_BFP_ROUND_NEGINF;
case Irrm_PosINF: return S390_BFP_ROUND_POSINF;
case Irrm_ZERO: return S390_BFP_ROUND_ZERO;
case Irrm_NEAREST_TIE_AWAY_0: return S390_BFP_ROUND_NEAREST_AWAY;
case Irrm_PREPARE_SHORTER: return S390_BFP_ROUND_PREPARE_SHORT;
}
vpanic("decode_bfp_rounding_mode");
}
@@ -880,6 +882,12 @@ decode_bfp_rounding_mode(UInt irrm)
({ \
UInt cc; \
switch (decode_bfp_rounding_mode(cc_dep2)) { \
case S390_BFP_ROUND_NEAREST_AWAY: \
cc = S390_CC_FOR_BFP_CONVERT_AUX(opcode,cc_dep1,1); \
break; \
case S390_BFP_ROUND_PREPARE_SHORT: \
cc = S390_CC_FOR_BFP_CONVERT_AUX(opcode,cc_dep1,3); \
break; \
case S390_BFP_ROUND_NEAREST_EVEN: \
cc = S390_CC_FOR_BFP_CONVERT_AUX(opcode,cc_dep1,4); \
break; \
@@ -914,6 +922,12 @@ decode_bfp_rounding_mode(UInt irrm)
({ \
UInt cc; \
switch (decode_bfp_rounding_mode(cc_dep2)) { \
case S390_BFP_ROUND_NEAREST_AWAY: \
cc = S390_CC_FOR_BFP_UCONVERT_AUX(opcode,cc_dep1,1); \
break; \
case S390_BFP_ROUND_PREPARE_SHORT: \
cc = S390_CC_FOR_BFP_UCONVERT_AUX(opcode,cc_dep1,3); \
break; \
case S390_BFP_ROUND_NEAREST_EVEN: \
cc = S390_CC_FOR_BFP_UCONVERT_AUX(opcode,cc_dep1,4); \
break; \
@@ -951,6 +965,12 @@ decode_bfp_rounding_mode(UInt irrm)
s390_cc_thunk_put3 for rationale. */ \
cc_dep2 = cc_dep2 ^ cc_ndep; \
switch (decode_bfp_rounding_mode(cc_ndep)) { \
case S390_BFP_ROUND_NEAREST_AWAY: \
cc = S390_CC_FOR_BFP128_CONVERT_AUX(opcode,cc_dep1,cc_dep2,1); \
break; \
case S390_BFP_ROUND_PREPARE_SHORT: \
cc = S390_CC_FOR_BFP128_CONVERT_AUX(opcode,cc_dep1,cc_dep2,3); \
break; \
case S390_BFP_ROUND_NEAREST_EVEN: \
cc = S390_CC_FOR_BFP128_CONVERT_AUX(opcode,cc_dep1,cc_dep2,4); \
break; \
@@ -988,6 +1008,13 @@ decode_bfp_rounding_mode(UInt irrm)
s390_cc_thunk_put3 for rationale. */ \
cc_dep2 = cc_dep2 ^ cc_ndep; \
switch (decode_bfp_rounding_mode(cc_ndep)) { \
case S390_BFP_ROUND_NEAREST_AWAY: \
cc = S390_CC_FOR_BFP128_UCONVERT_AUX(opcode,cc_dep1,cc_dep2,1); \
break; \
case S390_BFP_ROUND_PREPARE_SHORT: \
cc = S390_CC_FOR_BFP128_UCONVERT_AUX(opcode,cc_dep1,cc_dep2,3); \
cc = S390_CC_FOR_BFP_UCONVERT_AUX(opcode,cc_dep1,3); \
break; \
case S390_BFP_ROUND_NEAREST_EVEN: \
cc = S390_CC_FOR_BFP128_UCONVERT_AUX(opcode,cc_dep1,cc_dep2,4); \
break; \

View File

@@ -8,14 +8,11 @@
/* instructions (e.g. CFEBR) */
/* ---------------------------------------------------------------- */
#define M3_BFP_ROUND_PER_FPC 0
// Cannot be mapped to IRRoundingMode
#define M3_BFP_ROUND_NEAREST_AWAY 1
// 2 is not allowed
// Needs floating point extension facility
// Cannot be mapped to IRRoundingMode
#define M3_BFP_ROUND_PREPARE_SHORT 3
#define M3_BFP_ROUND_NEAREST_EVEN 4