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: [PATCH PING 1/5] Named address spaces: core middle-end support


I wrote:
> Richard Guenther wrote:
> > In tree_type you place the addr_space_t after the flags section.
> > As it is  of type char please add a comment that there are
> > 24 bits left on 32bit archs and 56 bits on 64bit archs (ugh).
> > Conveniently you may notice that tree_base has 32 spare bits
> > left (no, I'm not really suggesting to use them here ... well,
> > maybe - with a big disclaimer).  Ok, do it - make it a bitfield and
> > move it to tree_base with a disclaimer that it is only used for
> > types.
> 
> Huh, I guess I can do that, but it does seem a bit odd :-)
> 
> If this is purely a matter of data structure size, maybe a better
> way might be to reduce the size of the "align" member in tree_type?
> 
> Anyway, I'll try your suggestion in a follow-on patch.

Like so.  Was this what you'd been thinking of?

Bye,
Ulrich


ChangeLog:

	* tree.h (struct tree_type): Remove address_space field.
	(struct tree_base): Add address_space bitfield.  Reduce size of "spare".
	(TYPE_ADDR_SPACE): Update.

diff -x .pc -x patches -x .svn -urNp gcc-head/gcc/tree.h named-addr-spaces-branch/gcc/tree.h
--- gcc-head/gcc/tree.h	2009-09-17 15:07:23.000000000 +0200
+++ named-addr-spaces-branch/gcc/tree.h	2009-09-18 14:55:07.000000000 +0200
@@ -392,7 +392,12 @@ struct GTY(()) tree_base {
   unsigned packed_flag : 1;
   unsigned user_align : 1;
 
-  unsigned spare : 21;
+  unsigned spare : 13;
+
+  /* This field is only used with type nodes; the only reason it is present
+     in tree_base instead of tree_type is to save space.  The size of the
+     field must be large enough to hold addr_space_t values.  */
+  unsigned address_space : 8;
 
   union tree_ann_d *ann;
 };
@@ -2165,7 +2170,7 @@ extern enum machine_mode vector_type_mod
 #define TYPE_RESTRICT(NODE) (TYPE_CHECK (NODE)->type.restrict_flag)
 
 /* The address space the type is in.  */
-#define TYPE_ADDR_SPACE(NODE) (TYPE_CHECK (NODE)->type.address_space)
+#define TYPE_ADDR_SPACE(NODE) (TYPE_CHECK (NODE)->base.address_space)
 
 /* There is a TYPE_QUAL value for each type qualifier.  They can be
    combined by bitwise-or to form the complete set of qualifiers for a
@@ -2293,7 +2298,6 @@ struct GTY(()) tree_type {
   unsigned lang_flag_5 : 1;
   unsigned lang_flag_6 : 1;
 
-  addr_space_t address_space;
   unsigned int align;
   alias_set_type alias_set;
   tree pointer_to;


-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


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