1 /* Subroutines for manipulating rtx's in semantically interesting ways.
2 Copyright (C) 1987, 1991, 1994 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
26 #include "hard-reg-set.h"
27 #include "insn-config.h"
29 #include "insn-flags.h"
30 #include "insn-codes.h"
32 /* Return an rtx for the sum of X and the integer C.
34 This function should be used via the `plus_constant' macro. */
37 plus_constant_wide (x, c)
39 register HOST_WIDE_INT c;
41 register RTX_CODE code;
42 register enum machine_mode mode;
56 return GEN_INT (INTVAL (x) + c);
60 HOST_WIDE_INT l1 = CONST_DOUBLE_LOW (x);
61 HOST_WIDE_INT h1 = CONST_DOUBLE_HIGH (x);
63 HOST_WIDE_INT h2 = c < 0 ? ~0 : 0;
66 add_double (l1, h1, l2, h2, &lv, &hv);
68 return immed_double_const (lv, hv, VOIDmode);
72 /* If this is a reference to the constant pool, try replacing it with
73 a reference to a new constant. If the resulting address isn't
74 valid, don't return it because we have no way to validize it. */
75 if (GET_CODE (XEXP (x, 0)) == SYMBOL_REF
76 && CONSTANT_POOL_ADDRESS_P (XEXP (x, 0)))
79 = force_const_mem (GET_MODE (x),
80 plus_constant (get_pool_constant (XEXP (x, 0)),
82 if (memory_address_p (GET_MODE (tem), XEXP (tem, 0)))
88 /* If adding to something entirely constant, set a flag
89 so that we can add a CONST around the result. */
100 /* The interesting case is adding the integer to a sum.
101 Look for constant term in the sum and combine
102 with C. For an integer constant term, we make a combined
103 integer. For a constant term that is not an explicit integer,
104 we cannot really combine, but group them together anyway.
106 Use a recursive call in case the remaining operand is something
107 that we handle specially, such as a SYMBOL_REF. */
109 if (GET_CODE (XEXP (x, 1)) == CONST_INT)
110 return plus_constant (XEXP (x, 0), c + INTVAL (XEXP (x, 1)));
111 else if (CONSTANT_P (XEXP (x, 0)))
112 return gen_rtx (PLUS, mode,
113 plus_constant (XEXP (x, 0), c),
115 else if (CONSTANT_P (XEXP (x, 1)))
116 return gen_rtx (PLUS, mode,
118 plus_constant (XEXP (x, 1), c));
122 x = gen_rtx (PLUS, mode, x, GEN_INT (c));
124 if (GET_CODE (x) == SYMBOL_REF || GET_CODE (x) == LABEL_REF)
126 else if (all_constant)
127 return gen_rtx (CONST, mode, x);
132 /* This is the same as `plus_constant', except that it handles LO_SUM.
134 This function should be used via the `plus_constant_for_output' macro. */
137 plus_constant_for_output_wide (x, c)
139 register HOST_WIDE_INT c;
141 register RTX_CODE code = GET_CODE (x);
142 register enum machine_mode mode = GET_MODE (x);
143 int all_constant = 0;
145 if (GET_CODE (x) == LO_SUM)
146 return gen_rtx (LO_SUM, mode, XEXP (x, 0),
147 plus_constant_for_output (XEXP (x, 1), c));
150 return plus_constant (x, c);
153 /* If X is a sum, return a new sum like X but lacking any constant terms.
154 Add all the removed constant terms into *CONSTPTR.
155 X itself is not altered. The result != X if and only if
156 it is not isomorphic to X. */
159 eliminate_constant_term (x, constptr)
166 if (GET_CODE (x) != PLUS)
169 /* First handle constants appearing at this level explicitly. */
170 if (GET_CODE (XEXP (x, 1)) == CONST_INT
171 && 0 != (tem = simplify_binary_operation (PLUS, GET_MODE (x), *constptr,
173 && GET_CODE (tem) == CONST_INT)
176 return eliminate_constant_term (XEXP (x, 0), constptr);
180 x0 = eliminate_constant_term (XEXP (x, 0), &tem);
181 x1 = eliminate_constant_term (XEXP (x, 1), &tem);
182 if ((x1 != XEXP (x, 1) || x0 != XEXP (x, 0))
183 && 0 != (tem = simplify_binary_operation (PLUS, GET_MODE (x),
185 && GET_CODE (tem) == CONST_INT)
188 return gen_rtx (PLUS, GET_MODE (x), x0, x1);
194 /* Returns the insn that next references REG after INSN, or 0
195 if REG is clobbered before next referenced or we cannot find
196 an insn that references REG in a straight-line piece of code. */
199 find_next_ref (reg, insn)
205 for (insn = NEXT_INSN (insn); insn; insn = next)
207 next = NEXT_INSN (insn);
208 if (GET_CODE (insn) == NOTE)
210 if (GET_CODE (insn) == CODE_LABEL
211 || GET_CODE (insn) == BARRIER)
213 if (GET_CODE (insn) == INSN
214 || GET_CODE (insn) == JUMP_INSN
215 || GET_CODE (insn) == CALL_INSN)
217 if (reg_set_p (reg, insn))
219 if (reg_mentioned_p (reg, PATTERN (insn)))
221 if (GET_CODE (insn) == JUMP_INSN)
223 if (simplejump_p (insn))
224 next = JUMP_LABEL (insn);
228 if (GET_CODE (insn) == CALL_INSN
229 && REGNO (reg) < FIRST_PSEUDO_REGISTER
230 && call_used_regs[REGNO (reg)])
239 /* Return an rtx for the size in bytes of the value of EXP. */
245 tree size = size_in_bytes (TREE_TYPE (exp));
247 if (TREE_CODE (size) != INTEGER_CST
248 && contains_placeholder_p (size))
249 size = build (WITH_RECORD_EXPR, sizetype, size, exp);
251 return expand_expr (size, NULL_RTX, TYPE_MODE (sizetype), 0);
254 /* Return a copy of X in which all memory references
255 and all constants that involve symbol refs
256 have been replaced with new temporary registers.
257 Also emit code to load the memory locations and constants
258 into those registers.
260 If X contains no such constants or memory references,
261 X itself (not a copy) is returned.
263 If a constant is found in the address that is not a legitimate constant
264 in an insn, it is left alone in the hope that it might be valid in the
267 X may contain no arithmetic except addition, subtraction and multiplication.
268 Values returned by expand_expr with 1 for sum_ok fit this constraint. */
271 break_out_memory_refs (x)
274 if (GET_CODE (x) == MEM
275 || (CONSTANT_P (x) && CONSTANT_ADDRESS_P (x)
276 && GET_MODE (x) != VOIDmode))
278 register rtx temp = force_reg (GET_MODE (x), x);
279 mark_reg_pointer (temp);
282 else if (GET_CODE (x) == PLUS || GET_CODE (x) == MINUS
283 || GET_CODE (x) == MULT)
285 register rtx op0 = break_out_memory_refs (XEXP (x, 0));
286 register rtx op1 = break_out_memory_refs (XEXP (x, 1));
287 if (op0 != XEXP (x, 0) || op1 != XEXP (x, 1))
288 x = gen_rtx (GET_CODE (x), Pmode, op0, op1);
293 /* Given a memory address or facsimile X, construct a new address,
294 currently equivalent, that is stable: future stores won't change it.
296 X must be composed of constants, register and memory references
297 combined with addition, subtraction and multiplication:
298 in other words, just what you can get from expand_expr if sum_ok is 1.
300 Works by making copies of all regs and memory locations used
301 by X and combining them the same way X does.
302 You could also stabilize the reference to this address
303 by copying the address to a register with copy_to_reg;
304 but then you wouldn't get indexed addressing in the reference. */
310 if (GET_CODE (x) == REG)
312 if (REGNO (x) != FRAME_POINTER_REGNUM
313 #if HARD_FRAME_POINTER_REGNUM != FRAME_POINTER_REGNUM
314 && REGNO (x) != HARD_FRAME_POINTER_REGNUM
319 else if (GET_CODE (x) == MEM)
321 else if (GET_CODE (x) == PLUS || GET_CODE (x) == MINUS
322 || GET_CODE (x) == MULT)
324 register rtx op0 = copy_all_regs (XEXP (x, 0));
325 register rtx op1 = copy_all_regs (XEXP (x, 1));
326 if (op0 != XEXP (x, 0) || op1 != XEXP (x, 1))
327 x = gen_rtx (GET_CODE (x), Pmode, op0, op1);
332 /* Return something equivalent to X but valid as a memory address
333 for something of mode MODE. When X is not itself valid, this
334 works by copying X or subexpressions of it into registers. */
337 memory_address (mode, x)
338 enum machine_mode mode;
341 register rtx oldx = x;
343 /* By passing constant addresses thru registers
344 we get a chance to cse them. */
345 if (! cse_not_expected && CONSTANT_P (x) && CONSTANT_ADDRESS_P (x))
346 x = force_reg (Pmode, x);
348 /* Accept a QUEUED that refers to a REG
349 even though that isn't a valid address.
350 On attempting to put this in an insn we will call protect_from_queue
351 which will turn it into a REG, which is valid. */
352 else if (GET_CODE (x) == QUEUED
353 && GET_CODE (QUEUED_VAR (x)) == REG)
356 /* We get better cse by rejecting indirect addressing at this stage.
357 Let the combiner create indirect addresses where appropriate.
358 For now, generate the code so that the subexpressions useful to share
359 are visible. But not if cse won't be done! */
362 if (! cse_not_expected && GET_CODE (x) != REG)
363 x = break_out_memory_refs (x);
365 /* At this point, any valid address is accepted. */
366 GO_IF_LEGITIMATE_ADDRESS (mode, x, win);
368 /* If it was valid before but breaking out memory refs invalidated it,
369 use it the old way. */
370 if (memory_address_p (mode, oldx))
373 /* Perform machine-dependent transformations on X
374 in certain cases. This is not necessary since the code
375 below can handle all possible cases, but machine-dependent
376 transformations can make better code. */
377 LEGITIMIZE_ADDRESS (x, oldx, mode, win);
379 /* PLUS and MULT can appear in special ways
380 as the result of attempts to make an address usable for indexing.
381 Usually they are dealt with by calling force_operand, below.
382 But a sum containing constant terms is special
383 if removing them makes the sum a valid address:
384 then we generate that address in a register
385 and index off of it. We do this because it often makes
386 shorter code, and because the addresses thus generated
387 in registers often become common subexpressions. */
388 if (GET_CODE (x) == PLUS)
390 rtx constant_term = const0_rtx;
391 rtx y = eliminate_constant_term (x, &constant_term);
392 if (constant_term == const0_rtx
393 || ! memory_address_p (mode, y))
394 x = force_operand (x, NULL_RTX);
397 y = gen_rtx (PLUS, GET_MODE (x), copy_to_reg (y), constant_term);
398 if (! memory_address_p (mode, y))
399 x = force_operand (x, NULL_RTX);
405 if (GET_CODE (x) == MULT || GET_CODE (x) == MINUS)
406 x = force_operand (x, NULL_RTX);
408 /* If we have a register that's an invalid address,
409 it must be a hard reg of the wrong class. Copy it to a pseudo. */
410 else if (GET_CODE (x) == REG)
413 /* Last resort: copy the value to a register, since
414 the register is a valid address. */
416 x = force_reg (Pmode, x);
423 if (flag_force_addr && ! cse_not_expected && GET_CODE (x) != REG
424 /* Don't copy an addr via a reg if it is one of our stack slots. */
425 && ! (GET_CODE (x) == PLUS
426 && (XEXP (x, 0) == virtual_stack_vars_rtx
427 || XEXP (x, 0) == virtual_incoming_args_rtx)))
429 if (general_operand (x, Pmode))
430 x = force_reg (Pmode, x);
432 x = force_operand (x, NULL_RTX);
438 /* OLDX may have been the address on a temporary. Update the address
439 to indicate that X is now used. */
440 update_temp_slot_address (oldx, x);
445 /* Like `memory_address' but pretend `flag_force_addr' is 0. */
448 memory_address_noforce (mode, x)
449 enum machine_mode mode;
452 int ambient_force_addr = flag_force_addr;
456 val = memory_address (mode, x);
457 flag_force_addr = ambient_force_addr;
461 /* Convert a mem ref into one with a valid memory address.
462 Pass through anything else unchanged. */
468 if (GET_CODE (ref) != MEM)
470 if (memory_address_p (GET_MODE (ref), XEXP (ref, 0)))
472 /* Don't alter REF itself, since that is probably a stack slot. */
473 return change_address (ref, GET_MODE (ref), XEXP (ref, 0));
476 /* Return a modified copy of X with its memory address copied
477 into a temporary register to protect it from side effects.
478 If X is not a MEM, it is returned unchanged (and not copied).
479 Perhaps even if it is a MEM, if there is no need to change it. */
486 if (GET_CODE (x) != MEM)
489 if (rtx_unstable_p (addr))
491 rtx temp = copy_all_regs (addr);
493 if (GET_CODE (temp) != REG)
494 temp = copy_to_reg (temp);
495 mem = gen_rtx (MEM, GET_MODE (x), temp);
497 /* Mark returned memref with in_struct if it's in an array or
498 structure. Copy const and volatile from original memref. */
500 MEM_IN_STRUCT_P (mem) = MEM_IN_STRUCT_P (x) || GET_CODE (addr) == PLUS;
501 RTX_UNCHANGING_P (mem) = RTX_UNCHANGING_P (x);
502 MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (x);
508 /* Copy the value or contents of X to a new temp reg and return that reg. */
514 register rtx temp = gen_reg_rtx (GET_MODE (x));
516 /* If not an operand, must be an address with PLUS and MULT so
517 do the computation. */
518 if (! general_operand (x, VOIDmode))
519 x = force_operand (x, temp);
522 emit_move_insn (temp, x);
527 /* Like copy_to_reg but always give the new register mode Pmode
528 in case X is a constant. */
534 return copy_to_mode_reg (Pmode, x);
537 /* Like copy_to_reg but always give the new register mode MODE
538 in case X is a constant. */
541 copy_to_mode_reg (mode, x)
542 enum machine_mode mode;
545 register rtx temp = gen_reg_rtx (mode);
547 /* If not an operand, must be an address with PLUS and MULT so
548 do the computation. */
549 if (! general_operand (x, VOIDmode))
550 x = force_operand (x, temp);
552 if (GET_MODE (x) != mode && GET_MODE (x) != VOIDmode)
555 emit_move_insn (temp, x);
559 /* Load X into a register if it is not already one.
560 Use mode MODE for the register.
561 X should be valid for mode MODE, but it may be a constant which
562 is valid for all integer modes; that's why caller must specify MODE.
564 The caller must not alter the value in the register we return,
565 since we mark it as a "constant" register. */
569 enum machine_mode mode;
572 register rtx temp, insn;
574 if (GET_CODE (x) == REG)
576 temp = gen_reg_rtx (mode);
577 insn = emit_move_insn (temp, x);
578 /* Let optimizers know that TEMP's value never changes
579 and that X can be substituted for it. */
582 rtx note = find_reg_note (insn, REG_EQUAL, NULL_RTX);
587 REG_NOTES (insn) = gen_rtx (EXPR_LIST, REG_EQUAL, x, REG_NOTES (insn));
592 /* If X is a memory ref, copy its contents to a new temp reg and return
593 that reg. Otherwise, return X. */
600 if (GET_CODE (x) != MEM || GET_MODE (x) == BLKmode)
602 temp = gen_reg_rtx (GET_MODE (x));
603 emit_move_insn (temp, x);
607 /* Copy X to TARGET (if it's nonzero and a reg)
608 or to a new temp reg and return that reg.
609 MODE is the mode to use for X in case it is a constant. */
612 copy_to_suggested_reg (x, target, mode)
614 enum machine_mode mode;
618 if (target && GET_CODE (target) == REG)
621 temp = gen_reg_rtx (mode);
623 emit_move_insn (temp, x);
627 /* Adjust the stack pointer by ADJUST (an rtx for a number of bytes).
628 This pops when ADJUST is positive. ADJUST need not be constant. */
631 adjust_stack (adjust)
635 adjust = protect_from_queue (adjust, 0);
637 if (adjust == const0_rtx)
640 temp = expand_binop (Pmode,
641 #ifdef STACK_GROWS_DOWNWARD
646 stack_pointer_rtx, adjust, stack_pointer_rtx, 0,
649 if (temp != stack_pointer_rtx)
650 emit_move_insn (stack_pointer_rtx, temp);
653 /* Adjust the stack pointer by minus ADJUST (an rtx for a number of bytes).
654 This pushes when ADJUST is positive. ADJUST need not be constant. */
657 anti_adjust_stack (adjust)
661 adjust = protect_from_queue (adjust, 0);
663 if (adjust == const0_rtx)
666 temp = expand_binop (Pmode,
667 #ifdef STACK_GROWS_DOWNWARD
672 stack_pointer_rtx, adjust, stack_pointer_rtx, 0,
675 if (temp != stack_pointer_rtx)
676 emit_move_insn (stack_pointer_rtx, temp);
679 /* Round the size of a block to be pushed up to the boundary required
680 by this machine. SIZE is the desired size, which need not be constant. */
686 #ifdef STACK_BOUNDARY
687 int align = STACK_BOUNDARY / BITS_PER_UNIT;
690 if (GET_CODE (size) == CONST_INT)
692 int new = (INTVAL (size) + align - 1) / align * align;
693 if (INTVAL (size) != new)
694 size = GEN_INT (new);
698 size = expand_divmod (0, CEIL_DIV_EXPR, Pmode, size, GEN_INT (align),
700 size = expand_mult (Pmode, size, GEN_INT (align), NULL_RTX, 1);
702 #endif /* STACK_BOUNDARY */
706 /* Save the stack pointer for the purpose in SAVE_LEVEL. PSAVE is a pointer
707 to a previously-created save area. If no save area has been allocated,
708 this function will allocate one. If a save area is specified, it
709 must be of the proper mode.
711 The insns are emitted after insn AFTER, if nonzero, otherwise the insns
712 are emitted at the current position. */
715 emit_stack_save (save_level, psave, after)
716 enum save_level save_level;
721 /* The default is that we use a move insn and save in a Pmode object. */
722 rtx (*fcn) () = gen_move_insn;
723 enum machine_mode mode = Pmode;
725 /* See if this machine has anything special to do for this kind of save. */
728 #ifdef HAVE_save_stack_block
730 if (HAVE_save_stack_block)
732 fcn = gen_save_stack_block;
733 mode = insn_operand_mode[CODE_FOR_save_stack_block][0];
737 #ifdef HAVE_save_stack_function
739 if (HAVE_save_stack_function)
741 fcn = gen_save_stack_function;
742 mode = insn_operand_mode[CODE_FOR_save_stack_function][0];
746 #ifdef HAVE_save_stack_nonlocal
748 if (HAVE_save_stack_nonlocal)
750 fcn = gen_save_stack_nonlocal;
751 mode = insn_operand_mode[(int) CODE_FOR_save_stack_nonlocal][0];
757 /* If there is no save area and we have to allocate one, do so. Otherwise
758 verify the save area is the proper mode. */
762 if (mode != VOIDmode)
764 if (save_level == SAVE_NONLOCAL)
765 *psave = sa = assign_stack_local (mode, GET_MODE_SIZE (mode), 0);
767 *psave = sa = gen_reg_rtx (mode);
772 if (mode == VOIDmode || GET_MODE (sa) != mode)
781 /* We must validize inside the sequence, to ensure that any instructions
782 created by the validize call also get moved to the right place. */
784 sa = validize_mem (sa);
785 emit_insn (fcn (sa, stack_pointer_rtx));
786 seq = gen_sequence ();
788 emit_insn_after (seq, after);
793 sa = validize_mem (sa);
794 emit_insn (fcn (sa, stack_pointer_rtx));
798 /* Restore the stack pointer for the purpose in SAVE_LEVEL. SA is the save
799 area made by emit_stack_save. If it is zero, we have nothing to do.
801 Put any emitted insns after insn AFTER, if nonzero, otherwise at
805 emit_stack_restore (save_level, sa, after)
806 enum save_level save_level;
810 /* The default is that we use a move insn. */
811 rtx (*fcn) () = gen_move_insn;
813 /* See if this machine has anything special to do for this kind of save. */
816 #ifdef HAVE_restore_stack_block
818 if (HAVE_restore_stack_block)
819 fcn = gen_restore_stack_block;
822 #ifdef HAVE_restore_stack_function
824 if (HAVE_restore_stack_function)
825 fcn = gen_restore_stack_function;
828 #ifdef HAVE_restore_stack_nonlocal
831 if (HAVE_restore_stack_nonlocal)
832 fcn = gen_restore_stack_nonlocal;
838 sa = validize_mem (sa);
845 emit_insn (fcn (stack_pointer_rtx, sa));
846 seq = gen_sequence ();
848 emit_insn_after (seq, after);
851 emit_insn (fcn (stack_pointer_rtx, sa));
854 /* Return an rtx representing the address of an area of memory dynamically
855 pushed on the stack. This region of memory is always aligned to
856 a multiple of BIGGEST_ALIGNMENT.
858 Any required stack pointer alignment is preserved.
860 SIZE is an rtx representing the size of the area.
861 TARGET is a place in which the address can be placed.
863 KNOWN_ALIGN is the alignment (in bits) that we know SIZE has. */
866 allocate_dynamic_stack_space (size, target, known_align)
871 /* Ensure the size is in the proper mode. */
872 if (GET_MODE (size) != VOIDmode && GET_MODE (size) != Pmode)
873 size = convert_to_mode (Pmode, size, 1);
875 /* We will need to ensure that the address we return is aligned to
876 BIGGEST_ALIGNMENT. If STACK_DYNAMIC_OFFSET is defined, we don't
877 always know its final value at this point in the compilation (it
878 might depend on the size of the outgoing parameter lists, for
879 example), so we must align the value to be returned in that case.
880 (Note that STACK_DYNAMIC_OFFSET will have a default non-zero value if
881 STACK_POINTER_OFFSET or ACCUMULATE_OUTGOING_ARGS are defined).
882 We must also do an alignment operation on the returned value if
883 the stack pointer alignment is less strict that BIGGEST_ALIGNMENT.
885 If we have to align, we must leave space in SIZE for the hole
886 that might result from the alignment operation. */
888 #if defined (STACK_DYNAMIC_OFFSET) || defined(STACK_POINTER_OFFSET) || defined (ALLOCATE_OUTGOING_ARGS)
892 #if ! defined (MUST_ALIGN) && (!defined(STACK_BOUNDARY) || STACK_BOUNDARY < BIGGEST_ALIGNMENT)
898 #if 0 /* It turns out we must always make extra space, if MUST_ALIGN
899 because we must always round the address up at the end,
900 because we don't know whether the dynamic offset
901 will mess up the desired alignment. */
902 /* If we have to round the address up regardless of known_align,
903 make extra space regardless, also. */
904 if (known_align % BIGGEST_ALIGNMENT != 0)
907 if (GET_CODE (size) == CONST_INT)
908 size = GEN_INT (INTVAL (size)
909 + (BIGGEST_ALIGNMENT / BITS_PER_UNIT - 1));
911 size = expand_binop (Pmode, add_optab, size,
912 GEN_INT (BIGGEST_ALIGNMENT / BITS_PER_UNIT - 1),
913 NULL_RTX, 1, OPTAB_LIB_WIDEN);
918 #ifdef SETJMP_VIA_SAVE_AREA
919 /* If setjmp restores regs from a save area in the stack frame,
920 avoid clobbering the reg save area. Note that the offset of
921 virtual_incoming_args_rtx includes the preallocated stack args space.
922 It would be no problem to clobber that, but it's on the wrong side
923 of the old save area. */
926 = expand_binop (Pmode, sub_optab, virtual_stack_dynamic_rtx,
927 stack_pointer_rtx, NULL_RTX, 1, OPTAB_LIB_WIDEN);
928 size = expand_binop (Pmode, add_optab, size, dynamic_offset,
929 NULL_RTX, 1, OPTAB_LIB_WIDEN);
931 #endif /* SETJMP_VIA_SAVE_AREA */
933 /* Round the size to a multiple of the required stack alignment.
934 Since the stack if presumed to be rounded before this allocation,
935 this will maintain the required alignment.
937 If the stack grows downward, we could save an insn by subtracting
938 SIZE from the stack pointer and then aligning the stack pointer.
939 The problem with this is that the stack pointer may be unaligned
940 between the execution of the subtraction and alignment insns and
941 some machines do not allow this. Even on those that do, some
942 signal handlers malfunction if a signal should occur between those
943 insns. Since this is an extremely rare event, we have no reliable
944 way of knowing which systems have this problem. So we avoid even
945 momentarily mis-aligning the stack. */
947 #ifdef STACK_BOUNDARY
948 /* If we added a variable amount to SIZE,
949 we can no longer assume it is aligned. */
950 #if !defined (SETJMP_VIA_SAVE_AREA) && !defined (MUST_ALIGN)
951 if (known_align % STACK_BOUNDARY != 0)
953 size = round_push (size);
956 do_pending_stack_adjust ();
958 /* Don't use a TARGET that isn't a pseudo. */
959 if (target == 0 || GET_CODE (target) != REG
960 || REGNO (target) < FIRST_PSEUDO_REGISTER)
961 target = gen_reg_rtx (Pmode);
963 mark_reg_pointer (target);
965 #ifndef STACK_GROWS_DOWNWARD
966 emit_move_insn (target, virtual_stack_dynamic_rtx);
969 /* Perform the required allocation from the stack. Some systems do
970 this differently than simply incrementing/decrementing from the
972 #ifdef HAVE_allocate_stack
973 if (HAVE_allocate_stack)
975 enum machine_mode mode
976 = insn_operand_mode[(int) CODE_FOR_allocate_stack][0];
978 if (insn_operand_predicate[(int) CODE_FOR_allocate_stack][0]
979 && ! ((*insn_operand_predicate[(int) CODE_FOR_allocate_stack][0])
981 size = copy_to_mode_reg (mode, size);
983 emit_insn (gen_allocate_stack (size));
987 anti_adjust_stack (size);
989 #ifdef STACK_GROWS_DOWNWARD
990 emit_move_insn (target, virtual_stack_dynamic_rtx);
994 #if 0 /* Even if we know the stack pointer has enough alignment,
995 there's no way to tell whether virtual_stack_dynamic_rtx shares that
996 alignment, so we still need to round the address up. */
997 if (known_align % BIGGEST_ALIGNMENT != 0)
1000 target = expand_divmod (0, CEIL_DIV_EXPR, Pmode, target,
1001 GEN_INT (BIGGEST_ALIGNMENT / BITS_PER_UNIT),
1004 target = expand_mult (Pmode, target,
1005 GEN_INT (BIGGEST_ALIGNMENT / BITS_PER_UNIT),
1010 /* Some systems require a particular insn to refer to the stack
1011 to make the pages exist. */
1014 emit_insn (gen_probe ());
1020 /* Return an rtx representing the register or memory location
1021 in which a scalar value of data type VALTYPE
1022 was returned by a function call to function FUNC.
1023 FUNC is a FUNCTION_DECL node if the precise function is known,
1027 hard_function_value (valtype, func)
1031 return FUNCTION_VALUE (valtype, func);
1034 /* Return an rtx representing the register or memory location
1035 in which a scalar value of mode MODE was returned by a library call. */
1038 hard_libcall_value (mode)
1039 enum machine_mode mode;
1041 return LIBCALL_VALUE (mode);
1044 /* Look up the tree code for a given rtx code
1045 to provide the arithmetic operation for REAL_ARITHMETIC.
1046 The function returns an int because the caller may not know
1047 what `enum tree_code' means. */
1050 rtx_to_tree_code (code)
1053 enum tree_code tcode;
1076 tcode = LAST_AND_UNUSED_TREE_CODE;
1079 return ((int) tcode);