Hi Mike,

On Fri, Jun 01, 2018 at 07:28:40PM -0400, Michael Meissner wrote:
> This patch also makes __ibm128 or __float128 use the long double mode if long
> double uses the IBM extended double or IEEE 128-bit representations.

Does that need to be the same patch?  Please split such things out when
you can.

> This
> allows templates to work again with those types (the template code aborts if
> you have two distinct types use the same mangling).  However, overloaded types
> won't work, but I suspect these days people use templates over overloaded
> functions.  I fixed up the test case for this (pr85657.C) so that it only 
> tests
> for templates.

If tests fail, do not delete the test.  If we have a problem, we have
a problem, and it needs to be fixed (not necessarily today of course,
and there is xfail for long-standing problems).


> +/* Generate old manged name, not new name.  */
> +static bool old_mangling;

As Andreas said, this is not a good name.  Please at least mention for
what type this old mangling is.

> @@ -16355,14 +16394,21 @@ rs6000_init_builtins (void)
>       __ieee128.  */
>    if (TARGET_FLOAT128_TYPE)
>      {
> -      ibm128_float_type_node = make_node (REAL_TYPE);
> -      TYPE_PRECISION (ibm128_float_type_node) = 128;
> -      SET_TYPE_MODE (ibm128_float_type_node, IFmode);
> -      layout_type (ibm128_float_type_node);
> +      if (TARGET_IEEEQUAD || !TARGET_LONG_DOUBLE_128)
> +     {
> +       ibm128_float_type_node = make_node (REAL_TYPE);
> +       TYPE_PRECISION (ibm128_float_type_node) = 128;
> +       SET_TYPE_MODE (ibm128_float_type_node, IFmode);
> +       layout_type (ibm128_float_type_node);
> +     }
> +      else
> +     ibm128_float_type_node = long_double_type_node;

I wonder how hard it would be to alias the long double type to either
__ibm128 or __ieee128, instead of the other way around?  This would
simplify code a lot.  Esp. if we can do the same thing for the modes,
too.

> @@ -32117,7 +32163,7 @@ rs6000_mangle_type (const_tree type)
>    if (SCALAR_FLOAT_TYPE_P (type) && FLOAT128_IBM_P (TYPE_MODE (type)))
>      return "g";
>    if (SCALAR_FLOAT_TYPE_P (type) && FLOAT128_IEEE_P (TYPE_MODE (type)))
> -    return "u9__ieee128";
> +    return old_mangling ? "U10__float128" : "u9__ieee128";

> +#if TARGET_ELF && RS6000_WEAK
> +static void
> +rs6000_globalize_decl_name (FILE * stream, tree decl)
> +{
> +  const char *name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
> +
> +  targetm.asm_out.globalize_label (stream, name);
> +
> +  if (TARGET_OLD_NAME_MANGLING && rs6000_passes_ieee128
> +      && name[0] == '_' && name[1] == 'Z')
> +    {
> +      tree save_asm_name = DECL_ASSEMBLER_NAME (decl);
> +      const char *old_name;
> +
> +      old_mangling = true;
> +      lang_hooks.set_decl_assembler_name (decl);
> +      old_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
> +      SET_DECL_ASSEMBLER_NAME (decl, save_asm_name);
> +      old_mangling = false;

Eww.  Can't we just create old_name directly?  Maybe there already is
some nice helper for this?

> +;; -malias-old-name-mangling: implement an alias to map old C++ mangled names
> +;; to the new version of the name
> +malias-old-name-mangling
> +Target Undocumented Var(TARGET_OLD_NAME_MANGLING) Init(-1) Save

As said, better name please.  Or, just drop the option (always enable it).


Segher

Reply via email to