This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: Implement C _FloatN, _FloatNx types
- From: Michael Meissner <meissner at linux dot vnet dot ibm dot com>
- To: Joseph Myers <joseph at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org, jason at redhat dot com, richard dot earnshaw at arm dot com, nickc at redhat dot com, ramana dot radhakrishnan at arm dot com, marcus dot shawcroft at arm dot com, dje dot gcc at gmail dot com, segher at kernel dot crashing dot org, meissner at linux dot vnet dot ibm dot com, murphyp at linux dot vnet dot ibm dot com, bje at gnu dot org
- Date: Thu, 4 Aug 2016 20:09:34 -0400
- Subject: Re: Implement C _FloatN, _FloatNx types
- Authentication-results: sourceware.org; auth=none
- References: <alpine.DEB.2.20.1606211202040.4526@digraph.polyomino.org.uk>
In gcc/c-family/c-prettyprint.c in the function that you modified
pp_c_floating_constant:
It brings up a general complaint that I had when I started the whole PowerPC
__float128 adventure is that we have multiple places in the compiler it goes
through a list of floating point types, and only for the blessed types does it
do something. If a port happens to have a non-standard type, there really
should be target hooks for doing each of the actions.
But rather than having lots of different hooks, it may be better to have a hash
lookup given a type node (and/or mode) that registers all of the handling in a
central place, rather than continually having:
if (TREE_TYPE (r) == float_type_node)
pp_character (pp, 'f');
else if (TREE_TYPE (r) == long_double_type_node)
pp_character (pp, 'l');
else if (TREE_TYPE (r) == dfloat128_type_node)
pp_string (pp, "dl");
else if (TREE_TYPE (r) == dfloat64_type_node)
pp_string (pp, "dd");
else if (TREE_TYPE (r) == dfloat32_type_node)
pp_string (pp, "df");
Obviously, there are lots of places in the compiler that do this. But it has
been my experience, that usually when you have an enumeration like this, either
you miss one in the cut+paste of the same type of code, or when you add a new
type, you have to go through all of the places and update things (and usually
miss one, or get held up trying to get N maintainers to agree with the
patches).
And it may be that like I did, you might decide not to fix the general solution
in order to get what you want in the compiler.
--
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meissner@linux.vnet.ibm.com, phone: +1 (978) 899-4797