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.
---
 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 d34a4a17e03..cde885b6f12 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 c9e71b4c5a7..e7208412a68 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 2eb1fb825ad..300e98f0793 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);
-- 
2.39.5

Reply via email to