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: [csl-hpux-branch]: Use targetm structure for manglings


Nathan Sidwell <nathan@codesourcery.com> writes:

> Zack Weinberg wrote:
>> Nathan Sidwell <nathan@codesourcery.com> writes:
>
>>>Unfortunately there is a twisty interdependency on initializing the
>>>mangler. Part needs to be done early and parts late.
>
>> I don't see why.  The table's initializer is entirely static data,
>> isn't it?
> it has pointers to the global type node array, and relies on those
> being initialized so it can get the TYPE_UID as a hash key.
>
> Unfortunately part of the initialization sequence requires the
> mangler's string buffer to be initialized before that point.

I see.  It occurs to me that we might be able to guarantee that
TYPE_UID for a type in the global type node array is equal to the
type's index in that array, and then use the index enumerators
instead of pointers to *_type_node as the hash keys.

But this would require rearranging quite a bit of tree.h and other
places, so it can wait.

A few style nits:

> +   my_friendly_assert (!builtin_type_manglings, 20031212);

I don't think my_friendly_assert is supposed to be used in new code.
Jason?

> !  again:;

Unnecessary semicolon.

> !       if (type != t)
>   	{
> ! 	  type = t;
> ! 	  goto again;
>   	}
>         else
> ! 	{
> ! 	  sorry ("cannot mangle %T", type);
> ! 	  abort ();
> ! 	}
> !     }
> !   else
> !     {
> !       sorry ("cannot mangle %T", type);
>         abort ();
>       }
> +   

Control flow here is kind of weird.  May I suggest something like

  /* First look up a mangling for this specific type.  */
  mangling = htab_find_with_hash (builtin_type_manglings,
 				  type, (hashval_t)TYPE_UID (type));
  if (mangling)
    {
      write_char (mangling->mangling);
      return;
    }

  /* If we didn't find one, check for a generic mangling for a type of
     this mode.  */
  if (TREE_CODE (type) == INTEGER_TYPE)
    {
      tree t = c_common_type_for_mode (TYPE_MODE (type),
 				       TREE_UNSIGNED (type));
      if (type != t)
  	{
          mangling = htab_find_with_hash (builtin_type_manglings,
                                          t, (hashval_t)TYPE_UID (t));
          if (mangling)
            {
              write_char (mangling->mangling);
              return;
            }
        }
    }

  internal_error ("no mangling implemented for %T", type);

I think duplicating the hash table lookup and write_char call is
preferable to having this confusing thing that looks like it might
loop more than once.  The compiler ought to be bright enough to unify
the write_char calls, at least.

> + @deftypevr {Target Hook} {struct cxx_builtin_type_mangling} TARGET_ABI_CXX_BUILTIN_TYPE_MANGLING
> + Set this hook to augment or override the default mangling of the builtin
> + void, boolean, integral and floating point types.  When set the value
> + should be the name of an array of tuples.  The first is the address of
> + the cannonical type node and the second value is how to mangle it.  The

Typo: "canonical".

zw


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