insn_extract/constrain_operands caching version 2
Jan Hubicka
jh@suse.cz
Fri Sep 8 05:42:00 GMT 2000
OK now?
Honza
Mon Aug 28 01:16:16 CEST 2000 Jan Hubicka <jh@suse.cz>
* genrecog.c (write_tree): Output code to clear insn_extract cache.
* genattrtab.c (write_attr_case): Gen call to extract_insn_cache
instead of extract_insn and extract_constrain_insn_cache instead of
extract_insn and constrain_operands.
* recog.c (extract_insn_cached, extract_constrain_insn_cached):
New functions.
(extract_insn): Clear which_alternative.
(constrain_operands): Set which_alternative to -1 when failed.
* recog.h (extract_constrain_insn_cached, extract_insn_cached):
Declare.
*** /c/egcs/gcc/genrecog.c Tue Aug 29 14:02:34 2000
--- genrecog.c Mon Aug 16 09:35:36 2004
*************** peephole2%s (x0, insn, _pmatch_len)\n\
*** 2189,2194 ****
--- 2189,2197 ----
printf (" %s tem ATTRIBUTE_UNUSED;\n", IS_SPLIT (type) ? "rtx" : "int");
+ if (!subfunction)
+ printf (" recog_data.insn = NULL_RTX;\n");
+
if (head->first)
write_tree (head, "", type, 1);
else
*** /c/egcs/gcc/recog.c Wed Jan 1 00:10:22 1997
--- recog.c Mon Aug 16 11:05:42 2004
*************** adj_offsettable_operand (op, offset)
*** 1992,1997 ****
--- 1992,2022 ----
abort ();
}
+ /* Like extract_insn, but save insn extracted and don't extract again, when
+ called again for the same insn expecting that recog_data still contain the
+ valid information. This is used primary by gen_attr infrastructure that
+ often does extract insn again and again. */
+ void
+ extract_insn_cached (insn)
+ rtx insn;
+ {
+ if (recog_data.insn == insn && INSN_CODE (insn) >= 0)
+ return;
+ extract_insn (insn);
+ recog_data.insn = insn;
+ }
+ /* Do cached extract_insn, constrain_operand and complain about failures.
+ Used by insn_attrtab. */
+ void
+ extract_constrain_insn_cached (insn)
+ rtx insn;
+ {
+ extract_insn_cached (insn);
+ if (which_alternative == -1
+ && !constrain_operands (reload_completed))
+ fatal_insn_not_found (insn);
+ }
+
/* Analyze INSN and fill in recog_data. */
void
*************** extract_insn (insn)
*** 2003,2011 ****
--- 2028,2038 ----
int noperands;
rtx body = PATTERN (insn);
+ recog_data.insn = NULL;
recog_data.n_operands = 0;
recog_data.n_alternatives = 0;
recog_data.n_dups = 0;
+ which_alternative = -1;
switch (GET_CODE (body))
{
*************** constrain_operands (strict)
*** 2539,2544 ****
--- 2566,2572 ----
which_alternative++;
}
+ which_alternative = -1;
/* If we are about to reject this, but we are not to test strictly,
try a very loose test. Only return failure if it fails also. */
if (strict == 0)
*** /c/egcs/gcc/recog.h Sun Jul 30 20:41:43 2000
--- recog.h Mon Aug 16 09:30:39 2004
*************** extern int recog PARAMS ((rtx, rtx, in
*** 116,121 ****
--- 116,123 ----
extern void add_clobbers PARAMS ((rtx, int));
extern void insn_extract PARAMS ((rtx));
extern void extract_insn PARAMS ((rtx));
+ extern void extract_constrain_insn_cached PARAMS ((rtx));
+ extern void extract_insn_cached PARAMS ((rtx));
extern void preprocess_constraints PARAMS ((void));
extern rtx peep2_next_insn PARAMS ((int));
extern int peep2_regno_dead_p PARAMS ((int, int));
*************** struct recog_data
*** 186,191 ****
--- 188,196 ----
/* The number of alternatives in the constraints for the insn. */
char n_alternatives;
+
+ /* In case we are caching, hold insn data was generated for. */
+ rtx insn;
};
extern struct recog_data recog_data;
*** /c/egcs/gcc/genattrtab.c Tue Aug 29 14:02:33 2000
--- genattrtab.c Mon Aug 16 09:41:23 2004
*************** write_attr_case (attr, av, write_case_li
*** 5212,5229 ****
must_extract = must_constrain = address_used = 0;
walk_attr_value (av->value);
! if (must_extract)
{
write_indent (indent + 2);
! printf ("extract_insn (insn);\n");
}
!
! if (must_constrain)
{
write_indent (indent + 2);
! printf ("if (! constrain_operands (reload_completed))\n");
! write_indent (indent + 2);
! printf (" fatal_insn_not_found (insn);\n");
}
write_attr_set (attr, indent + 2, av->value, prefix, suffix,
--- 5265,5279 ----
must_extract = must_constrain = address_used = 0;
walk_attr_value (av->value);
! if (must_constrain)
{
write_indent (indent + 2);
! printf ("extract_constrain_insn_cached (insn);\n");
}
! else if (must_extract)
{
write_indent (indent + 2);
! printf ("extract_insn_cached (insn);\n");
}
write_attr_set (attr, indent + 2, av->value, prefix, suffix,
More information about the Gcc-patches
mailing list