|
|
1.1 root 1: /* Data flow analysis for GNU compiler.
1.1.1.2 root 2: Copyright (C) 1987, 1988 Free Software Foundation, Inc.
1.1 root 3:
4: This file is part of GNU CC.
5:
6: GNU CC is distributed in the hope that it will be useful,
7: but WITHOUT ANY WARRANTY. No author or distributor
8: accepts responsibility to anyone for the consequences of using it
9: or for whether it serves any particular purpose or works at all,
10: unless he says so in writing. Refer to the GNU CC General Public
11: License for full details.
12:
13: Everyone is granted permission to copy, modify and redistribute
14: GNU CC, but only under the conditions described in the
15: GNU CC General Public License. A copy of this license is
16: supposed to have been given to you along with GNU CC so you
17: can know your rights and responsibilities. It should be in a
18: file named COPYING. Among other things, the copyright notice
19: and this notice must be preserved on all copies. */
20:
21:
22: /* This file contains the data flow analysis pass of the compiler.
23: It computes data flow information
24: which tells combine_instructions which insns to consider combining
25: and controls register allocation.
26:
27: Additional data flow information that is too bulky to record
28: is generated during the analysis, and is used at that time to
29: create autoincrement and autodecrement addressing.
30:
31: The first step is dividing the function into basic blocks.
32: find_basic_blocks does this. Then life_analysis determines
33: where each register is live and where it is dead.
34:
35: ** find_basic_blocks **
36:
37: find_basic_blocks divides the current function's rtl
38: into basic blocks. It records the beginnings and ends of the
39: basic blocks in the vectors basic_block_head and basic_block_end,
40: and the number of blocks in n_basic_blocks.
41:
42: find_basic_blocks also finds any unreachable loops
43: and deletes them.
44:
45: ** life_analysis **
46:
47: life_analysis is called immediately after find_basic_blocks.
48: It uses the basic block information to determine where each
49: hard or pseudo register is live.
50:
51: ** live-register info **
52:
53: The information about where each register is live is in two parts:
54: the REG_NOTES of insns, and the vector basic_block_live_at_start.
55:
56: basic_block_live_at_start has an element for each basic block,
57: and the element is a bit-vector with a bit for each hard or pseudo
58: register. The bit is 1 if the register is live at the beginning
59: of the basic block.
60:
61: To each insn's REG_NOTES is added an element for each register
62: that is live before the insn or set by the insn, but is dead
63: after the insn.
64:
65: To determine which registers are live after any insn, one can
66: start from the beginning of the basic block and scan insns, noting
67: which registers are set by each insn and which die there.
68:
69: ** Other actions of life_analysis **
70:
71: life_analysis sets up the LOG_LINKS fields of insns because the
72: information needed to do so is readily available.
73:
74: life_analysis deletes insns whose only effect is to store a value
75: that is never used.
76:
77: life_analysis notices cases where a reference to a register as
78: a memory address can be combined with a preceding or following
79: incrementation or decrementation of the register. The separate
80: instruction to increment or decrement is deleted and the address
81: is changed to a POST_INC or similar rtx.
82:
83: Each time an incrementing or decrementing address is created,
84: a REG_INC element is added to the insn's REG_NOTES list.
85:
86: life_analysis fills in certain vectors containing information about
87: register usage: reg_n_refs, reg_n_deaths, reg_n_sets,
88: reg_live_length, reg_crosses_call and reg_basic_block. */
89:
90: #include <stdio.h>
91: #include "config.h"
92: #include "rtl.h"
93: #include "basic-block.h"
94: #include "regs.h"
1.1.1.2 root 95: #include "hard-reg-set.h"
96: #include "flags.h"
1.1 root 97:
98: /* Get the basic block number of an insn.
99: This info should not be expected to remain available
100: after the end of life_analysis. */
101:
102: #define BLOCK_NUM(INSN) uid_block_number[INSN_UID (INSN)]
103:
104: /* This is where the BLOCK_NUM values are really stored.
105: This is set up by find_basic_blocks and used there and in life_analysis,
106: and then freed. */
107:
108: static short *uid_block_number;
109:
1.1.1.2 root 110: /* INSN_VOLATILE (insn) is 1 if the insn refers to anything volatile. */
111:
112: #define INSN_VOLATILE(INSN) uid_volatile[INSN_UID (INSN)]
113: static char *uid_volatile;
114:
1.1 root 115: /* Number of basic blocks in the current function. */
116:
117: int n_basic_blocks;
118:
119: /* Maximum register number used in this function, plus one. */
120:
121: int max_regno;
122:
123: /* Indexed by n, gives number of basic block that (REG n) is used in.
124: Or gives -2 if (REG n) is used in more than one basic block.
125: Or -1 if it has not yet been seen so no basic block is known.
126: This information remains valid for the rest of the compilation
127: of the current function; it is used to control register allocation. */
128:
1.1.1.4 root 129: #define REG_BLOCK_UNKNOWN -1
130: #define REG_BLOCK_GLOBAL -2
1.1 root 131: short *reg_basic_block;
132:
133: /* Indexed by n, gives number of times (REG n) is used or set, each
134: weighted by its loop-depth.
135: This information remains valid for the rest of the compilation
136: of the current function; it is used to control register allocation. */
137:
138: short *reg_n_refs;
139:
140: /* Indexed by n, gives number of times (REG n) is set.
141: This information remains valid for the rest of the compilation
142: of the current function; it is used to control register allocation. */
143:
144: short *reg_n_sets;
145:
146: /* Indexed by N, gives number of places register N dies.
147: This information remains valid for the rest of the compilation
148: of the current function; it is used to control register allocation. */
149:
150: short *reg_n_deaths;
151:
152: /* Indexed by N, gives 1 if that reg is live across any CALL_INSNs.
153: This information remains valid for the rest of the compilation
154: of the current function; it is used to control register allocation. */
155:
156: char *reg_crosses_call;
157:
158: /* Total number of instructions at which (REG n) is live.
159: The larger this is, the less priority (REG n) gets for
160: allocation in a real register.
161: This information remains valid for the rest of the compilation
1.1.1.2 root 162: of the current function; it is used to control register allocation.
163:
164: local-alloc.c may alter this number to change the priority.
165:
166: Negative values are special.
167: -1 is used to mark a pseudo reg which has a constant or memory equivalent
168: and is used infrequently enough that it should not get a hard register.
169: -2 is used to mark a pseudo reg for a parameter, when a frame pointer
170: is not required. global-alloc.c makes an allocno for this but does
171: not try to assign a hard register to it. */
1.1 root 172:
173: int *reg_live_length;
174:
175: /* Element N is the next insn that uses (hard or pseudo) register number N
176: within the current basic block; or zero, if there is no such insn.
177: This is valid only during the final backward scan in propagate_block. */
178:
179: static rtx *reg_next_use;
180:
181: /* Size of a regset for the current function,
182: in (1) bytes and (2) elements. */
183:
184: int regset_bytes;
185: int regset_size;
186:
187: /* Element N is first insn in basic block N.
188: This info lasts until we finish compiling the function. */
189:
190: rtx *basic_block_head;
191:
192: /* Element N is last insn in basic block N.
193: This info lasts until we finish compiling the function. */
194:
195: rtx *basic_block_end;
196:
197: /* Element N is a regset describing the registers live
198: at the start of basic block N.
199: This info lasts until we finish compiling the function. */
200:
201: regset *basic_block_live_at_start;
202:
1.1.1.2 root 203: /* Regset of regs live when calls to `setjmp'-like functions happen. */
204:
205: regset regs_live_at_setjmp;
206:
1.1 root 207: /* Element N is nonzero if control can drop into basic block N
208: from the preceding basic block. Freed after life_analysis. */
209:
1.1.1.2 root 210: static char *basic_block_drops_in;
1.1 root 211:
212: /* Element N is depth within loops of basic block number N.
213: Freed after life_analysis. */
214:
1.1.1.2 root 215: static short *basic_block_loop_depth;
1.1 root 216:
217: /* Element N nonzero if basic block N can actually be reached.
218: Vector exists only during find_basic_blocks. */
219:
1.1.1.2 root 220: static char *block_live_static;
1.1 root 221:
222: /* Depth within loops of basic block being scanned for lifetime analysis,
223: plus one. This is the weight attached to references to registers. */
224:
1.1.1.2 root 225: static int loop_depth;
226:
227: /* Define AUTO_INC_DEC if machine has any kind of incrementing
228: or decrementing addressing. */
229:
230: #ifdef HAVE_PRE_DECREMENT
231: #define AUTO_INC_DEC
232: #endif
233:
234: #ifdef HAVE_PRE_INCREMENT
235: #define AUTO_INC_DEC
236: #endif
237:
238: #ifdef HAVE_POST_DECREMENT
239: #define AUTO_INC_DEC
240: #endif
241:
242: #ifdef HAVE_POST_INCREMENT
243: #define AUTO_INC_DEC
244: #endif
1.1 root 245:
246: /* Forward declarations */
247: static void find_basic_blocks ();
248: static void life_analysis ();
249: static void mark_label_ref ();
250: void allocate_for_life_analysis (); /* Used also in stupid_life_analysis */
251: static void init_regset_vector ();
252: static void propagate_block ();
253: static void mark_set_regs ();
254: static void mark_used_regs ();
255: static int insn_dead_p ();
256: static int try_pre_increment ();
257: static int try_pre_increment_1 ();
258: static rtx find_use_as_address ();
1.1.1.2 root 259: void dump_flow_info ();
1.1 root 260:
261: /* Find basic blocks of the current function and perform data flow analysis.
262: F is the first insn of the function and NREGS the number of register numbers
263: in use. */
264:
265: void
266: flow_analysis (f, nregs, file)
267: rtx f;
268: int nregs;
269: FILE *file;
270: {
271: register rtx insn;
272: register int i;
273: register int max_uid = 0;
274:
275: /* Count the basic blocks. Also find maximum insn uid value used. */
276:
277: {
278: register RTX_CODE prev_code = JUMP_INSN;
279: register RTX_CODE code;
280:
281: for (insn = f, i = 0; insn; insn = NEXT_INSN (insn))
282: {
283: code = GET_CODE (insn);
284: if (INSN_UID (insn) > max_uid)
285: max_uid = INSN_UID (insn);
286: if (code == CODE_LABEL
287: || (prev_code != INSN && prev_code != CALL_INSN
288: && prev_code != CODE_LABEL
289: && (code == INSN || code == CALL_INSN || code == JUMP_INSN)))
290: i++;
291: if (code != NOTE)
292: prev_code = code;
293: }
294: }
295:
296: /* Allocate some tables that last till end of compiling this function
297: and some needed only in find_basic_blocks and life_analysis. */
298:
299: n_basic_blocks = i;
300: basic_block_head = (rtx *) oballoc (n_basic_blocks * sizeof (rtx));
301: basic_block_end = (rtx *) oballoc (n_basic_blocks * sizeof (rtx));
302: basic_block_drops_in = (char *) alloca (n_basic_blocks);
303: basic_block_loop_depth = (short *) alloca (n_basic_blocks * sizeof (short));
304: uid_block_number = (short *) alloca ((max_uid + 1) * sizeof (short));
1.1.1.2 root 305: uid_volatile = (char *) alloca (max_uid + 1);
306: bzero (uid_volatile, max_uid + 1);
1.1 root 307:
308: find_basic_blocks (f);
309: life_analysis (f, nregs);
310: if (file)
311: dump_flow_info (file);
312:
313: basic_block_drops_in = 0;
314: uid_block_number = 0;
315: basic_block_loop_depth = 0;
316: }
317:
318: /* Find all basic blocks of the function whose first insn is F.
319: Store the correct data in the tables that describe the basic blocks,
320: set up the chains of references for each CODE_LABEL, and
321: delete any entire basic blocks that cannot be reached. */
322:
323: static void
324: find_basic_blocks (f)
325: rtx f;
326: {
327: register rtx insn;
328: register int i;
329:
330: /* Initialize the ref chain of each label to 0. */
331: /* Record where all the blocks start and end and their depth in loops. */
332: /* For each insn, record the block it is in. */
333:
334: {
335: register RTX_CODE prev_code = JUMP_INSN;
336: register RTX_CODE code;
337: int depth = 1;
338:
339: for (insn = f, i = -1; insn; insn = NEXT_INSN (insn))
340: {
341: code = GET_CODE (insn);
342: if (code == NOTE)
343: {
344: if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_LOOP_BEG)
345: depth++;
346: else if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_LOOP_END)
347: depth--;
348: }
349: else if (code == CODE_LABEL
350: || (prev_code != INSN && prev_code != CALL_INSN
351: && prev_code != CODE_LABEL
352: && (code == INSN || code == CALL_INSN || code == JUMP_INSN)))
353: {
354: basic_block_head[++i] = insn;
355: basic_block_end[i] = insn;
356: basic_block_loop_depth[i] = depth;
357: if (code == CODE_LABEL)
358: LABEL_REFS (insn) = insn;
359: }
360: else if (code == INSN || code == CALL_INSN || code == JUMP_INSN)
361: basic_block_end[i] = insn;
362: BLOCK_NUM (insn) = i;
363: if (code != NOTE)
364: prev_code = code;
365: }
1.1.1.4 root 366: if (i + 1 != n_basic_blocks)
367: abort ();
1.1 root 368: }
369:
370: /* Record which basic blocks control can drop in to. */
371:
372: {
373: register int i;
374: for (i = 0; i < n_basic_blocks; i++)
375: {
376: register rtx insn = PREV_INSN (basic_block_head[i]);
1.1.1.2 root 377: /* TEMP1 is used to avoid a bug in Sequent's compiler. */
378: register int temp1;
1.1 root 379: while (insn && GET_CODE (insn) == NOTE)
380: insn = PREV_INSN (insn);
1.1.1.2 root 381: temp1 = insn && GET_CODE (insn) != BARRIER;
382: basic_block_drops_in[i] = temp1;
1.1 root 383: }
384: }
385:
386: /* Now find which basic blocks can actually be reached
387: and put all jump insns' LABEL_REFS onto the ref-chains
388: of their target labels. */
389:
390: if (n_basic_blocks > 0)
391: {
392: register char *block_live = (char *) alloca (n_basic_blocks);
393: register char *block_marked = (char *) alloca (n_basic_blocks);
394: int something_marked = 1;
395:
396: /* Initialize with just block 0 reachable and no blocks marked. */
397:
398: bzero (block_live, n_basic_blocks);
399: bzero (block_marked, n_basic_blocks);
400: block_live[0] = 1;
401: block_live_static = block_live;
402:
403: /* Pass over all blocks, marking each block that is reachable
404: and has not yet been marked.
405: Keep doing this until, in one pass, no blocks have been marked.
406: Then blocks_live and blocks_marked are identical and correct.
407: In addition, all jumps actually reachable have been marked. */
408:
409: while (something_marked)
410: {
411: something_marked = 0;
412: for (i = 0; i < n_basic_blocks; i++)
413: if (block_live[i] && !block_marked[i])
414: {
415: block_marked[i] = 1;
416: something_marked = 1;
417: if (i + 1 < n_basic_blocks && basic_block_drops_in[i + 1])
418: block_live[i + 1] = 1;
419: insn = basic_block_end[i];
420: if (GET_CODE (insn) == JUMP_INSN)
421: mark_label_ref (PATTERN (insn), insn, 0);
422: }
423: }
424:
425: /* Now delete the code for any basic blocks that can't be reached.
426: They can occur because jump_optimize does not recognize
427: unreachable loops as unreachable. */
428:
429: for (i = 0; i < n_basic_blocks; i++)
430: if (!block_live[i])
431: {
432: insn = basic_block_head[i];
433: while (1)
434: {
1.1.1.2 root 435: if (GET_CODE (insn) == BARRIER)
436: abort ();
1.1 root 437: if (GET_CODE (insn) != NOTE)
438: {
439: PUT_CODE (insn, NOTE);
440: NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
441: NOTE_SOURCE_FILE (insn) = 0;
442: }
443: if (insn == basic_block_end[i])
1.1.1.2 root 444: {
445: /* BARRIERs are between basic blocks, not part of one.
446: Delete a BARRIER if the preceding jump is deleted.
447: We cannot alter a BARRIER into a NOTE
448: because it is too short; but we can really delete
449: it because it is not part of a basic block. */
450: if (NEXT_INSN (insn) != 0
451: && GET_CODE (NEXT_INSN (insn)) == BARRIER)
452: delete_insn (NEXT_INSN (insn));
453: break;
454: }
1.1 root 455: insn = NEXT_INSN (insn);
456: }
457: /* Each time we delete some basic blocks,
458: see if there is a jump around them that is
459: being turned into a no-op. If so, delete it. */
460:
461: if (block_live[i - 1])
462: {
463: register int j;
464: for (j = i; j < n_basic_blocks; j++)
465: if (block_live[j])
466: {
1.1.1.6 root 467: rtx label;
1.1 root 468: insn = basic_block_end[i - 1];
469: if (GET_CODE (insn) == JUMP_INSN
1.1.1.6 root 470: /* An unconditional jump is the only possibility
471: we must check for, since a conditional one
472: would make these blocks live. */
473: && simplejump_p (insn)
474: && (label = XEXP (SET_SRC (PATTERN (insn)), 0), 1)
475: && INSN_UID (label) != 0
476: && BLOCK_NUM (label) == j)
1.1 root 477: {
478: PUT_CODE (insn, NOTE);
479: NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
480: NOTE_SOURCE_FILE (insn) = 0;
1.1.1.2 root 481: if (GET_CODE (NEXT_INSN (insn)) != BARRIER)
482: abort ();
483: delete_insn (NEXT_INSN (insn));
1.1 root 484: }
485: break;
486: }
487: }
488: }
489: }
490: }
491:
492: /* Check expression X for label references;
493: if one is found, add INSN to the label's chain of references.
494:
495: CHECKDUP means check for and avoid creating duplicate references
496: from the same insn. Such duplicates do no serious harm but
497: can slow life analysis. CHECKDUP is set only when duplicates
498: are likely. */
499:
500: static void
501: mark_label_ref (x, insn, checkdup)
502: rtx x, insn;
503: int checkdup;
504: {
505: register RTX_CODE code = GET_CODE (x);
506: register int i;
507: register char *fmt;
508:
509: if (code == LABEL_REF)
510: {
511: register rtx label = XEXP (x, 0);
512: register rtx y;
513: if (GET_CODE (label) != CODE_LABEL)
1.1.1.4 root 514: abort ();
1.1.1.2 root 515: /* If the label was never emitted, this insn is junk,
516: but avoid a crash trying to refer to BLOCK_NUM (label).
517: This can happen as a result of a syntax error
518: and a diagnostic has already been printed. */
519: if (INSN_UID (label) == 0)
520: return;
1.1 root 521: CONTAINING_INSN (x) = insn;
522: /* if CHECKDUP is set, check for duplicate ref from same insn
523: and don't insert. */
524: if (checkdup)
525: for (y = LABEL_REFS (label); y != label; y = LABEL_NEXTREF (y))
526: if (CONTAINING_INSN (y) == insn)
527: return;
528: LABEL_NEXTREF (x) = LABEL_REFS (label);
529: LABEL_REFS (label) = x;
530: block_live_static[BLOCK_NUM (label)] = 1;
531: return;
532: }
533:
534: fmt = GET_RTX_FORMAT (code);
535: for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
536: {
537: if (fmt[i] == 'e')
538: mark_label_ref (XEXP (x, i), insn, 0);
539: if (fmt[i] == 'E')
540: {
541: register int j;
542: for (j = 0; j < XVECLEN (x, i); j++)
543: mark_label_ref (XVECEXP (x, i, j), insn, 1);
544: }
545: }
546: }
547:
548: /* Determine the which registers are live at the start of each
549: basic block of the function whose first insn is F.
550: NREGS is the number of registers used in F.
551: We allocate the vector basic_block_live_at_start
552: and the regsets that it points to, and fill them with the data.
553: regset_size and regset_bytes are also set here. */
554:
555: static void
556: life_analysis (f, nregs)
557: rtx f;
558: int nregs;
559: {
560: register regset tem;
561: int first_pass;
562: int changed;
563: /* For each basic block, a bitmask of regs
564: live on exit from the block. */
565: regset *basic_block_live_at_end;
566: /* For each basic block, a bitmask of regs
567: live on entry to a successor-block of this block.
568: If this does not match basic_block_live_at_end,
569: that must be updated, and the block must be rescanned. */
570: regset *basic_block_new_live_at_end;
571: /* For each basic block, a bitmask of regs
572: whose liveness at the end of the basic block
573: can make a difference in which regs are live on entry to the block.
574: These are the regs that are set within the basic block,
575: possibly excluding those that are used after they are set. */
576: regset *basic_block_significant;
577: register int i;
1.1.1.2 root 578: rtx insn;
1.1 root 579:
580: max_regno = nregs;
581:
582: bzero (regs_ever_live, sizeof regs_ever_live);
583:
584: /* Allocate and zero out many data structures
585: that will record the data from lifetime analysis. */
586:
587: allocate_for_life_analysis ();
588:
589: reg_next_use = (rtx *) alloca (nregs * sizeof (rtx));
590: bzero (reg_next_use, nregs * sizeof (rtx));
591:
592: /* Set up several regset-vectors used internally within this function.
593: Their meanings are documented above, with their declarations. */
594:
595: basic_block_live_at_end = (regset *) alloca (n_basic_blocks * sizeof (regset));
596: tem = (regset) alloca (n_basic_blocks * regset_bytes);
597: bzero (tem, n_basic_blocks * regset_bytes);
598: init_regset_vector (basic_block_live_at_end, tem, n_basic_blocks, regset_bytes);
599:
600: basic_block_new_live_at_end = (regset *) alloca (n_basic_blocks * sizeof (regset));
601: tem = (regset) alloca (n_basic_blocks * regset_bytes);
602: bzero (tem, n_basic_blocks * regset_bytes);
603: init_regset_vector (basic_block_new_live_at_end, tem, n_basic_blocks, regset_bytes);
604:
605: basic_block_significant = (regset *) alloca (n_basic_blocks * sizeof (regset));
606: tem = (regset) alloca (n_basic_blocks * regset_bytes);
607: bzero (tem, n_basic_blocks * regset_bytes);
608: init_regset_vector (basic_block_significant, tem, n_basic_blocks, regset_bytes);
609:
1.1.1.4 root 610: /* Record which insns refer to any volatile memory
611: or for any reason can't be deleted just because they are dead stores. */
1.1.1.2 root 612:
613: for (insn = f; insn; insn = NEXT_INSN (insn))
1.1.1.4 root 614: {
615: enum rtx_code code1 = GET_CODE (insn);
616: if (code1 == CALL_INSN)
617: INSN_VOLATILE (insn) = 1;
618: else if (code1 == INSN || code1 == JUMP_INSN)
619: {
620: if (GET_CODE (PATTERN (insn)) != USE)
621: INSN_VOLATILE (insn) = volatile_refs_p (PATTERN (insn));
622: }
1.1.1.6 root 623: /* A SET that makes space on the stack cannot be dead.
624: Even if this function never uses this stack pointer value,
625: signal handlers do! */
626: else if (code1 == INSN && GET_CODE (PATTERN (insn)) == SET
627: && SET_DEST (PATTERN (insn)) == stack_pointer_rtx
628: #ifdef STACK_GROWS_DOWNWARD
629: && GET_CODE (SET_SRC (PATTERN (insn))) == MINUS
630: #else
631: && GET_CODE (SET_SRC (PATTERN (insn))) == PLUS
632: #endif
633: && XEXP (SET_SRC (PATTERN (insn)), 0) == stack_pointer_rtx)
634: INSN_VOLATILE (insn) = 1;
1.1.1.4 root 635: }
1.1.1.2 root 636:
637: if (n_basic_blocks > 0)
638: #ifdef EXIT_IGNORE_STACK
639: if (! (EXIT_IGNORE_STACK) || ! frame_pointer_needed)
640: #endif
641: {
642: /* If exiting needs the right stack value,
643: consider the stack pointer live at the end of the function. */
644: basic_block_live_at_end[n_basic_blocks - 1]
645: [STACK_POINTER_REGNUM / REGSET_ELT_BITS]
646: |= 1 << (STACK_POINTER_REGNUM % REGSET_ELT_BITS);
647: basic_block_new_live_at_end[n_basic_blocks - 1]
648: [STACK_POINTER_REGNUM / REGSET_ELT_BITS]
649: |= 1 << (STACK_POINTER_REGNUM % REGSET_ELT_BITS);
650: }
651:
1.1 root 652: /* Propagate life info through the basic blocks
653: around the graph of basic blocks.
654:
655: This is a relaxation process: each time a new register
656: is live at the end of the basic block, we must scan the block
657: to determine which registers are, as a consequence, live at the beginning
658: of that block. These registers must then be marked live at the ends
659: of all the blocks that can transfer control to that block.
660: The process continues until it reaches a fixed point. */
661:
662: first_pass = 1;
663: changed = 1;
664: while (changed)
665: {
666: changed = 0;
667: for (i = n_basic_blocks - 1; i >= 0; i--)
668: {
669: int consider = first_pass;
670: int must_rescan = first_pass;
671: register int j;
672:
673: /* Set CONSIDER if this block needs thinking about at all
674: (that is, if the regs live now at the end of it
675: are not the same as were live at the end of it when
676: we last thought about it).
677: Set must_rescan if it needs to be thought about
678: instruction by instruction (that is, if any additional
679: reg that is live at the end now but was not live there before
680: is one of the significant regs of this basic block). */
681:
682: for (j = 0; j < regset_size; j++)
683: {
684: register int x = basic_block_new_live_at_end[i][j]
685: & ~basic_block_live_at_end[i][j];
686: if (x)
687: consider = 1;
688: if (x & basic_block_significant[i][j])
689: {
690: must_rescan = 1;
691: consider = 1;
692: break;
693: }
694: }
695:
696: if (! consider)
697: continue;
698:
699: /* The live_at_start of this block may be changing,
700: so another pass will be required after this one. */
701: changed = 1;
702:
703: if (! must_rescan)
704: {
705: /* No complete rescan needed;
706: just record those variables newly known live at end
707: as live at start as well. */
708: for (j = 0; j < regset_size; j++)
709: {
710: register int x = basic_block_new_live_at_end[i][j]
711: & ~basic_block_live_at_end[i][j];
712: basic_block_live_at_start[i][j] |= x;
713: basic_block_live_at_end[i][j] |= x;
714: }
715: }
716: else
717: {
718: /* Update the basic_block_live_at_start
719: by propagation backwards through the block. */
720: bcopy (basic_block_new_live_at_end[i],
721: basic_block_live_at_end[i], regset_bytes);
722: bcopy (basic_block_live_at_end[i],
723: basic_block_live_at_start[i], regset_bytes);
724: propagate_block (basic_block_live_at_start[i],
725: basic_block_head[i], basic_block_end[i], 0,
726: first_pass ? basic_block_significant[i] : 0,
727: i);
728: }
729:
730: {
731: register rtx jump, head;
732: /* Update the basic_block_new_live_at_end's of the block
733: that falls through into this one (if any). */
734: head = basic_block_head[i];
735: jump = PREV_INSN (head);
736: if (basic_block_drops_in[i])
737: {
738: register from_block = BLOCK_NUM (jump);
739: register int j;
740: for (j = 0; j < regset_size; j++)
741: basic_block_new_live_at_end[from_block][j]
742: |= basic_block_live_at_start[i][j];
743: }
744: /* Update the basic_block_new_live_at_end's of
745: all the blocks that jump to this one. */
746: if (GET_CODE (head) == CODE_LABEL)
747: for (jump = LABEL_REFS (head);
748: jump != head;
749: jump = LABEL_NEXTREF (jump))
750: {
751: register from_block = BLOCK_NUM (CONTAINING_INSN (jump));
752: register int j;
753: for (j = 0; j < regset_size; j++)
754: basic_block_new_live_at_end[from_block][j]
755: |= basic_block_live_at_start[i][j];
756: }
757: }
758: }
759: first_pass = 0;
760: }
761:
1.1.1.5 root 762: #if 0 /* This seems unnecessary; life at start of function shouldn't
763: mean that the reg is live in more than one basic block. */
764:
1.1.1.2 root 765: /* Process the regs live at the beginning of the function.
766: Mark them as not local to any one basic block. */
767:
768: if (n_basic_blocks > 0)
769: for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
770: if (basic_block_live_at_start[0][i / REGSET_ELT_BITS]
771: & (1 << (i % REGSET_ELT_BITS)))
1.1.1.4 root 772: reg_basic_block[i] = REG_BLOCK_GLOBAL;
1.1.1.5 root 773: #endif
1.1.1.2 root 774:
1.1 root 775: /* Now the life information is accurate.
776: Make one more pass over each basic block
777: to delete dead stores, create autoincrement addressing
778: and record how many times each register is used, is set, or dies.
779:
780: To save time, we operate directly in basic_block_live_at_end[i],
781: thus destroying it (in fact, converting it into a copy of
782: basic_block_live_at_start[i]). This is ok now because
783: basic_block_live_at_end[i] is no longer used past this point. */
784:
785: for (i = 0; i < n_basic_blocks; i++)
786: {
787: propagate_block (basic_block_live_at_end[i],
788: basic_block_head[i], basic_block_end[i], 1, 0, i);
789: }
790: }
791:
792: /* Subroutines of life analysis. */
793:
794: /* Allocate the permanent data structures that represent the results
795: of life analysis. Not static since used also for stupid life analysis. */
796:
797: void
798: allocate_for_life_analysis ()
799: {
800: register int i;
801: register regset tem;
802:
803: regset_size = ((max_regno + REGSET_ELT_BITS - 1) / REGSET_ELT_BITS);
804: regset_bytes = regset_size * sizeof (*(regset)0);
805:
806: reg_n_refs = (short *) oballoc (max_regno * sizeof (short));
807: bzero (reg_n_refs, max_regno * sizeof (short));
808:
809: reg_n_sets = (short *) oballoc (max_regno * sizeof (short));
810: bzero (reg_n_sets, max_regno * sizeof (short));
811:
812: reg_n_deaths = (short *) oballoc (max_regno * sizeof (short));
813: bzero (reg_n_deaths, max_regno * sizeof (short));
814:
815: reg_live_length = (int *) oballoc (max_regno * sizeof (int));
816: bzero (reg_live_length, max_regno * sizeof (int));
817:
818: reg_crosses_call = (char *) oballoc (max_regno);
819: bzero (reg_crosses_call, max_regno);
820:
821: reg_basic_block = (short *) oballoc (max_regno * sizeof (short));
822: for (i = 0; i < max_regno; i++)
1.1.1.4 root 823: reg_basic_block[i] = REG_BLOCK_UNKNOWN;
1.1 root 824:
825: basic_block_live_at_start = (regset *) oballoc (n_basic_blocks * sizeof (regset));
826: tem = (regset) oballoc (n_basic_blocks * regset_bytes);
827: bzero (tem, n_basic_blocks * regset_bytes);
828: init_regset_vector (basic_block_live_at_start, tem, n_basic_blocks, regset_bytes);
1.1.1.2 root 829:
830: regs_live_at_setjmp = (regset) oballoc (regset_bytes);
831: bzero (regs_live_at_setjmp, regset_bytes);
1.1 root 832: }
833:
834: /* Make each element of VECTOR point at a regset,
835: taking the space for all those regsets from SPACE.
836: SPACE is of type regset, but it is really as long as NELTS regsets.
837: BYTES_PER_ELT is the number of bytes in one regset. */
838:
839: static void
840: init_regset_vector (vector, space, nelts, bytes_per_elt)
841: regset *vector;
842: regset space;
843: int nelts;
844: int bytes_per_elt;
845: {
846: register int i;
847: register regset p = space;
848:
849: for (i = 0; i < nelts; i++)
850: {
851: vector[i] = p;
852: p += bytes_per_elt / sizeof (*p);
853: }
854: }
855:
856: /* Compute the registers live at the beginning of a basic block
857: from those live at the end.
858:
859: When called, OLD contains those live at the end.
860: On return, it contains those live at the beginning.
861: FIRST and LAST are the first and last insns of the basic block.
862:
863: FINAL is nonzero if we are doing the final pass which is not
864: for computing the life info (since that has already been done)
865: but for acting on it. On this pass, we delete dead stores,
866: set up the logical links and dead-variables lists of instructions,
867: and merge instructions for autoincrement and autodecrement addresses.
868:
869: SIGNIFICANT is nonzero only the first time for each basic block.
870: If it is nonzero, it points to a regset in which we store
871: a 1 for each register that is set within the block.
872:
873: BNUM is the number of the basic block. */
874:
875: static void
876: propagate_block (old, first, last, final, significant, bnum)
877: register regset old;
878: rtx first;
879: rtx last;
880: int final;
881: regset significant;
882: int bnum;
883: {
884: register rtx insn;
885: rtx prev;
886: regset live;
887: regset dead;
888:
889: /* The following variables are used only if FINAL is nonzero. */
890: /* This vector gets one element for each reg that has been live
891: at any point in the basic block that has been scanned so far.
892: SOMETIMES_MAX says how many elements are in use so far.
893: In each element, OFFSET is the byte-number within a regset
894: for the register described by the element, and BIT is a mask
895: for that register's bit within the byte. */
896: register struct foo { short offset; short bit; } *regs_sometimes_live;
897: int sometimes_max = 0;
898: /* This regset has 1 for each reg that we have seen live so far.
899: It and REGS_SOMETIMES_LIVE are updated together. */
900: regset maxlive;
901:
902: loop_depth = basic_block_loop_depth[bnum];
903:
904: dead = (regset) alloca (regset_bytes);
905: live = (regset) alloca (regset_bytes);
906:
907: if (final)
908: {
909: register int i, offset, bit;
910:
911: maxlive = (regset) alloca (regset_bytes);
912: bcopy (old, maxlive, regset_bytes);
913: regs_sometimes_live
914: = (struct foo *) alloca (max_regno * sizeof (struct foo));
915:
916: /* Process the regs live at the end of the block.
917: Enter them in MAXLIVE and REGS_SOMETIMES_LIVE.
918: Also mark them as not local to any one basic block. */
919:
920: for (offset = 0, i = 0; offset < regset_size; offset++)
921: for (bit = 1; bit; bit <<= 1, i++)
922: {
923: if (i == max_regno)
924: break;
925: if (old[offset] & bit)
926: {
1.1.1.4 root 927: reg_basic_block[i] = REG_BLOCK_GLOBAL;
1.1 root 928: regs_sometimes_live[sometimes_max].offset = offset;
929: regs_sometimes_live[sometimes_max].bit = i % REGSET_ELT_BITS;
930: sometimes_max++;
931: }
932: }
933: }
934:
935: /* Scan the block an insn at a time from end to beginning. */
936:
937: for (insn = last; ; insn = prev)
938: {
939: prev = PREV_INSN (insn);
940:
1.1.1.2 root 941: /* If this is a call to `setjmp' et al,
942: warn if any non-volatile datum is live. */
943:
944: if (final && GET_CODE (insn) == NOTE
945: && NOTE_LINE_NUMBER (insn) == NOTE_INSN_SETJMP)
946: {
947: int i;
948: for (i = 0; i < regset_size; i++)
949: regs_live_at_setjmp[i] |= old[i];
1.1 root 950: }
951:
952: /* Update the life-status of regs for this insn.
953: First DEAD gets which regs are set in this insn
954: then LIVE gets which regs are used in this insn.
955: Then the regs live before the insn
956: are those live after, with DEAD regs turned off,
957: and then LIVE regs turned on. */
958:
959: if (GET_CODE (insn) == INSN
960: || GET_CODE (insn) == JUMP_INSN
961: || GET_CODE (insn) == CALL_INSN)
962: {
963: register int i;
1.1.1.2 root 964: rtx note = find_reg_note (insn, REG_RETVAL, 0);
965:
1.1 root 966: /* If an instruction consists of just dead store(s) on final pass,
967: "delete" it by turning it into a NOTE of type NOTE_INSN_DELETED.
968: We could really delete it with delete_insn, but that
969: can cause trouble for first or last insn in a basic block. */
1.1.1.2 root 970: if (final && insn_dead_p (PATTERN (insn), old, 1)
971: /* Don't delete something that refers to volatile storage! */
972: && ! INSN_VOLATILE (insn))
1.1 root 973: {
974: PUT_CODE (insn, NOTE);
975: NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
976: NOTE_SOURCE_FILE (insn) = 0;
1.1.1.2 root 977: /* If this insn is copying the return value from a library call,
978: delete the entire library call. */
979: if (note)
980: {
981: rtx first = XEXP (note, 0);
982: rtx prev = insn;
983: while (first->volatil)
984: first = NEXT_INSN (first);
985: while (prev != first)
986: {
987: prev = PREV_INSN (prev);
988: PUT_CODE (prev, NOTE);
989: NOTE_LINE_NUMBER (prev) = NOTE_INSN_DELETED;
990: NOTE_SOURCE_FILE (prev) = 0;
991: }
992: }
1.1 root 993: goto flushed;
994: }
1.1.1.2 root 995:
996: for (i = 0; i < regset_size; i++)
1.1 root 997: {
1.1.1.2 root 998: dead[i] = 0; /* Faster than bzero here */
999: live[i] = 0; /* since regset_size is usually small */
1000: }
1.1 root 1001:
1.1.1.2 root 1002: /* See if this is an increment or decrement that can be
1003: merged into a following memory address. */
1004: #ifdef AUTO_INC_DEC
1005: {
1006: register rtx x = PATTERN (insn);
1007: /* Does this instruction increment or decrement a register? */
1008: if (final && GET_CODE (x) == SET
1009: && GET_CODE (SET_DEST (x)) == REG
1010: && (GET_CODE (SET_SRC (x)) == PLUS
1011: || GET_CODE (SET_SRC (x)) == MINUS)
1012: && XEXP (SET_SRC (x), 0) == SET_DEST (x)
1013: && GET_CODE (XEXP (SET_SRC (x), 1)) == CONST_INT
1014: /* Ok, look for a following memory ref we can combine with.
1015: If one is found, change the memory ref to a PRE_INC
1016: or PRE_DEC, cancel this insn, and return 1.
1017: Return 0 if nothing has been done. */
1018: && try_pre_increment_1 (insn))
1019: goto flushed;
1020: }
1021: #endif /* AUTO_INC_DEC */
1.1 root 1022:
1.1.1.2 root 1023: /* If this is not the final pass, and this insn is copying the
1024: value of a library call and it's dead, don't scan the
1025: insns that perform the library call, so that the call's
1026: arguments are not marked live. */
1027: if (note && insn_dead_p (PATTERN (insn), old, 1))
1.1.1.3 root 1028: {
1.1.1.4 root 1029: /* Mark the dest reg as `significant'. */
1030: mark_set_regs (old, dead, PATTERN (insn), 0, significant);
1031:
1.1.1.3 root 1032: insn = XEXP (note, 0);
1033: prev = PREV_INSN (insn);
1034: }
1.1.1.4 root 1035: else if (SET_DEST (PATTERN (insn)) == stack_pointer_rtx
1036: && GET_CODE (SET_SRC (PATTERN (insn))) == PLUS
1037: && XEXP (SET_SRC (PATTERN (insn)), 0) == stack_pointer_rtx
1038: && GET_CODE (XEXP (SET_SRC (PATTERN (insn)), 1)) == CONST_INT)
1039: /* These insns, if not dead stores, have no effect on life. */
1040: ;
1.1.1.2 root 1041: else
1042: {
1043: /* LIVE gets the regs used in INSN; DEAD gets those set by it. */
1.1 root 1044: mark_set_regs (old, dead, PATTERN (insn), final ? insn : 0,
1045: significant);
1.1.1.2 root 1046: mark_used_regs (old, live, PATTERN (insn), final, insn);
1.1 root 1047:
1048: /* Update OLD for the registers used or set. */
1049: for (i = 0; i < regset_size; i++)
1050: {
1051: old[i] &= ~dead[i];
1052: old[i] |= live[i];
1053: }
1054:
1.1.1.2 root 1055: if (GET_CODE (insn) == CALL_INSN)
1056: {
1057: register int i;
1058:
1059: /* Each call clobbers all call-clobbered regs.
1060: Note that the function-value reg is one of these, and
1061: mark_set_regs has already had a chance to handle it. */
1062: for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
1063: if (call_used_regs[i])
1064: old[i / REGSET_ELT_BITS]
1065: &= ~(1 << (i % REGSET_ELT_BITS));
1066:
1067: /* The stack ptr is used (honorarily) by a CALL insn. */
1068: old[STACK_POINTER_REGNUM / REGSET_ELT_BITS]
1069: |= (1 << (STACK_POINTER_REGNUM % REGSET_ELT_BITS));
1070:
1071: if (final)
1072: {
1073: /* Any regs live at the time of a call instruction
1074: must not go in a register clobbered by calls.
1075: Find all regs now live and record this for them. */
1076:
1077: register struct foo *p = regs_sometimes_live;
1078:
1079: for (i = 0; i < sometimes_max; i++, p++)
1080: {
1081: if (old[p->offset]
1082: & (1 << p->bit))
1083: reg_crosses_call[p->offset * REGSET_ELT_BITS + p->bit] = 1;
1084: }
1085: }
1086: }
1087: }
1088:
1089: /* On final pass, add any additional sometimes-live regs
1090: into MAXLIVE and REGS_SOMETIMES_LIVE.
1091: Also update counts of how many insns each reg is live at. */
1.1 root 1092:
1.1.1.2 root 1093: if (final)
1094: {
1095: for (i = 0; i < regset_size; i++)
1.1 root 1096: {
1.1.1.2 root 1097: register int diff = live[i] & ~maxlive[i];
1.1 root 1098:
1.1.1.2 root 1099: if (diff)
1100: {
1101: register int regno;
1102: maxlive[i] |= diff;
1103: for (regno = 0; diff && regno < REGSET_ELT_BITS; regno++)
1104: if (diff & (1 << regno))
1105: {
1106: regs_sometimes_live[sometimes_max].offset = i;
1107: regs_sometimes_live[sometimes_max].bit = regno;
1108: diff &= ~ (1 << regno);
1109: sometimes_max++;
1110: }
1111: }
1112: }
1.1 root 1113:
1.1.1.2 root 1114: {
1115: register struct foo *p = regs_sometimes_live;
1116: for (i = 0; i < sometimes_max; i++, p++)
1.1 root 1117: {
1.1.1.2 root 1118: if (old[p->offset] & (1 << p->bit))
1119: reg_live_length[p->offset * REGSET_ELT_BITS + p->bit]++;
1.1 root 1120: }
1.1.1.2 root 1121: }
1.1 root 1122: }
1123: }
1.1.1.2 root 1124: flushed: ;
1.1 root 1125: if (insn == first)
1126: break;
1127: }
1128: }
1129:
1130: /* Return 1 if X (the body of an insn, or part of it) is just dead stores
1131: (SET expressions whose destinations are registers dead after the insn).
1132: NEEDED is the regset that says which regs are alive after the insn. */
1133:
1134: static int
1.1.1.2 root 1135: insn_dead_p (x, needed, strict_low_ok)
1.1 root 1136: rtx x;
1137: regset needed;
1.1.1.2 root 1138: int strict_low_ok;
1.1 root 1139: {
1140: register RTX_CODE code = GET_CODE (x);
1.1.1.2 root 1141: #if 0
1.1 root 1142: /* Make sure insns to set the stack pointer are never deleted. */
1143: needed[STACK_POINTER_REGNUM / REGSET_ELT_BITS]
1144: |= 1 << (STACK_POINTER_REGNUM % REGSET_ELT_BITS);
1.1.1.2 root 1145: #endif
1146:
1147: /* If setting something that's a reg or part of one,
1148: see if that register's altered value will be live. */
1149:
1150: if (code == SET)
1.1 root 1151: {
1.1.1.2 root 1152: register rtx r = SET_DEST (x);
1153: /* A SET that is a subroutine call cannot be dead. */
1154: if (GET_CODE (SET_SRC (x)) == CALL)
1155: return 0;
1156: while (GET_CODE (r) == SUBREG
1157: || (strict_low_ok && GET_CODE (r) == STRICT_LOW_PART)
1158: || GET_CODE (r) == ZERO_EXTRACT
1159: || GET_CODE (r) == SIGN_EXTRACT)
1160: r = SUBREG_REG (r);
1161: if (GET_CODE (r) == REG)
1162: {
1163: register int regno = REGNO (r);
1164: register int offset = regno / REGSET_ELT_BITS;
1165: register int bit = 1 << (regno % REGSET_ELT_BITS);
1166: return (needed[offset] & bit) == 0;
1167: }
1.1 root 1168: }
1.1.1.2 root 1169: /* If performing several activities,
1170: insn is dead if each activity is individually dead.
1171: Also, CLOBBERs and USEs can be ignored; a CLOBBER or USE
1172: that's inside a PARALLEL doesn't make the insn worth keeping. */
1173: else if (code == PARALLEL)
1.1 root 1174: {
1175: register int i = XVECLEN (x, 0);
1176: for (i--; i >= 0; i--)
1.1.1.2 root 1177: {
1178: rtx elt = XVECEXP (x, 0, i);
1179: if (!insn_dead_p (elt, needed, strict_low_ok)
1180: && GET_CODE (elt) != CLOBBER
1181: && GET_CODE (elt) != USE)
1182: return 0;
1183: }
1.1 root 1184: return 1;
1185: }
1.1.1.2 root 1186: /* We do not check CLOBBER or USE here.
1187: An insn consisting of just a CLOBBER or just a USE
1188: should not be deleted. */
1.1 root 1189: return 0;
1190: }
1191:
1.1.1.2 root 1192: /* Return 1 if register REGNO was used before it was set.
1193: In other words, if it is live at function entry. */
1.1 root 1194:
1.1.1.2 root 1195: int
1196: regno_uninitialized (regno)
1.1 root 1197: int regno;
1198: {
1.1.1.2 root 1199: return (basic_block_live_at_start[0][regno / REGSET_ELT_BITS]
1200: & (1 << (regno % REGSET_ELT_BITS)));
1201: }
1202:
1203: /* 1 if register REGNO was alive at a place where `setjmp' was called
1204: and was set more than once. Such regs may be clobbered by `longjmp'. */
1205:
1206: int
1207: regno_clobbered_at_setjmp (regno)
1208: int regno;
1209: {
1210: return (reg_n_sets[regno] > 1
1211: && (regs_live_at_setjmp[regno / REGSET_ELT_BITS]
1212: & (1 << (regno % REGSET_ELT_BITS))));
1.1 root 1213: }
1214:
1215: /* Process the registers that are set within X.
1216: Their bits are set to 1 in the regset DEAD,
1217: because they are dead prior to this insn.
1218:
1219: If INSN is nonzero, it is the insn being processed
1220: and the fact that it is nonzero implies this is the FINAL pass
1221: in propagate_block. In this case, various info about register
1222: usage is stored, LOG_LINKS fields of insns are set up. */
1223:
1224: static void mark_set_1 ();
1225:
1226: static void
1227: mark_set_regs (needed, dead, x, insn, significant)
1228: regset needed;
1229: regset dead;
1230: rtx x;
1231: rtx insn;
1232: regset significant;
1233: {
1234: register RTX_CODE code = GET_CODE (x);
1235:
1236: if (code == SET || code == CLOBBER)
1237: mark_set_1 (needed, dead, x, insn, significant);
1238: else if (code == PARALLEL)
1239: {
1240: register int i;
1241: for (i = XVECLEN (x, 0) - 1; i >= 0; i--)
1242: {
1243: code = GET_CODE (XVECEXP (x, 0, i));
1244: if (code == SET || code == CLOBBER)
1245: mark_set_1 (needed, dead, XVECEXP (x, 0, i), insn, significant);
1246: }
1247: }
1248: }
1249:
1250: /* Process a single SET rtx, X. */
1251:
1252: static void
1253: mark_set_1 (needed, dead, x, insn, significant)
1254: regset needed;
1255: regset dead;
1256: rtx x;
1257: rtx insn;
1258: regset significant;
1259: {
1260: register int regno;
1261: register rtx reg = SET_DEST (x);
1262:
1.1.1.2 root 1263: if (reg == 0)
1264: return;
1265:
1.1 root 1266: if (GET_CODE (reg) == SUBREG)
1267: {
1268: /* Modifying just one hardware register
1269: of a multi-register value does not count as "setting"
1270: for live-dead analysis. Parts of the previous value
1271: might still be significant below this insn. */
1272: if (REG_SIZE (SUBREG_REG (reg)) > REG_SIZE (reg))
1273: return;
1274:
1275: reg = SUBREG_REG (reg);
1276: }
1277:
1278: if (GET_CODE (reg) == REG
1279: && (regno = REGNO (reg), regno != FRAME_POINTER_REGNUM)
1.1.1.2 root 1280: && regno != ARG_POINTER_REGNUM)
1281: /* && regno != STACK_POINTER_REGNUM) -- let's try without this. */
1.1 root 1282: {
1283: register int offset = regno / REGSET_ELT_BITS;
1284: register int bit = 1 << (regno % REGSET_ELT_BITS);
1.1.1.2 root 1285: int is_needed = 0;
1286:
1.1 root 1287: /* Mark the reg being set as dead before this insn. */
1288: dead[offset] |= bit;
1289: /* Mark it as a significant register for this basic block. */
1290: if (significant)
1291: significant[offset] |= bit;
1.1.1.2 root 1292: /* A hard reg in a wide mode may really be multiple registers.
1293: If so, mark all of them just like the first. */
1294: if (regno < FIRST_PSEUDO_REGISTER)
1295: {
1.1.1.4 root 1296: int n;
1297:
1298: /* Nothing below is needed for the stack pointer; get out asap.
1299: Eg, log links aren't needed, since combine won't use them. */
1300: if (regno == STACK_POINTER_REGNUM)
1301: return;
1302:
1303: n = HARD_REGNO_NREGS (regno, GET_MODE (reg));
1.1.1.2 root 1304: while (--n > 0)
1305: {
1306: dead[(regno + n) / REGSET_ELT_BITS]
1307: |= 1 << ((regno + n) % REGSET_ELT_BITS);
1308: if (significant)
1309: significant[(regno + n) / REGSET_ELT_BITS]
1310: |= 1 << ((regno + n) % REGSET_ELT_BITS);
1311: is_needed |= (needed[(regno + n) / REGSET_ELT_BITS]
1312: & 1 << ((regno + n) % REGSET_ELT_BITS));
1313: }
1314: }
1.1 root 1315: /* Additional data to record if this is the final pass. */
1316: if (insn)
1317: {
1318: register rtx y = reg_next_use[regno];
1319: register int blocknum = BLOCK_NUM (insn);
1320:
1321: /* If this is a hard reg, record this function uses the reg. */
1322:
1323: if (regno < FIRST_PSEUDO_REGISTER)
1324: {
1325: register int i;
1326: i = HARD_REGNO_NREGS (regno, GET_MODE (reg));
1327: do
1328: regs_ever_live[regno + --i] = 1;
1329: while (i > 0);
1.1.1.4 root 1330:
1331: if (! ((needed[offset] & bit) || is_needed))
1332: {
1333: /* Note that dead stores have already been deleted if poss.
1334: If we get here, we have found a dead store that cannot
1335: be eliminated (because the insn does something useful).
1336: Indicate this by marking the reg set as dying here. */
1337: REG_NOTES (insn)
1338: = gen_rtx (EXPR_LIST, REG_DEAD,
1339: reg, REG_NOTES (insn));
1340: reg_n_deaths[REGNO (reg)]++;
1341: }
1342: return;
1.1 root 1343: }
1344:
1345: /* Keep track of which basic blocks each reg appears in. */
1346:
1.1.1.4 root 1347: if (reg_basic_block[regno] == REG_BLOCK_UNKNOWN)
1.1 root 1348: reg_basic_block[regno] = blocknum;
1349: else if (reg_basic_block[regno] != blocknum)
1.1.1.4 root 1350: reg_basic_block[regno] = REG_BLOCK_GLOBAL;
1.1 root 1351:
1352: /* Count (weighted) references, stores, etc. */
1353: reg_n_refs[regno] += loop_depth;
1354: reg_n_sets[regno]++;
1.1.1.2 root 1355: /* The next use is no longer "next", since a store intervenes. */
1356: reg_next_use[regno] = 0;
1.1 root 1357: /* The insns where a reg is live are normally counted elsewhere,
1358: but we want the count to include the insn where the reg is set,
1359: and the normal counting mechanism would not count it. */
1360: reg_live_length[regno]++;
1.1.1.2 root 1361: if ((needed[offset] & bit) || is_needed)
1.1 root 1362: {
1363: /* Make a logical link from the next following insn
1364: that uses this register, back to this insn.
1365: The following insns have already been processed. */
1366: if (y && (BLOCK_NUM (y) == blocknum))
1367: LOG_LINKS (y)
1368: = gen_rtx (INSN_LIST, VOIDmode, insn, LOG_LINKS (y));
1369: }
1370: else
1371: {
1372: /* Note that dead stores have already been deleted when possible
1373: If we get here, we have found a dead store that cannot
1374: be eliminated (because the same insn does something useful).
1375: Indicate this by marking the reg being set as dying here. */
1376: REG_NOTES (insn)
1377: = gen_rtx (EXPR_LIST, REG_DEAD,
1378: reg, REG_NOTES (insn));
1.1.1.3 root 1379: reg_n_deaths[REGNO (reg)]++;
1.1 root 1380: }
1381: }
1382: }
1383: }
1384:
1385: /* Scan expression X and store a 1-bit in LIVE for each reg it uses.
1386: This is done assuming the registers needed from X
1387: are those that have 1-bits in NEEDED.
1388:
1.1.1.2 root 1389: On the final pass, FINAL is 1. This means try for autoincrement
1390: and count the uses and deaths of each pseudo-reg.
1391:
1392: INSN is the containing instruction. */
1.1 root 1393:
1394: static void
1.1.1.2 root 1395: mark_used_regs (needed, live, x, final, insn)
1.1 root 1396: regset needed;
1397: regset live;
1398: rtx x;
1399: rtx insn;
1.1.1.2 root 1400: int final;
1.1 root 1401: {
1402: register RTX_CODE code;
1403: register int regno;
1404:
1405: retry:
1406: code = GET_CODE (x);
1407: switch (code)
1408: {
1409: case LABEL_REF:
1410: case SYMBOL_REF:
1411: case CONST_INT:
1412: case CONST:
1.1.1.4 root 1413: case CONST_DOUBLE:
1.1 root 1414: case CC0:
1415: case PC:
1416: case CLOBBER:
1.1.1.4 root 1417: case ADDR_VEC:
1418: case ADDR_DIFF_VEC:
1419: case ASM_INPUT:
1.1 root 1420: return;
1421:
1422: #if defined (HAVE_POST_INCREMENT) || defined (HAVE_POST_DECREMENT)
1423: case MEM:
1424: /* Here we detect use of an index register which might
1425: be good for postincrement or postdecrement. */
1.1.1.2 root 1426: if (final)
1.1 root 1427: {
1428: rtx addr = XEXP (x, 0);
1429: register int size = GET_MODE_SIZE (GET_MODE (x));
1430:
1431: if (GET_CODE (addr) == REG)
1432: {
1433: register rtx y;
1434: regno = REGNO (addr);
1435: /* Is the next use an increment that might make auto-increment? */
1436: y = reg_next_use[regno];
1437: if (y && GET_CODE (PATTERN (y)) == SET
1438: && BLOCK_NUM (y) == BLOCK_NUM (insn)
1439: /* Can't add side effects to jumps; if reg is spilled and
1440: reloaded, there's no way to store back the altered value. */
1441: && GET_CODE (insn) != JUMP_INSN
1442: && (y = SET_SRC (PATTERN (y)),
1443: (0
1444: #ifdef HAVE_POST_INCREMENT
1445: || GET_CODE (y) == PLUS
1446: #endif
1447: #ifdef HAVE_POST_DECREMENT
1448: || GET_CODE (y) == MINUS
1449: #endif
1450: )
1451: && XEXP (y, 0) == addr
1452: && GET_CODE (XEXP (y, 1)) == CONST_INT
1.1.1.2 root 1453: && INTVAL (XEXP (y, 1)) == size)
1454: && dead_or_set_p (reg_next_use[regno], addr))
1.1 root 1455: {
1.1.1.2 root 1456: rtx use = find_use_as_address (PATTERN (insn), addr, 0);
1.1 root 1457:
1458: /* Make sure this register appears only once in this insn. */
1459: if (use != 0 && use != (rtx) 1)
1460: {
1461: /* We have found a suitable auto-increment:
1462: do POST_INC around the register here,
1463: and patch out the increment instruction that follows. */
1464: XEXP (x, 0)
1465: = gen_rtx (GET_CODE (y) == PLUS ? POST_INC : POST_DEC,
1466: Pmode, addr);
1467: /* Record that this insn has an implicit side effect. */
1468: REG_NOTES (insn)
1469: = gen_rtx (EXPR_LIST, REG_INC, addr, REG_NOTES (insn));
1470:
1.1.1.2 root 1471: /* Modify the old increment-insn to simply copy
1472: the already-incremented value of our register. */
1.1 root 1473: y = reg_next_use[regno];
1.1.1.2 root 1474: SET_SRC (PATTERN (y)) = addr;
1475:
1476: /* If that makes it a no-op (copying the register
1477: into itself) then change it to a simpler no-op
1478: so it won't appear to be a "use" and a "set"
1479: of this register. */
1480: if (SET_DEST (PATTERN (y)) == addr)
1481: PATTERN (y) = gen_rtx (USE, VOIDmode, const0_rtx);
1482:
1483: /* Count an extra reference to the reg for the increment.
1484: When a reg is incremented.
1.1 root 1485: spilling it is worse, so we want to make that
1486: less likely. */
1487: reg_n_refs[regno] += loop_depth;
1.1.1.2 root 1488: /* Count the increment as a setting of the register,
1489: even though it isn't a SET in rtl. */
1490: reg_n_sets[regno]++;
1.1 root 1491: }
1492: }
1493: }
1494: }
1495: break;
1496: #endif /* HAVE_POST_INCREMENT or HAVE_POST_DECREMENT */
1497:
1498: case REG:
1499: /* See a register other than being set
1500: => mark it as needed. */
1501:
1502: regno = REGNO (x);
1503: if (regno != FRAME_POINTER_REGNUM
1.1.1.2 root 1504: && regno != ARG_POINTER_REGNUM)
1505: /* && regno != STACK_POINTER_REGNUM) -- let's try without this. */
1.1 root 1506: {
1507: register int offset = regno / REGSET_ELT_BITS;
1508: register int bit = 1 << (regno % REGSET_ELT_BITS);
1.1.1.2 root 1509: int is_needed = 0;
1510:
1.1 root 1511: live[offset] |= bit;
1.1.1.2 root 1512: /* A hard reg in a wide mode may really be multiple registers.
1513: If so, mark all of them just like the first. */
1514: if (regno < FIRST_PSEUDO_REGISTER)
1515: {
1.1.1.4 root 1516: int n;
1517:
1518: /* For stack ptr, nothing below here can be necessary,
1519: so waste no more time. */
1520: if (regno == STACK_POINTER_REGNUM)
1521: return;
1522:
1523: n = HARD_REGNO_NREGS (regno, GET_MODE (x));
1.1.1.2 root 1524: while (--n > 0)
1525: {
1526: live[(regno + n) / REGSET_ELT_BITS]
1527: |= 1 << ((regno + n) % REGSET_ELT_BITS);
1528: is_needed |= (needed[(regno + n) / REGSET_ELT_BITS]
1529: & 1 << ((regno + n) % REGSET_ELT_BITS));
1530: }
1531: }
1532: if (final)
1.1 root 1533: {
1534: if (regno < FIRST_PSEUDO_REGISTER)
1535: {
1.1.1.4 root 1536: /* If a hard reg is being used,
1537: record that this function does use it. */
1538:
1.1 root 1539: register int i;
1540: i = HARD_REGNO_NREGS (regno, GET_MODE (x));
1541: do
1542: regs_ever_live[regno + --i] = 1;
1543: while (i > 0);
1544: }
1.1.1.4 root 1545: else
1546: {
1547: /* Keep track of which basic block each reg appears in. */
1.1 root 1548:
1.1.1.4 root 1549: register int blocknum = BLOCK_NUM (insn);
1.1 root 1550:
1.1.1.4 root 1551: if (reg_basic_block[regno] == REG_BLOCK_UNKNOWN)
1552: reg_basic_block[regno] = blocknum;
1553: else if (reg_basic_block[regno] != blocknum)
1554: reg_basic_block[regno] = REG_BLOCK_GLOBAL;
1.1 root 1555:
1.1.1.4 root 1556: /* Record where each reg is used, so when the reg
1557: is set we know the next insn that uses it. */
1.1 root 1558:
1.1.1.4 root 1559: reg_next_use[regno] = insn;
1.1 root 1560:
1.1.1.4 root 1561: /* Count (weighted) number of uses of each reg. */
1.1 root 1562:
1.1.1.4 root 1563: reg_n_refs[regno] += loop_depth;
1564: }
1.1 root 1565: /* Record and count the insns in which a reg dies.
1566: If it is used in this insn and was dead below the insn
1567: then it dies in this insn. */
1568:
1.1.1.2 root 1569: if (!(needed[offset] & bit) && !is_needed
1570: && ! find_regno_note (insn, REG_DEAD, regno))
1.1 root 1571: {
1572: REG_NOTES (insn)
1573: = gen_rtx (EXPR_LIST, REG_DEAD, x, REG_NOTES (insn));
1574: reg_n_deaths[regno]++;
1575: }
1576: }
1577: }
1578: return;
1579:
1580: case SET:
1581: {
1.1.1.2 root 1582: register rtx testreg = SET_DEST (x);
1583: int mark_dest = 0;
1.1 root 1584:
1.1.1.2 root 1585: /* Storing in STRICT_LOW_PART is like storing in a reg
1586: in that this SET might be dead, so ignore it in TESTREG.
1587: but in some other ways it is like using the reg. */
1588: /* Storing in a SUBREG or a bit field is like storing the entire
1589: register in that if the register's value is not used
1590: then this SET is not needed. */
1591: while (GET_CODE (testreg) == STRICT_LOW_PART
1592: || GET_CODE (testreg) == ZERO_EXTRACT
1593: || GET_CODE (testreg) == SIGN_EXTRACT
1594: || GET_CODE (testreg) == SUBREG)
1595: {
1596: /* Modifying a single register in an alternate mode
1597: does not use any of the old value. But these other
1598: ways of storing in a register do use the old value. */
1599: if (GET_CODE (testreg) == SUBREG
1600: && !(REG_SIZE (SUBREG_REG (testreg)) > REG_SIZE (testreg)))
1601: ;
1602: else
1603: mark_dest = 1;
1604:
1605: testreg = XEXP (testreg, 0);
1606: }
1.1 root 1607:
1608: /* If this is a store into a register,
1609: recursively scan the only value being stored,
1610: and only if the register's value is live after this insn.
1611: If the value being computed here would never be used
1612: then the values it uses don't need to be computed either. */
1613:
1.1.1.2 root 1614: if (GET_CODE (testreg) == REG
1615: && (regno = REGNO (testreg), regno != FRAME_POINTER_REGNUM)
1.1.1.7 ! root 1616: && regno != ARG_POINTER_REGNUM)
! 1617: #if 0 /* This was added in 1.25, but screws up death notes for hard regs.
! 1618: It probably isn't really needed anyway. */
1.1.1.6 root 1619: && (regno >= FIRST_PSEUDO_REGISTER
1620: || INSN_VOLATILE (insn)))
1.1.1.7 ! root 1621: #endif
1.1 root 1622: {
1623: register int offset = regno / REGSET_ELT_BITS;
1624: register int bit = 1 << (regno % REGSET_ELT_BITS);
1.1.1.2 root 1625: if ((needed[offset] & bit)
1626: /* If insn refers to volatile, we mustn't delete it,
1627: so its inputs are all needed. */
1628: || INSN_VOLATILE (insn))
1629: {
1630: mark_used_regs (needed, live, SET_SRC (x), final, insn);
1631: if (mark_dest)
1632: mark_used_regs (needed, live, SET_DEST (x), final, insn);
1633: }
1.1 root 1634: return;
1635: }
1636: }
1637: break;
1638: }
1639:
1640: /* Recursively scan the operands of this expression. */
1641:
1642: {
1643: register char *fmt = GET_RTX_FORMAT (code);
1644: register int i;
1645:
1646: for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
1647: {
1648: if (fmt[i] == 'e')
1649: {
1650: /* Tail recursive case: save a function call level. */
1651: if (i == 0)
1652: {
1653: x = XEXP (x, 0);
1654: goto retry;
1655: }
1.1.1.2 root 1656: mark_used_regs (needed, live, XEXP (x, i), final, insn);
1.1 root 1657: }
1.1.1.4 root 1658: else if (fmt[i] == 'E')
1.1 root 1659: {
1660: register int j;
1661: for (j = 0; j < XVECLEN (x, i); j++)
1.1.1.2 root 1662: mark_used_regs (needed, live, XVECEXP (x, i, j), final, insn);
1.1 root 1663: }
1664: }
1665: }
1666: }
1667:
1.1.1.2 root 1668: #ifdef AUTO_INC_DEC
1.1 root 1669:
1670: static int
1671: try_pre_increment_1 (insn)
1672: rtx insn;
1673: {
1674: /* Find the next use of this reg. If in same basic block,
1675: make it do pre-increment or pre-decrement if appropriate. */
1676: rtx x = PATTERN (insn);
1677: int amount = ((GET_CODE (SET_SRC (x)) == PLUS ? 1 : -1)
1678: * INTVAL (XEXP (SET_SRC (x), 1)));
1679: int regno = REGNO (SET_DEST (x));
1680: rtx y = reg_next_use[regno];
1681: if (y != 0
1682: && BLOCK_NUM (y) == BLOCK_NUM (insn)
1683: && try_pre_increment (y, SET_DEST (PATTERN (insn)),
1684: amount))
1685: {
1686: /* We have found a suitable auto-increment
1687: and already changed insn Y to do it.
1688: So flush this increment-instruction. */
1689: PUT_CODE (insn, NOTE);
1690: NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
1691: NOTE_SOURCE_FILE (insn) = 0;
1692: /* Count a reference to this reg for the increment
1693: insn we are deleting. When a reg is incremented.
1694: spilling it is worse, so we want to make that
1695: less likely. */
1696: reg_n_refs[regno] += loop_depth;
1.1.1.2 root 1697: reg_n_sets[regno]++;
1.1 root 1698: return 1;
1699: }
1700: return 0;
1701: }
1702:
1703: /* Try to change INSN so that it does pre-increment or pre-decrement
1704: addressing on register REG in order to add AMOUNT to REG.
1705: AMOUNT is negative for pre-decrement.
1706: Returns 1 if the change could be made.
1707: This checks all about the validity of the result of modifying INSN. */
1708:
1709: static int
1710: try_pre_increment (insn, reg, amount)
1711: rtx insn, reg;
1712: int amount;
1713: {
1714: register rtx use;
1715:
1.1.1.2 root 1716: /* Nonzero if we can try to make a pre-increment or pre-decrement.
1717: For example, addl $4,r1; movl (r1),... can become movl +(r1),... */
1718: int pre_ok = 0;
1719: /* Nonzero if we can try to make a post-increment or post-decrement.
1720: For example, addl $4,r1; movl -4(r1),... can become movl (r1)+,...
1721: It is possible for both PRE_OK and POST_OK to be nonzero if the machine
1722: supports both pre-inc and post-inc, or both pre-dec and post-dec. */
1723: int post_ok = 0;
1724:
1725: /* Nonzero if the opportunity actually requires post-inc or post-dec. */
1726: int do_post = 0;
1727:
1728: /* From the sign of increment, see which possibilities are conceivable
1729: on this target machine. */
1730: #ifdef HAVE_PRE_INCREMENT
1.1 root 1731: if (amount > 0)
1.1.1.2 root 1732: pre_ok = 1;
1.1 root 1733: #endif
1.1.1.2 root 1734: #ifdef HAVE_POST_INCREMENT
1735: if (amount > 0)
1736: post_ok = 1;
1.1 root 1737: #endif
1738:
1.1.1.2 root 1739: #ifdef HAVE_PRE_DECREMENT
1.1 root 1740: if (amount < 0)
1.1.1.2 root 1741: pre_ok = 1;
1742: #endif
1743: #ifdef HAVE_POST_DECREMENT
1744: if (amount < 0)
1745: post_ok = 1;
1.1 root 1746: #endif
1747:
1.1.1.2 root 1748: if (! (pre_ok || post_ok))
1749: return 0;
1750:
1.1 root 1751: /* It is not safe to add a side effect to a jump insn
1752: because if the incremented register is spilled and must be reloaded
1753: there would be no way to store the incremented value back in memory. */
1754:
1755: if (GET_CODE (insn) == JUMP_INSN)
1756: return 0;
1757:
1.1.1.2 root 1758: use = 0;
1759: if (pre_ok)
1760: use = find_use_as_address (PATTERN (insn), reg, 0);
1761: if (post_ok && (use == 0 || use == (rtx) 1))
1762: {
1763: use = find_use_as_address (PATTERN (insn), reg, -amount);
1764: do_post = 1;
1765: }
1.1 root 1766:
1767: if (use == 0 || use == (rtx) 1)
1768: return 0;
1769:
1770: if (GET_MODE_SIZE (GET_MODE (use)) != (amount > 0 ? amount : - amount))
1771: return 0;
1772:
1.1.1.2 root 1773: XEXP (use, 0) = gen_rtx (amount > 0
1774: ? (do_post ? POST_INC : PRE_INC)
1775: : (do_post ? POST_DEC : PRE_DEC),
1.1 root 1776: Pmode, reg);
1777:
1778: /* Record that this insn now has an implicit side effect on X. */
1779: REG_NOTES (insn) = gen_rtx (EXPR_LIST, REG_INC, reg, REG_NOTES (insn));
1780: return 1;
1781: }
1782:
1.1.1.2 root 1783: #endif /* AUTO_INC_DEC */
1784:
1.1 root 1785: /* Find the place in the rtx X where REG is used as a memory address.
1786: Return the MEM rtx that so uses it.
1.1.1.2 root 1787: If PLUSCONST is nonzero, search instead for a memory address equivalent to
1788: (plus REG (const_int PLUSCONST)).
1789:
1790: If such an address does not appear, return 0.
1791: If REG appears more than once, or is used other than in such an address,
1.1 root 1792: return (rtx)1. */
1793:
1794: static rtx
1.1.1.2 root 1795: find_use_as_address (x, reg, plusconst)
1.1 root 1796: register rtx x;
1797: rtx reg;
1.1.1.2 root 1798: int plusconst;
1.1 root 1799: {
1800: enum rtx_code code = GET_CODE (x);
1801: char *fmt = GET_RTX_FORMAT (code);
1802: register int i;
1803: register rtx value = 0;
1804: register rtx tem;
1805:
1.1.1.2 root 1806: if (code == MEM && XEXP (x, 0) == reg && plusconst == 0)
1.1 root 1807: return x;
1808:
1.1.1.2 root 1809: if (code == MEM && GET_CODE (XEXP (x, 0)) == PLUS
1810: && XEXP (XEXP (x, 0), 0) == reg
1811: && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT
1812: && INTVAL (XEXP (XEXP (x, 0), 1)) == plusconst)
1813: return x;
1814:
1815: if (code == SIGN_EXTRACT || code == ZERO_EXTRACT)
1816: {
1817: /* If REG occurs inside a MEM used in a bit-field reference,
1818: that is unacceptable. */
1819: if (find_use_as_address (XEXP (x, 0), reg, 0) != 0)
1820: return (rtx) 1;
1821: }
1822:
1.1 root 1823: if (x == reg)
1824: return (rtx) 1;
1825:
1826: for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
1827: {
1828: if (fmt[i] == 'e')
1829: {
1.1.1.2 root 1830: tem = find_use_as_address (XEXP (x, i), reg, plusconst);
1.1 root 1831: if (value == 0)
1832: value = tem;
1833: else if (tem != 0)
1834: return (rtx) 1;
1835: }
1836: if (fmt[i] == 'E')
1837: {
1838: register int j;
1839: for (j = XVECLEN (x, i) - 1; j >= 0; j--)
1840: {
1.1.1.2 root 1841: tem = find_use_as_address (XVECEXP (x, i, j), reg, plusconst);
1.1 root 1842: if (value == 0)
1843: value = tem;
1844: else if (tem != 0)
1845: return (rtx) 1;
1846: }
1847: }
1848: }
1849:
1850: return value;
1851: }
1852:
1853: /* Write information about registers and basic blocks into FILE.
1854: This is part of making a debugging dump. */
1855:
1.1.1.2 root 1856: void
1.1 root 1857: dump_flow_info (file)
1858: FILE *file;
1859: {
1860: register int i;
1861: static char *reg_class_names[] = REG_CLASS_NAMES;
1862:
1863: fprintf (file, "%d registers.\n", max_regno);
1864:
1865: for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
1866: if (reg_n_refs[i])
1867: {
1868: enum reg_class class;
1869: fprintf (file, "\nRegister %d used %d times across %d insns",
1870: i, reg_n_refs[i], reg_live_length[i]);
1871: if (reg_basic_block[i] >= 0)
1872: fprintf (file, " in block %d", reg_basic_block[i]);
1873: if (reg_n_deaths[i] != 1)
1874: fprintf (file, "; dies in %d places", reg_n_deaths[i]);
1875: if (reg_crosses_call[i])
1876: fprintf (file, "; crosses calls");
1877: if (PSEUDO_REGNO_BYTES (i) != UNITS_PER_WORD)
1878: fprintf (file, "; %d bytes", PSEUDO_REGNO_BYTES (i));
1879: class = reg_preferred_class (i);
1880: if (class != GENERAL_REGS)
1.1.1.2 root 1881: {
1882: if (reg_preferred_or_nothing (i))
1883: fprintf (file, "; %s or none", reg_class_names[(int) class]);
1884: else
1885: fprintf (file, "; pref %s", reg_class_names[(int) class]);
1886: }
1.1 root 1887: if (REGNO_POINTER_FLAG (i))
1888: fprintf (file, "; pointer");
1889: fprintf (file, ".\n");
1890: }
1891: fprintf (file, "\n%d basic blocks.\n", n_basic_blocks);
1892: for (i = 0; i < n_basic_blocks; i++)
1893: {
1894: register rtx head, jump;
1895: register int regno;
1896: fprintf (file, "\nBasic block %d: first insn %d, last %d.\n",
1897: i,
1898: INSN_UID (basic_block_head[i]),
1899: INSN_UID (basic_block_end[i]));
1900: /* The control flow graph's storage is freed
1901: now when flow_analysis returns.
1902: Don't try to print it if it is gone. */
1903: if (basic_block_drops_in)
1904: {
1905: fprintf (file, "Reached from blocks: ");
1906: head = basic_block_head[i];
1907: if (GET_CODE (head) == CODE_LABEL)
1908: for (jump = LABEL_REFS (head);
1909: jump != head;
1910: jump = LABEL_NEXTREF (jump))
1911: {
1912: register from_block = BLOCK_NUM (CONTAINING_INSN (jump));
1913: fprintf (file, " %d", from_block);
1914: }
1915: if (basic_block_drops_in[i])
1916: fprintf (file, " previous");
1917: }
1918: fprintf (file, "\nRegisters live at start:");
1919: for (regno = 0; regno < max_regno; regno++)
1920: {
1921: register int offset = regno / REGSET_ELT_BITS;
1922: register int bit = 1 << (regno % REGSET_ELT_BITS);
1923: if (basic_block_live_at_start[i][offset] & bit)
1924: fprintf (file, " %d", regno);
1925: }
1926: fprintf (file, "\n");
1927: }
1928: fprintf (file, "\n");
1929: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.