]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
modula2: Simplify REAL/LONGREAL/SHORTREAL node creation.
authorGaius Mulley <gaiusmod2@gmail.com>
Thu, 6 Jun 2024 18:27:56 +0000 (19:27 +0100)
committerGaius Mulley <gaiusmod2@gmail.com>
Thu, 6 Jun 2024 18:27:56 +0000 (19:27 +0100)
This patch simplifies the real type build functions by using
the default float_type_node, double_type_node rather than create
new nodes.  It also uses the default GCC long_double_type_node
or float128_type_nodes for longreal.

gcc/m2/ChangeLog:

* gm2-gcc/m2type.cc (build_m2_short_real_node): Rewrite
to use the default float_type_node.
(build_m2_real_node): Rewrite to use the default
double_type_node.
(build_m2_long_real_node): Rewrite to use the default
long_double_type_node or float128_type_node.

Co-Authored-By: Kewen.Lin <linkw@linux.ibm.com>
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
gcc/m2/gm2-gcc/m2type.cc

index 571923c08ef6b1fe8766e16149a0aaf4c3de057c..5773a5cbd19077a4496ab5c746ec723e775a0397 100644 (file)
@@ -1415,45 +1415,29 @@ build_m2_char_node (void)
 static tree
 build_m2_short_real_node (void)
 {
-  tree c;
-
-  /* Define `REAL'.  */
-
-  c = make_node (REAL_TYPE);
-  TYPE_PRECISION (c) = FLOAT_TYPE_SIZE;
-  layout_type (c);
-  return c;
+  /* Define `SHORTREAL'.  */
+  ASSERT_CONDITION (TYPE_PRECISION (float_type_node) == FLOAT_TYPE_SIZE);
+  return float_type_node;
 }
 
 static tree
 build_m2_real_node (void)
 {
-  tree c;
-
   /* Define `REAL'.  */
-
-  c = make_node (REAL_TYPE);
-  TYPE_PRECISION (c) = DOUBLE_TYPE_SIZE;
-  layout_type (c);
-  return c;
+  ASSERT_CONDITION (TYPE_PRECISION (double_type_node) == DOUBLE_TYPE_SIZE);  
+  return double_type_node;
 }
 
 static tree
 build_m2_long_real_node (void)
 {
   tree longreal;
-
+  
   /* Define `LONGREAL'.  */
-  if (M2Options_GetIBMLongDouble ())
-    {
-      longreal = make_node (REAL_TYPE);
-      TYPE_PRECISION (longreal) = LONG_DOUBLE_TYPE_SIZE;
-    }
-  else if (M2Options_GetIEEELongDouble ())
+  if (M2Options_GetIEEELongDouble ())
     longreal = float128_type_node;
   else
     longreal = long_double_type_node;
-  layout_type (longreal);
   return longreal;
 }