Commit 23280139 by Richard Henderson Committed by Richard Henderson

Makefile.in (recog.o): Don't depend on resource.h.

	* Makefile.in (recog.o): Don't depend on resource.h.
	* recog.c: Don't include resource.h.
	(recog_last_allowed_insn): Remove.
	(recog_next_insn): Remove.
	(struct peep2_insn_data): New.
	(peep2_insn_data, peep2_current): New.
	(peep2_next_insn): New.
	(peep2_regno_dead_p, peep2_reg_dead_p): New.
	(peep2_find_free_register): New.
	(peephole2_optimize): Track life information by insn as we go.
	* recog.h: Update declarations.
	* resource.c (find_free_register, reg_dead_p): Remove.
	* resource.h: Remove their declarations.
	* toplev.c: Include hard-reg-set.h before recog.h.

	* genconfig.c (max_insns_per_peep2): New.
	(gen_peephole2): New.
	(main): Call it.
	* genemit.c (output_peephole2_scratches): Generate calls to
	peep2_find_free_register; adjust surrounding code.
	(main): Have insn-emit.c include hard-reg-set.h before recog.h.
	* genrecog.c (change_state): Don't track last_insn.
	(write_action): Write into *_pmatch_len before accepting.
	(write_tree): Adjust peephole2_insns and subroutines to match.

	* config/i386/i386.md (all peepholes): Use peep2_regno_dead_p.

From-SVN: r34208
parent 30196c1f
2000-05-27 Richard Henderson <rth@cygnus.com> 2000-05-27 Richard Henderson <rth@cygnus.com>
* Makefile.in (recog.o): Don't depend on resource.h.
* recog.c: Don't include resource.h.
(recog_last_allowed_insn): Remove.
(recog_next_insn): Remove.
(struct peep2_insn_data): New.
(peep2_insn_data, peep2_current): New.
(peep2_next_insn): New.
(peep2_regno_dead_p, peep2_reg_dead_p): New.
(peep2_find_free_register): New.
(peephole2_optimize): Track life information by insn as we go.
* recog.h: Update declarations.
* resource.c (find_free_register, reg_dead_p): Remove.
* resource.h: Remove their declarations.
* toplev.c: Include hard-reg-set.h before recog.h.
* genconfig.c (max_insns_per_peep2): New.
(gen_peephole2): New.
(main): Call it.
* genemit.c (output_peephole2_scratches): Generate calls to
peep2_find_free_register; adjust surrounding code.
(main): Have insn-emit.c include hard-reg-set.h before recog.h.
* genrecog.c (change_state): Don't track last_insn.
(write_action): Write into *_pmatch_len before accepting.
(write_tree): Adjust peephole2_insns and subroutines to match.
* config/i386/i386.md (all peepholes): Use peep2_regno_dead_p.
2000-05-27 Richard Henderson <rth@cygnus.com>
* function.c (thread_prologue_epilogue_insns): Don't move the * function.c (thread_prologue_epilogue_insns): Don't move the
line note at the head of the chain. Only force a lineno note line note at the head of the chain. Only force a lineno note
before the end of block 0. before the end of block 0.
...@@ -1382,7 +1382,7 @@ final.o : final.c $(CONFIG_H) system.h $(RTL_H) $(TREE_H) flags.h intl.h \ ...@@ -1382,7 +1382,7 @@ final.o : final.c $(CONFIG_H) system.h $(RTL_H) $(TREE_H) flags.h intl.h \
dbxout.h $(BASIC_BLOCK_H) dbxout.h $(BASIC_BLOCK_H)
recog.o : recog.c $(CONFIG_H) system.h $(RTL_H) function.h $(BASIC_BLOCK_H) \ recog.o : recog.c $(CONFIG_H) system.h $(RTL_H) function.h $(BASIC_BLOCK_H) \
$(REGS_H) $(RECOG_H) hard-reg-set.h flags.h insn-config.h insn-attr.h \ $(REGS_H) $(RECOG_H) hard-reg-set.h flags.h insn-config.h insn-attr.h \
insn-flags.h insn-codes.h real.h toplev.h output.h resource.h insn-flags.h insn-codes.h real.h toplev.h output.h
reg-stack.o : reg-stack.c $(CONFIG_H) system.h $(RTL_H) $(TREE_H) $(RECOG_H) \ reg-stack.o : reg-stack.c $(CONFIG_H) system.h $(RTL_H) $(TREE_H) $(RECOG_H) \
$(REGS_H) hard-reg-set.h flags.h insn-config.h insn-flags.h toplev.h \ $(REGS_H) hard-reg-set.h flags.h insn-config.h insn-flags.h toplev.h \
varray.h function.h varray.h function.h
......
...@@ -9591,10 +9591,11 @@ ...@@ -9591,10 +9591,11 @@
[(match_scratch:SI 1 "r") [(match_scratch:SI 1 "r")
(set (match_operand:SI 0 "memory_operand" "") (set (match_operand:SI 0 "memory_operand" "")
(const_int 0))] (const_int 0))]
"! optimize_size && get_attr_length (insn) >= ix86_cost->large_insn "! optimize_size
&& reg_dead_p (insn, gen_rtx_REG (CCmode, FLAGS_REG))
&& ! TARGET_USE_MOV0 && ! TARGET_USE_MOV0
&& TARGET_SPLIT_LONG_MOVES" && TARGET_SPLIT_LONG_MOVES
&& get_attr_length (insn) >= ix86_cost->large_insn
&& peep2_regno_dead_p (0, FLAGS_REG)"
[(parallel [(set (match_dup 1) (const_int 0)) [(parallel [(set (match_dup 1) (const_int 0))
(clobber (reg:CC 17))]) (clobber (reg:CC 17))])
(set (match_dup 0) (match_dup 1))] (set (match_dup 0) (match_dup 1))]
...@@ -9604,10 +9605,11 @@ ...@@ -9604,10 +9605,11 @@
[(match_scratch:HI 1 "r") [(match_scratch:HI 1 "r")
(set (match_operand:HI 0 "memory_operand" "") (set (match_operand:HI 0 "memory_operand" "")
(const_int 0))] (const_int 0))]
"! optimize_size && get_attr_length (insn) >= ix86_cost->large_insn "! optimize_size
&& reg_dead_p (insn, gen_rtx_REG (CCmode, FLAGS_REG))
&& ! TARGET_USE_MOV0 && ! TARGET_USE_MOV0
&& TARGET_SPLIT_LONG_MOVES" && TARGET_SPLIT_LONG_MOVES
&& get_attr_length (insn) >= ix86_cost->large_insn
&& peep2_regno_dead_p (0, FLAGS_REG)"
[(parallel [(set (match_dup 2) (const_int 0)) [(parallel [(set (match_dup 2) (const_int 0))
(clobber (reg:CC 17))]) (clobber (reg:CC 17))])
(set (match_dup 0) (match_dup 1))] (set (match_dup 0) (match_dup 1))]
...@@ -9617,10 +9619,11 @@ ...@@ -9617,10 +9619,11 @@
[(match_scratch:QI 1 "q") [(match_scratch:QI 1 "q")
(set (match_operand:QI 0 "memory_operand" "") (set (match_operand:QI 0 "memory_operand" "")
(const_int 0))] (const_int 0))]
"! optimize_size && get_attr_length (insn) >= ix86_cost->large_insn "! optimize_size
&& reg_dead_p (insn, gen_rtx_REG (CCmode, FLAGS_REG))
&& ! TARGET_USE_MOV0 && ! TARGET_USE_MOV0
&& TARGET_SPLIT_LONG_MOVES" && TARGET_SPLIT_LONG_MOVES
&& get_attr_length (insn) >= ix86_cost->large_insn
&& peep2_regno_dead_p (0, FLAGS_REG)"
[(parallel [(set (match_dup 2) (const_int 0)) [(parallel [(set (match_dup 2) (const_int 0))
(clobber (reg:CC 17))]) (clobber (reg:CC 17))])
(set (match_dup 0) (match_dup 1))] (set (match_dup 0) (match_dup 1))]
...@@ -9630,8 +9633,9 @@ ...@@ -9630,8 +9633,9 @@
[(match_scratch:SI 2 "r") [(match_scratch:SI 2 "r")
(set (match_operand:SI 0 "memory_operand" "") (set (match_operand:SI 0 "memory_operand" "")
(match_operand:SI 1 "immediate_operand" ""))] (match_operand:SI 1 "immediate_operand" ""))]
"! optimize_size && get_attr_length (insn) >= ix86_cost->large_insn "! optimize_size
&& TARGET_SPLIT_LONG_MOVES" && get_attr_length (insn) >= ix86_cost->large_insn
&& TARGET_SPLIT_LONG_MOVES"
[(set (match_dup 2) (match_dup 1)) [(set (match_dup 2) (match_dup 1))
(set (match_dup 0) (match_dup 2))] (set (match_dup 0) (match_dup 2))]
"") "")
...@@ -9675,14 +9679,14 @@ ...@@ -9675,14 +9679,14 @@
;; represented using a modRM byte. The XOR replacement is long decoded, ;; represented using a modRM byte. The XOR replacement is long decoded,
;; so this split helps here as well. ;; so this split helps here as well.
;; ;;
;; Note: Can't do this as a regular split because reg_dead_p assumes ;; Note: Can't do this as a regular split because we can't get proper
;; resource info is live. ;; lifetime information then.
(define_peephole2 (define_peephole2
[(set (match_operand:SI 0 "nonimmediate_operand" "=rm") [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
(not:SI (match_operand:SI 1 "nonimmediate_operand" "0")))] (not:SI (match_operand:SI 1 "nonimmediate_operand" "0")))]
"!optimize_size "!optimize_size
&& reg_dead_p (insn, gen_rtx_REG (CCmode, FLAGS_REG)) && peep2_regno_dead_p (0, FLAGS_REG)
&& ((TARGET_PENTIUM && ((TARGET_PENTIUM
&& (GET_CODE (operands[0]) != MEM && (GET_CODE (operands[0]) != MEM
|| !memory_displacement_operand (operands[0], SImode))) || !memory_displacement_operand (operands[0], SImode)))
...@@ -9696,7 +9700,7 @@ ...@@ -9696,7 +9700,7 @@
[(set (match_operand:HI 0 "nonimmediate_operand" "=rm") [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
(not:HI (match_operand:HI 1 "nonimmediate_operand" "0")))] (not:HI (match_operand:HI 1 "nonimmediate_operand" "0")))]
"!optimize_size "!optimize_size
&& reg_dead_p (insn, gen_rtx_REG (CCmode, FLAGS_REG)) && peep2_regno_dead_p (0, FLAGS_REG)
&& ((TARGET_PENTIUM && ((TARGET_PENTIUM
&& (GET_CODE (operands[0]) != MEM && (GET_CODE (operands[0]) != MEM
|| !memory_displacement_operand (operands[0], HImode))) || !memory_displacement_operand (operands[0], HImode)))
...@@ -9710,7 +9714,7 @@ ...@@ -9710,7 +9714,7 @@
[(set (match_operand:QI 0 "nonimmediate_operand" "=rm") [(set (match_operand:QI 0 "nonimmediate_operand" "=rm")
(not:QI (match_operand:QI 1 "nonimmediate_operand" "0")))] (not:QI (match_operand:QI 1 "nonimmediate_operand" "0")))]
"!optimize_size "!optimize_size
&& reg_dead_p (insn, gen_rtx_REG (CCmode, FLAGS_REG)) && peep2_regno_dead_p (0, FLAGS_REG)
&& ((TARGET_PENTIUM && ((TARGET_PENTIUM
&& (GET_CODE (operands[0]) != MEM && (GET_CODE (operands[0]) != MEM
|| !memory_displacement_operand (operands[0], QImode))) || !memory_displacement_operand (operands[0], QImode)))
...@@ -9873,7 +9877,7 @@ ...@@ -9873,7 +9877,7 @@
|| GET_MODE (operands[0]) == HImode || GET_MODE (operands[0]) == HImode
|| GET_MODE (operands[0]) == SImode) || GET_MODE (operands[0]) == SImode)
&& (! TARGET_USE_MOV0 || optimize_size) && (! TARGET_USE_MOV0 || optimize_size)
&& reg_dead_p (insn, gen_rtx_REG (CCmode, FLAGS_REG))" && peep2_regno_dead_p (0, FLAGS_REG)"
[(parallel [(set (match_dup 0) (const_int 0)) [(parallel [(set (match_dup 0) (const_int 0))
(clobber (reg:CC 17))])] (clobber (reg:CC 17))])]
"operands[0] = gen_rtx_REG (SImode, true_regnum (operands[0]));") "operands[0] = gen_rtx_REG (SImode, true_regnum (operands[0]));")
...@@ -9885,7 +9889,7 @@ ...@@ -9885,7 +9889,7 @@
"(GET_MODE (operands[0]) == HImode "(GET_MODE (operands[0]) == HImode
|| GET_MODE (operands[0]) == SImode) || GET_MODE (operands[0]) == SImode)
&& (optimize_size || TARGET_PENTIUM) && (optimize_size || TARGET_PENTIUM)
&& reg_dead_p (insn, gen_rtx_REG (CCmode, FLAGS_REG))" && peep2_regno_dead_p (0, FLAGS_REG)"
[(parallel [(set (match_dup 0) (const_int -1)) [(parallel [(set (match_dup 0) (const_int -1))
(clobber (reg:CC 17))])] (clobber (reg:CC 17))])]
"operands[0] = gen_rtx_REG (SImode, true_regnum (operands[0]));") "operands[0] = gen_rtx_REG (SImode, true_regnum (operands[0]));")
...@@ -9896,7 +9900,7 @@ ...@@ -9896,7 +9900,7 @@
[(set (match_operand:SI 0 "register_operand" "") [(set (match_operand:SI 0 "register_operand" "")
(plus:SI (match_dup 0) (plus:SI (match_dup 0)
(match_operand:SI 1 "nonmemory_operand" "")))] (match_operand:SI 1 "nonmemory_operand" "")))]
"reg_dead_p (insn, gen_rtx_REG (CCmode, FLAGS_REG))" "peep2_regno_dead_p (0, FLAGS_REG)"
[(parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1))) [(parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
(clobber (reg:CC 17))])] (clobber (reg:CC 17))])]
"") "")
...@@ -9905,7 +9909,8 @@ ...@@ -9905,7 +9909,8 @@
[(set (match_operand:SI 0 "register_operand" "") [(set (match_operand:SI 0 "register_operand" "")
(mult:SI (match_dup 0) (mult:SI (match_dup 0)
(match_operand:SI 1 "immediate_operand" "")))] (match_operand:SI 1 "immediate_operand" "")))]
"reg_dead_p (insn, gen_rtx_REG (CCmode, FLAGS_REG))" "exact_log2 (INTVAL (operands[1])) >= 0
&& peep2_regno_dead_p (0, FLAGS_REG)"
[(parallel [(set (match_dup 0) (ashift:SI (match_dup 0) (match_dup 2))) [(parallel [(set (match_dup 0) (ashift:SI (match_dup 0) (match_dup 2)))
(clobber (reg:CC 17))])] (clobber (reg:CC 17))])]
"operands[2] = GEN_INT (exact_log2 (INTVAL (operands[1])));") "operands[2] = GEN_INT (exact_log2 (INTVAL (operands[1])));")
......
...@@ -42,6 +42,9 @@ static int have_peephole2_flag; ...@@ -42,6 +42,9 @@ static int have_peephole2_flag;
/* Maximum number of insns seen in a split. */ /* Maximum number of insns seen in a split. */
static int max_insns_per_split = 1; static int max_insns_per_split = 1;
/* Maximum number of input insns for peephole2. */
static int max_insns_per_peep2;
static int clobbers_seen_this_insn; static int clobbers_seen_this_insn;
static int dup_operands_seen_this_insn; static int dup_operands_seen_this_insn;
...@@ -239,6 +242,26 @@ gen_peephole (peep) ...@@ -239,6 +242,26 @@ gen_peephole (peep)
walk_insn_part (XVECEXP (peep, 0, i), 1, 0); walk_insn_part (XVECEXP (peep, 0, i), 1, 0);
} }
static void
gen_peephole2 (peep)
rtx peep;
{
int i, n;
/* Look through the patterns that are matched
to compute the maximum operand number. */
for (i = XVECLEN (peep, 0) - 1; i >= 0; --i)
walk_insn_part (XVECEXP (peep, 0, i), 1, 0);
/* Look at the number of insns this insn can be matched from. */
for (i = XVECLEN (peep, 0) - 1, n = 0; i >= 0; --i)
if (GET_CODE (XVECEXP (peep, 0, i)) != MATCH_DUP
&& GET_CODE (XVECEXP (peep, 0, i)) != MATCH_SCRATCH)
n++;
if (n > max_insns_per_peep2)
max_insns_per_peep2 = n;
}
extern int main PARAMS ((int, char **)); extern int main PARAMS ((int, char **));
int int
...@@ -289,7 +312,7 @@ from the machine description file `md'. */\n\n"); ...@@ -289,7 +312,7 @@ from the machine description file `md'. */\n\n");
case DEFINE_PEEPHOLE2: case DEFINE_PEEPHOLE2:
have_peephole2_flag = 1; have_peephole2_flag = 1;
gen_split (desc); gen_peephole2 (desc);
break; break;
case DEFINE_PEEPHOLE: case DEFINE_PEEPHOLE:
...@@ -302,9 +325,8 @@ from the machine description file `md'. */\n\n"); ...@@ -302,9 +325,8 @@ from the machine description file `md'. */\n\n");
} }
} }
printf ("\n#define MAX_RECOG_OPERANDS %d\n", max_recog_operands + 1); printf ("#define MAX_RECOG_OPERANDS %d\n", max_recog_operands + 1);
printf ("#define MAX_DUP_OPERANDS %d\n", max_dup_operands);
printf ("\n#define MAX_DUP_OPERANDS %d\n", max_dup_operands);
/* This is conditionally defined, in case the user writes code which emits /* This is conditionally defined, in case the user writes code which emits
more splits than we can readily see (and knows s/he does it). */ more splits than we can readily see (and knows s/he does it). */
...@@ -328,7 +350,10 @@ from the machine description file `md'. */\n\n"); ...@@ -328,7 +350,10 @@ from the machine description file `md'. */\n\n");
printf ("#define HAVE_peephole 1\n"); printf ("#define HAVE_peephole 1\n");
if (have_peephole2_flag) if (have_peephole2_flag)
printf ("#define HAVE_peephole2 1\n"); {
printf ("#define HAVE_peephole2 1\n");
printf ("#define MAX_INSNS_PER_PEEP2 %d\n", max_insns_per_peep2);
}
fflush (stdout); fflush (stdout);
return (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE); return (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
......
...@@ -699,10 +699,7 @@ output_peephole2_scratches (split) ...@@ -699,10 +699,7 @@ output_peephole2_scratches (split)
int i; int i;
int insn_nr = 0; int insn_nr = 0;
printf (" rtx first_insn ATTRIBUTE_UNUSED;\n");
printf (" rtx last_insn ATTRIBUTE_UNUSED;\n");
printf (" HARD_REG_SET _regs_allocated;\n"); printf (" HARD_REG_SET _regs_allocated;\n");
printf (" CLEAR_HARD_REG_SET (_regs_allocated);\n"); printf (" CLEAR_HARD_REG_SET (_regs_allocated);\n");
for (i = 0; i < XVECLEN (split, 0); i++) for (i = 0; i < XVECLEN (split, 0); i++)
...@@ -721,15 +718,11 @@ output_peephole2_scratches (split) ...@@ -721,15 +718,11 @@ output_peephole2_scratches (split)
} }
else if (GET_CODE (XVECEXP (split, 0, j)) != MATCH_SCRATCH) else if (GET_CODE (XVECEXP (split, 0, j)) != MATCH_SCRATCH)
cur_insn_nr++; cur_insn_nr++;
printf (" first_insn = recog_next_insn (curr_insn, %d);\n", insn_nr);
if (last_insn_nr > insn_nr) printf (" if ((operands[%d] = peep2_find_free_register (%d, %d, \"%s\", %smode, &_regs_allocated)) == NULL_RTX)\n\
printf (" last_insn = recog_next_insn (curr_insn, %d);\n",
last_insn_nr - 1);
else
printf (" last_insn = 0;\n");
printf (" if ((operands[%d] = find_free_register (first_insn, last_insn, \"%s\", %smode, &_regs_allocated)) == NULL_RTX)\n\
return NULL;\n", return NULL;\n",
XINT (elt, 0), XINT (elt, 0),
insn_nr, last_insn_nr,
XSTR (elt, 1), XSTR (elt, 1),
GET_MODE_NAME (GET_MODE (elt))); GET_MODE_NAME (GET_MODE (elt)));
...@@ -777,8 +770,8 @@ from the machine description file `md'. */\n\n"); ...@@ -777,8 +770,8 @@ from the machine description file `md'. */\n\n");
printf ("#include \"insn-config.h\"\n"); printf ("#include \"insn-config.h\"\n");
printf ("#include \"insn-flags.h\"\n"); printf ("#include \"insn-flags.h\"\n");
printf ("#include \"insn-codes.h\"\n"); printf ("#include \"insn-codes.h\"\n");
printf ("#include \"recog.h\"\n");
printf ("#include \"hard-reg-set.h\"\n"); printf ("#include \"hard-reg-set.h\"\n");
printf ("#include \"recog.h\"\n");
printf ("#include \"resource.h\"\n"); printf ("#include \"resource.h\"\n");
printf ("#include \"reload.h\"\n\n"); printf ("#include \"reload.h\"\n\n");
printf ("#define FAIL return (end_sequence (), _val)\n"); printf ("#define FAIL return (end_sequence (), _val)\n");
......
...@@ -272,8 +272,8 @@ static struct decision *write_switch ...@@ -272,8 +272,8 @@ static struct decision *write_switch
static void write_cond static void write_cond
PARAMS ((struct decision_test *, int, enum routine_type)); PARAMS ((struct decision_test *, int, enum routine_type));
static void write_action static void write_action
PARAMS ((struct decision_test *, int, int, struct decision *, PARAMS ((struct decision *, struct decision_test *, int, int,
enum routine_type)); struct decision *, enum routine_type));
static int is_unconditional static int is_unconditional
PARAMS ((struct decision_test *, enum routine_type)); PARAMS ((struct decision_test *, enum routine_type));
static int write_node static int write_node
...@@ -1578,10 +1578,6 @@ change_state (oldpos, newpos, afterward, indent) ...@@ -1578,10 +1578,6 @@ change_state (oldpos, newpos, afterward, indent)
if (newpos[new_has_insn] >= 'A' && newpos[new_has_insn] <= 'Z') if (newpos[new_has_insn] >= 'A' && newpos[new_has_insn] <= 'Z')
break; break;
/* Make sure to reset the last_insn pointer when popping back up. */
if (old_has_insn >= 0 && new_has_insn < 0)
printf ("%slast_insn = insn;\n", indent);
/* Go down to desired level. */ /* Go down to desired level. */
while (depth < ndepth) while (depth < ndepth)
{ {
...@@ -1591,21 +1587,20 @@ change_state (oldpos, newpos, afterward, indent) ...@@ -1591,21 +1587,20 @@ change_state (oldpos, newpos, afterward, indent)
/* We can only fail if we're moving down the tree. */ /* We can only fail if we're moving down the tree. */
if (old_has_insn >= 0 && oldpos[old_has_insn] >= newpos[depth]) if (old_has_insn >= 0 && oldpos[old_has_insn] >= newpos[depth])
{ {
printf ("%slast_insn = recog_next_insn (insn, %d);\n", printf ("%stem = peep2_next_insn (%d);\n",
indent, newpos[depth] - 'A'); indent, newpos[depth] - 'A');
} }
else else
{ {
printf ("%stem = recog_next_insn (insn, %d);\n", printf ("%stem = peep2_next_insn (%d);\n",
indent, newpos[depth] - 'A'); indent, newpos[depth] - 'A');
printf ("%sif (tem == NULL_RTX)\n", indent); printf ("%sif (tem == NULL_RTX)\n", indent);
if (afterward) if (afterward)
printf ("%s goto L%d;\n", indent, afterward->number); printf ("%s goto L%d;\n", indent, afterward->number);
else else
printf ("%s goto ret0;\n", indent); printf ("%s goto ret0;\n", indent);
printf ("%slast_insn = tem;\n", indent);
} }
printf ("%sx%d = PATTERN (last_insn);\n", indent, depth + 1); printf ("%sx%d = PATTERN (tem);\n", indent, depth + 1);
} }
else if (newpos[depth] >= 'a' && newpos[depth] <= 'z') else if (newpos[depth] >= 'a' && newpos[depth] <= 'z')
printf ("%sx%d = XVECEXP (x%d, 0, %d);\n", printf ("%sx%d = XVECEXP (x%d, 0, %d);\n",
...@@ -1888,7 +1883,8 @@ write_cond (p, depth, subroutine_type) ...@@ -1888,7 +1883,8 @@ write_cond (p, depth, subroutine_type)
perform a state change. For the `accept' tests we must do more work. */ perform a state change. For the `accept' tests we must do more work. */
static void static void
write_action (test, depth, uncond, success, subroutine_type) write_action (p, test, depth, uncond, success, subroutine_type)
struct decision *p;
struct decision_test *test; struct decision_test *test;
int depth, uncond; int depth, uncond;
struct decision *success; struct decision *success;
...@@ -1942,9 +1938,20 @@ write_action (test, depth, uncond, success, subroutine_type) ...@@ -1942,9 +1938,20 @@ write_action (test, depth, uncond, success, subroutine_type)
break; break;
case PEEPHOLE2: case PEEPHOLE2:
printf ("%stem = gen_peephole2_%d (insn, operands);\n", {
indent, test->u.insn.code_number); int match_len = 0, i;
printf ("%sif (tem != 0)\n%s goto ret1;\n", indent, indent);
for (i = strlen (p->position) - 1; i >= 0; --i)
if (p->position[i] >= 'A' && p->position[i] <= 'Z')
{
match_len = p->position[i] - 'A';
break;
}
printf ("%s*_pmatch_len = %d;\n", indent, match_len);
printf ("%stem = gen_peephole2_%d (insn, operands);\n",
indent, test->u.insn.code_number);
printf ("%sif (tem != 0)\n%s return tem;\n", indent, indent);
}
break; break;
default: default:
...@@ -2027,7 +2034,7 @@ write_node (p, depth, subroutine_type) ...@@ -2027,7 +2034,7 @@ write_node (p, depth, subroutine_type)
printf (")\n"); printf (")\n");
} }
write_action (last_test, depth, uncond, p->success.first, subroutine_type); write_action (p, last_test, depth, uncond, p->success.first, subroutine_type);
return uncond > 0; return uncond > 0;
} }
...@@ -2090,7 +2097,7 @@ write_tree (head, prevpos, type, initial) ...@@ -2090,7 +2097,7 @@ write_tree (head, prevpos, type, initial)
}; };
static const char * const call_suffix[] = { static const char * const call_suffix[] = {
", pnum_clobbers", "", ", _plast_insn" ", pnum_clobbers", "", ", _pmatch_len"
}; };
/* This node has been broken out into a separate subroutine. /* This node has been broken out into a separate subroutine.
...@@ -2167,12 +2174,13 @@ split%s (x0, insn)\n\ ...@@ -2167,12 +2174,13 @@ split%s (x0, insn)\n\
rtx insn ATTRIBUTE_UNUSED;\n", s_or_e, extension); rtx insn ATTRIBUTE_UNUSED;\n", s_or_e, extension);
break; break;
case PEEPHOLE2: case PEEPHOLE2:
printf ("%srtx peephole2%s PARAMS ((rtx, rtx, rtx *));\n", s_or_e, extension); printf ("%srtx peephole2%s PARAMS ((rtx, rtx, int *));\n",
s_or_e, extension);
printf ("%srtx\n\ printf ("%srtx\n\
peephole2%s (x0, insn, _plast_insn)\n\ peephole2%s (x0, insn, _pmatch_len)\n\
register rtx x0;\n\ register rtx x0;\n\
rtx insn ATTRIBUTE_UNUSED;\n\ rtx insn ATTRIBUTE_UNUSED;\n\
rtx *_plast_insn ATTRIBUTE_UNUSED;\n", s_or_e, extension); int *_pmatch_len ATTRIBUTE_UNUSED;\n", s_or_e, extension);
break; break;
} }
...@@ -2180,8 +2188,6 @@ peephole2%s (x0, insn, _plast_insn)\n\ ...@@ -2180,8 +2188,6 @@ peephole2%s (x0, insn, _plast_insn)\n\
for (i = 1; i <= max_depth; i++) for (i = 1; i <= max_depth; i++)
printf (" register rtx x%d ATTRIBUTE_UNUSED;\n", i); printf (" register rtx x%d ATTRIBUTE_UNUSED;\n", i);
if (type == PEEPHOLE2)
printf (" register rtx last_insn = insn;\n");
printf (" %s tem ATTRIBUTE_UNUSED;\n", IS_SPLIT (type) ? "rtx" : "int"); printf (" %s tem ATTRIBUTE_UNUSED;\n", IS_SPLIT (type) ? "rtx" : "int");
if (head->first) if (head->first)
...@@ -2189,8 +2195,6 @@ peephole2%s (x0, insn, _plast_insn)\n\ ...@@ -2189,8 +2195,6 @@ peephole2%s (x0, insn, _plast_insn)\n\
else else
printf (" goto ret0;\n"); printf (" goto ret0;\n");
if (type == PEEPHOLE2)
printf (" ret1:\n *_plast_insn = last_insn;\n return tem;\n");
printf (" ret0:\n return %d;\n}\n\n", IS_SPLIT (type) ? 0 : -1); printf (" ret0:\n return %d;\n}\n\n", IS_SPLIT (type) ? 0 : -1);
} }
......
...@@ -116,9 +116,16 @@ extern void add_clobbers PARAMS ((rtx, int)); ...@@ -116,9 +116,16 @@ extern void add_clobbers PARAMS ((rtx, int));
extern void insn_extract PARAMS ((rtx)); extern void insn_extract PARAMS ((rtx));
extern void extract_insn PARAMS ((rtx)); extern void extract_insn PARAMS ((rtx));
extern void preprocess_constraints PARAMS ((void)); extern void preprocess_constraints PARAMS ((void));
extern rtx recog_next_insn PARAMS ((rtx, int)); extern rtx peep2_next_insn PARAMS ((int));
extern int peep2_regno_dead_p PARAMS ((int, int));
extern int peep2_reg_dead_p PARAMS ((int, rtx));
#ifdef CLEAR_HARD_REG_SET
extern rtx peep2_find_free_register PARAMS ((int, int, const char *,
enum machine_mode,
HARD_REG_SET *));
#endif
extern void peephole2_optimize PARAMS ((FILE *)); extern void peephole2_optimize PARAMS ((FILE *));
extern rtx peephole2_insns PARAMS ((rtx, rtx, rtx *)); extern rtx peephole2_insns PARAMS ((rtx, rtx, int *));
/* Nonzero means volatile operands are recognized. */ /* Nonzero means volatile operands are recognized. */
extern int volatile_ok; extern int volatile_ok;
......
...@@ -1268,109 +1268,3 @@ mark_end_of_function_resources (trial, include_delayed_effects) ...@@ -1268,109 +1268,3 @@ mark_end_of_function_resources (trial, include_delayed_effects)
mark_referenced_resources (trial, &end_of_function_needs, mark_referenced_resources (trial, &end_of_function_needs,
include_delayed_effects); include_delayed_effects);
} }
/* Try to find a hard register of mode MODE, matching the register class in
CLASS_STR, which is available at the beginning of insn CURRENT_INSN and
remains available until the end of LAST_INSN. LAST_INSN may be NULL_RTX,
in which case the only condition is that the register must be available
before CURRENT_INSN.
Registers that already have bits set in REG_SET will not be considered.
If an appropriate register is available, it will be returned and the
corresponding bit(s) in REG_SET will be set; otherwise, NULL_RTX is
returned. */
rtx
find_free_register (current_insn, last_insn, class_str, mode, reg_set)
rtx current_insn, last_insn;
const char *class_str;
int mode;
HARD_REG_SET *reg_set;
{
int i, j;
struct resources used;
unsigned char clet = class_str[0];
enum reg_class class
= (clet == 'r' ? GENERAL_REGS : REG_CLASS_FROM_LETTER (clet));
mark_target_live_regs (get_insns (), current_insn, &used);
if (last_insn)
while (current_insn != last_insn)
{
/* Exclude anything set in this insn. */
mark_set_resources (PATTERN (current_insn), &used, 0,
MARK_SRC_DEST_CALL);
current_insn = next_nonnote_insn (current_insn);
}
for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
{
int regno;
int success;
#ifdef REG_ALLOC_ORDER
regno = reg_alloc_order [i];
#else
regno = i;
#endif
/* Don't allocate fixed registers. */
if (fixed_regs[regno])
continue;
/* Make sure the register is of the right class. */
if (! TEST_HARD_REG_BIT (reg_class_contents[class], regno))
continue;
/* And can support the mode we need. */
if (! HARD_REGNO_MODE_OK (regno, mode))
continue;
/* And that we don't create an extra save/restore. */
if (! call_used_regs[regno] && ! regs_ever_live[regno])
continue;
/* And we don't clobber traceback for noreturn functions. */
if ((regno == FRAME_POINTER_REGNUM || regno == HARD_FRAME_POINTER_REGNUM)
&& (! reload_completed || frame_pointer_needed))
continue;
success = 1;
for (j = HARD_REGNO_NREGS (regno, mode) - 1; j >= 0; j--)
{
if (TEST_HARD_REG_BIT (*reg_set, regno + j)
|| TEST_HARD_REG_BIT (used.regs, regno + j))
{
success = 0;
break;
}
}
if (success)
{
for (j = HARD_REGNO_NREGS (regno, mode) - 1; j >= 0; j--)
{
SET_HARD_REG_BIT (*reg_set, regno + j);
}
return gen_rtx_REG (mode, regno);
}
}
return NULL_RTX;
}
/* Return true if REG is dead at CURRENT_INSN. */
int
reg_dead_p (current_insn, reg)
rtx current_insn, reg;
{
struct resources used;
int regno, j;
mark_target_live_regs (get_insns (), current_insn, &used);
regno = REGNO (reg);
for (j = HARD_REGNO_NREGS (regno, GET_MODE (reg)) - 1; j >= 0; j--)
{
if (TEST_HARD_REG_BIT (used.regs, regno + j))
return 0;
}
return 1;
}
...@@ -50,6 +50,3 @@ extern void incr_ticks_for_insn PARAMS ((rtx)); ...@@ -50,6 +50,3 @@ extern void incr_ticks_for_insn PARAMS ((rtx));
extern void mark_end_of_function_resources PARAMS ((rtx, int)); extern void mark_end_of_function_resources PARAMS ((rtx, int));
extern void init_resource_info PARAMS ((rtx)); extern void init_resource_info PARAMS ((rtx));
extern void free_resource_info PARAMS ((void)); extern void free_resource_info PARAMS ((void));
extern rtx find_free_register PARAMS ((rtx, rtx, const char *, int,
HARD_REG_SET *));
extern int reg_dead_p PARAMS ((rtx, rtx));
...@@ -47,6 +47,7 @@ Boston, MA 02111-1307, USA. */ ...@@ -47,6 +47,7 @@ Boston, MA 02111-1307, USA. */
#include "insn-attr.h" #include "insn-attr.h"
#include "insn-codes.h" #include "insn-codes.h"
#include "insn-config.h" #include "insn-config.h"
#include "hard-reg-set.h"
#include "recog.h" #include "recog.h"
#include "defaults.h" #include "defaults.h"
#include "output.h" #include "output.h"
...@@ -54,7 +55,6 @@ Boston, MA 02111-1307, USA. */ ...@@ -54,7 +55,6 @@ Boston, MA 02111-1307, USA. */
#include "function.h" #include "function.h"
#include "toplev.h" #include "toplev.h"
#include "expr.h" #include "expr.h"
#include "hard-reg-set.h"
#include "basic-block.h" #include "basic-block.h"
#include "intl.h" #include "intl.h"
#include "ggc.h" #include "ggc.h"
......
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