This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: emit __float128 typeinfo


On Fri, 25 Apr 2014, Marc Glisse wrote:

the previous patch had to be reverted as it broke the strange handling of vectors in the ARM target. This new patch should be much more conservative I hope. Instead of adding this typeinfo to libsupc++, I am letting the FE know that it isn't available in libsupc++. There are 2 versions, both regtested fine.

Does this approach seem ok, or do we need to try harder to find a way to get this typeinfo into libsupc++?

2014-04-25  Marc Glisse  <marc.glisse@inria.fr>

	PR libstdc++/43622
	* rtti.c (emit_support_tinfos): Move the array...
	(fundamentals): ... and make it global.
	(typeinfo_in_lib_p): Use it.

2014-04-25  Marc Glisse  <marc.glisse@inria.fr>

	PR libstdc++/43622
	* rtti.c (typeinfo_in_lib_p) [REAL_TYPE]: Check against a
	hardcoded list of available types.

It seems better with a TYPE_CANONICAL in there. It passed bootstrap and the testsuite is running.

--
Marc Glisse
Index: gcc/cp/rtti.c
===================================================================
--- gcc/cp/rtti.c	(revision 209789)
+++ gcc/cp/rtti.c	(working copy)
@@ -1042,42 +1042,69 @@ class_initializer (tinfo_s *ti, tree tar
   for (i = 0; i < n; i++)
     CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, va_arg (extra_inits, tree));
   va_end (extra_inits);
 
   init = build_constructor (init_list_type_node, v);
   TREE_CONSTANT (init) = 1;
   TREE_STATIC (init) = 1;
   return init;
 }
 
+/* List of types for which the typeinfo should be placed in the
+   runtime library.
+   Dummy static variable so we can put nullptr in the array; it will be
+   set before we actually start to walk the array.  */
+static tree *const fundamentals[] =
+{
+  &void_type_node,
+  &boolean_type_node,
+  &wchar_type_node, &char16_type_node, &char32_type_node,
+  &char_type_node, &signed_char_type_node, &unsigned_char_type_node,
+  &short_integer_type_node, &short_unsigned_type_node,
+  &integer_type_node, &unsigned_type_node,
+  &long_integer_type_node, &long_unsigned_type_node,
+  &long_long_integer_type_node, &long_long_unsigned_type_node,
+  &int128_integer_type_node, &int128_unsigned_type_node,
+  &float_type_node, &double_type_node, &long_double_type_node,
+  &dfloat32_type_node, &dfloat64_type_node, &dfloat128_type_node,
+  &nullptr_type_node,
+  0
+};
+
 /* Returns true if the typeinfo for type should be placed in
    the runtime library.  */
 
 static bool
 typeinfo_in_lib_p (tree type)
 {
   /* The typeinfo objects for `T*' and `const T*' are in the runtime
      library for simple types T.  */
   if (TYPE_PTR_P (type)
       && (cp_type_quals (TREE_TYPE (type)) == TYPE_QUAL_CONST
 	  || cp_type_quals (TREE_TYPE (type)) == TYPE_UNQUALIFIED))
     type = TREE_TYPE (type);
 
   switch (TREE_CODE (type))
     {
-    case INTEGER_TYPE:
     case BOOLEAN_TYPE:
-    case REAL_TYPE:
     case VOID_TYPE:
     case NULLPTR_TYPE:
       return true;
 
+    case INTEGER_TYPE:
+    case REAL_TYPE:
+      type = TYPE_CANONICAL (type);
+      for (int ix = 0; fundamentals[ix]; ix++)
+	if (*fundamentals[ix] == type)
+	  return true;
+      return false;
+
     case LANG_TYPE:
       /* fall through.  */
 
     default:
       return false;
     }
 }
 
 /* Generate the initializer for the type info describing TYPE.  TK_INDEX is
    the index of the descriptor in the tinfo_desc vector. */
@@ -1505,38 +1532,20 @@ emit_support_tinfo_1 (tree bltn)
 
 /* Emit the type_info descriptors which are guaranteed to be in the runtime
    support.  Generating them here guarantees consistency with the other
    structures.  We use the following heuristic to determine when the runtime
    is being generated.  If std::__fundamental_type_info is defined, and its
    destructor is defined, then the runtime is being built.  */
 
 void
 emit_support_tinfos (void)
 {
-  /* Dummy static variable so we can put nullptr in the array; it will be
-     set before we actually start to walk the array.  */
-  static tree *const fundamentals[] =
-  {
-    &void_type_node,
-    &boolean_type_node,
-    &wchar_type_node, &char16_type_node, &char32_type_node,
-    &char_type_node, &signed_char_type_node, &unsigned_char_type_node,
-    &short_integer_type_node, &short_unsigned_type_node,
-    &integer_type_node, &unsigned_type_node,
-    &long_integer_type_node, &long_unsigned_type_node,
-    &long_long_integer_type_node, &long_long_unsigned_type_node,
-    &int128_integer_type_node, &int128_unsigned_type_node,
-    &float_type_node, &double_type_node, &long_double_type_node,
-    &dfloat32_type_node, &dfloat64_type_node, &dfloat128_type_node,
-    &nullptr_type_node,
-    0
-  };
   int ix;
   tree bltn_type, dtor;
 
   push_abi_namespace ();
   bltn_type = xref_tag (class_type,
 			get_identifier ("__fundamental_type_info"),
 			/*tag_scope=*/ts_current, false);
   pop_abi_namespace ();
   if (!COMPLETE_TYPE_P (bltn_type))
     return;
Index: gcc/cp/rtti.c
===================================================================
--- gcc/cp/rtti.c	(revision 209789)
+++ gcc/cp/rtti.c	(working copy)
@@ -1059,25 +1059,33 @@ typeinfo_in_lib_p (tree type)
      library for simple types T.  */
   if (TYPE_PTR_P (type)
       && (cp_type_quals (TREE_TYPE (type)) == TYPE_QUAL_CONST
 	  || cp_type_quals (TREE_TYPE (type)) == TYPE_UNQUALIFIED))
     type = TREE_TYPE (type);
 
   switch (TREE_CODE (type))
     {
     case INTEGER_TYPE:
     case BOOLEAN_TYPE:
-    case REAL_TYPE:
     case VOID_TYPE:
     case NULLPTR_TYPE:
       return true;
 
+    case REAL_TYPE:
+      type = TYPE_CANONICAL (type);
+      return type == float_type_node
+	     || type == double_type_node
+	     || type == long_double_type_node
+	     || type == dfloat32_type_node
+	     || type == dfloat64_type_node
+	     || type == dfloat128_type_node;
+
     case LANG_TYPE:
       /* fall through.  */
 
     default:
       return false;
     }
 }
 
 /* Generate the initializer for the type info describing TYPE.  TK_INDEX is
    the index of the descriptor in the tinfo_desc vector. */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]