]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/recog.c
ra.h (add_neighbor): Fix -Wc++-compat and/or -Wcast-qual warnings.
[thirdparty/gcc.git] / gcc / recog.c
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, 2008
4 Free Software Foundation, Inc.
5
6 This file is part of GCC.
7
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
11 version.
12
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
16 for more details.
17
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/>. */
21
22
23 #include "config.h"
24 #include "system.h"
25 #include "coretypes.h"
26 #include "tm.h"
27 #include "rtl.h"
28 #include "tm_p.h"
29 #include "insn-config.h"
30 #include "insn-attr.h"
31 #include "hard-reg-set.h"
32 #include "recog.h"
33 #include "regs.h"
34 #include "addresses.h"
35 #include "expr.h"
36 #include "function.h"
37 #include "flags.h"
38 #include "real.h"
39 #include "toplev.h"
40 #include "basic-block.h"
41 #include "output.h"
42 #include "reload.h"
43 #include "timevar.h"
44 #include "tree-pass.h"
45 #include "df.h"
46
47 #ifndef STACK_PUSH_CODE
48 #ifdef STACK_GROWS_DOWNWARD
49 #define STACK_PUSH_CODE PRE_DEC
50 #else
51 #define STACK_PUSH_CODE PRE_INC
52 #endif
53 #endif
54
55 #ifndef STACK_POP_CODE
56 #ifdef STACK_GROWS_DOWNWARD
57 #define STACK_POP_CODE POST_INC
58 #else
59 #define STACK_POP_CODE POST_DEC
60 #endif
61 #endif
62
63 #ifndef HAVE_ATTR_enabled
64 static inline bool
65 get_attr_enabled (rtx insn ATTRIBUTE_UNUSED)
66 {
67 return true;
68 }
69 #endif
70
71 static void validate_replace_rtx_1 (rtx *, rtx, rtx, rtx);
72 static void validate_replace_src_1 (rtx *, void *);
73 static rtx split_insn (rtx);
74
75 /* Nonzero means allow operands to be volatile.
76 This should be 0 if you are generating rtl, such as if you are calling
77 the functions in optabs.c and expmed.c (most of the time).
78 This should be 1 if all valid insns need to be recognized,
79 such as in regclass.c and final.c and reload.c.
80
81 init_recog and init_recog_no_volatile are responsible for setting this. */
82
83 int volatile_ok;
84
85 struct recog_data recog_data;
86
87 /* Contains a vector of operand_alternative structures for every operand.
88 Set up by preprocess_constraints. */
89 struct operand_alternative recog_op_alt[MAX_RECOG_OPERANDS][MAX_RECOG_ALTERNATIVES];
90
91 /* On return from `constrain_operands', indicate which alternative
92 was satisfied. */
93
94 int which_alternative;
95
96 /* Nonzero after end of reload pass.
97 Set to 1 or 0 by toplev.c.
98 Controls the significance of (SUBREG (MEM)). */
99
100 int reload_completed;
101
102 /* Nonzero after thread_prologue_and_epilogue_insns has run. */
103 int epilogue_completed;
104
105 /* Initialize data used by the function `recog'.
106 This must be called once in the compilation of a function
107 before any insn recognition may be done in the function. */
108
109 void
110 init_recog_no_volatile (void)
111 {
112 volatile_ok = 0;
113 }
114
115 void
116 init_recog (void)
117 {
118 volatile_ok = 1;
119 }
120
121 \f
122 /* Check that X is an insn-body for an `asm' with operands
123 and that the operands mentioned in it are legitimate. */
124
125 int
126 check_asm_operands (rtx x)
127 {
128 int noperands;
129 rtx *operands;
130 const char **constraints;
131 int i;
132
133 /* Post-reload, be more strict with things. */
134 if (reload_completed)
135 {
136 /* ??? Doh! We've not got the wrapping insn. Cook one up. */
137 extract_insn (make_insn_raw (x));
138 constrain_operands (1);
139 return which_alternative >= 0;
140 }
141
142 noperands = asm_noperands (x);
143 if (noperands < 0)
144 return 0;
145 if (noperands == 0)
146 return 1;
147
148 operands = XALLOCAVEC (rtx, noperands);
149 constraints = XALLOCAVEC (const char *, noperands);
150
151 decode_asm_operands (x, operands, NULL, constraints, NULL, NULL);
152
153 for (i = 0; i < noperands; i++)
154 {
155 const char *c = constraints[i];
156 if (c[0] == '%')
157 c++;
158 if (ISDIGIT ((unsigned char) c[0]) && c[1] == '\0')
159 c = constraints[c[0] - '0'];
160
161 if (! asm_operand_ok (operands[i], c))
162 return 0;
163 }
164
165 return 1;
166 }
167 \f
168 /* Static data for the next two routines. */
169
170 typedef struct change_t
171 {
172 rtx object;
173 int old_code;
174 rtx *loc;
175 rtx old;
176 bool unshare;
177 } change_t;
178
179 static change_t *changes;
180 static int changes_allocated;
181
182 static int num_changes = 0;
183
184 /* Validate a proposed change to OBJECT. LOC is the location in the rtl
185 at which NEW will be placed. If OBJECT is zero, no validation is done,
186 the change is simply made.
187
188 Two types of objects are supported: If OBJECT is a MEM, memory_address_p
189 will be called with the address and mode as parameters. If OBJECT is
190 an INSN, CALL_INSN, or JUMP_INSN, the insn will be re-recognized with
191 the change in place.
192
193 IN_GROUP is nonzero if this is part of a group of changes that must be
194 performed as a group. In that case, the changes will be stored. The
195 function `apply_change_group' will validate and apply the changes.
196
197 If IN_GROUP is zero, this is a single change. Try to recognize the insn
198 or validate the memory reference with the change applied. If the result
199 is not valid for the machine, suppress the change and return zero.
200 Otherwise, perform the change and return 1. */
201
202 static bool
203 validate_change_1 (rtx object, rtx *loc, rtx new, bool in_group, bool unshare)
204 {
205 rtx old = *loc;
206
207 if (old == new || rtx_equal_p (old, new))
208 return 1;
209
210 gcc_assert (in_group != 0 || num_changes == 0);
211
212 *loc = new;
213
214 /* Save the information describing this change. */
215 if (num_changes >= changes_allocated)
216 {
217 if (changes_allocated == 0)
218 /* This value allows for repeated substitutions inside complex
219 indexed addresses, or changes in up to 5 insns. */
220 changes_allocated = MAX_RECOG_OPERANDS * 5;
221 else
222 changes_allocated *= 2;
223
224 changes = XRESIZEVEC (change_t, changes, changes_allocated);
225 }
226
227 changes[num_changes].object = object;
228 changes[num_changes].loc = loc;
229 changes[num_changes].old = old;
230 changes[num_changes].unshare = unshare;
231
232 if (object && !MEM_P (object))
233 {
234 /* Set INSN_CODE to force rerecognition of insn. Save old code in
235 case invalid. */
236 changes[num_changes].old_code = INSN_CODE (object);
237 INSN_CODE (object) = -1;
238 }
239
240 num_changes++;
241
242 /* If we are making a group of changes, return 1. Otherwise, validate the
243 change group we made. */
244
245 if (in_group)
246 return 1;
247 else
248 return apply_change_group ();
249 }
250
251 /* Wrapper for validate_change_1 without the UNSHARE argument defaulting
252 UNSHARE to false. */
253
254 bool
255 validate_change (rtx object, rtx *loc, rtx new, bool in_group)
256 {
257 return validate_change_1 (object, loc, new, in_group, false);
258 }
259
260 /* Wrapper for validate_change_1 without the UNSHARE argument defaulting
261 UNSHARE to true. */
262
263 bool
264 validate_unshare_change (rtx object, rtx *loc, rtx new, bool in_group)
265 {
266 return validate_change_1 (object, loc, new, in_group, true);
267 }
268
269
270 /* Keep X canonicalized if some changes have made it non-canonical; only
271 modifies the operands of X, not (for example) its code. Simplifications
272 are not the job of this routine.
273
274 Return true if anything was changed. */
275 bool
276 canonicalize_change_group (rtx insn, rtx x)
277 {
278 if (COMMUTATIVE_P (x)
279 && swap_commutative_operands_p (XEXP (x, 0), XEXP (x, 1)))
280 {
281 /* Oops, the caller has made X no longer canonical.
282 Let's redo the changes in the correct order. */
283 rtx tem = XEXP (x, 0);
284 validate_change (insn, &XEXP (x, 0), XEXP (x, 1), 1);
285 validate_change (insn, &XEXP (x, 1), tem, 1);
286 return true;
287 }
288 else
289 return false;
290 }
291
292
293 /* This subroutine of apply_change_group verifies whether the changes to INSN
294 were valid; i.e. whether INSN can still be recognized. */
295
296 int
297 insn_invalid_p (rtx insn)
298 {
299 rtx pat = PATTERN (insn);
300 int num_clobbers = 0;
301 /* If we are before reload and the pattern is a SET, see if we can add
302 clobbers. */
303 int icode = recog (pat, insn,
304 (GET_CODE (pat) == SET
305 && ! reload_completed && ! reload_in_progress)
306 ? &num_clobbers : 0);
307 int is_asm = icode < 0 && asm_noperands (PATTERN (insn)) >= 0;
308
309
310 /* If this is an asm and the operand aren't legal, then fail. Likewise if
311 this is not an asm and the insn wasn't recognized. */
312 if ((is_asm && ! check_asm_operands (PATTERN (insn)))
313 || (!is_asm && icode < 0))
314 return 1;
315
316 /* If we have to add CLOBBERs, fail if we have to add ones that reference
317 hard registers since our callers can't know if they are live or not.
318 Otherwise, add them. */
319 if (num_clobbers > 0)
320 {
321 rtx newpat;
322
323 if (added_clobbers_hard_reg_p (icode))
324 return 1;
325
326 newpat = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (num_clobbers + 1));
327 XVECEXP (newpat, 0, 0) = pat;
328 add_clobbers (newpat, icode);
329 PATTERN (insn) = pat = newpat;
330 }
331
332 /* After reload, verify that all constraints are satisfied. */
333 if (reload_completed)
334 {
335 extract_insn (insn);
336
337 if (! constrain_operands (1))
338 return 1;
339 }
340
341 INSN_CODE (insn) = icode;
342 return 0;
343 }
344
345 /* Return number of changes made and not validated yet. */
346 int
347 num_changes_pending (void)
348 {
349 return num_changes;
350 }
351
352 /* Tentatively apply the changes numbered NUM and up.
353 Return 1 if all changes are valid, zero otherwise. */
354
355 int
356 verify_changes (int num)
357 {
358 int i;
359 rtx last_validated = NULL_RTX;
360
361 /* The changes have been applied and all INSN_CODEs have been reset to force
362 rerecognition.
363
364 The changes are valid if we aren't given an object, or if we are
365 given a MEM and it still is a valid address, or if this is in insn
366 and it is recognized. In the latter case, if reload has completed,
367 we also require that the operands meet the constraints for
368 the insn. */
369
370 for (i = num; i < num_changes; i++)
371 {
372 rtx object = changes[i].object;
373
374 /* If there is no object to test or if it is the same as the one we
375 already tested, ignore it. */
376 if (object == 0 || object == last_validated)
377 continue;
378
379 if (MEM_P (object))
380 {
381 if (! memory_address_p (GET_MODE (object), XEXP (object, 0)))
382 break;
383 }
384 else if (insn_invalid_p (object))
385 {
386 rtx pat = PATTERN (object);
387
388 /* Perhaps we couldn't recognize the insn because there were
389 extra CLOBBERs at the end. If so, try to re-recognize
390 without the last CLOBBER (later iterations will cause each of
391 them to be eliminated, in turn). But don't do this if we
392 have an ASM_OPERAND. */
393 if (GET_CODE (pat) == PARALLEL
394 && GET_CODE (XVECEXP (pat, 0, XVECLEN (pat, 0) - 1)) == CLOBBER
395 && asm_noperands (PATTERN (object)) < 0)
396 {
397 rtx newpat;
398
399 if (XVECLEN (pat, 0) == 2)
400 newpat = XVECEXP (pat, 0, 0);
401 else
402 {
403 int j;
404
405 newpat
406 = gen_rtx_PARALLEL (VOIDmode,
407 rtvec_alloc (XVECLEN (pat, 0) - 1));
408 for (j = 0; j < XVECLEN (newpat, 0); j++)
409 XVECEXP (newpat, 0, j) = XVECEXP (pat, 0, j);
410 }
411
412 /* Add a new change to this group to replace the pattern
413 with this new pattern. Then consider this change
414 as having succeeded. The change we added will
415 cause the entire call to fail if things remain invalid.
416
417 Note that this can lose if a later change than the one
418 we are processing specified &XVECEXP (PATTERN (object), 0, X)
419 but this shouldn't occur. */
420
421 validate_change (object, &PATTERN (object), newpat, 1);
422 continue;
423 }
424 else if (GET_CODE (pat) == USE || GET_CODE (pat) == CLOBBER)
425 /* If this insn is a CLOBBER or USE, it is always valid, but is
426 never recognized. */
427 continue;
428 else
429 break;
430 }
431 last_validated = object;
432 }
433
434 return (i == num_changes);
435 }
436
437 /* A group of changes has previously been issued with validate_change
438 and verified with verify_changes. Call df_insn_rescan for each of
439 the insn changed and clear num_changes. */
440
441 void
442 confirm_change_group (void)
443 {
444 int i;
445 rtx last_object = NULL;
446
447 for (i = 0; i < num_changes; i++)
448 {
449 rtx object = changes[i].object;
450
451 if (changes[i].unshare)
452 *changes[i].loc = copy_rtx (*changes[i].loc);
453
454 /* Avoid unnecessary rescanning when multiple changes to same instruction
455 are made. */
456 if (object)
457 {
458 if (object != last_object && last_object && INSN_P (last_object))
459 df_insn_rescan (last_object);
460 last_object = object;
461 }
462 }
463
464 if (last_object && INSN_P (last_object))
465 df_insn_rescan (last_object);
466 num_changes = 0;
467 }
468
469 /* Apply a group of changes previously issued with `validate_change'.
470 If all changes are valid, call confirm_change_group and return 1,
471 otherwise, call cancel_changes and return 0. */
472
473 int
474 apply_change_group (void)
475 {
476 if (verify_changes (0))
477 {
478 confirm_change_group ();
479 return 1;
480 }
481 else
482 {
483 cancel_changes (0);
484 return 0;
485 }
486 }
487
488
489 /* Return the number of changes so far in the current group. */
490
491 int
492 num_validated_changes (void)
493 {
494 return num_changes;
495 }
496
497 /* Retract the changes numbered NUM and up. */
498
499 void
500 cancel_changes (int num)
501 {
502 int i;
503
504 /* Back out all the changes. Do this in the opposite order in which
505 they were made. */
506 for (i = num_changes - 1; i >= num; i--)
507 {
508 *changes[i].loc = changes[i].old;
509 if (changes[i].object && !MEM_P (changes[i].object))
510 INSN_CODE (changes[i].object) = changes[i].old_code;
511 }
512 num_changes = num;
513 }
514
515 /* Replace every occurrence of FROM in X with TO. Mark each change with
516 validate_change passing OBJECT. */
517
518 static void
519 validate_replace_rtx_1 (rtx *loc, rtx from, rtx to, rtx object)
520 {
521 int i, j;
522 const char *fmt;
523 rtx x = *loc;
524 enum rtx_code code;
525 enum machine_mode op0_mode = VOIDmode;
526 int prev_changes = num_changes;
527 rtx new;
528
529 if (!x)
530 return;
531
532 code = GET_CODE (x);
533 fmt = GET_RTX_FORMAT (code);
534 if (fmt[0] == 'e')
535 op0_mode = GET_MODE (XEXP (x, 0));
536
537 /* X matches FROM if it is the same rtx or they are both referring to the
538 same register in the same mode. Avoid calling rtx_equal_p unless the
539 operands look similar. */
540
541 if (x == from
542 || (REG_P (x) && REG_P (from)
543 && GET_MODE (x) == GET_MODE (from)
544 && REGNO (x) == REGNO (from))
545 || (GET_CODE (x) == GET_CODE (from) && GET_MODE (x) == GET_MODE (from)
546 && rtx_equal_p (x, from)))
547 {
548 validate_unshare_change (object, loc, to, 1);
549 return;
550 }
551
552 /* Call ourself recursively to perform the replacements.
553 We must not replace inside already replaced expression, otherwise we
554 get infinite recursion for replacements like (reg X)->(subreg (reg X))
555 done by regmove, so we must special case shared ASM_OPERANDS. */
556
557 if (GET_CODE (x) == PARALLEL)
558 {
559 for (j = XVECLEN (x, 0) - 1; j >= 0; j--)
560 {
561 if (j && GET_CODE (XVECEXP (x, 0, j)) == SET
562 && GET_CODE (SET_SRC (XVECEXP (x, 0, j))) == ASM_OPERANDS)
563 {
564 /* Verify that operands are really shared. */
565 gcc_assert (ASM_OPERANDS_INPUT_VEC (SET_SRC (XVECEXP (x, 0, 0)))
566 == ASM_OPERANDS_INPUT_VEC (SET_SRC (XVECEXP
567 (x, 0, j))));
568 validate_replace_rtx_1 (&SET_DEST (XVECEXP (x, 0, j)),
569 from, to, object);
570 }
571 else
572 validate_replace_rtx_1 (&XVECEXP (x, 0, j), from, to, object);
573 }
574 }
575 else
576 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
577 {
578 if (fmt[i] == 'e')
579 validate_replace_rtx_1 (&XEXP (x, i), from, to, object);
580 else if (fmt[i] == 'E')
581 for (j = XVECLEN (x, i) - 1; j >= 0; j--)
582 validate_replace_rtx_1 (&XVECEXP (x, i, j), from, to, object);
583 }
584
585 /* If we didn't substitute, there is nothing more to do. */
586 if (num_changes == prev_changes)
587 return;
588
589 /* Allow substituted expression to have different mode. This is used by
590 regmove to change mode of pseudo register. */
591 if (fmt[0] == 'e' && GET_MODE (XEXP (x, 0)) != VOIDmode)
592 op0_mode = GET_MODE (XEXP (x, 0));
593
594 /* Do changes needed to keep rtx consistent. Don't do any other
595 simplifications, as it is not our job. */
596
597 if (SWAPPABLE_OPERANDS_P (x)
598 && swap_commutative_operands_p (XEXP (x, 0), XEXP (x, 1)))
599 {
600 validate_unshare_change (object, loc,
601 gen_rtx_fmt_ee (COMMUTATIVE_ARITH_P (x) ? code
602 : swap_condition (code),
603 GET_MODE (x), XEXP (x, 1),
604 XEXP (x, 0)), 1);
605 x = *loc;
606 code = GET_CODE (x);
607 }
608
609 switch (code)
610 {
611 case PLUS:
612 /* If we have a PLUS whose second operand is now a CONST_INT, use
613 simplify_gen_binary to try to simplify it.
614 ??? We may want later to remove this, once simplification is
615 separated from this function. */
616 if (GET_CODE (XEXP (x, 1)) == CONST_INT && XEXP (x, 1) == to)
617 validate_change (object, loc,
618 simplify_gen_binary
619 (PLUS, GET_MODE (x), XEXP (x, 0), XEXP (x, 1)), 1);
620 break;
621 case MINUS:
622 if (GET_CODE (XEXP (x, 1)) == CONST_INT
623 || GET_CODE (XEXP (x, 1)) == CONST_DOUBLE)
624 validate_change (object, loc,
625 simplify_gen_binary
626 (PLUS, GET_MODE (x), XEXP (x, 0),
627 simplify_gen_unary (NEG,
628 GET_MODE (x), XEXP (x, 1),
629 GET_MODE (x))), 1);
630 break;
631 case ZERO_EXTEND:
632 case SIGN_EXTEND:
633 if (GET_MODE (XEXP (x, 0)) == VOIDmode)
634 {
635 new = simplify_gen_unary (code, GET_MODE (x), XEXP (x, 0),
636 op0_mode);
637 /* If any of the above failed, substitute in something that
638 we know won't be recognized. */
639 if (!new)
640 new = gen_rtx_CLOBBER (GET_MODE (x), const0_rtx);
641 validate_change (object, loc, new, 1);
642 }
643 break;
644 case SUBREG:
645 /* All subregs possible to simplify should be simplified. */
646 new = simplify_subreg (GET_MODE (x), SUBREG_REG (x), op0_mode,
647 SUBREG_BYTE (x));
648
649 /* Subregs of VOIDmode operands are incorrect. */
650 if (!new && GET_MODE (SUBREG_REG (x)) == VOIDmode)
651 new = gen_rtx_CLOBBER (GET_MODE (x), const0_rtx);
652 if (new)
653 validate_change (object, loc, new, 1);
654 break;
655 case ZERO_EXTRACT:
656 case SIGN_EXTRACT:
657 /* If we are replacing a register with memory, try to change the memory
658 to be the mode required for memory in extract operations (this isn't
659 likely to be an insertion operation; if it was, nothing bad will
660 happen, we might just fail in some cases). */
661
662 if (MEM_P (XEXP (x, 0))
663 && GET_CODE (XEXP (x, 1)) == CONST_INT
664 && GET_CODE (XEXP (x, 2)) == CONST_INT
665 && !mode_dependent_address_p (XEXP (XEXP (x, 0), 0))
666 && !MEM_VOLATILE_P (XEXP (x, 0)))
667 {
668 enum machine_mode wanted_mode = VOIDmode;
669 enum machine_mode is_mode = GET_MODE (XEXP (x, 0));
670 int pos = INTVAL (XEXP (x, 2));
671
672 if (GET_CODE (x) == ZERO_EXTRACT)
673 {
674 enum machine_mode new_mode
675 = mode_for_extraction (EP_extzv, 1);
676 if (new_mode != MAX_MACHINE_MODE)
677 wanted_mode = new_mode;
678 }
679 else if (GET_CODE (x) == SIGN_EXTRACT)
680 {
681 enum machine_mode new_mode
682 = mode_for_extraction (EP_extv, 1);
683 if (new_mode != MAX_MACHINE_MODE)
684 wanted_mode = new_mode;
685 }
686
687 /* If we have a narrower mode, we can do something. */
688 if (wanted_mode != VOIDmode
689 && GET_MODE_SIZE (wanted_mode) < GET_MODE_SIZE (is_mode))
690 {
691 int offset = pos / BITS_PER_UNIT;
692 rtx newmem;
693
694 /* If the bytes and bits are counted differently, we
695 must adjust the offset. */
696 if (BYTES_BIG_ENDIAN != BITS_BIG_ENDIAN)
697 offset =
698 (GET_MODE_SIZE (is_mode) - GET_MODE_SIZE (wanted_mode) -
699 offset);
700
701 pos %= GET_MODE_BITSIZE (wanted_mode);
702
703 newmem = adjust_address_nv (XEXP (x, 0), wanted_mode, offset);
704
705 validate_change (object, &XEXP (x, 2), GEN_INT (pos), 1);
706 validate_change (object, &XEXP (x, 0), newmem, 1);
707 }
708 }
709
710 break;
711
712 default:
713 break;
714 }
715 }
716
717 /* Try replacing every occurrence of FROM in INSN with TO. After all
718 changes have been made, validate by seeing if INSN is still valid. */
719
720 int
721 validate_replace_rtx (rtx from, rtx to, rtx insn)
722 {
723 validate_replace_rtx_1 (&PATTERN (insn), from, to, insn);
724 return apply_change_group ();
725 }
726
727 /* Try replacing every occurrence of FROM in INSN with TO. */
728
729 void
730 validate_replace_rtx_group (rtx from, rtx to, rtx insn)
731 {
732 validate_replace_rtx_1 (&PATTERN (insn), from, to, insn);
733 }
734
735 /* Function called by note_uses to replace used subexpressions. */
736 struct validate_replace_src_data
737 {
738 rtx from; /* Old RTX */
739 rtx to; /* New RTX */
740 rtx insn; /* Insn in which substitution is occurring. */
741 };
742
743 static void
744 validate_replace_src_1 (rtx *x, void *data)
745 {
746 struct validate_replace_src_data *d
747 = (struct validate_replace_src_data *) data;
748
749 validate_replace_rtx_1 (x, d->from, d->to, d->insn);
750 }
751
752 /* Try replacing every occurrence of FROM in INSN with TO, avoiding
753 SET_DESTs. */
754
755 void
756 validate_replace_src_group (rtx from, rtx to, rtx insn)
757 {
758 struct validate_replace_src_data d;
759
760 d.from = from;
761 d.to = to;
762 d.insn = insn;
763 note_uses (&PATTERN (insn), validate_replace_src_1, &d);
764 }
765
766 /* Try simplify INSN.
767 Invoke simplify_rtx () on every SET_SRC and SET_DEST inside the INSN's
768 pattern and return true if something was simplified. */
769
770 bool
771 validate_simplify_insn (rtx insn)
772 {
773 int i;
774 rtx pat = NULL;
775 rtx newpat = NULL;
776
777 pat = PATTERN (insn);
778
779 if (GET_CODE (pat) == SET)
780 {
781 newpat = simplify_rtx (SET_SRC (pat));
782 if (newpat && !rtx_equal_p (SET_SRC (pat), newpat))
783 validate_change (insn, &SET_SRC (pat), newpat, 1);
784 newpat = simplify_rtx (SET_DEST (pat));
785 if (newpat && !rtx_equal_p (SET_DEST (pat), newpat))
786 validate_change (insn, &SET_DEST (pat), newpat, 1);
787 }
788 else if (GET_CODE (pat) == PARALLEL)
789 for (i = 0; i < XVECLEN (pat, 0); i++)
790 {
791 rtx s = XVECEXP (pat, 0, i);
792
793 if (GET_CODE (XVECEXP (pat, 0, i)) == SET)
794 {
795 newpat = simplify_rtx (SET_SRC (s));
796 if (newpat && !rtx_equal_p (SET_SRC (s), newpat))
797 validate_change (insn, &SET_SRC (s), newpat, 1);
798 newpat = simplify_rtx (SET_DEST (s));
799 if (newpat && !rtx_equal_p (SET_DEST (s), newpat))
800 validate_change (insn, &SET_DEST (s), newpat, 1);
801 }
802 }
803 return ((num_changes_pending () > 0) && (apply_change_group () > 0));
804 }
805 \f
806 #ifdef HAVE_cc0
807 /* Return 1 if the insn using CC0 set by INSN does not contain
808 any ordered tests applied to the condition codes.
809 EQ and NE tests do not count. */
810
811 int
812 next_insn_tests_no_inequality (rtx insn)
813 {
814 rtx next = next_cc0_user (insn);
815
816 /* If there is no next insn, we have to take the conservative choice. */
817 if (next == 0)
818 return 0;
819
820 return (INSN_P (next)
821 && ! inequality_comparisons_p (PATTERN (next)));
822 }
823 #endif
824 \f
825 /* Return 1 if OP is a valid general operand for machine mode MODE.
826 This is either a register reference, a memory reference,
827 or a constant. In the case of a memory reference, the address
828 is checked for general validity for the target machine.
829
830 Register and memory references must have mode MODE in order to be valid,
831 but some constants have no machine mode and are valid for any mode.
832
833 If MODE is VOIDmode, OP is checked for validity for whatever mode
834 it has.
835
836 The main use of this function is as a predicate in match_operand
837 expressions in the machine description.
838
839 For an explanation of this function's behavior for registers of
840 class NO_REGS, see the comment for `register_operand'. */
841
842 int
843 general_operand (rtx op, enum machine_mode mode)
844 {
845 enum rtx_code code = GET_CODE (op);
846
847 if (mode == VOIDmode)
848 mode = GET_MODE (op);
849
850 /* Don't accept CONST_INT or anything similar
851 if the caller wants something floating. */
852 if (GET_MODE (op) == VOIDmode && mode != VOIDmode
853 && GET_MODE_CLASS (mode) != MODE_INT
854 && GET_MODE_CLASS (mode) != MODE_PARTIAL_INT)
855 return 0;
856
857 if (GET_CODE (op) == CONST_INT
858 && mode != VOIDmode
859 && trunc_int_for_mode (INTVAL (op), mode) != INTVAL (op))
860 return 0;
861
862 if (CONSTANT_P (op))
863 return ((GET_MODE (op) == VOIDmode || GET_MODE (op) == mode
864 || mode == VOIDmode)
865 && (! flag_pic || LEGITIMATE_PIC_OPERAND_P (op))
866 && LEGITIMATE_CONSTANT_P (op));
867
868 /* Except for certain constants with VOIDmode, already checked for,
869 OP's mode must match MODE if MODE specifies a mode. */
870
871 if (GET_MODE (op) != mode)
872 return 0;
873
874 if (code == SUBREG)
875 {
876 rtx sub = SUBREG_REG (op);
877
878 #ifdef INSN_SCHEDULING
879 /* On machines that have insn scheduling, we want all memory
880 reference to be explicit, so outlaw paradoxical SUBREGs.
881 However, we must allow them after reload so that they can
882 get cleaned up by cleanup_subreg_operands. */
883 if (!reload_completed && MEM_P (sub)
884 && GET_MODE_SIZE (mode) > GET_MODE_SIZE (GET_MODE (sub)))
885 return 0;
886 #endif
887 /* Avoid memories with nonzero SUBREG_BYTE, as offsetting the memory
888 may result in incorrect reference. We should simplify all valid
889 subregs of MEM anyway. But allow this after reload because we
890 might be called from cleanup_subreg_operands.
891
892 ??? This is a kludge. */
893 if (!reload_completed && SUBREG_BYTE (op) != 0
894 && MEM_P (sub))
895 return 0;
896
897 /* FLOAT_MODE subregs can't be paradoxical. Combine will occasionally
898 create such rtl, and we must reject it. */
899 if (SCALAR_FLOAT_MODE_P (GET_MODE (op))
900 && GET_MODE_SIZE (GET_MODE (op)) > GET_MODE_SIZE (GET_MODE (sub)))
901 return 0;
902
903 op = sub;
904 code = GET_CODE (op);
905 }
906
907 if (code == REG)
908 /* A register whose class is NO_REGS is not a general operand. */
909 return (REGNO (op) >= FIRST_PSEUDO_REGISTER
910 || REGNO_REG_CLASS (REGNO (op)) != NO_REGS);
911
912 if (code == MEM)
913 {
914 rtx y = XEXP (op, 0);
915
916 if (! volatile_ok && MEM_VOLATILE_P (op))
917 return 0;
918
919 /* Use the mem's mode, since it will be reloaded thus. */
920 if (memory_address_p (GET_MODE (op), y))
921 return 1;
922 }
923
924 return 0;
925 }
926 \f
927 /* Return 1 if OP is a valid memory address for a memory reference
928 of mode MODE.
929
930 The main use of this function is as a predicate in match_operand
931 expressions in the machine description. */
932
933 int
934 address_operand (rtx op, enum machine_mode mode)
935 {
936 return memory_address_p (mode, op);
937 }
938
939 /* Return 1 if OP is a register reference of mode MODE.
940 If MODE is VOIDmode, accept a register in any mode.
941
942 The main use of this function is as a predicate in match_operand
943 expressions in the machine description.
944
945 As a special exception, registers whose class is NO_REGS are
946 not accepted by `register_operand'. The reason for this change
947 is to allow the representation of special architecture artifacts
948 (such as a condition code register) without extending the rtl
949 definitions. Since registers of class NO_REGS cannot be used
950 as registers in any case where register classes are examined,
951 it is most consistent to keep this function from accepting them. */
952
953 int
954 register_operand (rtx op, enum machine_mode mode)
955 {
956 if (GET_MODE (op) != mode && mode != VOIDmode)
957 return 0;
958
959 if (GET_CODE (op) == SUBREG)
960 {
961 rtx sub = SUBREG_REG (op);
962
963 /* Before reload, we can allow (SUBREG (MEM...)) as a register operand
964 because it is guaranteed to be reloaded into one.
965 Just make sure the MEM is valid in itself.
966 (Ideally, (SUBREG (MEM)...) should not exist after reload,
967 but currently it does result from (SUBREG (REG)...) where the
968 reg went on the stack.) */
969 if (! reload_completed && MEM_P (sub))
970 return general_operand (op, mode);
971
972 #ifdef CANNOT_CHANGE_MODE_CLASS
973 if (REG_P (sub)
974 && REGNO (sub) < FIRST_PSEUDO_REGISTER
975 && REG_CANNOT_CHANGE_MODE_P (REGNO (sub), GET_MODE (sub), mode)
976 && GET_MODE_CLASS (GET_MODE (sub)) != MODE_COMPLEX_INT
977 && GET_MODE_CLASS (GET_MODE (sub)) != MODE_COMPLEX_FLOAT)
978 return 0;
979 #endif
980
981 /* FLOAT_MODE subregs can't be paradoxical. Combine will occasionally
982 create such rtl, and we must reject it. */
983 if (SCALAR_FLOAT_MODE_P (GET_MODE (op))
984 && GET_MODE_SIZE (GET_MODE (op)) > GET_MODE_SIZE (GET_MODE (sub)))
985 return 0;
986
987 op = sub;
988 }
989
990 /* We don't consider registers whose class is NO_REGS
991 to be a register operand. */
992 return (REG_P (op)
993 && (REGNO (op) >= FIRST_PSEUDO_REGISTER
994 || REGNO_REG_CLASS (REGNO (op)) != NO_REGS));
995 }
996
997 /* Return 1 for a register in Pmode; ignore the tested mode. */
998
999 int
1000 pmode_register_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
1001 {
1002 return register_operand (op, Pmode);
1003 }
1004
1005 /* Return 1 if OP should match a MATCH_SCRATCH, i.e., if it is a SCRATCH
1006 or a hard register. */
1007
1008 int
1009 scratch_operand (rtx op, enum machine_mode mode)
1010 {
1011 if (GET_MODE (op) != mode && mode != VOIDmode)
1012 return 0;
1013
1014 return (GET_CODE (op) == SCRATCH
1015 || (REG_P (op)
1016 && REGNO (op) < FIRST_PSEUDO_REGISTER));
1017 }
1018
1019 /* Return 1 if OP is a valid immediate operand for mode MODE.
1020
1021 The main use of this function is as a predicate in match_operand
1022 expressions in the machine description. */
1023
1024 int
1025 immediate_operand (rtx op, enum machine_mode mode)
1026 {
1027 /* Don't accept CONST_INT or anything similar
1028 if the caller wants something floating. */
1029 if (GET_MODE (op) == VOIDmode && mode != VOIDmode
1030 && GET_MODE_CLASS (mode) != MODE_INT
1031 && GET_MODE_CLASS (mode) != MODE_PARTIAL_INT)
1032 return 0;
1033
1034 if (GET_CODE (op) == CONST_INT
1035 && mode != VOIDmode
1036 && trunc_int_for_mode (INTVAL (op), mode) != INTVAL (op))
1037 return 0;
1038
1039 return (CONSTANT_P (op)
1040 && (GET_MODE (op) == mode || mode == VOIDmode
1041 || GET_MODE (op) == VOIDmode)
1042 && (! flag_pic || LEGITIMATE_PIC_OPERAND_P (op))
1043 && LEGITIMATE_CONSTANT_P (op));
1044 }
1045
1046 /* Returns 1 if OP is an operand that is a CONST_INT. */
1047
1048 int
1049 const_int_operand (rtx op, enum machine_mode mode)
1050 {
1051 if (GET_CODE (op) != CONST_INT)
1052 return 0;
1053
1054 if (mode != VOIDmode
1055 && trunc_int_for_mode (INTVAL (op), mode) != INTVAL (op))
1056 return 0;
1057
1058 return 1;
1059 }
1060
1061 /* Returns 1 if OP is an operand that is a constant integer or constant
1062 floating-point number. */
1063
1064 int
1065 const_double_operand (rtx op, enum machine_mode mode)
1066 {
1067 /* Don't accept CONST_INT or anything similar
1068 if the caller wants something floating. */
1069 if (GET_MODE (op) == VOIDmode && mode != VOIDmode
1070 && GET_MODE_CLASS (mode) != MODE_INT
1071 && GET_MODE_CLASS (mode) != MODE_PARTIAL_INT)
1072 return 0;
1073
1074 return ((GET_CODE (op) == CONST_DOUBLE || GET_CODE (op) == CONST_INT)
1075 && (mode == VOIDmode || GET_MODE (op) == mode
1076 || GET_MODE (op) == VOIDmode));
1077 }
1078
1079 /* Return 1 if OP is a general operand that is not an immediate operand. */
1080
1081 int
1082 nonimmediate_operand (rtx op, enum machine_mode mode)
1083 {
1084 return (general_operand (op, mode) && ! CONSTANT_P (op));
1085 }
1086
1087 /* Return 1 if OP is a register reference or immediate value of mode MODE. */
1088
1089 int
1090 nonmemory_operand (rtx op, enum machine_mode mode)
1091 {
1092 if (CONSTANT_P (op))
1093 {
1094 /* Don't accept CONST_INT or anything similar
1095 if the caller wants something floating. */
1096 if (GET_MODE (op) == VOIDmode && mode != VOIDmode
1097 && GET_MODE_CLASS (mode) != MODE_INT
1098 && GET_MODE_CLASS (mode) != MODE_PARTIAL_INT)
1099 return 0;
1100
1101 if (GET_CODE (op) == CONST_INT
1102 && mode != VOIDmode
1103 && trunc_int_for_mode (INTVAL (op), mode) != INTVAL (op))
1104 return 0;
1105
1106 return ((GET_MODE (op) == VOIDmode || GET_MODE (op) == mode
1107 || mode == VOIDmode)
1108 && (! flag_pic || LEGITIMATE_PIC_OPERAND_P (op))
1109 && LEGITIMATE_CONSTANT_P (op));
1110 }
1111
1112 if (GET_MODE (op) != mode && mode != VOIDmode)
1113 return 0;
1114
1115 if (GET_CODE (op) == SUBREG)
1116 {
1117 /* Before reload, we can allow (SUBREG (MEM...)) as a register operand
1118 because it is guaranteed to be reloaded into one.
1119 Just make sure the MEM is valid in itself.
1120 (Ideally, (SUBREG (MEM)...) should not exist after reload,
1121 but currently it does result from (SUBREG (REG)...) where the
1122 reg went on the stack.) */
1123 if (! reload_completed && MEM_P (SUBREG_REG (op)))
1124 return general_operand (op, mode);
1125 op = SUBREG_REG (op);
1126 }
1127
1128 /* We don't consider registers whose class is NO_REGS
1129 to be a register operand. */
1130 return (REG_P (op)
1131 && (REGNO (op) >= FIRST_PSEUDO_REGISTER
1132 || REGNO_REG_CLASS (REGNO (op)) != NO_REGS));
1133 }
1134
1135 /* Return 1 if OP is a valid operand that stands for pushing a
1136 value of mode MODE onto the stack.
1137
1138 The main use of this function is as a predicate in match_operand
1139 expressions in the machine description. */
1140
1141 int
1142 push_operand (rtx op, enum machine_mode mode)
1143 {
1144 unsigned int rounded_size = GET_MODE_SIZE (mode);
1145
1146 #ifdef PUSH_ROUNDING
1147 rounded_size = PUSH_ROUNDING (rounded_size);
1148 #endif
1149
1150 if (!MEM_P (op))
1151 return 0;
1152
1153 if (mode != VOIDmode && GET_MODE (op) != mode)
1154 return 0;
1155
1156 op = XEXP (op, 0);
1157
1158 if (rounded_size == GET_MODE_SIZE (mode))
1159 {
1160 if (GET_CODE (op) != STACK_PUSH_CODE)
1161 return 0;
1162 }
1163 else
1164 {
1165 if (GET_CODE (op) != PRE_MODIFY
1166 || GET_CODE (XEXP (op, 1)) != PLUS
1167 || XEXP (XEXP (op, 1), 0) != XEXP (op, 0)
1168 || GET_CODE (XEXP (XEXP (op, 1), 1)) != CONST_INT
1169 #ifdef STACK_GROWS_DOWNWARD
1170 || INTVAL (XEXP (XEXP (op, 1), 1)) != - (int) rounded_size
1171 #else
1172 || INTVAL (XEXP (XEXP (op, 1), 1)) != (int) rounded_size
1173 #endif
1174 )
1175 return 0;
1176 }
1177
1178 return XEXP (op, 0) == stack_pointer_rtx;
1179 }
1180
1181 /* Return 1 if OP is a valid operand that stands for popping a
1182 value of mode MODE off the stack.
1183
1184 The main use of this function is as a predicate in match_operand
1185 expressions in the machine description. */
1186
1187 int
1188 pop_operand (rtx op, enum machine_mode mode)
1189 {
1190 if (!MEM_P (op))
1191 return 0;
1192
1193 if (mode != VOIDmode && GET_MODE (op) != mode)
1194 return 0;
1195
1196 op = XEXP (op, 0);
1197
1198 if (GET_CODE (op) != STACK_POP_CODE)
1199 return 0;
1200
1201 return XEXP (op, 0) == stack_pointer_rtx;
1202 }
1203
1204 /* Return 1 if ADDR is a valid memory address for mode MODE. */
1205
1206 int
1207 memory_address_p (enum machine_mode mode ATTRIBUTE_UNUSED, rtx addr)
1208 {
1209 GO_IF_LEGITIMATE_ADDRESS (mode, addr, win);
1210 return 0;
1211
1212 win:
1213 return 1;
1214 }
1215
1216 /* Return 1 if OP is a valid memory reference with mode MODE,
1217 including a valid address.
1218
1219 The main use of this function is as a predicate in match_operand
1220 expressions in the machine description. */
1221
1222 int
1223 memory_operand (rtx op, enum machine_mode mode)
1224 {
1225 rtx inner;
1226
1227 if (! reload_completed)
1228 /* Note that no SUBREG is a memory operand before end of reload pass,
1229 because (SUBREG (MEM...)) forces reloading into a register. */
1230 return MEM_P (op) && general_operand (op, mode);
1231
1232 if (mode != VOIDmode && GET_MODE (op) != mode)
1233 return 0;
1234
1235 inner = op;
1236 if (GET_CODE (inner) == SUBREG)
1237 inner = SUBREG_REG (inner);
1238
1239 return (MEM_P (inner) && general_operand (op, mode));
1240 }
1241
1242 /* Return 1 if OP is a valid indirect memory reference with mode MODE;
1243 that is, a memory reference whose address is a general_operand. */
1244
1245 int
1246 indirect_operand (rtx op, enum machine_mode mode)
1247 {
1248 /* Before reload, a SUBREG isn't in memory (see memory_operand, above). */
1249 if (! reload_completed
1250 && GET_CODE (op) == SUBREG && MEM_P (SUBREG_REG (op)))
1251 {
1252 int offset = SUBREG_BYTE (op);
1253 rtx inner = SUBREG_REG (op);
1254
1255 if (mode != VOIDmode && GET_MODE (op) != mode)
1256 return 0;
1257
1258 /* The only way that we can have a general_operand as the resulting
1259 address is if OFFSET is zero and the address already is an operand
1260 or if the address is (plus Y (const_int -OFFSET)) and Y is an
1261 operand. */
1262
1263 return ((offset == 0 && general_operand (XEXP (inner, 0), Pmode))
1264 || (GET_CODE (XEXP (inner, 0)) == PLUS
1265 && GET_CODE (XEXP (XEXP (inner, 0), 1)) == CONST_INT
1266 && INTVAL (XEXP (XEXP (inner, 0), 1)) == -offset
1267 && general_operand (XEXP (XEXP (inner, 0), 0), Pmode)));
1268 }
1269
1270 return (MEM_P (op)
1271 && memory_operand (op, mode)
1272 && general_operand (XEXP (op, 0), Pmode));
1273 }
1274
1275 /* Return 1 if this is a comparison operator. This allows the use of
1276 MATCH_OPERATOR to recognize all the branch insns. */
1277
1278 int
1279 comparison_operator (rtx op, enum machine_mode mode)
1280 {
1281 return ((mode == VOIDmode || GET_MODE (op) == mode)
1282 && COMPARISON_P (op));
1283 }
1284 \f
1285 /* If BODY is an insn body that uses ASM_OPERANDS,
1286 return the number of operands (both input and output) in the insn.
1287 Otherwise return -1. */
1288
1289 int
1290 asm_noperands (const_rtx body)
1291 {
1292 switch (GET_CODE (body))
1293 {
1294 case ASM_OPERANDS:
1295 /* No output operands: return number of input operands. */
1296 return ASM_OPERANDS_INPUT_LENGTH (body);
1297 case SET:
1298 if (GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1299 /* Single output operand: BODY is (set OUTPUT (asm_operands ...)). */
1300 return ASM_OPERANDS_INPUT_LENGTH (SET_SRC (body)) + 1;
1301 else
1302 return -1;
1303 case PARALLEL:
1304 if (GET_CODE (XVECEXP (body, 0, 0)) == SET
1305 && GET_CODE (SET_SRC (XVECEXP (body, 0, 0))) == ASM_OPERANDS)
1306 {
1307 /* Multiple output operands, or 1 output plus some clobbers:
1308 body is [(set OUTPUT (asm_operands ...))... (clobber (reg ...))...]. */
1309 int i;
1310 int n_sets;
1311
1312 /* Count backwards through CLOBBERs to determine number of SETs. */
1313 for (i = XVECLEN (body, 0); i > 0; i--)
1314 {
1315 if (GET_CODE (XVECEXP (body, 0, i - 1)) == SET)
1316 break;
1317 if (GET_CODE (XVECEXP (body, 0, i - 1)) != CLOBBER)
1318 return -1;
1319 }
1320
1321 /* N_SETS is now number of output operands. */
1322 n_sets = i;
1323
1324 /* Verify that all the SETs we have
1325 came from a single original asm_operands insn
1326 (so that invalid combinations are blocked). */
1327 for (i = 0; i < n_sets; i++)
1328 {
1329 rtx elt = XVECEXP (body, 0, i);
1330 if (GET_CODE (elt) != SET)
1331 return -1;
1332 if (GET_CODE (SET_SRC (elt)) != ASM_OPERANDS)
1333 return -1;
1334 /* If these ASM_OPERANDS rtx's came from different original insns
1335 then they aren't allowed together. */
1336 if (ASM_OPERANDS_INPUT_VEC (SET_SRC (elt))
1337 != ASM_OPERANDS_INPUT_VEC (SET_SRC (XVECEXP (body, 0, 0))))
1338 return -1;
1339 }
1340 return (ASM_OPERANDS_INPUT_LENGTH (SET_SRC (XVECEXP (body, 0, 0)))
1341 + n_sets);
1342 }
1343 else if (GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1344 {
1345 /* 0 outputs, but some clobbers:
1346 body is [(asm_operands ...) (clobber (reg ...))...]. */
1347 int i;
1348
1349 /* Make sure all the other parallel things really are clobbers. */
1350 for (i = XVECLEN (body, 0) - 1; i > 0; i--)
1351 if (GET_CODE (XVECEXP (body, 0, i)) != CLOBBER)
1352 return -1;
1353
1354 return ASM_OPERANDS_INPUT_LENGTH (XVECEXP (body, 0, 0));
1355 }
1356 else
1357 return -1;
1358 default:
1359 return -1;
1360 }
1361 }
1362
1363 /* Assuming BODY is an insn body that uses ASM_OPERANDS,
1364 copy its operands (both input and output) into the vector OPERANDS,
1365 the locations of the operands within the insn into the vector OPERAND_LOCS,
1366 and the constraints for the operands into CONSTRAINTS.
1367 Write the modes of the operands into MODES.
1368 Return the assembler-template.
1369
1370 If MODES, OPERAND_LOCS, CONSTRAINTS or OPERANDS is 0,
1371 we don't store that info. */
1372
1373 const char *
1374 decode_asm_operands (rtx body, rtx *operands, rtx **operand_locs,
1375 const char **constraints, enum machine_mode *modes,
1376 location_t *loc)
1377 {
1378 int i;
1379 int noperands;
1380 rtx asmop = 0;
1381
1382 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1383 {
1384 asmop = SET_SRC (body);
1385 /* Single output operand: BODY is (set OUTPUT (asm_operands ....)). */
1386
1387 noperands = ASM_OPERANDS_INPUT_LENGTH (asmop) + 1;
1388
1389 for (i = 1; i < noperands; i++)
1390 {
1391 if (operand_locs)
1392 operand_locs[i] = &ASM_OPERANDS_INPUT (asmop, i - 1);
1393 if (operands)
1394 operands[i] = ASM_OPERANDS_INPUT (asmop, i - 1);
1395 if (constraints)
1396 constraints[i] = ASM_OPERANDS_INPUT_CONSTRAINT (asmop, i - 1);
1397 if (modes)
1398 modes[i] = ASM_OPERANDS_INPUT_MODE (asmop, i - 1);
1399 }
1400
1401 /* The output is in the SET.
1402 Its constraint is in the ASM_OPERANDS itself. */
1403 if (operands)
1404 operands[0] = SET_DEST (body);
1405 if (operand_locs)
1406 operand_locs[0] = &SET_DEST (body);
1407 if (constraints)
1408 constraints[0] = ASM_OPERANDS_OUTPUT_CONSTRAINT (asmop);
1409 if (modes)
1410 modes[0] = GET_MODE (SET_DEST (body));
1411 }
1412 else if (GET_CODE (body) == ASM_OPERANDS)
1413 {
1414 asmop = body;
1415 /* No output operands: BODY is (asm_operands ....). */
1416
1417 noperands = ASM_OPERANDS_INPUT_LENGTH (asmop);
1418
1419 /* The input operands are found in the 1st element vector. */
1420 /* Constraints for inputs are in the 2nd element vector. */
1421 for (i = 0; i < noperands; i++)
1422 {
1423 if (operand_locs)
1424 operand_locs[i] = &ASM_OPERANDS_INPUT (asmop, i);
1425 if (operands)
1426 operands[i] = ASM_OPERANDS_INPUT (asmop, i);
1427 if (constraints)
1428 constraints[i] = ASM_OPERANDS_INPUT_CONSTRAINT (asmop, i);
1429 if (modes)
1430 modes[i] = ASM_OPERANDS_INPUT_MODE (asmop, i);
1431 }
1432 }
1433 else if (GET_CODE (body) == PARALLEL
1434 && GET_CODE (XVECEXP (body, 0, 0)) == SET
1435 && GET_CODE (SET_SRC (XVECEXP (body, 0, 0))) == ASM_OPERANDS)
1436 {
1437 int nparallel = XVECLEN (body, 0); /* Includes CLOBBERs. */
1438 int nin;
1439 int nout = 0; /* Does not include CLOBBERs. */
1440
1441 asmop = SET_SRC (XVECEXP (body, 0, 0));
1442 nin = ASM_OPERANDS_INPUT_LENGTH (asmop);
1443
1444 /* At least one output, plus some CLOBBERs. */
1445
1446 /* The outputs are in the SETs.
1447 Their constraints are in the ASM_OPERANDS itself. */
1448 for (i = 0; i < nparallel; i++)
1449 {
1450 if (GET_CODE (XVECEXP (body, 0, i)) == CLOBBER)
1451 break; /* Past last SET */
1452
1453 if (operands)
1454 operands[i] = SET_DEST (XVECEXP (body, 0, i));
1455 if (operand_locs)
1456 operand_locs[i] = &SET_DEST (XVECEXP (body, 0, i));
1457 if (constraints)
1458 constraints[i] = XSTR (SET_SRC (XVECEXP (body, 0, i)), 1);
1459 if (modes)
1460 modes[i] = GET_MODE (SET_DEST (XVECEXP (body, 0, i)));
1461 nout++;
1462 }
1463
1464 for (i = 0; i < nin; i++)
1465 {
1466 if (operand_locs)
1467 operand_locs[i + nout] = &ASM_OPERANDS_INPUT (asmop, i);
1468 if (operands)
1469 operands[i + nout] = ASM_OPERANDS_INPUT (asmop, i);
1470 if (constraints)
1471 constraints[i + nout] = ASM_OPERANDS_INPUT_CONSTRAINT (asmop, i);
1472 if (modes)
1473 modes[i + nout] = ASM_OPERANDS_INPUT_MODE (asmop, i);
1474 }
1475 }
1476 else if (GET_CODE (body) == PARALLEL
1477 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1478 {
1479 /* No outputs, but some CLOBBERs. */
1480
1481 int nin;
1482
1483 asmop = XVECEXP (body, 0, 0);
1484 nin = ASM_OPERANDS_INPUT_LENGTH (asmop);
1485
1486 for (i = 0; i < nin; i++)
1487 {
1488 if (operand_locs)
1489 operand_locs[i] = &ASM_OPERANDS_INPUT (asmop, i);
1490 if (operands)
1491 operands[i] = ASM_OPERANDS_INPUT (asmop, i);
1492 if (constraints)
1493 constraints[i] = ASM_OPERANDS_INPUT_CONSTRAINT (asmop, i);
1494 if (modes)
1495 modes[i] = ASM_OPERANDS_INPUT_MODE (asmop, i);
1496 }
1497
1498 }
1499
1500 if (loc)
1501 *loc = ASM_OPERANDS_SOURCE_LOCATION (asmop);
1502
1503 return ASM_OPERANDS_TEMPLATE (asmop);
1504 }
1505
1506 /* Check if an asm_operand matches its constraints.
1507 Return > 0 if ok, = 0 if bad, < 0 if inconclusive. */
1508
1509 int
1510 asm_operand_ok (rtx op, const char *constraint)
1511 {
1512 int result = 0;
1513
1514 /* Use constrain_operands after reload. */
1515 gcc_assert (!reload_completed);
1516
1517 while (*constraint)
1518 {
1519 char c = *constraint;
1520 int len;
1521 switch (c)
1522 {
1523 case ',':
1524 constraint++;
1525 continue;
1526 case '=':
1527 case '+':
1528 case '*':
1529 case '%':
1530 case '!':
1531 case '#':
1532 case '&':
1533 case '?':
1534 break;
1535
1536 case '0': case '1': case '2': case '3': case '4':
1537 case '5': case '6': case '7': case '8': case '9':
1538 /* For best results, our caller should have given us the
1539 proper matching constraint, but we can't actually fail
1540 the check if they didn't. Indicate that results are
1541 inconclusive. */
1542 do
1543 constraint++;
1544 while (ISDIGIT (*constraint));
1545 if (! result)
1546 result = -1;
1547 continue;
1548
1549 case 'p':
1550 if (address_operand (op, VOIDmode))
1551 result = 1;
1552 break;
1553
1554 case TARGET_MEM_CONSTRAINT:
1555 case 'V': /* non-offsettable */
1556 if (memory_operand (op, VOIDmode))
1557 result = 1;
1558 break;
1559
1560 case 'o': /* offsettable */
1561 if (offsettable_nonstrict_memref_p (op))
1562 result = 1;
1563 break;
1564
1565 case '<':
1566 /* ??? Before auto-inc-dec, auto inc/dec insns are not supposed to exist,
1567 excepting those that expand_call created. Further, on some
1568 machines which do not have generalized auto inc/dec, an inc/dec
1569 is not a memory_operand.
1570
1571 Match any memory and hope things are resolved after reload. */
1572
1573 if (MEM_P (op)
1574 && (1
1575 || GET_CODE (XEXP (op, 0)) == PRE_DEC
1576 || GET_CODE (XEXP (op, 0)) == POST_DEC))
1577 result = 1;
1578 break;
1579
1580 case '>':
1581 if (MEM_P (op)
1582 && (1
1583 || GET_CODE (XEXP (op, 0)) == PRE_INC
1584 || GET_CODE (XEXP (op, 0)) == POST_INC))
1585 result = 1;
1586 break;
1587
1588 case 'E':
1589 case 'F':
1590 if (GET_CODE (op) == CONST_DOUBLE
1591 || (GET_CODE (op) == CONST_VECTOR
1592 && GET_MODE_CLASS (GET_MODE (op)) == MODE_VECTOR_FLOAT))
1593 result = 1;
1594 break;
1595
1596 case 'G':
1597 if (GET_CODE (op) == CONST_DOUBLE
1598 && CONST_DOUBLE_OK_FOR_CONSTRAINT_P (op, 'G', constraint))
1599 result = 1;
1600 break;
1601 case 'H':
1602 if (GET_CODE (op) == CONST_DOUBLE
1603 && CONST_DOUBLE_OK_FOR_CONSTRAINT_P (op, 'H', constraint))
1604 result = 1;
1605 break;
1606
1607 case 's':
1608 if (GET_CODE (op) == CONST_INT
1609 || (GET_CODE (op) == CONST_DOUBLE
1610 && GET_MODE (op) == VOIDmode))
1611 break;
1612 /* Fall through. */
1613
1614 case 'i':
1615 if (CONSTANT_P (op) && (! flag_pic || LEGITIMATE_PIC_OPERAND_P (op)))
1616 result = 1;
1617 break;
1618
1619 case 'n':
1620 if (GET_CODE (op) == CONST_INT
1621 || (GET_CODE (op) == CONST_DOUBLE
1622 && GET_MODE (op) == VOIDmode))
1623 result = 1;
1624 break;
1625
1626 case 'I':
1627 if (GET_CODE (op) == CONST_INT
1628 && CONST_OK_FOR_CONSTRAINT_P (INTVAL (op), 'I', constraint))
1629 result = 1;
1630 break;
1631 case 'J':
1632 if (GET_CODE (op) == CONST_INT
1633 && CONST_OK_FOR_CONSTRAINT_P (INTVAL (op), 'J', constraint))
1634 result = 1;
1635 break;
1636 case 'K':
1637 if (GET_CODE (op) == CONST_INT
1638 && CONST_OK_FOR_CONSTRAINT_P (INTVAL (op), 'K', constraint))
1639 result = 1;
1640 break;
1641 case 'L':
1642 if (GET_CODE (op) == CONST_INT
1643 && CONST_OK_FOR_CONSTRAINT_P (INTVAL (op), 'L', constraint))
1644 result = 1;
1645 break;
1646 case 'M':
1647 if (GET_CODE (op) == CONST_INT
1648 && CONST_OK_FOR_CONSTRAINT_P (INTVAL (op), 'M', constraint))
1649 result = 1;
1650 break;
1651 case 'N':
1652 if (GET_CODE (op) == CONST_INT
1653 && CONST_OK_FOR_CONSTRAINT_P (INTVAL (op), 'N', constraint))
1654 result = 1;
1655 break;
1656 case 'O':
1657 if (GET_CODE (op) == CONST_INT
1658 && CONST_OK_FOR_CONSTRAINT_P (INTVAL (op), 'O', constraint))
1659 result = 1;
1660 break;
1661 case 'P':
1662 if (GET_CODE (op) == CONST_INT
1663 && CONST_OK_FOR_CONSTRAINT_P (INTVAL (op), 'P', constraint))
1664 result = 1;
1665 break;
1666
1667 case 'X':
1668 result = 1;
1669 break;
1670
1671 case 'g':
1672 if (general_operand (op, VOIDmode))
1673 result = 1;
1674 break;
1675
1676 default:
1677 /* For all other letters, we first check for a register class,
1678 otherwise it is an EXTRA_CONSTRAINT. */
1679 if (REG_CLASS_FROM_CONSTRAINT (c, constraint) != NO_REGS)
1680 {
1681 case 'r':
1682 if (GET_MODE (op) == BLKmode)
1683 break;
1684 if (register_operand (op, VOIDmode))
1685 result = 1;
1686 }
1687 #ifdef EXTRA_CONSTRAINT_STR
1688 else if (EXTRA_CONSTRAINT_STR (op, c, constraint))
1689 result = 1;
1690 else if (EXTRA_MEMORY_CONSTRAINT (c, constraint)
1691 /* Every memory operand can be reloaded to fit. */
1692 && memory_operand (op, VOIDmode))
1693 result = 1;
1694 else if (EXTRA_ADDRESS_CONSTRAINT (c, constraint)
1695 /* Every address operand can be reloaded to fit. */
1696 && address_operand (op, VOIDmode))
1697 result = 1;
1698 #endif
1699 break;
1700 }
1701 len = CONSTRAINT_LEN (c, constraint);
1702 do
1703 constraint++;
1704 while (--len && *constraint);
1705 if (len)
1706 return 0;
1707 }
1708
1709 return result;
1710 }
1711 \f
1712 /* Given an rtx *P, if it is a sum containing an integer constant term,
1713 return the location (type rtx *) of the pointer to that constant term.
1714 Otherwise, return a null pointer. */
1715
1716 rtx *
1717 find_constant_term_loc (rtx *p)
1718 {
1719 rtx *tem;
1720 enum rtx_code code = GET_CODE (*p);
1721
1722 /* If *P IS such a constant term, P is its location. */
1723
1724 if (code == CONST_INT || code == SYMBOL_REF || code == LABEL_REF
1725 || code == CONST)
1726 return p;
1727
1728 /* Otherwise, if not a sum, it has no constant term. */
1729
1730 if (GET_CODE (*p) != PLUS)
1731 return 0;
1732
1733 /* If one of the summands is constant, return its location. */
1734
1735 if (XEXP (*p, 0) && CONSTANT_P (XEXP (*p, 0))
1736 && XEXP (*p, 1) && CONSTANT_P (XEXP (*p, 1)))
1737 return p;
1738
1739 /* Otherwise, check each summand for containing a constant term. */
1740
1741 if (XEXP (*p, 0) != 0)
1742 {
1743 tem = find_constant_term_loc (&XEXP (*p, 0));
1744 if (tem != 0)
1745 return tem;
1746 }
1747
1748 if (XEXP (*p, 1) != 0)
1749 {
1750 tem = find_constant_term_loc (&XEXP (*p, 1));
1751 if (tem != 0)
1752 return tem;
1753 }
1754
1755 return 0;
1756 }
1757 \f
1758 /* Return 1 if OP is a memory reference
1759 whose address contains no side effects
1760 and remains valid after the addition
1761 of a positive integer less than the
1762 size of the object being referenced.
1763
1764 We assume that the original address is valid and do not check it.
1765
1766 This uses strict_memory_address_p as a subroutine, so
1767 don't use it before reload. */
1768
1769 int
1770 offsettable_memref_p (rtx op)
1771 {
1772 return ((MEM_P (op))
1773 && offsettable_address_p (1, GET_MODE (op), XEXP (op, 0)));
1774 }
1775
1776 /* Similar, but don't require a strictly valid mem ref:
1777 consider pseudo-regs valid as index or base regs. */
1778
1779 int
1780 offsettable_nonstrict_memref_p (rtx op)
1781 {
1782 return ((MEM_P (op))
1783 && offsettable_address_p (0, GET_MODE (op), XEXP (op, 0)));
1784 }
1785
1786 /* Return 1 if Y is a memory address which contains no side effects
1787 and would remain valid after the addition of a positive integer
1788 less than the size of that mode.
1789
1790 We assume that the original address is valid and do not check it.
1791 We do check that it is valid for narrower modes.
1792
1793 If STRICTP is nonzero, we require a strictly valid address,
1794 for the sake of use in reload.c. */
1795
1796 int
1797 offsettable_address_p (int strictp, enum machine_mode mode, rtx y)
1798 {
1799 enum rtx_code ycode = GET_CODE (y);
1800 rtx z;
1801 rtx y1 = y;
1802 rtx *y2;
1803 int (*addressp) (enum machine_mode, rtx) =
1804 (strictp ? strict_memory_address_p : memory_address_p);
1805 unsigned int mode_sz = GET_MODE_SIZE (mode);
1806
1807 if (CONSTANT_ADDRESS_P (y))
1808 return 1;
1809
1810 /* Adjusting an offsettable address involves changing to a narrower mode.
1811 Make sure that's OK. */
1812
1813 if (mode_dependent_address_p (y))
1814 return 0;
1815
1816 /* ??? How much offset does an offsettable BLKmode reference need?
1817 Clearly that depends on the situation in which it's being used.
1818 However, the current situation in which we test 0xffffffff is
1819 less than ideal. Caveat user. */
1820 if (mode_sz == 0)
1821 mode_sz = BIGGEST_ALIGNMENT / BITS_PER_UNIT;
1822
1823 /* If the expression contains a constant term,
1824 see if it remains valid when max possible offset is added. */
1825
1826 if ((ycode == PLUS) && (y2 = find_constant_term_loc (&y1)))
1827 {
1828 int good;
1829
1830 y1 = *y2;
1831 *y2 = plus_constant (*y2, mode_sz - 1);
1832 /* Use QImode because an odd displacement may be automatically invalid
1833 for any wider mode. But it should be valid for a single byte. */
1834 good = (*addressp) (QImode, y);
1835
1836 /* In any case, restore old contents of memory. */
1837 *y2 = y1;
1838 return good;
1839 }
1840
1841 if (GET_RTX_CLASS (ycode) == RTX_AUTOINC)
1842 return 0;
1843
1844 /* The offset added here is chosen as the maximum offset that
1845 any instruction could need to add when operating on something
1846 of the specified mode. We assume that if Y and Y+c are
1847 valid addresses then so is Y+d for all 0<d<c. adjust_address will
1848 go inside a LO_SUM here, so we do so as well. */
1849 if (GET_CODE (y) == LO_SUM
1850 && mode != BLKmode
1851 && mode_sz <= GET_MODE_ALIGNMENT (mode) / BITS_PER_UNIT)
1852 z = gen_rtx_LO_SUM (GET_MODE (y), XEXP (y, 0),
1853 plus_constant (XEXP (y, 1), mode_sz - 1));
1854 else
1855 z = plus_constant (y, mode_sz - 1);
1856
1857 /* Use QImode because an odd displacement may be automatically invalid
1858 for any wider mode. But it should be valid for a single byte. */
1859 return (*addressp) (QImode, z);
1860 }
1861
1862 /* Return 1 if ADDR is an address-expression whose effect depends
1863 on the mode of the memory reference it is used in.
1864
1865 Autoincrement addressing is a typical example of mode-dependence
1866 because the amount of the increment depends on the mode. */
1867
1868 int
1869 mode_dependent_address_p (rtx addr)
1870 {
1871 /* Auto-increment addressing with anything other than post_modify
1872 or pre_modify always introduces a mode dependency. Catch such
1873 cases now instead of deferring to the target. */
1874 if (GET_CODE (addr) == PRE_INC
1875 || GET_CODE (addr) == POST_INC
1876 || GET_CODE (addr) == PRE_DEC
1877 || GET_CODE (addr) == POST_DEC)
1878 return 1;
1879
1880 GO_IF_MODE_DEPENDENT_ADDRESS (addr, win);
1881 return 0;
1882 /* Label `win' might (not) be used via GO_IF_MODE_DEPENDENT_ADDRESS. */
1883 win: ATTRIBUTE_UNUSED_LABEL
1884 return 1;
1885 }
1886 \f
1887 /* Like extract_insn, but save insn extracted and don't extract again, when
1888 called again for the same insn expecting that recog_data still contain the
1889 valid information. This is used primary by gen_attr infrastructure that
1890 often does extract insn again and again. */
1891 void
1892 extract_insn_cached (rtx insn)
1893 {
1894 if (recog_data.insn == insn && INSN_CODE (insn) >= 0)
1895 return;
1896 extract_insn (insn);
1897 recog_data.insn = insn;
1898 }
1899
1900 /* Do cached extract_insn, constrain_operands and complain about failures.
1901 Used by insn_attrtab. */
1902 void
1903 extract_constrain_insn_cached (rtx insn)
1904 {
1905 extract_insn_cached (insn);
1906 if (which_alternative == -1
1907 && !constrain_operands (reload_completed))
1908 fatal_insn_not_found (insn);
1909 }
1910
1911 /* Do cached constrain_operands and complain about failures. */
1912 int
1913 constrain_operands_cached (int strict)
1914 {
1915 if (which_alternative == -1)
1916 return constrain_operands (strict);
1917 else
1918 return 1;
1919 }
1920 \f
1921 /* Analyze INSN and fill in recog_data. */
1922
1923 void
1924 extract_insn (rtx insn)
1925 {
1926 int i;
1927 int icode;
1928 int noperands;
1929 rtx body = PATTERN (insn);
1930
1931 recog_data.n_operands = 0;
1932 recog_data.n_alternatives = 0;
1933 recog_data.n_dups = 0;
1934
1935 switch (GET_CODE (body))
1936 {
1937 case USE:
1938 case CLOBBER:
1939 case ASM_INPUT:
1940 case ADDR_VEC:
1941 case ADDR_DIFF_VEC:
1942 return;
1943
1944 case SET:
1945 if (GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
1946 goto asm_insn;
1947 else
1948 goto normal_insn;
1949 case PARALLEL:
1950 if ((GET_CODE (XVECEXP (body, 0, 0)) == SET
1951 && GET_CODE (SET_SRC (XVECEXP (body, 0, 0))) == ASM_OPERANDS)
1952 || GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
1953 goto asm_insn;
1954 else
1955 goto normal_insn;
1956 case ASM_OPERANDS:
1957 asm_insn:
1958 recog_data.n_operands = noperands = asm_noperands (body);
1959 if (noperands >= 0)
1960 {
1961 /* This insn is an `asm' with operands. */
1962
1963 /* expand_asm_operands makes sure there aren't too many operands. */
1964 gcc_assert (noperands <= MAX_RECOG_OPERANDS);
1965
1966 /* Now get the operand values and constraints out of the insn. */
1967 decode_asm_operands (body, recog_data.operand,
1968 recog_data.operand_loc,
1969 recog_data.constraints,
1970 recog_data.operand_mode, NULL);
1971 if (noperands > 0)
1972 {
1973 const char *p = recog_data.constraints[0];
1974 recog_data.n_alternatives = 1;
1975 while (*p)
1976 recog_data.n_alternatives += (*p++ == ',');
1977 }
1978 break;
1979 }
1980 fatal_insn_not_found (insn);
1981
1982 default:
1983 normal_insn:
1984 /* Ordinary insn: recognize it, get the operands via insn_extract
1985 and get the constraints. */
1986
1987 icode = recog_memoized (insn);
1988 if (icode < 0)
1989 fatal_insn_not_found (insn);
1990
1991 recog_data.n_operands = noperands = insn_data[icode].n_operands;
1992 recog_data.n_alternatives = insn_data[icode].n_alternatives;
1993 recog_data.n_dups = insn_data[icode].n_dups;
1994
1995 insn_extract (insn);
1996
1997 for (i = 0; i < noperands; i++)
1998 {
1999 recog_data.constraints[i] = insn_data[icode].operand[i].constraint;
2000 recog_data.operand_mode[i] = insn_data[icode].operand[i].mode;
2001 /* VOIDmode match_operands gets mode from their real operand. */
2002 if (recog_data.operand_mode[i] == VOIDmode)
2003 recog_data.operand_mode[i] = GET_MODE (recog_data.operand[i]);
2004 }
2005 }
2006 for (i = 0; i < noperands; i++)
2007 recog_data.operand_type[i]
2008 = (recog_data.constraints[i][0] == '=' ? OP_OUT
2009 : recog_data.constraints[i][0] == '+' ? OP_INOUT
2010 : OP_IN);
2011
2012 gcc_assert (recog_data.n_alternatives <= MAX_RECOG_ALTERNATIVES);
2013
2014 if (INSN_CODE (insn) < 0)
2015 for (i = 0; i < recog_data.n_alternatives; i++)
2016 recog_data.alternative_enabled_p[i] = true;
2017 else
2018 {
2019 recog_data.insn = insn;
2020 for (i = 0; i < recog_data.n_alternatives; i++)
2021 {
2022 which_alternative = i;
2023 recog_data.alternative_enabled_p[i] = get_attr_enabled (insn);
2024 }
2025 }
2026
2027 recog_data.insn = NULL;
2028 which_alternative = -1;
2029 }
2030
2031 /* After calling extract_insn, you can use this function to extract some
2032 information from the constraint strings into a more usable form.
2033 The collected data is stored in recog_op_alt. */
2034 void
2035 preprocess_constraints (void)
2036 {
2037 int i;
2038
2039 for (i = 0; i < recog_data.n_operands; i++)
2040 memset (recog_op_alt[i], 0, (recog_data.n_alternatives
2041 * sizeof (struct operand_alternative)));
2042
2043 for (i = 0; i < recog_data.n_operands; i++)
2044 {
2045 int j;
2046 struct operand_alternative *op_alt;
2047 const char *p = recog_data.constraints[i];
2048
2049 op_alt = recog_op_alt[i];
2050
2051 for (j = 0; j < recog_data.n_alternatives; j++)
2052 {
2053 op_alt[j].cl = NO_REGS;
2054 op_alt[j].constraint = p;
2055 op_alt[j].matches = -1;
2056 op_alt[j].matched = -1;
2057
2058 if (!recog_data.alternative_enabled_p[j])
2059 {
2060 p = skip_alternative (p);
2061 continue;
2062 }
2063
2064 if (*p == '\0' || *p == ',')
2065 {
2066 op_alt[j].anything_ok = 1;
2067 continue;
2068 }
2069
2070 for (;;)
2071 {
2072 char c = *p;
2073 if (c == '#')
2074 do
2075 c = *++p;
2076 while (c != ',' && c != '\0');
2077 if (c == ',' || c == '\0')
2078 {
2079 p++;
2080 break;
2081 }
2082
2083 switch (c)
2084 {
2085 case '=': case '+': case '*': case '%':
2086 case 'E': case 'F': case 'G': case 'H':
2087 case 's': case 'i': case 'n':
2088 case 'I': case 'J': case 'K': case 'L':
2089 case 'M': case 'N': case 'O': case 'P':
2090 /* These don't say anything we care about. */
2091 break;
2092
2093 case '?':
2094 op_alt[j].reject += 6;
2095 break;
2096 case '!':
2097 op_alt[j].reject += 600;
2098 break;
2099 case '&':
2100 op_alt[j].earlyclobber = 1;
2101 break;
2102
2103 case '0': case '1': case '2': case '3': case '4':
2104 case '5': case '6': case '7': case '8': case '9':
2105 {
2106 char *end;
2107 op_alt[j].matches = strtoul (p, &end, 10);
2108 recog_op_alt[op_alt[j].matches][j].matched = i;
2109 p = end;
2110 }
2111 continue;
2112
2113 case TARGET_MEM_CONSTRAINT:
2114 op_alt[j].memory_ok = 1;
2115 break;
2116 case '<':
2117 op_alt[j].decmem_ok = 1;
2118 break;
2119 case '>':
2120 op_alt[j].incmem_ok = 1;
2121 break;
2122 case 'V':
2123 op_alt[j].nonoffmem_ok = 1;
2124 break;
2125 case 'o':
2126 op_alt[j].offmem_ok = 1;
2127 break;
2128 case 'X':
2129 op_alt[j].anything_ok = 1;
2130 break;
2131
2132 case 'p':
2133 op_alt[j].is_address = 1;
2134 op_alt[j].cl = reg_class_subunion[(int) op_alt[j].cl]
2135 [(int) base_reg_class (VOIDmode, ADDRESS, SCRATCH)];
2136 break;
2137
2138 case 'g':
2139 case 'r':
2140 op_alt[j].cl =
2141 reg_class_subunion[(int) op_alt[j].cl][(int) GENERAL_REGS];
2142 break;
2143
2144 default:
2145 if (EXTRA_MEMORY_CONSTRAINT (c, p))
2146 {
2147 op_alt[j].memory_ok = 1;
2148 break;
2149 }
2150 if (EXTRA_ADDRESS_CONSTRAINT (c, p))
2151 {
2152 op_alt[j].is_address = 1;
2153 op_alt[j].cl
2154 = (reg_class_subunion
2155 [(int) op_alt[j].cl]
2156 [(int) base_reg_class (VOIDmode, ADDRESS,
2157 SCRATCH)]);
2158 break;
2159 }
2160
2161 op_alt[j].cl
2162 = (reg_class_subunion
2163 [(int) op_alt[j].cl]
2164 [(int) REG_CLASS_FROM_CONSTRAINT ((unsigned char) c, p)]);
2165 break;
2166 }
2167 p += CONSTRAINT_LEN (c, p);
2168 }
2169 }
2170 }
2171 }
2172
2173 /* Check the operands of an insn against the insn's operand constraints
2174 and return 1 if they are valid.
2175 The information about the insn's operands, constraints, operand modes
2176 etc. is obtained from the global variables set up by extract_insn.
2177
2178 WHICH_ALTERNATIVE is set to a number which indicates which
2179 alternative of constraints was matched: 0 for the first alternative,
2180 1 for the next, etc.
2181
2182 In addition, when two operands are required to match
2183 and it happens that the output operand is (reg) while the
2184 input operand is --(reg) or ++(reg) (a pre-inc or pre-dec),
2185 make the output operand look like the input.
2186 This is because the output operand is the one the template will print.
2187
2188 This is used in final, just before printing the assembler code and by
2189 the routines that determine an insn's attribute.
2190
2191 If STRICT is a positive nonzero value, it means that we have been
2192 called after reload has been completed. In that case, we must
2193 do all checks strictly. If it is zero, it means that we have been called
2194 before reload has completed. In that case, we first try to see if we can
2195 find an alternative that matches strictly. If not, we try again, this
2196 time assuming that reload will fix up the insn. This provides a "best
2197 guess" for the alternative and is used to compute attributes of insns prior
2198 to reload. A negative value of STRICT is used for this internal call. */
2199
2200 struct funny_match
2201 {
2202 int this, other;
2203 };
2204
2205 int
2206 constrain_operands (int strict)
2207 {
2208 const char *constraints[MAX_RECOG_OPERANDS];
2209 int matching_operands[MAX_RECOG_OPERANDS];
2210 int earlyclobber[MAX_RECOG_OPERANDS];
2211 int c;
2212
2213 struct funny_match funny_match[MAX_RECOG_OPERANDS];
2214 int funny_match_index;
2215
2216 which_alternative = 0;
2217 if (recog_data.n_operands == 0 || recog_data.n_alternatives == 0)
2218 return 1;
2219
2220 for (c = 0; c < recog_data.n_operands; c++)
2221 {
2222 constraints[c] = recog_data.constraints[c];
2223 matching_operands[c] = -1;
2224 }
2225
2226 do
2227 {
2228 int seen_earlyclobber_at = -1;
2229 int opno;
2230 int lose = 0;
2231 funny_match_index = 0;
2232
2233 if (!recog_data.alternative_enabled_p[which_alternative])
2234 {
2235 int i;
2236
2237 for (i = 0; i < recog_data.n_operands; i++)
2238 constraints[i] = skip_alternative (constraints[i]);
2239
2240 which_alternative++;
2241 continue;
2242 }
2243
2244 for (opno = 0; opno < recog_data.n_operands; opno++)
2245 {
2246 rtx op = recog_data.operand[opno];
2247 enum machine_mode mode = GET_MODE (op);
2248 const char *p = constraints[opno];
2249 int offset = 0;
2250 int win = 0;
2251 int val;
2252 int len;
2253
2254 earlyclobber[opno] = 0;
2255
2256 /* A unary operator may be accepted by the predicate, but it
2257 is irrelevant for matching constraints. */
2258 if (UNARY_P (op))
2259 op = XEXP (op, 0);
2260
2261 if (GET_CODE (op) == SUBREG)
2262 {
2263 if (REG_P (SUBREG_REG (op))
2264 && REGNO (SUBREG_REG (op)) < FIRST_PSEUDO_REGISTER)
2265 offset = subreg_regno_offset (REGNO (SUBREG_REG (op)),
2266 GET_MODE (SUBREG_REG (op)),
2267 SUBREG_BYTE (op),
2268 GET_MODE (op));
2269 op = SUBREG_REG (op);
2270 }
2271
2272 /* An empty constraint or empty alternative
2273 allows anything which matched the pattern. */
2274 if (*p == 0 || *p == ',')
2275 win = 1;
2276
2277 do
2278 switch (c = *p, len = CONSTRAINT_LEN (c, p), c)
2279 {
2280 case '\0':
2281 len = 0;
2282 break;
2283 case ',':
2284 c = '\0';
2285 break;
2286
2287 case '?': case '!': case '*': case '%':
2288 case '=': case '+':
2289 break;
2290
2291 case '#':
2292 /* Ignore rest of this alternative as far as
2293 constraint checking is concerned. */
2294 do
2295 p++;
2296 while (*p && *p != ',');
2297 len = 0;
2298 break;
2299
2300 case '&':
2301 earlyclobber[opno] = 1;
2302 if (seen_earlyclobber_at < 0)
2303 seen_earlyclobber_at = opno;
2304 break;
2305
2306 case '0': case '1': case '2': case '3': case '4':
2307 case '5': case '6': case '7': case '8': case '9':
2308 {
2309 /* This operand must be the same as a previous one.
2310 This kind of constraint is used for instructions such
2311 as add when they take only two operands.
2312
2313 Note that the lower-numbered operand is passed first.
2314
2315 If we are not testing strictly, assume that this
2316 constraint will be satisfied. */
2317
2318 char *end;
2319 int match;
2320
2321 match = strtoul (p, &end, 10);
2322 p = end;
2323
2324 if (strict < 0)
2325 val = 1;
2326 else
2327 {
2328 rtx op1 = recog_data.operand[match];
2329 rtx op2 = recog_data.operand[opno];
2330
2331 /* A unary operator may be accepted by the predicate,
2332 but it is irrelevant for matching constraints. */
2333 if (UNARY_P (op1))
2334 op1 = XEXP (op1, 0);
2335 if (UNARY_P (op2))
2336 op2 = XEXP (op2, 0);
2337
2338 val = operands_match_p (op1, op2);
2339 }
2340
2341 matching_operands[opno] = match;
2342 matching_operands[match] = opno;
2343
2344 if (val != 0)
2345 win = 1;
2346
2347 /* If output is *x and input is *--x, arrange later
2348 to change the output to *--x as well, since the
2349 output op is the one that will be printed. */
2350 if (val == 2 && strict > 0)
2351 {
2352 funny_match[funny_match_index].this = opno;
2353 funny_match[funny_match_index++].other = match;
2354 }
2355 }
2356 len = 0;
2357 break;
2358
2359 case 'p':
2360 /* p is used for address_operands. When we are called by
2361 gen_reload, no one will have checked that the address is
2362 strictly valid, i.e., that all pseudos requiring hard regs
2363 have gotten them. */
2364 if (strict <= 0
2365 || (strict_memory_address_p (recog_data.operand_mode[opno],
2366 op)))
2367 win = 1;
2368 break;
2369
2370 /* No need to check general_operand again;
2371 it was done in insn-recog.c. Well, except that reload
2372 doesn't check the validity of its replacements, but
2373 that should only matter when there's a bug. */
2374 case 'g':
2375 /* Anything goes unless it is a REG and really has a hard reg
2376 but the hard reg is not in the class GENERAL_REGS. */
2377 if (REG_P (op))
2378 {
2379 if (strict < 0
2380 || GENERAL_REGS == ALL_REGS
2381 || (reload_in_progress
2382 && REGNO (op) >= FIRST_PSEUDO_REGISTER)
2383 || reg_fits_class_p (op, GENERAL_REGS, offset, mode))
2384 win = 1;
2385 }
2386 else if (strict < 0 || general_operand (op, mode))
2387 win = 1;
2388 break;
2389
2390 case 'X':
2391 /* This is used for a MATCH_SCRATCH in the cases when
2392 we don't actually need anything. So anything goes
2393 any time. */
2394 win = 1;
2395 break;
2396
2397 case TARGET_MEM_CONSTRAINT:
2398 /* Memory operands must be valid, to the extent
2399 required by STRICT. */
2400 if (MEM_P (op))
2401 {
2402 if (strict > 0
2403 && !strict_memory_address_p (GET_MODE (op),
2404 XEXP (op, 0)))
2405 break;
2406 if (strict == 0
2407 && !memory_address_p (GET_MODE (op), XEXP (op, 0)))
2408 break;
2409 win = 1;
2410 }
2411 /* Before reload, accept what reload can turn into mem. */
2412 else if (strict < 0 && CONSTANT_P (op))
2413 win = 1;
2414 /* During reload, accept a pseudo */
2415 else if (reload_in_progress && REG_P (op)
2416 && REGNO (op) >= FIRST_PSEUDO_REGISTER)
2417 win = 1;
2418 break;
2419
2420 case '<':
2421 if (MEM_P (op)
2422 && (GET_CODE (XEXP (op, 0)) == PRE_DEC
2423 || GET_CODE (XEXP (op, 0)) == POST_DEC))
2424 win = 1;
2425 break;
2426
2427 case '>':
2428 if (MEM_P (op)
2429 && (GET_CODE (XEXP (op, 0)) == PRE_INC
2430 || GET_CODE (XEXP (op, 0)) == POST_INC))
2431 win = 1;
2432 break;
2433
2434 case 'E':
2435 case 'F':
2436 if (GET_CODE (op) == CONST_DOUBLE
2437 || (GET_CODE (op) == CONST_VECTOR
2438 && GET_MODE_CLASS (GET_MODE (op)) == MODE_VECTOR_FLOAT))
2439 win = 1;
2440 break;
2441
2442 case 'G':
2443 case 'H':
2444 if (GET_CODE (op) == CONST_DOUBLE
2445 && CONST_DOUBLE_OK_FOR_CONSTRAINT_P (op, c, p))
2446 win = 1;
2447 break;
2448
2449 case 's':
2450 if (GET_CODE (op) == CONST_INT
2451 || (GET_CODE (op) == CONST_DOUBLE
2452 && GET_MODE (op) == VOIDmode))
2453 break;
2454 case 'i':
2455 if (CONSTANT_P (op))
2456 win = 1;
2457 break;
2458
2459 case 'n':
2460 if (GET_CODE (op) == CONST_INT
2461 || (GET_CODE (op) == CONST_DOUBLE
2462 && GET_MODE (op) == VOIDmode))
2463 win = 1;
2464 break;
2465
2466 case 'I':
2467 case 'J':
2468 case 'K':
2469 case 'L':
2470 case 'M':
2471 case 'N':
2472 case 'O':
2473 case 'P':
2474 if (GET_CODE (op) == CONST_INT
2475 && CONST_OK_FOR_CONSTRAINT_P (INTVAL (op), c, p))
2476 win = 1;
2477 break;
2478
2479 case 'V':
2480 if (MEM_P (op)
2481 && ((strict > 0 && ! offsettable_memref_p (op))
2482 || (strict < 0
2483 && !(CONSTANT_P (op) || MEM_P (op)))
2484 || (reload_in_progress
2485 && !(REG_P (op)
2486 && REGNO (op) >= FIRST_PSEUDO_REGISTER))))
2487 win = 1;
2488 break;
2489
2490 case 'o':
2491 if ((strict > 0 && offsettable_memref_p (op))
2492 || (strict == 0 && offsettable_nonstrict_memref_p (op))
2493 /* Before reload, accept what reload can handle. */
2494 || (strict < 0
2495 && (CONSTANT_P (op) || MEM_P (op)))
2496 /* During reload, accept a pseudo */
2497 || (reload_in_progress && REG_P (op)
2498 && REGNO (op) >= FIRST_PSEUDO_REGISTER))
2499 win = 1;
2500 break;
2501
2502 default:
2503 {
2504 enum reg_class cl;
2505
2506 cl = (c == 'r'
2507 ? GENERAL_REGS : REG_CLASS_FROM_CONSTRAINT (c, p));
2508 if (cl != NO_REGS)
2509 {
2510 if (strict < 0
2511 || (strict == 0
2512 && REG_P (op)
2513 && REGNO (op) >= FIRST_PSEUDO_REGISTER)
2514 || (strict == 0 && GET_CODE (op) == SCRATCH)
2515 || (REG_P (op)
2516 && reg_fits_class_p (op, cl, offset, mode)))
2517 win = 1;
2518 }
2519 #ifdef EXTRA_CONSTRAINT_STR
2520 else if (EXTRA_CONSTRAINT_STR (op, c, p))
2521 win = 1;
2522
2523 else if (EXTRA_MEMORY_CONSTRAINT (c, p)
2524 /* Every memory operand can be reloaded to fit. */
2525 && ((strict < 0 && MEM_P (op))
2526 /* Before reload, accept what reload can turn
2527 into mem. */
2528 || (strict < 0 && CONSTANT_P (op))
2529 /* During reload, accept a pseudo */
2530 || (reload_in_progress && REG_P (op)
2531 && REGNO (op) >= FIRST_PSEUDO_REGISTER)))
2532 win = 1;
2533 else if (EXTRA_ADDRESS_CONSTRAINT (c, p)
2534 /* Every address operand can be reloaded to fit. */
2535 && strict < 0)
2536 win = 1;
2537 #endif
2538 break;
2539 }
2540 }
2541 while (p += len, c);
2542
2543 constraints[opno] = p;
2544 /* If this operand did not win somehow,
2545 this alternative loses. */
2546 if (! win)
2547 lose = 1;
2548 }
2549 /* This alternative won; the operands are ok.
2550 Change whichever operands this alternative says to change. */
2551 if (! lose)
2552 {
2553 int opno, eopno;
2554
2555 /* See if any earlyclobber operand conflicts with some other
2556 operand. */
2557
2558 if (strict > 0 && seen_earlyclobber_at >= 0)
2559 for (eopno = seen_earlyclobber_at;
2560 eopno < recog_data.n_operands;
2561 eopno++)
2562 /* Ignore earlyclobber operands now in memory,
2563 because we would often report failure when we have
2564 two memory operands, one of which was formerly a REG. */
2565 if (earlyclobber[eopno]
2566 && REG_P (recog_data.operand[eopno]))
2567 for (opno = 0; opno < recog_data.n_operands; opno++)
2568 if ((MEM_P (recog_data.operand[opno])
2569 || recog_data.operand_type[opno] != OP_OUT)
2570 && opno != eopno
2571 /* Ignore things like match_operator operands. */
2572 && *recog_data.constraints[opno] != 0
2573 && ! (matching_operands[opno] == eopno
2574 && operands_match_p (recog_data.operand[opno],
2575 recog_data.operand[eopno]))
2576 && ! safe_from_earlyclobber (recog_data.operand[opno],
2577 recog_data.operand[eopno]))
2578 lose = 1;
2579
2580 if (! lose)
2581 {
2582 while (--funny_match_index >= 0)
2583 {
2584 recog_data.operand[funny_match[funny_match_index].other]
2585 = recog_data.operand[funny_match[funny_match_index].this];
2586 }
2587
2588 return 1;
2589 }
2590 }
2591
2592 which_alternative++;
2593 }
2594 while (which_alternative < recog_data.n_alternatives);
2595
2596 which_alternative = -1;
2597 /* If we are about to reject this, but we are not to test strictly,
2598 try a very loose test. Only return failure if it fails also. */
2599 if (strict == 0)
2600 return constrain_operands (-1);
2601 else
2602 return 0;
2603 }
2604
2605 /* Return 1 iff OPERAND (assumed to be a REG rtx)
2606 is a hard reg in class CLASS when its regno is offset by OFFSET
2607 and changed to mode MODE.
2608 If REG occupies multiple hard regs, all of them must be in CLASS. */
2609
2610 int
2611 reg_fits_class_p (rtx operand, enum reg_class cl, int offset,
2612 enum machine_mode mode)
2613 {
2614 int regno = REGNO (operand);
2615
2616 if (cl == NO_REGS)
2617 return 0;
2618
2619 return (regno < FIRST_PSEUDO_REGISTER
2620 && in_hard_reg_set_p (reg_class_contents[(int) cl],
2621 mode, regno + offset));
2622 }
2623 \f
2624 /* Split single instruction. Helper function for split_all_insns and
2625 split_all_insns_noflow. Return last insn in the sequence if successful,
2626 or NULL if unsuccessful. */
2627
2628 static rtx
2629 split_insn (rtx insn)
2630 {
2631 /* Split insns here to get max fine-grain parallelism. */
2632 rtx first = PREV_INSN (insn);
2633 rtx last = try_split (PATTERN (insn), insn, 1);
2634
2635 if (last == insn)
2636 return NULL_RTX;
2637
2638 /* try_split returns the NOTE that INSN became. */
2639 SET_INSN_DELETED (insn);
2640
2641 /* ??? Coddle to md files that generate subregs in post-reload
2642 splitters instead of computing the proper hard register. */
2643 if (reload_completed && first != last)
2644 {
2645 first = NEXT_INSN (first);
2646 for (;;)
2647 {
2648 if (INSN_P (first))
2649 cleanup_subreg_operands (first);
2650 if (first == last)
2651 break;
2652 first = NEXT_INSN (first);
2653 }
2654 }
2655 return last;
2656 }
2657
2658 /* Split all insns in the function. If UPD_LIFE, update life info after. */
2659
2660 void
2661 split_all_insns (void)
2662 {
2663 sbitmap blocks;
2664 bool changed;
2665 basic_block bb;
2666
2667 blocks = sbitmap_alloc (last_basic_block);
2668 sbitmap_zero (blocks);
2669 changed = false;
2670
2671 FOR_EACH_BB_REVERSE (bb)
2672 {
2673 rtx insn, next;
2674 bool finish = false;
2675
2676 for (insn = BB_HEAD (bb); !finish ; insn = next)
2677 {
2678 /* Can't use `next_real_insn' because that might go across
2679 CODE_LABELS and short-out basic blocks. */
2680 next = NEXT_INSN (insn);
2681 finish = (insn == BB_END (bb));
2682 if (INSN_P (insn))
2683 {
2684 rtx set = single_set (insn);
2685
2686 /* Don't split no-op move insns. These should silently
2687 disappear later in final. Splitting such insns would
2688 break the code that handles LIBCALL blocks. */
2689 if (set && set_noop_p (set))
2690 {
2691 /* Nops get in the way while scheduling, so delete them
2692 now if register allocation has already been done. It
2693 is too risky to try to do this before register
2694 allocation, and there are unlikely to be very many
2695 nops then anyways. */
2696 if (reload_completed)
2697 delete_insn_and_edges (insn);
2698 }
2699 else
2700 {
2701 rtx last = split_insn (insn);
2702 if (last)
2703 {
2704 /* The split sequence may include barrier, but the
2705 BB boundary we are interested in will be set to
2706 previous one. */
2707
2708 while (BARRIER_P (last))
2709 last = PREV_INSN (last);
2710 SET_BIT (blocks, bb->index);
2711 changed = true;
2712 }
2713 }
2714 }
2715 }
2716 }
2717
2718 if (changed)
2719 find_many_sub_basic_blocks (blocks);
2720
2721 #ifdef ENABLE_CHECKING
2722 verify_flow_info ();
2723 #endif
2724
2725 sbitmap_free (blocks);
2726 }
2727
2728 /* Same as split_all_insns, but do not expect CFG to be available.
2729 Used by machine dependent reorg passes. */
2730
2731 unsigned int
2732 split_all_insns_noflow (void)
2733 {
2734 rtx next, insn;
2735
2736 for (insn = get_insns (); insn; insn = next)
2737 {
2738 next = NEXT_INSN (insn);
2739 if (INSN_P (insn))
2740 {
2741 /* Don't split no-op move insns. These should silently
2742 disappear later in final. Splitting such insns would
2743 break the code that handles LIBCALL blocks. */
2744 rtx set = single_set (insn);
2745 if (set && set_noop_p (set))
2746 {
2747 /* Nops get in the way while scheduling, so delete them
2748 now if register allocation has already been done. It
2749 is too risky to try to do this before register
2750 allocation, and there are unlikely to be very many
2751 nops then anyways.
2752
2753 ??? Should we use delete_insn when the CFG isn't valid? */
2754 if (reload_completed)
2755 delete_insn_and_edges (insn);
2756 }
2757 else
2758 split_insn (insn);
2759 }
2760 }
2761 return 0;
2762 }
2763 \f
2764 #ifdef HAVE_peephole2
2765 struct peep2_insn_data
2766 {
2767 rtx insn;
2768 regset live_before;
2769 };
2770
2771 static struct peep2_insn_data peep2_insn_data[MAX_INSNS_PER_PEEP2 + 1];
2772 static int peep2_current;
2773 /* The number of instructions available to match a peep2. */
2774 int peep2_current_count;
2775
2776 /* A non-insn marker indicating the last insn of the block.
2777 The live_before regset for this element is correct, indicating
2778 DF_LIVE_OUT for the block. */
2779 #define PEEP2_EOB pc_rtx
2780
2781 /* Return the Nth non-note insn after `current', or return NULL_RTX if it
2782 does not exist. Used by the recognizer to find the next insn to match
2783 in a multi-insn pattern. */
2784
2785 rtx
2786 peep2_next_insn (int n)
2787 {
2788 gcc_assert (n <= peep2_current_count);
2789
2790 n += peep2_current;
2791 if (n >= MAX_INSNS_PER_PEEP2 + 1)
2792 n -= MAX_INSNS_PER_PEEP2 + 1;
2793
2794 return peep2_insn_data[n].insn;
2795 }
2796
2797 /* Return true if REGNO is dead before the Nth non-note insn
2798 after `current'. */
2799
2800 int
2801 peep2_regno_dead_p (int ofs, int regno)
2802 {
2803 gcc_assert (ofs < MAX_INSNS_PER_PEEP2 + 1);
2804
2805 ofs += peep2_current;
2806 if (ofs >= MAX_INSNS_PER_PEEP2 + 1)
2807 ofs -= MAX_INSNS_PER_PEEP2 + 1;
2808
2809 gcc_assert (peep2_insn_data[ofs].insn != NULL_RTX);
2810
2811 return ! REGNO_REG_SET_P (peep2_insn_data[ofs].live_before, regno);
2812 }
2813
2814 /* Similarly for a REG. */
2815
2816 int
2817 peep2_reg_dead_p (int ofs, rtx reg)
2818 {
2819 int regno, n;
2820
2821 gcc_assert (ofs < MAX_INSNS_PER_PEEP2 + 1);
2822
2823 ofs += peep2_current;
2824 if (ofs >= MAX_INSNS_PER_PEEP2 + 1)
2825 ofs -= MAX_INSNS_PER_PEEP2 + 1;
2826
2827 gcc_assert (peep2_insn_data[ofs].insn != NULL_RTX);
2828
2829 regno = REGNO (reg);
2830 n = hard_regno_nregs[regno][GET_MODE (reg)];
2831 while (--n >= 0)
2832 if (REGNO_REG_SET_P (peep2_insn_data[ofs].live_before, regno + n))
2833 return 0;
2834 return 1;
2835 }
2836
2837 /* Try to find a hard register of mode MODE, matching the register class in
2838 CLASS_STR, which is available at the beginning of insn CURRENT_INSN and
2839 remains available until the end of LAST_INSN. LAST_INSN may be NULL_RTX,
2840 in which case the only condition is that the register must be available
2841 before CURRENT_INSN.
2842 Registers that already have bits set in REG_SET will not be considered.
2843
2844 If an appropriate register is available, it will be returned and the
2845 corresponding bit(s) in REG_SET will be set; otherwise, NULL_RTX is
2846 returned. */
2847
2848 rtx
2849 peep2_find_free_register (int from, int to, const char *class_str,
2850 enum machine_mode mode, HARD_REG_SET *reg_set)
2851 {
2852 static int search_ofs;
2853 enum reg_class cl;
2854 HARD_REG_SET live;
2855 int i;
2856
2857 gcc_assert (from < MAX_INSNS_PER_PEEP2 + 1);
2858 gcc_assert (to < MAX_INSNS_PER_PEEP2 + 1);
2859
2860 from += peep2_current;
2861 if (from >= MAX_INSNS_PER_PEEP2 + 1)
2862 from -= MAX_INSNS_PER_PEEP2 + 1;
2863 to += peep2_current;
2864 if (to >= MAX_INSNS_PER_PEEP2 + 1)
2865 to -= MAX_INSNS_PER_PEEP2 + 1;
2866
2867 gcc_assert (peep2_insn_data[from].insn != NULL_RTX);
2868 REG_SET_TO_HARD_REG_SET (live, peep2_insn_data[from].live_before);
2869
2870 while (from != to)
2871 {
2872 HARD_REG_SET this_live;
2873
2874 if (++from >= MAX_INSNS_PER_PEEP2 + 1)
2875 from = 0;
2876 gcc_assert (peep2_insn_data[from].insn != NULL_RTX);
2877 REG_SET_TO_HARD_REG_SET (this_live, peep2_insn_data[from].live_before);
2878 IOR_HARD_REG_SET (live, this_live);
2879 }
2880
2881 cl = (class_str[0] == 'r' ? GENERAL_REGS
2882 : REG_CLASS_FROM_CONSTRAINT (class_str[0], class_str));
2883
2884 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
2885 {
2886 int raw_regno, regno, success, j;
2887
2888 /* Distribute the free registers as much as possible. */
2889 raw_regno = search_ofs + i;
2890 if (raw_regno >= FIRST_PSEUDO_REGISTER)
2891 raw_regno -= FIRST_PSEUDO_REGISTER;
2892 #ifdef REG_ALLOC_ORDER
2893 regno = reg_alloc_order[raw_regno];
2894 #else
2895 regno = raw_regno;
2896 #endif
2897
2898 /* Don't allocate fixed registers. */
2899 if (fixed_regs[regno])
2900 continue;
2901 /* Make sure the register is of the right class. */
2902 if (! TEST_HARD_REG_BIT (reg_class_contents[cl], regno))
2903 continue;
2904 /* And can support the mode we need. */
2905 if (! HARD_REGNO_MODE_OK (regno, mode))
2906 continue;
2907 /* And that we don't create an extra save/restore. */
2908 if (! call_used_regs[regno] && ! df_regs_ever_live_p (regno))
2909 continue;
2910 /* And we don't clobber traceback for noreturn functions. */
2911 if ((regno == FRAME_POINTER_REGNUM || regno == HARD_FRAME_POINTER_REGNUM)
2912 && (! reload_completed || frame_pointer_needed))
2913 continue;
2914
2915 success = 1;
2916 for (j = hard_regno_nregs[regno][mode] - 1; j >= 0; j--)
2917 {
2918 if (TEST_HARD_REG_BIT (*reg_set, regno + j)
2919 || TEST_HARD_REG_BIT (live, regno + j))
2920 {
2921 success = 0;
2922 break;
2923 }
2924 }
2925 if (success)
2926 {
2927 add_to_hard_reg_set (reg_set, mode, regno);
2928
2929 /* Start the next search with the next register. */
2930 if (++raw_regno >= FIRST_PSEUDO_REGISTER)
2931 raw_regno = 0;
2932 search_ofs = raw_regno;
2933
2934 return gen_rtx_REG (mode, regno);
2935 }
2936 }
2937
2938 search_ofs = 0;
2939 return NULL_RTX;
2940 }
2941
2942 /* Perform the peephole2 optimization pass. */
2943
2944 static void
2945 peephole2_optimize (void)
2946 {
2947 rtx insn, prev;
2948 bitmap live;
2949 int i;
2950 basic_block bb;
2951 bool do_cleanup_cfg = false;
2952 bool do_rebuild_jump_labels = false;
2953
2954 df_set_flags (DF_LR_RUN_DCE);
2955 df_analyze ();
2956
2957 /* Initialize the regsets we're going to use. */
2958 for (i = 0; i < MAX_INSNS_PER_PEEP2 + 1; ++i)
2959 peep2_insn_data[i].live_before = BITMAP_ALLOC (&reg_obstack);
2960 live = BITMAP_ALLOC (&reg_obstack);
2961
2962 FOR_EACH_BB_REVERSE (bb)
2963 {
2964 /* Indicate that all slots except the last holds invalid data. */
2965 for (i = 0; i < MAX_INSNS_PER_PEEP2; ++i)
2966 peep2_insn_data[i].insn = NULL_RTX;
2967 peep2_current_count = 0;
2968
2969 /* Indicate that the last slot contains live_after data. */
2970 peep2_insn_data[MAX_INSNS_PER_PEEP2].insn = PEEP2_EOB;
2971 peep2_current = MAX_INSNS_PER_PEEP2;
2972
2973 /* Start up propagation. */
2974 bitmap_copy (live, DF_LR_OUT (bb));
2975 df_simulate_artificial_refs_at_end (bb, live);
2976 bitmap_copy (peep2_insn_data[MAX_INSNS_PER_PEEP2].live_before, live);
2977
2978 for (insn = BB_END (bb); ; insn = prev)
2979 {
2980 prev = PREV_INSN (insn);
2981 if (INSN_P (insn))
2982 {
2983 rtx try, before_try, x;
2984 int match_len;
2985 rtx note;
2986 bool was_call = false;
2987
2988 /* Record this insn. */
2989 if (--peep2_current < 0)
2990 peep2_current = MAX_INSNS_PER_PEEP2;
2991 if (peep2_current_count < MAX_INSNS_PER_PEEP2
2992 && peep2_insn_data[peep2_current].insn == NULL_RTX)
2993 peep2_current_count++;
2994 peep2_insn_data[peep2_current].insn = insn;
2995 df_simulate_one_insn (bb, insn, live);
2996 COPY_REG_SET (peep2_insn_data[peep2_current].live_before, live);
2997
2998 if (RTX_FRAME_RELATED_P (insn))
2999 {
3000 /* If an insn has RTX_FRAME_RELATED_P set, peephole
3001 substitution would lose the
3002 REG_FRAME_RELATED_EXPR that is attached. */
3003 peep2_current_count = 0;
3004 try = NULL;
3005 }
3006 else
3007 /* Match the peephole. */
3008 try = peephole2_insns (PATTERN (insn), insn, &match_len);
3009
3010 if (try != NULL)
3011 {
3012 /* If we are splitting a CALL_INSN, look for the CALL_INSN
3013 in SEQ and copy our CALL_INSN_FUNCTION_USAGE and other
3014 cfg-related call notes. */
3015 for (i = 0; i <= match_len; ++i)
3016 {
3017 int j;
3018 rtx old_insn, new_insn, note;
3019
3020 j = i + peep2_current;
3021 if (j >= MAX_INSNS_PER_PEEP2 + 1)
3022 j -= MAX_INSNS_PER_PEEP2 + 1;
3023 old_insn = peep2_insn_data[j].insn;
3024 if (!CALL_P (old_insn))
3025 continue;
3026 was_call = true;
3027
3028 new_insn = try;
3029 while (new_insn != NULL_RTX)
3030 {
3031 if (CALL_P (new_insn))
3032 break;
3033 new_insn = NEXT_INSN (new_insn);
3034 }
3035
3036 gcc_assert (new_insn != NULL_RTX);
3037
3038 CALL_INSN_FUNCTION_USAGE (new_insn)
3039 = CALL_INSN_FUNCTION_USAGE (old_insn);
3040
3041 for (note = REG_NOTES (old_insn);
3042 note;
3043 note = XEXP (note, 1))
3044 switch (REG_NOTE_KIND (note))
3045 {
3046 case REG_NORETURN:
3047 case REG_SETJMP:
3048 REG_NOTES (new_insn)
3049 = gen_rtx_EXPR_LIST (REG_NOTE_KIND (note),
3050 XEXP (note, 0),
3051 REG_NOTES (new_insn));
3052 default:
3053 /* Discard all other reg notes. */
3054 break;
3055 }
3056
3057 /* Croak if there is another call in the sequence. */
3058 while (++i <= match_len)
3059 {
3060 j = i + peep2_current;
3061 if (j >= MAX_INSNS_PER_PEEP2 + 1)
3062 j -= MAX_INSNS_PER_PEEP2 + 1;
3063 old_insn = peep2_insn_data[j].insn;
3064 gcc_assert (!CALL_P (old_insn));
3065 }
3066 break;
3067 }
3068
3069 i = match_len + peep2_current;
3070 if (i >= MAX_INSNS_PER_PEEP2 + 1)
3071 i -= MAX_INSNS_PER_PEEP2 + 1;
3072
3073 note = find_reg_note (peep2_insn_data[i].insn,
3074 REG_EH_REGION, NULL_RTX);
3075
3076 /* Replace the old sequence with the new. */
3077 try = emit_insn_after_setloc (try, peep2_insn_data[i].insn,
3078 INSN_LOCATOR (peep2_insn_data[i].insn));
3079 before_try = PREV_INSN (insn);
3080 delete_insn_chain (insn, peep2_insn_data[i].insn, false);
3081
3082 /* Re-insert the EH_REGION notes. */
3083 if (note || (was_call && nonlocal_goto_handler_labels))
3084 {
3085 edge eh_edge;
3086 edge_iterator ei;
3087
3088 FOR_EACH_EDGE (eh_edge, ei, bb->succs)
3089 if (eh_edge->flags & (EDGE_EH | EDGE_ABNORMAL_CALL))
3090 break;
3091
3092 for (x = try ; x != before_try ; x = PREV_INSN (x))
3093 if (CALL_P (x)
3094 || (flag_non_call_exceptions
3095 && may_trap_p (PATTERN (x))
3096 && !find_reg_note (x, REG_EH_REGION, NULL)))
3097 {
3098 if (note)
3099 REG_NOTES (x)
3100 = gen_rtx_EXPR_LIST (REG_EH_REGION,
3101 XEXP (note, 0),
3102 REG_NOTES (x));
3103
3104 if (x != BB_END (bb) && eh_edge)
3105 {
3106 edge nfte, nehe;
3107 int flags;
3108
3109 nfte = split_block (bb, x);
3110 flags = (eh_edge->flags
3111 & (EDGE_EH | EDGE_ABNORMAL));
3112 if (CALL_P (x))
3113 flags |= EDGE_ABNORMAL_CALL;
3114 nehe = make_edge (nfte->src, eh_edge->dest,
3115 flags);
3116
3117 nehe->probability = eh_edge->probability;
3118 nfte->probability
3119 = REG_BR_PROB_BASE - nehe->probability;
3120
3121 do_cleanup_cfg |= purge_dead_edges (nfte->dest);
3122 bb = nfte->src;
3123 eh_edge = nehe;
3124 }
3125 }
3126
3127 /* Converting possibly trapping insn to non-trapping is
3128 possible. Zap dummy outgoing edges. */
3129 do_cleanup_cfg |= purge_dead_edges (bb);
3130 }
3131
3132 #ifdef HAVE_conditional_execution
3133 for (i = 0; i < MAX_INSNS_PER_PEEP2 + 1; ++i)
3134 peep2_insn_data[i].insn = NULL_RTX;
3135 peep2_insn_data[peep2_current].insn = PEEP2_EOB;
3136 peep2_current_count = 0;
3137 #else
3138 /* Back up lifetime information past the end of the
3139 newly created sequence. */
3140 if (++i >= MAX_INSNS_PER_PEEP2 + 1)
3141 i = 0;
3142 bitmap_copy (live, peep2_insn_data[i].live_before);
3143
3144 /* Update life information for the new sequence. */
3145 x = try;
3146 do
3147 {
3148 if (INSN_P (x))
3149 {
3150 if (--i < 0)
3151 i = MAX_INSNS_PER_PEEP2;
3152 if (peep2_current_count < MAX_INSNS_PER_PEEP2
3153 && peep2_insn_data[i].insn == NULL_RTX)
3154 peep2_current_count++;
3155 peep2_insn_data[i].insn = x;
3156 df_insn_rescan (x);
3157 df_simulate_one_insn (bb, x, live);
3158 bitmap_copy (peep2_insn_data[i].live_before, live);
3159 }
3160 x = PREV_INSN (x);
3161 }
3162 while (x != prev);
3163
3164 peep2_current = i;
3165 #endif
3166
3167 /* If we generated a jump instruction, it won't have
3168 JUMP_LABEL set. Recompute after we're done. */
3169 for (x = try; x != before_try; x = PREV_INSN (x))
3170 if (JUMP_P (x))
3171 {
3172 do_rebuild_jump_labels = true;
3173 break;
3174 }
3175 }
3176 }
3177
3178 if (insn == BB_HEAD (bb))
3179 break;
3180 }
3181 }
3182
3183 for (i = 0; i < MAX_INSNS_PER_PEEP2 + 1; ++i)
3184 BITMAP_FREE (peep2_insn_data[i].live_before);
3185 BITMAP_FREE (live);
3186 if (do_rebuild_jump_labels)
3187 rebuild_jump_labels (get_insns ());
3188 }
3189 #endif /* HAVE_peephole2 */
3190
3191 /* Common predicates for use with define_bypass. */
3192
3193 /* True if the dependency between OUT_INSN and IN_INSN is on the store
3194 data not the address operand(s) of the store. IN_INSN and OUT_INSN
3195 must be either a single_set or a PARALLEL with SETs inside. */
3196
3197 int
3198 store_data_bypass_p (rtx out_insn, rtx in_insn)
3199 {
3200 rtx out_set, in_set;
3201 rtx out_pat, in_pat;
3202 rtx out_exp, in_exp;
3203 int i, j;
3204
3205 in_set = single_set (in_insn);
3206 if (in_set)
3207 {
3208 if (!MEM_P (SET_DEST (in_set)))
3209 return false;
3210
3211 out_set = single_set (out_insn);
3212 if (out_set)
3213 {
3214 if (reg_mentioned_p (SET_DEST (out_set), SET_DEST (in_set)))
3215 return false;
3216 }
3217 else
3218 {
3219 out_pat = PATTERN (out_insn);
3220
3221 if (GET_CODE (out_pat) != PARALLEL)
3222 return false;
3223
3224 for (i = 0; i < XVECLEN (out_pat, 0); i++)
3225 {
3226 out_exp = XVECEXP (out_pat, 0, i);
3227
3228 if (GET_CODE (out_exp) == CLOBBER)
3229 continue;
3230
3231 gcc_assert (GET_CODE (out_exp) == SET);
3232
3233 if (reg_mentioned_p (SET_DEST (out_exp), SET_DEST (in_set)))
3234 return false;
3235 }
3236 }
3237 }
3238 else
3239 {
3240 in_pat = PATTERN (in_insn);
3241 gcc_assert (GET_CODE (in_pat) == PARALLEL);
3242
3243 for (i = 0; i < XVECLEN (in_pat, 0); i++)
3244 {
3245 in_exp = XVECEXP (in_pat, 0, i);
3246
3247 if (GET_CODE (in_exp) == CLOBBER)
3248 continue;
3249
3250 gcc_assert (GET_CODE (in_exp) == SET);
3251
3252 if (!MEM_P (SET_DEST (in_exp)))
3253 return false;
3254
3255 out_set = single_set (out_insn);
3256 if (out_set)
3257 {
3258 if (reg_mentioned_p (SET_DEST (out_set), SET_DEST (in_exp)))
3259 return false;
3260 }
3261 else
3262 {
3263 out_pat = PATTERN (out_insn);
3264 gcc_assert (GET_CODE (out_pat) == PARALLEL);
3265
3266 for (j = 0; j < XVECLEN (out_pat, 0); j++)
3267 {
3268 out_exp = XVECEXP (out_pat, 0, j);
3269
3270 if (GET_CODE (out_exp) == CLOBBER)
3271 continue;
3272
3273 gcc_assert (GET_CODE (out_exp) == SET);
3274
3275 if (reg_mentioned_p (SET_DEST (out_exp), SET_DEST (in_exp)))
3276 return false;
3277 }
3278 }
3279 }
3280 }
3281
3282 return true;
3283 }
3284
3285 /* True if the dependency between OUT_INSN and IN_INSN is in the IF_THEN_ELSE
3286 condition, and not the THEN or ELSE branch. OUT_INSN may be either a single
3287 or multiple set; IN_INSN should be single_set for truth, but for convenience
3288 of insn categorization may be any JUMP or CALL insn. */
3289
3290 int
3291 if_test_bypass_p (rtx out_insn, rtx in_insn)
3292 {
3293 rtx out_set, in_set;
3294
3295 in_set = single_set (in_insn);
3296 if (! in_set)
3297 {
3298 gcc_assert (JUMP_P (in_insn) || CALL_P (in_insn));
3299 return false;
3300 }
3301
3302 if (GET_CODE (SET_SRC (in_set)) != IF_THEN_ELSE)
3303 return false;
3304 in_set = SET_SRC (in_set);
3305
3306 out_set = single_set (out_insn);
3307 if (out_set)
3308 {
3309 if (reg_mentioned_p (SET_DEST (out_set), XEXP (in_set, 1))
3310 || reg_mentioned_p (SET_DEST (out_set), XEXP (in_set, 2)))
3311 return false;
3312 }
3313 else
3314 {
3315 rtx out_pat;
3316 int i;
3317
3318 out_pat = PATTERN (out_insn);
3319 gcc_assert (GET_CODE (out_pat) == PARALLEL);
3320
3321 for (i = 0; i < XVECLEN (out_pat, 0); i++)
3322 {
3323 rtx exp = XVECEXP (out_pat, 0, i);
3324
3325 if (GET_CODE (exp) == CLOBBER)
3326 continue;
3327
3328 gcc_assert (GET_CODE (exp) == SET);
3329
3330 if (reg_mentioned_p (SET_DEST (out_set), XEXP (in_set, 1))
3331 || reg_mentioned_p (SET_DEST (out_set), XEXP (in_set, 2)))
3332 return false;
3333 }
3334 }
3335
3336 return true;
3337 }
3338 \f
3339 static bool
3340 gate_handle_peephole2 (void)
3341 {
3342 return (optimize > 0 && flag_peephole2);
3343 }
3344
3345 static unsigned int
3346 rest_of_handle_peephole2 (void)
3347 {
3348 #ifdef HAVE_peephole2
3349 peephole2_optimize ();
3350 #endif
3351 return 0;
3352 }
3353
3354 struct rtl_opt_pass pass_peephole2 =
3355 {
3356 {
3357 RTL_PASS,
3358 "peephole2", /* name */
3359 gate_handle_peephole2, /* gate */
3360 rest_of_handle_peephole2, /* execute */
3361 NULL, /* sub */
3362 NULL, /* next */
3363 0, /* static_pass_number */
3364 TV_PEEPHOLE2, /* tv_id */
3365 0, /* properties_required */
3366 0, /* properties_provided */
3367 0, /* properties_destroyed */
3368 0, /* todo_flags_start */
3369 TODO_df_finish | TODO_verify_rtl_sharing |
3370 TODO_dump_func /* todo_flags_finish */
3371 }
3372 };
3373
3374 static unsigned int
3375 rest_of_handle_split_all_insns (void)
3376 {
3377 split_all_insns ();
3378 return 0;
3379 }
3380
3381 struct rtl_opt_pass pass_split_all_insns =
3382 {
3383 {
3384 RTL_PASS,
3385 "split1", /* name */
3386 NULL, /* gate */
3387 rest_of_handle_split_all_insns, /* execute */
3388 NULL, /* sub */
3389 NULL, /* next */
3390 0, /* static_pass_number */
3391 0, /* tv_id */
3392 0, /* properties_required */
3393 0, /* properties_provided */
3394 0, /* properties_destroyed */
3395 0, /* todo_flags_start */
3396 TODO_dump_func /* todo_flags_finish */
3397 }
3398 };
3399
3400 static unsigned int
3401 rest_of_handle_split_after_reload (void)
3402 {
3403 /* If optimizing, then go ahead and split insns now. */
3404 #ifndef STACK_REGS
3405 if (optimize > 0)
3406 #endif
3407 split_all_insns ();
3408 return 0;
3409 }
3410
3411 struct rtl_opt_pass pass_split_after_reload =
3412 {
3413 {
3414 RTL_PASS,
3415 "split2", /* name */
3416 NULL, /* gate */
3417 rest_of_handle_split_after_reload, /* execute */
3418 NULL, /* sub */
3419 NULL, /* next */
3420 0, /* static_pass_number */
3421 0, /* tv_id */
3422 0, /* properties_required */
3423 0, /* properties_provided */
3424 0, /* properties_destroyed */
3425 0, /* todo_flags_start */
3426 TODO_dump_func /* todo_flags_finish */
3427 }
3428 };
3429
3430 static bool
3431 gate_handle_split_before_regstack (void)
3432 {
3433 #if defined (HAVE_ATTR_length) && defined (STACK_REGS)
3434 /* If flow2 creates new instructions which need splitting
3435 and scheduling after reload is not done, they might not be
3436 split until final which doesn't allow splitting
3437 if HAVE_ATTR_length. */
3438 # ifdef INSN_SCHEDULING
3439 return (optimize && !flag_schedule_insns_after_reload);
3440 # else
3441 return (optimize);
3442 # endif
3443 #else
3444 return 0;
3445 #endif
3446 }
3447
3448 static unsigned int
3449 rest_of_handle_split_before_regstack (void)
3450 {
3451 split_all_insns ();
3452 return 0;
3453 }
3454
3455 struct rtl_opt_pass pass_split_before_regstack =
3456 {
3457 {
3458 RTL_PASS,
3459 "split3", /* name */
3460 gate_handle_split_before_regstack, /* gate */
3461 rest_of_handle_split_before_regstack, /* execute */
3462 NULL, /* sub */
3463 NULL, /* next */
3464 0, /* static_pass_number */
3465 0, /* tv_id */
3466 0, /* properties_required */
3467 0, /* properties_provided */
3468 0, /* properties_destroyed */
3469 0, /* todo_flags_start */
3470 TODO_dump_func /* todo_flags_finish */
3471 }
3472 };
3473
3474 static bool
3475 gate_handle_split_before_sched2 (void)
3476 {
3477 #ifdef INSN_SCHEDULING
3478 return optimize > 0 && flag_schedule_insns_after_reload;
3479 #else
3480 return 0;
3481 #endif
3482 }
3483
3484 static unsigned int
3485 rest_of_handle_split_before_sched2 (void)
3486 {
3487 #ifdef INSN_SCHEDULING
3488 split_all_insns ();
3489 #endif
3490 return 0;
3491 }
3492
3493 struct rtl_opt_pass pass_split_before_sched2 =
3494 {
3495 {
3496 RTL_PASS,
3497 "split4", /* name */
3498 gate_handle_split_before_sched2, /* gate */
3499 rest_of_handle_split_before_sched2, /* execute */
3500 NULL, /* sub */
3501 NULL, /* next */
3502 0, /* static_pass_number */
3503 0, /* tv_id */
3504 0, /* properties_required */
3505 0, /* properties_provided */
3506 0, /* properties_destroyed */
3507 0, /* todo_flags_start */
3508 TODO_verify_flow |
3509 TODO_dump_func /* todo_flags_finish */
3510 }
3511 };
3512
3513 /* The placement of the splitting that we do for shorten_branches
3514 depends on whether regstack is used by the target or not. */
3515 static bool
3516 gate_do_final_split (void)
3517 {
3518 #if defined (HAVE_ATTR_length) && !defined (STACK_REGS)
3519 return 1;
3520 #else
3521 return 0;
3522 #endif
3523 }
3524
3525 struct rtl_opt_pass pass_split_for_shorten_branches =
3526 {
3527 {
3528 RTL_PASS,
3529 "split5", /* name */
3530 gate_do_final_split, /* gate */
3531 split_all_insns_noflow, /* execute */
3532 NULL, /* sub */
3533 NULL, /* next */
3534 0, /* static_pass_number */
3535 0, /* tv_id */
3536 0, /* properties_required */
3537 0, /* properties_provided */
3538 0, /* properties_destroyed */
3539 0, /* todo_flags_start */
3540 TODO_dump_func | TODO_verify_rtl_sharing /* todo_flags_finish */
3541 }
3542 };
3543
3544