public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* proposal to make SIZE_TYPE more flexible
@ 2013-10-30  4:28 DJ Delorie
  2013-10-30 15:53 ` Joseph S. Myers
  0 siblings, 1 reply; 47+ messages in thread
From: DJ Delorie @ 2013-10-30  4:28 UTC (permalink / raw)
  To: gcc


There are a couple of places in gcc where wierd-sized pointers are an
issue.  While you can use a partial-integer mode for pointers, the
pointer *math* is still done in standard C types, which usually don't
match the modes of pointers and often result in suboptimal code.

My proposal is to allow the target to define its own type for
pointers, sizeof_t, and ptrdiff_t to use, so that gcc can adapt to
weird pointer sizes instead of the target having to use power-of-two
pointer math.

This means the target would somehow have to register its new types
(int20_t and uint20_t in the MSP430 case, for example), as well as
specify that type to the rest of gcc.  There are some problems with
the naive approach, though, and the changes are somewhat pervasive.

So my question is, would this approach be acceptable?  Most of the
cases where new code would be added, have gcc_unreachable() at the
moment anyway.

Specific issues follow...

SIZE_TYPE is used...

	tree.c: build_common_tree_nodes()
		compares against fixed strings; if no match it
		gcc_unreachable()'s - instead, look up type in
		language core.

	c-family/c-common.c
		just makes a string macro, it's up to the target to
		provide a legitimate value for it.

	lto/lto-lang.c
		compares against fixed strings to define THREE related
		types, including intmax_type_node and
		uintmax_type_node.  IMHO it should not be using
		pointer sizes to determine integer sizes.

PTRDIFF_TYPE is used...

	c-family/c-common.c
	fortran/iso-c-binding.def
	fortran/trans-types.c

		These all use lookups; however fortran's
		get_typenode_from_name only supports "standard" type
		names.

POINTER_SIZE is used...

	I have found in the past that gcc has issues if POINTER_SIZE
	is not a power of two.  IIRC BLKmode was used to copy pointer
	values.  Other examples:

  assemble_align (POINTER_SIZE);

	can't align to non-power-of-two bits

   assemble_integer (XEXP (DECL_RTL (src), 0),
	             POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1);

	need to round up, not truncate

^ permalink raw reply	[flat|nested] 47+ messages in thread

end of thread, other threads:[~2014-01-28 21:58 UTC | newest]

Thread overview: 47+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-30  4:28 proposal to make SIZE_TYPE more flexible DJ Delorie
2013-10-30 15:53 ` Joseph S. Myers
2013-10-30 19:18   ` DJ Delorie
2013-10-30 20:49     ` Joseph S. Myers
2013-10-30 22:19       ` DJ Delorie
2013-10-30 22:51         ` Joseph S. Myers
2013-11-14  1:58           ` DJ Delorie
2013-11-14 13:26             ` Joseph S. Myers
2013-11-14 18:12               ` DJ Delorie
2013-11-14 18:37                 ` Joseph S. Myers
2013-11-14 18:48                   ` DJ Delorie
2013-11-14 21:40                     ` Joseph S. Myers
2013-11-15  1:47                       ` DJ Delorie
2013-11-15  1:56                         ` Joseph S. Myers
2013-11-15 23:38               ` DJ Delorie
2013-11-16 11:23                 ` Richard Biener
2013-11-16 12:26                   ` Joseph S. Myers
2013-11-21 22:41                     ` DJ Delorie
2013-11-21 22:59                       ` Joseph S. Myers
2013-11-22  8:29                         ` DJ Delorie
2013-11-22 12:43                           ` Joseph S. Myers
2013-11-22 19:33                             ` DJ Delorie
2013-11-22 21:00                               ` Joseph S. Myers
2013-11-22 21:19                                 ` DJ Delorie
2013-11-23  0:41                                   ` Joseph S. Myers
2013-12-10  3:35                                     ` DJ Delorie
2013-12-10 17:17                                       ` Joseph S. Myers
2013-12-10 18:10                                         ` DJ Delorie
2013-12-10 18:38                                           ` Joseph S. Myers
2013-12-10 18:42                                             ` DJ Delorie
2013-12-11  9:27                                               ` Richard Biener
2013-12-20  4:58                                         ` DJ Delorie
2013-12-20 12:42                                           ` Joseph S. Myers
2013-12-20 19:47                                         ` DJ Delorie
2013-12-20 21:53                                           ` Joseph S. Myers
2013-12-20 21:59                                             ` DJ Delorie
2013-12-20 22:15                                               ` Joseph S. Myers
2013-12-20 22:40                                                 ` DJ Delorie
2013-12-21  1:01                                                   ` Joseph S. Myers
2014-01-09  2:31                                                     ` DJ Delorie
2014-01-09  3:23                                                       ` Joseph S. Myers
2014-01-09  7:02                                                         ` DJ Delorie
2014-01-09 16:22                                                           ` Joseph S. Myers
2014-01-15 12:48                                                             ` DJ Delorie
2014-01-28 21:52                                                               ` DJ Delorie
2014-01-28 21:58                                                                 ` Joseph S. Myers
2014-01-28 22:24                                                                   ` DJ Delorie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).