1 /* Subroutines used by or related to instruction recognition.
2 Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998
3 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
4 Free Software Foundation, Inc.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
25 #include "coretypes.h"
29 #include "insn-config.h"
30 #include "insn-attr.h"
31 #include "hard-reg-set.h"
34 #include "addresses.h"
40 #include "basic-block.h"
44 #include "tree-pass.h"
47 #ifndef STACK_PUSH_CODE
48 #ifdef STACK_GROWS_DOWNWARD
49 #define STACK_PUSH_CODE PRE_DEC
51 #define STACK_PUSH_CODE PRE_INC
55 #ifndef STACK_POP_CODE
56 #ifdef STACK_GROWS_DOWNWARD
57 #define STACK_POP_CODE POST_INC
59 #define STACK_POP_CODE POST_DEC
63 static void validate_replace_rtx_1 (rtx
*, rtx
, rtx
, rtx
);
64 static void validate_replace_src_1 (rtx
*, void *);
65 static rtx
split_insn (rtx
);
67 /* Nonzero means allow operands to be volatile.
68 This should be 0 if you are generating rtl, such as if you are calling
69 the functions in optabs.c and expmed.c (most of the time).
70 This should be 1 if all valid insns need to be recognized,
71 such as in regclass.c and final.c and reload.c.
73 init_recog and init_recog_no_volatile are responsible for setting this. */
77 struct recog_data recog_data
;
79 /* Contains a vector of operand_alternative structures for every operand.
80 Set up by preprocess_constraints. */
81 struct operand_alternative recog_op_alt
[MAX_RECOG_OPERANDS
][MAX_RECOG_ALTERNATIVES
];
83 /* On return from `constrain_operands', indicate which alternative
86 int which_alternative
;
88 /* Nonzero after end of reload pass.
89 Set to 1 or 0 by toplev.c.
90 Controls the significance of (SUBREG (MEM)). */
94 /* Nonzero after thread_prologue_and_epilogue_insns has run. */
95 int epilogue_completed
;
97 /* Initialize data used by the function `recog'.
98 This must be called once in the compilation of a function
99 before any insn recognition may be done in the function. */
102 init_recog_no_volatile (void)
114 /* Check that X is an insn-body for an `asm' with operands
115 and that the operands mentioned in it are legitimate. */
118 check_asm_operands (rtx x
)
122 const char **constraints
;
125 /* Post-reload, be more strict with things. */
126 if (reload_completed
)
128 /* ??? Doh! We've not got the wrapping insn. Cook one up. */
129 extract_insn (make_insn_raw (x
));
130 constrain_operands (1);
131 return which_alternative
>= 0;
134 noperands
= asm_noperands (x
);
140 operands
= alloca (noperands
* sizeof (rtx
));
141 constraints
= alloca (noperands
* sizeof (char *));
143 decode_asm_operands (x
, operands
, NULL
, constraints
, NULL
, NULL
);
145 for (i
= 0; i
< noperands
; i
++)
147 const char *c
= constraints
[i
];
150 if (ISDIGIT ((unsigned char) c
[0]) && c
[1] == '\0')
151 c
= constraints
[c
[0] - '0'];
153 if (! asm_operand_ok (operands
[i
], c
))
160 /* Static data for the next two routines. */
162 typedef struct change_t
171 static change_t
*changes
;
172 static int changes_allocated
;
174 static int num_changes
= 0;
176 /* Validate a proposed change to OBJECT. LOC is the location in the rtl
177 at which NEW will be placed. If OBJECT is zero, no validation is done,
178 the change is simply made.
180 Two types of objects are supported: If OBJECT is a MEM, memory_address_p
181 will be called with the address and mode as parameters. If OBJECT is
182 an INSN, CALL_INSN, or JUMP_INSN, the insn will be re-recognized with
185 IN_GROUP is nonzero if this is part of a group of changes that must be
186 performed as a group. In that case, the changes will be stored. The
187 function `apply_change_group' will validate and apply the changes.
189 If IN_GROUP is zero, this is a single change. Try to recognize the insn
190 or validate the memory reference with the change applied. If the result
191 is not valid for the machine, suppress the change and return zero.
192 Otherwise, perform the change and return 1. */
195 validate_change_1 (rtx object
, rtx
*loc
, rtx
new, bool in_group
, bool unshare
)
199 if (old
== new || rtx_equal_p (old
, new))
202 gcc_assert (in_group
!= 0 || num_changes
== 0);
206 /* Save the information describing this change. */
207 if (num_changes
>= changes_allocated
)
209 if (changes_allocated
== 0)
210 /* This value allows for repeated substitutions inside complex
211 indexed addresses, or changes in up to 5 insns. */
212 changes_allocated
= MAX_RECOG_OPERANDS
* 5;
214 changes_allocated
*= 2;
216 changes
= xrealloc (changes
, sizeof (change_t
) * changes_allocated
);
219 changes
[num_changes
].object
= object
;
220 changes
[num_changes
].loc
= loc
;
221 changes
[num_changes
].old
= old
;
222 changes
[num_changes
].unshare
= unshare
;
224 if (object
&& !MEM_P (object
))
226 /* Set INSN_CODE to force rerecognition of insn. Save old code in
228 changes
[num_changes
].old_code
= INSN_CODE (object
);
229 INSN_CODE (object
) = -1;
234 /* If we are making a group of changes, return 1. Otherwise, validate the
235 change group we made. */
240 return apply_change_group ();
243 /* Wrapper for validate_change_1 without the UNSHARE argument defaulting
247 validate_change (rtx object
, rtx
*loc
, rtx
new, bool in_group
)
249 return validate_change_1 (object
, loc
, new, in_group
, false);
252 /* Wrapper for validate_change_1 without the UNSHARE argument defaulting
256 validate_unshare_change (rtx object
, rtx
*loc
, rtx
new, bool in_group
)
258 return validate_change_1 (object
, loc
, new, in_group
, true);
262 /* Keep X canonicalized if some changes have made it non-canonical; only
263 modifies the operands of X, not (for example) its code. Simplifications
264 are not the job of this routine.
266 Return true if anything was changed. */
268 canonicalize_change_group (rtx insn
, rtx x
)
270 if (COMMUTATIVE_P (x
)
271 && swap_commutative_operands_p (XEXP (x
, 0), XEXP (x
, 1)))
273 /* Oops, the caller has made X no longer canonical.
274 Let's redo the changes in the correct order. */
275 rtx tem
= XEXP (x
, 0);
276 validate_change (insn
, &XEXP (x
, 0), XEXP (x
, 1), 1);
277 validate_change (insn
, &XEXP (x
, 1), tem
, 1);
285 /* This subroutine of apply_change_group verifies whether the changes to INSN
286 were valid; i.e. whether INSN can still be recognized. */
289 insn_invalid_p (rtx insn
)
291 rtx pat
= PATTERN (insn
);
292 int num_clobbers
= 0;
293 /* If we are before reload and the pattern is a SET, see if we can add
295 int icode
= recog (pat
, insn
,
296 (GET_CODE (pat
) == SET
297 && ! reload_completed
&& ! reload_in_progress
)
298 ? &num_clobbers
: 0);
299 int is_asm
= icode
< 0 && asm_noperands (PATTERN (insn
)) >= 0;
302 /* If this is an asm and the operand aren't legal, then fail. Likewise if
303 this is not an asm and the insn wasn't recognized. */
304 if ((is_asm
&& ! check_asm_operands (PATTERN (insn
)))
305 || (!is_asm
&& icode
< 0))
308 /* If we have to add CLOBBERs, fail if we have to add ones that reference
309 hard registers since our callers can't know if they are live or not.
310 Otherwise, add them. */
311 if (num_clobbers
> 0)
315 if (added_clobbers_hard_reg_p (icode
))
318 newpat
= gen_rtx_PARALLEL (VOIDmode
, rtvec_alloc (num_clobbers
+ 1));
319 XVECEXP (newpat
, 0, 0) = pat
;
320 add_clobbers (newpat
, icode
);
321 PATTERN (insn
) = pat
= newpat
;
324 /* After reload, verify that all constraints are satisfied. */
325 if (reload_completed
)
329 if (! constrain_operands (1))
333 INSN_CODE (insn
) = icode
;
337 /* Return number of changes made and not validated yet. */
339 num_changes_pending (void)
344 /* Tentatively apply the changes numbered NUM and up.
345 Return 1 if all changes are valid, zero otherwise. */
348 verify_changes (int num
)
351 rtx last_validated
= NULL_RTX
;
353 /* The changes have been applied and all INSN_CODEs have been reset to force
356 The changes are valid if we aren't given an object, or if we are
357 given a MEM and it still is a valid address, or if this is in insn
358 and it is recognized. In the latter case, if reload has completed,
359 we also require that the operands meet the constraints for
362 for (i
= num
; i
< num_changes
; i
++)
364 rtx object
= changes
[i
].object
;
366 /* If there is no object to test or if it is the same as the one we
367 already tested, ignore it. */
368 if (object
== 0 || object
== last_validated
)
373 if (! memory_address_p (GET_MODE (object
), XEXP (object
, 0)))
376 else if (insn_invalid_p (object
))
378 rtx pat
= PATTERN (object
);
380 /* Perhaps we couldn't recognize the insn because there were
381 extra CLOBBERs at the end. If so, try to re-recognize
382 without the last CLOBBER (later iterations will cause each of
383 them to be eliminated, in turn). But don't do this if we
384 have an ASM_OPERAND. */
385 if (GET_CODE (pat
) == PARALLEL
386 && GET_CODE (XVECEXP (pat
, 0, XVECLEN (pat
, 0) - 1)) == CLOBBER
387 && asm_noperands (PATTERN (object
)) < 0)
391 if (XVECLEN (pat
, 0) == 2)
392 newpat
= XVECEXP (pat
, 0, 0);
398 = gen_rtx_PARALLEL (VOIDmode
,
399 rtvec_alloc (XVECLEN (pat
, 0) - 1));
400 for (j
= 0; j
< XVECLEN (newpat
, 0); j
++)
401 XVECEXP (newpat
, 0, j
) = XVECEXP (pat
, 0, j
);
404 /* Add a new change to this group to replace the pattern
405 with this new pattern. Then consider this change
406 as having succeeded. The change we added will
407 cause the entire call to fail if things remain invalid.
409 Note that this can lose if a later change than the one
410 we are processing specified &XVECEXP (PATTERN (object), 0, X)
411 but this shouldn't occur. */
413 validate_change (object
, &PATTERN (object
), newpat
, 1);
416 else if (GET_CODE (pat
) == USE
|| GET_CODE (pat
) == CLOBBER
)
417 /* If this insn is a CLOBBER or USE, it is always valid, but is
423 last_validated
= object
;
426 return (i
== num_changes
);
429 /* A group of changes has previously been issued with validate_change
430 and verified with verify_changes. Call df_insn_rescan for each of
431 the insn changed and clear num_changes. */
434 confirm_change_group (void)
437 rtx last_object
= NULL
;
439 for (i
= 0; i
< num_changes
; i
++)
441 rtx object
= changes
[i
].object
;
443 if (changes
[i
].unshare
)
444 *changes
[i
].loc
= copy_rtx (*changes
[i
].loc
);
446 /* Avoid unnecesary rescanning when multiple changes to same instruction
450 if (object
!= last_object
&& last_object
&& INSN_P (last_object
))
451 df_insn_rescan (last_object
);
452 last_object
= object
;
456 if (last_object
&& INSN_P (last_object
))
457 df_insn_rescan (last_object
);
461 /* Apply a group of changes previously issued with `validate_change'.
462 If all changes are valid, call confirm_change_group and return 1,
463 otherwise, call cancel_changes and return 0. */
466 apply_change_group (void)
468 if (verify_changes (0))
470 confirm_change_group ();
481 /* Return the number of changes so far in the current group. */
484 num_validated_changes (void)
489 /* Retract the changes numbered NUM and up. */
492 cancel_changes (int num
)
496 /* Back out all the changes. Do this in the opposite order in which
498 for (i
= num_changes
- 1; i
>= num
; i
--)
500 *changes
[i
].loc
= changes
[i
].old
;
501 if (changes
[i
].object
&& !MEM_P (changes
[i
].object
))
502 INSN_CODE (changes
[i
].object
) = changes
[i
].old_code
;
507 /* Replace every occurrence of FROM in X with TO. Mark each change with
508 validate_change passing OBJECT. */
511 validate_replace_rtx_1 (rtx
*loc
, rtx from
, rtx to
, rtx object
)
517 enum machine_mode op0_mode
= VOIDmode
;
518 int prev_changes
= num_changes
;
525 fmt
= GET_RTX_FORMAT (code
);
527 op0_mode
= GET_MODE (XEXP (x
, 0));
529 /* X matches FROM if it is the same rtx or they are both referring to the
530 same register in the same mode. Avoid calling rtx_equal_p unless the
531 operands look similar. */
534 || (REG_P (x
) && REG_P (from
)
535 && GET_MODE (x
) == GET_MODE (from
)
536 && REGNO (x
) == REGNO (from
))
537 || (GET_CODE (x
) == GET_CODE (from
) && GET_MODE (x
) == GET_MODE (from
)
538 && rtx_equal_p (x
, from
)))
540 validate_unshare_change (object
, loc
, to
, 1);
544 /* Call ourself recursively to perform the replacements.
545 We must not replace inside already replaced expression, otherwise we
546 get infinite recursion for replacements like (reg X)->(subreg (reg X))
547 done by regmove, so we must special case shared ASM_OPERANDS. */
549 if (GET_CODE (x
) == PARALLEL
)
551 for (j
= XVECLEN (x
, 0) - 1; j
>= 0; j
--)
553 if (j
&& GET_CODE (XVECEXP (x
, 0, j
)) == SET
554 && GET_CODE (SET_SRC (XVECEXP (x
, 0, j
))) == ASM_OPERANDS
)
556 /* Verify that operands are really shared. */
557 gcc_assert (ASM_OPERANDS_INPUT_VEC (SET_SRC (XVECEXP (x
, 0, 0)))
558 == ASM_OPERANDS_INPUT_VEC (SET_SRC (XVECEXP
560 validate_replace_rtx_1 (&SET_DEST (XVECEXP (x
, 0, j
)),
564 validate_replace_rtx_1 (&XVECEXP (x
, 0, j
), from
, to
, object
);
568 for (i
= GET_RTX_LENGTH (code
) - 1; i
>= 0; i
--)
571 validate_replace_rtx_1 (&XEXP (x
, i
), from
, to
, object
);
572 else if (fmt
[i
] == 'E')
573 for (j
= XVECLEN (x
, i
) - 1; j
>= 0; j
--)
574 validate_replace_rtx_1 (&XVECEXP (x
, i
, j
), from
, to
, object
);
577 /* If we didn't substitute, there is nothing more to do. */
578 if (num_changes
== prev_changes
)
581 /* Allow substituted expression to have different mode. This is used by
582 regmove to change mode of pseudo register. */
583 if (fmt
[0] == 'e' && GET_MODE (XEXP (x
, 0)) != VOIDmode
)
584 op0_mode
= GET_MODE (XEXP (x
, 0));
586 /* Do changes needed to keep rtx consistent. Don't do any other
587 simplifications, as it is not our job. */
589 if (SWAPPABLE_OPERANDS_P (x
)
590 && swap_commutative_operands_p (XEXP (x
, 0), XEXP (x
, 1)))
592 validate_change (object
, loc
,
593 gen_rtx_fmt_ee (COMMUTATIVE_ARITH_P (x
) ? code
594 : swap_condition (code
),
595 GET_MODE (x
), XEXP (x
, 1),
604 /* If we have a PLUS whose second operand is now a CONST_INT, use
605 simplify_gen_binary to try to simplify it.
606 ??? We may want later to remove this, once simplification is
607 separated from this function. */
608 if (GET_CODE (XEXP (x
, 1)) == CONST_INT
&& XEXP (x
, 1) == to
)
609 validate_change (object
, loc
,
611 (PLUS
, GET_MODE (x
), XEXP (x
, 0), XEXP (x
, 1)), 1);
614 if (GET_CODE (XEXP (x
, 1)) == CONST_INT
615 || GET_CODE (XEXP (x
, 1)) == CONST_DOUBLE
)
616 validate_change (object
, loc
,
618 (PLUS
, GET_MODE (x
), XEXP (x
, 0),
619 simplify_gen_unary (NEG
,
620 GET_MODE (x
), XEXP (x
, 1),
625 if (GET_MODE (XEXP (x
, 0)) == VOIDmode
)
627 new = simplify_gen_unary (code
, GET_MODE (x
), XEXP (x
, 0),
629 /* If any of the above failed, substitute in something that
630 we know won't be recognized. */
632 new = gen_rtx_CLOBBER (GET_MODE (x
), const0_rtx
);
633 validate_change (object
, loc
, new, 1);
637 /* All subregs possible to simplify should be simplified. */
638 new = simplify_subreg (GET_MODE (x
), SUBREG_REG (x
), op0_mode
,
641 /* Subregs of VOIDmode operands are incorrect. */
642 if (!new && GET_MODE (SUBREG_REG (x
)) == VOIDmode
)
643 new = gen_rtx_CLOBBER (GET_MODE (x
), const0_rtx
);
645 validate_change (object
, loc
, new, 1);
649 /* If we are replacing a register with memory, try to change the memory
650 to be the mode required for memory in extract operations (this isn't
651 likely to be an insertion operation; if it was, nothing bad will
652 happen, we might just fail in some cases). */
654 if (MEM_P (XEXP (x
, 0))
655 && GET_CODE (XEXP (x
, 1)) == CONST_INT
656 && GET_CODE (XEXP (x
, 2)) == CONST_INT
657 && !mode_dependent_address_p (XEXP (XEXP (x
, 0), 0))
658 && !MEM_VOLATILE_P (XEXP (x
, 0)))
660 enum machine_mode wanted_mode
= VOIDmode
;
661 enum machine_mode is_mode
= GET_MODE (XEXP (x
, 0));
662 int pos
= INTVAL (XEXP (x
, 2));
664 if (GET_CODE (x
) == ZERO_EXTRACT
)
666 enum machine_mode new_mode
667 = mode_for_extraction (EP_extzv
, 1);
668 if (new_mode
!= MAX_MACHINE_MODE
)
669 wanted_mode
= new_mode
;
671 else if (GET_CODE (x
) == SIGN_EXTRACT
)
673 enum machine_mode new_mode
674 = mode_for_extraction (EP_extv
, 1);
675 if (new_mode
!= MAX_MACHINE_MODE
)
676 wanted_mode
= new_mode
;
679 /* If we have a narrower mode, we can do something. */
680 if (wanted_mode
!= VOIDmode
681 && GET_MODE_SIZE (wanted_mode
) < GET_MODE_SIZE (is_mode
))
683 int offset
= pos
/ BITS_PER_UNIT
;
686 /* If the bytes and bits are counted differently, we
687 must adjust the offset. */
688 if (BYTES_BIG_ENDIAN
!= BITS_BIG_ENDIAN
)
690 (GET_MODE_SIZE (is_mode
) - GET_MODE_SIZE (wanted_mode
) -
693 pos
%= GET_MODE_BITSIZE (wanted_mode
);
695 newmem
= adjust_address_nv (XEXP (x
, 0), wanted_mode
, offset
);
697 validate_change (object
, &XEXP (x
, 2), GEN_INT (pos
), 1);
698 validate_change (object
, &XEXP (x
, 0), newmem
, 1);
709 /* Try replacing every occurrence of FROM in INSN with TO. After all
710 changes have been made, validate by seeing if INSN is still valid. */
713 validate_replace_rtx (rtx from
, rtx to
, rtx insn
)
715 validate_replace_rtx_1 (&PATTERN (insn
), from
, to
, insn
);
716 return apply_change_group ();
719 /* Try replacing every occurrence of FROM in INSN with TO. */
722 validate_replace_rtx_group (rtx from
, rtx to
, rtx insn
)
724 validate_replace_rtx_1 (&PATTERN (insn
), from
, to
, insn
);
727 /* Function called by note_uses to replace used subexpressions. */
728 struct validate_replace_src_data
730 rtx from
; /* Old RTX */
731 rtx to
; /* New RTX */
732 rtx insn
; /* Insn in which substitution is occurring. */
736 validate_replace_src_1 (rtx
*x
, void *data
)
738 struct validate_replace_src_data
*d
739 = (struct validate_replace_src_data
*) data
;
741 validate_replace_rtx_1 (x
, d
->from
, d
->to
, d
->insn
);
744 /* Try replacing every occurrence of FROM in INSN with TO, avoiding
748 validate_replace_src_group (rtx from
, rtx to
, rtx insn
)
750 struct validate_replace_src_data d
;
755 note_uses (&PATTERN (insn
), validate_replace_src_1
, &d
);
758 /* Try simplify INSN.
759 Invoke simplify_rtx () on every SET_SRC and SET_DEST inside the INSN's
760 pattern and return true if something was simplified. */
763 validate_simplify_insn (rtx insn
)
769 pat
= PATTERN (insn
);
771 if (GET_CODE (pat
) == SET
)
773 newpat
= simplify_rtx (SET_SRC (pat
));
774 if (newpat
&& !rtx_equal_p (SET_SRC (pat
), newpat
))
775 validate_change (insn
, &SET_SRC (pat
), newpat
, 1);
776 newpat
= simplify_rtx (SET_DEST (pat
));
777 if (newpat
&& !rtx_equal_p (SET_DEST (pat
), newpat
))
778 validate_change (insn
, &SET_DEST (pat
), newpat
, 1);
780 else if (GET_CODE (pat
) == PARALLEL
)
781 for (i
= 0; i
< XVECLEN (pat
, 0); i
++)
783 rtx s
= XVECEXP (pat
, 0, i
);
785 if (GET_CODE (XVECEXP (pat
, 0, i
)) == SET
)
787 newpat
= simplify_rtx (SET_SRC (s
));
788 if (newpat
&& !rtx_equal_p (SET_SRC (s
), newpat
))
789 validate_change (insn
, &SET_SRC (s
), newpat
, 1);
790 newpat
= simplify_rtx (SET_DEST (s
));
791 if (newpat
&& !rtx_equal_p (SET_DEST (s
), newpat
))
792 validate_change (insn
, &SET_DEST (s
), newpat
, 1);
795 return ((num_changes_pending () > 0) && (apply_change_group () > 0));
799 /* Return 1 if the insn using CC0 set by INSN does not contain
800 any ordered tests applied to the condition codes.
801 EQ and NE tests do not count. */
804 next_insn_tests_no_inequality (rtx insn
)
806 rtx next
= next_cc0_user (insn
);
808 /* If there is no next insn, we have to take the conservative choice. */
812 return (INSN_P (next
)
813 && ! inequality_comparisons_p (PATTERN (next
)));
817 /* Return 1 if OP is a valid general operand for machine mode MODE.
818 This is either a register reference, a memory reference,
819 or a constant. In the case of a memory reference, the address
820 is checked for general validity for the target machine.
822 Register and memory references must have mode MODE in order to be valid,
823 but some constants have no machine mode and are valid for any mode.
825 If MODE is VOIDmode, OP is checked for validity for whatever mode
828 The main use of this function is as a predicate in match_operand
829 expressions in the machine description.
831 For an explanation of this function's behavior for registers of
832 class NO_REGS, see the comment for `register_operand'. */
835 general_operand (rtx op
, enum machine_mode mode
)
837 enum rtx_code code
= GET_CODE (op
);
839 if (mode
== VOIDmode
)
840 mode
= GET_MODE (op
);
842 /* Don't accept CONST_INT or anything similar
843 if the caller wants something floating. */
844 if (GET_MODE (op
) == VOIDmode
&& mode
!= VOIDmode
845 && GET_MODE_CLASS (mode
) != MODE_INT
846 && GET_MODE_CLASS (mode
) != MODE_PARTIAL_INT
)
849 if (GET_CODE (op
) == CONST_INT
851 && trunc_int_for_mode (INTVAL (op
), mode
) != INTVAL (op
))
855 return ((GET_MODE (op
) == VOIDmode
|| GET_MODE (op
) == mode
857 && (! flag_pic
|| LEGITIMATE_PIC_OPERAND_P (op
))
858 && LEGITIMATE_CONSTANT_P (op
));
860 /* Except for certain constants with VOIDmode, already checked for,
861 OP's mode must match MODE if MODE specifies a mode. */
863 if (GET_MODE (op
) != mode
)
868 rtx sub
= SUBREG_REG (op
);
870 #ifdef INSN_SCHEDULING
871 /* On machines that have insn scheduling, we want all memory
872 reference to be explicit, so outlaw paradoxical SUBREGs.
873 However, we must allow them after reload so that they can
874 get cleaned up by cleanup_subreg_operands. */
875 if (!reload_completed
&& MEM_P (sub
)
876 && GET_MODE_SIZE (mode
) > GET_MODE_SIZE (GET_MODE (sub
)))
879 /* Avoid memories with nonzero SUBREG_BYTE, as offsetting the memory
880 may result in incorrect reference. We should simplify all valid
881 subregs of MEM anyway. But allow this after reload because we
882 might be called from cleanup_subreg_operands.
884 ??? This is a kludge. */
885 if (!reload_completed
&& SUBREG_BYTE (op
) != 0
889 /* FLOAT_MODE subregs can't be paradoxical. Combine will occasionally
890 create such rtl, and we must reject it. */
891 if (SCALAR_FLOAT_MODE_P (GET_MODE (op
))
892 && GET_MODE_SIZE (GET_MODE (op
)) > GET_MODE_SIZE (GET_MODE (sub
)))
896 code
= GET_CODE (op
);
900 /* A register whose class is NO_REGS is not a general operand. */
901 return (REGNO (op
) >= FIRST_PSEUDO_REGISTER
902 || REGNO_REG_CLASS (REGNO (op
)) != NO_REGS
);
906 rtx y
= XEXP (op
, 0);
908 if (! volatile_ok
&& MEM_VOLATILE_P (op
))
911 /* Use the mem's mode, since it will be reloaded thus. */
912 if (memory_address_p (GET_MODE (op
), y
))
919 /* Return 1 if OP is a valid memory address for a memory reference
922 The main use of this function is as a predicate in match_operand
923 expressions in the machine description. */
926 address_operand (rtx op
, enum machine_mode mode
)
928 return memory_address_p (mode
, op
);
931 /* Return 1 if OP is a register reference of mode MODE.
932 If MODE is VOIDmode, accept a register in any mode.
934 The main use of this function is as a predicate in match_operand
935 expressions in the machine description.
937 As a special exception, registers whose class is NO_REGS are
938 not accepted by `register_operand'. The reason for this change
939 is to allow the representation of special architecture artifacts
940 (such as a condition code register) without extending the rtl
941 definitions. Since registers of class NO_REGS cannot be used
942 as registers in any case where register classes are examined,
943 it is most consistent to keep this function from accepting them. */
946 register_operand (rtx op
, enum machine_mode mode
)
948 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
951 if (GET_CODE (op
) == SUBREG
)
953 rtx sub
= SUBREG_REG (op
);
955 /* Before reload, we can allow (SUBREG (MEM...)) as a register operand
956 because it is guaranteed to be reloaded into one.
957 Just make sure the MEM is valid in itself.
958 (Ideally, (SUBREG (MEM)...) should not exist after reload,
959 but currently it does result from (SUBREG (REG)...) where the
960 reg went on the stack.) */
961 if (! reload_completed
&& MEM_P (sub
))
962 return general_operand (op
, mode
);
964 #ifdef CANNOT_CHANGE_MODE_CLASS
966 && REGNO (sub
) < FIRST_PSEUDO_REGISTER
967 && REG_CANNOT_CHANGE_MODE_P (REGNO (sub
), GET_MODE (sub
), mode
)
968 && GET_MODE_CLASS (GET_MODE (sub
)) != MODE_COMPLEX_INT
969 && GET_MODE_CLASS (GET_MODE (sub
)) != MODE_COMPLEX_FLOAT
)
973 /* FLOAT_MODE subregs can't be paradoxical. Combine will occasionally
974 create such rtl, and we must reject it. */
975 if (SCALAR_FLOAT_MODE_P (GET_MODE (op
))
976 && GET_MODE_SIZE (GET_MODE (op
)) > GET_MODE_SIZE (GET_MODE (sub
)))
982 /* We don't consider registers whose class is NO_REGS
983 to be a register operand. */
985 && (REGNO (op
) >= FIRST_PSEUDO_REGISTER
986 || REGNO_REG_CLASS (REGNO (op
)) != NO_REGS
));
989 /* Return 1 for a register in Pmode; ignore the tested mode. */
992 pmode_register_operand (rtx op
, enum machine_mode mode ATTRIBUTE_UNUSED
)
994 return register_operand (op
, Pmode
);
997 /* Return 1 if OP should match a MATCH_SCRATCH, i.e., if it is a SCRATCH
998 or a hard register. */
1001 scratch_operand (rtx op
, enum machine_mode mode
)
1003 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
1006 return (GET_CODE (op
) == SCRATCH
1008 && REGNO (op
) < FIRST_PSEUDO_REGISTER
));
1011 /* Return 1 if OP is a valid immediate operand for mode MODE.
1013 The main use of this function is as a predicate in match_operand
1014 expressions in the machine description. */
1017 immediate_operand (rtx op
, enum machine_mode mode
)
1019 /* Don't accept CONST_INT or anything similar
1020 if the caller wants something floating. */
1021 if (GET_MODE (op
) == VOIDmode
&& mode
!= VOIDmode
1022 && GET_MODE_CLASS (mode
) != MODE_INT
1023 && GET_MODE_CLASS (mode
) != MODE_PARTIAL_INT
)
1026 if (GET_CODE (op
) == CONST_INT
1028 && trunc_int_for_mode (INTVAL (op
), mode
) != INTVAL (op
))
1031 return (CONSTANT_P (op
)
1032 && (GET_MODE (op
) == mode
|| mode
== VOIDmode
1033 || GET_MODE (op
) == VOIDmode
)
1034 && (! flag_pic
|| LEGITIMATE_PIC_OPERAND_P (op
))
1035 && LEGITIMATE_CONSTANT_P (op
));
1038 /* Returns 1 if OP is an operand that is a CONST_INT. */
1041 const_int_operand (rtx op
, enum machine_mode mode
)
1043 if (GET_CODE (op
) != CONST_INT
)
1046 if (mode
!= VOIDmode
1047 && trunc_int_for_mode (INTVAL (op
), mode
) != INTVAL (op
))
1053 /* Returns 1 if OP is an operand that is a constant integer or constant
1054 floating-point number. */
1057 const_double_operand (rtx op
, enum machine_mode mode
)
1059 /* Don't accept CONST_INT or anything similar
1060 if the caller wants something floating. */
1061 if (GET_MODE (op
) == VOIDmode
&& mode
!= VOIDmode
1062 && GET_MODE_CLASS (mode
) != MODE_INT
1063 && GET_MODE_CLASS (mode
) != MODE_PARTIAL_INT
)
1066 return ((GET_CODE (op
) == CONST_DOUBLE
|| GET_CODE (op
) == CONST_INT
)
1067 && (mode
== VOIDmode
|| GET_MODE (op
) == mode
1068 || GET_MODE (op
) == VOIDmode
));
1071 /* Return 1 if OP is a general operand that is not an immediate operand. */
1074 nonimmediate_operand (rtx op
, enum machine_mode mode
)
1076 return (general_operand (op
, mode
) && ! CONSTANT_P (op
));
1079 /* Return 1 if OP is a register reference or immediate value of mode MODE. */
1082 nonmemory_operand (rtx op
, enum machine_mode mode
)
1084 if (CONSTANT_P (op
))
1086 /* Don't accept CONST_INT or anything similar
1087 if the caller wants something floating. */
1088 if (GET_MODE (op
) == VOIDmode
&& mode
!= VOIDmode
1089 && GET_MODE_CLASS (mode
) != MODE_INT
1090 && GET_MODE_CLASS (mode
) != MODE_PARTIAL_INT
)
1093 if (GET_CODE (op
) == CONST_INT
1095 && trunc_int_for_mode (INTVAL (op
), mode
) != INTVAL (op
))
1098 return ((GET_MODE (op
) == VOIDmode
|| GET_MODE (op
) == mode
1099 || mode
== VOIDmode
)
1100 && (! flag_pic
|| LEGITIMATE_PIC_OPERAND_P (op
))
1101 && LEGITIMATE_CONSTANT_P (op
));
1104 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
1107 if (GET_CODE (op
) == SUBREG
)
1109 /* Before reload, we can allow (SUBREG (MEM...)) as a register operand
1110 because it is guaranteed to be reloaded into one.
1111 Just make sure the MEM is valid in itself.
1112 (Ideally, (SUBREG (MEM)...) should not exist after reload,
1113 but currently it does result from (SUBREG (REG)...) where the
1114 reg went on the stack.) */
1115 if (! reload_completed
&& MEM_P (SUBREG_REG (op
)))
1116 return general_operand (op
, mode
);
1117 op
= SUBREG_REG (op
);
1120 /* We don't consider registers whose class is NO_REGS
1121 to be a register operand. */
1123 && (REGNO (op
) >= FIRST_PSEUDO_REGISTER
1124 || REGNO_REG_CLASS (REGNO (op
)) != NO_REGS
));
1127 /* Return 1 if OP is a valid operand that stands for pushing a
1128 value of mode MODE onto the stack.
1130 The main use of this function is as a predicate in match_operand
1131 expressions in the machine description. */
1134 push_operand (rtx op
, enum machine_mode mode
)
1136 unsigned int rounded_size
= GET_MODE_SIZE (mode
);
1138 #ifdef PUSH_ROUNDING
1139 rounded_size
= PUSH_ROUNDING (rounded_size
);
1145 if (mode
!= VOIDmode
&& GET_MODE (op
) != mode
)
1150 if (rounded_size
== GET_MODE_SIZE (mode
))
1152 if (GET_CODE (op
) != STACK_PUSH_CODE
)
1157 if (GET_CODE (op
) != PRE_MODIFY
1158 || GET_CODE (XEXP (op
, 1)) != PLUS
1159 || XEXP (XEXP (op
, 1), 0) != XEXP (op
, 0)
1160 || GET_CODE (XEXP (XEXP (op
, 1), 1)) != CONST_INT
1161 #ifdef STACK_GROWS_DOWNWARD
1162 || INTVAL (XEXP (XEXP (op
, 1), 1)) != - (int) rounded_size
1164 || INTVAL (XEXP (XEXP (op
, 1), 1)) != (int) rounded_size
1170 return XEXP (op
, 0) == stack_pointer_rtx
;
1173 /* Return 1 if OP is a valid operand that stands for popping a
1174 value of mode MODE off the stack.
1176 The main use of this function is as a predicate in match_operand
1177 expressions in the machine description. */
1180 pop_operand (rtx op
, enum machine_mode mode
)
1185 if (mode
!= VOIDmode
&& GET_MODE (op
) != mode
)
1190 if (GET_CODE (op
) != STACK_POP_CODE
)
1193 return XEXP (op
, 0) == stack_pointer_rtx
;
1196 /* Return 1 if ADDR is a valid memory address for mode MODE. */
1199 memory_address_p (enum machine_mode mode ATTRIBUTE_UNUSED
, rtx addr
)
1201 GO_IF_LEGITIMATE_ADDRESS (mode
, addr
, win
);
1208 /* Return 1 if OP is a valid memory reference with mode MODE,
1209 including a valid address.
1211 The main use of this function is as a predicate in match_operand
1212 expressions in the machine description. */
1215 memory_operand (rtx op
, enum machine_mode mode
)
1219 if (! reload_completed
)
1220 /* Note that no SUBREG is a memory operand before end of reload pass,
1221 because (SUBREG (MEM...)) forces reloading into a register. */
1222 return MEM_P (op
) && general_operand (op
, mode
);
1224 if (mode
!= VOIDmode
&& GET_MODE (op
) != mode
)
1228 if (GET_CODE (inner
) == SUBREG
)
1229 inner
= SUBREG_REG (inner
);
1231 return (MEM_P (inner
) && general_operand (op
, mode
));
1234 /* Return 1 if OP is a valid indirect memory reference with mode MODE;
1235 that is, a memory reference whose address is a general_operand. */
1238 indirect_operand (rtx op
, enum machine_mode mode
)
1240 /* Before reload, a SUBREG isn't in memory (see memory_operand, above). */
1241 if (! reload_completed
1242 && GET_CODE (op
) == SUBREG
&& MEM_P (SUBREG_REG (op
)))
1244 int offset
= SUBREG_BYTE (op
);
1245 rtx inner
= SUBREG_REG (op
);
1247 if (mode
!= VOIDmode
&& GET_MODE (op
) != mode
)
1250 /* The only way that we can have a general_operand as the resulting
1251 address is if OFFSET is zero and the address already is an operand
1252 or if the address is (plus Y (const_int -OFFSET)) and Y is an
1255 return ((offset
== 0 && general_operand (XEXP (inner
, 0), Pmode
))
1256 || (GET_CODE (XEXP (inner
, 0)) == PLUS
1257 && GET_CODE (XEXP (XEXP (inner
, 0), 1)) == CONST_INT
1258 && INTVAL (XEXP (XEXP (inner
, 0), 1)) == -offset
1259 && general_operand (XEXP (XEXP (inner
, 0), 0), Pmode
)));
1263 && memory_operand (op
, mode
)
1264 && general_operand (XEXP (op
, 0), Pmode
));
1267 /* Return 1 if this is a comparison operator. This allows the use of
1268 MATCH_OPERATOR to recognize all the branch insns. */
1271 comparison_operator (rtx op
, enum machine_mode mode
)
1273 return ((mode
== VOIDmode
|| GET_MODE (op
) == mode
)
1274 && COMPARISON_P (op
));
1277 /* If BODY is an insn body that uses ASM_OPERANDS,
1278 return the number of operands (both input and output) in the insn.
1279 Otherwise return -1. */
1282 asm_noperands (const_rtx body
)
1284 switch (GET_CODE (body
))
1287 /* No output operands: return number of input operands. */
1288 return ASM_OPERANDS_INPUT_LENGTH (body
);
1290 if (GET_CODE (SET_SRC (body
)) == ASM_OPERANDS
)
1291 /* Single output operand: BODY is (set OUTPUT (asm_operands ...)). */
1292 return ASM_OPERANDS_INPUT_LENGTH (SET_SRC (body
)) + 1;
1296 if (GET_CODE (XVECEXP (body
, 0, 0)) == SET
1297 && GET_CODE (SET_SRC (XVECEXP (body
, 0, 0))) == ASM_OPERANDS
)
1299 /* Multiple output operands, or 1 output plus some clobbers:
1300 body is [(set OUTPUT (asm_operands ...))... (clobber (reg ...))...]. */
1304 /* Count backwards through CLOBBERs to determine number of SETs. */
1305 for (i
= XVECLEN (body
, 0); i
> 0; i
--)
1307 if (GET_CODE (XVECEXP (body
, 0, i
- 1)) == SET
)
1309 if (GET_CODE (XVECEXP (body
, 0, i
- 1)) != CLOBBER
)
1313 /* N_SETS is now number of output operands. */
1316 /* Verify that all the SETs we have
1317 came from a single original asm_operands insn
1318 (so that invalid combinations are blocked). */
1319 for (i
= 0; i
< n_sets
; i
++)
1321 rtx elt
= XVECEXP (body
, 0, i
);
1322 if (GET_CODE (elt
) != SET
)
1324 if (GET_CODE (SET_SRC (elt
)) != ASM_OPERANDS
)
1326 /* If these ASM_OPERANDS rtx's came from different original insns
1327 then they aren't allowed together. */
1328 if (ASM_OPERANDS_INPUT_VEC (SET_SRC (elt
))
1329 != ASM_OPERANDS_INPUT_VEC (SET_SRC (XVECEXP (body
, 0, 0))))
1332 return (ASM_OPERANDS_INPUT_LENGTH (SET_SRC (XVECEXP (body
, 0, 0)))
1335 else if (GET_CODE (XVECEXP (body
, 0, 0)) == ASM_OPERANDS
)
1337 /* 0 outputs, but some clobbers:
1338 body is [(asm_operands ...) (clobber (reg ...))...]. */
1341 /* Make sure all the other parallel things really are clobbers. */
1342 for (i
= XVECLEN (body
, 0) - 1; i
> 0; i
--)
1343 if (GET_CODE (XVECEXP (body
, 0, i
)) != CLOBBER
)
1346 return ASM_OPERANDS_INPUT_LENGTH (XVECEXP (body
, 0, 0));
1355 /* Assuming BODY is an insn body that uses ASM_OPERANDS,
1356 copy its operands (both input and output) into the vector OPERANDS,
1357 the locations of the operands within the insn into the vector OPERAND_LOCS,
1358 and the constraints for the operands into CONSTRAINTS.
1359 Write the modes of the operands into MODES.
1360 Return the assembler-template.
1362 If MODES, OPERAND_LOCS, CONSTRAINTS or OPERANDS is 0,
1363 we don't store that info. */
1366 decode_asm_operands (rtx body
, rtx
*operands
, rtx
**operand_locs
,
1367 const char **constraints
, enum machine_mode
*modes
,
1374 if (GET_CODE (body
) == SET
&& GET_CODE (SET_SRC (body
)) == ASM_OPERANDS
)
1376 asmop
= SET_SRC (body
);
1377 /* Single output operand: BODY is (set OUTPUT (asm_operands ....)). */
1379 noperands
= ASM_OPERANDS_INPUT_LENGTH (asmop
) + 1;
1381 for (i
= 1; i
< noperands
; i
++)
1384 operand_locs
[i
] = &ASM_OPERANDS_INPUT (asmop
, i
- 1);
1386 operands
[i
] = ASM_OPERANDS_INPUT (asmop
, i
- 1);
1388 constraints
[i
] = ASM_OPERANDS_INPUT_CONSTRAINT (asmop
, i
- 1);
1390 modes
[i
] = ASM_OPERANDS_INPUT_MODE (asmop
, i
- 1);
1393 /* The output is in the SET.
1394 Its constraint is in the ASM_OPERANDS itself. */
1396 operands
[0] = SET_DEST (body
);
1398 operand_locs
[0] = &SET_DEST (body
);
1400 constraints
[0] = ASM_OPERANDS_OUTPUT_CONSTRAINT (asmop
);
1402 modes
[0] = GET_MODE (SET_DEST (body
));
1404 else if (GET_CODE (body
) == ASM_OPERANDS
)
1407 /* No output operands: BODY is (asm_operands ....). */
1409 noperands
= ASM_OPERANDS_INPUT_LENGTH (asmop
);
1411 /* The input operands are found in the 1st element vector. */
1412 /* Constraints for inputs are in the 2nd element vector. */
1413 for (i
= 0; i
< noperands
; i
++)
1416 operand_locs
[i
] = &ASM_OPERANDS_INPUT (asmop
, i
);
1418 operands
[i
] = ASM_OPERANDS_INPUT (asmop
, i
);
1420 constraints
[i
] = ASM_OPERANDS_INPUT_CONSTRAINT (asmop
, i
);
1422 modes
[i
] = ASM_OPERANDS_INPUT_MODE (asmop
, i
);
1425 else if (GET_CODE (body
) == PARALLEL
1426 && GET_CODE (XVECEXP (body
, 0, 0)) == SET
1427 && GET_CODE (SET_SRC (XVECEXP (body
, 0, 0))) == ASM_OPERANDS
)
1429 int nparallel
= XVECLEN (body
, 0); /* Includes CLOBBERs. */
1431 int nout
= 0; /* Does not include CLOBBERs. */
1433 asmop
= SET_SRC (XVECEXP (body
, 0, 0));
1434 nin
= ASM_OPERANDS_INPUT_LENGTH (asmop
);
1436 /* At least one output, plus some CLOBBERs. */
1438 /* The outputs are in the SETs.
1439 Their constraints are in the ASM_OPERANDS itself. */
1440 for (i
= 0; i
< nparallel
; i
++)
1442 if (GET_CODE (XVECEXP (body
, 0, i
)) == CLOBBER
)
1443 break; /* Past last SET */
1446 operands
[i
] = SET_DEST (XVECEXP (body
, 0, i
));
1448 operand_locs
[i
] = &SET_DEST (XVECEXP (body
, 0, i
));
1450 constraints
[i
] = XSTR (SET_SRC (XVECEXP (body
, 0, i
)), 1);
1452 modes
[i
] = GET_MODE (SET_DEST (XVECEXP (body
, 0, i
)));
1456 for (i
= 0; i
< nin
; i
++)
1459 operand_locs
[i
+ nout
] = &ASM_OPERANDS_INPUT (asmop
, i
);
1461 operands
[i
+ nout
] = ASM_OPERANDS_INPUT (asmop
, i
);
1463 constraints
[i
+ nout
] = ASM_OPERANDS_INPUT_CONSTRAINT (asmop
, i
);
1465 modes
[i
+ nout
] = ASM_OPERANDS_INPUT_MODE (asmop
, i
);
1468 else if (GET_CODE (body
) == PARALLEL
1469 && GET_CODE (XVECEXP (body
, 0, 0)) == ASM_OPERANDS
)
1471 /* No outputs, but some CLOBBERs. */
1475 asmop
= XVECEXP (body
, 0, 0);
1476 nin
= ASM_OPERANDS_INPUT_LENGTH (asmop
);
1478 for (i
= 0; i
< nin
; i
++)
1481 operand_locs
[i
] = &ASM_OPERANDS_INPUT (asmop
, i
);
1483 operands
[i
] = ASM_OPERANDS_INPUT (asmop
, i
);
1485 constraints
[i
] = ASM_OPERANDS_INPUT_CONSTRAINT (asmop
, i
);
1487 modes
[i
] = ASM_OPERANDS_INPUT_MODE (asmop
, i
);
1494 #ifdef USE_MAPPED_LOCATION
1495 *loc
= ASM_OPERANDS_SOURCE_LOCATION (asmop
);
1497 loc
->file
= ASM_OPERANDS_SOURCE_FILE (asmop
);
1498 loc
->line
= ASM_OPERANDS_SOURCE_LINE (asmop
);
1502 return ASM_OPERANDS_TEMPLATE (asmop
);
1505 /* Check if an asm_operand matches its constraints.
1506 Return > 0 if ok, = 0 if bad, < 0 if inconclusive. */
1509 asm_operand_ok (rtx op
, const char *constraint
)
1513 /* Use constrain_operands after reload. */
1514 gcc_assert (!reload_completed
);
1518 char c
= *constraint
;
1535 case '0': case '1': case '2': case '3': case '4':
1536 case '5': case '6': case '7': case '8': case '9':
1537 /* For best results, our caller should have given us the
1538 proper matching constraint, but we can't actually fail
1539 the check if they didn't. Indicate that results are
1543 while (ISDIGIT (*constraint
));
1549 if (address_operand (op
, VOIDmode
))
1554 case 'V': /* non-offsettable */
1555 if (memory_operand (op
, VOIDmode
))
1559 case 'o': /* offsettable */
1560 if (offsettable_nonstrict_memref_p (op
))
1565 /* ??? Before auto-inc-dec, auto inc/dec insns are not supposed to exist,
1566 excepting those that expand_call created. Further, on some
1567 machines which do not have generalized auto inc/dec, an inc/dec
1568 is not a memory_operand.
1570 Match any memory and hope things are resolved after reload. */
1574 || GET_CODE (XEXP (op
, 0)) == PRE_DEC
1575 || GET_CODE (XEXP (op
, 0)) == POST_DEC
))
1582 || GET_CODE (XEXP (op
, 0)) == PRE_INC
1583 || GET_CODE (XEXP (op
, 0)) == POST_INC
))
1589 if (GET_CODE (op
) == CONST_DOUBLE
1590 || (GET_CODE (op
) == CONST_VECTOR
1591 && GET_MODE_CLASS (GET_MODE (op
)) == MODE_VECTOR_FLOAT
))
1596 if (GET_CODE (op
) == CONST_DOUBLE
1597 && CONST_DOUBLE_OK_FOR_CONSTRAINT_P (op
, 'G', constraint
))
1601 if (GET_CODE (op
) == CONST_DOUBLE
1602 && CONST_DOUBLE_OK_FOR_CONSTRAINT_P (op
, 'H', constraint
))
1607 if (GET_CODE (op
) == CONST_INT
1608 || (GET_CODE (op
) == CONST_DOUBLE
1609 && GET_MODE (op
) == VOIDmode
))
1614 if (CONSTANT_P (op
) && (! flag_pic
|| LEGITIMATE_PIC_OPERAND_P (op
)))
1619 if (GET_CODE (op
) == CONST_INT
1620 || (GET_CODE (op
) == CONST_DOUBLE
1621 && GET_MODE (op
) == VOIDmode
))
1626 if (GET_CODE (op
) == CONST_INT
1627 && CONST_OK_FOR_CONSTRAINT_P (INTVAL (op
), 'I', constraint
))
1631 if (GET_CODE (op
) == CONST_INT
1632 && CONST_OK_FOR_CONSTRAINT_P (INTVAL (op
), 'J', constraint
))
1636 if (GET_CODE (op
) == CONST_INT
1637 && CONST_OK_FOR_CONSTRAINT_P (INTVAL (op
), 'K', constraint
))
1641 if (GET_CODE (op
) == CONST_INT
1642 && CONST_OK_FOR_CONSTRAINT_P (INTVAL (op
), 'L', constraint
))
1646 if (GET_CODE (op
) == CONST_INT
1647 && CONST_OK_FOR_CONSTRAINT_P (INTVAL (op
), 'M', constraint
))
1651 if (GET_CODE (op
) == CONST_INT
1652 && CONST_OK_FOR_CONSTRAINT_P (INTVAL (op
), 'N', constraint
))
1656 if (GET_CODE (op
) == CONST_INT
1657 && CONST_OK_FOR_CONSTRAINT_P (INTVAL (op
), 'O', constraint
))
1661 if (GET_CODE (op
) == CONST_INT
1662 && CONST_OK_FOR_CONSTRAINT_P (INTVAL (op
), 'P', constraint
))
1671 if (general_operand (op
, VOIDmode
))
1676 /* For all other letters, we first check for a register class,
1677 otherwise it is an EXTRA_CONSTRAINT. */
1678 if (REG_CLASS_FROM_CONSTRAINT (c
, constraint
) != NO_REGS
)
1681 if (GET_MODE (op
) == BLKmode
)
1683 if (register_operand (op
, VOIDmode
))
1686 #ifdef EXTRA_CONSTRAINT_STR
1687 else if (EXTRA_CONSTRAINT_STR (op
, c
, constraint
))
1689 else if (EXTRA_MEMORY_CONSTRAINT (c
, constraint
)
1690 /* Every memory operand can be reloaded to fit. */
1691 && memory_operand (op
, VOIDmode
))
1693 else if (EXTRA_ADDRESS_CONSTRAINT (c
, constraint
)
1694 /* Every address operand can be reloaded to fit. */
1695 && address_operand (op
, VOIDmode
))
1700 len
= CONSTRAINT_LEN (c
, constraint
);
1703 while (--len
&& *constraint
);
1711 /* Given an rtx *P, if it is a sum containing an integer constant term,
1712 return the location (type rtx *) of the pointer to that constant term.
1713 Otherwise, return a null pointer. */
1716 find_constant_term_loc (rtx
*p
)
1719 enum rtx_code code
= GET_CODE (*p
);
1721 /* If *P IS such a constant term, P is its location. */
1723 if (code
== CONST_INT
|| code
== SYMBOL_REF
|| code
== LABEL_REF
1727 /* Otherwise, if not a sum, it has no constant term. */
1729 if (GET_CODE (*p
) != PLUS
)
1732 /* If one of the summands is constant, return its location. */
1734 if (XEXP (*p
, 0) && CONSTANT_P (XEXP (*p
, 0))
1735 && XEXP (*p
, 1) && CONSTANT_P (XEXP (*p
, 1)))
1738 /* Otherwise, check each summand for containing a constant term. */
1740 if (XEXP (*p
, 0) != 0)
1742 tem
= find_constant_term_loc (&XEXP (*p
, 0));
1747 if (XEXP (*p
, 1) != 0)
1749 tem
= find_constant_term_loc (&XEXP (*p
, 1));
1757 /* Return 1 if OP is a memory reference
1758 whose address contains no side effects
1759 and remains valid after the addition
1760 of a positive integer less than the
1761 size of the object being referenced.
1763 We assume that the original address is valid and do not check it.
1765 This uses strict_memory_address_p as a subroutine, so
1766 don't use it before reload. */
1769 offsettable_memref_p (rtx op
)
1771 return ((MEM_P (op
))
1772 && offsettable_address_p (1, GET_MODE (op
), XEXP (op
, 0)));
1775 /* Similar, but don't require a strictly valid mem ref:
1776 consider pseudo-regs valid as index or base regs. */
1779 offsettable_nonstrict_memref_p (rtx op
)
1781 return ((MEM_P (op
))
1782 && offsettable_address_p (0, GET_MODE (op
), XEXP (op
, 0)));
1785 /* Return 1 if Y is a memory address which contains no side effects
1786 and would remain valid after the addition of a positive integer
1787 less than the size of that mode.
1789 We assume that the original address is valid and do not check it.
1790 We do check that it is valid for narrower modes.
1792 If STRICTP is nonzero, we require a strictly valid address,
1793 for the sake of use in reload.c. */
1796 offsettable_address_p (int strictp
, enum machine_mode mode
, rtx y
)
1798 enum rtx_code ycode
= GET_CODE (y
);
1802 int (*addressp
) (enum machine_mode
, rtx
) =
1803 (strictp
? strict_memory_address_p
: memory_address_p
);
1804 unsigned int mode_sz
= GET_MODE_SIZE (mode
);
1806 if (CONSTANT_ADDRESS_P (y
))
1809 /* Adjusting an offsettable address involves changing to a narrower mode.
1810 Make sure that's OK. */
1812 if (mode_dependent_address_p (y
))
1815 /* ??? How much offset does an offsettable BLKmode reference need?
1816 Clearly that depends on the situation in which it's being used.
1817 However, the current situation in which we test 0xffffffff is
1818 less than ideal. Caveat user. */
1820 mode_sz
= BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
;
1822 /* If the expression contains a constant term,
1823 see if it remains valid when max possible offset is added. */
1825 if ((ycode
== PLUS
) && (y2
= find_constant_term_loc (&y1
)))
1830 *y2
= plus_constant (*y2
, mode_sz
- 1);
1831 /* Use QImode because an odd displacement may be automatically invalid
1832 for any wider mode. But it should be valid for a single byte. */
1833 good
= (*addressp
) (QImode
, y
);
1835 /* In any case, restore old contents of memory. */
1840 if (GET_RTX_CLASS (ycode
) == RTX_AUTOINC
)
1843 /* The offset added here is chosen as the maximum offset that
1844 any instruction could need to add when operating on something
1845 of the specified mode. We assume that if Y and Y+c are
1846 valid addresses then so is Y+d for all 0<d<c. adjust_address will
1847 go inside a LO_SUM here, so we do so as well. */
1848 if (GET_CODE (y
) == LO_SUM
1850 && mode_sz
<= GET_MODE_ALIGNMENT (mode
) / BITS_PER_UNIT
)
1851 z
= gen_rtx_LO_SUM (GET_MODE (y
), XEXP (y
, 0),
1852 plus_constant (XEXP (y
, 1), mode_sz
- 1));
1854 z
= plus_constant (y
, mode_sz
- 1);
1856 /* Use QImode because an odd displacement may be automatically invalid
1857 for any wider mode. But it should be valid for a single byte. */
1858 return (*addressp
) (QImode
, z
);
1861 /* Return 1 if ADDR is an address-expression whose effect depends
1862 on the mode of the memory reference it is used in.
1864 Autoincrement addressing is a typical example of mode-dependence
1865 because the amount of the increment depends on the mode. */
1868 mode_dependent_address_p (rtx addr
)
1870 /* Auto-increment addressing with anything other than post_modify
1871 or pre_modify always introduces a mode dependency. Catch such
1872 cases now instead of deferring to the target. */
1873 if (GET_CODE (addr
) == PRE_INC
1874 || GET_CODE (addr
) == POST_INC
1875 || GET_CODE (addr
) == PRE_DEC
1876 || GET_CODE (addr
) == POST_DEC
)
1879 GO_IF_MODE_DEPENDENT_ADDRESS (addr
, win
);
1881 /* Label `win' might (not) be used via GO_IF_MODE_DEPENDENT_ADDRESS. */
1882 win
: ATTRIBUTE_UNUSED_LABEL
1886 /* Like extract_insn, but save insn extracted and don't extract again, when
1887 called again for the same insn expecting that recog_data still contain the
1888 valid information. This is used primary by gen_attr infrastructure that
1889 often does extract insn again and again. */
1891 extract_insn_cached (rtx insn
)
1893 if (recog_data
.insn
== insn
&& INSN_CODE (insn
) >= 0)
1895 extract_insn (insn
);
1896 recog_data
.insn
= insn
;
1899 /* Do cached extract_insn, constrain_operands and complain about failures.
1900 Used by insn_attrtab. */
1902 extract_constrain_insn_cached (rtx insn
)
1904 extract_insn_cached (insn
);
1905 if (which_alternative
== -1
1906 && !constrain_operands (reload_completed
))
1907 fatal_insn_not_found (insn
);
1910 /* Do cached constrain_operands and complain about failures. */
1912 constrain_operands_cached (int strict
)
1914 if (which_alternative
== -1)
1915 return constrain_operands (strict
);
1920 /* Analyze INSN and fill in recog_data. */
1923 extract_insn (rtx insn
)
1928 rtx body
= PATTERN (insn
);
1930 recog_data
.insn
= NULL
;
1931 recog_data
.n_operands
= 0;
1932 recog_data
.n_alternatives
= 0;
1933 recog_data
.n_dups
= 0;
1934 which_alternative
= -1;
1936 switch (GET_CODE (body
))
1946 if (GET_CODE (SET_SRC (body
)) == ASM_OPERANDS
)
1951 if ((GET_CODE (XVECEXP (body
, 0, 0)) == SET
1952 && GET_CODE (SET_SRC (XVECEXP (body
, 0, 0))) == ASM_OPERANDS
)
1953 || GET_CODE (XVECEXP (body
, 0, 0)) == ASM_OPERANDS
)
1959 recog_data
.n_operands
= noperands
= asm_noperands (body
);
1962 /* This insn is an `asm' with operands. */
1964 /* expand_asm_operands makes sure there aren't too many operands. */
1965 gcc_assert (noperands
<= MAX_RECOG_OPERANDS
);
1967 /* Now get the operand values and constraints out of the insn. */
1968 decode_asm_operands (body
, recog_data
.operand
,
1969 recog_data
.operand_loc
,
1970 recog_data
.constraints
,
1971 recog_data
.operand_mode
, NULL
);
1974 const char *p
= recog_data
.constraints
[0];
1975 recog_data
.n_alternatives
= 1;
1977 recog_data
.n_alternatives
+= (*p
++ == ',');
1981 fatal_insn_not_found (insn
);
1985 /* Ordinary insn: recognize it, get the operands via insn_extract
1986 and get the constraints. */
1988 icode
= recog_memoized (insn
);
1990 fatal_insn_not_found (insn
);
1992 recog_data
.n_operands
= noperands
= insn_data
[icode
].n_operands
;
1993 recog_data
.n_alternatives
= insn_data
[icode
].n_alternatives
;
1994 recog_data
.n_dups
= insn_data
[icode
].n_dups
;
1996 insn_extract (insn
);
1998 for (i
= 0; i
< noperands
; i
++)
2000 recog_data
.constraints
[i
] = insn_data
[icode
].operand
[i
].constraint
;
2001 recog_data
.operand_mode
[i
] = insn_data
[icode
].operand
[i
].mode
;
2002 /* VOIDmode match_operands gets mode from their real operand. */
2003 if (recog_data
.operand_mode
[i
] == VOIDmode
)
2004 recog_data
.operand_mode
[i
] = GET_MODE (recog_data
.operand
[i
]);
2007 for (i
= 0; i
< noperands
; i
++)
2008 recog_data
.operand_type
[i
]
2009 = (recog_data
.constraints
[i
][0] == '=' ? OP_OUT
2010 : recog_data
.constraints
[i
][0] == '+' ? OP_INOUT
2013 gcc_assert (recog_data
.n_alternatives
<= MAX_RECOG_ALTERNATIVES
);
2016 /* After calling extract_insn, you can use this function to extract some
2017 information from the constraint strings into a more usable form.
2018 The collected data is stored in recog_op_alt. */
2020 preprocess_constraints (void)
2024 for (i
= 0; i
< recog_data
.n_operands
; i
++)
2025 memset (recog_op_alt
[i
], 0, (recog_data
.n_alternatives
2026 * sizeof (struct operand_alternative
)));
2028 for (i
= 0; i
< recog_data
.n_operands
; i
++)
2031 struct operand_alternative
*op_alt
;
2032 const char *p
= recog_data
.constraints
[i
];
2034 op_alt
= recog_op_alt
[i
];
2036 for (j
= 0; j
< recog_data
.n_alternatives
; j
++)
2038 op_alt
[j
].cl
= NO_REGS
;
2039 op_alt
[j
].constraint
= p
;
2040 op_alt
[j
].matches
= -1;
2041 op_alt
[j
].matched
= -1;
2043 if (*p
== '\0' || *p
== ',')
2045 op_alt
[j
].anything_ok
= 1;
2055 while (c
!= ',' && c
!= '\0');
2056 if (c
== ',' || c
== '\0')
2064 case '=': case '+': case '*': case '%':
2065 case 'E': case 'F': case 'G': case 'H':
2066 case 's': case 'i': case 'n':
2067 case 'I': case 'J': case 'K': case 'L':
2068 case 'M': case 'N': case 'O': case 'P':
2069 /* These don't say anything we care about. */
2073 op_alt
[j
].reject
+= 6;
2076 op_alt
[j
].reject
+= 600;
2079 op_alt
[j
].earlyclobber
= 1;
2082 case '0': case '1': case '2': case '3': case '4':
2083 case '5': case '6': case '7': case '8': case '9':
2086 op_alt
[j
].matches
= strtoul (p
, &end
, 10);
2087 recog_op_alt
[op_alt
[j
].matches
][j
].matched
= i
;
2093 op_alt
[j
].memory_ok
= 1;
2096 op_alt
[j
].decmem_ok
= 1;
2099 op_alt
[j
].incmem_ok
= 1;
2102 op_alt
[j
].nonoffmem_ok
= 1;
2105 op_alt
[j
].offmem_ok
= 1;
2108 op_alt
[j
].anything_ok
= 1;
2112 op_alt
[j
].is_address
= 1;
2113 op_alt
[j
].cl
= reg_class_subunion
[(int) op_alt
[j
].cl
]
2114 [(int) base_reg_class (VOIDmode
, ADDRESS
, SCRATCH
)];
2120 reg_class_subunion
[(int) op_alt
[j
].cl
][(int) GENERAL_REGS
];
2124 if (EXTRA_MEMORY_CONSTRAINT (c
, p
))
2126 op_alt
[j
].memory_ok
= 1;
2129 if (EXTRA_ADDRESS_CONSTRAINT (c
, p
))
2131 op_alt
[j
].is_address
= 1;
2133 = (reg_class_subunion
2134 [(int) op_alt
[j
].cl
]
2135 [(int) base_reg_class (VOIDmode
, ADDRESS
,
2141 = (reg_class_subunion
2142 [(int) op_alt
[j
].cl
]
2143 [(int) REG_CLASS_FROM_CONSTRAINT ((unsigned char) c
, p
)]);
2146 p
+= CONSTRAINT_LEN (c
, p
);
2152 /* Check the operands of an insn against the insn's operand constraints
2153 and return 1 if they are valid.
2154 The information about the insn's operands, constraints, operand modes
2155 etc. is obtained from the global variables set up by extract_insn.
2157 WHICH_ALTERNATIVE is set to a number which indicates which
2158 alternative of constraints was matched: 0 for the first alternative,
2159 1 for the next, etc.
2161 In addition, when two operands are required to match
2162 and it happens that the output operand is (reg) while the
2163 input operand is --(reg) or ++(reg) (a pre-inc or pre-dec),
2164 make the output operand look like the input.
2165 This is because the output operand is the one the template will print.
2167 This is used in final, just before printing the assembler code and by
2168 the routines that determine an insn's attribute.
2170 If STRICT is a positive nonzero value, it means that we have been
2171 called after reload has been completed. In that case, we must
2172 do all checks strictly. If it is zero, it means that we have been called
2173 before reload has completed. In that case, we first try to see if we can
2174 find an alternative that matches strictly. If not, we try again, this
2175 time assuming that reload will fix up the insn. This provides a "best
2176 guess" for the alternative and is used to compute attributes of insns prior
2177 to reload. A negative value of STRICT is used for this internal call. */
2185 constrain_operands (int strict
)
2187 const char *constraints
[MAX_RECOG_OPERANDS
];
2188 int matching_operands
[MAX_RECOG_OPERANDS
];
2189 int earlyclobber
[MAX_RECOG_OPERANDS
];
2192 struct funny_match funny_match
[MAX_RECOG_OPERANDS
];
2193 int funny_match_index
;
2195 which_alternative
= 0;
2196 if (recog_data
.n_operands
== 0 || recog_data
.n_alternatives
== 0)
2199 for (c
= 0; c
< recog_data
.n_operands
; c
++)
2201 constraints
[c
] = recog_data
.constraints
[c
];
2202 matching_operands
[c
] = -1;
2207 int seen_earlyclobber_at
= -1;
2210 funny_match_index
= 0;
2212 for (opno
= 0; opno
< recog_data
.n_operands
; opno
++)
2214 rtx op
= recog_data
.operand
[opno
];
2215 enum machine_mode mode
= GET_MODE (op
);
2216 const char *p
= constraints
[opno
];
2222 earlyclobber
[opno
] = 0;
2224 /* A unary operator may be accepted by the predicate, but it
2225 is irrelevant for matching constraints. */
2229 if (GET_CODE (op
) == SUBREG
)
2231 if (REG_P (SUBREG_REG (op
))
2232 && REGNO (SUBREG_REG (op
)) < FIRST_PSEUDO_REGISTER
)
2233 offset
= subreg_regno_offset (REGNO (SUBREG_REG (op
)),
2234 GET_MODE (SUBREG_REG (op
)),
2237 op
= SUBREG_REG (op
);
2240 /* An empty constraint or empty alternative
2241 allows anything which matched the pattern. */
2242 if (*p
== 0 || *p
== ',')
2246 switch (c
= *p
, len
= CONSTRAINT_LEN (c
, p
), c
)
2255 case '?': case '!': case '*': case '%':
2260 /* Ignore rest of this alternative as far as
2261 constraint checking is concerned. */
2264 while (*p
&& *p
!= ',');
2269 earlyclobber
[opno
] = 1;
2270 if (seen_earlyclobber_at
< 0)
2271 seen_earlyclobber_at
= opno
;
2274 case '0': case '1': case '2': case '3': case '4':
2275 case '5': case '6': case '7': case '8': case '9':
2277 /* This operand must be the same as a previous one.
2278 This kind of constraint is used for instructions such
2279 as add when they take only two operands.
2281 Note that the lower-numbered operand is passed first.
2283 If we are not testing strictly, assume that this
2284 constraint will be satisfied. */
2289 match
= strtoul (p
, &end
, 10);
2296 rtx op1
= recog_data
.operand
[match
];
2297 rtx op2
= recog_data
.operand
[opno
];
2299 /* A unary operator may be accepted by the predicate,
2300 but it is irrelevant for matching constraints. */
2302 op1
= XEXP (op1
, 0);
2304 op2
= XEXP (op2
, 0);
2306 val
= operands_match_p (op1
, op2
);
2309 matching_operands
[opno
] = match
;
2310 matching_operands
[match
] = opno
;
2315 /* If output is *x and input is *--x, arrange later
2316 to change the output to *--x as well, since the
2317 output op is the one that will be printed. */
2318 if (val
== 2 && strict
> 0)
2320 funny_match
[funny_match_index
].this = opno
;
2321 funny_match
[funny_match_index
++].other
= match
;
2328 /* p is used for address_operands. When we are called by
2329 gen_reload, no one will have checked that the address is
2330 strictly valid, i.e., that all pseudos requiring hard regs
2331 have gotten them. */
2333 || (strict_memory_address_p (recog_data
.operand_mode
[opno
],
2338 /* No need to check general_operand again;
2339 it was done in insn-recog.c. Well, except that reload
2340 doesn't check the validity of its replacements, but
2341 that should only matter when there's a bug. */
2343 /* Anything goes unless it is a REG and really has a hard reg
2344 but the hard reg is not in the class GENERAL_REGS. */
2348 || GENERAL_REGS
== ALL_REGS
2349 || (reload_in_progress
2350 && REGNO (op
) >= FIRST_PSEUDO_REGISTER
)
2351 || reg_fits_class_p (op
, GENERAL_REGS
, offset
, mode
))
2354 else if (strict
< 0 || general_operand (op
, mode
))
2359 /* This is used for a MATCH_SCRATCH in the cases when
2360 we don't actually need anything. So anything goes
2366 /* Memory operands must be valid, to the extent
2367 required by STRICT. */
2371 && !strict_memory_address_p (GET_MODE (op
),
2375 && !memory_address_p (GET_MODE (op
), XEXP (op
, 0)))
2379 /* Before reload, accept what reload can turn into mem. */
2380 else if (strict
< 0 && CONSTANT_P (op
))
2382 /* During reload, accept a pseudo */
2383 else if (reload_in_progress
&& REG_P (op
)
2384 && REGNO (op
) >= FIRST_PSEUDO_REGISTER
)
2390 && (GET_CODE (XEXP (op
, 0)) == PRE_DEC
2391 || GET_CODE (XEXP (op
, 0)) == POST_DEC
))
2397 && (GET_CODE (XEXP (op
, 0)) == PRE_INC
2398 || GET_CODE (XEXP (op
, 0)) == POST_INC
))
2404 if (GET_CODE (op
) == CONST_DOUBLE
2405 || (GET_CODE (op
) == CONST_VECTOR
2406 && GET_MODE_CLASS (GET_MODE (op
)) == MODE_VECTOR_FLOAT
))
2412 if (GET_CODE (op
) == CONST_DOUBLE
2413 && CONST_DOUBLE_OK_FOR_CONSTRAINT_P (op
, c
, p
))
2418 if (GET_CODE (op
) == CONST_INT
2419 || (GET_CODE (op
) == CONST_DOUBLE
2420 && GET_MODE (op
) == VOIDmode
))
2423 if (CONSTANT_P (op
))
2428 if (GET_CODE (op
) == CONST_INT
2429 || (GET_CODE (op
) == CONST_DOUBLE
2430 && GET_MODE (op
) == VOIDmode
))
2442 if (GET_CODE (op
) == CONST_INT
2443 && CONST_OK_FOR_CONSTRAINT_P (INTVAL (op
), c
, p
))
2449 && ((strict
> 0 && ! offsettable_memref_p (op
))
2451 && !(CONSTANT_P (op
) || MEM_P (op
)))
2452 || (reload_in_progress
2454 && REGNO (op
) >= FIRST_PSEUDO_REGISTER
))))
2459 if ((strict
> 0 && offsettable_memref_p (op
))
2460 || (strict
== 0 && offsettable_nonstrict_memref_p (op
))
2461 /* Before reload, accept what reload can handle. */
2463 && (CONSTANT_P (op
) || MEM_P (op
)))
2464 /* During reload, accept a pseudo */
2465 || (reload_in_progress
&& REG_P (op
)
2466 && REGNO (op
) >= FIRST_PSEUDO_REGISTER
))
2475 ? GENERAL_REGS
: REG_CLASS_FROM_CONSTRAINT (c
, p
));
2481 && REGNO (op
) >= FIRST_PSEUDO_REGISTER
)
2482 || (strict
== 0 && GET_CODE (op
) == SCRATCH
)
2484 && reg_fits_class_p (op
, cl
, offset
, mode
)))
2487 #ifdef EXTRA_CONSTRAINT_STR
2488 else if (EXTRA_CONSTRAINT_STR (op
, c
, p
))
2491 else if (EXTRA_MEMORY_CONSTRAINT (c
, p
)
2492 /* Every memory operand can be reloaded to fit. */
2493 && ((strict
< 0 && MEM_P (op
))
2494 /* Before reload, accept what reload can turn
2496 || (strict
< 0 && CONSTANT_P (op
))
2497 /* During reload, accept a pseudo */
2498 || (reload_in_progress
&& REG_P (op
)
2499 && REGNO (op
) >= FIRST_PSEUDO_REGISTER
)))
2501 else if (EXTRA_ADDRESS_CONSTRAINT (c
, p
)
2502 /* Every address operand can be reloaded to fit. */
2509 while (p
+= len
, c
);
2511 constraints
[opno
] = p
;
2512 /* If this operand did not win somehow,
2513 this alternative loses. */
2517 /* This alternative won; the operands are ok.
2518 Change whichever operands this alternative says to change. */
2523 /* See if any earlyclobber operand conflicts with some other
2526 if (strict
> 0 && seen_earlyclobber_at
>= 0)
2527 for (eopno
= seen_earlyclobber_at
;
2528 eopno
< recog_data
.n_operands
;
2530 /* Ignore earlyclobber operands now in memory,
2531 because we would often report failure when we have
2532 two memory operands, one of which was formerly a REG. */
2533 if (earlyclobber
[eopno
]
2534 && REG_P (recog_data
.operand
[eopno
]))
2535 for (opno
= 0; opno
< recog_data
.n_operands
; opno
++)
2536 if ((MEM_P (recog_data
.operand
[opno
])
2537 || recog_data
.operand_type
[opno
] != OP_OUT
)
2539 /* Ignore things like match_operator operands. */
2540 && *recog_data
.constraints
[opno
] != 0
2541 && ! (matching_operands
[opno
] == eopno
2542 && operands_match_p (recog_data
.operand
[opno
],
2543 recog_data
.operand
[eopno
]))
2544 && ! safe_from_earlyclobber (recog_data
.operand
[opno
],
2545 recog_data
.operand
[eopno
]))
2550 while (--funny_match_index
>= 0)
2552 recog_data
.operand
[funny_match
[funny_match_index
].other
]
2553 = recog_data
.operand
[funny_match
[funny_match_index
].this];
2560 which_alternative
++;
2562 while (which_alternative
< recog_data
.n_alternatives
);
2564 which_alternative
= -1;
2565 /* If we are about to reject this, but we are not to test strictly,
2566 try a very loose test. Only return failure if it fails also. */
2568 return constrain_operands (-1);
2573 /* Return 1 iff OPERAND (assumed to be a REG rtx)
2574 is a hard reg in class CLASS when its regno is offset by OFFSET
2575 and changed to mode MODE.
2576 If REG occupies multiple hard regs, all of them must be in CLASS. */
2579 reg_fits_class_p (rtx operand
, enum reg_class cl
, int offset
,
2580 enum machine_mode mode
)
2582 int regno
= REGNO (operand
);
2587 return (regno
< FIRST_PSEUDO_REGISTER
2588 && in_hard_reg_set_p (reg_class_contents
[(int) cl
],
2589 mode
, regno
+ offset
));
2592 /* Split single instruction. Helper function for split_all_insns and
2593 split_all_insns_noflow. Return last insn in the sequence if successful,
2594 or NULL if unsuccessful. */
2597 split_insn (rtx insn
)
2599 /* Split insns here to get max fine-grain parallelism. */
2600 rtx first
= PREV_INSN (insn
);
2601 rtx last
= try_split (PATTERN (insn
), insn
, 1);
2606 /* try_split returns the NOTE that INSN became. */
2607 SET_INSN_DELETED (insn
);
2609 /* ??? Coddle to md files that generate subregs in post-reload
2610 splitters instead of computing the proper hard register. */
2611 if (reload_completed
&& first
!= last
)
2613 first
= NEXT_INSN (first
);
2617 cleanup_subreg_operands (first
);
2620 first
= NEXT_INSN (first
);
2626 /* Split all insns in the function. If UPD_LIFE, update life info after. */
2629 split_all_insns (void)
2635 blocks
= sbitmap_alloc (last_basic_block
);
2636 sbitmap_zero (blocks
);
2639 FOR_EACH_BB_REVERSE (bb
)
2642 bool finish
= false;
2644 for (insn
= BB_HEAD (bb
); !finish
; insn
= next
)
2646 /* Can't use `next_real_insn' because that might go across
2647 CODE_LABELS and short-out basic blocks. */
2648 next
= NEXT_INSN (insn
);
2649 finish
= (insn
== BB_END (bb
));
2652 rtx set
= single_set (insn
);
2654 /* Don't split no-op move insns. These should silently
2655 disappear later in final. Splitting such insns would
2656 break the code that handles REG_NO_CONFLICT blocks. */
2657 if (set
&& set_noop_p (set
))
2659 /* Nops get in the way while scheduling, so delete them
2660 now if register allocation has already been done. It
2661 is too risky to try to do this before register
2662 allocation, and there are unlikely to be very many
2663 nops then anyways. */
2664 if (reload_completed
)
2665 delete_insn_and_edges (insn
);
2669 rtx last
= split_insn (insn
);
2672 /* The split sequence may include barrier, but the
2673 BB boundary we are interested in will be set to
2676 while (BARRIER_P (last
))
2677 last
= PREV_INSN (last
);
2678 SET_BIT (blocks
, bb
->index
);
2687 find_many_sub_basic_blocks (blocks
);
2689 #ifdef ENABLE_CHECKING
2690 verify_flow_info ();
2693 sbitmap_free (blocks
);
2696 /* Same as split_all_insns, but do not expect CFG to be available.
2697 Used by machine dependent reorg passes. */
2700 split_all_insns_noflow (void)
2704 for (insn
= get_insns (); insn
; insn
= next
)
2706 next
= NEXT_INSN (insn
);
2709 /* Don't split no-op move insns. These should silently
2710 disappear later in final. Splitting such insns would
2711 break the code that handles REG_NO_CONFLICT blocks. */
2712 rtx set
= single_set (insn
);
2713 if (set
&& set_noop_p (set
))
2715 /* Nops get in the way while scheduling, so delete them
2716 now if register allocation has already been done. It
2717 is too risky to try to do this before register
2718 allocation, and there are unlikely to be very many
2721 ??? Should we use delete_insn when the CFG isn't valid? */
2722 if (reload_completed
)
2723 delete_insn_and_edges (insn
);
2732 #ifdef HAVE_peephole2
2733 struct peep2_insn_data
2739 static struct peep2_insn_data peep2_insn_data
[MAX_INSNS_PER_PEEP2
+ 1];
2740 static int peep2_current
;
2741 /* The number of instructions available to match a peep2. */
2742 int peep2_current_count
;
2744 /* A non-insn marker indicating the last insn of the block.
2745 The live_before regset for this element is correct, indicating
2746 DF_LIVE_OUT for the block. */
2747 #define PEEP2_EOB pc_rtx
2749 /* Return the Nth non-note insn after `current', or return NULL_RTX if it
2750 does not exist. Used by the recognizer to find the next insn to match
2751 in a multi-insn pattern. */
2754 peep2_next_insn (int n
)
2756 gcc_assert (n
<= peep2_current_count
);
2759 if (n
>= MAX_INSNS_PER_PEEP2
+ 1)
2760 n
-= MAX_INSNS_PER_PEEP2
+ 1;
2762 return peep2_insn_data
[n
].insn
;
2765 /* Return true if REGNO is dead before the Nth non-note insn
2769 peep2_regno_dead_p (int ofs
, int regno
)
2771 gcc_assert (ofs
< MAX_INSNS_PER_PEEP2
+ 1);
2773 ofs
+= peep2_current
;
2774 if (ofs
>= MAX_INSNS_PER_PEEP2
+ 1)
2775 ofs
-= MAX_INSNS_PER_PEEP2
+ 1;
2777 gcc_assert (peep2_insn_data
[ofs
].insn
!= NULL_RTX
);
2779 return ! REGNO_REG_SET_P (peep2_insn_data
[ofs
].live_before
, regno
);
2782 /* Similarly for a REG. */
2785 peep2_reg_dead_p (int ofs
, rtx reg
)
2789 gcc_assert (ofs
< MAX_INSNS_PER_PEEP2
+ 1);
2791 ofs
+= peep2_current
;
2792 if (ofs
>= MAX_INSNS_PER_PEEP2
+ 1)
2793 ofs
-= MAX_INSNS_PER_PEEP2
+ 1;
2795 gcc_assert (peep2_insn_data
[ofs
].insn
!= NULL_RTX
);
2797 regno
= REGNO (reg
);
2798 n
= hard_regno_nregs
[regno
][GET_MODE (reg
)];
2800 if (REGNO_REG_SET_P (peep2_insn_data
[ofs
].live_before
, regno
+ n
))
2805 /* Try to find a hard register of mode MODE, matching the register class in
2806 CLASS_STR, which is available at the beginning of insn CURRENT_INSN and
2807 remains available until the end of LAST_INSN. LAST_INSN may be NULL_RTX,
2808 in which case the only condition is that the register must be available
2809 before CURRENT_INSN.
2810 Registers that already have bits set in REG_SET will not be considered.
2812 If an appropriate register is available, it will be returned and the
2813 corresponding bit(s) in REG_SET will be set; otherwise, NULL_RTX is
2817 peep2_find_free_register (int from
, int to
, const char *class_str
,
2818 enum machine_mode mode
, HARD_REG_SET
*reg_set
)
2820 static int search_ofs
;
2825 gcc_assert (from
< MAX_INSNS_PER_PEEP2
+ 1);
2826 gcc_assert (to
< MAX_INSNS_PER_PEEP2
+ 1);
2828 from
+= peep2_current
;
2829 if (from
>= MAX_INSNS_PER_PEEP2
+ 1)
2830 from
-= MAX_INSNS_PER_PEEP2
+ 1;
2831 to
+= peep2_current
;
2832 if (to
>= MAX_INSNS_PER_PEEP2
+ 1)
2833 to
-= MAX_INSNS_PER_PEEP2
+ 1;
2835 gcc_assert (peep2_insn_data
[from
].insn
!= NULL_RTX
);
2836 REG_SET_TO_HARD_REG_SET (live
, peep2_insn_data
[from
].live_before
);
2840 HARD_REG_SET this_live
;
2842 if (++from
>= MAX_INSNS_PER_PEEP2
+ 1)
2844 gcc_assert (peep2_insn_data
[from
].insn
!= NULL_RTX
);
2845 REG_SET_TO_HARD_REG_SET (this_live
, peep2_insn_data
[from
].live_before
);
2846 IOR_HARD_REG_SET (live
, this_live
);
2849 cl
= (class_str
[0] == 'r' ? GENERAL_REGS
2850 : REG_CLASS_FROM_CONSTRAINT (class_str
[0], class_str
));
2852 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
2854 int raw_regno
, regno
, success
, j
;
2856 /* Distribute the free registers as much as possible. */
2857 raw_regno
= search_ofs
+ i
;
2858 if (raw_regno
>= FIRST_PSEUDO_REGISTER
)
2859 raw_regno
-= FIRST_PSEUDO_REGISTER
;
2860 #ifdef REG_ALLOC_ORDER
2861 regno
= reg_alloc_order
[raw_regno
];
2866 /* Don't allocate fixed registers. */
2867 if (fixed_regs
[regno
])
2869 /* Make sure the register is of the right class. */
2870 if (! TEST_HARD_REG_BIT (reg_class_contents
[cl
], regno
))
2872 /* And can support the mode we need. */
2873 if (! HARD_REGNO_MODE_OK (regno
, mode
))
2875 /* And that we don't create an extra save/restore. */
2876 if (! call_used_regs
[regno
] && ! df_regs_ever_live_p (regno
))
2878 /* And we don't clobber traceback for noreturn functions. */
2879 if ((regno
== FRAME_POINTER_REGNUM
|| regno
== HARD_FRAME_POINTER_REGNUM
)
2880 && (! reload_completed
|| frame_pointer_needed
))
2884 for (j
= hard_regno_nregs
[regno
][mode
] - 1; j
>= 0; j
--)
2886 if (TEST_HARD_REG_BIT (*reg_set
, regno
+ j
)
2887 || TEST_HARD_REG_BIT (live
, regno
+ j
))
2895 add_to_hard_reg_set (reg_set
, mode
, regno
);
2897 /* Start the next search with the next register. */
2898 if (++raw_regno
>= FIRST_PSEUDO_REGISTER
)
2900 search_ofs
= raw_regno
;
2902 return gen_rtx_REG (mode
, regno
);
2910 /* Perform the peephole2 optimization pass. */
2913 peephole2_optimize (void)
2919 bool do_cleanup_cfg
= false;
2920 bool do_rebuild_jump_labels
= false;
2922 df_set_flags (DF_LR_RUN_DCE
);
2925 /* Initialize the regsets we're going to use. */
2926 for (i
= 0; i
< MAX_INSNS_PER_PEEP2
+ 1; ++i
)
2927 peep2_insn_data
[i
].live_before
= BITMAP_ALLOC (®_obstack
);
2928 live
= BITMAP_ALLOC (®_obstack
);
2930 FOR_EACH_BB_REVERSE (bb
)
2932 /* Indicate that all slots except the last holds invalid data. */
2933 for (i
= 0; i
< MAX_INSNS_PER_PEEP2
; ++i
)
2934 peep2_insn_data
[i
].insn
= NULL_RTX
;
2935 peep2_current_count
= 0;
2937 /* Indicate that the last slot contains live_after data. */
2938 peep2_insn_data
[MAX_INSNS_PER_PEEP2
].insn
= PEEP2_EOB
;
2939 peep2_current
= MAX_INSNS_PER_PEEP2
;
2941 /* Start up propagation. */
2942 bitmap_copy (live
, DF_LR_OUT (bb
));
2943 df_simulate_artificial_refs_at_end (bb
, live
);
2944 bitmap_copy (peep2_insn_data
[MAX_INSNS_PER_PEEP2
].live_before
, live
);
2946 for (insn
= BB_END (bb
); ; insn
= prev
)
2948 prev
= PREV_INSN (insn
);
2951 rtx
try, before_try
, x
;
2954 bool was_call
= false;
2956 /* Record this insn. */
2957 if (--peep2_current
< 0)
2958 peep2_current
= MAX_INSNS_PER_PEEP2
;
2959 if (peep2_current_count
< MAX_INSNS_PER_PEEP2
2960 && peep2_insn_data
[peep2_current
].insn
== NULL_RTX
)
2961 peep2_current_count
++;
2962 peep2_insn_data
[peep2_current
].insn
= insn
;
2963 df_simulate_one_insn_backwards (bb
, insn
, live
);
2964 COPY_REG_SET (peep2_insn_data
[peep2_current
].live_before
, live
);
2966 if (RTX_FRAME_RELATED_P (insn
))
2968 /* If an insn has RTX_FRAME_RELATED_P set, peephole
2969 substitution would lose the
2970 REG_FRAME_RELATED_EXPR that is attached. */
2971 peep2_current_count
= 0;
2975 /* Match the peephole. */
2976 try = peephole2_insns (PATTERN (insn
), insn
, &match_len
);
2980 /* If we are splitting a CALL_INSN, look for the CALL_INSN
2981 in SEQ and copy our CALL_INSN_FUNCTION_USAGE and other
2982 cfg-related call notes. */
2983 for (i
= 0; i
<= match_len
; ++i
)
2986 rtx old_insn
, new_insn
, note
;
2988 j
= i
+ peep2_current
;
2989 if (j
>= MAX_INSNS_PER_PEEP2
+ 1)
2990 j
-= MAX_INSNS_PER_PEEP2
+ 1;
2991 old_insn
= peep2_insn_data
[j
].insn
;
2992 if (!CALL_P (old_insn
))
2997 while (new_insn
!= NULL_RTX
)
2999 if (CALL_P (new_insn
))
3001 new_insn
= NEXT_INSN (new_insn
);
3004 gcc_assert (new_insn
!= NULL_RTX
);
3006 CALL_INSN_FUNCTION_USAGE (new_insn
)
3007 = CALL_INSN_FUNCTION_USAGE (old_insn
);
3009 for (note
= REG_NOTES (old_insn
);
3011 note
= XEXP (note
, 1))
3012 switch (REG_NOTE_KIND (note
))
3016 REG_NOTES (new_insn
)
3017 = gen_rtx_EXPR_LIST (REG_NOTE_KIND (note
),
3019 REG_NOTES (new_insn
));
3021 /* Discard all other reg notes. */
3025 /* Croak if there is another call in the sequence. */
3026 while (++i
<= match_len
)
3028 j
= i
+ peep2_current
;
3029 if (j
>= MAX_INSNS_PER_PEEP2
+ 1)
3030 j
-= MAX_INSNS_PER_PEEP2
+ 1;
3031 old_insn
= peep2_insn_data
[j
].insn
;
3032 gcc_assert (!CALL_P (old_insn
));
3037 i
= match_len
+ peep2_current
;
3038 if (i
>= MAX_INSNS_PER_PEEP2
+ 1)
3039 i
-= MAX_INSNS_PER_PEEP2
+ 1;
3041 note
= find_reg_note (peep2_insn_data
[i
].insn
,
3042 REG_EH_REGION
, NULL_RTX
);
3044 /* Replace the old sequence with the new. */
3045 try = emit_insn_after_setloc (try, peep2_insn_data
[i
].insn
,
3046 INSN_LOCATOR (peep2_insn_data
[i
].insn
));
3047 before_try
= PREV_INSN (insn
);
3048 delete_insn_chain (insn
, peep2_insn_data
[i
].insn
, false);
3050 /* Re-insert the EH_REGION notes. */
3051 if (note
|| (was_call
&& nonlocal_goto_handler_labels
))
3056 FOR_EACH_EDGE (eh_edge
, ei
, bb
->succs
)
3057 if (eh_edge
->flags
& (EDGE_EH
| EDGE_ABNORMAL_CALL
))
3060 for (x
= try ; x
!= before_try
; x
= PREV_INSN (x
))
3062 || (flag_non_call_exceptions
3063 && may_trap_p (PATTERN (x
))
3064 && !find_reg_note (x
, REG_EH_REGION
, NULL
)))
3068 = gen_rtx_EXPR_LIST (REG_EH_REGION
,
3072 if (x
!= BB_END (bb
) && eh_edge
)
3077 nfte
= split_block (bb
, x
);
3078 flags
= (eh_edge
->flags
3079 & (EDGE_EH
| EDGE_ABNORMAL
));
3081 flags
|= EDGE_ABNORMAL_CALL
;
3082 nehe
= make_edge (nfte
->src
, eh_edge
->dest
,
3085 nehe
->probability
= eh_edge
->probability
;
3087 = REG_BR_PROB_BASE
- nehe
->probability
;
3089 do_cleanup_cfg
|= purge_dead_edges (nfte
->dest
);
3095 /* Converting possibly trapping insn to non-trapping is
3096 possible. Zap dummy outgoing edges. */
3097 do_cleanup_cfg
|= purge_dead_edges (bb
);
3100 #ifdef HAVE_conditional_execution
3101 for (i
= 0; i
< MAX_INSNS_PER_PEEP2
+ 1; ++i
)
3102 peep2_insn_data
[i
].insn
= NULL_RTX
;
3103 peep2_insn_data
[peep2_current
].insn
= PEEP2_EOB
;
3104 peep2_current_count
= 0;
3106 /* Back up lifetime information past the end of the
3107 newly created sequence. */
3108 if (++i
>= MAX_INSNS_PER_PEEP2
+ 1)
3110 bitmap_copy (live
, peep2_insn_data
[i
].live_before
);
3112 /* Update life information for the new sequence. */
3119 i
= MAX_INSNS_PER_PEEP2
;
3120 if (peep2_current_count
< MAX_INSNS_PER_PEEP2
3121 && peep2_insn_data
[i
].insn
== NULL_RTX
)
3122 peep2_current_count
++;
3123 peep2_insn_data
[i
].insn
= x
;
3125 df_simulate_one_insn_backwards (bb
, x
, live
);
3126 bitmap_copy (peep2_insn_data
[i
].live_before
, live
);
3135 /* If we generated a jump instruction, it won't have
3136 JUMP_LABEL set. Recompute after we're done. */
3137 for (x
= try; x
!= before_try
; x
= PREV_INSN (x
))
3140 do_rebuild_jump_labels
= true;
3146 if (insn
== BB_HEAD (bb
))
3151 for (i
= 0; i
< MAX_INSNS_PER_PEEP2
+ 1; ++i
)
3152 BITMAP_FREE (peep2_insn_data
[i
].live_before
);
3154 if (do_rebuild_jump_labels
)
3155 rebuild_jump_labels (get_insns ());
3157 #endif /* HAVE_peephole2 */
3159 /* Common predicates for use with define_bypass. */
3161 /* True if the dependency between OUT_INSN and IN_INSN is on the store
3162 data not the address operand(s) of the store. IN_INSN and OUT_INSN
3163 must be either a single_set or a PARALLEL with SETs inside. */
3166 store_data_bypass_p (rtx out_insn
, rtx in_insn
)
3168 rtx out_set
, in_set
;
3169 rtx out_pat
, in_pat
;
3170 rtx out_exp
, in_exp
;
3173 in_set
= single_set (in_insn
);
3176 if (!MEM_P (SET_DEST (in_set
)))
3179 out_set
= single_set (out_insn
);
3182 if (reg_mentioned_p (SET_DEST (out_set
), SET_DEST (in_set
)))
3187 out_pat
= PATTERN (out_insn
);
3189 if (GET_CODE (out_pat
) != PARALLEL
)
3192 for (i
= 0; i
< XVECLEN (out_pat
, 0); i
++)
3194 out_exp
= XVECEXP (out_pat
, 0, i
);
3196 if (GET_CODE (out_exp
) == CLOBBER
)
3199 gcc_assert (GET_CODE (out_exp
) == SET
);
3201 if (reg_mentioned_p (SET_DEST (out_exp
), SET_DEST (in_set
)))
3208 in_pat
= PATTERN (in_insn
);
3209 gcc_assert (GET_CODE (in_pat
) == PARALLEL
);
3211 for (i
= 0; i
< XVECLEN (in_pat
, 0); i
++)
3213 in_exp
= XVECEXP (in_pat
, 0, i
);
3215 if (GET_CODE (in_exp
) == CLOBBER
)
3218 gcc_assert (GET_CODE (in_exp
) == SET
);
3220 if (!MEM_P (SET_DEST (in_exp
)))
3223 out_set
= single_set (out_insn
);
3226 if (reg_mentioned_p (SET_DEST (out_set
), SET_DEST (in_exp
)))
3231 out_pat
= PATTERN (out_insn
);
3232 gcc_assert (GET_CODE (out_pat
) == PARALLEL
);
3234 for (j
= 0; j
< XVECLEN (out_pat
, 0); j
++)
3236 out_exp
= XVECEXP (out_pat
, 0, j
);
3238 if (GET_CODE (out_exp
) == CLOBBER
)
3241 gcc_assert (GET_CODE (out_exp
) == SET
);
3243 if (reg_mentioned_p (SET_DEST (out_exp
), SET_DEST (in_exp
)))
3253 /* True if the dependency between OUT_INSN and IN_INSN is in the IF_THEN_ELSE
3254 condition, and not the THEN or ELSE branch. OUT_INSN may be either a single
3255 or multiple set; IN_INSN should be single_set for truth, but for convenience
3256 of insn categorization may be any JUMP or CALL insn. */
3259 if_test_bypass_p (rtx out_insn
, rtx in_insn
)
3261 rtx out_set
, in_set
;
3263 in_set
= single_set (in_insn
);
3266 gcc_assert (JUMP_P (in_insn
) || CALL_P (in_insn
));
3270 if (GET_CODE (SET_SRC (in_set
)) != IF_THEN_ELSE
)
3272 in_set
= SET_SRC (in_set
);
3274 out_set
= single_set (out_insn
);
3277 if (reg_mentioned_p (SET_DEST (out_set
), XEXP (in_set
, 1))
3278 || reg_mentioned_p (SET_DEST (out_set
), XEXP (in_set
, 2)))
3286 out_pat
= PATTERN (out_insn
);
3287 gcc_assert (GET_CODE (out_pat
) == PARALLEL
);
3289 for (i
= 0; i
< XVECLEN (out_pat
, 0); i
++)
3291 rtx exp
= XVECEXP (out_pat
, 0, i
);
3293 if (GET_CODE (exp
) == CLOBBER
)
3296 gcc_assert (GET_CODE (exp
) == SET
);
3298 if (reg_mentioned_p (SET_DEST (out_set
), XEXP (in_set
, 1))
3299 || reg_mentioned_p (SET_DEST (out_set
), XEXP (in_set
, 2)))
3308 gate_handle_peephole2 (void)
3310 return (optimize
> 0 && flag_peephole2
);
3314 rest_of_handle_peephole2 (void)
3316 #ifdef HAVE_peephole2
3317 peephole2_optimize ();
3322 struct tree_opt_pass pass_peephole2
=
3324 "peephole2", /* name */
3325 gate_handle_peephole2
, /* gate */
3326 rest_of_handle_peephole2
, /* execute */
3329 0, /* static_pass_number */
3330 TV_PEEPHOLE2
, /* tv_id */
3331 0, /* properties_required */
3332 0, /* properties_provided */
3333 0, /* properties_destroyed */
3334 0, /* todo_flags_start */
3335 TODO_df_finish
| TODO_verify_rtl_sharing
|
3336 TODO_dump_func
, /* todo_flags_finish */
3341 rest_of_handle_split_all_insns (void)
3347 struct tree_opt_pass pass_split_all_insns
=
3349 "split1", /* name */
3351 rest_of_handle_split_all_insns
, /* execute */
3354 0, /* static_pass_number */
3356 0, /* properties_required */
3357 0, /* properties_provided */
3358 0, /* properties_destroyed */
3359 0, /* todo_flags_start */
3360 TODO_dump_func
, /* todo_flags_finish */
3365 rest_of_handle_split_after_reload (void)
3367 /* If optimizing, then go ahead and split insns now. */
3375 struct tree_opt_pass pass_split_after_reload
=
3377 "split2", /* name */
3379 rest_of_handle_split_after_reload
, /* execute */
3382 0, /* static_pass_number */
3384 0, /* properties_required */
3385 0, /* properties_provided */
3386 0, /* properties_destroyed */
3387 0, /* todo_flags_start */
3388 TODO_dump_func
, /* todo_flags_finish */
3393 gate_handle_split_before_regstack (void)
3395 #if defined (HAVE_ATTR_length) && defined (STACK_REGS)
3396 /* If flow2 creates new instructions which need splitting
3397 and scheduling after reload is not done, they might not be
3398 split until final which doesn't allow splitting
3399 if HAVE_ATTR_length. */
3400 # ifdef INSN_SCHEDULING
3401 return (optimize
&& !flag_schedule_insns_after_reload
);
3411 rest_of_handle_split_before_regstack (void)
3417 struct tree_opt_pass pass_split_before_regstack
=
3419 "split3", /* name */
3420 gate_handle_split_before_regstack
, /* gate */
3421 rest_of_handle_split_before_regstack
, /* execute */
3424 0, /* static_pass_number */
3426 0, /* properties_required */
3427 0, /* properties_provided */
3428 0, /* properties_destroyed */
3429 0, /* todo_flags_start */
3430 TODO_dump_func
, /* todo_flags_finish */
3435 gate_handle_split_before_sched2 (void)
3437 #ifdef INSN_SCHEDULING
3438 return optimize
> 0 && flag_schedule_insns_after_reload
;
3445 rest_of_handle_split_before_sched2 (void)
3447 #ifdef INSN_SCHEDULING
3453 struct tree_opt_pass pass_split_before_sched2
=
3455 "split4", /* name */
3456 gate_handle_split_before_sched2
, /* gate */
3457 rest_of_handle_split_before_sched2
, /* execute */
3460 0, /* static_pass_number */
3462 0, /* properties_required */
3463 0, /* properties_provided */
3464 0, /* properties_destroyed */
3465 0, /* todo_flags_start */
3467 TODO_dump_func
, /* todo_flags_finish */
3471 /* The placement of the splitting that we do for shorten_branches
3472 depends on whether regstack is used by the target or not. */
3474 gate_do_final_split (void)
3476 #if defined (HAVE_ATTR_length) && !defined (STACK_REGS)
3483 struct tree_opt_pass pass_split_for_shorten_branches
=
3485 "split5", /* name */
3486 gate_do_final_split
, /* gate */
3487 split_all_insns_noflow
, /* execute */
3490 0, /* static_pass_number */
3492 0, /* properties_required */
3493 0, /* properties_provided */
3494 0, /* properties_destroyed */
3495 0, /* todo_flags_start */
3496 TODO_dump_func
| TODO_verify_rtl_sharing
, /* todo_flags_finish */