diff mbox

emit __float128 typeinfo

Message ID alpine.DEB.2.02.1404251037260.29987@stedding.saclay.inria.fr
State New
Headers show

Commit Message

Marc Glisse April 25, 2014, 9:04 a.m. UTC
Hello,

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.

Comments

Jason Merrill May 21, 2014, 5:49 p.m. UTC | #1
On 04/25/2014 05:04 AM, Marc Glisse wrote:
> Does this approach seem ok, or do we need to try harder to find a way to
> get this typeinfo into libsupc++?

The latter, I think; these are base types, so they should go in the 
library.  Sorry for the slow response.

Jason
Marc Glisse May 23, 2014, 10:01 a.m. UTC | #2
On Wed, 21 May 2014, Jason Merrill wrote:

> On 04/25/2014 05:04 AM, Marc Glisse wrote:
>> Does this approach seem ok, or do we need to try harder to find a way to
>> get this typeinfo into libsupc++?
>
> The latter, I think; these are base types, so they should go in the library.

Hmm, ok. Because of the arm target, we can't just use the 
register_builtin_type hook as it is. The things I can think of right now 
are:

1) change the prototype of register_builtin_type so it takes an extra bool 
parameter that says if we want to generate runtime stuff like typeinfo (in 
addition to what register_builtin_type is already doing). I would then 
update all target calls with ", false" and let target maintainers switch 
to true when they are ready.

or

2) create a new register_builtin_type_runtime lang hook that would be 
defined only in (obj-)c++ and would be used only to generate typeinfo.

Does one of those seem acceptable?

Another alternative might be to wait for the intN_t work to land and do 
the same for floatN_t, but that's too big for me.
Jason Merrill June 4, 2014, 4:56 p.m. UTC | #3
How about, in emit_support_tinfos, using type_for_mode to check for a 
TF-mode floating point type different from long_double_type_node?

Jason
Marc Glisse June 4, 2014, 7:45 p.m. UTC | #4
On Wed, 4 Jun 2014, Jason Merrill wrote:

> How about, in emit_support_tinfos, using type_for_mode to check for a TF-mode 
> floating point type different from long_double_type_node?

What should I pass as the mode argument? I can't just write TFmode, that 
will fail to compile on platforms that don't define it, and powerpc seems 
likely to call it JFmode instead quite soon. MAX_MODE_FLOAT maybe? But 
then if we configure with long double = __float128, we will miss 
__float80.

Ah, we walk from GET_CLASS_NARROWEST_MODE (MODE_FLOAT) with 
GET_MODE_WIDER_MODE steps and test if the associated type is not in the 
list 0/float/double/long double. I think it should be ok with arm (it 
would be good if they removed their unused XFmode, but I don't even think 
it is necessary).

Is that what you were suggesting? I'll try to write a patch, thanks.
Jason Merrill June 4, 2014, 10 p.m. UTC | #5
On 06/04/2014 03:45 PM, Marc Glisse wrote:
> Ah, we walk from GET_CLASS_NARROWEST_MODE (MODE_FLOAT) with
> GET_MODE_WIDER_MODE steps and test if the associated type is not in the
> list 0/float/double/long double. I think it should be ok with arm (it
> would be good if they removed their unused XFmode, but I don't even
> think it is necessary).

Sounds good.

Jason
diff mbox

Patch

Index: gcc/cp/rtti.c
===================================================================
--- gcc/cp/rtti.c	(revision 209787)
+++ gcc/cp/rtti.c	(working copy)
@@ -1042,42 +1042,68 @@  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:
+      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 +1531,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;