https://gcc.gnu.org/g:9ad9f7f1826a059c88fef4b56586f107979773b3
commit r17-6030-g9ad9f7f1826a059c88fef4b56586f107979773b3 Author: Jose E. Marchesi <[email protected]> Date: Sat Oct 31 10:57:38 2026 +0100 a68: worden operator This patch adds a WORDEN operator defined for SIZETY int, SIZETY real and SIZETY bits, to obtain (via truncation or signed/unsigned extension) the corresponding word {real,int,bits}. This doesn't include documentation nor tests, which will come in separated commits. Signed-off-by: Jose E. Marchesi <[email protected]> gcc/algol68/ChangeLog * a68.h: Add prototypes for a68_lower_wordenint2 and a68_lower_wordenreal2. * a68-parser-prelude.cc (gnu_prelude): Define WORDEN for SIZETY int, SIZETY real and SIZETY bits. * a68-low-prelude.cc (a68_lower_wordenint2): New function. (a68_lower_wordenreal2): Likewise. Diff: --- gcc/algol68/a68-low-prelude.cc | 14 ++++++++++++++ gcc/algol68/a68-parser-prelude.cc | 26 ++++++++++++++++++++++++++ gcc/algol68/a68.h | 2 ++ 3 files changed, 42 insertions(+) diff --git a/gcc/algol68/a68-low-prelude.cc b/gcc/algol68/a68-low-prelude.cc index d34a4a17e034..cde885b6f126 100644 --- a/gcc/algol68/a68-low-prelude.cc +++ b/gcc/algol68/a68-low-prelude.cc @@ -1963,6 +1963,13 @@ a68_lower_lengint2 (NODE_T *p, LOW_CTX_T ctx) a68_lower_tree (NEXT (SUB (p)), ctx)); } +tree +a68_lower_wordenint2 (NODE_T *p, LOW_CTX_T ctx) +{ + return a68_int_leng (MOID (p), MOID (NEXT (SUB (p))), + a68_lower_tree (NEXT (SUB (p)), ctx)); +} + tree a68_lower_shortenreal2 (NODE_T *p, LOW_CTX_T ctx) { @@ -1977,6 +1984,13 @@ a68_lower_lengreal2 (NODE_T *p, LOW_CTX_T ctx) a68_lower_tree (NEXT (SUB (p)), ctx)); } +tree +a68_lower_wordenreal2 (NODE_T *p, LOW_CTX_T ctx) +{ + return a68_real_leng (MOID (p), MOID (NEXT (SUB (p))), + a68_lower_tree (NEXT (SUB (p)), ctx)); +} + tree a68_lower_random (NODE_T *p ATTRIBUTE_UNUSED, LOW_CTX_T ctx ATTRIBUTE_UNUSED) { diff --git a/gcc/algol68/a68-parser-prelude.cc b/gcc/algol68/a68-parser-prelude.cc index c9e71b4c5a75..e7208412a689 100644 --- a/gcc/algol68/a68-parser-prelude.cc +++ b/gcc/algol68/a68-parser-prelude.cc @@ -1375,6 +1375,16 @@ gnu_prelude (void) m = a68_proc (M_WORD_INT, M_WORD_INT, M_INT, NO_MOID); a68_op (A68_EXT, "**", m, a68_lower_pow_int); a68_op (A68_EXT, "^", m, a68_lower_pow_int); + m = a68_proc (M_WORD_INT, M_SHORT_SHORT_INT, NO_MOID); + a68_op (A68_EXT, "WORDEN", m, a68_lower_wordenreal2); + m = a68_proc (M_WORD_INT, M_SHORT_INT, NO_MOID); + a68_op (A68_EXT, "WORDEN", m, a68_lower_wordenreal2); + m = a68_proc (M_WORD_INT, M_INT, NO_MOID); + a68_op (A68_EXT, "WORDEN", m, a68_lower_wordenreal2); + m = a68_proc (M_WORD_INT, M_LONG_INT, NO_MOID); + a68_op (A68_EXT, "WORDEN", m, a68_lower_wordenreal2); + m = a68_proc (M_WORD_INT, M_LONG_LONG_INT, NO_MOID); + a68_op (A68_EXT, "WORDEN", m, a68_lower_wordenreal2); /* SHORT SHORT BITS operators. */ m = a68_proc (M_SHORT_SHORT_BITS, M_SHORT_SHORT_BITS, M_INT, NO_MOID); a68_op (A68_EXT, "SET", m, a68_lower_set3); @@ -1438,6 +1448,16 @@ gnu_prelude (void) a68_op (A68_EXT, "CLEAR", m, a68_lower_clear3); m = a68_proc (M_BOOL, M_WORD_BITS, M_INT, NO_MOID); a68_op (A68_EXT, "TEST", m, a68_lower_test3); + m = a68_proc (M_WORD_BITS, M_SHORT_SHORT_BITS, NO_MOID); + a68_op (A68_EXT, "WORDEN", m, a68_lower_wordenint2); + m = a68_proc (M_WORD_BITS, M_SHORT_BITS, NO_MOID); + a68_op (A68_EXT, "WORDEN", m, a68_lower_wordenint2); + m = a68_proc (M_WORD_BITS, M_BITS, NO_MOID); + a68_op (A68_EXT, "WORDEN", m, a68_lower_wordenint2); + m = a68_proc (M_WORD_BITS, M_LONG_BITS, NO_MOID); + a68_op (A68_EXT, "WORDEN", m, a68_lower_wordenint2); + m = a68_proc (M_WORD_BITS, M_LONG_LONG_BITS, NO_MOID); + a68_op (A68_EXT, "WORDEN", m, a68_lower_wordenint2); /* REAL operators. */ m = a68_proc (M_INT, M_REAL, NO_MOID); a68_op (A68_EXT, "FLOOR", m, a68_lower_entier2); @@ -1490,6 +1510,12 @@ gnu_prelude (void) m = a68_proc (M_WORD_REAL, M_WORD_REAL, M_INT, NO_MOID); a68_op (A68_EXT, "**", m, a68_lower_pow_real); a68_op (A68_EXT, "^", m, a68_lower_pow_real); + m = a68_proc (M_WORD_REAL, M_REAL, NO_MOID); + a68_op (A68_EXT, "WORDEN", m, a68_lower_wordenreal2); + m = a68_proc (M_WORD_REAL, M_LONG_REAL, NO_MOID); + a68_op (A68_EXT, "WORDEN", m, a68_lower_wordenreal2); + m = a68_proc (M_WORD_REAL, M_LONG_LONG_REAL, NO_MOID); + a68_op (A68_EXT, "WORDEN", m, a68_lower_wordenreal2); /* WORD COMPLEX operators */ m = a68_proc (M_WORD_COMPLEX, M_WORD_INT, M_WORD_INT, NO_MOID); a68_op (A68_STD, "I", m, a68_lower_wordinti); diff --git a/gcc/algol68/a68.h b/gcc/algol68/a68.h index 2eb1fb825ada..300e98f0793f 100644 --- a/gcc/algol68/a68.h +++ b/gcc/algol68/a68.h @@ -1100,6 +1100,8 @@ tree a68_lower_conj2 (NODE_T *p, LOW_CTX_T ctx); tree a68_lower_shortenint2 (NODE_T *p, LOW_CTX_T ctx); tree a68_lower_lengint2 (NODE_T *p, LOW_CTX_T ctx); tree a68_lower_lengreal2 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_wordenint2 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_wordenreal2 (NODE_T *p, LOW_CTX_T ctx); tree a68_lower_shortenreal2 (NODE_T *p, LOW_CTX_T ctx); tree a68_lower_random (NODE_T *p, LOW_CTX_T ctx); tree a68_lower_longrandom (NODE_T *p, LOW_CTX_T ctx);
