||Standardize DW_AT_GNU_numerator and DW_AT_GNU_denominator
Currently, we can describe scale factors that are a (positive or
negative) power of 2 with DW_AT_binary_scale, and scale factors that
are a (positive or negative) power of 10 with DW_AT_decimal_scale.
Both of these attributes provide an integer constant directly in the
attribute, giving the logarithm of the scale factor.
For other scale factors, we have DW_AT_small, which takes a reference
class value that points to a DW_TAG_constant DIE, which allows that
constant to provide an arbitrary scale factor as either a
floating-point or integer constant. In order to provide a rational
number as the scale factor, GCC currently implements an extension,
which adds DW_AT_numerator and DW_AT_denominator attributes
to the constant DIE.
It seems to me that this is unnecessarily complex and wasteful of
space. The only reason to put the constant in a separate DIE was
inability to represent a floating-point number directly in an
attribute, using a form code. A rational number has no such problem,
and I think it would be better to provide two additional scale
attributes that can be added directly to the type in question.
Add the following to Section 126.96.36.199 (Scaled Encodings)
on page 106.
For a data type with a rational scale factor, one or both of the
following attributes may be used:
- DW_AT_scale_multiplier. This attribute is an integer constant value
that represents a multiplicative scale factor to be applied to an
instance of the type.
- DW_AT_scale_divisor. This attribute is an integer constant value
that represents the reciprocal of a multiplicative scale factor to be
applied to an instance of the type.
If both attributes are present, both are applied, with the result
being equivalent to a rational scale factor x/y, where x is the
DW_AT_scale_multiplier, and y is the DW_AT_scale_divisor.
On line 14, where it says "For a data type with a non-decimal and
non-binary scale factor...", I suggest changing it to "For a data type
with a non-rational scale factor...".