This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Store type in fieldoff_s, not FIELD_DECL
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 25 Jul 2005 15:39:46 +0200 (CEST)
- Subject: [PATCH] Store type in fieldoff_s, not FIELD_DECL
This enables us to sft fields without a FIELD_DECL in future
(aka array elements). Two parts, actually, to be applied on
top of each other.
Bootstrapped and tested on x86_64-unknown-linux-gnu.
Ok for mainline?
Richard.
2005-07-25 Richard Guenther <rguenther@suse.de>
* tree-ssa-alias.c (create_sft): Take type as second
argument, not FIELD_DECL.
Index: tree-ssa-alias.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-alias.c,v
retrieving revision 2.107
diff -c -3 -p -r2.107 tree-ssa-alias.c
*** tree-ssa-alias.c 25 Jul 2005 12:04:50 -0000 2.107
--- tree-ssa-alias.c 25 Jul 2005 13:09:08 -0000
*************** get_or_create_used_part_for (size_t uid)
*** 2512,2525 ****
}
! /* Create and return a structure sub-variable for field FIELD of
variable VAR. */
static tree
! create_sft (tree var, tree field)
{
var_ann_t ann;
! tree subvar = create_tmp_var_raw (TREE_TYPE (field), "SFT");
/* We need to copy the various flags from VAR to SUBVAR, so that
they are is_global_var iff the original variable was. */
--- 2512,2525 ----
}
! /* Create and return a structure sub-variable for field type TYPE of
variable VAR. */
static tree
! create_sft (tree var, tree type)
{
var_ann_t ann;
! tree subvar = create_tmp_var_raw (type, "SFT");
/* We need to copy the various flags from VAR to SUBVAR, so that
they are is_global_var iff the original variable was. */
*************** create_overlap_variables_for (tree var)
*** 2648,2654 ****
sv->offset = fo->offset;
sv->size = fosize;
sv->next = *subvars;
! sv->var = create_sft (var, fo->field);
if (dump_file)
{
--- 2648,2654 ----
sv->offset = fo->offset;
sv->size = fosize;
sv->next = *subvars;
! sv->var = create_sft (var, TREE_TYPE (fo->field));
if (dump_file)
{
2005-07-25 Richard Guenther <rguenther@suse.de>
* tree-flow.h (struct fieldoff): Store field type, not field.
* tree-ssa-structalias.c: Adjust users.
* tree-ssa-alias.c: Likewise.
Index: tree-flow.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-flow.h,v
retrieving revision 2.130
diff -c -3 -p -r2.130 tree-flow.h
*** tree-flow.h 25 Jul 2005 12:04:49 -0000 2.130
--- tree-flow.h 25 Jul 2005 13:20:03 -0000
*************** tree maybe_fold_tmr (tree);
*** 874,881 ****
struct fieldoff
{
! tree field;
! HOST_WIDE_INT offset;
};
typedef struct fieldoff fieldoff_s;
--- 874,881 ----
struct fieldoff
{
! tree type;
! HOST_WIDE_INT offset;
};
typedef struct fieldoff fieldoff_s;
*** tree-ssa-alias.c.orig 2005-07-25 15:11:12.414738002 +0200
--- tree-ssa-alias.c 2005-07-25 15:18:28.028911514 +0200
*************** create_overlap_variables_for (tree var)
*** 2576,2584 ****
for (i = 0; VEC_iterate (fieldoff_s, fieldstack, i, fo); i++)
{
! if (!DECL_SIZE (fo->field)
! || TREE_CODE (DECL_SIZE (fo->field)) != INTEGER_CST
! || TREE_CODE (TREE_TYPE (fo->field)) == ARRAY_TYPE
|| fo->offset < 0)
{
notokay = true;
--- 2576,2584 ----
for (i = 0; VEC_iterate (fieldoff_s, fieldstack, i, fo); i++)
{
! if (!TYPE_SIZE (fo->type)
! || TREE_CODE (TYPE_SIZE (fo->type)) != INTEGER_CST
! || TREE_CODE (fo->type) == ARRAY_TYPE
|| fo->offset < 0)
{
notokay = true;
*************** create_overlap_variables_for (tree var)
*** 2630,2637 ****
HOST_WIDE_INT fosize;
tree currfotype;
! fosize = TREE_INT_CST_LOW (DECL_SIZE (fo->field));
! currfotype = TREE_TYPE (fo->field);
/* If this field isn't in the used portion,
or it has the exact same offset and size as the last
--- 2630,2637 ----
HOST_WIDE_INT fosize;
tree currfotype;
! fosize = TREE_INT_CST_LOW (TYPE_SIZE (fo->type));
! currfotype = fo->type;
/* If this field isn't in the used portion,
or it has the exact same offset and size as the last
*************** create_overlap_variables_for (tree var)
*** 2648,2654 ****
sv->offset = fo->offset;
sv->size = fosize;
sv->next = *subvars;
! sv->var = create_sft (var, TREE_TYPE (fo->field));
if (dump_file)
{
--- 2648,2654 ----
sv->offset = fo->offset;
sv->size = fosize;
sv->next = *subvars;
! sv->var = create_sft (var, fo->type);
if (dump_file)
{
Index: tree-ssa-structalias.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-structalias.c,v
retrieving revision 2.23
diff -c -3 -p -r2.23 tree-ssa-structalias.c
*** tree-ssa-structalias.c 22 Jul 2005 13:39:02 -0000 2.23
--- tree-ssa-structalias.c 25 Jul 2005 13:30:34 -0000
*************** fieldoff_compare (const void *pa, const
*** 2939,2946 ****
if (foa->offset != fob->offset)
return foa->offset - fob->offset;
! foasize = TREE_INT_CST_LOW (DECL_SIZE (foa->field));
! fobsize = TREE_INT_CST_LOW (DECL_SIZE (fob->field));
return foasize - fobsize;
}
--- 2939,2946 ----
if (foa->offset != fob->offset)
return foa->offset - fob->offset;
! foasize = TREE_INT_CST_LOW (TYPE_SIZE (foa->type));
! fobsize = TREE_INT_CST_LOW (TYPE_SIZE (fob->type));
return foasize - fobsize;
}
*************** push_fields_onto_fieldstack (tree type,
*** 2995,3001 ****
fieldoff_s *pair;
pair = VEC_safe_push (fieldoff_s, heap, *fieldstack, NULL);
! pair->field = field;
pair->offset = offset + bitpos_of_field (field);
count++;
}
--- 2995,3001 ----
fieldoff_s *pair;
pair = VEC_safe_push (fieldoff_s, heap, *fieldstack, NULL);
! pair->type = TREE_TYPE (field);
pair->offset = offset + bitpos_of_field (field);
count++;
}
*************** create_variable_info_for (tree decl, con
*** 3089,3097 ****
for (i = 0; !notokay && VEC_iterate (fieldoff_s, fieldstack, i, fo); i++)
{
! if (!DECL_SIZE (fo->field)
! || TREE_CODE (DECL_SIZE (fo->field)) != INTEGER_CST
! || TREE_CODE (TREE_TYPE (fo->field)) == ARRAY_TYPE
|| fo->offset < 0)
{
notokay = true;
--- 3089,3097 ----
for (i = 0; !notokay && VEC_iterate (fieldoff_s, fieldstack, i, fo); i++)
{
! if (!TYPE_SIZE (fo->type)
! || TREE_CODE (TYPE_SIZE (fo->type)) != INTEGER_CST
! || TREE_CODE (fo->type) == ARRAY_TYPE
|| fo->offset < 0)
{
notokay = true;
*************** create_variable_info_for (tree decl, con
*** 3118,3125 ****
return index;
}
! field = fo->field;
! vi->size = TREE_INT_CST_LOW (DECL_SIZE (field));
vi->offset = fo->offset;
for (i = 1; VEC_iterate (fieldoff_s, fieldstack, i, fo); i++)
{
--- 3118,3125 ----
return index;
}
! field = fo->type;
! vi->size = TREE_INT_CST_LOW (TYPE_SIZE (field));
vi->offset = fo->offset;
for (i = 1; VEC_iterate (fieldoff_s, fieldstack, i, fo); i++)
{
*************** create_variable_info_for (tree decl, con
*** 3127,3140 ****
const char *newname;
char *tempname;
! field = fo->field;
newindex = VEC_length (varinfo_t, varmap);
asprintf (&tempname, "%s.%s", vi->name, alias_get_name (field));
newname = ggc_strdup (tempname);
free (tempname);
newvi = new_var_info (decl, newindex, newname, newindex);
newvi->offset = fo->offset;
! newvi->size = TREE_INT_CST_LOW (DECL_SIZE (field));
newvi->fullsize = vi->fullsize;
insert_into_field_list (vi, newvi);
VEC_safe_push (varinfo_t, heap, varmap, newvi);
--- 3127,3140 ----
const char *newname;
char *tempname;
! field = fo->type;
newindex = VEC_length (varinfo_t, varmap);
asprintf (&tempname, "%s.%s", vi->name, alias_get_name (field));
newname = ggc_strdup (tempname);
free (tempname);
newvi = new_var_info (decl, newindex, newname, newindex);
newvi->offset = fo->offset;
! newvi->size = TREE_INT_CST_LOW (TYPE_SIZE (field));
newvi->fullsize = vi->fullsize;
insert_into_field_list (vi, newvi);
VEC_safe_push (varinfo_t, heap, varmap, newvi);