1 /* Generate code from machine description to recognize rtl as insns.
2 Copyright (C) 1987-2015 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 GCC is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
21 /* This program is used to produce insn-recog.c, which contains a
22 function called `recog' plus its subroutines. These functions
23 contain a decision tree that recognizes whether an rtx, the
24 argument given to recog, is a valid instruction.
26 recog returns -1 if the rtx is not valid. If the rtx is valid,
27 recog returns a nonnegative number which is the insn code number
28 for the pattern that matched. This is the same as the order in the
29 machine description of the entry that matched. This number can be
30 used as an index into various insn_* tables, such as insn_template,
31 insn_outfun, and insn_n_operands (found in insn-output.c).
33 The third argument to recog is an optional pointer to an int. If
34 present, recog will accept a pattern if it matches except for
35 missing CLOBBER expressions at the end. In that case, the value
36 pointed to by the optional pointer will be set to the number of
37 CLOBBERs that need to be added (it should be initialized to zero by
38 the caller). If it is set nonzero, the caller should allocate a
39 PARALLEL of the appropriate size, copy the initial entries, and
40 call add_clobbers (found in insn-emit.c) to fill in the CLOBBERs.
42 This program also generates the function `split_insns', which
43 returns 0 if the rtl could not be split, or it returns the split
46 This program also generates the function `peephole2_insns', which
47 returns 0 if the rtl could not be matched. If there was a match,
48 the new rtl is returned in an INSN list, and LAST_INSN will point
49 to the last recognized insn in the old sequence. */
53 #include "coretypes.h"
58 #include "gensupport.h"
60 #define OUTPUT_LABEL(INDENT_STRING, LABEL_NUMBER) \
61 printf ("%sL%d: ATTRIBUTE_UNUSED_LABEL\n", (INDENT_STRING), (LABEL_NUMBER))
63 /* Ways of obtaining an rtx to be tested. */
65 /* PATTERN (peep2_next_insn (ARG)). */
68 /* XEXP (BASE, ARG). */
71 /* XVECEXP (BASE, 0, ARG). */
75 /* The position of an rtx relative to X0. Each useful position is
76 represented by exactly one instance of this structure. */
79 /* The parent rtx. This is the root position for POS_PEEP2_INSNs. */
80 struct position
*base
;
82 /* A position with the same BASE and TYPE, but with the next value
84 struct position
*next
;
86 /* A list of all POS_XEXP positions that use this one as their base,
87 chained by NEXT fields. The first entry represents XEXP (this, 0),
88 the second represents XEXP (this, 1), and so on. */
89 struct position
*xexps
;
91 /* A list of POS_XVECEXP0 positions that use this one as their base,
92 chained by NEXT fields. The first entry represents XVECEXP (this, 0, 0),
93 the second represents XVECEXP (this, 0, 1), and so on. */
94 struct position
*xvecexp0s
;
96 /* The type of position. */
97 enum position_type type
;
99 /* The argument to TYPE (shown as ARG in the position_type comments). */
102 /* The depth of this position, with 0 as the root. */
106 /* A listhead of decision trees. The alternatives to a node are kept
107 in a doubly-linked list so we can easily add nodes to the proper
108 place when merging. */
112 struct decision
*first
;
113 struct decision
*last
;
116 /* These types are roughly in the order in which we'd like to test them. */
120 DT_mode
, DT_code
, DT_veclen
,
121 DT_elt_zero_int
, DT_elt_one_int
, DT_elt_zero_wide
, DT_elt_zero_wide_safe
,
123 DT_veclen_ge
, DT_dup
, DT_pred
, DT_c_test
,
124 DT_accept_op
, DT_accept_insn
127 /* A single test. The two accept types aren't tests per-se, but
128 their equality (or lack thereof) does affect tree merging so
129 it is convenient to keep them here. */
133 /* A linked list through the tests attached to a node. */
134 struct decision_test
*next
;
136 enum decision_type type
;
140 int num_insns
; /* Number if insn in a define_peephole2. */
141 machine_mode mode
; /* Machine mode of node. */
142 RTX_CODE code
; /* Code to test. */
146 const char *name
; /* Predicate to call. */
147 const struct pred_data
*data
;
148 /* Optimization hints for this predicate. */
149 machine_mode mode
; /* Machine mode for node. */
152 const char *c_test
; /* Additional test to perform. */
153 int veclen
; /* Length of vector. */
154 int dup
; /* Number of operand to compare against. */
155 HOST_WIDE_INT intval
; /* Value for XINT for XWINT. */
156 int opno
; /* Operand number matched. */
159 int code_number
; /* Insn number matched. */
160 int lineno
; /* Line number of the insn. */
161 int num_clobbers_to_add
; /* Number of CLOBBERs to be added. */
166 /* Data structure for decision tree for recognizing legitimate insns. */
170 struct decision_head success
; /* Nodes to test on success. */
171 struct decision
*next
; /* Node to test on failure. */
172 struct decision
*prev
; /* Node whose failure tests us. */
173 struct decision
*afterward
; /* Node to test on success,
174 but failure of successor nodes. */
176 struct position
*position
; /* Position in pattern. */
178 struct decision_test
*tests
; /* The tests for this node. */
180 int number
; /* Node number, used for labels */
181 int subroutine_number
; /* Number of subroutine this node starts */
182 int need_label
; /* Label needs to be output. */
185 #define SUBROUTINE_THRESHOLD 100
187 static int next_subroutine_number
;
189 /* We can write three types of subroutines: One for insn recognition,
190 one to split insns, and one for peephole-type optimizations. This
191 defines which type is being written. */
194 RECOG
, SPLIT
, PEEPHOLE2
197 #define IS_SPLIT(X) ((X) != RECOG)
199 /* Next available node number for tree nodes. */
201 static int next_number
;
203 /* Next number to use as an insn_code. */
205 static int next_insn_code
;
207 /* Record the highest depth we ever have so we know how many variables to
208 allocate in each subroutine we make. */
210 static int max_depth
;
212 /* The line number of the start of the pattern currently being processed. */
213 static int pattern_lineno
;
215 /* The root position (x0). */
216 static struct position root_pos
;
218 /* A list of all POS_PEEP2_INSNs. The entry for insn 0 is the root position,
219 since we are given that instruction's pattern as x0. */
220 static struct position
*peep2_insn_pos_list
= &root_pos
;
222 extern void debug_decision
224 extern void debug_decision_list
227 /* Return a position with the given BASE, TYPE and ARG. NEXT_PTR
228 points to where the unique object that represents the position
229 should be stored. Create the object if it doesn't already exist,
230 otherwise reuse the object that is already there. */
232 static struct position
*
233 next_position (struct position
**next_ptr
, struct position
*base
,
234 enum position_type type
, int arg
)
236 struct position
*pos
;
241 pos
= XCNEW (struct position
);
245 pos
->depth
= base
->depth
+ 1;
251 /* Compare positions POS1 and POS2 lexicographically. */
254 compare_positions (struct position
*pos1
, struct position
*pos2
)
258 diff
= pos1
->depth
- pos2
->depth
;
262 while (pos1
->depth
!= pos2
->depth
);
266 while (pos1
->depth
!= pos2
->depth
);
269 diff
= (int) pos1
->type
- (int) pos2
->type
;
271 diff
= pos1
->arg
- pos2
->arg
;
278 /* Create a new node in sequence after LAST. */
280 static struct decision
*
281 new_decision (struct position
*pos
, struct decision_head
*last
)
283 struct decision
*new_decision
= XCNEW (struct decision
);
285 new_decision
->success
= *last
;
286 new_decision
->position
= pos
;
287 new_decision
->number
= next_number
++;
289 last
->first
= last
->last
= new_decision
;
293 /* Create a new test and link it in at PLACE. */
295 static struct decision_test
*
296 new_decision_test (enum decision_type type
, struct decision_test
***pplace
)
298 struct decision_test
**place
= *pplace
;
299 struct decision_test
*test
;
301 test
= XNEW (struct decision_test
);
312 /* Search for and return operand N, stop when reaching node STOP. */
315 find_operand (rtx pattern
, int n
, rtx stop
)
325 code
= GET_CODE (pattern
);
326 if ((code
== MATCH_SCRATCH
327 || code
== MATCH_OPERAND
328 || code
== MATCH_OPERATOR
329 || code
== MATCH_PARALLEL
)
330 && XINT (pattern
, 0) == n
)
333 fmt
= GET_RTX_FORMAT (code
);
334 len
= GET_RTX_LENGTH (code
);
335 for (i
= 0; i
< len
; i
++)
340 if ((r
= find_operand (XEXP (pattern
, i
), n
, stop
)) != NULL_RTX
)
345 if (! XVEC (pattern
, i
))
350 for (j
= 0; j
< XVECLEN (pattern
, i
); j
++)
351 if ((r
= find_operand (XVECEXP (pattern
, i
, j
), n
, stop
))
356 case 'i': case 'w': case '0': case 's':
367 /* Search for and return operand M, such that it has a matching
368 constraint for operand N. */
371 find_matching_operand (rtx pattern
, int n
)
378 code
= GET_CODE (pattern
);
379 if (code
== MATCH_OPERAND
380 && (XSTR (pattern
, 2)[0] == '0' + n
381 || (XSTR (pattern
, 2)[0] == '%'
382 && XSTR (pattern
, 2)[1] == '0' + n
)))
385 fmt
= GET_RTX_FORMAT (code
);
386 len
= GET_RTX_LENGTH (code
);
387 for (i
= 0; i
< len
; i
++)
392 if ((r
= find_matching_operand (XEXP (pattern
, i
), n
)))
397 if (! XVEC (pattern
, i
))
402 for (j
= 0; j
< XVECLEN (pattern
, i
); j
++)
403 if ((r
= find_matching_operand (XVECEXP (pattern
, i
, j
), n
)))
407 case 'i': case 'w': case '0': case 's':
418 /* In DEFINE_EXPAND, DEFINE_SPLIT, and DEFINE_PEEPHOLE2, we
419 don't use the MATCH_OPERAND constraint, only the predicate.
420 This is confusing to folks doing new ports, so help them
421 not make the mistake. */
424 constraints_supported_in_insn_p (rtx insn
)
426 return !(GET_CODE (insn
) == DEFINE_EXPAND
427 || GET_CODE (insn
) == DEFINE_SPLIT
428 || GET_CODE (insn
) == DEFINE_PEEPHOLE2
);
431 /* Check for various errors in patterns. SET is nonnull for a destination,
432 and is the complete set pattern. SET_CODE is '=' for normal sets, and
433 '+' within a context that requires in-out constraints. */
436 validate_pattern (rtx pattern
, rtx insn
, rtx set
, int set_code
)
443 code
= GET_CODE (pattern
);
448 const char constraints0
= XSTR (pattern
, 1)[0];
450 if (!constraints_supported_in_insn_p (insn
))
454 error_with_line (pattern_lineno
,
455 "constraints not supported in %s",
456 rtx_name
[GET_CODE (insn
)]);
461 /* If a MATCH_SCRATCH is used in a context requiring an write-only
462 or read/write register, validate that. */
465 && constraints0
!= '='
466 && constraints0
!= '+')
468 error_with_line (pattern_lineno
,
469 "operand %d missing output reload",
477 if (find_operand (insn
, XINT (pattern
, 0), pattern
) == pattern
)
478 error_with_line (pattern_lineno
,
479 "operand %i duplicated before defined",
485 const char *pred_name
= XSTR (pattern
, 1);
486 const struct pred_data
*pred
;
489 if (GET_CODE (insn
) == DEFINE_INSN
)
490 c_test
= XSTR (insn
, 2);
492 c_test
= XSTR (insn
, 1);
494 if (pred_name
[0] != 0)
496 pred
= lookup_predicate (pred_name
);
498 error_with_line (pattern_lineno
, "unknown predicate '%s'",
504 if (code
== MATCH_OPERAND
)
506 const char *constraints
= XSTR (pattern
, 2);
507 const char constraints0
= constraints
[0];
509 if (!constraints_supported_in_insn_p (insn
))
513 error_with_line (pattern_lineno
,
514 "constraints not supported in %s",
515 rtx_name
[GET_CODE (insn
)]);
519 /* A MATCH_OPERAND that is a SET should have an output reload. */
520 else if (set
&& constraints0
)
524 if (constraints0
== '+')
526 /* If we've only got an output reload for this operand,
527 we'd better have a matching input operand. */
528 else if (constraints0
== '='
529 && find_matching_operand (insn
, XINT (pattern
, 0)))
532 error_with_line (pattern_lineno
,
533 "operand %d missing in-out reload",
536 else if (constraints0
!= '=' && constraints0
!= '+')
537 error_with_line (pattern_lineno
,
538 "operand %d missing output reload",
542 /* For matching constraint in MATCH_OPERAND, the digit must be a
543 smaller number than the number of the operand that uses it in the
547 while (constraints
[0]
548 && (constraints
[0] == ' ' || constraints
[0] == ','))
553 if (constraints
[0] >= '0' && constraints
[0] <= '9')
557 sscanf (constraints
, "%d", &val
);
558 if (val
>= XINT (pattern
, 0))
559 error_with_line (pattern_lineno
,
560 "constraint digit %d is not smaller than"
562 val
, XINT (pattern
, 0));
565 while (constraints
[0] && constraints
[0] != ',')
570 /* Allowing non-lvalues in destinations -- particularly CONST_INT --
571 while not likely to occur at runtime, results in less efficient
572 code from insn-recog.c. */
573 if (set
&& pred
&& pred
->allows_non_lvalue
)
574 error_with_line (pattern_lineno
,
575 "destination operand %d allows non-lvalue",
578 /* A modeless MATCH_OPERAND can be handy when we can check for
579 multiple modes in the c_test. In most other cases, it is a
580 mistake. Only DEFINE_INSN is eligible, since SPLIT and
581 PEEP2 can FAIL within the output pattern. Exclude special
582 predicates, which check the mode themselves. Also exclude
583 predicates that allow only constants. Exclude the SET_DEST
584 of a call instruction, as that is a common idiom. */
586 if (GET_MODE (pattern
) == VOIDmode
587 && code
== MATCH_OPERAND
588 && GET_CODE (insn
) == DEFINE_INSN
591 && pred
->allows_non_const
592 && strstr (c_test
, "operands") == NULL
594 && GET_CODE (set
) == SET
595 && GET_CODE (SET_SRC (set
)) == CALL
))
596 message_with_line (pattern_lineno
,
597 "warning: operand %d missing mode?",
604 machine_mode dmode
, smode
;
607 dest
= SET_DEST (pattern
);
608 src
= SET_SRC (pattern
);
610 /* STRICT_LOW_PART is a wrapper. Its argument is the real
611 destination, and it's mode should match the source. */
612 if (GET_CODE (dest
) == STRICT_LOW_PART
)
613 dest
= XEXP (dest
, 0);
615 /* Find the referent for a DUP. */
617 if (GET_CODE (dest
) == MATCH_DUP
618 || GET_CODE (dest
) == MATCH_OP_DUP
619 || GET_CODE (dest
) == MATCH_PAR_DUP
)
620 dest
= find_operand (insn
, XINT (dest
, 0), NULL
);
622 if (GET_CODE (src
) == MATCH_DUP
623 || GET_CODE (src
) == MATCH_OP_DUP
624 || GET_CODE (src
) == MATCH_PAR_DUP
)
625 src
= find_operand (insn
, XINT (src
, 0), NULL
);
627 dmode
= GET_MODE (dest
);
628 smode
= GET_MODE (src
);
630 /* The mode of an ADDRESS_OPERAND is the mode of the memory
631 reference, not the mode of the address. */
632 if (GET_CODE (src
) == MATCH_OPERAND
633 && ! strcmp (XSTR (src
, 1), "address_operand"))
636 /* The operands of a SET must have the same mode unless one
638 else if (dmode
!= VOIDmode
&& smode
!= VOIDmode
&& dmode
!= smode
)
639 error_with_line (pattern_lineno
,
640 "mode mismatch in set: %smode vs %smode",
641 GET_MODE_NAME (dmode
), GET_MODE_NAME (smode
));
643 /* If only one of the operands is VOIDmode, and PC or CC0 is
644 not involved, it's probably a mistake. */
645 else if (dmode
!= smode
646 && GET_CODE (dest
) != PC
647 && GET_CODE (dest
) != CC0
648 && GET_CODE (src
) != PC
649 && GET_CODE (src
) != CC0
650 && !CONST_INT_P (src
)
651 && !CONST_WIDE_INT_P (src
)
652 && GET_CODE (src
) != CALL
)
655 which
= (dmode
== VOIDmode
? "destination" : "source");
656 message_with_line (pattern_lineno
,
657 "warning: %s missing a mode?", which
);
660 if (dest
!= SET_DEST (pattern
))
661 validate_pattern (dest
, insn
, pattern
, '=');
662 validate_pattern (SET_DEST (pattern
), insn
, pattern
, '=');
663 validate_pattern (SET_SRC (pattern
), insn
, NULL_RTX
, 0);
668 validate_pattern (SET_DEST (pattern
), insn
, pattern
, '=');
672 validate_pattern (XEXP (pattern
, 0), insn
, set
, set
? '+' : 0);
673 validate_pattern (XEXP (pattern
, 1), insn
, NULL_RTX
, 0);
674 validate_pattern (XEXP (pattern
, 2), insn
, NULL_RTX
, 0);
677 case STRICT_LOW_PART
:
678 validate_pattern (XEXP (pattern
, 0), insn
, set
, set
? '+' : 0);
682 if (GET_MODE (LABEL_REF_LABEL (pattern
)) != VOIDmode
)
683 error_with_line (pattern_lineno
,
684 "operand to label_ref %smode not VOIDmode",
685 GET_MODE_NAME (GET_MODE (LABEL_REF_LABEL (pattern
))));
692 fmt
= GET_RTX_FORMAT (code
);
693 len
= GET_RTX_LENGTH (code
);
694 for (i
= 0; i
< len
; i
++)
699 validate_pattern (XEXP (pattern
, i
), insn
, NULL_RTX
, 0);
703 for (j
= 0; j
< XVECLEN (pattern
, i
); j
++)
704 validate_pattern (XVECEXP (pattern
, i
, j
), insn
, NULL_RTX
, 0);
707 case 'i': case 'w': case '0': case 's':
716 /* Create a chain of nodes to verify that an rtl expression matches
719 LAST is a pointer to the listhead in the previous node in the chain (or
720 in the calling function, for the first node).
722 POSITION is the current position in the insn.
724 INSN_TYPE is the type of insn for which we are emitting code.
726 A pointer to the final node in the chain is returned. */
728 static struct decision
*
729 add_to_sequence (rtx pattern
, struct decision_head
*last
,
730 struct position
*pos
, enum routine_type insn_type
, int top
)
733 struct decision
*this_decision
, *sub
;
734 struct decision_test
*test
;
735 struct decision_test
**place
;
736 struct position
*subpos
, **subpos_ptr
;
741 enum position_type pos_type
;
743 if (pos
->depth
> max_depth
)
744 max_depth
= pos
->depth
;
746 sub
= this_decision
= new_decision (pos
, last
);
747 place
= &this_decision
->tests
;
749 mode
= GET_MODE (pattern
);
750 code
= GET_CODE (pattern
);
755 /* Toplevel peephole pattern. */
756 if (insn_type
== PEEPHOLE2
&& top
)
760 /* Check we have sufficient insns. This avoids complications
761 because we then know peep2_next_insn never fails. */
762 num_insns
= XVECLEN (pattern
, 0);
765 test
= new_decision_test (DT_num_insns
, &place
);
766 test
->u
.num_insns
= num_insns
;
767 last
= &sub
->success
;
771 /* We don't need the node we just created -- unlink it. */
772 last
->first
= last
->last
= NULL
;
775 subpos_ptr
= &peep2_insn_pos_list
;
776 for (i
= 0; i
< (size_t) XVECLEN (pattern
, 0); i
++)
778 subpos
= next_position (subpos_ptr
, &root_pos
,
780 sub
= add_to_sequence (XVECEXP (pattern
, 0, i
),
781 last
, subpos
, insn_type
, 0);
782 last
= &sub
->success
;
783 subpos_ptr
= &subpos
->next
;
788 /* Else nothing special. */
792 /* The explicit patterns within a match_parallel enforce a minimum
793 length on the vector. The match_parallel predicate may allow
794 for more elements. We do need to check for this minimum here
795 or the code generated to match the internals may reference data
796 beyond the end of the vector. */
797 test
= new_decision_test (DT_veclen_ge
, &place
);
798 test
->u
.veclen
= XVECLEN (pattern
, 2);
805 RTX_CODE was_code
= code
;
806 const char *pred_name
;
807 bool allows_const_int
= true;
809 if (code
== MATCH_SCRATCH
)
811 pred_name
= "scratch_operand";
816 pred_name
= XSTR (pattern
, 1);
817 if (code
== MATCH_PARALLEL
)
823 if (pred_name
[0] != 0)
825 const struct pred_data
*pred
;
827 test
= new_decision_test (DT_pred
, &place
);
828 test
->u
.pred
.name
= pred_name
;
829 test
->u
.pred
.mode
= mode
;
831 /* See if we know about this predicate.
832 If we do, remember it for use below.
834 We can optimize the generated code a little if either
835 (a) the predicate only accepts one code, or (b) the
836 predicate does not allow CONST_INT or CONST_WIDE_INT,
837 in which case it can match only if the modes match. */
838 pred
= lookup_predicate (pred_name
);
841 test
->u
.pred
.data
= pred
;
842 allows_const_int
= (pred
->codes
[CONST_INT
]
843 || pred
->codes
[CONST_WIDE_INT
]);
844 if (was_code
== MATCH_PARALLEL
845 && pred
->singleton
!= PARALLEL
)
846 error_with_line (pattern_lineno
,
847 "predicate '%s' used in match_parallel "
848 "does not allow only PARALLEL", pred
->name
);
850 code
= pred
->singleton
;
853 error_with_line (pattern_lineno
,
854 "unknown predicate '%s' in '%s' expression",
855 pred_name
, GET_RTX_NAME (was_code
));
858 /* Can't enforce a mode if we allow const_int. */
859 if (allows_const_int
)
862 /* Accept the operand, i.e. record it in `operands'. */
863 test
= new_decision_test (DT_accept_op
, &place
);
864 test
->u
.opno
= XINT (pattern
, 0);
866 if (was_code
== MATCH_OPERATOR
|| was_code
== MATCH_PARALLEL
)
868 if (was_code
== MATCH_OPERATOR
)
871 subpos_ptr
= &pos
->xexps
;
875 pos_type
= POS_XVECEXP0
;
876 subpos_ptr
= &pos
->xvecexp0s
;
878 for (i
= 0; i
< (size_t) XVECLEN (pattern
, 2); i
++)
880 subpos
= next_position (subpos_ptr
, pos
, pos_type
, i
);
881 sub
= add_to_sequence (XVECEXP (pattern
, 2, i
),
882 &sub
->success
, subpos
, insn_type
, 0);
883 subpos_ptr
= &subpos
->next
;
892 test
= new_decision_test (DT_dup
, &place
);
893 test
->u
.dup
= XINT (pattern
, 0);
895 test
= new_decision_test (DT_accept_op
, &place
);
896 test
->u
.opno
= XINT (pattern
, 0);
898 subpos_ptr
= &pos
->xexps
;
899 for (i
= 0; i
< (size_t) XVECLEN (pattern
, 1); i
++)
901 subpos
= next_position (subpos_ptr
, pos
, POS_XEXP
, i
);
902 sub
= add_to_sequence (XVECEXP (pattern
, 1, i
),
903 &sub
->success
, subpos
, insn_type
, 0);
904 subpos_ptr
= &subpos
->next
;
912 test
= new_decision_test (DT_dup
, &place
);
913 test
->u
.dup
= XINT (pattern
, 0);
920 fmt
= GET_RTX_FORMAT (code
);
921 len
= GET_RTX_LENGTH (code
);
923 /* Do tests against the current node first. */
924 for (i
= 0; i
< (size_t) len
; i
++)
932 test
= new_decision_test (DT_elt_zero_int
, &place
);
933 test
->u
.intval
= XINT (pattern
, i
);
937 test
= new_decision_test (DT_elt_one_int
, &place
);
938 test
->u
.intval
= XINT (pattern
, i
);
941 else if (fmt
[i
] == 'w')
943 /* If this value actually fits in an int, we can use a switch
944 statement here, so indicate that. */
945 enum decision_type type
946 = ((int) XWINT (pattern
, i
) == XWINT (pattern
, i
))
947 ? DT_elt_zero_wide_safe
: DT_elt_zero_wide
;
951 test
= new_decision_test (type
, &place
);
952 test
->u
.intval
= XWINT (pattern
, i
);
954 else if (fmt
[i
] == 'E')
958 test
= new_decision_test (DT_veclen
, &place
);
959 test
->u
.veclen
= XVECLEN (pattern
, i
);
963 /* Now test our sub-patterns. */
964 subpos_ptr
= &pos
->xexps
;
965 for (i
= 0; i
< (size_t) len
; i
++)
967 subpos
= next_position (subpos_ptr
, pos
, POS_XEXP
, i
);
971 sub
= add_to_sequence (XEXP (pattern
, i
), &sub
->success
,
972 subpos
, insn_type
, 0);
977 struct position
*subpos2
, **subpos2_ptr
;
980 subpos2_ptr
= &pos
->xvecexp0s
;
981 for (j
= 0; j
< XVECLEN (pattern
, i
); j
++)
983 subpos2
= next_position (subpos2_ptr
, pos
, POS_XVECEXP0
, j
);
984 sub
= add_to_sequence (XVECEXP (pattern
, i
, j
),
985 &sub
->success
, subpos2
, insn_type
, 0);
986 subpos2_ptr
= &subpos2
->next
;
1000 subpos_ptr
= &subpos
->next
;
1004 /* Insert nodes testing mode and code, if they're still relevant,
1005 before any of the nodes we may have added above. */
1006 if (code
!= UNKNOWN
)
1008 place
= &this_decision
->tests
;
1009 test
= new_decision_test (DT_code
, &place
);
1010 test
->u
.code
= code
;
1013 if (mode
!= VOIDmode
)
1015 place
= &this_decision
->tests
;
1016 test
= new_decision_test (DT_mode
, &place
);
1017 test
->u
.mode
= mode
;
1020 /* If we didn't insert any tests or accept nodes, hork. */
1021 gcc_assert (this_decision
->tests
);
1027 /* A subroutine of maybe_both_true; examines only one test.
1028 Returns > 0 for "definitely both true" and < 0 for "maybe both true". */
1031 maybe_both_true_2 (struct decision_test
*d1
, struct decision_test
*d2
)
1033 if (d1
->type
== d2
->type
)
1038 if (d1
->u
.num_insns
== d2
->u
.num_insns
)
1044 return d1
->u
.mode
== d2
->u
.mode
;
1047 return d1
->u
.code
== d2
->u
.code
;
1050 return d1
->u
.veclen
== d2
->u
.veclen
;
1052 case DT_elt_zero_int
:
1053 case DT_elt_one_int
:
1054 case DT_elt_zero_wide
:
1055 case DT_elt_zero_wide_safe
:
1056 return d1
->u
.intval
== d2
->u
.intval
;
1063 /* If either has a predicate that we know something about, set
1064 things up so that D1 is the one that always has a known
1065 predicate. Then see if they have any codes in common. */
1067 if (d1
->type
== DT_pred
|| d2
->type
== DT_pred
)
1069 if (d2
->type
== DT_pred
)
1071 struct decision_test
*tmp
;
1072 tmp
= d1
, d1
= d2
, d2
= tmp
;
1075 /* If D2 tests a mode, see if it matches D1. */
1076 if (d1
->u
.pred
.mode
!= VOIDmode
)
1078 if (d2
->type
== DT_mode
)
1080 if (d1
->u
.pred
.mode
!= d2
->u
.mode
1081 /* The mode of an address_operand predicate is the
1082 mode of the memory, not the operand. It can only
1083 be used for testing the predicate, so we must
1085 && strcmp (d1
->u
.pred
.name
, "address_operand") != 0)
1088 /* Don't check two predicate modes here, because if both predicates
1089 accept CONST_INT, then both can still be true even if the modes
1090 are different. If they don't accept CONST_INT, there will be a
1091 separate DT_mode that will make maybe_both_true_1 return 0. */
1094 if (d1
->u
.pred
.data
)
1096 /* If D2 tests a code, see if it is in the list of valid
1097 codes for D1's predicate. */
1098 if (d2
->type
== DT_code
)
1100 if (!d1
->u
.pred
.data
->codes
[d2
->u
.code
])
1104 /* Otherwise see if the predicates have any codes in common. */
1105 else if (d2
->type
== DT_pred
&& d2
->u
.pred
.data
)
1107 bool common
= false;
1110 for (c
= 0; c
< NUM_RTX_CODE
; c
++)
1111 if (d1
->u
.pred
.data
->codes
[c
] && d2
->u
.pred
.data
->codes
[c
])
1123 /* Tests vs veclen may be known when strict equality is involved. */
1124 if (d1
->type
== DT_veclen
&& d2
->type
== DT_veclen_ge
)
1125 return d1
->u
.veclen
>= d2
->u
.veclen
;
1126 if (d1
->type
== DT_veclen_ge
&& d2
->type
== DT_veclen
)
1127 return d2
->u
.veclen
>= d1
->u
.veclen
;
1132 /* A subroutine of maybe_both_true; examines all the tests for a given node.
1133 Returns > 0 for "definitely both true" and < 0 for "maybe both true". */
1136 maybe_both_true_1 (struct decision_test
*d1
, struct decision_test
*d2
)
1138 struct decision_test
*t1
, *t2
;
1140 /* A match_operand with no predicate can match anything. Recognize
1141 this by the existence of a lone DT_accept_op test. */
1142 if (d1
->type
== DT_accept_op
|| d2
->type
== DT_accept_op
)
1145 /* Eliminate pairs of tests while they can exactly match. */
1146 while (d1
&& d2
&& d1
->type
== d2
->type
)
1148 if (maybe_both_true_2 (d1
, d2
) == 0)
1150 d1
= d1
->next
, d2
= d2
->next
;
1153 /* After that, consider all pairs. */
1154 for (t1
= d1
; t1
; t1
= t1
->next
)
1155 for (t2
= d2
; t2
; t2
= t2
->next
)
1156 if (maybe_both_true_2 (t1
, t2
) == 0)
1162 /* Return 0 if we can prove that there is no RTL that can match both
1163 D1 and D2. Otherwise, return 1 (it may be that there is an RTL that
1164 can match both or just that we couldn't prove there wasn't such an RTL).
1166 TOPLEVEL is nonzero if we are to only look at the top level and not
1167 recursively descend. */
1170 maybe_both_true (struct decision
*d1
, struct decision
*d2
,
1173 struct decision
*p1
, *p2
;
1176 /* Don't compare strings on the different positions in insn. Doing so
1177 is incorrect and results in false matches from constructs like
1179 [(set (subreg:HI (match_operand:SI "register_operand" "r") 0)
1180 (subreg:HI (match_operand:SI "register_operand" "r") 0))]
1182 [(set (match_operand:HI "register_operand" "r")
1183 (match_operand:HI "register_operand" "r"))]
1185 If we are presented with such, we are recursing through the remainder
1186 of a node's success nodes (from the loop at the end of this function).
1187 Skip forward until we come to a position that matches.
1189 Due to the way positions are constructed, we know that iterating
1190 forward from the lexically lower position will run into the lexically
1191 higher position and not the other way around. This saves a bit
1194 cmp
= compare_positions (d1
->position
, d2
->position
);
1197 gcc_assert (!toplevel
);
1199 /* If the d2->position was lexically lower, swap. */
1201 p1
= d1
, d1
= d2
, d2
= p1
;
1203 if (d1
->success
.first
== 0)
1205 for (p1
= d1
->success
.first
; p1
; p1
= p1
->next
)
1206 if (maybe_both_true (p1
, d2
, 0))
1212 /* Test the current level. */
1213 cmp
= maybe_both_true_1 (d1
->tests
, d2
->tests
);
1217 /* We can't prove that D1 and D2 cannot both be true. If we are only
1218 to check the top level, return 1. Otherwise, see if we can prove
1219 that all choices in both successors are mutually exclusive. If
1220 either does not have any successors, we can't prove they can't both
1223 if (toplevel
|| d1
->success
.first
== 0 || d2
->success
.first
== 0)
1226 for (p1
= d1
->success
.first
; p1
; p1
= p1
->next
)
1227 for (p2
= d2
->success
.first
; p2
; p2
= p2
->next
)
1228 if (maybe_both_true (p1
, p2
, 0))
1234 /* A subroutine of nodes_identical. Examine two tests for equivalence. */
1237 nodes_identical_1 (struct decision_test
*d1
, struct decision_test
*d2
)
1242 return d1
->u
.num_insns
== d2
->u
.num_insns
;
1245 return d1
->u
.mode
== d2
->u
.mode
;
1248 return d1
->u
.code
== d2
->u
.code
;
1251 return (d1
->u
.pred
.mode
== d2
->u
.pred
.mode
1252 && strcmp (d1
->u
.pred
.name
, d2
->u
.pred
.name
) == 0);
1255 return strcmp (d1
->u
.c_test
, d2
->u
.c_test
) == 0;
1259 return d1
->u
.veclen
== d2
->u
.veclen
;
1262 return d1
->u
.dup
== d2
->u
.dup
;
1264 case DT_elt_zero_int
:
1265 case DT_elt_one_int
:
1266 case DT_elt_zero_wide
:
1267 case DT_elt_zero_wide_safe
:
1268 return d1
->u
.intval
== d2
->u
.intval
;
1271 return d1
->u
.opno
== d2
->u
.opno
;
1273 case DT_accept_insn
:
1274 /* Differences will be handled in merge_accept_insn. */
1282 /* True iff the two nodes are identical (on one level only). Due
1283 to the way these lists are constructed, we shouldn't have to
1284 consider different orderings on the tests. */
1287 nodes_identical (struct decision
*d1
, struct decision
*d2
)
1289 struct decision_test
*t1
, *t2
;
1291 for (t1
= d1
->tests
, t2
= d2
->tests
; t1
&& t2
; t1
= t1
->next
, t2
= t2
->next
)
1293 if (t1
->type
!= t2
->type
)
1295 if (! nodes_identical_1 (t1
, t2
))
1299 /* For success, they should now both be null. */
1303 /* Check that their subnodes are at the same position, as any one set
1304 of sibling decisions must be at the same position. Allowing this
1305 requires complications to find_afterward and when change_state is
1307 if (d1
->success
.first
1308 && d2
->success
.first
1309 && d1
->success
.first
->position
!= d2
->success
.first
->position
)
1315 /* A subroutine of merge_trees; given two nodes that have been declared
1316 identical, cope with two insn accept states. If they differ in the
1317 number of clobbers, then the conflict was created by make_insn_sequence
1318 and we can drop the with-clobbers version on the floor. If both
1319 nodes have no additional clobbers, we have found an ambiguity in the
1320 source machine description. */
1323 merge_accept_insn (struct decision
*oldd
, struct decision
*addd
)
1325 struct decision_test
*old
, *add
;
1327 for (old
= oldd
->tests
; old
; old
= old
->next
)
1328 if (old
->type
== DT_accept_insn
)
1333 for (add
= addd
->tests
; add
; add
= add
->next
)
1334 if (add
->type
== DT_accept_insn
)
1339 /* If one node is for a normal insn and the second is for the base
1340 insn with clobbers stripped off, the second node should be ignored. */
1342 if (old
->u
.insn
.num_clobbers_to_add
== 0
1343 && add
->u
.insn
.num_clobbers_to_add
> 0)
1345 /* Nothing to do here. */
1347 else if (old
->u
.insn
.num_clobbers_to_add
> 0
1348 && add
->u
.insn
.num_clobbers_to_add
== 0)
1350 /* In this case, replace OLD with ADD. */
1351 old
->u
.insn
= add
->u
.insn
;
1355 error_with_line (add
->u
.insn
.lineno
, "`%s' matches `%s'",
1356 get_insn_name (add
->u
.insn
.code_number
),
1357 get_insn_name (old
->u
.insn
.code_number
));
1358 message_with_line (old
->u
.insn
.lineno
, "previous definition of `%s'",
1359 get_insn_name (old
->u
.insn
.code_number
));
1363 /* Merge two decision trees OLDH and ADDH, modifying OLDH destructively. */
1366 merge_trees (struct decision_head
*oldh
, struct decision_head
*addh
)
1368 struct decision
*next
, *add
;
1370 if (addh
->first
== 0)
1372 if (oldh
->first
== 0)
1378 /* Trying to merge bits at different positions isn't possible. */
1379 gcc_assert (oldh
->first
->position
== addh
->first
->position
);
1381 for (add
= addh
->first
; add
; add
= next
)
1383 struct decision
*old
, *insert_before
= NULL
;
1387 /* The semantics of pattern matching state that the tests are
1388 done in the order given in the MD file so that if an insn
1389 matches two patterns, the first one will be used. However,
1390 in practice, most, if not all, patterns are unambiguous so
1391 that their order is independent. In that case, we can merge
1392 identical tests and group all similar modes and codes together.
1394 Scan starting from the end of OLDH until we reach a point
1395 where we reach the head of the list or where we pass a
1396 pattern that could also be true if NEW is true. If we find
1397 an identical pattern, we can merge them. Also, record the
1398 last node that tests the same code and mode and the last one
1399 that tests just the same mode.
1401 If we have no match, place NEW after the closest match we found. */
1403 for (old
= oldh
->last
; old
; old
= old
->prev
)
1405 if (nodes_identical (old
, add
))
1407 merge_accept_insn (old
, add
);
1408 merge_trees (&old
->success
, &add
->success
);
1412 if (maybe_both_true (old
, add
, 0))
1415 /* Insert the nodes in DT test type order, which is roughly
1416 how expensive/important the test is. Given that the tests
1417 are also ordered within the list, examining the first is
1419 if ((int) add
->tests
->type
< (int) old
->tests
->type
)
1420 insert_before
= old
;
1423 if (insert_before
== NULL
)
1426 add
->prev
= oldh
->last
;
1427 oldh
->last
->next
= add
;
1432 if ((add
->prev
= insert_before
->prev
) != NULL
)
1433 add
->prev
->next
= add
;
1436 add
->next
= insert_before
;
1437 insert_before
->prev
= add
;
1444 /* Walk the tree looking for sub-nodes that perform common tests.
1445 Factor out the common test into a new node. This enables us
1446 (depending on the test type) to emit switch statements later. */
1449 factor_tests (struct decision_head
*head
)
1451 struct decision
*first
, *next
;
1453 for (first
= head
->first
; first
&& first
->next
; first
= next
)
1455 enum decision_type type
;
1456 struct decision
*new_dec
, *old_last
;
1458 type
= first
->tests
->type
;
1461 /* Want at least two compatible sequential nodes. */
1462 if (next
->tests
->type
!= type
)
1465 /* Don't want all node types, just those we can turn into
1466 switch statements. */
1469 && type
!= DT_veclen
1470 && type
!= DT_elt_zero_int
1471 && type
!= DT_elt_one_int
1472 && type
!= DT_elt_zero_wide_safe
)
1475 /* If we'd been performing more than one test, create a new node
1476 below our first test. */
1477 if (first
->tests
->next
!= NULL
)
1479 new_dec
= new_decision (first
->position
, &first
->success
);
1480 new_dec
->tests
= first
->tests
->next
;
1481 first
->tests
->next
= NULL
;
1484 /* Crop the node tree off after our first test. */
1486 old_last
= head
->last
;
1489 /* For each compatible test, adjust to perform only one test in
1490 the top level node, then merge the node back into the tree. */
1493 struct decision_head h
;
1495 if (next
->tests
->next
!= NULL
)
1497 new_dec
= new_decision (next
->position
, &next
->success
);
1498 new_dec
->tests
= next
->tests
->next
;
1499 next
->tests
->next
= NULL
;
1503 new_dec
->next
= NULL
;
1504 h
.first
= h
.last
= new_dec
;
1506 merge_trees (head
, &h
);
1508 while (next
&& next
->tests
->type
== type
);
1510 /* After we run out of compatible tests, graft the remaining nodes
1511 back onto the tree. */
1514 next
->prev
= head
->last
;
1515 head
->last
->next
= next
;
1516 head
->last
= old_last
;
1521 for (first
= head
->first
; first
; first
= first
->next
)
1522 factor_tests (&first
->success
);
1525 /* After factoring, try to simplify the tests on any one node.
1526 Tests that are useful for switch statements are recognizable
1527 by having only a single test on a node -- we'll be manipulating
1528 nodes with multiple tests:
1530 If we have mode tests or code tests that are redundant with
1531 predicates, remove them. */
1534 simplify_tests (struct decision_head
*head
)
1536 struct decision
*tree
;
1538 for (tree
= head
->first
; tree
; tree
= tree
->next
)
1540 struct decision_test
*a
, *b
;
1547 /* Find a predicate node. */
1548 while (b
&& b
->type
!= DT_pred
)
1552 /* Due to how these tests are constructed, we don't even need
1553 to check that the mode and code are compatible -- they were
1554 generated from the predicate in the first place. */
1555 while (a
->type
== DT_mode
|| a
->type
== DT_code
)
1562 for (tree
= head
->first
; tree
; tree
= tree
->next
)
1563 simplify_tests (&tree
->success
);
1566 /* Count the number of subnodes of HEAD. If the number is high enough,
1567 make the first node in HEAD start a separate subroutine in the C code
1568 that is generated. */
1571 break_out_subroutines (struct decision_head
*head
, int initial
)
1574 struct decision
*sub
;
1576 for (sub
= head
->first
; sub
; sub
= sub
->next
)
1577 size
+= 1 + break_out_subroutines (&sub
->success
, 0);
1579 if (size
> SUBROUTINE_THRESHOLD
&& ! initial
)
1581 head
->first
->subroutine_number
= ++next_subroutine_number
;
1587 /* For each node p, find the next alternative that might be true
1591 find_afterward (struct decision_head
*head
, struct decision
*real_afterward
)
1593 struct decision
*p
, *q
, *afterward
;
1595 /* We can't propagate alternatives across subroutine boundaries.
1596 This is not incorrect, merely a minor optimization loss. */
1599 afterward
= (p
->subroutine_number
> 0 ? NULL
: real_afterward
);
1601 for ( ; p
; p
= p
->next
)
1603 /* Find the next node that might be true if this one fails. */
1604 for (q
= p
->next
; q
; q
= q
->next
)
1605 if (maybe_both_true (p
, q
, 1))
1608 /* If we reached the end of the list without finding one,
1609 use the incoming afterward position. */
1618 for (p
= head
->first
; p
; p
= p
->next
)
1619 if (p
->success
.first
)
1620 find_afterward (&p
->success
, p
->afterward
);
1622 /* When we are generating a subroutine, record the real afterward
1623 position in the first node where write_tree can find it, and we
1624 can do the right thing at the subroutine call site. */
1626 if (p
->subroutine_number
> 0)
1627 p
->afterward
= real_afterward
;
1630 /* Assuming that the state of argument is denoted by OLDPOS, take whatever
1631 actions are necessary to move to NEWPOS. If we fail to move to the
1632 new state, branch to node AFTERWARD if nonzero, otherwise return.
1634 Failure to move to the new state can only occur if we are trying to
1635 match multiple insns and we try to step past the end of the stream. */
1638 change_state (struct position
*oldpos
, struct position
*newpos
,
1641 while (oldpos
->depth
> newpos
->depth
)
1642 oldpos
= oldpos
->base
;
1644 if (oldpos
!= newpos
)
1645 switch (newpos
->type
)
1647 case POS_PEEP2_INSN
:
1648 printf ("%stem = peep2_next_insn (%d);\n", indent
, newpos
->arg
);
1649 printf ("%sx%d = PATTERN (tem);\n", indent
, newpos
->depth
);
1653 change_state (oldpos
, newpos
->base
, indent
);
1654 printf ("%sx%d = XEXP (x%d, %d);\n",
1655 indent
, newpos
->depth
, newpos
->depth
- 1, newpos
->arg
);
1659 change_state (oldpos
, newpos
->base
, indent
);
1660 printf ("%sx%d = XVECEXP (x%d, 0, %d);\n",
1661 indent
, newpos
->depth
, newpos
->depth
- 1, newpos
->arg
);
1666 /* Print the enumerator constant for CODE -- the upcase version of
1670 print_code (enum rtx_code code
)
1673 for (p
= GET_RTX_NAME (code
); *p
; p
++)
1674 putchar (TOUPPER (*p
));
1677 /* Emit code to cross an afterward link -- change state and branch. */
1680 write_afterward (struct decision
*start
, struct decision
*afterward
,
1683 if (!afterward
|| start
->subroutine_number
> 0)
1684 printf ("%sgoto ret0;\n", indent
);
1687 change_state (start
->position
, afterward
->position
, indent
);
1688 printf ("%sgoto L%d;\n", indent
, afterward
->number
);
1692 /* Emit a HOST_WIDE_INT as an integer constant expression. We need to take
1693 special care to avoid "decimal constant is so large that it is unsigned"
1694 warnings in the resulting code. */
1697 print_host_wide_int (HOST_WIDE_INT val
)
1699 HOST_WIDE_INT min
= (unsigned HOST_WIDE_INT
)1 << (HOST_BITS_PER_WIDE_INT
-1);
1701 printf ("(" HOST_WIDE_INT_PRINT_DEC_C
"-1)", val
+ 1);
1703 printf (HOST_WIDE_INT_PRINT_DEC_C
, val
);
1706 /* Emit a switch statement, if possible, for an initial sequence of
1707 nodes at START. Return the first node yet untested. */
1709 static struct decision
*
1710 write_switch (struct decision
*start
, int depth
)
1712 struct decision
*p
= start
;
1713 enum decision_type type
= p
->tests
->type
;
1714 struct decision
*needs_label
= NULL
;
1716 /* If we have two or more nodes in sequence that test the same one
1717 thing, we may be able to use a switch statement. */
1721 || p
->next
->tests
->type
!= type
1722 || p
->next
->tests
->next
1723 || nodes_identical_1 (p
->tests
, p
->next
->tests
))
1726 /* DT_code is special in that we can do interesting things with
1727 known predicates at the same time. */
1728 if (type
== DT_code
)
1730 char codemap
[NUM_RTX_CODE
];
1731 struct decision
*ret
;
1734 memset (codemap
, 0, sizeof (codemap
));
1736 printf (" switch (GET_CODE (x%d))\n {\n", depth
);
1737 code
= p
->tests
->u
.code
;
1740 if (p
!= start
&& p
->need_label
&& needs_label
== NULL
)
1745 printf (":\n goto L%d;\n", p
->success
.first
->number
);
1746 p
->success
.first
->need_label
= 1;
1753 && p
->tests
->type
== DT_code
1754 && ! codemap
[code
= p
->tests
->u
.code
]);
1756 /* If P is testing a predicate that we know about and we haven't
1757 seen any of the codes that are valid for the predicate, we can
1758 write a series of "case" statement, one for each possible code.
1759 Since we are already in a switch, these redundant tests are very
1760 cheap and will reduce the number of predicates called. */
1762 /* Note that while we write out cases for these predicates here,
1763 we don't actually write the test here, as it gets kinda messy.
1764 It is trivial to leave this to later by telling our caller that
1765 we only processed the CODE tests. */
1766 if (needs_label
!= NULL
)
1771 while (p
&& p
->tests
->type
== DT_pred
&& p
->tests
->u
.pred
.data
)
1773 const struct pred_data
*data
= p
->tests
->u
.pred
.data
;
1776 for (c
= 0; c
< NUM_RTX_CODE
; c
++)
1777 if (codemap
[c
] && data
->codes
[c
])
1780 for (c
= 0; c
< NUM_RTX_CODE
; c
++)
1783 fputs (" case ", stdout
);
1784 print_code ((enum rtx_code
) c
);
1785 fputs (":\n", stdout
);
1789 printf (" goto L%d;\n", p
->number
);
1795 /* Make the default case skip the predicates we managed to match. */
1797 printf (" default:\n");
1802 printf (" goto L%d;\n", p
->number
);
1806 write_afterward (start
, start
->afterward
, " ");
1809 printf (" break;\n");
1814 else if (type
== DT_mode
1815 || type
== DT_veclen
1816 || type
== DT_elt_zero_int
1817 || type
== DT_elt_one_int
1818 || type
== DT_elt_zero_wide_safe
)
1820 const char *indent
= "";
1822 /* We cast switch parameter to integer, so we must ensure that the value
1824 if (type
== DT_elt_zero_wide_safe
)
1827 printf (" if ((int) XWINT (x%d, 0) == XWINT (x%d, 0))\n",
1830 printf ("%s switch (", indent
);
1834 printf ("GET_MODE (x%d)", depth
);
1837 printf ("XVECLEN (x%d, 0)", depth
);
1839 case DT_elt_zero_int
:
1840 printf ("XINT (x%d, 0)", depth
);
1842 case DT_elt_one_int
:
1843 printf ("XINT (x%d, 1)", depth
);
1845 case DT_elt_zero_wide_safe
:
1846 /* Convert result of XWINT to int for portability since some C
1847 compilers won't do it and some will. */
1848 printf ("(int) XWINT (x%d, 0)", depth
);
1853 printf (")\n%s {\n", indent
);
1857 /* Merge trees will not unify identical nodes if their
1858 sub-nodes are at different levels. Thus we must check
1859 for duplicate cases. */
1861 for (q
= start
; q
!= p
; q
= q
->next
)
1862 if (nodes_identical_1 (p
->tests
, q
->tests
))
1865 if (p
!= start
&& p
->need_label
&& needs_label
== NULL
)
1868 printf ("%s case ", indent
);
1872 printf ("%smode", GET_MODE_NAME (p
->tests
->u
.mode
));
1875 printf ("%d", p
->tests
->u
.veclen
);
1877 case DT_elt_zero_int
:
1878 case DT_elt_one_int
:
1879 case DT_elt_zero_wide
:
1880 case DT_elt_zero_wide_safe
:
1881 print_host_wide_int (p
->tests
->u
.intval
);
1886 printf (":\n%s goto L%d;\n", indent
, p
->success
.first
->number
);
1887 p
->success
.first
->need_label
= 1;
1891 while (p
&& p
->tests
->type
== type
&& !p
->tests
->next
);
1894 printf ("%s default:\n%s break;\n%s }\n",
1895 indent
, indent
, indent
);
1897 return needs_label
!= NULL
? needs_label
: p
;
1901 /* None of the other tests are amenable. */
1906 /* Emit code for one test. */
1909 write_cond (struct decision_test
*p
, int depth
,
1910 enum routine_type subroutine_type
)
1915 printf ("peep2_current_count >= %d", p
->u
.num_insns
);
1919 printf ("GET_MODE (x%d) == %smode", depth
, GET_MODE_NAME (p
->u
.mode
));
1923 printf ("GET_CODE (x%d) == ", depth
);
1924 print_code (p
->u
.code
);
1928 printf ("XVECLEN (x%d, 0) == %d", depth
, p
->u
.veclen
);
1931 case DT_elt_zero_int
:
1932 printf ("XINT (x%d, 0) == %d", depth
, (int) p
->u
.intval
);
1935 case DT_elt_one_int
:
1936 printf ("XINT (x%d, 1) == %d", depth
, (int) p
->u
.intval
);
1939 case DT_elt_zero_wide
:
1940 case DT_elt_zero_wide_safe
:
1941 printf ("XWINT (x%d, 0) == ", depth
);
1942 print_host_wide_int (p
->u
.intval
);
1946 printf ("x%d == const_int_rtx[MAX_SAVED_CONST_INT + (%d)]",
1947 depth
, (int) p
->u
.intval
);
1951 printf ("XVECLEN (x%d, 0) >= %d", depth
, p
->u
.veclen
);
1955 printf ("rtx_equal_p (x%d, operands[%d])", depth
, p
->u
.dup
);
1959 printf ("%s (x%d, %smode)", p
->u
.pred
.name
, depth
,
1960 GET_MODE_NAME (p
->u
.pred
.mode
));
1964 print_c_condition (p
->u
.c_test
);
1967 case DT_accept_insn
:
1968 gcc_assert (subroutine_type
== RECOG
);
1969 gcc_assert (p
->u
.insn
.num_clobbers_to_add
);
1970 printf ("pnum_clobbers != NULL");
1978 /* Emit code for one action. The previous tests have succeeded;
1979 TEST is the last of the chain. In the normal case we simply
1980 perform a state change. For the `accept' tests we must do more work. */
1983 write_action (struct decision
*p
, struct decision_test
*test
,
1984 int depth
, int uncond
, struct decision
*success
,
1985 enum routine_type subroutine_type
)
1992 else if (test
->type
== DT_accept_op
|| test
->type
== DT_accept_insn
)
1994 fputs (" {\n", stdout
);
2001 if (test
->type
== DT_accept_op
)
2003 printf ("%soperands[%d] = x%d;\n", indent
, test
->u
.opno
, depth
);
2005 /* Only allow DT_accept_insn to follow. */
2009 gcc_assert (test
->type
== DT_accept_insn
);
2013 /* Sanity check that we're now at the end of the list of tests. */
2014 gcc_assert (!test
->next
);
2016 if (test
->type
== DT_accept_insn
)
2018 switch (subroutine_type
)
2021 if (test
->u
.insn
.num_clobbers_to_add
!= 0)
2022 printf ("%s*pnum_clobbers = %d;\n",
2023 indent
, test
->u
.insn
.num_clobbers_to_add
);
2024 printf ("%sreturn %d; /* %s */\n", indent
,
2025 test
->u
.insn
.code_number
,
2026 get_insn_name (test
->u
.insn
.code_number
));
2030 printf ("%sreturn gen_split_%d (insn, operands);\n",
2031 indent
, test
->u
.insn
.code_number
);
2037 struct position
*pos
;
2039 for (pos
= p
->position
; pos
; pos
= pos
->base
)
2040 if (pos
->type
== POS_PEEP2_INSN
)
2042 match_len
= pos
->arg
;
2045 printf ("%s*_pmatch_len = %d;\n", indent
, match_len
);
2046 printf ("%stem = gen_peephole2_%d (insn, operands);\n",
2047 indent
, test
->u
.insn
.code_number
);
2048 printf ("%sif (tem != 0)\n%s return tem;\n", indent
, indent
);
2058 printf ("%sgoto L%d;\n", indent
, success
->number
);
2059 success
->need_label
= 1;
2063 fputs (" }\n", stdout
);
2066 /* Return 1 if the test is always true and has no fallthru path. Return -1
2067 if the test does have a fallthru path, but requires that the condition be
2068 terminated. Otherwise return 0 for a normal test. */
2069 /* ??? is_unconditional is a stupid name for a tri-state function. */
2072 is_unconditional (struct decision_test
*t
, enum routine_type subroutine_type
)
2074 if (t
->type
== DT_accept_op
)
2077 if (t
->type
== DT_accept_insn
)
2079 switch (subroutine_type
)
2082 return (t
->u
.insn
.num_clobbers_to_add
== 0);
2095 /* Emit code for one node -- the conditional and the accompanying action.
2096 Return true if there is no fallthru path. */
2099 write_node (struct decision
*p
, int depth
,
2100 enum routine_type subroutine_type
)
2102 struct decision_test
*test
, *last_test
;
2105 /* Scan the tests and simplify comparisons against small
2107 for (test
= p
->tests
; test
; test
= test
->next
)
2109 if (test
->type
== DT_code
2110 && test
->u
.code
== CONST_INT
2112 && test
->next
->type
== DT_elt_zero_wide_safe
2113 && -MAX_SAVED_CONST_INT
<= test
->next
->u
.intval
2114 && test
->next
->u
.intval
<= MAX_SAVED_CONST_INT
)
2116 test
->type
= DT_const_int
;
2117 test
->u
.intval
= test
->next
->u
.intval
;
2118 test
->next
= test
->next
->next
;
2122 last_test
= test
= p
->tests
;
2123 uncond
= is_unconditional (test
, subroutine_type
);
2127 write_cond (test
, depth
, subroutine_type
);
2129 while ((test
= test
->next
) != NULL
)
2132 if (is_unconditional (test
, subroutine_type
))
2136 write_cond (test
, depth
, subroutine_type
);
2142 write_action (p
, last_test
, depth
, uncond
, p
->success
.first
, subroutine_type
);
2147 /* Emit code for all of the sibling nodes of HEAD. */
2150 write_tree_1 (struct decision_head
*head
, int depth
,
2151 enum routine_type subroutine_type
)
2153 struct decision
*p
, *next
;
2156 for (p
= head
->first
; p
; p
= next
)
2158 /* The label for the first element was printed in write_tree. */
2159 if (p
!= head
->first
&& p
->need_label
)
2160 OUTPUT_LABEL (" ", p
->number
);
2162 /* Attempt to write a switch statement for a whole sequence. */
2163 next
= write_switch (p
, depth
);
2168 /* Failed -- fall back and write one node. */
2169 uncond
= write_node (p
, depth
, subroutine_type
);
2174 /* Finished with this chain. Close a fallthru path by branching
2175 to the afterward node. */
2177 write_afterward (head
->last
, head
->last
->afterward
, " ");
2180 /* Write out the decision tree starting at HEAD. PREVPOS is the
2181 position at the node that branched to this node. */
2184 write_tree (struct decision_head
*head
, struct position
*prevpos
,
2185 enum routine_type type
, int initial
)
2187 struct decision
*p
= head
->first
;
2191 OUTPUT_LABEL (" ", p
->number
);
2193 if (! initial
&& p
->subroutine_number
> 0)
2195 static const char * const name_prefix
[] = {
2196 "recog", "split", "peephole2"
2199 static const char * const call_suffix
[] = {
2200 ", pnum_clobbers", "", ", _pmatch_len"
2203 /* This node has been broken out into a separate subroutine.
2204 Call it, test the result, and branch accordingly. */
2208 printf (" tem = %s_%d (x0, insn%s);\n",
2209 name_prefix
[type
], p
->subroutine_number
, call_suffix
[type
]);
2210 if (IS_SPLIT (type
))
2211 printf (" if (tem != 0)\n return tem;\n");
2213 printf (" if (tem >= 0)\n return tem;\n");
2215 change_state (p
->position
, p
->afterward
->position
, " ");
2216 printf (" goto L%d;\n", p
->afterward
->number
);
2220 printf (" return %s_%d (x0, insn%s);\n",
2221 name_prefix
[type
], p
->subroutine_number
, call_suffix
[type
]);
2226 change_state (prevpos
, p
->position
, " ");
2227 write_tree_1 (head
, p
->position
->depth
, type
);
2229 for (p
= head
->first
; p
; p
= p
->next
)
2230 if (p
->success
.first
)
2231 write_tree (&p
->success
, p
->position
, type
, 0);
2235 /* Write out a subroutine of type TYPE to do comparisons starting at
2239 write_subroutine (struct decision_head
*head
, enum routine_type type
)
2241 int subfunction
= head
->first
? head
->first
->subroutine_number
: 0;
2245 const char *insn_param
;
2247 s_or_e
= subfunction
? "static " : "";
2250 sprintf (extension
, "_%d", subfunction
);
2251 else if (type
== RECOG
)
2252 extension
[0] = '\0';
2254 strcpy (extension
, "_insns");
2256 /* For now, the top-level functions take a plain "rtx", and perform a
2257 checked cast to "rtx_insn *" for use throughout the rest of the
2258 function and the code it calls. */
2259 insn_param
= subfunction
? "rtx_insn *insn" : "rtx uncast_insn";
2265 recog%s (rtx x0 ATTRIBUTE_UNUSED,\n\t%s ATTRIBUTE_UNUSED,\n\tint *pnum_clobbers ATTRIBUTE_UNUSED)\n",
2266 s_or_e
, extension
, insn_param
);
2270 split%s (rtx x0 ATTRIBUTE_UNUSED, %s ATTRIBUTE_UNUSED)\n",
2271 s_or_e
, extension
, insn_param
);
2275 peephole2%s (rtx x0 ATTRIBUTE_UNUSED,\n\t%s ATTRIBUTE_UNUSED,\n\tint *_pmatch_len ATTRIBUTE_UNUSED)\n",
2276 s_or_e
, extension
, insn_param
);
2280 printf ("{\n rtx * const operands ATTRIBUTE_UNUSED = &recog_data.operand[0];\n");
2281 for (i
= 1; i
<= max_depth
; i
++)
2282 printf (" rtx x%d ATTRIBUTE_UNUSED;\n", i
);
2284 printf (" %s tem ATTRIBUTE_UNUSED;\n", IS_SPLIT (type
) ? "rtx" : "int");
2287 printf (" recog_data.insn = NULL_RTX;\n");
2289 /* For now add the downcast to rtx_insn *, at the top of each top-level
2293 printf (" rtx_insn *insn ATTRIBUTE_UNUSED;\n");
2294 printf (" insn = safe_as_a <rtx_insn *> (uncast_insn);\n");
2298 write_tree (head
, &root_pos
, type
, 1);
2300 printf (" goto ret0;\n");
2302 printf (" ret0:\n return %d;\n}\n\n", IS_SPLIT (type
) ? 0 : -1);
2305 /* In break_out_subroutines, we discovered the boundaries for the
2306 subroutines, but did not write them out. Do so now. */
2309 write_subroutines (struct decision_head
*head
, enum routine_type type
)
2313 for (p
= head
->first
; p
; p
= p
->next
)
2314 if (p
->success
.first
)
2315 write_subroutines (&p
->success
, type
);
2317 if (head
->first
->subroutine_number
> 0)
2318 write_subroutine (head
, type
);
2321 /* Begin the output file. */
2327 /* Generated automatically by the program `genrecog' from the target\n\
2328 machine description file. */\n\
2330 #include \"config.h\"\n\
2331 #include \"system.h\"\n\
2332 #include \"coretypes.h\"\n\
2333 #include \"tm.h\"\n\
2334 #include \"rtl.h\"\n\
2335 #include \"tm_p.h\"\n\
2336 #include \"hashtab.h\"\n\
2337 #include \"hash-set.h\"\n\
2338 #include \"vec.h\"\n\
2339 #include \"machmode.h\"\n\
2340 #include \"hard-reg-set.h\"\n\
2341 #include \"input.h\"\n\
2342 #include \"function.h\"\n\
2343 #include \"insn-config.h\"\n\
2344 #include \"recog.h\"\n\
2345 #include \"output.h\"\n\
2346 #include \"flags.h\"\n\
2347 #include \"hard-reg-set.h\"\n\
2348 #include \"predict.h\"\n\
2349 #include \"basic-block.h\"\n\
2350 #include \"resource.h\"\n\
2351 #include \"diagnostic-core.h\"\n\
2352 #include \"reload.h\"\n\
2353 #include \"regs.h\"\n\
2354 #include \"tm-constrs.h\"\n\
2355 #include \"predict.h\"\n\
2359 /* `recog' contains a decision tree that recognizes whether the rtx\n\
2360 X0 is a valid instruction.\n\
2362 recog returns -1 if the rtx is not valid. If the rtx is valid, recog\n\
2363 returns a nonnegative number which is the insn code number for the\n\
2364 pattern that matched. This is the same as the order in the machine\n\
2365 description of the entry that matched. This number can be used as an\n\
2366 index into `insn_data' and other tables.\n");
2368 The third argument to recog is an optional pointer to an int. If\n\
2369 present, recog will accept a pattern if it matches except for missing\n\
2370 CLOBBER expressions at the end. In that case, the value pointed to by\n\
2371 the optional pointer will be set to the number of CLOBBERs that need\n\
2372 to be added (it should be initialized to zero by the caller). If it");
2374 is set nonzero, the caller should allocate a PARALLEL of the\n\
2375 appropriate size, copy the initial entries, and call add_clobbers\n\
2376 (found in insn-emit.c) to fill in the CLOBBERs.\n\
2380 The function split_insns returns 0 if the rtl could not\n\
2381 be split or the split rtl as an INSN list if it can be.\n\
2383 The function peephole2_insns returns 0 if the rtl could not\n\
2384 be matched. If there was a match, the new rtl is returned in an INSN list,\n\
2385 and LAST_INSN will point to the last recognized insn in the old sequence.\n\
2390 /* Construct and return a sequence of decisions
2391 that will recognize INSN.
2393 TYPE says what type of routine we are recognizing (RECOG or SPLIT). */
2395 static struct decision_head
2396 make_insn_sequence (rtx insn
, enum routine_type type
)
2399 const char *c_test
= XSTR (insn
, type
== RECOG
? 2 : 1);
2400 int truth
= maybe_eval_c_test (c_test
);
2401 struct decision
*last
;
2402 struct decision_test
*test
, **place
;
2403 struct decision_head head
;
2404 struct position
*c_test_pos
, **pos_ptr
;
2406 /* We should never see an insn whose C test is false at compile time. */
2409 c_test_pos
= &root_pos
;
2410 if (type
== PEEPHOLE2
)
2414 /* peephole2 gets special treatment:
2415 - X always gets an outer parallel even if it's only one entry
2416 - we remove all traces of outer-level match_scratch and match_dup
2417 expressions here. */
2418 x
= rtx_alloc (PARALLEL
);
2419 PUT_MODE (x
, VOIDmode
);
2420 XVEC (x
, 0) = rtvec_alloc (XVECLEN (insn
, 0));
2421 pos_ptr
= &peep2_insn_pos_list
;
2422 for (i
= j
= 0; i
< XVECLEN (insn
, 0); i
++)
2424 rtx tmp
= XVECEXP (insn
, 0, i
);
2425 if (GET_CODE (tmp
) != MATCH_SCRATCH
&& GET_CODE (tmp
) != MATCH_DUP
)
2427 c_test_pos
= next_position (pos_ptr
, &root_pos
,
2429 XVECEXP (x
, 0, j
) = tmp
;
2431 pos_ptr
= &c_test_pos
->next
;
2436 else if (XVECLEN (insn
, type
== RECOG
) == 1)
2437 x
= XVECEXP (insn
, type
== RECOG
, 0);
2440 x
= rtx_alloc (PARALLEL
);
2441 XVEC (x
, 0) = XVEC (insn
, type
== RECOG
);
2442 PUT_MODE (x
, VOIDmode
);
2445 validate_pattern (x
, insn
, NULL_RTX
, 0);
2447 memset (&head
, 0, sizeof (head
));
2448 last
= add_to_sequence (x
, &head
, &root_pos
, type
, 1);
2450 /* Find the end of the test chain on the last node. */
2451 for (test
= last
->tests
; test
->next
; test
= test
->next
)
2453 place
= &test
->next
;
2455 /* Skip the C test if it's known to be true at compile time. */
2458 /* Need a new node if we have another test to add. */
2459 if (test
->type
== DT_accept_op
)
2461 last
= new_decision (c_test_pos
, &last
->success
);
2462 place
= &last
->tests
;
2464 test
= new_decision_test (DT_c_test
, &place
);
2465 test
->u
.c_test
= c_test
;
2468 test
= new_decision_test (DT_accept_insn
, &place
);
2469 test
->u
.insn
.code_number
= next_insn_code
;
2470 test
->u
.insn
.lineno
= pattern_lineno
;
2471 test
->u
.insn
.num_clobbers_to_add
= 0;
2476 /* If this is a DEFINE_INSN and X is a PARALLEL, see if it ends
2477 with a group of CLOBBERs of (hard) registers or MATCH_SCRATCHes.
2478 If so, set up to recognize the pattern without these CLOBBERs. */
2480 if (GET_CODE (x
) == PARALLEL
)
2484 /* Find the last non-clobber in the parallel. */
2485 for (i
= XVECLEN (x
, 0); i
> 0; i
--)
2487 rtx y
= XVECEXP (x
, 0, i
- 1);
2488 if (GET_CODE (y
) != CLOBBER
2489 || (!REG_P (XEXP (y
, 0))
2490 && GET_CODE (XEXP (y
, 0)) != MATCH_SCRATCH
))
2494 if (i
!= XVECLEN (x
, 0))
2497 struct decision_head clobber_head
;
2499 /* Build a similar insn without the clobbers. */
2501 new_rtx
= XVECEXP (x
, 0, 0);
2506 new_rtx
= rtx_alloc (PARALLEL
);
2507 XVEC (new_rtx
, 0) = rtvec_alloc (i
);
2508 for (j
= i
- 1; j
>= 0; j
--)
2509 XVECEXP (new_rtx
, 0, j
) = XVECEXP (x
, 0, j
);
2513 memset (&clobber_head
, 0, sizeof (clobber_head
));
2514 last
= add_to_sequence (new_rtx
, &clobber_head
, &root_pos
,
2517 /* Find the end of the test chain on the last node. */
2518 for (test
= last
->tests
; test
->next
; test
= test
->next
)
2521 /* We definitely have a new test to add -- create a new
2523 place
= &test
->next
;
2524 if (test
->type
== DT_accept_op
)
2526 last
= new_decision (&root_pos
, &last
->success
);
2527 place
= &last
->tests
;
2530 /* Skip the C test if it's known to be true at compile
2534 test
= new_decision_test (DT_c_test
, &place
);
2535 test
->u
.c_test
= c_test
;
2538 test
= new_decision_test (DT_accept_insn
, &place
);
2539 test
->u
.insn
.code_number
= next_insn_code
;
2540 test
->u
.insn
.lineno
= pattern_lineno
;
2541 test
->u
.insn
.num_clobbers_to_add
= XVECLEN (x
, 0) - i
;
2543 merge_trees (&head
, &clobber_head
);
2549 /* Define the subroutine we will call below and emit in genemit. */
2550 printf ("extern rtx gen_split_%d (rtx_insn *, rtx *);\n", next_insn_code
);
2554 /* Define the subroutine we will call below and emit in genemit. */
2555 printf ("extern rtx gen_peephole2_%d (rtx_insn *, rtx *);\n",
2564 process_tree (struct decision_head
*head
, enum routine_type subroutine_type
)
2566 if (head
->first
== NULL
)
2568 /* We can elide peephole2_insns, but not recog or split_insns. */
2569 if (subroutine_type
== PEEPHOLE2
)
2574 factor_tests (head
);
2576 next_subroutine_number
= 0;
2577 break_out_subroutines (head
, 1);
2578 find_afterward (head
, NULL
);
2580 /* We run this after find_afterward, because find_afterward needs
2581 the redundant DT_mode tests on predicates to determine whether
2582 two tests can both be true or not. */
2583 simplify_tests (head
);
2585 write_subroutines (head
, subroutine_type
);
2588 write_subroutine (head
, subroutine_type
);
2591 extern int main (int, char **);
2594 main (int argc
, char **argv
)
2597 struct decision_head recog_tree
, split_tree
, peephole2_tree
, h
;
2599 progname
= "genrecog";
2601 memset (&recog_tree
, 0, sizeof recog_tree
);
2602 memset (&split_tree
, 0, sizeof split_tree
);
2603 memset (&peephole2_tree
, 0, sizeof peephole2_tree
);
2605 if (!init_rtx_reader_args (argc
, argv
))
2606 return (FATAL_EXIT_CODE
);
2612 /* Read the machine description. */
2616 desc
= read_md_rtx (&pattern_lineno
, &next_insn_code
);
2620 switch (GET_CODE (desc
))
2623 h
= make_insn_sequence (desc
, RECOG
);
2624 merge_trees (&recog_tree
, &h
);
2628 h
= make_insn_sequence (desc
, SPLIT
);
2629 merge_trees (&split_tree
, &h
);
2632 case DEFINE_PEEPHOLE2
:
2633 h
= make_insn_sequence (desc
, PEEPHOLE2
);
2634 merge_trees (&peephole2_tree
, &h
);
2642 return FATAL_EXIT_CODE
;
2646 process_tree (&recog_tree
, RECOG
);
2647 process_tree (&split_tree
, SPLIT
);
2648 process_tree (&peephole2_tree
, PEEPHOLE2
);
2651 return (ferror (stdout
) != 0 ? FATAL_EXIT_CODE
: SUCCESS_EXIT_CODE
);
2655 debug_decision_2 (struct decision_test
*test
)
2660 fprintf (stderr
, "num_insns=%d", test
->u
.num_insns
);
2663 fprintf (stderr
, "mode=%s", GET_MODE_NAME (test
->u
.mode
));
2666 fprintf (stderr
, "code=%s", GET_RTX_NAME (test
->u
.code
));
2669 fprintf (stderr
, "veclen=%d", test
->u
.veclen
);
2671 case DT_elt_zero_int
:
2672 fprintf (stderr
, "elt0_i=%d", (int) test
->u
.intval
);
2674 case DT_elt_one_int
:
2675 fprintf (stderr
, "elt1_i=%d", (int) test
->u
.intval
);
2677 case DT_elt_zero_wide
:
2678 fprintf (stderr
, "elt0_w=" HOST_WIDE_INT_PRINT_DEC
, test
->u
.intval
);
2680 case DT_elt_zero_wide_safe
:
2681 fprintf (stderr
, "elt0_ws=" HOST_WIDE_INT_PRINT_DEC
, test
->u
.intval
);
2684 fprintf (stderr
, "veclen>=%d", test
->u
.veclen
);
2687 fprintf (stderr
, "dup=%d", test
->u
.dup
);
2690 fprintf (stderr
, "pred=(%s,%s)",
2691 test
->u
.pred
.name
, GET_MODE_NAME (test
->u
.pred
.mode
));
2696 strncpy (sub
, test
->u
.c_test
, sizeof (sub
));
2697 memcpy (sub
+16, "...", 4);
2698 fprintf (stderr
, "c_test=\"%s\"", sub
);
2702 fprintf (stderr
, "A_op=%d", test
->u
.opno
);
2704 case DT_accept_insn
:
2705 fprintf (stderr
, "A_insn=(%d,%d)",
2706 test
->u
.insn
.code_number
, test
->u
.insn
.num_clobbers_to_add
);
2715 debug_decision_1 (struct decision
*d
, int indent
)
2718 struct decision_test
*test
;
2722 for (i
= 0; i
< indent
; ++i
)
2724 fputs ("(nil)\n", stderr
);
2728 for (i
= 0; i
< indent
; ++i
)
2735 debug_decision_2 (test
);
2736 while ((test
= test
->next
) != NULL
)
2738 fputs (" + ", stderr
);
2739 debug_decision_2 (test
);
2742 fprintf (stderr
, "} %d n %d a %d\n", d
->number
,
2743 (d
->next
? d
->next
->number
: -1),
2744 (d
->afterward
? d
->afterward
->number
: -1));
2748 debug_decision_0 (struct decision
*d
, int indent
, int maxdepth
)
2757 for (i
= 0; i
< indent
; ++i
)
2759 fputs ("(nil)\n", stderr
);
2763 debug_decision_1 (d
, indent
);
2764 for (n
= d
->success
.first
; n
; n
= n
->next
)
2765 debug_decision_0 (n
, indent
+ 2, maxdepth
- 1);
2769 debug_decision (struct decision
*d
)
2771 debug_decision_0 (d
, 0, 1000000);
2775 debug_decision_list (struct decision
*d
)
2779 debug_decision_0 (d
, 0, 0);