1 /* Expands front end tree to back end RTL for GNU C-Compiler
2 Copyright (C) 1987, 88, 89, 91-97, 1998 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
22 /* This file handles the generation of rtl code from tree structure
23 at the level of the function as a whole.
24 It creates the rtl expressions for parameters and auto variables
25 and has full responsibility for allocating stack slots.
27 `expand_function_start' is called at the beginning of a function,
28 before the function body is parsed, and `expand_function_end' is
29 called after parsing the body.
31 Call `assign_stack_local' to allocate a stack slot for a local variable.
32 This is usually done during the RTL generation for the function body,
33 but it can also be done in the reload pass when a pseudo-register does
34 not get a hard register.
36 Call `put_var_into_stack' when you learn, belatedly, that a variable
37 previously given a pseudo-register must in fact go in the stack.
38 This function changes the DECL_RTL to be a stack slot instead of a reg
39 then scans all the RTL instructions so far generated to correct them. */
48 #include "insn-flags.h"
50 #include "insn-codes.h"
52 #include "hard-reg-set.h"
53 #include "insn-config.h"
56 #include "basic-block.h"
60 #ifndef TRAMPOLINE_ALIGNMENT
61 #define TRAMPOLINE_ALIGNMENT FUNCTION_BOUNDARY
64 /* Some systems use __main in a way incompatible with its use in gcc, in these
65 cases use the macros NAME__MAIN to give a quoted symbol and SYMBOL__MAIN to
66 give the same symbol without quotes for an alternative entry point. You
67 must define both, or neither. */
69 #define NAME__MAIN "__main"
70 #define SYMBOL__MAIN __main
73 /* Round a value to the lowest integer less than it that is a multiple of
74 the required alignment. Avoid using division in case the value is
75 negative. Assume the alignment is a power of two. */
76 #define FLOOR_ROUND(VALUE,ALIGN) ((VALUE) & ~((ALIGN) - 1))
78 /* Similar, but round to the next highest integer that meets the
80 #define CEIL_ROUND(VALUE,ALIGN) (((VALUE) + (ALIGN) - 1) & ~((ALIGN)- 1))
82 /* NEED_SEPARATE_AP means that we cannot derive ap from the value of fp
83 during rtl generation. If they are different register numbers, this is
84 always true. It may also be true if
85 FIRST_PARM_OFFSET - STARTING_FRAME_OFFSET is not a constant during rtl
86 generation. See fix_lexical_addr for details. */
88 #if ARG_POINTER_REGNUM != FRAME_POINTER_REGNUM
89 #define NEED_SEPARATE_AP
92 /* Number of bytes of args popped by function being compiled on its return.
93 Zero if no bytes are to be popped.
94 May affect compilation of return insn or of function epilogue. */
96 int current_function_pops_args
;
98 /* Nonzero if function being compiled needs to be given an address
99 where the value should be stored. */
101 int current_function_returns_struct
;
103 /* Nonzero if function being compiled needs to
104 return the address of where it has put a structure value. */
106 int current_function_returns_pcc_struct
;
108 /* Nonzero if function being compiled needs to be passed a static chain. */
110 int current_function_needs_context
;
112 /* Nonzero if function being compiled can call setjmp. */
114 int current_function_calls_setjmp
;
116 /* Nonzero if function being compiled can call longjmp. */
118 int current_function_calls_longjmp
;
120 /* Nonzero if function being compiled receives nonlocal gotos
121 from nested functions. */
123 int current_function_has_nonlocal_label
;
125 /* Nonzero if function being compiled has nonlocal gotos to parent
128 int current_function_has_nonlocal_goto
;
130 /* Nonzero if this function has a computed goto.
132 It is computed during find_basic_blocks or during stupid life
135 int current_function_has_computed_jump
;
137 /* Nonzero if function being compiled contains nested functions. */
139 int current_function_contains_functions
;
141 /* Nonzero if the current function is a thunk (a lightweight function that
142 just adjusts one of its arguments and forwards to another function), so
143 we should try to cut corners where we can. */
144 int current_function_is_thunk
;
146 /* Nonzero if function being compiled can call alloca,
147 either as a subroutine or builtin. */
149 int current_function_calls_alloca
;
151 /* Nonzero if the current function returns a pointer type */
153 int current_function_returns_pointer
;
155 /* If some insns can be deferred to the delay slots of the epilogue, the
156 delay list for them is recorded here. */
158 rtx current_function_epilogue_delay_list
;
160 /* If function's args have a fixed size, this is that size, in bytes.
162 May affect compilation of return insn or of function epilogue. */
164 int current_function_args_size
;
166 /* # bytes the prologue should push and pretend that the caller pushed them.
167 The prologue must do this, but only if parms can be passed in registers. */
169 int current_function_pretend_args_size
;
171 /* # of bytes of outgoing arguments. If ACCUMULATE_OUTGOING_ARGS is
172 defined, the needed space is pushed by the prologue. */
174 int current_function_outgoing_args_size
;
176 /* This is the offset from the arg pointer to the place where the first
177 anonymous arg can be found, if there is one. */
179 rtx current_function_arg_offset_rtx
;
181 /* Nonzero if current function uses varargs.h or equivalent.
182 Zero for functions that use stdarg.h. */
184 int current_function_varargs
;
186 /* Nonzero if current function uses stdarg.h or equivalent.
187 Zero for functions that use varargs.h. */
189 int current_function_stdarg
;
191 /* Quantities of various kinds of registers
192 used for the current function's args. */
194 CUMULATIVE_ARGS current_function_args_info
;
196 /* Name of function now being compiled. */
198 char *current_function_name
;
200 /* If non-zero, an RTL expression for the location at which the current
201 function returns its result. If the current function returns its
202 result in a register, current_function_return_rtx will always be
203 the hard register containing the result. */
205 rtx current_function_return_rtx
;
207 /* Nonzero if the current function uses the constant pool. */
209 int current_function_uses_const_pool
;
211 /* Nonzero if the current function uses pic_offset_table_rtx. */
212 int current_function_uses_pic_offset_table
;
214 /* The arg pointer hard register, or the pseudo into which it was copied. */
215 rtx current_function_internal_arg_pointer
;
217 /* Language-specific reason why the current function cannot be made inline. */
218 char *current_function_cannot_inline
;
220 /* Nonzero if instrumentation calls for function entry and exit should be
222 int current_function_instrument_entry_exit
;
224 /* Nonzero if memory access checking be enabled in the current function. */
225 int current_function_check_memory_usage
;
227 /* The FUNCTION_DECL for an inline function currently being expanded. */
228 tree inline_function_decl
;
230 /* Number of function calls seen so far in current function. */
232 int function_call_count
;
234 /* List (chain of TREE_LIST) of LABEL_DECLs for all nonlocal labels
235 (labels to which there can be nonlocal gotos from nested functions)
238 tree nonlocal_labels
;
240 /* RTX for stack slot that holds the current handler for nonlocal gotos.
241 Zero when function does not have nonlocal labels. */
243 rtx nonlocal_goto_handler_slot
;
245 /* RTX for stack slot that holds the stack pointer value to restore
247 Zero when function does not have nonlocal labels. */
249 rtx nonlocal_goto_stack_level
;
251 /* Label that will go on parm cleanup code, if any.
252 Jumping to this label runs cleanup code for parameters, if
253 such code must be run. Following this code is the logical return label. */
257 /* Label that will go on function epilogue.
258 Jumping to this label serves as a "return" instruction
259 on machines which require execution of the epilogue on all returns. */
263 /* List (chain of EXPR_LISTs) of pseudo-regs of SAVE_EXPRs.
264 So we can mark them all live at the end of the function, if nonopt. */
267 /* List (chain of EXPR_LISTs) of all stack slots in this function.
268 Made for the sake of unshare_all_rtl. */
271 /* Chain of all RTL_EXPRs that have insns in them. */
274 /* Label to jump back to for tail recursion, or 0 if we have
275 not yet needed one for this function. */
276 rtx tail_recursion_label
;
278 /* Place after which to insert the tail_recursion_label if we need one. */
279 rtx tail_recursion_reentry
;
281 /* Location at which to save the argument pointer if it will need to be
282 referenced. There are two cases where this is done: if nonlocal gotos
283 exist, or if vars stored at an offset from the argument pointer will be
284 needed by inner routines. */
286 rtx arg_pointer_save_area
;
288 /* Offset to end of allocated area of stack frame.
289 If stack grows down, this is the address of the last stack slot allocated.
290 If stack grows up, this is the address for the next slot. */
291 HOST_WIDE_INT frame_offset
;
293 /* List (chain of TREE_LISTs) of static chains for containing functions.
294 Each link has a FUNCTION_DECL in the TREE_PURPOSE and a reg rtx
295 in an RTL_EXPR in the TREE_VALUE. */
296 static tree context_display
;
298 /* List (chain of TREE_LISTs) of trampolines for nested functions.
299 The trampoline sets up the static chain and jumps to the function.
300 We supply the trampoline's address when the function's address is requested.
302 Each link has a FUNCTION_DECL in the TREE_PURPOSE and a reg rtx
303 in an RTL_EXPR in the TREE_VALUE. */
304 static tree trampoline_list
;
306 /* Insn after which register parms and SAVE_EXPRs are born, if nonopt. */
307 static rtx parm_birth_insn
;
310 /* Nonzero if a stack slot has been generated whose address is not
311 actually valid. It means that the generated rtl must all be scanned
312 to detect and correct the invalid addresses where they occur. */
313 static int invalid_stack_slot
;
316 /* Last insn of those whose job was to put parms into their nominal homes. */
317 static rtx last_parm_insn
;
319 /* 1 + last pseudo register number possibly used for loading a copy
320 of a parameter of this function. */
323 /* Vector indexed by REGNO, containing location on stack in which
324 to put the parm which is nominally in pseudo register REGNO,
325 if we discover that that parm must go in the stack. The highest
326 element in this vector is one less than MAX_PARM_REG, above. */
327 rtx
*parm_reg_stack_loc
;
329 /* Nonzero once virtual register instantiation has been done.
330 assign_stack_local uses frame_pointer_rtx when this is nonzero. */
331 static int virtuals_instantiated
;
333 /* These variables hold pointers to functions to
334 save and restore machine-specific data,
335 in push_function_context and pop_function_context. */
336 void (*save_machine_status
) PROTO((struct function
*));
337 void (*restore_machine_status
) PROTO((struct function
*));
339 /* Nonzero if we need to distinguish between the return value of this function
340 and the return value of a function called by this function. This helps
343 extern int rtx_equal_function_value_matters
;
344 extern tree sequence_rtl_expr
;
346 /* In order to evaluate some expressions, such as function calls returning
347 structures in memory, we need to temporarily allocate stack locations.
348 We record each allocated temporary in the following structure.
350 Associated with each temporary slot is a nesting level. When we pop up
351 one level, all temporaries associated with the previous level are freed.
352 Normally, all temporaries are freed after the execution of the statement
353 in which they were created. However, if we are inside a ({...}) grouping,
354 the result may be in a temporary and hence must be preserved. If the
355 result could be in a temporary, we preserve it if we can determine which
356 one it is in. If we cannot determine which temporary may contain the
357 result, all temporaries are preserved. A temporary is preserved by
358 pretending it was allocated at the previous nesting level.
360 Automatic variables are also assigned temporary slots, at the nesting
361 level where they are defined. They are marked a "kept" so that
362 free_temp_slots will not free them. */
366 /* Points to next temporary slot. */
367 struct temp_slot
*next
;
368 /* The rtx to used to reference the slot. */
370 /* The rtx used to represent the address if not the address of the
371 slot above. May be an EXPR_LIST if multiple addresses exist. */
373 /* The size, in units, of the slot. */
375 /* The value of `sequence_rtl_expr' when this temporary is allocated. */
377 /* Non-zero if this temporary is currently in use. */
379 /* Non-zero if this temporary has its address taken. */
381 /* Nesting level at which this slot is being used. */
383 /* Non-zero if this should survive a call to free_temp_slots. */
385 /* The offset of the slot from the frame_pointer, including extra space
386 for alignment. This info is for combine_temp_slots. */
387 HOST_WIDE_INT base_offset
;
388 /* The size of the slot, including extra space for alignment. This
389 info is for combine_temp_slots. */
390 HOST_WIDE_INT full_size
;
393 /* List of all temporaries allocated, both available and in use. */
395 struct temp_slot
*temp_slots
;
397 /* Current nesting level for temporaries. */
401 /* Current nesting level for variables in a block. */
403 int var_temp_slot_level
;
405 /* When temporaries are created by TARGET_EXPRs, they are created at
406 this level of temp_slot_level, so that they can remain allocated
407 until no longer needed. CLEANUP_POINT_EXPRs define the lifetime
409 int target_temp_slot_level
;
411 /* This structure is used to record MEMs or pseudos used to replace VAR, any
412 SUBREGs of VAR, and any MEMs containing VAR as an address. We need to
413 maintain this list in case two operands of an insn were required to match;
414 in that case we must ensure we use the same replacement. */
416 struct fixup_replacement
420 struct fixup_replacement
*next
;
423 /* Forward declarations. */
425 static rtx assign_outer_stack_local
PROTO ((enum machine_mode
, HOST_WIDE_INT
,
426 int, struct function
*));
427 static struct temp_slot
*find_temp_slot_from_address
PROTO((rtx
));
428 static void put_reg_into_stack
PROTO((struct function
*, rtx
, tree
,
429 enum machine_mode
, enum machine_mode
,
431 static void fixup_var_refs
PROTO((rtx
, enum machine_mode
, int));
432 static struct fixup_replacement
433 *find_fixup_replacement
PROTO((struct fixup_replacement
**, rtx
));
434 static void fixup_var_refs_insns
PROTO((rtx
, enum machine_mode
, int,
436 static void fixup_var_refs_1
PROTO((rtx
, enum machine_mode
, rtx
*, rtx
,
437 struct fixup_replacement
**));
438 static rtx fixup_memory_subreg
PROTO((rtx
, rtx
, int));
439 static rtx walk_fixup_memory_subreg
PROTO((rtx
, rtx
, int));
440 static rtx fixup_stack_1
PROTO((rtx
, rtx
));
441 static void optimize_bit_field
PROTO((rtx
, rtx
, rtx
*));
442 static void instantiate_decls
PROTO((tree
, int));
443 static void instantiate_decls_1
PROTO((tree
, int));
444 static void instantiate_decl
PROTO((rtx
, int, int));
445 static int instantiate_virtual_regs_1
PROTO((rtx
*, rtx
, int));
446 static void delete_handlers
PROTO((void));
447 static void pad_to_arg_alignment
PROTO((struct args_size
*, int));
448 #ifndef ARGS_GROW_DOWNWARD
449 static void pad_below
PROTO((struct args_size
*, enum machine_mode
,
452 #ifdef ARGS_GROW_DOWNWARD
453 static tree round_down
PROTO((tree
, int));
455 static rtx round_trampoline_addr
PROTO((rtx
));
456 static tree blocks_nreverse
PROTO((tree
));
457 static int all_blocks
PROTO((tree
, tree
*));
458 #if defined (HAVE_prologue) || defined (HAVE_epilogue)
459 static int *record_insns
PROTO((rtx
));
460 static int contains
PROTO((rtx
, int *));
461 #endif /* HAVE_prologue || HAVE_epilogue */
462 static void put_addressof_into_stack
PROTO((rtx
));
463 static void purge_addressof_1
PROTO((rtx
*, rtx
, int, int));
465 /* Pointer to chain of `struct function' for containing functions. */
466 struct function
*outer_function_chain
;
468 /* Given a function decl for a containing function,
469 return the `struct function' for it. */
472 find_function_data (decl
)
477 for (p
= outer_function_chain
; p
; p
= p
->next
)
484 /* Save the current context for compilation of a nested function.
485 This is called from language-specific code.
486 The caller is responsible for saving any language-specific status,
487 since this function knows only about language-independent variables. */
490 push_function_context_to (context
)
493 struct function
*p
= (struct function
*) xmalloc (sizeof (struct function
));
495 p
->next
= outer_function_chain
;
496 outer_function_chain
= p
;
498 p
->name
= current_function_name
;
499 p
->decl
= current_function_decl
;
500 p
->pops_args
= current_function_pops_args
;
501 p
->returns_struct
= current_function_returns_struct
;
502 p
->returns_pcc_struct
= current_function_returns_pcc_struct
;
503 p
->returns_pointer
= current_function_returns_pointer
;
504 p
->needs_context
= current_function_needs_context
;
505 p
->calls_setjmp
= current_function_calls_setjmp
;
506 p
->calls_longjmp
= current_function_calls_longjmp
;
507 p
->calls_alloca
= current_function_calls_alloca
;
508 p
->has_nonlocal_label
= current_function_has_nonlocal_label
;
509 p
->has_nonlocal_goto
= current_function_has_nonlocal_goto
;
510 p
->contains_functions
= current_function_contains_functions
;
511 p
->is_thunk
= current_function_is_thunk
;
512 p
->args_size
= current_function_args_size
;
513 p
->pretend_args_size
= current_function_pretend_args_size
;
514 p
->arg_offset_rtx
= current_function_arg_offset_rtx
;
515 p
->varargs
= current_function_varargs
;
516 p
->stdarg
= current_function_stdarg
;
517 p
->uses_const_pool
= current_function_uses_const_pool
;
518 p
->uses_pic_offset_table
= current_function_uses_pic_offset_table
;
519 p
->internal_arg_pointer
= current_function_internal_arg_pointer
;
520 p
->cannot_inline
= current_function_cannot_inline
;
521 p
->max_parm_reg
= max_parm_reg
;
522 p
->parm_reg_stack_loc
= parm_reg_stack_loc
;
523 p
->outgoing_args_size
= current_function_outgoing_args_size
;
524 p
->return_rtx
= current_function_return_rtx
;
525 p
->nonlocal_goto_handler_slot
= nonlocal_goto_handler_slot
;
526 p
->nonlocal_goto_stack_level
= nonlocal_goto_stack_level
;
527 p
->nonlocal_labels
= nonlocal_labels
;
528 p
->cleanup_label
= cleanup_label
;
529 p
->return_label
= return_label
;
530 p
->save_expr_regs
= save_expr_regs
;
531 p
->stack_slot_list
= stack_slot_list
;
532 p
->parm_birth_insn
= parm_birth_insn
;
533 p
->frame_offset
= frame_offset
;
534 p
->tail_recursion_label
= tail_recursion_label
;
535 p
->tail_recursion_reentry
= tail_recursion_reentry
;
536 p
->arg_pointer_save_area
= arg_pointer_save_area
;
537 p
->rtl_expr_chain
= rtl_expr_chain
;
538 p
->last_parm_insn
= last_parm_insn
;
539 p
->context_display
= context_display
;
540 p
->trampoline_list
= trampoline_list
;
541 p
->function_call_count
= function_call_count
;
542 p
->temp_slots
= temp_slots
;
543 p
->temp_slot_level
= temp_slot_level
;
544 p
->target_temp_slot_level
= target_temp_slot_level
;
545 p
->var_temp_slot_level
= var_temp_slot_level
;
546 p
->fixup_var_refs_queue
= 0;
547 p
->epilogue_delay_list
= current_function_epilogue_delay_list
;
548 p
->args_info
= current_function_args_info
;
549 p
->check_memory_usage
= current_function_check_memory_usage
;
550 p
->instrument_entry_exit
= current_function_instrument_entry_exit
;
552 save_tree_status (p
, context
);
553 save_storage_status (p
);
554 save_emit_status (p
);
555 save_expr_status (p
);
556 save_stmt_status (p
);
557 save_varasm_status (p
, context
);
558 if (save_machine_status
)
559 (*save_machine_status
) (p
);
563 push_function_context ()
565 push_function_context_to (current_function_decl
);
568 /* Restore the last saved context, at the end of a nested function.
569 This function is called from language-specific code. */
572 pop_function_context_from (context
)
575 struct function
*p
= outer_function_chain
;
576 struct var_refs_queue
*queue
;
578 outer_function_chain
= p
->next
;
580 current_function_contains_functions
581 = p
->contains_functions
|| p
->inline_obstacks
582 || context
== current_function_decl
;
583 current_function_name
= p
->name
;
584 current_function_decl
= p
->decl
;
585 current_function_pops_args
= p
->pops_args
;
586 current_function_returns_struct
= p
->returns_struct
;
587 current_function_returns_pcc_struct
= p
->returns_pcc_struct
;
588 current_function_returns_pointer
= p
->returns_pointer
;
589 current_function_needs_context
= p
->needs_context
;
590 current_function_calls_setjmp
= p
->calls_setjmp
;
591 current_function_calls_longjmp
= p
->calls_longjmp
;
592 current_function_calls_alloca
= p
->calls_alloca
;
593 current_function_has_nonlocal_label
= p
->has_nonlocal_label
;
594 current_function_has_nonlocal_goto
= p
->has_nonlocal_goto
;
595 current_function_is_thunk
= p
->is_thunk
;
596 current_function_args_size
= p
->args_size
;
597 current_function_pretend_args_size
= p
->pretend_args_size
;
598 current_function_arg_offset_rtx
= p
->arg_offset_rtx
;
599 current_function_varargs
= p
->varargs
;
600 current_function_stdarg
= p
->stdarg
;
601 current_function_uses_const_pool
= p
->uses_const_pool
;
602 current_function_uses_pic_offset_table
= p
->uses_pic_offset_table
;
603 current_function_internal_arg_pointer
= p
->internal_arg_pointer
;
604 current_function_cannot_inline
= p
->cannot_inline
;
605 max_parm_reg
= p
->max_parm_reg
;
606 parm_reg_stack_loc
= p
->parm_reg_stack_loc
;
607 current_function_outgoing_args_size
= p
->outgoing_args_size
;
608 current_function_return_rtx
= p
->return_rtx
;
609 nonlocal_goto_handler_slot
= p
->nonlocal_goto_handler_slot
;
610 nonlocal_goto_stack_level
= p
->nonlocal_goto_stack_level
;
611 nonlocal_labels
= p
->nonlocal_labels
;
612 cleanup_label
= p
->cleanup_label
;
613 return_label
= p
->return_label
;
614 save_expr_regs
= p
->save_expr_regs
;
615 stack_slot_list
= p
->stack_slot_list
;
616 parm_birth_insn
= p
->parm_birth_insn
;
617 frame_offset
= p
->frame_offset
;
618 tail_recursion_label
= p
->tail_recursion_label
;
619 tail_recursion_reentry
= p
->tail_recursion_reentry
;
620 arg_pointer_save_area
= p
->arg_pointer_save_area
;
621 rtl_expr_chain
= p
->rtl_expr_chain
;
622 last_parm_insn
= p
->last_parm_insn
;
623 context_display
= p
->context_display
;
624 trampoline_list
= p
->trampoline_list
;
625 function_call_count
= p
->function_call_count
;
626 temp_slots
= p
->temp_slots
;
627 temp_slot_level
= p
->temp_slot_level
;
628 target_temp_slot_level
= p
->target_temp_slot_level
;
629 var_temp_slot_level
= p
->var_temp_slot_level
;
630 current_function_epilogue_delay_list
= p
->epilogue_delay_list
;
632 current_function_args_info
= p
->args_info
;
633 current_function_check_memory_usage
= p
->check_memory_usage
;
634 current_function_instrument_entry_exit
= p
->instrument_entry_exit
;
636 restore_tree_status (p
, context
);
637 restore_storage_status (p
);
638 restore_expr_status (p
);
639 restore_emit_status (p
);
640 restore_stmt_status (p
);
641 restore_varasm_status (p
);
643 if (restore_machine_status
)
644 (*restore_machine_status
) (p
);
646 /* Finish doing put_var_into_stack for any of our variables
647 which became addressable during the nested function. */
648 for (queue
= p
->fixup_var_refs_queue
; queue
; queue
= queue
->next
)
649 fixup_var_refs (queue
->modified
, queue
->promoted_mode
, queue
->unsignedp
);
653 /* Reset variables that have known state during rtx generation. */
654 rtx_equal_function_value_matters
= 1;
655 virtuals_instantiated
= 0;
658 void pop_function_context ()
660 pop_function_context_from (current_function_decl
);
663 /* Allocate fixed slots in the stack frame of the current function. */
665 /* Return size needed for stack frame based on slots so far allocated.
666 This size counts from zero. It is not rounded to STACK_BOUNDARY;
667 the caller may have to do that. */
672 #ifdef FRAME_GROWS_DOWNWARD
673 return -frame_offset
;
679 /* Allocate a stack slot of SIZE bytes and return a MEM rtx for it
680 with machine mode MODE.
682 ALIGN controls the amount of alignment for the address of the slot:
683 0 means according to MODE,
684 -1 means use BIGGEST_ALIGNMENT and round size to multiple of that,
685 positive specifies alignment boundary in bits.
687 We do not round to stack_boundary here. */
690 assign_stack_local (mode
, size
, align
)
691 enum machine_mode mode
;
695 register rtx x
, addr
;
696 int bigend_correction
= 0;
701 alignment
= GET_MODE_ALIGNMENT (mode
) / BITS_PER_UNIT
;
703 alignment
= BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
;
705 else if (align
== -1)
707 alignment
= BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
;
708 size
= CEIL_ROUND (size
, alignment
);
711 alignment
= align
/ BITS_PER_UNIT
;
713 /* Round frame offset to that alignment.
714 We must be careful here, since FRAME_OFFSET might be negative and
715 division with a negative dividend isn't as well defined as we might
716 like. So we instead assume that ALIGNMENT is a power of two and
717 use logical operations which are unambiguous. */
718 #ifdef FRAME_GROWS_DOWNWARD
719 frame_offset
= FLOOR_ROUND (frame_offset
, alignment
);
721 frame_offset
= CEIL_ROUND (frame_offset
, alignment
);
724 /* On a big-endian machine, if we are allocating more space than we will use,
725 use the least significant bytes of those that are allocated. */
726 if (BYTES_BIG_ENDIAN
&& mode
!= BLKmode
)
727 bigend_correction
= size
- GET_MODE_SIZE (mode
);
729 #ifdef FRAME_GROWS_DOWNWARD
730 frame_offset
-= size
;
733 /* If we have already instantiated virtual registers, return the actual
734 address relative to the frame pointer. */
735 if (virtuals_instantiated
)
736 addr
= plus_constant (frame_pointer_rtx
,
737 (frame_offset
+ bigend_correction
738 + STARTING_FRAME_OFFSET
));
740 addr
= plus_constant (virtual_stack_vars_rtx
,
741 frame_offset
+ bigend_correction
);
743 #ifndef FRAME_GROWS_DOWNWARD
744 frame_offset
+= size
;
747 x
= gen_rtx_MEM (mode
, addr
);
749 stack_slot_list
= gen_rtx_EXPR_LIST (VOIDmode
, x
, stack_slot_list
);
754 /* Assign a stack slot in a containing function.
755 First three arguments are same as in preceding function.
756 The last argument specifies the function to allocate in. */
759 assign_outer_stack_local (mode
, size
, align
, function
)
760 enum machine_mode mode
;
763 struct function
*function
;
765 register rtx x
, addr
;
766 int bigend_correction
= 0;
769 /* Allocate in the memory associated with the function in whose frame
771 push_obstacks (function
->function_obstack
,
772 function
->function_maybepermanent_obstack
);
776 alignment
= GET_MODE_ALIGNMENT (mode
) / BITS_PER_UNIT
;
778 alignment
= BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
;
780 else if (align
== -1)
782 alignment
= BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
;
783 size
= CEIL_ROUND (size
, alignment
);
786 alignment
= align
/ BITS_PER_UNIT
;
788 /* Round frame offset to that alignment. */
789 #ifdef FRAME_GROWS_DOWNWARD
790 function
->frame_offset
= FLOOR_ROUND (function
->frame_offset
, alignment
);
792 function
->frame_offset
= CEIL_ROUND (function
->frame_offset
, alignment
);
795 /* On a big-endian machine, if we are allocating more space than we will use,
796 use the least significant bytes of those that are allocated. */
797 if (BYTES_BIG_ENDIAN
&& mode
!= BLKmode
)
798 bigend_correction
= size
- GET_MODE_SIZE (mode
);
800 #ifdef FRAME_GROWS_DOWNWARD
801 function
->frame_offset
-= size
;
803 addr
= plus_constant (virtual_stack_vars_rtx
,
804 function
->frame_offset
+ bigend_correction
);
805 #ifndef FRAME_GROWS_DOWNWARD
806 function
->frame_offset
+= size
;
809 x
= gen_rtx_MEM (mode
, addr
);
811 function
->stack_slot_list
812 = gen_rtx_EXPR_LIST (VOIDmode
, x
, function
->stack_slot_list
);
819 /* Allocate a temporary stack slot and record it for possible later
822 MODE is the machine mode to be given to the returned rtx.
824 SIZE is the size in units of the space required. We do no rounding here
825 since assign_stack_local will do any required rounding.
827 KEEP is 1 if this slot is to be retained after a call to
828 free_temp_slots. Automatic variables for a block are allocated
829 with this flag. KEEP is 2 if we allocate a longer term temporary,
830 whose lifetime is controlled by CLEANUP_POINT_EXPRs. KEEP is 3
831 if we are to allocate something at an inner level to be treated as
832 a variable in the block (e.g., a SAVE_EXPR). */
835 assign_stack_temp (mode
, size
, keep
)
836 enum machine_mode mode
;
840 struct temp_slot
*p
, *best_p
= 0;
842 /* If SIZE is -1 it means that somebody tried to allocate a temporary
843 of a variable size. */
847 /* First try to find an available, already-allocated temporary that is the
848 exact size we require. */
849 for (p
= temp_slots
; p
; p
= p
->next
)
850 if (p
->size
== size
&& GET_MODE (p
->slot
) == mode
&& ! p
->in_use
)
853 /* If we didn't find, one, try one that is larger than what we want. We
854 find the smallest such. */
856 for (p
= temp_slots
; p
; p
= p
->next
)
857 if (p
->size
> size
&& GET_MODE (p
->slot
) == mode
&& ! p
->in_use
858 && (best_p
== 0 || best_p
->size
> p
->size
))
861 /* Make our best, if any, the one to use. */
864 /* If there are enough aligned bytes left over, make them into a new
865 temp_slot so that the extra bytes don't get wasted. Do this only
866 for BLKmode slots, so that we can be sure of the alignment. */
867 if (GET_MODE (best_p
->slot
) == BLKmode
)
869 int alignment
= BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
;
870 HOST_WIDE_INT rounded_size
= CEIL_ROUND (size
, alignment
);
872 if (best_p
->size
- rounded_size
>= alignment
)
874 p
= (struct temp_slot
*) oballoc (sizeof (struct temp_slot
));
875 p
->in_use
= p
->addr_taken
= 0;
876 p
->size
= best_p
->size
- rounded_size
;
877 p
->base_offset
= best_p
->base_offset
+ rounded_size
;
878 p
->full_size
= best_p
->full_size
- rounded_size
;
879 p
->slot
= gen_rtx_MEM (BLKmode
,
880 plus_constant (XEXP (best_p
->slot
, 0),
884 p
->next
= temp_slots
;
887 stack_slot_list
= gen_rtx_EXPR_LIST (VOIDmode
, p
->slot
,
890 best_p
->size
= rounded_size
;
891 best_p
->full_size
= rounded_size
;
898 /* If we still didn't find one, make a new temporary. */
901 HOST_WIDE_INT frame_offset_old
= frame_offset
;
903 p
= (struct temp_slot
*) oballoc (sizeof (struct temp_slot
));
905 /* If the temp slot mode doesn't indicate the alignment,
906 use the largest possible, so no one will be disappointed. */
907 p
->slot
= assign_stack_local (mode
, size
, mode
== BLKmode
? -1 : 0);
909 /* The following slot size computation is necessary because we don't
910 know the actual size of the temporary slot until assign_stack_local
911 has performed all the frame alignment and size rounding for the
912 requested temporary. Note that extra space added for alignment
913 can be either above or below this stack slot depending on which
914 way the frame grows. We include the extra space if and only if it
915 is above this slot. */
916 #ifdef FRAME_GROWS_DOWNWARD
917 p
->size
= frame_offset_old
- frame_offset
;
922 /* Now define the fields used by combine_temp_slots. */
923 #ifdef FRAME_GROWS_DOWNWARD
924 p
->base_offset
= frame_offset
;
925 p
->full_size
= frame_offset_old
- frame_offset
;
927 p
->base_offset
= frame_offset_old
;
928 p
->full_size
= frame_offset
- frame_offset_old
;
931 p
->next
= temp_slots
;
937 p
->rtl_expr
= sequence_rtl_expr
;
941 p
->level
= target_temp_slot_level
;
946 p
->level
= var_temp_slot_level
;
951 p
->level
= temp_slot_level
;
955 /* We may be reusing an old slot, so clear any MEM flags that may have been
957 RTX_UNCHANGING_P (p
->slot
) = 0;
958 MEM_IN_STRUCT_P (p
->slot
) = 0;
962 /* Assign a temporary of given TYPE.
963 KEEP is as for assign_stack_temp.
964 MEMORY_REQUIRED is 1 if the result must be addressable stack memory;
965 it is 0 if a register is OK.
966 DONT_PROMOTE is 1 if we should not promote values in register
970 assign_temp (type
, keep
, memory_required
, dont_promote
)
976 enum machine_mode mode
= TYPE_MODE (type
);
977 int unsignedp
= TREE_UNSIGNED (type
);
979 if (mode
== BLKmode
|| memory_required
)
981 HOST_WIDE_INT size
= int_size_in_bytes (type
);
984 /* Unfortunately, we don't yet know how to allocate variable-sized
985 temporaries. However, sometimes we have a fixed upper limit on
986 the size (which is stored in TYPE_ARRAY_MAX_SIZE) and can use that
987 instead. This is the case for Chill variable-sized strings. */
988 if (size
== -1 && TREE_CODE (type
) == ARRAY_TYPE
989 && TYPE_ARRAY_MAX_SIZE (type
) != NULL_TREE
990 && TREE_CODE (TYPE_ARRAY_MAX_SIZE (type
)) == INTEGER_CST
)
991 size
= TREE_INT_CST_LOW (TYPE_ARRAY_MAX_SIZE (type
));
993 tmp
= assign_stack_temp (mode
, size
, keep
);
994 MEM_IN_STRUCT_P (tmp
) = AGGREGATE_TYPE_P (type
);
998 #ifndef PROMOTE_FOR_CALL_ONLY
1000 mode
= promote_mode (type
, mode
, &unsignedp
, 0);
1003 return gen_reg_rtx (mode
);
1006 /* Combine temporary stack slots which are adjacent on the stack.
1008 This allows for better use of already allocated stack space. This is only
1009 done for BLKmode slots because we can be sure that we won't have alignment
1010 problems in this case. */
1013 combine_temp_slots ()
1015 struct temp_slot
*p
, *q
;
1016 struct temp_slot
*prev_p
, *prev_q
;
1019 /* If there are a lot of temp slots, don't do anything unless
1020 high levels of optimizaton. */
1021 if (! flag_expensive_optimizations
)
1022 for (p
= temp_slots
, num_slots
= 0; p
; p
= p
->next
, num_slots
++)
1023 if (num_slots
> 100 || (num_slots
> 10 && optimize
== 0))
1026 for (p
= temp_slots
, prev_p
= 0; p
; p
= prev_p
? prev_p
->next
: temp_slots
)
1030 if (! p
->in_use
&& GET_MODE (p
->slot
) == BLKmode
)
1031 for (q
= p
->next
, prev_q
= p
; q
; q
= prev_q
->next
)
1034 if (! q
->in_use
&& GET_MODE (q
->slot
) == BLKmode
)
1036 if (p
->base_offset
+ p
->full_size
== q
->base_offset
)
1038 /* Q comes after P; combine Q into P. */
1040 p
->full_size
+= q
->full_size
;
1043 else if (q
->base_offset
+ q
->full_size
== p
->base_offset
)
1045 /* P comes after Q; combine P into Q. */
1047 q
->full_size
+= p
->full_size
;
1052 /* Either delete Q or advance past it. */
1054 prev_q
->next
= q
->next
;
1058 /* Either delete P or advance past it. */
1062 prev_p
->next
= p
->next
;
1064 temp_slots
= p
->next
;
1071 /* Find the temp slot corresponding to the object at address X. */
1073 static struct temp_slot
*
1074 find_temp_slot_from_address (x
)
1077 struct temp_slot
*p
;
1080 for (p
= temp_slots
; p
; p
= p
->next
)
1085 else if (XEXP (p
->slot
, 0) == x
1087 || (GET_CODE (x
) == PLUS
1088 && XEXP (x
, 0) == virtual_stack_vars_rtx
1089 && GET_CODE (XEXP (x
, 1)) == CONST_INT
1090 && INTVAL (XEXP (x
, 1)) >= p
->base_offset
1091 && INTVAL (XEXP (x
, 1)) < p
->base_offset
+ p
->full_size
))
1094 else if (p
->address
!= 0 && GET_CODE (p
->address
) == EXPR_LIST
)
1095 for (next
= p
->address
; next
; next
= XEXP (next
, 1))
1096 if (XEXP (next
, 0) == x
)
1103 /* Indicate that NEW is an alternate way of referring to the temp slot
1104 that previously was known by OLD. */
1107 update_temp_slot_address (old
, new)
1110 struct temp_slot
*p
= find_temp_slot_from_address (old
);
1112 /* If none, return. Else add NEW as an alias. */
1115 else if (p
->address
== 0)
1119 if (GET_CODE (p
->address
) != EXPR_LIST
)
1120 p
->address
= gen_rtx_EXPR_LIST (VOIDmode
, p
->address
, NULL_RTX
);
1122 p
->address
= gen_rtx_EXPR_LIST (VOIDmode
, new, p
->address
);
1126 /* If X could be a reference to a temporary slot, mark the fact that its
1127 address was taken. */
1130 mark_temp_addr_taken (x
)
1133 struct temp_slot
*p
;
1138 /* If X is not in memory or is at a constant address, it cannot be in
1139 a temporary slot. */
1140 if (GET_CODE (x
) != MEM
|| CONSTANT_P (XEXP (x
, 0)))
1143 p
= find_temp_slot_from_address (XEXP (x
, 0));
1148 /* If X could be a reference to a temporary slot, mark that slot as
1149 belonging to the to one level higher than the current level. If X
1150 matched one of our slots, just mark that one. Otherwise, we can't
1151 easily predict which it is, so upgrade all of them. Kept slots
1152 need not be touched.
1154 This is called when an ({...}) construct occurs and a statement
1155 returns a value in memory. */
1158 preserve_temp_slots (x
)
1161 struct temp_slot
*p
= 0;
1163 /* If there is no result, we still might have some objects whose address
1164 were taken, so we need to make sure they stay around. */
1167 for (p
= temp_slots
; p
; p
= p
->next
)
1168 if (p
->in_use
&& p
->level
== temp_slot_level
&& p
->addr_taken
)
1174 /* If X is a register that is being used as a pointer, see if we have
1175 a temporary slot we know it points to. To be consistent with
1176 the code below, we really should preserve all non-kept slots
1177 if we can't find a match, but that seems to be much too costly. */
1178 if (GET_CODE (x
) == REG
&& REGNO_POINTER_FLAG (REGNO (x
)))
1179 p
= find_temp_slot_from_address (x
);
1181 /* If X is not in memory or is at a constant address, it cannot be in
1182 a temporary slot, but it can contain something whose address was
1184 if (p
== 0 && (GET_CODE (x
) != MEM
|| CONSTANT_P (XEXP (x
, 0))))
1186 for (p
= temp_slots
; p
; p
= p
->next
)
1187 if (p
->in_use
&& p
->level
== temp_slot_level
&& p
->addr_taken
)
1193 /* First see if we can find a match. */
1195 p
= find_temp_slot_from_address (XEXP (x
, 0));
1199 /* Move everything at our level whose address was taken to our new
1200 level in case we used its address. */
1201 struct temp_slot
*q
;
1203 if (p
->level
== temp_slot_level
)
1205 for (q
= temp_slots
; q
; q
= q
->next
)
1206 if (q
!= p
&& q
->addr_taken
&& q
->level
== p
->level
)
1215 /* Otherwise, preserve all non-kept slots at this level. */
1216 for (p
= temp_slots
; p
; p
= p
->next
)
1217 if (p
->in_use
&& p
->level
== temp_slot_level
&& ! p
->keep
)
1221 /* X is the result of an RTL_EXPR. If it is a temporary slot associated
1222 with that RTL_EXPR, promote it into a temporary slot at the present
1223 level so it will not be freed when we free slots made in the
1227 preserve_rtl_expr_result (x
)
1230 struct temp_slot
*p
;
1232 /* If X is not in memory or is at a constant address, it cannot be in
1233 a temporary slot. */
1234 if (x
== 0 || GET_CODE (x
) != MEM
|| CONSTANT_P (XEXP (x
, 0)))
1237 /* If we can find a match, move it to our level unless it is already at
1239 p
= find_temp_slot_from_address (XEXP (x
, 0));
1242 p
->level
= MIN (p
->level
, temp_slot_level
);
1249 /* Free all temporaries used so far. This is normally called at the end
1250 of generating code for a statement. Don't free any temporaries
1251 currently in use for an RTL_EXPR that hasn't yet been emitted.
1252 We could eventually do better than this since it can be reused while
1253 generating the same RTL_EXPR, but this is complex and probably not
1259 struct temp_slot
*p
;
1261 for (p
= temp_slots
; p
; p
= p
->next
)
1262 if (p
->in_use
&& p
->level
== temp_slot_level
&& ! p
->keep
1263 && p
->rtl_expr
== 0)
1266 combine_temp_slots ();
1269 /* Free all temporary slots used in T, an RTL_EXPR node. */
1272 free_temps_for_rtl_expr (t
)
1275 struct temp_slot
*p
;
1277 for (p
= temp_slots
; p
; p
= p
->next
)
1278 if (p
->rtl_expr
== t
)
1281 combine_temp_slots ();
1284 /* Mark all temporaries ever allocated in this function as not suitable
1285 for reuse until the current level is exited. */
1288 mark_all_temps_used ()
1290 struct temp_slot
*p
;
1292 for (p
= temp_slots
; p
; p
= p
->next
)
1294 p
->in_use
= p
->keep
= 1;
1295 p
->level
= MIN (p
->level
, temp_slot_level
);
1299 /* Push deeper into the nesting level for stack temporaries. */
1307 /* Likewise, but save the new level as the place to allocate variables
1311 push_temp_slots_for_block ()
1315 var_temp_slot_level
= temp_slot_level
;
1318 /* Likewise, but save the new level as the place to allocate temporaries
1319 for TARGET_EXPRs. */
1322 push_temp_slots_for_target ()
1326 target_temp_slot_level
= temp_slot_level
;
1329 /* Set and get the value of target_temp_slot_level. The only
1330 permitted use of these functions is to save and restore this value. */
1333 get_target_temp_slot_level ()
1335 return target_temp_slot_level
;
1339 set_target_temp_slot_level (level
)
1342 target_temp_slot_level
= level
;
1345 /* Pop a temporary nesting level. All slots in use in the current level
1351 struct temp_slot
*p
;
1353 for (p
= temp_slots
; p
; p
= p
->next
)
1354 if (p
->in_use
&& p
->level
== temp_slot_level
&& p
->rtl_expr
== 0)
1357 combine_temp_slots ();
1362 /* Initialize temporary slots. */
1367 /* We have not allocated any temporaries yet. */
1369 temp_slot_level
= 0;
1370 var_temp_slot_level
= 0;
1371 target_temp_slot_level
= 0;
1374 /* Retroactively move an auto variable from a register to a stack slot.
1375 This is done when an address-reference to the variable is seen. */
1378 put_var_into_stack (decl
)
1382 enum machine_mode promoted_mode
, decl_mode
;
1383 struct function
*function
= 0;
1385 int can_use_addressof
;
1387 context
= decl_function_context (decl
);
1389 /* Get the current rtl used for this object and its original mode. */
1390 reg
= TREE_CODE (decl
) == SAVE_EXPR
? SAVE_EXPR_RTL (decl
) : DECL_RTL (decl
);
1392 /* No need to do anything if decl has no rtx yet
1393 since in that case caller is setting TREE_ADDRESSABLE
1394 and a stack slot will be assigned when the rtl is made. */
1398 /* Get the declared mode for this object. */
1399 decl_mode
= (TREE_CODE (decl
) == SAVE_EXPR
? TYPE_MODE (TREE_TYPE (decl
))
1400 : DECL_MODE (decl
));
1401 /* Get the mode it's actually stored in. */
1402 promoted_mode
= GET_MODE (reg
);
1404 /* If this variable comes from an outer function,
1405 find that function's saved context. */
1406 if (context
!= current_function_decl
&& context
!= inline_function_decl
)
1407 for (function
= outer_function_chain
; function
; function
= function
->next
)
1408 if (function
->decl
== context
)
1411 /* If this is a variable-size object with a pseudo to address it,
1412 put that pseudo into the stack, if the var is nonlocal. */
1413 if (DECL_NONLOCAL (decl
)
1414 && GET_CODE (reg
) == MEM
1415 && GET_CODE (XEXP (reg
, 0)) == REG
1416 && REGNO (XEXP (reg
, 0)) > LAST_VIRTUAL_REGISTER
)
1418 reg
= XEXP (reg
, 0);
1419 decl_mode
= promoted_mode
= GET_MODE (reg
);
1425 /* FIXME make it work for promoted modes too */
1426 && decl_mode
== promoted_mode
1427 #ifdef NON_SAVING_SETJMP
1428 && ! (NON_SAVING_SETJMP
&& current_function_calls_setjmp
)
1432 /* If we can't use ADDRESSOF, make sure we see through one we already
1434 if (! can_use_addressof
&& GET_CODE (reg
) == MEM
1435 && GET_CODE (XEXP (reg
, 0)) == ADDRESSOF
)
1436 reg
= XEXP (XEXP (reg
, 0), 0);
1438 /* Now we should have a value that resides in one or more pseudo regs. */
1440 if (GET_CODE (reg
) == REG
)
1442 /* If this variable lives in the current function and we don't need
1443 to put things in the stack for the sake of setjmp, try to keep it
1444 in a register until we know we actually need the address. */
1445 if (can_use_addressof
)
1446 gen_mem_addressof (reg
, decl
);
1448 put_reg_into_stack (function
, reg
, TREE_TYPE (decl
),
1449 promoted_mode
, decl_mode
,
1450 TREE_SIDE_EFFECTS (decl
), 0,
1452 || DECL_INITIAL (decl
) != 0);
1454 else if (GET_CODE (reg
) == CONCAT
)
1456 /* A CONCAT contains two pseudos; put them both in the stack.
1457 We do it so they end up consecutive. */
1458 enum machine_mode part_mode
= GET_MODE (XEXP (reg
, 0));
1459 tree part_type
= TREE_TYPE (TREE_TYPE (decl
));
1460 #ifdef FRAME_GROWS_DOWNWARD
1461 /* Since part 0 should have a lower address, do it second. */
1462 put_reg_into_stack (function
, XEXP (reg
, 1), part_type
, part_mode
,
1463 part_mode
, TREE_SIDE_EFFECTS (decl
), 0,
1464 TREE_USED (decl
) || DECL_INITIAL (decl
) != 0);
1465 put_reg_into_stack (function
, XEXP (reg
, 0), part_type
, part_mode
,
1466 part_mode
, TREE_SIDE_EFFECTS (decl
), 0,
1467 TREE_USED (decl
) || DECL_INITIAL (decl
) != 0);
1469 put_reg_into_stack (function
, XEXP (reg
, 0), part_type
, part_mode
,
1470 part_mode
, TREE_SIDE_EFFECTS (decl
), 0,
1471 TREE_USED (decl
) || DECL_INITIAL (decl
) != 0);
1472 put_reg_into_stack (function
, XEXP (reg
, 1), part_type
, part_mode
,
1473 part_mode
, TREE_SIDE_EFFECTS (decl
), 0,
1474 TREE_USED (decl
) || DECL_INITIAL (decl
) != 0);
1477 /* Change the CONCAT into a combined MEM for both parts. */
1478 PUT_CODE (reg
, MEM
);
1479 MEM_VOLATILE_P (reg
) = MEM_VOLATILE_P (XEXP (reg
, 0));
1480 MEM_ALIAS_SET (reg
) = get_alias_set (decl
);
1482 /* The two parts are in memory order already.
1483 Use the lower parts address as ours. */
1484 XEXP (reg
, 0) = XEXP (XEXP (reg
, 0), 0);
1485 /* Prevent sharing of rtl that might lose. */
1486 if (GET_CODE (XEXP (reg
, 0)) == PLUS
)
1487 XEXP (reg
, 0) = copy_rtx (XEXP (reg
, 0));
1492 if (current_function_check_memory_usage
)
1493 emit_library_call (chkr_set_right_libfunc
, 1, VOIDmode
, 3,
1494 XEXP (reg
, 0), ptr_mode
,
1495 GEN_INT (GET_MODE_SIZE (GET_MODE (reg
))),
1496 TYPE_MODE (sizetype
),
1497 GEN_INT (MEMORY_USE_RW
),
1498 TYPE_MODE (integer_type_node
));
1501 /* Subroutine of put_var_into_stack. This puts a single pseudo reg REG
1502 into the stack frame of FUNCTION (0 means the current function).
1503 DECL_MODE is the machine mode of the user-level data type.
1504 PROMOTED_MODE is the machine mode of the register.
1505 VOLATILE_P is nonzero if this is for a "volatile" decl.
1506 USED_P is nonzero if this reg might have already been used in an insn. */
1509 put_reg_into_stack (function
, reg
, type
, promoted_mode
, decl_mode
, volatile_p
,
1510 original_regno
, used_p
)
1511 struct function
*function
;
1514 enum machine_mode promoted_mode
, decl_mode
;
1520 int regno
= original_regno
;
1523 regno
= REGNO (reg
);
1527 if (regno
< function
->max_parm_reg
)
1528 new = function
->parm_reg_stack_loc
[regno
];
1530 new = assign_outer_stack_local (decl_mode
, GET_MODE_SIZE (decl_mode
),
1535 if (regno
< max_parm_reg
)
1536 new = parm_reg_stack_loc
[regno
];
1538 new = assign_stack_local (decl_mode
, GET_MODE_SIZE (decl_mode
), 0);
1541 PUT_MODE (reg
, decl_mode
);
1542 XEXP (reg
, 0) = XEXP (new, 0);
1543 /* `volatil' bit means one thing for MEMs, another entirely for REGs. */
1544 MEM_VOLATILE_P (reg
) = volatile_p
;
1545 PUT_CODE (reg
, MEM
);
1547 /* If this is a memory ref that contains aggregate components,
1548 mark it as such for cse and loop optimize. If we are reusing a
1549 previously generated stack slot, then we need to copy the bit in
1550 case it was set for other reasons. For instance, it is set for
1551 __builtin_va_alist. */
1552 MEM_IN_STRUCT_P (reg
) = AGGREGATE_TYPE_P (type
) | MEM_IN_STRUCT_P (new);
1553 MEM_ALIAS_SET (reg
) = get_alias_set (type
);
1555 /* Now make sure that all refs to the variable, previously made
1556 when it was a register, are fixed up to be valid again. */
1558 if (used_p
&& function
!= 0)
1560 struct var_refs_queue
*temp
;
1562 /* Variable is inherited; fix it up when we get back to its function. */
1563 push_obstacks (function
->function_obstack
,
1564 function
->function_maybepermanent_obstack
);
1566 /* See comment in restore_tree_status in tree.c for why this needs to be
1567 on saveable obstack. */
1569 = (struct var_refs_queue
*) savealloc (sizeof (struct var_refs_queue
));
1570 temp
->modified
= reg
;
1571 temp
->promoted_mode
= promoted_mode
;
1572 temp
->unsignedp
= TREE_UNSIGNED (type
);
1573 temp
->next
= function
->fixup_var_refs_queue
;
1574 function
->fixup_var_refs_queue
= temp
;
1578 /* Variable is local; fix it up now. */
1579 fixup_var_refs (reg
, promoted_mode
, TREE_UNSIGNED (type
));
1583 fixup_var_refs (var
, promoted_mode
, unsignedp
)
1585 enum machine_mode promoted_mode
;
1589 rtx first_insn
= get_insns ();
1590 struct sequence_stack
*stack
= sequence_stack
;
1591 tree rtl_exps
= rtl_expr_chain
;
1593 /* Must scan all insns for stack-refs that exceed the limit. */
1594 fixup_var_refs_insns (var
, promoted_mode
, unsignedp
, first_insn
, stack
== 0);
1596 /* Scan all pending sequences too. */
1597 for (; stack
; stack
= stack
->next
)
1599 push_to_sequence (stack
->first
);
1600 fixup_var_refs_insns (var
, promoted_mode
, unsignedp
,
1601 stack
->first
, stack
->next
!= 0);
1602 /* Update remembered end of sequence
1603 in case we added an insn at the end. */
1604 stack
->last
= get_last_insn ();
1608 /* Scan all waiting RTL_EXPRs too. */
1609 for (pending
= rtl_exps
; pending
; pending
= TREE_CHAIN (pending
))
1611 rtx seq
= RTL_EXPR_SEQUENCE (TREE_VALUE (pending
));
1612 if (seq
!= const0_rtx
&& seq
!= 0)
1614 push_to_sequence (seq
);
1615 fixup_var_refs_insns (var
, promoted_mode
, unsignedp
, seq
, 0);
1621 /* REPLACEMENTS is a pointer to a list of the struct fixup_replacement and X is
1622 some part of an insn. Return a struct fixup_replacement whose OLD
1623 value is equal to X. Allocate a new structure if no such entry exists. */
1625 static struct fixup_replacement
*
1626 find_fixup_replacement (replacements
, x
)
1627 struct fixup_replacement
**replacements
;
1630 struct fixup_replacement
*p
;
1632 /* See if we have already replaced this. */
1633 for (p
= *replacements
; p
&& p
->old
!= x
; p
= p
->next
)
1638 p
= (struct fixup_replacement
*) oballoc (sizeof (struct fixup_replacement
));
1641 p
->next
= *replacements
;
1648 /* Scan the insn-chain starting with INSN for refs to VAR
1649 and fix them up. TOPLEVEL is nonzero if this chain is the
1650 main chain of insns for the current function. */
1653 fixup_var_refs_insns (var
, promoted_mode
, unsignedp
, insn
, toplevel
)
1655 enum machine_mode promoted_mode
;
1664 rtx next
= NEXT_INSN (insn
);
1665 rtx set
, prev
, prev_set
;
1668 if (GET_RTX_CLASS (GET_CODE (insn
)) == 'i')
1670 /* If this is a CLOBBER of VAR, delete it.
1672 If it has a REG_LIBCALL note, delete the REG_LIBCALL
1673 and REG_RETVAL notes too. */
1674 if (GET_CODE (PATTERN (insn
)) == CLOBBER
1675 && (XEXP (PATTERN (insn
), 0) == var
1676 || (GET_CODE (XEXP (PATTERN (insn
), 0)) == CONCAT
1677 && (XEXP (XEXP (PATTERN (insn
), 0), 0) == var
1678 || XEXP (XEXP (PATTERN (insn
), 0), 1) == var
))))
1680 if ((note
= find_reg_note (insn
, REG_LIBCALL
, NULL_RTX
)) != 0)
1681 /* The REG_LIBCALL note will go away since we are going to
1682 turn INSN into a NOTE, so just delete the
1683 corresponding REG_RETVAL note. */
1684 remove_note (XEXP (note
, 0),
1685 find_reg_note (XEXP (note
, 0), REG_RETVAL
,
1688 /* In unoptimized compilation, we shouldn't call delete_insn
1689 except in jump.c doing warnings. */
1690 PUT_CODE (insn
, NOTE
);
1691 NOTE_LINE_NUMBER (insn
) = NOTE_INSN_DELETED
;
1692 NOTE_SOURCE_FILE (insn
) = 0;
1695 /* The insn to load VAR from a home in the arglist
1696 is now a no-op. When we see it, just delete it.
1697 Similarly if this is storing VAR from a register from which
1698 it was loaded in the previous insn. This will occur
1699 when an ADDRESSOF was made for an arglist slot. */
1701 && (set
= single_set (insn
)) != 0
1702 && SET_DEST (set
) == var
1703 /* If this represents the result of an insn group,
1704 don't delete the insn. */
1705 && find_reg_note (insn
, REG_RETVAL
, NULL_RTX
) == 0
1706 && (rtx_equal_p (SET_SRC (set
), var
)
1707 || (GET_CODE (SET_SRC (set
)) == REG
1708 && (prev
= prev_nonnote_insn (insn
)) != 0
1709 && (prev_set
= single_set (prev
)) != 0
1710 && SET_DEST (prev_set
) == SET_SRC (set
)
1711 && rtx_equal_p (SET_SRC (prev_set
), var
))))
1713 /* In unoptimized compilation, we shouldn't call delete_insn
1714 except in jump.c doing warnings. */
1715 PUT_CODE (insn
, NOTE
);
1716 NOTE_LINE_NUMBER (insn
) = NOTE_INSN_DELETED
;
1717 NOTE_SOURCE_FILE (insn
) = 0;
1718 if (insn
== last_parm_insn
)
1719 last_parm_insn
= PREV_INSN (next
);
1723 struct fixup_replacement
*replacements
= 0;
1724 rtx next_insn
= NEXT_INSN (insn
);
1726 if (SMALL_REGISTER_CLASSES
)
1728 /* If the insn that copies the results of a CALL_INSN
1729 into a pseudo now references VAR, we have to use an
1730 intermediate pseudo since we want the life of the
1731 return value register to be only a single insn.
1733 If we don't use an intermediate pseudo, such things as
1734 address computations to make the address of VAR valid
1735 if it is not can be placed between the CALL_INSN and INSN.
1737 To make sure this doesn't happen, we record the destination
1738 of the CALL_INSN and see if the next insn uses both that
1741 if (call_dest
!= 0 && GET_CODE (insn
) == INSN
1742 && reg_mentioned_p (var
, PATTERN (insn
))
1743 && reg_mentioned_p (call_dest
, PATTERN (insn
)))
1745 rtx temp
= gen_reg_rtx (GET_MODE (call_dest
));
1747 emit_insn_before (gen_move_insn (temp
, call_dest
), insn
);
1749 PATTERN (insn
) = replace_rtx (PATTERN (insn
),
1753 if (GET_CODE (insn
) == CALL_INSN
1754 && GET_CODE (PATTERN (insn
)) == SET
)
1755 call_dest
= SET_DEST (PATTERN (insn
));
1756 else if (GET_CODE (insn
) == CALL_INSN
1757 && GET_CODE (PATTERN (insn
)) == PARALLEL
1758 && GET_CODE (XVECEXP (PATTERN (insn
), 0, 0)) == SET
)
1759 call_dest
= SET_DEST (XVECEXP (PATTERN (insn
), 0, 0));
1764 /* See if we have to do anything to INSN now that VAR is in
1765 memory. If it needs to be loaded into a pseudo, use a single
1766 pseudo for the entire insn in case there is a MATCH_DUP
1767 between two operands. We pass a pointer to the head of
1768 a list of struct fixup_replacements. If fixup_var_refs_1
1769 needs to allocate pseudos or replacement MEMs (for SUBREGs),
1770 it will record them in this list.
1772 If it allocated a pseudo for any replacement, we copy into
1775 fixup_var_refs_1 (var
, promoted_mode
, &PATTERN (insn
), insn
,
1778 /* If this is last_parm_insn, and any instructions were output
1779 after it to fix it up, then we must set last_parm_insn to
1780 the last such instruction emitted. */
1781 if (insn
== last_parm_insn
)
1782 last_parm_insn
= PREV_INSN (next_insn
);
1784 while (replacements
)
1786 if (GET_CODE (replacements
->new) == REG
)
1791 /* OLD might be a (subreg (mem)). */
1792 if (GET_CODE (replacements
->old
) == SUBREG
)
1794 = fixup_memory_subreg (replacements
->old
, insn
, 0);
1797 = fixup_stack_1 (replacements
->old
, insn
);
1799 insert_before
= insn
;
1801 /* If we are changing the mode, do a conversion.
1802 This might be wasteful, but combine.c will
1803 eliminate much of the waste. */
1805 if (GET_MODE (replacements
->new)
1806 != GET_MODE (replacements
->old
))
1809 convert_move (replacements
->new,
1810 replacements
->old
, unsignedp
);
1811 seq
= gen_sequence ();
1815 seq
= gen_move_insn (replacements
->new,
1818 emit_insn_before (seq
, insert_before
);
1821 replacements
= replacements
->next
;
1825 /* Also fix up any invalid exprs in the REG_NOTES of this insn.
1826 But don't touch other insns referred to by reg-notes;
1827 we will get them elsewhere. */
1828 for (note
= REG_NOTES (insn
); note
; note
= XEXP (note
, 1))
1829 if (GET_CODE (note
) != INSN_LIST
)
1831 = walk_fixup_memory_subreg (XEXP (note
, 0), insn
, 1);
1837 /* VAR is a MEM that used to be a pseudo register with mode PROMOTED_MODE.
1838 See if the rtx expression at *LOC in INSN needs to be changed.
1840 REPLACEMENTS is a pointer to a list head that starts out zero, but may
1841 contain a list of original rtx's and replacements. If we find that we need
1842 to modify this insn by replacing a memory reference with a pseudo or by
1843 making a new MEM to implement a SUBREG, we consult that list to see if
1844 we have already chosen a replacement. If none has already been allocated,
1845 we allocate it and update the list. fixup_var_refs_insns will copy VAR
1846 or the SUBREG, as appropriate, to the pseudo. */
1849 fixup_var_refs_1 (var
, promoted_mode
, loc
, insn
, replacements
)
1851 enum machine_mode promoted_mode
;
1854 struct fixup_replacement
**replacements
;
1857 register rtx x
= *loc
;
1858 RTX_CODE code
= GET_CODE (x
);
1860 register rtx tem
, tem1
;
1861 struct fixup_replacement
*replacement
;
1866 if (XEXP (x
, 0) == var
)
1868 /* Prevent sharing of rtl that might lose. */
1869 rtx sub
= copy_rtx (XEXP (var
, 0));
1873 if (! validate_change (insn
, loc
, sub
, 0))
1875 rtx y
= force_operand (sub
, NULL_RTX
);
1877 if (! validate_change (insn
, loc
, y
, 0))
1878 *loc
= copy_to_reg (y
);
1881 emit_insn_before (gen_sequence (), insn
);
1889 /* If we already have a replacement, use it. Otherwise,
1890 try to fix up this address in case it is invalid. */
1892 replacement
= find_fixup_replacement (replacements
, var
);
1893 if (replacement
->new)
1895 *loc
= replacement
->new;
1899 *loc
= replacement
->new = x
= fixup_stack_1 (x
, insn
);
1901 /* Unless we are forcing memory to register or we changed the mode,
1902 we can leave things the way they are if the insn is valid. */
1904 INSN_CODE (insn
) = -1;
1905 if (! flag_force_mem
&& GET_MODE (x
) == promoted_mode
1906 && recog_memoized (insn
) >= 0)
1909 *loc
= replacement
->new = gen_reg_rtx (promoted_mode
);
1913 /* If X contains VAR, we need to unshare it here so that we update
1914 each occurrence separately. But all identical MEMs in one insn
1915 must be replaced with the same rtx because of the possibility of
1918 if (reg_mentioned_p (var
, x
))
1920 replacement
= find_fixup_replacement (replacements
, x
);
1921 if (replacement
->new == 0)
1922 replacement
->new = copy_most_rtx (x
, var
);
1924 *loc
= x
= replacement
->new;
1940 /* Note that in some cases those types of expressions are altered
1941 by optimize_bit_field, and do not survive to get here. */
1942 if (XEXP (x
, 0) == var
1943 || (GET_CODE (XEXP (x
, 0)) == SUBREG
1944 && SUBREG_REG (XEXP (x
, 0)) == var
))
1946 /* Get TEM as a valid MEM in the mode presently in the insn.
1948 We don't worry about the possibility of MATCH_DUP here; it
1949 is highly unlikely and would be tricky to handle. */
1952 if (GET_CODE (tem
) == SUBREG
)
1954 if (GET_MODE_BITSIZE (GET_MODE (tem
))
1955 > GET_MODE_BITSIZE (GET_MODE (var
)))
1957 replacement
= find_fixup_replacement (replacements
, var
);
1958 if (replacement
->new == 0)
1959 replacement
->new = gen_reg_rtx (GET_MODE (var
));
1960 SUBREG_REG (tem
) = replacement
->new;
1963 tem
= fixup_memory_subreg (tem
, insn
, 0);
1966 tem
= fixup_stack_1 (tem
, insn
);
1968 /* Unless we want to load from memory, get TEM into the proper mode
1969 for an extract from memory. This can only be done if the
1970 extract is at a constant position and length. */
1972 if (! flag_force_mem
&& GET_CODE (XEXP (x
, 1)) == CONST_INT
1973 && GET_CODE (XEXP (x
, 2)) == CONST_INT
1974 && ! mode_dependent_address_p (XEXP (tem
, 0))
1975 && ! MEM_VOLATILE_P (tem
))
1977 enum machine_mode wanted_mode
= VOIDmode
;
1978 enum machine_mode is_mode
= GET_MODE (tem
);
1979 HOST_WIDE_INT pos
= INTVAL (XEXP (x
, 2));
1982 if (GET_CODE (x
) == ZERO_EXTRACT
)
1984 wanted_mode
= insn_operand_mode
[(int) CODE_FOR_extzv
][1];
1985 if (wanted_mode
== VOIDmode
)
1986 wanted_mode
= word_mode
;
1990 if (GET_CODE (x
) == SIGN_EXTRACT
)
1992 wanted_mode
= insn_operand_mode
[(int) CODE_FOR_extv
][1];
1993 if (wanted_mode
== VOIDmode
)
1994 wanted_mode
= word_mode
;
1997 /* If we have a narrower mode, we can do something. */
1998 if (wanted_mode
!= VOIDmode
1999 && GET_MODE_SIZE (wanted_mode
) < GET_MODE_SIZE (is_mode
))
2001 HOST_WIDE_INT offset
= pos
/ BITS_PER_UNIT
;
2002 rtx old_pos
= XEXP (x
, 2);
2005 /* If the bytes and bits are counted differently, we
2006 must adjust the offset. */
2007 if (BYTES_BIG_ENDIAN
!= BITS_BIG_ENDIAN
)
2008 offset
= (GET_MODE_SIZE (is_mode
)
2009 - GET_MODE_SIZE (wanted_mode
) - offset
);
2011 pos
%= GET_MODE_BITSIZE (wanted_mode
);
2013 newmem
= gen_rtx_MEM (wanted_mode
,
2014 plus_constant (XEXP (tem
, 0), offset
));
2015 RTX_UNCHANGING_P (newmem
) = RTX_UNCHANGING_P (tem
);
2016 MEM_VOLATILE_P (newmem
) = MEM_VOLATILE_P (tem
);
2017 MEM_IN_STRUCT_P (newmem
) = MEM_IN_STRUCT_P (tem
);
2019 /* Make the change and see if the insn remains valid. */
2020 INSN_CODE (insn
) = -1;
2021 XEXP (x
, 0) = newmem
;
2022 XEXP (x
, 2) = GEN_INT (pos
);
2024 if (recog_memoized (insn
) >= 0)
2027 /* Otherwise, restore old position. XEXP (x, 0) will be
2029 XEXP (x
, 2) = old_pos
;
2033 /* If we get here, the bitfield extract insn can't accept a memory
2034 reference. Copy the input into a register. */
2036 tem1
= gen_reg_rtx (GET_MODE (tem
));
2037 emit_insn_before (gen_move_insn (tem1
, tem
), insn
);
2044 if (SUBREG_REG (x
) == var
)
2046 /* If this is a special SUBREG made because VAR was promoted
2047 from a wider mode, replace it with VAR and call ourself
2048 recursively, this time saying that the object previously
2049 had its current mode (by virtue of the SUBREG). */
2051 if (SUBREG_PROMOTED_VAR_P (x
))
2054 fixup_var_refs_1 (var
, GET_MODE (var
), loc
, insn
, replacements
);
2058 /* If this SUBREG makes VAR wider, it has become a paradoxical
2059 SUBREG with VAR in memory, but these aren't allowed at this
2060 stage of the compilation. So load VAR into a pseudo and take
2061 a SUBREG of that pseudo. */
2062 if (GET_MODE_SIZE (GET_MODE (x
)) > GET_MODE_SIZE (GET_MODE (var
)))
2064 replacement
= find_fixup_replacement (replacements
, var
);
2065 if (replacement
->new == 0)
2066 replacement
->new = gen_reg_rtx (GET_MODE (var
));
2067 SUBREG_REG (x
) = replacement
->new;
2071 /* See if we have already found a replacement for this SUBREG.
2072 If so, use it. Otherwise, make a MEM and see if the insn
2073 is recognized. If not, or if we should force MEM into a register,
2074 make a pseudo for this SUBREG. */
2075 replacement
= find_fixup_replacement (replacements
, x
);
2076 if (replacement
->new)
2078 *loc
= replacement
->new;
2082 replacement
->new = *loc
= fixup_memory_subreg (x
, insn
, 0);
2084 INSN_CODE (insn
) = -1;
2085 if (! flag_force_mem
&& recog_memoized (insn
) >= 0)
2088 *loc
= replacement
->new = gen_reg_rtx (GET_MODE (x
));
2094 /* First do special simplification of bit-field references. */
2095 if (GET_CODE (SET_DEST (x
)) == SIGN_EXTRACT
2096 || GET_CODE (SET_DEST (x
)) == ZERO_EXTRACT
)
2097 optimize_bit_field (x
, insn
, 0);
2098 if (GET_CODE (SET_SRC (x
)) == SIGN_EXTRACT
2099 || GET_CODE (SET_SRC (x
)) == ZERO_EXTRACT
)
2100 optimize_bit_field (x
, insn
, NULL_PTR
);
2102 /* For a paradoxical SUBREG inside a ZERO_EXTRACT, load the object
2103 into a register and then store it back out. */
2104 if (GET_CODE (SET_DEST (x
)) == ZERO_EXTRACT
2105 && GET_CODE (XEXP (SET_DEST (x
), 0)) == SUBREG
2106 && SUBREG_REG (XEXP (SET_DEST (x
), 0)) == var
2107 && (GET_MODE_SIZE (GET_MODE (XEXP (SET_DEST (x
), 0)))
2108 > GET_MODE_SIZE (GET_MODE (var
))))
2110 replacement
= find_fixup_replacement (replacements
, var
);
2111 if (replacement
->new == 0)
2112 replacement
->new = gen_reg_rtx (GET_MODE (var
));
2114 SUBREG_REG (XEXP (SET_DEST (x
), 0)) = replacement
->new;
2115 emit_insn_after (gen_move_insn (var
, replacement
->new), insn
);
2118 /* If SET_DEST is now a paradoxical SUBREG, put the result of this
2119 insn into a pseudo and store the low part of the pseudo into VAR. */
2120 if (GET_CODE (SET_DEST (x
)) == SUBREG
2121 && SUBREG_REG (SET_DEST (x
)) == var
2122 && (GET_MODE_SIZE (GET_MODE (SET_DEST (x
)))
2123 > GET_MODE_SIZE (GET_MODE (var
))))
2125 SET_DEST (x
) = tem
= gen_reg_rtx (GET_MODE (SET_DEST (x
)));
2126 emit_insn_after (gen_move_insn (var
, gen_lowpart (GET_MODE (var
),
2133 rtx dest
= SET_DEST (x
);
2134 rtx src
= SET_SRC (x
);
2136 rtx outerdest
= dest
;
2139 while (GET_CODE (dest
) == SUBREG
|| GET_CODE (dest
) == STRICT_LOW_PART
2140 || GET_CODE (dest
) == SIGN_EXTRACT
2141 || GET_CODE (dest
) == ZERO_EXTRACT
)
2142 dest
= XEXP (dest
, 0);
2144 if (GET_CODE (src
) == SUBREG
)
2145 src
= XEXP (src
, 0);
2147 /* If VAR does not appear at the top level of the SET
2148 just scan the lower levels of the tree. */
2150 if (src
!= var
&& dest
!= var
)
2153 /* We will need to rerecognize this insn. */
2154 INSN_CODE (insn
) = -1;
2157 if (GET_CODE (outerdest
) == ZERO_EXTRACT
&& dest
== var
)
2159 /* Since this case will return, ensure we fixup all the
2161 fixup_var_refs_1 (var
, promoted_mode
, &XEXP (outerdest
, 1),
2162 insn
, replacements
);
2163 fixup_var_refs_1 (var
, promoted_mode
, &XEXP (outerdest
, 2),
2164 insn
, replacements
);
2165 fixup_var_refs_1 (var
, promoted_mode
, &SET_SRC (x
),
2166 insn
, replacements
);
2168 tem
= XEXP (outerdest
, 0);
2170 /* Clean up (SUBREG:SI (MEM:mode ...) 0)
2171 that may appear inside a ZERO_EXTRACT.
2172 This was legitimate when the MEM was a REG. */
2173 if (GET_CODE (tem
) == SUBREG
2174 && SUBREG_REG (tem
) == var
)
2175 tem
= fixup_memory_subreg (tem
, insn
, 0);
2177 tem
= fixup_stack_1 (tem
, insn
);
2179 if (GET_CODE (XEXP (outerdest
, 1)) == CONST_INT
2180 && GET_CODE (XEXP (outerdest
, 2)) == CONST_INT
2181 && ! mode_dependent_address_p (XEXP (tem
, 0))
2182 && ! MEM_VOLATILE_P (tem
))
2184 enum machine_mode wanted_mode
;
2185 enum machine_mode is_mode
= GET_MODE (tem
);
2186 HOST_WIDE_INT pos
= INTVAL (XEXP (outerdest
, 2));
2188 wanted_mode
= insn_operand_mode
[(int) CODE_FOR_insv
][0];
2189 if (wanted_mode
== VOIDmode
)
2190 wanted_mode
= word_mode
;
2192 /* If we have a narrower mode, we can do something. */
2193 if (GET_MODE_SIZE (wanted_mode
) < GET_MODE_SIZE (is_mode
))
2195 HOST_WIDE_INT offset
= pos
/ BITS_PER_UNIT
;
2196 rtx old_pos
= XEXP (outerdest
, 2);
2199 if (BYTES_BIG_ENDIAN
!= BITS_BIG_ENDIAN
)
2200 offset
= (GET_MODE_SIZE (is_mode
)
2201 - GET_MODE_SIZE (wanted_mode
) - offset
);
2203 pos
%= GET_MODE_BITSIZE (wanted_mode
);
2205 newmem
= gen_rtx_MEM (wanted_mode
,
2206 plus_constant (XEXP (tem
, 0), offset
));
2207 RTX_UNCHANGING_P (newmem
) = RTX_UNCHANGING_P (tem
);
2208 MEM_VOLATILE_P (newmem
) = MEM_VOLATILE_P (tem
);
2209 MEM_IN_STRUCT_P (newmem
) = MEM_IN_STRUCT_P (tem
);
2211 /* Make the change and see if the insn remains valid. */
2212 INSN_CODE (insn
) = -1;
2213 XEXP (outerdest
, 0) = newmem
;
2214 XEXP (outerdest
, 2) = GEN_INT (pos
);
2216 if (recog_memoized (insn
) >= 0)
2219 /* Otherwise, restore old position. XEXP (x, 0) will be
2221 XEXP (outerdest
, 2) = old_pos
;
2225 /* If we get here, the bit-field store doesn't allow memory
2226 or isn't located at a constant position. Load the value into
2227 a register, do the store, and put it back into memory. */
2229 tem1
= gen_reg_rtx (GET_MODE (tem
));
2230 emit_insn_before (gen_move_insn (tem1
, tem
), insn
);
2231 emit_insn_after (gen_move_insn (tem
, tem1
), insn
);
2232 XEXP (outerdest
, 0) = tem1
;
2237 /* STRICT_LOW_PART is a no-op on memory references
2238 and it can cause combinations to be unrecognizable,
2241 if (dest
== var
&& GET_CODE (SET_DEST (x
)) == STRICT_LOW_PART
)
2242 SET_DEST (x
) = XEXP (SET_DEST (x
), 0);
2244 /* A valid insn to copy VAR into or out of a register
2245 must be left alone, to avoid an infinite loop here.
2246 If the reference to VAR is by a subreg, fix that up,
2247 since SUBREG is not valid for a memref.
2248 Also fix up the address of the stack slot.
2250 Note that we must not try to recognize the insn until
2251 after we know that we have valid addresses and no
2252 (subreg (mem ...) ...) constructs, since these interfere
2253 with determining the validity of the insn. */
2255 if ((SET_SRC (x
) == var
2256 || (GET_CODE (SET_SRC (x
)) == SUBREG
2257 && SUBREG_REG (SET_SRC (x
)) == var
))
2258 && (GET_CODE (SET_DEST (x
)) == REG
2259 || (GET_CODE (SET_DEST (x
)) == SUBREG
2260 && GET_CODE (SUBREG_REG (SET_DEST (x
))) == REG
))
2261 && GET_MODE (var
) == promoted_mode
2262 && x
== single_set (insn
))
2266 replacement
= find_fixup_replacement (replacements
, SET_SRC (x
));
2267 if (replacement
->new)
2268 SET_SRC (x
) = replacement
->new;
2269 else if (GET_CODE (SET_SRC (x
)) == SUBREG
)
2270 SET_SRC (x
) = replacement
->new
2271 = fixup_memory_subreg (SET_SRC (x
), insn
, 0);
2273 SET_SRC (x
) = replacement
->new
2274 = fixup_stack_1 (SET_SRC (x
), insn
);
2276 if (recog_memoized (insn
) >= 0)
2279 /* INSN is not valid, but we know that we want to
2280 copy SET_SRC (x) to SET_DEST (x) in some way. So
2281 we generate the move and see whether it requires more
2282 than one insn. If it does, we emit those insns and
2283 delete INSN. Otherwise, we an just replace the pattern
2284 of INSN; we have already verified above that INSN has
2285 no other function that to do X. */
2287 pat
= gen_move_insn (SET_DEST (x
), SET_SRC (x
));
2288 if (GET_CODE (pat
) == SEQUENCE
)
2290 emit_insn_after (pat
, insn
);
2291 PUT_CODE (insn
, NOTE
);
2292 NOTE_LINE_NUMBER (insn
) = NOTE_INSN_DELETED
;
2293 NOTE_SOURCE_FILE (insn
) = 0;
2296 PATTERN (insn
) = pat
;
2301 if ((SET_DEST (x
) == var
2302 || (GET_CODE (SET_DEST (x
)) == SUBREG
2303 && SUBREG_REG (SET_DEST (x
)) == var
))
2304 && (GET_CODE (SET_SRC (x
)) == REG
2305 || (GET_CODE (SET_SRC (x
)) == SUBREG
2306 && GET_CODE (SUBREG_REG (SET_SRC (x
))) == REG
))
2307 && GET_MODE (var
) == promoted_mode
2308 && x
== single_set (insn
))
2312 if (GET_CODE (SET_DEST (x
)) == SUBREG
)
2313 SET_DEST (x
) = fixup_memory_subreg (SET_DEST (x
), insn
, 0);
2315 SET_DEST (x
) = fixup_stack_1 (SET_DEST (x
), insn
);
2317 if (recog_memoized (insn
) >= 0)
2320 pat
= gen_move_insn (SET_DEST (x
), SET_SRC (x
));
2321 if (GET_CODE (pat
) == SEQUENCE
)
2323 emit_insn_after (pat
, insn
);
2324 PUT_CODE (insn
, NOTE
);
2325 NOTE_LINE_NUMBER (insn
) = NOTE_INSN_DELETED
;
2326 NOTE_SOURCE_FILE (insn
) = 0;
2329 PATTERN (insn
) = pat
;
2334 /* Otherwise, storing into VAR must be handled specially
2335 by storing into a temporary and copying that into VAR
2336 with a new insn after this one. Note that this case
2337 will be used when storing into a promoted scalar since
2338 the insn will now have different modes on the input
2339 and output and hence will be invalid (except for the case
2340 of setting it to a constant, which does not need any
2341 change if it is valid). We generate extra code in that case,
2342 but combine.c will eliminate it. */
2347 rtx fixeddest
= SET_DEST (x
);
2349 /* STRICT_LOW_PART can be discarded, around a MEM. */
2350 if (GET_CODE (fixeddest
) == STRICT_LOW_PART
)
2351 fixeddest
= XEXP (fixeddest
, 0);
2352 /* Convert (SUBREG (MEM)) to a MEM in a changed mode. */
2353 if (GET_CODE (fixeddest
) == SUBREG
)
2355 fixeddest
= fixup_memory_subreg (fixeddest
, insn
, 0);
2356 promoted_mode
= GET_MODE (fixeddest
);
2359 fixeddest
= fixup_stack_1 (fixeddest
, insn
);
2361 temp
= gen_reg_rtx (promoted_mode
);
2363 emit_insn_after (gen_move_insn (fixeddest
,
2364 gen_lowpart (GET_MODE (fixeddest
),
2368 SET_DEST (x
) = temp
;
2376 /* Nothing special about this RTX; fix its operands. */
2378 fmt
= GET_RTX_FORMAT (code
);
2379 for (i
= GET_RTX_LENGTH (code
) - 1; i
>= 0; i
--)
2382 fixup_var_refs_1 (var
, promoted_mode
, &XEXP (x
, i
), insn
, replacements
);
2386 for (j
= 0; j
< XVECLEN (x
, i
); j
++)
2387 fixup_var_refs_1 (var
, promoted_mode
, &XVECEXP (x
, i
, j
),
2388 insn
, replacements
);
2393 /* Given X, an rtx of the form (SUBREG:m1 (MEM:m2 addr)),
2394 return an rtx (MEM:m1 newaddr) which is equivalent.
2395 If any insns must be emitted to compute NEWADDR, put them before INSN.
2397 UNCRITICAL nonzero means accept paradoxical subregs.
2398 This is used for subregs found inside REG_NOTES. */
2401 fixup_memory_subreg (x
, insn
, uncritical
)
2406 int offset
= SUBREG_WORD (x
) * UNITS_PER_WORD
;
2407 rtx addr
= XEXP (SUBREG_REG (x
), 0);
2408 enum machine_mode mode
= GET_MODE (x
);
2411 /* Paradoxical SUBREGs are usually invalid during RTL generation. */
2412 if (GET_MODE_SIZE (mode
) > GET_MODE_SIZE (GET_MODE (SUBREG_REG (x
)))
2416 if (BYTES_BIG_ENDIAN
)
2417 offset
+= (MIN (UNITS_PER_WORD
, GET_MODE_SIZE (GET_MODE (SUBREG_REG (x
))))
2418 - MIN (UNITS_PER_WORD
, GET_MODE_SIZE (mode
)));
2419 addr
= plus_constant (addr
, offset
);
2420 if (!flag_force_addr
&& memory_address_p (mode
, addr
))
2421 /* Shortcut if no insns need be emitted. */
2422 return change_address (SUBREG_REG (x
), mode
, addr
);
2424 result
= change_address (SUBREG_REG (x
), mode
, addr
);
2425 emit_insn_before (gen_sequence (), insn
);
2430 /* Do fixup_memory_subreg on all (SUBREG (MEM ...) ...) contained in X.
2431 Replace subexpressions of X in place.
2432 If X itself is a (SUBREG (MEM ...) ...), return the replacement expression.
2433 Otherwise return X, with its contents possibly altered.
2435 If any insns must be emitted to compute NEWADDR, put them before INSN.
2437 UNCRITICAL is as in fixup_memory_subreg. */
2440 walk_fixup_memory_subreg (x
, insn
, uncritical
)
2445 register enum rtx_code code
;
2452 code
= GET_CODE (x
);
2454 if (code
== SUBREG
&& GET_CODE (SUBREG_REG (x
)) == MEM
)
2455 return fixup_memory_subreg (x
, insn
, uncritical
);
2457 /* Nothing special about this RTX; fix its operands. */
2459 fmt
= GET_RTX_FORMAT (code
);
2460 for (i
= GET_RTX_LENGTH (code
) - 1; i
>= 0; i
--)
2463 XEXP (x
, i
) = walk_fixup_memory_subreg (XEXP (x
, i
), insn
, uncritical
);
2467 for (j
= 0; j
< XVECLEN (x
, i
); j
++)
2469 = walk_fixup_memory_subreg (XVECEXP (x
, i
, j
), insn
, uncritical
);
2475 /* For each memory ref within X, if it refers to a stack slot
2476 with an out of range displacement, put the address in a temp register
2477 (emitting new insns before INSN to load these registers)
2478 and alter the memory ref to use that register.
2479 Replace each such MEM rtx with a copy, to avoid clobberage. */
2482 fixup_stack_1 (x
, insn
)
2487 register RTX_CODE code
= GET_CODE (x
);
2492 register rtx ad
= XEXP (x
, 0);
2493 /* If we have address of a stack slot but it's not valid
2494 (displacement is too large), compute the sum in a register. */
2495 if (GET_CODE (ad
) == PLUS
2496 && GET_CODE (XEXP (ad
, 0)) == REG
2497 && ((REGNO (XEXP (ad
, 0)) >= FIRST_VIRTUAL_REGISTER
2498 && REGNO (XEXP (ad
, 0)) <= LAST_VIRTUAL_REGISTER
)
2499 || REGNO (XEXP (ad
, 0)) == FRAME_POINTER_REGNUM
2500 #if HARD_FRAME_POINTER_REGNUM != FRAME_POINTER_REGNUM
2501 || REGNO (XEXP (ad
, 0)) == HARD_FRAME_POINTER_REGNUM
2503 || REGNO (XEXP (ad
, 0)) == STACK_POINTER_REGNUM
2504 || REGNO (XEXP (ad
, 0)) == ARG_POINTER_REGNUM
2505 || XEXP (ad
, 0) == current_function_internal_arg_pointer
)
2506 && GET_CODE (XEXP (ad
, 1)) == CONST_INT
)
2509 if (memory_address_p (GET_MODE (x
), ad
))
2513 temp
= copy_to_reg (ad
);
2514 seq
= gen_sequence ();
2516 emit_insn_before (seq
, insn
);
2517 return change_address (x
, VOIDmode
, temp
);
2522 fmt
= GET_RTX_FORMAT (code
);
2523 for (i
= GET_RTX_LENGTH (code
) - 1; i
>= 0; i
--)
2526 XEXP (x
, i
) = fixup_stack_1 (XEXP (x
, i
), insn
);
2530 for (j
= 0; j
< XVECLEN (x
, i
); j
++)
2531 XVECEXP (x
, i
, j
) = fixup_stack_1 (XVECEXP (x
, i
, j
), insn
);
2537 /* Optimization: a bit-field instruction whose field
2538 happens to be a byte or halfword in memory
2539 can be changed to a move instruction.
2541 We call here when INSN is an insn to examine or store into a bit-field.
2542 BODY is the SET-rtx to be altered.
2544 EQUIV_MEM is the table `reg_equiv_mem' if that is available; else 0.
2545 (Currently this is called only from function.c, and EQUIV_MEM
2549 optimize_bit_field (body
, insn
, equiv_mem
)
2554 register rtx bitfield
;
2557 enum machine_mode mode
;
2559 if (GET_CODE (SET_DEST (body
)) == SIGN_EXTRACT
2560 || GET_CODE (SET_DEST (body
)) == ZERO_EXTRACT
)
2561 bitfield
= SET_DEST (body
), destflag
= 1;
2563 bitfield
= SET_SRC (body
), destflag
= 0;
2565 /* First check that the field being stored has constant size and position
2566 and is in fact a byte or halfword suitably aligned. */
2568 if (GET_CODE (XEXP (bitfield
, 1)) == CONST_INT
2569 && GET_CODE (XEXP (bitfield
, 2)) == CONST_INT
2570 && ((mode
= mode_for_size (INTVAL (XEXP (bitfield
, 1)), MODE_INT
, 1))
2572 && INTVAL (XEXP (bitfield
, 2)) % INTVAL (XEXP (bitfield
, 1)) == 0)
2574 register rtx memref
= 0;
2576 /* Now check that the containing word is memory, not a register,
2577 and that it is safe to change the machine mode. */
2579 if (GET_CODE (XEXP (bitfield
, 0)) == MEM
)
2580 memref
= XEXP (bitfield
, 0);
2581 else if (GET_CODE (XEXP (bitfield
, 0)) == REG
2583 memref
= equiv_mem
[REGNO (XEXP (bitfield
, 0))];
2584 else if (GET_CODE (XEXP (bitfield
, 0)) == SUBREG
2585 && GET_CODE (SUBREG_REG (XEXP (bitfield
, 0))) == MEM
)
2586 memref
= SUBREG_REG (XEXP (bitfield
, 0));
2587 else if (GET_CODE (XEXP (bitfield
, 0)) == SUBREG
2589 && GET_CODE (SUBREG_REG (XEXP (bitfield
, 0))) == REG
)
2590 memref
= equiv_mem
[REGNO (SUBREG_REG (XEXP (bitfield
, 0)))];
2593 && ! mode_dependent_address_p (XEXP (memref
, 0))
2594 && ! MEM_VOLATILE_P (memref
))
2596 /* Now adjust the address, first for any subreg'ing
2597 that we are now getting rid of,
2598 and then for which byte of the word is wanted. */
2600 HOST_WIDE_INT offset
= INTVAL (XEXP (bitfield
, 2));
2603 /* Adjust OFFSET to count bits from low-address byte. */
2604 if (BITS_BIG_ENDIAN
!= BYTES_BIG_ENDIAN
)
2605 offset
= (GET_MODE_BITSIZE (GET_MODE (XEXP (bitfield
, 0)))
2606 - offset
- INTVAL (XEXP (bitfield
, 1)));
2608 /* Adjust OFFSET to count bytes from low-address byte. */
2609 offset
/= BITS_PER_UNIT
;
2610 if (GET_CODE (XEXP (bitfield
, 0)) == SUBREG
)
2612 offset
+= SUBREG_WORD (XEXP (bitfield
, 0)) * UNITS_PER_WORD
;
2613 if (BYTES_BIG_ENDIAN
)
2614 offset
-= (MIN (UNITS_PER_WORD
,
2615 GET_MODE_SIZE (GET_MODE (XEXP (bitfield
, 0))))
2616 - MIN (UNITS_PER_WORD
,
2617 GET_MODE_SIZE (GET_MODE (memref
))));
2621 memref
= change_address (memref
, mode
,
2622 plus_constant (XEXP (memref
, 0), offset
));
2623 insns
= get_insns ();
2625 emit_insns_before (insns
, insn
);
2627 /* Store this memory reference where
2628 we found the bit field reference. */
2632 validate_change (insn
, &SET_DEST (body
), memref
, 1);
2633 if (! CONSTANT_ADDRESS_P (SET_SRC (body
)))
2635 rtx src
= SET_SRC (body
);
2636 while (GET_CODE (src
) == SUBREG
2637 && SUBREG_WORD (src
) == 0)
2638 src
= SUBREG_REG (src
);
2639 if (GET_MODE (src
) != GET_MODE (memref
))
2640 src
= gen_lowpart (GET_MODE (memref
), SET_SRC (body
));
2641 validate_change (insn
, &SET_SRC (body
), src
, 1);
2643 else if (GET_MODE (SET_SRC (body
)) != VOIDmode
2644 && GET_MODE (SET_SRC (body
)) != GET_MODE (memref
))
2645 /* This shouldn't happen because anything that didn't have
2646 one of these modes should have got converted explicitly
2647 and then referenced through a subreg.
2648 This is so because the original bit-field was
2649 handled by agg_mode and so its tree structure had
2650 the same mode that memref now has. */
2655 rtx dest
= SET_DEST (body
);
2657 while (GET_CODE (dest
) == SUBREG
2658 && SUBREG_WORD (dest
) == 0
2659 && (GET_MODE_CLASS (GET_MODE (dest
))
2660 == GET_MODE_CLASS (GET_MODE (SUBREG_REG (dest
)))))
2661 dest
= SUBREG_REG (dest
);
2663 validate_change (insn
, &SET_DEST (body
), dest
, 1);
2665 if (GET_MODE (dest
) == GET_MODE (memref
))
2666 validate_change (insn
, &SET_SRC (body
), memref
, 1);
2669 /* Convert the mem ref to the destination mode. */
2670 rtx newreg
= gen_reg_rtx (GET_MODE (dest
));
2673 convert_move (newreg
, memref
,
2674 GET_CODE (SET_SRC (body
)) == ZERO_EXTRACT
);
2678 validate_change (insn
, &SET_SRC (body
), newreg
, 1);
2682 /* See if we can convert this extraction or insertion into
2683 a simple move insn. We might not be able to do so if this
2684 was, for example, part of a PARALLEL.
2686 If we succeed, write out any needed conversions. If we fail,
2687 it is hard to guess why we failed, so don't do anything
2688 special; just let the optimization be suppressed. */
2690 if (apply_change_group () && seq
)
2691 emit_insns_before (seq
, insn
);
2696 /* These routines are responsible for converting virtual register references
2697 to the actual hard register references once RTL generation is complete.
2699 The following four variables are used for communication between the
2700 routines. They contain the offsets of the virtual registers from their
2701 respective hard registers. */
2703 static int in_arg_offset
;
2704 static int var_offset
;
2705 static int dynamic_offset
;
2706 static int out_arg_offset
;
2707 static int cfa_offset
;
2709 /* In most machines, the stack pointer register is equivalent to the bottom
2712 #ifndef STACK_POINTER_OFFSET
2713 #define STACK_POINTER_OFFSET 0
2716 /* If not defined, pick an appropriate default for the offset of dynamically
2717 allocated memory depending on the value of ACCUMULATE_OUTGOING_ARGS,
2718 REG_PARM_STACK_SPACE, and OUTGOING_REG_PARM_STACK_SPACE. */
2720 #ifndef STACK_DYNAMIC_OFFSET
2722 #ifdef ACCUMULATE_OUTGOING_ARGS
2723 /* The bottom of the stack points to the actual arguments. If
2724 REG_PARM_STACK_SPACE is defined, this includes the space for the register
2725 parameters. However, if OUTGOING_REG_PARM_STACK space is not defined,
2726 stack space for register parameters is not pushed by the caller, but
2727 rather part of the fixed stack areas and hence not included in
2728 `current_function_outgoing_args_size'. Nevertheless, we must allow
2729 for it when allocating stack dynamic objects. */
2731 #if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
2732 #define STACK_DYNAMIC_OFFSET(FNDECL) \
2733 (current_function_outgoing_args_size \
2734 + REG_PARM_STACK_SPACE (FNDECL) + (STACK_POINTER_OFFSET))
2737 #define STACK_DYNAMIC_OFFSET(FNDECL) \
2738 (current_function_outgoing_args_size + (STACK_POINTER_OFFSET))
2742 #define STACK_DYNAMIC_OFFSET(FNDECL) STACK_POINTER_OFFSET
2746 /* On a few machines, the CFA coincides with the arg pointer. */
2748 #ifndef ARG_POINTER_CFA_OFFSET
2749 #define ARG_POINTER_CFA_OFFSET 0
2753 /* Build up a (MEM (ADDRESSOF (REG))) rtx for a register REG that just had
2754 its address taken. DECL is the decl for the object stored in the
2755 register, for later use if we do need to force REG into the stack.
2756 REG is overwritten by the MEM like in put_reg_into_stack. */
2759 gen_mem_addressof (reg
, decl
)
2763 tree type
= TREE_TYPE (decl
);
2764 rtx r
= gen_rtx_ADDRESSOF (Pmode
, gen_reg_rtx (GET_MODE (reg
)), REGNO (reg
));
2765 SET_ADDRESSOF_DECL (r
, decl
);
2766 /* If the original REG was a user-variable, then so is the REG whose
2767 address is being taken. */
2768 REG_USERVAR_P (XEXP (r
, 0)) = REG_USERVAR_P (reg
);
2771 PUT_CODE (reg
, MEM
);
2772 PUT_MODE (reg
, DECL_MODE (decl
));
2773 MEM_VOLATILE_P (reg
) = TREE_SIDE_EFFECTS (decl
);
2774 MEM_IN_STRUCT_P (reg
) = AGGREGATE_TYPE_P (type
);
2775 MEM_ALIAS_SET (reg
) = get_alias_set (decl
);
2777 if (TREE_USED (decl
) || DECL_INITIAL (decl
) != 0)
2778 fixup_var_refs (reg
, GET_MODE (reg
), TREE_UNSIGNED (type
));
2783 /* If DECL has an RTL that is an ADDRESSOF rtx, put it into the stack. */
2786 flush_addressof (decl
)
2789 if ((TREE_CODE (decl
) == PARM_DECL
|| TREE_CODE (decl
) == VAR_DECL
)
2790 && DECL_RTL (decl
) != 0
2791 && GET_CODE (DECL_RTL (decl
)) == MEM
2792 && GET_CODE (XEXP (DECL_RTL (decl
), 0)) == ADDRESSOF
2793 && GET_CODE (XEXP (XEXP (DECL_RTL (decl
), 0), 0)) == REG
)
2794 put_addressof_into_stack (XEXP (DECL_RTL (decl
), 0));
2797 /* Force the register pointed to by R, an ADDRESSOF rtx, into the stack. */
2800 put_addressof_into_stack (r
)
2803 tree decl
= ADDRESSOF_DECL (r
);
2804 rtx reg
= XEXP (r
, 0);
2806 if (GET_CODE (reg
) != REG
)
2809 put_reg_into_stack (0, reg
, TREE_TYPE (decl
), GET_MODE (reg
),
2810 DECL_MODE (decl
), TREE_SIDE_EFFECTS (decl
),
2811 ADDRESSOF_REGNO (r
),
2812 TREE_USED (decl
) || DECL_INITIAL (decl
) != 0);
2815 /* Helper function for purge_addressof. See if the rtx expression at *LOC
2816 in INSN needs to be changed. If FORCE, always put any ADDRESSOFs into
2820 purge_addressof_1 (loc
, insn
, force
, store
)
2830 /* Re-start here to avoid recursion in common cases. */
2837 code
= GET_CODE (x
);
2839 if (code
== ADDRESSOF
&& GET_CODE (XEXP (x
, 0)) == MEM
)
2842 /* We must create a copy of the rtx because it was created by
2843 overwriting a REG rtx which is always shared. */
2844 rtx sub
= copy_rtx (XEXP (XEXP (x
, 0), 0));
2846 if (validate_change (insn
, loc
, sub
, 0))
2850 if (! validate_change (insn
, loc
,
2851 force_operand (sub
, NULL_RTX
),
2855 insns
= gen_sequence ();
2857 emit_insns_before (insns
, insn
);
2860 else if (code
== MEM
&& GET_CODE (XEXP (x
, 0)) == ADDRESSOF
&& ! force
)
2862 rtx sub
= XEXP (XEXP (x
, 0), 0);
2864 if (GET_CODE (sub
) == MEM
)
2865 sub
= gen_rtx_MEM (GET_MODE (x
), copy_rtx (XEXP (sub
, 0)));
2867 if (GET_CODE (sub
) == REG
2868 && (MEM_VOLATILE_P (x
) || GET_MODE (x
) == BLKmode
))
2870 put_addressof_into_stack (XEXP (x
, 0));
2873 else if (GET_CODE (sub
) == REG
&& GET_MODE (x
) != GET_MODE (sub
))
2875 int size_x
, size_sub
;
2877 size_x
= GET_MODE_BITSIZE (GET_MODE (x
));
2878 size_sub
= GET_MODE_BITSIZE (GET_MODE (sub
));
2880 /* Don't even consider working with paradoxical subregs,
2881 or the moral equivalent seen here. */
2882 if (size_x
< size_sub
2883 && int_mode_for_mode (GET_MODE (sub
)) != BLKmode
)
2885 /* Do a bitfield insertion to mirror what would happen
2892 /* If we can't replace with a register, be afraid. */
2895 val
= gen_reg_rtx (GET_MODE (x
));
2896 if (! validate_change (insn
, loc
, val
, 0))
2898 seq
= gen_sequence ();
2900 emit_insn_before (seq
, insn
);
2903 store_bit_field (sub
, size_x
, 0, GET_MODE (x
),
2904 val
, GET_MODE_SIZE (GET_MODE (sub
)),
2905 GET_MODE_SIZE (GET_MODE (sub
)));
2907 seq
= gen_sequence ();
2909 emit_insn_after (seq
, insn
);
2914 val
= extract_bit_field (sub
, size_x
, 0, 1, NULL_RTX
,
2915 GET_MODE (x
), GET_MODE (x
),
2916 GET_MODE_SIZE (GET_MODE (sub
)),
2917 GET_MODE_SIZE (GET_MODE (sub
)));
2919 /* If we can't replace with a register, be afraid. */
2920 if (! validate_change (insn
, loc
, val
, 0))
2923 seq
= gen_sequence ();
2925 emit_insn_before (seq
, insn
);
2928 /* We replaced with a reg -- all done. */
2932 else if (validate_change (insn
, loc
, sub
, 0))
2934 /* else give up and put it into the stack */
2936 else if (code
== ADDRESSOF
)
2938 put_addressof_into_stack (x
);
2941 else if (code
== SET
)
2943 purge_addressof_1 (&SET_DEST (x
), insn
, force
, 1);
2944 purge_addressof_1 (&SET_SRC (x
), insn
, force
, 0);
2948 /* Scan all subexpressions. */
2949 fmt
= GET_RTX_FORMAT (code
);
2950 for (i
= 0; i
< GET_RTX_LENGTH (code
); i
++, fmt
++)
2953 purge_addressof_1 (&XEXP (x
, i
), insn
, force
, 0);
2954 else if (*fmt
== 'E')
2955 for (j
= 0; j
< XVECLEN (x
, i
); j
++)
2956 purge_addressof_1 (&XVECEXP (x
, i
, j
), insn
, force
, 0);
2960 /* Eliminate all occurrences of ADDRESSOF from INSNS. Elide any remaining
2961 (MEM (ADDRESSOF)) patterns, and force any needed registers into the
2965 purge_addressof (insns
)
2969 for (insn
= insns
; insn
; insn
= NEXT_INSN (insn
))
2970 if (GET_CODE (insn
) == INSN
|| GET_CODE (insn
) == JUMP_INSN
2971 || GET_CODE (insn
) == CALL_INSN
)
2973 purge_addressof_1 (&PATTERN (insn
), insn
,
2974 asm_noperands (PATTERN (insn
)) > 0, 0);
2975 purge_addressof_1 (®_NOTES (insn
), NULL_RTX
, 0, 0);
2979 /* Pass through the INSNS of function FNDECL and convert virtual register
2980 references to hard register references. */
2983 instantiate_virtual_regs (fndecl
, insns
)
2990 /* Compute the offsets to use for this function. */
2991 in_arg_offset
= FIRST_PARM_OFFSET (fndecl
);
2992 var_offset
= STARTING_FRAME_OFFSET
;
2993 dynamic_offset
= STACK_DYNAMIC_OFFSET (fndecl
);
2994 out_arg_offset
= STACK_POINTER_OFFSET
;
2995 cfa_offset
= ARG_POINTER_CFA_OFFSET
;
2997 /* Scan all variables and parameters of this function. For each that is
2998 in memory, instantiate all virtual registers if the result is a valid
2999 address. If not, we do it later. That will handle most uses of virtual
3000 regs on many machines. */
3001 instantiate_decls (fndecl
, 1);
3003 /* Initialize recognition, indicating that volatile is OK. */
3006 /* Scan through all the insns, instantiating every virtual register still
3008 for (insn
= insns
; insn
; insn
= NEXT_INSN (insn
))
3009 if (GET_CODE (insn
) == INSN
|| GET_CODE (insn
) == JUMP_INSN
3010 || GET_CODE (insn
) == CALL_INSN
)
3012 instantiate_virtual_regs_1 (&PATTERN (insn
), insn
, 1);
3013 instantiate_virtual_regs_1 (®_NOTES (insn
), NULL_RTX
, 0);
3016 /* Instantiate the stack slots for the parm registers, for later use in
3017 addressof elimination. */
3018 for (i
= 0; i
< max_parm_reg
; ++i
)
3019 if (parm_reg_stack_loc
[i
])
3020 instantiate_virtual_regs_1 (&parm_reg_stack_loc
[i
], NULL_RTX
, 0);
3022 /* Now instantiate the remaining register equivalences for debugging info.
3023 These will not be valid addresses. */
3024 instantiate_decls (fndecl
, 0);
3026 /* Indicate that, from now on, assign_stack_local should use
3027 frame_pointer_rtx. */
3028 virtuals_instantiated
= 1;
3031 /* Scan all decls in FNDECL (both variables and parameters) and instantiate
3032 all virtual registers in their DECL_RTL's.
3034 If VALID_ONLY, do this only if the resulting address is still valid.
3035 Otherwise, always do it. */
3038 instantiate_decls (fndecl
, valid_only
)
3044 if (DECL_SAVED_INSNS (fndecl
))
3045 /* When compiling an inline function, the obstack used for
3046 rtl allocation is the maybepermanent_obstack. Calling
3047 `resume_temporary_allocation' switches us back to that
3048 obstack while we process this function's parameters. */
3049 resume_temporary_allocation ();
3051 /* Process all parameters of the function. */
3052 for (decl
= DECL_ARGUMENTS (fndecl
); decl
; decl
= TREE_CHAIN (decl
))
3054 HOST_WIDE_INT size
= int_size_in_bytes (TREE_TYPE (decl
));
3056 instantiate_decl (DECL_RTL (decl
), size
, valid_only
);
3058 /* If the parameter was promoted, then the incoming RTL mode may be
3059 larger than the declared type size. We must use the larger of
3061 size
= MAX (GET_MODE_SIZE (GET_MODE (DECL_INCOMING_RTL (decl
))), size
);
3062 instantiate_decl (DECL_INCOMING_RTL (decl
), size
, valid_only
);
3065 /* Now process all variables defined in the function or its subblocks. */
3066 instantiate_decls_1 (DECL_INITIAL (fndecl
), valid_only
);
3068 if (DECL_INLINE (fndecl
) || DECL_DEFER_OUTPUT (fndecl
))
3070 /* Save all rtl allocated for this function by raising the
3071 high-water mark on the maybepermanent_obstack. */
3073 /* All further rtl allocation is now done in the current_obstack. */
3074 rtl_in_current_obstack ();
3078 /* Subroutine of instantiate_decls: Process all decls in the given
3079 BLOCK node and all its subblocks. */
3082 instantiate_decls_1 (let
, valid_only
)
3088 for (t
= BLOCK_VARS (let
); t
; t
= TREE_CHAIN (t
))
3089 instantiate_decl (DECL_RTL (t
), int_size_in_bytes (TREE_TYPE (t
)),
3092 /* Process all subblocks. */
3093 for (t
= BLOCK_SUBBLOCKS (let
); t
; t
= TREE_CHAIN (t
))
3094 instantiate_decls_1 (t
, valid_only
);
3097 /* Subroutine of the preceding procedures: Given RTL representing a
3098 decl and the size of the object, do any instantiation required.
3100 If VALID_ONLY is non-zero, it means that the RTL should only be
3101 changed if the new address is valid. */
3104 instantiate_decl (x
, size
, valid_only
)
3109 enum machine_mode mode
;
3112 /* If this is not a MEM, no need to do anything. Similarly if the
3113 address is a constant or a register that is not a virtual register. */
3115 if (x
== 0 || GET_CODE (x
) != MEM
)
3119 if (CONSTANT_P (addr
)
3120 || (GET_CODE (addr
) == ADDRESSOF
&& GET_CODE (XEXP (addr
, 0)) == REG
)
3121 || (GET_CODE (addr
) == REG
3122 && (REGNO (addr
) < FIRST_VIRTUAL_REGISTER
3123 || REGNO (addr
) > LAST_VIRTUAL_REGISTER
)))
3126 /* If we should only do this if the address is valid, copy the address.
3127 We need to do this so we can undo any changes that might make the
3128 address invalid. This copy is unfortunate, but probably can't be
3132 addr
= copy_rtx (addr
);
3134 instantiate_virtual_regs_1 (&addr
, NULL_RTX
, 0);
3138 /* Now verify that the resulting address is valid for every integer or
3139 floating-point mode up to and including SIZE bytes long. We do this
3140 since the object might be accessed in any mode and frame addresses
3143 for (mode
= GET_CLASS_NARROWEST_MODE (MODE_INT
);
3144 mode
!= VOIDmode
&& GET_MODE_SIZE (mode
) <= size
;
3145 mode
= GET_MODE_WIDER_MODE (mode
))
3146 if (! memory_address_p (mode
, addr
))
3149 for (mode
= GET_CLASS_NARROWEST_MODE (MODE_FLOAT
);
3150 mode
!= VOIDmode
&& GET_MODE_SIZE (mode
) <= size
;
3151 mode
= GET_MODE_WIDER_MODE (mode
))
3152 if (! memory_address_p (mode
, addr
))
3156 /* Put back the address now that we have updated it and we either know
3157 it is valid or we don't care whether it is valid. */
3162 /* Given a pointer to a piece of rtx and an optional pointer to the
3163 containing object, instantiate any virtual registers present in it.
3165 If EXTRA_INSNS, we always do the replacement and generate
3166 any extra insns before OBJECT. If it zero, we do nothing if replacement
3169 Return 1 if we either had nothing to do or if we were able to do the
3170 needed replacement. Return 0 otherwise; we only return zero if
3171 EXTRA_INSNS is zero.
3173 We first try some simple transformations to avoid the creation of extra
3177 instantiate_virtual_regs_1 (loc
, object
, extra_insns
)
3185 HOST_WIDE_INT offset
;
3191 /* Re-start here to avoid recursion in common cases. */
3198 code
= GET_CODE (x
);
3200 /* Check for some special cases. */
3217 /* We are allowed to set the virtual registers. This means that
3218 the actual register should receive the source minus the
3219 appropriate offset. This is used, for example, in the handling
3220 of non-local gotos. */
3221 if (SET_DEST (x
) == virtual_incoming_args_rtx
)
3222 new = arg_pointer_rtx
, offset
= - in_arg_offset
;
3223 else if (SET_DEST (x
) == virtual_stack_vars_rtx
)
3224 new = frame_pointer_rtx
, offset
= - var_offset
;
3225 else if (SET_DEST (x
) == virtual_stack_dynamic_rtx
)
3226 new = stack_pointer_rtx
, offset
= - dynamic_offset
;
3227 else if (SET_DEST (x
) == virtual_outgoing_args_rtx
)
3228 new = stack_pointer_rtx
, offset
= - out_arg_offset
;
3229 else if (SET_DEST (x
) == virtual_cfa_rtx
)
3230 new = arg_pointer_rtx
, offset
= - cfa_offset
;
3234 /* The only valid sources here are PLUS or REG. Just do
3235 the simplest possible thing to handle them. */
3236 if (GET_CODE (SET_SRC (x
)) != REG
3237 && GET_CODE (SET_SRC (x
)) != PLUS
)
3241 if (GET_CODE (SET_SRC (x
)) != REG
)
3242 temp
= force_operand (SET_SRC (x
), NULL_RTX
);
3245 temp
= force_operand (plus_constant (temp
, offset
), NULL_RTX
);
3249 emit_insns_before (seq
, object
);
3252 if (! validate_change (object
, &SET_SRC (x
), temp
, 0)
3259 instantiate_virtual_regs_1 (&SET_DEST (x
), object
, extra_insns
);
3264 /* Handle special case of virtual register plus constant. */
3265 if (CONSTANT_P (XEXP (x
, 1)))
3267 rtx old
, new_offset
;
3269 /* Check for (plus (plus VIRT foo) (const_int)) first. */
3270 if (GET_CODE (XEXP (x
, 0)) == PLUS
)
3272 rtx inner
= XEXP (XEXP (x
, 0), 0);
3274 if (inner
== virtual_incoming_args_rtx
)
3275 new = arg_pointer_rtx
, offset
= in_arg_offset
;
3276 else if (inner
== virtual_stack_vars_rtx
)
3277 new = frame_pointer_rtx
, offset
= var_offset
;
3278 else if (inner
== virtual_stack_dynamic_rtx
)
3279 new = stack_pointer_rtx
, offset
= dynamic_offset
;
3280 else if (inner
== virtual_outgoing_args_rtx
)
3281 new = stack_pointer_rtx
, offset
= out_arg_offset
;
3282 else if (inner
== virtual_cfa_rtx
)
3283 new = arg_pointer_rtx
, offset
= cfa_offset
;
3290 instantiate_virtual_regs_1 (&XEXP (XEXP (x
, 0), 1), object
,
3292 new = gen_rtx_PLUS (Pmode
, new, XEXP (XEXP (x
, 0), 1));
3295 else if (XEXP (x
, 0) == virtual_incoming_args_rtx
)
3296 new = arg_pointer_rtx
, offset
= in_arg_offset
;
3297 else if (XEXP (x
, 0) == virtual_stack_vars_rtx
)
3298 new = frame_pointer_rtx
, offset
= var_offset
;
3299 else if (XEXP (x
, 0) == virtual_stack_dynamic_rtx
)
3300 new = stack_pointer_rtx
, offset
= dynamic_offset
;
3301 else if (XEXP (x
, 0) == virtual_outgoing_args_rtx
)
3302 new = stack_pointer_rtx
, offset
= out_arg_offset
;
3303 else if (XEXP (x
, 0) == virtual_cfa_rtx
)
3304 new = arg_pointer_rtx
, offset
= cfa_offset
;
3307 /* We know the second operand is a constant. Unless the
3308 first operand is a REG (which has been already checked),
3309 it needs to be checked. */
3310 if (GET_CODE (XEXP (x
, 0)) != REG
)
3318 new_offset
= plus_constant (XEXP (x
, 1), offset
);
3320 /* If the new constant is zero, try to replace the sum with just
3322 if (new_offset
== const0_rtx
3323 && validate_change (object
, loc
, new, 0))
3326 /* Next try to replace the register and new offset.
3327 There are two changes to validate here and we can't assume that
3328 in the case of old offset equals new just changing the register
3329 will yield a valid insn. In the interests of a little efficiency,
3330 however, we only call validate change once (we don't queue up the
3331 changes and then call apply_change_group). */
3335 ? ! validate_change (object
, &XEXP (x
, 0), new, 0)
3336 : (XEXP (x
, 0) = new,
3337 ! validate_change (object
, &XEXP (x
, 1), new_offset
, 0)))
3345 /* Otherwise copy the new constant into a register and replace
3346 constant with that register. */
3347 temp
= gen_reg_rtx (Pmode
);
3349 if (validate_change (object
, &XEXP (x
, 1), temp
, 0))
3350 emit_insn_before (gen_move_insn (temp
, new_offset
), object
);
3353 /* If that didn't work, replace this expression with a
3354 register containing the sum. */
3357 new = gen_rtx_PLUS (Pmode
, new, new_offset
);
3360 temp
= force_operand (new, NULL_RTX
);
3364 emit_insns_before (seq
, object
);
3365 if (! validate_change (object
, loc
, temp
, 0)
3366 && ! validate_replace_rtx (x
, temp
, object
))
3374 /* Fall through to generic two-operand expression case. */
3380 case DIV
: case UDIV
:
3381 case MOD
: case UMOD
:
3382 case AND
: case IOR
: case XOR
:
3383 case ROTATERT
: case ROTATE
:
3384 case ASHIFTRT
: case LSHIFTRT
: case ASHIFT
:
3386 case GE
: case GT
: case GEU
: case GTU
:
3387 case LE
: case LT
: case LEU
: case LTU
:
3388 if (XEXP (x
, 1) && ! CONSTANT_P (XEXP (x
, 1)))
3389 instantiate_virtual_regs_1 (&XEXP (x
, 1), object
, extra_insns
);
3394 /* Most cases of MEM that convert to valid addresses have already been
3395 handled by our scan of decls. The only special handling we
3396 need here is to make a copy of the rtx to ensure it isn't being
3397 shared if we have to change it to a pseudo.
3399 If the rtx is a simple reference to an address via a virtual register,
3400 it can potentially be shared. In such cases, first try to make it
3401 a valid address, which can also be shared. Otherwise, copy it and
3404 First check for common cases that need no processing. These are
3405 usually due to instantiation already being done on a previous instance
3409 if (CONSTANT_ADDRESS_P (temp
)
3410 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
3411 || temp
== arg_pointer_rtx
3413 #if HARD_FRAME_POINTER_REGNUM != FRAME_POINTER_REGNUM
3414 || temp
== hard_frame_pointer_rtx
3416 || temp
== frame_pointer_rtx
)
3419 if (GET_CODE (temp
) == PLUS
3420 && CONSTANT_ADDRESS_P (XEXP (temp
, 1))
3421 && (XEXP (temp
, 0) == frame_pointer_rtx
3422 #if HARD_FRAME_POINTER_REGNUM != FRAME_POINTER_REGNUM
3423 || XEXP (temp
, 0) == hard_frame_pointer_rtx
3425 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
3426 || XEXP (temp
, 0) == arg_pointer_rtx
3431 if (temp
== virtual_stack_vars_rtx
3432 || temp
== virtual_incoming_args_rtx
3433 || (GET_CODE (temp
) == PLUS
3434 && CONSTANT_ADDRESS_P (XEXP (temp
, 1))
3435 && (XEXP (temp
, 0) == virtual_stack_vars_rtx
3436 || XEXP (temp
, 0) == virtual_incoming_args_rtx
)))
3438 /* This MEM may be shared. If the substitution can be done without
3439 the need to generate new pseudos, we want to do it in place
3440 so all copies of the shared rtx benefit. The call below will
3441 only make substitutions if the resulting address is still
3444 Note that we cannot pass X as the object in the recursive call
3445 since the insn being processed may not allow all valid
3446 addresses. However, if we were not passed on object, we can
3447 only modify X without copying it if X will have a valid
3450 ??? Also note that this can still lose if OBJECT is an insn that
3451 has less restrictions on an address that some other insn.
3452 In that case, we will modify the shared address. This case
3453 doesn't seem very likely, though. One case where this could
3454 happen is in the case of a USE or CLOBBER reference, but we
3455 take care of that below. */
3457 if (instantiate_virtual_regs_1 (&XEXP (x
, 0),
3458 object
? object
: x
, 0))
3461 /* Otherwise make a copy and process that copy. We copy the entire
3462 RTL expression since it might be a PLUS which could also be
3464 *loc
= x
= copy_rtx (x
);
3467 /* Fall through to generic unary operation case. */
3469 case STRICT_LOW_PART
:
3471 case PRE_DEC
: case PRE_INC
: case POST_DEC
: case POST_INC
:
3472 case SIGN_EXTEND
: case ZERO_EXTEND
:
3473 case TRUNCATE
: case FLOAT_EXTEND
: case FLOAT_TRUNCATE
:
3474 case FLOAT
: case FIX
:
3475 case UNSIGNED_FIX
: case UNSIGNED_FLOAT
:
3479 /* These case either have just one operand or we know that we need not
3480 check the rest of the operands. */
3486 /* If the operand is a MEM, see if the change is a valid MEM. If not,
3487 go ahead and make the invalid one, but do it to a copy. For a REG,
3488 just make the recursive call, since there's no chance of a problem. */
3490 if ((GET_CODE (XEXP (x
, 0)) == MEM
3491 && instantiate_virtual_regs_1 (&XEXP (XEXP (x
, 0), 0), XEXP (x
, 0),
3493 || (GET_CODE (XEXP (x
, 0)) == REG
3494 && instantiate_virtual_regs_1 (&XEXP (x
, 0), object
, 0)))
3497 XEXP (x
, 0) = copy_rtx (XEXP (x
, 0));
3502 /* Try to replace with a PLUS. If that doesn't work, compute the sum
3503 in front of this insn and substitute the temporary. */
3504 if (x
== virtual_incoming_args_rtx
)
3505 new = arg_pointer_rtx
, offset
= in_arg_offset
;
3506 else if (x
== virtual_stack_vars_rtx
)
3507 new = frame_pointer_rtx
, offset
= var_offset
;
3508 else if (x
== virtual_stack_dynamic_rtx
)
3509 new = stack_pointer_rtx
, offset
= dynamic_offset
;
3510 else if (x
== virtual_outgoing_args_rtx
)
3511 new = stack_pointer_rtx
, offset
= out_arg_offset
;
3512 else if (x
== virtual_cfa_rtx
)
3513 new = arg_pointer_rtx
, offset
= cfa_offset
;
3517 temp
= plus_constant (new, offset
);
3518 if (!validate_change (object
, loc
, temp
, 0))
3524 temp
= force_operand (temp
, NULL_RTX
);
3528 emit_insns_before (seq
, object
);
3529 if (! validate_change (object
, loc
, temp
, 0)
3530 && ! validate_replace_rtx (x
, temp
, object
))
3538 if (GET_CODE (XEXP (x
, 0)) == REG
)
3541 else if (GET_CODE (XEXP (x
, 0)) == MEM
)
3543 /* If we have a (addressof (mem ..)), do any instantiation inside
3544 since we know we'll be making the inside valid when we finally
3545 remove the ADDRESSOF. */
3546 instantiate_virtual_regs_1 (&XEXP (XEXP (x
, 0), 0), NULL_RTX
, 0);
3555 /* Scan all subexpressions. */
3556 fmt
= GET_RTX_FORMAT (code
);
3557 for (i
= 0; i
< GET_RTX_LENGTH (code
); i
++, fmt
++)
3560 if (!instantiate_virtual_regs_1 (&XEXP (x
, i
), object
, extra_insns
))
3563 else if (*fmt
== 'E')
3564 for (j
= 0; j
< XVECLEN (x
, i
); j
++)
3565 if (! instantiate_virtual_regs_1 (&XVECEXP (x
, i
, j
), object
,
3572 /* Optimization: assuming this function does not receive nonlocal gotos,
3573 delete the handlers for such, as well as the insns to establish
3574 and disestablish them. */
3580 for (insn
= get_insns (); insn
; insn
= NEXT_INSN (insn
))
3582 /* Delete the handler by turning off the flag that would
3583 prevent jump_optimize from deleting it.
3584 Also permit deletion of the nonlocal labels themselves
3585 if nothing local refers to them. */
3586 if (GET_CODE (insn
) == CODE_LABEL
)
3590 LABEL_PRESERVE_P (insn
) = 0;
3592 /* Remove it from the nonlocal_label list, to avoid confusing
3594 for (t
= nonlocal_labels
, last_t
= 0; t
;
3595 last_t
= t
, t
= TREE_CHAIN (t
))
3596 if (DECL_RTL (TREE_VALUE (t
)) == insn
)
3601 nonlocal_labels
= TREE_CHAIN (nonlocal_labels
);
3603 TREE_CHAIN (last_t
) = TREE_CHAIN (t
);
3606 if (GET_CODE (insn
) == INSN
3607 && ((nonlocal_goto_handler_slot
!= 0
3608 && reg_mentioned_p (nonlocal_goto_handler_slot
, PATTERN (insn
)))
3609 || (nonlocal_goto_stack_level
!= 0
3610 && reg_mentioned_p (nonlocal_goto_stack_level
,
3616 /* Return a list (chain of EXPR_LIST nodes) for the nonlocal labels
3617 of the current function. */
3620 nonlocal_label_rtx_list ()
3625 for (t
= nonlocal_labels
; t
; t
= TREE_CHAIN (t
))
3626 x
= gen_rtx_EXPR_LIST (VOIDmode
, label_rtx (TREE_VALUE (t
)), x
);
3631 /* Output a USE for any register use in RTL.
3632 This is used with -noreg to mark the extent of lifespan
3633 of any registers used in a user-visible variable's DECL_RTL. */
3639 if (GET_CODE (rtl
) == REG
)
3640 /* This is a register variable. */
3641 emit_insn (gen_rtx_USE (VOIDmode
, rtl
));
3642 else if (GET_CODE (rtl
) == MEM
3643 && GET_CODE (XEXP (rtl
, 0)) == REG
3644 && (REGNO (XEXP (rtl
, 0)) < FIRST_VIRTUAL_REGISTER
3645 || REGNO (XEXP (rtl
, 0)) > LAST_VIRTUAL_REGISTER
)
3646 && XEXP (rtl
, 0) != current_function_internal_arg_pointer
)
3647 /* This is a variable-sized structure. */
3648 emit_insn (gen_rtx_USE (VOIDmode
, XEXP (rtl
, 0)));
3651 /* Like use_variable except that it outputs the USEs after INSN
3652 instead of at the end of the insn-chain. */
3655 use_variable_after (rtl
, insn
)
3658 if (GET_CODE (rtl
) == REG
)
3659 /* This is a register variable. */
3660 emit_insn_after (gen_rtx_USE (VOIDmode
, rtl
), insn
);
3661 else if (GET_CODE (rtl
) == MEM
3662 && GET_CODE (XEXP (rtl
, 0)) == REG
3663 && (REGNO (XEXP (rtl
, 0)) < FIRST_VIRTUAL_REGISTER
3664 || REGNO (XEXP (rtl
, 0)) > LAST_VIRTUAL_REGISTER
)
3665 && XEXP (rtl
, 0) != current_function_internal_arg_pointer
)
3666 /* This is a variable-sized structure. */
3667 emit_insn_after (gen_rtx_USE (VOIDmode
, XEXP (rtl
, 0)), insn
);
3673 return max_parm_reg
;
3676 /* Return the first insn following those generated by `assign_parms'. */
3679 get_first_nonparm_insn ()
3682 return NEXT_INSN (last_parm_insn
);
3683 return get_insns ();
3686 /* Return the first NOTE_INSN_BLOCK_BEG note in the function.
3687 Crash if there is none. */
3690 get_first_block_beg ()
3692 register rtx searcher
;
3693 register rtx insn
= get_first_nonparm_insn ();
3695 for (searcher
= insn
; searcher
; searcher
= NEXT_INSN (searcher
))
3696 if (GET_CODE (searcher
) == NOTE
3697 && NOTE_LINE_NUMBER (searcher
) == NOTE_INSN_BLOCK_BEG
)
3700 abort (); /* Invalid call to this function. (See comments above.) */
3704 /* Return 1 if EXP is an aggregate type (or a value with aggregate type).
3705 This means a type for which function calls must pass an address to the
3706 function or get an address back from the function.
3707 EXP may be a type node or an expression (whose type is tested). */
3710 aggregate_value_p (exp
)
3713 int i
, regno
, nregs
;
3716 if (TREE_CODE_CLASS (TREE_CODE (exp
)) == 't')
3719 type
= TREE_TYPE (exp
);
3721 if (RETURN_IN_MEMORY (type
))
3723 /* Types that are TREE_ADDRESSABLE must be constructed in memory,
3724 and thus can't be returned in registers. */
3725 if (TREE_ADDRESSABLE (type
))
3727 if (flag_pcc_struct_return
&& AGGREGATE_TYPE_P (type
))
3729 /* Make sure we have suitable call-clobbered regs to return
3730 the value in; if not, we must return it in memory. */
3731 reg
= hard_function_value (type
, 0);
3733 /* If we have something other than a REG (e.g. a PARALLEL), then assume
3735 if (GET_CODE (reg
) != REG
)
3738 regno
= REGNO (reg
);
3739 nregs
= HARD_REGNO_NREGS (regno
, TYPE_MODE (type
));
3740 for (i
= 0; i
< nregs
; i
++)
3741 if (! call_used_regs
[regno
+ i
])
3746 /* Assign RTL expressions to the function's parameters.
3747 This may involve copying them into registers and using
3748 those registers as the RTL for them.
3750 If SECOND_TIME is non-zero it means that this function is being
3751 called a second time. This is done by integrate.c when a function's
3752 compilation is deferred. We need to come back here in case the
3753 FUNCTION_ARG macro computes items needed for the rest of the compilation
3754 (such as changing which registers are fixed or caller-saved). But suppress
3755 writing any insns or setting DECL_RTL of anything in this case. */
3758 assign_parms (fndecl
, second_time
)
3763 register rtx entry_parm
= 0;
3764 register rtx stack_parm
= 0;
3765 CUMULATIVE_ARGS args_so_far
;
3766 enum machine_mode promoted_mode
, passed_mode
;
3767 enum machine_mode nominal_mode
, promoted_nominal_mode
;
3769 /* Total space needed so far for args on the stack,
3770 given as a constant and a tree-expression. */
3771 struct args_size stack_args_size
;
3772 tree fntype
= TREE_TYPE (fndecl
);
3773 tree fnargs
= DECL_ARGUMENTS (fndecl
);
3774 /* This is used for the arg pointer when referring to stack args. */
3775 rtx internal_arg_pointer
;
3776 /* This is a dummy PARM_DECL that we used for the function result if
3777 the function returns a structure. */
3778 tree function_result_decl
= 0;
3779 int varargs_setup
= 0;
3780 rtx conversion_insns
= 0;
3782 /* Nonzero if the last arg is named `__builtin_va_alist',
3783 which is used on some machines for old-fashioned non-ANSI varargs.h;
3784 this should be stuck onto the stack as if it had arrived there. */
3786 = (current_function_varargs
3788 && (parm
= tree_last (fnargs
)) != 0
3790 && (! strcmp (IDENTIFIER_POINTER (DECL_NAME (parm
)),
3791 "__builtin_va_alist")));
3793 /* Nonzero if function takes extra anonymous args.
3794 This means the last named arg must be on the stack
3795 right before the anonymous ones. */
3797 = (TYPE_ARG_TYPES (fntype
) != 0
3798 && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (fntype
)))
3799 != void_type_node
));
3801 current_function_stdarg
= stdarg
;
3803 /* If the reg that the virtual arg pointer will be translated into is
3804 not a fixed reg or is the stack pointer, make a copy of the virtual
3805 arg pointer, and address parms via the copy. The frame pointer is
3806 considered fixed even though it is not marked as such.
3808 The second time through, simply use ap to avoid generating rtx. */
3810 if ((ARG_POINTER_REGNUM
== STACK_POINTER_REGNUM
3811 || ! (fixed_regs
[ARG_POINTER_REGNUM
]
3812 || ARG_POINTER_REGNUM
== FRAME_POINTER_REGNUM
))
3814 internal_arg_pointer
= copy_to_reg (virtual_incoming_args_rtx
);
3816 internal_arg_pointer
= virtual_incoming_args_rtx
;
3817 current_function_internal_arg_pointer
= internal_arg_pointer
;
3819 stack_args_size
.constant
= 0;
3820 stack_args_size
.var
= 0;
3822 /* If struct value address is treated as the first argument, make it so. */
3823 if (aggregate_value_p (DECL_RESULT (fndecl
))
3824 && ! current_function_returns_pcc_struct
3825 && struct_value_incoming_rtx
== 0)
3827 tree type
= build_pointer_type (TREE_TYPE (fntype
));
3829 function_result_decl
= build_decl (PARM_DECL
, NULL_TREE
, type
);
3831 DECL_ARG_TYPE (function_result_decl
) = type
;
3832 TREE_CHAIN (function_result_decl
) = fnargs
;
3833 fnargs
= function_result_decl
;
3836 max_parm_reg
= LAST_VIRTUAL_REGISTER
+ 1;
3837 parm_reg_stack_loc
= (rtx
*) savealloc (max_parm_reg
* sizeof (rtx
));
3838 bzero ((char *) parm_reg_stack_loc
, max_parm_reg
* sizeof (rtx
));
3840 #ifdef INIT_CUMULATIVE_INCOMING_ARGS
3841 INIT_CUMULATIVE_INCOMING_ARGS (args_so_far
, fntype
, NULL_RTX
);
3843 INIT_CUMULATIVE_ARGS (args_so_far
, fntype
, NULL_RTX
, 0);
3846 /* We haven't yet found an argument that we must push and pretend the
3848 current_function_pretend_args_size
= 0;
3850 for (parm
= fnargs
; parm
; parm
= TREE_CHAIN (parm
))
3852 int aggregate
= AGGREGATE_TYPE_P (TREE_TYPE (parm
));
3853 struct args_size stack_offset
;
3854 struct args_size arg_size
;
3855 int passed_pointer
= 0;
3856 int did_conversion
= 0;
3857 tree passed_type
= DECL_ARG_TYPE (parm
);
3858 tree nominal_type
= TREE_TYPE (parm
);
3860 /* Set LAST_NAMED if this is last named arg before some
3862 int last_named
= ((TREE_CHAIN (parm
) == 0
3863 || DECL_NAME (TREE_CHAIN (parm
)) == 0)
3864 && (stdarg
|| current_function_varargs
));
3865 /* Set NAMED_ARG if this arg should be treated as a named arg. For
3866 most machines, if this is a varargs/stdarg function, then we treat
3867 the last named arg as if it were anonymous too. */
3868 int named_arg
= STRICT_ARGUMENT_NAMING
? 1 : ! last_named
;
3870 if (TREE_TYPE (parm
) == error_mark_node
3871 /* This can happen after weird syntax errors
3872 or if an enum type is defined among the parms. */
3873 || TREE_CODE (parm
) != PARM_DECL
3874 || passed_type
== NULL
)
3876 DECL_INCOMING_RTL (parm
) = DECL_RTL (parm
)
3877 = gen_rtx_MEM (BLKmode
, const0_rtx
);
3878 TREE_USED (parm
) = 1;
3882 /* For varargs.h function, save info about regs and stack space
3883 used by the individual args, not including the va_alist arg. */
3884 if (hide_last_arg
&& last_named
)
3885 current_function_args_info
= args_so_far
;
3887 /* Find mode of arg as it is passed, and mode of arg
3888 as it should be during execution of this function. */
3889 passed_mode
= TYPE_MODE (passed_type
);
3890 nominal_mode
= TYPE_MODE (nominal_type
);
3892 /* If the parm's mode is VOID, its value doesn't matter,
3893 and avoid the usual things like emit_move_insn that could crash. */
3894 if (nominal_mode
== VOIDmode
)
3896 DECL_INCOMING_RTL (parm
) = DECL_RTL (parm
) = const0_rtx
;
3900 /* If the parm is to be passed as a transparent union, use the
3901 type of the first field for the tests below. We have already
3902 verified that the modes are the same. */
3903 if (DECL_TRANSPARENT_UNION (parm
)
3904 || TYPE_TRANSPARENT_UNION (passed_type
))
3905 passed_type
= TREE_TYPE (TYPE_FIELDS (passed_type
));
3907 /* See if this arg was passed by invisible reference. It is if
3908 it is an object whose size depends on the contents of the
3909 object itself or if the machine requires these objects be passed
3912 if ((TREE_CODE (TYPE_SIZE (passed_type
)) != INTEGER_CST
3913 && contains_placeholder_p (TYPE_SIZE (passed_type
)))
3914 || TREE_ADDRESSABLE (passed_type
)
3915 #ifdef FUNCTION_ARG_PASS_BY_REFERENCE
3916 || FUNCTION_ARG_PASS_BY_REFERENCE (args_so_far
, passed_mode
,
3917 passed_type
, named_arg
)
3921 passed_type
= nominal_type
= build_pointer_type (passed_type
);
3923 passed_mode
= nominal_mode
= Pmode
;
3926 promoted_mode
= passed_mode
;
3928 #ifdef PROMOTE_FUNCTION_ARGS
3929 /* Compute the mode in which the arg is actually extended to. */
3930 unsignedp
= TREE_UNSIGNED (passed_type
);
3931 promoted_mode
= promote_mode (passed_type
, promoted_mode
, &unsignedp
, 1);
3934 /* Let machine desc say which reg (if any) the parm arrives in.
3935 0 means it arrives on the stack. */
3936 #ifdef FUNCTION_INCOMING_ARG
3937 entry_parm
= FUNCTION_INCOMING_ARG (args_so_far
, promoted_mode
,
3938 passed_type
, named_arg
);
3940 entry_parm
= FUNCTION_ARG (args_so_far
, promoted_mode
,
3941 passed_type
, named_arg
);
3944 if (entry_parm
== 0)
3945 promoted_mode
= passed_mode
;
3947 #ifdef SETUP_INCOMING_VARARGS
3948 /* If this is the last named parameter, do any required setup for
3949 varargs or stdargs. We need to know about the case of this being an
3950 addressable type, in which case we skip the registers it
3951 would have arrived in.
3953 For stdargs, LAST_NAMED will be set for two parameters, the one that
3954 is actually the last named, and the dummy parameter. We only
3955 want to do this action once.
3957 Also, indicate when RTL generation is to be suppressed. */
3958 if (last_named
&& !varargs_setup
)
3960 SETUP_INCOMING_VARARGS (args_so_far
, promoted_mode
, passed_type
,
3961 current_function_pretend_args_size
,
3967 /* Determine parm's home in the stack,
3968 in case it arrives in the stack or we should pretend it did.
3970 Compute the stack position and rtx where the argument arrives
3973 There is one complexity here: If this was a parameter that would
3974 have been passed in registers, but wasn't only because it is
3975 __builtin_va_alist, we want locate_and_pad_parm to treat it as if
3976 it came in a register so that REG_PARM_STACK_SPACE isn't skipped.
3977 In this case, we call FUNCTION_ARG with NAMED set to 1 instead of
3978 0 as it was the previous time. */
3980 locate_and_pad_parm (promoted_mode
, passed_type
,
3981 #ifdef STACK_PARMS_IN_REG_PARM_AREA
3984 #ifdef FUNCTION_INCOMING_ARG
3985 FUNCTION_INCOMING_ARG (args_so_far
, promoted_mode
,
3988 || varargs_setup
)) != 0,
3990 FUNCTION_ARG (args_so_far
, promoted_mode
,
3992 named_arg
|| varargs_setup
) != 0,
3995 fndecl
, &stack_args_size
, &stack_offset
, &arg_size
);
3999 rtx offset_rtx
= ARGS_SIZE_RTX (stack_offset
);
4001 if (offset_rtx
== const0_rtx
)
4002 stack_parm
= gen_rtx_MEM (promoted_mode
, internal_arg_pointer
);
4004 stack_parm
= gen_rtx_MEM (promoted_mode
,
4005 gen_rtx_PLUS (Pmode
,
4006 internal_arg_pointer
,
4009 /* If this is a memory ref that contains aggregate components,
4010 mark it as such for cse and loop optimize. Likewise if it
4012 MEM_IN_STRUCT_P (stack_parm
) = aggregate
;
4013 RTX_UNCHANGING_P (stack_parm
) = TREE_READONLY (parm
);
4014 MEM_ALIAS_SET (stack_parm
) = get_alias_set (parm
);
4017 /* If this parameter was passed both in registers and in the stack,
4018 use the copy on the stack. */
4019 if (MUST_PASS_IN_STACK (promoted_mode
, passed_type
))
4022 #ifdef FUNCTION_ARG_PARTIAL_NREGS
4023 /* If this parm was passed part in regs and part in memory,
4024 pretend it arrived entirely in memory
4025 by pushing the register-part onto the stack.
4027 In the special case of a DImode or DFmode that is split,
4028 we could put it together in a pseudoreg directly,
4029 but for now that's not worth bothering with. */
4033 int nregs
= FUNCTION_ARG_PARTIAL_NREGS (args_so_far
, promoted_mode
,
4034 passed_type
, named_arg
);
4038 current_function_pretend_args_size
4039 = (((nregs
* UNITS_PER_WORD
) + (PARM_BOUNDARY
/ BITS_PER_UNIT
) - 1)
4040 / (PARM_BOUNDARY
/ BITS_PER_UNIT
)
4041 * (PARM_BOUNDARY
/ BITS_PER_UNIT
));
4045 /* Handle calls that pass values in multiple non-contiguous
4046 locations. The Irix 6 ABI has examples of this. */
4047 if (GET_CODE (entry_parm
) == PARALLEL
)
4048 emit_group_store (validize_mem (stack_parm
), entry_parm
,
4049 int_size_in_bytes (TREE_TYPE (parm
)),
4050 (TYPE_ALIGN (TREE_TYPE (parm
))
4053 move_block_from_reg (REGNO (entry_parm
),
4054 validize_mem (stack_parm
), nregs
,
4055 int_size_in_bytes (TREE_TYPE (parm
)));
4057 entry_parm
= stack_parm
;
4062 /* If we didn't decide this parm came in a register,
4063 by default it came on the stack. */
4064 if (entry_parm
== 0)
4065 entry_parm
= stack_parm
;
4067 /* Record permanently how this parm was passed. */
4069 DECL_INCOMING_RTL (parm
) = entry_parm
;
4071 /* If there is actually space on the stack for this parm,
4072 count it in stack_args_size; otherwise set stack_parm to 0
4073 to indicate there is no preallocated stack slot for the parm. */
4075 if (entry_parm
== stack_parm
4076 #if defined (REG_PARM_STACK_SPACE) && ! defined (MAYBE_REG_PARM_STACK_SPACE)
4077 /* On some machines, even if a parm value arrives in a register
4078 there is still an (uninitialized) stack slot allocated for it.
4080 ??? When MAYBE_REG_PARM_STACK_SPACE is defined, we can't tell
4081 whether this parameter already has a stack slot allocated,
4082 because an arg block exists only if current_function_args_size
4083 is larger than some threshold, and we haven't calculated that
4084 yet. So, for now, we just assume that stack slots never exist
4086 || REG_PARM_STACK_SPACE (fndecl
) > 0
4090 stack_args_size
.constant
+= arg_size
.constant
;
4092 ADD_PARM_SIZE (stack_args_size
, arg_size
.var
);
4095 /* No stack slot was pushed for this parm. */
4098 /* Update info on where next arg arrives in registers. */
4100 FUNCTION_ARG_ADVANCE (args_so_far
, promoted_mode
,
4101 passed_type
, named_arg
);
4103 /* If this is our second time through, we are done with this parm. */
4107 /* If we can't trust the parm stack slot to be aligned enough
4108 for its ultimate type, don't use that slot after entry.
4109 We'll make another stack slot, if we need one. */
4111 int thisparm_boundary
4112 = FUNCTION_ARG_BOUNDARY (promoted_mode
, passed_type
);
4114 if (GET_MODE_ALIGNMENT (nominal_mode
) > thisparm_boundary
)
4118 /* If parm was passed in memory, and we need to convert it on entry,
4119 don't store it back in that same slot. */
4121 && nominal_mode
!= BLKmode
&& nominal_mode
!= passed_mode
)
4125 /* Now adjust STACK_PARM to the mode and precise location
4126 where this parameter should live during execution,
4127 if we discover that it must live in the stack during execution.
4128 To make debuggers happier on big-endian machines, we store
4129 the value in the last bytes of the space available. */
4131 if (nominal_mode
!= BLKmode
&& nominal_mode
!= passed_mode
4136 if (BYTES_BIG_ENDIAN
4137 && GET_MODE_SIZE (nominal_mode
) < UNITS_PER_WORD
)
4138 stack_offset
.constant
+= (GET_MODE_SIZE (passed_mode
)
4139 - GET_MODE_SIZE (nominal_mode
));
4141 offset_rtx
= ARGS_SIZE_RTX (stack_offset
);
4142 if (offset_rtx
== const0_rtx
)
4143 stack_parm
= gen_rtx_MEM (nominal_mode
, internal_arg_pointer
);
4145 stack_parm
= gen_rtx_MEM (nominal_mode
,
4146 gen_rtx_PLUS (Pmode
,
4147 internal_arg_pointer
,
4150 /* If this is a memory ref that contains aggregate components,
4151 mark it as such for cse and loop optimize. */
4152 MEM_IN_STRUCT_P (stack_parm
) = aggregate
;
4157 /* We need this "use" info, because the gcc-register->stack-register
4158 converter in reg-stack.c needs to know which registers are active
4159 at the start of the function call. The actual parameter loading
4160 instructions are not always available then anymore, since they might
4161 have been optimised away. */
4163 if (GET_CODE (entry_parm
) == REG
&& !(hide_last_arg
&& last_named
))
4164 emit_insn (gen_rtx_USE (GET_MODE (entry_parm
), entry_parm
));
4167 /* ENTRY_PARM is an RTX for the parameter as it arrives,
4168 in the mode in which it arrives.
4169 STACK_PARM is an RTX for a stack slot where the parameter can live
4170 during the function (in case we want to put it there).
4171 STACK_PARM is 0 if no stack slot was pushed for it.
4173 Now output code if necessary to convert ENTRY_PARM to
4174 the type in which this function declares it,
4175 and store that result in an appropriate place,
4176 which may be a pseudo reg, may be STACK_PARM,
4177 or may be a local stack slot if STACK_PARM is 0.
4179 Set DECL_RTL to that place. */
4181 if (nominal_mode
== BLKmode
|| GET_CODE (entry_parm
) == PARALLEL
)
4183 /* If a BLKmode arrives in registers, copy it to a stack slot.
4184 Handle calls that pass values in multiple non-contiguous
4185 locations. The Irix 6 ABI has examples of this. */
4186 if (GET_CODE (entry_parm
) == REG
4187 || GET_CODE (entry_parm
) == PARALLEL
)
4190 = CEIL_ROUND (int_size_in_bytes (TREE_TYPE (parm
)),
4193 /* Note that we will be storing an integral number of words.
4194 So we have to be careful to ensure that we allocate an
4195 integral number of words. We do this below in the
4196 assign_stack_local if space was not allocated in the argument
4197 list. If it was, this will not work if PARM_BOUNDARY is not
4198 a multiple of BITS_PER_WORD. It isn't clear how to fix this
4199 if it becomes a problem. */
4201 if (stack_parm
== 0)
4204 = assign_stack_local (GET_MODE (entry_parm
),
4207 /* If this is a memory ref that contains aggregate
4208 components, mark it as such for cse and loop optimize. */
4209 MEM_IN_STRUCT_P (stack_parm
) = aggregate
;
4212 else if (PARM_BOUNDARY
% BITS_PER_WORD
!= 0)
4215 if (TREE_READONLY (parm
))
4216 RTX_UNCHANGING_P (stack_parm
) = 1;
4218 /* Handle calls that pass values in multiple non-contiguous
4219 locations. The Irix 6 ABI has examples of this. */
4220 if (GET_CODE (entry_parm
) == PARALLEL
)
4221 emit_group_store (validize_mem (stack_parm
), entry_parm
,
4222 int_size_in_bytes (TREE_TYPE (parm
)),
4223 (TYPE_ALIGN (TREE_TYPE (parm
))
4226 move_block_from_reg (REGNO (entry_parm
),
4227 validize_mem (stack_parm
),
4228 size_stored
/ UNITS_PER_WORD
,
4229 int_size_in_bytes (TREE_TYPE (parm
)));
4231 DECL_RTL (parm
) = stack_parm
;
4233 else if (! ((obey_regdecls
&& ! DECL_REGISTER (parm
)
4234 && ! DECL_INLINE (fndecl
))
4235 /* layout_decl may set this. */
4236 || TREE_ADDRESSABLE (parm
)
4237 || TREE_SIDE_EFFECTS (parm
)
4238 /* If -ffloat-store specified, don't put explicit
4239 float variables into registers. */
4240 || (flag_float_store
4241 && TREE_CODE (TREE_TYPE (parm
)) == REAL_TYPE
))
4242 /* Always assign pseudo to structure return or item passed
4243 by invisible reference. */
4244 || passed_pointer
|| parm
== function_result_decl
)
4246 /* Store the parm in a pseudoregister during the function, but we
4247 may need to do it in a wider mode. */
4249 register rtx parmreg
;
4250 int regno
, regnoi
= 0, regnor
= 0;
4252 unsignedp
= TREE_UNSIGNED (TREE_TYPE (parm
));
4254 promoted_nominal_mode
4255 = promote_mode (TREE_TYPE (parm
), nominal_mode
, &unsignedp
, 0);
4257 parmreg
= gen_reg_rtx (promoted_nominal_mode
);
4258 mark_user_reg (parmreg
);
4260 /* If this was an item that we received a pointer to, set DECL_RTL
4265 = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (passed_type
)), parmreg
);
4266 MEM_IN_STRUCT_P (DECL_RTL (parm
)) = aggregate
;
4269 DECL_RTL (parm
) = parmreg
;
4271 /* Copy the value into the register. */
4272 if (nominal_mode
!= passed_mode
4273 || promoted_nominal_mode
!= promoted_mode
)
4275 /* ENTRY_PARM has been converted to PROMOTED_MODE, its
4276 mode, by the caller. We now have to convert it to
4277 NOMINAL_MODE, if different. However, PARMREG may be in
4278 a different mode than NOMINAL_MODE if it is being stored
4281 If ENTRY_PARM is a hard register, it might be in a register
4282 not valid for operating in its mode (e.g., an odd-numbered
4283 register for a DFmode). In that case, moves are the only
4284 thing valid, so we can't do a convert from there. This
4285 occurs when the calling sequence allow such misaligned
4288 In addition, the conversion may involve a call, which could
4289 clobber parameters which haven't been copied to pseudo
4290 registers yet. Therefore, we must first copy the parm to
4291 a pseudo reg here, and save the conversion until after all
4292 parameters have been moved. */
4294 rtx tempreg
= gen_reg_rtx (GET_MODE (entry_parm
));
4296 emit_move_insn (tempreg
, validize_mem (entry_parm
));
4298 push_to_sequence (conversion_insns
);
4299 tempreg
= convert_to_mode (nominal_mode
, tempreg
, unsignedp
);
4301 expand_assignment (parm
,
4302 make_tree (nominal_type
, tempreg
), 0, 0);
4303 conversion_insns
= get_insns ();
4308 emit_move_insn (parmreg
, validize_mem (entry_parm
));
4310 /* If we were passed a pointer but the actual value
4311 can safely live in a register, put it in one. */
4312 if (passed_pointer
&& TYPE_MODE (TREE_TYPE (parm
)) != BLKmode
4313 && ! ((obey_regdecls
&& ! DECL_REGISTER (parm
)
4314 && ! DECL_INLINE (fndecl
))
4315 /* layout_decl may set this. */
4316 || TREE_ADDRESSABLE (parm
)
4317 || TREE_SIDE_EFFECTS (parm
)
4318 /* If -ffloat-store specified, don't put explicit
4319 float variables into registers. */
4320 || (flag_float_store
4321 && TREE_CODE (TREE_TYPE (parm
)) == REAL_TYPE
)))
4323 /* We can't use nominal_mode, because it will have been set to
4324 Pmode above. We must use the actual mode of the parm. */
4325 parmreg
= gen_reg_rtx (TYPE_MODE (TREE_TYPE (parm
)));
4326 mark_user_reg (parmreg
);
4327 emit_move_insn (parmreg
, DECL_RTL (parm
));
4328 DECL_RTL (parm
) = parmreg
;
4329 /* STACK_PARM is the pointer, not the parm, and PARMREG is
4333 #ifdef FUNCTION_ARG_CALLEE_COPIES
4334 /* If we are passed an arg by reference and it is our responsibility
4335 to make a copy, do it now.
4336 PASSED_TYPE and PASSED mode now refer to the pointer, not the
4337 original argument, so we must recreate them in the call to
4338 FUNCTION_ARG_CALLEE_COPIES. */
4339 /* ??? Later add code to handle the case that if the argument isn't
4340 modified, don't do the copy. */
4342 else if (passed_pointer
4343 && FUNCTION_ARG_CALLEE_COPIES (args_so_far
,
4344 TYPE_MODE (DECL_ARG_TYPE (parm
)),
4345 DECL_ARG_TYPE (parm
),
4347 && ! TREE_ADDRESSABLE (DECL_ARG_TYPE (parm
)))
4350 tree type
= DECL_ARG_TYPE (parm
);
4352 /* This sequence may involve a library call perhaps clobbering
4353 registers that haven't been copied to pseudos yet. */
4355 push_to_sequence (conversion_insns
);
4357 if (TYPE_SIZE (type
) == 0
4358 || TREE_CODE (TYPE_SIZE (type
)) != INTEGER_CST
)
4359 /* This is a variable sized object. */
4360 copy
= gen_rtx_MEM (BLKmode
,
4361 allocate_dynamic_stack_space
4362 (expr_size (parm
), NULL_RTX
,
4363 TYPE_ALIGN (type
)));
4365 copy
= assign_stack_temp (TYPE_MODE (type
),
4366 int_size_in_bytes (type
), 1);
4367 MEM_IN_STRUCT_P (copy
) = AGGREGATE_TYPE_P (type
);
4368 RTX_UNCHANGING_P (copy
) = TREE_READONLY (parm
);
4370 store_expr (parm
, copy
, 0);
4371 emit_move_insn (parmreg
, XEXP (copy
, 0));
4372 if (current_function_check_memory_usage
)
4373 emit_library_call (chkr_set_right_libfunc
, 1, VOIDmode
, 3,
4374 XEXP (copy
, 0), ptr_mode
,
4375 GEN_INT (int_size_in_bytes (type
)),
4376 TYPE_MODE (sizetype
),
4377 GEN_INT (MEMORY_USE_RW
),
4378 TYPE_MODE (integer_type_node
));
4379 conversion_insns
= get_insns ();
4383 #endif /* FUNCTION_ARG_CALLEE_COPIES */
4385 /* In any case, record the parm's desired stack location
4386 in case we later discover it must live in the stack.
4388 If it is a COMPLEX value, store the stack location for both
4391 if (GET_CODE (parmreg
) == CONCAT
)
4392 regno
= MAX (REGNO (XEXP (parmreg
, 0)), REGNO (XEXP (parmreg
, 1)));
4394 regno
= REGNO (parmreg
);
4396 if (regno
>= max_parm_reg
)
4399 int old_max_parm_reg
= max_parm_reg
;
4401 /* It's slow to expand this one register at a time,
4402 but it's also rare and we need max_parm_reg to be
4403 precisely correct. */
4404 max_parm_reg
= regno
+ 1;
4405 new = (rtx
*) savealloc (max_parm_reg
* sizeof (rtx
));
4406 bcopy ((char *) parm_reg_stack_loc
, (char *) new,
4407 old_max_parm_reg
* sizeof (rtx
));
4408 bzero ((char *) (new + old_max_parm_reg
),
4409 (max_parm_reg
- old_max_parm_reg
) * sizeof (rtx
));
4410 parm_reg_stack_loc
= new;
4413 if (GET_CODE (parmreg
) == CONCAT
)
4415 enum machine_mode submode
= GET_MODE (XEXP (parmreg
, 0));
4417 regnor
= REGNO (gen_realpart (submode
, parmreg
));
4418 regnoi
= REGNO (gen_imagpart (submode
, parmreg
));
4420 if (stack_parm
!= 0)
4422 parm_reg_stack_loc
[regnor
]
4423 = gen_realpart (submode
, stack_parm
);
4424 parm_reg_stack_loc
[regnoi
]
4425 = gen_imagpart (submode
, stack_parm
);
4429 parm_reg_stack_loc
[regnor
] = 0;
4430 parm_reg_stack_loc
[regnoi
] = 0;
4434 parm_reg_stack_loc
[REGNO (parmreg
)] = stack_parm
;
4436 /* Mark the register as eliminable if we did no conversion
4437 and it was copied from memory at a fixed offset,
4438 and the arg pointer was not copied to a pseudo-reg.
4439 If the arg pointer is a pseudo reg or the offset formed
4440 an invalid address, such memory-equivalences
4441 as we make here would screw up life analysis for it. */
4442 if (nominal_mode
== passed_mode
4445 && GET_CODE (stack_parm
) == MEM
4446 && stack_offset
.var
== 0
4447 && reg_mentioned_p (virtual_incoming_args_rtx
,
4448 XEXP (stack_parm
, 0)))
4450 rtx linsn
= get_last_insn ();
4453 /* Mark complex types separately. */
4454 if (GET_CODE (parmreg
) == CONCAT
)
4455 /* Scan backwards for the set of the real and
4457 for (sinsn
= linsn
; sinsn
!= 0;
4458 sinsn
= prev_nonnote_insn (sinsn
))
4460 set
= single_set (sinsn
);
4462 && SET_DEST (set
) == regno_reg_rtx
[regnoi
])
4464 = gen_rtx_EXPR_LIST (REG_EQUIV
,
4465 parm_reg_stack_loc
[regnoi
],
4468 && SET_DEST (set
) == regno_reg_rtx
[regnor
])
4470 = gen_rtx_EXPR_LIST (REG_EQUIV
,
4471 parm_reg_stack_loc
[regnor
],
4474 else if ((set
= single_set (linsn
)) != 0
4475 && SET_DEST (set
) == parmreg
)
4477 = gen_rtx_EXPR_LIST (REG_EQUIV
,
4478 stack_parm
, REG_NOTES (linsn
));
4481 /* For pointer data type, suggest pointer register. */
4482 if (POINTER_TYPE_P (TREE_TYPE (parm
)))
4483 mark_reg_pointer (parmreg
,
4484 (TYPE_ALIGN (TREE_TYPE (TREE_TYPE (parm
)))
4489 /* Value must be stored in the stack slot STACK_PARM
4490 during function execution. */
4492 if (promoted_mode
!= nominal_mode
)
4494 /* Conversion is required. */
4495 rtx tempreg
= gen_reg_rtx (GET_MODE (entry_parm
));
4497 emit_move_insn (tempreg
, validize_mem (entry_parm
));
4499 push_to_sequence (conversion_insns
);
4500 entry_parm
= convert_to_mode (nominal_mode
, tempreg
,
4501 TREE_UNSIGNED (TREE_TYPE (parm
)));
4504 /* ??? This may need a big-endian conversion on sparc64. */
4505 stack_parm
= change_address (stack_parm
, nominal_mode
,
4508 conversion_insns
= get_insns ();
4513 if (entry_parm
!= stack_parm
)
4515 if (stack_parm
== 0)
4518 = assign_stack_local (GET_MODE (entry_parm
),
4519 GET_MODE_SIZE (GET_MODE (entry_parm
)), 0);
4520 /* If this is a memory ref that contains aggregate components,
4521 mark it as such for cse and loop optimize. */
4522 MEM_IN_STRUCT_P (stack_parm
) = aggregate
;
4525 if (promoted_mode
!= nominal_mode
)
4527 push_to_sequence (conversion_insns
);
4528 emit_move_insn (validize_mem (stack_parm
),
4529 validize_mem (entry_parm
));
4530 conversion_insns
= get_insns ();
4534 emit_move_insn (validize_mem (stack_parm
),
4535 validize_mem (entry_parm
));
4537 if (current_function_check_memory_usage
)
4539 push_to_sequence (conversion_insns
);
4540 emit_library_call (chkr_set_right_libfunc
, 1, VOIDmode
, 3,
4541 XEXP (stack_parm
, 0), ptr_mode
,
4542 GEN_INT (GET_MODE_SIZE (GET_MODE
4544 TYPE_MODE (sizetype
),
4545 GEN_INT (MEMORY_USE_RW
),
4546 TYPE_MODE (integer_type_node
));
4548 conversion_insns
= get_insns ();
4551 DECL_RTL (parm
) = stack_parm
;
4554 /* If this "parameter" was the place where we are receiving the
4555 function's incoming structure pointer, set up the result. */
4556 if (parm
== function_result_decl
)
4558 tree result
= DECL_RESULT (fndecl
);
4559 tree restype
= TREE_TYPE (result
);
4562 = gen_rtx_MEM (DECL_MODE (result
), DECL_RTL (parm
));
4564 MEM_IN_STRUCT_P (DECL_RTL (result
)) = AGGREGATE_TYPE_P (restype
);
4567 if (TREE_THIS_VOLATILE (parm
))
4568 MEM_VOLATILE_P (DECL_RTL (parm
)) = 1;
4569 if (TREE_READONLY (parm
))
4570 RTX_UNCHANGING_P (DECL_RTL (parm
)) = 1;
4573 /* Output all parameter conversion instructions (possibly including calls)
4574 now that all parameters have been copied out of hard registers. */
4575 emit_insns (conversion_insns
);
4577 last_parm_insn
= get_last_insn ();
4579 current_function_args_size
= stack_args_size
.constant
;
4581 /* Adjust function incoming argument size for alignment and
4584 #ifdef REG_PARM_STACK_SPACE
4585 #ifndef MAYBE_REG_PARM_STACK_SPACE
4586 current_function_args_size
= MAX (current_function_args_size
,
4587 REG_PARM_STACK_SPACE (fndecl
));
4591 #ifdef STACK_BOUNDARY
4592 #define STACK_BYTES (STACK_BOUNDARY / BITS_PER_UNIT)
4594 current_function_args_size
4595 = ((current_function_args_size
+ STACK_BYTES
- 1)
4596 / STACK_BYTES
) * STACK_BYTES
;
4599 #ifdef ARGS_GROW_DOWNWARD
4600 current_function_arg_offset_rtx
4601 = (stack_args_size
.var
== 0 ? GEN_INT (-stack_args_size
.constant
)
4602 : expand_expr (size_binop (MINUS_EXPR
, stack_args_size
.var
,
4603 size_int (-stack_args_size
.constant
)),
4604 NULL_RTX
, VOIDmode
, EXPAND_MEMORY_USE_BAD
));
4606 current_function_arg_offset_rtx
= ARGS_SIZE_RTX (stack_args_size
);
4609 /* See how many bytes, if any, of its args a function should try to pop
4612 current_function_pops_args
= RETURN_POPS_ARGS (fndecl
, TREE_TYPE (fndecl
),
4613 current_function_args_size
);
4615 /* For stdarg.h function, save info about
4616 regs and stack space used by the named args. */
4619 current_function_args_info
= args_so_far
;
4621 /* Set the rtx used for the function return value. Put this in its
4622 own variable so any optimizers that need this information don't have
4623 to include tree.h. Do this here so it gets done when an inlined
4624 function gets output. */
4626 current_function_return_rtx
= DECL_RTL (DECL_RESULT (fndecl
));
4629 /* Indicate whether REGNO is an incoming argument to the current function
4630 that was promoted to a wider mode. If so, return the RTX for the
4631 register (to get its mode). PMODE and PUNSIGNEDP are set to the mode
4632 that REGNO is promoted from and whether the promotion was signed or
4635 #ifdef PROMOTE_FUNCTION_ARGS
4638 promoted_input_arg (regno
, pmode
, punsignedp
)
4640 enum machine_mode
*pmode
;
4645 for (arg
= DECL_ARGUMENTS (current_function_decl
); arg
;
4646 arg
= TREE_CHAIN (arg
))
4647 if (GET_CODE (DECL_INCOMING_RTL (arg
)) == REG
4648 && REGNO (DECL_INCOMING_RTL (arg
)) == regno
4649 && TYPE_MODE (DECL_ARG_TYPE (arg
)) == TYPE_MODE (TREE_TYPE (arg
)))
4651 enum machine_mode mode
= TYPE_MODE (TREE_TYPE (arg
));
4652 int unsignedp
= TREE_UNSIGNED (TREE_TYPE (arg
));
4654 mode
= promote_mode (TREE_TYPE (arg
), mode
, &unsignedp
, 1);
4655 if (mode
== GET_MODE (DECL_INCOMING_RTL (arg
))
4656 && mode
!= DECL_MODE (arg
))
4658 *pmode
= DECL_MODE (arg
);
4659 *punsignedp
= unsignedp
;
4660 return DECL_INCOMING_RTL (arg
);
4669 /* Compute the size and offset from the start of the stacked arguments for a
4670 parm passed in mode PASSED_MODE and with type TYPE.
4672 INITIAL_OFFSET_PTR points to the current offset into the stacked
4675 The starting offset and size for this parm are returned in *OFFSET_PTR
4676 and *ARG_SIZE_PTR, respectively.
4678 IN_REGS is non-zero if the argument will be passed in registers. It will
4679 never be set if REG_PARM_STACK_SPACE is not defined.
4681 FNDECL is the function in which the argument was defined.
4683 There are two types of rounding that are done. The first, controlled by
4684 FUNCTION_ARG_BOUNDARY, forces the offset from the start of the argument
4685 list to be aligned to the specific boundary (in bits). This rounding
4686 affects the initial and starting offsets, but not the argument size.
4688 The second, controlled by FUNCTION_ARG_PADDING and PARM_BOUNDARY,
4689 optionally rounds the size of the parm to PARM_BOUNDARY. The
4690 initial offset is not affected by this rounding, while the size always
4691 is and the starting offset may be. */
4693 /* offset_ptr will be negative for ARGS_GROW_DOWNWARD case;
4694 initial_offset_ptr is positive because locate_and_pad_parm's
4695 callers pass in the total size of args so far as
4696 initial_offset_ptr. arg_size_ptr is always positive.*/
4699 locate_and_pad_parm (passed_mode
, type
, in_regs
, fndecl
,
4700 initial_offset_ptr
, offset_ptr
, arg_size_ptr
)
4701 enum machine_mode passed_mode
;
4705 struct args_size
*initial_offset_ptr
;
4706 struct args_size
*offset_ptr
;
4707 struct args_size
*arg_size_ptr
;
4710 = type
? size_in_bytes (type
) : size_int (GET_MODE_SIZE (passed_mode
));
4711 enum direction where_pad
= FUNCTION_ARG_PADDING (passed_mode
, type
);
4712 int boundary
= FUNCTION_ARG_BOUNDARY (passed_mode
, type
);
4714 #ifdef REG_PARM_STACK_SPACE
4715 /* If we have found a stack parm before we reach the end of the
4716 area reserved for registers, skip that area. */
4719 int reg_parm_stack_space
= 0;
4721 #ifdef MAYBE_REG_PARM_STACK_SPACE
4722 reg_parm_stack_space
= MAYBE_REG_PARM_STACK_SPACE
;
4724 reg_parm_stack_space
= REG_PARM_STACK_SPACE (fndecl
);
4726 if (reg_parm_stack_space
> 0)
4728 if (initial_offset_ptr
->var
)
4730 initial_offset_ptr
->var
4731 = size_binop (MAX_EXPR
, ARGS_SIZE_TREE (*initial_offset_ptr
),
4732 size_int (reg_parm_stack_space
));
4733 initial_offset_ptr
->constant
= 0;
4735 else if (initial_offset_ptr
->constant
< reg_parm_stack_space
)
4736 initial_offset_ptr
->constant
= reg_parm_stack_space
;
4739 #endif /* REG_PARM_STACK_SPACE */
4741 arg_size_ptr
->var
= 0;
4742 arg_size_ptr
->constant
= 0;
4744 #ifdef ARGS_GROW_DOWNWARD
4745 if (initial_offset_ptr
->var
)
4747 offset_ptr
->constant
= 0;
4748 offset_ptr
->var
= size_binop (MINUS_EXPR
, integer_zero_node
,
4749 initial_offset_ptr
->var
);
4753 offset_ptr
->constant
= - initial_offset_ptr
->constant
;
4754 offset_ptr
->var
= 0;
4756 if (where_pad
!= none
4757 && (TREE_CODE (sizetree
) != INTEGER_CST
4758 || ((TREE_INT_CST_LOW (sizetree
) * BITS_PER_UNIT
) % PARM_BOUNDARY
)))
4759 sizetree
= round_up (sizetree
, PARM_BOUNDARY
/ BITS_PER_UNIT
);
4760 SUB_PARM_SIZE (*offset_ptr
, sizetree
);
4761 if (where_pad
!= downward
)
4762 pad_to_arg_alignment (offset_ptr
, boundary
);
4763 if (initial_offset_ptr
->var
)
4765 arg_size_ptr
->var
= size_binop (MINUS_EXPR
,
4766 size_binop (MINUS_EXPR
,
4768 initial_offset_ptr
->var
),
4773 arg_size_ptr
->constant
= (- initial_offset_ptr
->constant
4774 - offset_ptr
->constant
);
4776 #else /* !ARGS_GROW_DOWNWARD */
4777 pad_to_arg_alignment (initial_offset_ptr
, boundary
);
4778 *offset_ptr
= *initial_offset_ptr
;
4780 #ifdef PUSH_ROUNDING
4781 if (passed_mode
!= BLKmode
)
4782 sizetree
= size_int (PUSH_ROUNDING (TREE_INT_CST_LOW (sizetree
)));
4785 /* Pad_below needs the pre-rounded size to know how much to pad below
4786 so this must be done before rounding up. */
4787 if (where_pad
== downward
4788 /* However, BLKmode args passed in regs have their padding done elsewhere.
4789 The stack slot must be able to hold the entire register. */
4790 && !(in_regs
&& passed_mode
== BLKmode
))
4791 pad_below (offset_ptr
, passed_mode
, sizetree
);
4793 if (where_pad
!= none
4794 && (TREE_CODE (sizetree
) != INTEGER_CST
4795 || ((TREE_INT_CST_LOW (sizetree
) * BITS_PER_UNIT
) % PARM_BOUNDARY
)))
4796 sizetree
= round_up (sizetree
, PARM_BOUNDARY
/ BITS_PER_UNIT
);
4798 ADD_PARM_SIZE (*arg_size_ptr
, sizetree
);
4799 #endif /* ARGS_GROW_DOWNWARD */
4802 /* Round the stack offset in *OFFSET_PTR up to a multiple of BOUNDARY.
4803 BOUNDARY is measured in bits, but must be a multiple of a storage unit. */
4806 pad_to_arg_alignment (offset_ptr
, boundary
)
4807 struct args_size
*offset_ptr
;
4810 int boundary_in_bytes
= boundary
/ BITS_PER_UNIT
;
4812 if (boundary
> BITS_PER_UNIT
)
4814 if (offset_ptr
->var
)
4817 #ifdef ARGS_GROW_DOWNWARD
4822 (ARGS_SIZE_TREE (*offset_ptr
),
4823 boundary
/ BITS_PER_UNIT
);
4824 offset_ptr
->constant
= 0; /*?*/
4827 offset_ptr
->constant
=
4828 #ifdef ARGS_GROW_DOWNWARD
4829 FLOOR_ROUND (offset_ptr
->constant
, boundary_in_bytes
);
4831 CEIL_ROUND (offset_ptr
->constant
, boundary_in_bytes
);
4836 #ifndef ARGS_GROW_DOWNWARD
4838 pad_below (offset_ptr
, passed_mode
, sizetree
)
4839 struct args_size
*offset_ptr
;
4840 enum machine_mode passed_mode
;
4843 if (passed_mode
!= BLKmode
)
4845 if (GET_MODE_BITSIZE (passed_mode
) % PARM_BOUNDARY
)
4846 offset_ptr
->constant
4847 += (((GET_MODE_BITSIZE (passed_mode
) + PARM_BOUNDARY
- 1)
4848 / PARM_BOUNDARY
* PARM_BOUNDARY
/ BITS_PER_UNIT
)
4849 - GET_MODE_SIZE (passed_mode
));
4853 if (TREE_CODE (sizetree
) != INTEGER_CST
4854 || (TREE_INT_CST_LOW (sizetree
) * BITS_PER_UNIT
) % PARM_BOUNDARY
)
4856 /* Round the size up to multiple of PARM_BOUNDARY bits. */
4857 tree s2
= round_up (sizetree
, PARM_BOUNDARY
/ BITS_PER_UNIT
);
4859 ADD_PARM_SIZE (*offset_ptr
, s2
);
4860 SUB_PARM_SIZE (*offset_ptr
, sizetree
);
4866 #ifdef ARGS_GROW_DOWNWARD
4868 round_down (value
, divisor
)
4872 return size_binop (MULT_EXPR
,
4873 size_binop (FLOOR_DIV_EXPR
, value
, size_int (divisor
)),
4874 size_int (divisor
));
4878 /* Walk the tree of blocks describing the binding levels within a function
4879 and warn about uninitialized variables.
4880 This is done after calling flow_analysis and before global_alloc
4881 clobbers the pseudo-regs to hard regs. */
4884 uninitialized_vars_warning (block
)
4887 register tree decl
, sub
;
4888 for (decl
= BLOCK_VARS (block
); decl
; decl
= TREE_CHAIN (decl
))
4890 if (TREE_CODE (decl
) == VAR_DECL
4891 /* These warnings are unreliable for and aggregates
4892 because assigning the fields one by one can fail to convince
4893 flow.c that the entire aggregate was initialized.
4894 Unions are troublesome because members may be shorter. */
4895 && ! AGGREGATE_TYPE_P (TREE_TYPE (decl
))
4896 && DECL_RTL (decl
) != 0
4897 && GET_CODE (DECL_RTL (decl
)) == REG
4898 && regno_uninitialized (REGNO (DECL_RTL (decl
))))
4899 warning_with_decl (decl
,
4900 "`%s' might be used uninitialized in this function");
4901 if (TREE_CODE (decl
) == VAR_DECL
4902 && DECL_RTL (decl
) != 0
4903 && GET_CODE (DECL_RTL (decl
)) == REG
4904 && regno_clobbered_at_setjmp (REGNO (DECL_RTL (decl
))))
4905 warning_with_decl (decl
,
4906 "variable `%s' might be clobbered by `longjmp' or `vfork'");
4908 for (sub
= BLOCK_SUBBLOCKS (block
); sub
; sub
= TREE_CHAIN (sub
))
4909 uninitialized_vars_warning (sub
);
4912 /* Do the appropriate part of uninitialized_vars_warning
4913 but for arguments instead of local variables. */
4916 setjmp_args_warning ()
4919 for (decl
= DECL_ARGUMENTS (current_function_decl
);
4920 decl
; decl
= TREE_CHAIN (decl
))
4921 if (DECL_RTL (decl
) != 0
4922 && GET_CODE (DECL_RTL (decl
)) == REG
4923 && regno_clobbered_at_setjmp (REGNO (DECL_RTL (decl
))))
4924 warning_with_decl (decl
, "argument `%s' might be clobbered by `longjmp' or `vfork'");
4927 /* If this function call setjmp, put all vars into the stack
4928 unless they were declared `register'. */
4931 setjmp_protect (block
)
4934 register tree decl
, sub
;
4935 for (decl
= BLOCK_VARS (block
); decl
; decl
= TREE_CHAIN (decl
))
4936 if ((TREE_CODE (decl
) == VAR_DECL
4937 || TREE_CODE (decl
) == PARM_DECL
)
4938 && DECL_RTL (decl
) != 0
4939 && (GET_CODE (DECL_RTL (decl
)) == REG
4940 || (GET_CODE (DECL_RTL (decl
)) == MEM
4941 && GET_CODE (XEXP (DECL_RTL (decl
), 0)) == ADDRESSOF
))
4942 /* If this variable came from an inline function, it must be
4943 that its life doesn't overlap the setjmp. If there was a
4944 setjmp in the function, it would already be in memory. We
4945 must exclude such variable because their DECL_RTL might be
4946 set to strange things such as virtual_stack_vars_rtx. */
4947 && ! DECL_FROM_INLINE (decl
)
4949 #ifdef NON_SAVING_SETJMP
4950 /* If longjmp doesn't restore the registers,
4951 don't put anything in them. */
4955 ! DECL_REGISTER (decl
)))
4956 put_var_into_stack (decl
);
4957 for (sub
= BLOCK_SUBBLOCKS (block
); sub
; sub
= TREE_CHAIN (sub
))
4958 setjmp_protect (sub
);
4961 /* Like the previous function, but for args instead of local variables. */
4964 setjmp_protect_args ()
4967 for (decl
= DECL_ARGUMENTS (current_function_decl
);
4968 decl
; decl
= TREE_CHAIN (decl
))
4969 if ((TREE_CODE (decl
) == VAR_DECL
4970 || TREE_CODE (decl
) == PARM_DECL
)
4971 && DECL_RTL (decl
) != 0
4972 && (GET_CODE (DECL_RTL (decl
)) == REG
4973 || (GET_CODE (DECL_RTL (decl
)) == MEM
4974 && GET_CODE (XEXP (DECL_RTL (decl
), 0)) == ADDRESSOF
))
4976 /* If longjmp doesn't restore the registers,
4977 don't put anything in them. */
4978 #ifdef NON_SAVING_SETJMP
4982 ! DECL_REGISTER (decl
)))
4983 put_var_into_stack (decl
);
4986 /* Return the context-pointer register corresponding to DECL,
4987 or 0 if it does not need one. */
4990 lookup_static_chain (decl
)
4993 tree context
= decl_function_context (decl
);
4997 || (TREE_CODE (decl
) == FUNCTION_DECL
&& DECL_NO_STATIC_CHAIN (decl
)))
5000 /* We treat inline_function_decl as an alias for the current function
5001 because that is the inline function whose vars, types, etc.
5002 are being merged into the current function.
5003 See expand_inline_function. */
5004 if (context
== current_function_decl
|| context
== inline_function_decl
)
5005 return virtual_stack_vars_rtx
;
5007 for (link
= context_display
; link
; link
= TREE_CHAIN (link
))
5008 if (TREE_PURPOSE (link
) == context
)
5009 return RTL_EXPR_RTL (TREE_VALUE (link
));
5014 /* Convert a stack slot address ADDR for variable VAR
5015 (from a containing function)
5016 into an address valid in this function (using a static chain). */
5019 fix_lexical_addr (addr
, var
)
5024 HOST_WIDE_INT displacement
;
5025 tree context
= decl_function_context (var
);
5026 struct function
*fp
;
5029 /* If this is the present function, we need not do anything. */
5030 if (context
== current_function_decl
|| context
== inline_function_decl
)
5033 for (fp
= outer_function_chain
; fp
; fp
= fp
->next
)
5034 if (fp
->decl
== context
)
5040 if (GET_CODE (addr
) == ADDRESSOF
&& GET_CODE (XEXP (addr
, 0)) == MEM
)
5041 addr
= XEXP (XEXP (addr
, 0), 0);
5043 /* Decode given address as base reg plus displacement. */
5044 if (GET_CODE (addr
) == REG
)
5045 basereg
= addr
, displacement
= 0;
5046 else if (GET_CODE (addr
) == PLUS
&& GET_CODE (XEXP (addr
, 1)) == CONST_INT
)
5047 basereg
= XEXP (addr
, 0), displacement
= INTVAL (XEXP (addr
, 1));
5051 /* We accept vars reached via the containing function's
5052 incoming arg pointer and via its stack variables pointer. */
5053 if (basereg
== fp
->internal_arg_pointer
)
5055 /* If reached via arg pointer, get the arg pointer value
5056 out of that function's stack frame.
5058 There are two cases: If a separate ap is needed, allocate a
5059 slot in the outer function for it and dereference it that way.
5060 This is correct even if the real ap is actually a pseudo.
5061 Otherwise, just adjust the offset from the frame pointer to
5064 #ifdef NEED_SEPARATE_AP
5067 if (fp
->arg_pointer_save_area
== 0)
5068 fp
->arg_pointer_save_area
5069 = assign_outer_stack_local (Pmode
, GET_MODE_SIZE (Pmode
), 0, fp
);
5071 addr
= fix_lexical_addr (XEXP (fp
->arg_pointer_save_area
, 0), var
);
5072 addr
= memory_address (Pmode
, addr
);
5074 base
= copy_to_reg (gen_rtx_MEM (Pmode
, addr
));
5076 displacement
+= (FIRST_PARM_OFFSET (context
) - STARTING_FRAME_OFFSET
);
5077 base
= lookup_static_chain (var
);
5081 else if (basereg
== virtual_stack_vars_rtx
)
5083 /* This is the same code as lookup_static_chain, duplicated here to
5084 avoid an extra call to decl_function_context. */
5087 for (link
= context_display
; link
; link
= TREE_CHAIN (link
))
5088 if (TREE_PURPOSE (link
) == context
)
5090 base
= RTL_EXPR_RTL (TREE_VALUE (link
));
5098 /* Use same offset, relative to appropriate static chain or argument
5100 return plus_constant (base
, displacement
);
5103 /* Return the address of the trampoline for entering nested fn FUNCTION.
5104 If necessary, allocate a trampoline (in the stack frame)
5105 and emit rtl to initialize its contents (at entry to this function). */
5108 trampoline_address (function
)
5114 struct function
*fp
;
5117 /* Find an existing trampoline and return it. */
5118 for (link
= trampoline_list
; link
; link
= TREE_CHAIN (link
))
5119 if (TREE_PURPOSE (link
) == function
)
5121 round_trampoline_addr (XEXP (RTL_EXPR_RTL (TREE_VALUE (link
)), 0));
5123 for (fp
= outer_function_chain
; fp
; fp
= fp
->next
)
5124 for (link
= fp
->trampoline_list
; link
; link
= TREE_CHAIN (link
))
5125 if (TREE_PURPOSE (link
) == function
)
5127 tramp
= fix_lexical_addr (XEXP (RTL_EXPR_RTL (TREE_VALUE (link
)), 0),
5129 return round_trampoline_addr (tramp
);
5132 /* None exists; we must make one. */
5134 /* Find the `struct function' for the function containing FUNCTION. */
5136 fn_context
= decl_function_context (function
);
5137 if (fn_context
!= current_function_decl
5138 && fn_context
!= inline_function_decl
)
5139 for (fp
= outer_function_chain
; fp
; fp
= fp
->next
)
5140 if (fp
->decl
== fn_context
)
5143 /* Allocate run-time space for this trampoline
5144 (usually in the defining function's stack frame). */
5145 #ifdef ALLOCATE_TRAMPOLINE
5146 tramp
= ALLOCATE_TRAMPOLINE (fp
);
5148 /* If rounding needed, allocate extra space
5149 to ensure we have TRAMPOLINE_SIZE bytes left after rounding up. */
5150 #ifdef TRAMPOLINE_ALIGNMENT
5151 #define TRAMPOLINE_REAL_SIZE \
5152 (TRAMPOLINE_SIZE + (TRAMPOLINE_ALIGNMENT / BITS_PER_UNIT) - 1)
5154 #define TRAMPOLINE_REAL_SIZE (TRAMPOLINE_SIZE)
5157 tramp
= assign_outer_stack_local (BLKmode
, TRAMPOLINE_REAL_SIZE
, 0, fp
);
5159 tramp
= assign_stack_local (BLKmode
, TRAMPOLINE_REAL_SIZE
, 0);
5162 /* Record the trampoline for reuse and note it for later initialization
5163 by expand_function_end. */
5166 push_obstacks (fp
->function_maybepermanent_obstack
,
5167 fp
->function_maybepermanent_obstack
);
5168 rtlexp
= make_node (RTL_EXPR
);
5169 RTL_EXPR_RTL (rtlexp
) = tramp
;
5170 fp
->trampoline_list
= tree_cons (function
, rtlexp
, fp
->trampoline_list
);
5175 /* Make the RTL_EXPR node temporary, not momentary, so that the
5176 trampoline_list doesn't become garbage. */
5177 int momentary
= suspend_momentary ();
5178 rtlexp
= make_node (RTL_EXPR
);
5179 resume_momentary (momentary
);
5181 RTL_EXPR_RTL (rtlexp
) = tramp
;
5182 trampoline_list
= tree_cons (function
, rtlexp
, trampoline_list
);
5185 tramp
= fix_lexical_addr (XEXP (tramp
, 0), function
);
5186 return round_trampoline_addr (tramp
);
5189 /* Given a trampoline address,
5190 round it to multiple of TRAMPOLINE_ALIGNMENT. */
5193 round_trampoline_addr (tramp
)
5196 #ifdef TRAMPOLINE_ALIGNMENT
5197 /* Round address up to desired boundary. */
5198 rtx temp
= gen_reg_rtx (Pmode
);
5199 temp
= expand_binop (Pmode
, add_optab
, tramp
,
5200 GEN_INT (TRAMPOLINE_ALIGNMENT
/ BITS_PER_UNIT
- 1),
5201 temp
, 0, OPTAB_LIB_WIDEN
);
5202 tramp
= expand_binop (Pmode
, and_optab
, temp
,
5203 GEN_INT (- TRAMPOLINE_ALIGNMENT
/ BITS_PER_UNIT
),
5204 temp
, 0, OPTAB_LIB_WIDEN
);
5209 /* The functions identify_blocks and reorder_blocks provide a way to
5210 reorder the tree of BLOCK nodes, for optimizers that reshuffle or
5211 duplicate portions of the RTL code. Call identify_blocks before
5212 changing the RTL, and call reorder_blocks after. */
5214 /* Put all this function's BLOCK nodes including those that are chained
5215 onto the first block into a vector, and return it.
5216 Also store in each NOTE for the beginning or end of a block
5217 the index of that block in the vector.
5218 The arguments are BLOCK, the chain of top-level blocks of the function,
5219 and INSNS, the insn chain of the function. */
5222 identify_blocks (block
, insns
)
5230 int next_block_number
= 1;
5231 int current_block_number
= 1;
5237 n_blocks
= all_blocks (block
, 0);
5238 block_vector
= (tree
*) xmalloc (n_blocks
* sizeof (tree
));
5239 block_stack
= (int *) alloca (n_blocks
* sizeof (int));
5241 all_blocks (block
, block_vector
);
5243 for (insn
= insns
; insn
; insn
= NEXT_INSN (insn
))
5244 if (GET_CODE (insn
) == NOTE
)
5246 if (NOTE_LINE_NUMBER (insn
) == NOTE_INSN_BLOCK_BEG
)
5248 block_stack
[depth
++] = current_block_number
;
5249 current_block_number
= next_block_number
;
5250 NOTE_BLOCK_NUMBER (insn
) = next_block_number
++;
5252 if (NOTE_LINE_NUMBER (insn
) == NOTE_INSN_BLOCK_END
)
5254 NOTE_BLOCK_NUMBER (insn
) = current_block_number
;
5255 current_block_number
= block_stack
[--depth
];
5259 if (n_blocks
!= next_block_number
)
5262 return block_vector
;
5265 /* Given BLOCK_VECTOR which was returned by identify_blocks,
5266 and a revised instruction chain, rebuild the tree structure
5267 of BLOCK nodes to correspond to the new order of RTL.
5268 The new block tree is inserted below TOP_BLOCK.
5269 Returns the current top-level block. */
5272 reorder_blocks (block_vector
, block
, insns
)
5277 tree current_block
= block
;
5280 if (block_vector
== 0)
5283 /* Prune the old trees away, so that it doesn't get in the way. */
5284 BLOCK_SUBBLOCKS (current_block
) = 0;
5285 BLOCK_CHAIN (current_block
) = 0;
5287 for (insn
= insns
; insn
; insn
= NEXT_INSN (insn
))
5288 if (GET_CODE (insn
) == NOTE
)
5290 if (NOTE_LINE_NUMBER (insn
) == NOTE_INSN_BLOCK_BEG
)
5292 tree block
= block_vector
[NOTE_BLOCK_NUMBER (insn
)];
5293 /* If we have seen this block before, copy it. */
5294 if (TREE_ASM_WRITTEN (block
))
5295 block
= copy_node (block
);
5296 BLOCK_SUBBLOCKS (block
) = 0;
5297 TREE_ASM_WRITTEN (block
) = 1;
5298 BLOCK_SUPERCONTEXT (block
) = current_block
;
5299 BLOCK_CHAIN (block
) = BLOCK_SUBBLOCKS (current_block
);
5300 BLOCK_SUBBLOCKS (current_block
) = block
;
5301 current_block
= block
;
5302 NOTE_SOURCE_FILE (insn
) = 0;
5304 if (NOTE_LINE_NUMBER (insn
) == NOTE_INSN_BLOCK_END
)
5306 BLOCK_SUBBLOCKS (current_block
)
5307 = blocks_nreverse (BLOCK_SUBBLOCKS (current_block
));
5308 current_block
= BLOCK_SUPERCONTEXT (current_block
);
5309 NOTE_SOURCE_FILE (insn
) = 0;
5313 BLOCK_SUBBLOCKS (current_block
)
5314 = blocks_nreverse (BLOCK_SUBBLOCKS (current_block
));
5315 return current_block
;
5318 /* Reverse the order of elements in the chain T of blocks,
5319 and return the new head of the chain (old last element). */
5325 register tree prev
= 0, decl
, next
;
5326 for (decl
= t
; decl
; decl
= next
)
5328 next
= BLOCK_CHAIN (decl
);
5329 BLOCK_CHAIN (decl
) = prev
;
5335 /* Count the subblocks of the list starting with BLOCK, and list them
5336 all into the vector VECTOR. Also clear TREE_ASM_WRITTEN in all
5340 all_blocks (block
, vector
)
5348 TREE_ASM_WRITTEN (block
) = 0;
5350 /* Record this block. */
5352 vector
[n_blocks
] = block
;
5356 /* Record the subblocks, and their subblocks... */
5357 n_blocks
+= all_blocks (BLOCK_SUBBLOCKS (block
),
5358 vector
? vector
+ n_blocks
: 0);
5359 block
= BLOCK_CHAIN (block
);
5365 /* Generate RTL for the start of the function SUBR (a FUNCTION_DECL tree node)
5366 and initialize static variables for generating RTL for the statements
5370 init_function_start (subr
, filename
, line
)
5375 init_stmt_for_function ();
5377 cse_not_expected
= ! optimize
;
5379 /* Caller save not needed yet. */
5380 caller_save_needed
= 0;
5382 /* No stack slots have been made yet. */
5383 stack_slot_list
= 0;
5385 /* There is no stack slot for handling nonlocal gotos. */
5386 nonlocal_goto_handler_slot
= 0;
5387 nonlocal_goto_stack_level
= 0;
5389 /* No labels have been declared for nonlocal use. */
5390 nonlocal_labels
= 0;
5392 /* No function calls so far in this function. */
5393 function_call_count
= 0;
5395 /* No parm regs have been allocated.
5396 (This is important for output_inline_function.) */
5397 max_parm_reg
= LAST_VIRTUAL_REGISTER
+ 1;
5399 /* Initialize the RTL mechanism. */
5402 /* Initialize the queue of pending postincrement and postdecrements,
5403 and some other info in expr.c. */
5406 /* We haven't done register allocation yet. */
5409 init_const_rtx_hash_table ();
5411 current_function_name
= (*decl_printable_name
) (subr
, 2);
5413 /* Nonzero if this is a nested function that uses a static chain. */
5415 current_function_needs_context
5416 = (decl_function_context (current_function_decl
) != 0
5417 && ! DECL_NO_STATIC_CHAIN (current_function_decl
));
5419 /* Set if a call to setjmp is seen. */
5420 current_function_calls_setjmp
= 0;
5422 /* Set if a call to longjmp is seen. */
5423 current_function_calls_longjmp
= 0;
5425 current_function_calls_alloca
= 0;
5426 current_function_has_nonlocal_label
= 0;
5427 current_function_has_nonlocal_goto
= 0;
5428 current_function_contains_functions
= 0;
5429 current_function_is_thunk
= 0;
5431 current_function_returns_pcc_struct
= 0;
5432 current_function_returns_struct
= 0;
5433 current_function_epilogue_delay_list
= 0;
5434 current_function_uses_const_pool
= 0;
5435 current_function_uses_pic_offset_table
= 0;
5436 current_function_cannot_inline
= 0;
5438 /* We have not yet needed to make a label to jump to for tail-recursion. */
5439 tail_recursion_label
= 0;
5441 /* We haven't had a need to make a save area for ap yet. */
5443 arg_pointer_save_area
= 0;
5445 /* No stack slots allocated yet. */
5448 /* No SAVE_EXPRs in this function yet. */
5451 /* No RTL_EXPRs in this function yet. */
5454 /* Set up to allocate temporaries. */
5457 /* Within function body, compute a type's size as soon it is laid out. */
5458 immediate_size_expand
++;
5460 /* We haven't made any trampolines for this function yet. */
5461 trampoline_list
= 0;
5463 init_pending_stack_adjust ();
5464 inhibit_defer_pop
= 0;
5466 current_function_outgoing_args_size
= 0;
5468 /* Prevent ever trying to delete the first instruction of a function.
5469 Also tell final how to output a linenum before the function prologue.
5470 Note linenums could be missing, e.g. when compiling a Java .class file. */
5472 emit_line_note (filename
, line
);
5474 /* Make sure first insn is a note even if we don't want linenums.
5475 This makes sure the first insn will never be deleted.
5476 Also, final expects a note to appear there. */
5477 emit_note (NULL_PTR
, NOTE_INSN_DELETED
);
5479 /* Set flags used by final.c. */
5480 if (aggregate_value_p (DECL_RESULT (subr
)))
5482 #ifdef PCC_STATIC_STRUCT_RETURN
5483 current_function_returns_pcc_struct
= 1;
5485 current_function_returns_struct
= 1;
5488 /* Warn if this value is an aggregate type,
5489 regardless of which calling convention we are using for it. */
5490 if (warn_aggregate_return
5491 && AGGREGATE_TYPE_P (TREE_TYPE (DECL_RESULT (subr
))))
5492 warning ("function returns an aggregate");
5494 current_function_returns_pointer
5495 = POINTER_TYPE_P (TREE_TYPE (DECL_RESULT (subr
)));
5497 /* Indicate that we need to distinguish between the return value of the
5498 present function and the return value of a function being called. */
5499 rtx_equal_function_value_matters
= 1;
5501 /* Indicate that we have not instantiated virtual registers yet. */
5502 virtuals_instantiated
= 0;
5504 /* Indicate we have no need of a frame pointer yet. */
5505 frame_pointer_needed
= 0;
5507 /* By default assume not varargs or stdarg. */
5508 current_function_varargs
= 0;
5509 current_function_stdarg
= 0;
5512 /* Indicate that the current function uses extra args
5513 not explicitly mentioned in the argument list in any fashion. */
5518 current_function_varargs
= 1;
5521 /* Expand a call to __main at the beginning of a possible main function. */
5523 #if defined(INIT_SECTION_ASM_OP) && !defined(INVOKE__main)
5524 #undef HAS_INIT_SECTION
5525 #define HAS_INIT_SECTION
5529 expand_main_function ()
5531 #if !defined (HAS_INIT_SECTION)
5532 emit_library_call (gen_rtx_SYMBOL_REF (Pmode
, NAME__MAIN
), 0,
5534 #endif /* not HAS_INIT_SECTION */
5537 extern struct obstack permanent_obstack
;
5539 /* Start the RTL for a new function, and set variables used for
5541 SUBR is the FUNCTION_DECL node.
5542 PARMS_HAVE_CLEANUPS is nonzero if there are cleanups associated with
5543 the function's parameters, which must be run at any return statement. */
5546 expand_function_start (subr
, parms_have_cleanups
)
5548 int parms_have_cleanups
;
5552 rtx last_ptr
= NULL_RTX
;
5554 /* Make sure volatile mem refs aren't considered
5555 valid operands of arithmetic insns. */
5556 init_recog_no_volatile ();
5558 /* Set this before generating any memory accesses. */
5559 current_function_check_memory_usage
5560 = (flag_check_memory_usage
5561 && ! DECL_NO_CHECK_MEMORY_USAGE (current_function_decl
));
5563 current_function_instrument_entry_exit
5564 = (flag_instrument_function_entry_exit
5565 && ! DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (subr
));
5567 /* If function gets a static chain arg, store it in the stack frame.
5568 Do this first, so it gets the first stack slot offset. */
5569 if (current_function_needs_context
)
5571 last_ptr
= assign_stack_local (Pmode
, GET_MODE_SIZE (Pmode
), 0);
5573 /* Delay copying static chain if it is not a register to avoid
5574 conflicts with regs used for parameters. */
5575 if (! SMALL_REGISTER_CLASSES
5576 || GET_CODE (static_chain_incoming_rtx
) == REG
)
5577 emit_move_insn (last_ptr
, static_chain_incoming_rtx
);
5580 /* If the parameters of this function need cleaning up, get a label
5581 for the beginning of the code which executes those cleanups. This must
5582 be done before doing anything with return_label. */
5583 if (parms_have_cleanups
)
5584 cleanup_label
= gen_label_rtx ();
5588 /* Make the label for return statements to jump to, if this machine
5589 does not have a one-instruction return and uses an epilogue,
5590 or if it returns a structure, or if it has parm cleanups. */
5592 if (cleanup_label
== 0 && HAVE_return
5593 && ! current_function_instrument_entry_exit
5594 && ! current_function_returns_pcc_struct
5595 && ! (current_function_returns_struct
&& ! optimize
))
5598 return_label
= gen_label_rtx ();
5600 return_label
= gen_label_rtx ();
5603 /* Initialize rtx used to return the value. */
5604 /* Do this before assign_parms so that we copy the struct value address
5605 before any library calls that assign parms might generate. */
5607 /* Decide whether to return the value in memory or in a register. */
5608 if (aggregate_value_p (DECL_RESULT (subr
)))
5610 /* Returning something that won't go in a register. */
5611 register rtx value_address
= 0;
5613 #ifdef PCC_STATIC_STRUCT_RETURN
5614 if (current_function_returns_pcc_struct
)
5616 int size
= int_size_in_bytes (TREE_TYPE (DECL_RESULT (subr
)));
5617 value_address
= assemble_static_space (size
);
5622 /* Expect to be passed the address of a place to store the value.
5623 If it is passed as an argument, assign_parms will take care of
5625 if (struct_value_incoming_rtx
)
5627 value_address
= gen_reg_rtx (Pmode
);
5628 emit_move_insn (value_address
, struct_value_incoming_rtx
);
5633 DECL_RTL (DECL_RESULT (subr
))
5634 = gen_rtx_MEM (DECL_MODE (DECL_RESULT (subr
)), value_address
);
5635 MEM_IN_STRUCT_P (DECL_RTL (DECL_RESULT (subr
)))
5636 = AGGREGATE_TYPE_P (TREE_TYPE (DECL_RESULT (subr
)));
5639 else if (DECL_MODE (DECL_RESULT (subr
)) == VOIDmode
)
5640 /* If return mode is void, this decl rtl should not be used. */
5641 DECL_RTL (DECL_RESULT (subr
)) = 0;
5642 else if (parms_have_cleanups
|| current_function_instrument_entry_exit
)
5644 /* If function will end with cleanup code for parms,
5645 compute the return values into a pseudo reg,
5646 which we will copy into the true return register
5647 after the cleanups are done. */
5649 enum machine_mode mode
= DECL_MODE (DECL_RESULT (subr
));
5651 #ifdef PROMOTE_FUNCTION_RETURN
5652 tree type
= TREE_TYPE (DECL_RESULT (subr
));
5653 int unsignedp
= TREE_UNSIGNED (type
);
5655 mode
= promote_mode (type
, mode
, &unsignedp
, 1);
5658 DECL_RTL (DECL_RESULT (subr
)) = gen_reg_rtx (mode
);
5661 /* Scalar, returned in a register. */
5663 #ifdef FUNCTION_OUTGOING_VALUE
5664 DECL_RTL (DECL_RESULT (subr
))
5665 = FUNCTION_OUTGOING_VALUE (TREE_TYPE (DECL_RESULT (subr
)), subr
);
5667 DECL_RTL (DECL_RESULT (subr
))
5668 = FUNCTION_VALUE (TREE_TYPE (DECL_RESULT (subr
)), subr
);
5671 /* Mark this reg as the function's return value. */
5672 if (GET_CODE (DECL_RTL (DECL_RESULT (subr
))) == REG
)
5674 REG_FUNCTION_VALUE_P (DECL_RTL (DECL_RESULT (subr
))) = 1;
5675 /* Needed because we may need to move this to memory
5676 in case it's a named return value whose address is taken. */
5677 DECL_REGISTER (DECL_RESULT (subr
)) = 1;
5681 /* Initialize rtx for parameters and local variables.
5682 In some cases this requires emitting insns. */
5684 assign_parms (subr
, 0);
5686 /* Copy the static chain now if it wasn't a register. The delay is to
5687 avoid conflicts with the parameter passing registers. */
5689 if (SMALL_REGISTER_CLASSES
&& current_function_needs_context
)
5690 if (GET_CODE (static_chain_incoming_rtx
) != REG
)
5691 emit_move_insn (last_ptr
, static_chain_incoming_rtx
);
5693 /* The following was moved from init_function_start.
5694 The move is supposed to make sdb output more accurate. */
5695 /* Indicate the beginning of the function body,
5696 as opposed to parm setup. */
5697 emit_note (NULL_PTR
, NOTE_INSN_FUNCTION_BEG
);
5699 /* If doing stupid allocation, mark parms as born here. */
5701 if (GET_CODE (get_last_insn ()) != NOTE
)
5702 emit_note (NULL_PTR
, NOTE_INSN_DELETED
);
5703 parm_birth_insn
= get_last_insn ();
5707 for (i
= LAST_VIRTUAL_REGISTER
+ 1; i
< max_parm_reg
; i
++)
5708 use_variable (regno_reg_rtx
[i
]);
5710 if (current_function_internal_arg_pointer
!= virtual_incoming_args_rtx
)
5711 use_variable (current_function_internal_arg_pointer
);
5714 context_display
= 0;
5715 if (current_function_needs_context
)
5717 /* Fetch static chain values for containing functions. */
5718 tem
= decl_function_context (current_function_decl
);
5719 /* If not doing stupid register allocation copy the static chain
5720 pointer into a pseudo. If we have small register classes, copy
5721 the value from memory if static_chain_incoming_rtx is a REG. If
5722 we do stupid register allocation, we use the stack address
5724 if (tem
&& ! obey_regdecls
)
5726 /* If the static chain originally came in a register, put it back
5727 there, then move it out in the next insn. The reason for
5728 this peculiar code is to satisfy function integration. */
5729 if (SMALL_REGISTER_CLASSES
5730 && GET_CODE (static_chain_incoming_rtx
) == REG
)
5731 emit_move_insn (static_chain_incoming_rtx
, last_ptr
);
5732 last_ptr
= copy_to_reg (static_chain_incoming_rtx
);
5737 tree rtlexp
= make_node (RTL_EXPR
);
5739 RTL_EXPR_RTL (rtlexp
) = last_ptr
;
5740 context_display
= tree_cons (tem
, rtlexp
, context_display
);
5741 tem
= decl_function_context (tem
);
5744 /* Chain thru stack frames, assuming pointer to next lexical frame
5745 is found at the place we always store it. */
5746 #ifdef FRAME_GROWS_DOWNWARD
5747 last_ptr
= plus_constant (last_ptr
, - GET_MODE_SIZE (Pmode
));
5749 last_ptr
= copy_to_reg (gen_rtx_MEM (Pmode
,
5750 memory_address (Pmode
, last_ptr
)));
5752 /* If we are not optimizing, ensure that we know that this
5753 piece of context is live over the entire function. */
5755 save_expr_regs
= gen_rtx_EXPR_LIST (VOIDmode
, last_ptr
,
5760 if (current_function_instrument_entry_exit
)
5762 rtx fun
= DECL_RTL (current_function_decl
);
5763 if (GET_CODE (fun
) == MEM
)
5764 fun
= XEXP (fun
, 0);
5767 emit_library_call (profile_function_entry_libfunc
, 0, VOIDmode
, 2,
5769 expand_builtin_return_addr (BUILT_IN_RETURN_ADDRESS
,
5771 hard_frame_pointer_rtx
),
5775 /* After the display initializations is where the tail-recursion label
5776 should go, if we end up needing one. Ensure we have a NOTE here
5777 since some things (like trampolines) get placed before this. */
5778 tail_recursion_reentry
= emit_note (NULL_PTR
, NOTE_INSN_DELETED
);
5780 /* Evaluate now the sizes of any types declared among the arguments. */
5781 for (tem
= nreverse (get_pending_sizes ()); tem
; tem
= TREE_CHAIN (tem
))
5783 expand_expr (TREE_VALUE (tem
), const0_rtx
, VOIDmode
,
5784 EXPAND_MEMORY_USE_BAD
);
5785 /* Flush the queue in case this parameter declaration has
5790 /* Make sure there is a line number after the function entry setup code. */
5791 force_next_line_note ();
5794 /* Generate RTL for the end of the current function.
5795 FILENAME and LINE are the current position in the source file.
5797 It is up to language-specific callers to do cleanups for parameters--
5798 or else, supply 1 for END_BINDINGS and we will call expand_end_bindings. */
5801 expand_function_end (filename
, line
, end_bindings
)
5809 #ifdef TRAMPOLINE_TEMPLATE
5810 static rtx initial_trampoline
;
5813 #ifdef NON_SAVING_SETJMP
5814 /* Don't put any variables in registers if we call setjmp
5815 on a machine that fails to restore the registers. */
5816 if (NON_SAVING_SETJMP
&& current_function_calls_setjmp
)
5818 if (DECL_INITIAL (current_function_decl
) != error_mark_node
)
5819 setjmp_protect (DECL_INITIAL (current_function_decl
));
5821 setjmp_protect_args ();
5825 /* Save the argument pointer if a save area was made for it. */
5826 if (arg_pointer_save_area
)
5828 rtx x
= gen_move_insn (arg_pointer_save_area
, virtual_incoming_args_rtx
);
5829 emit_insn_before (x
, tail_recursion_reentry
);
5832 /* Initialize any trampolines required by this function. */
5833 for (link
= trampoline_list
; link
; link
= TREE_CHAIN (link
))
5835 tree function
= TREE_PURPOSE (link
);
5836 rtx context
= lookup_static_chain (function
);
5837 rtx tramp
= RTL_EXPR_RTL (TREE_VALUE (link
));
5838 #ifdef TRAMPOLINE_TEMPLATE
5843 #ifdef TRAMPOLINE_TEMPLATE
5844 /* First make sure this compilation has a template for
5845 initializing trampolines. */
5846 if (initial_trampoline
== 0)
5848 end_temporary_allocation ();
5850 = gen_rtx_MEM (BLKmode
, assemble_trampoline_template ());
5851 resume_temporary_allocation ();
5855 /* Generate insns to initialize the trampoline. */
5857 tramp
= round_trampoline_addr (XEXP (tramp
, 0));
5858 #ifdef TRAMPOLINE_TEMPLATE
5859 blktramp
= change_address (initial_trampoline
, BLKmode
, tramp
);
5860 emit_block_move (blktramp
, initial_trampoline
,
5861 GEN_INT (TRAMPOLINE_SIZE
),
5862 TRAMPOLINE_ALIGNMENT
/ BITS_PER_UNIT
);
5864 INITIALIZE_TRAMPOLINE (tramp
, XEXP (DECL_RTL (function
), 0), context
);
5868 /* Put those insns at entry to the containing function (this one). */
5869 emit_insns_before (seq
, tail_recursion_reentry
);
5872 /* If we are doing stack checking and this function makes calls,
5873 do a stack probe at the start of the function to ensure we have enough
5874 space for another stack frame. */
5875 if (flag_stack_check
&& ! STACK_CHECK_BUILTIN
)
5879 for (insn
= get_insns (); insn
; insn
= NEXT_INSN (insn
))
5880 if (GET_CODE (insn
) == CALL_INSN
)
5883 probe_stack_range (STACK_CHECK_PROTECT
,
5884 GEN_INT (STACK_CHECK_MAX_FRAME_SIZE
));
5887 emit_insns_before (seq
, tail_recursion_reentry
);
5892 /* Warn about unused parms if extra warnings were specified. */
5893 if (warn_unused
&& extra_warnings
)
5897 for (decl
= DECL_ARGUMENTS (current_function_decl
);
5898 decl
; decl
= TREE_CHAIN (decl
))
5899 if (! TREE_USED (decl
) && TREE_CODE (decl
) == PARM_DECL
5900 && DECL_NAME (decl
) && ! DECL_ARTIFICIAL (decl
))
5901 warning_with_decl (decl
, "unused parameter `%s'");
5904 /* Delete handlers for nonlocal gotos if nothing uses them. */
5905 if (nonlocal_goto_handler_slot
!= 0 && !current_function_has_nonlocal_label
)
5908 /* End any sequences that failed to be closed due to syntax errors. */
5909 while (in_sequence_p ())
5912 /* Outside function body, can't compute type's actual size
5913 until next function's body starts. */
5914 immediate_size_expand
--;
5916 /* If doing stupid register allocation,
5917 mark register parms as dying here. */
5922 for (i
= LAST_VIRTUAL_REGISTER
+ 1; i
< max_parm_reg
; i
++)
5923 use_variable (regno_reg_rtx
[i
]);
5925 /* Likewise for the regs of all the SAVE_EXPRs in the function. */
5927 for (tem
= save_expr_regs
; tem
; tem
= XEXP (tem
, 1))
5929 use_variable (XEXP (tem
, 0));
5930 use_variable_after (XEXP (tem
, 0), parm_birth_insn
);
5933 if (current_function_internal_arg_pointer
!= virtual_incoming_args_rtx
)
5934 use_variable (current_function_internal_arg_pointer
);
5937 clear_pending_stack_adjust ();
5938 do_pending_stack_adjust ();
5940 /* Mark the end of the function body.
5941 If control reaches this insn, the function can drop through
5942 without returning a value. */
5943 emit_note (NULL_PTR
, NOTE_INSN_FUNCTION_END
);
5945 /* Must mark the last line number note in the function, so that the test
5946 coverage code can avoid counting the last line twice. This just tells
5947 the code to ignore the immediately following line note, since there
5948 already exists a copy of this note somewhere above. This line number
5949 note is still needed for debugging though, so we can't delete it. */
5950 if (flag_test_coverage
)
5951 emit_note (NULL_PTR
, NOTE_REPEATED_LINE_NUMBER
);
5953 /* Output a linenumber for the end of the function.
5954 SDB depends on this. */
5955 emit_line_note_force (filename
, line
);
5957 /* Output the label for the actual return from the function,
5958 if one is expected. This happens either because a function epilogue
5959 is used instead of a return instruction, or because a return was done
5960 with a goto in order to run local cleanups, or because of pcc-style
5961 structure returning. */
5964 emit_label (return_label
);
5966 /* C++ uses this. */
5968 expand_end_bindings (0, 0, 0);
5970 /* Now handle any leftover exception regions that may have been
5971 created for the parameters. */
5973 rtx last
= get_last_insn ();
5976 expand_leftover_cleanups ();
5978 /* If the above emitted any code, may sure we jump around it. */
5979 if (last
!= get_last_insn ())
5981 label
= gen_label_rtx ();
5982 last
= emit_jump_insn_after (gen_jump (label
), last
);
5983 last
= emit_barrier_after (last
);
5988 if (current_function_instrument_entry_exit
)
5990 rtx fun
= DECL_RTL (current_function_decl
);
5991 if (GET_CODE (fun
) == MEM
)
5992 fun
= XEXP (fun
, 0);
5995 emit_library_call (profile_function_exit_libfunc
, 0, VOIDmode
, 2,
5997 expand_builtin_return_addr (BUILT_IN_RETURN_ADDRESS
,
5999 hard_frame_pointer_rtx
),
6003 /* If we had calls to alloca, and this machine needs
6004 an accurate stack pointer to exit the function,
6005 insert some code to save and restore the stack pointer. */
6006 #ifdef EXIT_IGNORE_STACK
6007 if (! EXIT_IGNORE_STACK
)
6009 if (current_function_calls_alloca
)
6013 emit_stack_save (SAVE_FUNCTION
, &tem
, parm_birth_insn
);
6014 emit_stack_restore (SAVE_FUNCTION
, tem
, NULL_RTX
);
6017 /* If scalar return value was computed in a pseudo-reg,
6018 copy that to the hard return register. */
6019 if (DECL_RTL (DECL_RESULT (current_function_decl
)) != 0
6020 && GET_CODE (DECL_RTL (DECL_RESULT (current_function_decl
))) == REG
6021 && (REGNO (DECL_RTL (DECL_RESULT (current_function_decl
)))
6022 >= FIRST_PSEUDO_REGISTER
))
6024 rtx real_decl_result
;
6026 #ifdef FUNCTION_OUTGOING_VALUE
6028 = FUNCTION_OUTGOING_VALUE (TREE_TYPE (DECL_RESULT (current_function_decl
)),
6029 current_function_decl
);
6032 = FUNCTION_VALUE (TREE_TYPE (DECL_RESULT (current_function_decl
)),
6033 current_function_decl
);
6035 REG_FUNCTION_VALUE_P (real_decl_result
) = 1;
6036 /* If this is a BLKmode structure being returned in registers, then use
6037 the mode computed in expand_return. */
6038 if (GET_MODE (real_decl_result
) == BLKmode
)
6039 PUT_MODE (real_decl_result
,
6040 GET_MODE (DECL_RTL (DECL_RESULT (current_function_decl
))));
6041 emit_move_insn (real_decl_result
,
6042 DECL_RTL (DECL_RESULT (current_function_decl
)));
6043 emit_insn (gen_rtx_USE (VOIDmode
, real_decl_result
));
6045 /* The delay slot scheduler assumes that current_function_return_rtx
6046 holds the hard register containing the return value, not a temporary
6048 current_function_return_rtx
= real_decl_result
;
6051 /* If returning a structure, arrange to return the address of the value
6052 in a place where debuggers expect to find it.
6054 If returning a structure PCC style,
6055 the caller also depends on this value.
6056 And current_function_returns_pcc_struct is not necessarily set. */
6057 if (current_function_returns_struct
6058 || current_function_returns_pcc_struct
)
6060 rtx value_address
= XEXP (DECL_RTL (DECL_RESULT (current_function_decl
)), 0);
6061 tree type
= TREE_TYPE (DECL_RESULT (current_function_decl
));
6062 #ifdef FUNCTION_OUTGOING_VALUE
6064 = FUNCTION_OUTGOING_VALUE (build_pointer_type (type
),
6065 current_function_decl
);
6068 = FUNCTION_VALUE (build_pointer_type (type
),
6069 current_function_decl
);
6072 /* Mark this as a function return value so integrate will delete the
6073 assignment and USE below when inlining this function. */
6074 REG_FUNCTION_VALUE_P (outgoing
) = 1;
6076 emit_move_insn (outgoing
, value_address
);
6077 use_variable (outgoing
);
6080 /* If this is an implementation of __throw, do what's necessary to
6081 communicate between __builtin_eh_return and the epilogue. */
6082 expand_eh_return ();
6084 /* Output a return insn if we are using one.
6085 Otherwise, let the rtl chain end here, to drop through
6086 into the epilogue. */
6091 emit_jump_insn (gen_return ());
6096 /* Fix up any gotos that jumped out to the outermost
6097 binding level of the function.
6098 Must follow emitting RETURN_LABEL. */
6100 /* If you have any cleanups to do at this point,
6101 and they need to create temporary variables,
6102 then you will lose. */
6103 expand_fixups (get_insns ());
6106 /* These arrays record the INSN_UIDs of the prologue and epilogue insns. */
6108 static int *prologue
;
6109 static int *epilogue
;
6111 /* Create an array that records the INSN_UIDs of INSNS (either a sequence
6112 or a single insn). */
6114 #if defined (HAVE_prologue) || defined (HAVE_epilogue)
6116 record_insns (insns
)
6121 if (GET_CODE (insns
) == SEQUENCE
)
6123 int len
= XVECLEN (insns
, 0);
6124 vec
= (int *) oballoc ((len
+ 1) * sizeof (int));
6127 vec
[len
] = INSN_UID (XVECEXP (insns
, 0, len
));
6131 vec
= (int *) oballoc (2 * sizeof (int));
6132 vec
[0] = INSN_UID (insns
);
6138 /* Determine how many INSN_UIDs in VEC are part of INSN. */
6141 contains (insn
, vec
)
6147 if (GET_CODE (insn
) == INSN
6148 && GET_CODE (PATTERN (insn
)) == SEQUENCE
)
6151 for (i
= XVECLEN (PATTERN (insn
), 0) - 1; i
>= 0; i
--)
6152 for (j
= 0; vec
[j
]; j
++)
6153 if (INSN_UID (XVECEXP (PATTERN (insn
), 0, i
)) == vec
[j
])
6159 for (j
= 0; vec
[j
]; j
++)
6160 if (INSN_UID (insn
) == vec
[j
])
6165 #endif /* HAVE_prologue || HAVE_epilogue */
6167 /* Generate the prologue and epilogue RTL if the machine supports it. Thread
6168 this into place with notes indicating where the prologue ends and where
6169 the epilogue begins. Update the basic block information when possible. */
6172 thread_prologue_and_epilogue_insns (f
)
6175 #ifdef HAVE_prologue
6180 /* The first insn (a NOTE_INSN_DELETED) is followed by zero or more
6181 prologue insns and a NOTE_INSN_PROLOGUE_END. */
6182 emit_note_after (NOTE_INSN_PROLOGUE_END
, f
);
6183 seq
= gen_prologue ();
6184 head
= emit_insn_after (seq
, f
);
6186 /* Include the new prologue insns in the first block. Ignore them
6187 if they form a basic block unto themselves. */
6188 if (basic_block_head
&& n_basic_blocks
6189 && GET_CODE (basic_block_head
[0]) != CODE_LABEL
)
6190 basic_block_head
[0] = NEXT_INSN (f
);
6192 /* Retain a map of the prologue insns. */
6193 prologue
= record_insns (GET_CODE (seq
) == SEQUENCE
? seq
: head
);
6199 #ifdef HAVE_epilogue
6202 rtx insn
= get_last_insn ();
6203 rtx prev
= prev_nonnote_insn (insn
);
6205 /* If we end with a BARRIER, we don't need an epilogue. */
6206 if (! (prev
&& GET_CODE (prev
) == BARRIER
))
6212 /* The last basic block ends with a NOTE_INSN_EPILOGUE_BEG, the
6213 epilogue insns, the USE insns at the end of a function,
6214 the jump insn that returns, and then a BARRIER. */
6216 /* Move the USE insns at the end of a function onto a list. */
6218 && GET_CODE (prev
) == INSN
6219 && GET_CODE (PATTERN (prev
)) == USE
)
6222 prev
= prev_nonnote_insn (prev
);
6224 NEXT_INSN (PREV_INSN (tem
)) = NEXT_INSN (tem
);
6225 PREV_INSN (NEXT_INSN (tem
)) = PREV_INSN (tem
);
6228 NEXT_INSN (tem
) = first_use
;
6229 PREV_INSN (first_use
) = tem
;
6236 emit_barrier_after (insn
);
6238 seq
= gen_epilogue ();
6239 tail
= emit_jump_insn_after (seq
, insn
);
6241 /* Insert the USE insns immediately before the return insn, which
6242 must be the first instruction before the final barrier. */
6245 tem
= prev_nonnote_insn (get_last_insn ());
6246 NEXT_INSN (PREV_INSN (tem
)) = first_use
;
6247 PREV_INSN (first_use
) = PREV_INSN (tem
);
6248 PREV_INSN (tem
) = last_use
;
6249 NEXT_INSN (last_use
) = tem
;
6252 emit_note_after (NOTE_INSN_EPILOGUE_BEG
, insn
);
6254 /* Include the new epilogue insns in the last block. Ignore
6255 them if they form a basic block unto themselves. */
6256 if (basic_block_end
&& n_basic_blocks
6257 && GET_CODE (basic_block_end
[n_basic_blocks
- 1]) != JUMP_INSN
)
6258 basic_block_end
[n_basic_blocks
- 1] = tail
;
6260 /* Retain a map of the epilogue insns. */
6261 epilogue
= record_insns (GET_CODE (seq
) == SEQUENCE
? seq
: tail
);
6269 /* Reposition the prologue-end and epilogue-begin notes after instruction
6270 scheduling and delayed branch scheduling. */
6273 reposition_prologue_and_epilogue_notes (f
)
6276 #if defined (HAVE_prologue) || defined (HAVE_epilogue)
6277 /* Reposition the prologue and epilogue notes. */
6285 register rtx insn
, note
= 0;
6287 /* Scan from the beginning until we reach the last prologue insn.
6288 We apparently can't depend on basic_block_{head,end} after
6290 for (len
= 0; prologue
[len
]; len
++)
6292 for (insn
= f
; len
&& insn
; insn
= NEXT_INSN (insn
))
6294 if (GET_CODE (insn
) == NOTE
)
6296 if (NOTE_LINE_NUMBER (insn
) == NOTE_INSN_PROLOGUE_END
)
6299 else if ((len
-= contains (insn
, prologue
)) == 0)
6301 /* Find the prologue-end note if we haven't already, and
6302 move it to just after the last prologue insn. */
6305 for (note
= insn
; (note
= NEXT_INSN (note
));)
6306 if (GET_CODE (note
) == NOTE
6307 && NOTE_LINE_NUMBER (note
) == NOTE_INSN_PROLOGUE_END
)
6311 next
= NEXT_INSN (note
);
6312 prev
= PREV_INSN (note
);
6314 NEXT_INSN (prev
) = next
;
6316 PREV_INSN (next
) = prev
;
6318 /* Whether or not we can depend on basic_block_head,
6319 attempt to keep it up-to-date. */
6320 if (basic_block_head
[0] == note
)
6321 basic_block_head
[0] = next
;
6323 add_insn_after (note
, insn
);
6330 register rtx insn
, note
= 0;
6332 /* Scan from the end until we reach the first epilogue insn.
6333 We apparently can't depend on basic_block_{head,end} after
6335 for (len
= 0; epilogue
[len
]; len
++)
6337 for (insn
= get_last_insn (); len
&& insn
; insn
= PREV_INSN (insn
))
6339 if (GET_CODE (insn
) == NOTE
)
6341 if (NOTE_LINE_NUMBER (insn
) == NOTE_INSN_EPILOGUE_BEG
)
6344 else if ((len
-= contains (insn
, epilogue
)) == 0)
6346 /* Find the epilogue-begin note if we haven't already, and
6347 move it to just before the first epilogue insn. */
6350 for (note
= insn
; (note
= PREV_INSN (note
));)
6351 if (GET_CODE (note
) == NOTE
6352 && NOTE_LINE_NUMBER (note
) == NOTE_INSN_EPILOGUE_BEG
)
6355 next
= NEXT_INSN (note
);
6356 prev
= PREV_INSN (note
);
6358 NEXT_INSN (prev
) = next
;
6360 PREV_INSN (next
) = prev
;
6362 /* Whether or not we can depend on basic_block_head,
6363 attempt to keep it up-to-date. */
6365 && basic_block_head
[n_basic_blocks
-1] == insn
)
6366 basic_block_head
[n_basic_blocks
-1] = note
;
6368 add_insn_before (note
, insn
);
6373 #endif /* HAVE_prologue or HAVE_epilogue */