]> gcc.gnu.org Git - gcc.git/blame - gcc/function.c
(movdi): End by returning the last template; otherwise
[gcc.git] / gcc / function.c
CommitLineData
6f086dfc 1/* Expands front end tree to back end RTL for GNU C-Compiler
1b2ac438 2 Copyright (C) 1987, 1988, 1989, 1991, 1992 Free Software Foundation, Inc.
6f086dfc
RS
3
4This file is part of GNU CC.
5
6GNU CC is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU CC is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU CC; see the file COPYING. If not, write to
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20
21/* This file handles the generation of rtl code from tree structure
22 at the level of the function as a whole.
23 It creates the rtl expressions for parameters and auto variables
24 and has full responsibility for allocating stack slots.
25
26 `expand_function_start' is called at the beginning of a function,
27 before the function body is parsed, and `expand_function_end' is
28 called after parsing the body.
29
30 Call `assign_stack_local' to allocate a stack slot for a local variable.
31 This is usually done during the RTL generation for the function body,
32 but it can also be done in the reload pass when a pseudo-register does
33 not get a hard register.
34
35 Call `put_var_into_stack' when you learn, belatedly, that a variable
36 previously given a pseudo-register must in fact go in the stack.
37 This function changes the DECL_RTL to be a stack slot instead of a reg
38 then scans all the RTL instructions so far generated to correct them. */
39
40#include "config.h"
41
42#include <stdio.h>
43
44#include "rtl.h"
45#include "tree.h"
46#include "flags.h"
47#include "function.h"
48#include "insn-flags.h"
49#include "expr.h"
50#include "insn-codes.h"
51#include "regs.h"
52#include "hard-reg-set.h"
53#include "insn-config.h"
54#include "recog.h"
55#include "output.h"
bdac5f58 56#include "basic-block.h"
6f086dfc
RS
57
58/* Round a value to the lowest integer less than it that is a multiple of
59 the required alignment. Avoid using division in case the value is
60 negative. Assume the alignment is a power of two. */
61#define FLOOR_ROUND(VALUE,ALIGN) ((VALUE) & ~((ALIGN) - 1))
62
63/* Similar, but round to the next highest integer that meets the
64 alignment. */
65#define CEIL_ROUND(VALUE,ALIGN) (((VALUE) + (ALIGN) - 1) & ~((ALIGN)- 1))
66
67/* NEED_SEPARATE_AP means that we cannot derive ap from the value of fp
68 during rtl generation. If they are different register numbers, this is
69 always true. It may also be true if
70 FIRST_PARM_OFFSET - STARTING_FRAME_OFFSET is not a constant during rtl
71 generation. See fix_lexical_addr for details. */
72
73#if ARG_POINTER_REGNUM != FRAME_POINTER_REGNUM
74#define NEED_SEPARATE_AP
75#endif
76
77/* Number of bytes of args popped by function being compiled on its return.
78 Zero if no bytes are to be popped.
79 May affect compilation of return insn or of function epilogue. */
80
81int current_function_pops_args;
82
83/* Nonzero if function being compiled needs to be given an address
84 where the value should be stored. */
85
86int current_function_returns_struct;
87
88/* Nonzero if function being compiled needs to
89 return the address of where it has put a structure value. */
90
91int current_function_returns_pcc_struct;
92
93/* Nonzero if function being compiled needs to be passed a static chain. */
94
95int current_function_needs_context;
96
97/* Nonzero if function being compiled can call setjmp. */
98
99int current_function_calls_setjmp;
100
101/* Nonzero if function being compiled can call longjmp. */
102
103int current_function_calls_longjmp;
104
105/* Nonzero if function being compiled receives nonlocal gotos
106 from nested functions. */
107
108int current_function_has_nonlocal_label;
109
110/* Nonzero if function being compiled contains nested functions. */
111
112int current_function_contains_functions;
113
114/* Nonzero if function being compiled can call alloca,
115 either as a subroutine or builtin. */
116
117int current_function_calls_alloca;
118
119/* Nonzero if the current function returns a pointer type */
120
121int current_function_returns_pointer;
122
123/* If some insns can be deferred to the delay slots of the epilogue, the
124 delay list for them is recorded here. */
125
126rtx current_function_epilogue_delay_list;
127
128/* If function's args have a fixed size, this is that size, in bytes.
129 Otherwise, it is -1.
130 May affect compilation of return insn or of function epilogue. */
131
132int current_function_args_size;
133
134/* # bytes the prologue should push and pretend that the caller pushed them.
135 The prologue must do this, but only if parms can be passed in registers. */
136
137int current_function_pretend_args_size;
138
139/* # of bytes of outgoing arguments required to be pushed by the prologue.
140 If this is non-zero, it means that ACCUMULATE_OUTGOING_ARGS was defined
141 and no stack adjusts will be done on function calls. */
142
143int current_function_outgoing_args_size;
144
145/* This is the offset from the arg pointer to the place where the first
146 anonymous arg can be found, if there is one. */
147
148rtx current_function_arg_offset_rtx;
149
150/* Nonzero if current function uses varargs.h or equivalent.
151 Zero for functions that use stdarg.h. */
152
153int current_function_varargs;
154
155/* Quantities of various kinds of registers
156 used for the current function's args. */
157
158CUMULATIVE_ARGS current_function_args_info;
159
160/* Name of function now being compiled. */
161
162char *current_function_name;
163
164/* If non-zero, an RTL expression for that location at which the current
165 function returns its result. Always equal to
166 DECL_RTL (DECL_RESULT (current_function_decl)), but provided
167 independently of the tree structures. */
168
169rtx current_function_return_rtx;
170
171/* Nonzero if the current function uses the constant pool. */
172
173int current_function_uses_const_pool;
174
175/* Nonzero if the current function uses pic_offset_table_rtx. */
176int current_function_uses_pic_offset_table;
177
178/* The arg pointer hard register, or the pseudo into which it was copied. */
179rtx current_function_internal_arg_pointer;
180
181/* The FUNCTION_DECL for an inline function currently being expanded. */
182tree inline_function_decl;
183
184/* Number of function calls seen so far in current function. */
185
186int function_call_count;
187
188/* List (chain of TREE_LIST) of LABEL_DECLs for all nonlocal labels
189 (labels to which there can be nonlocal gotos from nested functions)
190 in this function. */
191
192tree nonlocal_labels;
193
194/* RTX for stack slot that holds the current handler for nonlocal gotos.
195 Zero when function does not have nonlocal labels. */
196
197rtx nonlocal_goto_handler_slot;
198
199/* RTX for stack slot that holds the stack pointer value to restore
200 for a nonlocal goto.
201 Zero when function does not have nonlocal labels. */
202
203rtx nonlocal_goto_stack_level;
204
205/* Label that will go on parm cleanup code, if any.
206 Jumping to this label runs cleanup code for parameters, if
207 such code must be run. Following this code is the logical return label. */
208
209rtx cleanup_label;
210
211/* Label that will go on function epilogue.
212 Jumping to this label serves as a "return" instruction
213 on machines which require execution of the epilogue on all returns. */
214
215rtx return_label;
216
217/* List (chain of EXPR_LISTs) of pseudo-regs of SAVE_EXPRs.
218 So we can mark them all live at the end of the function, if nonopt. */
219rtx save_expr_regs;
220
221/* List (chain of EXPR_LISTs) of all stack slots in this function.
222 Made for the sake of unshare_all_rtl. */
223rtx stack_slot_list;
224
225/* Chain of all RTL_EXPRs that have insns in them. */
226tree rtl_expr_chain;
227
228/* Label to jump back to for tail recursion, or 0 if we have
229 not yet needed one for this function. */
230rtx tail_recursion_label;
231
232/* Place after which to insert the tail_recursion_label if we need one. */
233rtx tail_recursion_reentry;
234
235/* Location at which to save the argument pointer if it will need to be
236 referenced. There are two cases where this is done: if nonlocal gotos
237 exist, or if vars stored at an offset from the argument pointer will be
238 needed by inner routines. */
239
240rtx arg_pointer_save_area;
241
242/* Offset to end of allocated area of stack frame.
243 If stack grows down, this is the address of the last stack slot allocated.
244 If stack grows up, this is the address for the next slot. */
245int frame_offset;
246
247/* List (chain of TREE_LISTs) of static chains for containing functions.
248 Each link has a FUNCTION_DECL in the TREE_PURPOSE and a reg rtx
249 in an RTL_EXPR in the TREE_VALUE. */
250static tree context_display;
251
252/* List (chain of TREE_LISTs) of trampolines for nested functions.
253 The trampoline sets up the static chain and jumps to the function.
254 We supply the trampoline's address when the function's address is requested.
255
256 Each link has a FUNCTION_DECL in the TREE_PURPOSE and a reg rtx
257 in an RTL_EXPR in the TREE_VALUE. */
258static tree trampoline_list;
259
260/* Insn after which register parms and SAVE_EXPRs are born, if nonopt. */
261static rtx parm_birth_insn;
262
263#if 0
264/* Nonzero if a stack slot has been generated whose address is not
265 actually valid. It means that the generated rtl must all be scanned
266 to detect and correct the invalid addresses where they occur. */
267static int invalid_stack_slot;
268#endif
269
270/* Last insn of those whose job was to put parms into their nominal homes. */
271static rtx last_parm_insn;
272
273/* 1 + last pseudo register number used for loading a copy
274 of a parameter of this function. */
275static int max_parm_reg;
276
277/* Vector indexed by REGNO, containing location on stack in which
278 to put the parm which is nominally in pseudo register REGNO,
279 if we discover that that parm must go in the stack. */
280static rtx *parm_reg_stack_loc;
281
282#if 0 /* Turned off because 0 seems to work just as well. */
283/* Cleanup lists are required for binding levels regardless of whether
284 that binding level has cleanups or not. This node serves as the
285 cleanup list whenever an empty list is required. */
286static tree empty_cleanup_list;
287#endif
288
289/* Nonzero once virtual register instantiation has been done.
290 assign_stack_local uses frame_pointer_rtx when this is nonzero. */
291static int virtuals_instantiated;
292
293/* Nonzero if we need to distinguish between the return value of this function
294 and the return value of a function called by this function. This helps
295 integrate.c */
296
297extern int rtx_equal_function_value_matters;
298
299void fixup_gotos ();
300
301static tree round_down ();
302static rtx round_trampoline_addr ();
303static rtx fixup_stack_1 ();
304static void fixup_var_refs ();
305static void fixup_var_refs_insns ();
306static void fixup_var_refs_1 ();
307static void optimize_bit_field ();
308static void instantiate_decls ();
309static void instantiate_decls_1 ();
5a73491b 310static void instantiate_decl ();
6f086dfc
RS
311static int instantiate_virtual_regs_1 ();
312static rtx fixup_memory_subreg ();
313static rtx walk_fixup_memory_subreg ();
314\f
315/* In order to evaluate some expressions, such as function calls returning
316 structures in memory, we need to temporarily allocate stack locations.
317 We record each allocated temporary in the following structure.
318
319 Associated with each temporary slot is a nesting level. When we pop up
320 one level, all temporaries associated with the previous level are freed.
321 Normally, all temporaries are freed after the execution of the statement
322 in which they were created. However, if we are inside a ({...}) grouping,
323 the result may be in a temporary and hence must be preserved. If the
324 result could be in a temporary, we preserve it if we can determine which
325 one it is in. If we cannot determine which temporary may contain the
326 result, all temporaries are preserved. A temporary is preserved by
327 pretending it was allocated at the previous nesting level.
328
329 Automatic variables are also assigned temporary slots, at the nesting
330 level where they are defined. They are marked a "kept" so that
331 free_temp_slots will not free them. */
332
333struct temp_slot
334{
335 /* Points to next temporary slot. */
336 struct temp_slot *next;
337 /* The rtx to used to reference the slot. */
338 rtx slot;
339 /* The size, in units, of the slot. */
340 int size;
341 /* Non-zero if this temporary is currently in use. */
342 char in_use;
343 /* Nesting level at which this slot is being used. */
344 int level;
345 /* Non-zero if this should survive a call to free_temp_slots. */
346 int keep;
347};
348
349/* List of all temporaries allocated, both available and in use. */
350
351struct temp_slot *temp_slots;
352
353/* Current nesting level for temporaries. */
354
355int temp_slot_level;
356\f
357/* Pointer to chain of `struct function' for containing functions. */
358struct function *outer_function_chain;
359
360/* Given a function decl for a containing function,
361 return the `struct function' for it. */
362
363struct function *
364find_function_data (decl)
365 tree decl;
366{
367 struct function *p;
368 for (p = outer_function_chain; p; p = p->next)
369 if (p->decl == decl)
370 return p;
371 abort ();
372}
373
374/* Save the current context for compilation of a nested function.
375 This is called from language-specific code.
376 The caller is responsible for saving any language-specific status,
6dc42e49 377 since this function knows only about language-independent variables. */
6f086dfc
RS
378
379void
380push_function_context ()
381{
382 struct function *p = (struct function *) xmalloc (sizeof (struct function));
383
384 p->next = outer_function_chain;
385 outer_function_chain = p;
386
387 p->name = current_function_name;
388 p->decl = current_function_decl;
389 p->pops_args = current_function_pops_args;
390 p->returns_struct = current_function_returns_struct;
391 p->returns_pcc_struct = current_function_returns_pcc_struct;
392 p->needs_context = current_function_needs_context;
393 p->calls_setjmp = current_function_calls_setjmp;
394 p->calls_longjmp = current_function_calls_longjmp;
395 p->calls_alloca = current_function_calls_alloca;
396 p->has_nonlocal_label = current_function_has_nonlocal_label;
397 p->args_size = current_function_args_size;
398 p->pretend_args_size = current_function_pretend_args_size;
399 p->arg_offset_rtx = current_function_arg_offset_rtx;
400 p->uses_const_pool = current_function_uses_const_pool;
401 p->uses_pic_offset_table = current_function_uses_pic_offset_table;
402 p->internal_arg_pointer = current_function_internal_arg_pointer;
403 p->max_parm_reg = max_parm_reg;
404 p->parm_reg_stack_loc = parm_reg_stack_loc;
405 p->outgoing_args_size = current_function_outgoing_args_size;
406 p->return_rtx = current_function_return_rtx;
407 p->nonlocal_goto_handler_slot = nonlocal_goto_handler_slot;
408 p->nonlocal_goto_stack_level = nonlocal_goto_stack_level;
409 p->nonlocal_labels = nonlocal_labels;
410 p->cleanup_label = cleanup_label;
411 p->return_label = return_label;
412 p->save_expr_regs = save_expr_regs;
413 p->stack_slot_list = stack_slot_list;
414 p->parm_birth_insn = parm_birth_insn;
415 p->frame_offset = frame_offset;
416 p->tail_recursion_label = tail_recursion_label;
417 p->tail_recursion_reentry = tail_recursion_reentry;
418 p->arg_pointer_save_area = arg_pointer_save_area;
419 p->rtl_expr_chain = rtl_expr_chain;
420 p->last_parm_insn = last_parm_insn;
421 p->context_display = context_display;
422 p->trampoline_list = trampoline_list;
423 p->function_call_count = function_call_count;
424 p->temp_slots = temp_slots;
425 p->temp_slot_level = temp_slot_level;
426 p->fixup_var_refs_queue = 0;
f979c996 427 p->epilogue_delay_list = current_function_epilogue_delay_list;
6f086dfc
RS
428
429 save_tree_status (p);
430 save_storage_status (p);
431 save_emit_status (p);
432 init_emit ();
433 save_expr_status (p);
434 save_stmt_status (p);
a506307a 435 save_varasm_status (p);
6f086dfc
RS
436}
437
438/* Restore the last saved context, at the end of a nested function.
439 This function is called from language-specific code. */
440
441void
442pop_function_context ()
443{
444 struct function *p = outer_function_chain;
445
446 outer_function_chain = p->next;
447
448 current_function_name = p->name;
449 current_function_decl = p->decl;
450 current_function_pops_args = p->pops_args;
451 current_function_returns_struct = p->returns_struct;
452 current_function_returns_pcc_struct = p->returns_pcc_struct;
453 current_function_needs_context = p->needs_context;
454 current_function_calls_setjmp = p->calls_setjmp;
455 current_function_calls_longjmp = p->calls_longjmp;
456 current_function_calls_alloca = p->calls_alloca;
457 current_function_has_nonlocal_label = p->has_nonlocal_label;
458 current_function_contains_functions = 1;
459 current_function_args_size = p->args_size;
460 current_function_pretend_args_size = p->pretend_args_size;
461 current_function_arg_offset_rtx = p->arg_offset_rtx;
462 current_function_uses_const_pool = p->uses_const_pool;
463 current_function_uses_pic_offset_table = p->uses_pic_offset_table;
464 current_function_internal_arg_pointer = p->internal_arg_pointer;
465 max_parm_reg = p->max_parm_reg;
466 parm_reg_stack_loc = p->parm_reg_stack_loc;
467 current_function_outgoing_args_size = p->outgoing_args_size;
468 current_function_return_rtx = p->return_rtx;
469 nonlocal_goto_handler_slot = p->nonlocal_goto_handler_slot;
470 nonlocal_goto_stack_level = p->nonlocal_goto_stack_level;
471 nonlocal_labels = p->nonlocal_labels;
472 cleanup_label = p->cleanup_label;
473 return_label = p->return_label;
474 save_expr_regs = p->save_expr_regs;
475 stack_slot_list = p->stack_slot_list;
476 parm_birth_insn = p->parm_birth_insn;
477 frame_offset = p->frame_offset;
478 tail_recursion_label = p->tail_recursion_label;
479 tail_recursion_reentry = p->tail_recursion_reentry;
480 arg_pointer_save_area = p->arg_pointer_save_area;
481 rtl_expr_chain = p->rtl_expr_chain;
482 last_parm_insn = p->last_parm_insn;
483 context_display = p->context_display;
484 trampoline_list = p->trampoline_list;
485 function_call_count = p->function_call_count;
486 temp_slots = p->temp_slots;
487 temp_slot_level = p->temp_slot_level;
f979c996 488 current_function_epilogue_delay_list = p->epilogue_delay_list;
6f086dfc
RS
489
490 restore_tree_status (p);
491 restore_storage_status (p);
492 restore_expr_status (p);
493 restore_emit_status (p);
494 restore_stmt_status (p);
a506307a 495 restore_varasm_status (p);
6f086dfc
RS
496
497 /* Finish doing put_var_into_stack for any of our variables
498 which became addressable during the nested function. */
499 {
500 struct var_refs_queue *queue = p->fixup_var_refs_queue;
501 for (; queue; queue = queue->next)
00d8a4c1 502 fixup_var_refs (queue->modified, queue->promoted_mode, queue->unsignedp);
6f086dfc
RS
503 }
504
505 free (p);
506
507 /* Reset variables that have known state during rtx generation. */
508 rtx_equal_function_value_matters = 1;
509 virtuals_instantiated = 0;
510}
511\f
512/* Allocate fixed slots in the stack frame of the current function. */
513
514/* Return size needed for stack frame based on slots so far allocated.
515 This size counts from zero. It is not rounded to STACK_BOUNDARY;
516 the caller may have to do that. */
517
518int
519get_frame_size ()
520{
521#ifdef FRAME_GROWS_DOWNWARD
522 return -frame_offset;
523#else
524 return frame_offset;
525#endif
526}
527
528/* Allocate a stack slot of SIZE bytes and return a MEM rtx for it
529 with machine mode MODE.
530
531 ALIGN controls the amount of alignment for the address of the slot:
532 0 means according to MODE,
533 -1 means use BIGGEST_ALIGNMENT and round size to multiple of that,
534 positive specifies alignment boundary in bits.
535
536 We do not round to stack_boundary here. */
537
538rtx
539assign_stack_local (mode, size, align)
540 enum machine_mode mode;
541 int size;
542 int align;
543{
544 register rtx x, addr;
545 int bigend_correction = 0;
546 int alignment;
547
548 if (align == 0)
549 {
550 alignment = GET_MODE_ALIGNMENT (mode) / BITS_PER_UNIT;
551 if (mode == BLKmode)
552 alignment = BIGGEST_ALIGNMENT / BITS_PER_UNIT;
553 }
554 else if (align == -1)
555 {
556 alignment = BIGGEST_ALIGNMENT / BITS_PER_UNIT;
557 size = CEIL_ROUND (size, alignment);
558 }
559 else
560 alignment = align / BITS_PER_UNIT;
561
6f086dfc
RS
562 /* Round frame offset to that alignment.
563 We must be careful here, since FRAME_OFFSET might be negative and
564 division with a negative dividend isn't as well defined as we might
565 like. So we instead assume that ALIGNMENT is a power of two and
566 use logical operations which are unambiguous. */
567#ifdef FRAME_GROWS_DOWNWARD
568 frame_offset = FLOOR_ROUND (frame_offset, alignment);
569#else
570 frame_offset = CEIL_ROUND (frame_offset, alignment);
571#endif
572
573 /* On a big-endian machine, if we are allocating more space than we will use,
574 use the least significant bytes of those that are allocated. */
575#if BYTES_BIG_ENDIAN
576 if (mode != BLKmode)
577 bigend_correction = size - GET_MODE_SIZE (mode);
578#endif
579
580#ifdef FRAME_GROWS_DOWNWARD
581 frame_offset -= size;
582#endif
583
584 /* If we have already instantiated virtual registers, return the actual
585 address relative to the frame pointer. */
586 if (virtuals_instantiated)
587 addr = plus_constant (frame_pointer_rtx,
588 (frame_offset + bigend_correction
589 + STARTING_FRAME_OFFSET));
590 else
591 addr = plus_constant (virtual_stack_vars_rtx,
592 frame_offset + bigend_correction);
593
594#ifndef FRAME_GROWS_DOWNWARD
595 frame_offset += size;
596#endif
597
598 x = gen_rtx (MEM, mode, addr);
599
600 stack_slot_list = gen_rtx (EXPR_LIST, VOIDmode, x, stack_slot_list);
601
602 return x;
603}
604
605/* Assign a stack slot in a containing function.
606 First three arguments are same as in preceding function.
607 The last argument specifies the function to allocate in. */
608
609rtx
610assign_outer_stack_local (mode, size, align, function)
611 enum machine_mode mode;
612 int size;
613 int align;
614 struct function *function;
615{
616 register rtx x, addr;
617 int bigend_correction = 0;
618 int alignment;
619
620 /* Allocate in the memory associated with the function in whose frame
621 we are assigning. */
622 push_obstacks (function->function_obstack,
623 function->function_maybepermanent_obstack);
624
625 if (align == 0)
626 {
627 alignment = GET_MODE_ALIGNMENT (mode) / BITS_PER_UNIT;
628 if (mode == BLKmode)
629 alignment = BIGGEST_ALIGNMENT / BITS_PER_UNIT;
630 }
631 else if (align == -1)
632 {
633 alignment = BIGGEST_ALIGNMENT / BITS_PER_UNIT;
634 size = CEIL_ROUND (size, alignment);
635 }
636 else
637 alignment = align / BITS_PER_UNIT;
638
6f086dfc
RS
639 /* Round frame offset to that alignment. */
640#ifdef FRAME_GROWS_DOWNWARD
2af69b62 641 function->frame_offset = FLOOR_ROUND (function->frame_offset, alignment);
6f086dfc 642#else
2af69b62 643 function->frame_offset = CEIL_ROUND (function->frame_offset, alignment);
6f086dfc
RS
644#endif
645
646 /* On a big-endian machine, if we are allocating more space than we will use,
647 use the least significant bytes of those that are allocated. */
648#if BYTES_BIG_ENDIAN
649 if (mode != BLKmode)
650 bigend_correction = size - GET_MODE_SIZE (mode);
651#endif
652
653#ifdef FRAME_GROWS_DOWNWARD
654 function->frame_offset -= size;
655#endif
656 addr = plus_constant (virtual_stack_vars_rtx,
657 function->frame_offset + bigend_correction);
658#ifndef FRAME_GROWS_DOWNWARD
659 function->frame_offset += size;
660#endif
661
662 x = gen_rtx (MEM, mode, addr);
663
664 function->stack_slot_list
665 = gen_rtx (EXPR_LIST, VOIDmode, x, function->stack_slot_list);
666
667 pop_obstacks ();
668
669 return x;
670}
671\f
672/* Allocate a temporary stack slot and record it for possible later
673 reuse.
674
675 MODE is the machine mode to be given to the returned rtx.
676
677 SIZE is the size in units of the space required. We do no rounding here
678 since assign_stack_local will do any required rounding.
679
680 KEEP is non-zero if this slot is to be retained after a call to
681 free_temp_slots. Automatic variables for a block are allocated with this
682 flag. */
683
684rtx
685assign_stack_temp (mode, size, keep)
686 enum machine_mode mode;
687 int size;
688 int keep;
689{
690 struct temp_slot *p, *best_p = 0;
691
692 /* First try to find an available, already-allocated temporary that is the
693 exact size we require. */
694 for (p = temp_slots; p; p = p->next)
695 if (p->size == size && GET_MODE (p->slot) == mode && ! p->in_use)
696 break;
697
698 /* If we didn't find, one, try one that is larger than what we want. We
699 find the smallest such. */
700 if (p == 0)
701 for (p = temp_slots; p; p = p->next)
702 if (p->size > size && GET_MODE (p->slot) == mode && ! p->in_use
703 && (best_p == 0 || best_p->size > p->size))
704 best_p = p;
705
706 /* Make our best, if any, the one to use. */
707 if (best_p)
708 p = best_p;
709
710 /* If we still didn't find one, make a new temporary. */
711 if (p == 0)
712 {
713 p = (struct temp_slot *) oballoc (sizeof (struct temp_slot));
714 p->size = size;
715 /* If the temp slot mode doesn't indicate the alignment,
716 use the largest possible, so no one will be disappointed. */
717 p->slot = assign_stack_local (mode, size, mode == BLKmode ? -1 : 0);
718 p->next = temp_slots;
719 temp_slots = p;
720 }
721
722 p->in_use = 1;
723 p->level = temp_slot_level;
724 p->keep = keep;
725 return p->slot;
726}
727\f
728/* If X could be a reference to a temporary slot, mark that slot as belonging
729 to the to one level higher. If X matched one of our slots, just mark that
730 one. Otherwise, we can't easily predict which it is, so upgrade all of
731 them. Kept slots need not be touched.
732
733 This is called when an ({...}) construct occurs and a statement
734 returns a value in memory. */
735
736void
737preserve_temp_slots (x)
738 rtx x;
739{
740 struct temp_slot *p;
741
742 /* If X is not in memory or is at a constant address, it cannot be in
743 a temporary slot. */
744 if (x == 0 || GET_CODE (x) != MEM || CONSTANT_P (XEXP (x, 0)))
745 return;
746
747 /* First see if we can find a match. */
748 for (p = temp_slots; p; p = p->next)
749 if (p->in_use && x == p->slot)
750 {
751 p->level--;
752 return;
753 }
754
755 /* Otherwise, preserve all non-kept slots at this level. */
756 for (p = temp_slots; p; p = p->next)
757 if (p->in_use && p->level == temp_slot_level && ! p->keep)
758 p->level--;
759}
760
761/* Free all temporaries used so far. This is normally called at the end
762 of generating code for a statement. */
763
764void
765free_temp_slots ()
766{
767 struct temp_slot *p;
768
769 for (p = temp_slots; p; p = p->next)
770 if (p->in_use && p->level == temp_slot_level && ! p->keep)
771 p->in_use = 0;
772}
773
774/* Push deeper into the nesting level for stack temporaries. */
775
776void
777push_temp_slots ()
778{
779 /* For GNU C++, we must allow a sequence to be emitted anywhere in
780 the level where the sequence was started. By not changing levels
781 when the compiler is inside a sequence, the temporaries for the
782 sequence and the temporaries will not unwittingly conflict with
783 the temporaries for other sequences and/or code at that level. */
784 if (in_sequence_p ())
785 return;
786
787 temp_slot_level++;
788}
789
790/* Pop a temporary nesting level. All slots in use in the current level
791 are freed. */
792
793void
794pop_temp_slots ()
795{
796 struct temp_slot *p;
797
798 /* See comment in push_temp_slots about why we don't change levels
799 in sequences. */
800 if (in_sequence_p ())
801 return;
802
803 for (p = temp_slots; p; p = p->next)
804 if (p->in_use && p->level == temp_slot_level)
805 p->in_use = 0;
806
807 temp_slot_level--;
808}
809\f
810/* Retroactively move an auto variable from a register to a stack slot.
811 This is done when an address-reference to the variable is seen. */
812
813void
814put_var_into_stack (decl)
815 tree decl;
816{
817 register rtx reg;
818 register rtx new = 0;
00d8a4c1 819 enum machine_mode promoted_mode, decl_mode;
6f086dfc
RS
820 struct function *function = 0;
821 tree context = decl_function_context (decl);
822
00d8a4c1 823 /* Get the current rtl used for this object and it's original mode. */
6f086dfc 824 reg = TREE_CODE (decl) == SAVE_EXPR ? SAVE_EXPR_RTL (decl) : DECL_RTL (decl);
2baccce2
RS
825
826 /* No need to do anything if decl has no rtx yet
827 since in that case caller is setting TREE_ADDRESSABLE
828 and a stack slot will be assigned when the rtl is made. */
829 if (reg == 0)
830 return;
00d8a4c1
RK
831
832 /* Get the declared mode for this object. */
833 decl_mode = (TREE_CODE (decl) == SAVE_EXPR ? TYPE_MODE (TREE_TYPE (decl))
834 : DECL_MODE (decl));
2baccce2
RS
835 /* Get the mode it's actually stored in. */
836 promoted_mode = GET_MODE (reg);
6f086dfc
RS
837
838 /* If this variable comes from an outer function,
839 find that function's saved context. */
840 if (context != current_function_decl)
841 for (function = outer_function_chain; function; function = function->next)
842 if (function->decl == context)
843 break;
844
6f086dfc
RS
845 /* If this is a variable-size object with a pseudo to address it,
846 put that pseudo into the stack, if the var is nonlocal. */
a82ad570 847 if (DECL_NONLOCAL (decl)
6f086dfc
RS
848 && GET_CODE (reg) == MEM
849 && GET_CODE (XEXP (reg, 0)) == REG
850 && REGNO (XEXP (reg, 0)) > LAST_VIRTUAL_REGISTER)
4cdb3e78
RS
851 {
852 reg = XEXP (reg, 0);
853 decl_mode = promoted_mode = GET_MODE (reg);
854 }
e15762df 855
6f086dfc
RS
856 if (GET_CODE (reg) != REG)
857 return;
858
859 if (function)
860 {
861 if (REGNO (reg) < function->max_parm_reg)
862 new = function->parm_reg_stack_loc[REGNO (reg)];
863 if (new == 0)
e15762df 864 new = assign_outer_stack_local (decl_mode, GET_MODE_SIZE (decl_mode),
6f086dfc
RS
865 0, function);
866 }
867 else
868 {
869 if (REGNO (reg) < max_parm_reg)
870 new = parm_reg_stack_loc[REGNO (reg)];
871 if (new == 0)
e15762df 872 new = assign_stack_local (decl_mode, GET_MODE_SIZE (decl_mode), 0);
6f086dfc
RS
873 }
874
875 XEXP (reg, 0) = XEXP (new, 0);
876 /* `volatil' bit means one thing for MEMs, another entirely for REGs. */
877 REG_USERVAR_P (reg) = 0;
878 PUT_CODE (reg, MEM);
00d8a4c1 879 PUT_MODE (reg, decl_mode);
6f086dfc
RS
880
881 /* If this is a memory ref that contains aggregate components,
882 mark it as such for cse and loop optimize. */
883 MEM_IN_STRUCT_P (reg)
884 = (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE
885 || TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
886 || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE);
887
888 /* Now make sure that all refs to the variable, previously made
889 when it was a register, are fixed up to be valid again. */
890 if (function)
891 {
892 struct var_refs_queue *temp;
893
894 /* Variable is inherited; fix it up when we get back to its function. */
895 push_obstacks (function->function_obstack,
896 function->function_maybepermanent_obstack);
897 temp
898 = (struct var_refs_queue *) oballoc (sizeof (struct var_refs_queue));
899 temp->modified = reg;
00d8a4c1
RK
900 temp->promoted_mode = promoted_mode;
901 temp->unsignedp = TREE_UNSIGNED (TREE_TYPE (decl));
6f086dfc
RS
902 temp->next = function->fixup_var_refs_queue;
903 function->fixup_var_refs_queue = temp;
904 pop_obstacks ();
905 }
906 else
907 /* Variable is local; fix it up now. */
00d8a4c1 908 fixup_var_refs (reg, promoted_mode, TREE_UNSIGNED (TREE_TYPE (decl)));
6f086dfc
RS
909}
910\f
911static void
00d8a4c1 912fixup_var_refs (var, promoted_mode, unsignedp)
6f086dfc 913 rtx var;
00d8a4c1
RK
914 enum machine_mode promoted_mode;
915 int unsignedp;
6f086dfc
RS
916{
917 tree pending;
918 rtx first_insn = get_insns ();
919 struct sequence_stack *stack = sequence_stack;
920 tree rtl_exps = rtl_expr_chain;
921
922 /* Must scan all insns for stack-refs that exceed the limit. */
00d8a4c1 923 fixup_var_refs_insns (var, promoted_mode, unsignedp, first_insn, stack == 0);
6f086dfc
RS
924
925 /* Scan all pending sequences too. */
926 for (; stack; stack = stack->next)
927 {
928 push_to_sequence (stack->first);
00d8a4c1
RK
929 fixup_var_refs_insns (var, promoted_mode, unsignedp,
930 stack->first, stack->next != 0);
6f086dfc
RS
931 /* Update remembered end of sequence
932 in case we added an insn at the end. */
933 stack->last = get_last_insn ();
934 end_sequence ();
935 }
936
937 /* Scan all waiting RTL_EXPRs too. */
938 for (pending = rtl_exps; pending; pending = TREE_CHAIN (pending))
939 {
940 rtx seq = RTL_EXPR_SEQUENCE (TREE_VALUE (pending));
941 if (seq != const0_rtx && seq != 0)
942 {
943 push_to_sequence (seq);
00d8a4c1 944 fixup_var_refs_insns (var, promoted_mode, unsignedp, seq, 0);
6f086dfc
RS
945 end_sequence ();
946 }
947 }
948}
949\f
950/* This structure is used by the following two functions to record MEMs or
951 pseudos used to replace VAR, any SUBREGs of VAR, and any MEMs containing
952 VAR as an address. We need to maintain this list in case two operands of
953 an insn were required to match; in that case we must ensure we use the
954 same replacement. */
955
956struct fixup_replacement
957{
958 rtx old;
959 rtx new;
960 struct fixup_replacement *next;
961};
962
963/* REPLACEMENTS is a pointer to a list of the above structures and X is
964 some part of an insn. Return a struct fixup_replacement whose OLD
965 value is equal to X. Allocate a new structure if no such entry exists. */
966
967static struct fixup_replacement *
2740a678 968find_fixup_replacement (replacements, x)
6f086dfc
RS
969 struct fixup_replacement **replacements;
970 rtx x;
971{
972 struct fixup_replacement *p;
973
974 /* See if we have already replaced this. */
975 for (p = *replacements; p && p->old != x; p = p->next)
976 ;
977
978 if (p == 0)
979 {
980 p = (struct fixup_replacement *) oballoc (sizeof (struct fixup_replacement));
981 p->old = x;
982 p->new = 0;
983 p->next = *replacements;
984 *replacements = p;
985 }
986
987 return p;
988}
989
990/* Scan the insn-chain starting with INSN for refs to VAR
991 and fix them up. TOPLEVEL is nonzero if this chain is the
992 main chain of insns for the current function. */
993
994static void
00d8a4c1 995fixup_var_refs_insns (var, promoted_mode, unsignedp, insn, toplevel)
6f086dfc 996 rtx var;
00d8a4c1
RK
997 enum machine_mode promoted_mode;
998 int unsignedp;
6f086dfc
RS
999 rtx insn;
1000 int toplevel;
1001{
02a10449
RK
1002 rtx call_dest = 0;
1003
6f086dfc
RS
1004 while (insn)
1005 {
1006 rtx next = NEXT_INSN (insn);
1007 rtx note;
e15762df 1008 if (GET_RTX_CLASS (GET_CODE (insn)) == 'i')
6f086dfc
RS
1009 {
1010 /* The insn to load VAR from a home in the arglist
1011 is now a no-op. When we see it, just delete it. */
1012 if (toplevel
1013 && GET_CODE (PATTERN (insn)) == SET
1014 && SET_DEST (PATTERN (insn)) == var
d1e37dc7
RS
1015 /* If this represents the result of an insn group,
1016 don't delete the insn. */
1017 && find_reg_note (insn, REG_RETVAL, NULL_RTX) == 0
6f086dfc
RS
1018 && rtx_equal_p (SET_SRC (PATTERN (insn)), var))
1019 {
b4ff474c
RS
1020 /* In unoptimized compilation, we shouldn't call delete_insn
1021 except in jump.c doing warnings. */
1022 PUT_CODE (insn, NOTE);
1023 NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
1024 NOTE_SOURCE_FILE (insn) = 0;
6f086dfc
RS
1025 if (insn == last_parm_insn)
1026 last_parm_insn = PREV_INSN (next);
1027 }
1028 else
1029 {
02a10449
RK
1030 struct fixup_replacement *replacements = 0;
1031 rtx next_insn = NEXT_INSN (insn);
1032
1033#ifdef SMALL_REGISTER_CLASSES
1034 /* If the insn that copies the results of a CALL_INSN
1035 into a pseudo now references VAR, we have to use an
1036 intermediate pseudo since we want the life of the
1037 return value register to be only a single insn.
1038
1039 If we don't use an intermediate pseudo, such things as
1040 address computations to make the address of VAR valid
1041 if it is not can be placed beween the CALL_INSN and INSN.
1042
1043 To make sure this doesn't happen, we record the destination
1044 of the CALL_INSN and see if the next insn uses both that
1045 and VAR. */
1046
1047 if (call_dest != 0 && GET_CODE (insn) == INSN
1048 && reg_mentioned_p (var, PATTERN (insn))
1049 && reg_mentioned_p (call_dest, PATTERN (insn)))
1050 {
1051 rtx temp = gen_reg_rtx (GET_MODE (call_dest));
1052
1053 emit_insn_before (gen_move_insn (temp, call_dest), insn);
1054
1055 PATTERN (insn) = replace_rtx (PATTERN (insn),
1056 call_dest, temp);
1057 }
1058
1059 if (GET_CODE (insn) == CALL_INSN
1060 && GET_CODE (PATTERN (insn)) == SET)
1061 call_dest = SET_DEST (PATTERN (insn));
1062 else if (GET_CODE (insn) == CALL_INSN
1063 && GET_CODE (PATTERN (insn)) == PARALLEL
1064 && GET_CODE (XVECEXP (PATTERN (insn), 0, 0)) == SET)
1065 call_dest = SET_DEST (XVECEXP (PATTERN (insn), 0, 0));
1066 else
1067 call_dest = 0;
1068#endif
1069
6f086dfc
RS
1070 /* See if we have to do anything to INSN now that VAR is in
1071 memory. If it needs to be loaded into a pseudo, use a single
1072 pseudo for the entire insn in case there is a MATCH_DUP
1073 between two operands. We pass a pointer to the head of
1074 a list of struct fixup_replacements. If fixup_var_refs_1
1075 needs to allocate pseudos or replacement MEMs (for SUBREGs),
1076 it will record them in this list.
1077
1078 If it allocated a pseudo for any replacement, we copy into
1079 it here. */
1080
00d8a4c1
RK
1081 fixup_var_refs_1 (var, promoted_mode, &PATTERN (insn), insn,
1082 &replacements);
6f086dfc 1083
77121fee
JW
1084 /* If this is last_parm_insn, and any instructions were output
1085 after it to fix it up, then we must set last_parm_insn to
1086 the last such instruction emitted. */
1087 if (insn == last_parm_insn)
1088 last_parm_insn = PREV_INSN (next_insn);
1089
6f086dfc
RS
1090 while (replacements)
1091 {
1092 if (GET_CODE (replacements->new) == REG)
1093 {
1094 rtx insert_before;
00d8a4c1 1095 rtx seq;
6f086dfc
RS
1096
1097 /* OLD might be a (subreg (mem)). */
1098 if (GET_CODE (replacements->old) == SUBREG)
1099 replacements->old
1100 = fixup_memory_subreg (replacements->old, insn, 0);
1101 else
1102 replacements->old
1103 = fixup_stack_1 (replacements->old, insn);
1104
1105 /* We can not separate USE insns from the CALL_INSN
1106 that they belong to. If this is a CALL_INSN, insert
b335c2cc 1107 the move insn before the USE insns preceding it
6f086dfc
RS
1108 instead of immediately before the insn. */
1109 if (GET_CODE (insn) == CALL_INSN)
1110 {
1111 insert_before = insn;
1112 while (GET_CODE (PREV_INSN (insert_before)) == INSN
1113 && GET_CODE (PATTERN (PREV_INSN (insert_before))) == USE)
1114 insert_before = PREV_INSN (insert_before);
1115 }
1116 else
1117 insert_before = insn;
1118
00d8a4c1
RK
1119 /* If we are changing the mode, do a conversion.
1120 This might be wasteful, but combine.c will
1121 eliminate much of the waste. */
1122
1123 if (GET_MODE (replacements->new)
1124 != GET_MODE (replacements->old))
1125 {
1126 start_sequence ();
1127 convert_move (replacements->new,
1128 replacements->old, unsignedp);
1129 seq = gen_sequence ();
1130 end_sequence ();
1131 }
1132 else
1133 seq = gen_move_insn (replacements->new,
1134 replacements->old);
1135
1136 emit_insn_before (seq, insert_before);
6f086dfc
RS
1137 }
1138
1139 replacements = replacements->next;
1140 }
1141 }
1142
1143 /* Also fix up any invalid exprs in the REG_NOTES of this insn.
1144 But don't touch other insns referred to by reg-notes;
1145 we will get them elsewhere. */
1146 for (note = REG_NOTES (insn); note; note = XEXP (note, 1))
1147 if (GET_CODE (note) != INSN_LIST)
1148 XEXP (note, 0) = walk_fixup_memory_subreg (XEXP (note, 0), insn);
1149 }
1150 insn = next;
1151 }
1152}
1153\f
00d8a4c1
RK
1154/* VAR is a MEM that used to be a pseudo register with mode PROMOTED_MODE.
1155 See if the rtx expression at *LOC in INSN needs to be changed.
6f086dfc
RS
1156
1157 REPLACEMENTS is a pointer to a list head that starts out zero, but may
1158 contain a list of original rtx's and replacements. If we find that we need
1159 to modify this insn by replacing a memory reference with a pseudo or by
1160 making a new MEM to implement a SUBREG, we consult that list to see if
1161 we have already chosen a replacement. If none has already been allocated,
1162 we allocate it and update the list. fixup_var_refs_insns will copy VAR
1163 or the SUBREG, as appropriate, to the pseudo. */
1164
1165static void
00d8a4c1 1166fixup_var_refs_1 (var, promoted_mode, loc, insn, replacements)
6f086dfc 1167 register rtx var;
00d8a4c1 1168 enum machine_mode promoted_mode;
6f086dfc
RS
1169 register rtx *loc;
1170 rtx insn;
1171 struct fixup_replacement **replacements;
1172{
1173 register int i;
1174 register rtx x = *loc;
1175 RTX_CODE code = GET_CODE (x);
1176 register char *fmt;
1177 register rtx tem, tem1;
1178 struct fixup_replacement *replacement;
1179
1180 switch (code)
1181 {
1182 case MEM:
1183 if (var == x)
1184 {
1185 /* If we already have a replacement, use it. Otherwise,
1186 try to fix up this address in case it is invalid. */
1187
2740a678 1188 replacement = find_fixup_replacement (replacements, var);
6f086dfc
RS
1189 if (replacement->new)
1190 {
1191 *loc = replacement->new;
1192 return;
1193 }
1194
1195 *loc = replacement->new = x = fixup_stack_1 (x, insn);
1196
00d8a4c1
RK
1197 /* Unless we are forcing memory to register or we changed the mode,
1198 we can leave things the way they are if the insn is valid. */
6f086dfc
RS
1199
1200 INSN_CODE (insn) = -1;
00d8a4c1
RK
1201 if (! flag_force_mem && GET_MODE (x) == promoted_mode
1202 && recog_memoized (insn) >= 0)
6f086dfc
RS
1203 return;
1204
00d8a4c1 1205 *loc = replacement->new = gen_reg_rtx (promoted_mode);
6f086dfc
RS
1206 return;
1207 }
1208
1209 /* If X contains VAR, we need to unshare it here so that we update
1210 each occurrence separately. But all identical MEMs in one insn
1211 must be replaced with the same rtx because of the possibility of
1212 MATCH_DUPs. */
1213
1214 if (reg_mentioned_p (var, x))
1215 {
2740a678 1216 replacement = find_fixup_replacement (replacements, x);
6f086dfc
RS
1217 if (replacement->new == 0)
1218 replacement->new = copy_most_rtx (x, var);
1219
1220 *loc = x = replacement->new;
1221 }
1222 break;
1223
1224 case REG:
1225 case CC0:
1226 case PC:
1227 case CONST_INT:
1228 case CONST:
1229 case SYMBOL_REF:
1230 case LABEL_REF:
1231 case CONST_DOUBLE:
1232 return;
1233
1234 case SIGN_EXTRACT:
1235 case ZERO_EXTRACT:
1236 /* Note that in some cases those types of expressions are altered
1237 by optimize_bit_field, and do not survive to get here. */
1238 if (XEXP (x, 0) == var
1239 || (GET_CODE (XEXP (x, 0)) == SUBREG
1240 && SUBREG_REG (XEXP (x, 0)) == var))
1241 {
1242 /* Get TEM as a valid MEM in the mode presently in the insn.
1243
1244 We don't worry about the possibility of MATCH_DUP here; it
1245 is highly unlikely and would be tricky to handle. */
1246
1247 tem = XEXP (x, 0);
1248 if (GET_CODE (tem) == SUBREG)
1249 tem = fixup_memory_subreg (tem, insn, 1);
1250 tem = fixup_stack_1 (tem, insn);
1251
1252 /* Unless we want to load from memory, get TEM into the proper mode
1253 for an extract from memory. This can only be done if the
1254 extract is at a constant position and length. */
1255
1256 if (! flag_force_mem && GET_CODE (XEXP (x, 1)) == CONST_INT
1257 && GET_CODE (XEXP (x, 2)) == CONST_INT
1258 && ! mode_dependent_address_p (XEXP (tem, 0))
1259 && ! MEM_VOLATILE_P (tem))
1260 {
1261 enum machine_mode wanted_mode = VOIDmode;
1262 enum machine_mode is_mode = GET_MODE (tem);
1263 int width = INTVAL (XEXP (x, 1));
1264 int pos = INTVAL (XEXP (x, 2));
1265
1266#ifdef HAVE_extzv
1267 if (GET_CODE (x) == ZERO_EXTRACT)
1268 wanted_mode = insn_operand_mode[(int) CODE_FOR_extzv][1];
1269#endif
1270#ifdef HAVE_extv
1271 if (GET_CODE (x) == SIGN_EXTRACT)
1272 wanted_mode = insn_operand_mode[(int) CODE_FOR_extv][1];
1273#endif
6dc42e49 1274 /* If we have a narrower mode, we can do something. */
6f086dfc
RS
1275 if (wanted_mode != VOIDmode
1276 && GET_MODE_SIZE (wanted_mode) < GET_MODE_SIZE (is_mode))
1277 {
1278 int offset = pos / BITS_PER_UNIT;
1279 rtx old_pos = XEXP (x, 2);
1280 rtx newmem;
1281
1282 /* If the bytes and bits are counted differently, we
1283 must adjust the offset. */
1284#if BYTES_BIG_ENDIAN != BITS_BIG_ENDIAN
1285 offset = (GET_MODE_SIZE (is_mode)
1286 - GET_MODE_SIZE (wanted_mode) - offset);
1287#endif
1288
1289 pos %= GET_MODE_BITSIZE (wanted_mode);
1290
1291 newmem = gen_rtx (MEM, wanted_mode,
1292 plus_constant (XEXP (tem, 0), offset));
1293 RTX_UNCHANGING_P (newmem) = RTX_UNCHANGING_P (tem);
1294 MEM_VOLATILE_P (newmem) = MEM_VOLATILE_P (tem);
1295 MEM_IN_STRUCT_P (newmem) = MEM_IN_STRUCT_P (tem);
1296
1297 /* Make the change and see if the insn remains valid. */
1298 INSN_CODE (insn) = -1;
1299 XEXP (x, 0) = newmem;
5f4f0e22 1300 XEXP (x, 2) = GEN_INT (pos);
6f086dfc
RS
1301
1302 if (recog_memoized (insn) >= 0)
1303 return;
1304
1305 /* Otherwise, restore old position. XEXP (x, 0) will be
1306 restored later. */
1307 XEXP (x, 2) = old_pos;
1308 }
1309 }
1310
1311 /* If we get here, the bitfield extract insn can't accept a memory
1312 reference. Copy the input into a register. */
1313
1314 tem1 = gen_reg_rtx (GET_MODE (tem));
1315 emit_insn_before (gen_move_insn (tem1, tem), insn);
1316 XEXP (x, 0) = tem1;
1317 return;
1318 }
1319 break;
1320
1321 case SUBREG:
1322 if (SUBREG_REG (x) == var)
1323 {
00d8a4c1
RK
1324 /* If this is a special SUBREG made because VAR was promoted
1325 from a wider mode, replace it with VAR and call ourself
1326 recursively, this time saying that the object previously
1327 had its current mode (by virtue of the SUBREG). */
1328
1329 if (SUBREG_PROMOTED_VAR_P (x))
1330 {
1331 *loc = var;
1332 fixup_var_refs_1 (var, GET_MODE (var), loc, insn, replacements);
1333 return;
1334 }
1335
6f086dfc
RS
1336 /* If this SUBREG makes VAR wider, it has become a paradoxical
1337 SUBREG with VAR in memory, but these aren't allowed at this
1338 stage of the compilation. So load VAR into a pseudo and take
1339 a SUBREG of that pseudo. */
1340 if (GET_MODE_SIZE (GET_MODE (x)) > GET_MODE_SIZE (GET_MODE (var)))
1341 {
2740a678 1342 replacement = find_fixup_replacement (replacements, var);
6f086dfc
RS
1343 if (replacement->new == 0)
1344 replacement->new = gen_reg_rtx (GET_MODE (var));
1345 SUBREG_REG (x) = replacement->new;
1346 return;
1347 }
1348
1349 /* See if we have already found a replacement for this SUBREG.
1350 If so, use it. Otherwise, make a MEM and see if the insn
1351 is recognized. If not, or if we should force MEM into a register,
1352 make a pseudo for this SUBREG. */
2740a678 1353 replacement = find_fixup_replacement (replacements, x);
6f086dfc
RS
1354 if (replacement->new)
1355 {
1356 *loc = replacement->new;
1357 return;
1358 }
1359
1360 replacement->new = *loc = fixup_memory_subreg (x, insn, 0);
1361
f898f031 1362 INSN_CODE (insn) = -1;
6f086dfc
RS
1363 if (! flag_force_mem && recog_memoized (insn) >= 0)
1364 return;
1365
1366 *loc = replacement->new = gen_reg_rtx (GET_MODE (x));
1367 return;
1368 }
1369 break;
1370
1371 case SET:
1372 /* First do special simplification of bit-field references. */
1373 if (GET_CODE (SET_DEST (x)) == SIGN_EXTRACT
1374 || GET_CODE (SET_DEST (x)) == ZERO_EXTRACT)
1375 optimize_bit_field (x, insn, 0);
1376 if (GET_CODE (SET_SRC (x)) == SIGN_EXTRACT
1377 || GET_CODE (SET_SRC (x)) == ZERO_EXTRACT)
5f4f0e22 1378 optimize_bit_field (x, insn, NULL_PTR);
6f086dfc
RS
1379
1380 /* If SET_DEST is now a paradoxical SUBREG, put the result of this
1381 insn into a pseudo and store the low part of the pseudo into VAR. */
1382 if (GET_CODE (SET_DEST (x)) == SUBREG
1383 && SUBREG_REG (SET_DEST (x)) == var
1384 && (GET_MODE_SIZE (GET_MODE (SET_DEST (x)))
1385 > GET_MODE_SIZE (GET_MODE (var))))
1386 {
1387 SET_DEST (x) = tem = gen_reg_rtx (GET_MODE (SET_DEST (x)));
1388 emit_insn_after (gen_move_insn (var, gen_lowpart (GET_MODE (var),
1389 tem)),
1390 insn);
1391 break;
1392 }
1393
1394 {
1395 rtx dest = SET_DEST (x);
1396 rtx src = SET_SRC (x);
1397 rtx outerdest = dest;
1398
1399 while (GET_CODE (dest) == SUBREG || GET_CODE (dest) == STRICT_LOW_PART
1400 || GET_CODE (dest) == SIGN_EXTRACT
1401 || GET_CODE (dest) == ZERO_EXTRACT)
1402 dest = XEXP (dest, 0);
1403
1404 if (GET_CODE (src) == SUBREG)
1405 src = XEXP (src, 0);
1406
1407 /* If VAR does not appear at the top level of the SET
1408 just scan the lower levels of the tree. */
1409
1410 if (src != var && dest != var)
1411 break;
1412
1413 /* We will need to rerecognize this insn. */
1414 INSN_CODE (insn) = -1;
1415
1416#ifdef HAVE_insv
1417 if (GET_CODE (outerdest) == ZERO_EXTRACT && dest == var)
1418 {
1419 /* Since this case will return, ensure we fixup all the
1420 operands here. */
00d8a4c1
RK
1421 fixup_var_refs_1 (var, promoted_mode, &XEXP (outerdest, 1),
1422 insn, replacements);
1423 fixup_var_refs_1 (var, promoted_mode, &XEXP (outerdest, 2),
1424 insn, replacements);
1425 fixup_var_refs_1 (var, promoted_mode, &SET_SRC (x),
1426 insn, replacements);
6f086dfc
RS
1427
1428 tem = XEXP (outerdest, 0);
1429
1430 /* Clean up (SUBREG:SI (MEM:mode ...) 0)
1431 that may appear inside a ZERO_EXTRACT.
1432 This was legitimate when the MEM was a REG. */
1433 if (GET_CODE (tem) == SUBREG
1434 && SUBREG_REG (tem) == var)
1435 tem = fixup_memory_subreg (tem, insn, 1);
1436 else
1437 tem = fixup_stack_1 (tem, insn);
1438
1439 if (GET_CODE (XEXP (outerdest, 1)) == CONST_INT
1440 && GET_CODE (XEXP (outerdest, 2)) == CONST_INT
1441 && ! mode_dependent_address_p (XEXP (tem, 0))
1442 && ! MEM_VOLATILE_P (tem))
1443 {
1444 enum machine_mode wanted_mode
1445 = insn_operand_mode[(int) CODE_FOR_insv][0];
1446 enum machine_mode is_mode = GET_MODE (tem);
1447 int width = INTVAL (XEXP (outerdest, 1));
1448 int pos = INTVAL (XEXP (outerdest, 2));
1449
6dc42e49 1450 /* If we have a narrower mode, we can do something. */
6f086dfc
RS
1451 if (GET_MODE_SIZE (wanted_mode) < GET_MODE_SIZE (is_mode))
1452 {
1453 int offset = pos / BITS_PER_UNIT;
1454 rtx old_pos = XEXP (outerdest, 2);
1455 rtx newmem;
1456
1457#if BYTES_BIG_ENDIAN != BITS_BIG_ENDIAN
1458 offset = (GET_MODE_SIZE (is_mode)
1459 - GET_MODE_SIZE (wanted_mode) - offset);
1460#endif
1461
1462 pos %= GET_MODE_BITSIZE (wanted_mode);
1463
1464 newmem = gen_rtx (MEM, wanted_mode,
1465 plus_constant (XEXP (tem, 0), offset));
1466 RTX_UNCHANGING_P (newmem) = RTX_UNCHANGING_P (tem);
1467 MEM_VOLATILE_P (newmem) = MEM_VOLATILE_P (tem);
1468 MEM_IN_STRUCT_P (newmem) = MEM_IN_STRUCT_P (tem);
1469
1470 /* Make the change and see if the insn remains valid. */
1471 INSN_CODE (insn) = -1;
1472 XEXP (outerdest, 0) = newmem;
5f4f0e22 1473 XEXP (outerdest, 2) = GEN_INT (pos);
6f086dfc
RS
1474
1475 if (recog_memoized (insn) >= 0)
1476 return;
1477
1478 /* Otherwise, restore old position. XEXP (x, 0) will be
1479 restored later. */
1480 XEXP (outerdest, 2) = old_pos;
1481 }
1482 }
1483
1484 /* If we get here, the bit-field store doesn't allow memory
1485 or isn't located at a constant position. Load the value into
1486 a register, do the store, and put it back into memory. */
1487
1488 tem1 = gen_reg_rtx (GET_MODE (tem));
1489 emit_insn_before (gen_move_insn (tem1, tem), insn);
1490 emit_insn_after (gen_move_insn (tem, tem1), insn);
1491 XEXP (outerdest, 0) = tem1;
1492 return;
1493 }
1494#endif
1495
1496 /* STRICT_LOW_PART is a no-op on memory references
1497 and it can cause combinations to be unrecognizable,
1498 so eliminate it. */
1499
1500 if (dest == var && GET_CODE (SET_DEST (x)) == STRICT_LOW_PART)
1501 SET_DEST (x) = XEXP (SET_DEST (x), 0);
1502
1503 /* A valid insn to copy VAR into or out of a register
1504 must be left alone, to avoid an infinite loop here.
1505 If the reference to VAR is by a subreg, fix that up,
1506 since SUBREG is not valid for a memref.
e15762df
RK
1507 Also fix up the address of the stack slot.
1508
1509 Note that we must not try to recognize the insn until
1510 after we know that we have valid addresses and no
1511 (subreg (mem ...) ...) constructs, since these interfere
1512 with determining the validity of the insn. */
6f086dfc
RS
1513
1514 if ((SET_SRC (x) == var
1515 || (GET_CODE (SET_SRC (x)) == SUBREG
1516 && SUBREG_REG (SET_SRC (x)) == var))
1517 && (GET_CODE (SET_DEST (x)) == REG
1518 || (GET_CODE (SET_DEST (x)) == SUBREG
1519 && GET_CODE (SUBREG_REG (SET_DEST (x))) == REG))
e15762df 1520 && x == single_set (PATTERN (insn)))
6f086dfc 1521 {
e15762df
RK
1522 rtx pat;
1523
2740a678 1524 replacement = find_fixup_replacement (replacements, SET_SRC (x));
6f086dfc 1525 if (replacement->new)
6f086dfc 1526 SET_SRC (x) = replacement->new;
6f086dfc
RS
1527 else if (GET_CODE (SET_SRC (x)) == SUBREG)
1528 SET_SRC (x) = replacement->new
1529 = fixup_memory_subreg (SET_SRC (x), insn, 0);
1530 else
1531 SET_SRC (x) = replacement->new
1532 = fixup_stack_1 (SET_SRC (x), insn);
e15762df
RK
1533
1534 if (recog_memoized (insn) >= 0)
1535 return;
1536
1537 /* INSN is not valid, but we know that we want to
1538 copy SET_SRC (x) to SET_DEST (x) in some way. So
1539 we generate the move and see whether it requires more
1540 than one insn. If it does, we emit those insns and
1541 delete INSN. Otherwise, we an just replace the pattern
1542 of INSN; we have already verified above that INSN has
1543 no other function that to do X. */
1544
1545 pat = gen_move_insn (SET_DEST (x), SET_SRC (x));
1546 if (GET_CODE (pat) == SEQUENCE)
1547 {
1548 emit_insn_after (pat, insn);
1549 PUT_CODE (insn, NOTE);
1550 NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
1551 NOTE_SOURCE_FILE (insn) = 0;
1552 }
1553 else
1554 PATTERN (insn) = pat;
1555
6f086dfc
RS
1556 return;
1557 }
1558
1559 if ((SET_DEST (x) == var
1560 || (GET_CODE (SET_DEST (x)) == SUBREG
1561 && SUBREG_REG (SET_DEST (x)) == var))
1562 && (GET_CODE (SET_SRC (x)) == REG
1563 || (GET_CODE (SET_SRC (x)) == SUBREG
1564 && GET_CODE (SUBREG_REG (SET_SRC (x))) == REG))
e15762df 1565 && x == single_set (PATTERN (insn)))
6f086dfc 1566 {
e15762df
RK
1567 rtx pat;
1568
6f086dfc
RS
1569 if (GET_CODE (SET_DEST (x)) == SUBREG)
1570 SET_DEST (x) = fixup_memory_subreg (SET_DEST (x), insn, 0);
1571 else
1572 SET_DEST (x) = fixup_stack_1 (SET_DEST (x), insn);
e15762df
RK
1573
1574 if (recog_memoized (insn) >= 0)
1575 return;
1576
1577 pat = gen_move_insn (SET_DEST (x), SET_SRC (x));
1578 if (GET_CODE (pat) == SEQUENCE)
1579 {
1580 emit_insn_after (pat, insn);
1581 PUT_CODE (insn, NOTE);
1582 NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
1583 NOTE_SOURCE_FILE (insn) = 0;
1584 }
1585 else
1586 PATTERN (insn) = pat;
1587
6f086dfc
RS
1588 return;
1589 }
1590
1591 /* Otherwise, storing into VAR must be handled specially
1592 by storing into a temporary and copying that into VAR
00d8a4c1
RK
1593 with a new insn after this one. Note that this case
1594 will be used when storing into a promoted scalar since
1595 the insn will now have different modes on the input
1596 and output and hence will be invalid (except for the case
1597 of setting it to a constant, which does not need any
1598 change if it is valid). We generate extra code in that case,
1599 but combine.c will eliminate it. */
6f086dfc
RS
1600
1601 if (dest == var)
1602 {
1603 rtx temp;
00d8a4c1
RK
1604 rtx fixeddest = SET_DEST (x);
1605
6f086dfc 1606 /* STRICT_LOW_PART can be discarded, around a MEM. */
00d8a4c1
RK
1607 if (GET_CODE (fixeddest) == STRICT_LOW_PART)
1608 fixeddest = XEXP (fixeddest, 0);
6f086dfc 1609 /* Convert (SUBREG (MEM)) to a MEM in a changed mode. */
00d8a4c1
RK
1610 if (GET_CODE (fixeddest) == SUBREG)
1611 fixeddest = fixup_memory_subreg (fixeddest, insn, 0);
6f086dfc 1612 else
00d8a4c1
RK
1613 fixeddest = fixup_stack_1 (fixeddest, insn);
1614
1615 temp = gen_reg_rtx (GET_MODE (SET_SRC (x)) == VOIDmode
1616 ? GET_MODE (fixeddest)
1617 : GET_MODE (SET_SRC (x)));
1618
1619 emit_insn_after (gen_move_insn (fixeddest,
1620 gen_lowpart (GET_MODE (fixeddest),
1621 temp)),
1622 insn);
6f086dfc 1623
6f086dfc
RS
1624 SET_DEST (x) = temp;
1625 }
1626 }
1627 }
1628
1629 /* Nothing special about this RTX; fix its operands. */
1630
1631 fmt = GET_RTX_FORMAT (code);
1632 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
1633 {
1634 if (fmt[i] == 'e')
00d8a4c1 1635 fixup_var_refs_1 (var, promoted_mode, &XEXP (x, i), insn, replacements);
6f086dfc
RS
1636 if (fmt[i] == 'E')
1637 {
1638 register int j;
1639 for (j = 0; j < XVECLEN (x, i); j++)
00d8a4c1
RK
1640 fixup_var_refs_1 (var, promoted_mode, &XVECEXP (x, i, j),
1641 insn, replacements);
6f086dfc
RS
1642 }
1643 }
1644}
1645\f
1646/* Given X, an rtx of the form (SUBREG:m1 (MEM:m2 addr)),
1647 return an rtx (MEM:m1 newaddr) which is equivalent.
1648 If any insns must be emitted to compute NEWADDR, put them before INSN.
1649
1650 UNCRITICAL nonzero means accept paradoxical subregs.
1651 This is used for subregs found inside of ZERO_EXTRACTs. */
1652
1653static rtx
1654fixup_memory_subreg (x, insn, uncritical)
1655 rtx x;
1656 rtx insn;
1657 int uncritical;
1658{
1659 int offset = SUBREG_WORD (x) * UNITS_PER_WORD;
1660 rtx addr = XEXP (SUBREG_REG (x), 0);
1661 enum machine_mode mode = GET_MODE (x);
1662 rtx saved, result;
1663
1664 /* Paradoxical SUBREGs are usually invalid during RTL generation. */
1665 if (GET_MODE_SIZE (mode) > GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)))
1666 && ! uncritical)
1667 abort ();
1668
1669#if BYTES_BIG_ENDIAN
1670 offset += (MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))))
1671 - MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode)));
1672#endif
1673 addr = plus_constant (addr, offset);
1674 if (!flag_force_addr && memory_address_p (mode, addr))
1675 /* Shortcut if no insns need be emitted. */
1676 return change_address (SUBREG_REG (x), mode, addr);
1677 start_sequence ();
1678 result = change_address (SUBREG_REG (x), mode, addr);
1679 emit_insn_before (gen_sequence (), insn);
1680 end_sequence ();
1681 return result;
1682}
1683
1684/* Do fixup_memory_subreg on all (SUBREG (MEM ...) ...) contained in X.
1685 Replace subexpressions of X in place.
1686 If X itself is a (SUBREG (MEM ...) ...), return the replacement expression.
1687 Otherwise return X, with its contents possibly altered.
1688
1689 If any insns must be emitted to compute NEWADDR, put them before INSN. */
1690
1691static rtx
1692walk_fixup_memory_subreg (x, insn)
1693 register rtx x;
1694 rtx insn;
1695{
1696 register enum rtx_code code;
1697 register char *fmt;
1698 register int i;
1699
1700 if (x == 0)
1701 return 0;
1702
1703 code = GET_CODE (x);
1704
1705 if (code == SUBREG && GET_CODE (SUBREG_REG (x)) == MEM)
1706 return fixup_memory_subreg (x, insn, 0);
1707
1708 /* Nothing special about this RTX; fix its operands. */
1709
1710 fmt = GET_RTX_FORMAT (code);
1711 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
1712 {
1713 if (fmt[i] == 'e')
1714 XEXP (x, i) = walk_fixup_memory_subreg (XEXP (x, i), insn);
1715 if (fmt[i] == 'E')
1716 {
1717 register int j;
1718 for (j = 0; j < XVECLEN (x, i); j++)
1719 XVECEXP (x, i, j)
1720 = walk_fixup_memory_subreg (XVECEXP (x, i, j), insn);
1721 }
1722 }
1723 return x;
1724}
1725\f
1726#if 0
1727/* Fix up any references to stack slots that are invalid memory addresses
1728 because they exceed the maximum range of a displacement. */
1729
1730void
1731fixup_stack_slots ()
1732{
1733 register rtx insn;
1734
1735 /* Did we generate a stack slot that is out of range
1736 or otherwise has an invalid address? */
1737 if (invalid_stack_slot)
1738 {
1739 /* Yes. Must scan all insns for stack-refs that exceed the limit. */
1740 for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
1741 if (GET_CODE (insn) == INSN || GET_CODE (insn) == CALL_INSN
1742 || GET_CODE (insn) == JUMP_INSN)
1743 fixup_stack_1 (PATTERN (insn), insn);
1744 }
1745}
1746#endif
1747
1748/* For each memory ref within X, if it refers to a stack slot
1749 with an out of range displacement, put the address in a temp register
1750 (emitting new insns before INSN to load these registers)
1751 and alter the memory ref to use that register.
1752 Replace each such MEM rtx with a copy, to avoid clobberage. */
1753
1754static rtx
1755fixup_stack_1 (x, insn)
1756 rtx x;
1757 rtx insn;
1758{
1759 register int i;
1760 register RTX_CODE code = GET_CODE (x);
1761 register char *fmt;
1762
1763 if (code == MEM)
1764 {
1765 register rtx ad = XEXP (x, 0);
1766 /* If we have address of a stack slot but it's not valid
1767 (displacement is too large), compute the sum in a register. */
1768 if (GET_CODE (ad) == PLUS
1769 && GET_CODE (XEXP (ad, 0)) == REG
1770 && REGNO (XEXP (ad, 0)) >= FIRST_VIRTUAL_REGISTER
1771 && REGNO (XEXP (ad, 0)) <= LAST_VIRTUAL_REGISTER
1772 && GET_CODE (XEXP (ad, 1)) == CONST_INT)
1773 {
1774 rtx temp, seq;
1775 if (memory_address_p (GET_MODE (x), ad))
1776 return x;
1777
1778 start_sequence ();
1779 temp = copy_to_reg (ad);
1780 seq = gen_sequence ();
1781 end_sequence ();
1782 emit_insn_before (seq, insn);
1783 return change_address (x, VOIDmode, temp);
1784 }
1785 return x;
1786 }
1787
1788 fmt = GET_RTX_FORMAT (code);
1789 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
1790 {
1791 if (fmt[i] == 'e')
1792 XEXP (x, i) = fixup_stack_1 (XEXP (x, i), insn);
1793 if (fmt[i] == 'E')
1794 {
1795 register int j;
1796 for (j = 0; j < XVECLEN (x, i); j++)
1797 XVECEXP (x, i, j) = fixup_stack_1 (XVECEXP (x, i, j), insn);
1798 }
1799 }
1800 return x;
1801}
1802\f
1803/* Optimization: a bit-field instruction whose field
1804 happens to be a byte or halfword in memory
1805 can be changed to a move instruction.
1806
1807 We call here when INSN is an insn to examine or store into a bit-field.
1808 BODY is the SET-rtx to be altered.
1809
1810 EQUIV_MEM is the table `reg_equiv_mem' if that is available; else 0.
1811 (Currently this is called only from function.c, and EQUIV_MEM
1812 is always 0.) */
1813
1814static void
1815optimize_bit_field (body, insn, equiv_mem)
1816 rtx body;
1817 rtx insn;
1818 rtx *equiv_mem;
1819{
1820 register rtx bitfield;
1821 int destflag;
1822 rtx seq = 0;
1823 enum machine_mode mode;
1824
1825 if (GET_CODE (SET_DEST (body)) == SIGN_EXTRACT
1826 || GET_CODE (SET_DEST (body)) == ZERO_EXTRACT)
1827 bitfield = SET_DEST (body), destflag = 1;
1828 else
1829 bitfield = SET_SRC (body), destflag = 0;
1830
1831 /* First check that the field being stored has constant size and position
1832 and is in fact a byte or halfword suitably aligned. */
1833
1834 if (GET_CODE (XEXP (bitfield, 1)) == CONST_INT
1835 && GET_CODE (XEXP (bitfield, 2)) == CONST_INT
1836 && ((mode = mode_for_size (INTVAL (XEXP (bitfield, 1)), MODE_INT, 1))
1837 != BLKmode)
1838 && INTVAL (XEXP (bitfield, 2)) % INTVAL (XEXP (bitfield, 1)) == 0)
1839 {
1840 register rtx memref = 0;
1841
1842 /* Now check that the containing word is memory, not a register,
1843 and that it is safe to change the machine mode. */
1844
1845 if (GET_CODE (XEXP (bitfield, 0)) == MEM)
1846 memref = XEXP (bitfield, 0);
1847 else if (GET_CODE (XEXP (bitfield, 0)) == REG
1848 && equiv_mem != 0)
1849 memref = equiv_mem[REGNO (XEXP (bitfield, 0))];
1850 else if (GET_CODE (XEXP (bitfield, 0)) == SUBREG
1851 && GET_CODE (SUBREG_REG (XEXP (bitfield, 0))) == MEM)
1852 memref = SUBREG_REG (XEXP (bitfield, 0));
1853 else if (GET_CODE (XEXP (bitfield, 0)) == SUBREG
1854 && equiv_mem != 0
1855 && GET_CODE (SUBREG_REG (XEXP (bitfield, 0))) == REG)
1856 memref = equiv_mem[REGNO (SUBREG_REG (XEXP (bitfield, 0)))];
1857
1858 if (memref
1859 && ! mode_dependent_address_p (XEXP (memref, 0))
1860 && ! MEM_VOLATILE_P (memref))
1861 {
1862 /* Now adjust the address, first for any subreg'ing
1863 that we are now getting rid of,
1864 and then for which byte of the word is wanted. */
1865
1866 register int offset = INTVAL (XEXP (bitfield, 2));
1867 /* Adjust OFFSET to count bits from low-address byte. */
1868#if BITS_BIG_ENDIAN != BYTES_BIG_ENDIAN
1869 offset = (GET_MODE_BITSIZE (GET_MODE (XEXP (bitfield, 0)))
1870 - offset - INTVAL (XEXP (bitfield, 1)));
1871#endif
1872 /* Adjust OFFSET to count bytes from low-address byte. */
1873 offset /= BITS_PER_UNIT;
1874 if (GET_CODE (XEXP (bitfield, 0)) == SUBREG)
1875 {
1876 offset += SUBREG_WORD (XEXP (bitfield, 0)) * UNITS_PER_WORD;
1877#if BYTES_BIG_ENDIAN
1878 offset -= (MIN (UNITS_PER_WORD,
1879 GET_MODE_SIZE (GET_MODE (XEXP (bitfield, 0))))
1880 - MIN (UNITS_PER_WORD,
1881 GET_MODE_SIZE (GET_MODE (memref))));
1882#endif
1883 }
1884
1885 memref = change_address (memref, mode,
1886 plus_constant (XEXP (memref, 0), offset));
1887
1888 /* Store this memory reference where
1889 we found the bit field reference. */
1890
1891 if (destflag)
1892 {
1893 validate_change (insn, &SET_DEST (body), memref, 1);
1894 if (! CONSTANT_ADDRESS_P (SET_SRC (body)))
1895 {
1896 rtx src = SET_SRC (body);
1897 while (GET_CODE (src) == SUBREG
1898 && SUBREG_WORD (src) == 0)
1899 src = SUBREG_REG (src);
1900 if (GET_MODE (src) != GET_MODE (memref))
1901 src = gen_lowpart (GET_MODE (memref), SET_SRC (body));
1902 validate_change (insn, &SET_SRC (body), src, 1);
1903 }
1904 else if (GET_MODE (SET_SRC (body)) != VOIDmode
1905 && GET_MODE (SET_SRC (body)) != GET_MODE (memref))
1906 /* This shouldn't happen because anything that didn't have
1907 one of these modes should have got converted explicitly
1908 and then referenced through a subreg.
1909 This is so because the original bit-field was
1910 handled by agg_mode and so its tree structure had
1911 the same mode that memref now has. */
1912 abort ();
1913 }
1914 else
1915 {
1916 rtx dest = SET_DEST (body);
1917
1918 while (GET_CODE (dest) == SUBREG
1919 && SUBREG_WORD (dest) == 0)
1920 dest = SUBREG_REG (dest);
1921
1922 validate_change (insn, &SET_DEST (body), dest, 1);
1923
1924 if (GET_MODE (dest) == GET_MODE (memref))
1925 validate_change (insn, &SET_SRC (body), memref, 1);
1926 else
1927 {
1928 /* Convert the mem ref to the destination mode. */
1929 rtx newreg = gen_reg_rtx (GET_MODE (dest));
1930
1931 start_sequence ();
1932 convert_move (newreg, memref,
1933 GET_CODE (SET_SRC (body)) == ZERO_EXTRACT);
1934 seq = get_insns ();
1935 end_sequence ();
1936
1937 validate_change (insn, &SET_SRC (body), newreg, 1);
1938 }
1939 }
1940
1941 /* See if we can convert this extraction or insertion into
1942 a simple move insn. We might not be able to do so if this
1943 was, for example, part of a PARALLEL.
1944
1945 If we succeed, write out any needed conversions. If we fail,
1946 it is hard to guess why we failed, so don't do anything
1947 special; just let the optimization be suppressed. */
1948
1949 if (apply_change_group () && seq)
1950 emit_insns_before (seq, insn);
1951 }
1952 }
1953}
1954\f
1955/* These routines are responsible for converting virtual register references
1956 to the actual hard register references once RTL generation is complete.
1957
1958 The following four variables are used for communication between the
1959 routines. They contain the offsets of the virtual registers from their
1960 respective hard registers. */
1961
1962static int in_arg_offset;
1963static int var_offset;
1964static int dynamic_offset;
1965static int out_arg_offset;
1966
1967/* In most machines, the stack pointer register is equivalent to the bottom
1968 of the stack. */
1969
1970#ifndef STACK_POINTER_OFFSET
1971#define STACK_POINTER_OFFSET 0
1972#endif
1973
1974/* If not defined, pick an appropriate default for the offset of dynamically
1975 allocated memory depending on the value of ACCUMULATE_OUTGOING_ARGS,
1976 REG_PARM_STACK_SPACE, and OUTGOING_REG_PARM_STACK_SPACE. */
1977
1978#ifndef STACK_DYNAMIC_OFFSET
1979
1980#ifdef ACCUMULATE_OUTGOING_ARGS
1981/* The bottom of the stack points to the actual arguments. If
1982 REG_PARM_STACK_SPACE is defined, this includes the space for the register
1983 parameters. However, if OUTGOING_REG_PARM_STACK space is not defined,
1984 stack space for register parameters is not pushed by the caller, but
1985 rather part of the fixed stack areas and hence not included in
1986 `current_function_outgoing_args_size'. Nevertheless, we must allow
1987 for it when allocating stack dynamic objects. */
1988
1989#if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
1990#define STACK_DYNAMIC_OFFSET(FNDECL) \
1991(current_function_outgoing_args_size \
1992 + REG_PARM_STACK_SPACE (FNDECL) + (STACK_POINTER_OFFSET))
1993
1994#else
1995#define STACK_DYNAMIC_OFFSET(FNDECL) \
1996(current_function_outgoing_args_size + (STACK_POINTER_OFFSET))
1997#endif
1998
1999#else
2000#define STACK_DYNAMIC_OFFSET(FNDECL) STACK_POINTER_OFFSET
2001#endif
2002#endif
2003
2004/* Pass through the INSNS of function FNDECL and convert virtual register
2005 references to hard register references. */
2006
2007void
2008instantiate_virtual_regs (fndecl, insns)
2009 tree fndecl;
2010 rtx insns;
2011{
2012 rtx insn;
2013
2014 /* Compute the offsets to use for this function. */
2015 in_arg_offset = FIRST_PARM_OFFSET (fndecl);
2016 var_offset = STARTING_FRAME_OFFSET;
2017 dynamic_offset = STACK_DYNAMIC_OFFSET (fndecl);
2018 out_arg_offset = STACK_POINTER_OFFSET;
2019
2020 /* Scan all variables and parameters of this function. For each that is
2021 in memory, instantiate all virtual registers if the result is a valid
2022 address. If not, we do it later. That will handle most uses of virtual
2023 regs on many machines. */
2024 instantiate_decls (fndecl, 1);
2025
2026 /* Initialize recognition, indicating that volatile is OK. */
2027 init_recog ();
2028
2029 /* Scan through all the insns, instantiating every virtual register still
2030 present. */
2031 for (insn = insns; insn; insn = NEXT_INSN (insn))
2032 if (GET_CODE (insn) == INSN || GET_CODE (insn) == JUMP_INSN
2033 || GET_CODE (insn) == CALL_INSN)
2034 {
2035 instantiate_virtual_regs_1 (&PATTERN (insn), insn, 1);
5f4f0e22 2036 instantiate_virtual_regs_1 (&REG_NOTES (insn), NULL_RTX, 0);
6f086dfc
RS
2037 }
2038
2039 /* Now instantiate the remaining register equivalences for debugging info.
2040 These will not be valid addresses. */
2041 instantiate_decls (fndecl, 0);
2042
2043 /* Indicate that, from now on, assign_stack_local should use
2044 frame_pointer_rtx. */
2045 virtuals_instantiated = 1;
2046}
2047
2048/* Scan all decls in FNDECL (both variables and parameters) and instantiate
2049 all virtual registers in their DECL_RTL's.
2050
2051 If VALID_ONLY, do this only if the resulting address is still valid.
2052 Otherwise, always do it. */
2053
2054static void
2055instantiate_decls (fndecl, valid_only)
2056 tree fndecl;
2057 int valid_only;
2058{
2059 tree decl;
2060
a82ad570 2061 if (DECL_INLINE (fndecl))
6f086dfc
RS
2062 /* When compiling an inline function, the obstack used for
2063 rtl allocation is the maybepermanent_obstack. Calling
2064 `resume_temporary_allocation' switches us back to that
2065 obstack while we process this function's parameters. */
2066 resume_temporary_allocation ();
2067
2068 /* Process all parameters of the function. */
2069 for (decl = DECL_ARGUMENTS (fndecl); decl; decl = TREE_CHAIN (decl))
2070 {
5a73491b
RK
2071 instantiate_decl (DECL_RTL (decl), int_size_in_bytes (TREE_TYPE (decl)),
2072 valid_only);
2073 instantiate_decl (DECL_INCOMING_RTL (decl),
2074 int_size_in_bytes (TREE_TYPE (decl)), valid_only);
6f086dfc
RS
2075 }
2076
2077 /* Now process all variables defined in the function or its subblocks. */
2078 instantiate_decls_1 (DECL_INITIAL (fndecl), valid_only);
2079
a82ad570 2080 if (DECL_INLINE (fndecl))
6f086dfc
RS
2081 {
2082 /* Save all rtl allocated for this function by raising the
2083 high-water mark on the maybepermanent_obstack. */
2084 preserve_data ();
2085 /* All further rtl allocation is now done in the current_obstack. */
2086 rtl_in_current_obstack ();
2087 }
2088}
2089
2090/* Subroutine of instantiate_decls: Process all decls in the given
2091 BLOCK node and all its subblocks. */
2092
2093static void
2094instantiate_decls_1 (let, valid_only)
2095 tree let;
2096 int valid_only;
2097{
2098 tree t;
2099
2100 for (t = BLOCK_VARS (let); t; t = TREE_CHAIN (t))
5a73491b
RK
2101 instantiate_decl (DECL_RTL (t), int_size_in_bytes (TREE_TYPE (t)),
2102 valid_only);
6f086dfc
RS
2103
2104 /* Process all subblocks. */
2105 for (t = BLOCK_SUBBLOCKS (let); t; t = TREE_CHAIN (t))
2106 instantiate_decls_1 (t, valid_only);
2107}
5a73491b 2108
8008b228 2109/* Subroutine of the preceding procedures: Given RTL representing a
5a73491b
RK
2110 decl and the size of the object, do any instantiation required.
2111
2112 If VALID_ONLY is non-zero, it means that the RTL should only be
2113 changed if the new address is valid. */
2114
2115static void
2116instantiate_decl (x, size, valid_only)
2117 rtx x;
2118 int size;
2119 int valid_only;
2120{
2121 enum machine_mode mode;
2122 rtx addr;
2123
2124 /* If this is not a MEM, no need to do anything. Similarly if the
2125 address is a constant or a register that is not a virtual register. */
2126
2127 if (x == 0 || GET_CODE (x) != MEM)
2128 return;
2129
2130 addr = XEXP (x, 0);
2131 if (CONSTANT_P (addr)
2132 || (GET_CODE (addr) == REG
2133 && (REGNO (addr) < FIRST_VIRTUAL_REGISTER
2134 || REGNO (addr) > LAST_VIRTUAL_REGISTER)))
2135 return;
2136
2137 /* If we should only do this if the address is valid, copy the address.
2138 We need to do this so we can undo any changes that might make the
2139 address invalid. This copy is unfortunate, but probably can't be
2140 avoided. */
2141
2142 if (valid_only)
2143 addr = copy_rtx (addr);
2144
2145 instantiate_virtual_regs_1 (&addr, NULL_RTX, 0);
2146
2147 if (! valid_only)
2148 return;
2149
2150 /* Now verify that the resulting address is valid for every integer or
2151 floating-point mode up to and including SIZE bytes long. We do this
2152 since the object might be accessed in any mode and frame addresses
2153 are shared. */
2154
2155 for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT);
2156 mode != VOIDmode && GET_MODE_SIZE (mode) <= size;
2157 mode = GET_MODE_WIDER_MODE (mode))
2158 if (! memory_address_p (mode, addr))
2159 return;
2160
2161 for (mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT);
2162 mode != VOIDmode && GET_MODE_SIZE (mode) <= size;
2163 mode = GET_MODE_WIDER_MODE (mode))
2164 if (! memory_address_p (mode, addr))
2165 return;
2166
2167 /* Otherwise, put back the address, now that we have updated it and we
2168 know it is valid. */
2169
2170 XEXP (x, 0) = addr;
2171}
6f086dfc
RS
2172\f
2173/* Given a pointer to a piece of rtx and an optional pointer to the
2174 containing object, instantiate any virtual registers present in it.
2175
2176 If EXTRA_INSNS, we always do the replacement and generate
2177 any extra insns before OBJECT. If it zero, we do nothing if replacement
2178 is not valid.
2179
2180 Return 1 if we either had nothing to do or if we were able to do the
2181 needed replacement. Return 0 otherwise; we only return zero if
2182 EXTRA_INSNS is zero.
2183
2184 We first try some simple transformations to avoid the creation of extra
2185 pseudos. */
2186
2187static int
2188instantiate_virtual_regs_1 (loc, object, extra_insns)
2189 rtx *loc;
2190 rtx object;
2191 int extra_insns;
2192{
2193 rtx x;
2194 RTX_CODE code;
2195 rtx new = 0;
2196 int offset;
2197 rtx temp;
2198 rtx seq;
2199 int i, j;
2200 char *fmt;
2201
2202 /* Re-start here to avoid recursion in common cases. */
2203 restart:
2204
2205 x = *loc;
2206 if (x == 0)
2207 return 1;
2208
2209 code = GET_CODE (x);
2210
2211 /* Check for some special cases. */
2212 switch (code)
2213 {
2214 case CONST_INT:
2215 case CONST_DOUBLE:
2216 case CONST:
2217 case SYMBOL_REF:
2218 case CODE_LABEL:
2219 case PC:
2220 case CC0:
2221 case ASM_INPUT:
2222 case ADDR_VEC:
2223 case ADDR_DIFF_VEC:
2224 case RETURN:
2225 return 1;
2226
2227 case SET:
2228 /* We are allowed to set the virtual registers. This means that
2229 that the actual register should receive the source minus the
2230 appropriate offset. This is used, for example, in the handling
2231 of non-local gotos. */
2232 if (SET_DEST (x) == virtual_incoming_args_rtx)
2233 new = arg_pointer_rtx, offset = - in_arg_offset;
2234 else if (SET_DEST (x) == virtual_stack_vars_rtx)
2235 new = frame_pointer_rtx, offset = - var_offset;
2236 else if (SET_DEST (x) == virtual_stack_dynamic_rtx)
2237 new = stack_pointer_rtx, offset = - dynamic_offset;
2238 else if (SET_DEST (x) == virtual_outgoing_args_rtx)
2239 new = stack_pointer_rtx, offset = - out_arg_offset;
2240
2241 if (new)
2242 {
2243 /* The only valid sources here are PLUS or REG. Just do
2244 the simplest possible thing to handle them. */
2245 if (GET_CODE (SET_SRC (x)) != REG
2246 && GET_CODE (SET_SRC (x)) != PLUS)
2247 abort ();
2248
2249 start_sequence ();
2250 if (GET_CODE (SET_SRC (x)) != REG)
5f4f0e22 2251 temp = force_operand (SET_SRC (x), NULL_RTX);
6f086dfc
RS
2252 else
2253 temp = SET_SRC (x);
5f4f0e22 2254 temp = force_operand (plus_constant (temp, offset), NULL_RTX);
6f086dfc
RS
2255 seq = get_insns ();
2256 end_sequence ();
2257
2258 emit_insns_before (seq, object);
2259 SET_DEST (x) = new;
2260
2261 if (!validate_change (object, &SET_SRC (x), temp, 0)
2262 || ! extra_insns)
2263 abort ();
2264
2265 return 1;
2266 }
2267
2268 instantiate_virtual_regs_1 (&SET_DEST (x), object, extra_insns);
2269 loc = &SET_SRC (x);
2270 goto restart;
2271
2272 case PLUS:
2273 /* Handle special case of virtual register plus constant. */
2274 if (CONSTANT_P (XEXP (x, 1)))
2275 {
2276 rtx old;
2277
2278 /* Check for (plus (plus VIRT foo) (const_int)) first. */
2279 if (GET_CODE (XEXP (x, 0)) == PLUS)
2280 {
2281 rtx inner = XEXP (XEXP (x, 0), 0);
2282
2283 if (inner == virtual_incoming_args_rtx)
2284 new = arg_pointer_rtx, offset = in_arg_offset;
2285 else if (inner == virtual_stack_vars_rtx)
2286 new = frame_pointer_rtx, offset = var_offset;
2287 else if (inner == virtual_stack_dynamic_rtx)
2288 new = stack_pointer_rtx, offset = dynamic_offset;
2289 else if (inner == virtual_outgoing_args_rtx)
2290 new = stack_pointer_rtx, offset = out_arg_offset;
2291 else
2292 {
2293 loc = &XEXP (x, 0);
2294 goto restart;
2295 }
2296
2297 instantiate_virtual_regs_1 (&XEXP (XEXP (x, 0), 1), object,
2298 extra_insns);
2299 new = gen_rtx (PLUS, Pmode, new, XEXP (XEXP (x, 0), 1));
2300 }
2301
2302 else if (XEXP (x, 0) == virtual_incoming_args_rtx)
2303 new = arg_pointer_rtx, offset = in_arg_offset;
2304 else if (XEXP (x, 0) == virtual_stack_vars_rtx)
2305 new = frame_pointer_rtx, offset = var_offset;
2306 else if (XEXP (x, 0) == virtual_stack_dynamic_rtx)
2307 new = stack_pointer_rtx, offset = dynamic_offset;
2308 else if (XEXP (x, 0) == virtual_outgoing_args_rtx)
2309 new = stack_pointer_rtx, offset = out_arg_offset;
2310 else
2311 {
2312 /* We know the second operand is a constant. Unless the
2313 first operand is a REG (which has been already checked),
2314 it needs to be checked. */
2315 if (GET_CODE (XEXP (x, 0)) != REG)
2316 {
2317 loc = &XEXP (x, 0);
2318 goto restart;
2319 }
2320 return 1;
2321 }
2322
2323 old = XEXP (x, 0);
2324 XEXP (x, 0) = new;
2325 new = plus_constant (XEXP (x, 1), offset);
2326
2327 /* If the new constant is zero, try to replace the sum with its
2328 first operand. */
2329 if (new == const0_rtx
2330 && validate_change (object, loc, XEXP (x, 0), 0))
2331 return 1;
2332
2333 /* Next try to replace constant with new one. */
2334 if (!validate_change (object, &XEXP (x, 1), new, 0))
2335 {
2336 if (! extra_insns)
2337 {
2338 XEXP (x, 0) = old;
2339 return 0;
2340 }
2341
2342 /* Otherwise copy the new constant into a register and replace
2343 constant with that register. */
2344 temp = gen_reg_rtx (Pmode);
2345 if (validate_change (object, &XEXP (x, 1), temp, 0))
2346 emit_insn_before (gen_move_insn (temp, new), object);
2347 else
2348 {
2349 /* If that didn't work, replace this expression with a
2350 register containing the sum. */
2351
2352 new = gen_rtx (PLUS, Pmode, XEXP (x, 0), new);
2353 XEXP (x, 0) = old;
2354
2355 start_sequence ();
5f4f0e22 2356 temp = force_operand (new, NULL_RTX);
6f086dfc
RS
2357 seq = get_insns ();
2358 end_sequence ();
2359
2360 emit_insns_before (seq, object);
2361 if (! validate_change (object, loc, temp, 0)
2362 && ! validate_replace_rtx (x, temp, object))
2363 abort ();
2364 }
2365 }
2366
2367 return 1;
2368 }
2369
2370 /* Fall through to generic two-operand expression case. */
2371 case EXPR_LIST:
2372 case CALL:
2373 case COMPARE:
2374 case MINUS:
2375 case MULT:
2376 case DIV: case UDIV:
2377 case MOD: case UMOD:
2378 case AND: case IOR: case XOR:
2379 case LSHIFT: case ASHIFT: case ROTATE:
2380 case ASHIFTRT: case LSHIFTRT: case ROTATERT:
2381 case NE: case EQ:
2382 case GE: case GT: case GEU: case GTU:
2383 case LE: case LT: case LEU: case LTU:
2384 if (XEXP (x, 1) && ! CONSTANT_P (XEXP (x, 1)))
2385 instantiate_virtual_regs_1 (&XEXP (x, 1), object, extra_insns);
2386 loc = &XEXP (x, 0);
2387 goto restart;
2388
2389 case MEM:
2390 /* Most cases of MEM that convert to valid addresses have already been
2391 handled by our scan of regno_reg_rtx. The only special handling we
2392 need here is to make a copy of the rtx to ensure it isn't being
b335c2cc 2393 shared if we have to change it to a pseudo.
6f086dfc
RS
2394
2395 If the rtx is a simple reference to an address via a virtual register,
2396 it can potentially be shared. In such cases, first try to make it
2397 a valid address, which can also be shared. Otherwise, copy it and
2398 proceed normally.
2399
2400 First check for common cases that need no processing. These are
2401 usually due to instantiation already being done on a previous instance
2402 of a shared rtx. */
2403
2404 temp = XEXP (x, 0);
2405 if (CONSTANT_ADDRESS_P (temp)
2406#if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
2407 || temp == arg_pointer_rtx
2408#endif
2409 || temp == frame_pointer_rtx)
2410 return 1;
2411
2412 if (GET_CODE (temp) == PLUS
2413 && CONSTANT_ADDRESS_P (XEXP (temp, 1))
2414 && (XEXP (temp, 0) == frame_pointer_rtx
2415#if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
2416 || XEXP (temp, 0) == arg_pointer_rtx
2417#endif
2418 ))
2419 return 1;
2420
2421 if (temp == virtual_stack_vars_rtx
2422 || temp == virtual_incoming_args_rtx
2423 || (GET_CODE (temp) == PLUS
2424 && CONSTANT_ADDRESS_P (XEXP (temp, 1))
2425 && (XEXP (temp, 0) == virtual_stack_vars_rtx
2426 || XEXP (temp, 0) == virtual_incoming_args_rtx)))
2427 {
2428 /* This MEM may be shared. If the substitution can be done without
2429 the need to generate new pseudos, we want to do it in place
2430 so all copies of the shared rtx benefit. The call below will
2431 only make substitutions if the resulting address is still
2432 valid.
2433
2434 Note that we cannot pass X as the object in the recursive call
2435 since the insn being processed may not allow all valid
6461be14
RS
2436 addresses. However, if we were not passed on object, we can
2437 only modify X without copying it if X will have a valid
2438 address.
6f086dfc 2439
6461be14
RS
2440 ??? Also note that this can still lose if OBJECT is an insn that
2441 has less restrictions on an address that some other insn.
2442 In that case, we will modify the shared address. This case
2443 doesn't seem very likely, though. */
2444
2445 if (instantiate_virtual_regs_1 (&XEXP (x, 0),
2446 object ? object : x, 0))
6f086dfc
RS
2447 return 1;
2448
2449 /* Otherwise make a copy and process that copy. We copy the entire
2450 RTL expression since it might be a PLUS which could also be
2451 shared. */
2452 *loc = x = copy_rtx (x);
2453 }
2454
2455 /* Fall through to generic unary operation case. */
2456 case USE:
2457 case CLOBBER:
2458 case SUBREG:
2459 case STRICT_LOW_PART:
2460 case NEG: case NOT:
2461 case PRE_DEC: case PRE_INC: case POST_DEC: case POST_INC:
2462 case SIGN_EXTEND: case ZERO_EXTEND:
2463 case TRUNCATE: case FLOAT_EXTEND: case FLOAT_TRUNCATE:
2464 case FLOAT: case FIX:
2465 case UNSIGNED_FIX: case UNSIGNED_FLOAT:
2466 case ABS:
2467 case SQRT:
2468 case FFS:
2469 /* These case either have just one operand or we know that we need not
2470 check the rest of the operands. */
2471 loc = &XEXP (x, 0);
2472 goto restart;
2473
2474 case REG:
2475 /* Try to replace with a PLUS. If that doesn't work, compute the sum
2476 in front of this insn and substitute the temporary. */
2477 if (x == virtual_incoming_args_rtx)
2478 new = arg_pointer_rtx, offset = in_arg_offset;
2479 else if (x == virtual_stack_vars_rtx)
2480 new = frame_pointer_rtx, offset = var_offset;
2481 else if (x == virtual_stack_dynamic_rtx)
2482 new = stack_pointer_rtx, offset = dynamic_offset;
2483 else if (x == virtual_outgoing_args_rtx)
2484 new = stack_pointer_rtx, offset = out_arg_offset;
2485
2486 if (new)
2487 {
2488 temp = plus_constant (new, offset);
2489 if (!validate_change (object, loc, temp, 0))
2490 {
2491 if (! extra_insns)
2492 return 0;
2493
2494 start_sequence ();
5f4f0e22 2495 temp = force_operand (temp, NULL_RTX);
6f086dfc
RS
2496 seq = get_insns ();
2497 end_sequence ();
2498
2499 emit_insns_before (seq, object);
2500 if (! validate_change (object, loc, temp, 0)
2501 && ! validate_replace_rtx (x, temp, object))
2502 abort ();
2503 }
2504 }
2505
2506 return 1;
2507 }
2508
2509 /* Scan all subexpressions. */
2510 fmt = GET_RTX_FORMAT (code);
2511 for (i = 0; i < GET_RTX_LENGTH (code); i++, fmt++)
2512 if (*fmt == 'e')
2513 {
2514 if (!instantiate_virtual_regs_1 (&XEXP (x, i), object, extra_insns))
2515 return 0;
2516 }
2517 else if (*fmt == 'E')
2518 for (j = 0; j < XVECLEN (x, i); j++)
2519 if (! instantiate_virtual_regs_1 (&XVECEXP (x, i, j), object,
2520 extra_insns))
2521 return 0;
2522
2523 return 1;
2524}
2525\f
2526/* Optimization: assuming this function does not receive nonlocal gotos,
2527 delete the handlers for such, as well as the insns to establish
2528 and disestablish them. */
2529
2530static void
2531delete_handlers ()
2532{
2533 rtx insn;
2534 for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
2535 {
2536 /* Delete the handler by turning off the flag that would
2537 prevent jump_optimize from deleting it.
2538 Also permit deletion of the nonlocal labels themselves
2539 if nothing local refers to them. */
2540 if (GET_CODE (insn) == CODE_LABEL)
2541 LABEL_PRESERVE_P (insn) = 0;
2542 if (GET_CODE (insn) == INSN
59257ff7
RK
2543 && ((nonlocal_goto_handler_slot != 0
2544 && reg_mentioned_p (nonlocal_goto_handler_slot, PATTERN (insn)))
2545 || (nonlocal_goto_stack_level != 0
2546 && reg_mentioned_p (nonlocal_goto_stack_level,
2547 PATTERN (insn)))))
6f086dfc
RS
2548 delete_insn (insn);
2549 }
2550}
2551
2552/* Return a list (chain of EXPR_LIST nodes) for the nonlocal labels
2553 of the current function. */
2554
2555rtx
2556nonlocal_label_rtx_list ()
2557{
2558 tree t;
2559 rtx x = 0;
2560
2561 for (t = nonlocal_labels; t; t = TREE_CHAIN (t))
2562 x = gen_rtx (EXPR_LIST, VOIDmode, label_rtx (TREE_VALUE (t)), x);
2563
2564 return x;
2565}
2566\f
2567/* Output a USE for any register use in RTL.
2568 This is used with -noreg to mark the extent of lifespan
2569 of any registers used in a user-visible variable's DECL_RTL. */
2570
2571void
2572use_variable (rtl)
2573 rtx rtl;
2574{
2575 if (GET_CODE (rtl) == REG)
2576 /* This is a register variable. */
2577 emit_insn (gen_rtx (USE, VOIDmode, rtl));
2578 else if (GET_CODE (rtl) == MEM
2579 && GET_CODE (XEXP (rtl, 0)) == REG
2580 && (REGNO (XEXP (rtl, 0)) < FIRST_VIRTUAL_REGISTER
2581 || REGNO (XEXP (rtl, 0)) > LAST_VIRTUAL_REGISTER)
2582 && XEXP (rtl, 0) != current_function_internal_arg_pointer)
2583 /* This is a variable-sized structure. */
2584 emit_insn (gen_rtx (USE, VOIDmode, XEXP (rtl, 0)));
2585}
2586
2587/* Like use_variable except that it outputs the USEs after INSN
2588 instead of at the end of the insn-chain. */
2589
2590void
2591use_variable_after (rtl, insn)
2592 rtx rtl, insn;
2593{
2594 if (GET_CODE (rtl) == REG)
2595 /* This is a register variable. */
2596 emit_insn_after (gen_rtx (USE, VOIDmode, rtl), insn);
2597 else if (GET_CODE (rtl) == MEM
2598 && GET_CODE (XEXP (rtl, 0)) == REG
2599 && (REGNO (XEXP (rtl, 0)) < FIRST_VIRTUAL_REGISTER
2600 || REGNO (XEXP (rtl, 0)) > LAST_VIRTUAL_REGISTER)
2601 && XEXP (rtl, 0) != current_function_internal_arg_pointer)
2602 /* This is a variable-sized structure. */
2603 emit_insn_after (gen_rtx (USE, VOIDmode, XEXP (rtl, 0)), insn);
2604}
2605\f
2606int
2607max_parm_reg_num ()
2608{
2609 return max_parm_reg;
2610}
2611
2612/* Return the first insn following those generated by `assign_parms'. */
2613
2614rtx
2615get_first_nonparm_insn ()
2616{
2617 if (last_parm_insn)
2618 return NEXT_INSN (last_parm_insn);
2619 return get_insns ();
2620}
2621
5378192b
RS
2622/* Return the first NOTE_INSN_BLOCK_BEG note in the function.
2623 Crash if there is none. */
2624
2625rtx
2626get_first_block_beg ()
2627{
2628 register rtx searcher;
2629 register rtx insn = get_first_nonparm_insn ();
2630
2631 for (searcher = insn; searcher; searcher = NEXT_INSN (searcher))
2632 if (GET_CODE (searcher) == NOTE
2633 && NOTE_LINE_NUMBER (searcher) == NOTE_INSN_BLOCK_BEG)
2634 return searcher;
2635
2636 abort (); /* Invalid call to this function. (See comments above.) */
2637 return NULL_RTX;
2638}
2639
6f086dfc
RS
2640/* Return 1 if EXP returns an aggregate value, for which an address
2641 must be passed to the function or returned by the function. */
2642
2643int
2644aggregate_value_p (exp)
2645 tree exp;
2646{
9d790a4f
RS
2647 int i, regno, nregs;
2648 rtx reg;
6f086dfc
RS
2649 if (RETURN_IN_MEMORY (TREE_TYPE (exp)))
2650 return 1;
2651 if (flag_pcc_struct_return
2652 && (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE
2653 || TREE_CODE (TREE_TYPE (exp)) == UNION_TYPE))
2654 return 1;
9d790a4f
RS
2655 /* Make sure we have suitable call-clobbered regs to return
2656 the value in; if not, we must return it in memory. */
2657 reg = hard_function_value (TREE_TYPE (exp), 0);
2658 regno = REGNO (reg);
2659 nregs = HARD_REGNO_NREGS (regno, TYPE_MODE (TREE_TYPE (exp)));
2660 for (i = 0; i < nregs; i++)
2661 if (! call_used_regs[regno + i])
2662 return 1;
6f086dfc
RS
2663 return 0;
2664}
2665\f
2666/* Assign RTL expressions to the function's parameters.
2667 This may involve copying them into registers and using
2668 those registers as the RTL for them.
2669
2670 If SECOND_TIME is non-zero it means that this function is being
2671 called a second time. This is done by integrate.c when a function's
2672 compilation is deferred. We need to come back here in case the
2673 FUNCTION_ARG macro computes items needed for the rest of the compilation
2674 (such as changing which registers are fixed or caller-saved). But suppress
2675 writing any insns or setting DECL_RTL of anything in this case. */
2676
2677void
2678assign_parms (fndecl, second_time)
2679 tree fndecl;
2680 int second_time;
2681{
2682 register tree parm;
2683 register rtx entry_parm = 0;
2684 register rtx stack_parm = 0;
2685 CUMULATIVE_ARGS args_so_far;
a53e14c0 2686 enum machine_mode promoted_mode, passed_mode, nominal_mode;
00d8a4c1 2687 int unsignedp;
6f086dfc
RS
2688 /* Total space needed so far for args on the stack,
2689 given as a constant and a tree-expression. */
2690 struct args_size stack_args_size;
2691 tree fntype = TREE_TYPE (fndecl);
2692 tree fnargs = DECL_ARGUMENTS (fndecl);
2693 /* This is used for the arg pointer when referring to stack args. */
2694 rtx internal_arg_pointer;
2695 /* This is a dummy PARM_DECL that we used for the function result if
2696 the function returns a structure. */
2697 tree function_result_decl = 0;
2698 int nparmregs = list_length (fnargs) + LAST_VIRTUAL_REGISTER + 1;
2699 int varargs_setup = 0;
3412b298 2700 rtx conversion_insns = 0;
6f086dfc
RS
2701
2702 /* Nonzero if the last arg is named `__builtin_va_alist',
2703 which is used on some machines for old-fashioned non-ANSI varargs.h;
2704 this should be stuck onto the stack as if it had arrived there. */
2705 int vararg
2706 = (fnargs
2707 && (parm = tree_last (fnargs)) != 0
2708 && DECL_NAME (parm)
2709 && (! strcmp (IDENTIFIER_POINTER (DECL_NAME (parm)),
2710 "__builtin_va_alist")));
2711
2712 /* Nonzero if function takes extra anonymous args.
2713 This means the last named arg must be on the stack
2714 right before the anonymous ones. */
2715 int stdarg
2716 = (TYPE_ARG_TYPES (fntype) != 0
2717 && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (fntype)))
2718 != void_type_node));
2719
2720 /* If the reg that the virtual arg pointer will be translated into is
2721 not a fixed reg or is the stack pointer, make a copy of the virtual
2722 arg pointer, and address parms via the copy. The frame pointer is
2723 considered fixed even though it is not marked as such.
2724
2725 The second time through, simply use ap to avoid generating rtx. */
2726
2727 if ((ARG_POINTER_REGNUM == STACK_POINTER_REGNUM
2728 || ! (fixed_regs[ARG_POINTER_REGNUM]
2729 || ARG_POINTER_REGNUM == FRAME_POINTER_REGNUM))
2730 && ! second_time)
2731 internal_arg_pointer = copy_to_reg (virtual_incoming_args_rtx);
2732 else
2733 internal_arg_pointer = virtual_incoming_args_rtx;
2734 current_function_internal_arg_pointer = internal_arg_pointer;
2735
2736 stack_args_size.constant = 0;
2737 stack_args_size.var = 0;
2738
2739 /* If struct value address is treated as the first argument, make it so. */
2740 if (aggregate_value_p (DECL_RESULT (fndecl))
2741 && ! current_function_returns_pcc_struct
2742 && struct_value_incoming_rtx == 0)
2743 {
2744 tree type = build_pointer_type (fntype);
2745
5f4f0e22 2746 function_result_decl = build_decl (PARM_DECL, NULL_TREE, type);
6f086dfc
RS
2747
2748 DECL_ARG_TYPE (function_result_decl) = type;
2749 TREE_CHAIN (function_result_decl) = fnargs;
2750 fnargs = function_result_decl;
2751 }
2752
2753 parm_reg_stack_loc = (rtx *) oballoc (nparmregs * sizeof (rtx));
2754 bzero (parm_reg_stack_loc, nparmregs * sizeof (rtx));
2755
2756#ifdef INIT_CUMULATIVE_INCOMING_ARGS
ea0d4c4b 2757 INIT_CUMULATIVE_INCOMING_ARGS (args_so_far, fntype, NULL_RTX);
6f086dfc 2758#else
ea0d4c4b 2759 INIT_CUMULATIVE_ARGS (args_so_far, fntype, NULL_RTX);
6f086dfc
RS
2760#endif
2761
2762 /* We haven't yet found an argument that we must push and pretend the
2763 caller did. */
2764 current_function_pretend_args_size = 0;
2765
2766 for (parm = fnargs; parm; parm = TREE_CHAIN (parm))
2767 {
2768 int aggregate
2769 = (TREE_CODE (TREE_TYPE (parm)) == ARRAY_TYPE
2770 || TREE_CODE (TREE_TYPE (parm)) == RECORD_TYPE
2771 || TREE_CODE (TREE_TYPE (parm)) == UNION_TYPE);
2772 struct args_size stack_offset;
2773 struct args_size arg_size;
2774 int passed_pointer = 0;
2775 tree passed_type = DECL_ARG_TYPE (parm);
2776
2777 /* Set LAST_NAMED if this is last named arg before some
2778 anonymous args. We treat it as if it were anonymous too. */
2779 int last_named = ((TREE_CHAIN (parm) == 0
2780 || DECL_NAME (TREE_CHAIN (parm)) == 0)
2781 && (vararg || stdarg));
2782
2783 if (TREE_TYPE (parm) == error_mark_node
2784 /* This can happen after weird syntax errors
2785 or if an enum type is defined among the parms. */
2786 || TREE_CODE (parm) != PARM_DECL
2787 || passed_type == NULL)
2788 {
587cb682
TW
2789 DECL_INCOMING_RTL (parm) = DECL_RTL (parm) = gen_rtx (MEM, BLKmode,
2790 const0_rtx);
6f086dfc
RS
2791 TREE_USED (parm) = 1;
2792 continue;
2793 }
2794
2795 /* For varargs.h function, save info about regs and stack space
2796 used by the individual args, not including the va_alist arg. */
2797 if (vararg && last_named)
2798 current_function_args_info = args_so_far;
2799
2800 /* Find mode of arg as it is passed, and mode of arg
2801 as it should be during execution of this function. */
2802 passed_mode = TYPE_MODE (passed_type);
2803 nominal_mode = TYPE_MODE (TREE_TYPE (parm));
2804
16bae307
RS
2805 /* If the parm's mode is VOID, its value doesn't matter,
2806 and avoid the usual things like emit_move_insn that could crash. */
2807 if (nominal_mode == VOIDmode)
2808 {
2809 DECL_INCOMING_RTL (parm) = DECL_RTL (parm) = const0_rtx;
2810 continue;
2811 }
2812
6f086dfc
RS
2813#ifdef FUNCTION_ARG_PASS_BY_REFERENCE
2814 /* See if this arg was passed by invisible reference. */
2815 if (FUNCTION_ARG_PASS_BY_REFERENCE (args_so_far, passed_mode,
2816 passed_type, ! last_named))
2817 {
2818 passed_type = build_pointer_type (passed_type);
2819 passed_pointer = 1;
2820 passed_mode = nominal_mode = Pmode;
2821 }
2822#endif
2823
a53e14c0
RK
2824 promoted_mode = passed_mode;
2825
2826#ifdef PROMOTE_FUNCTION_ARGS
2827 /* Compute the mode in which the arg is actually extended to. */
2828 if (TREE_CODE (passed_type) == INTEGER_TYPE
2829 || TREE_CODE (passed_type) == ENUMERAL_TYPE
2830 || TREE_CODE (passed_type) == BOOLEAN_TYPE
2831 || TREE_CODE (passed_type) == CHAR_TYPE
2832 || TREE_CODE (passed_type) == REAL_TYPE
2833 || TREE_CODE (passed_type) == POINTER_TYPE
2834 || TREE_CODE (passed_type) == OFFSET_TYPE)
2835 {
2836 unsignedp = TREE_UNSIGNED (passed_type);
2837 PROMOTE_MODE (promoted_mode, unsignedp, passed_type);
2838 }
2839#endif
2840
6f086dfc
RS
2841 /* Let machine desc say which reg (if any) the parm arrives in.
2842 0 means it arrives on the stack. */
2843#ifdef FUNCTION_INCOMING_ARG
a53e14c0 2844 entry_parm = FUNCTION_INCOMING_ARG (args_so_far, promoted_mode,
6f086dfc
RS
2845 passed_type, ! last_named);
2846#else
a53e14c0 2847 entry_parm = FUNCTION_ARG (args_so_far, promoted_mode,
6f086dfc
RS
2848 passed_type, ! last_named);
2849#endif
2850
a53e14c0
RK
2851 if (entry_parm)
2852 passed_mode = promoted_mode;
2853
6f086dfc
RS
2854#ifdef SETUP_INCOMING_VARARGS
2855 /* If this is the last named parameter, do any required setup for
2856 varargs or stdargs. We need to know about the case of this being an
2857 addressable type, in which case we skip the registers it
2858 would have arrived in.
2859
2860 For stdargs, LAST_NAMED will be set for two parameters, the one that
2861 is actually the last named, and the dummy parameter. We only
2862 want to do this action once.
2863
2864 Also, indicate when RTL generation is to be suppressed. */
2865 if (last_named && !varargs_setup)
2866 {
2867 SETUP_INCOMING_VARARGS (args_so_far, passed_mode, passed_type,
2868 current_function_pretend_args_size,
2869 second_time);
2870 varargs_setup = 1;
2871 }
2872#endif
2873
2874 /* Determine parm's home in the stack,
2875 in case it arrives in the stack or we should pretend it did.
2876
2877 Compute the stack position and rtx where the argument arrives
2878 and its size.
2879
2880 There is one complexity here: If this was a parameter that would
2881 have been passed in registers, but wasn't only because it is
2882 __builtin_va_alist, we want locate_and_pad_parm to treat it as if
2883 it came in a register so that REG_PARM_STACK_SPACE isn't skipped.
2884 In this case, we call FUNCTION_ARG with NAMED set to 1 instead of
2885 0 as it was the previous time. */
2886
2887 locate_and_pad_parm (passed_mode, passed_type,
2888#ifdef STACK_PARMS_IN_REG_PARM_AREA
2889 1,
2890#else
2891#ifdef FUNCTION_INCOMING_ARG
2892 FUNCTION_INCOMING_ARG (args_so_far, passed_mode,
2893 passed_type,
2894 (! last_named
2895 || varargs_setup)) != 0,
2896#else
2897 FUNCTION_ARG (args_so_far, passed_mode,
2898 passed_type,
2899 ! last_named || varargs_setup) != 0,
2900#endif
2901#endif
2902 fndecl, &stack_args_size, &stack_offset, &arg_size);
2903
2904 if (! second_time)
2905 {
2906 rtx offset_rtx = ARGS_SIZE_RTX (stack_offset);
2907
2908 if (offset_rtx == const0_rtx)
2909 stack_parm = gen_rtx (MEM, passed_mode, internal_arg_pointer);
2910 else
2911 stack_parm = gen_rtx (MEM, passed_mode,
2912 gen_rtx (PLUS, Pmode,
2913 internal_arg_pointer, offset_rtx));
2914
2915 /* If this is a memory ref that contains aggregate components,
2916 mark it as such for cse and loop optimize. */
2917 MEM_IN_STRUCT_P (stack_parm) = aggregate;
2918 }
2919
2920 /* If this parameter was passed both in registers and in the stack,
2921 use the copy on the stack. */
2922 if (MUST_PASS_IN_STACK (passed_mode, passed_type))
2923 entry_parm = 0;
2924
461beb10 2925#ifdef FUNCTION_ARG_PARTIAL_NREGS
6f086dfc
RS
2926 /* If this parm was passed part in regs and part in memory,
2927 pretend it arrived entirely in memory
2928 by pushing the register-part onto the stack.
2929
2930 In the special case of a DImode or DFmode that is split,
2931 we could put it together in a pseudoreg directly,
2932 but for now that's not worth bothering with. */
2933
2934 if (entry_parm)
2935 {
461beb10
DE
2936 int nregs = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, passed_mode,
2937 passed_type, ! last_named);
6f086dfc
RS
2938
2939 if (nregs > 0)
2940 {
2941 current_function_pretend_args_size
2942 = (((nregs * UNITS_PER_WORD) + (PARM_BOUNDARY / BITS_PER_UNIT) - 1)
2943 / (PARM_BOUNDARY / BITS_PER_UNIT)
2944 * (PARM_BOUNDARY / BITS_PER_UNIT));
2945
2946 if (! second_time)
2947 move_block_from_reg (REGNO (entry_parm),
2948 validize_mem (stack_parm), nregs);
2949 entry_parm = stack_parm;
2950 }
2951 }
461beb10 2952#endif
6f086dfc
RS
2953
2954 /* If we didn't decide this parm came in a register,
2955 by default it came on the stack. */
2956 if (entry_parm == 0)
2957 entry_parm = stack_parm;
2958
2959 /* Record permanently how this parm was passed. */
2960 if (! second_time)
2961 DECL_INCOMING_RTL (parm) = entry_parm;
2962
2963 /* If there is actually space on the stack for this parm,
2964 count it in stack_args_size; otherwise set stack_parm to 0
2965 to indicate there is no preallocated stack slot for the parm. */
2966
2967 if (entry_parm == stack_parm
d9ca49d5 2968#if defined (REG_PARM_STACK_SPACE) && ! defined (MAYBE_REG_PARM_STACK_SPACE)
6f086dfc 2969 /* On some machines, even if a parm value arrives in a register
d9ca49d5
JW
2970 there is still an (uninitialized) stack slot allocated for it.
2971
2972 ??? When MAYBE_REG_PARM_STACK_SPACE is defined, we can't tell
2973 whether this parameter already has a stack slot allocated,
2974 because an arg block exists only if current_function_args_size
2975 is larger than some threshhold, and we haven't calculated that
2976 yet. So, for now, we just assume that stack slots never exist
2977 in this case. */
6f086dfc
RS
2978 || REG_PARM_STACK_SPACE (fndecl) > 0
2979#endif
2980 )
2981 {
2982 stack_args_size.constant += arg_size.constant;
2983 if (arg_size.var)
2984 ADD_PARM_SIZE (stack_args_size, arg_size.var);
2985 }
2986 else
2987 /* No stack slot was pushed for this parm. */
2988 stack_parm = 0;
2989
2990 /* Update info on where next arg arrives in registers. */
2991
2992 FUNCTION_ARG_ADVANCE (args_so_far, passed_mode,
2993 passed_type, ! last_named);
2994
2995 /* If this is our second time through, we are done with this parm. */
2996 if (second_time)
2997 continue;
2998
e16c591a
RS
2999 /* If we can't trust the parm stack slot to be aligned enough
3000 for its ultimate type, don't use that slot after entry.
3001 We'll make another stack slot, if we need one. */
3002 {
e16c591a
RS
3003 int thisparm_boundary
3004 = FUNCTION_ARG_BOUNDARY (passed_mode, passed_type);
e16c591a
RS
3005
3006 if (GET_MODE_ALIGNMENT (nominal_mode) > thisparm_boundary)
3007 stack_parm = 0;
3008 }
3009
6f086dfc
RS
3010 /* Now adjust STACK_PARM to the mode and precise location
3011 where this parameter should live during execution,
3012 if we discover that it must live in the stack during execution.
3013 To make debuggers happier on big-endian machines, we store
3014 the value in the last bytes of the space available. */
3015
3016 if (nominal_mode != BLKmode && nominal_mode != passed_mode
3017 && stack_parm != 0)
3018 {
3019 rtx offset_rtx;
3020
3021#if BYTES_BIG_ENDIAN
3022 if (GET_MODE_SIZE (nominal_mode) < UNITS_PER_WORD)
3023 stack_offset.constant += (GET_MODE_SIZE (passed_mode)
3024 - GET_MODE_SIZE (nominal_mode));
3025#endif
3026
3027 offset_rtx = ARGS_SIZE_RTX (stack_offset);
3028 if (offset_rtx == const0_rtx)
3029 stack_parm = gen_rtx (MEM, nominal_mode, internal_arg_pointer);
3030 else
3031 stack_parm = gen_rtx (MEM, nominal_mode,
3032 gen_rtx (PLUS, Pmode,
3033 internal_arg_pointer, offset_rtx));
3034
3035 /* If this is a memory ref that contains aggregate components,
3036 mark it as such for cse and loop optimize. */
3037 MEM_IN_STRUCT_P (stack_parm) = aggregate;
3038 }
3039
3040 /* ENTRY_PARM is an RTX for the parameter as it arrives,
3041 in the mode in which it arrives.
3042 STACK_PARM is an RTX for a stack slot where the parameter can live
3043 during the function (in case we want to put it there).
3044 STACK_PARM is 0 if no stack slot was pushed for it.
3045
3046 Now output code if necessary to convert ENTRY_PARM to
3047 the type in which this function declares it,
3048 and store that result in an appropriate place,
3049 which may be a pseudo reg, may be STACK_PARM,
3050 or may be a local stack slot if STACK_PARM is 0.
3051
3052 Set DECL_RTL to that place. */
3053
3054 if (nominal_mode == BLKmode)
3055 {
3056 /* If a BLKmode arrives in registers, copy it to a stack slot. */
3057 if (GET_CODE (entry_parm) == REG)
3058 {
3059 int size_stored = CEIL_ROUND (int_size_in_bytes (TREE_TYPE (parm)),
3060 UNITS_PER_WORD);
3061
3062 /* Note that we will be storing an integral number of words.
3063 So we have to be careful to ensure that we allocate an
3064 integral number of words. We do this below in the
3065 assign_stack_local if space was not allocated in the argument
3066 list. If it was, this will not work if PARM_BOUNDARY is not
3067 a multiple of BITS_PER_WORD. It isn't clear how to fix this
3068 if it becomes a problem. */
3069
3070 if (stack_parm == 0)
7e41ffa2
RS
3071 {
3072 stack_parm
3073 = assign_stack_local (GET_MODE (entry_parm), size_stored, 0);
3074 /* If this is a memory ref that contains aggregate components,
3075 mark it as such for cse and loop optimize. */
3076 MEM_IN_STRUCT_P (stack_parm) = aggregate;
3077 }
3078
6f086dfc
RS
3079 else if (PARM_BOUNDARY % BITS_PER_WORD != 0)
3080 abort ();
3081
3082 move_block_from_reg (REGNO (entry_parm),
3083 validize_mem (stack_parm),
3084 size_stored / UNITS_PER_WORD);
3085 }
3086 DECL_RTL (parm) = stack_parm;
3087 }
74bd77a8 3088 else if (! ((obey_regdecls && ! DECL_REGISTER (parm)
a82ad570 3089 && ! DECL_INLINE (fndecl))
6f086dfc
RS
3090 /* layout_decl may set this. */
3091 || TREE_ADDRESSABLE (parm)
3092 || TREE_SIDE_EFFECTS (parm)
3093 /* If -ffloat-store specified, don't put explicit
3094 float variables into registers. */
3095 || (flag_float_store
3096 && TREE_CODE (TREE_TYPE (parm)) == REAL_TYPE))
3097 /* Always assign pseudo to structure return or item passed
3098 by invisible reference. */
3099 || passed_pointer || parm == function_result_decl)
3100 {
00d8a4c1
RK
3101 /* Store the parm in a pseudoregister during the function, but we
3102 may need to do it in a wider mode. */
3103
3104 register rtx parmreg;
3105
3106 unsignedp = TREE_UNSIGNED (TREE_TYPE (parm));
3107 if (TREE_CODE (TREE_TYPE (parm)) == INTEGER_TYPE
3108 || TREE_CODE (TREE_TYPE (parm)) == ENUMERAL_TYPE
3109 || TREE_CODE (TREE_TYPE (parm)) == BOOLEAN_TYPE
3110 || TREE_CODE (TREE_TYPE (parm)) == CHAR_TYPE
3111 || TREE_CODE (TREE_TYPE (parm)) == REAL_TYPE
3112 || TREE_CODE (TREE_TYPE (parm)) == POINTER_TYPE
3113 || TREE_CODE (TREE_TYPE (parm)) == OFFSET_TYPE)
3114 {
3115 PROMOTE_MODE (nominal_mode, unsignedp, TREE_TYPE (parm));
3116 }
6f086dfc 3117
00d8a4c1 3118 parmreg = gen_reg_rtx (nominal_mode);
6f086dfc
RS
3119 REG_USERVAR_P (parmreg) = 1;
3120
3121 /* If this was an item that we received a pointer to, set DECL_RTL
3122 appropriately. */
3123 if (passed_pointer)
3124 {
3125 DECL_RTL (parm) = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (passed_type)), parmreg);
3126 MEM_IN_STRUCT_P (DECL_RTL (parm)) = aggregate;
3127 }
3128 else
3129 DECL_RTL (parm) = parmreg;
3130
3131 /* Copy the value into the register. */
3132 if (GET_MODE (parmreg) != GET_MODE (entry_parm))
86f8eff3
RK
3133 {
3134 /* If ENTRY_PARM is a hard register, it might be in a register
3135 not valid for operating in its mode (e.g., an odd-numbered
3136 register for a DFmode). In that case, moves are the only
3137 thing valid, so we can't do a convert from there. This
3138 occurs when the calling sequence allow such misaligned
3412b298
JW
3139 usages.
3140
3141 In addition, the conversion may involve a call, which could
3142 clobber parameters which haven't been copied to pseudo
3143 registers yet. Therefore, we must first copy the parm to
3144 a pseudo reg here, and save the conversion until after all
3145 parameters have been moved. */
3146
3147 rtx tempreg = gen_reg_rtx (GET_MODE (entry_parm));
3148
3149 emit_move_insn (tempreg, validize_mem (entry_parm));
3150
3151 push_to_sequence (conversion_insns);
8c394878 3152 convert_move (parmreg, tempreg, unsignedp);
3412b298
JW
3153 conversion_insns = get_insns ();
3154 end_sequence ();
86f8eff3 3155 }
6f086dfc
RS
3156 else
3157 emit_move_insn (parmreg, validize_mem (entry_parm));
3158
74bd77a8
RS
3159 /* If we were passed a pointer but the actual value
3160 can safely live in a register, put it in one. */
16bae307 3161 if (passed_pointer && TYPE_MODE (TREE_TYPE (parm)) != BLKmode
74bd77a8
RS
3162 && ! ((obey_regdecls && ! DECL_REGISTER (parm)
3163 && ! DECL_INLINE (fndecl))
3164 /* layout_decl may set this. */
3165 || TREE_ADDRESSABLE (parm)
3166 || TREE_SIDE_EFFECTS (parm)
3167 /* If -ffloat-store specified, don't put explicit
3168 float variables into registers. */
3169 || (flag_float_store
3170 && TREE_CODE (TREE_TYPE (parm)) == REAL_TYPE)))
3171 {
2654605a
JW
3172 /* We can't use nominal_mode, because it will have been set to
3173 Pmode above. We must use the actual mode of the parm. */
3174 parmreg = gen_reg_rtx (TYPE_MODE (TREE_TYPE (parm)));
74bd77a8
RS
3175 emit_move_insn (parmreg, DECL_RTL (parm));
3176 DECL_RTL (parm) = parmreg;
3177 }
3178
6f086dfc
RS
3179 /* In any case, record the parm's desired stack location
3180 in case we later discover it must live in the stack. */
3181 if (REGNO (parmreg) >= nparmregs)
3182 {
3183 rtx *new;
3184 nparmregs = REGNO (parmreg) + 5;
3185 new = (rtx *) oballoc (nparmregs * sizeof (rtx));
3186 bcopy (parm_reg_stack_loc, new, nparmregs * sizeof (rtx));
3187 parm_reg_stack_loc = new;
3188 }
3189 parm_reg_stack_loc[REGNO (parmreg)] = stack_parm;
3190
3191 /* Mark the register as eliminable if we did no conversion
3192 and it was copied from memory at a fixed offset,
3193 and the arg pointer was not copied to a pseudo-reg.
3194 If the arg pointer is a pseudo reg or the offset formed
3195 an invalid address, such memory-equivalences
3196 as we make here would screw up life analysis for it. */
3197 if (nominal_mode == passed_mode
3198 && GET_CODE (entry_parm) == MEM
e16c591a 3199 && entry_parm == stack_parm
6f086dfc
RS
3200 && stack_offset.var == 0
3201 && reg_mentioned_p (virtual_incoming_args_rtx,
3202 XEXP (entry_parm, 0)))
3203 REG_NOTES (get_last_insn ())
3204 = gen_rtx (EXPR_LIST, REG_EQUIV,
3205 entry_parm, REG_NOTES (get_last_insn ()));
3206
3207 /* For pointer data type, suggest pointer register. */
3208 if (TREE_CODE (TREE_TYPE (parm)) == POINTER_TYPE)
3209 mark_reg_pointer (parmreg);
3210 }
3211 else
3212 {
3213 /* Value must be stored in the stack slot STACK_PARM
3214 during function execution. */
3215
3216 if (passed_mode != nominal_mode)
86f8eff3
RK
3217 {
3218 /* Conversion is required. */
3412b298
JW
3219 rtx tempreg = gen_reg_rtx (GET_MODE (entry_parm));
3220
3221 emit_move_insn (tempreg, validize_mem (entry_parm));
86f8eff3 3222
3412b298
JW
3223 push_to_sequence (conversion_insns);
3224 entry_parm = convert_to_mode (nominal_mode, tempreg,
a53e14c0 3225 TREE_UNSIGNED (TREE_TYPE (parm)));
3412b298
JW
3226 conversion_insns = get_insns ();
3227 end_sequence ();
86f8eff3 3228 }
6f086dfc
RS
3229
3230 if (entry_parm != stack_parm)
3231 {
3232 if (stack_parm == 0)
7e41ffa2
RS
3233 {
3234 stack_parm
3235 = assign_stack_local (GET_MODE (entry_parm),
3236 GET_MODE_SIZE (GET_MODE (entry_parm)), 0);
3237 /* If this is a memory ref that contains aggregate components,
3238 mark it as such for cse and loop optimize. */
3239 MEM_IN_STRUCT_P (stack_parm) = aggregate;
3240 }
3241
3412b298
JW
3242 if (passed_mode != nominal_mode)
3243 {
3244 push_to_sequence (conversion_insns);
3245 emit_move_insn (validize_mem (stack_parm),
3246 validize_mem (entry_parm));
3247 conversion_insns = get_insns ();
3248 end_sequence ();
3249 }
3250 else
3251 emit_move_insn (validize_mem (stack_parm),
3252 validize_mem (entry_parm));
6f086dfc
RS
3253 }
3254
3255 DECL_RTL (parm) = stack_parm;
3256 }
3257
3258 /* If this "parameter" was the place where we are receiving the
3259 function's incoming structure pointer, set up the result. */
3260 if (parm == function_result_decl)
3261 DECL_RTL (DECL_RESULT (fndecl))
3262 = gen_rtx (MEM, DECL_MODE (DECL_RESULT (fndecl)), DECL_RTL (parm));
3263
3264 if (TREE_THIS_VOLATILE (parm))
3265 MEM_VOLATILE_P (DECL_RTL (parm)) = 1;
3266 if (TREE_READONLY (parm))
3267 RTX_UNCHANGING_P (DECL_RTL (parm)) = 1;
3268 }
3269
3412b298
JW
3270 /* Output all parameter conversion instructions (possibly including calls)
3271 now that all parameters have been copied out of hard registers. */
3272 emit_insns (conversion_insns);
3273
6f086dfc
RS
3274 max_parm_reg = max_reg_num ();
3275 last_parm_insn = get_last_insn ();
3276
3277 current_function_args_size = stack_args_size.constant;
3278
3279 /* Adjust function incoming argument size for alignment and
3280 minimum length. */
3281
3282#ifdef REG_PARM_STACK_SPACE
6f90e075 3283#ifndef MAYBE_REG_PARM_STACK_SPACE
6f086dfc
RS
3284 current_function_args_size = MAX (current_function_args_size,
3285 REG_PARM_STACK_SPACE (fndecl));
3286#endif
6f90e075 3287#endif
6f086dfc
RS
3288
3289#ifdef STACK_BOUNDARY
3290#define STACK_BYTES (STACK_BOUNDARY / BITS_PER_UNIT)
3291
3292 current_function_args_size
3293 = ((current_function_args_size + STACK_BYTES - 1)
3294 / STACK_BYTES) * STACK_BYTES;
3295#endif
3296
3297#ifdef ARGS_GROW_DOWNWARD
3298 current_function_arg_offset_rtx
5f4f0e22 3299 = (stack_args_size.var == 0 ? GEN_INT (-stack_args_size.constant)
6f086dfc
RS
3300 : expand_expr (size_binop (MINUS_EXPR, stack_args_size.var,
3301 size_int (-stack_args_size.constant)),
5f4f0e22 3302 NULL_RTX, VOIDmode, 0));
6f086dfc
RS
3303#else
3304 current_function_arg_offset_rtx = ARGS_SIZE_RTX (stack_args_size);
3305#endif
3306
3307 /* See how many bytes, if any, of its args a function should try to pop
3308 on return. */
3309
3310 current_function_pops_args = RETURN_POPS_ARGS (TREE_TYPE (fndecl),
3311 current_function_args_size);
3312
3313 /* For stdarg.h function, save info about regs and stack space
3314 used by the named args. */
3315
3316 if (stdarg)
3317 current_function_args_info = args_so_far;
3318
3319 /* Set the rtx used for the function return value. Put this in its
3320 own variable so any optimizers that need this information don't have
3321 to include tree.h. Do this here so it gets done when an inlined
3322 function gets output. */
3323
3324 current_function_return_rtx = DECL_RTL (DECL_RESULT (fndecl));
3325}
3326\f
75dc3319
RK
3327/* Indicate whether REGNO is an incoming argument to the current function
3328 that was promoted to a wider mode. If so, return the RTX for the
3329 register (to get its mode). PMODE and PUNSIGNEDP are set to the mode
3330 that REGNO is promoted from and whether the promotion was signed or
3331 unsigned. */
3332
3333#ifdef PROMOTE_FUNCTION_ARGS
3334
3335rtx
3336promoted_input_arg (regno, pmode, punsignedp)
3337 int regno;
3338 enum machine_mode *pmode;
3339 int *punsignedp;
3340{
3341 tree arg;
3342
3343 for (arg = DECL_ARGUMENTS (current_function_decl); arg;
3344 arg = TREE_CHAIN (arg))
3345 if (GET_CODE (DECL_INCOMING_RTL (arg)) == REG
3346 && REGNO (DECL_INCOMING_RTL (arg)) == regno
3347 && (TREE_CODE (TREE_TYPE (arg)) == INTEGER_TYPE
3348 || TREE_CODE (TREE_TYPE (arg)) == ENUMERAL_TYPE
3349 || TREE_CODE (TREE_TYPE (arg)) == BOOLEAN_TYPE
3350 || TREE_CODE (TREE_TYPE (arg)) == CHAR_TYPE
3351 || TREE_CODE (TREE_TYPE (arg)) == REAL_TYPE
3352 || TREE_CODE (TREE_TYPE (arg)) == POINTER_TYPE
3353 || TREE_CODE (TREE_TYPE (arg)) == OFFSET_TYPE))
3354 {
3355 enum machine_mode mode = TYPE_MODE (TREE_TYPE (arg));
3356 int unsignedp = TREE_UNSIGNED (TREE_TYPE (arg));
3357
3358 PROMOTE_MODE (mode, unsignedp, TREE_TYPE (arg));
3359 if (mode == GET_MODE (DECL_INCOMING_RTL (arg))
3360 && mode != DECL_MODE (arg))
3361 {
3362 *pmode = DECL_MODE (arg);
3363 *punsignedp = unsignedp;
3364 return DECL_INCOMING_RTL (arg);
3365 }
3366 }
3367
3368 return 0;
3369}
3370
3371#endif
3372\f
6f086dfc
RS
3373/* Compute the size and offset from the start of the stacked arguments for a
3374 parm passed in mode PASSED_MODE and with type TYPE.
3375
3376 INITIAL_OFFSET_PTR points to the current offset into the stacked
3377 arguments.
3378
3379 The starting offset and size for this parm are returned in *OFFSET_PTR
3380 and *ARG_SIZE_PTR, respectively.
3381
3382 IN_REGS is non-zero if the argument will be passed in registers. It will
3383 never be set if REG_PARM_STACK_SPACE is not defined.
3384
3385 FNDECL is the function in which the argument was defined.
3386
3387 There are two types of rounding that are done. The first, controlled by
3388 FUNCTION_ARG_BOUNDARY, forces the offset from the start of the argument
3389 list to be aligned to the specific boundary (in bits). This rounding
3390 affects the initial and starting offsets, but not the argument size.
3391
3392 The second, controlled by FUNCTION_ARG_PADDING and PARM_BOUNDARY,
3393 optionally rounds the size of the parm to PARM_BOUNDARY. The
3394 initial offset is not affected by this rounding, while the size always
3395 is and the starting offset may be. */
3396
3397/* offset_ptr will be negative for ARGS_GROW_DOWNWARD case;
3398 initial_offset_ptr is positive because locate_and_pad_parm's
3399 callers pass in the total size of args so far as
3400 initial_offset_ptr. arg_size_ptr is always positive.*/
3401
3402static void pad_to_arg_alignment (), pad_below ();
3403
3404void
3405locate_and_pad_parm (passed_mode, type, in_regs, fndecl,
3406 initial_offset_ptr, offset_ptr, arg_size_ptr)
3407 enum machine_mode passed_mode;
3408 tree type;
3409 int in_regs;
3410 tree fndecl;
3411 struct args_size *initial_offset_ptr;
3412 struct args_size *offset_ptr;
3413 struct args_size *arg_size_ptr;
3414{
3415 tree sizetree
3416 = type ? size_in_bytes (type) : size_int (GET_MODE_SIZE (passed_mode));
3417 enum direction where_pad = FUNCTION_ARG_PADDING (passed_mode, type);
3418 int boundary = FUNCTION_ARG_BOUNDARY (passed_mode, type);
3419 int boundary_in_bytes = boundary / BITS_PER_UNIT;
3420 int reg_parm_stack_space = 0;
3421
3422#ifdef REG_PARM_STACK_SPACE
3423 /* If we have found a stack parm before we reach the end of the
3424 area reserved for registers, skip that area. */
3425 if (! in_regs)
3426 {
29008b51
JW
3427#ifdef MAYBE_REG_PARM_STACK_SPACE
3428 reg_parm_stack_space = MAYBE_REG_PARM_STACK_SPACE;
3429#else
6f086dfc 3430 reg_parm_stack_space = REG_PARM_STACK_SPACE (fndecl);
29008b51 3431#endif
6f086dfc
RS
3432 if (reg_parm_stack_space > 0)
3433 {
3434 if (initial_offset_ptr->var)
3435 {
3436 initial_offset_ptr->var
3437 = size_binop (MAX_EXPR, ARGS_SIZE_TREE (*initial_offset_ptr),
3438 size_int (reg_parm_stack_space));
3439 initial_offset_ptr->constant = 0;
3440 }
3441 else if (initial_offset_ptr->constant < reg_parm_stack_space)
3442 initial_offset_ptr->constant = reg_parm_stack_space;
3443 }
3444 }
3445#endif /* REG_PARM_STACK_SPACE */
3446
3447 arg_size_ptr->var = 0;
3448 arg_size_ptr->constant = 0;
3449
3450#ifdef ARGS_GROW_DOWNWARD
3451 if (initial_offset_ptr->var)
3452 {
3453 offset_ptr->constant = 0;
3454 offset_ptr->var = size_binop (MINUS_EXPR, integer_zero_node,
3455 initial_offset_ptr->var);
3456 }
3457 else
3458 {
3459 offset_ptr->constant = - initial_offset_ptr->constant;
3460 offset_ptr->var = 0;
3461 }
3462 if (where_pad == upward
3463 && (TREE_CODE (sizetree) != INTEGER_CST
3464 || ((TREE_INT_CST_LOW (sizetree) * BITS_PER_UNIT) % PARM_BOUNDARY)))
3465 sizetree = round_up (sizetree, PARM_BOUNDARY / BITS_PER_UNIT);
3466 SUB_PARM_SIZE (*offset_ptr, sizetree);
66bcbe19
TG
3467 if (where_pad != downward)
3468 pad_to_arg_alignment (offset_ptr, boundary);
6f086dfc
RS
3469 if (initial_offset_ptr->var)
3470 {
3471 arg_size_ptr->var = size_binop (MINUS_EXPR,
3472 size_binop (MINUS_EXPR,
3473 integer_zero_node,
3474 initial_offset_ptr->var),
3475 offset_ptr->var);
3476 }
3477 else
3478 {
3479 arg_size_ptr->constant = (- initial_offset_ptr->constant -
3480 offset_ptr->constant);
3481 }
3482/* ADD_PARM_SIZE (*arg_size_ptr, sizetree); */
3483 if (where_pad == downward)
3484 pad_below (arg_size_ptr, passed_mode, sizetree);
3485#else /* !ARGS_GROW_DOWNWARD */
3486 pad_to_arg_alignment (initial_offset_ptr, boundary);
3487 *offset_ptr = *initial_offset_ptr;
3488 if (where_pad == downward)
3489 pad_below (offset_ptr, passed_mode, sizetree);
3490
3491#ifdef PUSH_ROUNDING
3492 if (passed_mode != BLKmode)
3493 sizetree = size_int (PUSH_ROUNDING (TREE_INT_CST_LOW (sizetree)));
3494#endif
3495
3496 if (where_pad != none
3497 && (TREE_CODE (sizetree) != INTEGER_CST
3498 || ((TREE_INT_CST_LOW (sizetree) * BITS_PER_UNIT) % PARM_BOUNDARY)))
3499 sizetree = round_up (sizetree, PARM_BOUNDARY / BITS_PER_UNIT);
3500
3501 ADD_PARM_SIZE (*arg_size_ptr, sizetree);
3502#endif /* ARGS_GROW_DOWNWARD */
3503}
3504
e16c591a
RS
3505/* Round the stack offset in *OFFSET_PTR up to a multiple of BOUNDARY.
3506 BOUNDARY is measured in bits, but must be a multiple of a storage unit. */
3507
6f086dfc
RS
3508static void
3509pad_to_arg_alignment (offset_ptr, boundary)
3510 struct args_size *offset_ptr;
3511 int boundary;
3512{
3513 int boundary_in_bytes = boundary / BITS_PER_UNIT;
3514
3515 if (boundary > BITS_PER_UNIT)
3516 {
3517 if (offset_ptr->var)
3518 {
3519 offset_ptr->var =
3520#ifdef ARGS_GROW_DOWNWARD
3521 round_down
3522#else
3523 round_up
3524#endif
3525 (ARGS_SIZE_TREE (*offset_ptr),
3526 boundary / BITS_PER_UNIT);
3527 offset_ptr->constant = 0; /*?*/
3528 }
3529 else
3530 offset_ptr->constant =
3531#ifdef ARGS_GROW_DOWNWARD
3532 FLOOR_ROUND (offset_ptr->constant, boundary_in_bytes);
3533#else
3534 CEIL_ROUND (offset_ptr->constant, boundary_in_bytes);
3535#endif
3536 }
3537}
3538
3539static void
3540pad_below (offset_ptr, passed_mode, sizetree)
3541 struct args_size *offset_ptr;
3542 enum machine_mode passed_mode;
3543 tree sizetree;
3544{
3545 if (passed_mode != BLKmode)
3546 {
3547 if (GET_MODE_BITSIZE (passed_mode) % PARM_BOUNDARY)
3548 offset_ptr->constant
3549 += (((GET_MODE_BITSIZE (passed_mode) + PARM_BOUNDARY - 1)
3550 / PARM_BOUNDARY * PARM_BOUNDARY / BITS_PER_UNIT)
3551 - GET_MODE_SIZE (passed_mode));
3552 }
3553 else
3554 {
3555 if (TREE_CODE (sizetree) != INTEGER_CST
3556 || (TREE_INT_CST_LOW (sizetree) * BITS_PER_UNIT) % PARM_BOUNDARY)
3557 {
3558 /* Round the size up to multiple of PARM_BOUNDARY bits. */
3559 tree s2 = round_up (sizetree, PARM_BOUNDARY / BITS_PER_UNIT);
3560 /* Add it in. */
3561 ADD_PARM_SIZE (*offset_ptr, s2);
3562 SUB_PARM_SIZE (*offset_ptr, sizetree);
3563 }
3564 }
3565}
3566
3567static tree
3568round_down (value, divisor)
3569 tree value;
3570 int divisor;
3571{
3572 return size_binop (MULT_EXPR,
3573 size_binop (FLOOR_DIV_EXPR, value, size_int (divisor)),
3574 size_int (divisor));
3575}
3576\f
3577/* Walk the tree of blocks describing the binding levels within a function
3578 and warn about uninitialized variables.
3579 This is done after calling flow_analysis and before global_alloc
3580 clobbers the pseudo-regs to hard regs. */
3581
3582void
3583uninitialized_vars_warning (block)
3584 tree block;
3585{
3586 register tree decl, sub;
3587 for (decl = BLOCK_VARS (block); decl; decl = TREE_CHAIN (decl))
3588 {
3589 if (TREE_CODE (decl) == VAR_DECL
3590 /* These warnings are unreliable for and aggregates
3591 because assigning the fields one by one can fail to convince
3592 flow.c that the entire aggregate was initialized.
3593 Unions are troublesome because members may be shorter. */
3594 && TREE_CODE (TREE_TYPE (decl)) != RECORD_TYPE
3595 && TREE_CODE (TREE_TYPE (decl)) != UNION_TYPE
3596 && TREE_CODE (TREE_TYPE (decl)) != ARRAY_TYPE
3597 && DECL_RTL (decl) != 0
3598 && GET_CODE (DECL_RTL (decl)) == REG
3599 && regno_uninitialized (REGNO (DECL_RTL (decl))))
3600 warning_with_decl (decl,
3601 "`%s' may be used uninitialized in this function");
3602 if (TREE_CODE (decl) == VAR_DECL
3603 && DECL_RTL (decl) != 0
3604 && GET_CODE (DECL_RTL (decl)) == REG
3605 && regno_clobbered_at_setjmp (REGNO (DECL_RTL (decl))))
3606 warning_with_decl (decl,
3607 "variable `%s' may be clobbered by `longjmp'");
3608 }
3609 for (sub = BLOCK_SUBBLOCKS (block); sub; sub = TREE_CHAIN (sub))
3610 uninitialized_vars_warning (sub);
3611}
3612
3613/* Do the appropriate part of uninitialized_vars_warning
3614 but for arguments instead of local variables. */
3615
3616void
3617setjmp_args_warning (block)
3618 tree block;
3619{
3620 register tree decl;
3621 for (decl = DECL_ARGUMENTS (current_function_decl);
3622 decl; decl = TREE_CHAIN (decl))
3623 if (DECL_RTL (decl) != 0
3624 && GET_CODE (DECL_RTL (decl)) == REG
3625 && regno_clobbered_at_setjmp (REGNO (DECL_RTL (decl))))
3626 warning_with_decl (decl, "argument `%s' may be clobbered by `longjmp'");
3627}
3628
3629/* If this function call setjmp, put all vars into the stack
3630 unless they were declared `register'. */
3631
3632void
3633setjmp_protect (block)
3634 tree block;
3635{
3636 register tree decl, sub;
3637 for (decl = BLOCK_VARS (block); decl; decl = TREE_CHAIN (decl))
3638 if ((TREE_CODE (decl) == VAR_DECL
3639 || TREE_CODE (decl) == PARM_DECL)
3640 && DECL_RTL (decl) != 0
3641 && GET_CODE (DECL_RTL (decl)) == REG
b335c2cc
TW
3642 /* If this variable came from an inline function, it must be
3643 that it's life doesn't overlap the setjmp. If there was a
3644 setjmp in the function, it would already be in memory. We
3645 must exclude such variable because their DECL_RTL might be
3646 set to strange things such as virtual_stack_vars_rtx. */
3647 && ! DECL_FROM_INLINE (decl)
6f086dfc
RS
3648 && (
3649#ifdef NON_SAVING_SETJMP
3650 /* If longjmp doesn't restore the registers,
3651 don't put anything in them. */
3652 NON_SAVING_SETJMP
3653 ||
3654#endif
a82ad570 3655 ! DECL_REGISTER (decl)))
6f086dfc
RS
3656 put_var_into_stack (decl);
3657 for (sub = BLOCK_SUBBLOCKS (block); sub; sub = TREE_CHAIN (sub))
3658 setjmp_protect (sub);
3659}
3660\f
3661/* Like the previous function, but for args instead of local variables. */
3662
3663void
3664setjmp_protect_args ()
3665{
3666 register tree decl, sub;
3667 for (decl = DECL_ARGUMENTS (current_function_decl);
3668 decl; decl = TREE_CHAIN (decl))
3669 if ((TREE_CODE (decl) == VAR_DECL
3670 || TREE_CODE (decl) == PARM_DECL)
3671 && DECL_RTL (decl) != 0
3672 && GET_CODE (DECL_RTL (decl)) == REG
3673 && (
3674 /* If longjmp doesn't restore the registers,
3675 don't put anything in them. */
3676#ifdef NON_SAVING_SETJMP
3677 NON_SAVING_SETJMP
3678 ||
3679#endif
a82ad570 3680 ! DECL_REGISTER (decl)))
6f086dfc
RS
3681 put_var_into_stack (decl);
3682}
3683\f
3684/* Return the context-pointer register corresponding to DECL,
3685 or 0 if it does not need one. */
3686
3687rtx
3688lookup_static_chain (decl)
3689 tree decl;
3690{
3691 tree context = decl_function_context (decl);
3692 tree link;
3693
3694 if (context == 0)
3695 return 0;
3696
3697 /* We treat inline_function_decl as an alias for the current function
3698 because that is the inline function whose vars, types, etc.
3699 are being merged into the current function.
3700 See expand_inline_function. */
3701 if (context == current_function_decl || context == inline_function_decl)
3702 return virtual_stack_vars_rtx;
3703
3704 for (link = context_display; link; link = TREE_CHAIN (link))
3705 if (TREE_PURPOSE (link) == context)
3706 return RTL_EXPR_RTL (TREE_VALUE (link));
3707
3708 abort ();
3709}
3710\f
3711/* Convert a stack slot address ADDR for variable VAR
3712 (from a containing function)
3713 into an address valid in this function (using a static chain). */
3714
3715rtx
3716fix_lexical_addr (addr, var)
3717 rtx addr;
3718 tree var;
3719{
3720 rtx basereg;
3721 int displacement;
3722 tree context = decl_function_context (var);
3723 struct function *fp;
3724 rtx base = 0;
3725
3726 /* If this is the present function, we need not do anything. */
3727 if (context == current_function_decl || context == inline_function_decl)
3728 return addr;
3729
3730 for (fp = outer_function_chain; fp; fp = fp->next)
3731 if (fp->decl == context)
3732 break;
3733
3734 if (fp == 0)
3735 abort ();
3736
3737 /* Decode given address as base reg plus displacement. */
3738 if (GET_CODE (addr) == REG)
3739 basereg = addr, displacement = 0;
3740 else if (GET_CODE (addr) == PLUS && GET_CODE (XEXP (addr, 1)) == CONST_INT)
3741 basereg = XEXP (addr, 0), displacement = INTVAL (XEXP (addr, 1));
3742 else
3743 abort ();
3744
3745 /* We accept vars reached via the containing function's
3746 incoming arg pointer and via its stack variables pointer. */
3747 if (basereg == fp->internal_arg_pointer)
3748 {
3749 /* If reached via arg pointer, get the arg pointer value
3750 out of that function's stack frame.
3751
3752 There are two cases: If a separate ap is needed, allocate a
3753 slot in the outer function for it and dereference it that way.
3754 This is correct even if the real ap is actually a pseudo.
3755 Otherwise, just adjust the offset from the frame pointer to
3756 compensate. */
3757
3758#ifdef NEED_SEPARATE_AP
3759 rtx addr;
3760
3761 if (fp->arg_pointer_save_area == 0)
3762 fp->arg_pointer_save_area
3763 = assign_outer_stack_local (Pmode, GET_MODE_SIZE (Pmode), 0, fp);
3764
3765 addr = fix_lexical_addr (XEXP (fp->arg_pointer_save_area, 0), var);
3766 addr = memory_address (Pmode, addr);
3767
3768 base = copy_to_reg (gen_rtx (MEM, Pmode, addr));
3769#else
3770 displacement += (FIRST_PARM_OFFSET (context) - STARTING_FRAME_OFFSET);
86f8eff3 3771 base = lookup_static_chain (var);
6f086dfc
RS
3772#endif
3773 }
3774
3775 else if (basereg == virtual_stack_vars_rtx)
3776 {
3777 /* This is the same code as lookup_static_chain, duplicated here to
3778 avoid an extra call to decl_function_context. */
3779 tree link;
3780
3781 for (link = context_display; link; link = TREE_CHAIN (link))
3782 if (TREE_PURPOSE (link) == context)
3783 {
3784 base = RTL_EXPR_RTL (TREE_VALUE (link));
3785 break;
3786 }
3787 }
3788
3789 if (base == 0)
3790 abort ();
3791
3792 /* Use same offset, relative to appropriate static chain or argument
3793 pointer. */
3794 return plus_constant (base, displacement);
3795}
3796\f
3797/* Return the address of the trampoline for entering nested fn FUNCTION.
3798 If necessary, allocate a trampoline (in the stack frame)
3799 and emit rtl to initialize its contents (at entry to this function). */
3800
3801rtx
3802trampoline_address (function)
3803 tree function;
3804{
3805 tree link;
3806 tree rtlexp;
3807 rtx tramp;
3808 struct function *fp;
3809 tree fn_context;
3810
3811 /* Find an existing trampoline and return it. */
3812 for (link = trampoline_list; link; link = TREE_CHAIN (link))
3813 if (TREE_PURPOSE (link) == function)
3814 return XEXP (RTL_EXPR_RTL (TREE_VALUE (link)), 0);
3815 for (fp = outer_function_chain; fp; fp = fp->next)
3816 for (link = fp->trampoline_list; link; link = TREE_CHAIN (link))
3817 if (TREE_PURPOSE (link) == function)
3818 {
3819 tramp = fix_lexical_addr (XEXP (RTL_EXPR_RTL (TREE_VALUE (link)), 0),
3820 function);
3821 return round_trampoline_addr (tramp);
3822 }
3823
3824 /* None exists; we must make one. */
3825
3826 /* Find the `struct function' for the function containing FUNCTION. */
3827 fp = 0;
3828 fn_context = decl_function_context (function);
3829 if (fn_context != current_function_decl)
3830 for (fp = outer_function_chain; fp; fp = fp->next)
3831 if (fp->decl == fn_context)
3832 break;
3833
3834 /* Allocate run-time space for this trampoline
3835 (usually in the defining function's stack frame). */
3836#ifdef ALLOCATE_TRAMPOLINE
3837 tramp = ALLOCATE_TRAMPOLINE (fp);
3838#else
3839 /* If rounding needed, allocate extra space
3840 to ensure we have TRAMPOLINE_SIZE bytes left after rounding up. */
3841#ifdef TRAMPOLINE_ALIGNMENT
3842#define TRAMPOLINE_REAL_SIZE (TRAMPOLINE_SIZE + TRAMPOLINE_ALIGNMENT - 1)
3843#else
3844#define TRAMPOLINE_REAL_SIZE (TRAMPOLINE_SIZE)
3845#endif
3846 if (fp != 0)
3847 tramp = assign_outer_stack_local (BLKmode, TRAMPOLINE_REAL_SIZE, 0, fp);
3848 else
3849 tramp = assign_stack_local (BLKmode, TRAMPOLINE_REAL_SIZE, 0);
3850#endif
3851
3852 /* Record the trampoline for reuse and note it for later initialization
3853 by expand_function_end. */
3854 if (fp != 0)
3855 {
3856 push_obstacks (fp->current_obstack, fp->function_maybepermanent_obstack);
3857 rtlexp = make_node (RTL_EXPR);
3858 RTL_EXPR_RTL (rtlexp) = tramp;
3859 fp->trampoline_list = tree_cons (function, rtlexp, fp->trampoline_list);
3860 pop_obstacks ();
3861 }
3862 else
3863 {
3864 /* Make the RTL_EXPR node temporary, not momentary, so that the
3865 trampoline_list doesn't become garbage. */
3866 int momentary = suspend_momentary ();
3867 rtlexp = make_node (RTL_EXPR);
3868 resume_momentary (momentary);
3869
3870 RTL_EXPR_RTL (rtlexp) = tramp;
3871 trampoline_list = tree_cons (function, rtlexp, trampoline_list);
3872 }
3873
3874 tramp = fix_lexical_addr (XEXP (tramp, 0), function);
3875 return round_trampoline_addr (tramp);
3876}
3877
3878/* Given a trampoline address,
3879 round it to multiple of TRAMPOLINE_ALIGNMENT. */
3880
3881static rtx
3882round_trampoline_addr (tramp)
3883 rtx tramp;
3884{
3885#ifdef TRAMPOLINE_ALIGNMENT
3886 /* Round address up to desired boundary. */
3887 rtx temp = gen_reg_rtx (Pmode);
3888 temp = expand_binop (Pmode, add_optab, tramp,
5f4f0e22 3889 GEN_INT (TRAMPOLINE_ALIGNMENT - 1),
6f086dfc
RS
3890 temp, 0, OPTAB_LIB_WIDEN);
3891 tramp = expand_binop (Pmode, and_optab, temp,
5f4f0e22 3892 GEN_INT (- TRAMPOLINE_ALIGNMENT),
6f086dfc
RS
3893 temp, 0, OPTAB_LIB_WIDEN);
3894#endif
3895 return tramp;
3896}
3897\f
467456d0
RS
3898/* The functions identify_blocks and reorder_blocks provide a way to
3899 reorder the tree of BLOCK nodes, for optimizers that reshuffle or
3900 duplicate portions of the RTL code. Call identify_blocks before
3901 changing the RTL, and call reorder_blocks after. */
3902
3903static int all_blocks ();
3904static tree blocks_nreverse ();
3905
3906/* Put all this function's BLOCK nodes into a vector, and return it.
3907 Also store in each NOTE for the beginning or end of a block
3908 the index of that block in the vector.
3909 The arguments are TOP_BLOCK, the top-level block of the function,
3910 and INSNS, the insn chain of the function. */
3911
3912tree *
3913identify_blocks (top_block, insns)
3914 tree top_block;
3915 rtx insns;
3916{
fc289cd1
JW
3917 int n_blocks;
3918 tree *block_vector;
3919 int *block_stack;
467456d0
RS
3920 int depth = 0;
3921 int next_block_number = 0;
3922 int current_block_number = 0;
3923 rtx insn;
3924
fc289cd1
JW
3925 if (top_block == 0)
3926 return 0;
3927
3928 n_blocks = all_blocks (top_block, 0);
3929 block_vector = (tree *) xmalloc (n_blocks * sizeof (tree));
3930 block_stack = (int *) alloca (n_blocks * sizeof (int));
3931
467456d0
RS
3932 all_blocks (top_block, block_vector);
3933
3934 for (insn = insns; insn; insn = NEXT_INSN (insn))
3935 if (GET_CODE (insn) == NOTE)
3936 {
3937 if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_BLOCK_BEG)
3938 {
3939 block_stack[depth++] = current_block_number;
3940 current_block_number = next_block_number;
1b2ac438 3941 NOTE_BLOCK_NUMBER (insn) = next_block_number++;
467456d0
RS
3942 }
3943 if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_BLOCK_END)
3944 {
3945 current_block_number = block_stack[--depth];
1b2ac438 3946 NOTE_BLOCK_NUMBER (insn) = current_block_number;
467456d0
RS
3947 }
3948 }
3949
3950 return block_vector;
3951}
3952
3953/* Given BLOCK_VECTOR which was returned by identify_blocks,
3954 and a revised instruction chain, rebuild the tree structure
3955 of BLOCK nodes to correspond to the new order of RTL.
fc289cd1 3956 The new block tree is inserted below TOP_BLOCK.
467456d0
RS
3957 Returns the current top-level block. */
3958
3959tree
fc289cd1 3960reorder_blocks (block_vector, top_block, insns)
467456d0 3961 tree *block_vector;
fc289cd1 3962 tree top_block;
467456d0
RS
3963 rtx insns;
3964{
fc289cd1 3965 tree current_block = top_block;
467456d0
RS
3966 rtx insn;
3967
fc289cd1
JW
3968 if (block_vector == 0)
3969 return top_block;
3970
3971 /* Prune the old tree away, so that it doesn't get in the way. */
3972 BLOCK_SUBBLOCKS (current_block) = 0;
3973
467456d0
RS
3974 for (insn = insns; insn; insn = NEXT_INSN (insn))
3975 if (GET_CODE (insn) == NOTE)
3976 {
3977 if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_BLOCK_BEG)
3978 {
3979 tree block = block_vector[NOTE_BLOCK_NUMBER (insn)];
3980 /* If we have seen this block before, copy it. */
3981 if (TREE_ASM_WRITTEN (block))
3982 block = copy_node (block);
fc289cd1 3983 BLOCK_SUBBLOCKS (block) = 0;
467456d0
RS
3984 TREE_ASM_WRITTEN (block) = 1;
3985 BLOCK_SUPERCONTEXT (block) = current_block;
3986 BLOCK_CHAIN (block) = BLOCK_SUBBLOCKS (current_block);
3987 BLOCK_SUBBLOCKS (current_block) = block;
3988 current_block = block;
1b2ac438 3989 NOTE_SOURCE_FILE (insn) = 0;
467456d0
RS
3990 }
3991 if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_BLOCK_END)
3992 {
3993 BLOCK_SUBBLOCKS (current_block)
3994 = blocks_nreverse (BLOCK_SUBBLOCKS (current_block));
3995 current_block = BLOCK_SUPERCONTEXT (current_block);
1b2ac438 3996 NOTE_SOURCE_FILE (insn) = 0;
467456d0
RS
3997 }
3998 }
3999
4000 return current_block;
4001}
4002
4003/* Reverse the order of elements in the chain T of blocks,
4004 and return the new head of the chain (old last element). */
4005
4006static tree
4007blocks_nreverse (t)
4008 tree t;
4009{
4010 register tree prev = 0, decl, next;
4011 for (decl = t; decl; decl = next)
4012 {
4013 next = BLOCK_CHAIN (decl);
4014 BLOCK_CHAIN (decl) = prev;
4015 prev = decl;
4016 }
4017 return prev;
4018}
4019
4020/* Count the subblocks of BLOCK, and list them all into the vector VECTOR.
4021 Also clear TREE_ASM_WRITTEN in all blocks. */
4022
4023static int
4024all_blocks (block, vector)
4025 tree block;
4026 tree *vector;
4027{
4028 int n_blocks = 1;
4029 tree subblocks;
4030
4031 TREE_ASM_WRITTEN (block) = 0;
4032 /* Record this block. */
fc289cd1
JW
4033 if (vector)
4034 vector[0] = block;
467456d0
RS
4035
4036 /* Record the subblocks, and their subblocks. */
4037 for (subblocks = BLOCK_SUBBLOCKS (block);
4038 subblocks; subblocks = BLOCK_CHAIN (subblocks))
fc289cd1 4039 n_blocks += all_blocks (subblocks, vector ? vector + n_blocks : 0);
467456d0
RS
4040
4041 return n_blocks;
4042}
4043\f
6f086dfc
RS
4044/* Generate RTL for the start of the function SUBR (a FUNCTION_DECL tree node)
4045 and initialize static variables for generating RTL for the statements
4046 of the function. */
4047
4048void
4049init_function_start (subr, filename, line)
4050 tree subr;
4051 char *filename;
4052 int line;
4053{
4054 char *junk;
4055
4056 init_stmt_for_function ();
4057
4058 cse_not_expected = ! optimize;
4059
4060 /* Caller save not needed yet. */
4061 caller_save_needed = 0;
4062
4063 /* No stack slots have been made yet. */
4064 stack_slot_list = 0;
4065
4066 /* There is no stack slot for handling nonlocal gotos. */
4067 nonlocal_goto_handler_slot = 0;
4068 nonlocal_goto_stack_level = 0;
4069
4070 /* No labels have been declared for nonlocal use. */
4071 nonlocal_labels = 0;
4072
4073 /* No function calls so far in this function. */
4074 function_call_count = 0;
4075
4076 /* No parm regs have been allocated.
4077 (This is important for output_inline_function.) */
4078 max_parm_reg = LAST_VIRTUAL_REGISTER + 1;
4079
4080 /* Initialize the RTL mechanism. */
4081 init_emit ();
4082
4083 /* Initialize the queue of pending postincrement and postdecrements,
4084 and some other info in expr.c. */
4085 init_expr ();
4086
4087 /* We haven't done register allocation yet. */
4088 reg_renumber = 0;
4089
4090 init_const_rtx_hash_table ();
4091
4092 current_function_name = (*decl_printable_name) (subr, &junk);
4093
4094 /* Nonzero if this is a nested function that uses a static chain. */
4095
4096 current_function_needs_context
4097 = (decl_function_context (current_function_decl) != 0);
4098
4099 /* Set if a call to setjmp is seen. */
4100 current_function_calls_setjmp = 0;
4101
4102 /* Set if a call to longjmp is seen. */
4103 current_function_calls_longjmp = 0;
4104
4105 current_function_calls_alloca = 0;
4106 current_function_has_nonlocal_label = 0;
4107 current_function_contains_functions = 0;
4108
4109 current_function_returns_pcc_struct = 0;
4110 current_function_returns_struct = 0;
4111 current_function_epilogue_delay_list = 0;
4112 current_function_uses_const_pool = 0;
4113 current_function_uses_pic_offset_table = 0;
4114
4115 /* We have not yet needed to make a label to jump to for tail-recursion. */
4116 tail_recursion_label = 0;
4117
4118 /* We haven't had a need to make a save area for ap yet. */
4119
4120 arg_pointer_save_area = 0;
4121
4122 /* No stack slots allocated yet. */
4123 frame_offset = 0;
4124
4125 /* No SAVE_EXPRs in this function yet. */
4126 save_expr_regs = 0;
4127
4128 /* No RTL_EXPRs in this function yet. */
4129 rtl_expr_chain = 0;
4130
4131 /* We have not allocated any temporaries yet. */
4132 temp_slots = 0;
4133 temp_slot_level = 0;
4134
4135 /* Within function body, compute a type's size as soon it is laid out. */
4136 immediate_size_expand++;
4137
4138 init_pending_stack_adjust ();
4139 inhibit_defer_pop = 0;
4140
4141 current_function_outgoing_args_size = 0;
4142
4143 /* Initialize the insn lengths. */
4144 init_insn_lengths ();
4145
4146 /* Prevent ever trying to delete the first instruction of a function.
4147 Also tell final how to output a linenum before the function prologue. */
4148 emit_line_note (filename, line);
4149
4150 /* Make sure first insn is a note even if we don't want linenums.
4151 This makes sure the first insn will never be deleted.
4152 Also, final expects a note to appear there. */
5f4f0e22 4153 emit_note (NULL_PTR, NOTE_INSN_DELETED);
6f086dfc
RS
4154
4155 /* Set flags used by final.c. */
4156 if (aggregate_value_p (DECL_RESULT (subr)))
4157 {
4158#ifdef PCC_STATIC_STRUCT_RETURN
4159 if (flag_pcc_struct_return)
4160 current_function_returns_pcc_struct = 1;
4161 else
4162#endif
4163 current_function_returns_struct = 1;
4164 }
4165
4166 /* Warn if this value is an aggregate type,
4167 regardless of which calling convention we are using for it. */
4168 if (warn_aggregate_return
4169 && (TREE_CODE (TREE_TYPE (DECL_RESULT (subr))) == RECORD_TYPE
4170 || TREE_CODE (TREE_TYPE (DECL_RESULT (subr))) == UNION_TYPE
4171 || TREE_CODE (TREE_TYPE (DECL_RESULT (subr))) == ARRAY_TYPE))
4172 warning ("function returns an aggregate");
4173
4174 current_function_returns_pointer
4175 = (TREE_CODE (TREE_TYPE (DECL_RESULT (subr))) == POINTER_TYPE);
4176
4177 /* Indicate that we need to distinguish between the return value of the
4178 present function and the return value of a function being called. */
4179 rtx_equal_function_value_matters = 1;
4180
4181 /* Indicate that we have not instantiated virtual registers yet. */
4182 virtuals_instantiated = 0;
4183
4184 /* Indicate we have no need of a frame pointer yet. */
4185 frame_pointer_needed = 0;
4186
4187 /* By default assume not varargs. */
4188 current_function_varargs = 0;
4189}
4190
4191/* Indicate that the current function uses extra args
4192 not explicitly mentioned in the argument list in any fashion. */
4193
4194void
4195mark_varargs ()
4196{
4197 current_function_varargs = 1;
4198}
4199
4200/* Expand a call to __main at the beginning of a possible main function. */
4201
4202void
4203expand_main_function ()
4204{
b335c2cc 4205#if !defined (INIT_SECTION_ASM_OP) || defined (INVOKE__main)
6f086dfc
RS
4206 emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "__main"), 0,
4207 VOIDmode, 0);
b335c2cc 4208#endif /* not INIT_SECTION_ASM_OP or INVOKE__main */
6f086dfc
RS
4209}
4210\f
4211/* Start the RTL for a new function, and set variables used for
4212 emitting RTL.
4213 SUBR is the FUNCTION_DECL node.
4214 PARMS_HAVE_CLEANUPS is nonzero if there are cleanups associated with
4215 the function's parameters, which must be run at any return statement. */
4216
4217void
4218expand_function_start (subr, parms_have_cleanups)
4219 tree subr;
4220 int parms_have_cleanups;
4221{
4222 register int i;
4223 tree tem;
4224 rtx last_ptr;
4225
4226 /* Make sure volatile mem refs aren't considered
4227 valid operands of arithmetic insns. */
4228 init_recog_no_volatile ();
4229
4230 /* If function gets a static chain arg, store it in the stack frame.
4231 Do this first, so it gets the first stack slot offset. */
4232 if (current_function_needs_context)
3e2481e9
JW
4233 {
4234 last_ptr = assign_stack_local (Pmode, GET_MODE_SIZE (Pmode), 0);
4235 emit_move_insn (last_ptr, static_chain_incoming_rtx);
4236 }
6f086dfc
RS
4237
4238 /* If the parameters of this function need cleaning up, get a label
4239 for the beginning of the code which executes those cleanups. This must
4240 be done before doing anything with return_label. */
4241 if (parms_have_cleanups)
4242 cleanup_label = gen_label_rtx ();
4243 else
4244 cleanup_label = 0;
4245
4246 /* Make the label for return statements to jump to, if this machine
4247 does not have a one-instruction return and uses an epilogue,
4248 or if it returns a structure, or if it has parm cleanups. */
4249#ifdef HAVE_return
4250 if (cleanup_label == 0 && HAVE_return
4251 && ! current_function_returns_pcc_struct
4252 && ! (current_function_returns_struct && ! optimize))
4253 return_label = 0;
4254 else
4255 return_label = gen_label_rtx ();
4256#else
4257 return_label = gen_label_rtx ();
4258#endif
4259
4260 /* Initialize rtx used to return the value. */
4261 /* Do this before assign_parms so that we copy the struct value address
4262 before any library calls that assign parms might generate. */
4263
4264 /* Decide whether to return the value in memory or in a register. */
4265 if (aggregate_value_p (DECL_RESULT (subr)))
4266 {
4267 /* Returning something that won't go in a register. */
4268 register rtx value_address;
4269
4270#ifdef PCC_STATIC_STRUCT_RETURN
4271 if (current_function_returns_pcc_struct)
4272 {
4273 int size = int_size_in_bytes (TREE_TYPE (DECL_RESULT (subr)));
4274 value_address = assemble_static_space (size);
4275 }
4276 else
4277#endif
4278 {
4279 /* Expect to be passed the address of a place to store the value.
4280 If it is passed as an argument, assign_parms will take care of
4281 it. */
4282 if (struct_value_incoming_rtx)
4283 {
4284 value_address = gen_reg_rtx (Pmode);
4285 emit_move_insn (value_address, struct_value_incoming_rtx);
4286 }
4287 }
4288 if (value_address)
4289 DECL_RTL (DECL_RESULT (subr))
4290 = gen_rtx (MEM, DECL_MODE (DECL_RESULT (subr)),
4291 value_address);
4292 }
4293 else if (DECL_MODE (DECL_RESULT (subr)) == VOIDmode)
4294 /* If return mode is void, this decl rtl should not be used. */
4295 DECL_RTL (DECL_RESULT (subr)) = 0;
4296 else if (parms_have_cleanups)
a53e14c0
RK
4297 {
4298 /* If function will end with cleanup code for parms,
4299 compute the return values into a pseudo reg,
4300 which we will copy into the true return register
4301 after the cleanups are done. */
4302
4303 enum machine_mode mode = DECL_MODE (DECL_RESULT (subr));
4304#ifdef PROMOTE_FUNCTION_RETURN
4305 tree type = TREE_TYPE (DECL_RESULT (subr));
4306 int unsignedp = TREE_UNSIGNED (type);
4307
4308 if (TREE_CODE (type) == INTEGER_TYPE || TREE_CODE (type) == ENUMERAL_TYPE
4309 || TREE_CODE (type) == BOOLEAN_TYPE || TREE_CODE (type) == CHAR_TYPE
4310 || TREE_CODE (type) == REAL_TYPE || TREE_CODE (type) == POINTER_TYPE
4311 || TREE_CODE (type) == OFFSET_TYPE)
4312 {
4313 PROMOTE_MODE (mode, unsignedp, type);
4314 }
4315#endif
4316
4317 DECL_RTL (DECL_RESULT (subr)) = gen_reg_rtx (mode);
4318 }
6f086dfc
RS
4319 else
4320 /* Scalar, returned in a register. */
4321 {
4322#ifdef FUNCTION_OUTGOING_VALUE
4323 DECL_RTL (DECL_RESULT (subr))
4324 = FUNCTION_OUTGOING_VALUE (TREE_TYPE (DECL_RESULT (subr)), subr);
4325#else
4326 DECL_RTL (DECL_RESULT (subr))
4327 = FUNCTION_VALUE (TREE_TYPE (DECL_RESULT (subr)), subr);
4328#endif
4329
4330 /* Mark this reg as the function's return value. */
4331 if (GET_CODE (DECL_RTL (DECL_RESULT (subr))) == REG)
4332 {
4333 REG_FUNCTION_VALUE_P (DECL_RTL (DECL_RESULT (subr))) = 1;
4334 /* Needed because we may need to move this to memory
4335 in case it's a named return value whose address is taken. */
a82ad570 4336 DECL_REGISTER (DECL_RESULT (subr)) = 1;
6f086dfc
RS
4337 }
4338 }
4339
4340 /* Initialize rtx for parameters and local variables.
4341 In some cases this requires emitting insns. */
4342
4343 assign_parms (subr, 0);
4344
4345 /* The following was moved from init_function_start.
4346 The move is supposed to make sdb output more accurate. */
4347 /* Indicate the beginning of the function body,
4348 as opposed to parm setup. */
5f4f0e22 4349 emit_note (NULL_PTR, NOTE_INSN_FUNCTION_BEG);
6f086dfc
RS
4350
4351 /* If doing stupid allocation, mark parms as born here. */
4352
4353 if (GET_CODE (get_last_insn ()) != NOTE)
5f4f0e22 4354 emit_note (NULL_PTR, NOTE_INSN_DELETED);
6f086dfc
RS
4355 parm_birth_insn = get_last_insn ();
4356
4357 if (obey_regdecls)
4358 {
4359 for (i = LAST_VIRTUAL_REGISTER + 1; i < max_parm_reg; i++)
4360 use_variable (regno_reg_rtx[i]);
4361
4362 if (current_function_internal_arg_pointer != virtual_incoming_args_rtx)
4363 use_variable (current_function_internal_arg_pointer);
4364 }
4365
4366 /* Fetch static chain values for containing functions. */
4367 tem = decl_function_context (current_function_decl);
3e2481e9
JW
4368 /* If not doing stupid register allocation, then start off with the static
4369 chain pointer in a pseudo register. Otherwise, we use the stack
4370 address that was generated above. */
4371 if (tem && ! obey_regdecls)
6f086dfc
RS
4372 last_ptr = copy_to_reg (static_chain_incoming_rtx);
4373 context_display = 0;
4374 while (tem)
4375 {
4376 tree rtlexp = make_node (RTL_EXPR);
4377
4378 RTL_EXPR_RTL (rtlexp) = last_ptr;
4379 context_display = tree_cons (tem, rtlexp, context_display);
4380 tem = decl_function_context (tem);
4381 if (tem == 0)
4382 break;
4383 /* Chain thru stack frames, assuming pointer to next lexical frame
4384 is found at the place we always store it. */
4385#ifdef FRAME_GROWS_DOWNWARD
4386 last_ptr = plus_constant (last_ptr, - GET_MODE_SIZE (Pmode));
4387#endif
4388 last_ptr = copy_to_reg (gen_rtx (MEM, Pmode,
4389 memory_address (Pmode, last_ptr)));
4390 }
4391
4392 /* After the display initializations is where the tail-recursion label
4393 should go, if we end up needing one. Ensure we have a NOTE here
4394 since some things (like trampolines) get placed before this. */
5f4f0e22 4395 tail_recursion_reentry = emit_note (NULL_PTR, NOTE_INSN_DELETED);
6f086dfc
RS
4396
4397 /* Evaluate now the sizes of any types declared among the arguments. */
4398 for (tem = nreverse (get_pending_sizes ()); tem; tem = TREE_CHAIN (tem))
4752d3bc 4399 expand_expr (TREE_VALUE (tem), const0_rtx, VOIDmode, 0);
6f086dfc
RS
4400
4401 /* Make sure there is a line number after the function entry setup code. */
4402 force_next_line_note ();
4403}
4404\f
4405/* Generate RTL for the end of the current function.
4406 FILENAME and LINE are the current position in the source file. */
4407
4408/* It is up to language-specific callers to do cleanups for parameters. */
4409
4410void
4411expand_function_end (filename, line)
4412 char *filename;
4413 int line;
4414{
4415 register int i;
4416 tree link;
4417
4418 static rtx initial_trampoline;
4419
4420#ifdef NON_SAVING_SETJMP
4421 /* Don't put any variables in registers if we call setjmp
4422 on a machine that fails to restore the registers. */
4423 if (NON_SAVING_SETJMP && current_function_calls_setjmp)
4424 {
4425 setjmp_protect (DECL_INITIAL (current_function_decl));
4426 setjmp_protect_args ();
4427 }
4428#endif
4429
4430 /* Save the argument pointer if a save area was made for it. */
4431 if (arg_pointer_save_area)
4432 {
4433 rtx x = gen_move_insn (arg_pointer_save_area, virtual_incoming_args_rtx);
4434 emit_insn_before (x, tail_recursion_reentry);
4435 }
4436
4437 /* Initialize any trampolines required by this function. */
4438 for (link = trampoline_list; link; link = TREE_CHAIN (link))
4439 {
4440 tree function = TREE_PURPOSE (link);
4441 rtx context = lookup_static_chain (function);
4442 rtx tramp = RTL_EXPR_RTL (TREE_VALUE (link));
4443 rtx seq;
4444
4445 /* First make sure this compilation has a template for
4446 initializing trampolines. */
4447 if (initial_trampoline == 0)
86f8eff3
RK
4448 {
4449 end_temporary_allocation ();
4450 initial_trampoline
4451 = gen_rtx (MEM, BLKmode, assemble_trampoline_template ());
4452 resume_temporary_allocation ();
4453 }
6f086dfc
RS
4454
4455 /* Generate insns to initialize the trampoline. */
4456 start_sequence ();
4457 tramp = change_address (initial_trampoline, BLKmode,
4458 round_trampoline_addr (XEXP (tramp, 0)));
5f4f0e22 4459 emit_block_move (tramp, initial_trampoline, GEN_INT (TRAMPOLINE_SIZE),
6f086dfc
RS
4460 FUNCTION_BOUNDARY / BITS_PER_UNIT);
4461 INITIALIZE_TRAMPOLINE (XEXP (tramp, 0),
4462 XEXP (DECL_RTL (function), 0), context);
4463 seq = get_insns ();
4464 end_sequence ();
4465
4466 /* Put those insns at entry to the containing function (this one). */
4467 emit_insns_before (seq, tail_recursion_reentry);
4468 }
4469 /* Clear the trampoline_list for the next function. */
4470 trampoline_list = 0;
4471
4472#if 0 /* I think unused parms are legitimate enough. */
4473 /* Warn about unused parms. */
4474 if (warn_unused)
4475 {
4476 rtx decl;
4477
4478 for (decl = DECL_ARGUMENTS (current_function_decl);
4479 decl; decl = TREE_CHAIN (decl))
4480 if (! TREE_USED (decl) && TREE_CODE (decl) == VAR_DECL)
4481 warning_with_decl (decl, "unused parameter `%s'");
4482 }
4483#endif
4484
4485 /* Delete handlers for nonlocal gotos if nothing uses them. */
4486 if (nonlocal_goto_handler_slot != 0 && !current_function_has_nonlocal_label)
4487 delete_handlers ();
4488
4489 /* End any sequences that failed to be closed due to syntax errors. */
4490 while (in_sequence_p ())
5f4f0e22 4491 end_sequence ();
6f086dfc
RS
4492
4493 /* Outside function body, can't compute type's actual size
4494 until next function's body starts. */
4495 immediate_size_expand--;
4496
4497 /* If doing stupid register allocation,
4498 mark register parms as dying here. */
4499
4500 if (obey_regdecls)
4501 {
4502 rtx tem;
4503 for (i = LAST_VIRTUAL_REGISTER + 1; i < max_parm_reg; i++)
4504 use_variable (regno_reg_rtx[i]);
4505
4506 /* Likewise for the regs of all the SAVE_EXPRs in the function. */
4507
4508 for (tem = save_expr_regs; tem; tem = XEXP (tem, 1))
4509 {
4510 use_variable (XEXP (tem, 0));
4511 use_variable_after (XEXP (tem, 0), parm_birth_insn);
4512 }
4513
4514 if (current_function_internal_arg_pointer != virtual_incoming_args_rtx)
4515 use_variable (current_function_internal_arg_pointer);
4516 }
4517
4518 clear_pending_stack_adjust ();
4519 do_pending_stack_adjust ();
4520
4521 /* Mark the end of the function body.
4522 If control reaches this insn, the function can drop through
4523 without returning a value. */
5f4f0e22 4524 emit_note (NULL_PTR, NOTE_INSN_FUNCTION_END);
6f086dfc
RS
4525
4526 /* Output a linenumber for the end of the function.
4527 SDB depends on this. */
4528 emit_line_note_force (filename, line);
4529
4530 /* Output the label for the actual return from the function,
4531 if one is expected. This happens either because a function epilogue
4532 is used instead of a return instruction, or because a return was done
4533 with a goto in order to run local cleanups, or because of pcc-style
4534 structure returning. */
4535
4536 if (return_label)
4537 emit_label (return_label);
4538
4539 /* If we had calls to alloca, and this machine needs
4540 an accurate stack pointer to exit the function,
4541 insert some code to save and restore the stack pointer. */
4542#ifdef EXIT_IGNORE_STACK
4543 if (! EXIT_IGNORE_STACK)
4544#endif
4545 if (current_function_calls_alloca)
4546 {
59257ff7
RK
4547 rtx tem = 0;
4548
4549 emit_stack_save (SAVE_FUNCTION, &tem, parm_birth_insn);
5f4f0e22 4550 emit_stack_restore (SAVE_FUNCTION, tem, NULL_RTX);
6f086dfc
RS
4551 }
4552
4553 /* If scalar return value was computed in a pseudo-reg,
4554 copy that to the hard return register. */
4555 if (DECL_RTL (DECL_RESULT (current_function_decl)) != 0
4556 && GET_CODE (DECL_RTL (DECL_RESULT (current_function_decl))) == REG
4557 && (REGNO (DECL_RTL (DECL_RESULT (current_function_decl)))
4558 >= FIRST_PSEUDO_REGISTER))
4559 {
4560 rtx real_decl_result;
4561
4562#ifdef FUNCTION_OUTGOING_VALUE
4563 real_decl_result
4564 = FUNCTION_OUTGOING_VALUE (TREE_TYPE (DECL_RESULT (current_function_decl)),
4565 current_function_decl);
4566#else
4567 real_decl_result
4568 = FUNCTION_VALUE (TREE_TYPE (DECL_RESULT (current_function_decl)),
4569 current_function_decl);
4570#endif
4571 REG_FUNCTION_VALUE_P (real_decl_result) = 1;
4572 emit_move_insn (real_decl_result,
4573 DECL_RTL (DECL_RESULT (current_function_decl)));
4574 emit_insn (gen_rtx (USE, VOIDmode, real_decl_result));
4575 }
4576
4577 /* If returning a structure, arrange to return the address of the value
4578 in a place where debuggers expect to find it.
4579
4580 If returning a structure PCC style,
4581 the caller also depends on this value.
4582 And current_function_returns_pcc_struct is not necessarily set. */
4583 if (current_function_returns_struct
4584 || current_function_returns_pcc_struct)
4585 {
4586 rtx value_address = XEXP (DECL_RTL (DECL_RESULT (current_function_decl)), 0);
4587 tree type = TREE_TYPE (DECL_RESULT (current_function_decl));
4588#ifdef FUNCTION_OUTGOING_VALUE
4589 rtx outgoing
4590 = FUNCTION_OUTGOING_VALUE (build_pointer_type (type),
4591 current_function_decl);
4592#else
4593 rtx outgoing
4594 = FUNCTION_VALUE (build_pointer_type (type),
4595 current_function_decl);
4596#endif
4597
4598 /* Mark this as a function return value so integrate will delete the
4599 assignment and USE below when inlining this function. */
4600 REG_FUNCTION_VALUE_P (outgoing) = 1;
4601
4602 emit_move_insn (outgoing, value_address);
4603 use_variable (outgoing);
4604 }
4605
4606 /* Output a return insn if we are using one.
4607 Otherwise, let the rtl chain end here, to drop through
4608 into the epilogue. */
4609
4610#ifdef HAVE_return
4611 if (HAVE_return)
4612 {
4613 emit_jump_insn (gen_return ());
4614 emit_barrier ();
4615 }
4616#endif
4617
4618 /* Fix up any gotos that jumped out to the outermost
4619 binding level of the function.
4620 Must follow emitting RETURN_LABEL. */
4621
4622 /* If you have any cleanups to do at this point,
4623 and they need to create temporary variables,
4624 then you will lose. */
5f4f0e22 4625 fixup_gotos (NULL_PTR, NULL_RTX, NULL_TREE, get_insns (), 0);
6f086dfc 4626}
bdac5f58
TW
4627\f
4628/* These arrays record the INSN_UIDs of the prologue and epilogue insns. */
4629
4630static int *prologue;
4631static int *epilogue;
4632
4633/* Create an array that records the INSN_UIDs of INSNS (either a sequence
4634 or a single insn). */
4635
4636static int *
4637record_insns (insns)
4638 rtx insns;
4639{
4640 int *vec;
4641
4642 if (GET_CODE (insns) == SEQUENCE)
4643 {
4644 int len = XVECLEN (insns, 0);
4645 vec = (int *) oballoc ((len + 1) * sizeof (int));
4646 vec[len] = 0;
4647 while (--len >= 0)
4648 vec[len] = INSN_UID (XVECEXP (insns, 0, len));
4649 }
4650 else
4651 {
4652 vec = (int *) oballoc (2 * sizeof (int));
4653 vec[0] = INSN_UID (insns);
4654 vec[1] = 0;
4655 }
4656 return vec;
4657}
4658
10914065 4659/* Determine how many INSN_UIDs in VEC are part of INSN. */
bdac5f58 4660
10914065 4661static int
bdac5f58
TW
4662contains (insn, vec)
4663 rtx insn;
4664 int *vec;
4665{
4666 register int i, j;
4667
4668 if (GET_CODE (insn) == INSN
4669 && GET_CODE (PATTERN (insn)) == SEQUENCE)
4670 {
10914065 4671 int count = 0;
bdac5f58
TW
4672 for (i = XVECLEN (PATTERN (insn), 0) - 1; i >= 0; i--)
4673 for (j = 0; vec[j]; j++)
4674 if (INSN_UID (XVECEXP (PATTERN (insn), 0, i)) == vec[j])
10914065
TW
4675 count++;
4676 return count;
bdac5f58
TW
4677 }
4678 else
4679 {
4680 for (j = 0; vec[j]; j++)
4681 if (INSN_UID (insn) == vec[j])
10914065 4682 return 1;
bdac5f58
TW
4683 }
4684 return 0;
4685}
4686
4687/* Generate the prologe and epilogue RTL if the machine supports it. Thread
4688 this into place with notes indicating where the prologue ends and where
4689 the epilogue begins. Update the basic block information when possible. */
4690
4691void
4692thread_prologue_and_epilogue_insns (f)
4693 rtx f;
4694{
4695#ifdef HAVE_prologue
4696 if (HAVE_prologue)
4697 {
4698 rtx head, seq, insn;
4699
4700 /* The first insn (a NOTE_INSN_DELETED) is followed by zero or more
4701 prologue insns and a NOTE_INSN_PROLOGUE_END. */
4702 emit_note_after (NOTE_INSN_PROLOGUE_END, f);
4703 seq = gen_prologue ();
4704 head = emit_insn_after (seq, f);
4705
4706 /* Include the new prologue insns in the first block. Ignore them
4707 if they form a basic block unto themselves. */
4708 if (basic_block_head && n_basic_blocks
4709 && GET_CODE (basic_block_head[0]) != CODE_LABEL)
4710 basic_block_head[0] = NEXT_INSN (f);
4711
4712 /* Retain a map of the prologue insns. */
4713 prologue = record_insns (GET_CODE (seq) == SEQUENCE ? seq : head);
4714 }
4715 else
4716#endif
4717 prologue = 0;
4718
4719#ifdef HAVE_epilogue
4720 if (HAVE_epilogue)
4721 {
4722 rtx insn = get_last_insn ();
4723 rtx prev = prev_nonnote_insn (insn);
4724
4725 /* If we end with a BARRIER, we don't need an epilogue. */
4726 if (! (prev && GET_CODE (prev) == BARRIER))
4727 {
4728 rtx tail, seq;
4729
4730 /* The last basic block ends with a NOTE_INSN_EPILOGUE_BEG,
4731 the epilogue insns (this must include the jump insn that
4732 returns), USE insns ad the end of a function, and a BARRIER. */
4733
4734 emit_barrier_after (insn);
4735
4736 /* Place the epilogue before the USE insns at the end of a
4737 function. */
4738 while (prev
4739 && GET_CODE (prev) == INSN
4740 && GET_CODE (PATTERN (prev)) == USE)
4741 {
4742 insn = PREV_INSN (prev);
4743 prev = prev_nonnote_insn (prev);
4744 }
4745
4746 seq = gen_epilogue ();
4747 tail = emit_jump_insn_after (seq, insn);
4748 emit_note_after (NOTE_INSN_EPILOGUE_BEG, insn);
4749
4750 /* Include the new epilogue insns in the last block. Ignore
4751 them if they form a basic block unto themselves. */
4752 if (basic_block_end && n_basic_blocks
4753 && GET_CODE (basic_block_end[n_basic_blocks - 1]) != JUMP_INSN)
4754 basic_block_end[n_basic_blocks - 1] = tail;
4755
4756 /* Retain a map of the epilogue insns. */
4757 epilogue = record_insns (GET_CODE (seq) == SEQUENCE ? seq : tail);
4758 return;
4759 }
4760 }
4761#endif
4762 epilogue = 0;
4763}
4764
4765/* Reposition the prologue-end and epilogue-begin notes after instruction
4766 scheduling and delayed branch scheduling. */
4767
4768void
4769reposition_prologue_and_epilogue_notes (f)
4770 rtx f;
4771{
4772#if defined (HAVE_prologue) || defined (HAVE_epilogue)
4773 /* Reposition the prologue and epilogue notes. */
4774 if (n_basic_blocks)
4775 {
4776 rtx next, prev;
bf526252 4777 int len;
bdac5f58
TW
4778
4779 if (prologue)
4780 {
bf526252
RK
4781 register rtx insn, note = 0;
4782
4783 /* Scan from the beginning until we reach the last prologue insn.
4784 We apparently can't depend on basic_block_{head,end} after
4785 reorg has run. */
4786 for (len = 0; prologue[len]; len++)
4787 ;
9392c110
JH
4788 for (insn = f; len && insn; insn = NEXT_INSN (insn))
4789 {
4790 if (GET_CODE (insn) == NOTE)
4791 {
4792 if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_PROLOGUE_END)
4793 note = insn;
4794 }
4795 else if ((len -= contains (insn, prologue)) == 0)
4796 {
4797 /* Find the prologue-end note if we haven't already, and
4798 move it to just after the last prologue insn. */
4799 if (note == 0)
4800 {
4801 for (note = insn; note = NEXT_INSN (note);)
4802 if (GET_CODE (note) == NOTE
4803 && NOTE_LINE_NUMBER (note) == NOTE_INSN_PROLOGUE_END)
4804 break;
4805 }
4806 next = NEXT_INSN (note);
4807 prev = PREV_INSN (note);
4808 if (prev)
4809 NEXT_INSN (prev) = next;
4810 if (next)
4811 PREV_INSN (next) = prev;
4812 add_insn_after (note, insn);
4813 }
4814 }
bdac5f58
TW
4815 }
4816
4817 if (epilogue)
4818 {
bf526252
RK
4819 register rtx insn, note = 0;
4820
4821 /* Scan from the end until we reach the first epilogue insn.
4822 We apparently can't depend on basic_block_{head,end} after
4823 reorg has run. */
4824 for (len = 0; epilogue[len]; len++)
4825 ;
9392c110
JH
4826 for (insn = get_last_insn (); len && insn; insn = PREV_INSN (insn))
4827 {
4828 if (GET_CODE (insn) == NOTE)
4829 {
4830 if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_EPILOGUE_BEG)
4831 note = insn;
4832 }
4833 else if ((len -= contains (insn, epilogue)) == 0)
4834 {
4835 /* Find the epilogue-begin note if we haven't already, and
4836 move it to just before the first epilogue insn. */
4837 if (note == 0)
4838 {
4839 for (note = insn; note = PREV_INSN (note);)
4840 if (GET_CODE (note) == NOTE
4841 && NOTE_LINE_NUMBER (note) == NOTE_INSN_EPILOGUE_BEG)
4842 break;
4843 }
4844 next = NEXT_INSN (note);
4845 prev = PREV_INSN (note);
4846 if (prev)
4847 NEXT_INSN (prev) = next;
4848 if (next)
4849 PREV_INSN (next) = prev;
4850 add_insn_after (note, PREV_INSN (insn));
4851 }
4852 }
bdac5f58
TW
4853 }
4854 }
4855#endif /* HAVE_prologue or HAVE_epilogue */
4856}
This page took 0.594064 seconds and 5 git commands to generate.