diff mbox

Non-TFmode targets broken with "[fortran,patch] Complete front-end support for __float128"

Message ID AANLkTin2RTofZQVu13HkqxEV8=KgOkBctvys6agquvo-@mail.gmail.com
State New
Headers show

Commit Message

Andrew Pinski Aug. 28, 2010, 7:38 a.m. UTC
On Sat, Aug 28, 2010 at 12:35 AM, FX <fxcoudert@gmail.com> wrote:
>> Breaking targets without TFmode, like cris-elf
>
> Sorry for breaking bootstraps on (apparently) all targets. I thought I had tested it independently from library support, but apparently I failed to redo so properly after getting rid of the option.
>
> I committed the following fix as rev. 163611 to restore bootstrap:

Here is a very untested patch which should improve the issue.  I say
untested because I was writing this for Tobias just for sample code.

-- Pinski
diff mbox

Patch

Index: trans-types.c
===================================================================
--- trans-types.c	(revision 163610)
+++ trans-types.c	(working copy)
@@ -415,7 +415,7 @@  gfc_init_kinds (void)
 	if (mode != TYPE_MODE (float_type_node)
 	  && (mode != TYPE_MODE (double_type_node))
           && (mode != TYPE_MODE (long_double_type_node))
-	  && (mode != TFmode))
+	  && (float128_type_node && mode != TYPE_MODE (float128_type_node)))
 	continue;
 
       /* Let the kind equal the precision divided by 8, rounding up.  Again,
@@ -718,7 +718,8 @@  gfc_build_real_type (gfc_real_info *info
     info->c_double = 1;
   if (mode_precision == LONG_DOUBLE_TYPE_SIZE)
     info->c_long_double = 1;
-  if (mode_precision != LONG_DOUBLE_TYPE_SIZE && mode_precision == 128)
+  if (mode_precision != LONG_DOUBLE_TYPE_SIZE
+      && float128_type_node && TYPE_PRECISION (float128_type_node) == mode_precision)
     {
       info->c_float128 = 1;
       gfc_real16_is_float128 = true;
@@ -731,6 +732,9 @@  gfc_build_real_type (gfc_real_info *info
   if (TYPE_PRECISION (long_double_type_node) == mode_precision)
     return long_double_type_node;
 
+  if (float128_type_node && TYPE_PRECISION (float128_type_node) == mode_precision)
+    return float128_type_node;
+
   new_type = make_node (REAL_TYPE);
   TYPE_PRECISION (new_type) = mode_precision;
   layout_type (new_type);
@@ -750,6 +754,8 @@  gfc_build_complex_type (tree scalar_type
     return complex_double_type_node;
   if (scalar_type == long_double_type_node)
     return complex_long_double_type_node;
+  if (float128_type_node && scalar_type == float128_type_node)
+    return complex_float128_type_node;
 
   new_type = make_node (COMPLEX_TYPE);
   TREE_TYPE (new_type) = scalar_type;
@@ -847,17 +853,12 @@  gfc_init_types (void)
 		gfc_real_kinds[index].kind);
       PUSH_TYPE (name_buf, type);
 
-      if (gfc_real_kinds[index].c_float128)
-	float128_type_node = type;
-
       type = gfc_build_complex_type (type);
       gfc_complex_types[index] = type;
       snprintf (name_buf, sizeof(name_buf), "complex(kind=%d)",
 		gfc_real_kinds[index].kind);
       PUSH_TYPE (name_buf, type);
 
-      if (gfc_real_kinds[index].c_float128)
-	complex_float128_type_node = type;
     }
 
   for (index = 0; gfc_character_kinds[index].kind != 0; ++index)
@@ -2626,4 +2627,19 @@  gfc_get_array_descr_info (const_tree typ
   return true;
 }
 
+/* Registration of machine- or os-specific builtin types.  */
+void
+gfc_register_builtin_type (tree type,
+                           const char *name)
+{
+  /*  Record the __float128 type and the corresponding complex type too. */
+  if (strcmp (name, "__float128"))
+    {
+      float128_type_node = type;
+      complex_float128_type_node = make_node (COMPLEX_TYPE);
+      TREE_TYPE (complex_float128_type_node) = scalar_type;
+      layout_type (complex_float128_type_node);
+    }
+}
+
 #include "gt-fortran-trans-types.h"
Index: trans-types.h
===================================================================
--- trans-types.h	(revision 163610)
+++ trans-types.h	(working copy)
@@ -101,4 +101,6 @@  tree gfc_get_dtype (tree);
 
 tree gfc_get_ppc_type (gfc_component *);
 
+void gfc_register_builtin_type (tree, const char *);
+
 #endif
Index: f95-lang.c
===================================================================
--- f95-lang.c	(revision 163610)
+++ f95-lang.c	(working copy)
@@ -155,6 +155,7 @@  static void gfc_init_ts (void);
   gfc_omp_firstprivatize_type_sizes
 #define LANG_HOOKS_BUILTIN_FUNCTION          gfc_builtin_function
 #define LANG_HOOKS_GET_ARRAY_DESCR_INFO	     gfc_get_array_descr_info
+#define LANG_HOOKS_REGISTER_BUILTIN_TYPE     gfc_register_builtin_type
 
 struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;