public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Additional small changes to support opaque modes
@ 2020-11-20  1:04 acsawdey
  0 siblings, 0 replies; 6+ messages in thread
From: acsawdey @ 2020-11-20  1:04 UTC (permalink / raw)
  To: gcc-patches

From: Aaron Sawdey <acsawdey@linux.ibm.com>

After building some larger codes using opaque types and some c++ codes
using opaque types it became clear I needed to go through and look for
places where opaque types and modes needed to be handled. A whole pile
of one-liners.

If bootstrap/regtest passes for ppc64le and x86_64, ok for trunk?

gcc/
	* typeclass.h: Add opaque_type_class.
	* builtins.c (type_to_class): Identify opaque type class.
	* c-family/c-pretty-print.c (c_pretty_printer::simple_type_specifier):
	Treat opaque types like other types.
	(c_pretty_printer::direct_abstract_declarator): Opaque types are
	supported types.
	* c/c-aux-info.c (gen_type): Support opaque types.
	* cp/error.c (dump_type): Handle opaque types.
	(dump_type_prefix): Handle opaque types.
	(dump_type_suffix): Handle opaque types.
	(dump_expr): Handle opaque types.
	* cp/pt.c (tsubst): Allow opaque types in templates.
	(unify): Allow opaque types in templates.
	* cp/typeck.c (structural_comptypes): Handle comparison
	of opaque types.
	* dwarf2out.c (is_base_type): Handle opaque types.
	(loc_descriptor): Handle opaque modes like VOIDmode/BLKmode.
	(gen_type_die_with_usage): Handle opaque types.
	* expr.c (count_type_elements): Opaque types should
	never have initializers.
	* ipa-devirt.c (odr_types_equivalent_p): No type-specific handling
	for opaque types is needed as it eventually checks the underlying
	mode which is what is important.
	* tree-streamer.c (record_common_node): Handle opaque types.
	* tree.c (type_contains_placeholder_1): Handle opaque types.
	(type_cache_hasher::equal): No additional comparison needed for
	opaque types.
---
 gcc/builtins.c                | 1 +
 gcc/c-family/c-pretty-print.c | 2 ++
 gcc/c/c-aux-info.c            | 4 ++++
 gcc/cp/error.c                | 4 ++++
 gcc/cp/pt.c                   | 2 ++
 gcc/cp/typeck.c               | 1 +
 gcc/dwarf2out.c               | 4 +++-
 gcc/expr.c                    | 1 +
 gcc/ipa-devirt.c              | 1 +
 gcc/tree-streamer.c           | 1 +
 gcc/tree.c                    | 2 ++
 gcc/typeclass.h               | 2 +-
 12 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/gcc/builtins.c b/gcc/builtins.c
index 42c52a1925e..0958abcae49 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -2228,6 +2228,7 @@ type_to_class (tree type)
     case ARRAY_TYPE:	   return (TYPE_STRING_FLAG (type)
 				   ? string_type_class : array_type_class);
     case LANG_TYPE:	   return lang_type_class;
+    case OPAQUE_TYPE:      return opaque_type_class;
     default:		   return no_type_class;
     }
 }
diff --git a/gcc/c-family/c-pretty-print.c b/gcc/c-family/c-pretty-print.c
index 8953e3b678b..3027703056b 100644
--- a/gcc/c-family/c-pretty-print.c
+++ b/gcc/c-family/c-pretty-print.c
@@ -342,6 +342,7 @@ c_pretty_printer::simple_type_specifier (tree t)
       break;
 
     case VOID_TYPE:
+    case OPAQUE_TYPE:
     case BOOLEAN_TYPE:
     case INTEGER_TYPE:
     case REAL_TYPE:
@@ -662,6 +663,7 @@ c_pretty_printer::direct_abstract_declarator (tree t)
 
     case IDENTIFIER_NODE:
     case VOID_TYPE:
+    case OPAQUE_TYPE:
     case BOOLEAN_TYPE:
     case INTEGER_TYPE:
     case REAL_TYPE:
diff --git a/gcc/c/c-aux-info.c b/gcc/c/c-aux-info.c
index ffc8099856d..41f5598de38 100644
--- a/gcc/c/c-aux-info.c
+++ b/gcc/c/c-aux-info.c
@@ -413,6 +413,10 @@ gen_type (const char *ret_val, tree t, formals_style style)
 	  data_type = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (t)));
 	  break;
 
+	case OPAQUE_TYPE:
+	  data_type = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (t)));
+	  break;
+
 	case VOID_TYPE:
 	  data_type = "void";
 	  break;
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index 396558be17f..d27545d1223 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -529,6 +529,7 @@ dump_type (cxx_pretty_printer *pp, tree t, int flags)
     case INTEGER_TYPE:
     case REAL_TYPE:
     case VOID_TYPE:
+    case OPAQUE_TYPE:
     case BOOLEAN_TYPE:
     case COMPLEX_TYPE:
     case VECTOR_TYPE:
@@ -874,6 +875,7 @@ dump_type_prefix (cxx_pretty_printer *pp, tree t, int flags)
     case UNION_TYPE:
     case LANG_TYPE:
     case VOID_TYPE:
+    case OPAQUE_TYPE:
     case TYPENAME_TYPE:
     case COMPLEX_TYPE:
     case VECTOR_TYPE:
@@ -997,6 +999,7 @@ dump_type_suffix (cxx_pretty_printer *pp, tree t, int flags)
     case UNION_TYPE:
     case LANG_TYPE:
     case VOID_TYPE:
+    case OPAQUE_TYPE:
     case TYPENAME_TYPE:
     case COMPLEX_TYPE:
     case VECTOR_TYPE:
@@ -2810,6 +2813,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags)
     case ENUMERAL_TYPE:
     case REAL_TYPE:
     case VOID_TYPE:
+    case OPAQUE_TYPE:
     case BOOLEAN_TYPE:
     case INTEGER_TYPE:
     case COMPLEX_TYPE:
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 1babf833d32..415c431eaeb 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -15383,6 +15383,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
     case ERROR_MARK:
     case IDENTIFIER_NODE:
     case VOID_TYPE:
+    case OPAQUE_TYPE:
     case REAL_TYPE:
     case COMPLEX_TYPE:
     case VECTOR_TYPE:
@@ -23595,6 +23596,7 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict,
     case BOOLEAN_TYPE:
     case ENUMERAL_TYPE:
     case VOID_TYPE:
+    case OPAQUE_TYPE:
     case NULLPTR_TYPE:
       if (TREE_CODE (arg) != TREE_CODE (parm))
 	return unify_type_mismatch (explain_p, parm, arg);
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 700e166ca66..729c7069c4f 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -1314,6 +1314,7 @@ structural_comptypes (tree t1, tree t2, int strict)
       /* All void and bool types are the same.  */
       break;
 
+    case OPAQUE_TYPE:
     case INTEGER_TYPE:
     case FIXED_POINT_TYPE:
     case REAL_TYPE:
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 54eb445665c..d6d12efff34 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -13037,6 +13037,7 @@ is_base_type (tree type)
       return 1;
 
     case VOID_TYPE:
+    case OPAQUE_TYPE:
     case ARRAY_TYPE:
     case RECORD_TYPE:
     case UNION_TYPE:
@@ -16767,7 +16768,7 @@ loc_descriptor (rtx rtl, machine_mode mode,
       break;
 
     case CONST_INT:
-      if (mode != VOIDmode && mode != BLKmode)
+      if (mode != VOIDmode && mode != BLKmode && !OPAQUE_MODE_P (mode))
 	{
 	  int_mode = as_a <scalar_int_mode> (mode);
 	  loc_result = address_of_int_loc_descriptor (GET_MODE_SIZE (int_mode),
@@ -25775,6 +25776,7 @@ gen_type_die_with_usage (tree type, dw_die_ref context_die,
       return;
 
     case VOID_TYPE:
+    case OPAQUE_TYPE:
     case INTEGER_TYPE:
     case REAL_TYPE:
     case FIXED_POINT_TYPE:
diff --git a/gcc/expr.c b/gcc/expr.c
index ae16f077758..a8b1ea1d40c 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -6171,6 +6171,7 @@ count_type_elements (const_tree type, bool for_ctor_p)
       return 0;
 
     case VOID_TYPE:
+    case OPAQUE_TYPE:
     case METHOD_TYPE:
     case FUNCTION_TYPE:
     case LANG_TYPE:
diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c
index 6e6df0b2af5..0f2b8143849 100644
--- a/gcc/ipa-devirt.c
+++ b/gcc/ipa-devirt.c
@@ -1521,6 +1521,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
 	break;
       }
     case VOID_TYPE:
+    case OPAQUE_TYPE:
     case NULLPTR_TYPE:
       break;
 
diff --git a/gcc/tree-streamer.c b/gcc/tree-streamer.c
index b0afa1dc6c0..a393983f76c 100644
--- a/gcc/tree-streamer.c
+++ b/gcc/tree-streamer.c
@@ -317,6 +317,7 @@ record_common_node (struct streamer_tree_cache_d *cache, tree node)
     case TREE_LIST:
     case VOID_CST:
     case VOID_TYPE:
+    case OPAQUE_TYPE:
       /* No recursive trees.  */
       break;
     case ARRAY_TYPE:
diff --git a/gcc/tree.c b/gcc/tree.c
index 569a9b9317b..aa6db8dae70 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -3944,6 +3944,7 @@ type_contains_placeholder_1 (const_tree type)
   switch (TREE_CODE (type))
     {
     case VOID_TYPE:
+    case OPAQUE_TYPE:
     case COMPLEX_TYPE:
     case ENUMERAL_TYPE:
     case BOOLEAN_TYPE:
@@ -7072,6 +7073,7 @@ type_cache_hasher::equal (type_hash *a, type_hash *b)
   switch (TREE_CODE (a->type))
     {
     case VOID_TYPE:
+    case OPAQUE_TYPE:
     case COMPLEX_TYPE:
     case POINTER_TYPE:
     case REFERENCE_TYPE:
diff --git a/gcc/typeclass.h b/gcc/typeclass.h
index 434e6acf6c9..b4e3dda21ec 100644
--- a/gcc/typeclass.h
+++ b/gcc/typeclass.h
@@ -37,7 +37,7 @@ enum type_class
   function_type_class, method_type_class,
   record_type_class, union_type_class,
   array_type_class, string_type_class,
-  lang_type_class
+  lang_type_class, opaque_type_class
 };
 
 #endif /* GCC_TYPECLASS_H */
-- 
2.27.0


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

* Re: [PATCH] Additional small changes to support opaque modes
  2020-11-20 21:49     ` Aaron Sawdey
@ 2020-11-23  9:19       ` Richard Sandiford
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Sandiford @ 2020-11-23  9:19 UTC (permalink / raw)
  To: Aaron Sawdey; +Cc: Jakub Jelinek, Bill Schmidt, gcc-patches, Segher Boessenkool

Aaron Sawdey <acsawdey@linux.ibm.com> writes:
>> On Nov 20, 2020, at 4:57 AM, Aaron Sawdey via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>> 
>> 
>>> On Nov 20, 2020, at 3:55 AM, Richard Sandiford <richard.sandiford@arm.com> wrote:
>>> 
>>> acsawdey--- via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
>>>> @@ -16767,7 +16768,7 @@ loc_descriptor (rtx rtl, machine_mode mode,
>>>>      break;
>>>> 
>>>>    case CONST_INT:
>>>> -      if (mode != VOIDmode && mode != BLKmode)
>>>> +      if (mode != VOIDmode && mode != BLKmode && !OPAQUE_MODE_P (mode))
>>>> 	{
>>>> 	  int_mode = as_a <scalar_int_mode> (mode);
>>>> 	  loc_result = address_of_int_loc_descriptor (GET_MODE_SIZE (int_mode),
>>> 
>>> I realise I'm asking this about something that already appears to handle
>>> BLKmode CONST_INTs (?!), but this is the one change in the patch I
>>> struggled with.  Why do we see a CONST_INT that allegedly has an
>>> opaque mode?  It feels like something has gone wrong further up the
>>> call chain.
>>> 
>>> This might still be the expedient fix for whatever is happening,
>>> but I think it deserves a comment at least.
>>> 
>>> The rest looks good to me FWIW.
>>> 
>>> Richard
>> 
>> I should look at this again — since I originally put that in, I switched the target
>> portion of what I’ve been doing to use an UNSPEC to remove all use of an
>> opaque mode const_int from the rtf. This may not be needed any more. 
>
> And as a final addendum — I was able to remove this and the problem I saw
> before did not come back, probably because UNSPEC is used to hide all
> constants so we never see any opaque type or mode constants, which is a
> good thing.

Great.  The patch is OK without that hunk and with the gen_type nit fixed.

Thanks,
Richard

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

* Re: [PATCH] Additional small changes to support opaque modes
  2020-11-20 10:57   ` Aaron Sawdey
@ 2020-11-20 21:49     ` Aaron Sawdey
  2020-11-23  9:19       ` Richard Sandiford
  0 siblings, 1 reply; 6+ messages in thread
From: Aaron Sawdey @ 2020-11-20 21:49 UTC (permalink / raw)
  To: Aaron Sawdey
  Cc: Richard Sandiford, Jakub Jelinek, Bill Schmidt, gcc-patches,
	Segher Boessenkool

> On Nov 20, 2020, at 4:57 AM, Aaron Sawdey via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> 
> 
>> On Nov 20, 2020, at 3:55 AM, Richard Sandiford <richard.sandiford@arm.com> wrote:
>> 
>> acsawdey--- via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
>>> @@ -16767,7 +16768,7 @@ loc_descriptor (rtx rtl, machine_mode mode,
>>>      break;
>>> 
>>>    case CONST_INT:
>>> -      if (mode != VOIDmode && mode != BLKmode)
>>> +      if (mode != VOIDmode && mode != BLKmode && !OPAQUE_MODE_P (mode))
>>> 	{
>>> 	  int_mode = as_a <scalar_int_mode> (mode);
>>> 	  loc_result = address_of_int_loc_descriptor (GET_MODE_SIZE (int_mode),
>> 
>> I realise I'm asking this about something that already appears to handle
>> BLKmode CONST_INTs (?!), but this is the one change in the patch I
>> struggled with.  Why do we see a CONST_INT that allegedly has an
>> opaque mode?  It feels like something has gone wrong further up the
>> call chain.
>> 
>> This might still be the expedient fix for whatever is happening,
>> but I think it deserves a comment at least.
>> 
>> The rest looks good to me FWIW.
>> 
>> Richard
> 
> I should look at this again — since I originally put that in, I switched the target
> portion of what I’ve been doing to use an UNSPEC to remove all use of an
> opaque mode const_int from the rtf. This may not be needed any more. 

And as a final addendum — I was able to remove this and the problem I saw
before did not come back, probably because UNSPEC is used to hide all
constants so we never see any opaque type or mode constants, which is a
good thing.

Aaron Sawdey, Ph.D. sawdey@linux.ibm.com
IBM Linux on POWER Toolchain
 



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

* Re: [PATCH] Additional small changes to support opaque modes
  2020-11-20  9:55 ` Richard Sandiford
@ 2020-11-20 10:57   ` Aaron Sawdey
  2020-11-20 21:49     ` Aaron Sawdey
  0 siblings, 1 reply; 6+ messages in thread
From: Aaron Sawdey @ 2020-11-20 10:57 UTC (permalink / raw)
  To: Richard Sandiford
  Cc: gcc-patches, Jakub Jelinek, Segher Boessenkool, wschmidt


> On Nov 20, 2020, at 3:55 AM, Richard Sandiford <richard.sandiford@arm.com> wrote:
> 
> acsawdey--- via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
>> diff --git a/gcc/c/c-aux-info.c b/gcc/c/c-aux-info.c
>> index ffc8099856d..41f5598de38 100644
>> --- a/gcc/c/c-aux-info.c
>> +++ b/gcc/c/c-aux-info.c
>> @@ -413,6 +413,10 @@ gen_type (const char *ret_val, tree t, formals_style style)
>> 	  data_type = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (t)));
>> 	  break;
>> 
>> +	case OPAQUE_TYPE:
>> +	  data_type = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (t)));
>> +	  break;
>> +
> 
> Might as well just add this case to the REAL_TYPE one.
> 
>> 	case VOID_TYPE:
>> 	  data_type = "void";
>> 	  break;
>> […]
>> diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
>> index 54eb445665c..d6d12efff34 100644
>> --- a/gcc/dwarf2out.c
>> +++ b/gcc/dwarf2out.c
>> @@ -13037,6 +13037,7 @@ is_base_type (tree type)
>>       return 1;
>> 
>>     case VOID_TYPE:
>> +    case OPAQUE_TYPE:
>>     case ARRAY_TYPE:
>>     case RECORD_TYPE:
>>     case UNION_TYPE:
>> @@ -16767,7 +16768,7 @@ loc_descriptor (rtx rtl, machine_mode mode,
>>       break;
>> 
>>     case CONST_INT:
>> -      if (mode != VOIDmode && mode != BLKmode)
>> +      if (mode != VOIDmode && mode != BLKmode && !OPAQUE_MODE_P (mode))
>> 	{
>> 	  int_mode = as_a <scalar_int_mode> (mode);
>> 	  loc_result = address_of_int_loc_descriptor (GET_MODE_SIZE (int_mode),
> 
> I realise I'm asking this about something that already appears to handle
> BLKmode CONST_INTs (?!), but this is the one change in the patch I
> struggled with.  Why do we see a CONST_INT that allegedly has an
> opaque mode?  It feels like something has gone wrong further up the
> call chain.
> 
> This might still be the expedient fix for whatever is happening,
> but I think it deserves a comment at least.
> 
> The rest looks good to me FWIW.
> 
> Richard

I should look at this again — since I originally put that in, I switched the target
portion of what I’ve been doing to use an UNSPEC to remove all use of an
opaque mode const_int from the rtf. This may not be needed any more. 

Thanks,
   Aaron

Aaron Sawdey, Ph.D. sawdey@linux.ibm.com
IBM Linux on POWER Toolchain
 



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

* Re: [PATCH] Additional small changes to support opaque modes
  2020-11-20  0:57 acsawdey
@ 2020-11-20  9:55 ` Richard Sandiford
  2020-11-20 10:57   ` Aaron Sawdey
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Sandiford @ 2020-11-20  9:55 UTC (permalink / raw)
  To: acsawdey--- via Gcc-patches; +Cc: acsawdey, jakub, segher, wschmidt

acsawdey--- via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
> diff --git a/gcc/c/c-aux-info.c b/gcc/c/c-aux-info.c
> index ffc8099856d..41f5598de38 100644
> --- a/gcc/c/c-aux-info.c
> +++ b/gcc/c/c-aux-info.c
> @@ -413,6 +413,10 @@ gen_type (const char *ret_val, tree t, formals_style style)
>  	  data_type = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (t)));
>  	  break;
>  
> +	case OPAQUE_TYPE:
> +	  data_type = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (t)));
> +	  break;
> +

Might as well just add this case to the REAL_TYPE one.

>  	case VOID_TYPE:
>  	  data_type = "void";
>  	  break;
> […]
> diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
> index 54eb445665c..d6d12efff34 100644
> --- a/gcc/dwarf2out.c
> +++ b/gcc/dwarf2out.c
> @@ -13037,6 +13037,7 @@ is_base_type (tree type)
>        return 1;
>  
>      case VOID_TYPE:
> +    case OPAQUE_TYPE:
>      case ARRAY_TYPE:
>      case RECORD_TYPE:
>      case UNION_TYPE:
> @@ -16767,7 +16768,7 @@ loc_descriptor (rtx rtl, machine_mode mode,
>        break;
>  
>      case CONST_INT:
> -      if (mode != VOIDmode && mode != BLKmode)
> +      if (mode != VOIDmode && mode != BLKmode && !OPAQUE_MODE_P (mode))
>  	{
>  	  int_mode = as_a <scalar_int_mode> (mode);
>  	  loc_result = address_of_int_loc_descriptor (GET_MODE_SIZE (int_mode),

I realise I'm asking this about something that already appears to handle
BLKmode CONST_INTs (?!), but this is the one change in the patch I
struggled with.  Why do we see a CONST_INT that allegedly has an
opaque mode?  It feels like something has gone wrong further up the
call chain.

This might still be the expedient fix for whatever is happening,
but I think it deserves a comment at least.

The rest looks good to me FWIW.

Richard

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

* [PATCH] Additional small changes to support opaque modes
@ 2020-11-20  0:57 acsawdey
  2020-11-20  9:55 ` Richard Sandiford
  0 siblings, 1 reply; 6+ messages in thread
From: acsawdey @ 2020-11-20  0:57 UTC (permalink / raw)
  To: gcc-patches
  Cc: richard.sandiford, jakub, segher, wschmidt, bergner, Aaron Sawdey

From: Aaron Sawdey <acsawdey@linux.ibm.com>

After building some larger codes using opaque types and some c++ codes
using opaque types it became clear I needed to go through and look for
places where opaque types and modes needed to be handled. A whole pile
of one-liners.

If bootstrap/regtest passes for ppc64le and x86_64, ok for trunk?

gcc/
	* typeclass.h: Add opaque_type_class.
	* builtins.c (type_to_class): Identify opaque type class.
	* c-family/c-pretty-print.c (c_pretty_printer::simple_type_specifier):
	Treat opaque types like other types.
	(c_pretty_printer::direct_abstract_declarator): Opaque types are
	supported types.
	* c/c-aux-info.c (gen_type): Support opaque types.
	* cp/error.c (dump_type): Handle opaque types.
	(dump_type_prefix): Handle opaque types.
	(dump_type_suffix): Handle opaque types.
	(dump_expr): Handle opaque types.
	* cp/pt.c (tsubst): Allow opaque types in templates.
	(unify): Allow opaque types in templates.
	* cp/typeck.c (structural_comptypes): Handle comparison
	of opaque types.
	* dwarf2out.c (is_base_type): Handle opaque types.
	(loc_descriptor): Handle opaque modes like VOIDmode/BLKmode.
	(gen_type_die_with_usage): Handle opaque types.
	* expr.c (count_type_elements): Opaque types should
	never have initializers.
	* ipa-devirt.c (odr_types_equivalent_p): No type-specific handling
	for opaque types is needed as it eventually checks the underlying
	mode which is what is important.
	* tree-streamer.c (record_common_node): Handle opaque types.
	* tree.c (type_contains_placeholder_1): Handle opaque types.
	(type_cache_hasher::equal): No additional comparison needed for
	opaque types.
---
 gcc/builtins.c                | 1 +
 gcc/c-family/c-pretty-print.c | 2 ++
 gcc/c/c-aux-info.c            | 4 ++++
 gcc/cp/error.c                | 4 ++++
 gcc/cp/pt.c                   | 2 ++
 gcc/cp/typeck.c               | 1 +
 gcc/dwarf2out.c               | 4 +++-
 gcc/expr.c                    | 1 +
 gcc/ipa-devirt.c              | 1 +
 gcc/tree-streamer.c           | 1 +
 gcc/tree.c                    | 2 ++
 gcc/typeclass.h               | 2 +-
 12 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/gcc/builtins.c b/gcc/builtins.c
index 42c52a1925e..0958abcae49 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -2228,6 +2228,7 @@ type_to_class (tree type)
     case ARRAY_TYPE:	   return (TYPE_STRING_FLAG (type)
 				   ? string_type_class : array_type_class);
     case LANG_TYPE:	   return lang_type_class;
+    case OPAQUE_TYPE:      return opaque_type_class;
     default:		   return no_type_class;
     }
 }
diff --git a/gcc/c-family/c-pretty-print.c b/gcc/c-family/c-pretty-print.c
index 8953e3b678b..3027703056b 100644
--- a/gcc/c-family/c-pretty-print.c
+++ b/gcc/c-family/c-pretty-print.c
@@ -342,6 +342,7 @@ c_pretty_printer::simple_type_specifier (tree t)
       break;
 
     case VOID_TYPE:
+    case OPAQUE_TYPE:
     case BOOLEAN_TYPE:
     case INTEGER_TYPE:
     case REAL_TYPE:
@@ -662,6 +663,7 @@ c_pretty_printer::direct_abstract_declarator (tree t)
 
     case IDENTIFIER_NODE:
     case VOID_TYPE:
+    case OPAQUE_TYPE:
     case BOOLEAN_TYPE:
     case INTEGER_TYPE:
     case REAL_TYPE:
diff --git a/gcc/c/c-aux-info.c b/gcc/c/c-aux-info.c
index ffc8099856d..41f5598de38 100644
--- a/gcc/c/c-aux-info.c
+++ b/gcc/c/c-aux-info.c
@@ -413,6 +413,10 @@ gen_type (const char *ret_val, tree t, formals_style style)
 	  data_type = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (t)));
 	  break;
 
+	case OPAQUE_TYPE:
+	  data_type = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (t)));
+	  break;
+
 	case VOID_TYPE:
 	  data_type = "void";
 	  break;
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index 396558be17f..d27545d1223 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -529,6 +529,7 @@ dump_type (cxx_pretty_printer *pp, tree t, int flags)
     case INTEGER_TYPE:
     case REAL_TYPE:
     case VOID_TYPE:
+    case OPAQUE_TYPE:
     case BOOLEAN_TYPE:
     case COMPLEX_TYPE:
     case VECTOR_TYPE:
@@ -874,6 +875,7 @@ dump_type_prefix (cxx_pretty_printer *pp, tree t, int flags)
     case UNION_TYPE:
     case LANG_TYPE:
     case VOID_TYPE:
+    case OPAQUE_TYPE:
     case TYPENAME_TYPE:
     case COMPLEX_TYPE:
     case VECTOR_TYPE:
@@ -997,6 +999,7 @@ dump_type_suffix (cxx_pretty_printer *pp, tree t, int flags)
     case UNION_TYPE:
     case LANG_TYPE:
     case VOID_TYPE:
+    case OPAQUE_TYPE:
     case TYPENAME_TYPE:
     case COMPLEX_TYPE:
     case VECTOR_TYPE:
@@ -2810,6 +2813,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags)
     case ENUMERAL_TYPE:
     case REAL_TYPE:
     case VOID_TYPE:
+    case OPAQUE_TYPE:
     case BOOLEAN_TYPE:
     case INTEGER_TYPE:
     case COMPLEX_TYPE:
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 1babf833d32..415c431eaeb 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -15383,6 +15383,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
     case ERROR_MARK:
     case IDENTIFIER_NODE:
     case VOID_TYPE:
+    case OPAQUE_TYPE:
     case REAL_TYPE:
     case COMPLEX_TYPE:
     case VECTOR_TYPE:
@@ -23595,6 +23596,7 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict,
     case BOOLEAN_TYPE:
     case ENUMERAL_TYPE:
     case VOID_TYPE:
+    case OPAQUE_TYPE:
     case NULLPTR_TYPE:
       if (TREE_CODE (arg) != TREE_CODE (parm))
 	return unify_type_mismatch (explain_p, parm, arg);
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 700e166ca66..729c7069c4f 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -1314,6 +1314,7 @@ structural_comptypes (tree t1, tree t2, int strict)
       /* All void and bool types are the same.  */
       break;
 
+    case OPAQUE_TYPE:
     case INTEGER_TYPE:
     case FIXED_POINT_TYPE:
     case REAL_TYPE:
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 54eb445665c..d6d12efff34 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -13037,6 +13037,7 @@ is_base_type (tree type)
       return 1;
 
     case VOID_TYPE:
+    case OPAQUE_TYPE:
     case ARRAY_TYPE:
     case RECORD_TYPE:
     case UNION_TYPE:
@@ -16767,7 +16768,7 @@ loc_descriptor (rtx rtl, machine_mode mode,
       break;
 
     case CONST_INT:
-      if (mode != VOIDmode && mode != BLKmode)
+      if (mode != VOIDmode && mode != BLKmode && !OPAQUE_MODE_P (mode))
 	{
 	  int_mode = as_a <scalar_int_mode> (mode);
 	  loc_result = address_of_int_loc_descriptor (GET_MODE_SIZE (int_mode),
@@ -25775,6 +25776,7 @@ gen_type_die_with_usage (tree type, dw_die_ref context_die,
       return;
 
     case VOID_TYPE:
+    case OPAQUE_TYPE:
     case INTEGER_TYPE:
     case REAL_TYPE:
     case FIXED_POINT_TYPE:
diff --git a/gcc/expr.c b/gcc/expr.c
index ae16f077758..a8b1ea1d40c 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -6171,6 +6171,7 @@ count_type_elements (const_tree type, bool for_ctor_p)
       return 0;
 
     case VOID_TYPE:
+    case OPAQUE_TYPE:
     case METHOD_TYPE:
     case FUNCTION_TYPE:
     case LANG_TYPE:
diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c
index 6e6df0b2af5..0f2b8143849 100644
--- a/gcc/ipa-devirt.c
+++ b/gcc/ipa-devirt.c
@@ -1521,6 +1521,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
 	break;
       }
     case VOID_TYPE:
+    case OPAQUE_TYPE:
     case NULLPTR_TYPE:
       break;
 
diff --git a/gcc/tree-streamer.c b/gcc/tree-streamer.c
index b0afa1dc6c0..a393983f76c 100644
--- a/gcc/tree-streamer.c
+++ b/gcc/tree-streamer.c
@@ -317,6 +317,7 @@ record_common_node (struct streamer_tree_cache_d *cache, tree node)
     case TREE_LIST:
     case VOID_CST:
     case VOID_TYPE:
+    case OPAQUE_TYPE:
       /* No recursive trees.  */
       break;
     case ARRAY_TYPE:
diff --git a/gcc/tree.c b/gcc/tree.c
index 569a9b9317b..aa6db8dae70 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -3944,6 +3944,7 @@ type_contains_placeholder_1 (const_tree type)
   switch (TREE_CODE (type))
     {
     case VOID_TYPE:
+    case OPAQUE_TYPE:
     case COMPLEX_TYPE:
     case ENUMERAL_TYPE:
     case BOOLEAN_TYPE:
@@ -7072,6 +7073,7 @@ type_cache_hasher::equal (type_hash *a, type_hash *b)
   switch (TREE_CODE (a->type))
     {
     case VOID_TYPE:
+    case OPAQUE_TYPE:
     case COMPLEX_TYPE:
     case POINTER_TYPE:
     case REFERENCE_TYPE:
diff --git a/gcc/typeclass.h b/gcc/typeclass.h
index 434e6acf6c9..b4e3dda21ec 100644
--- a/gcc/typeclass.h
+++ b/gcc/typeclass.h
@@ -37,7 +37,7 @@ enum type_class
   function_type_class, method_type_class,
   record_type_class, union_type_class,
   array_type_class, string_type_class,
-  lang_type_class
+  lang_type_class, opaque_type_class
 };
 
 #endif /* GCC_TYPECLASS_H */
-- 
2.27.0


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

end of thread, other threads:[~2020-11-23  9:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-20  1:04 [PATCH] Additional small changes to support opaque modes acsawdey
  -- strict thread matches above, loose matches on Subject: below --
2020-11-20  0:57 acsawdey
2020-11-20  9:55 ` Richard Sandiford
2020-11-20 10:57   ` Aaron Sawdey
2020-11-20 21:49     ` Aaron Sawdey
2020-11-23  9:19       ` Richard Sandiford

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).