Commit 9ffc5a70 by Jan Hubicka Committed by Jan Hubicka

regclass.c (reg_pref): New structure and static variable

	* regclass.c (reg_pref): New structure and static variable
	(prefclass): Delete.
	(altclass): Delete.
	(all uses of prefclass and altclass): Use reg_pref instead.

From-SVN: r30610
parent 28a22acb
Mon Nov 22 14:42:22 MET 1999 Jan Hubicka <hubicka@freesoft.cz>
* regclass.c (reg_pref): New structure and static variable
(prefclass): Delete.
(altclass): Delete.
(all uses of prefclass and altclass): Use reg_pref instead.
1999-11-21 Nick Clifton <nickc@cygnus.com> 1999-11-21 Nick Clifton <nickc@cygnus.com>
* invoke.texi (ARM Options): Replace -mshort-load-bytes with * invoke.texi (ARM Options): Replace -mshort-load-bytes with
......
...@@ -661,6 +661,22 @@ struct costs ...@@ -661,6 +661,22 @@ struct costs
int mem_cost; int mem_cost;
}; };
/* Structure used to record preferrences of given pseudo. */
struct reg_pref
{
/* (enum reg_class) prefclass is the preferred class. */
char prefclass;
/* altclass is a register class that we should use for allocating
pseudo if no register in the preferred class is available.
If no register in this class is available, memory is preferred.
It might appear to be more general to have a bitmask of classes here,
but since it is recommended that there be a class corresponding to the
union of most major pair of classes, that generality is not required. */
char altclass;
};
/* Record the cost of each class for each pseudo. */ /* Record the cost of each class for each pseudo. */
static struct costs *costs; static struct costs *costs;
...@@ -675,26 +691,14 @@ static struct costs init_cost; ...@@ -675,26 +691,14 @@ static struct costs init_cost;
static struct costs op_costs[MAX_RECOG_OPERANDS]; static struct costs op_costs[MAX_RECOG_OPERANDS];
/* (enum reg_class) prefclass[R] is the preferred class for pseudo number R. /* Record preferrences of each pseudo.
This is available after `regclass' is run. */ This is available after `regclass' is run. */
static char *prefclass; static struct reg_pref *reg_pref;
/* altclass[R] is a register class that we should use for allocating
pseudo number R if no register in the preferred class is available.
If no register in this class is available, memory is preferred.
It might appear to be more general to have a bitmask of classes here,
but since it is recommended that there be a class corresponding to the
union of most major pair of classes, that generality is not required.
This is available after `regclass' is run. */ /* Allocated buffers for reg_pref. */
static char *altclass;
/* Allocated buffers for prefclass and altclass. */ static struct reg_pref *reg_pref_buffer;
static char *prefclass_buffer;
static char *altclass_buffer;
/* Record the depth of loops that we are in. */ /* Record the depth of loops that we are in. */
...@@ -725,19 +729,19 @@ enum reg_class ...@@ -725,19 +729,19 @@ enum reg_class
reg_preferred_class (regno) reg_preferred_class (regno)
int regno; int regno;
{ {
if (prefclass == 0) if (reg_pref == 0)
return GENERAL_REGS; return GENERAL_REGS;
return (enum reg_class) prefclass[regno]; return (enum reg_class) reg_pref[regno].prefclass;
} }
enum reg_class enum reg_class
reg_alternate_class (regno) reg_alternate_class (regno)
int regno; int regno;
{ {
if (prefclass == 0) if (reg_pref == 0)
return ALL_REGS; return ALL_REGS;
return (enum reg_class) altclass[regno]; return (enum reg_class) reg_pref[regno].altclass;
} }
/* Initialize some global data for this pass. */ /* Initialize some global data for this pass. */
...@@ -753,7 +757,7 @@ regclass_init () ...@@ -753,7 +757,7 @@ regclass_init ()
/* This prevents dump_flow_info from losing if called /* This prevents dump_flow_info from losing if called
before regclass is run. */ before regclass is run. */
prefclass = 0; reg_pref = NULL;
} }
/* Dump register costs. */ /* Dump register costs. */
...@@ -1077,14 +1081,11 @@ regclass (f, nregs, dump) ...@@ -1077,14 +1081,11 @@ regclass (f, nregs, dump)
/* Now for each register look at how desirable each class is /* Now for each register look at how desirable each class is
and find which class is preferred. Store that in and find which class is preferred. Store that in
`prefclass[REGNO]'. Record in `altclass[REGNO]' the largest register `prefclass'. Record in `altclass' the largest register
class any of whose registers is better than memory. */ class any of whose registers is better than memory. */
if (pass == 0) if (pass == 0)
{ reg_pref = reg_pref_buffer;
prefclass = prefclass_buffer;
altclass = altclass_buffer;
}
for (i = FIRST_PSEUDO_REGISTER; i < nregs; i++) for (i = FIRST_PSEUDO_REGISTER; i < nregs; i++)
{ {
...@@ -1138,8 +1139,8 @@ regclass (f, nregs, dump) ...@@ -1138,8 +1139,8 @@ regclass (f, nregs, dump)
alt = NO_REGS; alt = NO_REGS;
/* We cast to (int) because (char) hits bugs in some compilers. */ /* We cast to (int) because (char) hits bugs in some compilers. */
prefclass[i] = (int) best; reg_pref[i].prefclass = (int) best;
altclass[i] = (int) alt; reg_pref[i].altclass = (int) alt;
} }
} }
...@@ -1304,9 +1305,9 @@ record_reg_classes (n_alts, n_ops, ops, modes, subreg_changes_size, ...@@ -1304,9 +1305,9 @@ record_reg_classes (n_alts, n_ops, ops, modes, subreg_changes_size,
to what we would add if this register were not in the to what we would add if this register were not in the
appropriate class. */ appropriate class. */
if (prefclass) if (reg_pref)
alt_cost alt_cost
+= (may_move_in_cost[(unsigned char) prefclass[REGNO (op)]] += (may_move_in_cost[(unsigned char) reg_pref[REGNO (op)].prefclass]
[(int) classes[i]]); [(int) classes[i]]);
if (REGNO (ops[i]) != REGNO (ops[j]) if (REGNO (ops[i]) != REGNO (ops[j])
...@@ -1525,9 +1526,9 @@ record_reg_classes (n_alts, n_ops, ops, modes, subreg_changes_size, ...@@ -1525,9 +1526,9 @@ record_reg_classes (n_alts, n_ops, ops, modes, subreg_changes_size,
to what we would add if this register were not in the to what we would add if this register were not in the
appropriate class. */ appropriate class. */
if (prefclass) if (reg_pref)
alt_cost alt_cost
+= (may_move_in_cost[(unsigned char) prefclass[REGNO (op)]] += (may_move_in_cost[(unsigned char) reg_pref[REGNO (op)].prefclass]
[(int) classes[i]]); [(int) classes[i]]);
} }
} }
...@@ -1599,10 +1600,10 @@ record_reg_classes (n_alts, n_ops, ops, modes, subreg_changes_size, ...@@ -1599,10 +1600,10 @@ record_reg_classes (n_alts, n_ops, ops, modes, subreg_changes_size,
int class; int class;
int nr; int nr;
if (regno >= FIRST_PSEUDO_REGISTER && prefclass != 0 if (regno >= FIRST_PSEUDO_REGISTER && reg_pref != 0
&& (reg_class_size[(unsigned char) prefclass[regno]] && (reg_class_size[(unsigned char) reg_pref[regno].prefclass]
== CLASS_MAX_NREGS (prefclass[regno], mode))) == CLASS_MAX_NREGS (reg_pref[regno].prefclass, mode)))
op_costs[i].cost[(unsigned char) prefclass[regno]] = -1; op_costs[i].cost[(unsigned char) reg_pref[regno].prefclass] = -1;
else if (regno < FIRST_PSEUDO_REGISTER) else if (regno < FIRST_PSEUDO_REGISTER)
for (class = 0; class < N_REG_CLASSES; class++) for (class = 0; class < N_REG_CLASSES; class++)
if (TEST_HARD_REG_BIT (reg_class_contents[class], regno) if (TEST_HARD_REG_BIT (reg_class_contents[class], regno)
...@@ -1923,8 +1924,8 @@ allocate_reg_info (num_regs, new_p, renumber_p) ...@@ -1923,8 +1924,8 @@ allocate_reg_info (num_regs, new_p, renumber_p)
{ {
VARRAY_REG_INIT (reg_n_info, regno_allocated, "reg_n_info"); VARRAY_REG_INIT (reg_n_info, regno_allocated, "reg_n_info");
renumber = (short *) xmalloc (size_renumber); renumber = (short *) xmalloc (size_renumber);
prefclass_buffer = (char *) xmalloc (regno_allocated); reg_pref_buffer = (struct reg_pref *) xmalloc (regno_allocated
altclass_buffer = (char *) xmalloc (regno_allocated); * sizeof (struct reg_pref));
} }
else else
...@@ -1934,21 +1935,18 @@ allocate_reg_info (num_regs, new_p, renumber_p) ...@@ -1934,21 +1935,18 @@ allocate_reg_info (num_regs, new_p, renumber_p)
if (new_p) /* if we're zapping everything, no need to realloc */ if (new_p) /* if we're zapping everything, no need to realloc */
{ {
free ((char *)renumber); free ((char *)renumber);
free ((char *)prefclass_buffer); free ((char *)reg_pref);
free ((char *)altclass_buffer);
renumber = (short *) xmalloc (size_renumber); renumber = (short *) xmalloc (size_renumber);
prefclass_buffer = (char *) xmalloc (regno_allocated); reg_pref_buffer = (struct reg_pref *) xmalloc (regno_allocated
altclass_buffer = (char *) xmalloc (regno_allocated); * sizeof (struct reg_pref));
} }
else else
{ {
renumber = (short *) xrealloc ((char *)renumber, size_renumber); renumber = (short *) xrealloc ((char *)renumber, size_renumber);
prefclass_buffer = (char *) xrealloc ((char *)prefclass_buffer, reg_pref_buffer = (struct reg_pref *) xrealloc ((char *)reg_pref_buffer,
regno_allocated); regno_allocated
* sizeof (struct reg_pref));
altclass_buffer = (char *) xrealloc ((char *)altclass_buffer,
regno_allocated);
} }
} }
...@@ -1991,8 +1989,8 @@ allocate_reg_info (num_regs, new_p, renumber_p) ...@@ -1991,8 +1989,8 @@ allocate_reg_info (num_regs, new_p, renumber_p)
VARRAY_REG (reg_n_info, i) = &reg_data->data[i-min_index]; VARRAY_REG (reg_n_info, i) = &reg_data->data[i-min_index];
REG_BASIC_BLOCK (i) = REG_BLOCK_UNKNOWN; REG_BASIC_BLOCK (i) = REG_BLOCK_UNKNOWN;
renumber[i] = -1; renumber[i] = -1;
prefclass_buffer[i] = (char) NO_REGS; reg_pref_buffer[i].prefclass = (char) NO_REGS;
altclass_buffer[i] = (char) NO_REGS; reg_pref_buffer[i].altclass = (char) NO_REGS;
} }
} }
} }
...@@ -2000,11 +1998,8 @@ allocate_reg_info (num_regs, new_p, renumber_p) ...@@ -2000,11 +1998,8 @@ allocate_reg_info (num_regs, new_p, renumber_p)
/* If {pref,alt}class have already been allocated, update the pointers to /* If {pref,alt}class have already been allocated, update the pointers to
the newly realloced ones. */ the newly realloced ones. */
if (prefclass) if (reg_pref)
{ reg_pref = reg_pref_buffer;
prefclass = prefclass_buffer;
altclass = altclass_buffer;
}
if (renumber_p) if (renumber_p)
reg_renumber = renumber; reg_renumber = renumber;
...@@ -2029,10 +2024,8 @@ free_reg_info () ...@@ -2029,10 +2024,8 @@ free_reg_info ()
free ((char *)reg_data); free ((char *)reg_data);
} }
free (prefclass_buffer); free (reg_pref_buffer);
free (altclass_buffer); reg_pref_buffer = (struct reg_pref *)0;
prefclass_buffer = (char *)0;
altclass_buffer = (char *)0;
reg_info_head = (struct reg_info_data *)0; reg_info_head = (struct reg_info_data *)0;
renumber = (short *)0; renumber = (short *)0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment