This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Implement C _FloatN, _FloatNx types


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]