home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / NeXT / GnuSource / cc-61.0.1 / cc / explow.c < prev    next >
C/C++ Source or Header  |  1991-06-04  |  22KB  |  798 lines

  1. /* Subroutines for manipulating rtx's in semantically interesting ways.
  2.    Copyright (C) 1987, 1990 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  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)
  9. any later version.
  10.  
  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.
  15.  
  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.  */
  19.  
  20.  
  21. #include "config.h"
  22. #include "rtl.h"
  23. #include "tree.h"
  24. #include "flags.h"
  25. #include "expr.h"
  26. #include "hard-reg-set.h"
  27. #include "insn-flags.h"
  28.  
  29. /* Return an rtx for the sum of X and the integer C.  */
  30.  
  31. rtx
  32. plus_constant (x, c)
  33.      register rtx x;
  34.      register int c;
  35. {
  36.   register RTX_CODE code = GET_CODE (x);
  37.   register enum machine_mode mode = GET_MODE (x);
  38.   register rtx tem;
  39.   int all_constant = 0;
  40.  
  41.   if (c == 0)
  42.     return x;
  43.  
  44.   switch (code)
  45.     {
  46.     case CONST_INT:
  47.       return gen_rtx (CONST_INT, VOIDmode, (INTVAL (x) + c));
  48.  
  49.     case CONST_DOUBLE:
  50.       {
  51.     int l1 = CONST_DOUBLE_LOW (x);
  52.     int h1 = CONST_DOUBLE_HIGH (x);
  53.     int l2 = c;
  54.     int h2 = c < 0 ? ~0 : 0;
  55.     int lv, hv;
  56.  
  57.     add_double (l1, h1, l2, h2, &lv, &hv);
  58.  
  59.     return immed_double_const (lv, hv, VOIDmode);
  60.       }
  61.  
  62.     case MEM:
  63.       /* If this is a reference to the constant pool, try replacing it with
  64.      a reference to a new constant.  If the resulting address isn't
  65.      valid, don't return it because we have no way to validize it.  */
  66.       if (GET_CODE (XEXP (x, 0)) == SYMBOL_REF
  67.       && CONSTANT_POOL_ADDRESS_P (XEXP (x, 0)))
  68.     {
  69.       tem
  70.         = force_const_mem (GET_MODE (x),
  71.                    plus_constant (get_pool_constant (XEXP (x, 0)),
  72.                           c));
  73.       if (memory_address_p (GET_MODE (tem), XEXP (tem, 0)))
  74.         return tem;
  75.     }
  76.       break;
  77.  
  78.     case CONST:
  79.       /* If adding to something entirely constant, set a flag
  80.      so that we can add a CONST around the result.  */
  81.       x = XEXP (x, 0);
  82.       all_constant = 1;
  83.       break;
  84.  
  85.     case SYMBOL_REF:
  86.     case LABEL_REF:
  87.       all_constant = 1;
  88.       break;
  89.  
  90.     case PLUS:
  91.       /* The interesting case is adding the integer to a sum.
  92.      Look for constant term in the sum and combine
  93.      with C.  For an integer constant term, we make a combined
  94.      integer.  For a constant term that is not an explicit integer,
  95.      we cannot really combine, but group them together anyway.  */
  96.       if (GET_CODE (XEXP (x, 0)) == CONST_INT)
  97.     {
  98.       c += INTVAL (XEXP (x, 0));
  99.       x = XEXP (x, 1);
  100.     }
  101.       else if (GET_CODE (XEXP (x, 1)) == CONST_INT)
  102.     {
  103.       c += INTVAL (XEXP (x, 1));
  104.       x = XEXP (x, 0);
  105.     }
  106.       else if (CONSTANT_P (XEXP (x, 0)))
  107.     return gen_rtx (PLUS, mode,
  108.             plus_constant (XEXP (x, 0), c),
  109.             XEXP (x, 1));
  110.       else if (CONSTANT_P (XEXP (x, 1)))
  111.     return gen_rtx (PLUS, mode,
  112.             XEXP (x, 0),
  113.             plus_constant (XEXP (x, 1), c));
  114.     }
  115.  
  116.   if (c != 0)
  117.     x = gen_rtx (PLUS, mode, x, gen_rtx (CONST_INT, VOIDmode, c));
  118.  
  119.   if (GET_CODE (x) == SYMBOL_REF || GET_CODE (x) == LABEL_REF)
  120.     return x;
  121.   else if (all_constant)
  122.     return gen_rtx (CONST, mode, x);
  123.   else
  124.     return x;
  125. }
  126.  
  127. /* This is the same a `plus_constant', except that it handles LO_SUM.  */
  128.  
  129. rtx
  130. plus_constant_for_output (x, c)
  131.      register rtx x;
  132.      register int c;
  133. {
  134.   register RTX_CODE code = GET_CODE (x);
  135.   register enum machine_mode mode = GET_MODE (x);
  136.   int all_constant = 0;
  137.  
  138.   if (GET_CODE (x) == LO_SUM)
  139.     return gen_rtx (LO_SUM, mode, XEXP (x, 0),
  140.             plus_constant_for_output (XEXP (x, 1), c));
  141.  
  142.   else
  143.     return plus_constant (x, c);
  144. }
  145.  
  146. /* If X is a sum, return a new sum like X but lacking any constant terms.
  147.    Add all the removed constant terms into *CONSTPTR.
  148.    X itself is not altered.  The result != X if and only if
  149.    it is not isomorphic to X.  */
  150.  
  151. rtx
  152. eliminate_constant_term (x, constptr)
  153.      rtx x;
  154.      int *constptr;
  155. {
  156.   int c;
  157.   register rtx x0, x1;
  158.  
  159.   if (GET_CODE (x) != PLUS)
  160.     return x;
  161.  
  162.   /* First handle constants appearing at this level explicitly.  */
  163.   if (GET_CODE (XEXP (x, 0)) == CONST_INT)
  164.     {
  165.       *constptr += INTVAL (XEXP (x, 0));
  166.       return eliminate_constant_term (XEXP (x, 1), constptr);
  167.     }
  168.  
  169.   if (GET_CODE (XEXP (x, 1)) == CONST_INT)
  170.     {
  171.       *constptr += INTVAL (XEXP (x, 1));
  172.       return eliminate_constant_term (XEXP (x, 0), constptr);
  173.     }
  174.  
  175.   c = 0;
  176.   x0 = eliminate_constant_term (XEXP (x, 0), &c);
  177.   x1 = eliminate_constant_term (XEXP (x, 1), &c);
  178.   if (x1 != XEXP (x, 1) || x0 != XEXP (x, 0))
  179.     {
  180.       *constptr += c;
  181.       return gen_rtx (PLUS, GET_MODE (x), x0, x1);
  182.     }
  183.   return x;
  184. }
  185.  
  186. /* Returns the insn that next references REG after INSN, or 0
  187.    if REG is clobbered before next referenced or we cannot find
  188.    an insn that references REG in a straight-line piece of code.  */
  189.  
  190. rtx
  191. find_next_ref (reg, insn)
  192.      rtx reg;
  193.      rtx insn;
  194. {
  195.   rtx next;
  196.  
  197.   for (insn = NEXT_INSN (insn); insn; insn = next)
  198.     {
  199.       next = NEXT_INSN (insn);
  200.       if (GET_CODE (insn) == NOTE)
  201.     continue;
  202.       if (GET_CODE (insn) == CODE_LABEL
  203.       || GET_CODE (insn) == BARRIER)
  204.     return 0;
  205.       if (GET_CODE (insn) == INSN
  206.       || GET_CODE (insn) == JUMP_INSN
  207.       || GET_CODE (insn) == CALL_INSN)
  208.     {
  209.       if (reg_set_p (reg, PATTERN (insn)))
  210.         return 0;
  211.       if (reg_mentioned_p (reg, PATTERN (insn)))
  212.         return insn;
  213.       if (GET_CODE (insn) == JUMP_INSN)
  214.         {
  215.           if (simplejump_p (insn))
  216.         next = JUMP_LABEL (insn);
  217.           else
  218.         return 0;
  219.         }
  220.       if (GET_CODE (insn) == CALL_INSN
  221.           && REGNO (reg) < FIRST_PSEUDO_REGISTER
  222.           && call_used_regs[REGNO (reg)])
  223.         return 0;
  224.     }
  225.       else
  226.     abort ();
  227.     }
  228.   return 0;
  229. }
  230.  
  231. /* Return an rtx for the size in bytes of the value of EXP.  */
  232.  
  233. rtx
  234. expr_size (exp)
  235.      tree exp;
  236. {
  237.   return expand_expr (size_in_bytes (TREE_TYPE (exp)), 0, SImode, 0);
  238. }
  239.  
  240. /* Return a copy of X in which all memory references
  241.    and all constants that involve symbol refs
  242.    have been replaced with new temporary registers.
  243.    Also emit code to load the memory locations and constants
  244.    into those registers.
  245.  
  246.    If X contains no such constants or memory references,
  247.    X itself (not a copy) is returned.
  248.  
  249.    If a constant is found in the address that is not a legitimate constant
  250.    in an insn, it is left alone in the hope that it might be valid in the
  251.    address.
  252.  
  253.    X may contain no arithmetic except addition, subtraction and multiplication.
  254.    Values returned by expand_expr with 1 for sum_ok fit this constraint.  */
  255.  
  256. static rtx
  257. break_out_memory_refs (x)
  258.      register rtx x;
  259. {
  260.   if (GET_CODE (x) == MEM
  261.       || (CONSTANT_P (x) && LEGITIMATE_CONSTANT_P (x)
  262.       && GET_MODE (x) != VOIDmode))
  263.     {
  264.       register rtx temp = force_reg (GET_MODE (x), x);
  265.       mark_reg_pointer (temp);
  266.       x = temp;
  267.     }
  268.   else if (GET_CODE (x) == PLUS || GET_CODE (x) == MINUS
  269.        || GET_CODE (x) == MULT)
  270.     {
  271.       register rtx op0 = break_out_memory_refs (XEXP (x, 0));
  272.       register rtx op1 = break_out_memory_refs (XEXP (x, 1));
  273.       if (op0 != XEXP (x, 0) || op1 != XEXP (x, 1))
  274.     x = gen_rtx (GET_CODE (x), Pmode, op0, op1);
  275.     }
  276.   return x;
  277. }
  278.  
  279. /* Given a memory address or facsimile X, construct a new address,
  280.    currently equivalent, that is stable: future stores won't change it.
  281.  
  282.    X must be composed of constants, register and memory references
  283.    combined with addition, subtraction and multiplication:
  284.    in other words, just what you can get from expand_expr if sum_ok is 1.
  285.  
  286.    Works by making copies of all regs and memory locations used
  287.    by X and combining them the same way X does.
  288.    You could also stabilize the reference to this address
  289.    by copying the address to a register with copy_to_reg;
  290.    but then you wouldn't get indexed addressing in the reference.  */
  291.  
  292. rtx
  293. copy_all_regs (x)
  294.      register rtx x;
  295. {
  296.   if (GET_CODE (x) == REG)
  297.     {
  298.       if (REGNO (x) != FRAME_POINTER_REGNUM)
  299.     x = copy_to_reg (x);
  300.     }
  301.   else if (GET_CODE (x) == MEM)
  302.     x = copy_to_reg (x);
  303.   else if (GET_CODE (x) == PLUS || GET_CODE (x) == MINUS
  304.        || GET_CODE (x) == MULT)
  305.     {
  306.       register rtx op0 = copy_all_regs (XEXP (x, 0));
  307.       register rtx op1 = copy_all_regs (XEXP (x, 1));
  308.       if (op0 != XEXP (x, 0) || op1 != XEXP (x, 1))
  309.     x = gen_rtx (GET_CODE (x), Pmode, op0, op1);
  310.     }
  311.   return x;
  312. }
  313.  
  314. /* Return something equivalent to X but valid as a memory address
  315.    for something of mode MODE.  When X is not itself valid, this
  316.    works by copying X or subexpressions of it into registers.  */
  317.  
  318. rtx
  319. memory_address (mode, x)
  320.      enum machine_mode mode;
  321.      register rtx x;
  322. {
  323.   register rtx oldx;
  324.  
  325.   /* By passing constant addresses thru registers
  326.      we get a chance to cse them.  */
  327.   if (! cse_not_expected && CONSTANT_P (x) && LEGITIMATE_CONSTANT_P (x))
  328.     return force_reg (Pmode, x);
  329.  
  330.   /* Accept a QUEUED that refers to a REG
  331.      even though that isn't a valid address.
  332.      On attempting to put this in an insn we will call protect_from_queue
  333.      which will turn it into a REG, which is valid.  */
  334.   if (GET_CODE (x) == QUEUED
  335.       && GET_CODE (QUEUED_VAR (x)) == REG)
  336.     return x;
  337.  
  338.   /* We get better cse by rejecting indirect addressing at this stage.
  339.      Let the combiner create indirect addresses where appropriate.
  340.      For now, generate the code so that the subexpressions useful to share
  341.      are visible.  But not if cse won't be done!  */
  342.   oldx = x;
  343.   if (! cse_not_expected && GET_CODE (x) != REG)
  344.     x = break_out_memory_refs (x);
  345.  
  346.   /* At this point, any valid address is accepted.  */
  347.   GO_IF_LEGITIMATE_ADDRESS (mode, x, win);
  348.  
  349.   /* If it was valid before but breaking out memory refs invalidated it,
  350.      use it the old way.  */
  351.   if (memory_address_p (mode, oldx))
  352.     goto win2;
  353.  
  354.   /* Perform machine-dependent transformations on X
  355.      in certain cases.  This is not necessary since the code
  356.      below can handle all possible cases, but machine-dependent
  357.      transformations can make better code.  */
  358.   LEGITIMIZE_ADDRESS (x, oldx, mode, win);
  359.  
  360.   /* PLUS and MULT can appear in special ways
  361.      as the result of attempts to make an address usable for indexing.
  362.      Usually they are dealt with by calling force_operand, below.
  363.      But a sum containing constant terms is special
  364.      if removing them makes the sum a valid address:
  365.      then we generate that address in a register
  366.      and index off of it.  We do this because it often makes
  367.      shorter code, and because the addresses thus generated
  368.      in registers often become common subexpressions.  */
  369.   if (GET_CODE (x) == PLUS)
  370.     {
  371.       int constant_term = 0;
  372.       rtx y = eliminate_constant_term (x, &constant_term);
  373.       if (constant_term == 0
  374.       || ! memory_address_p (mode, y))
  375.     return force_operand (x, 0);
  376.  
  377.       y = plus_constant (copy_to_reg (y), constant_term);
  378.       if (! memory_address_p (mode, y))
  379.     return force_operand (x, 0);
  380.       return y;
  381.     }
  382.   if (GET_CODE (x) == MULT || GET_CODE (x) == MINUS)
  383.     return force_operand (x, 0);
  384.  
  385.   /* If we have a register that's an invalid address,
  386.      it must be a hard reg of the wrong class.  Copy it to a pseudo.  */
  387.   if (GET_CODE (x) == REG)
  388.     return copy_to_reg (x);
  389.  
  390.   /* Last resort: copy the value to a register, since
  391.      the register is a valid address.  */
  392.   return force_reg (Pmode, x);
  393.  
  394.  win2:
  395.   x = oldx;
  396.  win:
  397.   if (flag_force_addr && ! cse_not_expected && GET_CODE (x) != REG
  398.       /* Don't copy an addr via a reg if it is one of our stack slots.  */
  399.       && ! (GET_CODE (x) == PLUS
  400.         && (XEXP (x, 0) == virtual_stack_vars_rtx
  401.         || XEXP (x, 0) == virtual_incoming_args_rtx)))
  402.     {
  403.       if (general_operand (x, Pmode))
  404.     return force_reg (Pmode, x);
  405.       else
  406.     return force_operand (x, 0);
  407.     }
  408.   return x;
  409. }
  410.  
  411. /* Like `memory_address' but pretend `flag_force_addr' is 0.  */
  412.  
  413. rtx
  414. memory_address_noforce (mode, x)
  415.      enum machine_mode mode;
  416.      rtx x;
  417. {
  418.   int ambient_force_addr = flag_force_addr;
  419.   rtx val;
  420.  
  421.   flag_force_addr = 0;
  422.   val = memory_address (mode, x);
  423.   flag_force_addr = ambient_force_addr;
  424.   return val;
  425. }
  426.  
  427. /* Convert a mem ref into one with a valid memory address.
  428.    Pass through anything else unchanged.  */
  429.  
  430. rtx
  431. validize_mem (ref)
  432.      rtx ref;
  433. {
  434.   if (GET_CODE (ref) != MEM)
  435.     return ref;
  436.   if (memory_address_p (GET_MODE (ref), XEXP (ref, 0)))
  437.     return ref;
  438.   /* Don't alter REF itself, since that is probably a stack slot.  */
  439.   return change_address (ref, GET_MODE (ref), XEXP (ref, 0));
  440. }
  441.  
  442. /* Return a modified copy of X with its memory address copied
  443.    into a temporary register to protect it from side effects.
  444.    If X is not a MEM, it is returned unchanged (and not copied).
  445.    Perhaps even if it is a MEM, if there is no need to change it.  */
  446.  
  447. rtx
  448. stabilize (x)
  449.      rtx x;
  450. {
  451.   register rtx addr;
  452.   if (GET_CODE (x) != MEM)
  453.     return x;
  454.   addr = XEXP (x, 0);
  455.   if (rtx_unstable_p (addr))
  456.     {
  457.       rtx temp = copy_all_regs (addr);
  458.       rtx mem;
  459.       if (GET_CODE (temp) != REG)
  460.     temp = copy_to_reg (temp);
  461.       mem = gen_rtx (MEM, GET_MODE (x), temp);
  462.       /* Mark returned memref with in_struct
  463.      if it's in an array or structure. */
  464.       if (GET_CODE (addr) == PLUS || MEM_IN_STRUCT_P (x))
  465.     MEM_IN_STRUCT_P (mem) = 1;
  466.       return mem;
  467.     }
  468.   return x;
  469. }
  470.  
  471. /* Copy the value or contents of X to a new temp reg and return that reg.  */
  472.  
  473. rtx
  474. copy_to_reg (x)
  475.      rtx x;
  476. {
  477.   register rtx temp = gen_reg_rtx (GET_MODE (x));
  478.  
  479.   /* If not an operand, must be an address with PLUS and MULT so
  480.      do the computation.  */ 
  481.   if (! general_operand (x, VOIDmode))
  482.     x = force_operand (x, temp);
  483.   
  484.   if (x != temp)
  485.     emit_move_insn (temp, x);
  486.  
  487.   return temp;
  488. }
  489.  
  490. /* Like copy_to_reg but always give the new register mode Pmode
  491.    in case X is a constant.  */
  492.  
  493. rtx
  494. copy_addr_to_reg (x)
  495.      rtx x;
  496. {
  497.   return copy_to_mode_reg (Pmode, x);
  498. }
  499.  
  500. /* Like copy_to_reg but always give the new register mode MODE
  501.    in case X is a constant.  */
  502.  
  503. rtx
  504. copy_to_mode_reg (mode, x)
  505.      enum machine_mode mode;
  506.      rtx x;
  507. {
  508.   register rtx temp = gen_reg_rtx (mode);
  509.   
  510.   /* If not an operand, must be an address with PLUS and MULT so
  511.      do the computation.  */ 
  512.   if (! general_operand (x, VOIDmode))
  513.     x = force_operand (x, temp);
  514.  
  515.   if (GET_MODE (x) != mode && GET_MODE (x) != VOIDmode)
  516.     abort ();
  517.   if (x != temp)
  518.     emit_move_insn (temp, x);
  519.   return temp;
  520. }
  521.  
  522. /* Load X into a register if it is not already one.
  523.    Use mode MODE for the register.
  524.    X should be valid for mode MODE, but it may be a constant which
  525.    is valid for all integer modes; that's why caller must specify MODE.
  526.  
  527.    The caller must not alter the value in the register we return,
  528.    since we mark it as a "constant" register.  */
  529.  
  530. rtx
  531. force_reg (mode, x)
  532.      enum machine_mode mode;
  533.      rtx x;
  534. {
  535.   register rtx temp, insn;
  536.  
  537.   if (GET_CODE (x) == REG)
  538.     return x;
  539.   temp = gen_reg_rtx (mode);
  540.   insn = emit_move_insn (temp, x);
  541.   /* Let optimizers know that TEMP's value never changes
  542.      and that X can be substituted for it.  */
  543.   if (CONSTANT_P (x))
  544.     {
  545.       rtx note = find_reg_note (insn, REG_EQUAL, 0);
  546.  
  547.       if (note)
  548.     XEXP (note, 0) = x;
  549.       else
  550.     REG_NOTES (insn) = gen_rtx (EXPR_LIST, REG_EQUAL, x, REG_NOTES (insn));
  551.     }
  552.   return temp;
  553. }
  554.  
  555. /* If X is a memory ref, copy its contents to a new temp reg and return
  556.    that reg.  Otherwise, return X.  */
  557.  
  558. rtx
  559. force_not_mem (x)
  560.      rtx x;
  561. {
  562.   register rtx temp;
  563.   if (GET_CODE (x) != MEM || GET_MODE (x) == BLKmode)
  564.     return x;
  565.   temp = gen_reg_rtx (GET_MODE (x));
  566.   emit_move_insn (temp, x);
  567.   return temp;
  568. }
  569.  
  570. /* Copy X to TARGET (if it's nonzero and a reg)
  571.    or to a new temp reg and return that reg.  */
  572.  
  573. rtx
  574. copy_to_suggested_reg (x, target)
  575.      rtx x, target;
  576. {
  577.   register rtx temp;
  578.   if (target && GET_CODE (target) == REG)
  579.     temp = target;
  580.   else
  581.     temp = gen_reg_rtx (GET_MODE (x));
  582.   emit_move_insn (temp, x);
  583.   return temp;
  584. }
  585.  
  586. /* Adjust the stack pointer by ADJUST (an rtx for a number of bytes).
  587.    This pops when ADJUST is positive.  ADJUST need not be constant.  */
  588.  
  589. void
  590. adjust_stack (adjust)
  591.      rtx adjust;
  592. {
  593.   rtx temp;
  594.   adjust = protect_from_queue (adjust, 0);
  595.  
  596.   if (adjust == const0_rtx)
  597.     return;
  598.  
  599.   temp = expand_binop (Pmode,
  600. #ifdef STACK_GROWS_DOWNWARD
  601.                add_optab,
  602. #else
  603.                sub_optab,
  604. #endif
  605.                stack_pointer_rtx, adjust, stack_pointer_rtx, 0,
  606.                OPTAB_LIB_WIDEN);
  607.  
  608.   if (temp != stack_pointer_rtx)
  609.     emit_move_insn (stack_pointer_rtx, temp);
  610. }
  611.  
  612. /* Adjust the stack pointer by minus ADJUST (an rtx for a number of bytes).
  613.    This pushes when ADJUST is positive.  ADJUST need not be constant.  */
  614.  
  615. void
  616. anti_adjust_stack (adjust)
  617.      rtx adjust;
  618. {
  619.   rtx temp;
  620.   adjust = protect_from_queue (adjust, 0);
  621.  
  622.   if (adjust == const0_rtx)
  623.     return;
  624.  
  625.   temp = expand_binop (Pmode,
  626. #ifdef STACK_GROWS_DOWNWARD
  627.                sub_optab,
  628. #else
  629.                add_optab,
  630. #endif
  631.                stack_pointer_rtx, adjust, stack_pointer_rtx, 0,
  632.                OPTAB_LIB_WIDEN);
  633.  
  634.   if (temp != stack_pointer_rtx)
  635.     emit_move_insn (stack_pointer_rtx, temp);
  636. }
  637.  
  638. /* Round the size of a block to be pushed up to the boundary required
  639.    by this machine.  SIZE is the desired size, which need not be constant.  */
  640.  
  641. rtx
  642. round_push (size)
  643.      rtx size;
  644. {
  645. #ifdef STACK_BOUNDARY
  646.   int align = STACK_BOUNDARY / BITS_PER_UNIT;
  647.   if (align == 1)
  648.     return size;
  649.   if (GET_CODE (size) == CONST_INT)
  650.     {
  651.       int new = (INTVAL (size) + align - 1) / align * align;
  652.       if (INTVAL (size) != new)
  653.     size = gen_rtx (CONST_INT, VOIDmode, new);
  654.     }
  655.   else
  656.     {
  657.       size = expand_divmod (0, CEIL_DIV_EXPR, Pmode, size,
  658.                 gen_rtx (CONST_INT, VOIDmode, align),
  659.                 0, 1);
  660.       size = expand_mult (Pmode, size,
  661.               gen_rtx (CONST_INT, VOIDmode, align),
  662.               0, 1);
  663.     }
  664. #endif /* STACK_BOUNDARY */
  665.   return size;
  666. }
  667.  
  668. /* Return an rtx representing the address of an area of memory dynamically
  669.    pushed on the stack.  Any required rounding is done.
  670.  
  671.    SIZE is an rtx representing the size of the area.
  672.    TARGET is a place in which the address can be placed.  */
  673.  
  674. rtx
  675. allocate_dynamic_stack_space (size, target)
  676.      rtx size;
  677.      rtx target;
  678. {
  679. #ifdef STACK_POINTER_OFFSET
  680.   int misalignment
  681.     = STACK_POINTER_OFFSET % (BIGGEST_ALIGNMENT / BITS_PER_WORD);
  682.   int compensation = (BIGGEST_ALIGNMENT / BITS_PER_WORD) - misalignment;
  683. #else
  684.   int misalignment = 0, compensation = 0;
  685. #endif
  686.  
  687.   /* Ensure the size is in a register and is the proper mode.  */
  688.  
  689.   if (! CONSTANT_P (size))
  690.     {
  691.       size = force_reg (GET_MODE (size), size);
  692.       if (GET_MODE (size) != Pmode)
  693.     size = convert_to_mode (Pmode, size, 1);
  694.     }
  695.  
  696. #ifdef STACK_POINTER_OFFSET
  697.   /* Compensate for any lack of alignment of the storage
  698.      to actually be used.  */
  699.   if (misalignment != 0)
  700.     size = plus_constant (size, compensation);
  701. #endif
  702.  
  703.   do_pending_stack_adjust ();
  704.  
  705. #ifdef STACK_GROWS_DOWNWARD
  706. #ifdef STACK_BOUNDARY
  707. #define STACK_ALIGNMENT  (STACK_BOUNDARY / BITS_PER_UNIT)
  708. #else
  709. #define STACK_ALIGNMENT 1
  710. #endif
  711.   /* An important special-case is where the stack grows downward and where
  712.      we either do not have a stack offset or the stack offset is a multiple
  713.      of the alignment amount (if it isn't we don't know whether the actual
  714.      sp value or the virtual top of stack is what is to be aligned, so
  715.      we just assume it started aligned and align the amount to push).  In
  716.      that case, aligning the stack pointer value rather than the size to
  717.      push will save one insn.  */
  718.  
  719.   if (exact_log2 (STACK_ALIGNMENT) >= 0
  720.       && (target == 0 || GET_CODE (target) == REG)
  721. #ifdef STACK_POINTER_OFFSET
  722.       && STACK_POINTER_OFFSET % STACK_ALIGNMENT == 0
  723. #endif
  724.       )
  725.     {
  726.       anti_adjust_stack (size);
  727.       if (STACK_ALIGNMENT != 1)
  728.     {
  729.       rtx temp = expand_binop (Pmode, and_optab, stack_pointer_rtx,
  730.                    gen_rtx (CONST_INT, VOIDmode,
  731.                         ~ (STACK_ALIGNMENT - 1)),
  732.                    stack_pointer_rtx, 0, OPTAB_LIB_WIDEN);
  733.       if (temp != stack_pointer_rtx)
  734.         emit_move_insn (stack_pointer_rtx, temp);
  735.     }
  736.     }
  737.   else
  738.     anti_adjust_stack (round_push (size));
  739. #endif
  740.  
  741.   /* Return a copy of current stack ptr in TARGET.  */
  742.   if (target == 0)
  743.     target = gen_reg_rtx (Pmode);
  744.  
  745. #ifdef STACK_POINTER_OFFSET
  746.   /* Compensate for any lack of alignment of the storage to actually
  747.      be used, by skipping ahead to an aligned address.  */
  748.   if (misalignment)
  749.     {
  750.       rtx temp = expand_binop (Pmode, add_optab, target,
  751.                    gen_rtx (CONST_INT, VOIDmode, compensation),
  752.                    stack_pointer_rtx, 0, OPTAB_LIB_WIDEN);
  753.       if (temp != target)
  754.     emit_move_insn (target, temp);
  755.     }
  756.   else
  757. #endif
  758.     emit_move_insn (target, virtual_stack_dynamic_rtx);
  759.  
  760. #ifndef STACK_GROWS_DOWNWARD
  761.   anti_adjust_stack (round_push (size));
  762. #endif
  763.  
  764.   /* Some systems require a particular insn to refer to the stack
  765.      to make the pages exist or to format the bottom of the stack
  766.      in some particular way.  */
  767. #ifdef HAVE_probe
  768.   if (HAVE_probe)
  769.     emit_insn (gen_probe (size));
  770. #endif
  771.  
  772.   return target;
  773. }
  774.  
  775. /* Return an rtx representing the register or memory location
  776.    in which a scalar value of data type VALTYPE
  777.    was returned by a function call to function FUNC.
  778.    FUNC is a FUNCTION_DECL node if the precise function is known,
  779.    otherwise 0.  */
  780.  
  781. rtx
  782. hard_function_value (valtype, func)
  783.      tree valtype;
  784.      tree func;
  785. {
  786.   return FUNCTION_VALUE (valtype, func);
  787. }
  788.  
  789. /* Return an rtx representing the register or memory location
  790.    in which a scalar value of mode MODE was returned by a library call.  */
  791.  
  792. rtx
  793. hard_libcall_value (mode)
  794.      enum machine_mode mode;
  795. {
  796.   return LIBCALL_VALUE (mode);
  797. }
  798.