On Mon, Feb 27, 2023 at 06:26:04PM -0500, Jason Merrill wrote:
> > The following patch instead adds a target hook which allows the backend
> > to temporarily tweak registered types such that emit_support_tinfos
> > emits whatever is needed.
> 
> Why handle these types differently from the DFP handling at the end of
> emit_support_tinfos?

One thing is that the fallback_* nodes look like a waste to me,
the tinfo decls are mangled right away, and the fallback_* nodes need to be
walked by GC, so I think we could get away even for the decimal tinfos
to just do:
      dfloat32_type_node = make_node (REAL_TYPE);
      emit_support_tinfo_1 (dfloat32_type_node);
      dfloat32_type_node = NULL_TREE;
etc. and drop the fallback stuff.
If we wanted to do fallback_* even for the _Float*/decltype(0.0bf16)
nodes, which are at least sometimes mangled in target hooks it would
make stuff harder because fallback_* is C++ FE private.

And then there is a question whether we want to emit rtti for
_Float{16,32,64,128}, _Float{32,64,128}x and decltype(0.0bf16) regardless
of whether the target supports them at all or not.
Emitting them always would have an advantage, if say bfloat16_t support
isn't added for aarch64 for GCC 13 (it is still pending review), we wouldn't
need to deal with symbol versioning for it in GCC 14 or later.
On the other side, on some arches some types are very unlikely to be
supported.  And e.g. _Float128x isn't supported on any arch right now.

Though, if we can get rid of the fallback_* stuff and we wanted to emit
all _Float{16,32,64,128}, _Float{32,64,128}x and decltype(0.0bf16) tinfos
on all arches (or say for now all but _Float128x), we could do it simply
by splitting the fundamentals array in emit_support_tinfos into
one without fallback and one with fallback, put say
    &dfloat32_type_node, &dfloat64_type_node, &dfloat128_type_node,
    &bfloat16_type_node, &float16_type_node, &float32_type_node,
    &float64_type_node, &float128_type_node, &float32x_type_node,
    &float64x_type_node, &float128x_type_node, 0
into the latter and simply handle the NULL case with a temporary fallback,
like:
  tree fallback = NULL_TREE;
  for (ix = 0; fundamentals_with_fallback[ix]; ix++)
    if (*fundamentals_with_fallback[ix])
      emit_support_tinfo_1 (*fundamentals_with_fallback[ix]);
    else
      {
        if (fallback == NULL_TREE)
          fallback = make_node (REAL_TYPE);
        *fundamentals_with_fallback[ix] = fallback;
        emit_support_tinfo_1 (fallback);
        *fundamentals_with_fallback[ix] = NULL_TREE;
      }

        Jakub

Reply via email to