[RFC 3/7 V2] a68: low: support for fixed sized modes

Jose E. Marchesi jemarch@gnu.org
Mon Sep 21 10:26:27 GMT 2026


Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>

gcc/algol68/ChangeLog

	* a68-low-decls.cc: Update syntax grammar comments.
	* a68-low-units.cc (a68_lower_denotation): Lower
	M_WORD_{INT,BITS,REAL} denotations.
---
 gcc/algol68/a68-low-bits.cc      |  2 ++
 gcc/algol68/a68-low-coercions.cc | 16 +++++++------
 gcc/algol68/a68-low-complex.cc   |  2 ++
 gcc/algol68/a68-low-decls.cc     |  1 +
 gcc/algol68/a68-low-ints.cc      |  2 ++
 gcc/algol68/a68-low-moids.cc     | 11 ++++++++-
 gcc/algol68/a68-low-prelude.cc   | 30 ++++++++++++++++++++++++
 gcc/algol68/a68-low-reals.cc     | 39 ++++++++++++++++++++++++++++++++
 gcc/algol68/a68-low-units.cc     | 34 ++++++++++++++++++++--------
 9 files changed, 119 insertions(+), 18 deletions(-)

diff --git a/gcc/algol68/a68-low-bits.cc b/gcc/algol68/a68-low-bits.cc
index 2a4cd8b5ada..c11151e71e3 100644
--- a/gcc/algol68/a68-low-bits.cc
+++ b/gcc/algol68/a68-low-bits.cc
@@ -59,6 +59,8 @@ a68_get_bits_skip_tree (MOID_T *m)
     type = a68_short_bits_type;
   else if (m == M_SHORT_SHORT_BITS)
     type = a68_short_short_bits_type;
+  else if (m == M_WORD_BITS)
+    type = a68_word_bits_type;
   else
     gcc_unreachable ();
 
diff --git a/gcc/algol68/a68-low-coercions.cc b/gcc/algol68/a68-low-coercions.cc
index 54079122880..c5fe8c68818 100644
--- a/gcc/algol68/a68-low-coercions.cc
+++ b/gcc/algol68/a68-low-coercions.cc
@@ -315,30 +315,32 @@ a68_lower_rowing (NODE_T *p, LOW_CTX_T ctx)
 
    Widening allows the following conversions of mode:
 
-   LONGSETY INT to LONGSETY REAL
-   LONGSETY REAL to LONGSETY COMPL
-   LONGSETY BITS to []BOOL
-   LONGSETY BYTES to []CHAR  */
+   SIZETY INT to LONGSETY REAL
+   SIZETY REAL to LONGSETY COMPL
+   SIZETY BITS to []BOOL
+   SIZETY BYTES to []CHAR  */
 
 tree
 a68_lower_widening (NODE_T *p, LOW_CTX_T ctx)
 {
   if (MOID (p) == M_REAL
       || MOID (p) == M_LONG_REAL
-      || MOID (p) == M_LONG_LONG_REAL)
+      || MOID (p) == M_LONG_LONG_REAL
+      || MOID (p) == M_WORD_REAL)
     {
       return convert_to_real (CTYPE (MOID (p)), a68_lower_tree (SUB (p), ctx));
     }
   if (MOID (p) == M_COMPLEX
       || MOID (p) == M_LONG_COMPLEX
-      || MOID (p) == M_LONG_LONG_COMPLEX)
+      || MOID (p) == M_LONG_LONG_COMPLEX
+      || MOID (p) == M_WORD_COMPLEX)
     {
       return a68_complex_widen_from_real (MOID (p),
 					  a68_lower_tree (SUB (p), ctx));
     }
   else if (MOID (p) == M_ROW_BOOL)
     {
-      /* Widen a LONGSETY BITS to a row of BOOLs.  */
+      /* Widen a SIZETY BITS to a row of BOOLs.  */
       tree coercend = a68_lower_tree (SUB (p), ctx);
       tree coercend_type = TREE_TYPE (coercend);
       HOST_WIDE_INT bits_size = int_size_in_bytes (coercend_type);
diff --git a/gcc/algol68/a68-low-complex.cc b/gcc/algol68/a68-low-complex.cc
index aed1c3c3dab..027ddc2a4a9 100644
--- a/gcc/algol68/a68-low-complex.cc
+++ b/gcc/algol68/a68-low-complex.cc
@@ -108,6 +108,8 @@ a68_complex_widen_from_real (MOID_T *mode, tree r)
     gcc_assert (TREE_TYPE (r) == a68_long_real_type);
   else if (mode == M_LONG_LONG_COMPLEX)
     gcc_assert (TREE_TYPE (r) == a68_long_long_real_type);
+  else if (mode == M_WORD_COMPLEX)
+    gcc_assert (TREE_TYPE (r) == a68_word_real_type);
   else
     gcc_unreachable ();
 
diff --git a/gcc/algol68/a68-low-decls.cc b/gcc/algol68/a68-low-decls.cc
index 532f5b65c3b..582e3f2ed26 100644
--- a/gcc/algol68/a68-low-decls.cc
+++ b/gcc/algol68/a68-low-decls.cc
@@ -422,6 +422,7 @@ a68_lower_identity_declaration (NODE_T *p, LOW_CTX_T ctx)
      declarer : indicant;
      		longety, indicant;
      		shortety, indicant;
+		fixety, indicant;
 		flex symbol, declarer;
 		flex symbol, bounds, declarer;
 		flex symbol, formal bounds, declarer;
diff --git a/gcc/algol68/a68-low-ints.cc b/gcc/algol68/a68-low-ints.cc
index d80d35e8302..894b8fdf5e9 100644
--- a/gcc/algol68/a68-low-ints.cc
+++ b/gcc/algol68/a68-low-ints.cc
@@ -59,6 +59,8 @@ a68_get_int_skip_tree (MOID_T *m)
     type = a68_short_int_type;
   else if (m == M_SHORT_SHORT_INT)
     type = a68_short_short_int_type;
+  else if (m == M_WORD_INT)
+    type = a68_word_int_type;
   else
     gcc_unreachable ();
 
diff --git a/gcc/algol68/a68-low-moids.cc b/gcc/algol68/a68-low-moids.cc
index 27b28173003..ddd87671190 100644
--- a/gcc/algol68/a68-low-moids.cc
+++ b/gcc/algol68/a68-low-moids.cc
@@ -207,7 +207,8 @@ lower_hip_mode (MOID_T *m)
 /* Lower a standard mode to a GENERIC tree.
 
    Note that this function only has to handle the standard modes that have not
-   been resolved to some equivalent.  */
+   been resolved to some equivalent.  In particular, this excludes the complex
+   modes, for which equivalent modes are declared in a68-parser-prelude.cc.  */
 
 static tree
 lower_standard_mode (MOID_T *m)
@@ -230,12 +231,16 @@ lower_standard_mode (MOID_T *m)
     type = a68_long_int_type;
   else if (m == M_LONG_LONG_INT)
     type = a68_long_long_int_type;
+  else if (m == M_WORD_INT)
+    type = a68_word_int_type;
   else if (m == M_REAL)
     type = a68_real_type;
   else if (m == M_LONG_REAL)
     type = a68_long_real_type;
   else if (m == M_LONG_LONG_REAL)
     type = a68_long_long_real_type;
+  else if (m == M_WORD_REAL)
+    type = a68_word_real_type;
   else if (m == M_SHORT_SHORT_BITS)
     type = a68_short_short_bits_type;
   else if (m == M_SHORT_BITS)
@@ -246,10 +251,14 @@ lower_standard_mode (MOID_T *m)
     type = a68_long_bits_type;
   else if (m == M_LONG_LONG_BITS)
     type = a68_long_long_bits_type;
+  else if (m == M_WORD_BITS)
+    type = a68_word_bits_type;
   else if (m == M_BYTES)
     type = a68_bytes_type;
   else if (m == M_LONG_BYTES)
     type = a68_long_bytes_type;
+  else if (m == M_WORD_BYTES)
+    type = a68_word_bytes_type;
   else if (m == M_FILE)
     /* XXX for now this is a file descriptor.  */
     type = integer_type_node;
diff --git a/gcc/algol68/a68-low-prelude.cc b/gcc/algol68/a68-low-prelude.cc
index 804febf2c61..1ee4bf42184 100644
--- a/gcc/algol68/a68-low-prelude.cc
+++ b/gcc/algol68/a68-low-prelude.cc
@@ -1215,6 +1215,12 @@ a68_lower_shortshortbitswidth (NODE_T *p ATTRIBUTE_UNUSED, LOW_CTX_T ctx ATTRIBU
   return a68_bits_width (a68_short_short_bits_type);
 }
 
+tree
+a68_lower_wordbitswidth (NODE_T *p ATTRIBUTE_UNUSED, LOW_CTX_T ctx ATTRIBUTE_UNUSED)
+{
+  return a68_bits_width (a68_word_bits_type);
+}
+
 tree
 a68_lower_pi (NODE_T *p, LOW_CTX_T ctx ATTRIBUTE_UNUSED)
 {
@@ -1753,6 +1759,17 @@ a68_lower_longlongreali (NODE_T *p, LOW_CTX_T ctx)
   return t;
 }
 
+tree
+a68_lower_wordreali (NODE_T *p, LOW_CTX_T ctx)
+{
+  tree op1 = a68_lower_tree (SUB (p), ctx);
+  tree op2 = a68_lower_tree (NEXT (NEXT (SUB (p))), ctx);
+  tree t = a68_complex_i (M_WORD_COMPLEX, op1, op2);
+  if (CAN_HAVE_LOCATION_P (t))
+    SET_EXPR_LOCATION (t, a68_get_node_location (p));
+  return t;
+}
+
 tree
 a68_lower_inti (NODE_T *p, LOW_CTX_T ctx)
 {
@@ -1792,6 +1809,19 @@ a68_lower_longlonginti (NODE_T *p, LOW_CTX_T ctx)
   return t;
 }
 
+tree
+a68_lower_wordinti (NODE_T *p, LOW_CTX_T ctx)
+{
+  tree op1 = a68_lower_tree (SUB (p), ctx);
+  tree op2 = a68_lower_tree (NEXT (NEXT (SUB (p))), ctx);
+  tree t = a68_complex_i (M_WORD_COMPLEX,
+			  convert_to_real (a68_word_real_type, op1),
+			  convert_to_real (a68_word_real_type, op2));
+  if (CAN_HAVE_LOCATION_P (t))
+    SET_EXPR_LOCATION (t, a68_get_node_location (p));
+  return t;
+}
+
 tree
 a68_lower_re2 (NODE_T *p, LOW_CTX_T ctx)
 {
diff --git a/gcc/algol68/a68-low-reals.cc b/gcc/algol68/a68-low-reals.cc
index 418fbc8b796..f3fdb9d05f2 100644
--- a/gcc/algol68/a68-low-reals.cc
+++ b/gcc/algol68/a68-low-reals.cc
@@ -65,6 +65,11 @@ a68_get_real_skip_tree (MOID_T *m)
       int_type = a68_long_long_int_type;
       real_type = a68_long_long_real_type;
     }
+  else if (m == M_WORD_REAL)
+    {
+      int_type = a68_word_int_type;
+      real_type = a68_word_real_type;
+    }
   else
     gcc_unreachable ();
 
@@ -410,6 +415,20 @@ a68_real_entier (tree val, MOID_T *to_mode, MOID_T *from_mode)
       else
 	gcc_unreachable ();
     }
+  else if (from_mode == M_WORD_REAL)
+    {
+      if (to_type == integer_type_node)
+	fn = builtin_decl_explicit (BUILT_IN_IFLOOR);
+      else if (to_type == long_integer_type_node)
+	fn = builtin_decl_explicit (BUILT_IN_LFLOOR);
+      else if (to_type == long_long_integer_type_node)
+	fn = builtin_decl_explicit (BUILT_IN_LLFLOOR);
+      else if (to_type == a68_word_int_type)
+	/* XXX */
+	fn = builtin_decl_explicit (BUILT_IN_LFLOOR);
+      else
+	gcc_unreachable ();
+    }
   else
     gcc_unreachable ();
 
@@ -458,6 +477,20 @@ a68_real_round (tree val, MOID_T *to_mode, MOID_T *from_mode)
       else
 	gcc_unreachable ();
     }
+  else if (from_mode == M_WORD_REAL)
+    {
+      if (to_type == integer_type_node)
+	fn = builtin_decl_explicit (BUILT_IN_IROUND);
+      else if (to_type == long_integer_type_node)
+	fn = builtin_decl_explicit (BUILT_IN_LROUND);
+      else if (to_type == long_long_integer_type_node)
+	fn = builtin_decl_explicit (BUILT_IN_LLROUND);
+      else if (to_type == a68_word_int_type)
+	/* XXX */
+	fn = builtin_decl_explicit (BUILT_IN_LROUND);
+      else
+	gcc_unreachable ();
+    }
   else
     gcc_unreachable ();
 
@@ -584,6 +617,12 @@ a68_real_pow (MOID_T *m, MOID_T *a_mode, MOID_T *b_mode,
       gcc_assert (a_mode == M_LONG_LONG_REAL);
       built_in = b_mode == M_LONG_LONG_REAL ? BUILT_IN_POWL : BUILT_IN_POWIL;
     }
+  else if (m == M_WORD_REAL)
+    {
+      /* XXX */
+      gcc_assert (a_mode == M_WORD_REAL);
+      built_in = b_mode == M_WORD_REAL ? BUILT_IN_POW : BUILT_IN_POWI;
+    }
   else
     gcc_unreachable ();
 
diff --git a/gcc/algol68/a68-low-units.cc b/gcc/algol68/a68-low-units.cc
index ac7accd9051..418a50315e0 100644
--- a/gcc/algol68/a68-low-units.cc
+++ b/gcc/algol68/a68-low-units.cc
@@ -208,7 +208,10 @@ a68_lower_string_denotation (NODE_T *p, LOW_CTX_T ctx ATTRIBUTE_UNUSED)
 		  longety, bits denotation;
 		  shortety, int denotation;
 		  shortety, real denotation;
-		  shortety, bits denotation.
+		  shortety, bits denotation;
+		  word symbol, int denotation;
+		  word symbol, real denotation;
+		  word symbol, bits denotation.
 
    Denotations lower into GENERIC cst expressions.  */
 
@@ -239,13 +242,16 @@ a68_lower_denotation (NODE_T *p, LOW_CTX_T ctx)
 	   || moid == M_LONG_INT
 	   || moid == M_LONG_LONG_INT
 	   || moid == M_SHORT_INT
-	   || moid == M_SHORT_SHORT_INT)
+	   || moid == M_SHORT_SHORT_INT
+	   || moid == M_WORD_INT)
     {
       /* SIZETY INT */
       tree type;
       char *end;
       NODE_T *s = NO_NODE;
-      if (IS (SUB (p), LONGETY) || IS (SUB (p), SHORTETY))
+      if (IS (SUB (p), LONGETY)
+	  || IS (SUB (p), SHORTETY)
+	  || IS (SUB (p), FIXETY))
 	s = NEXT (SUB (p));
       else
 	s = SUB (p);
@@ -274,14 +280,17 @@ a68_lower_denotation (NODE_T *p, LOW_CTX_T ctx)
       || moid == M_LONG_BITS
       || moid == M_LONG_LONG_BITS
       || moid == M_SHORT_BITS
-      || moid == M_SHORT_SHORT_BITS)
+      || moid == M_SHORT_SHORT_BITS
+      || moid == M_WORD_BITS)
     {
       /* SIZETY BITS */
 
       tree type;
       char *end;
       NODE_T *s = NO_NODE;
-      if (IS (SUB (p), LONGETY) || IS (SUB (p), SHORTETY))
+      if (IS (SUB (p), LONGETY)
+	  || IS (SUB (p), SHORTETY)
+	  || IS (SUB (p), FIXETY))
 	s = NEXT (SUB (p));
       else
 	s = SUB (p);
@@ -313,22 +322,27 @@ a68_lower_denotation (NODE_T *p, LOW_CTX_T ctx)
     }
   else if (moid == M_REAL
 	   || moid == M_LONG_REAL
-	   || moid == M_LONG_LONG_REAL)
+	   || moid == M_LONG_LONG_REAL
+	   || moid == M_WORD_REAL)
     {
       /* SIZETY REAL */
       tree type;
       NODE_T *s = NO_NODE;
-      if (IS (SUB (p), LONGETY) || IS (SUB (p), SHORTETY))
+      if (IS (SUB (p), LONGETY)
+	  || IS (SUB (p), SHORTETY)
+	  || IS (SUB (p), FIXETY))
 	s = NEXT (SUB (p));
       else
 	s = SUB (p);
 
       if (moid == M_REAL)
-	type = float_type_node;
+	type = a68_real_type;
       else if (moid == M_LONG_REAL)
-	type = double_type_node;
+	type = a68_long_real_type;
       else if (moid == M_LONG_LONG_REAL)
-	type = long_double_type_node;
+	type = a68_long_long_real_type;
+      else if (moid == M_WORD_REAL)
+	type = a68_word_real_type;
       else
 	gcc_unreachable ();
 
-- 
2.39.5



More information about the Algol68 mailing list