home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / NeXT / GnuSource / cc-61.0.1 / cc / expr.c < prev    next >
C/C++ Source or Header  |  1992-06-19  |  176KB  |  5,712 lines

  1. /* Convert tree expression to rtl instructions, for GNU compiler.
  2.    Copyright (C) 1988-1991 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 "function.h"
  26. #include "insn-flags.h"
  27. #include "insn-codes.h"
  28. #include "expr.h"
  29. #include "insn-config.h"
  30. #include "recog.h"
  31. #include "output.h"
  32. #include "gvarargs.h"
  33. #include "typeclass.h"
  34.  
  35. #define MIN(x, y) ((x) < (y) ? (x) : (y))
  36. #define MAX(x, y) ((x) > (y) ? (x) : (y))
  37.  
  38. /* Decide whether a function's arguments should be processed
  39.    from first to last or from last to first.  */
  40.  
  41. #ifdef STACK_GROWS_DOWNWARD
  42. #ifdef PUSH_ROUNDING
  43. #define PUSH_ARGS_REVERSED    /* If it's last to first */
  44. #endif
  45. #endif
  46.  
  47. #ifndef STACK_PUSH_CODE
  48. #ifdef STACK_GROWS_DOWNWARD
  49. #define STACK_PUSH_CODE PRE_DEC
  50. #else
  51. #define STACK_PUSH_CODE PRE_INC
  52. #endif
  53. #endif
  54.  
  55. /* Like STACK_BOUNDARY but in units of bytes, not bits.  */
  56. #define STACK_BYTES (STACK_BOUNDARY / BITS_PER_UNIT)
  57.  
  58. /* If this is nonzero, we do not bother generating VOLATILE
  59.    around volatile memory references, and we are willing to
  60.    output indirect addresses.  If cse is to follow, we reject
  61.    indirect addresses so a useful potential cse is generated;
  62.    if it is used only once, instruction combination will produce
  63.    the same indirect address eventually.  */
  64. int cse_not_expected;
  65.  
  66. /* Nonzero to generate code for all the subroutines within an
  67.    expression before generating the upper levels of the expression.
  68.    Nowadays this is never zero.  */
  69. int do_preexpand_calls = 1;
  70.  
  71. /* Number of units that we should eventually pop off the stack.
  72.    These are the arguments to function calls that have already returned.  */
  73. int pending_stack_adjust;
  74.  
  75. /* Nonzero means stack pops must not be deferred, and deferred stack
  76.    pops must not be output.  It is nonzero inside a function call,
  77.    inside a conditional expression, inside a statement expression,
  78.    and in other cases as well.  */
  79. int inhibit_defer_pop;
  80.  
  81. /* A list of all cleanups which belong to the arguments of
  82.    function calls being expanded by expand_call.  */
  83. tree cleanups_this_call;
  84.  
  85. /* Nonzero means __builtin_saveregs has already been done in this function.
  86.    The value is the pseudoreg containing the value __builtin_saveregs
  87.    returned.  */
  88. static rtx saveregs_value;
  89.  
  90. rtx store_expr ();
  91. static void store_constructor ();
  92. static rtx store_field ();
  93. static rtx expand_builtin ();
  94. static rtx compare ();
  95. static rtx compare_constants ();
  96. static rtx do_store_flag ();
  97. static void preexpand_calls ();
  98. static rtx expand_increment ();
  99. static void init_queue ();
  100.  
  101. void do_pending_stack_adjust ();
  102. static void do_jump_for_compare ();
  103. static void do_jump_by_parts_equality ();
  104. static void do_jump_by_parts_equality_rtx ();
  105. static void do_jump_by_parts_greater ();
  106.  
  107. /* MOVE_RATIO is the number of move instructions that is better than
  108.    a block move.  */
  109.  
  110. #ifndef MOVE_RATIO
  111. #if defined (HAVE_movstrqi) || defined (HAVE_movstrhi) || defined (HAVE_movstrsi)
  112. #define MOVE_RATIO 2
  113. #else
  114. /* A value of around 6 would minimize code size; infinity would minimize
  115.    execution time.  */
  116. #define MOVE_RATIO 15
  117. #endif
  118. #endif
  119.  
  120. /* This is run at the start of compiling a function.  */
  121.  
  122. void
  123. init_expr ()
  124. {
  125.   init_queue ();
  126.  
  127.   pending_stack_adjust = 0;
  128.   inhibit_defer_pop = 0;
  129.   cleanups_this_call = 0;
  130.   saveregs_value = 0;
  131. }
  132.  
  133. /* Save all variables describing the current status into the structure *P.
  134.    This is used before starting a nested function.  */
  135.  
  136. void
  137. save_expr_status (p)
  138.      struct function *p;
  139. {
  140.   /* Instead of saving the postincrement queue, empty it.  */
  141.   emit_queue ();
  142.  
  143.   p->pending_stack_adjust = pending_stack_adjust;
  144.   p->inhibit_defer_pop = inhibit_defer_pop;
  145.   p->cleanups_this_call = cleanups_this_call;
  146.   p->saveregs_value = saveregs_value;
  147.  
  148.   pending_stack_adjust = 0;
  149.   inhibit_defer_pop = 0;
  150.   cleanups_this_call = 0;
  151.   saveregs_value = 0;
  152. }
  153.  
  154. /* Restore all variables describing the current status from the structure *P.
  155.    This is used after a nested function.  */
  156.  
  157. void
  158. restore_expr_status (p)
  159.      struct function *p;
  160. {
  161.   pending_stack_adjust = p->pending_stack_adjust;
  162.   inhibit_defer_pop = p->inhibit_defer_pop;
  163.   cleanups_this_call = p->cleanups_this_call;
  164.   saveregs_value = p->saveregs_value;
  165. }
  166.  
  167. /* Manage the queue of increment instructions to be output
  168.    for POSTINCREMENT_EXPR expressions, etc.  */
  169.  
  170. static rtx pending_chain;
  171.  
  172. /* Queue up to increment (or change) VAR later.  BODY says how:
  173.    BODY should be the same thing you would pass to emit_insn
  174.    to increment right away.  It will go to emit_insn later on.
  175.  
  176.    The value is a QUEUED expression to be used in place of VAR
  177.    where you want to guarantee the pre-incrementation value of VAR.  */
  178.  
  179. static rtx
  180. enqueue_insn (var, body)
  181.      rtx var, body;
  182. {
  183.   pending_chain = gen_rtx (QUEUED, GET_MODE (var),
  184.                var, 0, 0, body, pending_chain);
  185.   return pending_chain;
  186. }
  187.  
  188. /* Use protect_from_queue to convert a QUEUED expression
  189.    into something that you can put immediately into an instruction.
  190.    If the queued incrementation has not happened yet,
  191.    protect_from_queue returns the variable itself.
  192.    If the incrementation has happened, protect_from_queue returns a temp
  193.    that contains a copy of the old value of the variable.
  194.  
  195.    Any time an rtx which might possibly be a QUEUED is to be put
  196.    into an instruction, it must be passed through protect_from_queue first.
  197.    QUEUED expressions are not meaningful in instructions.
  198.  
  199.    Do not pass a value through protect_from_queue and then hold
  200.    on to it for a while before putting it in an instruction!
  201.    If the queue is flushed in between, incorrect code will result.  */
  202.  
  203. rtx
  204. protect_from_queue (x, modify)
  205.      register rtx x;
  206.      int modify;
  207. {
  208.   register RTX_CODE code = GET_CODE (x);
  209.  
  210. #if 0  /* A QUEUED can hang around after the queue is forced out.  */
  211.   /* Shortcut for most common case.  */
  212.   if (pending_chain == 0)
  213.     return x;
  214. #endif
  215.  
  216.   if (code != QUEUED)
  217.     {
  218.       /* A special hack for read access to (MEM (QUEUED ...))
  219.      to facilitate use of autoincrement.
  220.      Make a copy of the contents of the memory location
  221.      rather than a copy of the address, but not
  222.      if the value is of mode BLKmode.  */
  223.       if (code == MEM && GET_MODE (x) != BLKmode
  224.       && GET_CODE (XEXP (x, 0)) == QUEUED && !modify)
  225.     {
  226.       register rtx y = XEXP (x, 0);
  227.       XEXP (x, 0) = QUEUED_VAR (y);
  228.       if (QUEUED_INSN (y))
  229.         {
  230.           register rtx temp = gen_reg_rtx (GET_MODE (x));
  231.           emit_insn_before (gen_move_insn (temp, x),
  232.                 QUEUED_INSN (y));
  233.           return temp;
  234.         }
  235.       return x;
  236.     }
  237.       /* Otherwise, recursively protect the subexpressions of all
  238.      the kinds of rtx's that can contain a QUEUED.  */
  239.       if (code == MEM)
  240.     XEXP (x, 0) = protect_from_queue (XEXP (x, 0), 0);
  241.       else if (code == PLUS || code == MULT)
  242.     {
  243.       XEXP (x, 0) = protect_from_queue (XEXP (x, 0), 0);
  244.       XEXP (x, 1) = protect_from_queue (XEXP (x, 1), 0);
  245.     }
  246.       return x;
  247.     }
  248.   /* If the increment has not happened, use the variable itself.  */
  249.   if (QUEUED_INSN (x) == 0)
  250.     return QUEUED_VAR (x);
  251.   /* If the increment has happened and a pre-increment copy exists,
  252.      use that copy.  */
  253.   if (QUEUED_COPY (x) != 0)
  254.     return QUEUED_COPY (x);
  255.   /* The increment has happened but we haven't set up a pre-increment copy.
  256.      Set one up now, and use it.  */
  257.   QUEUED_COPY (x) = gen_reg_rtx (GET_MODE (QUEUED_VAR (x)));
  258.   emit_insn_before (gen_move_insn (QUEUED_COPY (x), QUEUED_VAR (x)),
  259.             QUEUED_INSN (x));
  260.   return QUEUED_COPY (x);
  261. }
  262.  
  263. /* Return nonzero if X contains a QUEUED expression:
  264.    if it contains anything that will be altered by a queued increment.
  265.    We handle only combinations of MEM, PLUS, MINUS and MULT operators
  266.    since memory addresses generally contain only those.  */
  267.  
  268. static int
  269. queued_subexp_p (x)
  270.      rtx x;
  271. {
  272.   register enum rtx_code code = GET_CODE (x);
  273.   switch (code)
  274.     {
  275.     case QUEUED:
  276.       return 1;
  277.     case MEM:
  278.       return queued_subexp_p (XEXP (x, 0));
  279.     case MULT:
  280.     case PLUS:
  281.     case MINUS:
  282.       return queued_subexp_p (XEXP (x, 0))
  283.     || queued_subexp_p (XEXP (x, 1));
  284.     }
  285.   return 0;
  286. }
  287.  
  288. /* Perform all the pending incrementations.  */
  289.  
  290. void
  291. emit_queue ()
  292. {
  293.   register rtx p;
  294.   while (p = pending_chain)
  295.     {
  296.       QUEUED_INSN (p) = emit_insn (QUEUED_BODY (p));
  297.       pending_chain = QUEUED_NEXT (p);
  298.     }
  299. }
  300.  
  301. static void
  302. init_queue ()
  303. {
  304.   if (pending_chain)
  305.     abort ();
  306. }
  307.  
  308. /* Copy data from FROM to TO, where the machine modes are not the same.
  309.    Both modes may be integer, or both may be floating.
  310.    UNSIGNEDP should be nonzero if FROM is an unsigned type.
  311.    This causes zero-extension instead of sign-extension.  */
  312.  
  313. void
  314. convert_move (to, from, unsignedp)
  315.      register rtx to, from;
  316.      int unsignedp;
  317. {
  318.   enum machine_mode to_mode = GET_MODE (to);
  319.   enum machine_mode from_mode = GET_MODE (from);
  320.   int to_real = GET_MODE_CLASS (to_mode) == MODE_FLOAT;
  321.   int from_real = GET_MODE_CLASS (from_mode) == MODE_FLOAT;
  322.   int extending = (int) to_mode > (int) from_mode;
  323.  
  324.   to = protect_from_queue (to, 1);
  325.   from = protect_from_queue (from, 0);
  326.  
  327.   if (to_real != from_real)
  328.     abort ();
  329.  
  330.   if (to_mode == from_mode
  331.       || (from_mode == VOIDmode && CONSTANT_P (from)))
  332.     {
  333.       emit_move_insn (to, from);
  334.       return;
  335.     }
  336.  
  337.   if (to_real)
  338.     {
  339. #ifdef HAVE_extendsfdf2
  340.       if (HAVE_extendsfdf2 && extending)
  341.     {
  342.       emit_unop_insn (CODE_FOR_extendsfdf2, to, from, UNKNOWN);
  343.       return;
  344.     }
  345. #endif
  346. #ifdef HAVE_truncdfsf2
  347.       if (HAVE_truncdfsf2 && ! extending)
  348.     {
  349.       emit_unop_insn (CODE_FOR_truncdfsf2, to, from, UNKNOWN);
  350.       return;
  351.     }
  352. #endif
  353.       emit_library_call (extending ? extendsfdf2_libfunc : truncdfsf2_libfunc,
  354.              0, GET_MODE (to), 1,
  355.              from,  (extending ? SFmode : DFmode));
  356.       emit_move_insn (to, hard_libcall_value (GET_MODE (to)));
  357.       return;
  358.     }
  359.  
  360.   /* Now both modes are integers.  */
  361.  
  362.   if (to_mode == DImode)
  363.     {
  364.       if (unsignedp)
  365.     {
  366. #ifdef HAVE_zero_extendsidi2
  367.       if (HAVE_zero_extendsidi2 && from_mode == SImode)
  368.         emit_unop_insn (CODE_FOR_zero_extendsidi2, to, from, ZERO_EXTEND);
  369.       else
  370. #endif
  371. #ifdef HAVE_zero_extendhidi2
  372.       if (HAVE_zero_extendhidi2 && from_mode == HImode)
  373.         emit_unop_insn (CODE_FOR_zero_extendhidi2, to, from, ZERO_EXTEND);
  374.       else
  375. #endif
  376. #ifdef HAVE_zero_extendqidi2
  377.       if (HAVE_zero_extendqidi2 && from_mode == QImode)
  378.         emit_unop_insn (CODE_FOR_zero_extendqidi2, to, from, ZERO_EXTEND);
  379.       else
  380. #endif
  381. #ifdef HAVE_zero_extendsidi2
  382.       if (HAVE_zero_extendsidi2)
  383.         {
  384.           convert_move (gen_lowpart (SImode, to), from, unsignedp);
  385.           emit_unop_insn (CODE_FOR_zero_extendsidi2, to,
  386.                   gen_lowpart (SImode, to), ZERO_EXTEND);
  387.         }
  388.       else
  389. #endif
  390.       if (GET_MODE_SIZE (DImode) == 2 * UNITS_PER_WORD)
  391.         {
  392.           rtx seq;
  393.  
  394.           start_sequence ();
  395.           convert_move (operand_subword (to, WORDS_BIG_ENDIAN, 1, DImode),
  396.                 from, unsignedp);
  397.           emit_clr_insn (operand_subword (to, 1 - WORDS_BIG_ENDIAN,
  398.                           1, DImode));
  399.  
  400.           seq = gen_sequence ();
  401.           end_sequence ();
  402.  
  403.           emit_no_conflict_block (seq, to, from, 0,
  404.                       gen_rtx (ZERO_EXTEND, DImode, from));
  405.         }
  406.       else
  407.         abort ();
  408.     }
  409. #ifdef HAVE_extendsidi2
  410.       else if (HAVE_extendsidi2 && from_mode == SImode)
  411.     emit_unop_insn (CODE_FOR_extendsidi2, to, from, SIGN_EXTEND);
  412. #endif
  413. #ifdef HAVE_extendhidi2
  414.       else if (HAVE_extendhidi2 && from_mode == HImode)
  415.     emit_unop_insn (CODE_FOR_extendhidi2, to, from, SIGN_EXTEND);
  416. #endif
  417. #ifdef HAVE_extendqidi2
  418.       else if (HAVE_extendqidi2 && from_mode == QImode)
  419.     emit_unop_insn (CODE_FOR_extendqidi2, to, from, SIGN_EXTEND);
  420. #endif
  421. #ifdef HAVE_extendsidi2
  422.       else if (HAVE_extendsidi2)
  423.     {
  424.       convert_move (gen_lowpart (SImode, to), from, unsignedp);
  425.       emit_unop_insn (CODE_FOR_extendsidi2, to,
  426.               gen_lowpart (SImode, to), SIGN_EXTEND);
  427.     }
  428. #endif
  429.       else if (GET_MODE_SIZE (DImode) == 2 * UNITS_PER_WORD)
  430.     {
  431.       rtx seq;
  432.       rtx lowpart = operand_subword (to, WORDS_BIG_ENDIAN, 1, DImode);
  433.       rtx highpart = operand_subword (to, 1 - WORDS_BIG_ENDIAN,
  434.                       1, DImode);
  435.  
  436.       start_sequence ();
  437.  
  438.       convert_move (lowpart, from, unsignedp);
  439. #ifdef HAVE_slt
  440.       if (HAVE_slt && insn_operand_mode[(int) CODE_FOR_slt][0] == SImode
  441.           && STORE_FLAG_VALUE == -1)
  442.         {
  443.           rtx temp;
  444.           emit_cmp_insn (lowpart, const0_rtx, NE, 0, 0, 0);
  445.           if (!(*insn_operand_predicate[(int) CODE_FOR_slt][0]) (highpart, SImode))
  446.         temp = gen_reg_rtx (SImode);
  447.           else
  448.         temp = highpart;
  449.           emit_insn (gen_slt (temp));
  450.           if (temp != highpart)
  451.         emit_move_insn (highpart, temp);
  452.         }
  453.       else
  454. #endif
  455.         {
  456.           rtx temp;
  457.  
  458.           temp = expand_shift (RSHIFT_EXPR, SImode, lowpart,
  459.                    size_int (GET_MODE_BITSIZE (SImode) - 1),
  460.                    highpart, 0);
  461.           if (temp != highpart)
  462.         emit_move_insn (highpart, temp);
  463.         }
  464.  
  465.       seq = gen_sequence ();
  466.       end_sequence ();
  467.  
  468.       emit_no_conflict_block (seq, to, from, 0,
  469.                   gen_rtx (SIGN_EXTEND, DImode, from));
  470.     }
  471.       else
  472.     abort ();
  473.       return;
  474.     }
  475.  
  476.   if (from_mode == DImode && GET_MODE_SIZE (DImode) > UNITS_PER_WORD)
  477.     {
  478.       convert_move (to, gen_lowpart (SImode, from), 0);
  479.       return;
  480.     }
  481.  
  482.   /* Handle pointer conversion */            /* SPEE 900220 */
  483.   if (to_mode == PSImode)
  484.     {
  485.       if (from_mode != SImode)
  486.     from = convert_to_mode (SImode, from, unsignedp);
  487.  
  488. #ifdef HAVE_truncsipsi
  489.       if (HAVE_truncsipsi)
  490.     {
  491.       emit_unop_insn (CODE_FOR_truncsipsi, to, from, UNKNOWN);
  492.       return;
  493.     }
  494. #endif /* HAVE_truncsipsi */
  495.       abort ();
  496.     }
  497.  
  498.   if (from_mode == PSImode)
  499.     {
  500.       if (to_mode != SImode)
  501.     {
  502.       from = convert_to_mode (SImode, from, unsignedp);
  503.       from_mode = SImode;
  504.     }
  505.       else
  506.     {
  507. #ifdef HAVE_extendpsisi
  508.       if (HAVE_extendpsisi)
  509.         {
  510.           emit_unop_insn (CODE_FOR_extendpsisi, to, from, UNKNOWN);
  511.           return;
  512.         }
  513. #endif /* HAVE_extendpsisi */
  514.       abort ();
  515.     }
  516.     }
  517.  
  518.   /* Now follow all the conversions between integers
  519.      no more than a word long.  */
  520.  
  521.   /* For truncation, usually we can just refer to FROM in a narrower mode.  */
  522.   if (GET_MODE_BITSIZE (to_mode) < GET_MODE_BITSIZE (from_mode)
  523.       && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (to_mode),
  524.                 GET_MODE_BITSIZE (from_mode))
  525.       && ((GET_CODE (from) == MEM
  526.        && ! MEM_VOLATILE_P (from)
  527.        && ! mode_dependent_address_p (XEXP (from, 0)))
  528.       || GET_CODE (from) == REG
  529.       || GET_CODE (from) == SUBREG))
  530.     {
  531.       emit_move_insn (to, gen_lowpart (to_mode, from));
  532.       return;
  533.     }
  534.  
  535.   if (to_mode == SImode && from_mode == HImode)
  536.     {
  537.       if (unsignedp)
  538.     {
  539. #ifdef HAVE_zero_extendhisi2
  540.       if (HAVE_zero_extendhisi2)
  541.         emit_unop_insn (CODE_FOR_zero_extendhisi2, to, from, ZERO_EXTEND);
  542.       else
  543. #endif
  544.         abort ();
  545.     }
  546.       else
  547.     {
  548. #ifdef HAVE_extendhisi2
  549.       if (HAVE_extendhisi2)
  550.         emit_unop_insn (CODE_FOR_extendhisi2, to, from, SIGN_EXTEND);
  551.       else
  552. #endif
  553.         abort ();
  554.     }
  555.       return;
  556.     }
  557.  
  558.   if (to_mode == SImode && from_mode == QImode)
  559.     {
  560.       if (unsignedp)
  561.     {
  562. #ifdef HAVE_zero_extendqisi2
  563.       if (HAVE_zero_extendqisi2)
  564.         {
  565.           emit_unop_insn (CODE_FOR_zero_extendqisi2, to, from, ZERO_EXTEND);
  566.           return;
  567.         }
  568. #endif
  569. #if defined (HAVE_zero_extendqihi2) && defined (HAVE_extendhisi2)
  570.       if (HAVE_zero_extendqihi2 && HAVE_extendhisi2)
  571.         {
  572.           register rtx temp = gen_reg_rtx (HImode);
  573.           emit_unop_insn (CODE_FOR_zero_extendqihi2, temp, from, ZERO_EXTEND);
  574.           emit_unop_insn (CODE_FOR_extendhisi2, to, temp, SIGN_EXTEND);
  575.           return;
  576.         }
  577. #endif
  578.     }
  579.       else
  580.     {
  581. #ifdef HAVE_extendqisi2
  582.       if (HAVE_extendqisi2)
  583.         {
  584.           emit_unop_insn (CODE_FOR_extendqisi2, to, from, SIGN_EXTEND);
  585.           return;
  586.         }
  587. #endif
  588. #if defined (HAVE_extendqihi2) && defined (HAVE_extendhisi2)
  589.       if (HAVE_extendqihi2 && HAVE_extendhisi2)
  590.         {
  591.           register rtx temp = gen_reg_rtx (HImode);
  592.           emit_unop_insn (CODE_FOR_extendqihi2, temp, from, SIGN_EXTEND);
  593.           emit_unop_insn (CODE_FOR_extendhisi2, to, temp, SIGN_EXTEND);
  594.           return;
  595.         }
  596. #endif
  597.     }
  598.       abort ();
  599.     }
  600.  
  601.   if (to_mode == HImode && from_mode == QImode)
  602.     {
  603.       if (unsignedp)
  604.     {
  605. #ifdef HAVE_zero_extendqihi2
  606.       if (HAVE_zero_extendqihi2)
  607.         {
  608.           emit_unop_insn (CODE_FOR_zero_extendqihi2, to, from, ZERO_EXTEND);
  609.           return;
  610.         }
  611. #endif
  612.     }
  613.       else
  614.     {
  615. #ifdef HAVE_extendqihi2
  616.       if (HAVE_extendqihi2)
  617.         {
  618.           emit_unop_insn (CODE_FOR_extendqihi2, to, from, SIGN_EXTEND);
  619.           return;
  620.         }
  621. #endif
  622.     }
  623.       abort ();
  624.     }
  625.  
  626. #if 0 /* This seems to be redundant with code 100 lines up.  */
  627.  
  628.   /* Now we are truncating an integer to a smaller one.
  629.      If the result is a temporary, we might as well just copy it,
  630.      since only the low-order part of the result needs to be valid
  631.      and it is valid with no change.  */
  632.  
  633.   if (GET_CODE (to) == REG)
  634.     {
  635.       if (GET_CODE (from) == REG)
  636.     {
  637.       emit_move_insn (to, gen_lowpart (GET_MODE (to), from));
  638.       return;
  639.     }
  640.       else if (GET_CODE (from) == SUBREG)
  641.     {
  642.       from = copy_rtx (from);
  643.       /* This is safe since FROM is not more than one word.  */
  644.       PUT_MODE (from, GET_MODE (to));
  645.       emit_move_insn (to, from);
  646.       return;
  647.     }
  648. #if !BYTES_BIG_ENDIAN
  649.       else if (GET_CODE (from) == MEM)
  650.     {
  651.       register rtx addr = XEXP (from, 0);
  652.       if (memory_address_p (GET_MODE (to), addr))
  653.         {
  654.           rtx new = gen_rtx (MEM, GET_MODE (to), addr);
  655.           MEM_VOLATILE_P (new) = MEM_VOLATILE_P (from);
  656.           RTX_UNCHANGING_P (new) = RTX_UNCHANGING_P (from);
  657.           MEM_IN_STRUCT_P (new) = MEM_IN_STRUCT_P (from);
  658.           emit_move_insn (to, new);
  659.           return;
  660.         }
  661.     }
  662. #endif /* not BYTES_BIG_ENDIAN */
  663.     }
  664. #endif /* 0 */
  665.  
  666.   if (from_mode == SImode && to_mode == HImode)
  667.     {
  668. #ifdef HAVE_truncsihi2
  669.       if (HAVE_truncsihi2)
  670.     {
  671.       emit_unop_insn (CODE_FOR_truncsihi2, to, from, UNKNOWN);
  672.       return;
  673.     }
  674. #endif
  675.       convert_move (to, force_reg (from_mode, from), unsignedp);
  676.       return;
  677.     }
  678.  
  679.   if (from_mode == SImode && to_mode == QImode)
  680.     {
  681. #ifdef HAVE_truncsiqi2
  682.       if (HAVE_truncsiqi2)
  683.     {
  684.       emit_unop_insn (CODE_FOR_truncsiqi2, to, from, UNKNOWN);
  685.       return;
  686.     }
  687. #endif
  688.       convert_move (to, force_reg (from_mode, from), unsignedp);
  689.       return;
  690.     }
  691.  
  692.   if (from_mode == HImode && to_mode == QImode)
  693.     {
  694. #ifdef HAVE_trunchiqi2
  695.       if (HAVE_trunchiqi2)
  696.     {
  697.       emit_unop_insn (CODE_FOR_trunchiqi2, to, from, UNKNOWN);
  698.       return;
  699.     }
  700. #endif
  701.       convert_move (to, force_reg (from_mode, from), unsignedp);
  702.       return;
  703.     }
  704.  
  705.   /* Mode combination is not recognized.  */
  706.   abort ();
  707. }
  708.  
  709. /* Return an rtx for a value that would result
  710.    from converting X to mode MODE.
  711.    Both X and MODE may be floating, or both integer.
  712.    UNSIGNEDP is nonzero if X is an unsigned value.
  713.    This can be done by referring to a part of X in place
  714.    or by copying to a new temporary with conversion.  */
  715.  
  716. rtx
  717. convert_to_mode (mode, x, unsignedp)
  718.      enum machine_mode mode;
  719.      rtx x;
  720.      int unsignedp;
  721. {
  722.   register rtx temp;
  723.  
  724.   x = protect_from_queue (x);
  725.  
  726.   if (mode == GET_MODE (x))
  727.     return x;
  728.  
  729.   /* We can do this with a gen_lowpart if both desired and current modes
  730.      are integer, and this is either a constant integer, a register, or a
  731.      non-volatile MEM.  Except for the constant case, we must be narrowing
  732.      the operand.  */
  733.  
  734.   if (GET_CODE (x) == CONST_INT
  735.       || (GET_MODE_CLASS (mode) == MODE_INT
  736.       && GET_MODE_CLASS (GET_MODE (x)) == MODE_INT
  737.       && (GET_CODE (x) == CONST_DOUBLE
  738.           || (GET_MODE_SIZE (mode) <= GET_MODE_SIZE (GET_MODE (x))
  739.           && ((GET_CODE (x) == MEM && ! MEM_VOLATILE_P (x))
  740.               || GET_CODE (x) == REG)))))
  741.     return gen_lowpart (mode, x);
  742.  
  743.   temp = gen_reg_rtx (mode);
  744.   convert_move (temp, x, unsignedp);
  745.   return temp;
  746. }
  747.  
  748. /* Generate several move instructions to copy LEN bytes
  749.    from block FROM to block TO.  (These are MEM rtx's with BLKmode).
  750.    The caller must pass FROM and TO
  751.     through protect_from_queue before calling.
  752.    ALIGN (in bytes) is maximum alignment we can assume.  */
  753.  
  754. struct move_by_pieces
  755. {
  756.   rtx to;
  757.   rtx to_addr;
  758.   int autinc_to;
  759.   int explicit_inc_to;
  760.   rtx from;
  761.   rtx from_addr;
  762.   int autinc_from;
  763.   int explicit_inc_from;
  764.   int len;
  765.   int offset;
  766.   int reverse;
  767. };
  768.  
  769. static void move_by_pieces_1 ();
  770. static int move_by_pieces_ninsns ();
  771.  
  772. static void
  773. move_by_pieces (to, from, len, align)
  774.      rtx to, from;
  775.      int len, align;
  776. {
  777.   struct move_by_pieces data;
  778.   rtx to_addr = XEXP (to, 0), from_addr = XEXP (from, 0);
  779.  
  780.   data.offset = 0;
  781.   data.to_addr = to_addr;
  782.   data.from_addr = from_addr;
  783.   data.to = to;
  784.   data.from = from;
  785.   data.autinc_to
  786.     = (GET_CODE (to_addr) == PRE_INC || GET_CODE (to_addr) == PRE_DEC
  787.        || GET_CODE (to_addr) == POST_INC || GET_CODE (to_addr) == POST_DEC);
  788.   data.autinc_from
  789.     = (GET_CODE (from_addr) == PRE_INC || GET_CODE (from_addr) == PRE_DEC
  790.        || GET_CODE (from_addr) == POST_INC
  791.        || GET_CODE (from_addr) == POST_DEC);
  792.  
  793.   data.explicit_inc_from = 0;
  794.   data.explicit_inc_to = 0;
  795.   data.reverse
  796.     = (GET_CODE (to_addr) == PRE_DEC || GET_CODE (to_addr) == POST_DEC);
  797.   if (data.reverse) data.offset = len;
  798.   data.len = len;
  799.  
  800.   /* If copying requires more than two move insns,
  801.      copy addresses to registers (to make displacements shorter)
  802.      and use post-increment if available.  */
  803.   if (!(data.autinc_from && data.autinc_to)
  804.       && move_by_pieces_ninsns (len, align) > 2)
  805.     {
  806. #ifdef HAVE_PRE_DECREMENT
  807.       if (data.reverse && ! data.autinc_from)
  808.     {
  809.       data.from_addr = copy_addr_to_reg (plus_constant (from_addr, len));
  810.       data.autinc_from = 1;
  811.       data.explicit_inc_from = -1;
  812.     }
  813. #endif
  814. #ifdef HAVE_POST_INCREMENT
  815.       if (! data.autinc_from)
  816.     {
  817.       data.from_addr = copy_addr_to_reg (from_addr);
  818.       data.autinc_from = 1;
  819.       data.explicit_inc_from = 1;
  820.     }
  821. #endif
  822.       if (!data.autinc_from && CONSTANT_P (from_addr))
  823.     data.from_addr = copy_addr_to_reg (from_addr);
  824. #ifdef HAVE_PRE_DECREMENT
  825.       if (data.reverse && ! data.autinc_to)
  826.     {
  827.       data.to_addr = copy_addr_to_reg (plus_constant (to_addr, len));
  828.       data.autinc_to = 1;
  829.       data.explicit_inc_to = -1;
  830.     }
  831. #endif
  832. #ifdef HAVE_POST_INCREMENT
  833.       if (! data.reverse && ! data.autinc_to)
  834.     {
  835.       data.to_addr = copy_addr_to_reg (to_addr);
  836.       data.autinc_to = 1;
  837.       data.explicit_inc_to = 1;
  838.     }
  839. #endif
  840.       if (!data.autinc_to && CONSTANT_P (to_addr))
  841.     data.to_addr = copy_addr_to_reg (to_addr);
  842.     }
  843.  
  844. #if defined (STRICT_ALIGNMENT) || defined (SLOW_UNALIGNED_ACCESS)
  845.   if (align > MOVE_MAX || align >= BIGGEST_ALIGNMENT / BITS_PER_UNIT)
  846.     align = MOVE_MAX;
  847. #else
  848.   align = MOVE_MAX;
  849. #endif
  850.  
  851. #ifdef HAVE_movti
  852.   if (HAVE_movti && align >= GET_MODE_SIZE (TImode))
  853.     move_by_pieces_1 (gen_movti, TImode, &data);
  854. #endif
  855. #ifdef HAVE_movdi
  856.   if (HAVE_movdi && align >= GET_MODE_SIZE (DImode))
  857.     move_by_pieces_1 (gen_movdi, DImode, &data);
  858. #endif
  859. #ifdef HAVE_movsi
  860.   if (align >= GET_MODE_SIZE (SImode))
  861.     move_by_pieces_1 (gen_movsi, SImode, &data);
  862. #endif
  863. #ifdef HAVE_movhi
  864.   if (HAVE_movhi && align >= GET_MODE_SIZE (HImode))
  865.     move_by_pieces_1 (gen_movhi, HImode, &data);
  866. #endif
  867. #ifdef HAVE_movqi
  868.   if (HAVE_movqi)
  869.     move_by_pieces_1 (gen_movqi, QImode, &data);
  870. #endif
  871.   /* The above should have handled everything.  */
  872.   if (data.len != 0)
  873.     abort ();
  874. }
  875.  
  876. /* Return number of insns required to move L bytes by pieces.
  877.    ALIGN (in bytes) is maximum alignment we can assume.  */
  878.  
  879. static int
  880. move_by_pieces_ninsns (l, align)
  881.      unsigned int l;
  882.      int align;
  883. {
  884.   register int n_insns = 0;
  885.  
  886. #if defined (STRICT_ALIGNMENT) || defined (SLOW_UNALIGNED_ACCESS)
  887.   if (align > MOVE_MAX || align >= BIGGEST_ALIGNMENT / BITS_PER_UNIT)
  888.     align = MOVE_MAX;
  889. #else
  890.   align = MOVE_MAX;
  891. #endif
  892.  
  893. #ifdef HAVE_movti
  894.   if (HAVE_movti && align >= GET_MODE_SIZE (TImode))
  895.     n_insns += l / GET_MODE_SIZE (TImode), l %= GET_MODE_SIZE (TImode);
  896. #endif
  897. #ifdef HAVE_movdi
  898.   if (HAVE_movdi && align >= GET_MODE_SIZE (DImode))
  899.     n_insns += l / GET_MODE_SIZE (DImode), l %= GET_MODE_SIZE (DImode);
  900. #endif
  901. #ifdef HAVE_movsi
  902.   if (HAVE_movsi && align >= GET_MODE_SIZE (SImode))
  903.     n_insns += l / GET_MODE_SIZE (SImode), l %= GET_MODE_SIZE (SImode);
  904. #endif
  905. #ifdef HAVE_movhi
  906.   if (HAVE_movhi && align >= GET_MODE_SIZE (HImode))
  907.     n_insns += l / GET_MODE_SIZE (HImode), l %= GET_MODE_SIZE (HImode);
  908. #endif
  909.   n_insns += l;
  910.  
  911.   return n_insns;
  912. }
  913.  
  914. /* Subroutine of move_by_pieces.  Move as many bytes as appropriate
  915.    with move instructions for mode MODE.  GENFUN is the gen_... function
  916.    to make a move insn for that mode.  DATA has all the other info.  */
  917.  
  918. static void
  919. move_by_pieces_1 (genfun, mode, data)
  920.      rtx (*genfun) ();
  921.      enum machine_mode mode;
  922.      struct move_by_pieces *data;
  923. {
  924.   register int size = GET_MODE_SIZE (mode);
  925.   register rtx to1, from1;
  926.  
  927.   while (data->len >= size)
  928.     {
  929.       if (data->reverse) data->offset -= size;
  930.  
  931.       to1 = (data->autinc_to
  932.          ? gen_rtx (MEM, mode, data->to_addr)
  933.          : change_address (data->to, mode,
  934.                    plus_constant (data->to_addr, data->offset)));
  935.       from1 =
  936.     (data->autinc_from
  937.      ? gen_rtx (MEM, mode, data->from_addr)
  938.      : change_address (data->from, mode,
  939.                plus_constant (data->from_addr, data->offset)));
  940.  
  941. #ifdef HAVE_PRE_DECREMENT
  942.       if (data->explicit_inc_to < 0)
  943.     emit_insn (gen_sub2_insn (data->to_addr,
  944.                   gen_rtx (CONST_INT, VOIDmode, size)));
  945.       if (data->explicit_inc_from < 0)
  946.     emit_insn (gen_sub2_insn (data->from_addr,
  947.                   gen_rtx (CONST_INT, VOIDmode, size)));
  948. #endif
  949.  
  950.       emit_insn ((*genfun) (to1, from1));
  951. #ifdef HAVE_POST_INCREMENT
  952.       if (data->explicit_inc_to > 0)
  953.     emit_insn (gen_add2_insn (data->to_addr,
  954.                   gen_rtx (CONST_INT, VOIDmode, size)));
  955.       if (data->explicit_inc_from > 0)
  956.     emit_insn (gen_add2_insn (data->from_addr,
  957.                   gen_rtx (CONST_INT, VOIDmode, size)));
  958. #endif
  959.  
  960.       if (! data->reverse) data->offset += size;
  961.  
  962.       data->len -= size;
  963.     }
  964. }
  965.  
  966. /* Emit code to move a block Y to a block X.
  967.    This may be done with string-move instructions,
  968.    with multiple scalar move instructions, or with a library call.
  969.  
  970.    Both X and Y must be MEM rtx's (perhaps inside VOLATILE)
  971.    with mode BLKmode.
  972.    SIZE is an rtx that says how long they are.
  973.    ALIGN is the maximum alignment we can assume they have,
  974.    measured in bytes.  */
  975.  
  976. void
  977. emit_block_move (x, y, size, align)
  978.      rtx x, y;
  979.      rtx size;
  980.      int align;
  981. {
  982.   if (GET_MODE (x) != BLKmode)
  983.     abort ();
  984.  
  985.   if (GET_MODE (y) != BLKmode)
  986.     abort ();
  987.  
  988.   x = protect_from_queue (x, 1);
  989.   y = protect_from_queue (y, 0);
  990.  
  991.   if (GET_CODE (x) != MEM)
  992.     abort ();
  993.   if (GET_CODE (y) != MEM)
  994.     abort ();
  995.   if (size == 0)
  996.     abort ();
  997.  
  998.   if (GET_CODE (size) == CONST_INT
  999.       && (move_by_pieces_ninsns ((unsigned) INTVAL (size), align)
  1000.       < MOVE_RATIO))
  1001.     move_by_pieces (x, y, INTVAL (size), align);
  1002.   else
  1003.     {
  1004.       /* Try the most limited insn first, because there's no point
  1005.      including more than one in the machine description unless
  1006.      the more limited one has some advantage.  */
  1007. #ifdef HAVE_movstrqi
  1008.       if (HAVE_movstrqi
  1009.       && GET_CODE (size) == CONST_INT
  1010.       && ((unsigned) INTVAL (size)
  1011.           < (1 << (GET_MODE_BITSIZE (QImode) - 1))))
  1012.     {
  1013.       rtx insn = gen_movstrqi (x, y, size,
  1014.                    gen_rtx (CONST_INT, VOIDmode, align));
  1015.       if (insn)
  1016.         {
  1017.           emit_insn (insn);
  1018.           return;
  1019.         }
  1020.     }
  1021. #endif
  1022. #ifdef HAVE_movstrhi
  1023.       if (HAVE_movstrhi
  1024.       && GET_CODE (size) == CONST_INT
  1025.       && ((unsigned) INTVAL (size)
  1026.           < (1 << (GET_MODE_BITSIZE (HImode) - 1))))
  1027.     {
  1028.       rtx insn = gen_movstrhi (x, y, size,
  1029.                    gen_rtx (CONST_INT, VOIDmode, align));
  1030.       if (insn)
  1031.         {
  1032.           emit_insn (insn);
  1033.           return;
  1034.         }
  1035.     }
  1036. #endif
  1037. #ifdef HAVE_movstrsi
  1038.       if (HAVE_movstrsi)
  1039.     {
  1040.       rtx insn = gen_movstrsi (x, y, size,
  1041.                    gen_rtx (CONST_INT, VOIDmode, align));
  1042.       if (insn)
  1043.         {
  1044.           emit_insn (insn);
  1045.           return;
  1046.         }
  1047.     }
  1048. #endif
  1049.  
  1050. #ifdef TARGET_MEM_FUNCTIONS
  1051.       emit_library_call (memcpy_libfunc, 0,
  1052.              VOIDmode, 3, XEXP (x, 0), Pmode,
  1053.              XEXP (y, 0), Pmode,
  1054.              size, Pmode);
  1055. #else
  1056.       emit_library_call (bcopy_libfunc, 0,
  1057.              VOIDmode, 3, XEXP (y, 0), Pmode,
  1058.              XEXP (x, 0), Pmode,
  1059.              size, Pmode);
  1060. #endif
  1061.     }
  1062. }
  1063.  
  1064. /* Copy all or part of a value X into registers starting at REGNO.
  1065.    The number of registers to be filled is NREGS.  */
  1066.  
  1067. void
  1068. move_block_to_reg (regno, x, nregs, mode)
  1069.      int regno;
  1070.      rtx x;
  1071.      int nregs;
  1072.      enum machine_mode mode;
  1073. {
  1074.   enum machine_mode submode = mode_for_size (BITS_PER_WORD, MODE_INT, 0);
  1075.   int i;
  1076.   rtx pat, last;
  1077.  
  1078.   if (! LEGITIMATE_CONSTANT_P (x))
  1079.     x = validize_mem (force_const_mem (mode, x));
  1080.  
  1081.   /* See if the machine can do this with a load multiple insn.  */
  1082. #ifdef HAVE_load_multiple
  1083.   last = get_last_insn ();
  1084.   pat = gen_load_multiple (gen_rtx (REG, submode, regno), x,
  1085.                gen_rtx (CONST_INT, VOIDmode, nregs));
  1086.   if (pat)
  1087.     {
  1088.       emit_insn (pat);
  1089.       return;
  1090.     }
  1091.   else
  1092.     delete_insns_since (last);
  1093. #endif
  1094.  
  1095.   for (i = 0; i < nregs; i++)
  1096.     emit_move_insn (gen_rtx (REG, submode, regno + i),
  1097.             operand_subword_force (x, i), mode);
  1098. }
  1099.  
  1100. /* Copy all or part of a BLKmode value X out of registers starting at REGNO.
  1101.    The number of registers to be filled is NREGS.  */
  1102.  
  1103. void
  1104. move_block_from_reg (regno, x, nregs)
  1105.      int regno;
  1106.      rtx x;
  1107.      int nregs;
  1108. {
  1109.   enum machine_mode submode = mode_for_size (BITS_PER_WORD, MODE_INT, 0);
  1110.   int i;
  1111.   rtx pat, last;
  1112.  
  1113.   /* See if the machine can do this with a store multiple insn.  */
  1114. #ifdef HAVE_store_multiple
  1115.   last = get_last_insn ();
  1116.   pat = gen_store_multiple (x, gen_rtx (REG, submode, regno),
  1117.                 gen_rtx (CONST_INT, VOIDmode, nregs));
  1118.   if (pat)
  1119.     {
  1120.       emit_insn (pat);
  1121.       return;
  1122.     }
  1123.   else
  1124.     delete_insns_since (last);
  1125. #endif
  1126.  
  1127.   for (i = 0; i < nregs; i++)
  1128.     emit_move_insn (operand_subword (x, i, 1, BLKmode),
  1129.             gen_rtx (REG, submode, regno + i));
  1130. }
  1131.  
  1132. /* Mark NREGS consecutive regs, starting at REGNO, as being live now.  */
  1133.  
  1134. void
  1135. use_regs (regno, nregs)
  1136.      int regno;
  1137.      int nregs;
  1138. {
  1139.   enum machine_mode submode = mode_for_size (BITS_PER_WORD, MODE_INT, 0);
  1140.   int i;
  1141.  
  1142.   for (i = 0; i < nregs; i++)
  1143.     emit_insn (gen_rtx (USE, VOIDmode, gen_rtx (REG, submode, regno + i)));
  1144. }
  1145.  
  1146. /* Write zeros through the storage of OBJECT.
  1147.    If OBJECT has BLKmode, SIZE is its length in bytes.  */
  1148.  
  1149. void
  1150. clear_storage (object, size)
  1151.      rtx object;
  1152.      int size;
  1153. {
  1154.   if (GET_MODE (object) == BLKmode)
  1155.     {
  1156. #ifdef TARGET_MEM_FUNCTIONS
  1157.       emit_library_call (memset_libfunc, 0,
  1158.              VOIDmode, 3,
  1159.              XEXP (object, 0), Pmode, const0_rtx, Pmode,
  1160.              gen_rtx (CONST_INT, VOIDmode, size), Pmode);
  1161. #else
  1162.       emit_library_call (bzero_libfunc, 0,
  1163.              VOIDmode, 2,
  1164.              XEXP (object, 0), Pmode,
  1165.              gen_rtx (CONST_INT, VOIDmode, size), Pmode);
  1166. #endif
  1167.     }
  1168.   else
  1169.     emit_move_insn (object, const0_rtx);
  1170. }
  1171.  
  1172. /* Generate code to copy Y into X.
  1173.    Both Y and X must have the same mode, except that
  1174.    Y can be a constant with VOIDmode.
  1175.    This mode cannot be BLKmode; use emit_block_move for that.
  1176.  
  1177.    Return the last instruction emitted.  */
  1178.  
  1179. rtx
  1180. emit_move_insn (x, y)
  1181.      rtx x, y;
  1182. {
  1183.   enum machine_mode mode = GET_MODE (x);
  1184.   int i;
  1185.  
  1186.   x = protect_from_queue (x, 1);
  1187.   y = protect_from_queue (y, 0);
  1188.  
  1189.   if (mode == BLKmode || (GET_MODE (y) != mode && GET_MODE (y) != VOIDmode))
  1190.     abort ();
  1191.  
  1192.   if (CONSTANT_P (y) && ! LEGITIMATE_CONSTANT_P (y))
  1193.     y = force_const_mem (mode, y);
  1194.  
  1195.   /* If X or Y are memory references, verify that their addresses are valid
  1196.      for the machine.  */
  1197.   if (GET_CODE (x) == MEM
  1198.       && ((! memory_address_p (GET_MODE (x), XEXP (x, 0))
  1199.        && ! push_operand (x, GET_MODE (x)))
  1200.       || (flag_force_addr
  1201.           && CONSTANT_ADDRESS_P (XEXP (x, 0)))))
  1202.     x = change_address (x, VOIDmode, XEXP (x, 0));
  1203.  
  1204.   if (GET_CODE (y) == MEM
  1205.       && (! memory_address_p (GET_MODE (y), XEXP (y, 0))
  1206.       || (flag_force_addr
  1207.           && CONSTANT_ADDRESS_P (XEXP (y, 0)))))
  1208.     y = change_address (y, VOIDmode, XEXP (y, 0));
  1209.  
  1210.   if (mode == BLKmode)
  1211.     abort ();
  1212.  
  1213.   if (mov_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing)
  1214.     return
  1215.       emit_insn (GEN_FCN (mov_optab->handlers[(int) mode].insn_code) (x, y));
  1216.  
  1217.   /* This will handle any multi-word mode that lacks a move_insn pattern.
  1218.      However, you will get better code if you define such patterns,
  1219.      even if they must turn into multiple assembler instructions.  */
  1220.   else if (GET_MODE_SIZE (mode) >= UNITS_PER_WORD)
  1221.     for (i = 0;
  1222.      i < (GET_MODE_SIZE (mode)  + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD;
  1223.      i++)
  1224.       {
  1225.     rtx ypart = operand_subword (y, i, 1, mode);
  1226.  
  1227.     /* If we can't get a part of Y, put Y into memory if it is a constant.
  1228.        If we still can't get a part of Y, abort.  */
  1229.     if (ypart == 0 && CONSTANT_P (y))
  1230.       {
  1231.         y = force_const_mem (mode, y);
  1232.         ypart = operand_subword (y, i, 1, mode);
  1233.       }
  1234.  
  1235.     if (ypart == 0)
  1236.       abort ();
  1237.  
  1238.     emit_move_insn (operand_subword (x, i, 1, mode), ypart);
  1239.       }
  1240.   else
  1241.     abort ();
  1242. }
  1243.  
  1244. /* Pushing data onto the stack.  */
  1245.  
  1246. /* Push a block of length SIZE (perhaps variable)
  1247.    and return an rtx to address the beginning of the block.
  1248.    Note that it is not possible for the value returned to be a QUEUED.
  1249.    The value may be virtual_outgoing_args_rtx.
  1250.  
  1251.    EXTRA is the number of bytes of padding to push in addition to SIZE.
  1252.    BELOW nonzero means this padding comes at low addresses;
  1253.    otherwise, the padding comes at high addresses.  */
  1254.  
  1255. rtx
  1256. push_block (size, extra, below)
  1257.      rtx size;
  1258.      int extra, below;
  1259. {
  1260.   register rtx temp;
  1261.   if (CONSTANT_P (size))
  1262.     anti_adjust_stack (plus_constant (size, extra));
  1263.   else if (GET_CODE (size) == REG && extra == 0)
  1264.     anti_adjust_stack (size);
  1265.   else
  1266.     {
  1267.       rtx temp = copy_to_mode_reg (Pmode, size);
  1268.       if (extra != 0)
  1269.     temp = expand_binop (Pmode, add_optab,
  1270.                  temp,
  1271.                  gen_rtx (CONST_INT, VOIDmode, extra),
  1272.                  temp, 0, OPTAB_LIB_WIDEN);
  1273.       anti_adjust_stack (temp);
  1274.     }
  1275.  
  1276. #ifdef STACK_GROWS_DOWNWARD
  1277.   temp = virtual_outgoing_args_rtx;
  1278.   if (extra != 0 && below)
  1279.     temp = plus_constant (temp, extra);
  1280. #else
  1281.   if (GET_CODE (size) == CONST_INT)
  1282.     temp = plus_constant (virtual_outgoing_args_rtx,
  1283.               - INTVAL (size) - (below ? 0 : extra));
  1284.   else if (extra != 0 && !below)
  1285.     temp = gen_rtx (PLUS, Pmode, virtual_outgoing_args_rtx,
  1286.             negate_rtx (Pmode, plus_constant (size, extra)));
  1287.   else
  1288.     temp = gen_rtx (PLUS, Pmode, virtual_outgoing_args_rtx,
  1289.             negate_rtx (Pmode, size));
  1290. #endif
  1291.  
  1292.   return memory_address (QImode, temp);
  1293. }
  1294.  
  1295. static rtx
  1296. gen_push_operand ()
  1297. {
  1298.   return gen_rtx (STACK_PUSH_CODE, Pmode, stack_pointer_rtx);
  1299. }
  1300.  
  1301. /* Generate code to push X onto the stack, assuming it has mode MODE and
  1302.    type TYPE.
  1303.    MODE is redundant except when X is a CONST_INT (since they don't
  1304.    carry mode info).
  1305.    SIZE is an rtx for the size of data to be copied (in bytes),
  1306.    needed only if X is BLKmode.
  1307.  
  1308.    ALIGN (in bytes) is maximum alignment we can assume.
  1309.  
  1310.    If PARTIAL is nonzero, then copy that many of the first words
  1311.    of X into registers starting with REG, and push the rest of X.
  1312.    The amount of space pushed is decreased by PARTIAL words,
  1313.    rounded *down* to a multiple of PARM_BOUNDARY.
  1314.    REG must be a hard register in this case.
  1315.  
  1316.    EXTRA is the amount in bytes of extra space to leave next to this arg.
  1317.    This is ignored if an argument block has already been allocted.
  1318.  
  1319.    On a machine that lacks real push insns, ARGS_ADDR is the address of
  1320.    the bottom of the argument block for this call.  We use indexing off there
  1321.    to store the arg.  On machines with push insns, ARGS_ADDR is 0 when a
  1322.    argument block has not been preallocated.
  1323.  
  1324.    ARGS_SO_FAR is the size of args previously pushed for this call.  */
  1325.  
  1326. void
  1327. emit_push_insn (x, mode, type, size, align, partial, reg, extra,
  1328.         args_addr, args_so_far)
  1329.      register rtx x;
  1330.      enum machine_mode mode;
  1331.      tree type;
  1332.      rtx size;
  1333.      int align;
  1334.      int partial;
  1335.      rtx reg;
  1336.      int extra;
  1337.      rtx args_addr;
  1338.      rtx args_so_far;
  1339. {
  1340.   rtx xinner;
  1341.   enum direction stack_direction
  1342. #ifdef STACK_GROWS_DOWNWARD
  1343.     = downward;
  1344. #else
  1345.     = upward;
  1346. #endif
  1347.  
  1348.   /* Decide where to pad the argument: `downward' for below,
  1349.      `upward' for above, or `none' for don't pad it.
  1350.      Default is below for small data on big-endian machines; else above.  */
  1351.   enum direction where_pad = FUNCTION_ARG_PADDING (mode, type);
  1352.  
  1353.   /* Invert direction if stack is post-update.  */
  1354.   if (STACK_PUSH_CODE == POST_INC || STACK_PUSH_CODE == POST_DEC)
  1355.     if (where_pad != none)
  1356.       where_pad = (where_pad == downward ? upward : downward);
  1357.  
  1358.   xinner = x = protect_from_queue (x, 0);
  1359.  
  1360.   if (mode == BLKmode)
  1361.     {
  1362.       /* Copy a block into the stack, entirely or partially.  */
  1363.  
  1364.       register rtx temp;
  1365.       int used = partial * UNITS_PER_WORD;
  1366.       int offset = used % (PARM_BOUNDARY / BITS_PER_UNIT);
  1367.       int skip;
  1368.       
  1369.       if (size == 0)
  1370.     abort ();
  1371.  
  1372.       used -= offset;
  1373.  
  1374.       /* USED is now the # of bytes we need not copy to the stack
  1375.      because registers will take care of them.  */
  1376.  
  1377.       if (partial != 0)
  1378.     xinner = change_address (xinner, BLKmode,
  1379.                  plus_constant (XEXP (xinner, 0), used));
  1380.  
  1381.       /* If the partial register-part of the arg counts in its stack size,
  1382.      skip the part of stack space corresponding to the registers.
  1383.      Otherwise, start copying to the beginning of the stack space,
  1384.      by setting SKIP to 0.  */
  1385. #ifndef REG_PARM_STACK_SPACE
  1386.       skip = 0;
  1387. #else
  1388.       skip = used;
  1389. #endif
  1390.  
  1391. #ifdef PUSH_ROUNDING
  1392.       /* Do it with several push insns if that doesn't take lots of insns
  1393.      and if there is no difficulty with push insns that skip bytes
  1394.      on the stack for alignment purposes.  */
  1395.       if (args_addr == 0
  1396.       && GET_CODE (size) == CONST_INT
  1397.       && skip == 0
  1398.       && (move_by_pieces_ninsns ((unsigned) INTVAL (size) - used, align)
  1399.           < MOVE_RATIO)
  1400. #if defined (STRICT_ALIGNMENT) || defined (SLOW_UNALIGNED_ACCESS)
  1401.       /* Here we avoid the case of a structure whose weak alignment
  1402.          forces many pushes of a small amount of data,
  1403.          and such small pushes do rounding that causes trouble.  */
  1404.       && (align >= BIGGEST_ALIGNMENT / BITS_PER_UNIT
  1405.           || PUSH_ROUNDING (align) == align)
  1406. #endif
  1407.       && PUSH_ROUNDING (INTVAL (size)) == INTVAL (size))
  1408.     {
  1409.       /* Push padding now if padding above and stack grows down,
  1410.          or if padding below and stack grows up.
  1411.          But if space already allocated, this has already been done.  */
  1412.       if (extra && args_addr == 0
  1413.           && where_pad != none && where_pad != stack_direction)
  1414.         anti_adjust_stack (gen_rtx (CONST_INT, VOIDmode, extra));
  1415.  
  1416.       move_by_pieces (gen_rtx (MEM, BLKmode, gen_push_operand ()), xinner,
  1417.               INTVAL (size) - used, align);
  1418.     }
  1419.       else
  1420. #endif /* PUSH_ROUNDING */
  1421.     {
  1422.       /* Otherwise make space on the stack and copy the data
  1423.          to the address of that space.  */
  1424.  
  1425.       /* Deduct words put into registers from the size we must copy.  */
  1426.       if (partial != 0)
  1427.         {
  1428.           if (GET_CODE (size) == CONST_INT)
  1429.         size = gen_rtx (CONST_INT, VOIDmode, INTVAL (size) - used);
  1430.           else
  1431.         size = expand_binop (GET_MODE (size), sub_optab, size,
  1432.                      gen_rtx (CONST_INT, VOIDmode, used),
  1433.                      0, 0, OPTAB_LIB_WIDEN);
  1434.         }
  1435.  
  1436.       /* Get the address of the stack space.
  1437.          In this case, we do not deal with EXTRA separately.
  1438.          A single stack adjust will do.  */
  1439.       if (! args_addr)
  1440.         {
  1441.           temp = push_block (size, extra, where_pad == downward);
  1442.           extra = 0;
  1443.         }
  1444.       else if (GET_CODE (args_so_far) == CONST_INT)
  1445.         temp = memory_address (BLKmode,
  1446.                    plus_constant (args_addr,
  1447.                           skip + INTVAL (args_so_far)));
  1448.       else
  1449.         temp = memory_address (BLKmode,
  1450.                    plus_constant (gen_rtx (PLUS, Pmode,
  1451.                                args_addr, args_so_far),
  1452.                           skip));
  1453.  
  1454.       /* TEMP is the address of the block.  Copy the data there.  */
  1455.       if (GET_CODE (size) == CONST_INT
  1456.           && (move_by_pieces_ninsns ((unsigned) INTVAL (size), align)
  1457.           < MOVE_RATIO))
  1458.         {
  1459.           move_by_pieces (gen_rtx (MEM, BLKmode, temp), xinner,
  1460.                   INTVAL (size), align);
  1461.           goto ret;
  1462.         }
  1463.       /* Try the most limited insn first, because there's no point
  1464.          including more than one in the machine description unless
  1465.          the more limited one has some advantage.  */
  1466. #ifdef HAVE_movstrqi
  1467.       if (HAVE_movstrqi
  1468.           && GET_CODE (size) == CONST_INT
  1469.           && ((unsigned) INTVAL (size)
  1470.           < (1 << (GET_MODE_BITSIZE (QImode) - 1))))
  1471.         {
  1472.           emit_insn (gen_movstrqi (gen_rtx (MEM, BLKmode, temp),
  1473.                        xinner, size,
  1474.                        gen_rtx (CONST_INT, VOIDmode, align)));
  1475.           goto ret;
  1476.         }
  1477. #endif
  1478. #ifdef HAVE_movstrhi
  1479.       if (HAVE_movstrhi
  1480.           && GET_CODE (size) == CONST_INT
  1481.           && ((unsigned) INTVAL (size)
  1482.           < (1 << (GET_MODE_BITSIZE (HImode) - 1))))
  1483.         {
  1484.           emit_insn (gen_movstrhi (gen_rtx (MEM, BLKmode, temp),
  1485.                        xinner, size,
  1486.                        gen_rtx (CONST_INT, VOIDmode, align)));
  1487.           goto ret;
  1488.         }
  1489. #endif
  1490. #ifdef HAVE_movstrsi
  1491.       if (HAVE_movstrsi)
  1492.         {
  1493.           emit_insn (gen_movstrsi (gen_rtx (MEM, BLKmode, temp),
  1494.                        xinner, size,
  1495.                        gen_rtx (CONST_INT, VOIDmode, align)));
  1496.           goto ret;
  1497.         }
  1498. #endif
  1499.  
  1500. #ifndef ACCUMULATE_OUTGOING_ARGS
  1501.       /* If the source is referenced relative to the stack pointer,
  1502.          copy it to another register to stabilize it.  We do not need
  1503.          to do this if we know that we won't be changing sp.  */
  1504.  
  1505.       if (reg_mentioned_p (virtual_stack_dynamic_rtx, temp)
  1506.           || reg_mentioned_p (virtual_outgoing_args_rtx, temp))
  1507.         temp = copy_to_reg (temp);
  1508. #endif
  1509.  
  1510.       /* Make inhibit_defer_pop nonzero around the library call
  1511.          to force it to pop the bcopy-arguments right away.  */
  1512.       NO_DEFER_POP;
  1513. #ifdef TARGET_MEM_FUNCTIONS
  1514.       emit_library_call (memcpy_libfunc, 0,
  1515.                  VOIDmode, 3, temp, Pmode, XEXP (xinner, 0), Pmode,
  1516.                  size, Pmode);
  1517. #else
  1518.       emit_library_call (bcopy_libfunc, 0,
  1519.                  VOIDmode, 3, XEXP (xinner, 0), Pmode, temp, Pmode,
  1520.                  size, Pmode);
  1521. #endif
  1522.       OK_DEFER_POP;
  1523.     }
  1524.     }
  1525.   else if (partial > 0)
  1526.     {
  1527.       /* Scalar partly in registers.  */
  1528.  
  1529.       int size = GET_MODE_SIZE (mode) / UNITS_PER_WORD;
  1530.       int i;
  1531.       int not_stack;
  1532.       /* # words of start of argument
  1533.      that we must make space for but need not store.  */
  1534.       int offset = partial % (PARM_BOUNDARY / BITS_PER_WORD);
  1535.       int args_offset = INTVAL (args_so_far);
  1536.       int skip;
  1537.       enum machine_mode submode = mode_for_size (BITS_PER_WORD, MODE_INT, 0);
  1538.  
  1539.       /* Push padding now if padding above and stack grows down,
  1540.      or if padding below and stack grows up.
  1541.      But if space already allocated, this has already been done.  */
  1542.       if (extra && args_addr == 0
  1543.       && where_pad != none && where_pad != stack_direction)
  1544.     anti_adjust_stack (gen_rtx (CONST_INT, VOIDmode, extra));
  1545.  
  1546.       /* If we make space by pushing it, we might as well push
  1547.      the real data.  Otherwise, we can leave OFFSET nonzero
  1548.      and leave the space uninitialized.  */
  1549.       if (args_addr == 0)
  1550.     offset = 0;
  1551.  
  1552.       /* Now NOT_STACK gets the number of words that we don't need to
  1553.      allocate on the stack.  */
  1554.       not_stack = partial - offset;
  1555.  
  1556.       /* If the partial register-part of the arg counts in its stack size,
  1557.      skip the part of stack space corresponding to the registers.
  1558.      Otherwise, start copying to the beginning of the stack space,
  1559.      by setting SKIP to 0.  */
  1560. #ifndef REG_PARM_STACK_SPACE
  1561.       skip = 0;
  1562. #else
  1563.       skip = not_stack;
  1564. #endif
  1565.  
  1566.       if (! LEGITIMATE_CONSTANT_P (x))
  1567.     x = validize_mem (force_const_mem (mode, x));
  1568.  
  1569.       /* If X is a hard register in a non-integer mode, copy it into a pseudo.
  1570.      SUBREGs of such registers are not allowed.  Similarly if it is a 
  1571.      constant and the host and target wordsizes aren't the same.  */
  1572.       if ((GET_CODE (x) == REG && REGNO (x) < FIRST_PSEUDO_REGISTER
  1573.        && GET_MODE_CLASS (GET_MODE (x)) != MODE_INT)
  1574. #if HOST_BITS_PER_INT != BITS_PER_WORD
  1575.       || CONSTANT_P (x)
  1576. #endif
  1577.       )
  1578.     x = copy_to_reg (x);
  1579.  
  1580.       /* Loop over all the words allocated on the stack for this arg.  */
  1581.       /* We can do it by words, because any scalar bigger than a word
  1582.      has a size a multiple of a word.  */
  1583. #ifndef PUSH_ARGS_REVERSED
  1584.       for (i = not_stack; i < size; i++)
  1585. #else
  1586.       for (i = size - 1; i >= not_stack; i--)
  1587. #endif
  1588.     if (i >= not_stack + offset)
  1589.       emit_push_insn (operand_subword_force (x, i, mode),
  1590.               submode, 0, 0, align, 0, 0, 0, args_addr,
  1591.               gen_rtx (CONST_INT, VOIDmode,
  1592.                    args_offset + ((i - not_stack + skip)
  1593.                           * UNITS_PER_WORD)));
  1594.     }
  1595.   else
  1596.     {
  1597.       rtx addr;
  1598.  
  1599.       /* Push padding now if padding above and stack grows down,
  1600.      or if padding below and stack grows up.
  1601.      But if space already allocated, this has already been done.  */
  1602.       if (extra && args_addr == 0
  1603.       && where_pad != none && where_pad != stack_direction)
  1604.     anti_adjust_stack (gen_rtx (CONST_INT, VOIDmode, extra));
  1605.  
  1606. #ifdef PUSH_ROUNDING
  1607.       if (args_addr == 0)
  1608.     addr = gen_push_operand ();
  1609.       else
  1610. #endif
  1611.     if (GET_CODE (args_so_far) == CONST_INT)
  1612.       addr
  1613.         = memory_address (mode,
  1614.                   plus_constant (args_addr, INTVAL (args_so_far)));
  1615.       else
  1616.     addr = memory_address (mode, gen_rtx (PLUS, Pmode, args_addr,
  1617.                           args_so_far));
  1618.  
  1619.       emit_move_insn (gen_rtx (MEM, mode, addr), x);
  1620.     }
  1621.  
  1622.  ret:
  1623.   /* If part should go in registers, copy that part
  1624.      into the appropriate registers.  Do this now, at the end,
  1625.      since mem-to-mem copies above may do function calls.  */
  1626.   if (partial > 0)
  1627.     move_block_to_reg (REGNO (reg), x, partial, mode);
  1628.  
  1629.   if (extra && args_addr == 0 && where_pad == stack_direction)
  1630.     anti_adjust_stack (gen_rtx (CONST_INT, VOIDmode, extra));
  1631. }
  1632.  
  1633. /* Output a library call to function FUN (a SYMBOL_REF rtx)
  1634.    (emitting the queue unless NO_QUEUE is nonzero),
  1635.    for a value of mode OUTMODE,
  1636.    with NARGS different arguments, passed as alternating rtx values
  1637.    and machine_modes to convert them to.
  1638.    The rtx values should have been passed through protect_from_queue already.  */
  1639.  
  1640. void
  1641. emit_library_call (va_alist)
  1642.      va_dcl
  1643. {
  1644.   register va_list p;
  1645.   struct args_size args_size;
  1646.   register int argnum;
  1647.   enum machine_mode outmode;
  1648.   int nargs;
  1649.   rtx fun;
  1650.   rtx orgfun;
  1651.   int inc;
  1652.   int count;
  1653.   rtx argblock = 0;
  1654.   CUMULATIVE_ARGS args_so_far;
  1655.   struct arg { rtx value; enum machine_mode mode; rtx reg; int partial;
  1656.            struct args_size offset; struct args_size size; };
  1657.   struct arg *argvec;
  1658.   int old_inhibit_defer_pop = inhibit_defer_pop;
  1659.   int no_queue = 0;
  1660.   rtx use_insns;
  1661.  
  1662.   va_start (p);
  1663.   orgfun = fun = va_arg (p, rtx);
  1664.   no_queue = va_arg (p, int);
  1665.   outmode = va_arg (p, enum machine_mode);
  1666.   nargs = va_arg (p, int);
  1667.  
  1668.   /* Copy all the libcall-arguments out of the varargs data
  1669.      and into a vector ARGVEC.
  1670.  
  1671.      Compute how to pass each argument.  We only support a very small subset
  1672.      of the full argument passing conventions to limit complexity here since
  1673.      library functions shouldn't have many args.  */
  1674.  
  1675.   argvec = (struct arg *) alloca (nargs * sizeof (struct arg));
  1676.  
  1677.   INIT_CUMULATIVE_ARGS (args_so_far, (tree)0, fun);
  1678.  
  1679.   args_size.constant = 0;
  1680.   args_size.var = 0;
  1681.  
  1682.   for (count = 0; count < nargs; count++)
  1683.     {
  1684.       rtx val = va_arg (p, rtx);
  1685.       enum machine_mode mode = va_arg (p, enum machine_mode);
  1686.  
  1687.       /* We cannot convert the arg value to the mode the library wants here;
  1688.      must do it earlier where we know the signedness of the arg.  */
  1689.       if (mode == BLKmode
  1690.       || (GET_MODE (val) != mode && GET_MODE (val) != VOIDmode))
  1691.     abort ();
  1692.  
  1693.       /* On some machines, there's no way to pass a float to a library fcn.
  1694.      Pass it as a double instead.  */
  1695. #ifdef GNULIB_NEEDS_DOUBLE
  1696.       if (GNULIB_NEEDS_DOUBLE && mode == SFmode)
  1697.     val = convert_to_mode (DFmode, val), mode = DFmode;
  1698. #endif
  1699.  
  1700.       /* Make sure it is a reasonable operand for a move or push insn.  */
  1701.       if (GET_CODE (val) != REG && GET_CODE (val) != MEM
  1702.       && ! (CONSTANT_P (val) && LEGITIMATE_CONSTANT_P (val)))
  1703.     val = force_operand (val, 0);
  1704.  
  1705.       argvec[count].value = val;
  1706.       argvec[count].mode = mode;
  1707.  
  1708. #ifdef FUNCTION_ARG_PASS_BY_REFERENCE
  1709.       if (FUNCTION_ARG_PASS_BY_REFERENCE (args_so_far, mode, (tree)0, 1))
  1710.     abort ();
  1711. #endif
  1712.  
  1713.       argvec[count].reg = FUNCTION_ARG (args_so_far, mode, (tree)0, 1);
  1714.       if (argvec[count].reg && GET_CODE (argvec[count].reg) == EXPR_LIST)
  1715.     abort ();
  1716. #ifdef FUNCTION_ARG_PARTIAL_NREGS
  1717.       argvec[count].partial
  1718.     = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, mode, (tree)0, 1);
  1719. #else
  1720.       argvec[count].partial = 0;
  1721. #endif
  1722.  
  1723.       locate_and_pad_parm (mode, 0,
  1724.                argvec[count].reg && argvec[count].partial == 0,
  1725.                0, &args_size, &argvec[count].offset,
  1726.                &argvec[count].size);
  1727.  
  1728.       if (argvec[count].size.var)
  1729.     abort ();
  1730.  
  1731. #ifndef REG_PARM_STACK_SPACE
  1732.       if (argvec[count].partial)
  1733.     argvec[count].size.constant -= argvec[count].partial * UNITS_PER_WORD;
  1734. #endif
  1735.  
  1736.       if (argvec[count].reg == 0 || argvec[count].partial != 0
  1737. #ifdef REG_PARM_STACK_SPACE
  1738.       || 1
  1739. #endif
  1740.       )
  1741.     args_size.constant += argvec[count].size.constant;
  1742.  
  1743. #ifdef ACCUMULATE_OUTGOING_ARGS
  1744.       /* If this arg is actually passed on the stack, it might be
  1745.      clobbering something we already put there (this library call might
  1746.      be inside the evaluation of an argument to a function whose call
  1747.      requires the stack).  This will only occur when the library call
  1748.      has sufficient args to run out of argument registers.  Abort in
  1749.      this case; if this ever occurs, code must be added to save and
  1750.      restore the arg slot.  */
  1751.  
  1752.       if (argvec[count].reg == 0 || argvec[count].partial != 0)
  1753.     abort ();
  1754. #endif
  1755.  
  1756.       FUNCTION_ARG_ADVANCE (args_so_far, mode, (tree)0, 1);
  1757.     }
  1758.   va_end (p);
  1759.  
  1760.   /* If this machine requires an external definition for library
  1761.      functions, write one out.  */
  1762.   assemble_external_libcall (fun);
  1763.  
  1764. #ifdef STACK_BOUNDARY
  1765.   args_size.constant = (((args_size.constant + (STACK_BYTES - 1))
  1766.              / STACK_BYTES) * STACK_BYTES);
  1767. #endif
  1768.  
  1769. #ifdef REG_PARM_STACK_SPACE
  1770.   args_size.constant = MAX (args_size.constant,
  1771.                 REG_PARM_STACK_SPACE ((tree) 0));
  1772. #endif
  1773.  
  1774. #ifdef ACCUMULATE_OUTGOING_ARGS
  1775.   if (args_size.constant > current_function_outgoing_args_size)
  1776.     current_function_outgoing_args_size = args_size.constant;
  1777.   args_size.constant = 0;
  1778. #endif
  1779.  
  1780. #ifndef PUSH_ROUNDING
  1781.   argblock = push_block (gen_rtx (CONST_INT, VOIDmode, args_size.constant),
  1782.              0, 0);
  1783. #endif
  1784.  
  1785. #ifdef PUSH_ARGS_REVERSED
  1786.   inc = -1;
  1787.   argnum = nargs - 1;
  1788. #else
  1789.   inc = 1;
  1790.   argnum = 0;
  1791. #endif
  1792.  
  1793.   /* Push the args that need to be pushed.  */
  1794.  
  1795.   for (count = 0; count < nargs; count++, argnum += inc)
  1796.     {
  1797.       register enum machine_mode mode = argvec[argnum].mode;
  1798.       register rtx val = argvec[argnum].value;
  1799.       rtx reg = argvec[argnum].reg;
  1800.       int partial = argvec[argnum].partial;
  1801.  
  1802.       if (! (reg != 0 && partial == 0))
  1803.     emit_push_insn (val, mode, 0, 0, 0, partial, reg, 0, argblock,
  1804.             gen_rtx (CONST_INT, VOIDmode,
  1805.                  argvec[count].offset.constant));
  1806.       NO_DEFER_POP;
  1807.     }
  1808.  
  1809. #ifdef PUSH_ARGS_REVERSED
  1810.   argnum = nargs - 1;
  1811. #else
  1812.   argnum = 0;
  1813. #endif
  1814.  
  1815.   /* Now load any reg parms into their regs.  */
  1816.  
  1817.   for (count = 0; count < nargs; count++, argnum += inc)
  1818.     {
  1819.       register enum machine_mode mode = argvec[argnum].mode;
  1820.       register rtx val = argvec[argnum].value;
  1821.       rtx reg = argvec[argnum].reg;
  1822.       int partial = argvec[argnum].partial;
  1823.  
  1824.       if (reg != 0 && partial == 0)
  1825.     emit_move_insn (reg, val);
  1826.       NO_DEFER_POP;
  1827.     }
  1828.  
  1829.   /* For version 1.37, try deleting this entirely.  */
  1830.   if (! no_queue)
  1831.     emit_queue ();
  1832.  
  1833.   /* Any regs containing parms remain in use through the call.  */
  1834.   start_sequence ();
  1835.   for (count = 0; count < nargs; count++)
  1836.     if (argvec[count].reg != 0)
  1837.       emit_insn (gen_rtx (USE, VOIDmode, argvec[count].reg));
  1838.  
  1839.   use_insns = get_insns ();
  1840.   end_sequence ();
  1841.  
  1842.   fun = prepare_call_address (fun, 0, use_insns);
  1843.  
  1844.   /* Don't allow popping to be deferred, since then
  1845.      cse'ing of library calls could delete a call and leave the pop.  */
  1846.   NO_DEFER_POP;
  1847.  
  1848.   /* We pass the old value of inhibit_defer_pop + 1 to emit_call_1, which
  1849.      will set inhibit_defer_pop to that value.  */
  1850.  
  1851.   emit_call_1 (fun, get_identifier (XSTR (orgfun, 0)), args_size.constant,
  1852.            FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1),
  1853.            outmode != VOIDmode ? hard_libcall_value (outmode) : 0,
  1854.            old_inhibit_defer_pop + 1, use_insns);
  1855.  
  1856.   /* Now restore inhibit_defer_pop to its actual original value.  */
  1857.   OK_DEFER_POP;
  1858. }
  1859.  
  1860. /* Expand an assignment that stores the value of FROM into TO.
  1861.    If WANT_VALUE is nonzero, return an rtx for the value of TO.
  1862.    (This may contain a QUEUED rtx.)
  1863.    Otherwise, the returned value is not meaningful.
  1864.  
  1865.    SUGGEST_REG is no longer actually used.
  1866.    It used to mean, copy the value through a register
  1867.    and return that register, if that is possible.
  1868.    But now we do this if WANT_VALUE.
  1869.  
  1870.    If the value stored is a constant, we return the constant.  */
  1871.  
  1872. rtx
  1873. expand_assignment (to, from, want_value, suggest_reg)
  1874.      tree to, from;
  1875.      int want_value;
  1876.      int suggest_reg;
  1877. {
  1878.   register rtx to_rtx = 0;
  1879.   rtx result;
  1880.  
  1881.   /* Don't crash if the lhs of the assignment was erroneous.  */
  1882.  
  1883.   if (TREE_CODE (to) == ERROR_MARK)
  1884.     return expand_expr (from, 0, VOIDmode, 0);
  1885.  
  1886.   /* Assignment of a structure component needs special treatment
  1887.      if the structure component's rtx is not simply a MEM.
  1888.      Assignment of an array element at a constant index
  1889.      has the same problem.  */
  1890.  
  1891.   if (TREE_CODE (to) == COMPONENT_REF
  1892.       || TREE_CODE (to) == BIT_FIELD_REF
  1893.       || (TREE_CODE (to) == ARRAY_REF
  1894.       && TREE_CODE (TREE_OPERAND (to, 1)) == INTEGER_CST
  1895.       && TREE_CODE (TYPE_SIZE (TREE_TYPE (to))) == INTEGER_CST))
  1896.     {
  1897.       enum machine_mode mode1;
  1898.       int bitsize;
  1899.       int bitpos;
  1900.       int unsignedp;
  1901.       int volatilep = 0;
  1902.       tree tem = get_inner_reference (to, &bitsize, &bitpos,
  1903.                       &mode1, &unsignedp, &volatilep);
  1904.  
  1905.       /* If we are going to use store_bit_field and extract_bit_field,
  1906.      make sure to_rtx will be safe for multiple use.  */
  1907.  
  1908.       if (mode1 == VOIDmode && want_value)
  1909.     tem = stabilize_reference (tem);
  1910.  
  1911.       to_rtx = expand_expr (tem, 0, VOIDmode, 0);
  1912.       if (volatilep)
  1913.     {
  1914.       if (GET_CODE (to_rtx) == MEM)
  1915.         MEM_VOLATILE_P (to_rtx) = 1;
  1916.       else
  1917.         abort ();
  1918.     }
  1919.  
  1920.       result = store_field (to_rtx, bitsize, bitpos, mode1, from,
  1921.                 (want_value
  1922.                  /* Spurious cast makes HPUX compiler happy.  */
  1923.                  ? (enum machine_mode) TYPE_MODE (TREE_TYPE (to))
  1924.                  : VOIDmode),
  1925.                 unsignedp,
  1926.                 /* Required alignment of containing datum.  */
  1927.                 TYPE_ALIGN (TREE_TYPE (tem)) / BITS_PER_UNIT,
  1928.                 int_size_in_bytes (TREE_TYPE (tem)));
  1929.       preserve_temp_slots (result);
  1930.       free_temp_slots ();
  1931.  
  1932.       return result;
  1933.     }
  1934.  
  1935.   /* Ordinary treatment.  Expand TO to get a REG or MEM rtx.
  1936.      Don't re-expand if it was expanded already (in COMPONENT_REF case).  */
  1937.  
  1938.   if (to_rtx == 0)
  1939.     to_rtx = expand_expr (to, 0, VOIDmode, 0);
  1940.  
  1941.   /* In case we are returning the contents of an object which overlaps
  1942.      the place the value is being stored, use a safe function when copying
  1943.      a value through a pointer into a structure value return block.  */
  1944.   if (TREE_CODE (to) == RESULT_DECL && TREE_CODE (from) == INDIRECT_REF
  1945.       && current_function_returns_struct
  1946.       && !current_function_returns_pcc_struct)
  1947.     {
  1948.       rtx from_rtx = expand_expr (from, 0, VOIDmode, 0);
  1949.       rtx size = expr_size (from);
  1950.  
  1951. #ifdef TARGET_MEM_FUNCTIONS
  1952.       emit_library_call (memcpy_libfunc, 0,
  1953.              VOIDmode, 3, XEXP (to_rtx, 0), Pmode,
  1954.              XEXP (from_rtx, 0), Pmode,
  1955.              size, Pmode);
  1956. #else
  1957.       emit_library_call (bcopy_libfunc, 0,
  1958.              VOIDmode, 3, XEXP (from_rtx, 0), Pmode,
  1959.              XEXP (to_rtx, 0), Pmode,
  1960.              size, Pmode);
  1961. #endif
  1962.  
  1963.       preserve_temp_slots (to_rtx);
  1964.       free_temp_slots ();
  1965.       return to_rtx;
  1966.     }
  1967.  
  1968.   /* Compute FROM and store the value in the rtx we got.  */
  1969.  
  1970.   result = store_expr (from, to_rtx, want_value);
  1971.   preserve_temp_slots (result);
  1972.   free_temp_slots ();
  1973.   return result;
  1974. }
  1975.  
  1976. /* Generate code for computing expression EXP,
  1977.    and storing the value into TARGET.
  1978.    Returns TARGET or an equivalent value.
  1979.    TARGET may contain a QUEUED rtx.
  1980.  
  1981.    If SUGGEST_REG is nonzero, copy the value through a register
  1982.    and return that register, if that is possible.
  1983.  
  1984.    If the value stored is a constant, we return the constant.  */
  1985.  
  1986. rtx
  1987. store_expr (exp, target, suggest_reg)
  1988.      register tree exp;
  1989.      register rtx target;
  1990.      int suggest_reg;
  1991. {
  1992.   register rtx temp;
  1993.   int dont_return_target = 0;
  1994.  
  1995.   if (TREE_CODE (exp) == COMPOUND_EXPR)
  1996.     {
  1997.       /* Perform first part of compound expression, then assign from second
  1998.      part.  */
  1999.       expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0);
  2000.       emit_queue ();
  2001.       return store_expr (TREE_OPERAND (exp, 1), target, suggest_reg);
  2002.     }
  2003.   else if (TREE_CODE (exp) == COND_EXPR && GET_MODE (target) == BLKmode)
  2004.     {
  2005.       /* For conditional expression, get safe form of the target.  Then
  2006.      test the condition, doing the appropriate assignment on either
  2007.      side.  This avoids the creation of unnecessary temporaries.
  2008.      For non-BLKmode, it is more efficient not to do this.  */
  2009.  
  2010.       rtx lab1 = gen_label_rtx (), lab2 = gen_label_rtx ();
  2011.  
  2012.       emit_queue ();
  2013.       target = protect_from_queue (target, 1);
  2014.  
  2015.       NO_DEFER_POP;
  2016.       jumpifnot (TREE_OPERAND (exp, 0), lab1);
  2017.       store_expr (TREE_OPERAND (exp, 1), target, suggest_reg);
  2018.       emit_queue ();
  2019.       emit_jump_insn (gen_jump (lab2));
  2020.       emit_barrier ();
  2021.       emit_label (lab1);
  2022.       store_expr (TREE_OPERAND (exp, 2), target, suggest_reg);
  2023.       emit_queue ();
  2024.       emit_label (lab2);
  2025.       OK_DEFER_POP;
  2026.       return target;
  2027.     }
  2028.   else if (suggest_reg && GET_CODE (target) == MEM
  2029.        && GET_MODE (target) != BLKmode)
  2030.     /* If target is in memory and caller wants value in a register instead,
  2031.        arrange that.  Pass TARGET as target for expand_expr so that,
  2032.        if EXP is another assignment, SUGGEST_REG will be nonzero for it.
  2033.        We know expand_expr will not use the target in that case.  */
  2034.     {
  2035.       temp = expand_expr (exp, cse_not_expected ? 0 : target,
  2036.               GET_MODE (target), 0);
  2037.       if (GET_MODE (temp) != BLKmode && GET_MODE (temp) != VOIDmode)
  2038.     temp = copy_to_reg (temp);
  2039.       dont_return_target = 1;
  2040.     }
  2041.   else if (queued_subexp_p (target))
  2042.     /* If target contains a postincrement, it is not safe
  2043.        to use as the returned value.  It would access the wrong
  2044.        place by the time the queued increment gets output.
  2045.        So copy the value through a temporary and use that temp
  2046.        as the result.  */
  2047.     {
  2048.       if (GET_MODE (target) != BLKmode && GET_MODE (target) != VOIDmode)
  2049.     {
  2050.       /* Expand EXP into a new pseudo.  */
  2051.       temp = gen_reg_rtx (GET_MODE (target));
  2052.       temp = expand_expr (exp, temp, GET_MODE (target), 0);
  2053.     }
  2054.       else
  2055.     temp = expand_expr (exp, 0, GET_MODE (target), 0);
  2056.       dont_return_target = 1;
  2057.     }
  2058.   else
  2059.     {
  2060.       temp = expand_expr (exp, target, GET_MODE (target), 0);
  2061.       /* DO return TARGET if it's a specified hardware register.
  2062.      expand_return relies on this.  */
  2063.       if (!(target && GET_CODE (target) == REG
  2064.         && REGNO (target) < FIRST_PSEUDO_REGISTER)
  2065.       && CONSTANT_P (temp))
  2066.     dont_return_target = 1;
  2067.     }
  2068.  
  2069.   /* If value was not generated in the target, store it there.
  2070.      Convert the value to TARGET's type first if nec.  */
  2071.  
  2072.   if (temp != target && TREE_CODE (exp) != ERROR_MARK)
  2073.     {
  2074.       target = protect_from_queue (target, 1);
  2075.       if (GET_MODE (temp) != GET_MODE (target)
  2076.       && GET_MODE (temp) != VOIDmode)
  2077.     {
  2078.       int unsignedp = TREE_UNSIGNED (TREE_TYPE (exp));
  2079.       if (dont_return_target)
  2080.         {
  2081.           /* In this case, we will return TEMP,
  2082.          so make sure it has the proper mode.
  2083.          But don't forget to store the value into TARGET.  */
  2084.           temp = convert_to_mode (GET_MODE (target), temp, unsignedp);
  2085.           emit_move_insn (target, temp);
  2086.         }
  2087.       else
  2088.         convert_move (target, temp, unsignedp);
  2089.     }
  2090.  
  2091.       else if (GET_MODE (temp) == BLKmode)
  2092.     emit_block_move (target, temp, expr_size (exp),
  2093.              TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
  2094.       else
  2095.     emit_move_insn (target, temp);
  2096.     }
  2097.   if (dont_return_target)
  2098.     return temp;
  2099.   return target;
  2100. }
  2101.  
  2102. /* Store the value of constructor EXP into the rtx TARGET.
  2103.    TARGET is either a REG or a MEM.  */
  2104.  
  2105. static void
  2106. store_constructor (exp, target)
  2107.      tree exp;
  2108.      rtx target;
  2109. {
  2110.   /* We know our target cannot conflict, since safe_from_p has been called.  */
  2111. #if 0
  2112.   /* Don't try copying piece by piece into a hard register
  2113.      since that is vulnerable to being clobbered by EXP.
  2114.      Instead, construct in a pseudo register and then copy it all.  */
  2115.   if (GET_CODE (target) == REG && REGNO (target) < FIRST_PSEUDO_REGISTER)
  2116.     {
  2117.       rtx temp = gen_reg_rtx (GET_MODE (target));
  2118.       store_constructor (exp, temp);
  2119.       emit_move_insn (target, temp);
  2120.       return;
  2121.     }
  2122. #endif
  2123.  
  2124.   if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE
  2125.       || TREE_CODE (TREE_TYPE (exp)) == UNION_TYPE)
  2126.     {
  2127.       register tree elt;
  2128.  
  2129.       if (TREE_CODE (TREE_TYPE (exp)) == UNION_TYPE)
  2130.     /* Inform later passes that the whole union value is dead.  */
  2131.     emit_insn (gen_rtx (CLOBBER, VOIDmode, target));
  2132.       /* If the constructor has fewer fields than the structure,
  2133.      clear the whole structure first.  */
  2134.       else if (list_length (CONSTRUCTOR_ELTS (exp))
  2135.            != list_length (TYPE_FIELDS (TREE_TYPE (exp))))
  2136.     clear_storage (target, int_size_in_bytes (TREE_TYPE (exp)));
  2137.       else
  2138.     /* Inform later passes that the old value is dead.  */
  2139.     emit_insn (gen_rtx (CLOBBER, VOIDmode, target));
  2140.  
  2141.       /* Store each element of the constructor into
  2142.      the corresponding field of TARGET.  */
  2143.  
  2144.       for (elt = CONSTRUCTOR_ELTS (exp); elt; elt = TREE_CHAIN (elt))
  2145.     {
  2146.       register tree field = TREE_PURPOSE (elt);
  2147.       register enum machine_mode mode;
  2148.       int bitsize;
  2149.       int bitpos;
  2150.       int unsignedp;
  2151.  
  2152.       bitsize = TREE_INT_CST_LOW (DECL_SIZE (field));
  2153.       unsignedp = TREE_UNSIGNED (field);
  2154.       mode = DECL_MODE (field);
  2155.       if (DECL_BIT_FIELD (field))
  2156.         mode = VOIDmode;
  2157.  
  2158.       if (TREE_CODE (DECL_FIELD_BITPOS (field)) != INTEGER_CST)
  2159.         /* ??? This case remains to be written.  */
  2160.         abort ();
  2161.  
  2162.       bitpos = TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field));
  2163.  
  2164.       store_field (target, bitsize, bitpos, mode, TREE_VALUE (elt),
  2165.                /* The alignment of TARGET is
  2166.               at least what its type requires.  */
  2167.                VOIDmode, 0,
  2168.                TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT,
  2169.                int_size_in_bytes (TREE_TYPE (exp)));
  2170.     }
  2171.     }
  2172.   else if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
  2173.     {
  2174.       register tree elt;
  2175.       register int i;
  2176.       tree domain = TYPE_DOMAIN (TREE_TYPE (exp));
  2177.       int minelt = TREE_INT_CST_LOW (TYPE_MIN_VALUE (domain));
  2178.       int maxelt = TREE_INT_CST_LOW (TYPE_MAX_VALUE (domain));
  2179.       tree elttype = TREE_TYPE (TREE_TYPE (exp));
  2180.  
  2181.       /* If the constructor has fewer fields than the structure,
  2182.      clear the whole structure first.  */
  2183.  
  2184.       if (list_length (CONSTRUCTOR_ELTS (exp)) < maxelt - minelt + 1)
  2185.     clear_storage (target, maxelt - minelt + 1);
  2186.       else
  2187.     /* Inform later passes that the old value is dead.  */
  2188.     emit_insn (gen_rtx (CLOBBER, VOIDmode, target));
  2189.  
  2190.       /* Store each element of the constructor into
  2191.      the corresponding element of TARGET, determined
  2192.      by counting the elements.  */
  2193.       for (elt = CONSTRUCTOR_ELTS (exp), i = 0;
  2194.        elt;
  2195.        elt = TREE_CHAIN (elt), i++)
  2196.     {
  2197.       register enum machine_mode mode;
  2198.       int bitsize;
  2199.       int bitpos;
  2200.       int unsignedp;
  2201.  
  2202.       mode = TYPE_MODE (elttype);
  2203.       bitsize = GET_MODE_BITSIZE (mode);
  2204.       unsignedp = TREE_UNSIGNED (elttype);
  2205.  
  2206.       bitpos = (i * TREE_INT_CST_LOW (TYPE_SIZE (elttype)));
  2207.  
  2208.       store_field (target, bitsize, bitpos, mode, TREE_VALUE (elt),
  2209.                /* The alignment of TARGET is
  2210.               at least what its type requires.  */
  2211.                VOIDmode, 0,
  2212.                TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT,
  2213.                int_size_in_bytes (TREE_TYPE (exp)));
  2214.     }
  2215.     }
  2216.  
  2217.   else
  2218.     abort ();
  2219. }
  2220.  
  2221. /* Store the value of EXP (an expression tree)
  2222.    into a subfield of TARGET which has mode MODE and occupies
  2223.    BITSIZE bits, starting BITPOS bits from the start of TARGET.
  2224.    If MODE is VOIDmode, it means that we are storing into a bit-field.
  2225.  
  2226.    If VALUE_MODE is VOIDmode, return nothing in particular.
  2227.    UNSIGNEDP is not used in this case.
  2228.  
  2229.    Otherwise, return an rtx for the value stored.  This rtx
  2230.    has mode VALUE_MODE if that is convenient to do.
  2231.    In this case, UNSIGNEDP must be nonzero if the value is an unsigned type.
  2232.  
  2233.    ALIGN is the alignment that TARGET is known to have, measured in bytes.
  2234.    TOTAL_SIZE is the size in bytes of the structure, or -1 if varying.  */
  2235.  
  2236. static rtx
  2237. store_field (target, bitsize, bitpos, mode, exp, value_mode,
  2238.          unsignedp, align, total_size)
  2239.      rtx target;
  2240.      int bitsize, bitpos;
  2241.      enum machine_mode mode;
  2242.      tree exp;
  2243.      enum machine_mode value_mode;
  2244.      int unsignedp;
  2245.      int align;
  2246.      int total_size;
  2247. {
  2248.   int width_mask = 0;
  2249.  
  2250.   if (bitsize < HOST_BITS_PER_INT)
  2251.     width_mask = (1 << bitsize) - 1;
  2252.  
  2253.   /* If the structure is in a register or if the component
  2254.      is a bit field, we cannot use addressing to access it.
  2255.      Use bit-field techniques or SUBREG to store in it.  */
  2256.  
  2257.   if (mode == VOIDmode || GET_CODE (target) == REG
  2258.       || GET_CODE (target) == SUBREG)
  2259.     {
  2260.       rtx temp = expand_expr (exp, 0, VOIDmode, 0);
  2261.       /* Store the value in the bitfield.  */
  2262.       store_bit_field (target, bitsize, bitpos, mode, temp, align, total_size);
  2263.       if (value_mode != VOIDmode)
  2264.     {
  2265.       /* The caller wants an rtx for the value.  */
  2266.       /* If possible, avoid refetching from the bitfield itself.  */
  2267.       if (width_mask != 0
  2268.           && ! (GET_CODE (target) == MEM && MEM_VOLATILE_P (target)))
  2269.         return expand_and (temp,
  2270.                    gen_rtx (CONST_INT, VOIDmode, width_mask), 0);
  2271.       return extract_bit_field (target, bitsize, bitpos, unsignedp,
  2272.                     0, value_mode, 0, align, total_size);
  2273.     }
  2274.       return const0_rtx;
  2275.     }
  2276.   else
  2277.     {
  2278.       rtx addr = XEXP (target, 0);
  2279.       rtx to_rtx;
  2280.  
  2281.       /* If a value is wanted, it must be the lhs;
  2282.      so make the address stable for multiple use.  */
  2283.  
  2284.       if (value_mode != VOIDmode && GET_CODE (addr) != REG
  2285.       && ! CONSTANT_ADDRESS_P (addr)
  2286.       /* A frame-pointer reference is already stable.  */
  2287.       && ! (GET_CODE (addr) == PLUS
  2288.         && GET_CODE (XEXP (addr, 1)) == CONST_INT
  2289.         && (XEXP (addr, 0) == virtual_incoming_args_rtx
  2290.             || XEXP (addr, 0) == virtual_stack_vars_rtx)))
  2291.     addr = copy_to_reg (addr);
  2292.  
  2293.       /* Now build a reference to just the desired component.  */
  2294.  
  2295.       to_rtx = change_address (target, mode,
  2296.                    plus_constant (addr, (bitpos / BITS_PER_UNIT)));
  2297.       MEM_IN_STRUCT_P (to_rtx) = 1;
  2298.  
  2299.       return store_expr (exp, to_rtx, value_mode != VOIDmode);
  2300.     }
  2301. }
  2302.  
  2303. /* Given an expression EXP that may be a COMPONENT_REF, a BIT_FIELD_REF,
  2304.    or an ARRAY_REF, look for nested COMPONENT_REFs, BIT_FIELD_REFs, or
  2305.    ARRAY_REFs at constant positions and find the ultimate containing object,
  2306.    which we return.
  2307.  
  2308.    We set *PBITSIZE to the size in bits that we want, *PBITPOS to the
  2309.    bit position, and *PUNSIGNEDP to the signedness of the field.
  2310.  
  2311.    If any of the extraction expressions is volatile,
  2312.    we store 1 in *PVOLATILEP.  Otherwise we don't change that.
  2313.  
  2314.    If the field is a bit-field, *PMODE is set to VOIDmode.  Otherwise, it
  2315.    is a mode that can be used to access the field.  In that case, *PBITSIZE
  2316.    is redundant.  */
  2317.  
  2318. tree
  2319. get_inner_reference (exp, pbitsize, pbitpos, pmode, punsignedp, pvolatilep)
  2320.      tree exp;
  2321.      int *pbitsize;
  2322.      int *pbitpos;
  2323.      enum machine_mode *pmode;
  2324.      int *punsignedp;
  2325.      int *pvolatilep;
  2326. {
  2327.   tree size_tree = 0;
  2328.   enum machine_mode mode = VOIDmode;
  2329.  
  2330.   if (TREE_CODE (exp) == COMPONENT_REF)
  2331.     {
  2332.       size_tree = DECL_SIZE (TREE_OPERAND (exp, 1));
  2333.       if (! DECL_BIT_FIELD (TREE_OPERAND (exp, 1)))
  2334.     mode = DECL_MODE (TREE_OPERAND (exp, 1));
  2335.       *punsignedp = TREE_UNSIGNED (TREE_OPERAND (exp, 1));
  2336.     }
  2337.   else if (TREE_CODE (exp) == BIT_FIELD_REF)
  2338.     {
  2339.       size_tree = TREE_OPERAND (exp, 1);
  2340.       *punsignedp = TREE_UNSIGNED (exp);
  2341.     }
  2342.   else
  2343.     {
  2344.       mode = TYPE_MODE (TREE_TYPE (exp));
  2345.       *pbitsize = GET_MODE_BITSIZE (mode);
  2346.       *punsignedp = TREE_UNSIGNED (TREE_TYPE (exp));
  2347.     }
  2348.       
  2349.   if (size_tree)
  2350.     {
  2351.       if (TREE_CODE (size_tree) != INTEGER_CST)
  2352.     abort ();
  2353.  
  2354.       *pbitsize = TREE_INT_CST_LOW (size_tree);
  2355.     }
  2356.  
  2357.   /* Compute cumulative bit-offset for nested component-refs and array-refs,
  2358.      and find the ultimate containing object.  */
  2359.  
  2360.   *pbitpos = 0;
  2361.  
  2362.   while (1)
  2363.     {
  2364.       if (TREE_CODE (exp) == COMPONENT_REF)
  2365.     {
  2366.       tree field = TREE_OPERAND (exp, 1);
  2367.  
  2368.       if (TREE_CODE (DECL_FIELD_BITPOS (field)) != INTEGER_CST)
  2369.         /* ??? This case remains to be written.  */
  2370.         abort ();
  2371.  
  2372.       *pbitpos += TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field));
  2373.       if (TREE_THIS_VOLATILE (exp))
  2374.         *pvolatilep = 1;
  2375.     }
  2376.       else if (TREE_CODE (exp) == BIT_FIELD_REF)
  2377.     {
  2378.       if (TREE_CODE (TREE_OPERAND (exp, 2)) != INTEGER_CST)
  2379.         /* ??? This case remains to be written.  */
  2380.         abort ();
  2381.  
  2382.       *pbitpos += TREE_INT_CST_LOW (TREE_OPERAND (exp, 2));
  2383.       if (TREE_THIS_VOLATILE (exp))
  2384.         *pvolatilep = 1;
  2385.     }
  2386.       else if (TREE_CODE (exp) == ARRAY_REF
  2387.            && TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST
  2388.            && TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) == INTEGER_CST)
  2389.     {
  2390.       *pbitpos += (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1))
  2391.                * TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (exp))));
  2392.       if (TREE_THIS_VOLATILE (exp))
  2393.         *pvolatilep = 1;
  2394.     }
  2395.       else if (TREE_CODE (exp) != NON_LVALUE_EXPR
  2396.            && ! ((TREE_CODE (exp) == NOP_EXPR
  2397.               || TREE_CODE (exp) == CONVERT_EXPR)
  2398.              && (TYPE_MODE (TREE_TYPE (exp))
  2399.              == TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))))
  2400.     break;
  2401.       exp = TREE_OPERAND (exp, 0);
  2402.     }
  2403.  
  2404.   /* If this was a bit-field, see if there is a mode that allows direct
  2405.      access in case EXP is in memory.  */
  2406.   if (mode == VOIDmode && *pbitpos % *pbitsize == 0)
  2407.     for (mode = QImode; mode != VOIDmode; mode = GET_MODE_WIDER_MODE (mode))
  2408.       if (GET_MODE_BITSIZE (mode) == *pbitsize)
  2409.     break;
  2410.  
  2411.   *pmode = mode;
  2412.  
  2413.   return exp;
  2414. }
  2415.  
  2416. /* Given an rtx VALUE that may contain additions and multiplications,
  2417.    return an equivalent value that just refers to a register or memory.
  2418.    This is done by generating instructions to perform the arithmetic
  2419.    and returning a pseudo-register containing the value.  */
  2420.  
  2421. rtx
  2422. force_operand (value, target)
  2423.      rtx value, target;
  2424. {
  2425.   register optab binoptab = 0;
  2426.   /* Use a temporary to force order of execution of calls to
  2427.      `force_operand'.  */
  2428.   rtx tmp;
  2429.   register rtx op2;
  2430.   /* Use subtarget as the target for operand 0 of a binary operation.  */
  2431.   register rtx subtarget = (target != 0 && GET_CODE (target) == REG ? target : 0);
  2432.  
  2433.   if (GET_CODE (value) == PLUS)
  2434.     binoptab = add_optab;
  2435.   else if (GET_CODE (value) == MINUS)
  2436.     binoptab = sub_optab;
  2437.   else if (GET_CODE (value) == MULT)
  2438.     {
  2439.       op2 = XEXP (value, 1);
  2440.       if (!CONSTANT_P (op2)
  2441.       && !(GET_CODE (op2) == REG && op2 != subtarget))
  2442.     subtarget = 0;
  2443.       tmp = force_operand (XEXP (value, 0), subtarget);
  2444.       return expand_mult (GET_MODE (value), tmp,
  2445.               force_operand (op2, 0),
  2446.               target, 0);
  2447.     }
  2448.  
  2449.   if (binoptab)
  2450.     {
  2451.       op2 = XEXP (value, 1);
  2452.       if (!CONSTANT_P (op2)
  2453.       && !(GET_CODE (op2) == REG && op2 != subtarget))
  2454.     subtarget = 0;
  2455.       if (binoptab == sub_optab && GET_CODE (op2) == CONST_INT)
  2456.     {
  2457.       binoptab = add_optab;
  2458.       op2 = negate_rtx (GET_MODE (value), op2);
  2459.     }
  2460.  
  2461.       /* Check for an addition with OP2 a constant integer and our first
  2462.      operand a PLUS of a virtual register and something else.  In that
  2463.      case, we want to emit the sum of the virtual register and the
  2464.      constant first and then add the other value.  This allows virtual
  2465.      register instantiation to simply modify the constant rather than
  2466.      creating another one around this addition.  */
  2467.       if (binoptab == add_optab && GET_CODE (op2) == CONST_INT
  2468.       && GET_CODE (XEXP (value, 0)) == PLUS
  2469.       && GET_CODE (XEXP (XEXP (value, 0), 0)) == REG
  2470.       && REGNO (XEXP (XEXP (value, 0), 0)) >= FIRST_VIRTUAL_REGISTER
  2471.       && REGNO (XEXP (XEXP (value, 0), 0)) <= LAST_VIRTUAL_REGISTER)
  2472.     {
  2473.       rtx temp = expand_binop (GET_MODE (value), binoptab,
  2474.                    XEXP (XEXP (value, 0), 0), op2,
  2475.                    subtarget, 0, OPTAB_LIB_WIDEN);
  2476.       return expand_binop (GET_MODE (value), binoptab, temp,
  2477.                    force_operand (XEXP (XEXP (value, 0), 1), 0),
  2478.                    target, 0, OPTAB_LIB_WIDEN);
  2479.     }
  2480.                    
  2481.       tmp = force_operand (XEXP (value, 0), subtarget);
  2482.       return expand_binop (GET_MODE (value), binoptab, tmp,
  2483.                force_operand (op2, 0),
  2484.                target, 0, OPTAB_LIB_WIDEN);
  2485.       /* We give UNSIGNEP = 0 to expand_binop
  2486.      because the only operations we are expanding here are signed ones.  */
  2487.     }
  2488.   return value;
  2489. }
  2490.  
  2491. /* Subroutine of expand_expr:
  2492.    save the non-copied parts (LIST) of an expr (LHS), and return a list
  2493.    which can restore these values to their previous values,
  2494.    should something modify their storage.  */
  2495.  
  2496. static tree
  2497. save_noncopied_parts (lhs, list)
  2498.      tree lhs;
  2499.      tree list;
  2500. {
  2501.   tree tail;
  2502.   tree parts = 0;
  2503.  
  2504.   for (tail = list; tail; tail = TREE_CHAIN (tail))
  2505.     if (TREE_CODE (TREE_VALUE (tail)) == TREE_LIST)
  2506.       parts = chainon (parts, save_noncopied_parts (lhs, TREE_VALUE (tail)));
  2507.     else
  2508.       {
  2509.     tree part = TREE_VALUE (tail);
  2510.     tree part_type = TREE_TYPE (part);
  2511.     tree to_be_saved = build (COMPONENT_REF, part_type, lhs, part, 0);
  2512.     rtx target = assign_stack_temp (TYPE_MODE (part_type),
  2513.                     int_size_in_bytes (part_type), 0);
  2514.     if (! memory_address_p (TYPE_MODE (part_type), XEXP (target, 0)))
  2515.       target = change_address (target, TYPE_MODE (part_type), 0);
  2516.     parts = tree_cons (to_be_saved,
  2517.                build (RTL_EXPR, part_type, 0, (tree) target),
  2518.                parts);
  2519.     store_expr (TREE_PURPOSE (parts), RTL_EXPR_RTL (TREE_VALUE (parts)), 0);
  2520.       }
  2521.   return parts;
  2522. }
  2523.  
  2524. /* Subroutine of expand_expr:
  2525.    record the non-copied parts (LIST) of an expr (LHS), and return a list
  2526.    which specifies the initial values of these parts.  */
  2527.  
  2528. static tree
  2529. init_noncopied_parts (lhs, list)
  2530.      tree lhs;
  2531.      tree list;
  2532. {
  2533.   tree tail;
  2534.   tree parts = 0;
  2535.  
  2536.   for (tail = list; tail; tail = TREE_CHAIN (tail))
  2537.     if (TREE_CODE (TREE_VALUE (tail)) == TREE_LIST)
  2538.       parts = chainon (parts, init_noncopied_parts (lhs, TREE_VALUE (tail)));
  2539.     else
  2540.       {
  2541.     tree part = TREE_VALUE (tail);
  2542.     tree part_type = TREE_TYPE (part);
  2543.     tree to_be_initialized = build (COMPONENT_REF, part_type, lhs, part, 0);
  2544.     parts = tree_cons (TREE_PURPOSE (tail), to_be_initialized, parts);
  2545.       }
  2546.   return parts;
  2547. }
  2548.  
  2549. /* Subroutine of expand_expr: return nonzero iff there is no way that
  2550.    EXP can reference X, which is being modified.  */
  2551.  
  2552. static int
  2553. safe_from_p (x, exp)
  2554.      rtx x;
  2555.      tree exp;
  2556. {
  2557.   rtx exp_rtl = 0;
  2558.   int i, nops;
  2559.  
  2560.   if (x == 0)
  2561.     return 1;
  2562.  
  2563.   /* If this is a subreg of a hard register, declare it unsafe, otherwise,
  2564.      find the underlying pseudo.  */
  2565.   if (GET_CODE (x) == SUBREG)
  2566.     {
  2567.       x = SUBREG_REG (x);
  2568.       if (GET_CODE (x) == REG && REGNO (x) < FIRST_PSEUDO_REGISTER)
  2569.     return 0;
  2570.     }
  2571.  
  2572.   /* If X is a location in the outgoing argument area, it is always safe.  */
  2573.   if (GET_CODE (x) == MEM
  2574.       && (XEXP (x, 0) == virtual_outgoing_args_rtx
  2575.       || (GET_CODE (XEXP (x, 0)) == PLUS
  2576.           && XEXP (XEXP (x, 0), 0) == virtual_outgoing_args_rtx)))
  2577.     return 1;
  2578.  
  2579.   switch (TREE_CODE_CLASS (TREE_CODE (exp)))
  2580.     {
  2581.     case 'd':
  2582.       exp_rtl = DECL_RTL (exp);
  2583.       break;
  2584.  
  2585.     case 'c':
  2586.       return 1;
  2587.  
  2588.     case 'x':
  2589.       if (TREE_CODE (exp) == TREE_LIST)
  2590.     return (safe_from_p (x, TREE_VALUE (exp))
  2591.         && (TREE_CHAIN (exp) == 0
  2592.             || safe_from_p (x, TREE_CHAIN (exp))));
  2593.       else
  2594.     return 0;
  2595.  
  2596.     case '1':
  2597.       return safe_from_p (x, TREE_OPERAND (exp, 0));
  2598.  
  2599.     case '2':
  2600.     case '<':
  2601.       return (safe_from_p (x, TREE_OPERAND (exp, 0))
  2602.           && safe_from_p (x, TREE_OPERAND (exp, 1)));
  2603.  
  2604.     case 'e':
  2605.     case 'r':
  2606.       /* Now do code-specific tests.  EXP_RTL is set to any rtx we find in
  2607.      the expression.  If it is set, we conflict iff we are that rtx or
  2608.      both are in memory.  Otherwise, we check all operands of the
  2609.      expression recursively.  */
  2610.  
  2611.       switch (TREE_CODE (exp))
  2612.     {
  2613.     case ADDR_EXPR:
  2614.       return staticp (TREE_OPERAND (exp, 0));
  2615.  
  2616.     case INDIRECT_REF:
  2617.       if (GET_CODE (x) == MEM)
  2618.         return 0;
  2619.       break;
  2620.  
  2621.     case CALL_EXPR:
  2622.       exp_rtl = CALL_EXPR_RTL (exp);
  2623.       if (exp_rtl == 0)
  2624.         {
  2625.           /* Assume that the call will clobber all hard registers and
  2626.          all of memory.  */
  2627.           if ((GET_CODE (x) == REG && REGNO (x) < FIRST_PSEUDO_REGISTER)
  2628.           || GET_CODE (x) == MEM)
  2629.         return 0;
  2630.         }
  2631.  
  2632.       break;
  2633.  
  2634.     case RTL_EXPR:
  2635.       exp_rtl = RTL_EXPR_RTL (exp);
  2636.       if (exp_rtl == 0)
  2637.         /* We don't know what this can modify.  */
  2638.         return 0;
  2639.  
  2640.       break;
  2641.  
  2642.     case WITH_CLEANUP_EXPR:
  2643.       exp_rtl = RTL_EXPR_RTL (exp);
  2644.       break;
  2645.  
  2646.     case SAVE_EXPR:
  2647.       exp_rtl = SAVE_EXPR_RTL (exp);
  2648.       break;
  2649.  
  2650.     case METHOD_CALL_EXPR:
  2651.       /* This takes a rtx argument, but shouldn't appear here. */
  2652.       abort ();
  2653.     }
  2654.  
  2655.       /* If we have an rtx, we do not need to scan our operands.  */
  2656.       if (exp_rtl)
  2657.     break;
  2658.  
  2659.       nops = tree_code_length[(int) TREE_CODE (exp)];
  2660.       for (i = 0; i < nops; i++)
  2661.     if (TREE_OPERAND (exp, i) != 0
  2662.         && ! safe_from_p (x, TREE_OPERAND (exp, i)))
  2663.       return 0;
  2664.     }
  2665.  
  2666.   /* If we have an rtl, find any enclosed object.  Then see if we conflict
  2667.      with it.  */
  2668.   if (exp_rtl)
  2669.     {
  2670.       if (GET_CODE (exp_rtl) == SUBREG)
  2671.     {
  2672.       exp_rtl = SUBREG_REG (exp_rtl);
  2673.       if (GET_CODE (exp_rtl) == REG
  2674.           && REGNO (exp_rtl) < FIRST_PSEUDO_REGISTER)
  2675.         return 0;
  2676.     }
  2677.  
  2678.       /* If the rtl is X, then it is not safe.  Otherwise, it is unless both
  2679.      are memory and EXP is not readonly.  */
  2680.       return ! (rtx_equal_p (x, exp_rtl)
  2681.         || (GET_CODE (x) == MEM && GET_CODE (exp_rtl) == MEM
  2682.             && ! TREE_READONLY (exp)));
  2683.     }
  2684.  
  2685.   /* If we reach here, it is safe.  */
  2686.   return 1;
  2687. }
  2688.  
  2689. /* Subroutine of expand_expr: return nonzero iff EXP is an
  2690.    expression whose type is statically determinable.  */
  2691.  
  2692. static int
  2693. fixed_type_p (exp)
  2694.      tree exp;
  2695. {
  2696.   if (TREE_CODE (exp) == PARM_DECL
  2697.       || TREE_CODE (exp) == VAR_DECL
  2698.       || TREE_CODE (exp) == CALL_EXPR || TREE_CODE (exp) == TARGET_EXPR
  2699.       || TREE_CODE (exp) == COMPONENT_REF
  2700.       || TREE_CODE (exp) == ARRAY_REF)
  2701.     return 1;
  2702.   return 0;
  2703. }
  2704.  
  2705. /* expand_expr: generate code for computing expression EXP.
  2706.    An rtx for the computed value is returned.  The value is never null.
  2707.    In the case of a void EXP, const0_rtx is returned.
  2708.  
  2709.    The value may be stored in TARGET if TARGET is nonzero.
  2710.    TARGET is just a suggestion; callers must assume that
  2711.    the rtx returned may not be the same as TARGET.
  2712.  
  2713.    If TARGET is CONST0_RTX, it means that the value will be ignored.
  2714.  
  2715.    If TMODE is not VOIDmode, it suggests generating the
  2716.    result in mode TMODE.  But this is done only when convenient.
  2717.    Otherwise, TMODE is ignored and the value generated in its natural mode.
  2718.    TMODE is just a suggestion; callers must assume that
  2719.    the rtx returned may not have mode TMODE.
  2720.  
  2721.    If MODIFIER is EXPAND_SUM then when EXP is an addition
  2722.    we can return an rtx of the form (MULT (REG ...) (CONST_INT ...))
  2723.    or a nest of (PLUS ...) and (MINUS ...) where the terms are
  2724.    products as above, or REG or MEM, or constant.
  2725.    Ordinarily in such cases we would output mul or add instructions
  2726.    and then return a pseudo reg containing the sum.
  2727.  
  2728.    If MODIFIER is EXPAND_CONST_ADDRESS, EXPAND_SUM, or EXPAND_INTO_STACK
  2729.    then it is ok to return a MEM rtx whose address is a constant that isn't
  2730.    a legitimate address.  It is the caller's responsibility to call
  2731.    memory_address or equivalent before using the returned address in an 
  2732.    insn.  */
  2733.  
  2734. rtx
  2735. expand_expr (exp, target, tmode, modifier)
  2736.      register tree exp;
  2737.      rtx target;
  2738.      enum machine_mode tmode;
  2739.      enum expand_modifier modifier;
  2740. {
  2741.   register rtx op0, op1, temp;
  2742.   tree type = TREE_TYPE (exp);
  2743.   int unsignedp = TREE_UNSIGNED (type);
  2744.   register enum machine_mode mode = TYPE_MODE (type);
  2745.   register enum tree_code code = TREE_CODE (exp);
  2746.   optab this_optab;
  2747.   /* Use subtarget as the target for operand 0 of a binary operation.  */
  2748.   rtx subtarget = (target != 0 && GET_CODE (target) == REG ? target : 0);
  2749.   rtx original_target = target;
  2750.   int ignore = target == const0_rtx;
  2751.   tree context;
  2752.  
  2753.   extern rtx (*lang_expand_expr)();
  2754.  
  2755.   /* Don't use hard regs as subtargets, because the combiner
  2756.      can only handle pseudo regs.  */
  2757.   if (subtarget && REGNO (subtarget) < FIRST_PSEUDO_REGISTER)
  2758.     subtarget = 0;
  2759.   /* Avoid subtargets inside loops,
  2760.      since they hide some invariant expressions.  */
  2761.   if (preserve_subexpressions_p ())
  2762.     subtarget = 0;
  2763.  
  2764.   if (ignore) target = 0, original_target = 0;
  2765.  
  2766.   /* If will do cse, generate all results into pseudo registers
  2767.      since 1) that allows cse to find more things
  2768.      and 2) otherwise cse could produce an insn the machine
  2769.      cannot support.  */
  2770.  
  2771.   if (! cse_not_expected && mode != BLKmode && target
  2772.       && (GET_CODE (target) != REG || REGNO (target) < FIRST_PSEUDO_REGISTER))
  2773.     target = subtarget;
  2774.  
  2775.   /* Ensure we reference a volatile object even if value is ignored.  */
  2776.   if (ignore && TREE_THIS_VOLATILE (exp)
  2777.       && mode != VOIDmode && mode != BLKmode)
  2778.     {
  2779.       target = gen_reg_rtx (mode);
  2780.       temp = expand_expr (exp, target, VOIDmode, modifier);
  2781.       if (temp != target)
  2782.     emit_move_insn (target, temp);
  2783.       return target;
  2784.     }
  2785.  
  2786.   switch (code)
  2787.     {
  2788.     case LABEL_DECL:
  2789.       return gen_rtx (MEM, Pmode, gen_rtx (LABEL_REF, VOIDmode,
  2790.                        label_rtx (exp)));
  2791.  
  2792.     case PARM_DECL:
  2793.       if (DECL_RTL (exp) == 0)
  2794.     {
  2795.       error_with_decl (exp, "prior parameter's size depends on `%s'");
  2796.       return const0_rtx;
  2797.     }
  2798.  
  2799.     case FUNCTION_DECL:
  2800.     case VAR_DECL:
  2801.     case RESULT_DECL:
  2802.       if (DECL_RTL (exp) == 0)
  2803.     abort ();
  2804.       /* Ensure variable marked as used
  2805.      even if it doesn't go through a parser.  */
  2806.       TREE_USED (exp) = 1;
  2807.       /* Handle variables inherited from containing functions.  */
  2808.       context = decl_function_context (exp);
  2809.       if (context != 0 && context != current_function_decl
  2810.       /* If var is static, we don't need a static chain to access it.  */
  2811.       && ! (GET_CODE (DECL_RTL (exp)) == MEM
  2812.         && CONSTANT_P (XEXP (DECL_RTL (exp), 0))))
  2813.     {
  2814.       rtx addr;
  2815.  
  2816.       /* Mark as non-local and addressable.  */
  2817.       TREE_NONLOCAL (exp) = 1;
  2818.       mark_addressable (exp);
  2819.       if (GET_CODE (DECL_RTL (exp)) != MEM)
  2820.         abort ();
  2821.       addr = XEXP (DECL_RTL (exp), 0);
  2822.       if (GET_CODE (addr) == MEM)
  2823.         addr = gen_rtx (MEM, Pmode, fix_lexical_addr (XEXP (addr, 0), exp));
  2824.       else
  2825.         addr = fix_lexical_addr (addr, exp);
  2826.       return change_address (DECL_RTL (exp), mode, addr);
  2827.     }
  2828.       /* This is the case of an array whose size is to be determined
  2829.      from its initializer, while the initializer is still being parsed.
  2830.      See expand_decl.  */
  2831.       if (GET_CODE (DECL_RTL (exp)) == MEM
  2832.       && GET_CODE (XEXP (DECL_RTL (exp), 0)) == REG)
  2833.     return change_address (DECL_RTL (exp), GET_MODE (DECL_RTL (exp)),
  2834.                    XEXP (DECL_RTL (exp), 0));
  2835.       if (GET_CODE (DECL_RTL (exp)) == MEM
  2836.       && modifier != EXPAND_CONST_ADDRESS
  2837.       && modifier != EXPAND_SUM
  2838.       && modifier != EXPAND_INTO_STACK)
  2839.     {
  2840.       /* DECL_RTL probably contains a constant address.
  2841.          On RISC machines where a constant address isn't valid,
  2842.          make some insns to get that address into a register.  */
  2843.       if (!memory_address_p (DECL_MODE (exp), XEXP (DECL_RTL (exp), 0))
  2844.           || (flag_force_addr
  2845.           && CONSTANT_ADDRESS_P (XEXP (DECL_RTL (exp), 0))))
  2846.         return change_address (DECL_RTL (exp), VOIDmode,
  2847.                    copy_rtx (XEXP (DECL_RTL (exp), 0)));
  2848.     }
  2849.       return DECL_RTL (exp);
  2850.  
  2851.     case INTEGER_CST:
  2852.       return immed_double_const (TREE_INT_CST_LOW (exp),
  2853.                  TREE_INT_CST_HIGH (exp),
  2854.                  mode);
  2855.  
  2856.     case CONST_DECL:
  2857.       return expand_expr (DECL_INITIAL (exp), target, VOIDmode, 0);
  2858.  
  2859.     case REAL_CST:
  2860.       /* If optimized, generate immediate CONST_DOUBLE
  2861.      which will be turned into memory by reload if necessary. 
  2862.      
  2863.      We used to force a register so that loop.c could see it.  But
  2864.      this does not allow gen_* patterns to perform optimizations with
  2865.      the constants.  It also produces two insns in cases like "x = 1.0;".
  2866.      On most machines, floating-point constants are not permitted in
  2867.      many insns, so we'd end up copying it to a register in any case.
  2868.  
  2869.      Now, we do the copying in expand_binop, if appropriate.  */
  2870.       return immed_real_const (exp);
  2871.  
  2872.     case COMPLEX_CST:
  2873.     case STRING_CST:
  2874.       if (! TREE_CST_RTL (exp))
  2875.     output_constant_def (exp);
  2876.  
  2877.       /* TREE_CST_RTL probably contains a constant address.
  2878.      On RISC machines where a constant address isn't valid,
  2879.      make some insns to get that address into a register.  */
  2880.       if (GET_CODE (TREE_CST_RTL (exp)) == MEM
  2881.       && modifier != EXPAND_CONST_ADDRESS
  2882.       && !memory_address_p (mode, XEXP (TREE_CST_RTL (exp), 0)))
  2883.     return change_address (TREE_CST_RTL (exp), VOIDmode,
  2884.                    copy_rtx (XEXP (TREE_CST_RTL (exp), 0)));
  2885.       return TREE_CST_RTL (exp);
  2886.  
  2887.     case SAVE_EXPR:
  2888.       context = decl_function_context (exp);
  2889.       if (context == current_function_decl)
  2890.     context = 0;
  2891.  
  2892.       /* If this is non-local, handle it.  */
  2893.       if (context)
  2894.     {
  2895.       temp = SAVE_EXPR_RTL (exp);
  2896.       if (temp && GET_CODE (temp) == REG)
  2897.         {
  2898.           put_var_into_stack (exp);
  2899.           temp = SAVE_EXPR_RTL (exp);
  2900.         }
  2901.       if (temp == 0 || GET_CODE (temp) != MEM)
  2902.         abort ();
  2903.       return change_address (temp, mode,
  2904.                  fix_lexical_addr (XEXP (temp, 0), exp));
  2905.     }
  2906.       if (SAVE_EXPR_RTL (exp) == 0)
  2907.     {
  2908.       if (mode == BLKmode)
  2909.         temp
  2910.           = assign_stack_temp (mode,
  2911.                    int_size_in_bytes (TREE_TYPE (exp)), 0);
  2912.       else
  2913.         temp = gen_reg_rtx (mode);
  2914.       SAVE_EXPR_RTL (exp) = temp;
  2915.       store_expr (TREE_OPERAND (exp, 0), temp, 0);
  2916.       if (!optimize && GET_CODE (temp) == REG)
  2917.         save_expr_regs = gen_rtx (EXPR_LIST, VOIDmode, temp,
  2918.                       save_expr_regs);
  2919.     }
  2920.       return SAVE_EXPR_RTL (exp);
  2921.  
  2922.     case EXIT_EXPR:
  2923.       /* Exit the current loop if the body-expression is true.  */
  2924.       {
  2925.     rtx label = gen_label_rtx ();
  2926.     do_jump (TREE_OPERAND (exp, 0), label, 0);
  2927.     expand_exit_loop (0);
  2928.     emit_label (label);
  2929.       }
  2930.       return const0_rtx;
  2931.  
  2932.     case LOOP_EXPR:
  2933.       expand_start_loop (1);
  2934.       expand_expr_stmt (TREE_OPERAND (exp, 0));
  2935.       expand_end_loop ();
  2936.  
  2937.       return const0_rtx;
  2938.  
  2939.     case BIND_EXPR:
  2940.       {
  2941.     tree vars = TREE_OPERAND (exp, 0);
  2942.     int vars_need_expansion = 0;
  2943.  
  2944.     /* Need to open a binding contour here because
  2945.        if there are any cleanups they most be contained here.  */
  2946.     expand_start_bindings (0);
  2947.  
  2948.     /* Mark the corresponding BLOCK for output.  */
  2949.     if (TREE_OPERAND (exp, 2) != 0)
  2950.       TREE_USED (TREE_OPERAND (exp, 2)) = 1;
  2951.  
  2952.     /* If VARS have not yet been expanded, expand them now.  */
  2953.     while (vars)
  2954.       {
  2955.         if (DECL_RTL (vars) == 0)
  2956.           {
  2957.         vars_need_expansion = 1;
  2958.         expand_decl (vars);
  2959.           }
  2960.         expand_decl_init (vars);
  2961.         vars = TREE_CHAIN (vars);
  2962.       }
  2963.  
  2964.     temp = expand_expr (TREE_OPERAND (exp, 1), target, tmode, modifier);
  2965.  
  2966.     expand_end_bindings (vars, 0, 0);
  2967.  
  2968.     return temp;
  2969.       }
  2970.  
  2971.     case RTL_EXPR:
  2972.       if (RTL_EXPR_SEQUENCE (exp) == const0_rtx)
  2973.     abort ();
  2974.       emit_insns (RTL_EXPR_SEQUENCE (exp));
  2975.       RTL_EXPR_SEQUENCE (exp) = const0_rtx;
  2976.       return RTL_EXPR_RTL (exp);
  2977.  
  2978.     case CONSTRUCTOR:
  2979.       /* All elts simple constants => refer to a constant in memory.  */
  2980.       if (TREE_STATIC (exp))
  2981.     /* For aggregate types with non-BLKmode modes,
  2982.        this should ideally construct a CONST_INT.  */
  2983.     {
  2984.       rtx constructor = output_constant_def (exp);
  2985.       if (! memory_address_p (GET_MODE (constructor),
  2986.                   XEXP (constructor, 0)))
  2987.         constructor = change_address (constructor, VOIDmode,
  2988.                       XEXP (constructor, 0));
  2989.       return constructor;
  2990.     }
  2991.  
  2992.       if (ignore)
  2993.     {
  2994.       tree elt;
  2995.       for (elt = CONSTRUCTOR_ELTS (exp); elt; elt = TREE_CHAIN (elt))
  2996.         expand_expr (TREE_VALUE (elt), const0_rtx, VOIDmode, 0);
  2997.       return const0_rtx;
  2998.     }
  2999.       else
  3000.     {
  3001.       if (target == 0 || ! safe_from_p (target, exp))
  3002.         {
  3003.           if (mode != BLKmode)
  3004.         target = gen_reg_rtx (mode);
  3005.           else
  3006.         target = assign_stack_temp (mode, int_size_in_bytes (type), 0);
  3007.         }
  3008.       store_constructor (exp, target);
  3009.       return target;
  3010.     }
  3011.  
  3012.     case INDIRECT_REF:
  3013.       {
  3014.     tree exp1 = TREE_OPERAND (exp, 0);
  3015.     tree exp2;
  3016.  
  3017.     /* A SAVE_EXPR as the address in an INDIRECT_EXPR is generated
  3018.        for  *PTR += ANYTHING  where PTR is put inside the SAVE_EXPR.
  3019.        This code has the same general effect as simply doing
  3020.        expand_expr on the save expr, except that the expression PTR
  3021.        is computed for use as a memory address.  This means different
  3022.        code, suitable for indexing, may be generated.  */
  3023.     if (TREE_CODE (exp1) == SAVE_EXPR
  3024.         && SAVE_EXPR_RTL (exp1) == 0
  3025.         && TREE_CODE (exp2 = TREE_OPERAND (exp1, 0)) != ERROR_MARK
  3026.         && TYPE_MODE (TREE_TYPE (exp1)) == Pmode
  3027.         && TYPE_MODE (TREE_TYPE (exp2)) == Pmode)
  3028.       {
  3029.         temp = expand_expr (TREE_OPERAND (exp1, 0), 0, VOIDmode, EXPAND_SUM);
  3030.         op0 = memory_address (mode, temp);
  3031.         op0 = copy_all_regs (op0);
  3032.         SAVE_EXPR_RTL (exp1) = op0;
  3033.       }
  3034.     else
  3035.       {
  3036.         /* ??? Tiemann: please explain why these precise
  3037.            conditions are desirable.  */
  3038.         if (modifier == EXPAND_INTO_STACK
  3039.         && original_target
  3040.         && GET_CODE (original_target) == MEM)
  3041.           op0 = expand_expr (exp1, XEXP (original_target, 0),
  3042.                  VOIDmode, EXPAND_INTO_STACK);
  3043.         else
  3044.           op0 = expand_expr (exp1, 0, VOIDmode, EXPAND_SUM);
  3045.         op0 = memory_address (mode, op0);
  3046.       }
  3047.       }
  3048.       temp = gen_rtx (MEM, mode, op0);
  3049.       /* If address was computed by addition,
  3050.      mark this as an element of an aggregate.  */
  3051.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == PLUS_EXPR
  3052.       || (TREE_CODE (TREE_OPERAND (exp, 0)) == SAVE_EXPR
  3053.           && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) == PLUS_EXPR))
  3054.     MEM_IN_STRUCT_P (temp) = 1;
  3055.       MEM_VOLATILE_P (temp) = TREE_THIS_VOLATILE (exp) || flag_volatile;
  3056. #if 0 /* It is incorrect to set RTX_UNCHANGING_P here, because the fact that
  3057.      a location is accessed through a pointer to const does not mean
  3058.      that the value there can never change.  */
  3059.       RTX_UNCHANGING_P (temp) = TREE_READONLY (exp);
  3060. #endif
  3061.       return temp;
  3062.  
  3063.     case ARRAY_REF:
  3064.       if (TREE_CODE (TREE_OPERAND (exp, 1)) != INTEGER_CST
  3065.       || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
  3066.     {
  3067.       /* Nonconstant array index or nonconstant element size.
  3068.          Generate the tree for *(&array+index) and expand that,
  3069.          except do it in a language-independent way
  3070.          and don't complain about non-lvalue arrays.
  3071.          `mark_addressable' should already have been called
  3072.          for any array for which this case will be reached.  */
  3073.  
  3074.       /* Don't forget the const or volatile flag from the array element. */
  3075.       tree variant_type = build_type_variant (type,
  3076.                           TREE_READONLY (exp),
  3077.                           TREE_THIS_VOLATILE (exp));
  3078.       tree array_adr = build1 (ADDR_EXPR, build_pointer_type (variant_type),
  3079.                    TREE_OPERAND (exp, 0));
  3080.       tree index = TREE_OPERAND (exp, 1);
  3081.       tree elt;
  3082.  
  3083.       /* Convert the integer argument to a type the same size as a pointer
  3084.          so the multiply won't overflow spuriously.  */
  3085.       if (TYPE_PRECISION (TREE_TYPE (index)) != POINTER_SIZE)
  3086.         index = convert (type_for_size (POINTER_SIZE, 0), index);
  3087.  
  3088.       /* Don't think the address has side effects
  3089.          just because the array does.
  3090.          (In some cases the address might have side effects,
  3091.          and we fail to record that fact here.  However, it should not
  3092.          matter, since expand_expr should not care.)  */
  3093.       TREE_SIDE_EFFECTS (array_adr) = 0;
  3094.  
  3095.       elt = build1 (INDIRECT_REF, type,
  3096.             fold (build (PLUS_EXPR, TYPE_POINTER_TO (variant_type),
  3097.                      array_adr,
  3098.                      fold (build (MULT_EXPR,
  3099.                           TYPE_POINTER_TO (variant_type),
  3100.                           index, size_in_bytes (type))))));
  3101.  
  3102.       /* Volatility, etc., of new expression is same as old expression.  */
  3103.       TREE_SIDE_EFFECTS (elt) = TREE_SIDE_EFFECTS (exp);
  3104.       TREE_THIS_VOLATILE (elt) = TREE_THIS_VOLATILE (exp);
  3105.       TREE_READONLY (elt) = TREE_READONLY (exp);
  3106.  
  3107.       return expand_expr (elt, target, tmode, modifier);
  3108.     }
  3109.  
  3110.       /* Fold an expression like: "foo"[2].
  3111.      This is not done in fold so it won't happen inside &.  */
  3112.       {
  3113.     int i;
  3114.     tree arg0 = TREE_OPERAND (exp, 0);
  3115.     tree arg1 = TREE_OPERAND (exp, 1);
  3116.  
  3117.     if (TREE_CODE (arg0) == STRING_CST
  3118.         && TREE_CODE (arg1) == INTEGER_CST
  3119.         && !TREE_INT_CST_HIGH (arg1)
  3120.         && (i = TREE_INT_CST_LOW (arg1)) < TREE_STRING_LENGTH (arg0))
  3121.       {
  3122.         if (TREE_TYPE (TREE_TYPE (arg0)) == integer_type_node)
  3123.           {
  3124.         exp = build_int_2 (((int *)TREE_STRING_POINTER (arg0))[i], 0);
  3125.         TREE_TYPE (exp) = integer_type_node;
  3126.         return expand_expr (exp, target, tmode, modifier);
  3127.           }
  3128.         if (TREE_TYPE (TREE_TYPE (arg0)) == char_type_node)
  3129.           {
  3130.         exp = build_int_2 (TREE_STRING_POINTER (arg0)[i], 0);
  3131.         TREE_TYPE (exp) = integer_type_node;
  3132.         return expand_expr (convert (TREE_TYPE (TREE_TYPE (arg0)), exp), target, tmode, modifier);
  3133.           }
  3134.       }
  3135.       }
  3136.  
  3137.       /* If this is a constant index into a constant array,
  3138.      just get the value from the array.  */
  3139.       if (TREE_READONLY (TREE_OPERAND (exp, 0))
  3140.       && ! TREE_SIDE_EFFECTS (TREE_OPERAND (exp, 0))
  3141.       && TREE_CODE (TREE_TYPE (TREE_OPERAND (exp, 0))) == ARRAY_TYPE
  3142.       && TREE_CODE (TREE_OPERAND (exp, 0)) == VAR_DECL
  3143.       && DECL_INITIAL (TREE_OPERAND (exp, 0))
  3144.       && TREE_CODE (DECL_INITIAL (TREE_OPERAND (exp, 0))) != ERROR_MARK)
  3145.     {
  3146.       tree index = fold (TREE_OPERAND (exp, 1));
  3147.       if (TREE_CODE (index) == INTEGER_CST)
  3148.         {
  3149.           int i = TREE_INT_CST_LOW (index);
  3150.           tree init = CONSTRUCTOR_ELTS (DECL_INITIAL (TREE_OPERAND (exp, 0)));
  3151.  
  3152.           while (init && i--)
  3153.         init = TREE_CHAIN (init);
  3154.           if (init)
  3155.         return expand_expr (fold (TREE_VALUE (init)), target, tmode, modifier);
  3156.         }
  3157.     }
  3158.       /* Treat array-ref with constant index as a component-ref.  */
  3159.  
  3160.     case COMPONENT_REF:
  3161.     case BIT_FIELD_REF:
  3162.       {
  3163.     enum machine_mode mode1;
  3164.     int bitsize;
  3165.     int bitpos;
  3166.     int volatilep = 0;
  3167.     tree tem = get_inner_reference (exp, &bitsize, &bitpos,
  3168.                     &mode1, &unsignedp, &volatilep);
  3169.  
  3170.     /* In some cases, we will be offsetting OP0's address by a constant.
  3171.        So get it as a sum, if possible.  If we will be using it
  3172.        directly in an insn, we validate it.  */
  3173.     op0 = expand_expr (tem, 0, VOIDmode, EXPAND_SUM);
  3174.  
  3175.     /* Don't forget about volatility even if this is a bitfield.  */
  3176.     if (GET_CODE (op0) == MEM && volatilep && ! MEM_VOLATILE_P (op0))
  3177.       {
  3178.         op0 = copy_rtx (op0);
  3179.         MEM_VOLATILE_P (op0) = 1;
  3180.       }
  3181.  
  3182.     if (mode1 == VOIDmode
  3183.         || GET_CODE (op0) == REG || GET_CODE (op0) == SUBREG)
  3184.       return extract_bit_field (validize_mem (op0), bitsize, bitpos,
  3185.                     unsignedp, target, mode, tmode,
  3186.                     TYPE_ALIGN (TREE_TYPE (tem)) / BITS_PER_UNIT,
  3187.                     int_size_in_bytes (TREE_TYPE (tem)));
  3188.     /* Get a reference to just this component.  */
  3189.     if (modifier == EXPAND_CONST_ADDRESS)
  3190.       op0 = gen_rtx (MEM, mode1, plus_constant (XEXP (op0, 0),
  3191.                             (bitpos / BITS_PER_UNIT)));
  3192.     else
  3193.       op0 = change_address (op0, mode1,
  3194.                 plus_constant (XEXP (op0, 0),
  3195.                            (bitpos / BITS_PER_UNIT)));
  3196.     MEM_IN_STRUCT_P (op0) = 1;
  3197.     MEM_VOLATILE_P (op0) |= volatilep;
  3198.     if (mode == mode1 || mode1 == BLKmode || mode1 == tmode)
  3199.       return op0;
  3200.     if (target == 0)
  3201.       target = gen_reg_rtx (tmode != VOIDmode ? tmode : mode);
  3202.     convert_move (target, op0, unsignedp);
  3203.     return target;
  3204.       }
  3205.  
  3206.       /* Intended for a reference to a buffer of a file-object in Pascal.
  3207.      But it's not certain that a special tree code will really be
  3208.      necessary for these.  INDIRECT_REF might work for them.  */
  3209.     case BUFFER_REF:
  3210.       abort ();
  3211.  
  3212.     case WITH_CLEANUP_EXPR:
  3213.       if (RTL_EXPR_RTL (exp) == 0)
  3214.     {
  3215.       RTL_EXPR_RTL (exp)
  3216.         = expand_expr (TREE_OPERAND (exp, 0), target, tmode, modifier);
  3217.       cleanups_this_call = tree_cons (0, TREE_OPERAND (exp, 2), cleanups_this_call);
  3218.       /* That's it for this cleanup.  */
  3219.       TREE_OPERAND (exp, 2) = 0;
  3220.     }
  3221.       return RTL_EXPR_RTL (exp);
  3222.  
  3223.     case CALL_EXPR:
  3224.       /* Check for a built-in function.  */
  3225.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR
  3226.       && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) == FUNCTION_DECL
  3227.       && DECL_BUILT_IN (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
  3228.     return expand_builtin (exp, target, subtarget, tmode, ignore);
  3229.       /* If this call was expanded already by preexpand_calls,
  3230.      just return the result we got.  */
  3231.       if (CALL_EXPR_RTL (exp) != 0)
  3232.     return CALL_EXPR_RTL (exp);
  3233.       return expand_call (exp,
  3234.               (modifier == EXPAND_INTO_STACK) ? original_target : target,
  3235.               ignore, modifier);
  3236.  
  3237.     case NON_LVALUE_EXPR:
  3238.     case NOP_EXPR:
  3239.     case CONVERT_EXPR:
  3240.     case REFERENCE_EXPR:
  3241.       if (TREE_CODE (type) == VOID_TYPE || ignore)
  3242.     {
  3243.       expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, modifier);
  3244.       return const0_rtx;
  3245.     }
  3246.       if (mode == TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))
  3247.     return expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, modifier);
  3248.       if (TREE_CODE (type) == UNION_TYPE)
  3249.     {
  3250.       tree valtype = TREE_TYPE (TREE_OPERAND (exp, 0));
  3251.       if (target == 0)
  3252.         {
  3253.           if (mode == BLKmode)
  3254.         {
  3255.           if (TYPE_SIZE (type) == 0
  3256.               || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
  3257.             abort ();
  3258.           target = assign_stack_temp (BLKmode,
  3259.                           (TREE_INT_CST_LOW (TYPE_SIZE (type))
  3260.                            + BITS_PER_UNIT - 1)
  3261.                           / BITS_PER_UNIT, 0);
  3262.         }
  3263.           else
  3264.         target = gen_reg_rtx (mode);
  3265.         }
  3266.       if (GET_CODE (target) == MEM)
  3267.         /* Store data into beginning of memory target.  */
  3268.         store_expr (TREE_OPERAND (exp, 0),
  3269.             change_address (target, TYPE_MODE (valtype), 0), 0);
  3270.       else if (GET_CODE (target) == REG)
  3271.         /* Store this field into a union of the proper type.  */
  3272.         store_field (target, GET_MODE_BITSIZE (TYPE_MODE (valtype)), 0,
  3273.              TYPE_MODE (valtype), TREE_OPERAND (exp, 0),
  3274.              VOIDmode, 0, 1,
  3275.              int_size_in_bytes (TREE_TYPE (TREE_OPERAND (exp, 0))));
  3276.       else
  3277.         abort ();
  3278.  
  3279.       /* Return the entire union.  */
  3280.       return target;
  3281.     }
  3282.       op0 = expand_expr (TREE_OPERAND (exp, 0), 0, mode, 0);
  3283.       if (GET_MODE (op0) == mode || GET_MODE (op0) == VOIDmode)
  3284.     return op0;
  3285.       if (flag_force_mem && GET_CODE (op0) == MEM)
  3286.     op0 = copy_to_reg (op0);
  3287.  
  3288.       if (target == 0)
  3289.     return convert_to_mode (mode, op0, TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))));
  3290.       else
  3291.     convert_move (target, op0, TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))));
  3292.       return target;
  3293.  
  3294.     case PLUS_EXPR:
  3295.       /* We come here from MINUS_EXPR when the second operand is a constant. */
  3296.     plus_expr:
  3297.       this_optab = add_optab;
  3298.  
  3299.       /* If the result is to be Pmode and we are adding an integer to
  3300.      something, we might be forming a constant.  So try to use
  3301.      plus_constant.  If it produces a sum and we can't accept it,
  3302.      use force_operand.  This allows P = &ARR[const] to generate
  3303.      efficient code on machines where a SYMBOL_REF is not a valid
  3304.      address.
  3305.  
  3306.      If this is an EXPAND_SUM call, always return the sum.  */
  3307.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == INTEGER_CST
  3308.       && GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_INT
  3309.       && (modifier == EXPAND_SUM || mode == Pmode))
  3310.     {
  3311.       op1 = expand_expr (TREE_OPERAND (exp, 1), subtarget, VOIDmode,
  3312.                  EXPAND_SUM);
  3313.       op1 = plus_constant (op1, TREE_INT_CST_LOW (TREE_OPERAND (exp, 0)));
  3314.       if (modifier != EXPAND_SUM)
  3315.         op1 = force_operand (op1, target);
  3316.       return op1;
  3317.     }
  3318.  
  3319.       else if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST
  3320.            && GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_INT
  3321.            && (modifier == EXPAND_SUM || mode == Pmode))
  3322.     {
  3323.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode,
  3324.                  EXPAND_SUM);
  3325.       op0 = plus_constant (op0, TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)));
  3326.       if (modifier != EXPAND_SUM)
  3327.         op0 = force_operand (op0, target);
  3328.       return op0;
  3329.     }
  3330.  
  3331.       /* No sense saving up arithmetic to be done
  3332.      if it's all in the wrong mode to form part of an address.
  3333.      And force_operand won't know whether to sign-extend or
  3334.      zero-extend.  */
  3335.       if (modifier != EXPAND_SUM || mode != Pmode) goto binop;
  3336.  
  3337.       preexpand_calls (exp);
  3338.       if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1)))
  3339.     subtarget = 0;
  3340.  
  3341.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, EXPAND_SUM);
  3342.       op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, EXPAND_SUM);
  3343.       /* Put a sum last, to simplify what follows.  */
  3344. #ifdef OLD_INDEXING
  3345.       if (GET_CODE (op1) == MULT)
  3346.     {
  3347.       temp = op0;
  3348.       op0 = op1;
  3349.       op1 = temp;
  3350.     }
  3351. #endif
  3352. #ifndef OLD_INDEXING
  3353.       /* Make sure any term that's a sum with a constant comes last.  */
  3354.       if (GET_CODE (op0) == PLUS
  3355.       && CONSTANT_P (XEXP (op0, 1)))
  3356.     {
  3357.       temp = op0;
  3358.       op0 = op1;
  3359.       op1 = temp;
  3360.     }
  3361.       /* If adding to a sum including a constant,
  3362.      associate it to put the constant outside.  */
  3363.       if (GET_CODE (op1) == PLUS
  3364.       && CONSTANT_P (XEXP (op1, 1)))
  3365.     {
  3366.       rtx tem;
  3367.       int constant_term = 0;
  3368.  
  3369.       op0 = gen_rtx (PLUS, mode, XEXP (op1, 0), op0);
  3370.       /* Let's also eliminate constants from op0 if possible.  */
  3371.       tem = eliminate_constant_term (op0, &constant_term);
  3372.       if (GET_CODE (XEXP (op1, 1)) == CONST_INT)
  3373.         {
  3374.           if (constant_term != 0)
  3375.         return plus_constant (tem, INTVAL (XEXP (op1, 1)) + constant_term);
  3376.           else
  3377.         return plus_constant (op0, INTVAL (XEXP (op1, 1)));
  3378.         }
  3379.       else
  3380.         return gen_rtx (PLUS, mode, op0, XEXP (op1, 1));
  3381.     }
  3382. #endif
  3383.       /* Put a constant term last.  */
  3384.       if (CONSTANT_P (op0))
  3385.     return gen_rtx (PLUS, mode, op1, op0);
  3386.       else
  3387.     return gen_rtx (PLUS, mode, op0, op1);
  3388.  
  3389.     case MINUS_EXPR:
  3390.       /* Handle difference of two symbolic constants,
  3391.      for the sake of an initializer.  */
  3392.       if (modifier == EXPAND_SUM
  3393.       && really_constant_p (TREE_OPERAND (exp, 0))
  3394.       && really_constant_p (TREE_OPERAND (exp, 1)))
  3395.     {
  3396.       rtx op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, modifier);
  3397.       rtx op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, modifier);
  3398.       return gen_rtx (MINUS, mode, op0, op1);
  3399.     }
  3400.       /* Convert A - const to A + (-const).  */
  3401.       if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST)
  3402.     {
  3403.       exp = build (PLUS_EXPR, type, TREE_OPERAND (exp, 0),
  3404.                fold (build1 (NEGATE_EXPR, type,
  3405.                      TREE_OPERAND (exp, 1))));
  3406.       goto plus_expr;
  3407.     }
  3408.       this_optab = sub_optab;
  3409.       goto binop;
  3410.  
  3411.     case MULT_EXPR:
  3412.       preexpand_calls (exp);
  3413.       /* If first operand is constant, swap them.
  3414.      Thus the following special case checks need only
  3415.      check the second operand.  */
  3416.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == INTEGER_CST)
  3417.     {
  3418.       register tree t1 = TREE_OPERAND (exp, 0);
  3419.       TREE_OPERAND (exp, 0) = TREE_OPERAND (exp, 1);
  3420.       TREE_OPERAND (exp, 1) = t1;
  3421.     }
  3422.  
  3423.       /* Attempt to return something suitable for generating an
  3424.      indexed address, for machines that support that.  */
  3425.  
  3426.       if (modifier == EXPAND_SUM && mode == Pmode
  3427.       && TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST
  3428.       && GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_INT)
  3429.     {
  3430.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, EXPAND_SUM);
  3431.  
  3432.       /* Apply distributive law if OP0 is x+c.  */
  3433.       if (GET_CODE (op0) == PLUS
  3434.           && GET_CODE (XEXP (op0, 1)) == CONST_INT)
  3435.         return gen_rtx (PLUS, mode,
  3436.                 gen_rtx (MULT, mode, XEXP (op0, 0),
  3437.                      gen_rtx (CONST_INT, VOIDmode,
  3438.                           TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)))),
  3439.                 gen_rtx (CONST_INT, VOIDmode,
  3440.                      (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1))
  3441.                       * INTVAL (XEXP (op0, 1)))));
  3442.  
  3443.       if (GET_CODE (op0) != REG)
  3444.         op0 = force_operand (op0, 0);
  3445.       if (GET_CODE (op0) != REG)
  3446.         op0 = copy_to_mode_reg (mode, op0);
  3447.  
  3448.       return gen_rtx (MULT, mode, op0,
  3449.               gen_rtx (CONST_INT, VOIDmode,
  3450.                    TREE_INT_CST_LOW (TREE_OPERAND (exp, 1))));
  3451.     }
  3452.  
  3453.       if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1)))
  3454.     subtarget = 0;
  3455.  
  3456.       /* Check for multiplying things that have been extended
  3457.      from a narrower type.  If this machine supports multiplying
  3458.      in that narrower type with a result in the desired type,
  3459.      do it that way, and avoid the explicit type-conversion.  */
  3460.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == NOP_EXPR
  3461.       && TREE_CODE (type) == INTEGER_TYPE
  3462.       && (TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
  3463.           < TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (exp, 0))))
  3464.       && ((TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST
  3465.            && int_fits_type_p (TREE_OPERAND (exp, 1),
  3466.                    TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
  3467.            /* Don't use a widening multiply if a shift will do.  */
  3468.            && ((GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 1))))
  3469.             > HOST_BITS_PER_INT)
  3470.            || exact_log2 (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1))) < 0))
  3471.           ||
  3472.           (TREE_CODE (TREE_OPERAND (exp, 1)) == NOP_EXPR
  3473.            && (TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 1), 0)))
  3474.            ==
  3475.            TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))))
  3476.            /* If both operands are extended, they must either both
  3477.           be zero-extended or both be sign-extended.  */
  3478.            && (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 1), 0)))
  3479.            ==
  3480.            TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))))))
  3481.     {
  3482.       enum machine_mode innermode
  3483.         = TYPE_MODE (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)));
  3484.       this_optab = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
  3485.             ? umul_widen_optab : smul_widen_optab);
  3486.       if (mode == GET_MODE_WIDER_MODE (innermode)
  3487.           && this_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing)
  3488.         {
  3489.           op0 = expand_expr (TREE_OPERAND (TREE_OPERAND (exp, 0), 0),
  3490.                  0, VOIDmode, 0);
  3491.           if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST)
  3492.         op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
  3493.           else
  3494.         op1 = expand_expr (TREE_OPERAND (TREE_OPERAND (exp, 1), 0),
  3495.                    0, VOIDmode, 0);
  3496.           goto binop2;
  3497.         }
  3498.     }
  3499.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  3500.       op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
  3501.       return expand_mult (mode, op0, op1, target, unsignedp);
  3502.  
  3503.     case TRUNC_DIV_EXPR:
  3504.     case FLOOR_DIV_EXPR:
  3505.     case CEIL_DIV_EXPR:
  3506.     case ROUND_DIV_EXPR:
  3507.     case EXACT_DIV_EXPR:
  3508.       preexpand_calls (exp);
  3509.       if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1)))
  3510.     subtarget = 0;
  3511.       /* Possible optimization: compute the dividend with EXPAND_SUM
  3512.      then if the divisor is constant can optimize the case
  3513.      where some terms of the dividend have coeffs divisible by it.  */
  3514.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  3515.       op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
  3516.       return expand_divmod (0, code, mode, op0, op1, target, unsignedp);
  3517.  
  3518.     case RDIV_EXPR:
  3519.       this_optab = flodiv_optab;
  3520.       goto binop;
  3521.  
  3522.     case TRUNC_MOD_EXPR:
  3523.     case FLOOR_MOD_EXPR:
  3524.     case CEIL_MOD_EXPR:
  3525.     case ROUND_MOD_EXPR:
  3526.       preexpand_calls (exp);
  3527.       if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1)))
  3528.     subtarget = 0;
  3529.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  3530.       op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
  3531.       return expand_divmod (1, code, mode, op0, op1, target, unsignedp);
  3532. #if 0
  3533. #ifdef HAVE_divmoddisi4
  3534.       if (GET_MODE (op0) != DImode)
  3535.     {
  3536.       temp = gen_reg_rtx (DImode);
  3537.       convert_move (temp, op0, 0);
  3538.       op0 = temp;
  3539.       if (GET_MODE (op1) != SImode && GET_CODE (op1) != CONST_INT)
  3540.         {
  3541.           temp = gen_reg_rtx (SImode);
  3542.           convert_move (temp, op1, 0);
  3543.           op1 = temp;
  3544.         }
  3545.       temp = gen_reg_rtx (SImode);
  3546.       if (target == 0)
  3547.         target = gen_reg_rtx (SImode);
  3548.       emit_insn (gen_divmoddisi4 (temp, protect_from_queue (op0, 0),
  3549.                       protect_from_queue (op1, 0),
  3550.                       protect_from_queue (target, 1)));
  3551.       return target;
  3552.     }
  3553. #endif
  3554. #endif
  3555.  
  3556.     case FIX_ROUND_EXPR:
  3557.     case FIX_FLOOR_EXPR:
  3558.     case FIX_CEIL_EXPR:
  3559.       abort ();            /* Not used for C.  */
  3560.  
  3561.     case FIX_TRUNC_EXPR:
  3562.       op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
  3563.       if (target == 0)
  3564.     target = gen_reg_rtx (mode);
  3565.       expand_fix (target, op0, unsignedp);
  3566.       return target;
  3567.  
  3568.     case FLOAT_EXPR:
  3569.       op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
  3570.       if (target == 0)
  3571.     target = gen_reg_rtx (mode);
  3572. #ifdef NeXT
  3573.       /* expand_float can't figure out what to do if FROM has VOIDmode.
  3574.      So give it the correct mode.  With -O, cse will optimize this.  */
  3575.       if (GET_MODE (op0) == VOIDmode)
  3576.     op0 = copy_to_mode_reg (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))),
  3577.                 op0);
  3578. #endif /* NeXT */
  3579.       expand_float (target, op0,
  3580.             TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))));
  3581.       return target;
  3582.  
  3583.     case NEGATE_EXPR:
  3584.       op0 = expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, 0);
  3585.       temp = expand_unop (mode, neg_optab, op0, target, 0);
  3586.       if (temp == 0)
  3587.     abort ();
  3588.       return temp;
  3589.  
  3590.     case ABS_EXPR:
  3591.       /* First try to do it with a special abs instruction.
  3592.      If that does not win, use conditional jump and negate.  */
  3593.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  3594.       temp = expand_unop (mode, abs_optab, op0, target, 0);
  3595.       if (temp != 0)
  3596.     return temp;
  3597.  
  3598.       target = original_target;
  3599.       temp = gen_label_rtx ();
  3600.       if (target == 0 || ! safe_from_p (target, TREE_OPERAND (exp, 0)))
  3601.     target = gen_reg_rtx (mode);
  3602.       emit_move_insn (target, op0);
  3603.       emit_cmp_insn (target,
  3604.              expand_expr (convert (type, integer_zero_node),
  3605.                   0, VOIDmode, 0),
  3606.              GE, 0, 0, 0);
  3607.       NO_DEFER_POP;
  3608.       emit_jump_insn (gen_bge (temp));
  3609.       op0 = expand_unop (mode, neg_optab, target, target, 0);
  3610.       if (op0 != target)
  3611.     emit_move_insn (target, op0);
  3612.       emit_label (temp);
  3613.       OK_DEFER_POP;
  3614.       return target;
  3615.  
  3616.     case MAX_EXPR:
  3617.     case MIN_EXPR:
  3618.       target = original_target;
  3619.       mode = TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 1)));
  3620.       op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
  3621.       if (target == 0 || ! safe_from_p (target, exp))
  3622.     target = gen_reg_rtx (mode);
  3623.       op0 = expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, 0);
  3624.       if (target != op0)
  3625.     emit_move_insn (target, op0);
  3626.       op0 = gen_label_rtx ();
  3627.       if (code == MAX_EXPR)
  3628.     temp = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 1)))
  3629.         ? compare_from_rtx (target, op1, GEU, 1, mode, 0, 0)
  3630.         : compare_from_rtx (target, op1, GE, 0, mode, 0, 0));
  3631.       else
  3632.     temp = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 1)))
  3633.         ? compare_from_rtx (target, op1, LEU, 1, mode, 0, 0)
  3634.         : compare_from_rtx (target, op1, LE, 0, mode, 0, 0));
  3635.       if (temp == const0_rtx)
  3636.     emit_move_insn (target, op1);
  3637.       else if (temp != const1_rtx)
  3638.     {
  3639.       if (bcc_gen_fctn[(int) GET_CODE (temp)] != 0)
  3640.         emit_jump_insn ((*bcc_gen_fctn[(int) GET_CODE (temp)]) (op0));
  3641.       else
  3642.         abort ();
  3643.       emit_move_insn (target, op1);
  3644.     }
  3645.       emit_label (op0);
  3646.       return target;
  3647.  
  3648. /* ??? Can optimize when the operand of this is a bitwise operation,
  3649.    by using a different bitwise operation.  */
  3650.     case BIT_NOT_EXPR:
  3651.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  3652.       temp = expand_unop (mode, one_cmpl_optab, op0, target, 1);
  3653.       if (temp == 0)
  3654.     abort ();
  3655.       return temp;
  3656.  
  3657.     case FFS_EXPR:
  3658.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  3659.       temp = expand_unop (mode, ffs_optab, op0, target, 1);
  3660.       if (temp == 0)
  3661.     abort ();
  3662.       return temp;
  3663.  
  3664. /* ??? Can optimize bitwise operations with one arg constant.
  3665.    Can optimize (a bitwise1 n) bitwise2 (a bitwise3 b)
  3666.    and (a bitwise1 b) bitwise2 b (etc)
  3667.    but that is probably not worth while.  */
  3668.  
  3669. /* BIT_AND_EXPR is for bitwise anding.
  3670.    TRUTH_AND_EXPR is for anding two boolean values
  3671.    when we want in all cases to compute both of them.
  3672.    In general it is fastest to do TRUTH_AND_EXPR by
  3673.    computing both operands as actual zero-or-1 values
  3674.    and then bitwise anding.  In cases where there cannot
  3675.    be any side effects, better code would be made by
  3676.    treating TRUTH_AND_EXPR like TRUTH_ANDIF_EXPR;
  3677.    but the question is how to recognize those cases.  */
  3678.  
  3679.     case TRUTH_AND_EXPR:
  3680.     case BIT_AND_EXPR:
  3681.       this_optab = and_optab;
  3682.       goto binop;
  3683.  
  3684. /* See comment above about TRUTH_AND_EXPR; it applies here too.  */
  3685.     case TRUTH_OR_EXPR:
  3686.     case BIT_IOR_EXPR:
  3687.       this_optab = ior_optab;
  3688.       goto binop;
  3689.  
  3690.     case BIT_XOR_EXPR:
  3691.       this_optab = xor_optab;
  3692.       goto binop;
  3693.  
  3694.     case LSHIFT_EXPR:
  3695.     case RSHIFT_EXPR:
  3696.     case LROTATE_EXPR:
  3697.     case RROTATE_EXPR:
  3698.       preexpand_calls (exp);
  3699.       if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1)))
  3700.     subtarget = 0;
  3701.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  3702.       return expand_shift (code, mode, op0, TREE_OPERAND (exp, 1), target,
  3703.                unsignedp);
  3704.  
  3705. /* Could determine the answer when only additive constants differ.
  3706.    Also, the addition of one can be handled by changing the condition.  */
  3707.     case LT_EXPR:
  3708.     case LE_EXPR:
  3709.     case GT_EXPR:
  3710.     case GE_EXPR:
  3711.     case EQ_EXPR:
  3712.     case NE_EXPR:
  3713.       preexpand_calls (exp);
  3714.       temp = do_store_flag (exp, target, tmode != VOIDmode ? tmode : mode, 0);
  3715.       if (temp != 0)
  3716.     return temp;
  3717.       /* For foo != 0, load foo, and if it is nonzero load 1 instead. */
  3718.       if (code == NE_EXPR && integer_zerop (TREE_OPERAND (exp, 1))
  3719.       && original_target
  3720.       && GET_CODE (original_target) == REG
  3721.       && (GET_MODE (original_target)
  3722.           == TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  3723.     {
  3724.       temp = expand_expr (TREE_OPERAND (exp, 0), original_target, VOIDmode, 0);
  3725.       if (temp != original_target)
  3726.         temp = copy_to_reg (temp);
  3727.       op1 = gen_label_rtx ();
  3728.       emit_cmp_insn (temp, const0_rtx, EQ, 0, unsignedp, 0);
  3729.       emit_jump_insn (gen_beq (op1));
  3730.       emit_move_insn (temp, const1_rtx);
  3731.       emit_label (op1);
  3732.       return temp;
  3733.     }
  3734.       /* If no set-flag instruction, must generate a conditional
  3735.      store into a temporary variable.  Drop through
  3736.      and handle this like && and ||.  */
  3737.  
  3738.     case TRUTH_ANDIF_EXPR:
  3739.     case TRUTH_ORIF_EXPR:
  3740.       if (target == 0 || ! safe_from_p (target, exp)
  3741.       /* Make sure we don't have a hard reg (such as function's return
  3742.          value) live across basic blocks, if not optimizing.  */
  3743.       || (!optimize && GET_CODE (target) == REG
  3744.           && REGNO (target) < FIRST_PSEUDO_REGISTER))
  3745.     target = gen_reg_rtx (tmode != VOIDmode ? tmode : mode);
  3746.       emit_clr_insn (target);
  3747.       op1 = gen_label_rtx ();
  3748.       jumpifnot (exp, op1);
  3749.       emit_0_to_1_insn (target);
  3750.       emit_label (op1);
  3751.       return target;
  3752.  
  3753.     case TRUTH_NOT_EXPR:
  3754.       op0 = expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, 0);
  3755.       /* The parser is careful to generate TRUTH_NOT_EXPR
  3756.      only with operands that are always zero or one.  */
  3757.       temp = expand_binop (mode, xor_optab, op0,
  3758.                gen_rtx (CONST_INT, mode, 1),
  3759.                target, 1, OPTAB_LIB_WIDEN);
  3760.       if (temp == 0)
  3761.     abort ();
  3762.       return temp;
  3763.  
  3764.     case COMPOUND_EXPR:
  3765.       expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0);
  3766.       emit_queue ();
  3767.       return expand_expr (TREE_OPERAND (exp, 1),
  3768.               (ignore ? const0_rtx : target),
  3769.               VOIDmode, 0);
  3770.  
  3771.     case COND_EXPR:
  3772.       {
  3773.     /* Note that COND_EXPRs whose type is a structure or union
  3774.        are required to be constructed to contain assignments of
  3775.        a temporary variable, so that we can evaluate them here
  3776.        for side effect only.  If type is void, we must do likewise.  */
  3777.  
  3778.     /* If an arm of the branch requires a cleanup,
  3779.        only that cleanup is performed.  */
  3780.  
  3781.     tree singleton = 0;
  3782.     tree binary_op = 0, unary_op = 0;
  3783.     tree old_cleanups = cleanups_this_call;
  3784.     cleanups_this_call = 0;
  3785.  
  3786.     /* If this is (A ? 1 : 0) and A is a condition, just evaluate it and
  3787.        convert it to our mode, if necessary.  */
  3788.     if (integer_onep (TREE_OPERAND (exp, 1))
  3789.         && integer_zerop (TREE_OPERAND (exp, 2))
  3790.         && TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 0))) == '<')
  3791.       {
  3792.         op0 = expand_expr (TREE_OPERAND (exp, 0), target, mode, modifier);
  3793.         if (GET_MODE (op0) == mode)
  3794.           return op0;
  3795.         if (target == 0)
  3796.           target = gen_reg_rtx (mode);
  3797.         convert_move (target, op0, unsignedp);
  3798.         return target;
  3799.       }
  3800.  
  3801.     /* If we are not to produce a result, we have no target.  Otherwise,
  3802.        if a target was specified use it; it will not be used as an
  3803.        intermediate target unless it is safe.  If no target, use a 
  3804.        temporary.  */
  3805.  
  3806.     if (mode == VOIDmode || ignore)
  3807.       temp = 0;
  3808.     else if (original_target
  3809.          && safe_from_p (original_target, TREE_OPERAND (exp, 0)))
  3810.       temp = original_target;
  3811.     else if (mode == BLKmode)
  3812.       {
  3813.         if (TYPE_SIZE (type) == 0
  3814.         || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
  3815.           abort ();
  3816.         temp = assign_stack_temp (BLKmode,
  3817.                       (TREE_INT_CST_LOW (TYPE_SIZE (type))
  3818.                        + BITS_PER_UNIT - 1)
  3819.                       / BITS_PER_UNIT, 0);
  3820.       }
  3821.     else
  3822.       temp = gen_reg_rtx (mode);
  3823.  
  3824.     /* Check for X ? A + B : A.  If we have this, we can copy
  3825.        A to the output and conditionally add B.  Similarly for unary
  3826.        operations.  */
  3827.     if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 1))) == '2'
  3828.         && operand_equal_p (TREE_OPERAND (exp, 2),
  3829.                 TREE_OPERAND (TREE_OPERAND (exp, 1), 0), 0))
  3830.       singleton = TREE_OPERAND (exp, 2), binary_op = TREE_OPERAND (exp, 1);
  3831.     else if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 2))) == '2'
  3832.          && operand_equal_p (TREE_OPERAND (exp, 1),
  3833.                      TREE_OPERAND (TREE_OPERAND (exp, 2), 0), 0))
  3834.       singleton = TREE_OPERAND (exp, 1), binary_op = TREE_OPERAND (exp, 2);
  3835.     else if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 1))) == '1'
  3836.          && operand_equal_p (TREE_OPERAND (exp, 2),
  3837.                      TREE_OPERAND (TREE_OPERAND (exp, 1), 0), 0))
  3838.       singleton = TREE_OPERAND (exp, 2), unary_op = TREE_OPERAND (exp, 1);
  3839.     else if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 2))) == '1'
  3840.          && operand_equal_p (TREE_OPERAND (exp, 1),
  3841.                      TREE_OPERAND (TREE_OPERAND (exp, 2), 0), 0))
  3842.       singleton = TREE_OPERAND (exp, 1), unary_op = TREE_OPERAND (exp, 2);
  3843.  
  3844.     /* If we had X ? A + 1 : A and we can do the test of X as a store-flag
  3845.        operation, do this as A + (X != 0).  */
  3846.     if (singleton && binary_op && TREE_CODE (binary_op) == PLUS_EXPR
  3847.         && integer_onep (TREE_OPERAND (binary_op, 1))
  3848.         && TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 0))) == '<')
  3849.       {
  3850.         rtx result
  3851.           = do_store_flag (TREE_OPERAND (exp, 0),
  3852.                    safe_from_p (temp, singleton) ? temp : 0,
  3853.                    mode, 1);
  3854.  
  3855.         if (result)
  3856.           {
  3857.         op1 = expand_expr (singleton, 0, VOIDmode, 0);
  3858.         return expand_binop (mode, add_optab, result, op1, temp,
  3859.                      unsignedp, OPTAB_LIB_WIDEN);
  3860.           }
  3861.       }
  3862.         
  3863.     NO_DEFER_POP;
  3864.     op0 = gen_label_rtx ();
  3865.  
  3866.     if (singleton)
  3867.       {
  3868.         if (temp != 0)
  3869.           {
  3870.         /* Don't allow a hard-register because evaluating the
  3871.            condition might involve a CALL which can clobber it.  */
  3872.         if ((GET_CODE (temp) == REG
  3873.              && REGNO (temp) < FIRST_PSEUDO_REGISTER)
  3874.             /* If the target conflicts with the other operand of the
  3875.                binary op, we can't use it.  */
  3876.             || (binary_op
  3877.             && ! safe_from_p (temp, TREE_OPERAND (binary_op, 1))))
  3878.           temp = gen_reg_rtx (mode);
  3879.         store_expr (singleton, temp, 0);
  3880.           }
  3881.         else
  3882.           expand_expr (singleton, ignore ? const1_rtx : 0, VOIDmode, 0);
  3883.         if (cleanups_this_call)
  3884.           {
  3885.         sorry ("aggregate value in COND_EXPR");
  3886.         cleanups_this_call = 0;
  3887.           }
  3888.         if (singleton == TREE_OPERAND (exp, 1))
  3889.           jumpif (TREE_OPERAND (exp, 0), op0);
  3890.         else
  3891.           jumpifnot (TREE_OPERAND (exp, 0), op0);
  3892.  
  3893.         if (binary_op && temp == 0)
  3894.           /* Just touch the other operand.  */
  3895.           expand_expr (TREE_OPERAND (binary_op, 1),
  3896.                ignore ? const0_rtx : 0, VOIDmode, 0);
  3897.         else if (binary_op)
  3898.           store_expr (build (TREE_CODE (binary_op), type,
  3899.                  make_tree (type, temp),
  3900.                  TREE_OPERAND (binary_op, 1)),
  3901.               temp, 0);
  3902.         else
  3903.           store_expr (build1 (TREE_CODE (unary_op), type,
  3904.                   make_tree (type, temp)),
  3905.               temp, 0);
  3906.         op1 = op0;
  3907.       }
  3908. #if 0
  3909.     /* This is now done in jump.c and is better done there because it
  3910.        produces shorter register lifetimes.  */
  3911.        
  3912.     /* Check for both possibilities either constants or variables
  3913.        in registers (but not the same as the target!).  If so, can
  3914.        save branches by assigning one, branching, and assigning the
  3915.        other.  */
  3916.     else if (temp && GET_MODE (temp) != BLKmode
  3917.          && (TREE_CONSTANT (TREE_OPERAND (exp, 1))
  3918.              || ((TREE_CODE (TREE_OPERAND (exp, 1)) == PARM_DECL
  3919.               || TREE_CODE (TREE_OPERAND (exp, 1)) == VAR_DECL)
  3920.              && DECL_RTL (TREE_OPERAND (exp, 1))
  3921.              && GET_CODE (DECL_RTL (TREE_OPERAND (exp, 1))) == REG
  3922.              && DECL_RTL (TREE_OPERAND (exp, 1)) != temp))
  3923.          && (TREE_CONSTANT (TREE_OPERAND (exp, 2))
  3924.              || ((TREE_CODE (TREE_OPERAND (exp, 2)) == PARM_DECL
  3925.               || TREE_CODE (TREE_OPERAND (exp, 2)) == VAR_DECL)
  3926.              && DECL_RTL (TREE_OPERAND (exp, 2))
  3927.              && GET_CODE (DECL_RTL (TREE_OPERAND (exp, 2))) == REG
  3928.              && DECL_RTL (TREE_OPERAND (exp, 2)) != temp)))
  3929.       {
  3930.         if (GET_CODE (temp) == REG && REGNO (temp) < FIRST_PSEUDO_REGISTER)
  3931.           temp = gen_reg_rtx (mode);
  3932.         store_expr (TREE_OPERAND (exp, 2), temp, 0);
  3933.         jumpifnot (TREE_OPERAND (exp, 0), op0);
  3934.         store_expr (TREE_OPERAND (exp, 1), temp, 0);
  3935.         op1 = op0;
  3936.       }
  3937. #endif
  3938.     /* Check for A op 0 ? A : FOO and A op 0 ? FOO : A where OP is any
  3939.        comparison operator.  If we have one of these cases, set the
  3940.        output to A, branch on A (cse will merge these two references),
  3941.        then set the output to FOO.  */
  3942.     else if (temp
  3943.          && TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 0))) == '<'
  3944.          && integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 0), 1))
  3945.          && operand_equal_p (TREE_OPERAND (TREE_OPERAND (exp, 0), 0),
  3946.                      TREE_OPERAND (exp, 1), 0)
  3947.          && safe_from_p (temp, TREE_OPERAND (exp, 2)))
  3948.       {
  3949.         if (GET_CODE (temp) == REG && REGNO (temp) < FIRST_PSEUDO_REGISTER)
  3950.           temp = gen_reg_rtx (mode);
  3951.         store_expr (TREE_OPERAND (exp, 1), temp, 0);
  3952.         jumpif (TREE_OPERAND (exp, 0), op0);
  3953.         store_expr (TREE_OPERAND (exp, 2), temp, 0);
  3954.         op1 = op0;
  3955.       }
  3956.     else if (temp
  3957.          && TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 0))) == '<'
  3958.          && integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 0), 1))
  3959.          && operand_equal_p (TREE_OPERAND (TREE_OPERAND (exp, 0), 0),
  3960.                      TREE_OPERAND (exp, 2), 0)
  3961.          && safe_from_p (temp, TREE_OPERAND (exp, 1)))
  3962.       {
  3963.         if (GET_CODE (temp) == REG && REGNO (temp) < FIRST_PSEUDO_REGISTER)
  3964.           temp = gen_reg_rtx (mode);
  3965.         store_expr (TREE_OPERAND (exp, 2), temp, 0);
  3966.         jumpifnot (TREE_OPERAND (exp, 0), op0);
  3967.         store_expr (TREE_OPERAND (exp, 1), temp, 0);
  3968.         op1 = op0;
  3969.       }
  3970.     else
  3971.       {
  3972.         op1 = gen_label_rtx ();
  3973.         jumpifnot (TREE_OPERAND (exp, 0), op0);
  3974.         if (temp != 0)
  3975.           store_expr (TREE_OPERAND (exp, 1), temp, 0);
  3976.         else
  3977.           expand_expr (TREE_OPERAND (exp, 1), ignore ? const0_rtx : 0,
  3978.                VOIDmode, 0);
  3979.         if (cleanups_this_call)
  3980.           {
  3981.         sorry ("aggregate value in COND_EXPR");
  3982.         cleanups_this_call = 0;
  3983.           }
  3984.  
  3985.         emit_queue ();
  3986.         emit_jump_insn (gen_jump (op1));
  3987.         emit_barrier ();
  3988.         emit_label (op0);
  3989.         if (temp != 0)
  3990.           store_expr (TREE_OPERAND (exp, 2), temp, 0);
  3991.         else
  3992.           expand_expr (TREE_OPERAND (exp, 2), ignore ? const0_rtx : 0,
  3993.                VOIDmode, 0);
  3994.       }
  3995.  
  3996.     if (cleanups_this_call)
  3997.       {
  3998.         sorry ("aggregate value in COND_EXPR");
  3999.         cleanups_this_call = 0;
  4000.       }
  4001.  
  4002.     emit_queue ();
  4003.     emit_label (op1);
  4004.     OK_DEFER_POP;
  4005.     cleanups_this_call = old_cleanups;
  4006.     return temp;
  4007.       }
  4008.  
  4009.     case TARGET_EXPR:
  4010.       {
  4011.     /* Something needs to be initialized, but we didn't know
  4012.        where that thing was when building the tree.  For example,
  4013.        it could be the return value of a function, or a parameter
  4014.        to a function which lays down in the stack, or a temporary
  4015.        variable which must be passed by reference.
  4016.  
  4017.        We guarantee that the expression will either be constructed
  4018.        or copied into our original target.  */
  4019.  
  4020.     tree slot = TREE_OPERAND (exp, 0);
  4021.  
  4022.     if (TREE_CODE (slot) != VAR_DECL)
  4023.       abort ();
  4024.  
  4025.     if (target == 0)
  4026.       {
  4027.         if (DECL_RTL (slot) != 0)
  4028.           target = DECL_RTL (slot);
  4029.         else
  4030.           {
  4031.         target = assign_stack_temp (mode, int_size_in_bytes (type), 0);
  4032.         /* All temp slots at this level must not conflict.  */
  4033.         preserve_temp_slots (target);
  4034.         DECL_RTL (slot) = target;
  4035.           }
  4036.  
  4037. #if 0
  4038.         /* Since SLOT is not known to the called function
  4039.            to belong to its stack frame, we must build an explicit
  4040.            cleanup.  This case occurs when we must build up a reference
  4041.            to pass the reference as an argument.  In this case,
  4042.            it is very likely that such a reference need not be
  4043.            built here.  */
  4044.  
  4045.         if (TREE_OPERAND (exp, 2) == 0)
  4046.           TREE_OPERAND (exp, 2) = maybe_build_cleanup (slot);
  4047.         if (TREE_OPERAND (exp, 2))
  4048.           cleanups_this_call = tree_cons (0, TREE_OPERAND (exp, 2),
  4049.                          cleanups_this_call);
  4050. #endif
  4051.       }
  4052.     else
  4053.       {
  4054.         /* This case does occur, when expanding a parameter which
  4055.            needs to be constructed on the stack.  The target
  4056.            is the actual stack address that we want to initialize.
  4057.            The function we call will perform the cleanup in this case.  */
  4058.  
  4059.         DECL_RTL (slot) = target;
  4060.       }
  4061.  
  4062.     return expand_expr (TREE_OPERAND (exp, 1), target, tmode, modifier);
  4063.       }
  4064.  
  4065.     case INIT_EXPR:
  4066.       {
  4067.     tree lhs = TREE_OPERAND (exp, 0);
  4068.     tree rhs = TREE_OPERAND (exp, 1);
  4069.     tree noncopied_parts = 0;
  4070.     tree lhs_type = TREE_TYPE (lhs);
  4071.  
  4072.     temp = expand_assignment (lhs, rhs, ! ignore, original_target != 0);
  4073.     if (TYPE_NONCOPIED_PARTS (lhs_type) != 0 && !fixed_type_p (rhs))
  4074.       noncopied_parts = init_noncopied_parts (stabilize_reference (lhs),
  4075.                           TYPE_NONCOPIED_PARTS (lhs_type));
  4076.     while (noncopied_parts != 0)
  4077.       {
  4078.         expand_assignment (TREE_VALUE (noncopied_parts),
  4079.                    TREE_PURPOSE (noncopied_parts), 0, 0);
  4080.         noncopied_parts = TREE_CHAIN (noncopied_parts);
  4081.       }
  4082.     return temp;
  4083.       }
  4084.  
  4085.     case MODIFY_EXPR:
  4086.       {
  4087.     /* If lhs is complex, expand calls in rhs before computing it.
  4088.        That's so we don't compute a pointer and save it over a call.
  4089.        If lhs is simple, compute it first so we can give it as a
  4090.        target if the rhs is just a call.  This avoids an extra temp and copy
  4091.        and that prevents a partial-subsumption which makes bad code.
  4092.        Actually we could treat component_ref's of vars like vars.  */
  4093.  
  4094.     tree lhs = TREE_OPERAND (exp, 0);
  4095.     tree rhs = TREE_OPERAND (exp, 1);
  4096.     tree noncopied_parts = 0;
  4097.     tree lhs_type = TREE_TYPE (lhs);
  4098.  
  4099.     temp = 0;
  4100.  
  4101.     if (TREE_CODE (lhs) != VAR_DECL
  4102.         && TREE_CODE (lhs) != RESULT_DECL
  4103.         && TREE_CODE (lhs) != PARM_DECL)
  4104.       preexpand_calls (exp);
  4105.  
  4106.     /* Check for |= or &= of a bitfield of size one into another bitfield
  4107.        of size 1.  In this case, (unless we need the result of the
  4108.        assignment) we can do this more efficiently with a
  4109.        test followed by an assignment, if necessary.
  4110.  
  4111.        ??? At this point, we can't get a BIT_FIELD_REF here.  But if
  4112.        things change so we do, this code should be enhanced to
  4113.        support it.  */
  4114.     if (ignore
  4115.         && TREE_CODE (lhs) == COMPONENT_REF
  4116.         && (TREE_CODE (rhs) == BIT_IOR_EXPR
  4117.         || TREE_CODE (rhs) == BIT_AND_EXPR)
  4118.         && TREE_OPERAND (rhs, 0) == lhs
  4119.         && TREE_CODE (TREE_OPERAND (rhs, 1)) == COMPONENT_REF
  4120.         && TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (lhs, 1))) == 1
  4121.         && TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (TREE_OPERAND (rhs, 1), 1))) == 1)
  4122.       {
  4123.         rtx label = gen_label_rtx ();
  4124.  
  4125.         do_jump (TREE_OPERAND (rhs, 1),
  4126.              TREE_CODE (rhs) == BIT_IOR_EXPR ? label : 0,
  4127.              TREE_CODE (rhs) == BIT_AND_EXPR ? label : 0);
  4128.         expand_assignment (lhs, convert (TREE_TYPE (rhs),
  4129.                          (TREE_CODE (rhs) == BIT_IOR_EXPR
  4130.                           ? integer_one_node
  4131.                           : integer_zero_node)),
  4132.                    0, 0);
  4133.         emit_label (label);
  4134.         return const0_rtx;
  4135.       }
  4136.  
  4137.     if (TYPE_NONCOPIED_PARTS (lhs_type) != 0
  4138.         && ! (fixed_type_p (lhs) && fixed_type_p (rhs)))
  4139.       noncopied_parts = save_noncopied_parts (stabilize_reference (lhs),
  4140.                           TYPE_NONCOPIED_PARTS (lhs_type));
  4141.  
  4142.     temp = expand_assignment (lhs, rhs, ! ignore, original_target != 0);
  4143.     while (noncopied_parts != 0)
  4144.       {
  4145.         expand_assignment (TREE_PURPOSE (noncopied_parts),
  4146.                    TREE_VALUE (noncopied_parts), 0, 0);
  4147.         noncopied_parts = TREE_CHAIN (noncopied_parts);
  4148.       }
  4149.     return temp;
  4150.       }
  4151.  
  4152.     case PREINCREMENT_EXPR:
  4153.     case PREDECREMENT_EXPR:
  4154.       return expand_increment (exp, 0);
  4155.  
  4156.     case POSTINCREMENT_EXPR:
  4157.     case POSTDECREMENT_EXPR:
  4158.       /* Faster to treat as pre-increment if result is not used.  */
  4159.       return expand_increment (exp, ! ignore);
  4160.  
  4161.     case ADDR_EXPR:
  4162.       /* Are we taking the address of a nested function?  */
  4163.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == FUNCTION_DECL
  4164.       && decl_function_context (TREE_OPERAND (exp, 0)) != 0)
  4165.     return trampoline_address (TREE_OPERAND (exp, 0));
  4166.       op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode,
  4167.              (modifier != EXPAND_INTO_STACK
  4168.               ? EXPAND_CONST_ADDRESS
  4169.               : EXPAND_INTO_STACK));
  4170.       if (GET_CODE (op0) != MEM)
  4171.     abort ();
  4172.   
  4173.       if (modifier == EXPAND_SUM)
  4174.     return XEXP (op0, 0);
  4175.       op0 = force_operand (XEXP (op0, 0), target);
  4176.       if (flag_force_addr && GET_CODE (op0) != REG)
  4177.     return force_reg (Pmode, op0);
  4178.       return op0;
  4179.  
  4180.     case ENTRY_VALUE_EXPR:
  4181.       abort ();
  4182.  
  4183.     case ERROR_MARK:
  4184.       return const0_rtx;
  4185.  
  4186.     default:
  4187.       return (*lang_expand_expr) (exp, target, tmode, modifier);
  4188.     }
  4189.  
  4190.   /* Here to do an ordinary binary operator, generating an instruction
  4191.      from the optab already placed in `this_optab'.  */
  4192.  binop:
  4193.   preexpand_calls (exp);
  4194.   if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1)))
  4195.     subtarget = 0;
  4196.   op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  4197.   op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
  4198.  binop2:
  4199.   temp = expand_binop (mode, this_optab, op0, op1, target,
  4200.                unsignedp, OPTAB_LIB_WIDEN);
  4201.   if (temp == 0)
  4202.     abort ();
  4203.   return temp;
  4204. }
  4205.  
  4206. /* Return the alignment of EXP, a pointer valued expression for the mem*
  4207.    builtin functions.  Alignments greater than MAX_ALIGN are not significant.
  4208.    The alignment returned is, by default, the alignment of the thing that
  4209.    EXP points to (if it is not a POINTER_TYPE, 0 is returned).
  4210.  
  4211.    Otherwise, look at the expression to see if we can do better, i.e., if the
  4212.    expression is actually pointing at an object whose alignment is tighter.  */
  4213.  
  4214. static int
  4215. get_pointer_alignment (exp, max_align)
  4216.      tree exp;
  4217.      int max_align;
  4218. {
  4219.   int align, inner;
  4220.  
  4221.   if (TREE_CODE (TREE_TYPE (exp)) != POINTER_TYPE)
  4222.     return 0;
  4223.  
  4224.   align = TYPE_ALIGN (TREE_TYPE (TREE_TYPE (exp)));
  4225.   align = MIN (align, max_align);
  4226.  
  4227.   while (1)
  4228.     {
  4229.       switch (TREE_CODE (exp))
  4230.     {
  4231.     case NOP_EXPR:
  4232.     case CONVERT_EXPR:
  4233.     case NON_LVALUE_EXPR:
  4234.       exp = TREE_OPERAND (exp, 0);
  4235.       if (TREE_CODE (TREE_TYPE (exp)) != POINTER_TYPE)
  4236.         return align;
  4237.       inner = TYPE_ALIGN (TREE_TYPE (TREE_TYPE (exp)));
  4238.       inner = MIN (inner, max_align);
  4239.       align = MAX (align, inner);
  4240.       break;
  4241.  
  4242.     case PLUS_EXPR:
  4243.       /* If sum of pointer + int, restrict our maximum alignment to that
  4244.          imposed by the integer.  If not, we can't do any better than
  4245.          ALIGN.  */
  4246.       if (TREE_CODE (TREE_OPERAND (exp, 1)) != INTEGER_CST)
  4247.         return align;
  4248.  
  4249.       while ((TREE_INT_CST_LOW (TREE_OPERAND (exp, 1))
  4250.           & (max_align - 1)) != 0)
  4251.         max_align >>= 1;
  4252.  
  4253.       exp = TREE_OPERAND (exp, 0);
  4254.       break;
  4255.  
  4256.     case ADDR_EXPR:
  4257.       /* See what we are pointing at and look at its alignment.  */
  4258.       exp = TREE_OPERAND (exp, 0);
  4259.       if (TREE_CODE_CLASS (TREE_CODE (exp)) == 'd')
  4260.         align = MAX (align, DECL_ALIGN (exp));
  4261. #ifdef CONSTANT_ALIGNMENT
  4262.       else if (TREE_CODE_CLASS (TREE_CODE (exp)) == 'c')
  4263.         align = CONSTANT_ALIGNMENT (exp, align);
  4264. #endif
  4265.       return MIN (align, max_align);
  4266.  
  4267.     default:
  4268.       return align;
  4269.     }
  4270.     }
  4271. }
  4272.  
  4273. /* Return the tree node and offset if a given argument corresponds to
  4274.    a string constant.  */
  4275.  
  4276. static tree
  4277. string_constant (arg, ptr_offset)
  4278.      tree arg;
  4279.      tree *ptr_offset;
  4280. {
  4281.   while (TREE_CODE (arg) == NOP_EXPR
  4282.      || TREE_CODE (arg) == CONVERT_EXPR
  4283.      || TREE_CODE (arg) == NON_LVALUE_EXPR)
  4284.     arg = TREE_OPERAND (arg, 0);
  4285.  
  4286.   if (TREE_CODE (arg) == ADDR_EXPR
  4287.       && TREE_CODE (TREE_OPERAND (arg, 0)) == STRING_CST)
  4288.     {
  4289.       *ptr_offset = integer_zero_node;
  4290.       return TREE_OPERAND (arg, 0);
  4291.     }
  4292.   else if (TREE_CODE (arg) == PLUS_EXPR)
  4293.     {
  4294.       if (TREE_CODE (TREE_OPERAND (arg, 0)) == ADDR_EXPR
  4295.       && TREE_CODE (TREE_OPERAND (TREE_OPERAND (arg, 0), 0)) == STRING_CST)
  4296.     {
  4297.       *ptr_offset = TREE_OPERAND (arg, 1);
  4298.       return TREE_OPERAND (TREE_OPERAND (arg, 0), 0);
  4299.     }
  4300.       else if (TREE_CODE (TREE_OPERAND (arg, 1)) == ADDR_EXPR
  4301.            && TREE_CODE (TREE_OPERAND (TREE_OPERAND (arg, 1), 0)) == STRING_CST)
  4302.     {
  4303.       *ptr_offset = TREE_OPERAND (arg, 0);
  4304.       return TREE_OPERAND (TREE_OPERAND (arg, 1), 0);
  4305.     }
  4306.     }
  4307.  
  4308.   return 0;
  4309. }
  4310.  
  4311. /* Expand an expression EXP that calls a built-in function,
  4312.    with result going to TARGET if that's convenient
  4313.    (and in mode MODE if that's convenient).
  4314.    SUBTARGET may be used as the target for computing one of EXP's operands.
  4315.    IGNORE is nonzero if the value is to be ignored.  */
  4316.  
  4317. static rtx
  4318. expand_builtin (exp, target, subtarget, mode, ignore)
  4319.      tree exp;
  4320.      rtx target;
  4321.      rtx subtarget;
  4322.      enum machine_mode mode;
  4323.      int ignore;
  4324. {
  4325.   tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
  4326.   tree arglist = TREE_OPERAND (exp, 1);
  4327.   rtx op0;
  4328.  
  4329.   switch (DECL_FUNCTION_CODE (fndecl))
  4330.     {
  4331.     case BUILT_IN_ABS:
  4332.     case BUILT_IN_LABS:
  4333.     case BUILT_IN_FABS:
  4334.       /* build_function_call changes these into ABS_EXPR.  */
  4335.       abort ();
  4336.  
  4337.     case BUILT_IN_SAVEREGS:
  4338.       /* Don't do __builtin_saveregs more than once in a function.
  4339.      Save the result of the first call and reuse it.  */
  4340.       if (saveregs_value != 0)
  4341.     return saveregs_value;
  4342.       {
  4343.     /* When this function is called, it means that registers must be
  4344.        saved on entry to this function.  So we migrate the
  4345.        call to the first insn of this function.  */
  4346.     rtx temp;
  4347.     rtx seq;
  4348.     /* Now really call the function.  `expand_call' does not call
  4349.        expand_builtin, so there is no danger of infinite recursion here.  */
  4350.     start_sequence ();
  4351. #ifdef EXPAND_BUILTIN_SAVEREGS
  4352.     /* Do whatever the machine needs done in this case.  */
  4353.     temp = EXPAND_BUILTIN_SAVEREGS (arglist);
  4354. #else
  4355.     temp = expand_call (exp, target, ignore);
  4356. #endif
  4357.     seq = get_insns ();
  4358.     end_sequence ();
  4359.  
  4360.     saveregs_value = temp;
  4361.  
  4362.     /* This won't work inside a SEQUENCE--it really has to be
  4363.        at the start of the function.  */
  4364.     if (in_sequence_p ())
  4365.       {
  4366.         /* Better to do this than to crash.  */
  4367.         error ("`va_start' used within `({...})'");
  4368.         return temp;
  4369.       }
  4370.  
  4371.     /* Put the sequence after the NOTE that starts the function.  */
  4372.     emit_insns_before (seq, NEXT_INSN (get_insns ()));
  4373.     return temp;
  4374.       }
  4375.  
  4376.     case BUILT_IN_NEXT_ARG:
  4377.       {
  4378.     tree fntype = TREE_TYPE (current_function_decl);
  4379.     if (!(TYPE_ARG_TYPES (fntype) != 0
  4380.           && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (fntype)))
  4381.           != void_type_node)))
  4382.       {
  4383.         error ("`stdarg.h' facilities used, but function has fixed args");
  4384.         return const0_rtx;
  4385.       }
  4386.       }
  4387.  
  4388.       return expand_binop (Pmode, add_optab,
  4389.                virtual_incoming_args_rtx,
  4390.                current_function_arg_offset_rtx,
  4391.                0, 0, OPTAB_LIB_WIDEN);
  4392.  
  4393.     case BUILT_IN_CLASSIFY_TYPE:
  4394.       if (arglist != 0)
  4395.     {
  4396.       tree type = TREE_TYPE (TREE_VALUE (arglist));
  4397.       enum tree_code code = TREE_CODE (type);
  4398.       if (code == VOID_TYPE)
  4399.         return gen_rtx (CONST_INT, VOIDmode, void_type_class);
  4400.       if (code == INTEGER_TYPE)
  4401.         return gen_rtx (CONST_INT, VOIDmode, integer_type_class);
  4402.       if (code == CHAR_TYPE)
  4403.         return gen_rtx (CONST_INT, VOIDmode, char_type_class);
  4404.       if (code == ENUMERAL_TYPE)
  4405.         return gen_rtx (CONST_INT, VOIDmode, enumeral_type_class);
  4406.       if (code == BOOLEAN_TYPE)
  4407.         return gen_rtx (CONST_INT, VOIDmode, boolean_type_class);
  4408.       if (code == POINTER_TYPE)
  4409.         return gen_rtx (CONST_INT, VOIDmode, pointer_type_class);
  4410.       if (code == REFERENCE_TYPE)
  4411.         return gen_rtx (CONST_INT, VOIDmode, reference_type_class);
  4412.       if (code == OFFSET_TYPE)
  4413.         return gen_rtx (CONST_INT, VOIDmode, offset_type_class);
  4414.       if (code == REAL_TYPE)
  4415.         return gen_rtx (CONST_INT, VOIDmode, real_type_class);
  4416.       if (code == COMPLEX_TYPE)
  4417.         return gen_rtx (CONST_INT, VOIDmode, complex_type_class);
  4418.       if (code == FUNCTION_TYPE)
  4419.         return gen_rtx (CONST_INT, VOIDmode, function_type_class);
  4420.       if (code == METHOD_TYPE)
  4421.         return gen_rtx (CONST_INT, VOIDmode, method_type_class);
  4422.       if (code == RECORD_TYPE)
  4423.         return gen_rtx (CONST_INT, VOIDmode, record_type_class);
  4424.       if (code == UNION_TYPE)
  4425.         return gen_rtx (CONST_INT, VOIDmode, union_type_class);
  4426.       if (code == ARRAY_TYPE)
  4427.         return gen_rtx (CONST_INT, VOIDmode, array_type_class);
  4428.       if (code == STRING_TYPE)
  4429.         return gen_rtx (CONST_INT, VOIDmode, string_type_class);
  4430.       if (code == SET_TYPE)
  4431.         return gen_rtx (CONST_INT, VOIDmode, set_type_class);
  4432.       if (code == FILE_TYPE)
  4433.         return gen_rtx (CONST_INT, VOIDmode, file_type_class);
  4434.       if (code == LANG_TYPE)
  4435.         return gen_rtx (CONST_INT, VOIDmode, lang_type_class);
  4436.     }
  4437.       return gen_rtx (CONST_INT, VOIDmode, no_type_class);
  4438.  
  4439.     case BUILT_IN_CONSTANT_P:
  4440.       return (TREE_CODE_CLASS (TREE_VALUE (arglist)) == 'c'
  4441.           ? const1_rtx : const0_rtx);
  4442.  
  4443.     case BUILT_IN_ALLOCA:
  4444.       if (arglist == 0
  4445.       /* Arg could be non-integer if user redeclared this fcn wrong.  */
  4446.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != INTEGER_TYPE)
  4447.     return const0_rtx;
  4448.       current_function_calls_alloca = 1;
  4449.       /* Compute the argument.  */
  4450.       op0 = expand_expr (TREE_VALUE (arglist), 0, VOIDmode, 0);
  4451.  
  4452.       /* Allocate the desired space.  */
  4453.       target = allocate_dynamic_stack_space (op0, target);
  4454.  
  4455.       /* Record the new stack level for nonlocal gotos.  */
  4456.       if (nonlocal_goto_stack_level != 0)
  4457.     emit_move_insn (nonlocal_goto_stack_level, stack_pointer_rtx);
  4458.       return target;
  4459.  
  4460.     case BUILT_IN_FFS:
  4461.       if (arglist == 0
  4462.       /* Arg could be non-integer if user redeclared this fcn wrong.  */
  4463.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != INTEGER_TYPE)
  4464.     return const0_rtx;
  4465.  
  4466.       /* Compute the argument.  */
  4467.       op0 = expand_expr (TREE_VALUE (arglist), subtarget, VOIDmode, 0);
  4468.       /* Compute ffs, into TARGET if possible.
  4469.      Set TARGET to wherever the result comes back.  */
  4470.       target = expand_unop (TYPE_MODE (TREE_TYPE (TREE_VALUE (arglist))),
  4471.                 ffs_optab, op0, target, 1);
  4472.       if (target == 0)
  4473.     abort ();
  4474.       return target;
  4475.  
  4476.     case BUILT_IN_STRCPY:
  4477.       {
  4478.     tree src = TREE_VALUE (TREE_CHAIN (arglist));
  4479.     tree offset;
  4480.     tree len;
  4481.  
  4482.     src = string_constant (src, &offset);
  4483.     if (src == 0)
  4484.       break;
  4485.  
  4486.     len = size_binop (MINUS_EXPR,
  4487.               build_int_2 (TREE_STRING_LENGTH (src), 0),
  4488.               offset);
  4489.         
  4490.     chainon (arglist, build_tree_list (0, len));
  4491.       }
  4492.  
  4493.       /* Drops in.  */
  4494.     case BUILT_IN_MEMCPY:
  4495.       {
  4496.     tree dest = TREE_VALUE (arglist);
  4497.     tree src = TREE_VALUE (TREE_CHAIN (arglist));
  4498.     tree len = TREE_VALUE (TREE_CHAIN (TREE_CHAIN (arglist)));
  4499.  
  4500.     int src_align
  4501.       = get_pointer_alignment (src, BIGGEST_ALIGNMENT) / BITS_PER_UNIT;
  4502.     int dest_align
  4503.       = get_pointer_alignment (dest, BIGGEST_ALIGNMENT) / BITS_PER_UNIT;
  4504.     rtx dest_rtx;
  4505.  
  4506.     /* If either SRC or DEST is not a pointer type, don't do
  4507.        this operation in-line.  */
  4508.     if (src_align == 0 || dest_align == 0)
  4509.       break;
  4510.  
  4511.     dest_rtx = expand_expr (dest, 0, Pmode, EXPAND_NORMAL);
  4512.  
  4513.     /* Copy word part most expediently.  */
  4514.     emit_block_move (gen_rtx (MEM, BLKmode, dest_rtx),
  4515.              gen_rtx (MEM, BLKmode,
  4516.                   expand_expr (src, 0, Pmode, EXPAND_NORMAL)),
  4517.              expand_expr (len, 0, VOIDmode, 0),
  4518.              MIN (src_align, dest_align));
  4519.     return dest_rtx;
  4520.       }
  4521.  
  4522. /* These comparison functions need an instruction that returns an actual
  4523.    index.  An ordinary compare that just sets the condition codes
  4524.    is not enough.  */
  4525. #ifdef HAVE_cmpstrsi
  4526.     case BUILT_IN_STRCMP:
  4527.       {
  4528.     tree arg1 = TREE_VALUE (arglist);
  4529.     tree arg2 = TREE_VALUE (TREE_CHAIN (arglist));
  4530.     tree offset;
  4531.     tree len = 0;
  4532.  
  4533.     arg1 = string_constant (arg1, &offset);
  4534.     if (arg1)
  4535.       len = size_binop (MINUS_EXPR,
  4536.                 build_int_2 (TREE_STRING_LENGTH (arg1), 0),
  4537.                 offset);
  4538.     else
  4539.       {
  4540.         arg2 = string_constant (arg2, &offset);
  4541.         if (arg2)
  4542.           len = size_binop (MINUS_EXPR,
  4543.                 build_int_2 (TREE_STRING_LENGTH (arg2), 0),
  4544.                 offset);
  4545.       }
  4546.  
  4547.     if (len == 0)
  4548.       break;
  4549.  
  4550.     chainon (arglist, build_tree_list (0, len));
  4551.       }
  4552.  
  4553.       /* Drops in.  */
  4554.     case BUILT_IN_MEMCMP:
  4555.       {
  4556.     tree arg1 = TREE_VALUE (arglist);
  4557.     tree arg2 = TREE_VALUE (TREE_CHAIN (arglist));
  4558.     tree len = TREE_VALUE (TREE_CHAIN (TREE_CHAIN (arglist)));
  4559.  
  4560.     int arg1_align
  4561.       = get_pointer_alignment (arg1, BIGGEST_ALIGNMENT) / BITS_PER_UNIT;
  4562.     int arg2_align
  4563.       = get_pointer_alignment (arg2, BIGGEST_ALIGNMENT) / BITS_PER_UNIT;
  4564.     rtx result;
  4565.  
  4566.     /* If we don't have POINTER_TYPE, call the function.  */
  4567.     if (arg1_align == 0 || arg2_align == 0)
  4568.       break;
  4569.  
  4570.     result = gen_reg_rtx (mode != VOIDmode ? mode
  4571.                   : mode_for_size (BITS_PER_WORD, MODE_INT, 0));
  4572.     emit_insn (gen_cmpstrsi (result,
  4573.                  gen_rtx (MEM, BLKmode,
  4574.                       expand_expr (arg1, 0, Pmode, EXPAND_NORMAL)),
  4575.                  gen_rtx (MEM, BLKmode,
  4576.                       expand_expr (arg2, 0, Pmode, EXPAND_NORMAL)),
  4577.                  expand_expr (len, 0, VOIDmode, 0),
  4578.                  gen_rtx (CONST_INT, VOIDmode,
  4579.                       MIN (arg1_align, arg2_align))));
  4580.     return result;
  4581.       }    
  4582. #else
  4583.     case BUILT_IN_STRCMP:
  4584.     case BUILT_IN_MEMCMP:
  4585.       break;
  4586. #endif
  4587.  
  4588.     default:            /* just do library call, if unknown builtin */
  4589.       error ("built-in function %s not currently supported",
  4590.          IDENTIFIER_POINTER (DECL_NAME (fndecl)));
  4591.     }
  4592.  
  4593.   /* The switch statement above can drop through to cause the function
  4594.      to be called normally.  */
  4595.  
  4596.   return expand_call (exp, target, ignore);
  4597. }
  4598.  
  4599. /* Expand code for a post- or pre- increment or decrement
  4600.    and return the RTX for the result.
  4601.    POST is 1 for postinc/decrements and 0 for preinc/decrements.  */
  4602.  
  4603. static rtx
  4604. expand_increment (exp, post)
  4605.      register tree exp;
  4606.      int post;
  4607. {
  4608.   register rtx op0, op1;
  4609.   register rtx temp, value;
  4610.   register tree incremented = TREE_OPERAND (exp, 0);
  4611.   optab this_optab = add_optab;
  4612.   int icode;
  4613.   enum machine_mode mode = TYPE_MODE (TREE_TYPE (exp));
  4614.   int op0_is_copy = 0;
  4615.  
  4616.   /* Stabilize any component ref that might need to be
  4617.      evaluated more than once below.  */
  4618.   if (TREE_CODE (incremented) == BIT_FIELD_REF
  4619.       || (TREE_CODE (incremented) == COMPONENT_REF
  4620.       && (TREE_CODE (TREE_OPERAND (incremented, 0)) != INDIRECT_REF
  4621.           || DECL_BIT_FIELD (TREE_OPERAND (incremented, 1)))))
  4622.     incremented = stabilize_reference (incremented);
  4623.  
  4624.   /* Compute the operands as RTX.
  4625.      Note whether OP0 is the actual lvalue or a copy of it:
  4626.      I believe it is a copy iff it is a register and insns were
  4627.      generated in computing it.  */
  4628.   temp = get_last_insn ();
  4629.   op0 = expand_expr (incremented, 0, VOIDmode, 0);
  4630.   if (temp != get_last_insn ())
  4631.     op0_is_copy = (GET_CODE (op0) == REG || GET_CODE (op0) == SUBREG);
  4632.   op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
  4633.  
  4634.   /* Decide whether incrementing or decrementing.  */
  4635.   if (TREE_CODE (exp) == POSTDECREMENT_EXPR
  4636.       || TREE_CODE (exp) == PREDECREMENT_EXPR)
  4637.     this_optab = sub_optab;
  4638.  
  4639.   /* If OP0 is not the actual lvalue, but rather a copy in a register,
  4640.      then we cannot just increment OP0.  We must
  4641.      therefore contrive to increment the original value.
  4642.      Then we can return OP0 since it is a copy of the old value.  */
  4643.   if (op0_is_copy)
  4644.     {
  4645.       /* This is the easiest way to increment the value wherever it is.
  4646.      Problems with multiple evaluation of INCREMENTED
  4647.      are prevented because either (1) it is a component_ref,
  4648.      in which case it was stabilized above, or (2) it is an array_ref
  4649.      with constant index in an array in a register, which is
  4650.      safe to reevaluate.  */
  4651.       tree newexp = build ((this_optab == add_optab
  4652.                 ? PLUS_EXPR : MINUS_EXPR),
  4653.                TREE_TYPE (exp),
  4654.                incremented,
  4655.                TREE_OPERAND (exp, 1));
  4656.       temp = expand_assignment (incremented, newexp, ! post, 0);
  4657.       return post ? op0 : temp;
  4658.     }
  4659.  
  4660.   /* Convert decrement by a constant into a negative increment.  */
  4661.   if (this_optab == sub_optab
  4662.       && GET_CODE (op1) == CONST_INT)
  4663.     {
  4664.       op1 = gen_rtx (CONST_INT, VOIDmode, - INTVAL (op1));
  4665.       this_optab = add_optab;
  4666.     }
  4667.  
  4668.   if (post)
  4669.     {
  4670.       /* We have a true reference to the value in OP0.
  4671.      If there is an insn to add or subtract in this mode, queue it.  */
  4672.  
  4673. #if 0  /* Turned off to avoid making extra insn for indexed memref.  */
  4674.       op0 = stabilize (op0);
  4675. #endif
  4676.  
  4677.       icode = (int) this_optab->handlers[(int) mode].insn_code;
  4678.       if (icode != (int) CODE_FOR_nothing
  4679.       /* Make sure that OP0 is valid for operands 0 and 1
  4680.          of the insn we want to queue.  */
  4681.       && (*insn_operand_predicate[icode][0]) (op0, mode)
  4682.       && (*insn_operand_predicate[icode][1]) (op0, mode))
  4683.     {
  4684.       if (! (*insn_operand_predicate[icode][2]) (op1, mode))
  4685.         op1 = force_reg (mode, op1);
  4686.  
  4687.       return enqueue_insn (op0, GEN_FCN (icode) (op0, op0, op1));
  4688.     }
  4689.     }
  4690.  
  4691.   /* Preincrement, or we can't increment with one simple insn.  */
  4692.   if (post)
  4693.     /* Save a copy of the value before inc or dec, to return it later.  */
  4694.     temp = value = copy_to_reg (op0);
  4695.   else
  4696.     /* Arrange to return the incremented value.  */
  4697.     /* Copy the rtx because expand_binop will protect from the queue,
  4698.        and the results of that would be invalid for us to return
  4699.        if our caller does emit_queue before using our result.  */
  4700.     temp = copy_rtx (value = op0);
  4701.  
  4702.   /* Increment however we can.  */
  4703.   op1 = expand_binop (mode, this_optab, value, op1, op0,
  4704.               TREE_UNSIGNED (TREE_TYPE (exp)), OPTAB_LIB_WIDEN);
  4705.   /* Make sure the value is stored into OP0.  */
  4706.   if (op1 != op0)
  4707.     emit_move_insn (op0, op1);
  4708.  
  4709.   return temp;
  4710. }
  4711.  
  4712. /* Expand all function calls contained within EXP, innermost ones first.
  4713.    But don't look within expressions that have sequence points.
  4714.    For each CALL_EXPR, record the rtx for its value
  4715.    in the CALL_EXPR_RTL field.  */
  4716.  
  4717. static void
  4718. preexpand_calls (exp)
  4719.      tree exp;
  4720. {
  4721.   register int nops, i;
  4722.   int type = TREE_CODE_CLASS (TREE_CODE (exp));
  4723.  
  4724.   if (! do_preexpand_calls)
  4725.     return;
  4726.  
  4727.   /* Only expressions and references can contain calls.  */
  4728.  
  4729.   if (type != 'e' && type != '<' && type != '1' && type != '2' && type != 'r')
  4730.     return;
  4731.  
  4732.   switch (TREE_CODE (exp))
  4733.     {
  4734.     case CALL_EXPR:
  4735.       /* Do nothing if already expanded.  */
  4736.       if (CALL_EXPR_RTL (exp) != 0)
  4737.     return;
  4738.  
  4739.       /* Do nothing to built-in functions.  */
  4740.       if (TREE_CODE (TREE_OPERAND (exp, 0)) != ADDR_EXPR
  4741.       || TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) != FUNCTION_DECL
  4742.       || ! DECL_BUILT_IN (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
  4743.     CALL_EXPR_RTL (exp) = expand_call (exp, 0, 0, 0);
  4744.       return;
  4745.  
  4746.     case COMPOUND_EXPR:
  4747.     case COND_EXPR:
  4748.     case TRUTH_ANDIF_EXPR:
  4749.     case TRUTH_ORIF_EXPR:
  4750.       /* If we find one of these, then we can be sure
  4751.      the adjust will be done for it (since it makes jumps).
  4752.      Do it now, so that if this is inside an argument
  4753.      of a function, we don't get the stack adjustment
  4754.      after some other args have already been pushed.  */
  4755.       do_pending_stack_adjust ();
  4756.       return;
  4757.  
  4758.     case BLOCK:
  4759.     case RTL_EXPR:
  4760.       return;
  4761.  
  4762.     case SAVE_EXPR:
  4763.       if (SAVE_EXPR_RTL (exp) != 0)
  4764.     return;
  4765.     }
  4766.  
  4767.   nops = tree_code_length[(int) TREE_CODE (exp)];
  4768.   for (i = 0; i < nops; i++)
  4769.     if (TREE_OPERAND (exp, i) != 0)
  4770.       {
  4771.     type = TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, i)));
  4772.     if (type == 'e' || type == '<' || type == '1' || type == '2'
  4773.         || type == 'r')
  4774.       preexpand_calls (TREE_OPERAND (exp, i));
  4775.       }
  4776. }
  4777.  
  4778. /* At the start of a function, record that we have no previously-pushed
  4779.    arguments waiting to be popped.  */
  4780.  
  4781. void
  4782. init_pending_stack_adjust ()
  4783. {
  4784.   pending_stack_adjust = 0;
  4785. }
  4786.  
  4787. /* When exiting from function, if safe, clear out any pending stack adjust
  4788.    so the adjustment won't get done.  */
  4789.  
  4790. void
  4791. clear_pending_stack_adjust ()
  4792. {
  4793. #ifdef EXIT_IGNORE_STACK
  4794.   if (!flag_omit_frame_pointer && EXIT_IGNORE_STACK
  4795.       && ! (TREE_INLINE (current_function_decl) && optimize)
  4796.       && ! flag_inline_functions)
  4797.     pending_stack_adjust = 0;
  4798. #endif
  4799. }
  4800.  
  4801. /* Pop any previously-pushed arguments that have not been popped yet.  */
  4802.  
  4803. void
  4804. do_pending_stack_adjust ()
  4805. {
  4806.   if (inhibit_defer_pop == 0)
  4807.     {
  4808.       if (pending_stack_adjust != 0)
  4809.     adjust_stack (gen_rtx (CONST_INT, VOIDmode, pending_stack_adjust));
  4810.       pending_stack_adjust = 0;
  4811.     }
  4812. }
  4813.  
  4814. /* Expand all cleanups up to OLD_CLEANUPS.
  4815.    Needed here, and also for language-dependent calls.  */
  4816.  
  4817. void
  4818. expand_cleanups_to (old_cleanups)
  4819.      tree old_cleanups;
  4820. {
  4821.   while (cleanups_this_call != old_cleanups)
  4822.     {
  4823.       expand_expr (TREE_VALUE (cleanups_this_call), 0, VOIDmode, 0);
  4824.       cleanups_this_call = TREE_CHAIN (cleanups_this_call);
  4825.     }
  4826. }
  4827.  
  4828. /* Expand conditional expressions.  */
  4829.  
  4830. /* Generate code to evaluate EXP and jump to LABEL if the value is zero.
  4831.    LABEL is an rtx of code CODE_LABEL, in this function and all the
  4832.    functions here.  */
  4833.  
  4834. void
  4835. jumpifnot (exp, label)
  4836.      tree exp;
  4837.      rtx label;
  4838. {
  4839.   do_jump (exp, label, 0);
  4840. }
  4841.  
  4842. /* Generate code to evaluate EXP and jump to LABEL if the value is nonzero.  */
  4843.  
  4844. void
  4845. jumpif (exp, label)
  4846.      tree exp;
  4847.      rtx label;
  4848. {
  4849.   do_jump (exp, 0, label);
  4850. }
  4851.  
  4852. /* Generate code to evaluate EXP and jump to IF_FALSE_LABEL if
  4853.    the result is zero, or IF_TRUE_LABEL if the result is one.
  4854.    Either of IF_FALSE_LABEL and IF_TRUE_LABEL may be zero,
  4855.    meaning fall through in that case.
  4856.  
  4857.    This function is responsible for optimizing cases such as
  4858.    &&, || and comparison operators in EXP.  */
  4859.  
  4860. void
  4861. do_jump (exp, if_false_label, if_true_label)
  4862.      tree exp;
  4863.      rtx if_false_label, if_true_label;
  4864. {
  4865.   register enum tree_code code = TREE_CODE (exp);
  4866.   /* Some cases need to create a label to jump to
  4867.      in order to properly fall through.
  4868.      These cases set DROP_THROUGH_LABEL nonzero.  */
  4869.   rtx drop_through_label = 0;
  4870.   rtx temp;
  4871.   rtx comparison = 0;
  4872.   int i;
  4873.   tree type;
  4874.  
  4875.   emit_queue ();
  4876.  
  4877.   switch (code)
  4878.     {
  4879.     case ERROR_MARK:
  4880.       break;
  4881.  
  4882.     case INTEGER_CST:
  4883.       temp = integer_zerop (exp) ? if_false_label : if_true_label;
  4884.       if (temp)
  4885.     emit_jump (temp);
  4886.       break;
  4887.  
  4888. #if 0
  4889.       /* This is not true with #pragma weak  */
  4890.     case ADDR_EXPR:
  4891.       /* The address of something can never be zero.  */
  4892.       if (if_true_label)
  4893.     emit_jump (if_true_label);
  4894.       break;
  4895. #endif
  4896.  
  4897.     case NOP_EXPR:
  4898.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == COMPONENT_REF
  4899.       || TREE_CODE (TREE_OPERAND (exp, 0)) == BIT_FIELD_REF
  4900.       || TREE_CODE (TREE_OPERAND (exp, 0)) == ARRAY_REF)
  4901.     goto normal;
  4902.     case CONVERT_EXPR:
  4903.       /* If we are narrowing the operand, we have to do the compare in the
  4904.      narrower mode.  */
  4905.       if ((TYPE_PRECISION (TREE_TYPE (exp))
  4906.        < TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  4907.     goto normal;
  4908.     case NON_LVALUE_EXPR:
  4909.     case REFERENCE_EXPR:
  4910.     case ABS_EXPR:
  4911.     case NEGATE_EXPR:
  4912.     case LROTATE_EXPR:
  4913.     case RROTATE_EXPR:
  4914.       /* These cannot change zero->non-zero or vice versa.  */
  4915.       do_jump (TREE_OPERAND (exp, 0), if_false_label, if_true_label);
  4916.       break;
  4917.  
  4918. #if 0
  4919.       /* This is never less insns than evaluating the PLUS_EXPR followed by
  4920.      a test and can be longer if the test is eliminated.  */
  4921.     case PLUS_EXPR:
  4922.       /* Reduce to minus.  */
  4923.       exp = build (MINUS_EXPR, TREE_TYPE (exp),
  4924.            TREE_OPERAND (exp, 0),
  4925.            fold (build1 (NEGATE_EXPR, TREE_TYPE (TREE_OPERAND (exp, 1)),
  4926.                  TREE_OPERAND (exp, 1))));
  4927.       /* Process as MINUS.  */
  4928. #endif
  4929.  
  4930.     case MINUS_EXPR:
  4931.       /* Non-zero iff operands of minus differ.  */
  4932.       comparison = compare (build (NE_EXPR, TREE_TYPE (exp),
  4933.                    TREE_OPERAND (exp, 0),
  4934.                    TREE_OPERAND (exp, 1)),
  4935.                 NE, NE);
  4936.       break;
  4937.  
  4938.     case BIT_AND_EXPR:
  4939.       /* If we are AND'ing with a small constant, do this comparison in the
  4940.      smallest type that fits.  If the machine doesn't have comparisons
  4941.      that small, it will be converted back to the wider comparison.
  4942.      This helps if we are testing the sign bit of a narrower object.
  4943.      combine can't do this for us because it can't know whether a
  4944.      ZERO_EXTRACT or a compare in a smaller mode exists, but we do.  */
  4945.  
  4946.       if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST
  4947.       && TYPE_PRECISION (TREE_TYPE (exp)) <= HOST_BITS_PER_INT
  4948.       && (i = floor_log2 (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)))) >= 0
  4949.       && (type = type_for_size (i + 1, 1)) != 0
  4950.       && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (exp)))
  4951.     {
  4952.       do_jump (convert (type, exp), if_false_label, if_true_label);
  4953.       break;
  4954.     }
  4955.       goto normal;
  4956.  
  4957.     case TRUTH_NOT_EXPR:
  4958.       do_jump (TREE_OPERAND (exp, 0), if_true_label, if_false_label);
  4959.       break;
  4960.  
  4961.     case TRUTH_ANDIF_EXPR:
  4962.       if (if_false_label == 0)
  4963.     if_false_label = drop_through_label = gen_label_rtx ();
  4964.       do_jump (TREE_OPERAND (exp, 0), if_false_label, 0);
  4965.       do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label);
  4966.       break;
  4967.  
  4968.     case TRUTH_ORIF_EXPR:
  4969.       if (if_true_label == 0)
  4970.     if_true_label = drop_through_label = gen_label_rtx ();
  4971.       do_jump (TREE_OPERAND (exp, 0), 0, if_true_label);
  4972.       do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label);
  4973.       break;
  4974.  
  4975.     case COMPOUND_EXPR:
  4976.       expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0);
  4977.       free_temp_slots ();
  4978.       emit_queue ();
  4979.       do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label);
  4980.       break;
  4981.  
  4982.     case COMPONENT_REF:
  4983.     case BIT_FIELD_REF:
  4984.     case ARRAY_REF:
  4985.       {
  4986.     int bitsize, bitpos, unsignedp;
  4987.     enum machine_mode mode;
  4988.     tree type;
  4989.     int volatilep = 0;
  4990.  
  4991.     /* Get description of this reference.  We don't actually care
  4992.        about the underlying object here.  */
  4993.     get_inner_reference (exp, &bitsize, &bitpos, &mode, &unsignedp,
  4994.                  &volatilep);
  4995.  
  4996.     type = type_for_size (bitsize, unsignedp);
  4997.     if (type != 0
  4998.         && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (exp)))
  4999.       {
  5000.         do_jump (convert (type, exp), if_false_label, if_true_label);
  5001.         break;
  5002.       }
  5003.     goto normal;
  5004.       }
  5005.  
  5006.     case COND_EXPR:
  5007.       /* Do (a ? 1 : 0) and (a ? 0 : 1) as special cases.  */
  5008.       if (integer_onep (TREE_OPERAND (exp, 1))
  5009.       && integer_zerop (TREE_OPERAND (exp, 2)))
  5010.     do_jump (TREE_OPERAND (exp, 0), if_false_label, if_true_label);
  5011.  
  5012.       else if (integer_zerop (TREE_OPERAND (exp, 1))
  5013.            && integer_onep (TREE_OPERAND (exp, 2)))
  5014.     do_jump (TREE_OPERAND (exp, 0), if_true_label, if_false_label);
  5015.  
  5016.       else
  5017.     {
  5018.       register rtx label1 = gen_label_rtx ();
  5019.       drop_through_label = gen_label_rtx ();
  5020.       do_jump (TREE_OPERAND (exp, 0), label1, 0);
  5021.       /* Now the THEN-expression.  */
  5022.       do_jump (TREE_OPERAND (exp, 1),
  5023.            if_false_label ? if_false_label : drop_through_label,
  5024.            if_true_label ? if_true_label : drop_through_label);
  5025.       emit_label (label1);
  5026.       /* Now the ELSE-expression.  */
  5027.       do_jump (TREE_OPERAND (exp, 2),
  5028.            if_false_label ? if_false_label : drop_through_label,
  5029.            if_true_label ? if_true_label : drop_through_label);
  5030.     }
  5031.       break;
  5032.  
  5033.     case EQ_EXPR:
  5034.       if (integer_zerop (TREE_OPERAND (exp, 1)))
  5035.     do_jump (TREE_OPERAND (exp, 0), if_true_label, if_false_label);
  5036.       else if ((GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))
  5037.         == MODE_INT)
  5038.            && 
  5039.            !can_compare_p (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  5040.     do_jump_by_parts_equality (exp, if_false_label, if_true_label);
  5041.       else
  5042.     comparison = compare (exp, EQ, EQ);
  5043.       break;
  5044.  
  5045.     case NE_EXPR:
  5046.       if (integer_zerop (TREE_OPERAND (exp, 1)))
  5047.     do_jump (TREE_OPERAND (exp, 0), if_false_label, if_true_label);
  5048.       else if ((GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))
  5049.         == MODE_INT)
  5050.            && 
  5051.            !can_compare_p (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  5052.     do_jump_by_parts_equality (exp, if_true_label, if_false_label);
  5053.       else
  5054.     comparison = compare (exp, NE, NE);
  5055.       break;
  5056.  
  5057.     case LT_EXPR:
  5058.       if ((GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))
  5059.        == MODE_INT)
  5060.       && !can_compare_p (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  5061.     do_jump_by_parts_greater (exp, 1, if_false_label, if_true_label);
  5062.       else
  5063.     comparison = compare (exp, LT, LTU);
  5064.       break;
  5065.  
  5066.     case LE_EXPR:
  5067.       if ((GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))
  5068.        == MODE_INT)
  5069.       && !can_compare_p (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  5070.     do_jump_by_parts_greater (exp, 0, if_true_label, if_false_label);
  5071.       else
  5072.     comparison = compare (exp, LE, LEU);
  5073.       break;
  5074.  
  5075.     case GT_EXPR:
  5076.       if ((GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))
  5077.        == MODE_INT)
  5078.       && !can_compare_p (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  5079.     do_jump_by_parts_greater (exp, 0, if_false_label, if_true_label);
  5080.       else
  5081.     comparison = compare (exp, GT, GTU);
  5082.       break;
  5083.  
  5084.     case GE_EXPR:
  5085.       if ((GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))
  5086.        == MODE_INT)
  5087.       && !can_compare_p (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  5088.     do_jump_by_parts_greater (exp, 1, if_true_label, if_false_label);
  5089.       else
  5090.     comparison = compare (exp, GE, GEU);
  5091.       break;
  5092.  
  5093.     default:
  5094.     normal:
  5095.       temp = expand_expr (exp, 0, VOIDmode, 0);
  5096. #if 0
  5097.       /* This is not needed any more and causes poor code since it causes
  5098.      comparisons and tests from non-SI objects to have different code
  5099.      sequences.  */
  5100.       /* Copy to register to avoid generating bad insns by cse
  5101.      from (set (mem ...) (arithop))  (set (cc0) (mem ...)).  */
  5102.       if (!cse_not_expected && GET_CODE (temp) == MEM)
  5103.     temp = copy_to_reg (temp);
  5104. #endif
  5105.       do_pending_stack_adjust ();
  5106.       if (GET_CODE (temp) == CONST_INT)
  5107.     comparison = (temp == const0_rtx ? const0_rtx : const_true_rtx);
  5108.       else if (GET_MODE_CLASS (GET_MODE (temp)) == MODE_INT
  5109.            && !can_compare_p (GET_MODE (temp)))
  5110.     /* Note swapping the labels gives us not-equal.  */
  5111.     do_jump_by_parts_equality_rtx (temp, if_true_label, if_false_label);
  5112.       else if (GET_MODE (temp) != VOIDmode)
  5113.     comparison = compare_from_rtx (temp, CONST0_RTX (GET_MODE (temp)),
  5114.                        NE, 1, GET_MODE (temp), 0, 0);
  5115.       else
  5116.     abort ();
  5117.     }
  5118.  
  5119.   /* Do any postincrements in the expression that was tested.  */
  5120.   emit_queue ();
  5121.  
  5122.   /* If COMPARISON is nonzero here, it is an rtx that can be substituted
  5123.      straight into a conditional jump instruction as the jump condition.
  5124.      Otherwise, all the work has been done already.  */
  5125.  
  5126.   if (comparison == const_true_rtx)
  5127.     {
  5128.       if (if_true_label)
  5129.     emit_jump (if_true_label);
  5130.     }
  5131.   else if (comparison == const0_rtx)
  5132.     {
  5133.       if (if_false_label)
  5134.     emit_jump (if_false_label);
  5135.     }
  5136.   else if (comparison)
  5137.     do_jump_for_compare (comparison, if_false_label, if_true_label);
  5138.  
  5139.   free_temp_slots ();
  5140.  
  5141.   if (drop_through_label)
  5142.     emit_label (drop_through_label);
  5143. }
  5144.  
  5145. /* Given a comparison expression EXP for values too wide to be compared
  5146.    with one insn, test the comparison and jump to the appropriate label.
  5147.    The code of EXP is ignored; we always test GT if SWAP is 0,
  5148.    and LT if SWAP is 1.  */
  5149.  
  5150. static void
  5151. do_jump_by_parts_greater (exp, swap, if_false_label, if_true_label)
  5152.      tree exp;
  5153.      int swap;
  5154.      rtx if_false_label, if_true_label;
  5155. {
  5156.   rtx op0 = expand_expr (TREE_OPERAND (exp, swap), 0, VOIDmode, 0);
  5157.   rtx op1 = expand_expr (TREE_OPERAND (exp, !swap), 0, VOIDmode, 0);
  5158.   enum machine_mode mode = TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)));
  5159.   int nwords = (GET_MODE_SIZE (mode) / UNITS_PER_WORD);
  5160.   enum machine_mode submode
  5161.     = mode_for_size (BITS_PER_WORD, MODE_INT, 0);
  5162.   rtx drop_through_label = 0;
  5163.   int unsignedp = TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0)));
  5164.   int i;
  5165.  
  5166.   if (! if_true_label || ! if_false_label)
  5167.     drop_through_label = gen_label_rtx ();
  5168.   if (! if_true_label)
  5169.     if_true_label = drop_through_label;
  5170.   if (! if_false_label)
  5171.     if_false_label = drop_through_label;
  5172.  
  5173.   /* Compare a word at a time, high order first.  */
  5174.   for (i = 0; i < nwords; i++)
  5175.     {
  5176.       rtx comp;
  5177.       rtx op0_word, op1_word;
  5178.  
  5179.       if (WORDS_BIG_ENDIAN)
  5180.     {
  5181.       op0_word = operand_subword_force (op0, i, mode);
  5182.       op1_word = operand_subword_force (op1, i, mode);
  5183.     }
  5184.       else
  5185.     {
  5186.       op0_word = operand_subword_force (op0, nwords - 1 - i, mode);
  5187.       op1_word = operand_subword_force (op1, nwords - 1 - i, mode);
  5188.     }
  5189.  
  5190.       /* All but high-order word must be compared as unsigned.  */
  5191.       comp = compare_from_rtx (op0_word, op1_word,
  5192.                    (unsignedp || i > 0) ? GTU : GT,
  5193.                    unsignedp, submode, 0, 0);
  5194.       do_jump_for_compare (comp, 0, if_true_label);
  5195.       /* Consider lower words only if these are equal.  */
  5196.       comp = compare_from_rtx (op0_word, op1_word, NE, unsignedp, submode,
  5197.                    0, 0);
  5198.       do_jump_for_compare (comp, 0, if_false_label);
  5199.     }
  5200.  
  5201.   if (if_false_label)
  5202.     emit_jump (if_false_label);
  5203.   if (drop_through_label)
  5204.     emit_label (drop_through_label);
  5205. }
  5206.  
  5207. /* Given an EQ_EXPR expression EXP for values too wide to be compared
  5208.    with one insn, test the comparison and jump to the appropriate label.  */
  5209.  
  5210. static void
  5211. do_jump_by_parts_equality (exp, if_false_label, if_true_label)
  5212.      tree exp;
  5213.      rtx if_false_label, if_true_label;
  5214. {
  5215.   rtx op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
  5216.   rtx op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
  5217.   enum machine_mode mode = TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)));
  5218.   int nwords = (GET_MODE_SIZE (mode) / UNITS_PER_WORD);
  5219.   enum machine_mode submode
  5220.     = mode_for_size (BITS_PER_WORD, MODE_INT, 0);
  5221.   int i;
  5222.   rtx drop_through_label = 0;
  5223.  
  5224.   if (! if_false_label)
  5225.     drop_through_label = if_false_label = gen_label_rtx ();
  5226.  
  5227.   for (i = 0; i < nwords; i++)
  5228.     {
  5229.       rtx comp = compare_from_rtx (operand_subword_force (op0, i, mode),
  5230.                    operand_subword_force (op1, i, mode),
  5231.                    EQ, 0, submode, 0, 0);
  5232.       do_jump_for_compare (comp, if_false_label, 0);
  5233.     }
  5234.  
  5235.   if (if_true_label)
  5236.     emit_jump (if_true_label);
  5237.   if (drop_through_label)
  5238.     emit_label (drop_through_label);
  5239. }
  5240.  
  5241. /* Jump according to whether OP0 is 0.
  5242.    We assume that OP0 has an integer mode that is too wide
  5243.    for the available compare insns.  */
  5244.  
  5245. static void
  5246. do_jump_by_parts_equality_rtx (op0, if_false_label, if_true_label)
  5247.      rtx op0;
  5248.      rtx if_false_label, if_true_label;
  5249. {
  5250.   int nwords = GET_MODE_SIZE (GET_MODE (op0)) / UNITS_PER_WORD;
  5251.   enum machine_mode submode
  5252.     = mode_for_size (BITS_PER_WORD, MODE_INT, 0);
  5253.   int i;
  5254.   rtx drop_through_label = 0;
  5255.  
  5256.   if (! if_false_label)
  5257.     drop_through_label = if_false_label = gen_label_rtx ();
  5258.  
  5259.   for (i = 0; i < nwords; i++)
  5260.     {
  5261.       rtx comp = compare_from_rtx (operand_subword_force (op0, i,
  5262.                               GET_MODE (op0)),
  5263.                    const0_rtx, EQ, 0, submode, 0, 0);
  5264.       do_jump_for_compare (comp, if_false_label, 0);
  5265.     }
  5266.  
  5267.   if (if_true_label)
  5268.     emit_jump (if_true_label);
  5269.   if (drop_through_label)
  5270.     emit_label (drop_through_label);
  5271. }
  5272.  
  5273. /* Given a comparison expression in rtl form, output conditional branches to
  5274.    IF_TRUE_LABEL, IF_FALSE_LABEL, or both.  */
  5275.  
  5276. static void
  5277. do_jump_for_compare (comparison, if_false_label, if_true_label)
  5278.      rtx comparison, if_false_label, if_true_label;
  5279. {
  5280.   if (if_true_label)
  5281.     {
  5282.       if (bcc_gen_fctn[(int) GET_CODE (comparison)] != 0)
  5283.     emit_jump_insn ((*bcc_gen_fctn[(int) GET_CODE (comparison)]) (if_true_label));
  5284.       else
  5285.     abort ();
  5286.  
  5287.       if (if_false_label)
  5288.     emit_jump (if_false_label);
  5289.     }
  5290.   else if (if_false_label)
  5291.     {
  5292.       rtx insn = get_last_insn ();
  5293.       rtx branch = 0;
  5294.  
  5295.       /* Output the branch with the opposite condition.  Then try to invert
  5296.      what is generated.  If more than one insn is a branch, or if the
  5297.      branch is not the last insn written, abort. If we can't invert
  5298.      the branch, emit make a true label, redirect this jump to that,
  5299.      emit a jump to the false label and define the true label.  */
  5300.  
  5301.       if (bcc_gen_fctn[(int) GET_CODE (comparison)] != 0)
  5302.     emit_jump_insn ((*bcc_gen_fctn[(int) GET_CODE (comparison)]) (if_false_label));
  5303.       else
  5304.     abort ();
  5305.  
  5306.       for (insn = NEXT_INSN (insn); insn; insn = NEXT_INSN (insn))
  5307.     if (GET_CODE (insn) == JUMP_INSN)
  5308.       {
  5309.         if (branch)
  5310.           abort ();
  5311.         branch = insn;
  5312.       }
  5313.  
  5314.       if (branch != get_last_insn ())
  5315.     abort ();
  5316.  
  5317.       if (! invert_jump (branch, if_false_label))
  5318.     {
  5319.       if_true_label = gen_label_rtx ();
  5320.       redirect_jump (branch, if_true_label);
  5321.       emit_jump (if_false_label);
  5322.       emit_label (if_true_label);
  5323.     }
  5324.     }
  5325. }
  5326.  
  5327. /* Compare two integer constant rtx's, OP0 and OP1.
  5328.    The comparison operation is OPERATION.
  5329.    Return an rtx representing the value 1 or 0.
  5330.    WIDTH is the width in bits that is significant.  */
  5331.  
  5332. static rtx
  5333. compare_constants (operation, unsignedp, op0, op1, width)
  5334.      enum rtx_code operation;
  5335.      int unsignedp;
  5336.      int op0, op1;
  5337.      int width;
  5338. {
  5339.   int val;
  5340.  
  5341.   /* Sign-extend or zero-extend the operands to a full word
  5342.      from an initial width of WIDTH bits.  */
  5343.   if (width < HOST_BITS_PER_INT)
  5344.     {
  5345.       op0 &= (1 << width) - 1;
  5346.       op1 &= (1 << width) - 1;
  5347.  
  5348.       if (! unsignedp)
  5349.     {
  5350.       if (op0 & (1 << (width - 1)))
  5351.         op0 |= ((-1) << width);
  5352.       if (op1 & (1 << (width - 1)))
  5353.         op1 |= ((-1) << width);
  5354.     }
  5355.     }
  5356.  
  5357.   switch (operation)
  5358.     {
  5359.     case EQ:
  5360.       val = op0 == op1;
  5361.       break;
  5362.  
  5363.     case NE:
  5364.       val = op0 != op1;
  5365.       break;
  5366.  
  5367.     case GT:
  5368.       val = op0 > op1;
  5369.       break;
  5370.  
  5371.     case GTU:
  5372.       val = (unsigned) op0 > (unsigned) op1;
  5373.       break;
  5374.  
  5375.     case LT:
  5376.       val = op0 < op1;
  5377.       break;
  5378.  
  5379.     case LTU:
  5380.       val = (unsigned) op0 < (unsigned) op1;
  5381.       break;
  5382.  
  5383.     case GE:
  5384.       val = op0 >= op1;
  5385.       break;
  5386.  
  5387.     case GEU:
  5388.       val = (unsigned) op0 >= (unsigned) op1;
  5389.       break;
  5390.  
  5391.     case LE:
  5392.       val = op0 <= op1;
  5393.       break;
  5394.  
  5395.     case LEU:
  5396.       val = (unsigned) op0 <= (unsigned) op1;
  5397.       break;
  5398.     }
  5399.  
  5400.   return val ? const_true_rtx : const0_rtx;
  5401. }
  5402.  
  5403. /* Generate code for a comparison expression EXP
  5404.    (including code to compute the values to be compared)
  5405.    and set (CC0) according to the result.
  5406.    SIGNED_CODE should be the rtx operation for this comparison for
  5407.    signed data; UNSIGNED_CODE, likewise for use if data is unsigned.
  5408.  
  5409.    We force a stack adjustment unless there are currently
  5410.    things pushed on the stack that aren't yet used.  */
  5411.  
  5412. static rtx
  5413. compare (exp, signed_code, unsigned_code)
  5414.      register tree exp;
  5415.      enum rtx_code signed_code, unsigned_code;
  5416. {
  5417.   register rtx op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
  5418.   register rtx op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
  5419.   register tree type = TREE_TYPE (TREE_OPERAND (exp, 0));
  5420.   register enum machine_mode mode = TYPE_MODE (type);
  5421.   int unsignedp = TREE_UNSIGNED (type);
  5422.   enum rtx_code code = unsignedp ? unsigned_code : signed_code;
  5423.  
  5424.   return compare_from_rtx (op0, op1, code, unsignedp, mode,
  5425.                ((mode == BLKmode)
  5426.                 ? expr_size (TREE_OPERAND (exp, 0)) : 0),
  5427.                TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
  5428. }
  5429.  
  5430. /* Like compare but expects the values to compare as two rtx's.
  5431.    The decision as to signed or unsigned comparison must be made by the caller.
  5432.  
  5433.    If MODE is BLKmode, SIZE is an RTX giving the size of the objects being
  5434.    compared.
  5435.  
  5436.    If ALIGN is non-zero, it is the alignment of this type; if zero, the
  5437.    size of MODE should be used.  */
  5438.  
  5439. rtx
  5440. compare_from_rtx (op0, op1, code, unsignedp, mode, size, align)
  5441.      register rtx op0, op1;
  5442.      enum rtx_code code;
  5443.      int unsignedp;
  5444.      enum machine_mode mode;
  5445.      rtx size;
  5446.      int align;
  5447. {
  5448.   /* If one operand is constant, make it the second one.  */
  5449.  
  5450.   if (GET_CODE (op0) == CONST_INT || GET_CODE (op0) == CONST_DOUBLE)
  5451.     {
  5452.       rtx tem = op0;
  5453.       op0 = op1;
  5454.       op1 = tem;
  5455.       code = swap_condition (code);
  5456.     }
  5457.  
  5458.   if (flag_force_mem)
  5459.     {
  5460.       op0 = force_not_mem (op0);
  5461.       op1 = force_not_mem (op1);
  5462.     }
  5463.  
  5464.   do_pending_stack_adjust ();
  5465.  
  5466.   if (GET_CODE (op0) == CONST_INT && GET_CODE (op1) == CONST_INT)
  5467.     {
  5468.       if (mode == VOIDmode)
  5469.     abort ();
  5470.       return compare_constants (code, unsignedp, INTVAL (op0), INTVAL (op1),
  5471.                 GET_MODE_BITSIZE (mode));
  5472.     }
  5473.  
  5474.   /* If this is a signed equality comparison, we can do it as an
  5475.      unsigned comparison since zero-extension is cheaper than sign
  5476.      extension and comparisons with zero are done as unsigned.  If we
  5477.      are comparing against a constant, we must convert it to what it
  5478.      would look like unsigned.  */
  5479.   if ((code == EQ || code == NE) && ! unsignedp)
  5480.     {
  5481.       if (GET_CODE (op1) == CONST_INT
  5482.       && (INTVAL (op1) & GET_MODE_MASK (GET_MODE (op0))) != INTVAL (op1))
  5483.     op1 = gen_rtx (CONST_INT, VOIDmode, 
  5484.                INTVAL (op1) & GET_MODE_MASK (GET_MODE (op0)));
  5485.       unsignedp = 1;
  5486.     }
  5487.     
  5488.   emit_cmp_insn (op0, op1, code, size, unsignedp, align);
  5489.  
  5490.   return gen_rtx (code, VOIDmode, cc0_rtx, const0_rtx);
  5491. }
  5492.  
  5493. /* Generate code to calculate EXP using a store-flag instruction
  5494.    and return an rtx for the result.
  5495.    If TARGET is nonzero, store the result there if convenient.
  5496.  
  5497.    If ONLY_CHEAP is non-zero, only do this if it is likely to be very
  5498.    cheap.
  5499.  
  5500.    Return zero if there is no suitable set-flag instruction
  5501.    available on this machine.
  5502.  
  5503.    Once expand_expr has been called on the arguments of the comparison,
  5504.    we are committed to doing the store flag, since it is not safe to
  5505.    re-evaluate the expression.  We emit the store-flag insn by calling
  5506.    emit_store_flag, but only expand the arguments if we have a reason
  5507.    to believe that emit_store_flag will be successful.  If we think that
  5508.    it will, but it isn't, we have to simulate the store-flag with a
  5509.    set/jump/set sequence.  */
  5510.  
  5511. static rtx
  5512. do_store_flag (exp, target, mode, only_cheap)
  5513.      tree exp;
  5514.      rtx target;
  5515.      enum machine_mode mode;
  5516.      int only_cheap;
  5517. {
  5518.   enum rtx_code code;
  5519.   tree arg0 = TREE_OPERAND (exp, 0);
  5520.   tree arg1 = TREE_OPERAND (exp, 1);
  5521.   tree tem;
  5522.   tree type = TREE_TYPE (arg0);
  5523.   enum machine_mode operand_mode = TYPE_MODE (type);
  5524.   int unsignedp = TREE_UNSIGNED (type);
  5525.   rtx op0, op1;
  5526.   enum insn_code icode;
  5527.   rtx subtarget = target;
  5528.   rtx result, label, pattern, jump_pat;
  5529.  
  5530.   /* We won't bother with BLKmode store-flag operations because it would mean
  5531.      passing a lot of information to emit_store_flag.  */
  5532.   if (operand_mode == BLKmode)
  5533.     return 0;
  5534.  
  5535.   while (TREE_CODE (arg0) == NON_LVALUE_EXPR)
  5536.     arg0 = TREE_OPERAND (arg0, 0);
  5537.  
  5538.   while (TREE_CODE (arg1) == NON_LVALUE_EXPR)
  5539.     arg1 = TREE_OPERAND (arg1, 0);
  5540.  
  5541.   /* Get the rtx comparison code to use.  We know that EXP is a comparison
  5542.      operation of some type.  */
  5543.   switch (TREE_CODE (exp))
  5544.     {
  5545.     case EQ_EXPR:
  5546.       code = EQ;
  5547.       break;
  5548.     case NE_EXPR:
  5549.       code = NE;
  5550.       break;
  5551.     case LT_EXPR:
  5552.       code = unsignedp ? LTU : LT;
  5553.       break;
  5554.     case LE_EXPR:
  5555.       code = unsignedp ? LEU : LE;
  5556.       break;
  5557.     case GT_EXPR:
  5558.       code = unsignedp ? GTU : GT;
  5559.       break;
  5560.     case GE_EXPR:
  5561.       code = unsignedp ? GEU : GE;
  5562.       break;
  5563.     default:
  5564.       abort ();
  5565.     }
  5566.  
  5567.   /* Put a constant second.  */
  5568.   if (TREE_CODE (arg0) == REAL_CST || TREE_CODE (arg0) == INTEGER_CST)
  5569.     {
  5570.       tem = arg0; arg0 = arg1; arg1 = tem;
  5571.       code = swap_condition (code);
  5572.     }
  5573.  
  5574.   /* If this is an equality or inequality test of a single bit, we can
  5575.      do this by shifting the bit being tested to the low-order bit and
  5576.      masking the result with the constant 1.  If the condition was EQ,
  5577.      we xor it with 1.  This does not require an scc insn and is faster
  5578.      than an scc insn even if we have it.  */
  5579.  
  5580.   if ((code == NE || code == EQ)
  5581.       && TREE_CODE (arg0) == BIT_AND_EXPR && integer_zerop (arg1)
  5582.       && integer_pow2p (TREE_OPERAND (arg0, 1))
  5583.       && TYPE_PRECISION (type) <= HOST_BITS_PER_INT)
  5584.     {
  5585.       int bitnum = exact_log2 (INTVAL (expand_expr (TREE_OPERAND (arg0, 1),
  5586.                             0, VOIDmode, 0)));
  5587.  
  5588.       if (subtarget == 0 || GET_CODE (subtarget) != REG
  5589.       || GET_MODE (subtarget) != operand_mode
  5590.       || ! safe_from_p (subtarget, TREE_OPERAND (arg0, 0)))
  5591.     subtarget = 0;
  5592.  
  5593.       op0 = expand_expr (TREE_OPERAND (arg0, 0), subtarget, VOIDmode, 0);
  5594.  
  5595.       if (bitnum != 0)
  5596.     op0 = expand_shift (RSHIFT_EXPR, GET_MODE (op0), op0,
  5597.                 size_int (bitnum), target, 1);
  5598.  
  5599.       if (GET_MODE (op0) != mode)
  5600.     op0 = convert_to_mode (mode, op0, 1);
  5601.  
  5602.       if (bitnum != TYPE_PRECISION (type) - 1)
  5603.     op0 = expand_and (op0, const1_rtx, target);
  5604.  
  5605.       if (code == EQ)
  5606.     op0 = expand_binop (mode, xor_optab, op0, const1_rtx, target, 0,
  5607.                 OPTAB_LIB_WIDEN);
  5608.  
  5609.       return op0;
  5610.     }
  5611.  
  5612.   /* Now see if we are likely to be able to do this.  Return if not.  */
  5613.   if (! can_compare_p (operand_mode))
  5614.     return 0;
  5615.   icode = setcc_gen_code[(int) code];
  5616.   if (icode == CODE_FOR_nothing
  5617.       || (only_cheap && insn_operand_mode[(int) icode][0] != mode))
  5618.     {
  5619.       /* We can only do this if it is one of the special cases that
  5620.      can be handled without an scc insn.  */
  5621.       if ((code == LT && integer_zerop (arg1))
  5622.       || (! only_cheap && code == GE && integer_zerop (arg1)))
  5623.     ;
  5624.       else if (! only_cheap && (code == NE || code == EQ)
  5625.            && TREE_CODE (type) != REAL_TYPE
  5626.            && (abs_optab->handlers[(int) operand_mode].insn_code
  5627.            != CODE_FOR_nothing))
  5628.     ;
  5629.       else
  5630.     return 0;
  5631.     }
  5632.       
  5633.   preexpand_calls (exp);
  5634.   if (subtarget == 0 || GET_CODE (subtarget) != REG
  5635.       || GET_MODE (subtarget) != operand_mode
  5636.       || ! safe_from_p (subtarget, arg1))
  5637.     subtarget = 0;
  5638.  
  5639.   op0 = expand_expr (arg0, subtarget, VOIDmode, 0);
  5640.   op1 = expand_expr (arg1, 0, VOIDmode, 0);
  5641.  
  5642.   if (target == 0)
  5643.     target = gen_reg_rtx (mode);
  5644.  
  5645.   result = emit_store_flag (target, code, op0, op1, operand_mode, unsignedp, 1);
  5646.  
  5647.   if (result)
  5648.     return result;
  5649.  
  5650.   /* If this failed, we have to do this with set/compare/jump/set code.  */
  5651.   if (target == 0 || GET_CODE (target) != REG
  5652.       || reg_mentioned_p (target, op0) || reg_mentioned_p (target, op1))
  5653.     target = gen_reg_rtx (GET_MODE (target));
  5654.  
  5655.   emit_move_insn (target, const1_rtx);
  5656.   result = compare_from_rtx (op0, op1, code, unsignedp, operand_mode, 0, 0);
  5657.   if (GET_CODE (result) == CONST_INT)
  5658.     return result == const0_rtx ? const0_rtx : const1_rtx;
  5659.  
  5660.   label = gen_label_rtx ();
  5661.   if (bcc_gen_fctn[(int) code] == 0)
  5662.     abort ();
  5663.  
  5664.   emit_jump_insn ((*bcc_gen_fctn[(int) code]) (label));
  5665.   emit_move_insn (target, const0_rtx);
  5666.   emit_label (label);
  5667.  
  5668.   return target;
  5669. }
  5670.  
  5671. /* Generate a tablejump instruction (used for switch statements).  */
  5672.  
  5673. #ifdef HAVE_tablejump
  5674.  
  5675. /* INDEX is the value being switched on, with the lowest value
  5676.    in the table already subtracted.
  5677.    RANGE is the length of the jump table.
  5678.    TABLE_LABEL is a CODE_LABEL rtx for the table itself.
  5679.  
  5680.    DEFAULT_LABEL is a CODE_LABEL rtx to jump to if the
  5681.    index value is out of range.  */
  5682.  
  5683. void
  5684. do_tablejump (index, range, table_label, default_label)
  5685.      rtx index, range, table_label, default_label;
  5686. {
  5687.   register rtx temp, vector;
  5688.  
  5689.   emit_cmp_insn (range, index, LTU, 0, 0, 0);
  5690.   emit_jump_insn (gen_bltu (default_label));
  5691.   /* If flag_force_addr were to affect this address
  5692.      it could interfere with the tricky assumptions made
  5693.      about addresses that contain label-refs,
  5694.      which may be valid only very near the tablejump itself.  */
  5695.   index = memory_address_noforce
  5696.     (CASE_VECTOR_MODE,
  5697.      gen_rtx (PLUS, Pmode,
  5698.           gen_rtx (MULT, Pmode, index,
  5699.                gen_rtx (CONST_INT, VOIDmode,
  5700.                 GET_MODE_SIZE (CASE_VECTOR_MODE))),
  5701.           gen_rtx (LABEL_REF, Pmode, table_label)));
  5702.   temp = gen_reg_rtx (CASE_VECTOR_MODE);
  5703.   vector = gen_rtx (MEM, CASE_VECTOR_MODE, index);
  5704.   RTX_UNCHANGING_P (vector) = 1;
  5705.   convert_move (temp, vector, 0);
  5706.  
  5707.   emit_jump_insn (gen_tablejump (temp, table_label));
  5708.   emit_barrier ();
  5709. }
  5710.  
  5711. #endif /* HAVE_tablejump */
  5712.