Desire to allocate bit in DT_PARM bitmask for DEC FORMAT compatibility purposes
Jeff Law
law@redhat.com
Thu Mar 22 05:49:00 GMT 2018
On 03/21/2018 12:38 PM, Janne Blomqvist wrote:
> One thing which struck me was that you (or
> whoever implemented it???) has reinvented setting the various default
> widths, code which already exists in libgfortran in order to support
> list directed output and zero width formats (zero width formats being,
> roughly, the standardized version of the DEC Format extension).
So I've been wandering around the runtime trying to find this code. The
most obvious analogous code is the list directed output support. But
sadly the constants are different.
Maybe there's some aspect of the implementation which corrects them
later, but I don't see it. Let's take a look at kind/length of 4. In
set_fnode_default we have:
case 4:
f->u.real.w = 16;
f->u.real.d = 9;
f->u.real.e = 2;
break;
But in the tables I referenced and in the new code we want 15, 7, 2
respectively.
There's differences for the other kind/lengths as well.
For integer types, we have write_integer which has
case 4:
width = 11;
break;
But in the tables I referenced we'd get a width of 12. THere's other
differences in the integer type handling as well.
So I don't offhand see that we can share that code -- unless there's
some formulaic adjustment we could make to the return values.
I didn't find the relevant code for zero width formats. If we look at
parse_format_list:
case FMT_I:
case FMT_B:
case FMT_O:
case FMT_Z:
*seen_dd = true;
get_fnode (fmt, &head, &tail, t);
tail->repeat = repeat;
t = format_lex (fmt);
if (dtp->u.p.mode == READING)
{
if (t != FMT_POSINT)
{
fmt->error = posint_required;
goto finished;
}
}
else
{
if (t != FMT_ZERO && t != FMT_POSINT)
{
fmt->error = nonneg_required;
goto finished;
}
}
It appears to me that we require a FMT_POSINT when reading. FMT_ZERO
would result in setting fmt->error to posint_required AFAICT. If we
were writing, I can see how we don't get an error, but the w field still
gets set to zero via fmt->value. I don't immediately see where we
set/use a default though.
Maybe it works for other formats. But my my relatively brief looksie I
don't see how we can really piggyback on the FMT_ZERO support.
Anyway, I'll open a discussion with Fritz to see if we can move this
forward on way or another. If he's OK with reserving the bit in DT_PARM
for default width support is that enough for you at this stage? Again,
I'm not pushing for the code into gcc-8 (seems way too late), but just
the bit allocated for this purpose since it effectively is part of the ABI.
Jeff
ps. The bulk of the code was from Jim MacArthur @ Codethink I just
reworked it to use a bit in DT_PARM in a manner similar to what Fritz
Reese had done for defaulted exponents.
More information about the Fortran
mailing list