1 /* Analyze RTL for C-Compiler
2 Copyright (C) 1987, 88, 92-99, 2000 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
26 static int rtx_addr_can_trap_p PARAMS ((rtx));
27 static void reg_set_p_1 PARAMS ((rtx, rtx, void *));
28 static void reg_set_last_1 PARAMS ((rtx, rtx, void *));
31 /* Forward declarations */
32 static int jmp_uses_reg_or_mem PARAMS ((rtx));
34 /* Bit flags that specify the machine subtype we are compiling for.
35 Bits are tested using macros TARGET_... defined in the tm.h file
36 and set by `-m...' switches. Must be defined in rtlanal.c. */
40 /* Return 1 if the value of X is unstable
41 (would be different at a different point in the program).
42 The frame pointer, arg pointer, etc. are considered stable
43 (within one function) and so is anything marked `unchanging'. */
49 register RTX_CODE code = GET_CODE (x);
51 register const char *fmt;
54 return ! RTX_UNCHANGING_P (x);
59 if (code == CONST || code == CONST_INT)
63 return ! (REGNO (x) == FRAME_POINTER_REGNUM
64 || REGNO (x) == HARD_FRAME_POINTER_REGNUM
65 || REGNO (x) == ARG_POINTER_REGNUM
66 || RTX_UNCHANGING_P (x));
68 fmt = GET_RTX_FORMAT (code);
69 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
71 if (rtx_unstable_p (XEXP (x, i)))
76 /* Return 1 if X has a value that can vary even between two
77 executions of the program. 0 means X can be compared reliably
78 against certain constants or near-constants.
79 The frame pointer and the arg pointer are considered constant. */
85 register RTX_CODE code = GET_CODE (x);
87 register const char *fmt;
103 /* Note that we have to test for the actual rtx used for the frame
104 and arg pointers and not just the register number in case we have
105 eliminated the frame and/or arg pointer and are using it
107 return ! (x == frame_pointer_rtx || x == hard_frame_pointer_rtx
108 || x == arg_pointer_rtx || x == pic_offset_table_rtx);
111 /* The operand 0 of a LO_SUM is considered constant
112 (in fact is it related specifically to operand 1). */
113 return rtx_varies_p (XEXP (x, 1));
119 fmt = GET_RTX_FORMAT (code);
120 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
122 if (rtx_varies_p (XEXP (x, i)))
127 /* Return 0 if the use of X as an address in a MEM can cause a trap. */
130 rtx_addr_can_trap_p (x)
133 register enum rtx_code code = GET_CODE (x);
139 /* SYMBOL_REF is problematic due to the possible presence of
140 a #pragma weak, but to say that loads from symbols can trap is
141 *very* costly. It's not at all clear what's best here. For
142 now, we ignore the impact of #pragma weak. */
146 /* As in rtx_varies_p, we have to use the actual rtx, not reg number. */
147 return ! (x == frame_pointer_rtx || x == hard_frame_pointer_rtx
148 || x == stack_pointer_rtx || x == arg_pointer_rtx);
151 return rtx_addr_can_trap_p (XEXP (x, 0));
154 /* An address is assumed not to trap if it is an address that can't
155 trap plus a constant integer. */
156 return (rtx_addr_can_trap_p (XEXP (x, 0))
157 || GET_CODE (XEXP (x, 1)) != CONST_INT);
160 return rtx_addr_can_trap_p (XEXP (x, 1));
166 /* If it isn't one of the case above, it can cause a trap. */
170 /* Return 1 if X refers to a memory location whose address
171 cannot be compared reliably with constant addresses,
172 or if X refers to a BLKmode memory object. */
175 rtx_addr_varies_p (x)
178 register enum rtx_code code;
180 register const char *fmt;
187 return GET_MODE (x) == BLKmode || rtx_varies_p (XEXP (x, 0));
189 fmt = GET_RTX_FORMAT (code);
190 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
193 if (rtx_addr_varies_p (XEXP (x, i)))
196 else if (fmt[i] == 'E')
199 for (j = 0; j < XVECLEN (x, i); j++)
200 if (rtx_addr_varies_p (XVECEXP (x, i, j)))
206 /* Return the value of the integer term in X, if one is apparent;
208 Only obvious integer terms are detected.
209 This is used in cse.c with the `related_value' field.*/
215 if (GET_CODE (x) == CONST)
218 if (GET_CODE (x) == MINUS
219 && GET_CODE (XEXP (x, 1)) == CONST_INT)
220 return - INTVAL (XEXP (x, 1));
221 if (GET_CODE (x) == PLUS
222 && GET_CODE (XEXP (x, 1)) == CONST_INT)
223 return INTVAL (XEXP (x, 1));
227 /* If X is a constant, return the value sans apparent integer term;
229 Only obvious integer terms are detected. */
232 get_related_value (x)
235 if (GET_CODE (x) != CONST)
238 if (GET_CODE (x) == PLUS
239 && GET_CODE (XEXP (x, 1)) == CONST_INT)
241 else if (GET_CODE (x) == MINUS
242 && GET_CODE (XEXP (x, 1)) == CONST_INT)
247 /* Nonzero if register REG appears somewhere within IN.
248 Also works if REG is not a register; in this case it checks
249 for a subexpression of IN that is Lisp "equal" to REG. */
252 reg_mentioned_p (reg, in)
253 register rtx reg, in;
255 register const char *fmt;
257 register enum rtx_code code;
265 if (GET_CODE (in) == LABEL_REF)
266 return reg == XEXP (in, 0);
268 code = GET_CODE (in);
272 /* Compare registers by number. */
274 return GET_CODE (reg) == REG && REGNO (in) == REGNO (reg);
276 /* These codes have no constituent expressions
284 return GET_CODE (reg) == CONST_INT && INTVAL (in) == INTVAL (reg);
287 /* These are kept unique for a given value. */
294 if (GET_CODE (reg) == code && rtx_equal_p (reg, in))
297 fmt = GET_RTX_FORMAT (code);
299 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
304 for (j = XVECLEN (in, i) - 1; j >= 0; j--)
305 if (reg_mentioned_p (reg, XVECEXP (in, i, j)))
308 else if (fmt[i] == 'e'
309 && reg_mentioned_p (reg, XEXP (in, i)))
315 /* Return 1 if in between BEG and END, exclusive of BEG and END, there is
316 no CODE_LABEL insn. */
319 no_labels_between_p (beg, end)
323 for (p = NEXT_INSN (beg); p != end; p = NEXT_INSN (p))
324 if (GET_CODE (p) == CODE_LABEL)
329 /* Return 1 if in between BEG and END, exclusive of BEG and END, there is
330 no JUMP_INSN insn. */
333 no_jumps_between_p (beg, end)
337 for (p = NEXT_INSN (beg); p != end; p = NEXT_INSN (p))
338 if (GET_CODE (p) == JUMP_INSN)
343 /* Nonzero if register REG is used in an insn between
344 FROM_INSN and TO_INSN (exclusive of those two). */
347 reg_used_between_p (reg, from_insn, to_insn)
348 rtx reg, from_insn, to_insn;
352 if (from_insn == to_insn)
355 for (insn = NEXT_INSN (from_insn); insn != to_insn; insn = NEXT_INSN (insn))
356 if (GET_RTX_CLASS (GET_CODE (insn)) == 'i'
357 && (reg_overlap_mentioned_p (reg, PATTERN (insn))
358 || (GET_CODE (insn) == CALL_INSN
359 && (find_reg_fusage (insn, USE, reg)
360 || find_reg_fusage (insn, CLOBBER, reg)))))
365 /* Nonzero if the old value of X, a register, is referenced in BODY. If X
366 is entirely replaced by a new value and the only use is as a SET_DEST,
367 we do not consider it a reference. */
370 reg_referenced_p (x, body)
376 switch (GET_CODE (body))
379 if (reg_overlap_mentioned_p (x, SET_SRC (body)))
382 /* If the destination is anything other than CC0, PC, a REG or a SUBREG
383 of a REG that occupies all of the REG, the insn references X if
384 it is mentioned in the destination. */
385 if (GET_CODE (SET_DEST (body)) != CC0
386 && GET_CODE (SET_DEST (body)) != PC
387 && GET_CODE (SET_DEST (body)) != REG
388 && ! (GET_CODE (SET_DEST (body)) == SUBREG
389 && GET_CODE (SUBREG_REG (SET_DEST (body))) == REG
390 && (((GET_MODE_SIZE (GET_MODE (SUBREG_REG (SET_DEST (body))))
391 + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD)
392 == ((GET_MODE_SIZE (GET_MODE (SET_DEST (body)))
393 + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD)))
394 && reg_overlap_mentioned_p (x, SET_DEST (body)))
399 for (i = ASM_OPERANDS_INPUT_LENGTH (body) - 1; i >= 0; i--)
400 if (reg_overlap_mentioned_p (x, ASM_OPERANDS_INPUT (body, i)))
407 return reg_overlap_mentioned_p (x, body);
410 return reg_overlap_mentioned_p (x, TRAP_CONDITION (body));
413 case UNSPEC_VOLATILE:
414 for (i = XVECLEN (body, 0) - 1; i >= 0; i--)
415 if (reg_overlap_mentioned_p (x, XVECEXP (body, 0, i)))
420 for (i = XVECLEN (body, 0) - 1; i >= 0; i--)
421 if (reg_referenced_p (x, XVECEXP (body, 0, i)))
426 if (GET_CODE (XEXP (body, 0)) == MEM)
427 if (reg_overlap_mentioned_p (x, XEXP (XEXP (body, 0), 0)))
436 /* Nonzero if register REG is referenced in an insn between
437 FROM_INSN and TO_INSN (exclusive of those two). Sets of REG do
441 reg_referenced_between_p (reg, from_insn, to_insn)
442 rtx reg, from_insn, to_insn;
446 if (from_insn == to_insn)
449 for (insn = NEXT_INSN (from_insn); insn != to_insn; insn = NEXT_INSN (insn))
450 if (GET_RTX_CLASS (GET_CODE (insn)) == 'i'
451 && (reg_referenced_p (reg, PATTERN (insn))
452 || (GET_CODE (insn) == CALL_INSN
453 && find_reg_fusage (insn, USE, reg))))
458 /* Nonzero if register REG is set or clobbered in an insn between
459 FROM_INSN and TO_INSN (exclusive of those two). */
462 reg_set_between_p (reg, from_insn, to_insn)
463 rtx reg, from_insn, to_insn;
467 if (from_insn == to_insn)
470 for (insn = NEXT_INSN (from_insn); insn != to_insn; insn = NEXT_INSN (insn))
471 if (GET_RTX_CLASS (GET_CODE (insn)) == 'i'
472 && reg_set_p (reg, insn))
477 /* Internals of reg_set_between_p. */
479 static rtx reg_set_reg;
480 static int reg_set_flag;
483 reg_set_p_1 (x, pat, data)
485 rtx pat ATTRIBUTE_UNUSED;
486 void *data ATTRIBUTE_UNUSED;
488 /* We don't want to return 1 if X is a MEM that contains a register
489 within REG_SET_REG. */
491 if ((GET_CODE (x) != MEM)
492 && reg_overlap_mentioned_p (reg_set_reg, x))
497 reg_set_p (reg, insn)
502 /* We can be passed an insn or part of one. If we are passed an insn,
503 check if a side-effect of the insn clobbers REG. */
504 if (GET_RTX_CLASS (GET_CODE (insn)) == 'i')
506 if (FIND_REG_INC_NOTE (insn, reg)
507 || (GET_CODE (insn) == CALL_INSN
508 /* We'd like to test call_used_regs here, but rtlanal.c can't
509 reference that variable due to its use in genattrtab. So
510 we'll just be more conservative.
512 ??? Unless we could ensure that the CALL_INSN_FUNCTION_USAGE
513 information holds all clobbered registers. */
514 && ((GET_CODE (reg) == REG
515 && REGNO (reg) < FIRST_PSEUDO_REGISTER)
516 || GET_CODE (reg) == MEM
517 || find_reg_fusage (insn, CLOBBER, reg))))
520 body = PATTERN (insn);
525 note_stores (body, reg_set_p_1, NULL);
529 /* Similar to reg_set_between_p, but check all registers in X. Return 0
530 only if none of them are modified between START and END. Do not
531 consider non-registers one way or the other. */
534 regs_set_between_p (x, start, end)
538 enum rtx_code code = GET_CODE (x);
554 return reg_set_between_p (x, start, end);
560 fmt = GET_RTX_FORMAT (code);
561 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
563 if (fmt[i] == 'e' && regs_set_between_p (XEXP (x, i), start, end))
566 else if (fmt[i] == 'E')
567 for (j = XVECLEN (x, i) - 1; j >= 0; j--)
568 if (regs_set_between_p (XVECEXP (x, i, j), start, end))
575 /* Similar to reg_set_between_p, but check all registers in X. Return 0
576 only if none of them are modified between START and END. Return 1 if
577 X contains a MEM; this routine does not perform any memory aliasing. */
580 modified_between_p (x, start, end)
584 enum rtx_code code = GET_CODE (x);
602 /* If the memory is not constant, assume it is modified. If it is
603 constant, we still have to check the address. */
604 if (! RTX_UNCHANGING_P (x))
609 return reg_set_between_p (x, start, end);
615 fmt = GET_RTX_FORMAT (code);
616 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
618 if (fmt[i] == 'e' && modified_between_p (XEXP (x, i), start, end))
621 else if (fmt[i] == 'E')
622 for (j = XVECLEN (x, i) - 1; j >= 0; j--)
623 if (modified_between_p (XVECEXP (x, i, j), start, end))
630 /* Similar to reg_set_p, but check all registers in X. Return 0 only if none
631 of them are modified in INSN. Return 1 if X contains a MEM; this routine
632 does not perform any memory aliasing. */
635 modified_in_p (x, insn)
639 enum rtx_code code = GET_CODE (x);
657 /* If the memory is not constant, assume it is modified. If it is
658 constant, we still have to check the address. */
659 if (! RTX_UNCHANGING_P (x))
664 return reg_set_p (x, insn);
670 fmt = GET_RTX_FORMAT (code);
671 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
673 if (fmt[i] == 'e' && modified_in_p (XEXP (x, i), insn))
676 else if (fmt[i] == 'E')
677 for (j = XVECLEN (x, i) - 1; j >= 0; j--)
678 if (modified_in_p (XVECEXP (x, i, j), insn))
685 /* Given an INSN, return a SET expression if this insn has only a single SET.
686 It may also have CLOBBERs, USEs, or SET whose output
687 will not be used, which we ignore. */
696 if (GET_RTX_CLASS (GET_CODE (insn)) != 'i')
699 if (GET_CODE (PATTERN (insn)) == SET)
700 return PATTERN (insn);
702 else if (GET_CODE (PATTERN (insn)) == PARALLEL)
704 for (i = 0, set = 0; i < XVECLEN (PATTERN (insn), 0); i++)
705 if (GET_CODE (XVECEXP (PATTERN (insn), 0, i)) == SET
706 && (! find_reg_note (insn, REG_UNUSED,
707 SET_DEST (XVECEXP (PATTERN (insn), 0, i)))
708 || side_effects_p (XVECEXP (PATTERN (insn), 0, i))))
713 set = XVECEXP (PATTERN (insn), 0, i);
721 /* Given an INSN, return nonzero if it has more than one SET, else return
731 /* INSN must be an insn. */
732 if (GET_RTX_CLASS (GET_CODE (insn)) != 'i')
735 /* Only a PARALLEL can have multiple SETs. */
736 if (GET_CODE (PATTERN (insn)) == PARALLEL)
738 for (i = 0, found = 0; i < XVECLEN (PATTERN (insn), 0); i++)
739 if (GET_CODE (XVECEXP (PATTERN (insn), 0, i)) == SET)
741 /* If we have already found a SET, then return now. */
749 /* Either zero or one SET. */
753 /* Return the last thing that X was assigned from before *PINSN. Verify that
754 the object is not modified up to VALID_TO. If it was, if we hit
755 a partial assignment to X, or hit a CODE_LABEL first, return X. If we
756 found an assignment, update *PINSN to point to it.
757 ALLOW_HWREG is set to 1 if hardware registers are allowed to be the src. */
760 find_last_value (x, pinsn, valid_to, allow_hwreg)
768 for (p = PREV_INSN (*pinsn); p && GET_CODE (p) != CODE_LABEL;
770 if (GET_RTX_CLASS (GET_CODE (p)) == 'i')
772 rtx set = single_set (p);
773 rtx note = find_reg_note (p, REG_EQUAL, NULL_RTX);
775 if (set && rtx_equal_p (x, SET_DEST (set)))
777 rtx src = SET_SRC (set);
779 if (note && GET_CODE (XEXP (note, 0)) != EXPR_LIST)
780 src = XEXP (note, 0);
782 if (! modified_between_p (src, PREV_INSN (p), valid_to)
783 /* Reject hard registers because we don't usually want
784 to use them; we'd rather use a pseudo. */
785 && (! (GET_CODE (src) == REG
786 && REGNO (src) < FIRST_PSEUDO_REGISTER) || allow_hwreg))
793 /* If set in non-simple way, we don't have a value. */
794 if (reg_set_p (x, p))
801 /* Return nonzero if register in range [REGNO, ENDREGNO)
802 appears either explicitly or implicitly in X
803 other than being stored into.
805 References contained within the substructure at LOC do not count.
806 LOC may be zero, meaning don't ignore anything. */
809 refers_to_regno_p (regno, endregno, x, loc)
815 register RTX_CODE code;
816 register const char *fmt;
819 /* The contents of a REG_NONNEG note is always zero, so we must come here
820 upon repeat in case the last REG_NOTE is a REG_NONNEG note. */
831 /* If we modifying the stack, frame, or argument pointer, it will
832 clobber a virtual register. In fact, we could be more precise,
833 but it isn't worth it. */
834 if ((i == STACK_POINTER_REGNUM
835 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
836 || i == ARG_POINTER_REGNUM
838 || i == FRAME_POINTER_REGNUM)
839 && regno >= FIRST_VIRTUAL_REGISTER && regno <= LAST_VIRTUAL_REGISTER)
843 && regno < i + (i < FIRST_PSEUDO_REGISTER
844 ? HARD_REGNO_NREGS (i, GET_MODE (x))
848 /* If this is a SUBREG of a hard reg, we can see exactly which
849 registers are being modified. Otherwise, handle normally. */
850 if (GET_CODE (SUBREG_REG (x)) == REG
851 && REGNO (SUBREG_REG (x)) < FIRST_PSEUDO_REGISTER)
853 int inner_regno = REGNO (SUBREG_REG (x)) + SUBREG_WORD (x);
855 = inner_regno + (inner_regno < FIRST_PSEUDO_REGISTER
856 ? HARD_REGNO_NREGS (regno, GET_MODE (x)) : 1);
858 return endregno > inner_regno && regno < inner_endregno;
864 if (&SET_DEST (x) != loc
865 /* Note setting a SUBREG counts as referring to the REG it is in for
866 a pseudo but not for hard registers since we can
867 treat each word individually. */
868 && ((GET_CODE (SET_DEST (x)) == SUBREG
869 && loc != &SUBREG_REG (SET_DEST (x))
870 && GET_CODE (SUBREG_REG (SET_DEST (x))) == REG
871 && REGNO (SUBREG_REG (SET_DEST (x))) >= FIRST_PSEUDO_REGISTER
872 && refers_to_regno_p (regno, endregno,
873 SUBREG_REG (SET_DEST (x)), loc))
874 || (GET_CODE (SET_DEST (x)) != REG
875 && refers_to_regno_p (regno, endregno, SET_DEST (x), loc))))
878 if (code == CLOBBER || loc == &SET_SRC (x))
887 /* X does not match, so try its subexpressions. */
889 fmt = GET_RTX_FORMAT (code);
890 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
892 if (fmt[i] == 'e' && loc != &XEXP (x, i))
900 if (refers_to_regno_p (regno, endregno, XEXP (x, i), loc))
903 else if (fmt[i] == 'E')
906 for (j = XVECLEN (x, i) - 1; j >=0; j--)
907 if (loc != &XVECEXP (x, i, j)
908 && refers_to_regno_p (regno, endregno, XVECEXP (x, i, j), loc))
915 /* Nonzero if modifying X will affect IN. If X is a register or a SUBREG,
916 we check if any register number in X conflicts with the relevant register
917 numbers. If X is a constant, return 0. If X is a MEM, return 1 iff IN
918 contains a MEM (we don't bother checking for memory addresses that can't
919 conflict because we expect this to be a rare case. */
922 reg_overlap_mentioned_p (x, in)
927 /* Overly conservative. */
928 if (GET_CODE (x) == STRICT_LOW_PART)
931 /* If either argument is a constant, then modifying X can not affect IN. */
932 if (CONSTANT_P (x) || CONSTANT_P (in))
934 else if (GET_CODE (x) == SUBREG)
936 regno = REGNO (SUBREG_REG (x));
937 if (regno < FIRST_PSEUDO_REGISTER)
938 regno += SUBREG_WORD (x);
940 else if (GET_CODE (x) == REG)
942 else if (GET_CODE (x) == MEM)
947 if (GET_CODE (in) == MEM)
950 fmt = GET_RTX_FORMAT (GET_CODE (in));
952 for (i = GET_RTX_LENGTH (GET_CODE (in)) - 1; i >= 0; i--)
953 if (fmt[i] == 'e' && reg_overlap_mentioned_p (x, XEXP (in, i)))
958 else if (GET_CODE (x) == SCRATCH || GET_CODE (x) == PC
959 || GET_CODE (x) == CC0)
960 return reg_mentioned_p (x, in);
961 else if (GET_CODE (x) == PARALLEL
962 && GET_MODE (x) == BLKmode)
966 /* If any register in here refers to it
968 for (i = XVECLEN (x, 0) - 1; i >= 0; i--)
969 if (reg_overlap_mentioned_p (SET_DEST (XVECEXP (x, 0, i)), in))
976 endregno = regno + (regno < FIRST_PSEUDO_REGISTER
977 ? HARD_REGNO_NREGS (regno, GET_MODE (x)) : 1);
979 return refers_to_regno_p (regno, endregno, in, NULL_PTR);
982 /* Used for communications between the next few functions. */
984 static int reg_set_last_unknown;
985 static rtx reg_set_last_value;
986 static int reg_set_last_first_regno, reg_set_last_last_regno;
988 /* Called via note_stores from reg_set_last. */
991 reg_set_last_1 (x, pat, data)
994 void *data ATTRIBUTE_UNUSED;
998 /* If X is not a register, or is not one in the range we care
1000 if (GET_CODE (x) != REG)
1004 last = first + (first < FIRST_PSEUDO_REGISTER
1005 ? HARD_REGNO_NREGS (first, GET_MODE (x)) : 1);
1007 if (first >= reg_set_last_last_regno
1008 || last <= reg_set_last_first_regno)
1011 /* If this is a CLOBBER or is some complex LHS, or doesn't modify
1012 exactly the registers we care about, show we don't know the value. */
1013 if (GET_CODE (pat) == CLOBBER || SET_DEST (pat) != x
1014 || first != reg_set_last_first_regno
1015 || last != reg_set_last_last_regno)
1016 reg_set_last_unknown = 1;
1018 reg_set_last_value = SET_SRC (pat);
1021 /* Return the last value to which REG was set prior to INSN. If we can't
1022 find it easily, return 0.
1024 We only return a REG, SUBREG, or constant because it is too hard to
1025 check if a MEM remains unchanged. */
1028 reg_set_last (x, insn)
1032 rtx orig_insn = insn;
1034 reg_set_last_first_regno = REGNO (x);
1036 reg_set_last_last_regno
1037 = reg_set_last_first_regno
1038 + (reg_set_last_first_regno < FIRST_PSEUDO_REGISTER
1039 ? HARD_REGNO_NREGS (reg_set_last_first_regno, GET_MODE (x)) : 1);
1041 reg_set_last_unknown = 0;
1042 reg_set_last_value = 0;
1044 /* Scan backwards until reg_set_last_1 changed one of the above flags.
1045 Stop when we reach a label or X is a hard reg and we reach a
1046 CALL_INSN (if reg_set_last_last_regno is a hard reg).
1048 If we find a set of X, ensure that its SET_SRC remains unchanged. */
1050 /* We compare with <= here, because reg_set_last_last_regno
1051 is actually the number of the first reg *not* in X. */
1053 insn && GET_CODE (insn) != CODE_LABEL
1054 && ! (GET_CODE (insn) == CALL_INSN
1055 && reg_set_last_last_regno <= FIRST_PSEUDO_REGISTER);
1056 insn = PREV_INSN (insn))
1057 if (GET_RTX_CLASS (GET_CODE (insn)) == 'i')
1059 note_stores (PATTERN (insn), reg_set_last_1, NULL);
1060 if (reg_set_last_unknown)
1062 else if (reg_set_last_value)
1064 if (CONSTANT_P (reg_set_last_value)
1065 || ((GET_CODE (reg_set_last_value) == REG
1066 || GET_CODE (reg_set_last_value) == SUBREG)
1067 && ! reg_set_between_p (reg_set_last_value,
1069 return reg_set_last_value;
1078 /* Call FUN on each register or MEM that is stored into or clobbered by X.
1079 (X would be the pattern of an insn).
1080 FUN receives two arguments:
1081 the REG, MEM, CC0 or PC being stored in or clobbered,
1082 the SET or CLOBBER rtx that does the store.
1084 If the item being stored in or clobbered is a SUBREG of a hard register,
1085 the SUBREG will be passed. */
1088 note_stores (x, fun, data)
1090 void (*fun) PARAMS ((rtx, rtx, void *));
1093 if ((GET_CODE (x) == SET || GET_CODE (x) == CLOBBER))
1095 register rtx dest = SET_DEST (x);
1096 while ((GET_CODE (dest) == SUBREG
1097 && (GET_CODE (SUBREG_REG (dest)) != REG
1098 || REGNO (SUBREG_REG (dest)) >= FIRST_PSEUDO_REGISTER))
1099 || GET_CODE (dest) == ZERO_EXTRACT
1100 || GET_CODE (dest) == SIGN_EXTRACT
1101 || GET_CODE (dest) == STRICT_LOW_PART)
1102 dest = XEXP (dest, 0);
1104 if (GET_CODE (dest) == PARALLEL
1105 && GET_MODE (dest) == BLKmode)
1108 for (i = XVECLEN (dest, 0) - 1; i >= 0; i--)
1109 (*fun) (SET_DEST (XVECEXP (dest, 0, i)), x, data);
1112 (*fun) (dest, x, data);
1114 else if (GET_CODE (x) == PARALLEL)
1117 for (i = XVECLEN (x, 0) - 1; i >= 0; i--)
1119 register rtx y = XVECEXP (x, 0, i);
1120 if (GET_CODE (y) == SET || GET_CODE (y) == CLOBBER)
1122 register rtx dest = SET_DEST (y);
1123 while ((GET_CODE (dest) == SUBREG
1124 && (GET_CODE (SUBREG_REG (dest)) != REG
1125 || (REGNO (SUBREG_REG (dest))
1126 >= FIRST_PSEUDO_REGISTER)))
1127 || GET_CODE (dest) == ZERO_EXTRACT
1128 || GET_CODE (dest) == SIGN_EXTRACT
1129 || GET_CODE (dest) == STRICT_LOW_PART)
1130 dest = XEXP (dest, 0);
1131 if (GET_CODE (dest) == PARALLEL
1132 && GET_MODE (dest) == BLKmode)
1135 for (i = XVECLEN (dest, 0) - 1; i >= 0; i--)
1136 (*fun) (SET_DEST (XVECEXP (dest, 0, i)), y, data);
1139 (*fun) (dest, y, data);
1145 /* Return nonzero if X's old contents don't survive after INSN.
1146 This will be true if X is (cc0) or if X is a register and
1147 X dies in INSN or because INSN entirely sets X.
1149 "Entirely set" means set directly and not through a SUBREG,
1150 ZERO_EXTRACT or SIGN_EXTRACT, so no trace of the old contents remains.
1151 Likewise, REG_INC does not count.
1153 REG may be a hard or pseudo reg. Renumbering is not taken into account,
1154 but for this use that makes no difference, since regs don't overlap
1155 during their lifetimes. Therefore, this function may be used
1156 at any time after deaths have been computed (in flow.c).
1158 If REG is a hard reg that occupies multiple machine registers, this
1159 function will only return 1 if each of those registers will be replaced
1163 dead_or_set_p (insn, x)
1167 register int regno, last_regno;
1170 /* Can't use cc0_rtx below since this file is used by genattrtab.c. */
1171 if (GET_CODE (x) == CC0)
1174 if (GET_CODE (x) != REG)
1178 last_regno = (regno >= FIRST_PSEUDO_REGISTER ? regno
1179 : regno + HARD_REGNO_NREGS (regno, GET_MODE (x)) - 1);
1181 for (i = regno; i <= last_regno; i++)
1182 if (! dead_or_set_regno_p (insn, i))
1188 /* Utility function for dead_or_set_p to check an individual register. Also
1189 called from flow.c. */
1192 dead_or_set_regno_p (insn, test_regno)
1196 int regno, endregno;
1199 /* See if there is a death note for something that includes
1201 for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
1203 if (REG_NOTE_KIND (link) != REG_DEAD
1204 || GET_CODE (XEXP (link, 0)) != REG)
1207 regno = REGNO (XEXP (link, 0));
1208 endregno = (regno >= FIRST_PSEUDO_REGISTER ? regno + 1
1209 : regno + HARD_REGNO_NREGS (regno,
1210 GET_MODE (XEXP (link, 0))));
1212 if (test_regno >= regno && test_regno < endregno)
1216 if (GET_CODE (insn) == CALL_INSN
1217 && find_regno_fusage (insn, CLOBBER, test_regno))
1220 if (GET_CODE (PATTERN (insn)) == SET)
1222 rtx dest = SET_DEST (PATTERN (insn));
1224 /* A value is totally replaced if it is the destination or the
1225 destination is a SUBREG of REGNO that does not change the number of
1227 if (GET_CODE (dest) == SUBREG
1228 && (((GET_MODE_SIZE (GET_MODE (dest))
1229 + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
1230 == ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (dest)))
1231 + UNITS_PER_WORD - 1) / UNITS_PER_WORD)))
1232 dest = SUBREG_REG (dest);
1234 if (GET_CODE (dest) != REG)
1237 regno = REGNO (dest);
1238 endregno = (regno >= FIRST_PSEUDO_REGISTER ? regno + 1
1239 : regno + HARD_REGNO_NREGS (regno, GET_MODE (dest)));
1241 return (test_regno >= regno && test_regno < endregno);
1243 else if (GET_CODE (PATTERN (insn)) == PARALLEL)
1247 for (i = XVECLEN (PATTERN (insn), 0) - 1; i >= 0; i--)
1249 rtx body = XVECEXP (PATTERN (insn), 0, i);
1251 if (GET_CODE (body) == SET || GET_CODE (body) == CLOBBER)
1253 rtx dest = SET_DEST (body);
1255 if (GET_CODE (dest) == SUBREG
1256 && (((GET_MODE_SIZE (GET_MODE (dest))
1257 + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
1258 == ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (dest)))
1259 + UNITS_PER_WORD - 1) / UNITS_PER_WORD)))
1260 dest = SUBREG_REG (dest);
1262 if (GET_CODE (dest) != REG)
1265 regno = REGNO (dest);
1266 endregno = (regno >= FIRST_PSEUDO_REGISTER ? regno + 1
1267 : regno + HARD_REGNO_NREGS (regno, GET_MODE (dest)));
1269 if (test_regno >= regno && test_regno < endregno)
1278 /* Return the reg-note of kind KIND in insn INSN, if there is one.
1279 If DATUM is nonzero, look for one whose datum is DATUM. */
1282 find_reg_note (insn, kind, datum)
1289 /* Ignore anything that is not an INSN, JUMP_INSN or CALL_INSN. */
1290 if (GET_RTX_CLASS (GET_CODE (insn)) != 'i')
1293 for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
1294 if (REG_NOTE_KIND (link) == kind
1295 && (datum == 0 || datum == XEXP (link, 0)))
1300 /* Return the reg-note of kind KIND in insn INSN which applies to register
1301 number REGNO, if any. Return 0 if there is no such reg-note. Note that
1302 the REGNO of this NOTE need not be REGNO if REGNO is a hard register;
1303 it might be the case that the note overlaps REGNO. */
1306 find_regno_note (insn, kind, regno)
1313 /* Ignore anything that is not an INSN, JUMP_INSN or CALL_INSN. */
1314 if (GET_RTX_CLASS (GET_CODE (insn)) != 'i')
1317 for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
1318 if (REG_NOTE_KIND (link) == kind
1319 /* Verify that it is a register, so that scratch and MEM won't cause a
1321 && GET_CODE (XEXP (link, 0)) == REG
1322 && REGNO (XEXP (link, 0)) <= regno
1323 && ((REGNO (XEXP (link, 0))
1324 + (REGNO (XEXP (link, 0)) >= FIRST_PSEUDO_REGISTER ? 1
1325 : HARD_REGNO_NREGS (REGNO (XEXP (link, 0)),
1326 GET_MODE (XEXP (link, 0)))))
1332 /* Return true if DATUM, or any overlap of DATUM, of kind CODE is found
1333 in the CALL_INSN_FUNCTION_USAGE information of INSN. */
1336 find_reg_fusage (insn, code, datum)
1341 /* If it's not a CALL_INSN, it can't possibly have a
1342 CALL_INSN_FUNCTION_USAGE field, so don't bother checking. */
1343 if (GET_CODE (insn) != CALL_INSN)
1349 if (GET_CODE (datum) != REG)
1353 for (link = CALL_INSN_FUNCTION_USAGE (insn);
1355 link = XEXP (link, 1))
1356 if (GET_CODE (XEXP (link, 0)) == code
1357 && rtx_equal_p (datum, SET_DEST (XEXP (link, 0))))
1362 register int regno = REGNO (datum);
1364 /* CALL_INSN_FUNCTION_USAGE information cannot contain references
1365 to pseudo registers, so don't bother checking. */
1367 if (regno < FIRST_PSEUDO_REGISTER)
1369 int end_regno = regno + HARD_REGNO_NREGS (regno, GET_MODE (datum));
1372 for (i = regno; i < end_regno; i++)
1373 if (find_regno_fusage (insn, code, i))
1381 /* Return true if REGNO, or any overlap of REGNO, of kind CODE is found
1382 in the CALL_INSN_FUNCTION_USAGE information of INSN. */
1385 find_regno_fusage (insn, code, regno)
1392 /* CALL_INSN_FUNCTION_USAGE information cannot contain references
1393 to pseudo registers, so don't bother checking. */
1395 if (regno >= FIRST_PSEUDO_REGISTER
1396 || GET_CODE (insn) != CALL_INSN )
1399 for (link = CALL_INSN_FUNCTION_USAGE (insn); link; link = XEXP (link, 1))
1401 register int regnote;
1402 register rtx op, reg;
1404 if (GET_CODE (op = XEXP (link, 0)) == code
1405 && GET_CODE (reg = XEXP (op, 0)) == REG
1406 && (regnote = REGNO (reg)) <= regno
1407 && regnote + HARD_REGNO_NREGS (regnote, GET_MODE (reg)) > regno)
1414 /* Remove register note NOTE from the REG_NOTES of INSN. */
1417 remove_note (insn, note)
1423 if (note == NULL_RTX)
1426 if (REG_NOTES (insn) == note)
1428 REG_NOTES (insn) = XEXP (note, 1);
1432 for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
1433 if (XEXP (link, 1) == note)
1435 XEXP (link, 1) = XEXP (note, 1);
1442 /* Search LISTP (an EXPR_LIST) for NODE and remove NODE from the list
1445 A simple equality test is used to determine if NODE is on the
1449 remove_node_from_expr_list (node, listp)
1454 rtx prev = NULL_RTX;
1458 if (node == XEXP (temp, 0))
1460 /* Splice the node out of the list. */
1462 XEXP (prev, 1) = XEXP (temp, 1);
1464 *listp = XEXP (temp, 1);
1468 temp = XEXP (temp, 1);
1472 /* Nonzero if X contains any volatile instructions. These are instructions
1473 which may cause unpredictable machine state instructions, and thus no
1474 instructions should be moved or combined across them. This includes
1475 only volatile asms and UNSPEC_VOLATILE instructions. */
1481 register RTX_CODE code;
1483 code = GET_CODE (x);
1503 case UNSPEC_VOLATILE:
1504 /* case TRAP_IF: This isn't clear yet. */
1508 if (MEM_VOLATILE_P (x))
1515 /* Recursively scan the operands of this expression. */
1518 register const char *fmt = GET_RTX_FORMAT (code);
1521 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
1525 if (volatile_insn_p (XEXP (x, i)))
1528 else if (fmt[i] == 'E')
1531 for (j = 0; j < XVECLEN (x, i); j++)
1532 if (volatile_insn_p (XVECEXP (x, i, j)))
1540 /* Nonzero if X contains any volatile memory references
1541 UNSPEC_VOLATILE operations or volatile ASM_OPERANDS expressions. */
1547 register RTX_CODE code;
1549 code = GET_CODE (x);
1568 case UNSPEC_VOLATILE:
1569 /* case TRAP_IF: This isn't clear yet. */
1574 if (MEM_VOLATILE_P (x))
1581 /* Recursively scan the operands of this expression. */
1584 register const char *fmt = GET_RTX_FORMAT (code);
1587 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
1591 if (volatile_refs_p (XEXP (x, i)))
1594 else if (fmt[i] == 'E')
1597 for (j = 0; j < XVECLEN (x, i); j++)
1598 if (volatile_refs_p (XVECEXP (x, i, j)))
1606 /* Similar to above, except that it also rejects register pre- and post-
1613 register RTX_CODE code;
1615 code = GET_CODE (x);
1633 /* Reject CLOBBER with a non-VOID mode. These are made by combine.c
1634 when some combination can't be done. If we see one, don't think
1635 that we can simplify the expression. */
1636 return (GET_MODE (x) != VOIDmode);
1643 case UNSPEC_VOLATILE:
1644 /* case TRAP_IF: This isn't clear yet. */
1649 if (MEM_VOLATILE_P (x))
1656 /* Recursively scan the operands of this expression. */
1659 register const char *fmt = GET_RTX_FORMAT (code);
1662 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
1666 if (side_effects_p (XEXP (x, i)))
1669 else if (fmt[i] == 'E')
1672 for (j = 0; j < XVECLEN (x, i); j++)
1673 if (side_effects_p (XVECEXP (x, i, j)))
1681 /* Return nonzero if evaluating rtx X might cause a trap. */
1693 code = GET_CODE (x);
1696 /* Handle these cases quickly. */
1708 /* Conditional trap can trap! */
1709 case UNSPEC_VOLATILE:
1713 /* Memory ref can trap unless it's a static var or a stack slot. */
1715 return rtx_addr_can_trap_p (XEXP (x, 0));
1717 /* Division by a non-constant might trap. */
1722 if (! CONSTANT_P (XEXP (x, 1))
1723 || GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
1725 /* This was const0_rtx, but by not using that,
1726 we can link this file into other programs. */
1727 if (GET_CODE (XEXP (x, 1)) == CONST_INT && INTVAL (XEXP (x, 1)) == 0)
1732 /* An EXPR_LIST is used to represent a function call. This
1733 certainly may trap. */
1737 /* Any floating arithmetic may trap. */
1738 if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
1742 fmt = GET_RTX_FORMAT (code);
1743 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
1747 if (may_trap_p (XEXP (x, i)))
1750 else if (fmt[i] == 'E')
1753 for (j = 0; j < XVECLEN (x, i); j++)
1754 if (may_trap_p (XVECEXP (x, i, j)))
1761 /* Return nonzero if X contains a comparison that is not either EQ or NE,
1762 i.e., an inequality. */
1765 inequality_comparisons_p (x)
1768 register const char *fmt;
1769 register int len, i;
1770 register enum rtx_code code = GET_CODE (x);
1799 len = GET_RTX_LENGTH (code);
1800 fmt = GET_RTX_FORMAT (code);
1802 for (i = 0; i < len; i++)
1806 if (inequality_comparisons_p (XEXP (x, i)))
1809 else if (fmt[i] == 'E')
1812 for (j = XVECLEN (x, i) - 1; j >= 0; j--)
1813 if (inequality_comparisons_p (XVECEXP (x, i, j)))
1821 /* Replace any occurrence of FROM in X with TO. The function does
1822 not enter into CONST_DOUBLE for the replace.
1824 Note that copying is not done so X must not be shared unless all copies
1825 are to be modified. */
1828 replace_rtx (x, from, to)
1832 register const char *fmt;
1834 /* The following prevents loops occurrence when we change MEM in
1835 CONST_DOUBLE onto the same CONST_DOUBLE. */
1836 if (x != 0 && GET_CODE (x) == CONST_DOUBLE)
1842 /* Allow this function to make replacements in EXPR_LISTs. */
1846 fmt = GET_RTX_FORMAT (GET_CODE (x));
1847 for (i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; i--)
1850 XEXP (x, i) = replace_rtx (XEXP (x, i), from, to);
1851 else if (fmt[i] == 'E')
1852 for (j = XVECLEN (x, i) - 1; j >= 0; j--)
1853 XVECEXP (x, i, j) = replace_rtx (XVECEXP (x, i, j), from, to);
1859 /* Throughout the rtx X, replace many registers according to REG_MAP.
1860 Return the replacement for X (which may be X with altered contents).
1861 REG_MAP[R] is the replacement for register R, or 0 for don't replace.
1862 NREGS is the length of REG_MAP; regs >= NREGS are not mapped.
1864 We only support REG_MAP entries of REG or SUBREG. Also, hard registers
1865 should not be mapped to pseudos or vice versa since validate_change
1868 If REPLACE_DEST is 1, replacements are also done in destinations;
1869 otherwise, only sources are replaced. */
1872 replace_regs (x, reg_map, nregs, replace_dest)
1878 register enum rtx_code code;
1880 register const char *fmt;
1885 code = GET_CODE (x);
1899 /* Verify that the register has an entry before trying to access it. */
1900 if (REGNO (x) < nregs && reg_map[REGNO (x)] != 0)
1902 /* SUBREGs can't be shared. Always return a copy to ensure that if
1903 this replacement occurs more than once then each instance will
1904 get distinct rtx. */
1905 if (GET_CODE (reg_map[REGNO (x)]) == SUBREG)
1906 return copy_rtx (reg_map[REGNO (x)]);
1907 return reg_map[REGNO (x)];
1912 /* Prevent making nested SUBREGs. */
1913 if (GET_CODE (SUBREG_REG (x)) == REG && REGNO (SUBREG_REG (x)) < nregs
1914 && reg_map[REGNO (SUBREG_REG (x))] != 0
1915 && GET_CODE (reg_map[REGNO (SUBREG_REG (x))]) == SUBREG)
1917 rtx map_val = reg_map[REGNO (SUBREG_REG (x))];
1918 rtx map_inner = SUBREG_REG (map_val);
1920 if (GET_MODE (x) == GET_MODE (map_inner))
1924 /* We cannot call gen_rtx here since we may be linked with
1926 /* Let's try clobbering the incoming SUBREG and see
1927 if this is really safe. */
1928 SUBREG_REG (x) = map_inner;
1929 SUBREG_WORD (x) += SUBREG_WORD (map_val);
1932 rtx new = rtx_alloc (SUBREG);
1933 PUT_MODE (new, GET_MODE (x));
1934 SUBREG_REG (new) = map_inner;
1935 SUBREG_WORD (new) = SUBREG_WORD (x) + SUBREG_WORD (map_val);
1943 SET_DEST (x) = replace_regs (SET_DEST (x), reg_map, nregs, 0);
1945 else if (GET_CODE (SET_DEST (x)) == MEM
1946 || GET_CODE (SET_DEST (x)) == STRICT_LOW_PART)
1947 /* Even if we are not to replace destinations, replace register if it
1948 is CONTAINED in destination (destination is memory or
1949 STRICT_LOW_PART). */
1950 XEXP (SET_DEST (x), 0) = replace_regs (XEXP (SET_DEST (x), 0),
1952 else if (GET_CODE (SET_DEST (x)) == ZERO_EXTRACT)
1953 /* Similarly, for ZERO_EXTRACT we replace all operands. */
1956 SET_SRC (x) = replace_regs (SET_SRC (x), reg_map, nregs, 0);
1963 fmt = GET_RTX_FORMAT (code);
1964 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
1967 XEXP (x, i) = replace_regs (XEXP (x, i), reg_map, nregs, replace_dest);
1968 else if (fmt[i] == 'E')
1971 for (j = 0; j < XVECLEN (x, i); j++)
1972 XVECEXP (x, i, j) = replace_regs (XVECEXP (x, i, j), reg_map,
1973 nregs, replace_dest);
1979 /* Return 1 if X, the SRC_SRC of SET of (pc) contain a REG or MEM that is
1980 not in the constant pool and not in the condition of an IF_THEN_ELSE. */
1983 jmp_uses_reg_or_mem (x)
1986 enum rtx_code code = GET_CODE (x);
2001 return ! (GET_CODE (XEXP (x, 0)) == SYMBOL_REF
2002 && CONSTANT_POOL_ADDRESS_P (XEXP (x, 0)));
2005 return (jmp_uses_reg_or_mem (XEXP (x, 1))
2006 || jmp_uses_reg_or_mem (XEXP (x, 2)));
2008 case PLUS: case MINUS: case MULT:
2009 return (jmp_uses_reg_or_mem (XEXP (x, 0))
2010 || jmp_uses_reg_or_mem (XEXP (x, 1)));
2016 fmt = GET_RTX_FORMAT (code);
2017 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
2020 && jmp_uses_reg_or_mem (XEXP (x, i)))
2023 else if (fmt[i] == 'E')
2024 for (j = 0; j < XVECLEN (x, i); j++)
2025 if (jmp_uses_reg_or_mem (XVECEXP (x, i, j)))
2032 /* Return nonzero if INSN is an indirect jump (aka computed jump).
2034 Tablejumps and casesi insns are not considered indirect jumps;
2035 we can recognize them by a (use (lael_ref)). */
2038 computed_jump_p (insn)
2042 if (GET_CODE (insn) == JUMP_INSN)
2044 rtx pat = PATTERN (insn);
2046 if (GET_CODE (pat) == PARALLEL)
2048 int len = XVECLEN (pat, 0);
2049 int has_use_labelref = 0;
2051 for (i = len - 1; i >= 0; i--)
2052 if (GET_CODE (XVECEXP (pat, 0, i)) == USE
2053 && (GET_CODE (XEXP (XVECEXP (pat, 0, i), 0))
2055 has_use_labelref = 1;
2057 if (! has_use_labelref)
2058 for (i = len - 1; i >= 0; i--)
2059 if (GET_CODE (XVECEXP (pat, 0, i)) == SET
2060 && SET_DEST (XVECEXP (pat, 0, i)) == pc_rtx
2061 && jmp_uses_reg_or_mem (SET_SRC (XVECEXP (pat, 0, i))))
2064 else if (GET_CODE (pat) == SET
2065 && SET_DEST (pat) == pc_rtx
2066 && jmp_uses_reg_or_mem (SET_SRC (pat)))
2072 /* Traverse X via depth-first search, calling F for each
2073 sub-expression (including X itself). F is also passed the DATA.
2074 If F returns -1, do not traverse sub-expressions, but continue
2075 traversing the rest of the tree. If F ever returns any other
2076 non-zero value, stop the traversal, and return the value returned
2077 by F. Otherwise, return 0. This function does not traverse inside
2078 tree structure that contains RTX_EXPRs, or into sub-expressions
2079 whose format code is `0' since it is not known whether or not those
2080 codes are actually RTL.
2082 This routine is very general, and could (should?) be used to
2083 implement many of the other routines in this file. */
2086 for_each_rtx (x, f, data)
2097 result = (*f)(x, data);
2099 /* Do not traverse sub-expressions. */
2101 else if (result != 0)
2102 /* Stop the traversal. */
2106 /* There are no sub-expressions. */
2109 length = GET_RTX_LENGTH (GET_CODE (*x));
2110 format = GET_RTX_FORMAT (GET_CODE (*x));
2112 for (i = 0; i < length; ++i)
2117 result = for_each_rtx (&XEXP (*x, i), f, data);
2124 if (XVEC (*x, i) != 0)
2127 for (j = 0; j < XVECLEN (*x, i); ++j)
2129 result = for_each_rtx (&XVECEXP (*x, i, j), f, data);
2137 /* Nothing to do. */
2146 /* Searches X for any reference to REGNO, returning the rtx of the
2147 reference found if any. Otherwise, returns NULL_RTX. */
2150 regno_use_in (regno, x)
2154 register const char *fmt;
2158 if (GET_CODE (x) == REG && REGNO (x) == regno)
2161 fmt = GET_RTX_FORMAT (GET_CODE (x));
2162 for (i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; i--)
2166 if ((tem = regno_use_in (regno, XEXP (x, i))))
2169 else if (fmt[i] == 'E')
2170 for (j = XVECLEN (x, i) - 1; j >= 0; j--)
2171 if ((tem = regno_use_in (regno , XVECEXP (x, i, j))))
2179 /* Return 1 if X is an autoincrement side effect and the register is
2180 not the stack pointer. */
2185 switch (GET_CODE (x))
2193 /* There are no REG_INC notes for SP. */
2194 if (XEXP (x, 0) != stack_pointer_rtx)
2202 /* Return 1 if the sequence of instructions beginning with FROM and up
2203 to and including TO is safe to move. If NEW_TO is non-NULL, and
2204 the sequence is not already safe to move, but can be easily
2205 extended to a sequence which is safe, then NEW_TO will point to the
2206 end of the extended sequence.
2208 For now, this function only checks that the region contains whole
2209 exception regiongs, but it could be extended to check additional
2210 conditions as well. */
2213 insns_safe_to_move_p (from, to, new_to)
2218 int eh_region_count = 0;
2222 /* By default, assume the end of the region will be what was
2229 if (GET_CODE (r) == NOTE)
2231 switch (NOTE_LINE_NUMBER (r))
2233 case NOTE_INSN_EH_REGION_BEG:
2237 case NOTE_INSN_EH_REGION_END:
2238 if (eh_region_count == 0)
2239 /* This sequence of instructions contains the end of
2240 an exception region, but not he beginning. Moving
2241 it will cause chaos. */
2252 /* If we've passed TO, and we see a non-note instruction, we
2253 can't extend the sequence to a movable sequence. */
2259 /* It's OK to move the sequence if there were matched sets of
2260 exception region notes. */
2261 return eh_region_count == 0;
2266 /* It's OK to move the sequence if there were matched sets of
2267 exception region notes. */
2268 if (past_to_p && eh_region_count == 0)
2274 /* Go to the next instruction. */