public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* emit __float128 typeinfo
@ 2014-04-25  9:12 Marc Glisse
  2014-04-25 11:25 ` Marc Glisse
  2014-05-21 17:49 ` Jason Merrill
  0 siblings, 2 replies; 8+ messages in thread
From: Marc Glisse @ 2014-04-25  9:12 UTC (permalink / raw)
  To: gcc-patches; +Cc: jason

[-- Attachment #1: Type: TEXT/PLAIN, Size: 810 bytes --]

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.

-- 
Marc Glisse

[-- Attachment #2: Type: TEXT/PLAIN, Size: 4011 bytes --]

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;

[-- Attachment #3: Type: TEXT/PLAIN, Size: 1127 bytes --]

Index: gcc/cp/rtti.c
===================================================================
--- gcc/cp/rtti.c	(revision 209787)
+++ gcc/cp/rtti.c	(working copy)
@@ -1059,25 +1059,32 @@ 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:
+      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. */

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: emit __float128 typeinfo
  2014-04-25  9:12 emit __float128 typeinfo Marc Glisse
@ 2014-04-25 11:25 ` Marc Glisse
  2014-05-08 14:36   ` Marc Glisse
  2014-05-21 17:49 ` Jason Merrill
  1 sibling, 1 reply; 8+ messages in thread
From: Marc Glisse @ 2014-04-25 11:25 UTC (permalink / raw)
  To: gcc-patches; +Cc: jason

[-- Attachment #1: Type: TEXT/PLAIN, Size: 973 bytes --]

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

[-- Attachment #2: Type: TEXT/PLAIN, Size: 4049 bytes --]

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;

[-- Attachment #3: Type: TEXT/PLAIN, Size: 1165 bytes --]

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. */

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: emit __float128 typeinfo
  2014-04-25 11:25 ` Marc Glisse
@ 2014-05-08 14:36   ` Marc Glisse
  0 siblings, 0 replies; 8+ messages in thread
From: Marc Glisse @ 2014-05-08 14:36 UTC (permalink / raw)
  To: gcc-patches; +Cc: jason

Ping
http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01651.html


On Fri, 25 Apr 2014, Marc Glisse wrote:

> 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: emit __float128 typeinfo
  2014-04-25  9:12 emit __float128 typeinfo Marc Glisse
  2014-04-25 11:25 ` Marc Glisse
@ 2014-05-21 17:49 ` Jason Merrill
  2014-05-23 10:01   ` Marc Glisse
  1 sibling, 1 reply; 8+ messages in thread
From: Jason Merrill @ 2014-05-21 17:49 UTC (permalink / raw)
  To: Marc Glisse, gcc-patches

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: emit __float128 typeinfo
  2014-05-21 17:49 ` Jason Merrill
@ 2014-05-23 10:01   ` Marc Glisse
  2014-06-04 16:56     ` Jason Merrill
  0 siblings, 1 reply; 8+ messages in thread
From: Marc Glisse @ 2014-05-23 10:01 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches

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.

-- 
Marc Glisse

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: emit __float128 typeinfo
  2014-05-23 10:01   ` Marc Glisse
@ 2014-06-04 16:56     ` Jason Merrill
  2014-06-04 19:45       ` Marc Glisse
  0 siblings, 1 reply; 8+ messages in thread
From: Jason Merrill @ 2014-06-04 16:56 UTC (permalink / raw)
  To: Marc Glisse; +Cc: gcc-patches

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: emit __float128 typeinfo
  2014-06-04 16:56     ` Jason Merrill
@ 2014-06-04 19:45       ` Marc Glisse
  2014-06-04 22:00         ` Jason Merrill
  0 siblings, 1 reply; 8+ messages in thread
From: Marc Glisse @ 2014-06-04 19:45 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches

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.

-- 
Marc Glisse

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: emit __float128 typeinfo
  2014-06-04 19:45       ` Marc Glisse
@ 2014-06-04 22:00         ` Jason Merrill
  0 siblings, 0 replies; 8+ messages in thread
From: Jason Merrill @ 2014-06-04 22:00 UTC (permalink / raw)
  To: Marc Glisse; +Cc: gcc-patches

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-06-04 22:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-25  9:12 emit __float128 typeinfo Marc Glisse
2014-04-25 11:25 ` Marc Glisse
2014-05-08 14:36   ` Marc Glisse
2014-05-21 17:49 ` Jason Merrill
2014-05-23 10:01   ` Marc Glisse
2014-06-04 16:56     ` Jason Merrill
2014-06-04 19:45       ` Marc Glisse
2014-06-04 22:00         ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).