home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / gcc / expr.c < prev    next >
C/C++ Source or Header  |  1996-12-12  |  335KB  |  10,898 lines

  1. /* Convert tree expression to rtl instructions, for GNU compiler.
  2.    Copyright (C) 1988, 1992, 1993, 1994, 1995 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, 59 Temple Place - Suite 330,
  19. Boston, MA 02111-1307, USA.  */
  20.  
  21.  
  22. #include "config.h"
  23. #include "machmode.h"
  24. #include "rtl.h"
  25. #include "tree.h"
  26. #include "obstack.h"
  27. #include "flags.h"
  28. #include "regs.h"
  29. #include "function.h"
  30. #include "insn-flags.h"
  31. #include "insn-codes.h"
  32. #include "expr.h"
  33. #include "insn-config.h"
  34. #include "recog.h"
  35. #include "output.h"
  36. #include "typeclass.h"
  37.  
  38. #include "bytecode.h"
  39. #include "bc-opcode.h"
  40. #include "bc-typecd.h"
  41. #include "bc-optab.h"
  42. #include "bc-emit.h"
  43.  
  44.  
  45. #define CEIL(x,y) (((x) + (y) - 1) / (y))
  46.  
  47. /* Decide whether a function's arguments should be processed
  48.    from first to last or from last to first.
  49.  
  50.    They should if the stack and args grow in opposite directions, but
  51.    only if we have push insns.  */
  52.  
  53. #ifdef PUSH_ROUNDING
  54.  
  55. #if defined (STACK_GROWS_DOWNWARD) != defined (ARGS_GROW_DOWNWARD)
  56. #define PUSH_ARGS_REVERSED    /* If it's last to first */
  57. #endif
  58.  
  59. #endif
  60.  
  61. #ifndef STACK_PUSH_CODE
  62. #ifdef STACK_GROWS_DOWNWARD
  63. #define STACK_PUSH_CODE PRE_DEC
  64. #else
  65. #define STACK_PUSH_CODE PRE_INC
  66. #endif
  67. #endif
  68.  
  69. /* Like STACK_BOUNDARY but in units of bytes, not bits.  */
  70. #define STACK_BYTES (STACK_BOUNDARY / BITS_PER_UNIT)
  71.  
  72. /* If this is nonzero, we do not bother generating VOLATILE
  73.    around volatile memory references, and we are willing to
  74.    output indirect addresses.  If cse is to follow, we reject
  75.    indirect addresses so a useful potential cse is generated;
  76.    if it is used only once, instruction combination will produce
  77.    the same indirect address eventually.  */
  78. int cse_not_expected;
  79.  
  80. /* Nonzero to generate code for all the subroutines within an
  81.    expression before generating the upper levels of the expression.
  82.    Nowadays this is never zero.  */
  83. int do_preexpand_calls = 1;
  84.  
  85. /* Number of units that we should eventually pop off the stack.
  86.    These are the arguments to function calls that have already returned.  */
  87. int pending_stack_adjust;
  88.  
  89. /* Nonzero means stack pops must not be deferred, and deferred stack
  90.    pops must not be output.  It is nonzero inside a function call,
  91.    inside a conditional expression, inside a statement expression,
  92.    and in other cases as well.  */
  93. int inhibit_defer_pop;
  94.  
  95. /* A list of all cleanups which belong to the arguments of
  96.    function calls being expanded by expand_call.  */
  97. tree cleanups_this_call;
  98.  
  99. /* When temporaries are created by TARGET_EXPRs, they are created at
  100.    this level of temp_slot_level, so that they can remain allocated
  101.    until no longer needed.  CLEANUP_POINT_EXPRs define the lifetime
  102.    of TARGET_EXPRs.  */
  103. int target_temp_slot_level;
  104.  
  105. /* Nonzero means __builtin_saveregs has already been done in this function.
  106.    The value is the pseudoreg containing the value __builtin_saveregs
  107.    returned.  */
  108. static rtx saveregs_value;
  109.  
  110. /* Similarly for __builtin_apply_args.  */
  111. static rtx apply_args_value;
  112.  
  113. /* This structure is used by move_by_pieces to describe the move to
  114.    be performed.  */
  115.  
  116. struct move_by_pieces
  117. {
  118.   rtx to;
  119.   rtx to_addr;
  120.   int autinc_to;
  121.   int explicit_inc_to;
  122.   int to_struct;
  123.   rtx from;
  124.   rtx from_addr;
  125.   int autinc_from;
  126.   int explicit_inc_from;
  127.   int from_struct;
  128.   int len;
  129.   int offset;
  130.   int reverse;
  131. };
  132.  
  133. /* Used to generate bytecodes: keep track of size of local variables,
  134.    as well as depth of arithmetic stack. (Notice that variables are
  135.    stored on the machine's stack, not the arithmetic stack.) */
  136.  
  137. extern int local_vars_size;
  138. extern int stack_depth;
  139. extern int max_stack_depth;
  140. extern struct obstack permanent_obstack;
  141.  
  142.  
  143. static rtx enqueue_insn        PROTO((rtx, rtx));
  144. static int queued_subexp_p    PROTO((rtx));
  145. static void init_queue        PROTO((void));
  146. static void move_by_pieces    PROTO((rtx, rtx, int, int));
  147. static int move_by_pieces_ninsns PROTO((unsigned int, int));
  148. static void move_by_pieces_1    PROTO((rtx (*) (), enum machine_mode,
  149.                        struct move_by_pieces *));
  150. static void store_constructor    PROTO((tree, rtx));
  151. static rtx store_field        PROTO((rtx, int, int, enum machine_mode, tree,
  152.                        enum machine_mode, int, int, int));
  153. static int get_inner_unaligned_p PROTO((tree));
  154. static tree save_noncopied_parts PROTO((tree, tree));
  155. static tree init_noncopied_parts PROTO((tree, tree));
  156. static int safe_from_p        PROTO((rtx, tree));
  157. static int fixed_type_p        PROTO((tree));
  158. static int get_pointer_alignment PROTO((tree, unsigned));
  159. static tree string_constant    PROTO((tree, tree *));
  160. static tree c_strlen        PROTO((tree));
  161. static rtx expand_builtin    PROTO((tree, rtx, rtx,
  162.                        enum machine_mode, int));
  163. static int apply_args_size    PROTO((void));
  164. static int apply_result_size    PROTO((void));
  165. static rtx result_vector    PROTO((int, rtx));
  166. static rtx expand_builtin_apply_args PROTO((void));
  167. static rtx expand_builtin_apply    PROTO((rtx, rtx, rtx));
  168. static void expand_builtin_return PROTO((rtx));
  169. static rtx expand_increment    PROTO((tree, int));
  170. rtx bc_expand_increment        PROTO((struct increment_operator *, tree));
  171. tree bc_runtime_type_code     PROTO((tree));
  172. rtx bc_allocate_local        PROTO((int, int));
  173. void bc_store_memory         PROTO((tree, tree));
  174. tree bc_expand_component_address PROTO((tree));
  175. tree bc_expand_address         PROTO((tree));
  176. void bc_expand_constructor     PROTO((tree));
  177. void bc_adjust_stack         PROTO((int));
  178. tree bc_canonicalize_array_ref    PROTO((tree));
  179. void bc_load_memory        PROTO((tree, tree));
  180. void bc_load_externaddr        PROTO((rtx));
  181. void bc_load_externaddr_id    PROTO((tree, int));
  182. void bc_load_localaddr        PROTO((rtx));
  183. void bc_load_parmaddr        PROTO((rtx));
  184. static void preexpand_calls    PROTO((tree));
  185. static void do_jump_by_parts_greater PROTO((tree, int, rtx, rtx));
  186. void do_jump_by_parts_greater_rtx PROTO((enum machine_mode, int, rtx, rtx, rtx, rtx));
  187. static void do_jump_by_parts_equality PROTO((tree, rtx, rtx));
  188. static void do_jump_by_parts_equality_rtx PROTO((rtx, rtx, rtx));
  189. static void do_jump_for_compare    PROTO((rtx, rtx, rtx));
  190. static rtx compare        PROTO((tree, enum rtx_code, enum rtx_code));
  191. static rtx do_store_flag    PROTO((tree, rtx, enum machine_mode, int));
  192. static tree defer_cleanups_to    PROTO((tree));
  193. extern void (*interim_eh_hook)    PROTO((tree));
  194. extern tree truthvalue_conversion       PROTO((tree));
  195.  
  196. /* Record for each mode whether we can move a register directly to or
  197.    from an object of that mode in memory.  If we can't, we won't try
  198.    to use that mode directly when accessing a field of that mode.  */
  199.  
  200. static char direct_load[NUM_MACHINE_MODES];
  201. static char direct_store[NUM_MACHINE_MODES];
  202.  
  203. /* MOVE_RATIO is the number of move instructions that is better than
  204.    a block move.  */
  205.  
  206. #ifndef MOVE_RATIO
  207. #if defined (HAVE_movstrqi) || defined (HAVE_movstrhi) || defined (HAVE_movstrsi) || defined (HAVE_movstrdi) || defined (HAVE_movstrti)
  208. #define MOVE_RATIO 2
  209. #else
  210. /* A value of around 6 would minimize code size; infinity would minimize
  211.    execution time.  */
  212. #define MOVE_RATIO 15
  213. #endif
  214. #endif
  215.  
  216. /* This array records the insn_code of insns to perform block moves.  */
  217. enum insn_code movstr_optab[NUM_MACHINE_MODES];
  218.  
  219. /* SLOW_UNALIGNED_ACCESS is non-zero if unaligned accesses are very slow. */
  220.  
  221. #ifndef SLOW_UNALIGNED_ACCESS
  222. #define SLOW_UNALIGNED_ACCESS STRICT_ALIGNMENT
  223. #endif
  224.  
  225. /* Register mappings for target machines without register windows.  */
  226. #ifndef INCOMING_REGNO
  227. #define INCOMING_REGNO(OUT) (OUT)
  228. #endif
  229. #ifndef OUTGOING_REGNO
  230. #define OUTGOING_REGNO(IN) (IN)
  231. #endif
  232.  
  233. /* Maps used to convert modes to const, load, and store bytecodes. */
  234. enum bytecode_opcode mode_to_const_map[MAX_MACHINE_MODE];
  235. enum bytecode_opcode mode_to_load_map[MAX_MACHINE_MODE];
  236. enum bytecode_opcode mode_to_store_map[MAX_MACHINE_MODE];
  237.  
  238. /* Initialize maps used to convert modes to const, load, and store
  239.    bytecodes. */
  240. void
  241. bc_init_mode_to_opcode_maps ()
  242. {
  243.   int mode;
  244.  
  245.   for (mode = 0; mode < (int) MAX_MACHINE_MODE; mode++)
  246.     mode_to_const_map[mode] =
  247.       mode_to_load_map[mode] =
  248.     mode_to_store_map[mode] = neverneverland;
  249.       
  250. #define DEF_MODEMAP(SYM, CODE, UCODE, CONST, LOAD, STORE) \
  251.   mode_to_const_map[(int) SYM] = CONST; \
  252.   mode_to_load_map[(int) SYM] = LOAD; \
  253.   mode_to_store_map[(int) SYM] = STORE;
  254.  
  255. #include "modemap.def"
  256. #undef DEF_MODEMAP
  257. }
  258.  
  259. /* This is run once per compilation to set up which modes can be used
  260.    directly in memory and to initialize the block move optab.  */
  261.  
  262. void
  263. init_expr_once ()
  264. {
  265.   rtx insn, pat;
  266.   enum machine_mode mode;
  267.   /* Try indexing by frame ptr and try by stack ptr.
  268.      It is known that on the Convex the stack ptr isn't a valid index.
  269.      With luck, one or the other is valid on any machine.  */
  270.   rtx mem = gen_rtx (MEM, VOIDmode, stack_pointer_rtx);
  271.   rtx mem1 = gen_rtx (MEM, VOIDmode, frame_pointer_rtx);
  272.  
  273.   start_sequence ();
  274.   insn = emit_insn (gen_rtx (SET, 0, 0));
  275.   pat = PATTERN (insn);
  276.  
  277.   for (mode = VOIDmode; (int) mode < NUM_MACHINE_MODES;
  278.        mode = (enum machine_mode) ((int) mode + 1))
  279.     {
  280.       int regno;
  281.       rtx reg;
  282.       int num_clobbers;
  283.  
  284.       direct_load[(int) mode] = direct_store[(int) mode] = 0;
  285.       PUT_MODE (mem, mode);
  286.       PUT_MODE (mem1, mode);
  287.  
  288.       /* See if there is some register that can be used in this mode and
  289.      directly loaded or stored from memory.  */
  290.  
  291.       if (mode != VOIDmode && mode != BLKmode)
  292.     for (regno = 0; regno < FIRST_PSEUDO_REGISTER
  293.          && (direct_load[(int) mode] == 0 || direct_store[(int) mode] == 0);
  294.          regno++)
  295.       {
  296.         if (! HARD_REGNO_MODE_OK (regno, mode))
  297.           continue;
  298.  
  299.         reg = gen_rtx (REG, mode, regno);
  300.  
  301.         SET_SRC (pat) = mem;
  302.         SET_DEST (pat) = reg;
  303.         if (recog (pat, insn, &num_clobbers) >= 0)
  304.           direct_load[(int) mode] = 1;
  305.  
  306.         SET_SRC (pat) = mem1;
  307.         SET_DEST (pat) = reg;
  308.         if (recog (pat, insn, &num_clobbers) >= 0)
  309.           direct_load[(int) mode] = 1;
  310.  
  311.         SET_SRC (pat) = reg;
  312.         SET_DEST (pat) = mem;
  313.         if (recog (pat, insn, &num_clobbers) >= 0)
  314.           direct_store[(int) mode] = 1;
  315.  
  316.         SET_SRC (pat) = reg;
  317.         SET_DEST (pat) = mem1;
  318.         if (recog (pat, insn, &num_clobbers) >= 0)
  319.           direct_store[(int) mode] = 1;
  320.       }
  321.     }
  322.  
  323.   end_sequence ();
  324. }
  325.       
  326. /* This is run at the start of compiling a function.  */
  327.  
  328. void
  329. init_expr ()
  330. {
  331.   init_queue ();
  332.  
  333.   pending_stack_adjust = 0;
  334.   inhibit_defer_pop = 0;
  335.   cleanups_this_call = 0;
  336.   saveregs_value = 0;
  337.   apply_args_value = 0;
  338.   forced_labels = 0;
  339. }
  340.  
  341. /* Save all variables describing the current status into the structure *P.
  342.    This is used before starting a nested function.  */
  343.  
  344. void
  345. save_expr_status (p)
  346.      struct function *p;
  347. {
  348.   /* Instead of saving the postincrement queue, empty it.  */
  349.   emit_queue ();
  350.  
  351.   p->pending_stack_adjust = pending_stack_adjust;
  352.   p->inhibit_defer_pop = inhibit_defer_pop;
  353.   p->cleanups_this_call = cleanups_this_call;
  354.   p->saveregs_value = saveregs_value;
  355.   p->apply_args_value = apply_args_value;
  356.   p->forced_labels = forced_labels;
  357.  
  358.   pending_stack_adjust = 0;
  359.   inhibit_defer_pop = 0;
  360.   cleanups_this_call = 0;
  361.   saveregs_value = 0;
  362.   apply_args_value = 0;
  363.   forced_labels = 0;
  364. }
  365.  
  366. /* Restore all variables describing the current status from the structure *P.
  367.    This is used after a nested function.  */
  368.  
  369. void
  370. restore_expr_status (p)
  371.      struct function *p;
  372. {
  373.   pending_stack_adjust = p->pending_stack_adjust;
  374.   inhibit_defer_pop = p->inhibit_defer_pop;
  375.   cleanups_this_call = p->cleanups_this_call;
  376.   saveregs_value = p->saveregs_value;
  377.   apply_args_value = p->apply_args_value;
  378.   forced_labels = p->forced_labels;
  379. }
  380.  
  381. /* Manage the queue of increment instructions to be output
  382.    for POSTINCREMENT_EXPR expressions, etc.  */
  383.  
  384. static rtx pending_chain;
  385.  
  386. /* Queue up to increment (or change) VAR later.  BODY says how:
  387.    BODY should be the same thing you would pass to emit_insn
  388.    to increment right away.  It will go to emit_insn later on.
  389.  
  390.    The value is a QUEUED expression to be used in place of VAR
  391.    where you want to guarantee the pre-incrementation value of VAR.  */
  392.  
  393. static rtx
  394. enqueue_insn (var, body)
  395.      rtx var, body;
  396. {
  397.   pending_chain = gen_rtx (QUEUED, GET_MODE (var),
  398.                var, NULL_RTX, NULL_RTX, body, pending_chain);
  399.   return pending_chain;
  400. }
  401.  
  402. /* Use protect_from_queue to convert a QUEUED expression
  403.    into something that you can put immediately into an instruction.
  404.    If the queued incrementation has not happened yet,
  405.    protect_from_queue returns the variable itself.
  406.    If the incrementation has happened, protect_from_queue returns a temp
  407.    that contains a copy of the old value of the variable.
  408.  
  409.    Any time an rtx which might possibly be a QUEUED is to be put
  410.    into an instruction, it must be passed through protect_from_queue first.
  411.    QUEUED expressions are not meaningful in instructions.
  412.  
  413.    Do not pass a value through protect_from_queue and then hold
  414.    on to it for a while before putting it in an instruction!
  415.    If the queue is flushed in between, incorrect code will result.  */
  416.  
  417. rtx
  418. protect_from_queue (x, modify)
  419.      register rtx x;
  420.      int modify;
  421. {
  422.   register RTX_CODE code = GET_CODE (x);
  423.  
  424. #if 0  /* A QUEUED can hang around after the queue is forced out.  */
  425.   /* Shortcut for most common case.  */
  426.   if (pending_chain == 0)
  427.     return x;
  428. #endif
  429.  
  430.   if (code != QUEUED)
  431.     {
  432.       /* A special hack for read access to (MEM (QUEUED ...)) to facilitate
  433.      use of autoincrement.  Make a copy of the contents of the memory
  434.      location rather than a copy of the address, but not if the value is
  435.      of mode BLKmode.  Don't modify X in place since it might be
  436.      shared.  */
  437.       if (code == MEM && GET_MODE (x) != BLKmode
  438.       && GET_CODE (XEXP (x, 0)) == QUEUED && !modify)
  439.     {
  440.       register rtx y = XEXP (x, 0);
  441. #ifdef NEXT_SEMANTICS
  442.       /* ??? THIS CODE IS PROBABLY WRONG!!!
  443.          x should not be modified in place!!!  */
  444.       register rtx new = x;
  445.       XEXP (new, 0) = QUEUED_VAR (y);
  446. #else
  447.       register rtx new = gen_rtx (MEM, GET_MODE (x), QUEUED_VAR (y));
  448.  
  449.       MEM_IN_STRUCT_P (new) = MEM_IN_STRUCT_P (x);
  450.       RTX_UNCHANGING_P (new) = RTX_UNCHANGING_P (x);
  451.       MEM_VOLATILE_P (new) = MEM_VOLATILE_P (x);
  452. #endif
  453.  
  454.       if (QUEUED_INSN (y))
  455.         {
  456.           register rtx temp = gen_reg_rtx (GET_MODE (new));
  457.           emit_insn_before (gen_move_insn (temp, new),
  458.                 QUEUED_INSN (y));
  459.           return temp;
  460.         }
  461.       return new;
  462.     }
  463.       /* Otherwise, recursively protect the subexpressions of all
  464.      the kinds of rtx's that can contain a QUEUED.  */
  465.       if (code == MEM)
  466.     {
  467.       rtx tem = protect_from_queue (XEXP (x, 0), 0);
  468.       if (tem != XEXP (x, 0))
  469.         {
  470.           x = copy_rtx (x);
  471.           XEXP (x, 0) = tem;
  472.         }
  473.     }
  474.       else if (code == PLUS || code == MULT)
  475.     {
  476.       rtx new0 = protect_from_queue (XEXP (x, 0), 0);
  477.       rtx new1 = protect_from_queue (XEXP (x, 1), 0);
  478.       if (new0 != XEXP (x, 0) || new1 != XEXP (x, 1))
  479.         {
  480.           x = copy_rtx (x);
  481.           XEXP (x, 0) = new0;
  482.           XEXP (x, 1) = new1;
  483.         }
  484.     }
  485.       return x;
  486.     }
  487.   /* If the increment has not happened, use the variable itself.  */
  488.   if (QUEUED_INSN (x) == 0)
  489.     return QUEUED_VAR (x);
  490.   /* If the increment has happened and a pre-increment copy exists,
  491.      use that copy.  */
  492.   if (QUEUED_COPY (x) != 0)
  493.     return QUEUED_COPY (x);
  494.   /* The increment has happened but we haven't set up a pre-increment copy.
  495.      Set one up now, and use it.  */
  496.   QUEUED_COPY (x) = gen_reg_rtx (GET_MODE (QUEUED_VAR (x)));
  497.   emit_insn_before (gen_move_insn (QUEUED_COPY (x), QUEUED_VAR (x)),
  498.             QUEUED_INSN (x));
  499.   return QUEUED_COPY (x);
  500. }
  501.  
  502. /* Return nonzero if X contains a QUEUED expression:
  503.    if it contains anything that will be altered by a queued increment.
  504.    We handle only combinations of MEM, PLUS, MINUS and MULT operators
  505.    since memory addresses generally contain only those.  */
  506.  
  507. static int
  508. queued_subexp_p (x)
  509.      rtx x;
  510. {
  511.   register enum rtx_code code = GET_CODE (x);
  512.   switch (code)
  513.     {
  514.     case QUEUED:
  515.       return 1;
  516.     case MEM:
  517.       return queued_subexp_p (XEXP (x, 0));
  518.     case MULT:
  519.     case PLUS:
  520.     case MINUS:
  521.       return queued_subexp_p (XEXP (x, 0))
  522.     || queued_subexp_p (XEXP (x, 1));
  523.     }
  524.   return 0;
  525. }
  526.  
  527. /* Perform all the pending incrementations.  */
  528.  
  529. void
  530. emit_queue ()
  531. {
  532.   register rtx p;
  533.   while (p = pending_chain)
  534.     {
  535.       QUEUED_INSN (p) = emit_insn (QUEUED_BODY (p));
  536.       pending_chain = QUEUED_NEXT (p);
  537.     }
  538. }
  539.  
  540. static void
  541. init_queue ()
  542. {
  543.   if (pending_chain)
  544.     abort ();
  545. }
  546.  
  547. /* Copy data from FROM to TO, where the machine modes are not the same.
  548.    Both modes may be integer, or both may be floating.
  549.    UNSIGNEDP should be nonzero if FROM is an unsigned type.
  550.    This causes zero-extension instead of sign-extension.  */
  551.  
  552. void
  553. convert_move (to, from, unsignedp)
  554.      register rtx to, from;
  555.      int unsignedp;
  556. {
  557.   enum machine_mode to_mode = GET_MODE (to);
  558.   enum machine_mode from_mode = GET_MODE (from);
  559.   int to_real = GET_MODE_CLASS (to_mode) == MODE_FLOAT;
  560.   int from_real = GET_MODE_CLASS (from_mode) == MODE_FLOAT;
  561.   enum insn_code code;
  562.   rtx libcall;
  563.  
  564.   /* rtx code for making an equivalent value.  */
  565.   enum rtx_code equiv_code = (unsignedp ? ZERO_EXTEND : SIGN_EXTEND);
  566.  
  567.   to = protect_from_queue (to, 1);
  568.   from = protect_from_queue (from, 0);
  569.  
  570.   if (to_real != from_real)
  571.     abort ();
  572.  
  573.   /* If FROM is a SUBREG that indicates that we have already done at least
  574.      the required extension, strip it.  We don't handle such SUBREGs as
  575.      TO here.  */
  576.  
  577.   if (GET_CODE (from) == SUBREG && SUBREG_PROMOTED_VAR_P (from)
  578.       && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (from)))
  579.       >= GET_MODE_SIZE (to_mode))
  580.       && SUBREG_PROMOTED_UNSIGNED_P (from) == unsignedp)
  581.     from = gen_lowpart (to_mode, from), from_mode = to_mode;
  582.  
  583.   if (GET_CODE (to) == SUBREG && SUBREG_PROMOTED_VAR_P (to))
  584.     abort ();
  585.  
  586.   if (to_mode == from_mode
  587.       || (from_mode == VOIDmode && CONSTANT_P (from)))
  588.     {
  589.       emit_move_insn (to, from);
  590.       return;
  591.     }
  592.  
  593.   if (to_real)
  594.     {
  595.       rtx value;
  596.  
  597. #ifdef HAVE_extendqfhf2
  598.       if (HAVE_extendqfsf2 && from_mode == QFmode && to_mode == HFmode)
  599.     {
  600.       emit_unop_insn (CODE_FOR_extendqfsf2, to, from, UNKNOWN);
  601.       return;
  602.     }
  603. #endif
  604. #ifdef HAVE_extendqfsf2
  605.       if (HAVE_extendqfsf2 && from_mode == QFmode && to_mode == SFmode)
  606.     {
  607.       emit_unop_insn (CODE_FOR_extendqfsf2, to, from, UNKNOWN);
  608.       return;
  609.     }
  610. #endif
  611. #ifdef HAVE_extendqfdf2
  612.       if (HAVE_extendqfdf2 && from_mode == QFmode && to_mode == DFmode)
  613.     {
  614.       emit_unop_insn (CODE_FOR_extendqfdf2, to, from, UNKNOWN);
  615.       return;
  616.     }
  617. #endif
  618. #ifdef HAVE_extendqfxf2
  619.       if (HAVE_extendqfxf2 && from_mode == QFmode && to_mode == XFmode)
  620.     {
  621.       emit_unop_insn (CODE_FOR_extendqfxf2, to, from, UNKNOWN);
  622.       return;
  623.     }
  624. #endif
  625. #ifdef HAVE_extendqftf2
  626.       if (HAVE_extendqftf2 && from_mode == QFmode && to_mode == TFmode)
  627.     {
  628.       emit_unop_insn (CODE_FOR_extendqftf2, to, from, UNKNOWN);
  629.       return;
  630.     }
  631. #endif
  632.  
  633. #ifdef HAVE_extendhftqf2
  634.       if (HAVE_extendhftqf2 && from_mode == HFmode && to_mode == TQFmode)
  635.     {
  636.       emit_unop_insn (CODE_FOR_extendhftqf2, to, from, UNKNOWN);
  637.       return;
  638.     }
  639. #endif
  640.  
  641. #ifdef HAVE_extendhfsf2
  642.       if (HAVE_extendhfsf2 && from_mode == HFmode && to_mode == SFmode)
  643.     {
  644.       emit_unop_insn (CODE_FOR_extendhfsf2, to, from, UNKNOWN);
  645.       return;
  646.     }
  647. #endif
  648. #ifdef HAVE_extendhfdf2
  649.       if (HAVE_extendhfdf2 && from_mode == HFmode && to_mode == DFmode)
  650.     {
  651.       emit_unop_insn (CODE_FOR_extendhfdf2, to, from, UNKNOWN);
  652.       return;
  653.     }
  654. #endif
  655. #ifdef HAVE_extendhfxf2
  656.       if (HAVE_extendhfxf2 && from_mode == HFmode && to_mode == XFmode)
  657.     {
  658.       emit_unop_insn (CODE_FOR_extendhfxf2, to, from, UNKNOWN);
  659.       return;
  660.     }
  661. #endif
  662. #ifdef HAVE_extendhftf2
  663.       if (HAVE_extendhftf2 && from_mode == HFmode && to_mode == TFmode)
  664.     {
  665.       emit_unop_insn (CODE_FOR_extendhftf2, to, from, UNKNOWN);
  666.       return;
  667.     }
  668. #endif
  669.  
  670. #ifdef HAVE_extendsfdf2
  671.       if (HAVE_extendsfdf2 && from_mode == SFmode && to_mode == DFmode)
  672.     {
  673.       emit_unop_insn (CODE_FOR_extendsfdf2, to, from, UNKNOWN);
  674.       return;
  675.     }
  676. #endif
  677. #ifdef HAVE_extendsfxf2
  678.       if (HAVE_extendsfxf2 && from_mode == SFmode && to_mode == XFmode)
  679.     {
  680.       emit_unop_insn (CODE_FOR_extendsfxf2, to, from, UNKNOWN);
  681.       return;
  682.     }
  683. #endif
  684. #ifdef HAVE_extendsftf2
  685.       if (HAVE_extendsftf2 && from_mode == SFmode && to_mode == TFmode)
  686.     {
  687.       emit_unop_insn (CODE_FOR_extendsftf2, to, from, UNKNOWN);
  688.       return;
  689.     }
  690. #endif
  691. #ifdef HAVE_extenddfxf2
  692.       if (HAVE_extenddfxf2 && from_mode == DFmode && to_mode == XFmode)
  693.     {
  694.       emit_unop_insn (CODE_FOR_extenddfxf2, to, from, UNKNOWN);
  695.       return;
  696.     }
  697. #endif
  698. #ifdef HAVE_extenddftf2
  699.       if (HAVE_extenddftf2 && from_mode == DFmode && to_mode == TFmode)
  700.     {
  701.       emit_unop_insn (CODE_FOR_extenddftf2, to, from, UNKNOWN);
  702.       return;
  703.     }
  704. #endif
  705.  
  706. #ifdef HAVE_trunchfqf2
  707.       if (HAVE_trunchfqf2 && from_mode == HFmode && to_mode == QFmode)
  708.     {
  709.       emit_unop_insn (CODE_FOR_trunchfqf2, to, from, UNKNOWN);
  710.       return;
  711.     }
  712. #endif
  713. #ifdef HAVE_truncsfqf2
  714.       if (HAVE_truncsfqf2 && from_mode == SFmode && to_mode == QFmode)
  715.     {
  716.       emit_unop_insn (CODE_FOR_truncsfqf2, to, from, UNKNOWN);
  717.       return;
  718.     }
  719. #endif
  720. #ifdef HAVE_truncdfqf2
  721.       if (HAVE_truncdfqf2 && from_mode == DFmode && to_mode == QFmode)
  722.     {
  723.       emit_unop_insn (CODE_FOR_truncdfqf2, to, from, UNKNOWN);
  724.       return;
  725.     }
  726. #endif
  727. #ifdef HAVE_truncxfqf2
  728.       if (HAVE_truncxfqf2 && from_mode == XFmode && to_mode == QFmode)
  729.     {
  730.       emit_unop_insn (CODE_FOR_truncxfqf2, to, from, UNKNOWN);
  731.       return;
  732.     }
  733. #endif
  734. #ifdef HAVE_trunctfqf2
  735.       if (HAVE_trunctfqf2 && from_mode == TFmode && to_mode == QFmode)
  736.     {
  737.       emit_unop_insn (CODE_FOR_trunctfqf2, to, from, UNKNOWN);
  738.       return;
  739.     }
  740. #endif
  741.  
  742. #ifdef HAVE_trunctqfhf2
  743.       if (HAVE_trunctqfhf2 && from_mode == TQFmode && to_mode == HFmode)
  744.     {
  745.       emit_unop_insn (CODE_FOR_trunctqfhf2, to, from, UNKNOWN);
  746.       return;
  747.     }
  748. #endif
  749. #ifdef HAVE_truncsfhf2
  750.       if (HAVE_truncsfhf2 && from_mode == SFmode && to_mode == HFmode)
  751.     {
  752.       emit_unop_insn (CODE_FOR_truncsfhf2, to, from, UNKNOWN);
  753.       return;
  754.     }
  755. #endif
  756. #ifdef HAVE_truncdfhf2
  757.       if (HAVE_truncdfhf2 && from_mode == DFmode && to_mode == HFmode)
  758.     {
  759.       emit_unop_insn (CODE_FOR_truncdfhf2, to, from, UNKNOWN);
  760.       return;
  761.     }
  762. #endif
  763. #ifdef HAVE_truncxfhf2
  764.       if (HAVE_truncxfhf2 && from_mode == XFmode && to_mode == HFmode)
  765.     {
  766.       emit_unop_insn (CODE_FOR_truncxfhf2, to, from, UNKNOWN);
  767.       return;
  768.     }
  769. #endif
  770. #ifdef HAVE_trunctfhf2
  771.       if (HAVE_trunctfhf2 && from_mode == TFmode && to_mode == HFmode)
  772.     {
  773.       emit_unop_insn (CODE_FOR_trunctfhf2, to, from, UNKNOWN);
  774.       return;
  775.     }
  776. #endif
  777. #ifdef HAVE_truncdfsf2
  778.       if (HAVE_truncdfsf2 && from_mode == DFmode && to_mode == SFmode)
  779.     {
  780.       emit_unop_insn (CODE_FOR_truncdfsf2, to, from, UNKNOWN);
  781.       return;
  782.     }
  783. #endif
  784. #ifdef HAVE_truncxfsf2
  785.       if (HAVE_truncxfsf2 && from_mode == XFmode && to_mode == SFmode)
  786.     {
  787.       emit_unop_insn (CODE_FOR_truncxfsf2, to, from, UNKNOWN);
  788.       return;
  789.     }
  790. #endif
  791. #ifdef HAVE_trunctfsf2
  792.       if (HAVE_trunctfsf2 && from_mode == TFmode && to_mode == SFmode)
  793.     {
  794.       emit_unop_insn (CODE_FOR_trunctfsf2, to, from, UNKNOWN);
  795.       return;
  796.     }
  797. #endif
  798. #ifdef HAVE_truncxfdf2
  799.       if (HAVE_truncxfdf2 && from_mode == XFmode && to_mode == DFmode)
  800.     {
  801.       emit_unop_insn (CODE_FOR_truncxfdf2, to, from, UNKNOWN);
  802.       return;
  803.     }
  804. #endif
  805. #ifdef HAVE_trunctfdf2
  806.       if (HAVE_trunctfdf2 && from_mode == TFmode && to_mode == DFmode)
  807.     {
  808.       emit_unop_insn (CODE_FOR_trunctfdf2, to, from, UNKNOWN);
  809.       return;
  810.     }
  811. #endif
  812.  
  813.       libcall = (rtx) 0;
  814.       switch (from_mode)
  815.     {
  816.     case SFmode:
  817.       switch (to_mode)
  818.         {
  819.         case DFmode:
  820.           libcall = extendsfdf2_libfunc;
  821.           break;
  822.  
  823.         case XFmode:
  824.           libcall = extendsfxf2_libfunc;
  825.           break;
  826.  
  827.         case TFmode:
  828.           libcall = extendsftf2_libfunc;
  829.           break;
  830.         }
  831.       break;
  832.  
  833.     case DFmode:
  834.       switch (to_mode)
  835.         {
  836.         case SFmode:
  837.           libcall = truncdfsf2_libfunc;
  838.           break;
  839.  
  840.         case XFmode:
  841.           libcall = extenddfxf2_libfunc;
  842.           break;
  843.  
  844.         case TFmode:
  845.           libcall = extenddftf2_libfunc;
  846.           break;
  847.         }
  848.       break;
  849.  
  850.     case XFmode:
  851.       switch (to_mode)
  852.         {
  853.         case SFmode:
  854.           libcall = truncxfsf2_libfunc;
  855.           break;
  856.  
  857.         case DFmode:
  858.           libcall = truncxfdf2_libfunc;
  859.           break;
  860.         }
  861.       break;
  862.  
  863.     case TFmode:
  864.       switch (to_mode)
  865.         {
  866.         case SFmode:
  867.           libcall = trunctfsf2_libfunc;
  868.           break;
  869.  
  870.         case DFmode:
  871.           libcall = trunctfdf2_libfunc;
  872.           break;
  873.         }
  874.       break;
  875.     }
  876.  
  877.       if (libcall == (rtx) 0)
  878.     /* This conversion is not implemented yet.  */
  879.     abort ();
  880.  
  881.       value = emit_library_call_value (libcall, NULL_RTX, 1, to_mode,
  882.                        1, from, from_mode);
  883.       emit_move_insn (to, value);
  884.       return;
  885.     }
  886.  
  887.   /* Now both modes are integers.  */
  888.  
  889.   /* Handle expanding beyond a word.  */
  890.   if (GET_MODE_BITSIZE (from_mode) < GET_MODE_BITSIZE (to_mode)
  891.       && GET_MODE_BITSIZE (to_mode) > BITS_PER_WORD)
  892.     {
  893.       rtx insns;
  894.       rtx lowpart;
  895.       rtx fill_value;
  896.       rtx lowfrom;
  897.       int i;
  898.       enum machine_mode lowpart_mode;
  899.       int nwords = CEIL (GET_MODE_SIZE (to_mode), UNITS_PER_WORD);
  900.  
  901.       /* Try converting directly if the insn is supported.  */
  902.       if ((code = can_extend_p (to_mode, from_mode, unsignedp))
  903.       != CODE_FOR_nothing)
  904.     {
  905.       /* If FROM is a SUBREG, put it into a register.  Do this
  906.          so that we always generate the same set of insns for
  907.          better cse'ing; if an intermediate assignment occurred,
  908.          we won't be doing the operation directly on the SUBREG.  */
  909.       if (optimize > 0 && GET_CODE (from) == SUBREG)
  910.         from = force_reg (from_mode, from);
  911.       emit_unop_insn (code, to, from, equiv_code);
  912.       return;
  913.     }
  914.       /* Next, try converting via full word.  */
  915.       else if (GET_MODE_BITSIZE (from_mode) < BITS_PER_WORD
  916.            && ((code = can_extend_p (to_mode, word_mode, unsignedp))
  917.            != CODE_FOR_nothing))
  918.     {
  919.       if (GET_CODE (to) == REG)
  920.         emit_insn (gen_rtx (CLOBBER, VOIDmode, to));
  921.       convert_move (gen_lowpart (word_mode, to), from, unsignedp);
  922.       emit_unop_insn (code, to,
  923.               gen_lowpart (word_mode, to), equiv_code);
  924.       return;
  925.     }
  926.  
  927.       /* No special multiword conversion insn; do it by hand.  */
  928.       start_sequence ();
  929.  
  930.       /* Since we will turn this into a no conflict block, we must ensure
  931.      that the source does not overlap the target.  */
  932.  
  933.       if (reg_overlap_mentioned_p (to, from))
  934.     from = force_reg (from_mode, from);
  935.  
  936.       /* Get a copy of FROM widened to a word, if necessary.  */
  937.       if (GET_MODE_BITSIZE (from_mode) < BITS_PER_WORD)
  938.     lowpart_mode = word_mode;
  939.       else
  940.     lowpart_mode = from_mode;
  941.  
  942.       lowfrom = convert_to_mode (lowpart_mode, from, unsignedp);
  943.  
  944.       lowpart = gen_lowpart (lowpart_mode, to);
  945.       emit_move_insn (lowpart, lowfrom);
  946.  
  947.       /* Compute the value to put in each remaining word.  */
  948.       if (unsignedp)
  949.     fill_value = const0_rtx;
  950.       else
  951.     {
  952. #ifdef HAVE_slt
  953.       if (HAVE_slt
  954.           && insn_operand_mode[(int) CODE_FOR_slt][0] == word_mode
  955.           && STORE_FLAG_VALUE == -1)
  956.         {
  957.           emit_cmp_insn (lowfrom, const0_rtx, NE, NULL_RTX,
  958.                  lowpart_mode, 0, 0);
  959.           fill_value = gen_reg_rtx (word_mode);
  960.           emit_insn (gen_slt (fill_value));
  961.         }
  962.       else
  963. #endif
  964.         {
  965.           fill_value
  966.         = expand_shift (RSHIFT_EXPR, lowpart_mode, lowfrom,
  967.                 size_int (GET_MODE_BITSIZE (lowpart_mode) - 1),
  968.                 NULL_RTX, 0);
  969.           fill_value = convert_to_mode (word_mode, fill_value, 1);
  970.         }
  971.     }
  972.  
  973.       /* Fill the remaining words.  */
  974.       for (i = GET_MODE_SIZE (lowpart_mode) / UNITS_PER_WORD; i < nwords; i++)
  975.     {
  976.       int index = (WORDS_BIG_ENDIAN ? nwords - i - 1 : i);
  977.       rtx subword = operand_subword (to, index, 1, to_mode);
  978.  
  979.       if (subword == 0)
  980.         abort ();
  981.  
  982.       if (fill_value != subword)
  983.         emit_move_insn (subword, fill_value);
  984.     }
  985.  
  986.       insns = get_insns ();
  987.       end_sequence ();
  988.  
  989.       emit_no_conflict_block (insns, to, from, NULL_RTX,
  990.                   gen_rtx (equiv_code, to_mode, copy_rtx (from)));
  991.       return;
  992.     }
  993.  
  994.   /* Truncating multi-word to a word or less.  */
  995.   if (GET_MODE_BITSIZE (from_mode) > BITS_PER_WORD
  996.       && GET_MODE_BITSIZE (to_mode) <= BITS_PER_WORD)
  997.     {
  998.       if (!((GET_CODE (from) == MEM
  999.          && ! MEM_VOLATILE_P (from)
  1000.          && direct_load[(int) to_mode]
  1001.          && ! mode_dependent_address_p (XEXP (from, 0)))
  1002.         || GET_CODE (from) == REG
  1003.         || GET_CODE (from) == SUBREG))
  1004.     from = force_reg (from_mode, from);
  1005.       convert_move (to, gen_lowpart (word_mode, from), 0);
  1006.       return;
  1007.     }
  1008.  
  1009.   /* Handle pointer conversion */            /* SPEE 900220 */
  1010.   if (to_mode == PSImode)
  1011.     {
  1012.       if (from_mode != SImode)
  1013.     from = convert_to_mode (SImode, from, unsignedp);
  1014.  
  1015. #ifdef HAVE_truncsipsi2
  1016.       if (HAVE_truncsipsi2)
  1017.     {
  1018.       emit_unop_insn (CODE_FOR_truncsipsi2, to, from, UNKNOWN);
  1019.       return;
  1020.     }
  1021. #endif /* HAVE_truncsipsi2 */
  1022.       abort ();
  1023.     }
  1024.  
  1025.   if (from_mode == PSImode)
  1026.     {
  1027.       if (to_mode != SImode)
  1028.     {
  1029.       from = convert_to_mode (SImode, from, unsignedp);
  1030.       from_mode = SImode;
  1031.     }
  1032.       else
  1033.     {
  1034. #ifdef HAVE_extendpsisi2
  1035.       if (HAVE_extendpsisi2)
  1036.         {
  1037.           emit_unop_insn (CODE_FOR_extendpsisi2, to, from, UNKNOWN);
  1038.           return;
  1039.         }
  1040. #endif /* HAVE_extendpsisi2 */
  1041.       abort ();
  1042.     }
  1043.     }
  1044.  
  1045.   if (to_mode == PDImode)
  1046.     {
  1047.       if (from_mode != DImode)
  1048.     from = convert_to_mode (DImode, from, unsignedp);
  1049.  
  1050. #ifdef HAVE_truncdipdi2
  1051.       if (HAVE_truncdipdi2)
  1052.     {
  1053.       emit_unop_insn (CODE_FOR_truncdipdi2, to, from, UNKNOWN);
  1054.       return;
  1055.     }
  1056. #endif /* HAVE_truncdipdi2 */
  1057.       abort ();
  1058.     }
  1059.  
  1060.   if (from_mode == PDImode)
  1061.     {
  1062.       if (to_mode != DImode)
  1063.     {
  1064.       from = convert_to_mode (DImode, from, unsignedp);
  1065.       from_mode = DImode;
  1066.     }
  1067.       else
  1068.     {
  1069. #ifdef HAVE_extendpdidi2
  1070.       if (HAVE_extendpdidi2)
  1071.         {
  1072.           emit_unop_insn (CODE_FOR_extendpdidi2, to, from, UNKNOWN);
  1073.           return;
  1074.         }
  1075. #endif /* HAVE_extendpdidi2 */
  1076.       abort ();
  1077.     }
  1078.     }
  1079.  
  1080.   /* Now follow all the conversions between integers
  1081.      no more than a word long.  */
  1082.  
  1083.   /* For truncation, usually we can just refer to FROM in a narrower mode.  */
  1084.   if (GET_MODE_BITSIZE (to_mode) < GET_MODE_BITSIZE (from_mode)
  1085.       && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (to_mode),
  1086.                 GET_MODE_BITSIZE (from_mode)))
  1087.     {
  1088.       if (!((GET_CODE (from) == MEM
  1089.          && ! MEM_VOLATILE_P (from)
  1090.          && direct_load[(int) to_mode]
  1091.          && ! mode_dependent_address_p (XEXP (from, 0)))
  1092.         || GET_CODE (from) == REG
  1093.         || GET_CODE (from) == SUBREG))
  1094.     from = force_reg (from_mode, from);
  1095.       if (GET_CODE (from) == REG && REGNO (from) < FIRST_PSEUDO_REGISTER
  1096.       && ! HARD_REGNO_MODE_OK (REGNO (from), to_mode))
  1097.     from = copy_to_reg (from);
  1098.       emit_move_insn (to, gen_lowpart (to_mode, from));
  1099.       return;
  1100.     }
  1101.  
  1102.   /* Handle extension.  */
  1103.   if (GET_MODE_BITSIZE (to_mode) > GET_MODE_BITSIZE (from_mode))
  1104.     {
  1105.       /* Convert directly if that works.  */
  1106.       if ((code = can_extend_p (to_mode, from_mode, unsignedp))
  1107.       != CODE_FOR_nothing)
  1108.     {
  1109.       emit_unop_insn (code, to, from, equiv_code);
  1110.       return;
  1111.     }
  1112.       else
  1113.     {
  1114.       enum machine_mode intermediate;
  1115.  
  1116.       /* Search for a mode to convert via.  */
  1117.       for (intermediate = from_mode; intermediate != VOIDmode;
  1118.            intermediate = GET_MODE_WIDER_MODE (intermediate))
  1119.         if (((can_extend_p (to_mode, intermediate, unsignedp)
  1120.           != CODE_FOR_nothing)
  1121.          || (GET_MODE_SIZE (to_mode) < GET_MODE_SIZE (intermediate)
  1122.              && TRULY_NOOP_TRUNCATION (to_mode, intermediate)))
  1123.         && (can_extend_p (intermediate, from_mode, unsignedp)
  1124.             != CODE_FOR_nothing))
  1125.           {
  1126.         convert_move (to, convert_to_mode (intermediate, from,
  1127.                            unsignedp), unsignedp);
  1128.         return;
  1129.           }
  1130.  
  1131.       /* No suitable intermediate mode.  */
  1132.       abort ();
  1133.     }
  1134.     }
  1135.  
  1136.   /* Support special truncate insns for certain modes.  */ 
  1137.  
  1138.   if (from_mode == DImode && to_mode == SImode)
  1139.     {
  1140. #ifdef HAVE_truncdisi2
  1141.       if (HAVE_truncdisi2)
  1142.     {
  1143.       emit_unop_insn (CODE_FOR_truncdisi2, to, from, UNKNOWN);
  1144.       return;
  1145.     }
  1146. #endif
  1147.       convert_move (to, force_reg (from_mode, from), unsignedp);
  1148.       return;
  1149.     }
  1150.  
  1151.   if (from_mode == DImode && to_mode == HImode)
  1152.     {
  1153. #ifdef HAVE_truncdihi2
  1154.       if (HAVE_truncdihi2)
  1155.     {
  1156.       emit_unop_insn (CODE_FOR_truncdihi2, to, from, UNKNOWN);
  1157.       return;
  1158.     }
  1159. #endif
  1160.       convert_move (to, force_reg (from_mode, from), unsignedp);
  1161.       return;
  1162.     }
  1163.  
  1164.   if (from_mode == DImode && to_mode == QImode)
  1165.     {
  1166. #ifdef HAVE_truncdiqi2
  1167.       if (HAVE_truncdiqi2)
  1168.     {
  1169.       emit_unop_insn (CODE_FOR_truncdiqi2, to, from, UNKNOWN);
  1170.       return;
  1171.     }
  1172. #endif
  1173.       convert_move (to, force_reg (from_mode, from), unsignedp);
  1174.       return;
  1175.     }
  1176.  
  1177.   if (from_mode == SImode && to_mode == HImode)
  1178.     {
  1179. #ifdef HAVE_truncsihi2
  1180.       if (HAVE_truncsihi2)
  1181.     {
  1182.       emit_unop_insn (CODE_FOR_truncsihi2, to, from, UNKNOWN);
  1183.       return;
  1184.     }
  1185. #endif
  1186.       convert_move (to, force_reg (from_mode, from), unsignedp);
  1187.       return;
  1188.     }
  1189.  
  1190.   if (from_mode == SImode && to_mode == QImode)
  1191.     {
  1192. #ifdef HAVE_truncsiqi2
  1193.       if (HAVE_truncsiqi2)
  1194.     {
  1195.       emit_unop_insn (CODE_FOR_truncsiqi2, to, from, UNKNOWN);
  1196.       return;
  1197.     }
  1198. #endif
  1199.       convert_move (to, force_reg (from_mode, from), unsignedp);
  1200.       return;
  1201.     }
  1202.  
  1203.   if (from_mode == HImode && to_mode == QImode)
  1204.     {
  1205. #ifdef HAVE_trunchiqi2
  1206.       if (HAVE_trunchiqi2)
  1207.     {
  1208.       emit_unop_insn (CODE_FOR_trunchiqi2, to, from, UNKNOWN);
  1209.       return;
  1210.     }
  1211. #endif
  1212.       convert_move (to, force_reg (from_mode, from), unsignedp);
  1213.       return;
  1214.     }
  1215.  
  1216.   if (from_mode == TImode && to_mode == DImode)
  1217.     {
  1218. #ifdef HAVE_trunctidi2
  1219.       if (HAVE_trunctidi2)
  1220.     {
  1221.       emit_unop_insn (CODE_FOR_trunctidi2, to, from, UNKNOWN);
  1222.       return;
  1223.     }
  1224. #endif
  1225.       convert_move (to, force_reg (from_mode, from), unsignedp);
  1226.       return;
  1227.     }
  1228.  
  1229.   if (from_mode == TImode && to_mode == SImode)
  1230.     {
  1231. #ifdef HAVE_trunctisi2
  1232.       if (HAVE_trunctisi2)
  1233.     {
  1234.       emit_unop_insn (CODE_FOR_trunctisi2, to, from, UNKNOWN);
  1235.       return;
  1236.     }
  1237. #endif
  1238.       convert_move (to, force_reg (from_mode, from), unsignedp);
  1239.       return;
  1240.     }
  1241.  
  1242.   if (from_mode == TImode && to_mode == HImode)
  1243.     {
  1244. #ifdef HAVE_trunctihi2
  1245.       if (HAVE_trunctihi2)
  1246.     {
  1247.       emit_unop_insn (CODE_FOR_trunctihi2, to, from, UNKNOWN);
  1248.       return;
  1249.     }
  1250. #endif
  1251.       convert_move (to, force_reg (from_mode, from), unsignedp);
  1252.       return;
  1253.     }
  1254.  
  1255.   if (from_mode == TImode && to_mode == QImode)
  1256.     {
  1257. #ifdef HAVE_trunctiqi2
  1258.       if (HAVE_trunctiqi2)
  1259.     {
  1260.       emit_unop_insn (CODE_FOR_trunctiqi2, to, from, UNKNOWN);
  1261.       return;
  1262.     }
  1263. #endif
  1264.       convert_move (to, force_reg (from_mode, from), unsignedp);
  1265.       return;
  1266.     }
  1267.  
  1268.   /* Handle truncation of volatile memrefs, and so on;
  1269.      the things that couldn't be truncated directly,
  1270.      and for which there was no special instruction.  */
  1271.   if (GET_MODE_BITSIZE (to_mode) < GET_MODE_BITSIZE (from_mode))
  1272.     {
  1273.       rtx temp = force_reg (to_mode, gen_lowpart (to_mode, from));
  1274.       emit_move_insn (to, temp);
  1275.       return;
  1276.     }
  1277.  
  1278.   /* Mode combination is not recognized.  */
  1279.   abort ();
  1280. }
  1281.  
  1282. /* Return an rtx for a value that would result
  1283.    from converting X to mode MODE.
  1284.    Both X and MODE may be floating, or both integer.
  1285.    UNSIGNEDP is nonzero if X is an unsigned value.
  1286.    This can be done by referring to a part of X in place
  1287.    or by copying to a new temporary with conversion.
  1288.  
  1289.    This function *must not* call protect_from_queue
  1290.    except when putting X into an insn (in which case convert_move does it).  */
  1291.  
  1292. rtx
  1293. convert_to_mode (mode, x, unsignedp)
  1294.      enum machine_mode mode;
  1295.      rtx x;
  1296.      int unsignedp;
  1297. {
  1298.   return convert_modes (mode, VOIDmode, x, unsignedp);
  1299. }
  1300.  
  1301. /* Return an rtx for a value that would result
  1302.    from converting X from mode OLDMODE to mode MODE.
  1303.    Both modes may be floating, or both integer.
  1304.    UNSIGNEDP is nonzero if X is an unsigned value.
  1305.  
  1306.    This can be done by referring to a part of X in place
  1307.    or by copying to a new temporary with conversion.
  1308.  
  1309.    You can give VOIDmode for OLDMODE, if you are sure X has a nonvoid mode.
  1310.  
  1311.    This function *must not* call protect_from_queue
  1312.    except when putting X into an insn (in which case convert_move does it).  */
  1313.  
  1314. rtx
  1315. convert_modes (mode, oldmode, x, unsignedp)
  1316.      enum machine_mode mode, oldmode;
  1317.      rtx x;
  1318.      int unsignedp;
  1319. {
  1320.   register rtx temp;
  1321.  
  1322.   /* If FROM is a SUBREG that indicates that we have already done at least
  1323.      the required extension, strip it.  */
  1324.  
  1325.   if (GET_CODE (x) == SUBREG && SUBREG_PROMOTED_VAR_P (x)
  1326.       && GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))) >= GET_MODE_SIZE (mode)
  1327.       && SUBREG_PROMOTED_UNSIGNED_P (x) == unsignedp)
  1328.     x = gen_lowpart (mode, x);
  1329.  
  1330.   if (GET_MODE (x) != VOIDmode)
  1331.     oldmode = GET_MODE (x);
  1332.  
  1333.   if (mode == oldmode)
  1334.     return x;
  1335.  
  1336.   /* There is one case that we must handle specially: If we are converting
  1337.      a CONST_INT into a mode whose size is twice HOST_BITS_PER_WIDE_INT and
  1338.      we are to interpret the constant as unsigned, gen_lowpart will do
  1339.      the wrong if the constant appears negative.  What we want to do is
  1340.      make the high-order word of the constant zero, not all ones.  */
  1341.  
  1342.   if (unsignedp && GET_MODE_CLASS (mode) == MODE_INT
  1343.       && GET_MODE_BITSIZE (mode) == 2 * HOST_BITS_PER_WIDE_INT
  1344.       && GET_CODE (x) == CONST_INT && INTVAL (x) < 0)
  1345.     return immed_double_const (INTVAL (x), (HOST_WIDE_INT) 0, mode);
  1346.  
  1347.   /* We can do this with a gen_lowpart if both desired and current modes
  1348.      are integer, and this is either a constant integer, a register, or a
  1349.      non-volatile MEM.  Except for the constant case where MODE is no
  1350.      wider than HOST_BITS_PER_WIDE_INT, we must be narrowing the operand.  */
  1351.  
  1352.   if ((GET_CODE (x) == CONST_INT
  1353.        && GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT)
  1354.       || (GET_MODE_CLASS (mode) == MODE_INT
  1355.       && GET_MODE_CLASS (oldmode) == MODE_INT
  1356.       && (GET_CODE (x) == CONST_DOUBLE
  1357.           || (GET_MODE_SIZE (mode) <= GET_MODE_SIZE (oldmode)
  1358.           && ((GET_CODE (x) == MEM && ! MEM_VOLATILE_P (x)
  1359.                && direct_load[(int) mode])
  1360.               || (GET_CODE (x) == REG
  1361.               && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (mode),
  1362.                             GET_MODE_BITSIZE (GET_MODE (x)))))))))
  1363.     {
  1364.       /* ?? If we don't know OLDMODE, we have to assume here that
  1365.      X does not need sign- or zero-extension.   This may not be
  1366.      the case, but it's the best we can do.  */
  1367.       if (GET_CODE (x) == CONST_INT && oldmode != VOIDmode
  1368.       && GET_MODE_SIZE (mode) > GET_MODE_SIZE (oldmode))
  1369.     {
  1370.       HOST_WIDE_INT val = INTVAL (x);
  1371.       int width = GET_MODE_BITSIZE (oldmode);
  1372.  
  1373.       /* We must sign or zero-extend in this case.  Start by
  1374.          zero-extending, then sign extend if we need to.  */
  1375.       val &= ((HOST_WIDE_INT) 1 << width) - 1;
  1376.       if (! unsignedp
  1377.           && (val & ((HOST_WIDE_INT) 1 << (width - 1))))
  1378.         val |= (HOST_WIDE_INT) (-1) << width;
  1379.  
  1380.       return GEN_INT (val);
  1381.     }
  1382.  
  1383.       return gen_lowpart (mode, x);
  1384.     }
  1385.  
  1386.   temp = gen_reg_rtx (mode);
  1387.   convert_move (temp, x, unsignedp);
  1388.   return temp;
  1389. }
  1390.  
  1391. /* Generate several move instructions to copy LEN bytes
  1392.    from block FROM to block TO.  (These are MEM rtx's with BLKmode).
  1393.    The caller must pass FROM and TO
  1394.     through protect_from_queue before calling.
  1395.    ALIGN (in bytes) is maximum alignment we can assume.  */
  1396.  
  1397. static void
  1398. move_by_pieces (to, from, len, align)
  1399.      rtx to, from;
  1400.      int len, align;
  1401. {
  1402.   struct move_by_pieces data;
  1403.   rtx to_addr = XEXP (to, 0), from_addr = XEXP (from, 0);
  1404.   int max_size = MOVE_MAX + 1;
  1405.  
  1406.   data.offset = 0;
  1407.   data.to_addr = to_addr;
  1408.   data.from_addr = from_addr;
  1409.   data.to = to;
  1410.   data.from = from;
  1411.   data.autinc_to
  1412.     = (GET_CODE (to_addr) == PRE_INC || GET_CODE (to_addr) == PRE_DEC
  1413.        || GET_CODE (to_addr) == POST_INC || GET_CODE (to_addr) == POST_DEC);
  1414.   data.autinc_from
  1415.     = (GET_CODE (from_addr) == PRE_INC || GET_CODE (from_addr) == PRE_DEC
  1416.        || GET_CODE (from_addr) == POST_INC
  1417.        || GET_CODE (from_addr) == POST_DEC);
  1418.  
  1419.   data.explicit_inc_from = 0;
  1420.   data.explicit_inc_to = 0;
  1421.   data.reverse
  1422.     = (GET_CODE (to_addr) == PRE_DEC || GET_CODE (to_addr) == POST_DEC);
  1423.   if (data.reverse) data.offset = len;
  1424.   data.len = len;
  1425.  
  1426.   data.to_struct = MEM_IN_STRUCT_P (to);
  1427.   data.from_struct = MEM_IN_STRUCT_P (from);
  1428.  
  1429.   /* If copying requires more than two move insns,
  1430.      copy addresses to registers (to make displacements shorter)
  1431.      and use post-increment if available.  */
  1432.   if (!(data.autinc_from && data.autinc_to)
  1433.       && move_by_pieces_ninsns (len, align) > 2)
  1434.     {
  1435. #ifdef HAVE_PRE_DECREMENT
  1436.       if (data.reverse && ! data.autinc_from)
  1437.     {
  1438.       data.from_addr = copy_addr_to_reg (plus_constant (from_addr, len));
  1439.       data.autinc_from = 1;
  1440.       data.explicit_inc_from = -1;
  1441.     }
  1442. #endif
  1443. #ifdef HAVE_POST_INCREMENT
  1444.       if (! data.autinc_from)
  1445.     {
  1446.       data.from_addr = copy_addr_to_reg (from_addr);
  1447.       data.autinc_from = 1;
  1448.       data.explicit_inc_from = 1;
  1449.     }
  1450. #endif
  1451.       if (!data.autinc_from && CONSTANT_P (from_addr))
  1452.     data.from_addr = copy_addr_to_reg (from_addr);
  1453. #ifdef HAVE_PRE_DECREMENT
  1454.       if (data.reverse && ! data.autinc_to)
  1455.     {
  1456.       data.to_addr = copy_addr_to_reg (plus_constant (to_addr, len));
  1457.       data.autinc_to = 1;
  1458.       data.explicit_inc_to = -1;
  1459.     }
  1460. #endif
  1461. #ifdef HAVE_POST_INCREMENT
  1462.       if (! data.reverse && ! data.autinc_to)
  1463.     {
  1464.       data.to_addr = copy_addr_to_reg (to_addr);
  1465.       data.autinc_to = 1;
  1466.       data.explicit_inc_to = 1;
  1467.     }
  1468. #endif
  1469.       if (!data.autinc_to && CONSTANT_P (to_addr))
  1470.     data.to_addr = copy_addr_to_reg (to_addr);
  1471.     }
  1472.  
  1473.   if (! SLOW_UNALIGNED_ACCESS
  1474.       || align > MOVE_MAX || align >= BIGGEST_ALIGNMENT / BITS_PER_UNIT)
  1475.     align = MOVE_MAX;
  1476.  
  1477.   /* First move what we can in the largest integer mode, then go to
  1478.      successively smaller modes.  */
  1479.  
  1480.   while (max_size > 1)
  1481.     {
  1482.       enum machine_mode mode = VOIDmode, tmode;
  1483.       enum insn_code icode;
  1484.  
  1485.       for (tmode = GET_CLASS_NARROWEST_MODE (MODE_INT);
  1486.        tmode != VOIDmode; tmode = GET_MODE_WIDER_MODE (tmode))
  1487.     if (GET_MODE_SIZE (tmode) < max_size)
  1488.       mode = tmode;
  1489.  
  1490.       if (mode == VOIDmode)
  1491.     break;
  1492.  
  1493.       icode = mov_optab->handlers[(int) mode].insn_code;
  1494.       if (icode != CODE_FOR_nothing
  1495.       && align >= MIN (BIGGEST_ALIGNMENT / BITS_PER_UNIT,
  1496.                GET_MODE_SIZE (mode)))
  1497.     move_by_pieces_1 (GEN_FCN (icode), mode, &data);
  1498.  
  1499.       max_size = GET_MODE_SIZE (mode);
  1500.     }
  1501.  
  1502.   /* The code above should have handled everything.  */
  1503.   if (data.len != 0)
  1504.     abort ();
  1505. }
  1506.  
  1507. /* Return number of insns required to move L bytes by pieces.
  1508.    ALIGN (in bytes) is maximum alignment we can assume.  */
  1509.  
  1510. static int
  1511. move_by_pieces_ninsns (l, align)
  1512.      unsigned int l;
  1513.      int align;
  1514. {
  1515.   register int n_insns = 0;
  1516.   int max_size = MOVE_MAX + 1;
  1517.  
  1518.   if (! SLOW_UNALIGNED_ACCESS
  1519.       || align > MOVE_MAX || align >= BIGGEST_ALIGNMENT / BITS_PER_UNIT)
  1520.     align = MOVE_MAX;
  1521.  
  1522.   while (max_size > 1)
  1523.     {
  1524.       enum machine_mode mode = VOIDmode, tmode;
  1525.       enum insn_code icode;
  1526.  
  1527.       for (tmode = GET_CLASS_NARROWEST_MODE (MODE_INT);
  1528.        tmode != VOIDmode; tmode = GET_MODE_WIDER_MODE (tmode))
  1529.     if (GET_MODE_SIZE (tmode) < max_size)
  1530.       mode = tmode;
  1531.  
  1532.       if (mode == VOIDmode)
  1533.     break;
  1534.  
  1535.       icode = mov_optab->handlers[(int) mode].insn_code;
  1536.       if (icode != CODE_FOR_nothing
  1537.       && align >= MIN (BIGGEST_ALIGNMENT / BITS_PER_UNIT,
  1538.                GET_MODE_SIZE (mode)))
  1539.     n_insns += l / GET_MODE_SIZE (mode), l %= GET_MODE_SIZE (mode);
  1540.  
  1541.       max_size = GET_MODE_SIZE (mode);
  1542.     }
  1543.  
  1544.   return n_insns;
  1545. }
  1546.  
  1547. /* Subroutine of move_by_pieces.  Move as many bytes as appropriate
  1548.    with move instructions for mode MODE.  GENFUN is the gen_... function
  1549.    to make a move insn for that mode.  DATA has all the other info.  */
  1550.  
  1551. static void
  1552. move_by_pieces_1 (genfun, mode, data)
  1553.      rtx (*genfun) ();
  1554.      enum machine_mode mode;
  1555.      struct move_by_pieces *data;
  1556. {
  1557.   register int size = GET_MODE_SIZE (mode);
  1558.   register rtx to1, from1;
  1559.  
  1560.   while (data->len >= size)
  1561.     {
  1562.       if (data->reverse) data->offset -= size;
  1563.  
  1564.       to1 = (data->autinc_to
  1565.          ? gen_rtx (MEM, mode, data->to_addr)
  1566.          : change_address (data->to, mode,
  1567.                    plus_constant (data->to_addr, data->offset)));
  1568.       MEM_IN_STRUCT_P (to1) = data->to_struct;
  1569.       from1 =
  1570.     (data->autinc_from
  1571.      ? gen_rtx (MEM, mode, data->from_addr)
  1572.      : change_address (data->from, mode,
  1573.                plus_constant (data->from_addr, data->offset)));
  1574.       MEM_IN_STRUCT_P (from1) = data->from_struct;
  1575.  
  1576. #ifdef HAVE_PRE_DECREMENT
  1577.       if (data->explicit_inc_to < 0)
  1578.     emit_insn (gen_add2_insn (data->to_addr, GEN_INT (-size)));
  1579.       if (data->explicit_inc_from < 0)
  1580.     emit_insn (gen_add2_insn (data->from_addr, GEN_INT (-size)));
  1581. #endif
  1582.  
  1583.       emit_insn ((*genfun) (to1, from1));
  1584. #ifdef HAVE_POST_INCREMENT
  1585.       if (data->explicit_inc_to > 0)
  1586.     emit_insn (gen_add2_insn (data->to_addr, GEN_INT (size)));
  1587.       if (data->explicit_inc_from > 0)
  1588.     emit_insn (gen_add2_insn (data->from_addr, GEN_INT (size)));
  1589. #endif
  1590.  
  1591.       if (! data->reverse) data->offset += size;
  1592.  
  1593.       data->len -= size;
  1594.     }
  1595. }
  1596.  
  1597. /* Emit code to move a block Y to a block X.
  1598.    This may be done with string-move instructions,
  1599.    with multiple scalar move instructions, or with a library call.
  1600.  
  1601.    Both X and Y must be MEM rtx's (perhaps inside VOLATILE)
  1602.    with mode BLKmode.
  1603.    SIZE is an rtx that says how long they are.
  1604.    ALIGN is the maximum alignment we can assume they have,
  1605.    measured in bytes.  */
  1606.  
  1607. void
  1608. emit_block_move (x, y, size, align)
  1609.      rtx x, y;
  1610.      rtx size;
  1611.      int align;
  1612. {
  1613.   if (GET_MODE (x) != BLKmode)
  1614.     abort ();
  1615.  
  1616.   if (GET_MODE (y) != BLKmode)
  1617.     abort ();
  1618.  
  1619.   x = protect_from_queue (x, 1);
  1620.   y = protect_from_queue (y, 0);
  1621.   size = protect_from_queue (size, 0);
  1622.  
  1623.   if (GET_CODE (x) != MEM)
  1624.     abort ();
  1625.   if (GET_CODE (y) != MEM)
  1626.     abort ();
  1627.   if (size == 0)
  1628.     abort ();
  1629.  
  1630.   if (GET_CODE (size) == CONST_INT
  1631.       && (move_by_pieces_ninsns (INTVAL (size), align) < MOVE_RATIO))
  1632.     move_by_pieces (x, y, INTVAL (size), align);
  1633.   else
  1634.     {
  1635.       /* Try the most limited insn first, because there's no point
  1636.      including more than one in the machine description unless
  1637.      the more limited one has some advantage.  */
  1638.  
  1639.       rtx opalign = GEN_INT (align);
  1640.       enum machine_mode mode;
  1641.  
  1642.       for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); mode != VOIDmode;
  1643.        mode = GET_MODE_WIDER_MODE (mode))
  1644.     {
  1645.       enum insn_code code = movstr_optab[(int) mode];
  1646.  
  1647.       if (code != CODE_FOR_nothing
  1648.           /* We don't need MODE to be narrower than BITS_PER_HOST_WIDE_INT
  1649.          here because if SIZE is less than the mode mask, as it is
  1650.          returned by the macro, it will definitely be less than the
  1651.          actual mode mask.  */
  1652.           && ((GET_CODE (size) == CONST_INT
  1653.            && ((unsigned HOST_WIDE_INT) INTVAL (size)
  1654.                <= GET_MODE_MASK (mode)))
  1655.           || GET_MODE_BITSIZE (mode) >= BITS_PER_WORD)
  1656.           && (insn_operand_predicate[(int) code][0] == 0
  1657.           || (*insn_operand_predicate[(int) code][0]) (x, BLKmode))
  1658.           && (insn_operand_predicate[(int) code][1] == 0
  1659.           || (*insn_operand_predicate[(int) code][1]) (y, BLKmode))
  1660.           && (insn_operand_predicate[(int) code][3] == 0
  1661.           || (*insn_operand_predicate[(int) code][3]) (opalign,
  1662.                                    VOIDmode)))
  1663.         {
  1664.           rtx op2;
  1665.           rtx last = get_last_insn ();
  1666.           rtx pat;
  1667.  
  1668.           op2 = convert_to_mode (mode, size, 1);
  1669.           if (insn_operand_predicate[(int) code][2] != 0
  1670.           && ! (*insn_operand_predicate[(int) code][2]) (op2, mode))
  1671.         op2 = copy_to_mode_reg (mode, op2);
  1672.  
  1673.           pat = GEN_FCN ((int) code) (x, y, op2, opalign);
  1674.           if (pat)
  1675.         {
  1676.           emit_insn (pat);
  1677.           return;
  1678.         }
  1679.           else
  1680.         delete_insns_since (last);
  1681.         }
  1682.     }
  1683.  
  1684. #ifdef TARGET_MEM_FUNCTIONS
  1685.       emit_library_call (memcpy_libfunc, 0,
  1686.              VOIDmode, 3, XEXP (x, 0), Pmode,
  1687.              XEXP (y, 0), Pmode,
  1688.              convert_to_mode (TYPE_MODE (sizetype), size,
  1689.                       TREE_UNSIGNED (sizetype)),
  1690.              TYPE_MODE (sizetype));
  1691. #else
  1692.       emit_library_call (bcopy_libfunc, 0,
  1693.              VOIDmode, 3, XEXP (y, 0), Pmode,
  1694.              XEXP (x, 0), Pmode,
  1695.              convert_to_mode (TYPE_MODE (sizetype), size,
  1696.                       TREE_UNSIGNED (sizetype)),
  1697.              TYPE_MODE (sizetype));
  1698. #endif
  1699.     }
  1700. }
  1701.  
  1702. /* Copy all or part of a value X into registers starting at REGNO.
  1703.    The number of registers to be filled is NREGS.  */
  1704.  
  1705. void
  1706. move_block_to_reg (regno, x, nregs, mode)
  1707.      int regno;
  1708.      rtx x;
  1709.      int nregs;
  1710.      enum machine_mode mode;
  1711. {
  1712.   int i;
  1713.   rtx pat, last;
  1714.  
  1715.   if (nregs == 0)
  1716.     return;
  1717.  
  1718.   if (CONSTANT_P (x) && ! LEGITIMATE_CONSTANT_P (x))
  1719.     x = validize_mem (force_const_mem (mode, x));
  1720.  
  1721.   /* See if the machine can do this with a load multiple insn.  */
  1722. #ifdef HAVE_load_multiple
  1723.   if (HAVE_load_multiple)
  1724.     {
  1725.       last = get_last_insn ();
  1726.       pat = gen_load_multiple (gen_rtx (REG, word_mode, regno), x,
  1727.                    GEN_INT (nregs));
  1728.       if (pat)
  1729.     {
  1730.       emit_insn (pat);
  1731.       return;
  1732.     }
  1733.       else
  1734.     delete_insns_since (last);
  1735.     }
  1736. #endif
  1737.  
  1738.   for (i = 0; i < nregs; i++)
  1739.     emit_move_insn (gen_rtx (REG, word_mode, regno + i),
  1740.             operand_subword_force (x, i, mode));
  1741. }
  1742.  
  1743. /* Copy all or part of a BLKmode value X out of registers starting at REGNO.
  1744.    The number of registers to be filled is NREGS.  SIZE indicates the number
  1745.    of bytes in the object X.  */
  1746.  
  1747.  
  1748. void
  1749. move_block_from_reg (regno, x, nregs, size)
  1750.      int regno;
  1751.      rtx x;
  1752.      int nregs;
  1753.      int size;
  1754. {
  1755.   int i;
  1756.   rtx pat, last;
  1757.  
  1758.   /* Blocks smaller than a word on a BYTES_BIG_ENDIAN machine must be aligned
  1759.      to the left before storing to memory.  */
  1760.   if (size < UNITS_PER_WORD && BYTES_BIG_ENDIAN)
  1761.     {
  1762.       rtx tem = operand_subword (x, 0, 1, BLKmode);
  1763.       rtx shift;
  1764.  
  1765.       if (tem == 0)
  1766.     abort ();
  1767.  
  1768.       shift = expand_shift (LSHIFT_EXPR, word_mode,
  1769.                 gen_rtx (REG, word_mode, regno),
  1770.                 build_int_2 ((UNITS_PER_WORD - size)
  1771.                      * BITS_PER_UNIT, 0), NULL_RTX, 0);
  1772.       emit_move_insn (tem, shift);
  1773.       return;
  1774.     }
  1775.  
  1776.   /* See if the machine can do this with a store multiple insn.  */
  1777. #ifdef HAVE_store_multiple
  1778.   if (HAVE_store_multiple)
  1779.     {
  1780.       last = get_last_insn ();
  1781.       pat = gen_store_multiple (x, gen_rtx (REG, word_mode, regno),
  1782.                 GEN_INT (nregs));
  1783.       if (pat)
  1784.     {
  1785.       emit_insn (pat);
  1786.       return;
  1787.     }
  1788.       else
  1789.     delete_insns_since (last);
  1790.     }
  1791. #endif
  1792.  
  1793.   for (i = 0; i < nregs; i++)
  1794.     {
  1795.       rtx tem = operand_subword (x, i, 1, BLKmode);
  1796.  
  1797.       if (tem == 0)
  1798.     abort ();
  1799.  
  1800.       emit_move_insn (tem, gen_rtx (REG, word_mode, regno + i));
  1801.     }
  1802. }
  1803.  
  1804. /* Add a USE expression for REG to the (possibly empty) list pointed
  1805.    to by CALL_FUSAGE.  REG must denote a hard register.  */
  1806.  
  1807. void
  1808. use_reg (call_fusage, reg)
  1809.      rtx *call_fusage, reg;
  1810. {
  1811.   if (GET_CODE (reg) != REG
  1812.       || REGNO (reg) >= FIRST_PSEUDO_REGISTER)
  1813.     abort();
  1814.  
  1815.   *call_fusage
  1816.     = gen_rtx (EXPR_LIST, VOIDmode,
  1817.            gen_rtx (USE, VOIDmode, reg), *call_fusage);
  1818. }
  1819.  
  1820. /* Add USE expressions to *CALL_FUSAGE for each of NREGS consecutive regs,
  1821.    starting at REGNO.  All of these registers must be hard registers.  */
  1822.  
  1823. void
  1824. use_regs (call_fusage, regno, nregs)
  1825.      rtx *call_fusage;
  1826.      int regno;
  1827.      int nregs;
  1828. {
  1829.   int i;
  1830.  
  1831.   if (regno + nregs > FIRST_PSEUDO_REGISTER)
  1832.     abort ();
  1833.  
  1834.   for (i = 0; i < nregs; i++)
  1835.     use_reg (call_fusage, gen_rtx (REG, reg_raw_mode[regno + i], regno + i));
  1836. }
  1837.  
  1838. /* Write zeros through the storage of OBJECT.
  1839.    If OBJECT has BLKmode, SIZE is its length in bytes.  */
  1840.  
  1841. void
  1842. clear_storage (object, size)
  1843.      rtx object;
  1844.      rtx size;
  1845. {
  1846.   if (GET_MODE (object) == BLKmode)
  1847.     {
  1848. #ifdef TARGET_MEM_FUNCTIONS
  1849.       emit_library_call (memset_libfunc, 0,
  1850.              VOIDmode, 3,
  1851.              XEXP (object, 0), Pmode, const0_rtx, ptr_mode,
  1852.              convert_to_mode (TYPE_MODE (sizetype),
  1853.                       size, TREE_UNSIGNED (sizetype)),
  1854.              TYPE_MODE (sizetype));
  1855. #else
  1856.       emit_library_call (bzero_libfunc, 0,
  1857.              VOIDmode, 2,
  1858.              XEXP (object, 0), Pmode,    
  1859.              convert_to_mode (TYPE_MODE (sizetype),
  1860.                       size, TREE_UNSIGNED (sizetype)),
  1861.              TYPE_MODE (sizetype));
  1862. #endif
  1863.     }
  1864.   else
  1865.     emit_move_insn (object, const0_rtx);
  1866. }
  1867.  
  1868. /* Generate code to copy Y into X.
  1869.    Both Y and X must have the same mode, except that
  1870.    Y can be a constant with VOIDmode.
  1871.    This mode cannot be BLKmode; use emit_block_move for that.
  1872.  
  1873.    Return the last instruction emitted.  */
  1874.  
  1875. rtx
  1876. emit_move_insn (x, y)
  1877.      rtx x, y;
  1878. {
  1879.   enum machine_mode mode = GET_MODE (x);
  1880.  
  1881.   x = protect_from_queue (x, 1);
  1882.   y = protect_from_queue (y, 0);
  1883.  
  1884.   if (mode == BLKmode || (GET_MODE (y) != mode && GET_MODE (y) != VOIDmode))
  1885.     abort ();
  1886.  
  1887.   if (CONSTANT_P (y) && ! LEGITIMATE_CONSTANT_P (y))
  1888.     y = force_const_mem (mode, y);
  1889.  
  1890.   /* If X or Y are memory references, verify that their addresses are valid
  1891.      for the machine.  */
  1892.   if (GET_CODE (x) == MEM
  1893.       && ((! memory_address_p (GET_MODE (x), XEXP (x, 0))
  1894.        && ! push_operand (x, GET_MODE (x)))
  1895.       || (flag_force_addr
  1896.           && CONSTANT_ADDRESS_P (XEXP (x, 0)))))
  1897.     x = change_address (x, VOIDmode, XEXP (x, 0));
  1898.  
  1899.   if (GET_CODE (y) == MEM
  1900.       && (! memory_address_p (GET_MODE (y), XEXP (y, 0))
  1901.       || (flag_force_addr
  1902.           && CONSTANT_ADDRESS_P (XEXP (y, 0)))))
  1903.     y = change_address (y, VOIDmode, XEXP (y, 0));
  1904.  
  1905.   if (mode == BLKmode)
  1906.     abort ();
  1907.  
  1908.   return emit_move_insn_1 (x, y);
  1909. }
  1910.  
  1911. /* Low level part of emit_move_insn.
  1912.    Called just like emit_move_insn, but assumes X and Y
  1913.    are basically valid.  */
  1914.  
  1915. rtx
  1916. emit_move_insn_1 (x, y)
  1917.      rtx x, y;
  1918. {
  1919.   enum machine_mode mode = GET_MODE (x);
  1920.   enum machine_mode submode;
  1921.   enum mode_class class = GET_MODE_CLASS (mode);
  1922.   int i;
  1923.  
  1924.   if (mov_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing)
  1925.     return
  1926.       emit_insn (GEN_FCN (mov_optab->handlers[(int) mode].insn_code) (x, y));
  1927.  
  1928.   /* Expand complex moves by moving real part and imag part, if possible.  */
  1929.   else if ((class == MODE_COMPLEX_FLOAT || class == MODE_COMPLEX_INT)
  1930.        && BLKmode != (submode = mode_for_size ((GET_MODE_UNIT_SIZE (mode)
  1931.                             * BITS_PER_UNIT),
  1932.                            (class == MODE_COMPLEX_INT
  1933.                             ? MODE_INT : MODE_FLOAT),
  1934.                            0))
  1935.        && (mov_optab->handlers[(int) submode].insn_code
  1936.            != CODE_FOR_nothing))
  1937.     {
  1938.       /* Don't split destination if it is a stack push.  */
  1939.       int stack = push_operand (x, GET_MODE (x));
  1940.       rtx insns;
  1941.  
  1942.       /* If this is a stack, push the highpart first, so it
  1943.      will be in the argument order.
  1944.  
  1945.      In that case, change_address is used only to convert
  1946.      the mode, not to change the address.  */
  1947.       if (stack)
  1948.     {
  1949.       /* Note that the real part always precedes the imag part in memory
  1950.          regardless of machine's endianness.  */
  1951. #ifdef STACK_GROWS_DOWNWARD
  1952.       emit_insn (GEN_FCN (mov_optab->handlers[(int) submode].insn_code)
  1953.              (gen_rtx (MEM, submode, (XEXP (x, 0))),
  1954.               gen_imagpart (submode, y)));
  1955.       emit_insn (GEN_FCN (mov_optab->handlers[(int) submode].insn_code)
  1956.              (gen_rtx (MEM, submode, (XEXP (x, 0))),
  1957.               gen_realpart (submode, y)));
  1958. #else
  1959.       emit_insn (GEN_FCN (mov_optab->handlers[(int) submode].insn_code)
  1960.              (gen_rtx (MEM, submode, (XEXP (x, 0))),
  1961.               gen_realpart (submode, y)));
  1962.       emit_insn (GEN_FCN (mov_optab->handlers[(int) submode].insn_code)
  1963.              (gen_rtx (MEM, submode, (XEXP (x, 0))),
  1964.               gen_imagpart (submode, y)));
  1965. #endif
  1966.     }
  1967.       else
  1968.     {
  1969.       emit_insn (GEN_FCN (mov_optab->handlers[(int) submode].insn_code)
  1970.              (gen_realpart (submode, x), gen_realpart (submode, y)));
  1971.       emit_insn (GEN_FCN (mov_optab->handlers[(int) submode].insn_code)
  1972.              (gen_imagpart (submode, x), gen_imagpart (submode, y)));
  1973.     }
  1974.  
  1975.       return get_last_insn ();
  1976.     }
  1977.  
  1978.   /* This will handle any multi-word mode that lacks a move_insn pattern.
  1979.      However, you will get better code if you define such patterns,
  1980.      even if they must turn into multiple assembler instructions.  */
  1981.   else if (GET_MODE_SIZE (mode) > UNITS_PER_WORD)
  1982.     {
  1983.       rtx last_insn = 0;
  1984.       rtx insns;
  1985.       
  1986. #ifdef PUSH_ROUNDING
  1987.  
  1988.       /* If X is a push on the stack, do the push now and replace
  1989.      X with a reference to the stack pointer.  */
  1990.       if (push_operand (x, GET_MODE (x)))
  1991.     {
  1992.       anti_adjust_stack (GEN_INT (GET_MODE_SIZE (GET_MODE (x))));
  1993.       x = change_address (x, VOIDmode, stack_pointer_rtx);
  1994.     }
  1995. #endif
  1996.                  
  1997.       /* Show the output dies here.  */
  1998.       emit_insn (gen_rtx (CLOBBER, VOIDmode, x));
  1999.  
  2000.       for (i = 0;
  2001.        i < (GET_MODE_SIZE (mode)  + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD;
  2002.        i++)
  2003.     {
  2004.       rtx xpart = operand_subword (x, i, 1, mode);
  2005.       rtx ypart = operand_subword (y, i, 1, mode);
  2006.  
  2007.       /* If we can't get a part of Y, put Y into memory if it is a
  2008.          constant.  Otherwise, force it into a register.  If we still
  2009.          can't get a part of Y, abort.  */
  2010.       if (ypart == 0 && CONSTANT_P (y))
  2011.         {
  2012.           y = force_const_mem (mode, y);
  2013.           ypart = operand_subword (y, i, 1, mode);
  2014.         }
  2015.       else if (ypart == 0)
  2016.         ypart = operand_subword_force (y, i, mode);
  2017.  
  2018.       if (xpart == 0 || ypart == 0)
  2019.         abort ();
  2020.  
  2021.       last_insn = emit_move_insn (xpart, ypart);
  2022.     }
  2023.  
  2024.       return last_insn;
  2025.     }
  2026.   else
  2027.     abort ();
  2028. }
  2029.  
  2030. /* Pushing data onto the stack.  */
  2031.  
  2032. /* Push a block of length SIZE (perhaps variable)
  2033.    and return an rtx to address the beginning of the block.
  2034.    Note that it is not possible for the value returned to be a QUEUED.
  2035.    The value may be virtual_outgoing_args_rtx.
  2036.  
  2037.    EXTRA is the number of bytes of padding to push in addition to SIZE.
  2038.    BELOW nonzero means this padding comes at low addresses;
  2039.    otherwise, the padding comes at high addresses.  */
  2040.  
  2041. rtx
  2042. push_block (size, extra, below)
  2043.      rtx size;
  2044.      int extra, below;
  2045. {
  2046.   register rtx temp;
  2047.  
  2048.   size = convert_modes (Pmode, ptr_mode, size, 1);
  2049.   if (CONSTANT_P (size))
  2050.     anti_adjust_stack (plus_constant (size, extra));
  2051.   else if (GET_CODE (size) == REG && extra == 0)
  2052.     anti_adjust_stack (size);
  2053.   else
  2054.     {
  2055.       rtx temp = copy_to_mode_reg (Pmode, size);
  2056.       if (extra != 0)
  2057.     temp = expand_binop (Pmode, add_optab, temp, GEN_INT (extra),
  2058.                  temp, 0, OPTAB_LIB_WIDEN);
  2059.       anti_adjust_stack (temp);
  2060.     }
  2061.  
  2062. #ifdef STACK_GROWS_DOWNWARD
  2063.   temp = virtual_outgoing_args_rtx;
  2064.   if (extra != 0 && below)
  2065.     temp = plus_constant (temp, extra);
  2066. #else
  2067.   if (GET_CODE (size) == CONST_INT)
  2068.     temp = plus_constant (virtual_outgoing_args_rtx,
  2069.               - INTVAL (size) - (below ? 0 : extra));
  2070.   else if (extra != 0 && !below)
  2071.     temp = gen_rtx (PLUS, Pmode, virtual_outgoing_args_rtx,
  2072.             negate_rtx (Pmode, plus_constant (size, extra)));
  2073.   else
  2074.     temp = gen_rtx (PLUS, Pmode, virtual_outgoing_args_rtx,
  2075.             negate_rtx (Pmode, size));
  2076. #endif
  2077.  
  2078.   return memory_address (GET_CLASS_NARROWEST_MODE (MODE_INT), temp);
  2079. }
  2080.  
  2081. rtx
  2082. gen_push_operand ()
  2083. {
  2084.   return gen_rtx (STACK_PUSH_CODE, Pmode, stack_pointer_rtx);
  2085. }
  2086.  
  2087. /* Generate code to push X onto the stack, assuming it has mode MODE and
  2088.    type TYPE.
  2089.    MODE is redundant except when X is a CONST_INT (since they don't
  2090.    carry mode info).
  2091.    SIZE is an rtx for the size of data to be copied (in bytes),
  2092.    needed only if X is BLKmode.
  2093.  
  2094.    ALIGN (in bytes) is maximum alignment we can assume.
  2095.  
  2096.    If PARTIAL and REG are both nonzero, then copy that many of the first
  2097.    words of X into registers starting with REG, and push the rest of X.
  2098.    The amount of space pushed is decreased by PARTIAL words,
  2099.    rounded *down* to a multiple of PARM_BOUNDARY.
  2100.    REG must be a hard register in this case.
  2101.    If REG is zero but PARTIAL is not, take any all others actions for an
  2102.    argument partially in registers, but do not actually load any
  2103.    registers.
  2104.  
  2105.    EXTRA is the amount in bytes of extra space to leave next to this arg.
  2106.    This is ignored if an argument block has already been allocated.
  2107.  
  2108.    On a machine that lacks real push insns, ARGS_ADDR is the address of
  2109.    the bottom of the argument block for this call.  We use indexing off there
  2110.    to store the arg.  On machines with push insns, ARGS_ADDR is 0 when a
  2111.    argument block has not been preallocated.
  2112.  
  2113.    ARGS_SO_FAR is the size of args previously pushed for this call.  */
  2114.  
  2115. void
  2116. emit_push_insn (x, mode, type, size, align, partial, reg, extra,
  2117.         args_addr, args_so_far)
  2118.      register rtx x;
  2119.      enum machine_mode mode;
  2120.      tree type;
  2121.      rtx size;
  2122.      int align;
  2123.      int partial;
  2124.      rtx reg;
  2125.      int extra;
  2126.      rtx args_addr;
  2127.      rtx args_so_far;
  2128. {
  2129.   rtx xinner;
  2130.   enum direction stack_direction
  2131. #ifdef STACK_GROWS_DOWNWARD
  2132.     = downward;
  2133. #else
  2134.     = upward;
  2135. #endif
  2136.  
  2137.   /* Decide where to pad the argument: `downward' for below,
  2138.      `upward' for above, or `none' for don't pad it.
  2139.      Default is below for small data on big-endian machines; else above.  */
  2140.   enum direction where_pad = FUNCTION_ARG_PADDING (mode, type);
  2141.  
  2142.   /* Invert direction if stack is post-update.  */
  2143.   if (STACK_PUSH_CODE == POST_INC || STACK_PUSH_CODE == POST_DEC)
  2144.     if (where_pad != none)
  2145.       where_pad = (where_pad == downward ? upward : downward);
  2146.  
  2147.   xinner = x = protect_from_queue (x, 0);
  2148.  
  2149.   if (mode == BLKmode)
  2150.     {
  2151.       /* Copy a block into the stack, entirely or partially.  */
  2152.  
  2153.       register rtx temp;
  2154.       int used = partial * UNITS_PER_WORD;
  2155.       int offset = used % (PARM_BOUNDARY / BITS_PER_UNIT);
  2156.       int skip;
  2157.       
  2158.       if (size == 0)
  2159.     abort ();
  2160.  
  2161.       used -= offset;
  2162.  
  2163.       /* USED is now the # of bytes we need not copy to the stack
  2164.      because registers will take care of them.  */
  2165.  
  2166.       if (partial != 0)
  2167.     xinner = change_address (xinner, BLKmode,
  2168.                  plus_constant (XEXP (xinner, 0), used));
  2169.  
  2170.       /* If the partial register-part of the arg counts in its stack size,
  2171.      skip the part of stack space corresponding to the registers.
  2172.      Otherwise, start copying to the beginning of the stack space,
  2173.      by setting SKIP to 0.  */
  2174. #ifndef REG_PARM_STACK_SPACE
  2175.       skip = 0;
  2176. #else
  2177.       skip = used;
  2178. #endif
  2179.  
  2180. #ifdef PUSH_ROUNDING
  2181.       /* Do it with several push insns if that doesn't take lots of insns
  2182.      and if there is no difficulty with push insns that skip bytes
  2183.      on the stack for alignment purposes.  */
  2184.       if (args_addr == 0
  2185.       && GET_CODE (size) == CONST_INT
  2186.       && skip == 0
  2187.       && (move_by_pieces_ninsns ((unsigned) INTVAL (size) - used, align)
  2188.           < MOVE_RATIO)
  2189.       /* Here we avoid the case of a structure whose weak alignment
  2190.          forces many pushes of a small amount of data,
  2191.          and such small pushes do rounding that causes trouble.  */
  2192.       && ((! SLOW_UNALIGNED_ACCESS)
  2193.           || align >= BIGGEST_ALIGNMENT / BITS_PER_UNIT
  2194.           || PUSH_ROUNDING (align) == align)
  2195.       && PUSH_ROUNDING (INTVAL (size)) == INTVAL (size))
  2196.     {
  2197.       /* Push padding now if padding above and stack grows down,
  2198.          or if padding below and stack grows up.
  2199.          But if space already allocated, this has already been done.  */
  2200.       if (extra && args_addr == 0
  2201.           && where_pad != none && where_pad != stack_direction)
  2202.         anti_adjust_stack (GEN_INT (extra));
  2203.  
  2204.       move_by_pieces (gen_rtx (MEM, BLKmode, gen_push_operand ()), xinner,
  2205.               INTVAL (size) - used, align);
  2206.     }
  2207.       else
  2208. #endif /* PUSH_ROUNDING */
  2209.     {
  2210.       /* Otherwise make space on the stack and copy the data
  2211.          to the address of that space.  */
  2212.  
  2213.       /* Deduct words put into registers from the size we must copy.  */
  2214.       if (partial != 0)
  2215.         {
  2216.           if (GET_CODE (size) == CONST_INT)
  2217.         size = GEN_INT (INTVAL (size) - used);
  2218.           else
  2219.         size = expand_binop (GET_MODE (size), sub_optab, size,
  2220.                      GEN_INT (used), NULL_RTX, 0,
  2221.                      OPTAB_LIB_WIDEN);
  2222.         }
  2223.  
  2224.       /* Get the address of the stack space.
  2225.          In this case, we do not deal with EXTRA separately.
  2226.          A single stack adjust will do.  */
  2227.       if (! args_addr)
  2228.         {
  2229.           temp = push_block (size, extra, where_pad == downward);
  2230.           extra = 0;
  2231.         }
  2232.       else if (GET_CODE (args_so_far) == CONST_INT)
  2233.         temp = memory_address (BLKmode,
  2234.                    plus_constant (args_addr,
  2235.                           skip + INTVAL (args_so_far)));
  2236.       else
  2237.         temp = memory_address (BLKmode,
  2238.                    plus_constant (gen_rtx (PLUS, Pmode,
  2239.                                args_addr, args_so_far),
  2240.                           skip));
  2241.  
  2242.       /* TEMP is the address of the block.  Copy the data there.  */
  2243.       if (GET_CODE (size) == CONST_INT
  2244.           && (move_by_pieces_ninsns ((unsigned) INTVAL (size), align)
  2245.           < MOVE_RATIO))
  2246.         {
  2247.           move_by_pieces (gen_rtx (MEM, BLKmode, temp), xinner,
  2248.                   INTVAL (size), align);
  2249.           goto ret;
  2250.         }
  2251.       /* Try the most limited insn first, because there's no point
  2252.          including more than one in the machine description unless
  2253.          the more limited one has some advantage.  */
  2254. #ifdef HAVE_movstrqi
  2255.       if (HAVE_movstrqi
  2256.           && GET_CODE (size) == CONST_INT
  2257.           && ((unsigned) INTVAL (size)
  2258.           < (1 << (GET_MODE_BITSIZE (QImode) - 1))))
  2259.         {
  2260.           rtx pat = gen_movstrqi (gen_rtx (MEM, BLKmode, temp),
  2261.                       xinner, size, GEN_INT (align));
  2262.           if (pat != 0)
  2263.         {
  2264.           emit_insn (pat);
  2265.           goto ret;
  2266.         }
  2267.         }
  2268. #endif
  2269. #ifdef HAVE_movstrhi
  2270.       if (HAVE_movstrhi
  2271.           && GET_CODE (size) == CONST_INT
  2272.           && ((unsigned) INTVAL (size)
  2273.           < (1 << (GET_MODE_BITSIZE (HImode) - 1))))
  2274.         {
  2275.           rtx pat = gen_movstrhi (gen_rtx (MEM, BLKmode, temp),
  2276.                       xinner, size, GEN_INT (align));
  2277.           if (pat != 0)
  2278.         {
  2279.           emit_insn (pat);
  2280.           goto ret;
  2281.         }
  2282.         }
  2283. #endif
  2284. #ifdef HAVE_movstrsi
  2285.       if (HAVE_movstrsi)
  2286.         {
  2287.           rtx pat = gen_movstrsi (gen_rtx (MEM, BLKmode, temp),
  2288.                       xinner, size, GEN_INT (align));
  2289.           if (pat != 0)
  2290.         {
  2291.           emit_insn (pat);
  2292.           goto ret;
  2293.         }
  2294.         }
  2295. #endif
  2296. #ifdef HAVE_movstrdi
  2297.       if (HAVE_movstrdi)
  2298.         {
  2299.           rtx pat = gen_movstrdi (gen_rtx (MEM, BLKmode, temp),
  2300.                       xinner, size, GEN_INT (align));
  2301.           if (pat != 0)
  2302.         {
  2303.           emit_insn (pat);
  2304.           goto ret;
  2305.         }
  2306.         }
  2307. #endif
  2308.  
  2309. #ifndef ACCUMULATE_OUTGOING_ARGS
  2310.       /* If the source is referenced relative to the stack pointer,
  2311.          copy it to another register to stabilize it.  We do not need
  2312.          to do this if we know that we won't be changing sp.  */
  2313.  
  2314.       if (reg_mentioned_p (virtual_stack_dynamic_rtx, temp)
  2315.           || reg_mentioned_p (virtual_outgoing_args_rtx, temp))
  2316.         temp = copy_to_reg (temp);
  2317. #endif
  2318.  
  2319.       /* Make inhibit_defer_pop nonzero around the library call
  2320.          to force it to pop the bcopy-arguments right away.  */
  2321.       NO_DEFER_POP;
  2322. #ifdef TARGET_MEM_FUNCTIONS
  2323.       emit_library_call (memcpy_libfunc, 0,
  2324.                  VOIDmode, 3, temp, Pmode, XEXP (xinner, 0), Pmode,
  2325.                  convert_to_mode (TYPE_MODE (sizetype),
  2326.                           size, TREE_UNSIGNED (sizetype)),
  2327.                  TYPE_MODE (sizetype));
  2328. #else
  2329.       emit_library_call (bcopy_libfunc, 0,
  2330.                  VOIDmode, 3, XEXP (xinner, 0), Pmode, temp, Pmode,
  2331.                  convert_to_mode (TYPE_MODE (sizetype),
  2332.                           size, TREE_UNSIGNED (sizetype)),
  2333.                  TYPE_MODE (sizetype));
  2334. #endif
  2335.       OK_DEFER_POP;
  2336.     }
  2337.     }
  2338.   else if (partial > 0)
  2339.     {
  2340.       /* Scalar partly in registers.  */
  2341.  
  2342.       int size = GET_MODE_SIZE (mode) / UNITS_PER_WORD;
  2343.       int i;
  2344.       int not_stack;
  2345.       /* # words of start of argument
  2346.      that we must make space for but need not store.  */
  2347.       int offset = partial % (PARM_BOUNDARY / BITS_PER_WORD);
  2348.       int args_offset = INTVAL (args_so_far);
  2349.       int skip;
  2350.  
  2351.       /* Push padding now if padding above and stack grows down,
  2352.      or if padding below and stack grows up.
  2353.      But if space already allocated, this has already been done.  */
  2354.       if (extra && args_addr == 0
  2355.       && where_pad != none && where_pad != stack_direction)
  2356.     anti_adjust_stack (GEN_INT (extra));
  2357.  
  2358.       /* If we make space by pushing it, we might as well push
  2359.      the real data.  Otherwise, we can leave OFFSET nonzero
  2360.      and leave the space uninitialized.  */
  2361.       if (args_addr == 0)
  2362.     offset = 0;
  2363.  
  2364.       /* Now NOT_STACK gets the number of words that we don't need to
  2365.      allocate on the stack.  */
  2366.       not_stack = partial - offset;
  2367.  
  2368.       /* If the partial register-part of the arg counts in its stack size,
  2369.      skip the part of stack space corresponding to the registers.
  2370.      Otherwise, start copying to the beginning of the stack space,
  2371.      by setting SKIP to 0.  */
  2372. #ifndef REG_PARM_STACK_SPACE
  2373.       skip = 0;
  2374. #else
  2375.       skip = not_stack;
  2376. #endif
  2377.  
  2378.       if (CONSTANT_P (x) && ! LEGITIMATE_CONSTANT_P (x))
  2379.     x = validize_mem (force_const_mem (mode, x));
  2380.  
  2381.       /* If X is a hard register in a non-integer mode, copy it into a pseudo;
  2382.      SUBREGs of such registers are not allowed.  */
  2383.       if ((GET_CODE (x) == REG && REGNO (x) < FIRST_PSEUDO_REGISTER
  2384.        && GET_MODE_CLASS (GET_MODE (x)) != MODE_INT))
  2385.     x = copy_to_reg (x);
  2386.  
  2387.       /* Loop over all the words allocated on the stack for this arg.  */
  2388.       /* We can do it by words, because any scalar bigger than a word
  2389.      has a size a multiple of a word.  */
  2390. #ifndef PUSH_ARGS_REVERSED
  2391.       for (i = not_stack; i < size; i++)
  2392. #else
  2393.       for (i = size - 1; i >= not_stack; i--)
  2394. #endif
  2395.     if (i >= not_stack + offset)
  2396.       emit_push_insn (operand_subword_force (x, i, mode),
  2397.               word_mode, NULL_TREE, NULL_RTX, align, 0, NULL_RTX,
  2398.               0, args_addr,
  2399.               GEN_INT (args_offset + ((i - not_stack + skip)
  2400.                           * UNITS_PER_WORD)));
  2401.     }
  2402.   else
  2403.     {
  2404.       rtx addr;
  2405.  
  2406.       /* Push padding now if padding above and stack grows down,
  2407.      or if padding below and stack grows up.
  2408.      But if space already allocated, this has already been done.  */
  2409.       if (extra && args_addr == 0
  2410.       && where_pad != none && where_pad != stack_direction)
  2411.     anti_adjust_stack (GEN_INT (extra));
  2412.  
  2413. #ifdef PUSH_ROUNDING
  2414.       if (args_addr == 0)
  2415.     addr = gen_push_operand ();
  2416.       else
  2417. #endif
  2418.     if (GET_CODE (args_so_far) == CONST_INT)
  2419.       addr
  2420.         = memory_address (mode,
  2421.                   plus_constant (args_addr, INTVAL (args_so_far)));
  2422.       else
  2423.     addr = memory_address (mode, gen_rtx (PLUS, Pmode, args_addr,
  2424.                           args_so_far));
  2425.  
  2426.       emit_move_insn (gen_rtx (MEM, mode, addr), x);
  2427.     }
  2428.  
  2429.  ret:
  2430.   /* If part should go in registers, copy that part
  2431.      into the appropriate registers.  Do this now, at the end,
  2432.      since mem-to-mem copies above may do function calls.  */
  2433.   if (partial > 0 && reg != 0)
  2434.     move_block_to_reg (REGNO (reg), x, partial, mode);
  2435.  
  2436.   if (extra && args_addr == 0 && where_pad == stack_direction)
  2437.     anti_adjust_stack (GEN_INT (extra));
  2438. }
  2439.  
  2440. /* Expand an assignment that stores the value of FROM into TO.
  2441.    If WANT_VALUE is nonzero, return an rtx for the value of TO.
  2442.    (This may contain a QUEUED rtx;
  2443.    if the value is constant, this rtx is a constant.)
  2444.    Otherwise, the returned value is NULL_RTX.
  2445.  
  2446.    SUGGEST_REG is no longer actually used.
  2447.    It used to mean, copy the value through a register
  2448.    and return that register, if that is possible.
  2449.    We now use WANT_VALUE to decide whether to do this.  */
  2450.  
  2451. rtx
  2452. expand_assignment (to, from, want_value, suggest_reg)
  2453.      tree to, from;
  2454.      int want_value;
  2455.      int suggest_reg;
  2456. {
  2457.   register rtx to_rtx = 0;
  2458.   rtx result;
  2459.  
  2460.   /* Don't crash if the lhs of the assignment was erroneous.  */
  2461.  
  2462.   if (TREE_CODE (to) == ERROR_MARK)
  2463.     {
  2464.       result = expand_expr (from, NULL_RTX, VOIDmode, 0);
  2465.       return want_value ? result : NULL_RTX;
  2466.     }
  2467.  
  2468.   if (output_bytecode)
  2469.     {
  2470.       tree dest_innermost;
  2471.  
  2472.       bc_expand_expr (from);
  2473.       bc_emit_instruction (duplicate);
  2474.  
  2475.       dest_innermost = bc_expand_address (to);
  2476.  
  2477.       /* Can't deduce from TYPE that we're dealing with a bitfield, so
  2478.      take care of it here. */
  2479.  
  2480.       bc_store_memory (TREE_TYPE (to), dest_innermost);
  2481.       return NULL;
  2482.     }
  2483.  
  2484.   /* Assignment of a structure component needs special treatment
  2485.      if the structure component's rtx is not simply a MEM.
  2486.      Assignment of an array element at a constant index, and assignment of
  2487.      an array element in an unaligned packed structure field, has the same
  2488.      problem.  */
  2489.  
  2490.   if (TREE_CODE (to) == COMPONENT_REF
  2491.       || TREE_CODE (to) == BIT_FIELD_REF
  2492.       || (TREE_CODE (to) == ARRAY_REF
  2493.       && ((TREE_CODE (TREE_OPERAND (to, 1)) == INTEGER_CST
  2494.            && TREE_CODE (TYPE_SIZE (TREE_TYPE (to))) == INTEGER_CST)
  2495.           || (SLOW_UNALIGNED_ACCESS && get_inner_unaligned_p (to)))))
  2496.     {
  2497.       enum machine_mode mode1;
  2498.       int bitsize;
  2499.       int bitpos;
  2500.       tree offset;
  2501.       int unsignedp;
  2502.       int volatilep = 0;
  2503.       tree tem;
  2504.       int alignment;
  2505.  
  2506.       push_temp_slots ();
  2507.       tem = get_inner_reference (to, &bitsize, &bitpos, &offset,
  2508.                       &mode1, &unsignedp, &volatilep);
  2509.  
  2510.       /* If we are going to use store_bit_field and extract_bit_field,
  2511.      make sure to_rtx will be safe for multiple use.  */
  2512.  
  2513.       if (mode1 == VOIDmode && want_value)
  2514.     tem = stabilize_reference (tem);
  2515.  
  2516.       alignment = TYPE_ALIGN (TREE_TYPE (tem)) / BITS_PER_UNIT;
  2517.       to_rtx = expand_expr (tem, NULL_RTX, VOIDmode, 0);
  2518.       if (offset != 0)
  2519.     {
  2520.       rtx offset_rtx = expand_expr (offset, NULL_RTX, VOIDmode, 0);
  2521.  
  2522.       if (GET_CODE (to_rtx) != MEM)
  2523.         abort ();
  2524.       to_rtx = change_address (to_rtx, VOIDmode,
  2525.                    gen_rtx (PLUS, ptr_mode, XEXP (to_rtx, 0),
  2526.                         force_reg (ptr_mode, offset_rtx)));
  2527.       /* If we have a variable offset, the known alignment
  2528.          is only that of the innermost structure containing the field.
  2529.          (Actually, we could sometimes do better by using the
  2530.          align of an element of the innermost array, but no need.)  */
  2531.       if (TREE_CODE (to) == COMPONENT_REF
  2532.           || TREE_CODE (to) == BIT_FIELD_REF)
  2533.         alignment
  2534.           = TYPE_ALIGN (TREE_TYPE (TREE_OPERAND (to, 0))) / BITS_PER_UNIT;
  2535.     }
  2536.       if (volatilep)
  2537.     {
  2538.       if (GET_CODE (to_rtx) == MEM)
  2539.         {
  2540.           /* When the offset is zero, to_rtx is the address of the
  2541.          structure we are storing into, and hence may be shared.
  2542.          We must make a new MEM before setting the volatile bit.  */
  2543.           if (offset == 0)
  2544.         to_rtx = change_address (to_rtx, VOIDmode, XEXP (to_rtx, 0));
  2545.           MEM_VOLATILE_P (to_rtx) = 1;
  2546.         }
  2547. #if 0  /* This was turned off because, when a field is volatile
  2548.       in an object which is not volatile, the object may be in a register,
  2549.       and then we would abort over here.  */
  2550.       else
  2551.         abort ();
  2552. #endif
  2553.     }
  2554.  
  2555. #ifdef NEXT_SEMANTICS
  2556.       if ((TREE_CODE (TREE_OPERAND (to, 1)) == VAR_DECL
  2557.        || TREE_CODE (TREE_OPERAND (to, 1)) == FIELD_DECL)
  2558.       &&  DECL_RELATIVE (TREE_OPERAND (to, 1)))
  2559.     {
  2560.       from = (tree) build_binary_op (MINUS_EXPR, from,
  2561.                   build1 (ADDR_EXPR, TREE_TYPE (to), to));
  2562.     }
  2563. #endif
  2564.  
  2565.       result = store_field (to_rtx, bitsize, bitpos, mode1, from,
  2566.                 (want_value
  2567.                  /* Spurious cast makes HPUX compiler happy.  */
  2568.                  ? (enum machine_mode) TYPE_MODE (TREE_TYPE (to))
  2569.                  : VOIDmode),
  2570.                 unsignedp,
  2571.                 /* Required alignment of containing datum.  */
  2572.                 alignment,
  2573.                 int_size_in_bytes (TREE_TYPE (tem)));
  2574.       preserve_temp_slots (result);
  2575.       free_temp_slots ();
  2576.       pop_temp_slots ();
  2577.  
  2578.       /* If the value is meaningful, convert RESULT to the proper mode.
  2579.      Otherwise, return nothing.  */
  2580.       return (want_value ? convert_modes (TYPE_MODE (TREE_TYPE (to)),
  2581.                       TYPE_MODE (TREE_TYPE (from)),
  2582.                       result,
  2583.                       TREE_UNSIGNED (TREE_TYPE (to)))
  2584.           : NULL_RTX);
  2585.     }
  2586.  
  2587.   /* If the rhs is a function call and its value is not an aggregate,
  2588.      call the function before we start to compute the lhs.
  2589.      This is needed for correct code for cases such as
  2590.      val = setjmp (buf) on machines where reference to val
  2591.      requires loading up part of an address in a separate insn.
  2592.  
  2593.      Don't do this if TO is a VAR_DECL whose DECL_RTL is REG since it might be
  2594.      a promoted variable where the zero- or sign- extension needs to be done.
  2595.      Handling this in the normal way is safe because no computation is done
  2596.      before the call.  */
  2597.   if (TREE_CODE (from) == CALL_EXPR && ! aggregate_value_p (from)
  2598.       && ! (TREE_CODE (to) == VAR_DECL && GET_CODE (DECL_RTL (to)) == REG))
  2599.     {
  2600.       rtx value;
  2601.  
  2602.       push_temp_slots ();
  2603.       value = expand_expr (from, NULL_RTX, VOIDmode, 0);
  2604.       if (to_rtx == 0)
  2605. #ifdef NEXT_SEMANTICS
  2606.     to_rtx = expand_expr (to, NULL_RTX, VOIDmode, EXPAND_CONST_ADDRESS);
  2607. #else
  2608.     to_rtx = expand_expr (to, NULL_RTX, VOIDmode, 0);
  2609. #endif
  2610.  
  2611.       if (GET_MODE (to_rtx) == BLKmode)
  2612.     {
  2613.       int align = MIN (TYPE_ALIGN (TREE_TYPE (from)), BITS_PER_WORD);
  2614.       emit_block_move (to_rtx, value, expr_size (from), align);
  2615.     }
  2616.       else
  2617.     emit_move_insn (to_rtx, value);
  2618.       preserve_temp_slots (to_rtx);
  2619.       free_temp_slots ();
  2620.       pop_temp_slots ();
  2621.       return want_value ? to_rtx : NULL_RTX;
  2622.     }
  2623.  
  2624.   /* Ordinary treatment.  Expand TO to get a REG or MEM rtx.
  2625.      Don't re-expand if it was expanded already (in COMPONENT_REF case).  */
  2626.  
  2627.   if (to_rtx == 0)
  2628. #ifdef NEXT_SEMANTICS
  2629.     to_rtx = expand_expr (to, NULL_RTX, VOIDmode, EXPAND_CONST_ADDRESS);
  2630.  
  2631.   if ((TREE_CODE (to) == VAR_DECL
  2632.        || TREE_CODE (to) == FIELD_DECL)
  2633.       && DECL_RELATIVE (to))
  2634.     {
  2635.       from = (tree) build_binary_op (MINUS_EXPR, from,
  2636.                   build1 (ADDR_EXPR, TREE_TYPE (to), to));
  2637.     }
  2638. #else
  2639.     to_rtx = expand_expr (to, NULL_RTX, VOIDmode, 0);
  2640. #endif
  2641.  
  2642.   /* Don't move directly into a return register.  */
  2643.   if (TREE_CODE (to) == RESULT_DECL && GET_CODE (to_rtx) == REG)
  2644.     {
  2645.       rtx temp;
  2646.  
  2647.       push_temp_slots ();
  2648.       temp = expand_expr (from, 0, GET_MODE (to_rtx), 0);
  2649.       emit_move_insn (to_rtx, temp);
  2650.       preserve_temp_slots (to_rtx);
  2651.       free_temp_slots ();
  2652.       pop_temp_slots ();
  2653.       return want_value ? to_rtx : NULL_RTX;
  2654.     }
  2655.  
  2656.   /* In case we are returning the contents of an object which overlaps
  2657.      the place the value is being stored, use a safe function when copying
  2658.      a value through a pointer into a structure value return block.  */
  2659.   if (TREE_CODE (to) == RESULT_DECL && TREE_CODE (from) == INDIRECT_REF
  2660.       && current_function_returns_struct
  2661.       && !current_function_returns_pcc_struct)
  2662.     {
  2663.       rtx from_rtx, size;
  2664.  
  2665.       push_temp_slots ();
  2666.       size = expr_size (from);
  2667.       from_rtx = expand_expr (from, NULL_RTX, VOIDmode, 0);
  2668.  
  2669. #ifdef TARGET_MEM_FUNCTIONS
  2670.       emit_library_call (memcpy_libfunc, 0,
  2671.              VOIDmode, 3, XEXP (to_rtx, 0), Pmode,
  2672.              XEXP (from_rtx, 0), Pmode,
  2673.              convert_to_mode (TYPE_MODE (sizetype),
  2674.                       size, TREE_UNSIGNED (sizetype)),
  2675.              TYPE_MODE (sizetype));
  2676. #else
  2677.       emit_library_call (bcopy_libfunc, 0,
  2678.              VOIDmode, 3, XEXP (from_rtx, 0), Pmode,
  2679.              XEXP (to_rtx, 0), Pmode,
  2680.              convert_to_mode (TYPE_MODE (sizetype),
  2681.                       size, TREE_UNSIGNED (sizetype)),
  2682.              TYPE_MODE (sizetype));
  2683. #endif
  2684.  
  2685.       preserve_temp_slots (to_rtx);
  2686.       free_temp_slots ();
  2687.       pop_temp_slots ();
  2688.       return want_value ? to_rtx : NULL_RTX;
  2689.     }
  2690.  
  2691.   /* Compute FROM and store the value in the rtx we got.  */
  2692.  
  2693.   push_temp_slots ();
  2694.   result = store_expr (from, to_rtx, want_value);
  2695.   preserve_temp_slots (result);
  2696.   free_temp_slots ();
  2697.   pop_temp_slots ();
  2698.   return want_value ? result : NULL_RTX;
  2699. }
  2700.  
  2701. /* Generate code for computing expression EXP,
  2702.    and storing the value into TARGET.
  2703.    TARGET may contain a QUEUED rtx.
  2704.  
  2705.    If WANT_VALUE is nonzero, return a copy of the value
  2706.    not in TARGET, so that we can be sure to use the proper
  2707.    value in a containing expression even if TARGET has something
  2708.    else stored in it.  If possible, we copy the value through a pseudo
  2709.    and return that pseudo.  Or, if the value is constant, we try to
  2710.    return the constant.  In some cases, we return a pseudo
  2711.    copied *from* TARGET.
  2712.  
  2713.    If the mode is BLKmode then we may return TARGET itself.
  2714.    It turns out that in BLKmode it doesn't cause a problem.
  2715.    because C has no operators that could combine two different
  2716.    assignments into the same BLKmode object with different values
  2717.    with no sequence point.  Will other languages need this to
  2718.    be more thorough?
  2719.  
  2720.    If WANT_VALUE is 0, we return NULL, to make sure
  2721.    to catch quickly any cases where the caller uses the value
  2722.    and fails to set WANT_VALUE.  */
  2723.  
  2724. rtx
  2725. store_expr (exp, target, want_value)
  2726.      register tree exp;
  2727.      register rtx target;
  2728.      int want_value;
  2729. {
  2730.   register rtx temp;
  2731.   int dont_return_target = 0;
  2732.  
  2733.   if (TREE_CODE (exp) == COMPOUND_EXPR)
  2734.     {
  2735.       /* Perform first part of compound expression, then assign from second
  2736.      part.  */
  2737.       expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0);
  2738.       emit_queue ();
  2739.       return store_expr (TREE_OPERAND (exp, 1), target, want_value);
  2740.     }
  2741.   else if (TREE_CODE (exp) == COND_EXPR && GET_MODE (target) == BLKmode)
  2742.     {
  2743.       /* For conditional expression, get safe form of the target.  Then
  2744.      test the condition, doing the appropriate assignment on either
  2745.      side.  This avoids the creation of unnecessary temporaries.
  2746.      For non-BLKmode, it is more efficient not to do this.  */
  2747.  
  2748.       rtx lab1 = gen_label_rtx (), lab2 = gen_label_rtx ();
  2749.  
  2750.       emit_queue ();
  2751.       target = protect_from_queue (target, 1);
  2752.  
  2753.       do_pending_stack_adjust ();
  2754.       NO_DEFER_POP;
  2755.       jumpifnot (TREE_OPERAND (exp, 0), lab1);
  2756.       store_expr (TREE_OPERAND (exp, 1), target, 0);
  2757.       emit_queue ();
  2758.       emit_jump_insn (gen_jump (lab2));
  2759.       emit_barrier ();
  2760.       emit_label (lab1);
  2761.       store_expr (TREE_OPERAND (exp, 2), target, 0);
  2762.       emit_queue ();
  2763.       emit_label (lab2);
  2764.       OK_DEFER_POP;
  2765.       return want_value ? target : NULL_RTX;
  2766.     }
  2767.   else if (want_value && GET_CODE (target) == MEM && ! MEM_VOLATILE_P (target)
  2768.        && GET_MODE (target) != BLKmode)
  2769.     /* If target is in memory and caller wants value in a register instead,
  2770.        arrange that.  Pass TARGET as target for expand_expr so that,
  2771.        if EXP is another assignment, WANT_VALUE will be nonzero for it.
  2772.        We know expand_expr will not use the target in that case.
  2773.        Don't do this if TARGET is volatile because we are supposed
  2774.        to write it and then read it.  */
  2775.     {
  2776.       temp = expand_expr (exp, cse_not_expected ? NULL_RTX : target,
  2777.               GET_MODE (target), 0);
  2778.       if (GET_MODE (temp) != BLKmode && GET_MODE (temp) != VOIDmode)
  2779.     temp = copy_to_reg (temp);
  2780.       dont_return_target = 1;
  2781.     }
  2782.   else if (queued_subexp_p (target))
  2783.     /* If target contains a postincrement, let's not risk
  2784.        using it as the place to generate the rhs.  */
  2785.     {
  2786.       if (GET_MODE (target) != BLKmode && GET_MODE (target) != VOIDmode)
  2787.     {
  2788.       /* Expand EXP into a new pseudo.  */
  2789.       temp = gen_reg_rtx (GET_MODE (target));
  2790.       temp = expand_expr (exp, temp, GET_MODE (target), 0);
  2791.     }
  2792.       else
  2793.     temp = expand_expr (exp, NULL_RTX, GET_MODE (target), 0);
  2794.  
  2795.       /* If target is volatile, ANSI requires accessing the value
  2796.      *from* the target, if it is accessed.  So make that happen.
  2797.      In no case return the target itself.  */
  2798.       if (! MEM_VOLATILE_P (target) && want_value)
  2799.     dont_return_target = 1;
  2800.     }
  2801.   else if (GET_CODE (target) == SUBREG && SUBREG_PROMOTED_VAR_P (target))
  2802.     /* If this is an scalar in a register that is stored in a wider mode
  2803.        than the declared mode, compute the result into its declared mode
  2804.        and then convert to the wider mode.  Our value is the computed
  2805.        expression.  */
  2806.     {
  2807.       /* If we don't want a value, we can do the conversion inside EXP,
  2808.      which will often result in some optimizations.  Do the conversion
  2809.      in two steps: first change the signedness, if needed, then
  2810.      the extend.  */
  2811.       if (! want_value)
  2812.     {
  2813.       if (TREE_UNSIGNED (TREE_TYPE (exp))
  2814.           != SUBREG_PROMOTED_UNSIGNED_P (target))
  2815.         exp
  2816.           = convert
  2817.         (signed_or_unsigned_type (SUBREG_PROMOTED_UNSIGNED_P (target),
  2818.                       TREE_TYPE (exp)),
  2819.          exp);
  2820.  
  2821.       exp = convert (type_for_mode (GET_MODE (SUBREG_REG (target)),
  2822.                     SUBREG_PROMOTED_UNSIGNED_P (target)),
  2823.              exp);
  2824.     }
  2825.      
  2826.       temp = expand_expr (exp, NULL_RTX, VOIDmode, 0);
  2827.  
  2828.       /* If TEMP is a volatile MEM and we want a result value, make
  2829.      the access now so it gets done only once.  Likewise if
  2830.      it contains TARGET.  */
  2831.       if (GET_CODE (temp) == MEM && want_value
  2832.       && (MEM_VOLATILE_P (temp)
  2833.           || reg_mentioned_p (SUBREG_REG (target), XEXP (temp, 0))))
  2834.     temp = copy_to_reg (temp);
  2835.  
  2836.       /* If TEMP is a VOIDmode constant, use convert_modes to make
  2837.      sure that we properly convert it.  */
  2838.       if (CONSTANT_P (temp) && GET_MODE (temp) == VOIDmode)
  2839.     temp = convert_modes (GET_MODE (SUBREG_REG (target)),
  2840.                   TYPE_MODE (TREE_TYPE (exp)), temp,
  2841.                   SUBREG_PROMOTED_UNSIGNED_P (target));
  2842.  
  2843.       convert_move (SUBREG_REG (target), temp,
  2844.             SUBREG_PROMOTED_UNSIGNED_P (target));
  2845.       return want_value ? temp : NULL_RTX;
  2846.     }
  2847.   else
  2848.     {
  2849.       temp = expand_expr (exp, target, GET_MODE (target), 0);
  2850.       /* Return TARGET if it's a specified hardware register.
  2851.      If TARGET is a volatile mem ref, either return TARGET
  2852.      or return a reg copied *from* TARGET; ANSI requires this.
  2853.  
  2854.      Otherwise, if TEMP is not TARGET, return TEMP
  2855.      if it is constant (for efficiency),
  2856.      or if we really want the correct value.  */
  2857.       if (!(target && GET_CODE (target) == REG
  2858.         && REGNO (target) < FIRST_PSEUDO_REGISTER)
  2859.       && !(GET_CODE (target) == MEM && MEM_VOLATILE_P (target))
  2860.       && temp != target
  2861.       && (CONSTANT_P (temp) || want_value))
  2862.     dont_return_target = 1;
  2863.     }
  2864.  
  2865.   /* If TEMP is a VOIDmode constant and the mode of the type of EXP is not
  2866.      the same as that of TARGET, adjust the constant.  This is needed, for
  2867.      example, in case it is a CONST_DOUBLE and we want only a word-sized
  2868.      value.  */
  2869.   if (CONSTANT_P (temp) && GET_MODE (temp) == VOIDmode
  2870.       && TREE_CODE (exp) != ERROR_MARK
  2871.       && GET_MODE (target) != TYPE_MODE (TREE_TYPE (exp)))
  2872.     temp = convert_modes (GET_MODE (target), TYPE_MODE (TREE_TYPE (exp)),
  2873.               temp, TREE_UNSIGNED (TREE_TYPE (exp)));
  2874.  
  2875.   /* If value was not generated in the target, store it there.
  2876.      Convert the value to TARGET's type first if nec.  */
  2877.  
  2878.   if (temp != target && TREE_CODE (exp) != ERROR_MARK)
  2879.     {
  2880.       target = protect_from_queue (target, 1);
  2881.       if (GET_MODE (temp) != GET_MODE (target)
  2882.       && GET_MODE (temp) != VOIDmode)
  2883.     {
  2884.       int unsignedp = TREE_UNSIGNED (TREE_TYPE (exp));
  2885.       if (dont_return_target)
  2886.         {
  2887.           /* In this case, we will return TEMP,
  2888.          so make sure it has the proper mode.
  2889.          But don't forget to store the value into TARGET.  */
  2890.           temp = convert_to_mode (GET_MODE (target), temp, unsignedp);
  2891.           emit_move_insn (target, temp);
  2892.         }
  2893.       else
  2894.         convert_move (target, temp, unsignedp);
  2895.     }
  2896.  
  2897.       else if (GET_MODE (temp) == BLKmode && TREE_CODE (exp) == STRING_CST)
  2898.     {
  2899.       /* Handle copying a string constant into an array.
  2900.          The string constant may be shorter than the array.
  2901.          So copy just the string's actual length, and clear the rest.  */
  2902.       rtx size;
  2903.       rtx addr;
  2904.  
  2905.       /* Get the size of the data type of the string,
  2906.          which is actually the size of the target.  */
  2907.       size = expr_size (exp);
  2908.       if (GET_CODE (size) == CONST_INT
  2909.           && INTVAL (size) < TREE_STRING_LENGTH (exp))
  2910.         emit_block_move (target, temp, size,
  2911.                  TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
  2912.       else
  2913.         {
  2914.           /* Compute the size of the data to copy from the string.  */
  2915.           tree copy_size
  2916.         = size_binop (MIN_EXPR,
  2917.                   make_tree (sizetype, size),
  2918.                   convert (sizetype,
  2919.                        build_int_2 (TREE_STRING_LENGTH (exp), 0)));
  2920.           rtx copy_size_rtx = expand_expr (copy_size, NULL_RTX,
  2921.                            VOIDmode, 0);
  2922.           rtx label = 0;
  2923.  
  2924.           /* Copy that much.  */
  2925.           emit_block_move (target, temp, copy_size_rtx,
  2926.                    TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
  2927.  
  2928.           /* Figure out how much is left in TARGET that we have to clear.
  2929.          Do all calculations in ptr_mode.  */
  2930.  
  2931.           addr = XEXP (target, 0);
  2932.           addr = convert_modes (ptr_mode, Pmode, addr, 1);
  2933.  
  2934.           if (GET_CODE (copy_size_rtx) == CONST_INT)
  2935.         {
  2936.           addr = plus_constant (addr, TREE_STRING_LENGTH (exp));
  2937.           size = plus_constant (size, - TREE_STRING_LENGTH (exp));
  2938.         }
  2939.           else
  2940.         {
  2941.           addr = force_reg (ptr_mode, addr);
  2942.           addr = expand_binop (ptr_mode, add_optab, addr,
  2943.                        copy_size_rtx, NULL_RTX, 0,
  2944.                        OPTAB_LIB_WIDEN);
  2945.  
  2946.           size = expand_binop (ptr_mode, sub_optab, size,
  2947.                        copy_size_rtx, NULL_RTX, 0,
  2948.                        OPTAB_LIB_WIDEN);
  2949.  
  2950.           emit_cmp_insn (size, const0_rtx, LT, NULL_RTX,
  2951.                  GET_MODE (size), 0, 0);
  2952.           label = gen_label_rtx ();
  2953.           emit_jump_insn (gen_blt (label));
  2954.         }
  2955.  
  2956.           if (size != const0_rtx)
  2957.         {
  2958. #ifdef TARGET_MEM_FUNCTIONS
  2959.           emit_library_call (memset_libfunc, 0, VOIDmode, 3, addr,
  2960.                      Pmode, const0_rtx, Pmode, size, ptr_mode);
  2961. #else
  2962.           emit_library_call (bzero_libfunc, 0, VOIDmode, 2,
  2963.                      addr, Pmode, size, ptr_mode);
  2964. #endif
  2965.         }
  2966.  
  2967.           if (label)
  2968.         emit_label (label);
  2969.         }
  2970.     }
  2971.       else if (GET_MODE (temp) == BLKmode)
  2972.     emit_block_move (target, temp, expr_size (exp),
  2973.              TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
  2974.       else
  2975.     emit_move_insn (target, temp);
  2976.     }
  2977.  
  2978.   /* If we don't want a value, return NULL_RTX.  */
  2979.   if (! want_value)
  2980.     return NULL_RTX;
  2981.  
  2982.   /* If we are supposed to return TEMP, do so as long as it isn't a MEM.
  2983.      ??? The latter test doesn't seem to make sense.  */
  2984.   else if (dont_return_target && GET_CODE (temp) != MEM)
  2985.     return temp;
  2986.  
  2987.   /* Return TARGET itself if it is a hard register.  */
  2988.   else if (want_value && GET_MODE (target) != BLKmode
  2989.        && ! (GET_CODE (target) == REG
  2990.          && REGNO (target) < FIRST_PSEUDO_REGISTER))
  2991.     return copy_to_reg (target);
  2992.   
  2993.   else
  2994.     return target;
  2995. }
  2996.  
  2997. /* Store the value of constructor EXP into the rtx TARGET.
  2998.    TARGET is either a REG or a MEM.  */
  2999.  
  3000. static void
  3001. store_constructor (exp, target)
  3002.      tree exp;
  3003.      rtx target;
  3004. {
  3005.   tree type = TREE_TYPE (exp);
  3006.  
  3007.   /* We know our target cannot conflict, since safe_from_p has been called.  */
  3008. #if 0
  3009.   /* Don't try copying piece by piece into a hard register
  3010.      since that is vulnerable to being clobbered by EXP.
  3011.      Instead, construct in a pseudo register and then copy it all.  */
  3012.   if (GET_CODE (target) == REG && REGNO (target) < FIRST_PSEUDO_REGISTER)
  3013.     {
  3014.       rtx temp = gen_reg_rtx (GET_MODE (target));
  3015.       store_constructor (exp, temp);
  3016.       emit_move_insn (target, temp);
  3017.       return;
  3018.     }
  3019. #endif
  3020.  
  3021.   if (TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
  3022.       || TREE_CODE (type) == QUAL_UNION_TYPE)
  3023.     {
  3024.       register tree elt;
  3025.  
  3026.       /* Inform later passes that the whole union value is dead.  */
  3027.       if (TREE_CODE (type) == UNION_TYPE
  3028.       || TREE_CODE (type) == QUAL_UNION_TYPE)
  3029.     emit_insn (gen_rtx (CLOBBER, VOIDmode, target));
  3030.  
  3031.       /* If we are building a static constructor into a register,
  3032.      set the initial value as zero so we can fold the value into
  3033.      a constant.  But if more than one register is involved,
  3034.      this probably loses.  */
  3035.       else if (GET_CODE (target) == REG && TREE_STATIC (exp)
  3036.            && GET_MODE_SIZE (GET_MODE (target)) <= UNITS_PER_WORD)
  3037.     emit_move_insn (target, const0_rtx);
  3038.  
  3039.       /* If the constructor has fewer fields than the structure,
  3040.      clear the whole structure first.  */
  3041.       else if (list_length (CONSTRUCTOR_ELTS (exp))
  3042.            != list_length (TYPE_FIELDS (type)))
  3043.     clear_storage (target, expr_size (exp));
  3044.       else
  3045.     /* Inform later passes that the old value is dead.  */
  3046.     emit_insn (gen_rtx (CLOBBER, VOIDmode, target));
  3047.  
  3048.       /* Store each element of the constructor into
  3049.      the corresponding field of TARGET.  */
  3050.  
  3051.       for (elt = CONSTRUCTOR_ELTS (exp); elt; elt = TREE_CHAIN (elt))
  3052.     {
  3053.       register tree field = TREE_PURPOSE (elt);
  3054.       register enum machine_mode mode;
  3055.       int bitsize;
  3056.       int bitpos = 0;
  3057.       int unsignedp;
  3058.       tree pos, constant = 0, offset = 0;
  3059.       rtx to_rtx = target;
  3060.  
  3061.       /* Just ignore missing fields.
  3062.          We cleared the whole structure, above,
  3063.          if any fields are missing.  */
  3064.       if (field == 0)
  3065.         continue;
  3066.  
  3067.       bitsize = TREE_INT_CST_LOW (DECL_SIZE (field));
  3068.       unsignedp = TREE_UNSIGNED (field);
  3069.       mode = DECL_MODE (field);
  3070.       if (DECL_BIT_FIELD (field))
  3071.         mode = VOIDmode;
  3072.  
  3073.       pos = DECL_FIELD_BITPOS (field);
  3074.       if (TREE_CODE (pos) == INTEGER_CST)
  3075.         constant = pos;
  3076.       else if (TREE_CODE (pos) == PLUS_EXPR
  3077.            && TREE_CODE (TREE_OPERAND (pos, 1)) == INTEGER_CST)
  3078.         constant = TREE_OPERAND (pos, 1), offset = TREE_OPERAND (pos, 0);
  3079.       else
  3080.         offset = pos;
  3081.  
  3082.       if (constant)
  3083.         bitpos = TREE_INT_CST_LOW (constant);
  3084.  
  3085.       if (offset)
  3086.         {
  3087.           rtx offset_rtx;
  3088.  
  3089.           if (contains_placeholder_p (offset))
  3090.         offset = build (WITH_RECORD_EXPR, sizetype,
  3091.                 offset, exp);
  3092.  
  3093.           offset = size_binop (FLOOR_DIV_EXPR, offset,
  3094.                    size_int (BITS_PER_UNIT));
  3095.  
  3096.           offset_rtx = expand_expr (offset, NULL_RTX, VOIDmode, 0);
  3097.           if (GET_CODE (to_rtx) != MEM)
  3098.         abort ();
  3099.  
  3100.           to_rtx
  3101.         = change_address (to_rtx, VOIDmode,
  3102.                   gen_rtx (PLUS, ptr_mode, XEXP (to_rtx, 0),
  3103.                        force_reg (ptr_mode, offset_rtx)));
  3104.         }
  3105.  
  3106.       store_field (to_rtx, bitsize, bitpos, mode, TREE_VALUE (elt),
  3107.                /* The alignment of TARGET is
  3108.               at least what its type requires.  */
  3109.                VOIDmode, 0,
  3110.                TYPE_ALIGN (type) / BITS_PER_UNIT,
  3111.                int_size_in_bytes (type));
  3112.     }
  3113.     }
  3114.   else if (TREE_CODE (type) == ARRAY_TYPE)
  3115.     {
  3116.       register tree elt;
  3117.       register int i;
  3118.       tree domain = TYPE_DOMAIN (type);
  3119.       HOST_WIDE_INT minelt = TREE_INT_CST_LOW (TYPE_MIN_VALUE (domain));
  3120.       HOST_WIDE_INT maxelt = TREE_INT_CST_LOW (TYPE_MAX_VALUE (domain));
  3121.       tree elttype = TREE_TYPE (type);
  3122.  
  3123.       /* If the constructor has fewer fields than the structure,
  3124.      clear the whole structure first.  Similarly if this this is
  3125.      static constructor of a non-BLKmode object.  */
  3126.  
  3127.       if (list_length (CONSTRUCTOR_ELTS (exp)) < maxelt - minelt + 1
  3128.       || (GET_CODE (target) == REG && TREE_STATIC (exp)))
  3129.     clear_storage (target, expr_size (exp));
  3130.       else
  3131.     /* Inform later passes that the old value is dead.  */
  3132.     emit_insn (gen_rtx (CLOBBER, VOIDmode, target));
  3133.  
  3134.       /* Store each element of the constructor into
  3135.      the corresponding element of TARGET, determined
  3136.      by counting the elements.  */
  3137.       for (elt = CONSTRUCTOR_ELTS (exp), i = 0;
  3138.        elt;
  3139.        elt = TREE_CHAIN (elt), i++)
  3140.     {
  3141.       register enum machine_mode mode;
  3142.       int bitsize;
  3143.       int bitpos;
  3144.       int unsignedp;
  3145.       tree index = TREE_PURPOSE (elt);
  3146.       rtx xtarget = target;
  3147.  
  3148.       mode = TYPE_MODE (elttype);
  3149.       bitsize = GET_MODE_BITSIZE (mode);
  3150.       unsignedp = TREE_UNSIGNED (elttype);
  3151.  
  3152.       if ((index != 0 && TREE_CODE (index) != INTEGER_CST)
  3153.           || TREE_CODE (TYPE_SIZE (elttype)) != INTEGER_CST)
  3154.         {
  3155.           rtx pos_rtx, addr, xtarget;
  3156.           tree position;
  3157.  
  3158.           if (index == 0)
  3159.         index = size_int (i);
  3160.  
  3161.           position = size_binop (EXACT_DIV_EXPR, TYPE_SIZE (elttype),
  3162.                      size_int (BITS_PER_UNIT));
  3163.           position = size_binop (MULT_EXPR, index, position);
  3164.           pos_rtx = expand_expr (position, 0, VOIDmode, 0);
  3165.           addr = gen_rtx (PLUS, Pmode, XEXP (target, 0), pos_rtx);
  3166.           xtarget = change_address (target, mode, addr);
  3167.           store_expr (TREE_VALUE (elt), xtarget, 0);
  3168.         }
  3169.       else
  3170.         {
  3171.           if (index != 0)
  3172.         bitpos = ((TREE_INT_CST_LOW (index) - minelt)
  3173.               * TREE_INT_CST_LOW (TYPE_SIZE (elttype)));
  3174.           else
  3175.         bitpos = (i * TREE_INT_CST_LOW (TYPE_SIZE (elttype)));
  3176.  
  3177.           store_field (xtarget, bitsize, bitpos, mode, TREE_VALUE (elt),
  3178.                /* The alignment of TARGET is
  3179.                   at least what its type requires.  */
  3180.                VOIDmode, 0,
  3181.                TYPE_ALIGN (type) / BITS_PER_UNIT,
  3182.                int_size_in_bytes (type));
  3183.         }
  3184.     }
  3185.     }
  3186.   /* set constructor assignments */
  3187.   else if (TREE_CODE (type) == SET_TYPE)
  3188.     {
  3189.       tree elt;
  3190.       rtx xtarget = XEXP (target, 0);
  3191.       int set_word_size = TYPE_ALIGN (type);
  3192.       int nbytes = int_size_in_bytes (type);
  3193.       tree non_const_elements;
  3194.       int need_to_clear_first;
  3195.       tree domain = TYPE_DOMAIN (type);
  3196.       tree domain_min, domain_max, bitlength;
  3197.  
  3198.       /* The default implementation strategy is to extract the constant
  3199.      parts of the constructor, use that to initialize the target,
  3200.      and then "or" in whatever non-constant ranges we need in addition.
  3201.  
  3202.      If a large set is all zero or all ones, it is
  3203.      probably better to set it using memset (if available) or bzero.
  3204.      Also, if a large set has just a single range, it may also be
  3205.      better to first clear all the first clear the set (using
  3206.      bzero/memset), and set the bits we want. */
  3207.        
  3208.       /* Check for all zeros. */
  3209.       if (CONSTRUCTOR_ELTS (exp) == NULL_TREE)
  3210.     {
  3211.       clear_storage (target, expr_size (exp));
  3212.       return;
  3213.     }
  3214.  
  3215.       if (nbytes < 0)
  3216.     abort ();
  3217.  
  3218.       domain_min = convert (sizetype, TYPE_MIN_VALUE (domain));
  3219.       domain_max = convert (sizetype, TYPE_MAX_VALUE (domain));
  3220.       bitlength = size_binop (PLUS_EXPR,
  3221.                   size_binop (MINUS_EXPR, domain_max, domain_min),
  3222.                   size_one_node);
  3223.  
  3224.       /* Check for range all ones, or at most a single range.
  3225.        (This optimization is only a win for big sets.) */
  3226.       if (GET_MODE (target) == BLKmode && nbytes > 16
  3227.       && TREE_CHAIN (CONSTRUCTOR_ELTS (exp)) == NULL_TREE)
  3228.     {
  3229.       need_to_clear_first = 1;
  3230.       non_const_elements = CONSTRUCTOR_ELTS (exp);
  3231.     }
  3232.       else
  3233.     {
  3234.       int nbits = nbytes * BITS_PER_UNIT;
  3235.       int set_word_size = TYPE_ALIGN (TREE_TYPE (exp));
  3236.       enum machine_mode mode = mode_for_size (set_word_size, MODE_INT, 1);
  3237.       char *bit_buffer = (char*) alloca (nbits);
  3238.       HOST_WIDE_INT word = 0;
  3239.       int bit_pos = 0;
  3240.       int ibit = 0;
  3241.       int offset = 0;  /* In bytes from beginning of set. */
  3242.       non_const_elements = get_set_constructor_bits (exp,
  3243.                              bit_buffer, nbits);
  3244.       for (;;)
  3245.         {
  3246.           if (bit_buffer[ibit])
  3247.         {
  3248.           if (BYTES_BIG_ENDIAN)
  3249.             word |= (1 << (set_word_size - 1 - bit_pos));
  3250.           else
  3251.             word |= 1 << bit_pos;
  3252.         }
  3253.           bit_pos++;  ibit++;
  3254.           if (bit_pos >= set_word_size || ibit == nbits)
  3255.         {
  3256.           rtx datum = GEN_INT (word);
  3257.           rtx to_rtx;
  3258.           /* The assumption here is that it is safe to use XEXP if
  3259.              the set is multi-word, but not if it's single-word. */
  3260.           if (GET_CODE (target) == MEM)
  3261.             to_rtx = change_address (target, mode,
  3262.                          plus_constant (XEXP (target, 0),
  3263.                                 offset));
  3264.           else if (offset == 0) 
  3265.             to_rtx = target;
  3266.           else
  3267.             abort ();
  3268.           emit_move_insn (to_rtx, datum);
  3269.           if (ibit == nbits)
  3270.             break;
  3271.           word = 0;
  3272.           bit_pos = 0;
  3273.           offset += set_word_size / BITS_PER_UNIT;
  3274.         }
  3275.         }
  3276.       need_to_clear_first = 0;
  3277.     }
  3278.  
  3279.       for (elt = non_const_elements; elt != NULL_TREE; elt = TREE_CHAIN (elt))
  3280.     {
  3281.       /* start of range of element or NULL */
  3282.       tree startbit = TREE_PURPOSE (elt);
  3283.       /* end of range of element, or element value */
  3284.       tree endbit   = TREE_VALUE (elt);
  3285.       HOST_WIDE_INT startb, endb;
  3286.       rtx  bitlength_rtx, startbit_rtx, endbit_rtx, targetx;
  3287.  
  3288.       bitlength_rtx = expand_expr (bitlength,
  3289.                 NULL_RTX, MEM, EXPAND_CONST_ADDRESS);
  3290.  
  3291.       /* handle non-range tuple element like [ expr ]  */
  3292.       if (startbit == NULL_TREE)
  3293.         {
  3294.           startbit = save_expr (endbit);
  3295.           endbit = startbit;
  3296.         }
  3297.       startbit = convert (sizetype, startbit);
  3298.       endbit = convert (sizetype, endbit);
  3299.       if (! integer_zerop (domain_min))
  3300.         {
  3301.           startbit = size_binop (MINUS_EXPR, startbit, domain_min);
  3302.           endbit = size_binop (MINUS_EXPR, endbit, domain_min);
  3303.         }
  3304.       startbit_rtx = expand_expr (startbit, NULL_RTX, MEM, 
  3305.                       EXPAND_CONST_ADDRESS);
  3306.       endbit_rtx = expand_expr (endbit, NULL_RTX, MEM, 
  3307.                     EXPAND_CONST_ADDRESS);
  3308.  
  3309.       if (REG_P (target))
  3310.         {
  3311.           targetx = assign_stack_temp (GET_MODE (target),
  3312.                        GET_MODE_SIZE (GET_MODE (target)),
  3313.                        0);
  3314.           emit_move_insn (targetx, target);
  3315.         }
  3316.       else if (GET_CODE (target) == MEM)
  3317.         targetx = target;
  3318.       else
  3319.         abort ();
  3320.  
  3321. #ifdef TARGET_MEM_FUNCTIONS
  3322.       /* Optimization:  If startbit and endbit are
  3323.          constants divisible by BITS_PER_UNIT,
  3324.          call memset instead. */
  3325.       if (TREE_CODE (startbit) == INTEGER_CST
  3326.           && TREE_CODE (endbit) == INTEGER_CST
  3327.           && (startb = TREE_INT_CST_LOW (startbit)) % BITS_PER_UNIT == 0
  3328.           && (endb = TREE_INT_CST_LOW (endbit)) % BITS_PER_UNIT == 0)
  3329.         {
  3330.         
  3331.           if (need_to_clear_first
  3332.           && endb - startb != nbytes * BITS_PER_UNIT)
  3333.         clear_storage (target, expr_size (exp));
  3334.           need_to_clear_first = 0;
  3335.           emit_library_call (memset_libfunc, 0,
  3336.                  VOIDmode, 3,
  3337.                  plus_constant (XEXP (targetx, 0), startb),
  3338.                  Pmode,
  3339.                  constm1_rtx, Pmode,
  3340.                  GEN_INT ((endb - startb) / BITS_PER_UNIT),
  3341.                  Pmode);
  3342.         }
  3343.       else
  3344. #endif
  3345.         {
  3346.           if (need_to_clear_first)
  3347.         {
  3348.           clear_storage (target, expr_size (exp));
  3349.           need_to_clear_first = 0;
  3350.         }
  3351.           emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "__setbits"),
  3352.                  0, VOIDmode, 4, XEXP (targetx, 0), Pmode,
  3353.                  bitlength_rtx, TYPE_MODE (sizetype),
  3354.                  startbit_rtx, TYPE_MODE (sizetype),
  3355.                  endbit_rtx, TYPE_MODE (sizetype));
  3356.         }
  3357.       if (REG_P (target))
  3358.         emit_move_insn (target, targetx);
  3359.     }
  3360.     }
  3361.  
  3362.   else
  3363.     abort ();
  3364. }
  3365.  
  3366. /* Store the value of EXP (an expression tree)
  3367.    into a subfield of TARGET which has mode MODE and occupies
  3368.    BITSIZE bits, starting BITPOS bits from the start of TARGET.
  3369.    If MODE is VOIDmode, it means that we are storing into a bit-field.
  3370.  
  3371.    If VALUE_MODE is VOIDmode, return nothing in particular.
  3372.    UNSIGNEDP is not used in this case.
  3373.  
  3374.    Otherwise, return an rtx for the value stored.  This rtx
  3375.    has mode VALUE_MODE if that is convenient to do.
  3376.    In this case, UNSIGNEDP must be nonzero if the value is an unsigned type.
  3377.  
  3378.    ALIGN is the alignment that TARGET is known to have, measured in bytes.
  3379.    TOTAL_SIZE is the size in bytes of the structure, or -1 if varying.  */
  3380.  
  3381. static rtx
  3382. store_field (target, bitsize, bitpos, mode, exp, value_mode,
  3383.          unsignedp, align, total_size)
  3384.      rtx target;
  3385.      int bitsize, bitpos;
  3386.      enum machine_mode mode;
  3387.      tree exp;
  3388.      enum machine_mode value_mode;
  3389.      int unsignedp;
  3390.      int align;
  3391.      int total_size;
  3392. {
  3393.   HOST_WIDE_INT width_mask = 0;
  3394.  
  3395.   if (bitsize < HOST_BITS_PER_WIDE_INT)
  3396.     width_mask = ((HOST_WIDE_INT) 1 << bitsize) - 1;
  3397.  
  3398.   /* If we are storing into an unaligned field of an aligned union that is
  3399.      in a register, we may have the mode of TARGET being an integer mode but
  3400.      MODE == BLKmode.  In that case, get an aligned object whose size and
  3401.      alignment are the same as TARGET and store TARGET into it (we can avoid
  3402.      the store if the field being stored is the entire width of TARGET).  Then
  3403.      call ourselves recursively to store the field into a BLKmode version of
  3404.      that object.  Finally, load from the object into TARGET.  This is not
  3405.      very efficient in general, but should only be slightly more expensive
  3406.      than the otherwise-required unaligned accesses.  Perhaps this can be
  3407.      cleaned up later.  */
  3408.  
  3409.   if (mode == BLKmode
  3410.       && (GET_CODE (target) == REG || GET_CODE (target) == SUBREG))
  3411.     {
  3412.       rtx object = assign_stack_temp (GET_MODE (target),
  3413.                       GET_MODE_SIZE (GET_MODE (target)), 0);
  3414.       rtx blk_object = copy_rtx (object);
  3415.  
  3416.       MEM_IN_STRUCT_P (object) = 1;
  3417.       MEM_IN_STRUCT_P (blk_object) = 1;
  3418.       PUT_MODE (blk_object, BLKmode);
  3419.  
  3420.       if (bitsize != GET_MODE_BITSIZE (GET_MODE (target)))
  3421.     emit_move_insn (object, target);
  3422.  
  3423.       store_field (blk_object, bitsize, bitpos, mode, exp, VOIDmode, 0,
  3424.            align, total_size);
  3425.  
  3426.       /* Even though we aren't returning target, we need to
  3427.      give it the updated value.  */
  3428.       emit_move_insn (target, object);
  3429.  
  3430.       return blk_object;
  3431.     }
  3432.  
  3433.   /* If the structure is in a register or if the component
  3434.      is a bit field, we cannot use addressing to access it.
  3435.      Use bit-field techniques or SUBREG to store in it.  */
  3436.  
  3437.   if (mode == VOIDmode
  3438.       || (mode != BLKmode && ! direct_store[(int) mode])
  3439.       || GET_CODE (target) == REG
  3440.       || GET_CODE (target) == SUBREG
  3441.       /* If the field isn't aligned enough to store as an ordinary memref,
  3442.      store it as a bit field.  */
  3443.       || (SLOW_UNALIGNED_ACCESS
  3444.       && align * BITS_PER_UNIT < GET_MODE_ALIGNMENT (mode))
  3445.       || (SLOW_UNALIGNED_ACCESS && bitpos % GET_MODE_ALIGNMENT (mode) != 0))
  3446.     {
  3447.       rtx temp = expand_expr (exp, NULL_RTX, VOIDmode, 0);
  3448.  
  3449.       /* Unless MODE is VOIDmode or BLKmode, convert TEMP to
  3450.      MODE.  */
  3451.       if (mode != VOIDmode && mode != BLKmode
  3452.       && mode != TYPE_MODE (TREE_TYPE (exp)))
  3453.     temp = convert_modes (mode, TYPE_MODE (TREE_TYPE (exp)), temp, 1);
  3454.  
  3455.       /* Store the value in the bitfield.  */
  3456.       store_bit_field (target, bitsize, bitpos, mode, temp, align, total_size);
  3457.       if (value_mode != VOIDmode)
  3458.     {
  3459.       /* The caller wants an rtx for the value.  */
  3460.       /* If possible, avoid refetching from the bitfield itself.  */
  3461.       if (width_mask != 0
  3462.           && ! (GET_CODE (target) == MEM && MEM_VOLATILE_P (target)))
  3463.         {
  3464.           tree count;
  3465.           enum machine_mode tmode;
  3466.  
  3467.           if (unsignedp)
  3468.         return expand_and (temp, GEN_INT (width_mask), NULL_RTX);
  3469.           tmode = GET_MODE (temp);
  3470.           if (tmode == VOIDmode)
  3471.         tmode = value_mode;
  3472.           count = build_int_2 (GET_MODE_BITSIZE (tmode) - bitsize, 0);
  3473.           temp = expand_shift (LSHIFT_EXPR, tmode, temp, count, 0, 0);
  3474.           return expand_shift (RSHIFT_EXPR, tmode, temp, count, 0, 0);
  3475.         }
  3476.       return extract_bit_field (target, bitsize, bitpos, unsignedp,
  3477.                     NULL_RTX, value_mode, 0, align,
  3478.                     total_size);
  3479.     }
  3480.       return const0_rtx;
  3481.     }
  3482.   else
  3483.     {
  3484.       rtx addr = XEXP (target, 0);
  3485.       rtx to_rtx;
  3486.  
  3487.       /* If a value is wanted, it must be the lhs;
  3488.      so make the address stable for multiple use.  */
  3489.  
  3490.       if (value_mode != VOIDmode && GET_CODE (addr) != REG
  3491.       && ! CONSTANT_ADDRESS_P (addr)
  3492.       /* A frame-pointer reference is already stable.  */
  3493.       && ! (GET_CODE (addr) == PLUS
  3494.         && GET_CODE (XEXP (addr, 1)) == CONST_INT
  3495.         && (XEXP (addr, 0) == virtual_incoming_args_rtx
  3496.             || XEXP (addr, 0) == virtual_stack_vars_rtx)))
  3497.     addr = copy_to_reg (addr);
  3498.  
  3499.       /* Now build a reference to just the desired component.  */
  3500.  
  3501.       to_rtx = change_address (target, mode,
  3502.                    plus_constant (addr, (bitpos / BITS_PER_UNIT)));
  3503.       MEM_IN_STRUCT_P (to_rtx) = 1;
  3504.  
  3505.       return store_expr (exp, to_rtx, value_mode != VOIDmode);
  3506.     }
  3507. }
  3508.  
  3509. /* Return true if any object containing the innermost array is an unaligned
  3510.    packed structure field.  */
  3511.  
  3512. static int
  3513. get_inner_unaligned_p (exp)
  3514.      tree exp;
  3515. {
  3516.   int needed_alignment = TYPE_ALIGN (TREE_TYPE (exp));
  3517.  
  3518.   while (1)
  3519.     {
  3520.       if (TREE_CODE (exp) == COMPONENT_REF || TREE_CODE (exp) == BIT_FIELD_REF)
  3521.     {
  3522.       if (TYPE_ALIGN (TREE_TYPE (TREE_OPERAND (exp, 0)))
  3523.           < needed_alignment)
  3524.         return 1;
  3525.     }
  3526.       else if (TREE_CODE (exp) != ARRAY_REF
  3527.            && TREE_CODE (exp) != NON_LVALUE_EXPR
  3528.            && ! ((TREE_CODE (exp) == NOP_EXPR
  3529.               || TREE_CODE (exp) == CONVERT_EXPR)
  3530.              && (TYPE_MODE (TREE_TYPE (exp))
  3531.              == TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))))
  3532.     break;
  3533.  
  3534.       exp = TREE_OPERAND (exp, 0);
  3535.     }
  3536.  
  3537.   return 0;
  3538. }
  3539.  
  3540. /* Given an expression EXP that may be a COMPONENT_REF, a BIT_FIELD_REF,
  3541.    or an ARRAY_REF, look for nested COMPONENT_REFs, BIT_FIELD_REFs, or
  3542.    ARRAY_REFs and find the ultimate containing object, which we return.
  3543.  
  3544.    We set *PBITSIZE to the size in bits that we want, *PBITPOS to the
  3545.    bit position, and *PUNSIGNEDP to the signedness of the field.
  3546.    If the position of the field is variable, we store a tree
  3547.    giving the variable offset (in units) in *POFFSET.
  3548.    This offset is in addition to the bit position.
  3549.    If the position is not variable, we store 0 in *POFFSET.
  3550.  
  3551.    If any of the extraction expressions is volatile,
  3552.    we store 1 in *PVOLATILEP.  Otherwise we don't change that.
  3553.  
  3554.    If the field is a bit-field, *PMODE is set to VOIDmode.  Otherwise, it
  3555.    is a mode that can be used to access the field.  In that case, *PBITSIZE
  3556.    is redundant.
  3557.  
  3558.    If the field describes a variable-sized object, *PMODE is set to
  3559.    VOIDmode and *PBITSIZE is set to -1.  An access cannot be made in
  3560.    this case, but the address of the object can be found.  */
  3561.  
  3562. tree
  3563. get_inner_reference (exp, pbitsize, pbitpos, poffset, pmode,
  3564.              punsignedp, pvolatilep)
  3565.      tree exp;
  3566.      int *pbitsize;
  3567.      int *pbitpos;
  3568.      tree *poffset;
  3569.      enum machine_mode *pmode;
  3570.      int *punsignedp;
  3571.      int *pvolatilep;
  3572. {
  3573.   tree orig_exp = exp;
  3574.   tree size_tree = 0;
  3575.   enum machine_mode mode = VOIDmode;
  3576.   tree offset = integer_zero_node;
  3577.  
  3578.   if (TREE_CODE (exp) == COMPONENT_REF)
  3579.     {
  3580.       size_tree = DECL_SIZE (TREE_OPERAND (exp, 1));
  3581.       if (! DECL_BIT_FIELD (TREE_OPERAND (exp, 1)))
  3582.     mode = DECL_MODE (TREE_OPERAND (exp, 1));
  3583.       *punsignedp = TREE_UNSIGNED (TREE_OPERAND (exp, 1));
  3584.     }
  3585.   else if (TREE_CODE (exp) == BIT_FIELD_REF)
  3586.     {
  3587.       size_tree = TREE_OPERAND (exp, 1);
  3588.       *punsignedp = TREE_UNSIGNED (exp);
  3589.     }
  3590.   else
  3591.     {
  3592.       mode = TYPE_MODE (TREE_TYPE (exp));
  3593.       *pbitsize = GET_MODE_BITSIZE (mode);
  3594.       *punsignedp = TREE_UNSIGNED (TREE_TYPE (exp));
  3595.     }
  3596.       
  3597.   if (size_tree)
  3598.     {
  3599.       if (TREE_CODE (size_tree) != INTEGER_CST)
  3600.     mode = BLKmode, *pbitsize = -1;
  3601.       else
  3602.     *pbitsize = TREE_INT_CST_LOW (size_tree);
  3603.     }
  3604.  
  3605.   /* Compute cumulative bit-offset for nested component-refs and array-refs,
  3606.      and find the ultimate containing object.  */
  3607.  
  3608.   *pbitpos = 0;
  3609.  
  3610.   while (1)
  3611.     {
  3612.       if (TREE_CODE (exp) == COMPONENT_REF || TREE_CODE (exp) == BIT_FIELD_REF)
  3613.     {
  3614.       tree pos = (TREE_CODE (exp) == COMPONENT_REF
  3615.               ? DECL_FIELD_BITPOS (TREE_OPERAND (exp, 1))
  3616.               : TREE_OPERAND (exp, 2));
  3617.       tree constant = integer_zero_node, var = pos;
  3618.  
  3619.       /* If this field hasn't been filled in yet, don't go
  3620.          past it.  This should only happen when folding expressions
  3621.          made during type construction.  */
  3622.       if (pos == 0)
  3623.         break;
  3624.  
  3625.       /* Assume here that the offset is a multiple of a unit.
  3626.          If not, there should be an explicitly added constant.  */
  3627.       if (TREE_CODE (pos) == PLUS_EXPR
  3628.           && TREE_CODE (TREE_OPERAND (pos, 1)) == INTEGER_CST)
  3629.         constant = TREE_OPERAND (pos, 1), var = TREE_OPERAND (pos, 0);
  3630.       else if (TREE_CODE (pos) == INTEGER_CST)
  3631.         constant = pos, var = integer_zero_node;
  3632.  
  3633.       *pbitpos += TREE_INT_CST_LOW (constant);
  3634.  
  3635.       if (var)
  3636.         offset = size_binop (PLUS_EXPR, offset,
  3637.                  size_binop (EXACT_DIV_EXPR, var,
  3638.                          size_int (BITS_PER_UNIT)));
  3639.     }
  3640.  
  3641.       else if (TREE_CODE (exp) == ARRAY_REF)
  3642.     {
  3643.       /* This code is based on the code in case ARRAY_REF in expand_expr
  3644.          below.  We assume here that the size of an array element is
  3645.          always an integral multiple of BITS_PER_UNIT.  */
  3646.  
  3647.       tree index = TREE_OPERAND (exp, 1);
  3648.       tree domain = TYPE_DOMAIN (TREE_TYPE (TREE_OPERAND (exp, 0)));
  3649.       tree low_bound
  3650.         = domain ? TYPE_MIN_VALUE (domain) : integer_zero_node;
  3651.       tree index_type = TREE_TYPE (index);
  3652.  
  3653.       if (! integer_zerop (low_bound))
  3654.         index = fold (build (MINUS_EXPR, index_type, index, low_bound));
  3655.  
  3656.       if (TYPE_PRECISION (index_type) != TYPE_PRECISION (sizetype))
  3657.         {
  3658.           index = convert (type_for_size (TYPE_PRECISION (sizetype), 0),
  3659.                    index);
  3660.           index_type = TREE_TYPE (index);
  3661.         }
  3662.  
  3663.       index = fold (build (MULT_EXPR, index_type, index,
  3664.                    TYPE_SIZE (TREE_TYPE (exp))));
  3665.  
  3666.       if (TREE_CODE (index) == INTEGER_CST
  3667.           && TREE_INT_CST_HIGH (index) == 0)
  3668.         *pbitpos += TREE_INT_CST_LOW (index);
  3669.       else
  3670.         offset = size_binop (PLUS_EXPR, offset,
  3671.                  size_binop (FLOOR_DIV_EXPR, index,
  3672.                          size_int (BITS_PER_UNIT)));
  3673.     }
  3674.       else if (TREE_CODE (exp) != NON_LVALUE_EXPR
  3675.            && ! ((TREE_CODE (exp) == NOP_EXPR
  3676.               || TREE_CODE (exp) == CONVERT_EXPR)
  3677.              && ! (TREE_CODE (TREE_TYPE (exp)) == UNION_TYPE
  3678.                && (TREE_CODE (TREE_TYPE (TREE_OPERAND (exp, 0)))
  3679.                    != UNION_TYPE))
  3680.              && (TYPE_MODE (TREE_TYPE (exp))
  3681.              == TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))))
  3682.     break;
  3683.  
  3684.       /* If any reference in the chain is volatile, the effect is volatile.  */
  3685.       if (TREE_THIS_VOLATILE (exp))
  3686.     *pvolatilep = 1;
  3687.       exp = TREE_OPERAND (exp, 0);
  3688.     }
  3689.  
  3690.   /* If this was a bit-field, see if there is a mode that allows direct
  3691.      access in case EXP is in memory.  */
  3692.   if (mode == VOIDmode && *pbitsize != 0 && *pbitpos % *pbitsize == 0)
  3693.     {
  3694.       mode = mode_for_size (*pbitsize, MODE_INT, 0);
  3695.       if (mode == BLKmode)
  3696.     mode = VOIDmode;
  3697.     }
  3698.  
  3699.   if (integer_zerop (offset))
  3700.     offset = 0;
  3701.  
  3702.   if (offset != 0 && contains_placeholder_p (offset))
  3703.     offset = build (WITH_RECORD_EXPR, sizetype, offset, orig_exp);
  3704.  
  3705.   *pmode = mode;
  3706.   *poffset = offset;
  3707.   return exp;
  3708. }
  3709.  
  3710. /* Given an rtx VALUE that may contain additions and multiplications,
  3711.    return an equivalent value that just refers to a register or memory.
  3712.    This is done by generating instructions to perform the arithmetic
  3713.    and returning a pseudo-register containing the value.
  3714.  
  3715.    The returned value may be a REG, SUBREG, MEM or constant.  */
  3716.  
  3717. rtx
  3718. force_operand (value, target)
  3719.      rtx value, target;
  3720. {
  3721.   register optab binoptab = 0;
  3722.   /* Use a temporary to force order of execution of calls to
  3723.      `force_operand'.  */
  3724.   rtx tmp;
  3725.   register rtx op2;
  3726.   /* Use subtarget as the target for operand 0 of a binary operation.  */
  3727.   register rtx subtarget = (target != 0 && GET_CODE (target) == REG ? target : 0);
  3728.  
  3729.   if (GET_CODE (value) == PLUS)
  3730.     binoptab = add_optab;
  3731.   else if (GET_CODE (value) == MINUS)
  3732.     binoptab = sub_optab;
  3733.   else if (GET_CODE (value) == MULT)
  3734.     {
  3735.       op2 = XEXP (value, 1);
  3736.       if (!CONSTANT_P (op2)
  3737.       && !(GET_CODE (op2) == REG && op2 != subtarget))
  3738.     subtarget = 0;
  3739.       tmp = force_operand (XEXP (value, 0), subtarget);
  3740.       return expand_mult (GET_MODE (value), tmp,
  3741.               force_operand (op2, NULL_RTX),
  3742.               target, 0);
  3743.     }
  3744.  
  3745.   if (binoptab)
  3746.     {
  3747.       op2 = XEXP (value, 1);
  3748.       if (!CONSTANT_P (op2)
  3749.       && !(GET_CODE (op2) == REG && op2 != subtarget))
  3750.     subtarget = 0;
  3751.       if (binoptab == sub_optab && GET_CODE (op2) == CONST_INT)
  3752.     {
  3753.       binoptab = add_optab;
  3754.       op2 = negate_rtx (GET_MODE (value), op2);
  3755.     }
  3756.  
  3757.       /* Check for an addition with OP2 a constant integer and our first
  3758.      operand a PLUS of a virtual register and something else.  In that
  3759.      case, we want to emit the sum of the virtual register and the
  3760.      constant first and then add the other value.  This allows virtual
  3761.      register instantiation to simply modify the constant rather than
  3762.      creating another one around this addition.  */
  3763.       if (binoptab == add_optab && GET_CODE (op2) == CONST_INT
  3764.       && GET_CODE (XEXP (value, 0)) == PLUS
  3765.       && GET_CODE (XEXP (XEXP (value, 0), 0)) == REG
  3766.       && REGNO (XEXP (XEXP (value, 0), 0)) >= FIRST_VIRTUAL_REGISTER
  3767.       && REGNO (XEXP (XEXP (value, 0), 0)) <= LAST_VIRTUAL_REGISTER)
  3768.     {
  3769.       rtx temp = expand_binop (GET_MODE (value), binoptab,
  3770.                    XEXP (XEXP (value, 0), 0), op2,
  3771.                    subtarget, 0, OPTAB_LIB_WIDEN);
  3772.       return expand_binop (GET_MODE (value), binoptab, temp,
  3773.                    force_operand (XEXP (XEXP (value, 0), 1), 0),
  3774.                    target, 0, OPTAB_LIB_WIDEN);
  3775.     }
  3776.                    
  3777.       tmp = force_operand (XEXP (value, 0), subtarget);
  3778.       return expand_binop (GET_MODE (value), binoptab, tmp,
  3779.                force_operand (op2, NULL_RTX),
  3780.                target, 0, OPTAB_LIB_WIDEN);
  3781.       /* We give UNSIGNEDP = 0 to expand_binop
  3782.      because the only operations we are expanding here are signed ones.  */
  3783.     }
  3784.   return value;
  3785. }
  3786.  
  3787. /* Subroutine of expand_expr:
  3788.    save the non-copied parts (LIST) of an expr (LHS), and return a list
  3789.    which can restore these values to their previous values,
  3790.    should something modify their storage.  */
  3791.  
  3792. static tree
  3793. save_noncopied_parts (lhs, list)
  3794.      tree lhs;
  3795.      tree list;
  3796. {
  3797.   tree tail;
  3798.   tree parts = 0;
  3799.  
  3800.   for (tail = list; tail; tail = TREE_CHAIN (tail))
  3801.     if (TREE_CODE (TREE_VALUE (tail)) == TREE_LIST)
  3802.       parts = chainon (parts, save_noncopied_parts (lhs, TREE_VALUE (tail)));
  3803.     else
  3804.       {
  3805.     tree part = TREE_VALUE (tail);
  3806.     tree part_type = TREE_TYPE (part);
  3807.     tree to_be_saved = build (COMPONENT_REF, part_type, lhs, part);
  3808.     rtx target = assign_stack_temp (TYPE_MODE (part_type),
  3809.                     int_size_in_bytes (part_type), 0);
  3810.     MEM_IN_STRUCT_P (target) = AGGREGATE_TYPE_P (part_type);
  3811.     if (! memory_address_p (TYPE_MODE (part_type), XEXP (target, 0)))
  3812.       target = change_address (target, TYPE_MODE (part_type), NULL_RTX);
  3813.     parts = tree_cons (to_be_saved,
  3814.                build (RTL_EXPR, part_type, NULL_TREE,
  3815.                   (tree) target),
  3816.                parts);
  3817.     store_expr (TREE_PURPOSE (parts), RTL_EXPR_RTL (TREE_VALUE (parts)), 0);
  3818.       }
  3819.   return parts;
  3820. }
  3821.  
  3822. /* Subroutine of expand_expr:
  3823.    record the non-copied parts (LIST) of an expr (LHS), and return a list
  3824.    which specifies the initial values of these parts.  */
  3825.  
  3826. static tree
  3827. init_noncopied_parts (lhs, list)
  3828.      tree lhs;
  3829.      tree list;
  3830. {
  3831.   tree tail;
  3832.   tree parts = 0;
  3833.  
  3834.   for (tail = list; tail; tail = TREE_CHAIN (tail))
  3835.     if (TREE_CODE (TREE_VALUE (tail)) == TREE_LIST)
  3836.       parts = chainon (parts, init_noncopied_parts (lhs, TREE_VALUE (tail)));
  3837.     else
  3838.       {
  3839.     tree part = TREE_VALUE (tail);
  3840.     tree part_type = TREE_TYPE (part);
  3841.     tree to_be_initialized = build (COMPONENT_REF, part_type, lhs, part);
  3842.     parts = tree_cons (TREE_PURPOSE (tail), to_be_initialized, parts);
  3843.       }
  3844.   return parts;
  3845. }
  3846.  
  3847. /* Subroutine of expand_expr: return nonzero iff there is no way that
  3848.    EXP can reference X, which is being modified.  */
  3849.  
  3850. static int
  3851. safe_from_p (x, exp)
  3852.      rtx x;
  3853.      tree exp;
  3854. {
  3855.   rtx exp_rtl = 0;
  3856.   int i, nops;
  3857.  
  3858.   if (x == 0
  3859.       /* If EXP has varying size, we MUST use a target since we currently
  3860.      have no way of allocating temporaries of variable size.  So we
  3861.      assume here that something at a higher level has prevented a
  3862.      clash.  This is somewhat bogus, but the best we can do.  Only
  3863.      do this when X is BLKmode.  */
  3864.       || (TREE_TYPE (exp) != 0 && TYPE_SIZE (TREE_TYPE (exp)) != 0
  3865.       && TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) != INTEGER_CST
  3866.       && GET_MODE (x) == BLKmode))
  3867.     return 1;
  3868.  
  3869.   /* If this is a subreg of a hard register, declare it unsafe, otherwise,
  3870.      find the underlying pseudo.  */
  3871.   if (GET_CODE (x) == SUBREG)
  3872.     {
  3873.       x = SUBREG_REG (x);
  3874.       if (GET_CODE (x) == REG && REGNO (x) < FIRST_PSEUDO_REGISTER)
  3875.     return 0;
  3876.     }
  3877.  
  3878.   /* If X is a location in the outgoing argument area, it is always safe.  */
  3879.   if (GET_CODE (x) == MEM
  3880.       && (XEXP (x, 0) == virtual_outgoing_args_rtx
  3881.       || (GET_CODE (XEXP (x, 0)) == PLUS
  3882.           && XEXP (XEXP (x, 0), 0) == virtual_outgoing_args_rtx)))
  3883.     return 1;
  3884.  
  3885.   switch (TREE_CODE_CLASS (TREE_CODE (exp)))
  3886.     {
  3887.     case 'd':
  3888.       exp_rtl = DECL_RTL (exp);
  3889.       break;
  3890.  
  3891.     case 'c':
  3892.       return 1;
  3893.  
  3894.     case 'x':
  3895.       if (TREE_CODE (exp) == TREE_LIST)
  3896.     return ((TREE_VALUE (exp) == 0
  3897.          || safe_from_p (x, TREE_VALUE (exp)))
  3898.         && (TREE_CHAIN (exp) == 0
  3899.             || safe_from_p (x, TREE_CHAIN (exp))));
  3900.       else
  3901.     return 0;
  3902.  
  3903.     case '1':
  3904.       return safe_from_p (x, TREE_OPERAND (exp, 0));
  3905.  
  3906.     case '2':
  3907.     case '<':
  3908.       return (safe_from_p (x, TREE_OPERAND (exp, 0))
  3909.           && safe_from_p (x, TREE_OPERAND (exp, 1)));
  3910.  
  3911.     case 'e':
  3912.     case 'r':
  3913.       /* Now do code-specific tests.  EXP_RTL is set to any rtx we find in
  3914.      the expression.  If it is set, we conflict iff we are that rtx or
  3915.      both are in memory.  Otherwise, we check all operands of the
  3916.      expression recursively.  */
  3917.  
  3918.       switch (TREE_CODE (exp))
  3919.     {
  3920.     case ADDR_EXPR:
  3921.       return (staticp (TREE_OPERAND (exp, 0))
  3922.           || safe_from_p (x, TREE_OPERAND (exp, 0)));
  3923.  
  3924.     case INDIRECT_REF:
  3925.       if (GET_CODE (x) == MEM)
  3926.         return 0;
  3927.       break;
  3928.  
  3929.     case CALL_EXPR:
  3930.       exp_rtl = CALL_EXPR_RTL (exp);
  3931.       if (exp_rtl == 0)
  3932.         {
  3933.           /* Assume that the call will clobber all hard registers and
  3934.          all of memory.  */
  3935.           if ((GET_CODE (x) == REG && REGNO (x) < FIRST_PSEUDO_REGISTER)
  3936.           || GET_CODE (x) == MEM)
  3937.         return 0;
  3938.         }
  3939.  
  3940.       break;
  3941.  
  3942.     case RTL_EXPR:
  3943.       /* If a sequence exists, we would have to scan every instruction
  3944.          in the sequence to see if it was safe.  This is probably not
  3945.          worthwhile.  */
  3946.       if (RTL_EXPR_SEQUENCE (exp))
  3947.         return 0;
  3948.  
  3949.       exp_rtl = RTL_EXPR_RTL (exp);
  3950.       break;
  3951.  
  3952.     case WITH_CLEANUP_EXPR:
  3953.       exp_rtl = RTL_EXPR_RTL (exp);
  3954.       break;
  3955.  
  3956.     case CLEANUP_POINT_EXPR:
  3957.       return safe_from_p (x, TREE_OPERAND (exp, 0));
  3958.  
  3959.     case SAVE_EXPR:
  3960.       exp_rtl = SAVE_EXPR_RTL (exp);
  3961.       break;
  3962.  
  3963.     case BIND_EXPR:
  3964.       /* The only operand we look at is operand 1.  The rest aren't
  3965.          part of the expression.  */
  3966.       return safe_from_p (x, TREE_OPERAND (exp, 1));
  3967.  
  3968.     case METHOD_CALL_EXPR:
  3969.       /* This takes a rtx argument, but shouldn't appear here. */
  3970.       abort ();
  3971.     }
  3972.  
  3973.       /* If we have an rtx, we do not need to scan our operands.  */
  3974.       if (exp_rtl)
  3975.     break;
  3976.  
  3977.       nops = tree_code_length[(int) TREE_CODE (exp)];
  3978.       for (i = 0; i < nops; i++)
  3979.     if (TREE_OPERAND (exp, i) != 0
  3980.         && ! safe_from_p (x, TREE_OPERAND (exp, i)))
  3981.       return 0;
  3982.     }
  3983.  
  3984.   /* If we have an rtl, find any enclosed object.  Then see if we conflict
  3985.      with it.  */
  3986.   if (exp_rtl)
  3987.     {
  3988.       if (GET_CODE (exp_rtl) == SUBREG)
  3989.     {
  3990.       exp_rtl = SUBREG_REG (exp_rtl);
  3991.       if (GET_CODE (exp_rtl) == REG
  3992.           && REGNO (exp_rtl) < FIRST_PSEUDO_REGISTER)
  3993.         return 0;
  3994.     }
  3995.  
  3996.       /* If the rtl is X, then it is not safe.  Otherwise, it is unless both
  3997.      are memory and EXP is not readonly.  */
  3998.       return ! (rtx_equal_p (x, exp_rtl)
  3999.         || (GET_CODE (x) == MEM && GET_CODE (exp_rtl) == MEM
  4000.             && ! TREE_READONLY (exp)));
  4001.     }
  4002.  
  4003.   /* If we reach here, it is safe.  */
  4004.   return 1;
  4005. }
  4006.  
  4007. /* Subroutine of expand_expr: return nonzero iff EXP is an
  4008.    expression whose type is statically determinable.  */
  4009.  
  4010. static int
  4011. fixed_type_p (exp)
  4012.      tree exp;
  4013. {
  4014.   if (TREE_CODE (exp) == PARM_DECL
  4015.       || TREE_CODE (exp) == VAR_DECL
  4016.       || TREE_CODE (exp) == CALL_EXPR || TREE_CODE (exp) == TARGET_EXPR
  4017.       || TREE_CODE (exp) == COMPONENT_REF
  4018.       || TREE_CODE (exp) == ARRAY_REF)
  4019.     return 1;
  4020.   return 0;
  4021. }
  4022.  
  4023. /* expand_expr: generate code for computing expression EXP.
  4024.    An rtx for the computed value is returned.  The value is never null.
  4025.    In the case of a void EXP, const0_rtx is returned.
  4026.  
  4027.    The value may be stored in TARGET if TARGET is nonzero.
  4028.    TARGET is just a suggestion; callers must assume that
  4029.    the rtx returned may not be the same as TARGET.
  4030.  
  4031.    If TARGET is CONST0_RTX, it means that the value will be ignored.
  4032.  
  4033.    If TMODE is not VOIDmode, it suggests generating the
  4034.    result in mode TMODE.  But this is done only when convenient.
  4035.    Otherwise, TMODE is ignored and the value generated in its natural mode.
  4036.    TMODE is just a suggestion; callers must assume that
  4037.    the rtx returned may not have mode TMODE.
  4038.  
  4039.    Note that TARGET may have neither TMODE nor MODE.  In that case, it
  4040.    probably will not be used.
  4041.  
  4042.    If MODIFIER is EXPAND_SUM then when EXP is an addition
  4043.    we can return an rtx of the form (MULT (REG ...) (CONST_INT ...))
  4044.    or a nest of (PLUS ...) and (MINUS ...) where the terms are
  4045.    products as above, or REG or MEM, or constant.
  4046.    Ordinarily in such cases we would output mul or add instructions
  4047.    and then return a pseudo reg containing the sum.
  4048.  
  4049.    EXPAND_INITIALIZER is much like EXPAND_SUM except that
  4050.    it also marks a label as absolutely required (it can't be dead).
  4051.    It also makes a ZERO_EXTEND or SIGN_EXTEND instead of emitting extend insns.
  4052.    This is used for outputting expressions used in initializers.
  4053.  
  4054.    EXPAND_CONST_ADDRESS says that it is okay to return a MEM
  4055.    with a constant address even if that address is not normally legitimate.
  4056.    EXPAND_INITIALIZER and EXPAND_SUM also have this effect.  */
  4057.  
  4058. rtx
  4059. expand_expr (exp, target, tmode, modifier)
  4060.      register tree exp;
  4061.      rtx target;
  4062.      enum machine_mode tmode;
  4063.      enum expand_modifier modifier;
  4064. {
  4065.   /* Chain of pending expressions for PLACEHOLDER_EXPR to replace.
  4066.      This is static so it will be accessible to our recursive callees.  */
  4067.   static tree placeholder_list = 0;
  4068.   register rtx op0, op1, temp;
  4069.   tree type = TREE_TYPE (exp);
  4070.   int unsignedp = TREE_UNSIGNED (type);
  4071.   register enum machine_mode mode = TYPE_MODE (type);
  4072.   register enum tree_code code = TREE_CODE (exp);
  4073.   optab this_optab;
  4074.   /* Use subtarget as the target for operand 0 of a binary operation.  */
  4075.   rtx subtarget = (target != 0 && GET_CODE (target) == REG ? target : 0);
  4076.   rtx original_target = target;
  4077.   /* Maybe defer this until sure not doing bytecode?  */
  4078.   int ignore = (target == const0_rtx
  4079.         || ((code == NON_LVALUE_EXPR || code == NOP_EXPR
  4080.              || code == CONVERT_EXPR || code == REFERENCE_EXPR
  4081.              || code == COND_EXPR)
  4082.             && TREE_CODE (type) == VOID_TYPE));
  4083.   tree context;
  4084.  
  4085.  
  4086.   if (output_bytecode && modifier != EXPAND_INITIALIZER)
  4087.     {
  4088.       bc_expand_expr (exp);
  4089.       return NULL;
  4090.     }
  4091.  
  4092.   /* Don't use hard regs as subtargets, because the combiner
  4093.      can only handle pseudo regs.  */
  4094.   if (subtarget && REGNO (subtarget) < FIRST_PSEUDO_REGISTER)
  4095.     subtarget = 0;
  4096.   /* Avoid subtargets inside loops,
  4097.      since they hide some invariant expressions.  */
  4098.   if (preserve_subexpressions_p ())
  4099.     subtarget = 0;
  4100.  
  4101.   /* If we are going to ignore this result, we need only do something
  4102.      if there is a side-effect somewhere in the expression.  If there
  4103.      is, short-circuit the most common cases here.  Note that we must
  4104.      not call expand_expr with anything but const0_rtx in case this
  4105.      is an initial expansion of a size that contains a PLACEHOLDER_EXPR.  */
  4106.  
  4107.   if (ignore)
  4108.     {
  4109.       if (! TREE_SIDE_EFFECTS (exp))
  4110.     return const0_rtx;
  4111.  
  4112.       /* Ensure we reference a volatile object even if value is ignored.  */
  4113.       if (TREE_THIS_VOLATILE (exp)
  4114.       && TREE_CODE (exp) != FUNCTION_DECL
  4115.       && mode != VOIDmode && mode != BLKmode)
  4116.     {
  4117.       temp = expand_expr (exp, NULL_RTX, VOIDmode, modifier);
  4118.       if (GET_CODE (temp) == MEM)
  4119.         temp = copy_to_reg (temp);
  4120.       return const0_rtx;
  4121.     }
  4122.  
  4123.       if (TREE_CODE_CLASS (code) == '1')
  4124.     return expand_expr (TREE_OPERAND (exp, 0), const0_rtx,
  4125.                 VOIDmode, modifier);
  4126.       else if (TREE_CODE_CLASS (code) == '2'
  4127.            || TREE_CODE_CLASS (code) == '<')
  4128.     {
  4129.       expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, modifier);
  4130.       expand_expr (TREE_OPERAND (exp, 1), const0_rtx, VOIDmode, modifier);
  4131.       return const0_rtx;
  4132.     }
  4133.       else if ((code == TRUTH_ANDIF_EXPR || code == TRUTH_ORIF_EXPR)
  4134.            && ! TREE_SIDE_EFFECTS (TREE_OPERAND (exp, 1)))
  4135.     /* If the second operand has no side effects, just evaluate
  4136.        the first. */
  4137.     return expand_expr (TREE_OPERAND (exp, 0), const0_rtx,
  4138.                 VOIDmode, modifier);
  4139.  
  4140.       target = 0;
  4141.     }
  4142.  
  4143.   /* If will do cse, generate all results into pseudo registers
  4144.      since 1) that allows cse to find more things
  4145.      and 2) otherwise cse could produce an insn the machine
  4146.      cannot support.  */
  4147.  
  4148.   if (! cse_not_expected && mode != BLKmode && target
  4149.       && (GET_CODE (target) != REG || REGNO (target) < FIRST_PSEUDO_REGISTER))
  4150.     target = subtarget;
  4151.  
  4152.   switch (code)
  4153.     {
  4154.     case LABEL_DECL:
  4155.       {
  4156.     tree function = decl_function_context (exp);
  4157.     /* Handle using a label in a containing function.  */
  4158.     if (function != current_function_decl && function != 0)
  4159.       {
  4160.         struct function *p = find_function_data (function);
  4161.         /* Allocate in the memory associated with the function
  4162.            that the label is in.  */
  4163.         push_obstacks (p->function_obstack,
  4164.                p->function_maybepermanent_obstack);
  4165.  
  4166.         p->forced_labels = gen_rtx (EXPR_LIST, VOIDmode,
  4167.                     label_rtx (exp), p->forced_labels);
  4168.         pop_obstacks ();
  4169.       }
  4170.     else if (modifier == EXPAND_INITIALIZER)
  4171.       forced_labels = gen_rtx (EXPR_LIST, VOIDmode,
  4172.                    label_rtx (exp), forced_labels);
  4173.     temp = gen_rtx (MEM, FUNCTION_MODE,
  4174.             gen_rtx (LABEL_REF, Pmode, label_rtx (exp)));
  4175.     if (function != current_function_decl && function != 0)
  4176.       LABEL_REF_NONLOCAL_P (XEXP (temp, 0)) = 1;
  4177.     return temp;
  4178.       }
  4179.  
  4180.     case PARM_DECL:
  4181.       if (DECL_RTL (exp) == 0)
  4182.     {
  4183.       error_with_decl (exp, "prior parameter's size depends on `%s'");
  4184.       return CONST0_RTX (mode);
  4185.     }
  4186.  
  4187.       /* ... fall through ... */
  4188.  
  4189.     case VAR_DECL:
  4190.       /* If a static var's type was incomplete when the decl was written,
  4191.      but the type is complete now, lay out the decl now.  */
  4192.       if (DECL_SIZE (exp) == 0 && TYPE_SIZE (TREE_TYPE (exp)) != 0
  4193.       && (TREE_STATIC (exp) || DECL_EXTERNAL (exp)))
  4194.     {
  4195.       push_obstacks_nochange ();
  4196.       end_temporary_allocation ();
  4197.       layout_decl (exp, 0);
  4198.       PUT_MODE (DECL_RTL (exp), DECL_MODE (exp));
  4199.       pop_obstacks ();
  4200.     }
  4201.  
  4202.       /* ... fall through ... */
  4203.  
  4204.     case FUNCTION_DECL:
  4205.     case RESULT_DECL:
  4206.       if (DECL_RTL (exp) == 0)
  4207.     abort ();
  4208.  
  4209.       /* Ensure variable marked as used even if it doesn't go through
  4210.      a parser.  If it hasn't be used yet, write out an external
  4211.      definition.  */
  4212.       if (! TREE_USED (exp))
  4213.     {
  4214.       assemble_external (exp);
  4215.       TREE_USED (exp) = 1;
  4216.     }
  4217.  
  4218.       /* Handle variables inherited from containing functions.  */
  4219.       context = decl_function_context (exp);
  4220.  
  4221.       /* We treat inline_function_decl as an alias for the current function
  4222.      because that is the inline function whose vars, types, etc.
  4223.      are being merged into the current function.
  4224.      See expand_inline_function.  */
  4225.  
  4226.       if (context != 0 && context != current_function_decl
  4227.       && context != inline_function_decl
  4228.       /* If var is static, we don't need a static chain to access it.  */
  4229.       && ! (GET_CODE (DECL_RTL (exp)) == MEM
  4230.         && CONSTANT_P (XEXP (DECL_RTL (exp), 0))))
  4231.     {
  4232.       rtx addr;
  4233.  
  4234.       /* Mark as non-local and addressable.  */
  4235.       DECL_NONLOCAL (exp) = 1;
  4236.       mark_addressable (exp);
  4237.       if (GET_CODE (DECL_RTL (exp)) != MEM)
  4238.         abort ();
  4239.       addr = XEXP (DECL_RTL (exp), 0);
  4240.       if (GET_CODE (addr) == MEM)
  4241.         addr = gen_rtx (MEM, Pmode,
  4242.                 fix_lexical_addr (XEXP (addr, 0), exp));
  4243.       else
  4244.         addr = fix_lexical_addr (addr, exp);
  4245. #ifdef WIN32
  4246.       addr = 
  4247. #else
  4248.       return
  4249. #endif
  4250.         change_address (DECL_RTL (exp), mode, addr);
  4251. #ifdef WIN32
  4252.       if (DECL_DLLIMPORT (exp))
  4253.       {
  4254.         addr = gen_rtx (MEM, Pmode, force_reg (Pmode, addr));
  4255.       }
  4256.       return addr;
  4257. #endif
  4258.     }
  4259.  
  4260.       /* This is the case of an array whose size is to be determined
  4261.      from its initializer, while the initializer is still being parsed.
  4262.      See expand_decl.  */
  4263.  
  4264.       if (GET_CODE (DECL_RTL (exp)) == MEM
  4265.       && GET_CODE (XEXP (DECL_RTL (exp), 0)) == REG)
  4266. #ifdef WIN32
  4267.     {
  4268.       rtx addr = 
  4269. #else
  4270.     return
  4271. #endif
  4272.       change_address (DECL_RTL (exp), GET_MODE (DECL_RTL (exp)),
  4273.               XEXP (DECL_RTL (exp), 0));
  4274. #ifdef WIN32
  4275.       if (DECL_DLLIMPORT (exp))
  4276.         addr = gen_rtx (MEM, Pmode, force_reg (Pmode, addr));
  4277.         return addr;
  4278.     }
  4279. #endif
  4280.  
  4281.       /* If DECL_RTL is memory, we are in the normal case and either
  4282.      the address is not valid or it is not a register and -fforce-addr
  4283.      is specified, get the address into a register.  */
  4284.  
  4285.       if (GET_CODE (DECL_RTL (exp)) == MEM
  4286.       && modifier != EXPAND_CONST_ADDRESS
  4287.       && modifier != EXPAND_SUM
  4288.       && modifier != EXPAND_INITIALIZER
  4289.       && (! memory_address_p (DECL_MODE (exp), XEXP (DECL_RTL (exp), 0))
  4290.           || (flag_force_addr
  4291.           && GET_CODE (XEXP (DECL_RTL (exp), 0)) != REG)))
  4292. #ifdef WIN32
  4293.     {
  4294.       rtx addr = 
  4295. #else
  4296.     return
  4297. #endif
  4298.       change_address (DECL_RTL (exp), VOIDmode,
  4299.               copy_rtx (XEXP (DECL_RTL (exp), 0)));
  4300. #ifdef WIN32
  4301.       if (DECL_DLLIMPORT (exp))
  4302.         addr = gen_rtx (MEM, Pmode, force_reg (Pmode, addr));
  4303.       return addr;
  4304.     }
  4305. #endif
  4306.  
  4307.       /* If the mode of DECL_RTL does not match that of the decl, it
  4308.      must be a promoted value.  We return a SUBREG of the wanted mode,
  4309.      but mark it so that we know that it was already extended.  */
  4310.  
  4311.       if (GET_CODE (DECL_RTL (exp)) == REG
  4312.       && GET_MODE (DECL_RTL (exp)) != mode)
  4313.     {
  4314.       /* Get the signedness used for this variable.  Ensure we get the
  4315.          same mode we got when the variable was declared.  */
  4316.       if (GET_MODE (DECL_RTL (exp))
  4317.           != promote_mode (type, DECL_MODE (exp), &unsignedp, 0))
  4318.         abort ();
  4319.  
  4320.       temp = gen_rtx (SUBREG, mode, DECL_RTL (exp), 0);
  4321.       SUBREG_PROMOTED_VAR_P (temp) = 1;
  4322.       SUBREG_PROMOTED_UNSIGNED_P (temp) = unsignedp;
  4323. #ifdef WIN32
  4324.           if (DECL_DLLIMPORT (exp))
  4325.         {
  4326.             temp = gen_rtx (MEM, Pmode, force_reg (Pmode, temp));
  4327.           }
  4328. #endif
  4329.       return temp;
  4330.     }
  4331. #ifdef WIN32
  4332.     {
  4333.         rtx loc = DECL_RTL (exp);
  4334.  
  4335.           if (DECL_DLLIMPORT (exp))
  4336.         {
  4337.             rtx addr = copy_rtx (loc);
  4338.  
  4339.             if (modifier == EXPAND_INITIALIZER)
  4340.                 fatal ("dllimport'ed value used as initializer");
  4341.     
  4342.             PUT_MODE (addr, Pmode);
  4343.  
  4344.             loc = gen_rtx (MEM, GET_MODE (loc), force_reg (Pmode, addr));
  4345.           }
  4346.         return loc;
  4347.     }
  4348. #endif
  4349.  
  4350. #ifdef NEXT_SEMANTICS
  4351.       if (code == VAR_DECL 
  4352.       && modifier == EXPAND_NORMAL
  4353.       && DECL_RELATIVE (exp))
  4354.     {
  4355.       rtx op0 = memory_address (mode, XEXP (DECL_RTL (exp), 0));
  4356.       rtx op1 = gen_rtx (PLUS, mode, op0, DECL_RTL (exp));
  4357.       temp = gen_rtx (MEM, mode, memory_address (mode, op1));
  4358.       MEM_IN_STRUCT_P (temp) = 1;
  4359.       MEM_VOLATILE_P (temp) = TREE_THIS_VOLATILE (exp);
  4360.       return temp;
  4361.     }
  4362.       else
  4363. #endif
  4364.       return DECL_RTL (exp);
  4365.  
  4366.     case INTEGER_CST:
  4367.       return immed_double_const (TREE_INT_CST_LOW (exp),
  4368.                  TREE_INT_CST_HIGH (exp),
  4369.                  mode);
  4370.  
  4371.     case CONST_DECL:
  4372.       return expand_expr (DECL_INITIAL (exp), target, VOIDmode, 0);
  4373.  
  4374.     case REAL_CST:
  4375.       /* If optimized, generate immediate CONST_DOUBLE
  4376.      which will be turned into memory by reload if necessary. 
  4377.      
  4378.      We used to force a register so that loop.c could see it.  But
  4379.      this does not allow gen_* patterns to perform optimizations with
  4380.      the constants.  It also produces two insns in cases like "x = 1.0;".
  4381.      On most machines, floating-point constants are not permitted in
  4382.      many insns, so we'd end up copying it to a register in any case.
  4383.  
  4384.      Now, we do the copying in expand_binop, if appropriate.  */
  4385.       return immed_real_const (exp);
  4386.  
  4387.     case COMPLEX_CST:
  4388.     case STRING_CST:
  4389.       if (! TREE_CST_RTL (exp))
  4390.     output_constant_def (exp);
  4391.  
  4392.       /* TREE_CST_RTL probably contains a constant address.
  4393.      On RISC machines where a constant address isn't valid,
  4394.      make some insns to get that address into a register.  */
  4395.       if (GET_CODE (TREE_CST_RTL (exp)) == MEM
  4396.       && modifier != EXPAND_CONST_ADDRESS
  4397.       && modifier != EXPAND_INITIALIZER
  4398.       && modifier != EXPAND_SUM
  4399.       && (! memory_address_p (mode, XEXP (TREE_CST_RTL (exp), 0))
  4400.           || (flag_force_addr
  4401.           && GET_CODE (XEXP (TREE_CST_RTL (exp), 0)) != REG)))
  4402.     return change_address (TREE_CST_RTL (exp), VOIDmode,
  4403.                    copy_rtx (XEXP (TREE_CST_RTL (exp), 0)));
  4404.       return TREE_CST_RTL (exp);
  4405.  
  4406.     case SAVE_EXPR:
  4407.       context = decl_function_context (exp);
  4408.  
  4409.       /* We treat inline_function_decl as an alias for the current function
  4410.      because that is the inline function whose vars, types, etc.
  4411.      are being merged into the current function.
  4412.      See expand_inline_function.  */
  4413.       if (context == current_function_decl || context == inline_function_decl)
  4414.     context = 0;
  4415.  
  4416.       /* If this is non-local, handle it.  */
  4417.       if (context)
  4418.     {
  4419.       temp = SAVE_EXPR_RTL (exp);
  4420.       if (temp && GET_CODE (temp) == REG)
  4421.         {
  4422.           put_var_into_stack (exp);
  4423.           temp = SAVE_EXPR_RTL (exp);
  4424.         }
  4425.       if (temp == 0 || GET_CODE (temp) != MEM)
  4426.         abort ();
  4427.       return change_address (temp, mode,
  4428.                  fix_lexical_addr (XEXP (temp, 0), exp));
  4429.     }
  4430.       if (SAVE_EXPR_RTL (exp) == 0)
  4431.     {
  4432.       if (mode == BLKmode)
  4433.         {
  4434.           temp
  4435.         = assign_stack_temp (mode, int_size_in_bytes (type), 0);
  4436.           MEM_IN_STRUCT_P (temp) = AGGREGATE_TYPE_P (type);
  4437.         }
  4438.       else if (mode == VOIDmode)
  4439.         temp = const0_rtx;
  4440.       else
  4441.         temp = gen_reg_rtx (promote_mode (type, mode, &unsignedp, 0));
  4442.  
  4443.       SAVE_EXPR_RTL (exp) = temp;
  4444.       if (!optimize && GET_CODE (temp) == REG)
  4445.         save_expr_regs = gen_rtx (EXPR_LIST, VOIDmode, temp,
  4446.                       save_expr_regs);
  4447.  
  4448.       /* If the mode of TEMP does not match that of the expression, it
  4449.          must be a promoted value.  We pass store_expr a SUBREG of the
  4450.          wanted mode but mark it so that we know that it was already
  4451.          extended.  Note that `unsignedp' was modified above in
  4452.          this case.  */
  4453.  
  4454.       if (GET_CODE (temp) == REG && GET_MODE (temp) != mode)
  4455.         {
  4456.           temp = gen_rtx (SUBREG, mode, SAVE_EXPR_RTL (exp), 0);
  4457.           SUBREG_PROMOTED_VAR_P (temp) = 1;
  4458.           SUBREG_PROMOTED_UNSIGNED_P (temp) = unsignedp;
  4459.         }
  4460.  
  4461.       if (temp == const0_rtx)
  4462.         expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0);
  4463.       else
  4464.         store_expr (TREE_OPERAND (exp, 0), temp, 0);
  4465.     }
  4466.  
  4467.       /* If the mode of SAVE_EXPR_RTL does not match that of the expression, it
  4468.      must be a promoted value.  We return a SUBREG of the wanted mode,
  4469.      but mark it so that we know that it was already extended. */
  4470.  
  4471.       if (GET_CODE (SAVE_EXPR_RTL (exp)) == REG
  4472.       && GET_MODE (SAVE_EXPR_RTL (exp)) != mode)
  4473.     {
  4474.       /* Compute the signedness and make the proper SUBREG.  */
  4475.       promote_mode (type, mode, &unsignedp, 0);
  4476.       temp = gen_rtx (SUBREG, mode, SAVE_EXPR_RTL (exp), 0);
  4477.       SUBREG_PROMOTED_VAR_P (temp) = 1;
  4478.       SUBREG_PROMOTED_UNSIGNED_P (temp) = unsignedp;
  4479.       return temp;
  4480.     }
  4481.  
  4482.       return SAVE_EXPR_RTL (exp);
  4483.  
  4484.     case PLACEHOLDER_EXPR:
  4485.       /* If there is an object on the head of the placeholder list,
  4486.      see if some object in it's references is of type TYPE.  For
  4487.      further information, see tree.def.  */
  4488.       if (placeholder_list)
  4489.     {
  4490.       tree object;
  4491.       tree old_list = placeholder_list;
  4492.  
  4493.       for (object = TREE_PURPOSE (placeholder_list);
  4494.            (TYPE_MAIN_VARIANT (TREE_TYPE (object))
  4495.         != TYPE_MAIN_VARIANT (type))
  4496.            && (TREE_CODE_CLASS (TREE_CODE (object)) == 'r'
  4497.            || TREE_CODE_CLASS (TREE_CODE (object)) == '1'
  4498.            || TREE_CODE_CLASS (TREE_CODE (object)) == '2'
  4499.            || TREE_CODE_CLASS (TREE_CODE (object)) == 'e');
  4500.            object = TREE_OPERAND (object, 0))
  4501.         ;
  4502.  
  4503.       if (object != 0
  4504.           && (TYPE_MAIN_VARIANT (TREE_TYPE (object))
  4505.           == TYPE_MAIN_VARIANT (type)))
  4506.         {
  4507.           /* Expand this object skipping the list entries before
  4508.          it was found in case it is also a PLACEHOLDER_EXPR.
  4509.          In that case, we want to translate it using subsequent
  4510.          entries.  */
  4511.           placeholder_list = TREE_CHAIN (placeholder_list);
  4512.           temp = expand_expr (object, original_target, tmode, modifier);
  4513.           placeholder_list = old_list;
  4514.           return temp;
  4515.         }
  4516.     }
  4517.  
  4518.       /* We can't find the object or there was a missing WITH_RECORD_EXPR.  */
  4519.       abort ();
  4520.  
  4521.     case WITH_RECORD_EXPR:
  4522.       /* Put the object on the placeholder list, expand our first operand,
  4523.      and pop the list.  */
  4524.       placeholder_list = tree_cons (TREE_OPERAND (exp, 1), NULL_TREE,
  4525.                     placeholder_list);
  4526.       target = expand_expr (TREE_OPERAND (exp, 0), original_target,
  4527.                 tmode, modifier);
  4528.       placeholder_list = TREE_CHAIN (placeholder_list);
  4529.       return target;
  4530.  
  4531.     case EXIT_EXPR:
  4532.       expand_exit_loop_if_false (NULL_PTR,
  4533.                  invert_truthvalue (TREE_OPERAND (exp, 0)));
  4534.       return const0_rtx;
  4535.  
  4536.     case LOOP_EXPR:
  4537.       push_temp_slots ();
  4538.       expand_start_loop (1);
  4539.       expand_expr_stmt (TREE_OPERAND (exp, 0));
  4540.       expand_end_loop ();
  4541.       pop_temp_slots ();
  4542.  
  4543.       return const0_rtx;
  4544.  
  4545.     case BIND_EXPR:
  4546.       {
  4547.     tree vars = TREE_OPERAND (exp, 0);
  4548.     int vars_need_expansion = 0;
  4549.  
  4550.     /* Need to open a binding contour here because
  4551.        if there are any cleanups they most be contained here.  */
  4552.     expand_start_bindings (0);
  4553.  
  4554.     /* Mark the corresponding BLOCK for output in its proper place.  */
  4555.     if (TREE_OPERAND (exp, 2) != 0
  4556.         && ! TREE_USED (TREE_OPERAND (exp, 2)))
  4557.       insert_block (TREE_OPERAND (exp, 2));
  4558.  
  4559.     /* If VARS have not yet been expanded, expand them now.  */
  4560.     while (vars)
  4561.       {
  4562.         if (DECL_RTL (vars) == 0)
  4563.           {
  4564.         vars_need_expansion = 1;
  4565.         expand_decl (vars);
  4566.           }
  4567.         expand_decl_init (vars);
  4568.         vars = TREE_CHAIN (vars);
  4569.       }
  4570.  
  4571.     temp = expand_expr (TREE_OPERAND (exp, 1), target, tmode, modifier);
  4572.  
  4573.     expand_end_bindings (TREE_OPERAND (exp, 0), 0, 0);
  4574.  
  4575.     return temp;
  4576.       }
  4577.  
  4578.     case RTL_EXPR:
  4579.       if (RTL_EXPR_SEQUENCE (exp) == const0_rtx)
  4580.     abort ();
  4581.       emit_insns (RTL_EXPR_SEQUENCE (exp));
  4582.       RTL_EXPR_SEQUENCE (exp) = const0_rtx;
  4583. #ifndef NEXT_SEMANTICS
  4584.       preserve_rtl_expr_result (RTL_EXPR_RTL (exp));
  4585. #endif
  4586.       free_temps_for_rtl_expr (exp);
  4587.       return RTL_EXPR_RTL (exp);
  4588.  
  4589.     case CONSTRUCTOR:
  4590.       /* If we don't need the result, just ensure we evaluate any
  4591.      subexpressions.  */
  4592.       if (ignore)
  4593.     {
  4594.       tree elt;
  4595.       for (elt = CONSTRUCTOR_ELTS (exp); elt; elt = TREE_CHAIN (elt))
  4596.         expand_expr (TREE_VALUE (elt), const0_rtx, VOIDmode, 0);
  4597.       return const0_rtx;
  4598.     }
  4599.  
  4600.       /* All elts simple constants => refer to a constant in memory.  But
  4601.      if this is a non-BLKmode mode, let it store a field at a time
  4602.      since that should make a CONST_INT or CONST_DOUBLE when we
  4603.      fold.  Likewise, if we have a target we can use, it is best to
  4604.      store directly into the target unless the type is large enough
  4605.      that memcpy will be used.  If we are making an initializer and
  4606.      all operands are constant, put it in memory as well.  */
  4607.       else if ((TREE_STATIC (exp)
  4608.         && ((mode == BLKmode
  4609.              && ! (target != 0 && safe_from_p (target, exp)))
  4610.             || TREE_ADDRESSABLE (exp)
  4611.             || (TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
  4612.             && (move_by_pieces_ninsns
  4613.                 (TREE_INT_CST_LOW (TYPE_SIZE (type))/BITS_PER_UNIT,
  4614.                  TYPE_ALIGN (type) / BITS_PER_UNIT)
  4615.                 > MOVE_RATIO))))
  4616.            || (modifier == EXPAND_INITIALIZER && TREE_CONSTANT (exp)))
  4617.     {
  4618.       rtx constructor = output_constant_def (exp);
  4619.       if (modifier != EXPAND_CONST_ADDRESS
  4620.           && modifier != EXPAND_INITIALIZER
  4621.           && modifier != EXPAND_SUM
  4622.           && (! memory_address_p (GET_MODE (constructor),
  4623.                       XEXP (constructor, 0))
  4624.           || (flag_force_addr
  4625.               && GET_CODE (XEXP (constructor, 0)) != REG)))
  4626.         constructor = change_address (constructor, VOIDmode,
  4627.                       XEXP (constructor, 0));
  4628.       return constructor;
  4629.     }
  4630.  
  4631.       else
  4632.     {
  4633.       if (target == 0 || ! safe_from_p (target, exp))
  4634.         {
  4635.           if (mode != BLKmode && ! TREE_ADDRESSABLE (exp))
  4636.         target = gen_reg_rtx (tmode != VOIDmode ? tmode : mode);
  4637.           else
  4638.         {
  4639.           target
  4640.             = assign_stack_temp (mode, int_size_in_bytes (type), 0);
  4641.           if (AGGREGATE_TYPE_P (type))
  4642.             MEM_IN_STRUCT_P (target) = 1;
  4643.         }
  4644.         }
  4645.       store_constructor (exp, target);
  4646.       return target;
  4647.     }
  4648.  
  4649.     case INDIRECT_REF:
  4650.       {
  4651.     tree exp1 = TREE_OPERAND (exp, 0);
  4652.     tree exp2;
  4653.  
  4654.     /* A SAVE_EXPR as the address in an INDIRECT_EXPR is generated
  4655.        for  *PTR += ANYTHING  where PTR is put inside the SAVE_EXPR.
  4656.        This code has the same general effect as simply doing
  4657.        expand_expr on the save expr, except that the expression PTR
  4658.        is computed for use as a memory address.  This means different
  4659.        code, suitable for indexing, may be generated.  */
  4660.     if (TREE_CODE (exp1) == SAVE_EXPR
  4661.         && SAVE_EXPR_RTL (exp1) == 0
  4662.         && TYPE_MODE (TREE_TYPE (exp1)) == ptr_mode)
  4663.       {
  4664.         temp = expand_expr (TREE_OPERAND (exp1, 0), NULL_RTX,
  4665.                 VOIDmode, EXPAND_SUM);
  4666.         op0 = memory_address (mode, temp);
  4667.         op0 = copy_all_regs (op0);
  4668.         SAVE_EXPR_RTL (exp1) = op0;
  4669.       }
  4670.     else
  4671.       {
  4672.         op0 = expand_expr (exp1, NULL_RTX, VOIDmode, EXPAND_SUM);
  4673.         op0 = memory_address (mode, op0);
  4674.       }
  4675.  
  4676.     temp = gen_rtx (MEM, mode, op0);
  4677.     /* If address was computed by addition,
  4678.        mark this as an element of an aggregate.  */
  4679.     if (TREE_CODE (TREE_OPERAND (exp, 0)) == PLUS_EXPR
  4680.         || (TREE_CODE (TREE_OPERAND (exp, 0)) == SAVE_EXPR
  4681.         && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) == PLUS_EXPR)
  4682.         || AGGREGATE_TYPE_P (TREE_TYPE (exp))
  4683.         || (TREE_CODE (exp1) == ADDR_EXPR
  4684.         && (exp2 = TREE_OPERAND (exp1, 0))
  4685.         && AGGREGATE_TYPE_P (TREE_TYPE (exp2))))
  4686.       MEM_IN_STRUCT_P (temp) = 1;
  4687.     MEM_VOLATILE_P (temp) = TREE_THIS_VOLATILE (exp) | flag_volatile;
  4688.  
  4689.     /* It is incorrect to set RTX_UNCHANGING_P from TREE_READONLY
  4690.        here, because, in C and C++, the fact that a location is accessed
  4691.        through a pointer to const does not mean that the value there can
  4692.        never change.  Languages where it can never change should
  4693.        also set TREE_STATIC.  */
  4694.     RTX_UNCHANGING_P (temp) = TREE_READONLY (exp) & TREE_STATIC (exp);
  4695.     return temp;
  4696.       }
  4697.  
  4698.     case ARRAY_REF:
  4699.       if (TREE_CODE (TREE_TYPE (TREE_OPERAND (exp, 0))) != ARRAY_TYPE)
  4700.     abort ();
  4701.  
  4702.       {
  4703.     tree array = TREE_OPERAND (exp, 0);
  4704.     tree domain = TYPE_DOMAIN (TREE_TYPE (array));
  4705.     tree low_bound = domain ? TYPE_MIN_VALUE (domain) : integer_zero_node;
  4706.     tree index = TREE_OPERAND (exp, 1);
  4707.     tree index_type = TREE_TYPE (index);
  4708.     int i;
  4709.  
  4710.     if (TREE_CODE (low_bound) != INTEGER_CST
  4711.         && contains_placeholder_p (low_bound))
  4712.       low_bound = build (WITH_RECORD_EXPR, sizetype, low_bound, exp);
  4713.  
  4714.     /* Optimize the special-case of a zero lower bound.
  4715.  
  4716.        We convert the low_bound to sizetype to avoid some problems
  4717.        with constant folding.  (E.g. suppose the lower bound is 1,
  4718.        and its mode is QI.  Without the conversion,  (ARRAY
  4719.        +(INDEX-(unsigned char)1)) becomes ((ARRAY+(-(unsigned char)1))
  4720.        +INDEX), which becomes (ARRAY+255+INDEX).  Oops!)
  4721.  
  4722.        But sizetype isn't quite right either (especially if
  4723.        the lowbound is negative).  FIXME */
  4724.  
  4725.     if (! integer_zerop (low_bound))
  4726.       index = fold (build (MINUS_EXPR, index_type, index,
  4727.                    convert (sizetype, low_bound)));
  4728.  
  4729.     if ((TREE_CODE (index) != INTEGER_CST
  4730.          || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
  4731.         && (! SLOW_UNALIGNED_ACCESS || ! get_inner_unaligned_p (exp)))
  4732.       {
  4733.         /* Nonconstant array index or nonconstant element size, and
  4734.            not an array in an unaligned (packed) structure field.
  4735.            Generate the tree for *(&array+index) and expand that,
  4736.            except do it in a language-independent way
  4737.            and don't complain about non-lvalue arrays.
  4738.            `mark_addressable' should already have been called
  4739.            for any array for which this case will be reached.  */
  4740.  
  4741.         /* Don't forget the const or volatile flag from the array
  4742.            element. */
  4743.         tree variant_type = build_type_variant (type,
  4744.                             TREE_READONLY (exp),
  4745.                             TREE_THIS_VOLATILE (exp));
  4746.         tree array_adr = build1 (ADDR_EXPR,
  4747.                      build_pointer_type (variant_type), array);
  4748.         tree elt;
  4749.         tree size = size_in_bytes (type);
  4750.  
  4751.         /* Convert the integer argument to a type the same size as sizetype
  4752.            so the multiply won't overflow spuriously.  */
  4753.         if (TYPE_PRECISION (index_type) != TYPE_PRECISION (sizetype))
  4754.           index = convert (type_for_size (TYPE_PRECISION (sizetype), 0),
  4755.                    index);
  4756.  
  4757.         if (TREE_CODE (size) != INTEGER_CST
  4758.         && contains_placeholder_p (size))
  4759.           size = build (WITH_RECORD_EXPR, sizetype, size, exp);
  4760.  
  4761.         /* Don't think the address has side effects
  4762.            just because the array does.
  4763.            (In some cases the address might have side effects,
  4764.            and we fail to record that fact here.  However, it should not
  4765.            matter, since expand_expr should not care.)  */
  4766.         TREE_SIDE_EFFECTS (array_adr) = 0;
  4767.  
  4768.         elt
  4769.           = build1
  4770.         (INDIRECT_REF, type,
  4771.          fold (build (PLUS_EXPR,
  4772.                   TYPE_POINTER_TO (variant_type),
  4773.                   array_adr,
  4774.                   fold
  4775.                   (build1
  4776.                    (NOP_EXPR,
  4777.                 TYPE_POINTER_TO (variant_type),
  4778.                 fold (build (MULT_EXPR, TREE_TYPE (index),
  4779.                          index,
  4780.                          convert (TREE_TYPE (index),
  4781.                               size))))))));;
  4782.  
  4783.         /* Volatility, etc., of new expression is same as old
  4784.            expression.  */
  4785.         TREE_SIDE_EFFECTS (elt) = TREE_SIDE_EFFECTS (exp);
  4786.         TREE_THIS_VOLATILE (elt) = TREE_THIS_VOLATILE (exp);
  4787.         TREE_READONLY (elt) = TREE_READONLY (exp);
  4788.  
  4789.         return expand_expr (elt, target, tmode, modifier);
  4790.       }
  4791.  
  4792.     /* Fold an expression like: "foo"[2].
  4793.        This is not done in fold so it won't happen inside &.
  4794.        Don't fold if this is for wide characters since it's too
  4795.        difficult to do correctly and this is a very rare case.  */
  4796.  
  4797.     if (TREE_CODE (array) == STRING_CST
  4798.         && TREE_CODE (index) == INTEGER_CST
  4799.         && !TREE_INT_CST_HIGH (index)
  4800.         && (i = TREE_INT_CST_LOW (index)) < TREE_STRING_LENGTH (array)
  4801.         && GET_MODE_CLASS (mode) == MODE_INT
  4802.         && GET_MODE_SIZE (mode) == 1)
  4803.       return GEN_INT (TREE_STRING_POINTER (array)[i]);
  4804.  
  4805.     /* If this is a constant index into a constant array,
  4806.        just get the value from the array.  Handle both the cases when
  4807.        we have an explicit constructor and when our operand is a variable
  4808.        that was declared const.  */
  4809.  
  4810.     if (TREE_CODE (array) == CONSTRUCTOR && ! TREE_SIDE_EFFECTS (array))
  4811.       {
  4812.         if (TREE_CODE (index) == INTEGER_CST
  4813.         && TREE_INT_CST_HIGH (index) == 0)
  4814.           {
  4815.         tree elem = CONSTRUCTOR_ELTS (TREE_OPERAND (exp, 0));
  4816.  
  4817.         i = TREE_INT_CST_LOW (index);
  4818.         while (elem && i--)
  4819.           elem = TREE_CHAIN (elem);
  4820.         if (elem)
  4821.           return expand_expr (fold (TREE_VALUE (elem)), target,
  4822.                       tmode, modifier);
  4823.           }
  4824.       }
  4825.       
  4826.     else if (optimize >= 1
  4827.          && TREE_READONLY (array) && ! TREE_SIDE_EFFECTS (array)
  4828.          && TREE_CODE (array) == VAR_DECL && DECL_INITIAL (array)
  4829.          && TREE_CODE (DECL_INITIAL (array)) != ERROR_MARK)
  4830.       {
  4831.         if (TREE_CODE (index) == INTEGER_CST
  4832.         && TREE_INT_CST_HIGH (index) == 0)
  4833.           {
  4834.         tree init = DECL_INITIAL (array);
  4835.  
  4836.         i = TREE_INT_CST_LOW (index);
  4837.         if (TREE_CODE (init) == CONSTRUCTOR)
  4838.           {
  4839.             tree elem = CONSTRUCTOR_ELTS (init);
  4840.  
  4841.             while (elem
  4842.                && !tree_int_cst_equal (TREE_PURPOSE (elem), index))
  4843.               elem = TREE_CHAIN (elem);
  4844.             if (elem)
  4845.               return expand_expr (fold (TREE_VALUE (elem)), target,
  4846.                       tmode, modifier);
  4847.           }
  4848.         else if (TREE_CODE (init) == STRING_CST
  4849.              && i < TREE_STRING_LENGTH (init))
  4850.           return GEN_INT (TREE_STRING_POINTER (init)[i]);
  4851.           }
  4852.       }
  4853.       }
  4854.  
  4855.       /* Treat array-ref with constant index as a component-ref.  */
  4856.  
  4857.     case COMPONENT_REF:
  4858. #ifdef NEXT_SEMANTICS
  4859.       /* Treat union-cast as an ordinary cast, i.e. translate
  4860.        * "((union foo*)X)->elem" into "*(typeof (foo.elem)*)X",
  4861.        * so that MEM_IN_STRUCT_P will not be set for the resulting rtl.
  4862.        */
  4863.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == INDIRECT_REF
  4864.       && TREE_CODE (TREE_TYPE (TREE_OPERAND (exp, 0))) == UNION_TYPE
  4865.       && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) == NOP_EXPR)
  4866.     {
  4867.       tree addr = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (exp, 0), 0), 0);
  4868.       tree casted_type = build_pointer_type (TREE_TYPE (exp));
  4869.       tree casted_addr = build1 (NOP_EXPR, casted_type, addr);
  4870.       return expand_expr (build1 (INDIRECT_REF, TREE_TYPE (exp), casted_addr),
  4871.                   target, tmode, modifier);
  4872.     }
  4873. #endif
  4874.     case BIT_FIELD_REF:
  4875.       /* If the operand is a CONSTRUCTOR, we can just extract the
  4876.      appropriate field if it is present.  Don't do this if we have
  4877.      already written the data since we want to refer to that copy
  4878.      and varasm.c assumes that's what we'll do.  */
  4879.       if (code != ARRAY_REF
  4880.       && TREE_CODE (TREE_OPERAND (exp, 0)) == CONSTRUCTOR
  4881.       && TREE_CST_RTL (TREE_OPERAND (exp, 0)) == 0)
  4882.     {
  4883.       tree elt;
  4884.  
  4885.       for (elt = CONSTRUCTOR_ELTS (TREE_OPERAND (exp, 0)); elt;
  4886.            elt = TREE_CHAIN (elt))
  4887.         if (TREE_PURPOSE (elt) == TREE_OPERAND (exp, 1))
  4888.           return expand_expr (TREE_VALUE (elt), target, tmode, modifier);
  4889.     }
  4890.  
  4891.       {
  4892.     enum machine_mode mode1;
  4893.     int bitsize;
  4894.     int bitpos;
  4895.     tree offset;
  4896.     int volatilep = 0;
  4897.     tree tem = get_inner_reference (exp, &bitsize, &bitpos, &offset,
  4898.                     &mode1, &unsignedp, &volatilep);
  4899.     int alignment;
  4900.  
  4901.     /* If we got back the original object, something is wrong.  Perhaps
  4902.        we are evaluating an expression too early.  In any event, don't
  4903.        infinitely recurse.  */
  4904.     if (tem == exp)
  4905.       abort ();
  4906.  
  4907.     /* In some cases, we will be offsetting OP0's address by a constant.
  4908.        So get it as a sum, if possible.  If we will be using it
  4909.        directly in an insn, we validate it. 
  4910.  
  4911.        If TEM's type is a union of variable size, pass TARGET to the inner
  4912.        computation, since it will need a temporary and TARGET is known
  4913.        to have to do.  This occurs in unchecked conversion in Ada.  */
  4914.   
  4915.     op0 = expand_expr (tem,
  4916.                (TREE_CODE (TREE_TYPE (tem)) == UNION_TYPE
  4917.                 && (TREE_CODE (TYPE_SIZE (TREE_TYPE (tem)))
  4918.                 != INTEGER_CST)
  4919.                 ? target : NULL_RTX),
  4920.                VOIDmode, EXPAND_SUM);
  4921.  
  4922.     /* If this is a constant, put it into a register if it is a
  4923.        legitimate constant and memory if it isn't.  */
  4924.     if (CONSTANT_P (op0))
  4925.       {
  4926.         enum machine_mode mode = TYPE_MODE (TREE_TYPE (tem));
  4927.         if (mode != BLKmode && LEGITIMATE_CONSTANT_P (op0))
  4928.           op0 = force_reg (mode, op0);
  4929.         else
  4930.           op0 = validize_mem (force_const_mem (mode, op0));
  4931.       }
  4932.  
  4933.     alignment = TYPE_ALIGN (TREE_TYPE (tem)) / BITS_PER_UNIT;
  4934.     if (offset != 0)
  4935.       {
  4936.         rtx offset_rtx = expand_expr (offset, NULL_RTX, VOIDmode, 0);
  4937.  
  4938.         if (GET_CODE (op0) != MEM)
  4939.           abort ();
  4940.         op0 = change_address (op0, VOIDmode,
  4941.                   gen_rtx (PLUS, ptr_mode, XEXP (op0, 0),
  4942.                        force_reg (ptr_mode, offset_rtx)));
  4943.       /* If we have a variable offset, the known alignment
  4944.          is only that of the innermost structure containing the field.
  4945.          (Actually, we could sometimes do better by using the
  4946.          size of an element of the innermost array, but no need.)  */
  4947.       if (TREE_CODE (exp) == COMPONENT_REF
  4948.           || TREE_CODE (exp) == BIT_FIELD_REF)
  4949.         alignment = (TYPE_ALIGN (TREE_TYPE (TREE_OPERAND (exp, 0)))
  4950.              / BITS_PER_UNIT);
  4951.       }
  4952.  
  4953.     /* Don't forget about volatility even if this is a bitfield.  */
  4954.     if (GET_CODE (op0) == MEM && volatilep && ! MEM_VOLATILE_P (op0))
  4955.       {
  4956.         op0 = copy_rtx (op0);
  4957.         MEM_VOLATILE_P (op0) = 1;
  4958.       }
  4959.  
  4960.     /* In cases where an aligned union has an unaligned object
  4961.        as a field, we might be extracting a BLKmode value from
  4962.        an integer-mode (e.g., SImode) object.  Handle this case
  4963.        by doing the extract into an object as wide as the field
  4964.        (which we know to be the width of a basic mode), then
  4965.        storing into memory, and changing the mode to BLKmode.  */
  4966.     if (mode1 == VOIDmode
  4967.         || GET_CODE (op0) == REG || GET_CODE (op0) == SUBREG
  4968.         || (modifier != EXPAND_CONST_ADDRESS
  4969.         && modifier != EXPAND_SUM
  4970.         && modifier != EXPAND_INITIALIZER
  4971.         && ((mode1 != BLKmode && ! direct_load[(int) mode1])
  4972.             /* If the field isn't aligned enough to fetch as a memref,
  4973.                fetch it as a bit field.  */
  4974.             || (SLOW_UNALIGNED_ACCESS
  4975.             && ((TYPE_ALIGN (TREE_TYPE (tem)) < GET_MODE_ALIGNMENT (mode))
  4976.                 || (bitpos % GET_MODE_ALIGNMENT (mode) != 0))))))
  4977.       {
  4978.         enum machine_mode ext_mode = mode;
  4979.  
  4980.         if (ext_mode == BLKmode)
  4981.           ext_mode = mode_for_size (bitsize, MODE_INT, 1);
  4982.  
  4983.         if (ext_mode == BLKmode)
  4984.           abort ();
  4985.  
  4986.         op0 = extract_bit_field (validize_mem (op0), bitsize, bitpos,
  4987.                      unsignedp, target, ext_mode, ext_mode,
  4988.                      alignment,
  4989.                      int_size_in_bytes (TREE_TYPE (tem)));
  4990.         if (mode == BLKmode)
  4991.           {
  4992.         rtx new = assign_stack_temp (ext_mode,
  4993.                          bitsize / BITS_PER_UNIT, 0);
  4994.  
  4995.         emit_move_insn (new, op0);
  4996.         op0 = copy_rtx (new);
  4997.         PUT_MODE (op0, BLKmode);
  4998.         MEM_IN_STRUCT_P (op0) = 1;
  4999.           }
  5000.  
  5001.         return op0;
  5002.       }
  5003.  
  5004.     /* Get a reference to just this component.  */
  5005.     if (modifier == EXPAND_CONST_ADDRESS
  5006.         || modifier == EXPAND_SUM || modifier == EXPAND_INITIALIZER)
  5007.       op0 = gen_rtx (MEM, mode1, plus_constant (XEXP (op0, 0),
  5008.                             (bitpos / BITS_PER_UNIT)));
  5009.     else
  5010.       op0 = change_address (op0, mode1,
  5011.                 plus_constant (XEXP (op0, 0),
  5012.                            (bitpos / BITS_PER_UNIT)));
  5013.     MEM_IN_STRUCT_P (op0) = 1;
  5014.     MEM_VOLATILE_P (op0) |= volatilep;
  5015.     if (mode == mode1 || mode1 == BLKmode || mode1 == tmode)
  5016. #ifdef NEXT_SEMANTICS
  5017.       target =
  5018. #else
  5019.       return
  5020. #endif
  5021.         op0;
  5022. #ifdef NEXT_SEMANTICS
  5023.     else 
  5024.       {
  5025. #endif
  5026.     if (target == 0)
  5027.       target = gen_reg_rtx (tmode != VOIDmode ? tmode : mode);
  5028.     convert_move (target, op0, unsignedp);
  5029. #ifdef NEXT_SEMANTICS
  5030.       }
  5031.     if (modifier == EXPAND_NORMAL 
  5032.         && ((TREE_CODE (exp) == VAR_DECL
  5033.          || TREE_CODE (exp) == FIELD_DECL)
  5034.         && DECL_RELATIVE (TREE_OPERAND (exp, 1))))
  5035.       {
  5036.         rtx op0 = memory_address (mode, XEXP (target, 0));
  5037.         rtx op1 = gen_rtx (PLUS, mode, op0, target);
  5038.         temp = gen_rtx (MEM, mode, memory_address (mode, op1));
  5039.         MEM_IN_STRUCT_P (temp) = 1;
  5040.         MEM_VOLATILE_P (temp) = MEM_VOLATILE_P (target);
  5041.         return temp;
  5042.       }
  5043.     else
  5044. #endif
  5045.     return target;
  5046.       }
  5047.  
  5048.     case OFFSET_REF:
  5049.       {
  5050.     tree base = build1 (ADDR_EXPR, type, TREE_OPERAND (exp, 0));
  5051.     tree addr = build (PLUS_EXPR, type, base, TREE_OPERAND (exp, 1));
  5052.     op0 = expand_expr (addr, NULL_RTX, VOIDmode, EXPAND_SUM);
  5053.     temp = gen_rtx (MEM, mode, memory_address (mode, op0));
  5054.     MEM_IN_STRUCT_P (temp) = 1;
  5055.     MEM_VOLATILE_P (temp) = TREE_THIS_VOLATILE (exp);
  5056. #if 0 /* It is incorrect to set RTX_UNCHANGING_P here, because the fact that
  5057.      a location is accessed through a pointer to const does not mean
  5058.      that the value there can never change.  */
  5059.     RTX_UNCHANGING_P (temp) = TREE_READONLY (exp);
  5060. #endif
  5061.     return temp;
  5062.       }
  5063.  
  5064.       /* Intended for a reference to a buffer of a file-object in Pascal.
  5065.      But it's not certain that a special tree code will really be
  5066.      necessary for these.  INDIRECT_REF might work for them.  */
  5067.     case BUFFER_REF:
  5068.       abort ();
  5069.  
  5070.     case IN_EXPR:
  5071.       {
  5072.     /* Pascal set IN expression.
  5073.  
  5074.        Algorithm:
  5075.            rlo       = set_low - (set_low%bits_per_word);
  5076.            the_word  = set [ (index - rlo)/bits_per_word ];
  5077.            bit_index = index % bits_per_word;
  5078.            bitmask   = 1 << bit_index;
  5079.            return !!(the_word & bitmask);  */
  5080.  
  5081.     tree set = TREE_OPERAND (exp, 0);
  5082.     tree index = TREE_OPERAND (exp, 1);
  5083.     int iunsignedp = TREE_UNSIGNED (TREE_TYPE (index));
  5084.     tree set_type = TREE_TYPE (set);
  5085.     tree set_low_bound = TYPE_MIN_VALUE (TYPE_DOMAIN (set_type));
  5086.     tree set_high_bound = TYPE_MAX_VALUE (TYPE_DOMAIN (set_type));
  5087.     rtx index_val = expand_expr (index, 0, VOIDmode, 0);
  5088.     rtx lo_r = expand_expr (set_low_bound, 0, VOIDmode, 0);
  5089.     rtx hi_r = expand_expr (set_high_bound, 0, VOIDmode, 0);
  5090.     rtx setval = expand_expr (set, 0, VOIDmode, 0);
  5091.     rtx setaddr = XEXP (setval, 0);
  5092.     enum machine_mode index_mode = TYPE_MODE (TREE_TYPE (index));
  5093.     rtx rlow;
  5094.     rtx diff, quo, rem, addr, bit, result;
  5095.  
  5096.     preexpand_calls (exp);
  5097.  
  5098.     /* If domain is empty, answer is no.  Likewise if index is constant
  5099.        and out of bounds.  */
  5100.     if ((TREE_CODE (set_high_bound) == INTEGER_CST
  5101.          && TREE_CODE (set_low_bound) == INTEGER_CST
  5102.          && tree_int_cst_lt (set_high_bound, set_low_bound)
  5103.          || (TREE_CODE (index) == INTEGER_CST
  5104.          && TREE_CODE (set_low_bound) == INTEGER_CST
  5105.          && tree_int_cst_lt (index, set_low_bound))
  5106.          || (TREE_CODE (set_high_bound) == INTEGER_CST
  5107.          && TREE_CODE (index) == INTEGER_CST
  5108.          && tree_int_cst_lt (set_high_bound, index))))
  5109.       return const0_rtx;
  5110.  
  5111.     if (target == 0)
  5112.       target = gen_reg_rtx (tmode != VOIDmode ? tmode : mode);
  5113.  
  5114.     /* If we get here, we have to generate the code for both cases
  5115.        (in range and out of range).  */
  5116.  
  5117.     op0 = gen_label_rtx ();
  5118.     op1 = gen_label_rtx ();
  5119.  
  5120.     if (! (GET_CODE (index_val) == CONST_INT
  5121.            && GET_CODE (lo_r) == CONST_INT))
  5122.       {
  5123.         emit_cmp_insn (index_val, lo_r, LT, NULL_RTX,
  5124.                GET_MODE (index_val), iunsignedp, 0);
  5125.         emit_jump_insn (gen_blt (op1));
  5126.       }
  5127.  
  5128.     if (! (GET_CODE (index_val) == CONST_INT
  5129.            && GET_CODE (hi_r) == CONST_INT))
  5130.       {
  5131.         emit_cmp_insn (index_val, hi_r, GT, NULL_RTX,
  5132.                GET_MODE (index_val), iunsignedp, 0);
  5133.         emit_jump_insn (gen_bgt (op1));
  5134.       }
  5135.  
  5136.     /* Calculate the element number of bit zero in the first word
  5137.        of the set.  */
  5138.     if (GET_CODE (lo_r) == CONST_INT)
  5139.       rlow = GEN_INT (INTVAL (lo_r)
  5140.               & ~ ((HOST_WIDE_INT) 1 << BITS_PER_UNIT));
  5141.     else
  5142.       rlow = expand_binop (index_mode, and_optab, lo_r,
  5143.                    GEN_INT (~((HOST_WIDE_INT) 1 << BITS_PER_UNIT)),
  5144.                    NULL_RTX, iunsignedp, OPTAB_LIB_WIDEN);
  5145.  
  5146.     diff = expand_binop (index_mode, sub_optab, index_val, rlow,
  5147.                  NULL_RTX, iunsignedp, OPTAB_LIB_WIDEN);
  5148.  
  5149.     quo = expand_divmod (0, TRUNC_DIV_EXPR, index_mode, diff,
  5150.                  GEN_INT (BITS_PER_UNIT), NULL_RTX, iunsignedp);
  5151.     rem = expand_divmod (1, TRUNC_MOD_EXPR, index_mode, index_val,
  5152.                  GEN_INT (BITS_PER_UNIT), NULL_RTX, iunsignedp);
  5153.  
  5154.     addr = memory_address (byte_mode,
  5155.                    expand_binop (index_mode, add_optab, diff,
  5156.                          setaddr, NULL_RTX, iunsignedp,
  5157.                          OPTAB_LIB_WIDEN));
  5158.  
  5159.     /* Extract the bit we want to examine */
  5160.     bit = expand_shift (RSHIFT_EXPR, byte_mode,
  5161.                 gen_rtx (MEM, byte_mode, addr),
  5162.                 make_tree (TREE_TYPE (index), rem),
  5163.                 NULL_RTX, 1);
  5164.     result = expand_binop (byte_mode, and_optab, bit, const1_rtx,
  5165.                    GET_MODE (target) == byte_mode ? target : 0,
  5166.                    1, OPTAB_LIB_WIDEN);
  5167.  
  5168.     if (result != target)
  5169.       convert_move (target, result, 1);
  5170.  
  5171.     /* Output the code to handle the out-of-range case.  */
  5172.     emit_jump (op0);
  5173.     emit_label (op1);
  5174.     emit_move_insn (target, const0_rtx);
  5175.     emit_label (op0);
  5176.     return target;
  5177.       }
  5178.  
  5179.     case WITH_CLEANUP_EXPR:
  5180.       if (RTL_EXPR_RTL (exp) == 0)
  5181.     {
  5182.       RTL_EXPR_RTL (exp)
  5183.         = expand_expr (TREE_OPERAND (exp, 0), target, tmode, modifier);
  5184.       cleanups_this_call
  5185.         = tree_cons (NULL_TREE, TREE_OPERAND (exp, 2), cleanups_this_call);
  5186.       /* That's it for this cleanup.  */
  5187.       TREE_OPERAND (exp, 2) = 0;
  5188.       (*interim_eh_hook) (NULL_TREE);
  5189.     }
  5190.       return RTL_EXPR_RTL (exp);
  5191.  
  5192.     case CLEANUP_POINT_EXPR:
  5193.       {
  5194.     extern int temp_slot_level;
  5195.     tree old_cleanups = cleanups_this_call;
  5196.     int old_temp_level = target_temp_slot_level;
  5197.     push_temp_slots ();
  5198.     target_temp_slot_level = temp_slot_level;
  5199.     op0 = expand_expr (TREE_OPERAND (exp, 0), target, tmode, modifier);
  5200.     /* If we're going to use this value, load it up now.  */
  5201.     if (! ignore)
  5202.       op0 = force_not_mem (op0);
  5203.     expand_cleanups_to (old_cleanups);
  5204.     preserve_temp_slots (op0);
  5205.     free_temp_slots ();
  5206.     pop_temp_slots ();
  5207.     target_temp_slot_level = old_temp_level;
  5208.       }
  5209.       return op0;
  5210.  
  5211.     case CALL_EXPR:
  5212.       /* Check for a built-in function.  */
  5213.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR
  5214.       && (TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
  5215.           == FUNCTION_DECL)
  5216.       && DECL_BUILT_IN (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
  5217.     return expand_builtin (exp, target, subtarget, tmode, ignore);
  5218.  
  5219.       /* If this call was expanded already by preexpand_calls,
  5220.      just return the result we got.  */
  5221.       if (CALL_EXPR_RTL (exp) != 0)
  5222.     return CALL_EXPR_RTL (exp);
  5223.  
  5224.       return expand_call (exp, target, ignore);
  5225.  
  5226.     case NON_LVALUE_EXPR:
  5227.     case NOP_EXPR:
  5228.     case CONVERT_EXPR:
  5229.     case REFERENCE_EXPR:
  5230.       if (TREE_CODE (type) == UNION_TYPE)
  5231.     {
  5232.       tree valtype = TREE_TYPE (TREE_OPERAND (exp, 0));
  5233.       if (target == 0)
  5234.         {
  5235.           if (mode == BLKmode)
  5236.         {
  5237.           if (TYPE_SIZE (type) == 0
  5238.               || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
  5239.             abort ();
  5240.           target = assign_stack_temp (BLKmode,
  5241.                           (TREE_INT_CST_LOW (TYPE_SIZE (type))
  5242.                            + BITS_PER_UNIT - 1)
  5243.                           / BITS_PER_UNIT, 0);
  5244.           MEM_IN_STRUCT_P (target) = AGGREGATE_TYPE_P (type);
  5245.         }
  5246.           else
  5247.         target = gen_reg_rtx (tmode != VOIDmode ? tmode : mode);
  5248.         }
  5249.  
  5250.       if (GET_CODE (target) == MEM)
  5251.         /* Store data into beginning of memory target.  */
  5252.         store_expr (TREE_OPERAND (exp, 0),
  5253.             change_address (target, TYPE_MODE (valtype), 0), 0);
  5254.  
  5255.       else if (GET_CODE (target) == REG)
  5256.         /* Store this field into a union of the proper type.  */
  5257.         store_field (target, GET_MODE_BITSIZE (TYPE_MODE (valtype)), 0,
  5258.              TYPE_MODE (valtype), TREE_OPERAND (exp, 0),
  5259.              VOIDmode, 0, 1,
  5260.              int_size_in_bytes (TREE_TYPE (TREE_OPERAND (exp, 0))));
  5261.       else
  5262.         abort ();
  5263.  
  5264.       /* Return the entire union.  */
  5265.       return target;
  5266.     }
  5267.  
  5268.       if (mode == TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))
  5269.     {
  5270.       op0 = expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode,
  5271.                  modifier);
  5272.  
  5273.       /* If the signedness of the conversion differs and OP0 is
  5274.          a promoted SUBREG, clear that indication since we now
  5275.          have to do the proper extension.  */
  5276.       if (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))) != unsignedp
  5277.           && GET_CODE (op0) == SUBREG)
  5278.         SUBREG_PROMOTED_VAR_P (op0) = 0;
  5279.  
  5280.       return op0;
  5281.     }
  5282.  
  5283.       op0 = expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, mode, 0);
  5284.       if (GET_MODE (op0) == mode)
  5285.     return op0;
  5286.  
  5287.       /* If OP0 is a constant, just convert it into the proper mode.  */
  5288.       if (CONSTANT_P (op0))
  5289.     return
  5290.       convert_modes (mode, TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))),
  5291.              op0, TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))));
  5292.  
  5293.       if (modifier == EXPAND_INITIALIZER)
  5294.     return gen_rtx (unsignedp ? ZERO_EXTEND : SIGN_EXTEND, mode, op0);
  5295.  
  5296.       if (flag_force_mem && GET_CODE (op0) == MEM)
  5297.     op0 = copy_to_reg (op0);
  5298.  
  5299.       if (target == 0)
  5300.     return
  5301.       convert_to_mode (mode, op0,
  5302.                TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))));
  5303.       else
  5304.     convert_move (target, op0,
  5305.               TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))));
  5306.       return target;
  5307.  
  5308.     case PLUS_EXPR:
  5309.       /* We come here from MINUS_EXPR when the second operand is a constant. */
  5310.     plus_expr:
  5311.       this_optab = add_optab;
  5312.  
  5313.       /* If we are adding a constant, an RTL_EXPR that is sp, fp, or ap, and
  5314.      something else, make sure we add the register to the constant and
  5315.      then to the other thing.  This case can occur during strength
  5316.      reduction and doing it this way will produce better code if the
  5317.      frame pointer or argument pointer is eliminated.
  5318.  
  5319.      fold-const.c will ensure that the constant is always in the inner
  5320.      PLUS_EXPR, so the only case we need to do anything about is if
  5321.      sp, ap, or fp is our second argument, in which case we must swap
  5322.      the innermost first argument and our second argument.  */
  5323.  
  5324.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == PLUS_EXPR
  5325.       && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 1)) == INTEGER_CST
  5326.       && TREE_CODE (TREE_OPERAND (exp, 1)) == RTL_EXPR
  5327.       && (RTL_EXPR_RTL (TREE_OPERAND (exp, 1)) == frame_pointer_rtx
  5328.           || RTL_EXPR_RTL (TREE_OPERAND (exp, 1)) == stack_pointer_rtx
  5329.           || RTL_EXPR_RTL (TREE_OPERAND (exp, 1)) == arg_pointer_rtx))
  5330.     {
  5331.       tree t = TREE_OPERAND (exp, 1);
  5332.  
  5333.       TREE_OPERAND (exp, 1) = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
  5334.       TREE_OPERAND (TREE_OPERAND (exp, 0), 0) = t;
  5335.     }
  5336.  
  5337.       /* If the result is to be ptr_mode and we are adding an integer to
  5338.      something, we might be forming a constant.  So try to use
  5339.      plus_constant.  If it produces a sum and we can't accept it,
  5340.      use force_operand.  This allows P = &ARR[const] to generate
  5341.      efficient code on machines where a SYMBOL_REF is not a valid
  5342.      address.
  5343.  
  5344.      If this is an EXPAND_SUM call, always return the sum.  */
  5345.       if (modifier == EXPAND_SUM || modifier == EXPAND_INITIALIZER
  5346.       || mode == ptr_mode)
  5347.     {
  5348.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == INTEGER_CST
  5349.           && GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT
  5350.           && TREE_CONSTANT (TREE_OPERAND (exp, 1)))
  5351.         {
  5352.           op1 = expand_expr (TREE_OPERAND (exp, 1), subtarget, VOIDmode,
  5353.                  EXPAND_SUM);
  5354.           op1 = plus_constant (op1, TREE_INT_CST_LOW (TREE_OPERAND (exp, 0)));
  5355.           if (modifier != EXPAND_SUM && modifier != EXPAND_INITIALIZER)
  5356.         op1 = force_operand (op1, target);
  5357.           return op1;
  5358.         }
  5359.  
  5360.       else if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST
  5361.            && GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_INT
  5362.            && TREE_CONSTANT (TREE_OPERAND (exp, 0)))
  5363.         {
  5364.           op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode,
  5365.                  EXPAND_SUM);
  5366.           if (! CONSTANT_P (op0))
  5367.         {
  5368.           op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX,
  5369.                      VOIDmode, modifier);
  5370.           /* Don't go to both_summands if modifier
  5371.              says it's not right to return a PLUS.  */
  5372.           if (modifier != EXPAND_SUM && modifier != EXPAND_INITIALIZER)
  5373.             goto binop2;
  5374.           goto both_summands;
  5375.         }
  5376.           op0 = plus_constant (op0, TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)));
  5377.           if (modifier != EXPAND_SUM && modifier != EXPAND_INITIALIZER)
  5378.         op0 = force_operand (op0, target);
  5379.           return op0;
  5380.         }
  5381.     }
  5382.  
  5383.       /* No sense saving up arithmetic to be done
  5384.      if it's all in the wrong mode to form part of an address.
  5385.      And force_operand won't know whether to sign-extend or
  5386.      zero-extend.  */
  5387.       if ((modifier != EXPAND_SUM && modifier != EXPAND_INITIALIZER)
  5388.       || mode != ptr_mode)
  5389.     goto binop;
  5390.  
  5391.       preexpand_calls (exp);
  5392.       if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1)))
  5393.     subtarget = 0;
  5394.  
  5395.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, modifier);
  5396.       op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, modifier);
  5397.  
  5398.     both_summands:
  5399.       /* Make sure any term that's a sum with a constant comes last.  */
  5400.       if (GET_CODE (op0) == PLUS
  5401.       && CONSTANT_P (XEXP (op0, 1)))
  5402.     {
  5403.       temp = op0;
  5404.       op0 = op1;
  5405.       op1 = temp;
  5406.     }
  5407.       /* If adding to a sum including a constant,
  5408.      associate it to put the constant outside.  */
  5409.       if (GET_CODE (op1) == PLUS
  5410.       && CONSTANT_P (XEXP (op1, 1)))
  5411.     {
  5412.       rtx constant_term = const0_rtx;
  5413.  
  5414.       temp = simplify_binary_operation (PLUS, mode, XEXP (op1, 0), op0);
  5415.       if (temp != 0)
  5416.         op0 = temp;
  5417.       /* Ensure that MULT comes first if there is one.  */
  5418.       else if (GET_CODE (op0) == MULT)
  5419.         op0 = gen_rtx (PLUS, mode, op0, XEXP (op1, 0));
  5420.       else
  5421.         op0 = gen_rtx (PLUS, mode, XEXP (op1, 0), op0);
  5422.  
  5423.       /* Let's also eliminate constants from op0 if possible.  */
  5424.       op0 = eliminate_constant_term (op0, &constant_term);
  5425.  
  5426.       /* CONSTANT_TERM and XEXP (op1, 1) are known to be constant, so
  5427.          their sum should be a constant.  Form it into OP1, since the 
  5428.          result we want will then be OP0 + OP1.  */
  5429.  
  5430.       temp = simplify_binary_operation (PLUS, mode, constant_term,
  5431.                         XEXP (op1, 1));
  5432.       if (temp != 0)
  5433.         op1 = temp;
  5434.       else
  5435.         op1 = gen_rtx (PLUS, mode, constant_term, XEXP (op1, 1));
  5436.     }
  5437.  
  5438.       /* Put a constant term last and put a multiplication first.  */
  5439.       if (CONSTANT_P (op0) || GET_CODE (op1) == MULT)
  5440.     temp = op1, op1 = op0, op0 = temp;
  5441.  
  5442.       temp = simplify_binary_operation (PLUS, mode, op0, op1);
  5443.       return temp ? temp : gen_rtx (PLUS, mode, op0, op1);
  5444.  
  5445.     case MINUS_EXPR:
  5446.       /* For initializers, we are allowed to return a MINUS of two
  5447.      symbolic constants.  Here we handle all cases when both operands
  5448.      are constant.  */
  5449.       /* Handle difference of two symbolic constants,
  5450.      for the sake of an initializer.  */
  5451.       if ((modifier == EXPAND_SUM || modifier == EXPAND_INITIALIZER)
  5452.       && really_constant_p (TREE_OPERAND (exp, 0))
  5453.       && really_constant_p (TREE_OPERAND (exp, 1)))
  5454.     {
  5455.       rtx op0 = expand_expr (TREE_OPERAND (exp, 0), NULL_RTX,
  5456.                  VOIDmode, modifier);
  5457.       rtx op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX,
  5458.                  VOIDmode, modifier);
  5459.  
  5460.       /* If the last operand is a CONST_INT, use plus_constant of
  5461.          the negated constant.  Else make the MINUS.  */
  5462.       if (GET_CODE (op1) == CONST_INT)
  5463.         return plus_constant (op0, - INTVAL (op1));
  5464.       else
  5465.         return gen_rtx (MINUS, mode, op0, op1);
  5466.     }
  5467.       /* Convert A - const to A + (-const).  */
  5468.       if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST)
  5469.     {
  5470.       tree negated = fold (build1 (NEGATE_EXPR, type,
  5471.                        TREE_OPERAND (exp, 1)));
  5472.  
  5473.       /* Deal with the case where we can't negate the constant
  5474.          in TYPE.  */
  5475.       if (TREE_UNSIGNED (type) || TREE_OVERFLOW (negated))
  5476.         {
  5477.           tree newtype = signed_type (type);
  5478.           tree newop0 = convert (newtype, TREE_OPERAND (exp, 0));
  5479.           tree newop1 = convert (newtype, TREE_OPERAND (exp, 1));
  5480.           tree newneg = fold (build1 (NEGATE_EXPR, newtype, newop1));
  5481.  
  5482.           if (! TREE_OVERFLOW (newneg))
  5483.         return expand_expr (convert (type, 
  5484.                          build (PLUS_EXPR, newtype,
  5485.                             newop0, newneg)),
  5486.                     target, tmode, modifier);
  5487.         }
  5488.       else
  5489.         {
  5490.           exp = build (PLUS_EXPR, type, TREE_OPERAND (exp, 0), negated);
  5491.           goto plus_expr;
  5492.         }
  5493.     }
  5494.       this_optab = sub_optab;
  5495.       goto binop;
  5496.  
  5497.     case MULT_EXPR:
  5498.       preexpand_calls (exp);
  5499.       /* If first operand is constant, swap them.
  5500.      Thus the following special case checks need only
  5501.      check the second operand.  */
  5502.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == INTEGER_CST)
  5503.     {
  5504.       register tree t1 = TREE_OPERAND (exp, 0);
  5505.       TREE_OPERAND (exp, 0) = TREE_OPERAND (exp, 1);
  5506.       TREE_OPERAND (exp, 1) = t1;
  5507.     }
  5508.  
  5509.       /* Attempt to return something suitable for generating an
  5510.      indexed address, for machines that support that.  */
  5511.  
  5512.       if (modifier == EXPAND_SUM && mode == ptr_mode
  5513.       && TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST
  5514.       && GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT)
  5515.     {
  5516.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, EXPAND_SUM);
  5517.  
  5518.       /* Apply distributive law if OP0 is x+c.  */
  5519.       if (GET_CODE (op0) == PLUS
  5520.           && GET_CODE (XEXP (op0, 1)) == CONST_INT)
  5521.         return gen_rtx (PLUS, mode,
  5522.                 gen_rtx (MULT, mode, XEXP (op0, 0),
  5523.                      GEN_INT (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)))),
  5524.                 GEN_INT (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1))
  5525.                      * INTVAL (XEXP (op0, 1))));
  5526.  
  5527.       if (GET_CODE (op0) != REG)
  5528.         op0 = force_operand (op0, NULL_RTX);
  5529.       if (GET_CODE (op0) != REG)
  5530.         op0 = copy_to_mode_reg (mode, op0);
  5531.  
  5532.       return gen_rtx (MULT, mode, op0,
  5533.               GEN_INT (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1))));
  5534.     }
  5535.  
  5536.       if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1)))
  5537.     subtarget = 0;
  5538.  
  5539.       /* Check for multiplying things that have been extended
  5540.      from a narrower type.  If this machine supports multiplying
  5541.      in that narrower type with a result in the desired type,
  5542.      do it that way, and avoid the explicit type-conversion.  */
  5543.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == NOP_EXPR
  5544.       && TREE_CODE (type) == INTEGER_TYPE
  5545.       && (TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
  5546.           < TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (exp, 0))))
  5547.       && ((TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST
  5548.            && int_fits_type_p (TREE_OPERAND (exp, 1),
  5549.                    TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
  5550.            /* Don't use a widening multiply if a shift will do.  */
  5551.            && ((GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 1))))
  5552.             > HOST_BITS_PER_WIDE_INT)
  5553.            || exact_log2 (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1))) < 0))
  5554.           ||
  5555.           (TREE_CODE (TREE_OPERAND (exp, 1)) == NOP_EXPR
  5556.            && (TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 1), 0)))
  5557.            ==
  5558.            TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))))
  5559.            /* If both operands are extended, they must either both
  5560.           be zero-extended or both be sign-extended.  */
  5561.            && (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 1), 0)))
  5562.            ==
  5563.            TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))))))
  5564.     {
  5565.       enum machine_mode innermode
  5566.         = TYPE_MODE (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)));
  5567.       this_optab = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
  5568.             ? umul_widen_optab : smul_widen_optab);
  5569.       if (mode == GET_MODE_WIDER_MODE (innermode)
  5570.           && this_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing)
  5571.         {
  5572.           op0 = expand_expr (TREE_OPERAND (TREE_OPERAND (exp, 0), 0),
  5573.                  NULL_RTX, VOIDmode, 0);
  5574.           if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST)
  5575.         op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX,
  5576.                    VOIDmode, 0);
  5577.           else
  5578.         op1 = expand_expr (TREE_OPERAND (TREE_OPERAND (exp, 1), 0),
  5579.                    NULL_RTX, VOIDmode, 0);
  5580.           goto binop2;
  5581.         }
  5582.     }
  5583.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  5584.       op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0);
  5585.       return expand_mult (mode, op0, op1, target, unsignedp);
  5586.  
  5587.     case TRUNC_DIV_EXPR:
  5588.     case FLOOR_DIV_EXPR:
  5589.     case CEIL_DIV_EXPR:
  5590.     case ROUND_DIV_EXPR:
  5591.     case EXACT_DIV_EXPR:
  5592.       preexpand_calls (exp);
  5593.       if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1)))
  5594.     subtarget = 0;
  5595.       /* Possible optimization: compute the dividend with EXPAND_SUM
  5596.      then if the divisor is constant can optimize the case
  5597.      where some terms of the dividend have coeffs divisible by it.  */
  5598.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  5599.       op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0);
  5600.       return expand_divmod (0, code, mode, op0, op1, target, unsignedp);
  5601.  
  5602.     case RDIV_EXPR:
  5603.       this_optab = flodiv_optab;
  5604.       goto binop;
  5605.  
  5606.     case TRUNC_MOD_EXPR:
  5607.     case FLOOR_MOD_EXPR:
  5608.     case CEIL_MOD_EXPR:
  5609.     case ROUND_MOD_EXPR:
  5610.       preexpand_calls (exp);
  5611.       if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1)))
  5612.     subtarget = 0;
  5613.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  5614.       op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0);
  5615.       return expand_divmod (1, code, mode, op0, op1, target, unsignedp);
  5616.  
  5617.     case FIX_ROUND_EXPR:
  5618.     case FIX_FLOOR_EXPR:
  5619.     case FIX_CEIL_EXPR:
  5620.       abort ();            /* Not used for C.  */
  5621.  
  5622.     case FIX_TRUNC_EXPR:
  5623.       op0 = expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, VOIDmode, 0);
  5624.       if (target == 0)
  5625.     target = gen_reg_rtx (mode);
  5626.       expand_fix (target, op0, unsignedp);
  5627.       return target;
  5628.  
  5629.     case FLOAT_EXPR:
  5630.       op0 = expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, VOIDmode, 0);
  5631.       if (target == 0)
  5632.     target = gen_reg_rtx (mode);
  5633.       /* expand_float can't figure out what to do if FROM has VOIDmode.
  5634.      So give it the correct mode.  With -O, cse will optimize this.  */
  5635.       if (GET_MODE (op0) == VOIDmode)
  5636.     op0 = copy_to_mode_reg (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))),
  5637.                 op0);
  5638.       expand_float (target, op0,
  5639.             TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))));
  5640.       return target;
  5641.  
  5642.     case NEGATE_EXPR:
  5643.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  5644.       temp = expand_unop (mode, neg_optab, op0, target, 0);
  5645.       if (temp == 0)
  5646.     abort ();
  5647.       return temp;
  5648.  
  5649.     case ABS_EXPR:
  5650.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  5651.  
  5652.       /* Handle complex values specially.  */
  5653.       if (GET_MODE_CLASS (mode) == MODE_COMPLEX_INT
  5654.       || GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT)
  5655.     return expand_complex_abs (mode, op0, target, unsignedp);
  5656.  
  5657.       /* Unsigned abs is simply the operand.  Testing here means we don't
  5658.      risk generating incorrect code below.  */
  5659.       if (TREE_UNSIGNED (type))
  5660.     return op0;
  5661.  
  5662.       return expand_abs (mode, op0, target, unsignedp,
  5663.              safe_from_p (target, TREE_OPERAND (exp, 0)));
  5664.  
  5665.     case MAX_EXPR:
  5666.     case MIN_EXPR:
  5667.       target = original_target;
  5668.       if (target == 0 || ! safe_from_p (target, TREE_OPERAND (exp, 1))
  5669.       || (GET_CODE (target) == MEM && MEM_VOLATILE_P (target))
  5670.       || GET_MODE (target) != mode
  5671.       || (GET_CODE (target) == REG
  5672.           && REGNO (target) < FIRST_PSEUDO_REGISTER))
  5673.     target = gen_reg_rtx (mode);
  5674.       op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0);
  5675.       op0 = expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, 0);
  5676.  
  5677.       /* First try to do it with a special MIN or MAX instruction.
  5678.      If that does not win, use a conditional jump to select the proper
  5679.      value.  */
  5680.       this_optab = (TREE_UNSIGNED (type)
  5681.             ? (code == MIN_EXPR ? umin_optab : umax_optab)
  5682.             : (code == MIN_EXPR ? smin_optab : smax_optab));
  5683.  
  5684.       temp = expand_binop (mode, this_optab, op0, op1, target, unsignedp,
  5685.                OPTAB_WIDEN);
  5686.       if (temp != 0)
  5687.     return temp;
  5688.  
  5689.       /* At this point, a MEM target is no longer useful; we will get better
  5690.      code without it.  */
  5691.      
  5692.       if (GET_CODE (target) == MEM)
  5693.     target = gen_reg_rtx (mode);
  5694.  
  5695.       if (target != op0)
  5696.     emit_move_insn (target, op0);
  5697.  
  5698.       op0 = gen_label_rtx ();
  5699.  
  5700.       /* If this mode is an integer too wide to compare properly,
  5701.      compare word by word.  Rely on cse to optimize constant cases.  */
  5702.       if (GET_MODE_CLASS (mode) == MODE_INT && !can_compare_p (mode))
  5703.     {
  5704.       if (code == MAX_EXPR)
  5705.         do_jump_by_parts_greater_rtx (mode, TREE_UNSIGNED (type),
  5706.                       target, op1, NULL_RTX, op0);
  5707.       else
  5708.         do_jump_by_parts_greater_rtx (mode, TREE_UNSIGNED (type),
  5709.                       op1, target, NULL_RTX, op0);
  5710.       emit_move_insn (target, op1);
  5711.     }
  5712.       else
  5713.     {
  5714.       if (code == MAX_EXPR)
  5715.         temp = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 1)))
  5716.             ? compare_from_rtx (target, op1, GEU, 1, mode, NULL_RTX, 0)
  5717.             : compare_from_rtx (target, op1, GE, 0, mode, NULL_RTX, 0));
  5718.       else
  5719.         temp = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 1)))
  5720.             ? compare_from_rtx (target, op1, LEU, 1, mode, NULL_RTX, 0)
  5721.             : compare_from_rtx (target, op1, LE, 0, mode, NULL_RTX, 0));
  5722.       if (temp == const0_rtx)
  5723.         emit_move_insn (target, op1);
  5724.       else if (temp != const_true_rtx)
  5725.         {
  5726.           if (bcc_gen_fctn[(int) GET_CODE (temp)] != 0)
  5727.         emit_jump_insn ((*bcc_gen_fctn[(int) GET_CODE (temp)]) (op0));
  5728.           else
  5729.         abort ();
  5730.           emit_move_insn (target, op1);
  5731.         }
  5732.     }
  5733.       emit_label (op0);
  5734.       return target;
  5735.  
  5736.     case BIT_NOT_EXPR:
  5737.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  5738.       temp = expand_unop (mode, one_cmpl_optab, op0, target, 1);
  5739.       if (temp == 0)
  5740.     abort ();
  5741.       return temp;
  5742.  
  5743.     case FFS_EXPR:
  5744.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  5745.       temp = expand_unop (mode, ffs_optab, op0, target, 1);
  5746.       if (temp == 0)
  5747.     abort ();
  5748.       return temp;
  5749.  
  5750.       /* ??? Can optimize bitwise operations with one arg constant.
  5751.      Can optimize (a bitwise1 n) bitwise2 (a bitwise3 b)
  5752.      and (a bitwise1 b) bitwise2 b (etc)
  5753.      but that is probably not worth while.  */
  5754.  
  5755.       /* BIT_AND_EXPR is for bitwise anding.  TRUTH_AND_EXPR is for anding two
  5756.      boolean values when we want in all cases to compute both of them.  In
  5757.      general it is fastest to do TRUTH_AND_EXPR by computing both operands
  5758.      as actual zero-or-1 values and then bitwise anding.  In cases where
  5759.      there cannot be any side effects, better code would be made by
  5760.      treating TRUTH_AND_EXPR like TRUTH_ANDIF_EXPR; but the question is
  5761.      how to recognize those cases.  */
  5762.  
  5763.     case TRUTH_AND_EXPR:
  5764.     case BIT_AND_EXPR:
  5765.       this_optab = and_optab;
  5766.       goto binop;
  5767.  
  5768.     case TRUTH_OR_EXPR:
  5769.     case BIT_IOR_EXPR:
  5770.       this_optab = ior_optab;
  5771.       goto binop;
  5772.  
  5773.     case TRUTH_XOR_EXPR:
  5774.     case BIT_XOR_EXPR:
  5775.       this_optab = xor_optab;
  5776.       goto binop;
  5777.  
  5778.     case LSHIFT_EXPR:
  5779.     case RSHIFT_EXPR:
  5780.     case LROTATE_EXPR:
  5781.     case RROTATE_EXPR:
  5782.       preexpand_calls (exp);
  5783.       if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1)))
  5784.     subtarget = 0;
  5785.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  5786.       return expand_shift (code, mode, op0, TREE_OPERAND (exp, 1), target,
  5787.                unsignedp);
  5788.  
  5789.       /* Could determine the answer when only additive constants differ.  Also,
  5790.      the addition of one can be handled by changing the condition.  */
  5791.     case LT_EXPR:
  5792.     case LE_EXPR:
  5793.     case GT_EXPR:
  5794.     case GE_EXPR:
  5795.     case EQ_EXPR:
  5796.     case NE_EXPR:
  5797.       preexpand_calls (exp);
  5798.       temp = do_store_flag (exp, target, tmode != VOIDmode ? tmode : mode, 0);
  5799.       if (temp != 0)
  5800.     return temp;
  5801.  
  5802.       /* For foo != 0, load foo, and if it is nonzero load 1 instead. */
  5803.       if (code == NE_EXPR && integer_zerop (TREE_OPERAND (exp, 1))
  5804.       && original_target
  5805.       && GET_CODE (original_target) == REG
  5806.       && (GET_MODE (original_target)
  5807.           == TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  5808.     {
  5809.       temp = expand_expr (TREE_OPERAND (exp, 0), original_target,
  5810.                   VOIDmode, 0);
  5811.  
  5812.       if (temp != original_target)
  5813.         temp = copy_to_reg (temp);
  5814.  
  5815.       op1 = gen_label_rtx ();
  5816.       emit_cmp_insn (temp, const0_rtx, EQ, NULL_RTX,
  5817.              GET_MODE (temp), unsignedp, 0);
  5818.       emit_jump_insn (gen_beq (op1));
  5819.       emit_move_insn (temp, const1_rtx);
  5820.       emit_label (op1);
  5821.       return temp;
  5822.     }
  5823.  
  5824.       /* If no set-flag instruction, must generate a conditional
  5825.      store into a temporary variable.  Drop through
  5826.      and handle this like && and ||.  */
  5827.  
  5828.     case TRUTH_ANDIF_EXPR:
  5829.     case TRUTH_ORIF_EXPR:
  5830.       if (! ignore
  5831.       && (target == 0 || ! safe_from_p (target, exp)
  5832.           /* Make sure we don't have a hard reg (such as function's return
  5833.          value) live across basic blocks, if not optimizing.  */
  5834.           || (!optimize && GET_CODE (target) == REG
  5835.           && REGNO (target) < FIRST_PSEUDO_REGISTER)))
  5836.     target = gen_reg_rtx (tmode != VOIDmode ? tmode : mode);
  5837.  
  5838.       if (target)
  5839.     emit_clr_insn (target);
  5840.  
  5841.       op1 = gen_label_rtx ();
  5842.       jumpifnot (exp, op1);
  5843.  
  5844.       if (target)
  5845.     emit_0_to_1_insn (target);
  5846.  
  5847.       emit_label (op1);
  5848.       return ignore ? const0_rtx : target;
  5849.  
  5850.     case TRUTH_NOT_EXPR:
  5851.       op0 = expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, 0);
  5852.       /* The parser is careful to generate TRUTH_NOT_EXPR
  5853.      only with operands that are always zero or one.  */
  5854.       temp = expand_binop (mode, xor_optab, op0, const1_rtx,
  5855.                target, 1, OPTAB_LIB_WIDEN);
  5856.       if (temp == 0)
  5857.     abort ();
  5858.       return temp;
  5859.  
  5860.     case COMPOUND_EXPR:
  5861.       expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0);
  5862.       emit_queue ();
  5863.       return expand_expr (TREE_OPERAND (exp, 1),
  5864.               (ignore ? const0_rtx : target),
  5865.               VOIDmode, 0);
  5866.  
  5867.     case COND_EXPR:
  5868.       {
  5869.     rtx flag = NULL_RTX;
  5870.     tree left_cleanups = NULL_TREE;
  5871.     tree right_cleanups = NULL_TREE;
  5872.  
  5873.     /* Used to save a pointer to the place to put the setting of
  5874.        the flag that indicates if this side of the conditional was
  5875.        taken.  We backpatch the code, if we find out later that we
  5876.        have any conditional cleanups that need to be performed. */
  5877.     rtx dest_right_flag = NULL_RTX;
  5878.     rtx dest_left_flag = NULL_RTX;
  5879.  
  5880.     /* Note that COND_EXPRs whose type is a structure or union
  5881.        are required to be constructed to contain assignments of
  5882.        a temporary variable, so that we can evaluate them here
  5883.        for side effect only.  If type is void, we must do likewise.  */
  5884.  
  5885.     /* If an arm of the branch requires a cleanup,
  5886.        only that cleanup is performed.  */
  5887.  
  5888.     tree singleton = 0;
  5889.     tree binary_op = 0, unary_op = 0;
  5890.     tree old_cleanups = cleanups_this_call;
  5891.  
  5892.     /* If this is (A ? 1 : 0) and A is a condition, just evaluate it and
  5893.        convert it to our mode, if necessary.  */
  5894.     if (integer_onep (TREE_OPERAND (exp, 1))
  5895.         && integer_zerop (TREE_OPERAND (exp, 2))
  5896.         && TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 0))) == '<')
  5897.       {
  5898.         if (ignore)
  5899.           {
  5900.         expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode,
  5901.                  modifier);
  5902.         return const0_rtx;
  5903.           }
  5904.  
  5905.         op0 = expand_expr (TREE_OPERAND (exp, 0), target, mode, modifier);
  5906.         if (GET_MODE (op0) == mode)
  5907.           return op0;
  5908.  
  5909.         if (target == 0)
  5910.           target = gen_reg_rtx (mode);
  5911.         convert_move (target, op0, unsignedp);
  5912.         return target;
  5913.       }
  5914.  
  5915.     /* If we are not to produce a result, we have no target.  Otherwise,
  5916.        if a target was specified use it; it will not be used as an
  5917.        intermediate target unless it is safe.  If no target, use a 
  5918.        temporary.  */
  5919.  
  5920.     if (ignore)
  5921.       temp = 0;
  5922.     else if (original_target
  5923.          && safe_from_p (original_target, TREE_OPERAND (exp, 0))
  5924.          && GET_MODE (original_target) == mode
  5925.          && ! (GET_CODE (original_target) == MEM
  5926.                && MEM_VOLATILE_P (original_target)))
  5927.       temp = original_target;
  5928.     else if (mode == BLKmode)
  5929.       {
  5930.         if (TYPE_SIZE (type) == 0
  5931.         || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
  5932.           abort ();
  5933.  
  5934.         temp = assign_stack_temp (BLKmode,
  5935.                       (TREE_INT_CST_LOW (TYPE_SIZE (type))
  5936.                        + BITS_PER_UNIT - 1)
  5937.                       / BITS_PER_UNIT, 0);
  5938.         MEM_IN_STRUCT_P (temp) = AGGREGATE_TYPE_P (type);
  5939.       }
  5940.     else
  5941.       temp = gen_reg_rtx (mode);
  5942.  
  5943.     /* Check for X ? A + B : A.  If we have this, we can copy
  5944.        A to the output and conditionally add B.  Similarly for unary
  5945.        operations.  Don't do this if X has side-effects because
  5946.        those side effects might affect A or B and the "?" operation is
  5947.        a sequence point in ANSI.  (We test for side effects later.)  */
  5948.  
  5949.     if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 1))) == '2'
  5950.         && operand_equal_p (TREE_OPERAND (exp, 2),
  5951.                 TREE_OPERAND (TREE_OPERAND (exp, 1), 0), 0))
  5952.       singleton = TREE_OPERAND (exp, 2), binary_op = TREE_OPERAND (exp, 1);
  5953.     else if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 2))) == '2'
  5954.          && operand_equal_p (TREE_OPERAND (exp, 1),
  5955.                      TREE_OPERAND (TREE_OPERAND (exp, 2), 0), 0))
  5956.       singleton = TREE_OPERAND (exp, 1), binary_op = TREE_OPERAND (exp, 2);
  5957.     else if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 1))) == '1'
  5958.          && operand_equal_p (TREE_OPERAND (exp, 2),
  5959.                      TREE_OPERAND (TREE_OPERAND (exp, 1), 0), 0))
  5960.       singleton = TREE_OPERAND (exp, 2), unary_op = TREE_OPERAND (exp, 1);
  5961.     else if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 2))) == '1'
  5962.          && operand_equal_p (TREE_OPERAND (exp, 1),
  5963.                      TREE_OPERAND (TREE_OPERAND (exp, 2), 0), 0))
  5964.       singleton = TREE_OPERAND (exp, 1), unary_op = TREE_OPERAND (exp, 2);
  5965.  
  5966.     /* If we had X ? A + 1 : A and we can do the test of X as a store-flag
  5967.        operation, do this as A + (X != 0).  Similarly for other simple
  5968.        binary operators.  */
  5969.     if (temp && singleton && binary_op
  5970.         && ! TREE_SIDE_EFFECTS (TREE_OPERAND (exp, 0))
  5971.         && (TREE_CODE (binary_op) == PLUS_EXPR
  5972.         || TREE_CODE (binary_op) == MINUS_EXPR
  5973.         || TREE_CODE (binary_op) == BIT_IOR_EXPR
  5974.         || TREE_CODE (binary_op) == BIT_XOR_EXPR)
  5975.         && integer_onep (TREE_OPERAND (binary_op, 1))
  5976.         && TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 0))) == '<')
  5977.       {
  5978.         rtx result;
  5979.         optab boptab = (TREE_CODE (binary_op) == PLUS_EXPR ? add_optab
  5980.                 : TREE_CODE (binary_op) == MINUS_EXPR ? sub_optab
  5981.                 : TREE_CODE (binary_op) == BIT_IOR_EXPR ? ior_optab
  5982.                 : xor_optab);
  5983.  
  5984.         /* If we had X ? A : A + 1, do this as A + (X == 0).
  5985.  
  5986.            We have to invert the truth value here and then put it
  5987.            back later if do_store_flag fails.  We cannot simply copy
  5988.            TREE_OPERAND (exp, 0) to another variable and modify that
  5989.            because invert_truthvalue can modify the tree pointed to
  5990.            by its argument.  */
  5991.         if (singleton == TREE_OPERAND (exp, 1))
  5992.           TREE_OPERAND (exp, 0)
  5993.         = invert_truthvalue (TREE_OPERAND (exp, 0));
  5994.  
  5995.         result = do_store_flag (TREE_OPERAND (exp, 0),
  5996.                     (safe_from_p (temp, singleton)
  5997.                      ? temp : NULL_RTX),
  5998.                     mode, BRANCH_COST <= 1);
  5999.  
  6000.         if (result)
  6001.           {
  6002.         op1 = expand_expr (singleton, NULL_RTX, VOIDmode, 0);
  6003.         return expand_binop (mode, boptab, op1, result, temp,
  6004.                      unsignedp, OPTAB_LIB_WIDEN);
  6005.           }
  6006.         else if (singleton == TREE_OPERAND (exp, 1))
  6007.           TREE_OPERAND (exp, 0)
  6008.         = invert_truthvalue (TREE_OPERAND (exp, 0));
  6009.       }
  6010.         
  6011.     do_pending_stack_adjust ();
  6012.     NO_DEFER_POP;
  6013.     op0 = gen_label_rtx ();
  6014.  
  6015.     flag = gen_reg_rtx (word_mode);
  6016.     if (singleton && ! TREE_SIDE_EFFECTS (TREE_OPERAND (exp, 0)))
  6017.       {
  6018.         if (temp != 0)
  6019.           {
  6020.         /* If the target conflicts with the other operand of the
  6021.            binary op, we can't use it.  Also, we can't use the target
  6022.            if it is a hard register, because evaluating the condition
  6023.            might clobber it.  */
  6024.         if ((binary_op
  6025.              && ! safe_from_p (temp, TREE_OPERAND (binary_op, 1)))
  6026.             || (GET_CODE (temp) == REG
  6027.             && REGNO (temp) < FIRST_PSEUDO_REGISTER))
  6028.           temp = gen_reg_rtx (mode);
  6029.         store_expr (singleton, temp, 0);
  6030.           }
  6031.         else
  6032.           expand_expr (singleton,
  6033.                ignore ? const0_rtx : NULL_RTX, VOIDmode, 0);
  6034.         dest_left_flag = get_last_insn ();
  6035.         if (singleton == TREE_OPERAND (exp, 1))
  6036.           jumpif (TREE_OPERAND (exp, 0), op0);
  6037.         else
  6038.           jumpifnot (TREE_OPERAND (exp, 0), op0);
  6039.  
  6040.         /* Allows cleanups up to here. */
  6041.         old_cleanups = cleanups_this_call;
  6042.         if (binary_op && temp == 0)
  6043.           /* Just touch the other operand.  */
  6044.           expand_expr (TREE_OPERAND (binary_op, 1),
  6045.                ignore ? const0_rtx : NULL_RTX, VOIDmode, 0);
  6046.         else if (binary_op)
  6047.           store_expr (build (TREE_CODE (binary_op), type,
  6048.                  make_tree (type, temp),
  6049.                  TREE_OPERAND (binary_op, 1)),
  6050.               temp, 0);
  6051.         else
  6052.           store_expr (build1 (TREE_CODE (unary_op), type,
  6053.                   make_tree (type, temp)),
  6054.               temp, 0);
  6055.         op1 = op0;
  6056.         dest_right_flag = get_last_insn ();
  6057.       }
  6058. #if 0
  6059.     /* This is now done in jump.c and is better done there because it
  6060.        produces shorter register lifetimes.  */
  6061.        
  6062.     /* Check for both possibilities either constants or variables
  6063.        in registers (but not the same as the target!).  If so, can
  6064.        save branches by assigning one, branching, and assigning the
  6065.        other.  */
  6066.     else if (temp && GET_MODE (temp) != BLKmode
  6067.          && (TREE_CONSTANT (TREE_OPERAND (exp, 1))
  6068.              || ((TREE_CODE (TREE_OPERAND (exp, 1)) == PARM_DECL
  6069.               || TREE_CODE (TREE_OPERAND (exp, 1)) == VAR_DECL)
  6070.              && DECL_RTL (TREE_OPERAND (exp, 1))
  6071.              && GET_CODE (DECL_RTL (TREE_OPERAND (exp, 1))) == REG
  6072.              && DECL_RTL (TREE_OPERAND (exp, 1)) != temp))
  6073.          && (TREE_CONSTANT (TREE_OPERAND (exp, 2))
  6074.              || ((TREE_CODE (TREE_OPERAND (exp, 2)) == PARM_DECL
  6075.               || TREE_CODE (TREE_OPERAND (exp, 2)) == VAR_DECL)
  6076.              && DECL_RTL (TREE_OPERAND (exp, 2))
  6077.              && GET_CODE (DECL_RTL (TREE_OPERAND (exp, 2))) == REG
  6078.              && DECL_RTL (TREE_OPERAND (exp, 2)) != temp)))
  6079.       {
  6080.         if (GET_CODE (temp) == REG && REGNO (temp) < FIRST_PSEUDO_REGISTER)
  6081.           temp = gen_reg_rtx (mode);
  6082.         store_expr (TREE_OPERAND (exp, 2), temp, 0);
  6083.         dest_left_flag = get_last_insn ();
  6084.         jumpifnot (TREE_OPERAND (exp, 0), op0);
  6085.  
  6086.         /* Allows cleanups up to here. */
  6087.         old_cleanups = cleanups_this_call;
  6088.         store_expr (TREE_OPERAND (exp, 1), temp, 0);
  6089.         op1 = op0;
  6090.         dest_right_flag = get_last_insn ();
  6091.       }
  6092. #endif
  6093.     /* Check for A op 0 ? A : FOO and A op 0 ? FOO : A where OP is any
  6094.        comparison operator.  If we have one of these cases, set the
  6095.        output to A, branch on A (cse will merge these two references),
  6096.        then set the output to FOO.  */
  6097.     else if (temp
  6098.          && TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 0))) == '<'
  6099.          && integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 0), 1))
  6100.          && operand_equal_p (TREE_OPERAND (TREE_OPERAND (exp, 0), 0),
  6101.                      TREE_OPERAND (exp, 1), 0)
  6102.          && ! TREE_SIDE_EFFECTS (TREE_OPERAND (exp, 0))
  6103.          && safe_from_p (temp, TREE_OPERAND (exp, 2)))
  6104.       {
  6105.         if (GET_CODE (temp) == REG && REGNO (temp) < FIRST_PSEUDO_REGISTER)
  6106.           temp = gen_reg_rtx (mode);
  6107.         store_expr (TREE_OPERAND (exp, 1), temp, 0);
  6108.         dest_left_flag = get_last_insn ();
  6109.         jumpif (TREE_OPERAND (exp, 0), op0);
  6110.  
  6111.         /* Allows cleanups up to here. */
  6112.         old_cleanups = cleanups_this_call;
  6113.         store_expr (TREE_OPERAND (exp, 2), temp, 0);
  6114.         op1 = op0;
  6115.         dest_right_flag = get_last_insn ();
  6116.       }
  6117.     else if (temp
  6118.          && TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 0))) == '<'
  6119.          && integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 0), 1))
  6120.          && operand_equal_p (TREE_OPERAND (TREE_OPERAND (exp, 0), 0),
  6121.                      TREE_OPERAND (exp, 2), 0)
  6122.          && ! TREE_SIDE_EFFECTS (TREE_OPERAND (exp, 0))
  6123.          && safe_from_p (temp, TREE_OPERAND (exp, 1)))
  6124.       {
  6125.         if (GET_CODE (temp) == REG && REGNO (temp) < FIRST_PSEUDO_REGISTER)
  6126.           temp = gen_reg_rtx (mode);
  6127.         store_expr (TREE_OPERAND (exp, 2), temp, 0);
  6128.         dest_left_flag = get_last_insn ();
  6129.         jumpifnot (TREE_OPERAND (exp, 0), op0);
  6130.  
  6131.         /* Allows cleanups up to here. */
  6132.         old_cleanups = cleanups_this_call;
  6133.         store_expr (TREE_OPERAND (exp, 1), temp, 0);
  6134.         op1 = op0;
  6135.         dest_right_flag = get_last_insn ();
  6136.       }
  6137.     else
  6138.       {
  6139.         op1 = gen_label_rtx ();
  6140.         jumpifnot (TREE_OPERAND (exp, 0), op0);
  6141.  
  6142.         /* Allows cleanups up to here. */
  6143.         old_cleanups = cleanups_this_call;
  6144.         if (temp != 0)
  6145.           store_expr (TREE_OPERAND (exp, 1), temp, 0);
  6146.         else
  6147.           expand_expr (TREE_OPERAND (exp, 1),
  6148.                ignore ? const0_rtx : NULL_RTX, VOIDmode, 0);
  6149.         dest_left_flag = get_last_insn ();
  6150.  
  6151.         /* Handle conditional cleanups, if any. */
  6152.         left_cleanups = defer_cleanups_to (old_cleanups);
  6153.  
  6154.         emit_queue ();
  6155.         emit_jump_insn (gen_jump (op1));
  6156.         emit_barrier ();
  6157.         emit_label (op0);
  6158.         if (temp != 0)
  6159.           store_expr (TREE_OPERAND (exp, 2), temp, 0);
  6160.         else
  6161.           expand_expr (TREE_OPERAND (exp, 2),
  6162.                ignore ? const0_rtx : NULL_RTX, VOIDmode, 0);
  6163.         dest_right_flag = get_last_insn ();
  6164.       }
  6165.  
  6166.     /* Handle conditional cleanups, if any. */
  6167.     right_cleanups = defer_cleanups_to (old_cleanups);
  6168.  
  6169.     emit_queue ();
  6170.     emit_label (op1);
  6171.     OK_DEFER_POP;
  6172.  
  6173.     /* Add back in, any conditional cleanups. */
  6174.     if (left_cleanups || right_cleanups)
  6175.       {
  6176.         tree new_cleanups;
  6177.         tree cond;
  6178.         rtx last;
  6179.  
  6180.         /* Now that we know that a flag is needed, go back and add in the
  6181.            setting of the flag. */
  6182.  
  6183.         /* Do the left side flag. */
  6184.         last = get_last_insn ();
  6185.         /* Flag left cleanups as needed. */
  6186.         emit_move_insn (flag, const1_rtx);
  6187.         /* ??? deprecated, use sequences instead.  */
  6188.         reorder_insns (NEXT_INSN (last), get_last_insn (), dest_left_flag);
  6189.  
  6190.         /* Do the right side flag. */
  6191.         last = get_last_insn ();
  6192.         /* Flag left cleanups as needed. */
  6193.         emit_move_insn (flag, const0_rtx);
  6194.         /* ??? deprecated, use sequences instead.  */
  6195.         reorder_insns (NEXT_INSN (last), get_last_insn (), dest_right_flag);
  6196.  
  6197.         /* convert flag, which is an rtx, into a tree. */
  6198.         cond = make_node (RTL_EXPR);
  6199.         TREE_TYPE (cond) = integer_type_node;
  6200.         RTL_EXPR_RTL (cond) = flag;
  6201.         RTL_EXPR_SEQUENCE (cond) = NULL_RTX;
  6202.         cond = save_expr (cond);
  6203.  
  6204.         if (! left_cleanups)
  6205.           left_cleanups = integer_zero_node;
  6206.         if (! right_cleanups)
  6207.           right_cleanups = integer_zero_node;
  6208.         new_cleanups = build (COND_EXPR, void_type_node,
  6209.                   truthvalue_conversion (cond),
  6210.                   left_cleanups, right_cleanups);
  6211.         new_cleanups = fold (new_cleanups);
  6212.  
  6213.         /* Now add in the conditionalized cleanups. */
  6214.         cleanups_this_call
  6215.           = tree_cons (NULL_TREE, new_cleanups, cleanups_this_call);
  6216.         (*interim_eh_hook) (NULL_TREE);
  6217.       }
  6218.     return temp;
  6219.       }
  6220.  
  6221.     case TARGET_EXPR:
  6222.       {
  6223.     int need_exception_region = 0;
  6224.     /* Something needs to be initialized, but we didn't know
  6225.        where that thing was when building the tree.  For example,
  6226.        it could be the return value of a function, or a parameter
  6227.        to a function which lays down in the stack, or a temporary
  6228.        variable which must be passed by reference.
  6229.  
  6230.        We guarantee that the expression will either be constructed
  6231.        or copied into our original target.  */
  6232.  
  6233.     tree slot = TREE_OPERAND (exp, 0);
  6234.     tree exp1;
  6235.     rtx temp;
  6236.  
  6237.     if (TREE_CODE (slot) != VAR_DECL)
  6238.       abort ();
  6239.  
  6240.     if (! ignore)
  6241.       target = original_target;
  6242.  
  6243.     if (target == 0)
  6244.       {
  6245.         if (DECL_RTL (slot) != 0)
  6246.           {
  6247.         target = DECL_RTL (slot);
  6248.         /* If we have already expanded the slot, so don't do
  6249.            it again.  (mrs)  */
  6250.         if (TREE_OPERAND (exp, 1) == NULL_TREE)
  6251.           return target;
  6252.           }
  6253.         else
  6254.           {
  6255.         target = assign_stack_temp (mode, int_size_in_bytes (type), 2);
  6256.         MEM_IN_STRUCT_P (target) = AGGREGATE_TYPE_P (type);
  6257.         /* All temp slots at this level must not conflict.  */
  6258.         preserve_temp_slots (target);
  6259.         DECL_RTL (slot) = target;
  6260.  
  6261.         /* Since SLOT is not known to the called function
  6262.            to belong to its stack frame, we must build an explicit
  6263.            cleanup.  This case occurs when we must build up a reference
  6264.            to pass the reference as an argument.  In this case,
  6265.            it is very likely that such a reference need not be
  6266.            built here.  */
  6267.  
  6268.         if (TREE_OPERAND (exp, 2) == 0)
  6269.           TREE_OPERAND (exp, 2) = maybe_build_cleanup (slot);
  6270.         if (TREE_OPERAND (exp, 2))
  6271.           {
  6272.             cleanups_this_call = tree_cons (NULL_TREE,
  6273.                             TREE_OPERAND (exp, 2),
  6274.                             cleanups_this_call);
  6275.             need_exception_region = 1;
  6276.           }
  6277.           }
  6278.       }
  6279.     else
  6280.       {
  6281.         /* This case does occur, when expanding a parameter which
  6282.            needs to be constructed on the stack.  The target
  6283.            is the actual stack address that we want to initialize.
  6284.            The function we call will perform the cleanup in this case.  */
  6285.  
  6286.         /* If we have already assigned it space, use that space,
  6287.            not target that we were passed in, as our target
  6288.            parameter is only a hint.  */
  6289.         if (DECL_RTL (slot) != 0)
  6290.               {
  6291.                 target = DECL_RTL (slot);
  6292.                 /* If we have already expanded the slot, so don't do
  6293.                    it again.  (mrs)  */
  6294.                 if (TREE_OPERAND (exp, 1) == NULL_TREE)
  6295.                   return target;
  6296.           }
  6297.  
  6298.         DECL_RTL (slot) = target;
  6299.       }
  6300.  
  6301.     exp1 = TREE_OPERAND (exp, 1);
  6302.     /* Mark it as expanded.  */
  6303.     TREE_OPERAND (exp, 1) = NULL_TREE;
  6304.  
  6305.     temp = expand_expr (exp1, target, tmode, modifier);
  6306.  
  6307.     if (need_exception_region)
  6308.       (*interim_eh_hook) (NULL_TREE);
  6309.     
  6310.     return temp;
  6311.       }
  6312.  
  6313.     case INIT_EXPR:
  6314.       {
  6315.     tree lhs = TREE_OPERAND (exp, 0);
  6316.     tree rhs = TREE_OPERAND (exp, 1);
  6317.     tree noncopied_parts = 0;
  6318.     tree lhs_type = TREE_TYPE (lhs);
  6319.  
  6320.     temp = expand_assignment (lhs, rhs, ! ignore, original_target != 0);
  6321.     if (TYPE_NONCOPIED_PARTS (lhs_type) != 0 && !fixed_type_p (rhs))
  6322.       noncopied_parts = init_noncopied_parts (stabilize_reference (lhs),
  6323.                           TYPE_NONCOPIED_PARTS (lhs_type));
  6324.     while (noncopied_parts != 0)
  6325.       {
  6326.         expand_assignment (TREE_VALUE (noncopied_parts),
  6327.                    TREE_PURPOSE (noncopied_parts), 0, 0);
  6328.         noncopied_parts = TREE_CHAIN (noncopied_parts);
  6329.       }
  6330.     return temp;
  6331.       }
  6332.  
  6333.     case MODIFY_EXPR:
  6334.       {
  6335.     /* If lhs is complex, expand calls in rhs before computing it.
  6336.        That's so we don't compute a pointer and save it over a call.
  6337.        If lhs is simple, compute it first so we can give it as a
  6338.        target if the rhs is just a call.  This avoids an extra temp and copy
  6339.        and that prevents a partial-subsumption which makes bad code.
  6340.        Actually we could treat component_ref's of vars like vars.  */
  6341.  
  6342.     tree lhs = TREE_OPERAND (exp, 0);
  6343.     tree rhs = TREE_OPERAND (exp, 1);
  6344.     tree noncopied_parts = 0;
  6345.     tree lhs_type = TREE_TYPE (lhs);
  6346.  
  6347.     temp = 0;
  6348.  
  6349.     if (TREE_CODE (lhs) != VAR_DECL
  6350.         && TREE_CODE (lhs) != RESULT_DECL
  6351.         && TREE_CODE (lhs) != PARM_DECL)
  6352.       preexpand_calls (exp);
  6353.  
  6354.     /* Check for |= or &= of a bitfield of size one into another bitfield
  6355.        of size 1.  In this case, (unless we need the result of the
  6356.        assignment) we can do this more efficiently with a
  6357.        test followed by an assignment, if necessary.
  6358.  
  6359.        ??? At this point, we can't get a BIT_FIELD_REF here.  But if
  6360.        things change so we do, this code should be enhanced to
  6361.        support it.  */
  6362.     if (ignore
  6363.         && TREE_CODE (lhs) == COMPONENT_REF
  6364.         && (TREE_CODE (rhs) == BIT_IOR_EXPR
  6365.         || TREE_CODE (rhs) == BIT_AND_EXPR)
  6366.         && TREE_OPERAND (rhs, 0) == lhs
  6367.         && TREE_CODE (TREE_OPERAND (rhs, 1)) == COMPONENT_REF
  6368.         && TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (lhs, 1))) == 1
  6369.         && TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (TREE_OPERAND (rhs, 1), 1))) == 1)
  6370.       {
  6371.         rtx label = gen_label_rtx ();
  6372.  
  6373.         do_jump (TREE_OPERAND (rhs, 1),
  6374.              TREE_CODE (rhs) == BIT_IOR_EXPR ? label : 0,
  6375.              TREE_CODE (rhs) == BIT_AND_EXPR ? label : 0);
  6376.         expand_assignment (lhs, convert (TREE_TYPE (rhs),
  6377.                          (TREE_CODE (rhs) == BIT_IOR_EXPR
  6378.                           ? integer_one_node
  6379.                           : integer_zero_node)),
  6380.                    0, 0);
  6381.         do_pending_stack_adjust ();
  6382.         emit_label (label);
  6383.         return const0_rtx;
  6384.       }
  6385.  
  6386.     if (TYPE_NONCOPIED_PARTS (lhs_type) != 0
  6387.         && ! (fixed_type_p (lhs) && fixed_type_p (rhs)))
  6388.       noncopied_parts = save_noncopied_parts (stabilize_reference (lhs),
  6389.                           TYPE_NONCOPIED_PARTS (lhs_type));
  6390.  
  6391.     temp = expand_assignment (lhs, rhs, ! ignore, original_target != 0);
  6392.     while (noncopied_parts != 0)
  6393.       {
  6394.         expand_assignment (TREE_PURPOSE (noncopied_parts),
  6395.                    TREE_VALUE (noncopied_parts), 0, 0);
  6396.         noncopied_parts = TREE_CHAIN (noncopied_parts);
  6397.       }
  6398.     return temp;
  6399.       }
  6400.  
  6401.     case PREINCREMENT_EXPR:
  6402.     case PREDECREMENT_EXPR:
  6403.       return expand_increment (exp, 0);
  6404.  
  6405.     case POSTINCREMENT_EXPR:
  6406.     case POSTDECREMENT_EXPR:
  6407.       /* Faster to treat as pre-increment if result is not used.  */
  6408.       return expand_increment (exp, ! ignore);
  6409.  
  6410.     case ADDR_EXPR:
  6411.       /* If nonzero, TEMP will be set to the address of something that might
  6412.      be a MEM corresponding to a stack slot. */
  6413.       temp = 0;
  6414.  
  6415.       /* Are we taking the address of a nested function?  */
  6416.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == FUNCTION_DECL
  6417.       && decl_function_context (TREE_OPERAND (exp, 0)) != 0)
  6418.     {
  6419.       op0 = trampoline_address (TREE_OPERAND (exp, 0));
  6420.       op0 = force_operand (op0, target);
  6421.     }
  6422.       /* If we are taking the address of something erroneous, just
  6423.      return a zero.  */
  6424.       else if (TREE_CODE (TREE_OPERAND (exp, 0)) == ERROR_MARK)
  6425.     return const0_rtx;
  6426.       else
  6427.     {
  6428.       /* We make sure to pass const0_rtx down if we came in with
  6429.          ignore set, to avoid doing the cleanups twice for something.  */
  6430.       op0 = expand_expr (TREE_OPERAND (exp, 0),
  6431.                  ignore ? const0_rtx : NULL_RTX, VOIDmode,
  6432.                  (modifier == EXPAND_INITIALIZER
  6433.                   ? modifier : EXPAND_CONST_ADDRESS));
  6434.  
  6435.       /* If we are going to ignore the result, OP0 will have been set
  6436.          to const0_rtx, so just return it.  Don't get confused and
  6437.          think we are taking the address of the constant.  */
  6438.       if (ignore)
  6439.         return op0;
  6440.  
  6441.       /* We would like the object in memory.  If it is a constant,
  6442.          we can have it be statically allocated into memory.  For
  6443.          a non-constant (REG, SUBREG or CONCAT), we need to allocate some
  6444.          memory and store the value into it.  */
  6445.  
  6446.       if (CONSTANT_P (op0))
  6447.         op0 = force_const_mem (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))),
  6448.                    op0);
  6449.       else if (GET_CODE (op0) == MEM)
  6450.         {
  6451.           mark_temp_addr_taken (op0);
  6452.           temp = XEXP (op0, 0);
  6453.         }
  6454.  
  6455.       else if (GET_CODE (op0) == REG || GET_CODE (op0) == SUBREG
  6456.            || GET_CODE (op0) == CONCAT)
  6457.         {
  6458.           /* If this object is in a register, it must be not
  6459.          be BLKmode. */
  6460.           tree inner_type = TREE_TYPE (TREE_OPERAND (exp, 0));
  6461.           enum machine_mode inner_mode = TYPE_MODE (inner_type);
  6462.           rtx memloc
  6463.         = assign_stack_temp (inner_mode,
  6464.                      int_size_in_bytes (inner_type), 1);
  6465.           MEM_IN_STRUCT_P (memloc) = AGGREGATE_TYPE_P (inner_type);
  6466.  
  6467.           mark_temp_addr_taken (memloc);
  6468.           emit_move_insn (memloc, op0);
  6469.           op0 = memloc;
  6470.         }
  6471.  
  6472.       if (GET_CODE (op0) != MEM)
  6473.         abort ();
  6474.   
  6475.       if (modifier == EXPAND_SUM || modifier == EXPAND_INITIALIZER)
  6476.         {
  6477.           temp = XEXP (op0, 0);
  6478. #ifdef POINTERS_EXTEND_UNSIGNED
  6479.           if (GET_MODE (temp) == Pmode && GET_MODE (temp) != mode
  6480.           && mode == ptr_mode)
  6481.         temp = convert_memory_address (ptr_mode, temp);
  6482. #endif
  6483.           return temp;
  6484.         }
  6485.  
  6486.       op0 = force_operand (XEXP (op0, 0), target);
  6487.     }
  6488.  
  6489.       if (flag_force_addr && GET_CODE (op0) != REG)
  6490.     op0 = force_reg (Pmode, op0);
  6491.  
  6492.       if (GET_CODE (op0) == REG)
  6493.     mark_reg_pointer (op0);
  6494.  
  6495.       /* If we might have had a temp slot, add an equivalent address
  6496.      for it.  */
  6497.       if (temp != 0)
  6498.     update_temp_slot_address (temp, op0);
  6499.  
  6500. #ifdef POINTERS_EXTEND_UNSIGNED
  6501.       if (GET_MODE (op0) == Pmode && GET_MODE (op0) != mode
  6502.       && mode == ptr_mode)
  6503.     op0 = convert_memory_address (ptr_mode, op0);
  6504. #endif
  6505.  
  6506.       return op0;
  6507.  
  6508.     case ENTRY_VALUE_EXPR:
  6509.       abort ();
  6510.  
  6511.     /* COMPLEX type for Extended Pascal & Fortran  */
  6512.     case COMPLEX_EXPR:
  6513.       {
  6514.     enum machine_mode mode = TYPE_MODE (TREE_TYPE (TREE_TYPE (exp)));
  6515.     rtx insns;
  6516.  
  6517.     /* Get the rtx code of the operands.  */
  6518.     op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
  6519.     op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
  6520.  
  6521.     if (! target)
  6522.       target = gen_reg_rtx (TYPE_MODE (TREE_TYPE (exp)));
  6523.  
  6524.     start_sequence ();
  6525.  
  6526.     /* Move the real (op0) and imaginary (op1) parts to their location.  */
  6527.     emit_move_insn (gen_realpart (mode, target), op0);
  6528.     emit_move_insn (gen_imagpart (mode, target), op1);
  6529.  
  6530.     insns = get_insns ();
  6531.     end_sequence ();
  6532.  
  6533.     /* Complex construction should appear as a single unit.  */
  6534.     /* If TARGET is a CONCAT, we got insns like RD = RS, ID = IS,
  6535.        each with a separate pseudo as destination.
  6536.        It's not correct for flow to treat them as a unit.  */
  6537.     if (GET_CODE (target) != CONCAT)
  6538.       emit_no_conflict_block (insns, target, op0, op1, NULL_RTX);
  6539.     else
  6540.       emit_insns (insns);
  6541.  
  6542.     return target;
  6543.       }
  6544.  
  6545.     case REALPART_EXPR:
  6546.       op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
  6547.       return gen_realpart (mode, op0);
  6548.       
  6549.     case IMAGPART_EXPR:
  6550.       op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
  6551.       return gen_imagpart (mode, op0);
  6552.  
  6553.     case CONJ_EXPR:
  6554.       {
  6555.     enum machine_mode partmode = TYPE_MODE (TREE_TYPE (TREE_TYPE (exp)));
  6556.     rtx imag_t;
  6557.     rtx insns;
  6558.     
  6559.     op0  = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
  6560.  
  6561.     if (! target)
  6562.       target = gen_reg_rtx (mode);
  6563.                                     
  6564.     start_sequence ();
  6565.  
  6566.     /* Store the realpart and the negated imagpart to target.  */
  6567.     emit_move_insn (gen_realpart (partmode, target),
  6568.             gen_realpart (partmode, op0));
  6569.  
  6570.     imag_t = gen_imagpart (partmode, target);
  6571.     temp = expand_unop (partmode, neg_optab,
  6572.                    gen_imagpart (partmode, op0), imag_t, 0);
  6573.     if (temp != imag_t)
  6574.       emit_move_insn (imag_t, temp);
  6575.  
  6576.     insns = get_insns ();
  6577.     end_sequence ();
  6578.  
  6579.     /* Conjugate should appear as a single unit 
  6580.        If TARGET is a CONCAT, we got insns like RD = RS, ID = - IS,
  6581.        each with a separate pseudo as destination.
  6582.        It's not correct for flow to treat them as a unit.  */
  6583.     if (GET_CODE (target) != CONCAT)
  6584.       emit_no_conflict_block (insns, target, op0, NULL_RTX, NULL_RTX);
  6585.     else
  6586.       emit_insns (insns);
  6587.  
  6588.     return target;
  6589.       }
  6590.  
  6591.     case ERROR_MARK:
  6592.       op0 = CONST0_RTX (tmode);
  6593.       if (op0 != 0)
  6594.     return op0;
  6595.       return const0_rtx;
  6596.  
  6597.     default:
  6598.       return (*lang_expand_expr) (exp, original_target, tmode, modifier);
  6599.     }
  6600.  
  6601.   /* Here to do an ordinary binary operator, generating an instruction
  6602.      from the optab already placed in `this_optab'.  */
  6603.  binop:
  6604.   preexpand_calls (exp);
  6605.   if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1)))
  6606.     subtarget = 0;
  6607.   op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  6608.   op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0);
  6609.  binop2:
  6610.   temp = expand_binop (mode, this_optab, op0, op1, target,
  6611.                unsignedp, OPTAB_LIB_WIDEN);
  6612.   if (temp == 0)
  6613.     abort ();
  6614.   return temp;
  6615. }
  6616.  
  6617.  
  6618. /* Emit bytecode to evaluate the given expression EXP to the stack. */
  6619. void
  6620. bc_expand_expr (exp)
  6621.     tree exp;
  6622. {
  6623.   enum tree_code code;
  6624.   tree type, arg0;
  6625.   rtx r;
  6626.   struct binary_operator *binoptab;
  6627.   struct unary_operator *unoptab;
  6628.   struct increment_operator *incroptab;
  6629.   struct bc_label *lab, *lab1;
  6630.   enum bytecode_opcode opcode;
  6631.   
  6632.   
  6633.   code = TREE_CODE (exp);
  6634.   
  6635.   switch (code)
  6636.     {
  6637.     case PARM_DECL:
  6638.       
  6639.       if (DECL_RTL (exp) == 0)
  6640.     {
  6641.       error_with_decl (exp, "prior parameter's size depends on `%s'");
  6642.       return;
  6643.     }
  6644.       
  6645.       bc_load_parmaddr (DECL_RTL (exp));
  6646.       bc_load_memory (TREE_TYPE (exp), exp);
  6647.       
  6648.       return;
  6649.       
  6650.     case VAR_DECL:
  6651.       
  6652.       if (DECL_RTL (exp) == 0)
  6653.     abort ();
  6654.       
  6655. #if 0
  6656.       if (BYTECODE_LABEL (DECL_RTL (exp)))
  6657.     bc_load_externaddr (DECL_RTL (exp));
  6658.       else
  6659.     bc_load_localaddr (DECL_RTL (exp));
  6660. #endif
  6661.       if (TREE_PUBLIC (exp))
  6662.     bc_load_externaddr_id (DECL_ASSEMBLER_NAME (exp),
  6663.                    BYTECODE_BC_LABEL (DECL_RTL (exp))->offset);
  6664.       else
  6665.     bc_load_localaddr (DECL_RTL (exp));
  6666.       
  6667.       bc_load_memory (TREE_TYPE (exp), exp);
  6668.       return;
  6669.       
  6670.     case INTEGER_CST:
  6671.       
  6672. #ifdef DEBUG_PRINT_CODE
  6673.       fprintf (stderr, " [%x]\n", TREE_INT_CST_LOW (exp));
  6674. #endif
  6675.       bc_emit_instruction (mode_to_const_map[(int) (DECL_BIT_FIELD (exp)
  6676.                          ? SImode
  6677.                          : TYPE_MODE (TREE_TYPE (exp)))],
  6678.                (HOST_WIDE_INT) TREE_INT_CST_LOW (exp));
  6679.       return;
  6680.       
  6681.     case REAL_CST:
  6682.       
  6683. #if 0
  6684. #ifdef DEBUG_PRINT_CODE
  6685.       fprintf (stderr, " [%g]\n", (double) TREE_INT_CST_LOW (exp));
  6686. #endif
  6687.       /* FIX THIS: find a better way to pass real_cst's. -bson */
  6688.       bc_emit_instruction (mode_to_const_map[TYPE_MODE (TREE_TYPE (exp))],
  6689.                (double) TREE_REAL_CST (exp));
  6690. #else
  6691.       abort ();
  6692. #endif
  6693.  
  6694.       return;
  6695.       
  6696.     case CALL_EXPR:
  6697.       
  6698.       /* We build a call description vector describing the type of
  6699.      the return value and of the arguments; this call vector,
  6700.      together with a pointer to a location for the return value
  6701.      and the base of the argument list, is passed to the low
  6702.      level machine dependent call subroutine, which is responsible
  6703.      for putting the arguments wherever real functions expect
  6704.      them, as well as getting the return value back.  */
  6705.       {
  6706.     tree calldesc = 0, arg;
  6707.     int nargs = 0, i;
  6708.     rtx retval;
  6709.     
  6710.     /* Push the evaluated args on the evaluation stack in reverse
  6711.        order.  Also make an entry for each arg in the calldesc
  6712.        vector while we're at it.  */
  6713.     
  6714.     TREE_OPERAND (exp, 1) = nreverse (TREE_OPERAND (exp, 1));
  6715.     
  6716.     for (arg = TREE_OPERAND (exp, 1); arg; arg = TREE_CHAIN (arg))
  6717.       {
  6718.         ++nargs;
  6719.         bc_expand_expr (TREE_VALUE (arg));
  6720.         
  6721.         calldesc = tree_cons ((tree) 0,
  6722.                   size_in_bytes (TREE_TYPE (TREE_VALUE (arg))),
  6723.                   calldesc);
  6724.         calldesc = tree_cons ((tree) 0,
  6725.                   bc_runtime_type_code (TREE_TYPE (TREE_VALUE (arg))),
  6726.                   calldesc);
  6727.       }
  6728.     
  6729.     TREE_OPERAND (exp, 1) = nreverse (TREE_OPERAND (exp, 1));
  6730.     
  6731.     /* Allocate a location for the return value and push its
  6732.        address on the evaluation stack.  Also make an entry
  6733.        at the front of the calldesc for the return value type. */
  6734.     
  6735.     type = TREE_TYPE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (exp, 0))));
  6736.     retval = bc_allocate_local (int_size_in_bytes (type), TYPE_ALIGN (type));
  6737.     bc_load_localaddr (retval);
  6738.     
  6739.     calldesc = tree_cons ((tree) 0, size_in_bytes (type), calldesc);
  6740.     calldesc = tree_cons ((tree) 0, bc_runtime_type_code (type), calldesc);
  6741.     
  6742.     /* Prepend the argument count.  */
  6743.     calldesc = tree_cons ((tree) 0,
  6744.                   build_int_2 (nargs, 0),
  6745.                   calldesc);
  6746.     
  6747.     /* Push the address of the call description vector on the stack.  */
  6748.     calldesc = build_nt (CONSTRUCTOR, (tree) 0, calldesc);
  6749.     TREE_TYPE (calldesc) = build_array_type (integer_type_node,
  6750.                          build_index_type (build_int_2 (nargs * 2, 0)));
  6751.     r = output_constant_def (calldesc);
  6752.     bc_load_externaddr (r);
  6753.     
  6754.     /* Push the address of the function to be called. */
  6755.     bc_expand_expr (TREE_OPERAND (exp, 0));
  6756.     
  6757.     /* Call the function, popping its address and the calldesc vector
  6758.        address off the evaluation stack in the process.  */
  6759.     bc_emit_instruction (call);
  6760.     
  6761.     /* Pop the arguments off the stack.  */
  6762.     bc_adjust_stack (nargs);
  6763.     
  6764.     /* Load the return value onto the stack.  */
  6765.     bc_load_localaddr (retval);
  6766.     bc_load_memory (type, TREE_OPERAND (exp, 0));
  6767.       }
  6768.       return;
  6769.       
  6770.     case SAVE_EXPR:
  6771.       
  6772.       if (!SAVE_EXPR_RTL (exp))
  6773.     {
  6774.       /* First time around: copy to local variable */
  6775.       SAVE_EXPR_RTL (exp) = bc_allocate_local (int_size_in_bytes (TREE_TYPE (exp)),
  6776.                            TYPE_ALIGN (TREE_TYPE(exp)));
  6777.       bc_expand_expr (TREE_OPERAND (exp, 0));
  6778.       bc_emit_instruction (duplicate);
  6779.       
  6780.       bc_load_localaddr (SAVE_EXPR_RTL (exp));
  6781.       bc_store_memory (TREE_TYPE (exp), TREE_OPERAND (exp, 0));
  6782.     }
  6783.       else
  6784.     {
  6785.       /* Consecutive reference: use saved copy */
  6786.       bc_load_localaddr (SAVE_EXPR_RTL (exp));
  6787.       bc_load_memory (TREE_TYPE (exp), TREE_OPERAND (exp, 0));
  6788.     }
  6789.       return;
  6790.       
  6791. #if 0
  6792.       /* FIXME: the XXXX_STMT codes have been removed in GCC2, but
  6793.      how are they handled instead? */
  6794.     case LET_STMT:
  6795.       
  6796.       TREE_USED (exp) = 1;
  6797.       bc_expand_expr (STMT_BODY (exp));
  6798.       return;
  6799. #endif
  6800.       
  6801.     case NOP_EXPR:
  6802.     case CONVERT_EXPR:
  6803.       
  6804.       bc_expand_expr (TREE_OPERAND (exp, 0));
  6805.       bc_expand_conversion (TREE_TYPE (TREE_OPERAND (exp, 0)), TREE_TYPE (exp));
  6806.       return;
  6807.       
  6808.     case MODIFY_EXPR:
  6809.       
  6810.       expand_assignment (TREE_OPERAND (exp, 0), TREE_OPERAND (exp, 1), 0, 0);
  6811.       return;
  6812.       
  6813.     case ADDR_EXPR:
  6814.       
  6815.       bc_expand_address (TREE_OPERAND (exp, 0));
  6816.       return;
  6817.       
  6818.     case INDIRECT_REF:
  6819.       
  6820.       bc_expand_expr (TREE_OPERAND (exp, 0));
  6821.       bc_load_memory (TREE_TYPE (exp), TREE_OPERAND (exp, 0));
  6822.       return;
  6823.       
  6824.     case ARRAY_REF:
  6825.       
  6826.       bc_expand_expr (bc_canonicalize_array_ref (exp));
  6827.       return;
  6828.       
  6829.     case COMPONENT_REF:
  6830.       
  6831.       bc_expand_component_address (exp);
  6832.       
  6833.       /* If we have a bitfield, generate a proper load */
  6834.       bc_load_memory (TREE_TYPE (TREE_OPERAND (exp, 1)), TREE_OPERAND (exp, 1));
  6835.       return;
  6836.       
  6837.     case COMPOUND_EXPR:
  6838.       
  6839.       bc_expand_expr (TREE_OPERAND (exp, 0));
  6840.       bc_emit_instruction (drop);
  6841.       bc_expand_expr (TREE_OPERAND (exp, 1));
  6842.       return;
  6843.       
  6844.     case COND_EXPR:
  6845.       
  6846.       bc_expand_expr (TREE_OPERAND (exp, 0));
  6847.       bc_expand_truth_conversion (TREE_TYPE (TREE_OPERAND (exp, 0)));
  6848.       lab = bc_get_bytecode_label ();
  6849.       bc_emit_bytecode (xjumpifnot);
  6850.       bc_emit_bytecode_labelref (lab);
  6851.       
  6852. #ifdef DEBUG_PRINT_CODE
  6853.       fputc ('\n', stderr);
  6854. #endif
  6855.       bc_expand_expr (TREE_OPERAND (exp, 1));
  6856.       lab1 = bc_get_bytecode_label ();
  6857.       bc_emit_bytecode (jump);
  6858.       bc_emit_bytecode_labelref (lab1);
  6859.       
  6860. #ifdef DEBUG_PRINT_CODE
  6861.       fputc ('\n', stderr);
  6862. #endif
  6863.       
  6864.       bc_emit_bytecode_labeldef (lab);
  6865.       bc_expand_expr (TREE_OPERAND (exp, 2));
  6866.       bc_emit_bytecode_labeldef (lab1);
  6867.       return;
  6868.       
  6869.     case TRUTH_ANDIF_EXPR:
  6870.       
  6871.       opcode = xjumpifnot;
  6872.       goto andorif;
  6873.       
  6874.     case TRUTH_ORIF_EXPR:
  6875.       
  6876.       opcode = xjumpif;
  6877.       goto andorif;
  6878.       
  6879.     case PLUS_EXPR:
  6880.       
  6881.       binoptab = optab_plus_expr;
  6882.       goto binop;
  6883.       
  6884.     case MINUS_EXPR:
  6885.       
  6886.       binoptab = optab_minus_expr;
  6887.       goto binop;
  6888.       
  6889.     case MULT_EXPR:
  6890.       
  6891.       binoptab = optab_mult_expr;
  6892.       goto binop;
  6893.       
  6894.     case TRUNC_DIV_EXPR:
  6895.     case FLOOR_DIV_EXPR:
  6896.     case CEIL_DIV_EXPR:
  6897.     case ROUND_DIV_EXPR:
  6898.     case EXACT_DIV_EXPR:
  6899.       
  6900.       binoptab = optab_trunc_div_expr;
  6901.       goto binop;
  6902.       
  6903.     case TRUNC_MOD_EXPR:
  6904.     case FLOOR_MOD_EXPR:
  6905.     case CEIL_MOD_EXPR:
  6906.     case ROUND_MOD_EXPR:
  6907.       
  6908.       binoptab = optab_trunc_mod_expr;
  6909.       goto binop;
  6910.       
  6911.     case FIX_ROUND_EXPR:
  6912.     case FIX_FLOOR_EXPR:
  6913.     case FIX_CEIL_EXPR:
  6914.       abort ();            /* Not used for C.  */
  6915.       
  6916.     case FIX_TRUNC_EXPR:
  6917.     case FLOAT_EXPR:
  6918.     case MAX_EXPR:
  6919.     case MIN_EXPR:
  6920.     case FFS_EXPR:
  6921.     case LROTATE_EXPR:
  6922.     case RROTATE_EXPR:
  6923.       abort ();            /* FIXME */
  6924.       
  6925.     case RDIV_EXPR:
  6926.       
  6927.       binoptab = optab_rdiv_expr;
  6928.       goto binop;
  6929.       
  6930.     case BIT_AND_EXPR:
  6931.       
  6932.       binoptab = optab_bit_and_expr;
  6933.       goto binop;
  6934.       
  6935.     case BIT_IOR_EXPR:
  6936.       
  6937.       binoptab = optab_bit_ior_expr;
  6938.       goto binop;
  6939.       
  6940.     case BIT_XOR_EXPR:
  6941.       
  6942.       binoptab = optab_bit_xor_expr;
  6943.       goto binop;
  6944.       
  6945.     case LSHIFT_EXPR:
  6946.       
  6947.       binoptab = optab_lshift_expr;
  6948.       goto binop;
  6949.       
  6950.     case RSHIFT_EXPR:
  6951.       
  6952.       binoptab = optab_rshift_expr;
  6953.       goto binop;
  6954.       
  6955.     case TRUTH_AND_EXPR:
  6956.       
  6957.       binoptab = optab_truth_and_expr;
  6958.       goto binop;
  6959.       
  6960.     case TRUTH_OR_EXPR:
  6961.       
  6962.       binoptab = optab_truth_or_expr;
  6963.       goto binop;
  6964.       
  6965.     case LT_EXPR:
  6966.       
  6967.       binoptab = optab_lt_expr;
  6968.       goto binop;
  6969.       
  6970.     case LE_EXPR:
  6971.       
  6972.       binoptab = optab_le_expr;
  6973.       goto binop;
  6974.       
  6975.     case GE_EXPR:
  6976.       
  6977.       binoptab = optab_ge_expr;
  6978.       goto binop;
  6979.       
  6980.     case GT_EXPR:
  6981.       
  6982.       binoptab = optab_gt_expr;
  6983.       goto binop;
  6984.       
  6985.     case EQ_EXPR:
  6986.       
  6987.       binoptab = optab_eq_expr;
  6988.       goto binop;
  6989.       
  6990.     case NE_EXPR:
  6991.       
  6992.       binoptab = optab_ne_expr;
  6993.       goto binop;
  6994.       
  6995.     case NEGATE_EXPR:
  6996.       
  6997.       unoptab = optab_negate_expr;
  6998.       goto unop;
  6999.       
  7000.     case BIT_NOT_EXPR:
  7001.       
  7002.       unoptab = optab_bit_not_expr;
  7003.       goto unop;
  7004.       
  7005.     case TRUTH_NOT_EXPR:
  7006.       
  7007.       unoptab = optab_truth_not_expr;
  7008.       goto unop;
  7009.       
  7010.     case PREDECREMENT_EXPR:
  7011.       
  7012.       incroptab = optab_predecrement_expr;
  7013.       goto increment;
  7014.       
  7015.     case PREINCREMENT_EXPR:
  7016.       
  7017.       incroptab = optab_preincrement_expr;
  7018.       goto increment;
  7019.       
  7020.     case POSTDECREMENT_EXPR:
  7021.       
  7022.       incroptab = optab_postdecrement_expr;
  7023.       goto increment;
  7024.       
  7025.     case POSTINCREMENT_EXPR:
  7026.       
  7027.       incroptab = optab_postincrement_expr;
  7028.       goto increment;
  7029.       
  7030.     case CONSTRUCTOR:
  7031.       
  7032.       bc_expand_constructor (exp);
  7033.       return;
  7034.       
  7035.     case ERROR_MARK:
  7036.     case RTL_EXPR:
  7037.       
  7038.       return;
  7039.       
  7040.     case BIND_EXPR:
  7041.       {
  7042.     tree vars = TREE_OPERAND (exp, 0);
  7043.     int vars_need_expansion = 0;
  7044.     
  7045.     /* Need to open a binding contour here because
  7046.        if there are any cleanups they most be contained here.  */
  7047.     expand_start_bindings (0);
  7048.     
  7049.     /* Mark the corresponding BLOCK for output.  */
  7050.     if (TREE_OPERAND (exp, 2) != 0)
  7051.       TREE_USED (TREE_OPERAND (exp, 2)) = 1;
  7052.     
  7053.     /* If VARS have not yet been expanded, expand them now.  */
  7054.     while (vars)
  7055.       {
  7056.         if (DECL_RTL (vars) == 0)
  7057.           {
  7058.         vars_need_expansion = 1;
  7059.         expand_decl (vars);
  7060.           }
  7061.         expand_decl_init (vars);
  7062.         vars = TREE_CHAIN (vars);
  7063.       }
  7064.     
  7065.     bc_expand_expr (TREE_OPERAND (exp, 1));
  7066.     
  7067.     expand_end_bindings (TREE_OPERAND (exp, 0), 0, 0);
  7068.     
  7069.     return;
  7070.       }
  7071.     }
  7072.   
  7073.   abort ();
  7074.   
  7075.  binop:
  7076.   
  7077.   bc_expand_binary_operation (binoptab, TREE_TYPE (exp),
  7078.                   TREE_OPERAND (exp, 0), TREE_OPERAND (exp, 1));
  7079.   return;
  7080.   
  7081.   
  7082.  unop:
  7083.   
  7084.   bc_expand_unary_operation (unoptab, TREE_TYPE (exp), TREE_OPERAND (exp, 0));
  7085.   return;
  7086.   
  7087.   
  7088.  andorif:
  7089.   
  7090.   bc_expand_expr (TREE_OPERAND (exp, 0));
  7091.   bc_expand_truth_conversion (TREE_TYPE (TREE_OPERAND (exp, 0)));
  7092.   lab = bc_get_bytecode_label ();
  7093.   
  7094.   bc_emit_instruction (duplicate);
  7095.   bc_emit_bytecode (opcode);
  7096.   bc_emit_bytecode_labelref (lab);
  7097.   
  7098. #ifdef DEBUG_PRINT_CODE
  7099.   fputc ('\n', stderr);
  7100. #endif
  7101.   
  7102.   bc_emit_instruction (drop);
  7103.   
  7104.   bc_expand_expr (TREE_OPERAND (exp, 1));
  7105.   bc_expand_truth_conversion (TREE_TYPE (TREE_OPERAND (exp, 1)));
  7106.   bc_emit_bytecode_labeldef (lab);
  7107.   return;
  7108.   
  7109.   
  7110.  increment:
  7111.   
  7112.   type = TREE_TYPE (TREE_OPERAND (exp, 0));
  7113.   
  7114.   /* Push the quantum.  */
  7115.   bc_expand_expr (TREE_OPERAND (exp, 1));
  7116.   
  7117.   /* Convert it to the lvalue's type.  */
  7118.   bc_expand_conversion (TREE_TYPE (TREE_OPERAND (exp, 1)), type);
  7119.   
  7120.   /* Push the address of the lvalue */
  7121.   bc_expand_expr (build1 (ADDR_EXPR, TYPE_POINTER_TO (type), TREE_OPERAND (exp, 0)));
  7122.   
  7123.   /* Perform actual increment */
  7124.   bc_expand_increment (incroptab, type);
  7125.   return;
  7126. }
  7127.  
  7128. /* Return the alignment in bits of EXP, a pointer valued expression.
  7129.    But don't return more than MAX_ALIGN no matter what.
  7130.    The alignment returned is, by default, the alignment of the thing that
  7131.    EXP points to (if it is not a POINTER_TYPE, 0 is returned).
  7132.  
  7133.    Otherwise, look at the expression to see if we can do better, i.e., if the
  7134.    expression is actually pointing at an object whose alignment is tighter.  */
  7135.  
  7136. static int
  7137. get_pointer_alignment (exp, max_align)
  7138.      tree exp;
  7139.      unsigned max_align;
  7140. {
  7141.   unsigned align, inner;
  7142.  
  7143.   if (TREE_CODE (TREE_TYPE (exp)) != POINTER_TYPE)
  7144.     return 0;
  7145.  
  7146.   align = TYPE_ALIGN (TREE_TYPE (TREE_TYPE (exp)));
  7147.   align = MIN (align, max_align);
  7148.  
  7149.   while (1)
  7150.     {
  7151.       switch (TREE_CODE (exp))
  7152.     {
  7153.     case NOP_EXPR:
  7154.     case CONVERT_EXPR:
  7155.     case NON_LVALUE_EXPR:
  7156.       exp = TREE_OPERAND (exp, 0);
  7157.       if (TREE_CODE (TREE_TYPE (exp)) != POINTER_TYPE)
  7158.         return align;
  7159.       inner = TYPE_ALIGN (TREE_TYPE (TREE_TYPE (exp)));
  7160.       align = MIN (inner, max_align);
  7161.       break;
  7162.  
  7163.     case PLUS_EXPR:
  7164.       /* If sum of pointer + int, restrict our maximum alignment to that
  7165.          imposed by the integer.  If not, we can't do any better than
  7166.          ALIGN.  */
  7167.       if (TREE_CODE (TREE_OPERAND (exp, 1)) != INTEGER_CST)
  7168.         return align;
  7169.  
  7170.       while (((TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)) * BITS_PER_UNIT)
  7171.           & (max_align - 1))
  7172.          != 0)
  7173.         max_align >>= 1;
  7174.  
  7175.       exp = TREE_OPERAND (exp, 0);
  7176.       break;
  7177.  
  7178.     case ADDR_EXPR:
  7179.       /* See what we are pointing at and look at its alignment.  */
  7180.       exp = TREE_OPERAND (exp, 0);
  7181.       if (TREE_CODE (exp) == FUNCTION_DECL)
  7182.         align = FUNCTION_BOUNDARY;
  7183.       else if (TREE_CODE_CLASS (TREE_CODE (exp)) == 'd')
  7184.         align = DECL_ALIGN (exp);
  7185. #ifdef CONSTANT_ALIGNMENT
  7186.       else if (TREE_CODE_CLASS (TREE_CODE (exp)) == 'c')
  7187.         align = CONSTANT_ALIGNMENT (exp, align);
  7188. #endif
  7189.       return MIN (align, max_align);
  7190.  
  7191.     default:
  7192.       return align;
  7193.     }
  7194.     }
  7195. }
  7196.  
  7197. /* Return the tree node and offset if a given argument corresponds to
  7198.    a string constant.  */
  7199.  
  7200. static tree
  7201. string_constant (arg, ptr_offset)
  7202.      tree arg;
  7203.      tree *ptr_offset;
  7204. {
  7205.   STRIP_NOPS (arg);
  7206.  
  7207.   if (TREE_CODE (arg) == ADDR_EXPR
  7208.       && TREE_CODE (TREE_OPERAND (arg, 0)) == STRING_CST)
  7209.     {
  7210.       *ptr_offset = integer_zero_node;
  7211.       return TREE_OPERAND (arg, 0);
  7212.     }
  7213.   else if (TREE_CODE (arg) == PLUS_EXPR)
  7214.     {
  7215.       tree arg0 = TREE_OPERAND (arg, 0);
  7216.       tree arg1 = TREE_OPERAND (arg, 1);
  7217.  
  7218.       STRIP_NOPS (arg0);
  7219.       STRIP_NOPS (arg1);
  7220.  
  7221.       if (TREE_CODE (arg0) == ADDR_EXPR
  7222.       && TREE_CODE (TREE_OPERAND (arg0, 0)) == STRING_CST)
  7223.     {
  7224.       *ptr_offset = arg1;
  7225.       return TREE_OPERAND (arg0, 0);
  7226.     }
  7227.       else if (TREE_CODE (arg1) == ADDR_EXPR
  7228.            && TREE_CODE (TREE_OPERAND (arg1, 0)) == STRING_CST)
  7229.     {
  7230.       *ptr_offset = arg0;
  7231.       return TREE_OPERAND (arg1, 0);
  7232.     }
  7233.     }
  7234.  
  7235.   return 0;
  7236. }
  7237.  
  7238. /* Compute the length of a C string.  TREE_STRING_LENGTH is not the right
  7239.    way, because it could contain a zero byte in the middle.
  7240.    TREE_STRING_LENGTH is the size of the character array, not the string.
  7241.  
  7242.    Unfortunately, string_constant can't access the values of const char
  7243.    arrays with initializers, so neither can we do so here.  */
  7244.  
  7245. static tree
  7246. c_strlen (src)
  7247.      tree src;
  7248. {
  7249.   tree offset_node;
  7250.   int offset, max;
  7251.   char *ptr;
  7252.  
  7253.   src = string_constant (src, &offset_node);
  7254.   if (src == 0)
  7255.     return 0;
  7256.   max = TREE_STRING_LENGTH (src);
  7257.   ptr = TREE_STRING_POINTER (src);
  7258.   if (offset_node && TREE_CODE (offset_node) != INTEGER_CST)
  7259.     {
  7260.       /* If the string has an internal zero byte (e.g., "foo\0bar"), we can't
  7261.      compute the offset to the following null if we don't know where to
  7262.      start searching for it.  */
  7263.       int i;
  7264.       for (i = 0; i < max; i++)
  7265.     if (ptr[i] == 0)
  7266.       return 0;
  7267.       /* We don't know the starting offset, but we do know that the string
  7268.      has no internal zero bytes.  We can assume that the offset falls
  7269.      within the bounds of the string; otherwise, the programmer deserves
  7270.      what he gets.  Subtract the offset from the length of the string,
  7271.      and return that.  */
  7272.       /* This would perhaps not be valid if we were dealing with named
  7273.          arrays in addition to literal string constants.  */
  7274.       return size_binop (MINUS_EXPR, size_int (max), offset_node);
  7275.     }
  7276.  
  7277.   /* We have a known offset into the string.  Start searching there for
  7278.      a null character.  */
  7279.   if (offset_node == 0)
  7280.     offset = 0;
  7281.   else
  7282.     {
  7283.       /* Did we get a long long offset?  If so, punt.  */
  7284.       if (TREE_INT_CST_HIGH (offset_node) != 0)
  7285.     return 0;
  7286.       offset = TREE_INT_CST_LOW (offset_node);
  7287.     }
  7288.   /* If the offset is known to be out of bounds, warn, and call strlen at
  7289.      runtime.  */
  7290.   if (offset < 0 || offset > max)
  7291.     {
  7292.       warning ("offset outside bounds of constant string");
  7293.       return 0;
  7294.     }
  7295.   /* Use strlen to search for the first zero byte.  Since any strings
  7296.      constructed with build_string will have nulls appended, we win even
  7297.      if we get handed something like (char[4])"abcd".
  7298.  
  7299.      Since OFFSET is our starting index into the string, no further
  7300.      calculation is needed.  */
  7301.   return size_int (strlen (ptr + offset));
  7302. }
  7303.  
  7304. rtx
  7305. expand_builtin_return_addr (fndecl_code, count, tem)
  7306.      enum built_in_function fndecl_code;
  7307.      rtx tem;
  7308.      int count;
  7309. {
  7310.   int i;
  7311.  
  7312.   /* Some machines need special handling before we can access
  7313.      arbitrary frames.  For example, on the sparc, we must first flush
  7314.      all register windows to the stack.  */
  7315. #ifdef SETUP_FRAME_ADDRESSES
  7316.   SETUP_FRAME_ADDRESSES ();
  7317. #endif
  7318.  
  7319.   /* On the sparc, the return address is not in the frame, it is in a
  7320.      register.  There is no way to access it off of the current frame
  7321.      pointer, but it can be accessed off the previous frame pointer by
  7322.      reading the value from the register window save area.  */
  7323. #ifdef RETURN_ADDR_IN_PREVIOUS_FRAME
  7324.   if (fndecl_code == BUILT_IN_RETURN_ADDRESS)
  7325.     count--;
  7326. #endif
  7327.  
  7328.   /* Scan back COUNT frames to the specified frame.  */
  7329.   for (i = 0; i < count; i++)
  7330.     {
  7331.       /* Assume the dynamic chain pointer is in the word that the
  7332.      frame address points to, unless otherwise specified.  */
  7333. #ifdef DYNAMIC_CHAIN_ADDRESS
  7334.       tem = DYNAMIC_CHAIN_ADDRESS (tem);
  7335. #endif
  7336.       tem = memory_address (Pmode, tem);
  7337.       tem = copy_to_reg (gen_rtx (MEM, Pmode, tem));
  7338.     }
  7339.  
  7340.   /* For __builtin_frame_address, return what we've got.  */
  7341.   if (fndecl_code == BUILT_IN_FRAME_ADDRESS)
  7342.     return tem;
  7343.  
  7344.   /* For __builtin_return_address, Get the return address from that
  7345.      frame.  */
  7346. #ifdef RETURN_ADDR_RTX
  7347.   tem = RETURN_ADDR_RTX (count, tem);
  7348. #else
  7349.   tem = memory_address (Pmode,
  7350.             plus_constant (tem, GET_MODE_SIZE (Pmode)));
  7351.   tem = gen_rtx (MEM, Pmode, tem);
  7352. #endif
  7353.   return tem;
  7354. }
  7355.  
  7356. /* Expand an expression EXP that calls a built-in function,
  7357.    with result going to TARGET if that's convenient
  7358.    (and in mode MODE if that's convenient).
  7359.    SUBTARGET may be used as the target for computing one of EXP's operands.
  7360.    IGNORE is nonzero if the value is to be ignored.  */
  7361.  
  7362. #define CALLED_AS_BUILT_IN(NODE) \
  7363.    (!strncmp (IDENTIFIER_POINTER (DECL_NAME (NODE)), "__builtin_", 10))
  7364.  
  7365. static rtx
  7366. expand_builtin (exp, target, subtarget, mode, ignore)
  7367.      tree exp;
  7368.      rtx target;
  7369.      rtx subtarget;
  7370.      enum machine_mode mode;
  7371.      int ignore;
  7372. {
  7373.   tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
  7374.   tree arglist = TREE_OPERAND (exp, 1);
  7375.   rtx op0;
  7376.   rtx lab1, insns;
  7377.   enum machine_mode value_mode = TYPE_MODE (TREE_TYPE (exp));
  7378.   optab builtin_optab;
  7379.  
  7380.   switch (DECL_FUNCTION_CODE (fndecl))
  7381.     {
  7382.     case BUILT_IN_ABS:
  7383.     case BUILT_IN_LABS:
  7384.     case BUILT_IN_FABS:
  7385.       /* build_function_call changes these into ABS_EXPR.  */
  7386.       abort ();
  7387.  
  7388.     case BUILT_IN_SIN:
  7389.     case BUILT_IN_COS:
  7390.       /* Treat these like sqrt, but only if the user asks for them. */
  7391.       if (! flag_fast_math)
  7392.     break;
  7393.     case BUILT_IN_FSQRT:
  7394.       /* If not optimizing, call the library function.  */
  7395.       if (! optimize)
  7396.     break;
  7397.  
  7398.       if (arglist == 0
  7399.       /* Arg could be wrong type if user redeclared this fcn wrong.  */
  7400.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != REAL_TYPE)
  7401.     break;
  7402.  
  7403.       /* Stabilize and compute the argument.  */
  7404.       if (TREE_CODE (TREE_VALUE (arglist)) != VAR_DECL
  7405.       && TREE_CODE (TREE_VALUE (arglist)) != PARM_DECL)
  7406.     {
  7407.       exp = copy_node (exp);
  7408.       arglist = copy_node (arglist);
  7409.       TREE_OPERAND (exp, 1) = arglist;
  7410.       TREE_VALUE (arglist) = save_expr (TREE_VALUE (arglist));
  7411.     }
  7412.       op0 = expand_expr (TREE_VALUE (arglist), subtarget, VOIDmode, 0);
  7413.  
  7414.       /* Make a suitable register to place result in.  */
  7415.       target = gen_reg_rtx (TYPE_MODE (TREE_TYPE (exp)));
  7416.  
  7417.       emit_queue ();
  7418.       start_sequence ();
  7419.  
  7420.       switch (DECL_FUNCTION_CODE (fndecl))
  7421.     {
  7422.     case BUILT_IN_SIN:
  7423.       builtin_optab = sin_optab; break;
  7424.     case BUILT_IN_COS:
  7425.       builtin_optab = cos_optab; break;
  7426.     case BUILT_IN_FSQRT:
  7427.       builtin_optab = sqrt_optab; break;
  7428.     default:
  7429.       abort ();
  7430.     }
  7431.  
  7432.       /* Compute into TARGET.
  7433.      Set TARGET to wherever the result comes back.  */
  7434.       target = expand_unop (TYPE_MODE (TREE_TYPE (TREE_VALUE (arglist))),
  7435.                 builtin_optab, op0, target, 0);
  7436.  
  7437.       /* If we were unable to expand via the builtin, stop the
  7438.      sequence (without outputting the insns) and break, causing
  7439.      a call the the library function.  */
  7440.       if (target == 0)
  7441.     {
  7442.       end_sequence ();
  7443.       break;
  7444.         }
  7445.  
  7446.       /* Check the results by default.  But if flag_fast_math is turned on,
  7447.      then assume sqrt will always be called with valid arguments.  */
  7448.  
  7449.       if (! flag_fast_math)
  7450.     {
  7451.       /* Don't define the builtin FP instructions
  7452.          if your machine is not IEEE.  */
  7453.       if (TARGET_FLOAT_FORMAT != IEEE_FLOAT_FORMAT)
  7454.         abort ();
  7455.  
  7456.       lab1 = gen_label_rtx ();
  7457.  
  7458.       /* Test the result; if it is NaN, set errno=EDOM because
  7459.          the argument was not in the domain.  */
  7460.       emit_cmp_insn (target, target, EQ, 0, GET_MODE (target), 0, 0);
  7461.       emit_jump_insn (gen_beq (lab1));
  7462.  
  7463. #ifdef TARGET_EDOM
  7464.       {
  7465. #ifdef GEN_ERRNO_RTX
  7466.         rtx errno_rtx = GEN_ERRNO_RTX;
  7467. #else
  7468.         rtx errno_rtx
  7469.           = gen_rtx (MEM, word_mode, gen_rtx (SYMBOL_REF, Pmode, "errno"));
  7470. #endif
  7471.  
  7472.         emit_move_insn (errno_rtx, GEN_INT (TARGET_EDOM));
  7473.       }
  7474. #else
  7475.       /* We can't set errno=EDOM directly; let the library call do it.
  7476.          Pop the arguments right away in case the call gets deleted. */
  7477.       NO_DEFER_POP;
  7478.       expand_call (exp, target, 0);
  7479.       OK_DEFER_POP;
  7480. #endif
  7481.  
  7482.       emit_label (lab1);
  7483.     }
  7484.  
  7485.       /* Output the entire sequence. */
  7486.       insns = get_insns ();
  7487.       end_sequence ();
  7488.       emit_insns (insns);
  7489.  
  7490.       return target;
  7491.  
  7492.       /* __builtin_apply_args returns block of memory allocated on
  7493.      the stack into which is stored the arg pointer, structure
  7494.      value address, static chain, and all the registers that might
  7495.      possibly be used in performing a function call.  The code is
  7496.      moved to the start of the function so the incoming values are
  7497.      saved.  */
  7498.     case BUILT_IN_APPLY_ARGS:
  7499.       /* Don't do __builtin_apply_args more than once in a function.
  7500.      Save the result of the first call and reuse it.  */
  7501.       if (apply_args_value != 0)
  7502.     return apply_args_value;
  7503.       {
  7504.     /* When this function is called, it means that registers must be
  7505.        saved on entry to this function.  So we migrate the
  7506.        call to the first insn of this function.  */
  7507.     rtx temp;
  7508.     rtx seq;
  7509.  
  7510.     start_sequence ();
  7511.     temp = expand_builtin_apply_args ();
  7512.     seq = get_insns ();
  7513.     end_sequence ();
  7514.  
  7515.     apply_args_value = temp;
  7516.  
  7517.     /* Put the sequence after the NOTE that starts the function.
  7518.        If this is inside a SEQUENCE, make the outer-level insn
  7519.        chain current, so the code is placed at the start of the
  7520.        function.  */
  7521.     push_topmost_sequence ();
  7522.     emit_insns_before (seq, NEXT_INSN (get_insns ()));
  7523.     pop_topmost_sequence ();
  7524.     return temp;
  7525.       }
  7526.  
  7527.       /* __builtin_apply (FUNCTION, ARGUMENTS, ARGSIZE) invokes
  7528.      FUNCTION with a copy of the parameters described by
  7529.      ARGUMENTS, and ARGSIZE.  It returns a block of memory
  7530.      allocated on the stack into which is stored all the registers
  7531.      that might possibly be used for returning the result of a
  7532.      function.  ARGUMENTS is the value returned by
  7533.      __builtin_apply_args.  ARGSIZE is the number of bytes of
  7534.      arguments that must be copied.  ??? How should this value be
  7535.      computed?  We'll also need a safe worst case value for varargs
  7536.      functions.  */
  7537.     case BUILT_IN_APPLY:
  7538.       if (arglist == 0
  7539.       /* Arg could be non-pointer if user redeclared this fcn wrong.  */
  7540.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != POINTER_TYPE
  7541.       || TREE_CHAIN (arglist) == 0
  7542.       || TREE_CODE (TREE_TYPE (TREE_VALUE (TREE_CHAIN (arglist)))) != POINTER_TYPE
  7543.       || TREE_CHAIN (TREE_CHAIN (arglist)) == 0
  7544.       || TREE_CODE (TREE_TYPE (TREE_VALUE (TREE_CHAIN (TREE_CHAIN (arglist))))) != INTEGER_TYPE)
  7545.     return const0_rtx;
  7546.       else
  7547.     {
  7548.       int i;
  7549.       tree t;
  7550.       rtx ops[3];
  7551.  
  7552.       for (t = arglist, i = 0; t; t = TREE_CHAIN (t), i++)
  7553.         ops[i] = expand_expr (TREE_VALUE (t), NULL_RTX, VOIDmode, 0);
  7554.  
  7555.       return expand_builtin_apply (ops[0], ops[1], ops[2]);
  7556.     }
  7557.  
  7558.       /* __builtin_return (RESULT) causes the function to return the
  7559.      value described by RESULT.  RESULT is address of the block of
  7560.      memory returned by __builtin_apply.  */
  7561.     case BUILT_IN_RETURN:
  7562.       if (arglist
  7563.       /* Arg could be non-pointer if user redeclared this fcn wrong.  */
  7564.       && TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) == POINTER_TYPE)
  7565.     expand_builtin_return (expand_expr (TREE_VALUE (arglist),
  7566.                         NULL_RTX, VOIDmode, 0));
  7567.       return const0_rtx;
  7568.  
  7569.     case BUILT_IN_SAVEREGS:
  7570.       /* Don't do __builtin_saveregs more than once in a function.
  7571.      Save the result of the first call and reuse it.  */
  7572.       if (saveregs_value != 0)
  7573.     return saveregs_value;
  7574.       {
  7575.     /* When this function is called, it means that registers must be
  7576.        saved on entry to this function.  So we migrate the
  7577.        call to the first insn of this function.  */
  7578.     rtx temp;
  7579.     rtx seq;
  7580.  
  7581.     /* Now really call the function.  `expand_call' does not call
  7582.        expand_builtin, so there is no danger of infinite recursion here.  */
  7583.     start_sequence ();
  7584.  
  7585. #ifdef EXPAND_BUILTIN_SAVEREGS
  7586.     /* Do whatever the machine needs done in this case.  */
  7587.     temp = EXPAND_BUILTIN_SAVEREGS (arglist);
  7588. #else
  7589.     /* The register where the function returns its value
  7590.        is likely to have something else in it, such as an argument.
  7591.        So preserve that register around the call.  */
  7592.  
  7593.     if (value_mode != VOIDmode)
  7594.       {
  7595.         rtx valreg = hard_libcall_value (value_mode);
  7596.         rtx saved_valreg = gen_reg_rtx (value_mode);
  7597.  
  7598.         emit_move_insn (saved_valreg, valreg);
  7599.         temp = expand_call (exp, target, ignore);
  7600.         emit_move_insn (valreg, saved_valreg);
  7601.       }
  7602.     else
  7603.       /* Generate the call, putting the value in a pseudo.  */
  7604.       temp = expand_call (exp, target, ignore);
  7605. #endif
  7606.  
  7607.     seq = get_insns ();
  7608.     end_sequence ();
  7609.  
  7610.     saveregs_value = temp;
  7611.  
  7612.     /* Put the sequence after the NOTE that starts the function.
  7613.        If this is inside a SEQUENCE, make the outer-level insn
  7614.        chain current, so the code is placed at the start of the
  7615.        function.  */
  7616.     push_topmost_sequence ();
  7617.     emit_insns_before (seq, NEXT_INSN (get_insns ()));
  7618.     pop_topmost_sequence ();
  7619.     return temp;
  7620.       }
  7621.  
  7622.       /* __builtin_args_info (N) returns word N of the arg space info
  7623.      for the current function.  The number and meanings of words
  7624.      is controlled by the definition of CUMULATIVE_ARGS.  */
  7625.     case BUILT_IN_ARGS_INFO:
  7626.       {
  7627.     int nwords = sizeof (CUMULATIVE_ARGS) / sizeof (int);
  7628.     int i;
  7629.     int *word_ptr = (int *) ¤t_function_args_info;
  7630.     tree type, elts, result;
  7631.  
  7632.     if (sizeof (CUMULATIVE_ARGS) % sizeof (int) != 0)
  7633.       fatal ("CUMULATIVE_ARGS type defined badly; see %s, line %d",
  7634.          __FILE__, __LINE__);
  7635.  
  7636.     if (arglist != 0)
  7637.       {
  7638.         tree arg = TREE_VALUE (arglist);
  7639.         if (TREE_CODE (arg) != INTEGER_CST)
  7640.           error ("argument of `__builtin_args_info' must be constant");
  7641.         else
  7642.           {
  7643.         int wordnum = TREE_INT_CST_LOW (arg);
  7644.  
  7645.         if (wordnum < 0 || wordnum >= nwords || TREE_INT_CST_HIGH (arg))
  7646.           error ("argument of `__builtin_args_info' out of range");
  7647.         else
  7648.           return GEN_INT (word_ptr[wordnum]);
  7649.           }
  7650.       }
  7651.     else
  7652.       error ("missing argument in `__builtin_args_info'");
  7653.  
  7654.     return const0_rtx;
  7655.  
  7656. #if 0
  7657.     for (i = 0; i < nwords; i++)
  7658.       elts = tree_cons (NULL_TREE, build_int_2 (word_ptr[i], 0));
  7659.  
  7660.     type = build_array_type (integer_type_node,
  7661.                  build_index_type (build_int_2 (nwords, 0)));
  7662.     result = build (CONSTRUCTOR, type, NULL_TREE, nreverse (elts));
  7663.     TREE_CONSTANT (result) = 1;
  7664.     TREE_STATIC (result) = 1;
  7665.     result = build (INDIRECT_REF, build_pointer_type (type), result);
  7666.     TREE_CONSTANT (result) = 1;
  7667.     return expand_expr (result, NULL_RTX, VOIDmode, 0);
  7668. #endif
  7669.       }
  7670.  
  7671.       /* Return the address of the first anonymous stack arg.  */
  7672.     case BUILT_IN_NEXT_ARG:
  7673.       {
  7674.     tree fntype = TREE_TYPE (current_function_decl);
  7675.  
  7676.     if ((TYPE_ARG_TYPES (fntype) == 0
  7677.          || (TREE_VALUE (tree_last (TYPE_ARG_TYPES (fntype)))
  7678.          == void_type_node))
  7679.         && ! current_function_varargs)
  7680.       {
  7681.         error ("`va_start' used in function with fixed args");
  7682.         return const0_rtx;
  7683.       }
  7684.  
  7685.     if (arglist)
  7686.       {
  7687.         tree last_parm = tree_last (DECL_ARGUMENTS (current_function_decl));
  7688.         tree arg = TREE_VALUE (arglist);
  7689.  
  7690.         /* Strip off all nops for the sake of the comparison.  This
  7691.            is not quite the same as STRIP_NOPS.  It does more.  */
  7692.         while (TREE_CODE (arg) == NOP_EXPR
  7693.            || TREE_CODE (arg) == CONVERT_EXPR
  7694.            || TREE_CODE (arg) == NON_LVALUE_EXPR)
  7695.           arg = TREE_OPERAND (arg, 0);
  7696.         if (arg != last_parm)
  7697.           warning ("second parameter of `va_start' not last named argument");
  7698.       }
  7699.     else if (! current_function_varargs)
  7700.       /* Evidently an out of date version of <stdarg.h>; can't validate
  7701.          va_start's second argument, but can still work as intended.  */
  7702.       warning ("`__builtin_next_arg' called without an argument");
  7703.       }
  7704.  
  7705.       return expand_binop (Pmode, add_optab,
  7706.                current_function_internal_arg_pointer,
  7707.                current_function_arg_offset_rtx,
  7708.                NULL_RTX, 0, OPTAB_LIB_WIDEN);
  7709.  
  7710.     case BUILT_IN_CLASSIFY_TYPE:
  7711.       if (arglist != 0)
  7712.     {
  7713.       tree type = TREE_TYPE (TREE_VALUE (arglist));
  7714.       enum tree_code code = TREE_CODE (type);
  7715.       if (code == VOID_TYPE)
  7716.         return GEN_INT (void_type_class);
  7717.       if (code == INTEGER_TYPE)
  7718.         return GEN_INT (integer_type_class);
  7719.       if (code == CHAR_TYPE)
  7720.         return GEN_INT (char_type_class);
  7721.       if (code == ENUMERAL_TYPE)
  7722.         return GEN_INT (enumeral_type_class);
  7723.       if (code == BOOLEAN_TYPE)
  7724.         return GEN_INT (boolean_type_class);
  7725.       if (code == POINTER_TYPE)
  7726.         return GEN_INT (pointer_type_class);
  7727.       if (code == REFERENCE_TYPE)
  7728.         return GEN_INT (reference_type_class);
  7729.       if (code == OFFSET_TYPE)
  7730.         return GEN_INT (offset_type_class);
  7731.       if (code == REAL_TYPE)
  7732.         return GEN_INT (real_type_class);
  7733.       if (code == COMPLEX_TYPE)
  7734.         return GEN_INT (complex_type_class);
  7735.       if (code == FUNCTION_TYPE)
  7736.         return GEN_INT (function_type_class);
  7737.       if (code == METHOD_TYPE)
  7738.         return GEN_INT (method_type_class);
  7739.       if (code == RECORD_TYPE)
  7740.         return GEN_INT (record_type_class);
  7741.       if (code == UNION_TYPE || code == QUAL_UNION_TYPE)
  7742.         return GEN_INT (union_type_class);
  7743.       if (code == ARRAY_TYPE)
  7744.         {
  7745.           if (TYPE_STRING_FLAG (type))
  7746.         return GEN_INT (string_type_class);
  7747.           else
  7748.         return GEN_INT (array_type_class);
  7749.         }
  7750.       if (code == SET_TYPE)
  7751.         return GEN_INT (set_type_class);
  7752.       if (code == FILE_TYPE)
  7753.         return GEN_INT (file_type_class);
  7754.       if (code == LANG_TYPE)
  7755.         return GEN_INT (lang_type_class);
  7756.     }
  7757.       return GEN_INT (no_type_class);
  7758.  
  7759.     case BUILT_IN_CONSTANT_P:
  7760.       if (arglist == 0)
  7761.     return const0_rtx;
  7762.       else
  7763.     {
  7764.       tree arg = TREE_VALUE (arglist);
  7765.  
  7766.       STRIP_NOPS (arg);
  7767.       return (TREE_CODE_CLASS (TREE_CODE (arg)) == 'c'
  7768.           || (TREE_CODE (arg) == ADDR_EXPR
  7769.               && TREE_CODE (TREE_OPERAND (arg, 0)) == STRING_CST)
  7770.           ? const1_rtx : const0_rtx);
  7771.     }
  7772.  
  7773.     case BUILT_IN_FRAME_ADDRESS:
  7774.       /* The argument must be a nonnegative integer constant.
  7775.      It counts the number of frames to scan up the stack.
  7776.      The value is the address of that frame.  */
  7777.     case BUILT_IN_RETURN_ADDRESS:
  7778.       /* The argument must be a nonnegative integer constant.
  7779.      It counts the number of frames to scan up the stack.
  7780.      The value is the return address saved in that frame.  */
  7781.       if (arglist == 0)
  7782.     /* Warning about missing arg was already issued.  */
  7783.     return const0_rtx;
  7784.       else if (TREE_CODE (TREE_VALUE (arglist)) != INTEGER_CST)
  7785.     {
  7786.       error ("invalid arg to `__builtin_return_address'");
  7787.       return const0_rtx;
  7788.     }
  7789.       else if (tree_int_cst_sgn (TREE_VALUE (arglist)) < 0)
  7790.     {
  7791.       error ("invalid arg to `__builtin_return_address'");
  7792.       return const0_rtx;
  7793.     }
  7794.       else
  7795.     {
  7796.       rtx tem = expand_builtin_return_addr (DECL_FUNCTION_CODE (fndecl),
  7797.                         TREE_INT_CST_LOW (TREE_VALUE (arglist)),
  7798.                         hard_frame_pointer_rtx);
  7799.  
  7800.       /* For __builtin_frame_address, return what we've got.  */
  7801.       if (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_FRAME_ADDRESS)
  7802.         return tem;
  7803.  
  7804.       if (GET_CODE (tem) != REG)
  7805.         tem = copy_to_reg (tem);
  7806.       return tem;
  7807.     }
  7808.  
  7809.     case BUILT_IN_ALLOCA:
  7810.       if (arglist == 0
  7811.       /* Arg could be non-integer if user redeclared this fcn wrong.  */
  7812.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != INTEGER_TYPE)
  7813.     break;
  7814.  
  7815.       /* Compute the argument.  */
  7816.       op0 = expand_expr (TREE_VALUE (arglist), NULL_RTX, VOIDmode, 0);
  7817.  
  7818.       /* Allocate the desired space.  */
  7819.       return allocate_dynamic_stack_space (op0, target, BITS_PER_UNIT);
  7820.  
  7821.     case BUILT_IN_FFS:
  7822.       /* If not optimizing, call the library function.  */
  7823.       if (!optimize && ! CALLED_AS_BUILT_IN (fndecl))
  7824.     break;
  7825.  
  7826.       if (arglist == 0
  7827.       /* Arg could be non-integer if user redeclared this fcn wrong.  */
  7828.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != INTEGER_TYPE)
  7829.     break;
  7830.  
  7831.       /* Compute the argument.  */
  7832.       op0 = expand_expr (TREE_VALUE (arglist), subtarget, VOIDmode, 0);
  7833.       /* Compute ffs, into TARGET if possible.
  7834.      Set TARGET to wherever the result comes back.  */
  7835.       target = expand_unop (TYPE_MODE (TREE_TYPE (TREE_VALUE (arglist))),
  7836.                 ffs_optab, op0, target, 1);
  7837.       if (target == 0)
  7838.     abort ();
  7839.       return target;
  7840.  
  7841.     case BUILT_IN_STRLEN:
  7842.       /* If not optimizing, call the library function.  */
  7843.       if (!optimize && ! CALLED_AS_BUILT_IN (fndecl))
  7844.     break;
  7845.  
  7846.       if (arglist == 0
  7847.       /* Arg could be non-pointer if user redeclared this fcn wrong.  */
  7848.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != POINTER_TYPE)
  7849.     break;
  7850.       else
  7851.     {
  7852.       tree src = TREE_VALUE (arglist);
  7853.       tree len = c_strlen (src);
  7854.  
  7855.       int align
  7856.         = get_pointer_alignment (src, BIGGEST_ALIGNMENT) / BITS_PER_UNIT;
  7857.  
  7858.       rtx result, src_rtx, char_rtx;
  7859.       enum machine_mode insn_mode = value_mode, char_mode;
  7860.       enum insn_code icode;
  7861.  
  7862.       /* If the length is known, just return it. */
  7863.       if (len != 0)
  7864.         return expand_expr (len, target, mode, 0);
  7865.  
  7866.       /* If SRC is not a pointer type, don't do this operation inline. */
  7867.       if (align == 0)
  7868.         break;
  7869.  
  7870.       /* Call a function if we can't compute strlen in the right mode. */
  7871.  
  7872.       while (insn_mode != VOIDmode)
  7873.         {
  7874.           icode = strlen_optab->handlers[(int) insn_mode].insn_code;
  7875.           if (icode != CODE_FOR_nothing)
  7876.         break;
  7877.  
  7878.           insn_mode = GET_MODE_WIDER_MODE (insn_mode);
  7879.         }
  7880.       if (insn_mode == VOIDmode)
  7881.         break;
  7882.  
  7883.       /* Make a place to write the result of the instruction.  */
  7884.       result = target;
  7885.       if (! (result != 0
  7886.          && GET_CODE (result) == REG
  7887.          && GET_MODE (result) == insn_mode
  7888.          && REGNO (result) >= FIRST_PSEUDO_REGISTER))
  7889.         result = gen_reg_rtx (insn_mode);
  7890.  
  7891.       /* Make sure the operands are acceptable to the predicates.  */
  7892.  
  7893.       if (! (*insn_operand_predicate[(int)icode][0]) (result, insn_mode))
  7894.         result = gen_reg_rtx (insn_mode);
  7895.  
  7896.       src_rtx = memory_address (BLKmode,
  7897.                     expand_expr (src, NULL_RTX, ptr_mode,
  7898.                          EXPAND_NORMAL));
  7899.       if (! (*insn_operand_predicate[(int)icode][1]) (src_rtx, Pmode))
  7900.         src_rtx = copy_to_mode_reg (Pmode, src_rtx);
  7901.  
  7902.       char_rtx = const0_rtx;
  7903.       char_mode = insn_operand_mode[(int)icode][2];
  7904.       if (! (*insn_operand_predicate[(int)icode][2]) (char_rtx, char_mode))
  7905.         char_rtx = copy_to_mode_reg (char_mode, char_rtx);
  7906.  
  7907.       emit_insn (GEN_FCN (icode) (result,
  7908.                       gen_rtx (MEM, BLKmode, src_rtx),
  7909.                       char_rtx, GEN_INT (align)));
  7910.  
  7911.       /* Return the value in the proper mode for this function.  */
  7912.       if (GET_MODE (result) == value_mode)
  7913.         return result;
  7914.       else if (target != 0)
  7915.         {
  7916.           convert_move (target, result, 0);
  7917.           return target;
  7918.         }
  7919.       else
  7920.         return convert_to_mode (value_mode, result, 0);
  7921.     }
  7922.  
  7923.     case BUILT_IN_STRCPY:
  7924.       /* If not optimizing, call the library function.  */
  7925.       if (!optimize && ! CALLED_AS_BUILT_IN (fndecl))
  7926.     break;
  7927.  
  7928.       if (arglist == 0
  7929.       /* Arg could be non-pointer if user redeclared this fcn wrong.  */
  7930.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != POINTER_TYPE
  7931.       || TREE_CHAIN (arglist) == 0
  7932.       || TREE_CODE (TREE_TYPE (TREE_VALUE (TREE_CHAIN (arglist)))) != POINTER_TYPE)
  7933.     break;
  7934.       else
  7935.     {
  7936.       tree len = c_strlen (TREE_VALUE (TREE_CHAIN (arglist)));
  7937.  
  7938.       if (len == 0)
  7939.         break;
  7940.  
  7941.       len = size_binop (PLUS_EXPR, len, integer_one_node);
  7942.  
  7943.       chainon (arglist, build_tree_list (NULL_TREE, len));
  7944.     }
  7945.  
  7946.       /* Drops in.  */
  7947.     case BUILT_IN_MEMCPY:
  7948.       /* If not optimizing, call the library function.  */
  7949.       if (!optimize && ! CALLED_AS_BUILT_IN (fndecl))
  7950.     break;
  7951.  
  7952.       if (arglist == 0
  7953.       /* Arg could be non-pointer if user redeclared this fcn wrong.  */
  7954.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != POINTER_TYPE
  7955.       || TREE_CHAIN (arglist) == 0
  7956.       || TREE_CODE (TREE_TYPE (TREE_VALUE (TREE_CHAIN (arglist)))) != POINTER_TYPE
  7957.       || TREE_CHAIN (TREE_CHAIN (arglist)) == 0
  7958.       || TREE_CODE (TREE_TYPE (TREE_VALUE (TREE_CHAIN (TREE_CHAIN (arglist))))) != INTEGER_TYPE)
  7959.     break;
  7960.       else
  7961.     {
  7962.       tree dest = TREE_VALUE (arglist);
  7963.       tree src = TREE_VALUE (TREE_CHAIN (arglist));
  7964.       tree len = TREE_VALUE (TREE_CHAIN (TREE_CHAIN (arglist)));
  7965.       tree type;
  7966.  
  7967.       int src_align
  7968.         = get_pointer_alignment (src, BIGGEST_ALIGNMENT) / BITS_PER_UNIT;
  7969.       int dest_align
  7970.         = get_pointer_alignment (dest, BIGGEST_ALIGNMENT) / BITS_PER_UNIT;
  7971.       rtx dest_rtx, dest_mem, src_mem;
  7972.  
  7973.       /* If either SRC or DEST is not a pointer type, don't do
  7974.          this operation in-line.  */
  7975.       if (src_align == 0 || dest_align == 0)
  7976.         {
  7977.           if (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_STRCPY)
  7978.         TREE_CHAIN (TREE_CHAIN (arglist)) = 0;
  7979.           break;
  7980.         }
  7981.  
  7982.       dest_rtx = expand_expr (dest, NULL_RTX, ptr_mode, EXPAND_SUM);
  7983.       dest_mem = gen_rtx (MEM, BLKmode,
  7984.                   memory_address (BLKmode, dest_rtx));
  7985.       /* There could be a void* cast on top of the object.  */
  7986.       while (TREE_CODE (dest) == NOP_EXPR)
  7987.         dest = TREE_OPERAND (dest, 0);
  7988.       type = TREE_TYPE (TREE_TYPE (dest));
  7989.       MEM_IN_STRUCT_P (dest_mem) = AGGREGATE_TYPE_P (type);
  7990.       src_mem = gen_rtx (MEM, BLKmode,
  7991.                  memory_address (BLKmode,
  7992.                          expand_expr (src, NULL_RTX,
  7993.                               ptr_mode,
  7994.                               EXPAND_SUM)));
  7995.       /* There could be a void* cast on top of the object.  */
  7996.       while (TREE_CODE (src) == NOP_EXPR)
  7997.         src = TREE_OPERAND (src, 0);
  7998.       type = TREE_TYPE (TREE_TYPE (src));
  7999.       MEM_IN_STRUCT_P (src_mem) = AGGREGATE_TYPE_P (type);
  8000.  
  8001.       /* Copy word part most expediently.  */
  8002.       emit_block_move (dest_mem, src_mem,
  8003.                expand_expr (len, NULL_RTX, VOIDmode, 0),
  8004.                MIN (src_align, dest_align));
  8005.       return force_operand (dest_rtx, NULL_RTX);
  8006.     }
  8007.  
  8008. /* These comparison functions need an instruction that returns an actual
  8009.    index.  An ordinary compare that just sets the condition codes
  8010.    is not enough.  */
  8011. #ifdef HAVE_cmpstrsi
  8012.     case BUILT_IN_STRCMP:
  8013.       /* If not optimizing, call the library function.  */
  8014.       if (!optimize && ! CALLED_AS_BUILT_IN (fndecl))
  8015.     break;
  8016.  
  8017.       if (arglist == 0
  8018.       /* Arg could be non-pointer if user redeclared this fcn wrong.  */
  8019.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != POINTER_TYPE
  8020.       || TREE_CHAIN (arglist) == 0
  8021.       || TREE_CODE (TREE_TYPE (TREE_VALUE (TREE_CHAIN (arglist)))) != POINTER_TYPE)
  8022.     break;
  8023.       else if (!HAVE_cmpstrsi)
  8024.     break;
  8025.       {
  8026.     tree arg1 = TREE_VALUE (arglist);
  8027.     tree arg2 = TREE_VALUE (TREE_CHAIN (arglist));
  8028.     tree offset;
  8029.     tree len, len2;
  8030.  
  8031.     len = c_strlen (arg1);
  8032.     if (len)
  8033.       len = size_binop (PLUS_EXPR, integer_one_node, len);
  8034.     len2 = c_strlen (arg2);
  8035.     if (len2)
  8036.       len2 = size_binop (PLUS_EXPR, integer_one_node, len2);
  8037.  
  8038.     /* If we don't have a constant length for the first, use the length
  8039.        of the second, if we know it.  We don't require a constant for
  8040.        this case; some cost analysis could be done if both are available
  8041.        but neither is constant.  For now, assume they're equally cheap.
  8042.  
  8043.        If both strings have constant lengths, use the smaller.  This
  8044.        could arise if optimization results in strcpy being called with
  8045.        two fixed strings, or if the code was machine-generated.  We should
  8046.        add some code to the `memcmp' handler below to deal with such
  8047.        situations, someday.  */
  8048.     if (!len || TREE_CODE (len) != INTEGER_CST)
  8049.       {
  8050.         if (len2)
  8051.           len = len2;
  8052.         else if (len == 0)
  8053.           break;
  8054.       }
  8055.     else if (len2 && TREE_CODE (len2) == INTEGER_CST)
  8056.       {
  8057.         if (tree_int_cst_lt (len2, len))
  8058.           len = len2;
  8059.       }
  8060.  
  8061.     chainon (arglist, build_tree_list (NULL_TREE, len));
  8062.       }
  8063.  
  8064.       /* Drops in.  */
  8065.     case BUILT_IN_MEMCMP:
  8066.       /* If not optimizing, call the library function.  */
  8067.       if (!optimize && ! CALLED_AS_BUILT_IN (fndecl))
  8068.     break;
  8069.  
  8070.       if (arglist == 0
  8071.       /* Arg could be non-pointer if user redeclared this fcn wrong.  */
  8072.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != POINTER_TYPE
  8073.       || TREE_CHAIN (arglist) == 0
  8074.       || TREE_CODE (TREE_TYPE (TREE_VALUE (TREE_CHAIN (arglist)))) != POINTER_TYPE
  8075.       || TREE_CHAIN (TREE_CHAIN (arglist)) == 0
  8076.       || TREE_CODE (TREE_TYPE (TREE_VALUE (TREE_CHAIN (TREE_CHAIN (arglist))))) != INTEGER_TYPE)
  8077.     break;
  8078.       else if (!HAVE_cmpstrsi)
  8079.     break;
  8080.       {
  8081.     tree arg1 = TREE_VALUE (arglist);
  8082.     tree arg2 = TREE_VALUE (TREE_CHAIN (arglist));
  8083.     tree len = TREE_VALUE (TREE_CHAIN (TREE_CHAIN (arglist)));
  8084.     rtx result;
  8085.  
  8086.     int arg1_align
  8087.       = get_pointer_alignment (arg1, BIGGEST_ALIGNMENT) / BITS_PER_UNIT;
  8088.     int arg2_align
  8089.       = get_pointer_alignment (arg2, BIGGEST_ALIGNMENT) / BITS_PER_UNIT;
  8090.     enum machine_mode insn_mode
  8091.       = insn_operand_mode[(int) CODE_FOR_cmpstrsi][0];
  8092.  
  8093.     /* If we don't have POINTER_TYPE, call the function.  */
  8094.     if (arg1_align == 0 || arg2_align == 0)
  8095.       {
  8096.         if (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_STRCMP)
  8097.           TREE_CHAIN (TREE_CHAIN (arglist)) = 0;
  8098.         break;
  8099.       }
  8100.  
  8101.     /* Make a place to write the result of the instruction.  */
  8102.     result = target;
  8103.     if (! (result != 0
  8104.            && GET_CODE (result) == REG && GET_MODE (result) == insn_mode
  8105.            && REGNO (result) >= FIRST_PSEUDO_REGISTER))
  8106.       result = gen_reg_rtx (insn_mode);
  8107.  
  8108.     emit_insn (gen_cmpstrsi (result,
  8109.                  gen_rtx (MEM, BLKmode,
  8110.                       expand_expr (arg1, NULL_RTX,
  8111.                                ptr_mode,
  8112.                                EXPAND_NORMAL)),
  8113.                  gen_rtx (MEM, BLKmode,
  8114.                       expand_expr (arg2, NULL_RTX,
  8115.                                ptr_mode,
  8116.                                EXPAND_NORMAL)),
  8117.                  expand_expr (len, NULL_RTX, VOIDmode, 0),
  8118.                  GEN_INT (MIN (arg1_align, arg2_align))));
  8119.  
  8120.     /* Return the value in the proper mode for this function.  */
  8121.     mode = TYPE_MODE (TREE_TYPE (exp));
  8122.     if (GET_MODE (result) == mode)
  8123.       return result;
  8124.     else if (target != 0)
  8125.       {
  8126.         convert_move (target, result, 0);
  8127.         return target;
  8128.       }
  8129.     else
  8130.       return convert_to_mode (mode, result, 0);
  8131.       }    
  8132. #else
  8133.     case BUILT_IN_STRCMP:
  8134.     case BUILT_IN_MEMCMP:
  8135.       break;
  8136. #endif
  8137.  
  8138.     default:            /* just do library call, if unknown builtin */
  8139.       error ("built-in function `%s' not currently supported",
  8140.          IDENTIFIER_POINTER (DECL_NAME (fndecl)));
  8141.     }
  8142.  
  8143.   /* The switch statement above can drop through to cause the function
  8144.      to be called normally.  */
  8145.  
  8146.   return expand_call (exp, target, ignore);
  8147. }
  8148.  
  8149. /* Built-in functions to perform an untyped call and return.  */
  8150.  
  8151. /* For each register that may be used for calling a function, this
  8152.    gives a mode used to copy the register's value.  VOIDmode indicates
  8153.    the register is not used for calling a function.  If the machine
  8154.    has register windows, this gives only the outbound registers.
  8155.    INCOMING_REGNO gives the corresponding inbound register.  */
  8156. static enum machine_mode apply_args_mode[FIRST_PSEUDO_REGISTER];
  8157.  
  8158. /* For each register that may be used for returning values, this gives
  8159.    a mode used to copy the register's value.  VOIDmode indicates the
  8160.    register is not used for returning values.  If the machine has
  8161.    register windows, this gives only the outbound registers.
  8162.    INCOMING_REGNO gives the corresponding inbound register.  */
  8163. static enum machine_mode apply_result_mode[FIRST_PSEUDO_REGISTER];
  8164.  
  8165. /* For each register that may be used for calling a function, this
  8166.    gives the offset of that register into the block returned by
  8167.    __builtin_apply_args.  0 indicates that the register is not
  8168.    used for calling a function. */
  8169. static int apply_args_reg_offset[FIRST_PSEUDO_REGISTER];
  8170.  
  8171. /* Return the offset of register REGNO into the block returned by 
  8172.    __builtin_apply_args.  This is not declared static, since it is
  8173.    needed in objc-act.c. */
  8174.  
  8175. int 
  8176. apply_args_register_offset (regno)
  8177.      int regno;
  8178. {
  8179.   apply_args_size ();
  8180.  
  8181.   /* Arguments are always put in outgoing registers (in the argument
  8182.      block) if such make sense. */
  8183. #ifdef OUTGOING_REGNO
  8184.   regno = OUTGOING_REGNO(regno);
  8185. #endif
  8186.   return apply_args_reg_offset[regno];
  8187. }
  8188.  
  8189. /* Return the size required for the block returned by __builtin_apply_args,
  8190.    and initialize apply_args_mode.  */
  8191.  
  8192. static int
  8193. apply_args_size ()
  8194. {
  8195.   static int size = -1;
  8196.   int align, regno;
  8197.   enum machine_mode mode;
  8198.  
  8199.   /* The values computed by this function never change.  */
  8200.   if (size < 0)
  8201.     {
  8202.       /* The first value is the incoming arg-pointer.  */
  8203.       size = GET_MODE_SIZE (Pmode);
  8204.  
  8205.       /* The second value is the structure value address unless this is
  8206.      passed as an "invisible" first argument.  */
  8207.       if (struct_value_rtx)
  8208.     size += GET_MODE_SIZE (Pmode);
  8209.  
  8210.       for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
  8211.     if (FUNCTION_ARG_REGNO_P (regno))
  8212.       {
  8213.         /* Search for the proper mode for copying this register's
  8214.            value.  I'm not sure this is right, but it works so far.  */
  8215.         enum machine_mode best_mode = VOIDmode;
  8216.  
  8217.         for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT);
  8218.          mode != VOIDmode;
  8219.          mode = GET_MODE_WIDER_MODE (mode))
  8220.           if (HARD_REGNO_MODE_OK (regno, mode)
  8221.           && HARD_REGNO_NREGS (regno, mode) == 1)
  8222.         best_mode = mode;
  8223.  
  8224.         if (best_mode == VOIDmode)
  8225.           for (mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT);
  8226.            mode != VOIDmode;
  8227.            mode = GET_MODE_WIDER_MODE (mode))
  8228.         if (HARD_REGNO_MODE_OK (regno, mode)
  8229.             && (mov_optab->handlers[(int) mode].insn_code
  8230.             != CODE_FOR_nothing))
  8231.           best_mode = mode;
  8232.  
  8233.         mode = best_mode;
  8234.         if (mode == VOIDmode)
  8235.           abort ();
  8236.  
  8237.         align = GET_MODE_ALIGNMENT (mode) / BITS_PER_UNIT;
  8238.         if (size % align != 0)
  8239.           size = CEIL (size, align) * align;
  8240.         apply_args_reg_offset[regno] = size;
  8241.         size += GET_MODE_SIZE (mode);
  8242.         apply_args_mode[regno] = mode;
  8243.       }
  8244.     else
  8245.       {
  8246.         apply_args_mode[regno] = VOIDmode;
  8247.         apply_args_reg_offset[regno] = 0;
  8248.       }
  8249.     }
  8250.   return size;
  8251. }
  8252.  
  8253. /* Return the size required for the block returned by __builtin_apply,
  8254.    and initialize apply_result_mode.  */
  8255.  
  8256. static int
  8257. apply_result_size ()
  8258. {
  8259.   static int size = -1;
  8260.   int align, regno;
  8261.   enum machine_mode mode;
  8262.  
  8263.   /* The values computed by this function never change.  */
  8264.   if (size < 0)
  8265.     {
  8266.       size = 0;
  8267.  
  8268.       for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
  8269.     if (FUNCTION_VALUE_REGNO_P (regno))
  8270.       {
  8271.         /* Search for the proper mode for copying this register's
  8272.            value.  I'm not sure this is right, but it works so far.  */
  8273.         enum machine_mode best_mode = VOIDmode;
  8274.  
  8275.         for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT);
  8276.          mode != TImode;
  8277.          mode = GET_MODE_WIDER_MODE (mode))
  8278.           if (HARD_REGNO_MODE_OK (regno, mode))
  8279.         best_mode = mode;
  8280.  
  8281.         if (best_mode == VOIDmode)
  8282.           for (mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT);
  8283.            mode != VOIDmode;
  8284.            mode = GET_MODE_WIDER_MODE (mode))
  8285.         if (HARD_REGNO_MODE_OK (regno, mode)
  8286.             && (mov_optab->handlers[(int) mode].insn_code
  8287.             != CODE_FOR_nothing))
  8288.           best_mode = mode;
  8289.  
  8290.         mode = best_mode;
  8291.         if (mode == VOIDmode)
  8292.           abort ();
  8293.  
  8294.         align = GET_MODE_ALIGNMENT (mode) / BITS_PER_UNIT;
  8295.         if (size % align != 0)
  8296.           size = CEIL (size, align) * align;
  8297.         size += GET_MODE_SIZE (mode);
  8298.         apply_result_mode[regno] = mode;
  8299.       }
  8300.     else
  8301.       apply_result_mode[regno] = VOIDmode;
  8302.  
  8303.       /* Allow targets that use untyped_call and untyped_return to override
  8304.      the size so that machine-specific information can be stored here.  */
  8305. #ifdef APPLY_RESULT_SIZE
  8306.       size = APPLY_RESULT_SIZE;
  8307. #endif
  8308.     }
  8309.   return size;
  8310. }
  8311.  
  8312. #if defined (HAVE_untyped_call) || defined (HAVE_untyped_return)
  8313. /* Create a vector describing the result block RESULT.  If SAVEP is true,
  8314.    the result block is used to save the values; otherwise it is used to
  8315.    restore the values.  */
  8316.  
  8317. static rtx
  8318. result_vector (savep, result)
  8319.      int savep;
  8320.      rtx result;
  8321. {
  8322.   int regno, size, align, nelts;
  8323.   enum machine_mode mode;
  8324.   rtx reg, mem;
  8325.   rtx *savevec = (rtx *) alloca (FIRST_PSEUDO_REGISTER * sizeof (rtx));
  8326.   
  8327.   size = nelts = 0;
  8328.   for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
  8329.     if ((mode = apply_result_mode[regno]) != VOIDmode)
  8330.       {
  8331.     align = GET_MODE_ALIGNMENT (mode) / BITS_PER_UNIT;
  8332.     if (size % align != 0)
  8333.       size = CEIL (size, align) * align;
  8334.     reg = gen_rtx (REG, mode, savep ? regno : INCOMING_REGNO (regno));
  8335.     mem = change_address (result, mode,
  8336.                   plus_constant (XEXP (result, 0), size));
  8337.     savevec[nelts++] = (savep
  8338.                 ? gen_rtx (SET, VOIDmode, mem, reg)
  8339.                 : gen_rtx (SET, VOIDmode, reg, mem));
  8340.     size += GET_MODE_SIZE (mode);
  8341.       }
  8342.   return gen_rtx (PARALLEL, VOIDmode, gen_rtvec_v (nelts, savevec));
  8343. }
  8344. #endif /* HAVE_untyped_call or HAVE_untyped_return */
  8345.  
  8346. /* Save the state required to perform an untyped call with the same
  8347.    arguments as were passed to the current function.  */
  8348.  
  8349. static rtx
  8350. expand_builtin_apply_args ()
  8351. {
  8352.   rtx registers;
  8353.   int size, align, regno;
  8354.   enum machine_mode mode;
  8355.  
  8356.   /* Create a block where the arg-pointer, structure value address,
  8357.      and argument registers can be saved.  */
  8358.   registers = assign_stack_local (BLKmode, apply_args_size (), -1);
  8359.  
  8360.   /* Walk past the arg-pointer and structure value address.  */
  8361.   size = GET_MODE_SIZE (Pmode);
  8362.   if (struct_value_rtx)
  8363.     size += GET_MODE_SIZE (Pmode);
  8364.  
  8365.   /* Save each register used in calling a function to the block.  */
  8366.   for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
  8367.     if ((mode = apply_args_mode[regno]) != VOIDmode)
  8368.       {
  8369.     rtx tem;
  8370.  
  8371.     align = GET_MODE_ALIGNMENT (mode) / BITS_PER_UNIT;
  8372.     if (size % align != 0)
  8373.       size = CEIL (size, align) * align;
  8374.  
  8375.     tem = gen_rtx (REG, mode, INCOMING_REGNO (regno));
  8376.  
  8377. #ifdef STACK_REGS
  8378.         /* For reg-stack.c's stack register household.
  8379.        Compare with a similar piece of code in function.c.  */
  8380.  
  8381.         emit_insn (gen_rtx (USE, mode, tem));
  8382. #endif
  8383.  
  8384.     emit_move_insn (change_address (registers, mode,
  8385.                     plus_constant (XEXP (registers, 0),
  8386.                                size)),
  8387.             tem);
  8388.     size += GET_MODE_SIZE (mode);
  8389.       }
  8390.  
  8391.   /* Save the arg pointer to the block.  */
  8392.   emit_move_insn (change_address (registers, Pmode, XEXP (registers, 0)),
  8393.           copy_to_reg (virtual_incoming_args_rtx));
  8394.   size = GET_MODE_SIZE (Pmode);
  8395.  
  8396.   /* Save the structure value address unless this is passed as an
  8397.      "invisible" first argument.  */
  8398.   if (struct_value_incoming_rtx)
  8399.     {
  8400.       emit_move_insn (change_address (registers, Pmode,
  8401.                       plus_constant (XEXP (registers, 0),
  8402.                              size)),
  8403.               copy_to_reg (struct_value_incoming_rtx));
  8404.       size += GET_MODE_SIZE (Pmode);
  8405.     }
  8406.  
  8407.   /* Return the address of the block.  */
  8408.   return copy_addr_to_reg (XEXP (registers, 0));
  8409. }
  8410.  
  8411. /* Perform an untyped call and save the state required to perform an
  8412.    untyped return of whatever value was returned by the given function.  */
  8413.  
  8414. static rtx
  8415. expand_builtin_apply (function, arguments, argsize)
  8416.      rtx function, arguments, argsize;
  8417. {
  8418.   int size, align, regno;
  8419.   enum machine_mode mode;
  8420.   rtx incoming_args, result, reg, dest, call_insn;
  8421.   rtx old_stack_level = 0;
  8422.   rtx call_fusage = 0;
  8423.  
  8424.   /* Create a block where the return registers can be saved.  */
  8425.   result = assign_stack_local (BLKmode, apply_result_size (), -1);
  8426.  
  8427.   /* ??? The argsize value should be adjusted here.  */
  8428.  
  8429.   /* Fetch the arg pointer from the ARGUMENTS block.  */
  8430.   incoming_args = gen_reg_rtx (Pmode);
  8431.   emit_move_insn (incoming_args,
  8432.           gen_rtx (MEM, Pmode, arguments));
  8433. #ifndef STACK_GROWS_DOWNWARD
  8434.   incoming_args = expand_binop (Pmode, sub_optab, incoming_args, argsize,
  8435.                 incoming_args, 0, OPTAB_LIB_WIDEN);
  8436. #endif
  8437.  
  8438.   /* Perform postincrements before actually calling the function.  */
  8439.   emit_queue ();
  8440.  
  8441.   /* Push a new argument block and copy the arguments.  */
  8442.   do_pending_stack_adjust ();
  8443.   emit_stack_save (SAVE_BLOCK, &old_stack_level, NULL_RTX);
  8444.  
  8445.   /* Push a block of memory onto the stack to store the memory arguments.
  8446.      Save the address in a register, and copy the memory arguments.  ??? I
  8447.      haven't figured out how the calling convention macros effect this,
  8448.      but it's likely that the source and/or destination addresses in
  8449.      the block copy will need updating in machine specific ways.  */
  8450.   dest = copy_addr_to_reg (push_block (argsize, 0, 0));
  8451.   emit_block_move (gen_rtx (MEM, BLKmode, dest),
  8452.            gen_rtx (MEM, BLKmode, incoming_args),
  8453.            argsize,
  8454.            PARM_BOUNDARY / BITS_PER_UNIT);
  8455.  
  8456.   /* Refer to the argument block.  */
  8457.   apply_args_size ();
  8458.   arguments = gen_rtx (MEM, BLKmode, arguments);
  8459.  
  8460.   /* Walk past the arg-pointer and structure value address.  */
  8461.   size = GET_MODE_SIZE (Pmode);
  8462.   if (struct_value_rtx)
  8463.     size += GET_MODE_SIZE (Pmode);
  8464.  
  8465.   /* Restore each of the registers previously saved.  Make USE insns
  8466.      for each of these registers for use in making the call.  */
  8467.   for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
  8468.     if ((mode = apply_args_mode[regno]) != VOIDmode)
  8469.       {
  8470.     align = GET_MODE_ALIGNMENT (mode) / BITS_PER_UNIT;
  8471.     if (size % align != 0)
  8472.       size = CEIL (size, align) * align;
  8473.     reg = gen_rtx (REG, mode, regno);
  8474.     emit_move_insn (reg,
  8475.             change_address (arguments, mode,
  8476.                     plus_constant (XEXP (arguments, 0),
  8477.                                size)));
  8478.  
  8479.     use_reg (&call_fusage, reg);
  8480.     size += GET_MODE_SIZE (mode);
  8481.       }
  8482.  
  8483.   /* Restore the structure value address unless this is passed as an
  8484.      "invisible" first argument.  */
  8485.   size = GET_MODE_SIZE (Pmode);
  8486.   if (struct_value_rtx)
  8487.     {
  8488.       rtx value = gen_reg_rtx (Pmode);
  8489.       emit_move_insn (value,
  8490.               change_address (arguments, Pmode,
  8491.                       plus_constant (XEXP (arguments, 0),
  8492.                              size)));
  8493.       emit_move_insn (struct_value_rtx, value);
  8494.       if (GET_CODE (struct_value_rtx) == REG)
  8495.       use_reg (&call_fusage, struct_value_rtx);
  8496.       size += GET_MODE_SIZE (Pmode);
  8497.     }
  8498.  
  8499.   /* All arguments and registers used for the call are set up by now!  */
  8500.   function = prepare_call_address (function, NULL_TREE, &call_fusage, 0);
  8501.  
  8502.   /* Ensure address is valid.  SYMBOL_REF is already valid, so no need,
  8503.      and we don't want to load it into a register as an optimization,
  8504.      because prepare_call_address already did it if it should be done.  */
  8505.   if (GET_CODE (function) != SYMBOL_REF)
  8506.     function = memory_address (FUNCTION_MODE, function);
  8507.  
  8508.   /* Generate the actual call instruction and save the return value.  */
  8509. #ifdef HAVE_untyped_call
  8510.   if (HAVE_untyped_call)
  8511.     emit_call_insn (gen_untyped_call (gen_rtx (MEM, FUNCTION_MODE, function),
  8512.                       result, result_vector (1, result)));
  8513.   else
  8514. #endif
  8515. #ifdef HAVE_call_value
  8516.   if (HAVE_call_value)
  8517.     {
  8518.       rtx valreg = 0;
  8519.  
  8520.       /* Locate the unique return register.  It is not possible to
  8521.      express a call that sets more than one return register using
  8522.      call_value; use untyped_call for that.  In fact, untyped_call
  8523.      only needs to save the return registers in the given block.  */
  8524.       for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
  8525.     if ((mode = apply_result_mode[regno]) != VOIDmode)
  8526.       {
  8527.         if (valreg)
  8528.           abort (); /* HAVE_untyped_call required.  */
  8529.         valreg = gen_rtx (REG, mode, regno);
  8530.       }
  8531.  
  8532.       emit_call_insn (gen_call_value (valreg,
  8533.                       gen_rtx (MEM, FUNCTION_MODE, function),
  8534.                       const0_rtx, NULL_RTX, const0_rtx));
  8535.  
  8536.       emit_move_insn (change_address (result, GET_MODE (valreg),
  8537.                       XEXP (result, 0)),
  8538.               valreg);
  8539.     }
  8540.   else
  8541. #endif
  8542.     abort ();
  8543.  
  8544.   /* Find the CALL insn we just emitted.  */
  8545.   for (call_insn = get_last_insn ();
  8546.        call_insn && GET_CODE (call_insn) != CALL_INSN;
  8547.        call_insn = PREV_INSN (call_insn))
  8548.     ;
  8549.  
  8550.   if (! call_insn)
  8551.     abort ();
  8552.  
  8553.   /* Put the register usage information on the CALL.  If there is already
  8554.      some usage information, put ours at the end.  */
  8555.   if (CALL_INSN_FUNCTION_USAGE (call_insn))
  8556.     {
  8557.       rtx link;
  8558.  
  8559.       for (link = CALL_INSN_FUNCTION_USAGE (call_insn); XEXP (link, 1) != 0;
  8560.        link = XEXP (link, 1))
  8561.     ;
  8562.  
  8563.       XEXP (link, 1) = call_fusage;
  8564.     }
  8565.   else
  8566.     CALL_INSN_FUNCTION_USAGE (call_insn) = call_fusage;
  8567.  
  8568.   /* Restore the stack.  */
  8569.   emit_stack_restore (SAVE_BLOCK, old_stack_level, NULL_RTX);
  8570.  
  8571.   /* Return the address of the result block.  */
  8572.   return copy_addr_to_reg (XEXP (result, 0));
  8573. }
  8574.  
  8575. /* Perform an untyped return.  */
  8576.  
  8577. static void
  8578. expand_builtin_return (result)
  8579.      rtx result;
  8580. {
  8581.   int size, align, regno;
  8582.   enum machine_mode mode;
  8583.   rtx reg;
  8584.   rtx call_fusage = 0;
  8585.  
  8586.   apply_result_size ();
  8587.   result = gen_rtx (MEM, BLKmode, result);
  8588.  
  8589. #ifdef HAVE_untyped_return
  8590.   if (HAVE_untyped_return)
  8591.     {
  8592.       emit_jump_insn (gen_untyped_return (result, result_vector (0, result)));
  8593.       emit_barrier ();
  8594.       return;
  8595.     }
  8596. #endif
  8597.  
  8598.   /* Restore the return value and note that each value is used.  */
  8599.   size = 0;
  8600.   for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
  8601.     if ((mode = apply_result_mode[regno]) != VOIDmode)
  8602.       {
  8603.     align = GET_MODE_ALIGNMENT (mode) / BITS_PER_UNIT;
  8604.     if (size % align != 0)
  8605.       size = CEIL (size, align) * align;
  8606.     reg = gen_rtx (REG, mode, INCOMING_REGNO (regno));
  8607.     emit_move_insn (reg,
  8608.             change_address (result, mode,
  8609.                     plus_constant (XEXP (result, 0),
  8610.                                size)));
  8611.  
  8612.     push_to_sequence (call_fusage);
  8613.     emit_insn (gen_rtx (USE, VOIDmode, reg));
  8614.     call_fusage = get_insns ();
  8615.     end_sequence ();
  8616.     size += GET_MODE_SIZE (mode);
  8617.       }
  8618.  
  8619.   /* Put the USE insns before the return.  */
  8620.   emit_insns (call_fusage);
  8621.  
  8622.   /* Return whatever values was restored by jumping directly to the end
  8623.      of the function.  */
  8624.   expand_null_return ();
  8625. }
  8626.  
  8627. /* Expand code for a post- or pre- increment or decrement
  8628.    and return the RTX for the result.
  8629.    POST is 1 for postinc/decrements and 0 for preinc/decrements.  */
  8630.  
  8631. static rtx
  8632. expand_increment (exp, post)
  8633.      register tree exp;
  8634.      int post;
  8635. {
  8636.   register rtx op0, op1;
  8637.   register rtx temp, value;
  8638.   register tree incremented = TREE_OPERAND (exp, 0);
  8639.   optab this_optab = add_optab;
  8640.   int icode;
  8641.   enum machine_mode mode = TYPE_MODE (TREE_TYPE (exp));
  8642.   int op0_is_copy = 0;
  8643.   int single_insn = 0;
  8644.   /* 1 means we can't store into OP0 directly,
  8645.      because it is a subreg narrower than a word,
  8646.      and we don't dare clobber the rest of the word.  */
  8647.   int bad_subreg = 0;
  8648.  
  8649.   if (output_bytecode)
  8650.     {
  8651.       bc_expand_expr (exp);
  8652.       return NULL_RTX;
  8653.     }
  8654.  
  8655.   /* Stabilize any component ref that might need to be
  8656.      evaluated more than once below.  */
  8657.   if (!post
  8658.       || TREE_CODE (incremented) == BIT_FIELD_REF
  8659.       || (TREE_CODE (incremented) == COMPONENT_REF
  8660.       && (TREE_CODE (TREE_OPERAND (incremented, 0)) != INDIRECT_REF
  8661.           || DECL_BIT_FIELD (TREE_OPERAND (incremented, 1)))))
  8662.     incremented = stabilize_reference (incremented);
  8663.   /* Nested *INCREMENT_EXPRs can happen in C++.  We must force innermost
  8664.      ones into save exprs so that they don't accidentally get evaluated
  8665.      more than once by the code below.  */
  8666.   if (TREE_CODE (incremented) == PREINCREMENT_EXPR
  8667.       || TREE_CODE (incremented) == PREDECREMENT_EXPR)
  8668.     incremented = save_expr (incremented);
  8669.  
  8670.   /* Compute the operands as RTX.
  8671.      Note whether OP0 is the actual lvalue or a copy of it:
  8672.      I believe it is a copy iff it is a register or subreg
  8673.      and insns were generated in computing it.   */
  8674.  
  8675.   temp = get_last_insn ();
  8676.   op0 = expand_expr (incremented, NULL_RTX, VOIDmode, 0);
  8677.  
  8678.   /* If OP0 is a SUBREG made for a promoted variable, we cannot increment
  8679.      in place but instead must do sign- or zero-extension during assignment,
  8680.      so we copy it into a new register and let the code below use it as
  8681.      a copy.
  8682.  
  8683.      Note that we can safely modify this SUBREG since it is know not to be
  8684.      shared (it was made by the expand_expr call above).  */
  8685.  
  8686.   if (GET_CODE (op0) == SUBREG && SUBREG_PROMOTED_VAR_P (op0))
  8687.     {
  8688.       if (post)
  8689.     SUBREG_REG (op0) = copy_to_reg (SUBREG_REG (op0));
  8690.       else
  8691.     bad_subreg = 1;
  8692.     }
  8693.   else if (GET_CODE (op0) == SUBREG
  8694.        && GET_MODE_BITSIZE (GET_MODE (op0)) < BITS_PER_WORD)
  8695.     {
  8696.       /* We cannot increment this SUBREG in place.  If we are
  8697.      post-incrementing, get a copy of the old value.  Otherwise,
  8698.      just mark that we cannot increment in place.  */
  8699.       if (post)
  8700.     op0 = copy_to_reg (op0);
  8701.       else
  8702.     bad_subreg = 1;
  8703.     }
  8704.  
  8705.   op0_is_copy = ((GET_CODE (op0) == SUBREG || GET_CODE (op0) == REG)
  8706.          && temp != get_last_insn ());
  8707.   op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0);
  8708.  
  8709.   /* Decide whether incrementing or decrementing.  */
  8710.   if (TREE_CODE (exp) == POSTDECREMENT_EXPR
  8711.       || TREE_CODE (exp) == PREDECREMENT_EXPR)
  8712.     this_optab = sub_optab;
  8713.  
  8714.   /* Convert decrement by a constant into a negative increment.  */
  8715.   if (this_optab == sub_optab
  8716.       && GET_CODE (op1) == CONST_INT)
  8717.     {
  8718.       op1 = GEN_INT (- INTVAL (op1));
  8719.       this_optab = add_optab;
  8720.     }
  8721.  
  8722.   /* For a preincrement, see if we can do this with a single instruction.  */
  8723.   if (!post)
  8724.     {
  8725.       icode = (int) this_optab->handlers[(int) mode].insn_code;
  8726.       if (icode != (int) CODE_FOR_nothing
  8727.       /* Make sure that OP0 is valid for operands 0 and 1
  8728.          of the insn we want to queue.  */
  8729.       && (*insn_operand_predicate[icode][0]) (op0, mode)
  8730.       && (*insn_operand_predicate[icode][1]) (op0, mode)
  8731.       && (*insn_operand_predicate[icode][2]) (op1, mode))
  8732.     single_insn = 1;
  8733.     }
  8734.  
  8735.   /* If OP0 is not the actual lvalue, but rather a copy in a register,
  8736.      then we cannot just increment OP0.  We must therefore contrive to
  8737.      increment the original value.  Then, for postincrement, we can return
  8738.      OP0 since it is a copy of the old value.  For preincrement, expand here
  8739.      unless we can do it with a single insn.
  8740.  
  8741.      Likewise if storing directly into OP0 would clobber high bits
  8742.      we need to preserve (bad_subreg).  */
  8743.   if (op0_is_copy || (!post && !single_insn) || bad_subreg)
  8744.     {
  8745.       /* This is the easiest way to increment the value wherever it is.
  8746.      Problems with multiple evaluation of INCREMENTED are prevented
  8747.      because either (1) it is a component_ref or preincrement,
  8748.      in which case it was stabilized above, or (2) it is an array_ref
  8749.      with constant index in an array in a register, which is
  8750.      safe to reevaluate.  */
  8751.       tree newexp = build (((TREE_CODE (exp) == POSTDECREMENT_EXPR
  8752.                  || TREE_CODE (exp) == PREDECREMENT_EXPR)
  8753.                 ? MINUS_EXPR : PLUS_EXPR),
  8754.                TREE_TYPE (exp),
  8755.                incremented,
  8756.                TREE_OPERAND (exp, 1));
  8757.  
  8758.       while (TREE_CODE (incremented) == NOP_EXPR
  8759.          || TREE_CODE (incremented) == CONVERT_EXPR)
  8760.     {
  8761.       newexp = convert (TREE_TYPE (incremented), newexp);
  8762.       incremented = TREE_OPERAND (incremented, 0);
  8763.     }
  8764.  
  8765.       temp = expand_assignment (incremented, newexp, ! post, 0);
  8766.       return post ? op0 : temp;
  8767.     }
  8768.  
  8769.   if (post)
  8770.     {
  8771.       /* We have a true reference to the value in OP0.
  8772.      If there is an insn to add or subtract in this mode, queue it.
  8773.      Queueing the increment insn avoids the register shuffling
  8774.      that often results if we must increment now and first save
  8775.      the old value for subsequent use.  */
  8776.  
  8777. #if 0  /* Turned off to avoid making extra insn for indexed memref.  */
  8778.       op0 = stabilize (op0);
  8779. #endif
  8780.  
  8781.       icode = (int) this_optab->handlers[(int) mode].insn_code;
  8782.       if (icode != (int) CODE_FOR_nothing
  8783.       /* Make sure that OP0 is valid for operands 0 and 1
  8784.          of the insn we want to queue.  */
  8785.       && (*insn_operand_predicate[icode][0]) (op0, mode)
  8786.       && (*insn_operand_predicate[icode][1]) (op0, mode))
  8787.     {
  8788.       if (! (*insn_operand_predicate[icode][2]) (op1, mode))
  8789.         op1 = force_reg (mode, op1);
  8790.  
  8791.       return enqueue_insn (op0, GEN_FCN (icode) (op0, op0, op1));
  8792.     }
  8793.     }
  8794.  
  8795.   /* Preincrement, or we can't increment with one simple insn.  */
  8796.   if (post)
  8797.     /* Save a copy of the value before inc or dec, to return it later.  */
  8798.     temp = value = copy_to_reg (op0);
  8799.   else
  8800.     /* Arrange to return the incremented value.  */
  8801.     /* Copy the rtx because expand_binop will protect from the queue,
  8802.        and the results of that would be invalid for us to return
  8803.        if our caller does emit_queue before using our result.  */
  8804.     temp = copy_rtx (value = op0);
  8805.  
  8806.   /* Increment however we can.  */
  8807.   op1 = expand_binop (mode, this_optab, value, op1, op0,
  8808.               TREE_UNSIGNED (TREE_TYPE (exp)), OPTAB_LIB_WIDEN);
  8809.   /* Make sure the value is stored into OP0.  */
  8810.   if (op1 != op0)
  8811.     emit_move_insn (op0, op1);
  8812.  
  8813.   return temp;
  8814. }
  8815.  
  8816. /* Expand all function calls contained within EXP, innermost ones first.
  8817.    But don't look within expressions that have sequence points.
  8818.    For each CALL_EXPR, record the rtx for its value
  8819.    in the CALL_EXPR_RTL field.  */
  8820.  
  8821. static void
  8822. preexpand_calls (exp)
  8823.      tree exp;
  8824. {
  8825.   register int nops, i;
  8826.   int type = TREE_CODE_CLASS (TREE_CODE (exp));
  8827.  
  8828.   if (! do_preexpand_calls)
  8829.     return;
  8830.  
  8831.   /* Only expressions and references can contain calls.  */
  8832.  
  8833.   if (type != 'e' && type != '<' && type != '1' && type != '2' && type != 'r')
  8834.     return;
  8835.  
  8836.   switch (TREE_CODE (exp))
  8837.     {
  8838.     case CALL_EXPR:
  8839.       /* Do nothing if already expanded.  */
  8840.       if (CALL_EXPR_RTL (exp) != 0)
  8841.     return;
  8842.  
  8843.       /* Do nothing to built-in functions.  */
  8844.       if (TREE_CODE (TREE_OPERAND (exp, 0)) != ADDR_EXPR
  8845.       || TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) != FUNCTION_DECL
  8846.       || ! DECL_BUILT_IN (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
  8847.       /* Do nothing if the call returns a variable-sized object.  */
  8848.       || TREE_CODE (TYPE_SIZE (TREE_TYPE(exp))) != INTEGER_CST)
  8849.     CALL_EXPR_RTL (exp) = expand_call (exp, NULL_RTX, 0);
  8850.       return;
  8851.  
  8852.     case COMPOUND_EXPR:
  8853.     case COND_EXPR:
  8854.     case TRUTH_ANDIF_EXPR:
  8855.     case TRUTH_ORIF_EXPR:
  8856.       /* If we find one of these, then we can be sure
  8857.      the adjust will be done for it (since it makes jumps).
  8858.      Do it now, so that if this is inside an argument
  8859.      of a function, we don't get the stack adjustment
  8860.      after some other args have already been pushed.  */
  8861.       do_pending_stack_adjust ();
  8862.       return;
  8863.  
  8864.     case BLOCK:
  8865.     case RTL_EXPR:
  8866.     case WITH_CLEANUP_EXPR:
  8867.     case CLEANUP_POINT_EXPR:
  8868.       return;
  8869.  
  8870.     case SAVE_EXPR:
  8871.       if (SAVE_EXPR_RTL (exp) != 0)
  8872.     return;
  8873.     }
  8874.  
  8875.   nops = tree_code_length[(int) TREE_CODE (exp)];
  8876.   for (i = 0; i < nops; i++)
  8877.     if (TREE_OPERAND (exp, i) != 0)
  8878.       {
  8879.     type = TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, i)));
  8880.     if (type == 'e' || type == '<' || type == '1' || type == '2'
  8881.         || type == 'r')
  8882.       preexpand_calls (TREE_OPERAND (exp, i));
  8883.       }
  8884. }
  8885.  
  8886. /* At the start of a function, record that we have no previously-pushed
  8887.    arguments waiting to be popped.  */
  8888.  
  8889. void
  8890. init_pending_stack_adjust ()
  8891. {
  8892.   pending_stack_adjust = 0;
  8893. }
  8894.  
  8895. /* When exiting from function, if safe, clear out any pending stack adjust
  8896.    so the adjustment won't get done.  */
  8897.  
  8898. void
  8899. clear_pending_stack_adjust ()
  8900. {
  8901. #ifdef EXIT_IGNORE_STACK
  8902.   if (! flag_omit_frame_pointer && EXIT_IGNORE_STACK
  8903.       && ! (DECL_INLINE (current_function_decl) && ! flag_no_inline)
  8904.       && ! flag_inline_functions)
  8905.     pending_stack_adjust = 0;
  8906. #endif
  8907. }
  8908.  
  8909. /* Pop any previously-pushed arguments that have not been popped yet.  */
  8910.  
  8911. void
  8912. do_pending_stack_adjust ()
  8913. {
  8914.   if (inhibit_defer_pop == 0)
  8915.     {
  8916.       if (pending_stack_adjust != 0)
  8917.     adjust_stack (GEN_INT (pending_stack_adjust));
  8918.       pending_stack_adjust = 0;
  8919.     }
  8920. }
  8921.  
  8922. /* Defer the expansion all cleanups up to OLD_CLEANUPS.
  8923.    Returns the cleanups to be performed.  */
  8924.  
  8925. static tree
  8926. defer_cleanups_to (old_cleanups)
  8927.      tree old_cleanups;
  8928. {
  8929.   tree new_cleanups = NULL_TREE;
  8930.   tree cleanups = cleanups_this_call;
  8931.   tree last = NULL_TREE;
  8932.  
  8933.   while (cleanups_this_call != old_cleanups)
  8934.     {
  8935.       (*interim_eh_hook) (TREE_VALUE (cleanups_this_call));
  8936.       last = cleanups_this_call;
  8937.       cleanups_this_call = TREE_CHAIN (cleanups_this_call);
  8938.     }      
  8939.  
  8940.   if (last)
  8941.     {
  8942.       /* Remove the list from the chain of cleanups.  */
  8943.       TREE_CHAIN (last) = NULL_TREE;
  8944.  
  8945.       /* reverse them so that we can build them in the right order.  */
  8946.       cleanups = nreverse (cleanups);
  8947.  
  8948.       while (cleanups)
  8949.     {
  8950.       if (new_cleanups)
  8951.         new_cleanups = build (COMPOUND_EXPR, TREE_TYPE (new_cleanups),
  8952.                   TREE_VALUE (cleanups), new_cleanups);
  8953.       else
  8954.         new_cleanups = TREE_VALUE (cleanups);
  8955.  
  8956.       cleanups = TREE_CHAIN (cleanups);
  8957.     }
  8958.     }
  8959.  
  8960.   return new_cleanups;
  8961. }
  8962.  
  8963. /* Expand all cleanups up to OLD_CLEANUPS.
  8964.    Needed here, and also for language-dependent calls.  */
  8965.  
  8966. void
  8967. expand_cleanups_to (old_cleanups)
  8968.      tree old_cleanups;
  8969. {
  8970.   while (cleanups_this_call != old_cleanups)
  8971.     {
  8972.       (*interim_eh_hook) (TREE_VALUE (cleanups_this_call));
  8973.       expand_expr (TREE_VALUE (cleanups_this_call), const0_rtx, VOIDmode, 0);
  8974.       cleanups_this_call = TREE_CHAIN (cleanups_this_call);
  8975.     }
  8976. }
  8977.  
  8978. /* Expand conditional expressions.  */
  8979.  
  8980. /* Generate code to evaluate EXP and jump to LABEL if the value is zero.
  8981.    LABEL is an rtx of code CODE_LABEL, in this function and all the
  8982.    functions here.  */
  8983.  
  8984. void
  8985. jumpifnot (exp, label)
  8986.      tree exp;
  8987.      rtx label;
  8988. {
  8989.   do_jump (exp, label, NULL_RTX);
  8990. }
  8991.  
  8992. /* Generate code to evaluate EXP and jump to LABEL if the value is nonzero.  */
  8993.  
  8994. void
  8995. jumpif (exp, label)
  8996.      tree exp;
  8997.      rtx label;
  8998. {
  8999.   do_jump (exp, NULL_RTX, label);
  9000. }
  9001.  
  9002. /* Generate code to evaluate EXP and jump to IF_FALSE_LABEL if
  9003.    the result is zero, or IF_TRUE_LABEL if the result is one.
  9004.    Either of IF_FALSE_LABEL and IF_TRUE_LABEL may be zero,
  9005.    meaning fall through in that case.
  9006.  
  9007.    do_jump always does any pending stack adjust except when it does not
  9008.    actually perform a jump.  An example where there is no jump
  9009.    is when EXP is `(foo (), 0)' and IF_FALSE_LABEL is null.
  9010.  
  9011.    This function is responsible for optimizing cases such as
  9012.    &&, || and comparison operators in EXP.  */
  9013.  
  9014. void
  9015. do_jump (exp, if_false_label, if_true_label)
  9016.      tree exp;
  9017.      rtx if_false_label, if_true_label;
  9018. {
  9019.   register enum tree_code code = TREE_CODE (exp);
  9020.   /* Some cases need to create a label to jump to
  9021.      in order to properly fall through.
  9022.      These cases set DROP_THROUGH_LABEL nonzero.  */
  9023.   rtx drop_through_label = 0;
  9024.   rtx temp;
  9025.   rtx comparison = 0;
  9026.   int i;
  9027.   tree type;
  9028.   enum machine_mode mode;
  9029.  
  9030.   emit_queue ();
  9031.  
  9032.   switch (code)
  9033.     {
  9034.     case ERROR_MARK:
  9035.       break;
  9036.  
  9037.     case INTEGER_CST:
  9038.       temp = integer_zerop (exp) ? if_false_label : if_true_label;
  9039.       if (temp)
  9040.     emit_jump (temp);
  9041.       break;
  9042.  
  9043. #if 0
  9044.       /* This is not true with #pragma weak  */
  9045.     case ADDR_EXPR:
  9046.       /* The address of something can never be zero.  */
  9047.       if (if_true_label)
  9048.     emit_jump (if_true_label);
  9049.       break;
  9050. #endif
  9051.  
  9052.     case NOP_EXPR:
  9053.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == COMPONENT_REF
  9054.       || TREE_CODE (TREE_OPERAND (exp, 0)) == BIT_FIELD_REF
  9055.       || TREE_CODE (TREE_OPERAND (exp, 0)) == ARRAY_REF)
  9056.     goto normal;
  9057.     case CONVERT_EXPR:
  9058.       /* If we are narrowing the operand, we have to do the compare in the
  9059.      narrower mode.  */
  9060.       if ((TYPE_PRECISION (TREE_TYPE (exp))
  9061.        < TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  9062.     goto normal;
  9063.     case NON_LVALUE_EXPR:
  9064.     case REFERENCE_EXPR:
  9065.     case ABS_EXPR:
  9066.     case NEGATE_EXPR:
  9067.     case LROTATE_EXPR:
  9068.     case RROTATE_EXPR:
  9069.       /* These cannot change zero->non-zero or vice versa.  */
  9070.       do_jump (TREE_OPERAND (exp, 0), if_false_label, if_true_label);
  9071.       break;
  9072.  
  9073. #if 0
  9074.       /* This is never less insns than evaluating the PLUS_EXPR followed by
  9075.      a test and can be longer if the test is eliminated.  */
  9076.     case PLUS_EXPR:
  9077.       /* Reduce to minus.  */
  9078.       exp = build (MINUS_EXPR, TREE_TYPE (exp),
  9079.            TREE_OPERAND (exp, 0),
  9080.            fold (build1 (NEGATE_EXPR, TREE_TYPE (TREE_OPERAND (exp, 1)),
  9081.                  TREE_OPERAND (exp, 1))));
  9082.       /* Process as MINUS.  */
  9083. #endif
  9084.  
  9085.     case MINUS_EXPR:
  9086.       /* Non-zero iff operands of minus differ.  */
  9087.       comparison = compare (build (NE_EXPR, TREE_TYPE (exp),
  9088.                    TREE_OPERAND (exp, 0),
  9089.                    TREE_OPERAND (exp, 1)),
  9090.                 NE, NE);
  9091.       break;
  9092.  
  9093.     case BIT_AND_EXPR:
  9094.       /* If we are AND'ing with a small constant, do this comparison in the
  9095.      smallest type that fits.  If the machine doesn't have comparisons
  9096.      that small, it will be converted back to the wider comparison.
  9097.      This helps if we are testing the sign bit of a narrower object.
  9098.      combine can't do this for us because it can't know whether a
  9099.      ZERO_EXTRACT or a compare in a smaller mode exists, but we do.  */
  9100.  
  9101.       if (! SLOW_BYTE_ACCESS
  9102.       && TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST
  9103.       && TYPE_PRECISION (TREE_TYPE (exp)) <= HOST_BITS_PER_WIDE_INT
  9104.       && (i = floor_log2 (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)))) >= 0
  9105.       && (mode = mode_for_size (i + 1, MODE_INT, 0)) != BLKmode
  9106.       && (type = type_for_mode (mode, 1)) != 0
  9107.       && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (exp))
  9108.       && (cmp_optab->handlers[(int) TYPE_MODE (type)].insn_code
  9109.           != CODE_FOR_nothing))
  9110.     {
  9111.       do_jump (convert (type, exp), if_false_label, if_true_label);
  9112.       break;
  9113.     }
  9114.       goto normal;
  9115.  
  9116.     case TRUTH_NOT_EXPR:
  9117.       do_jump (TREE_OPERAND (exp, 0), if_true_label, if_false_label);
  9118.       break;
  9119.  
  9120.     case TRUTH_ANDIF_EXPR:
  9121.       {
  9122.     rtx seq1, seq2;
  9123.     tree cleanups, old_cleanups;
  9124.  
  9125.     if (if_false_label == 0)
  9126.       if_false_label = drop_through_label = gen_label_rtx ();
  9127.     start_sequence ();
  9128.     do_jump (TREE_OPERAND (exp, 0), if_false_label, NULL_RTX);
  9129.     seq1 = get_insns ();
  9130.     end_sequence ();
  9131.  
  9132.     old_cleanups = cleanups_this_call;
  9133.     start_sequence ();
  9134.     do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label);
  9135.     seq2 = get_insns ();
  9136.     end_sequence ();
  9137.  
  9138.     cleanups = defer_cleanups_to (old_cleanups);
  9139.     if (cleanups)
  9140.       {
  9141.         rtx flag = gen_reg_rtx (word_mode);
  9142.         tree new_cleanups;
  9143.         tree cond;
  9144.  
  9145.         /* Flag cleanups as not needed. */
  9146.         emit_move_insn (flag, const0_rtx);
  9147.         emit_insns (seq1);
  9148.  
  9149.         /* Flag cleanups as needed. */
  9150.         emit_move_insn (flag, const1_rtx);
  9151.         emit_insns (seq2);
  9152.  
  9153.         /* convert flag, which is an rtx, into a tree. */
  9154.         cond = make_node (RTL_EXPR);
  9155.         TREE_TYPE (cond) = integer_type_node;
  9156.         RTL_EXPR_RTL (cond) = flag;
  9157.         RTL_EXPR_SEQUENCE (cond) = NULL_RTX;
  9158.         cond = save_expr (cond);
  9159.  
  9160.         new_cleanups = build (COND_EXPR, void_type_node,
  9161.                   truthvalue_conversion (cond),
  9162.                   cleanups, integer_zero_node);
  9163.         new_cleanups = fold (new_cleanups);
  9164.  
  9165.         /* Now add in the conditionalized cleanups. */
  9166.         cleanups_this_call
  9167.           = tree_cons (NULL_TREE, new_cleanups, cleanups_this_call);
  9168.         (*interim_eh_hook) (NULL_TREE);
  9169.       }
  9170.     else
  9171.       {
  9172.         emit_insns (seq1);
  9173.         emit_insns (seq2);
  9174.       }
  9175.       }
  9176.       break;
  9177.  
  9178.     case TRUTH_ORIF_EXPR:
  9179.       {
  9180.     rtx seq1, seq2;
  9181.     tree cleanups, old_cleanups;
  9182.  
  9183.     if (if_true_label == 0)
  9184.       if_true_label = drop_through_label = gen_label_rtx ();
  9185.     start_sequence ();
  9186.     do_jump (TREE_OPERAND (exp, 0), NULL_RTX, if_true_label);
  9187.     seq1 = get_insns ();
  9188.     end_sequence ();
  9189.  
  9190.     old_cleanups = cleanups_this_call;
  9191.     start_sequence ();
  9192.     do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label);
  9193.     seq2 = get_insns ();
  9194.     end_sequence ();
  9195.  
  9196.     cleanups = defer_cleanups_to (old_cleanups);
  9197.     if (cleanups)
  9198.       {
  9199.         rtx flag = gen_reg_rtx (word_mode);
  9200.         tree new_cleanups;
  9201.         tree cond;
  9202.  
  9203.         /* Flag cleanups as not needed. */
  9204.         emit_move_insn (flag, const0_rtx);
  9205.         emit_insns (seq1);
  9206.  
  9207.         /* Flag cleanups as needed. */
  9208.         emit_move_insn (flag, const1_rtx);
  9209.         emit_insns (seq2);
  9210.  
  9211.         /* convert flag, which is an rtx, into a tree. */
  9212.         cond = make_node (RTL_EXPR);
  9213.         TREE_TYPE (cond) = integer_type_node;
  9214.         RTL_EXPR_RTL (cond) = flag;
  9215.         RTL_EXPR_SEQUENCE (cond) = NULL_RTX;
  9216.         cond = save_expr (cond);
  9217.  
  9218.         new_cleanups = build (COND_EXPR, void_type_node,
  9219.                   truthvalue_conversion (cond),
  9220.                   cleanups, integer_zero_node);
  9221.         new_cleanups = fold (new_cleanups);
  9222.  
  9223.         /* Now add in the conditionalized cleanups. */
  9224.         cleanups_this_call
  9225.           = tree_cons (NULL_TREE, new_cleanups, cleanups_this_call);
  9226.         (*interim_eh_hook) (NULL_TREE);
  9227.       }
  9228.     else
  9229.       {
  9230.         emit_insns (seq1);
  9231.         emit_insns (seq2);
  9232.       }
  9233.       }
  9234.       break;
  9235.  
  9236.     case COMPOUND_EXPR:
  9237.       push_temp_slots ();
  9238.       expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0);
  9239.       free_temp_slots ();
  9240.       pop_temp_slots ();
  9241.       emit_queue ();
  9242.       do_pending_stack_adjust ();
  9243.       do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label);
  9244.       break;
  9245.  
  9246.     case COMPONENT_REF:
  9247.     case BIT_FIELD_REF:
  9248.     case ARRAY_REF:
  9249.       {
  9250.     int bitsize, bitpos, unsignedp;
  9251.     enum machine_mode mode;
  9252.     tree type;
  9253.     tree offset;
  9254.     int volatilep = 0;
  9255.  
  9256.     /* Get description of this reference.  We don't actually care
  9257.        about the underlying object here.  */
  9258.     get_inner_reference (exp, &bitsize, &bitpos, &offset,
  9259.                  &mode, &unsignedp, &volatilep);
  9260.  
  9261.     type = type_for_size (bitsize, unsignedp);
  9262.     if (! SLOW_BYTE_ACCESS
  9263.         && type != 0 && bitsize >= 0
  9264.         && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (exp))
  9265.         && (cmp_optab->handlers[(int) TYPE_MODE (type)].insn_code
  9266.         != CODE_FOR_nothing))
  9267.       {
  9268.         do_jump (convert (type, exp), if_false_label, if_true_label);
  9269.         break;
  9270.       }
  9271.     goto normal;
  9272.       }
  9273.  
  9274.     case COND_EXPR:
  9275.       /* Do (a ? 1 : 0) and (a ? 0 : 1) as special cases.  */
  9276.       if (integer_onep (TREE_OPERAND (exp, 1))
  9277.       && integer_zerop (TREE_OPERAND (exp, 2)))
  9278.     do_jump (TREE_OPERAND (exp, 0), if_false_label, if_true_label);
  9279.  
  9280.       else if (integer_zerop (TREE_OPERAND (exp, 1))
  9281.            && integer_onep (TREE_OPERAND (exp, 2)))
  9282.     do_jump (TREE_OPERAND (exp, 0), if_true_label, if_false_label);
  9283.  
  9284.       else
  9285.     {
  9286.       register rtx label1 = gen_label_rtx ();
  9287.       drop_through_label = gen_label_rtx ();
  9288.       do_jump (TREE_OPERAND (exp, 0), label1, NULL_RTX);
  9289.       /* Now the THEN-expression.  */
  9290.       do_jump (TREE_OPERAND (exp, 1),
  9291.            if_false_label ? if_false_label : drop_through_label,
  9292.            if_true_label ? if_true_label : drop_through_label);
  9293.       /* In case the do_jump just above never jumps.  */
  9294.       do_pending_stack_adjust ();
  9295.       emit_label (label1);
  9296.       /* Now the ELSE-expression.  */
  9297.       do_jump (TREE_OPERAND (exp, 2),
  9298.            if_false_label ? if_false_label : drop_through_label,
  9299.            if_true_label ? if_true_label : drop_through_label);
  9300.     }
  9301.       break;
  9302.  
  9303.     case EQ_EXPR:
  9304.       {
  9305.     tree inner_type = TREE_TYPE (TREE_OPERAND (exp, 0));
  9306.  
  9307.     if (integer_zerop (TREE_OPERAND (exp, 1)))
  9308.       do_jump (TREE_OPERAND (exp, 0), if_true_label, if_false_label);
  9309.     else if (GET_MODE_CLASS (TYPE_MODE (inner_type)) == MODE_COMPLEX_FLOAT
  9310.          || GET_MODE_CLASS (TYPE_MODE (inner_type)) == MODE_COMPLEX_INT)
  9311.       do_jump
  9312.         (fold
  9313.          (build (TRUTH_ANDIF_EXPR, TREE_TYPE (exp),
  9314.              fold (build (EQ_EXPR, TREE_TYPE (exp),
  9315.                   fold (build1 (REALPART_EXPR,
  9316.                         TREE_TYPE (inner_type),
  9317.                         TREE_OPERAND (exp, 0))),
  9318.                   fold (build1 (REALPART_EXPR,
  9319.                         TREE_TYPE (inner_type),
  9320.                         TREE_OPERAND (exp, 1))))),
  9321.              fold (build (EQ_EXPR, TREE_TYPE (exp),
  9322.                   fold (build1 (IMAGPART_EXPR,
  9323.                         TREE_TYPE (inner_type),
  9324.                         TREE_OPERAND (exp, 0))),
  9325.                   fold (build1 (IMAGPART_EXPR,
  9326.                         TREE_TYPE (inner_type),
  9327.                         TREE_OPERAND (exp, 1))))))),
  9328.          if_false_label, if_true_label);
  9329.     else if (GET_MODE_CLASS (TYPE_MODE (inner_type)) == MODE_INT
  9330.          && !can_compare_p (TYPE_MODE (inner_type)))
  9331.       do_jump_by_parts_equality (exp, if_false_label, if_true_label);
  9332.     else
  9333.       comparison = compare (exp, EQ, EQ);
  9334.     break;
  9335.       }
  9336.  
  9337.     case NE_EXPR:
  9338.       {
  9339.     tree inner_type = TREE_TYPE (TREE_OPERAND (exp, 0));
  9340.  
  9341.     if (integer_zerop (TREE_OPERAND (exp, 1)))
  9342.       do_jump (TREE_OPERAND (exp, 0), if_false_label, if_true_label);
  9343.     else if (GET_MODE_CLASS (TYPE_MODE (inner_type)) == MODE_COMPLEX_FLOAT
  9344.          || GET_MODE_CLASS (TYPE_MODE (inner_type)) == MODE_COMPLEX_INT)
  9345.       do_jump
  9346.         (fold
  9347.          (build (TRUTH_ORIF_EXPR, TREE_TYPE (exp),
  9348.              fold (build (NE_EXPR, TREE_TYPE (exp),
  9349.                   fold (build1 (REALPART_EXPR,
  9350.                         TREE_TYPE (inner_type),
  9351.                         TREE_OPERAND (exp, 0))),
  9352.                   fold (build1 (REALPART_EXPR,
  9353.                         TREE_TYPE (inner_type),
  9354.                         TREE_OPERAND (exp, 1))))),
  9355.              fold (build (NE_EXPR, TREE_TYPE (exp),
  9356.                   fold (build1 (IMAGPART_EXPR,
  9357.                         TREE_TYPE (inner_type),
  9358.                         TREE_OPERAND (exp, 0))),
  9359.                   fold (build1 (IMAGPART_EXPR,
  9360.                         TREE_TYPE (inner_type),
  9361.                         TREE_OPERAND (exp, 1))))))),
  9362.          if_false_label, if_true_label);
  9363.     else if (GET_MODE_CLASS (TYPE_MODE (inner_type)) == MODE_INT
  9364.          && !can_compare_p (TYPE_MODE (inner_type)))
  9365.       do_jump_by_parts_equality (exp, if_true_label, if_false_label);
  9366.     else
  9367.       comparison = compare (exp, NE, NE);
  9368.     break;
  9369.       }
  9370.  
  9371.     case LT_EXPR:
  9372.       if ((GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))
  9373.        == MODE_INT)
  9374.       && !can_compare_p (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  9375.     do_jump_by_parts_greater (exp, 1, if_false_label, if_true_label);
  9376.       else
  9377.     comparison = compare (exp, LT, LTU);
  9378.       break;
  9379.  
  9380.     case LE_EXPR:
  9381.       if ((GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))
  9382.        == MODE_INT)
  9383.       && !can_compare_p (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  9384.     do_jump_by_parts_greater (exp, 0, if_true_label, if_false_label);
  9385.       else
  9386.     comparison = compare (exp, LE, LEU);
  9387.       break;
  9388.  
  9389.     case GT_EXPR:
  9390.       if ((GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))
  9391.        == MODE_INT)
  9392.       && !can_compare_p (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  9393.     do_jump_by_parts_greater (exp, 0, if_false_label, if_true_label);
  9394.       else
  9395.     comparison = compare (exp, GT, GTU);
  9396.       break;
  9397.  
  9398.     case GE_EXPR:
  9399.       if ((GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))
  9400.        == MODE_INT)
  9401.       && !can_compare_p (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  9402.     do_jump_by_parts_greater (exp, 1, if_true_label, if_false_label);
  9403.       else
  9404.     comparison = compare (exp, GE, GEU);
  9405.       break;
  9406.  
  9407.     default:
  9408.     normal:
  9409.       temp = expand_expr (exp, NULL_RTX, VOIDmode, 0);
  9410. #if 0
  9411.       /* This is not needed any more and causes poor code since it causes
  9412.      comparisons and tests from non-SI objects to have different code
  9413.      sequences.  */
  9414.       /* Copy to register to avoid generating bad insns by cse
  9415.      from (set (mem ...) (arithop))  (set (cc0) (mem ...)).  */
  9416.       if (!cse_not_expected && GET_CODE (temp) == MEM)
  9417.     temp = copy_to_reg (temp);
  9418. #endif
  9419.       do_pending_stack_adjust ();
  9420.       if (GET_CODE (temp) == CONST_INT)
  9421.     comparison = (temp == const0_rtx ? const0_rtx : const_true_rtx);
  9422.       else if (GET_CODE (temp) == LABEL_REF)
  9423.     comparison = const_true_rtx;
  9424.       else if (GET_MODE_CLASS (GET_MODE (temp)) == MODE_INT
  9425.            && !can_compare_p (GET_MODE (temp)))
  9426.     /* Note swapping the labels gives us not-equal.  */
  9427.     do_jump_by_parts_equality_rtx (temp, if_true_label, if_false_label);
  9428.       else if (GET_MODE (temp) != VOIDmode)
  9429.     comparison = compare_from_rtx (temp, CONST0_RTX (GET_MODE (temp)),
  9430.                        NE, TREE_UNSIGNED (TREE_TYPE (exp)),
  9431.                        GET_MODE (temp), NULL_RTX, 0);
  9432.       else
  9433.     abort ();
  9434.     }
  9435.  
  9436.   /* Do any postincrements in the expression that was tested.  */
  9437.   emit_queue ();
  9438.  
  9439.   /* If COMPARISON is nonzero here, it is an rtx that can be substituted
  9440.      straight into a conditional jump instruction as the jump condition.
  9441.      Otherwise, all the work has been done already.  */
  9442.  
  9443.   if (comparison == const_true_rtx)
  9444.     {
  9445.       if (if_true_label)
  9446.     emit_jump (if_true_label);
  9447.     }
  9448.   else if (comparison == const0_rtx)
  9449.     {
  9450.       if (if_false_label)
  9451.     emit_jump (if_false_label);
  9452.     }
  9453.   else if (comparison)
  9454.     do_jump_for_compare (comparison, if_false_label, if_true_label);
  9455.  
  9456.   if (drop_through_label)
  9457.     {
  9458.       /* If do_jump produces code that might be jumped around,
  9459.      do any stack adjusts from that code, before the place
  9460.      where control merges in.  */
  9461.       do_pending_stack_adjust ();
  9462.       emit_label (drop_through_label);
  9463.     }
  9464. }
  9465.  
  9466. /* Given a comparison expression EXP for values too wide to be compared
  9467.    with one insn, test the comparison and jump to the appropriate label.
  9468.    The code of EXP is ignored; we always test GT if SWAP is 0,
  9469.    and LT if SWAP is 1.  */
  9470.  
  9471. static void
  9472. do_jump_by_parts_greater (exp, swap, if_false_label, if_true_label)
  9473.      tree exp;
  9474.      int swap;
  9475.      rtx if_false_label, if_true_label;
  9476. {
  9477.   rtx op0 = expand_expr (TREE_OPERAND (exp, swap), NULL_RTX, VOIDmode, 0);
  9478.   rtx op1 = expand_expr (TREE_OPERAND (exp, !swap), NULL_RTX, VOIDmode, 0);
  9479.   enum machine_mode mode = TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)));
  9480.   int nwords = (GET_MODE_SIZE (mode) / UNITS_PER_WORD);
  9481.   rtx drop_through_label = 0;
  9482.   int unsignedp = TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0)));
  9483.   int i;
  9484.  
  9485.   if (! if_true_label || ! if_false_label)
  9486.     drop_through_label = gen_label_rtx ();
  9487.   if (! if_true_label)
  9488.     if_true_label = drop_through_label;
  9489.   if (! if_false_label)
  9490.     if_false_label = drop_through_label;
  9491.  
  9492.   /* Compare a word at a time, high order first.  */
  9493.   for (i = 0; i < nwords; i++)
  9494.     {
  9495.       rtx comp;
  9496.       rtx op0_word, op1_word;
  9497.  
  9498.       if (WORDS_BIG_ENDIAN)
  9499.     {
  9500.       op0_word = operand_subword_force (op0, i, mode);
  9501.       op1_word = operand_subword_force (op1, i, mode);
  9502.     }
  9503.       else
  9504.     {
  9505.       op0_word = operand_subword_force (op0, nwords - 1 - i, mode);
  9506.       op1_word = operand_subword_force (op1, nwords - 1 - i, mode);
  9507.     }
  9508.  
  9509.       /* All but high-order word must be compared as unsigned.  */
  9510.       comp = compare_from_rtx (op0_word, op1_word,
  9511.                    (unsignedp || i > 0) ? GTU : GT,
  9512.                    unsignedp, word_mode, NULL_RTX, 0);
  9513.       if (comp == const_true_rtx)
  9514.     emit_jump (if_true_label);
  9515.       else if (comp != const0_rtx)
  9516.     do_jump_for_compare (comp, NULL_RTX, if_true_label);
  9517.  
  9518.       /* Consider lower words only if these are equal.  */
  9519.       comp = compare_from_rtx (op0_word, op1_word, NE, unsignedp, word_mode,
  9520.                    NULL_RTX, 0);
  9521.       if (comp == const_true_rtx)
  9522.     emit_jump (if_false_label);
  9523.       else if (comp != const0_rtx)
  9524.     do_jump_for_compare (comp, NULL_RTX, if_false_label);
  9525.     }
  9526.  
  9527.   if (if_false_label)
  9528.     emit_jump (if_false_label);
  9529.   if (drop_through_label)
  9530.     emit_label (drop_through_label);
  9531. }
  9532.  
  9533. /* Compare OP0 with OP1, word at a time, in mode MODE.
  9534.    UNSIGNEDP says to do unsigned comparison.
  9535.    Jump to IF_TRUE_LABEL if OP0 is greater, IF_FALSE_LABEL otherwise.  */
  9536.  
  9537. void
  9538. do_jump_by_parts_greater_rtx (mode, unsignedp, op0, op1, if_false_label, if_true_label)
  9539.      enum machine_mode mode;
  9540.      int unsignedp;
  9541.      rtx op0, op1;
  9542.      rtx if_false_label, if_true_label;
  9543. {
  9544.   int nwords = (GET_MODE_SIZE (mode) / UNITS_PER_WORD);
  9545.   rtx drop_through_label = 0;
  9546.   int i;
  9547.  
  9548.   if (! if_true_label || ! if_false_label)
  9549.     drop_through_label = gen_label_rtx ();
  9550.   if (! if_true_label)
  9551.     if_true_label = drop_through_label;
  9552.   if (! if_false_label)
  9553.     if_false_label = drop_through_label;
  9554.  
  9555.   /* Compare a word at a time, high order first.  */
  9556.   for (i = 0; i < nwords; i++)
  9557.     {
  9558.       rtx comp;
  9559.       rtx op0_word, op1_word;
  9560.  
  9561.       if (WORDS_BIG_ENDIAN)
  9562.     {
  9563.       op0_word = operand_subword_force (op0, i, mode);
  9564.       op1_word = operand_subword_force (op1, i, mode);
  9565.     }
  9566.       else
  9567.     {
  9568.       op0_word = operand_subword_force (op0, nwords - 1 - i, mode);
  9569.       op1_word = operand_subword_force (op1, nwords - 1 - i, mode);
  9570.     }
  9571.  
  9572.       /* All but high-order word must be compared as unsigned.  */
  9573.       comp = compare_from_rtx (op0_word, op1_word,
  9574.                    (unsignedp || i > 0) ? GTU : GT,
  9575.                    unsignedp, word_mode, NULL_RTX, 0);
  9576.       if (comp == const_true_rtx)
  9577.     emit_jump (if_true_label);
  9578.       else if (comp != const0_rtx)
  9579.     do_jump_for_compare (comp, NULL_RTX, if_true_label);
  9580.  
  9581.       /* Consider lower words only if these are equal.  */
  9582.       comp = compare_from_rtx (op0_word, op1_word, NE, unsignedp, word_mode,
  9583.                    NULL_RTX, 0);
  9584.       if (comp == const_true_rtx)
  9585.     emit_jump (if_false_label);
  9586.       else if (comp != const0_rtx)
  9587.     do_jump_for_compare (comp, NULL_RTX, if_false_label);
  9588.     }
  9589.  
  9590.   if (if_false_label)
  9591.     emit_jump (if_false_label);
  9592.   if (drop_through_label)
  9593.     emit_label (drop_through_label);
  9594. }
  9595.  
  9596. /* Given an EQ_EXPR expression EXP for values too wide to be compared
  9597.    with one insn, test the comparison and jump to the appropriate label.  */
  9598.  
  9599. static void
  9600. do_jump_by_parts_equality (exp, if_false_label, if_true_label)
  9601.      tree exp;
  9602.      rtx if_false_label, if_true_label;
  9603. {
  9604.   rtx op0 = expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, VOIDmode, 0);
  9605.   rtx op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0);
  9606.   enum machine_mode mode = TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)));
  9607.   int nwords = (GET_MODE_SIZE (mode) / UNITS_PER_WORD);
  9608.   int i;
  9609.   rtx drop_through_label = 0;
  9610.  
  9611.   if (! if_false_label)
  9612.     drop_through_label = if_false_label = gen_label_rtx ();
  9613.  
  9614.   for (i = 0; i < nwords; i++)
  9615.     {
  9616.       rtx comp = compare_from_rtx (operand_subword_force (op0, i, mode),
  9617.                    operand_subword_force (op1, i, mode),
  9618.                    EQ, TREE_UNSIGNED (TREE_TYPE (exp)),
  9619.                    word_mode, NULL_RTX, 0);
  9620.       if (comp == const_true_rtx)
  9621.     emit_jump (if_false_label);
  9622.       else if (comp != const0_rtx)
  9623.     do_jump_for_compare (comp, if_false_label, NULL_RTX);
  9624.     }
  9625.  
  9626.   if (if_true_label)
  9627.     emit_jump (if_true_label);
  9628.   if (drop_through_label)
  9629.     emit_label (drop_through_label);
  9630. }
  9631.  
  9632. /* Jump according to whether OP0 is 0.
  9633.    We assume that OP0 has an integer mode that is too wide
  9634.    for the available compare insns.  */
  9635.  
  9636. static void
  9637. do_jump_by_parts_equality_rtx (op0, if_false_label, if_true_label)
  9638.      rtx op0;
  9639.      rtx if_false_label, if_true_label;
  9640. {
  9641.   int nwords = GET_MODE_SIZE (GET_MODE (op0)) / UNITS_PER_WORD;
  9642.   int i;
  9643.   rtx drop_through_label = 0;
  9644.  
  9645.   if (! if_false_label)
  9646.     drop_through_label = if_false_label = gen_label_rtx ();
  9647.  
  9648.   for (i = 0; i < nwords; i++)
  9649.     {
  9650.       rtx comp = compare_from_rtx (operand_subword_force (op0, i,
  9651.                               GET_MODE (op0)),
  9652.                    const0_rtx, EQ, 1, word_mode, NULL_RTX, 0);
  9653.       if (comp == const_true_rtx)
  9654.     emit_jump (if_false_label);
  9655.       else if (comp != const0_rtx)
  9656.     do_jump_for_compare (comp, if_false_label, NULL_RTX);
  9657.     }
  9658.  
  9659.   if (if_true_label)
  9660.     emit_jump (if_true_label);
  9661.   if (drop_through_label)
  9662.     emit_label (drop_through_label);
  9663. }
  9664.  
  9665. /* Given a comparison expression in rtl form, output conditional branches to
  9666.    IF_TRUE_LABEL, IF_FALSE_LABEL, or both.  */
  9667.  
  9668. static void
  9669. do_jump_for_compare (comparison, if_false_label, if_true_label)
  9670.      rtx comparison, if_false_label, if_true_label;
  9671. {
  9672.   if (if_true_label)
  9673.     {
  9674.       if (bcc_gen_fctn[(int) GET_CODE (comparison)] != 0)
  9675.     emit_jump_insn ((*bcc_gen_fctn[(int) GET_CODE (comparison)]) (if_true_label));
  9676.       else
  9677.     abort ();
  9678.  
  9679.       if (if_false_label)
  9680.     emit_jump (if_false_label);
  9681.     }
  9682.   else if (if_false_label)
  9683.     {
  9684.       rtx insn;
  9685.       rtx prev = get_last_insn ();
  9686.       rtx branch = 0;
  9687.  
  9688.       /* Output the branch with the opposite condition.  Then try to invert
  9689.      what is generated.  If more than one insn is a branch, or if the
  9690.      branch is not the last insn written, abort. If we can't invert
  9691.      the branch, emit make a true label, redirect this jump to that,
  9692.      emit a jump to the false label and define the true label.  */
  9693.  
  9694.       if (bcc_gen_fctn[(int) GET_CODE (comparison)] != 0)
  9695.     emit_jump_insn ((*bcc_gen_fctn[(int) GET_CODE (comparison)])(if_false_label));
  9696.       else
  9697.     abort ();
  9698.  
  9699.       /* Here we get the first insn that was just emitted.  It used to be  the
  9700.      case that, on some machines, emitting the branch would discard
  9701.      the previous compare insn and emit a replacement.  This isn't
  9702.      done anymore, but abort if we see that PREV is deleted.  */
  9703.  
  9704.       if (prev == 0)
  9705.     insn = get_insns ();
  9706.       else if (INSN_DELETED_P (prev))
  9707.     abort ();
  9708.       else
  9709.     insn = NEXT_INSN (prev);
  9710.  
  9711.       for (; insn; insn = NEXT_INSN (insn))
  9712.     if (GET_CODE (insn) == JUMP_INSN)
  9713.       {
  9714.         if (branch)
  9715.           abort ();
  9716.         branch = insn;
  9717.       }
  9718.  
  9719.       if (branch != get_last_insn ())
  9720.     abort ();
  9721.  
  9722.       JUMP_LABEL (branch) = if_false_label;
  9723.       if (! invert_jump (branch, if_false_label))
  9724.     {
  9725.       if_true_label = gen_label_rtx ();
  9726.       redirect_jump (branch, if_true_label);
  9727.       emit_jump (if_false_label);
  9728.       emit_label (if_true_label);
  9729.     }
  9730.     }
  9731. }
  9732.  
  9733. /* Generate code for a comparison expression EXP
  9734.    (including code to compute the values to be compared)
  9735.    and set (CC0) according to the result.
  9736.    SIGNED_CODE should be the rtx operation for this comparison for
  9737.    signed data; UNSIGNED_CODE, likewise for use if data is unsigned.
  9738.  
  9739.    We force a stack adjustment unless there are currently
  9740.    things pushed on the stack that aren't yet used.  */
  9741.  
  9742. static rtx
  9743. compare (exp, signed_code, unsigned_code)
  9744.      register tree exp;
  9745.      enum rtx_code signed_code, unsigned_code;
  9746. {
  9747.   register rtx op0
  9748.     = expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, VOIDmode, 0);
  9749.   register rtx op1
  9750.     = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0);
  9751.   register tree type = TREE_TYPE (TREE_OPERAND (exp, 0));
  9752.   register enum machine_mode mode = TYPE_MODE (type);
  9753.   int unsignedp = TREE_UNSIGNED (type);
  9754.   enum rtx_code code = unsignedp ? unsigned_code : signed_code;
  9755.  
  9756.   return compare_from_rtx (op0, op1, code, unsignedp, mode,
  9757.                ((mode == BLKmode)
  9758.                 ? expr_size (TREE_OPERAND (exp, 0)) : NULL_RTX),
  9759.                TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
  9760. }
  9761.  
  9762. /* Like compare but expects the values to compare as two rtx's.
  9763.    The decision as to signed or unsigned comparison must be made by the caller.
  9764.  
  9765.    If MODE is BLKmode, SIZE is an RTX giving the size of the objects being
  9766.    compared.
  9767.  
  9768.    If ALIGN is non-zero, it is the alignment of this type; if zero, the
  9769.    size of MODE should be used.  */
  9770.  
  9771. rtx
  9772. compare_from_rtx (op0, op1, code, unsignedp, mode, size, align)
  9773.      register rtx op0, op1;
  9774.      enum rtx_code code;
  9775.      int unsignedp;
  9776.      enum machine_mode mode;
  9777.      rtx size;
  9778.      int align;
  9779. {
  9780.   rtx tem;
  9781.  
  9782.   /* If one operand is constant, make it the second one.  Only do this
  9783.      if the other operand is not constant as well.  */
  9784.  
  9785.   if ((CONSTANT_P (op0) && ! CONSTANT_P (op1))
  9786.       || (GET_CODE (op0) == CONST_INT && GET_CODE (op1) != CONST_INT))
  9787.     {
  9788.       tem = op0;
  9789.       op0 = op1;
  9790.       op1 = tem;
  9791.       code = swap_condition (code);
  9792.     }
  9793.  
  9794.   if (flag_force_mem)
  9795.     {
  9796.       op0 = force_not_mem (op0);
  9797.       op1 = force_not_mem (op1);
  9798.     }
  9799.  
  9800.   do_pending_stack_adjust ();
  9801.  
  9802.   if (GET_CODE (op0) == CONST_INT && GET_CODE (op1) == CONST_INT
  9803.       && (tem = simplify_relational_operation (code, mode, op0, op1)) != 0)
  9804.     return tem;
  9805.  
  9806. #if 0
  9807.   /* There's no need to do this now that combine.c can eliminate lots of
  9808.      sign extensions.  This can be less efficient in certain cases on other
  9809.      machines. */
  9810.  
  9811.   /* If this is a signed equality comparison, we can do it as an
  9812.      unsigned comparison since zero-extension is cheaper than sign
  9813.      extension and comparisons with zero are done as unsigned.  This is
  9814.      the case even on machines that can do fast sign extension, since
  9815.      zero-extension is easier to combine with other operations than
  9816.      sign-extension is.  If we are comparing against a constant, we must
  9817.      convert it to what it would look like unsigned.  */
  9818.   if ((code == EQ || code == NE) && ! unsignedp
  9819.       && GET_MODE_BITSIZE (GET_MODE (op0)) <= HOST_BITS_PER_WIDE_INT)
  9820.     {
  9821.       if (GET_CODE (op1) == CONST_INT
  9822.       && (INTVAL (op1) & GET_MODE_MASK (GET_MODE (op0))) != INTVAL (op1))
  9823.     op1 = GEN_INT (INTVAL (op1) & GET_MODE_MASK (GET_MODE (op0)));
  9824.       unsignedp = 1;
  9825.     }
  9826. #endif
  9827.     
  9828.   emit_cmp_insn (op0, op1, code, size, mode, unsignedp, align);
  9829.  
  9830.   return gen_rtx (code, VOIDmode, cc0_rtx, const0_rtx);
  9831. }
  9832.  
  9833. /* Generate code to calculate EXP using a store-flag instruction
  9834.    and return an rtx for the result.  EXP is either a comparison
  9835.    or a TRUTH_NOT_EXPR whose operand is a comparison.
  9836.  
  9837.    If TARGET is nonzero, store the result there if convenient.
  9838.  
  9839.    If ONLY_CHEAP is non-zero, only do this if it is likely to be very
  9840.    cheap.
  9841.  
  9842.    Return zero if there is no suitable set-flag instruction
  9843.    available on this machine.
  9844.  
  9845.    Once expand_expr has been called on the arguments of the comparison,
  9846.    we are committed to doing the store flag, since it is not safe to
  9847.    re-evaluate the expression.  We emit the store-flag insn by calling
  9848.    emit_store_flag, but only expand the arguments if we have a reason
  9849.    to believe that emit_store_flag will be successful.  If we think that
  9850.    it will, but it isn't, we have to simulate the store-flag with a
  9851.    set/jump/set sequence.  */
  9852.  
  9853. static rtx
  9854. do_store_flag (exp, target, mode, only_cheap)
  9855.      tree exp;
  9856.      rtx target;
  9857.      enum machine_mode mode;
  9858.      int only_cheap;
  9859. {
  9860.   enum rtx_code code;
  9861.   tree arg0, arg1, type;
  9862.   tree tem;
  9863.   enum machine_mode operand_mode;
  9864.   int invert = 0;
  9865.   int unsignedp;
  9866.   rtx op0, op1;
  9867.   enum insn_code icode;
  9868.   rtx subtarget = target;
  9869.   rtx result, label, pattern, jump_pat;
  9870.  
  9871.   /* If this is a TRUTH_NOT_EXPR, set a flag indicating we must invert the
  9872.      result at the end.  We can't simply invert the test since it would
  9873.      have already been inverted if it were valid.  This case occurs for
  9874.      some floating-point comparisons.  */
  9875.  
  9876.   if (TREE_CODE (exp) == TRUTH_NOT_EXPR)
  9877.     invert = 1, exp = TREE_OPERAND (exp, 0);
  9878.  
  9879.   arg0 = TREE_OPERAND (exp, 0);
  9880.   arg1 = TREE_OPERAND (exp, 1);
  9881.   type = TREE_TYPE (arg0);
  9882.   operand_mode = TYPE_MODE (type);
  9883.   unsignedp = TREE_UNSIGNED (type);
  9884.  
  9885.   /* We won't bother with BLKmode store-flag operations because it would mean
  9886.      passing a lot of information to emit_store_flag.  */
  9887.   if (operand_mode == BLKmode)
  9888.     return 0;
  9889.  
  9890.   STRIP_NOPS (arg0);
  9891.   STRIP_NOPS (arg1);
  9892.  
  9893.   /* Get the rtx comparison code to use.  We know that EXP is a comparison
  9894.      operation of some type.  Some comparisons against 1 and -1 can be
  9895.      converted to comparisons with zero.  Do so here so that the tests
  9896.      below will be aware that we have a comparison with zero.   These
  9897.      tests will not catch constants in the first operand, but constants
  9898.      are rarely passed as the first operand.  */
  9899.  
  9900.   switch (TREE_CODE (exp))
  9901.     {
  9902.     case EQ_EXPR:
  9903.       code = EQ;
  9904.       break;
  9905.     case NE_EXPR:
  9906.       code = NE;
  9907.       break;
  9908.     case LT_EXPR:
  9909.       if (integer_onep (arg1))
  9910.     arg1 = integer_zero_node, code = unsignedp ? LEU : LE;
  9911.       else
  9912.     code = unsignedp ? LTU : LT;
  9913.       break;
  9914.     case LE_EXPR:
  9915.       if (! unsignedp && integer_all_onesp (arg1))
  9916.     arg1 = integer_zero_node, code = LT;
  9917.       else
  9918.     code = unsignedp ? LEU : LE;
  9919.       break;
  9920.     case GT_EXPR:
  9921.       if (! unsignedp && integer_all_onesp (arg1))
  9922.     arg1 = integer_zero_node, code = GE;
  9923.       else
  9924.     code = unsignedp ? GTU : GT;
  9925.       break;
  9926.     case GE_EXPR:
  9927.       if (integer_onep (arg1))
  9928.     arg1 = integer_zero_node, code = unsignedp ? GTU : GT;
  9929.       else
  9930.     code = unsignedp ? GEU : GE;
  9931.       break;
  9932.     default:
  9933.       abort ();
  9934.     }
  9935.  
  9936.   /* Put a constant second.  */
  9937.   if (TREE_CODE (arg0) == REAL_CST || TREE_CODE (arg0) == INTEGER_CST)
  9938.     {
  9939.       tem = arg0; arg0 = arg1; arg1 = tem;
  9940.       code = swap_condition (code);
  9941.     }
  9942.  
  9943.   /* If this is an equality or inequality test of a single bit, we can
  9944.      do this by shifting the bit being tested to the low-order bit and
  9945.      masking the result with the constant 1.  If the condition was EQ,
  9946.      we xor it with 1.  This does not require an scc insn and is faster
  9947.      than an scc insn even if we have it.  */
  9948.  
  9949.   if ((code == NE || code == EQ)
  9950.       && TREE_CODE (arg0) == BIT_AND_EXPR && integer_zerop (arg1)
  9951.       && integer_pow2p (TREE_OPERAND (arg0, 1))
  9952.       && TYPE_PRECISION (type) <= HOST_BITS_PER_WIDE_INT)
  9953.     {
  9954.       tree inner = TREE_OPERAND (arg0, 0);
  9955.       int bitnum = exact_log2 (INTVAL (expand_expr (TREE_OPERAND (arg0, 1),
  9956.                             NULL_RTX, VOIDmode, 0)));
  9957.       int ops_unsignedp;
  9958.  
  9959.       /* If INNER is a right shift of a constant and it plus BITNUM does
  9960.      not overflow, adjust BITNUM and INNER.  */
  9961.  
  9962.       if (TREE_CODE (inner) == RSHIFT_EXPR
  9963.       && TREE_CODE (TREE_OPERAND (inner, 1)) == INTEGER_CST
  9964.       && TREE_INT_CST_HIGH (TREE_OPERAND (inner, 1)) == 0
  9965.       && (bitnum + TREE_INT_CST_LOW (TREE_OPERAND (inner, 1))
  9966.           < TYPE_PRECISION (type)))
  9967.     {
  9968.       bitnum +=TREE_INT_CST_LOW (TREE_OPERAND (inner, 1));
  9969.       inner = TREE_OPERAND (inner, 0);
  9970.     }
  9971.  
  9972.       /* If we are going to be able to omit the AND below, we must do our
  9973.      operations as unsigned.  If we must use the AND, we have a choice.
  9974.      Normally unsigned is faster, but for some machines signed is.  */
  9975.       ops_unsignedp = (bitnum == TYPE_PRECISION (type) - 1 ? 1
  9976. #ifdef LOAD_EXTEND_OP
  9977.                : (LOAD_EXTEND_OP (operand_mode) == SIGN_EXTEND ? 0 : 1)
  9978. #else
  9979.                : 1
  9980. #endif
  9981.                );
  9982.  
  9983.       if (subtarget == 0 || GET_CODE (subtarget) != REG
  9984.       || GET_MODE (subtarget) != operand_mode
  9985.       || ! safe_from_p (subtarget, inner))
  9986.     subtarget = 0;
  9987.  
  9988.       op0 = expand_expr (inner, subtarget, VOIDmode, 0);
  9989.  
  9990.       if (bitnum != 0)
  9991.     op0 = expand_shift (RSHIFT_EXPR, GET_MODE (op0), op0,
  9992.                 size_int (bitnum), subtarget, ops_unsignedp);
  9993.  
  9994.       if (GET_MODE (op0) != mode)
  9995.     op0 = convert_to_mode (mode, op0, ops_unsignedp);
  9996.  
  9997.       if ((code == EQ && ! invert) || (code == NE && invert))
  9998.     op0 = expand_binop (mode, xor_optab, op0, const1_rtx, subtarget,
  9999.                 ops_unsignedp, OPTAB_LIB_WIDEN);
  10000.  
  10001.       /* Put the AND last so it can combine with more things.  */
  10002.       if (bitnum != TYPE_PRECISION (type) - 1)
  10003.     op0 = expand_and (op0, const1_rtx, subtarget);
  10004.  
  10005.       return op0;
  10006.     }
  10007.  
  10008.   /* Now see if we are likely to be able to do this.  Return if not.  */
  10009.   if (! can_compare_p (operand_mode))
  10010.     return 0;
  10011.   icode = setcc_gen_code[(int) code];
  10012.   if (icode == CODE_FOR_nothing
  10013.       || (only_cheap && insn_operand_mode[(int) icode][0] != mode))
  10014.     {
  10015.       /* We can only do this if it is one of the special cases that
  10016.      can be handled without an scc insn.  */
  10017.       if ((code == LT && integer_zerop (arg1))
  10018.       || (! only_cheap && code == GE && integer_zerop (arg1)))
  10019.     ;
  10020.       else if (BRANCH_COST >= 0
  10021.            && ! only_cheap && (code == NE || code == EQ)
  10022.            && TREE_CODE (type) != REAL_TYPE
  10023.            && ((abs_optab->handlers[(int) operand_mode].insn_code
  10024.             != CODE_FOR_nothing)
  10025.            || (ffs_optab->handlers[(int) operand_mode].insn_code
  10026.                != CODE_FOR_nothing)))
  10027.     ;
  10028.       else
  10029.     return 0;
  10030.     }
  10031.       
  10032.   preexpand_calls (exp);
  10033.   if (subtarget == 0 || GET_CODE (subtarget) != REG
  10034.       || GET_MODE (subtarget) != operand_mode
  10035.       || ! safe_from_p (subtarget, arg1))
  10036.     subtarget = 0;
  10037.  
  10038.   op0 = expand_expr (arg0, subtarget, VOIDmode, 0);
  10039.   op1 = expand_expr (arg1, NULL_RTX, VOIDmode, 0);
  10040.  
  10041.   if (target == 0)
  10042.     target = gen_reg_rtx (mode);
  10043.  
  10044.   /* Pass copies of OP0 and OP1 in case they contain a QUEUED.  This is safe
  10045.      because, if the emit_store_flag does anything it will succeed and
  10046.      OP0 and OP1 will not be used subsequently.  */
  10047.  
  10048.   result = emit_store_flag (target, code,
  10049.                 queued_subexp_p (op0) ? copy_rtx (op0) : op0,
  10050.                 queued_subexp_p (op1) ? copy_rtx (op1) : op1,
  10051.                 operand_mode, unsignedp, 1);
  10052.  
  10053.   if (result)
  10054.     {
  10055.       if (invert)
  10056.     result = expand_binop (mode, xor_optab, result, const1_rtx,
  10057.                    result, 0, OPTAB_LIB_WIDEN);
  10058.       return result;
  10059.     }
  10060.  
  10061.   /* If this failed, we have to do this with set/compare/jump/set code.  */
  10062.   if (target == 0 || GET_CODE (target) != REG
  10063.       || reg_mentioned_p (target, op0) || reg_mentioned_p (target, op1))
  10064.     target = gen_reg_rtx (GET_MODE (target));
  10065.  
  10066.   emit_move_insn (target, invert ? const0_rtx : const1_rtx);
  10067.   result = compare_from_rtx (op0, op1, code, unsignedp,
  10068.                  operand_mode, NULL_RTX, 0);
  10069.   if (GET_CODE (result) == CONST_INT)
  10070.     return (((result == const0_rtx && ! invert)
  10071.          || (result != const0_rtx && invert))
  10072.         ? const0_rtx : const1_rtx);
  10073.  
  10074.   label = gen_label_rtx ();
  10075.   if (bcc_gen_fctn[(int) code] == 0)
  10076.     abort ();
  10077.  
  10078.   emit_jump_insn ((*bcc_gen_fctn[(int) code]) (label));
  10079.   emit_move_insn (target, invert ? const1_rtx : const0_rtx);
  10080.   emit_label (label);
  10081.  
  10082.   return target;
  10083. }
  10084.  
  10085. /* Generate a tablejump instruction (used for switch statements).  */
  10086.  
  10087. #ifdef HAVE_tablejump
  10088.  
  10089. /* INDEX is the value being switched on, with the lowest value
  10090.    in the table already subtracted.
  10091.    MODE is its expected mode (needed if INDEX is constant).
  10092.    RANGE is the length of the jump table.
  10093.    TABLE_LABEL is a CODE_LABEL rtx for the table itself.
  10094.  
  10095.    DEFAULT_LABEL is a CODE_LABEL rtx to jump to if the
  10096.    index value is out of range.  */
  10097.  
  10098. void
  10099. do_tablejump (index, mode, range, table_label, default_label)
  10100.      rtx index, range, table_label, default_label;
  10101.      enum machine_mode mode;
  10102. {
  10103.   register rtx temp, vector;
  10104.  
  10105.   /* Do an unsigned comparison (in the proper mode) between the index
  10106.      expression and the value which represents the length of the range.
  10107.      Since we just finished subtracting the lower bound of the range
  10108.      from the index expression, this comparison allows us to simultaneously
  10109.      check that the original index expression value is both greater than
  10110.      or equal to the minimum value of the range and less than or equal to
  10111.      the maximum value of the range.  */
  10112.  
  10113.   emit_cmp_insn (index, range, GTU, NULL_RTX, mode, 1, 0);
  10114.   emit_jump_insn (gen_bgtu (default_label));
  10115.  
  10116.   /* If index is in range, it must fit in Pmode.
  10117.      Convert to Pmode so we can index with it.  */
  10118.   if (mode != Pmode)
  10119.     index = convert_to_mode (Pmode, index, 1);
  10120.  
  10121.   /* Don't let a MEM slip thru, because then INDEX that comes
  10122.      out of PIC_CASE_VECTOR_ADDRESS won't be a valid address,
  10123.      and break_out_memory_refs will go to work on it and mess it up.  */
  10124. #ifdef PIC_CASE_VECTOR_ADDRESS
  10125.   if (flag_pic && GET_CODE (index) != REG)
  10126.     index = copy_to_mode_reg (Pmode, index);
  10127. #endif
  10128.  
  10129.   /* If flag_force_addr were to affect this address
  10130.      it could interfere with the tricky assumptions made
  10131.      about addresses that contain label-refs,
  10132.      which may be valid only very near the tablejump itself.  */
  10133.   /* ??? The only correct use of CASE_VECTOR_MODE is the one inside the
  10134.      GET_MODE_SIZE, because this indicates how large insns are.  The other
  10135.      uses should all be Pmode, because they are addresses.  This code
  10136.      could fail if addresses and insns are not the same size.  */
  10137.   index = gen_rtx (PLUS, Pmode,
  10138.            gen_rtx (MULT, Pmode, index,
  10139.                 GEN_INT (GET_MODE_SIZE (CASE_VECTOR_MODE))),
  10140.            gen_rtx (LABEL_REF, Pmode, table_label));
  10141. #ifdef PIC_CASE_VECTOR_ADDRESS
  10142.   if (flag_pic)
  10143.     index = PIC_CASE_VECTOR_ADDRESS (index);
  10144.   else
  10145. #endif
  10146.     index = memory_address_noforce (CASE_VECTOR_MODE, index);
  10147.   temp = gen_reg_rtx (CASE_VECTOR_MODE);
  10148.   vector = gen_rtx (MEM, CASE_VECTOR_MODE, index);
  10149.   RTX_UNCHANGING_P (vector) = 1;
  10150.   convert_move (temp, vector, 0);
  10151.  
  10152.   emit_jump_insn (gen_tablejump (temp, table_label));
  10153.  
  10154. #ifndef CASE_VECTOR_PC_RELATIVE
  10155.   /* If we are generating PIC code or if the table is PC-relative, the
  10156.      table and JUMP_INSN must be adjacent, so don't output a BARRIER.  */
  10157.   if (! flag_pic)
  10158.     emit_barrier ();
  10159. #endif
  10160. }
  10161.  
  10162. #endif /* HAVE_tablejump */
  10163.  
  10164.  
  10165. /* Emit a suitable bytecode to load a value from memory, assuming a pointer
  10166.    to that value is on the top of the stack. The resulting type is TYPE, and
  10167.    the source declaration is DECL. */
  10168.  
  10169. void
  10170. bc_load_memory (type, decl)
  10171.      tree type, decl;
  10172. {
  10173.   enum bytecode_opcode opcode;
  10174.   
  10175.   
  10176.   /* Bit fields are special.  We only know about signed and
  10177.      unsigned ints, and enums.  The latter are treated as
  10178.      signed integers. */
  10179.   
  10180.   if (DECL_BIT_FIELD (decl))
  10181.     if (TREE_CODE (type) == ENUMERAL_TYPE
  10182.     || TREE_CODE (type) == INTEGER_TYPE)
  10183.       opcode = TREE_UNSIGNED (type) ? zxloadBI : sxloadBI;
  10184.     else
  10185.       abort ();
  10186.   else
  10187.     /* See corresponding comment in bc_store_memory(). */
  10188.     if (TYPE_MODE (type) == BLKmode
  10189.     || TYPE_MODE (type) == VOIDmode)
  10190.       return;
  10191.     else
  10192.       opcode = mode_to_load_map [(int) TYPE_MODE (type)];
  10193.  
  10194.   if (opcode == neverneverland)
  10195.     abort ();
  10196.   
  10197.   bc_emit_bytecode (opcode);
  10198.   
  10199. #ifdef DEBUG_PRINT_CODE
  10200.   fputc ('\n', stderr);
  10201. #endif
  10202. }
  10203.  
  10204.  
  10205. /* Store the contents of the second stack slot to the address in the
  10206.    top stack slot.  DECL is the declaration of the destination and is used
  10207.    to determine whether we're dealing with a bitfield. */
  10208.  
  10209. void
  10210. bc_store_memory (type, decl)
  10211.      tree type, decl;
  10212. {
  10213.   enum bytecode_opcode opcode;
  10214.   
  10215.   
  10216.   if (DECL_BIT_FIELD (decl))
  10217.     {
  10218.       if (TREE_CODE (type) == ENUMERAL_TYPE
  10219.       || TREE_CODE (type) == INTEGER_TYPE)
  10220.     opcode = sstoreBI;
  10221.       else
  10222.     abort ();
  10223.     }
  10224.   else
  10225.     if (TYPE_MODE (type) == BLKmode)
  10226.       {
  10227.     /* Copy structure.  This expands to a block copy instruction, storeBLK.
  10228.        In addition to the arguments expected by the other store instructions,
  10229.        it also expects a type size (SImode) on top of the stack, which is the
  10230.        structure size in size units (usually bytes).  The two first arguments
  10231.        are already on the stack; so we just put the size on level 1.  For some
  10232.        other languages, the size may be variable, this is why we don't encode
  10233.        it as a storeBLK literal, but rather treat it as a full-fledged expression. */
  10234.     
  10235.     bc_expand_expr (TYPE_SIZE (type));
  10236.     opcode = storeBLK;
  10237.       }
  10238.     else
  10239.       opcode = mode_to_store_map [(int) TYPE_MODE (type)];
  10240.  
  10241.   if (opcode == neverneverland)
  10242.     abort ();
  10243.  
  10244.   bc_emit_bytecode (opcode);
  10245.   
  10246. #ifdef DEBUG_PRINT_CODE
  10247.   fputc ('\n', stderr);
  10248. #endif
  10249. }
  10250.  
  10251.  
  10252. /* Allocate local stack space sufficient to hold a value of the given
  10253.    SIZE at alignment boundary ALIGNMENT bits.  ALIGNMENT must be an
  10254.    integral power of 2.  A special case is locals of type VOID, which
  10255.    have size 0 and alignment 1 - any "voidish" SIZE or ALIGNMENT is
  10256.    remapped into the corresponding attribute of SI.  */
  10257.  
  10258. rtx
  10259. bc_allocate_local (size, alignment)
  10260.      int size, alignment;
  10261. {
  10262.   rtx retval;
  10263.   int byte_alignment;
  10264.  
  10265.   if (size < 0)
  10266.     abort ();
  10267.  
  10268.   /* Normalize size and alignment  */
  10269.   if (!size)
  10270.     size = UNITS_PER_WORD;
  10271.  
  10272.   if (alignment < BITS_PER_UNIT)
  10273.     byte_alignment = 1 << (INT_ALIGN - 1);
  10274.   else
  10275.     /* Align */
  10276.     byte_alignment = alignment / BITS_PER_UNIT;
  10277.  
  10278.   if (local_vars_size & (byte_alignment - 1))
  10279.     local_vars_size += byte_alignment - (local_vars_size & (byte_alignment - 1));
  10280.  
  10281.   retval = bc_gen_rtx ((char *) 0, local_vars_size, (struct bc_label *) 0);
  10282.   local_vars_size += size;
  10283.  
  10284.   return retval;
  10285. }
  10286.  
  10287.  
  10288. /* Allocate variable-sized local array. Variable-sized arrays are
  10289.    actually pointers to the address in memory where they are stored. */
  10290.  
  10291. rtx
  10292. bc_allocate_variable_array (size)
  10293.      tree size;
  10294. {
  10295.   rtx retval;
  10296.   const int ptralign = (1 << (PTR_ALIGN - 1));
  10297.  
  10298.   /* Align pointer */
  10299.   if (local_vars_size & ptralign)
  10300.     local_vars_size +=  ptralign - (local_vars_size & ptralign);
  10301.  
  10302.   /* Note down local space needed: pointer to block; also return
  10303.      dummy rtx */
  10304.  
  10305.   retval = bc_gen_rtx ((char *) 0, local_vars_size, (struct bc_label *) 0);
  10306.   local_vars_size += POINTER_SIZE / BITS_PER_UNIT;
  10307.   return retval;
  10308. }
  10309.  
  10310.  
  10311. /* Push the machine address for the given external variable offset.  */
  10312. void
  10313. bc_load_externaddr (externaddr)
  10314.      rtx externaddr;
  10315. {
  10316.   bc_emit_bytecode (constP);
  10317.   bc_emit_code_labelref (BYTECODE_LABEL (externaddr),
  10318.              BYTECODE_BC_LABEL (externaddr)->offset);
  10319.  
  10320. #ifdef DEBUG_PRINT_CODE
  10321.   fputc ('\n', stderr);
  10322. #endif
  10323. }
  10324.  
  10325.  
  10326. static char *
  10327. bc_strdup (s)
  10328.     char *s;
  10329. {
  10330.   char *new = (char *) xmalloc ((strlen (s) + 1) * sizeof *s);
  10331.   strcpy (new, s);
  10332.   return new;
  10333. }
  10334.  
  10335.  
  10336. /* Like above, but expects an IDENTIFIER.  */
  10337. void
  10338. bc_load_externaddr_id (id, offset)
  10339.      tree id;
  10340.      int offset;
  10341. {
  10342.   if (!IDENTIFIER_POINTER (id))
  10343.     abort ();
  10344.  
  10345.   bc_emit_bytecode (constP);
  10346.   bc_emit_code_labelref (bc_xstrdup (IDENTIFIER_POINTER (id)), offset);
  10347.  
  10348. #ifdef DEBUG_PRINT_CODE
  10349.   fputc ('\n', stderr);
  10350. #endif
  10351. }
  10352.  
  10353.  
  10354. /* Push the machine address for the given local variable offset.  */
  10355. void
  10356. bc_load_localaddr (localaddr)
  10357.      rtx localaddr;
  10358. {
  10359.   bc_emit_instruction (localP, (HOST_WIDE_INT) BYTECODE_BC_LABEL (localaddr)->offset);
  10360. }
  10361.  
  10362.  
  10363. /* Push the machine address for the given parameter offset.
  10364.    NOTE: offset is in bits. */
  10365. void
  10366. bc_load_parmaddr (parmaddr)
  10367.      rtx parmaddr;
  10368. {
  10369.   bc_emit_instruction (argP, ((HOST_WIDE_INT) BYTECODE_BC_LABEL (parmaddr)->offset
  10370.                   / BITS_PER_UNIT));
  10371. }
  10372.  
  10373.  
  10374. /* Convert a[i] into *(a + i).  */
  10375. tree
  10376. bc_canonicalize_array_ref (exp)
  10377.      tree exp;
  10378. {
  10379.   tree type = TREE_TYPE (exp);
  10380.   tree array_adr = build1 (ADDR_EXPR, TYPE_POINTER_TO (type),
  10381.                TREE_OPERAND (exp, 0));
  10382.   tree index = TREE_OPERAND (exp, 1);
  10383.  
  10384.  
  10385.   /* Convert the integer argument to a type the same size as a pointer
  10386.      so the multiply won't overflow spuriously.  */
  10387.  
  10388.   if (TYPE_PRECISION (TREE_TYPE (index)) != POINTER_SIZE)
  10389.     index = convert (type_for_size (POINTER_SIZE, 0), index);
  10390.  
  10391.   /* The array address isn't volatile even if the array is.
  10392.      (Of course this isn't terribly relevant since the bytecode
  10393.      translator treats nearly everything as volatile anyway.)  */
  10394.   TREE_THIS_VOLATILE (array_adr) = 0;
  10395.  
  10396.   return build1 (INDIRECT_REF, type,
  10397.          fold (build (PLUS_EXPR,
  10398.                   TYPE_POINTER_TO (type),
  10399.                   array_adr,
  10400.                   fold (build (MULT_EXPR,
  10401.                        TYPE_POINTER_TO (type),
  10402.                        index,
  10403.                        size_in_bytes (type))))));
  10404. }
  10405.  
  10406.  
  10407. /* Load the address of the component referenced by the given
  10408.    COMPONENT_REF expression.
  10409.  
  10410.    Returns innermost lvalue. */
  10411.  
  10412. tree
  10413. bc_expand_component_address (exp)
  10414.      tree exp;
  10415. {
  10416.   tree tem, chain;
  10417.   enum machine_mode mode;
  10418.   int bitpos = 0;
  10419.   HOST_WIDE_INT SIval;
  10420.  
  10421.  
  10422.   tem = TREE_OPERAND (exp, 1);
  10423.   mode = DECL_MODE (tem);
  10424.  
  10425.  
  10426.   /* Compute cumulative bit offset for nested component refs
  10427.      and array refs, and find the ultimate containing object.  */
  10428.  
  10429.   for (tem = exp;; tem = TREE_OPERAND (tem, 0))
  10430.     {
  10431.       if (TREE_CODE (tem) == COMPONENT_REF)
  10432.     bitpos += TREE_INT_CST_LOW (DECL_FIELD_BITPOS (TREE_OPERAND (tem, 1)));
  10433.       else
  10434.     if (TREE_CODE (tem) == ARRAY_REF
  10435.         && TREE_CODE (TREE_OPERAND (tem, 1)) == INTEGER_CST
  10436.         && TREE_CODE (TYPE_SIZE (TREE_TYPE (tem))) == INTEGER_CST)
  10437.  
  10438.       bitpos += (TREE_INT_CST_LOW (TREE_OPERAND (tem, 1))
  10439.              * TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (tem)))
  10440.              /* * TYPE_SIZE_UNIT (TREE_TYPE (tem)) */);
  10441.     else
  10442.       break;
  10443.     }
  10444.  
  10445.   bc_expand_expr (tem);
  10446.  
  10447.  
  10448.   /* For bitfields also push their offset and size */
  10449.   if (DECL_BIT_FIELD (TREE_OPERAND (exp, 1)))
  10450.     bc_push_offset_and_size (bitpos, /* DECL_SIZE_UNIT */ (TREE_OPERAND (exp, 1)));
  10451.   else
  10452.     if (SIval = bitpos / BITS_PER_UNIT)
  10453.       bc_emit_instruction (addconstPSI, SIval);
  10454.  
  10455.   return (TREE_OPERAND (exp, 1));
  10456. }
  10457.  
  10458.  
  10459. /* Emit code to push two SI constants */
  10460. void
  10461. bc_push_offset_and_size (offset, size)
  10462.      HOST_WIDE_INT offset, size;
  10463. {
  10464.   bc_emit_instruction (constSI, offset);
  10465.   bc_emit_instruction (constSI, size);
  10466. }
  10467.  
  10468.  
  10469. /* Emit byte code to push the address of the given lvalue expression to
  10470.    the stack.  If it's a bit field, we also push offset and size info.
  10471.  
  10472.    Returns innermost component, which allows us to determine not only
  10473.    its type, but also whether it's a bitfield. */
  10474.  
  10475. tree
  10476. bc_expand_address (exp)
  10477.      tree exp;
  10478. {
  10479.   /* Safeguard */
  10480.   if (!exp || TREE_CODE (exp) == ERROR_MARK)
  10481.     return (exp);
  10482.  
  10483.  
  10484.   switch (TREE_CODE (exp))
  10485.     {
  10486.     case ARRAY_REF:
  10487.  
  10488.       return (bc_expand_address (bc_canonicalize_array_ref (exp)));
  10489.  
  10490.     case COMPONENT_REF:
  10491.  
  10492.       return (bc_expand_component_address (exp));
  10493.  
  10494.     case INDIRECT_REF:
  10495.  
  10496.       bc_expand_expr (TREE_OPERAND (exp, 0));
  10497.  
  10498.       /* For variable-sized types: retrieve pointer.  Sometimes the
  10499.      TYPE_SIZE tree is NULL.  Is this a bug or a feature?  Let's
  10500.      also make sure we have an operand, just in case... */
  10501.  
  10502.       if (TREE_OPERAND (exp, 0)
  10503.       && TYPE_SIZE (TREE_TYPE (TREE_OPERAND (exp, 0)))
  10504.       && TREE_CODE (TYPE_SIZE (TREE_TYPE (TREE_OPERAND (exp, 0)))) != INTEGER_CST)
  10505.     bc_emit_instruction (loadP);
  10506.  
  10507.       /* If packed, also return offset and size */
  10508.       if (DECL_BIT_FIELD (TREE_OPERAND (exp, 0)))
  10509.     
  10510.     bc_push_offset_and_size (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (TREE_OPERAND (exp, 0))),
  10511.                  TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (exp, 0))));
  10512.  
  10513.       return (TREE_OPERAND (exp, 0));
  10514.  
  10515.     case FUNCTION_DECL:
  10516.  
  10517.       bc_load_externaddr_id (DECL_ASSEMBLER_NAME (exp),
  10518.                  BYTECODE_BC_LABEL (DECL_RTL (exp))->offset);
  10519.       break;
  10520.  
  10521.     case PARM_DECL:
  10522.  
  10523.       bc_load_parmaddr (DECL_RTL (exp));
  10524.  
  10525.       /* For variable-sized types: retrieve pointer */
  10526.       if (TYPE_SIZE (TREE_TYPE (exp))
  10527.       && TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) != INTEGER_CST)
  10528.     bc_emit_instruction (loadP);
  10529.  
  10530.       /* If packed, also return offset and size */
  10531.       if (DECL_BIT_FIELD (exp))
  10532.     bc_push_offset_and_size (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (exp)),
  10533.                  TREE_INT_CST_LOW (DECL_SIZE (exp)));
  10534.  
  10535.       break;
  10536.  
  10537.     case RESULT_DECL:
  10538.  
  10539.       bc_emit_instruction (returnP);
  10540.       break;
  10541.  
  10542.     case VAR_DECL:
  10543.  
  10544. #if 0
  10545.       if (BYTECODE_LABEL (DECL_RTL (exp)))
  10546.     bc_load_externaddr (DECL_RTL (exp));
  10547. #endif
  10548.  
  10549.       if (DECL_EXTERNAL (exp))
  10550.     bc_load_externaddr_id (DECL_ASSEMBLER_NAME (exp),
  10551.                    (BYTECODE_BC_LABEL (DECL_RTL (exp)))->offset);
  10552.       else
  10553.     bc_load_localaddr (DECL_RTL (exp));
  10554.  
  10555.       /* For variable-sized types: retrieve pointer */
  10556.       if (TYPE_SIZE (TREE_TYPE (exp))
  10557.       && TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) != INTEGER_CST)
  10558.     bc_emit_instruction (loadP);
  10559.  
  10560.       /* If packed, also return offset and size */
  10561.       if (DECL_BIT_FIELD (exp))
  10562.     bc_push_offset_and_size (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (exp)),
  10563.                  TREE_INT_CST_LOW (DECL_SIZE (exp)));
  10564.       
  10565.       break;
  10566.  
  10567.     case STRING_CST:
  10568.       {
  10569.     rtx r;
  10570.     
  10571.     bc_emit_bytecode (constP);
  10572.     r = output_constant_def (exp);
  10573.     bc_emit_code_labelref (BYTECODE_LABEL (r), BYTECODE_BC_LABEL (r)->offset);
  10574.  
  10575. #ifdef DEBUG_PRINT_CODE
  10576.     fputc ('\n', stderr);
  10577. #endif
  10578.       }
  10579.       break;
  10580.  
  10581.     default:
  10582.  
  10583.       abort();
  10584.       break;
  10585.     }
  10586.  
  10587.   /* Most lvalues don't have components. */
  10588.   return (exp);
  10589. }
  10590.  
  10591.  
  10592. /* Emit a type code to be used by the runtime support in handling
  10593.    parameter passing.   The type code consists of the machine mode
  10594.    plus the minimal alignment shifted left 8 bits.  */
  10595.  
  10596. tree
  10597. bc_runtime_type_code (type)
  10598.      tree type;
  10599. {
  10600.   int val;
  10601.  
  10602.   switch (TREE_CODE (type))
  10603.     {
  10604.     case VOID_TYPE:
  10605.     case INTEGER_TYPE:
  10606.     case REAL_TYPE:
  10607.     case COMPLEX_TYPE:
  10608.     case ENUMERAL_TYPE:
  10609.     case POINTER_TYPE:
  10610.     case RECORD_TYPE:
  10611.  
  10612.       val = (int) TYPE_MODE (type) | TYPE_ALIGN (type) << 8;
  10613.       break;
  10614.  
  10615.     case ERROR_MARK:
  10616.  
  10617.       val = 0;
  10618.       break;
  10619.  
  10620.     default:
  10621.  
  10622.       abort ();
  10623.     }
  10624.   return build_int_2 (val, 0);
  10625. }
  10626.  
  10627.  
  10628. /* Generate constructor label */
  10629. char *
  10630. bc_gen_constr_label ()
  10631. {
  10632.   static int label_counter;
  10633.   static char label[20];
  10634.  
  10635.   sprintf (label, "*LR%d", label_counter++);
  10636.  
  10637.   return (obstack_copy0 (&permanent_obstack, label, strlen (label)));
  10638. }
  10639.  
  10640.  
  10641. /* Evaluate constructor CONSTR and return pointer to it on level one.  We
  10642.    expand the constructor data as static data, and push a pointer to it.
  10643.    The pointer is put in the pointer table and is retrieved by a constP
  10644.    bytecode instruction.  We then loop and store each constructor member in
  10645.    the corresponding component.  Finally, we return the original pointer on
  10646.    the stack. */
  10647.  
  10648. void
  10649. bc_expand_constructor (constr)
  10650.      tree constr;
  10651. {
  10652.   char *l;
  10653.   HOST_WIDE_INT ptroffs;
  10654.   rtx constr_rtx;
  10655.  
  10656.   
  10657.   /* Literal constructors are handled as constants, whereas
  10658.      non-literals are evaluated and stored element by element
  10659.      into the data segment. */
  10660.   
  10661.   /* Allocate space in proper segment and push pointer to space on stack.
  10662.    */
  10663.  
  10664.   l = bc_gen_constr_label ();
  10665.  
  10666.   if (TREE_CONSTANT (constr))
  10667.     {
  10668.       text_section ();
  10669.  
  10670.       bc_emit_const_labeldef (l);
  10671.       bc_output_constructor (constr, int_size_in_bytes (TREE_TYPE (constr)));
  10672.     }
  10673.   else
  10674.     {
  10675.       data_section ();
  10676.  
  10677.       bc_emit_data_labeldef (l);
  10678.       bc_output_data_constructor (constr);
  10679.     }
  10680.  
  10681.   
  10682.   /* Add reference to pointer table and recall pointer to stack;
  10683.      this code is common for both types of constructors: literals
  10684.      and non-literals. */
  10685.  
  10686.   ptroffs = bc_define_pointer (l);
  10687.   bc_emit_instruction (constP, ptroffs);
  10688.  
  10689.   /* This is all that has to be done if it's a literal. */
  10690.   if (TREE_CONSTANT (constr))
  10691.     return;
  10692.  
  10693.  
  10694.   /* At this point, we have the pointer to the structure on top of the stack.
  10695.      Generate sequences of store_memory calls for the constructor. */
  10696.   
  10697.   /* constructor type is structure */
  10698.   if (TREE_CODE (TREE_TYPE (constr)) == RECORD_TYPE)
  10699.     {
  10700.       register tree elt;
  10701.       
  10702.       /* If the constructor has fewer fields than the structure,
  10703.      clear the whole structure first.  */
  10704.       
  10705.       if (list_length (CONSTRUCTOR_ELTS (constr))
  10706.       != list_length (TYPE_FIELDS (TREE_TYPE (constr))))
  10707.     {
  10708.       bc_emit_instruction (duplicate);
  10709.       bc_emit_instruction (constSI, (HOST_WIDE_INT) int_size_in_bytes (TREE_TYPE (constr)));
  10710.       bc_emit_instruction (clearBLK);
  10711.     }
  10712.       
  10713.       /* Store each element of the constructor into the corresponding
  10714.      field of TARGET.  */
  10715.       
  10716.       for (elt = CONSTRUCTOR_ELTS (constr); elt; elt = TREE_CHAIN (elt))
  10717.     {
  10718.       register tree field = TREE_PURPOSE (elt);
  10719.       register enum machine_mode mode;
  10720.       int bitsize;
  10721.       int bitpos;
  10722.       int unsignedp;
  10723.       
  10724.       bitsize = TREE_INT_CST_LOW (DECL_SIZE (field)) /* * DECL_SIZE_UNIT (field) */;
  10725.       mode = DECL_MODE (field);
  10726.       unsignedp = TREE_UNSIGNED (field);
  10727.  
  10728.       bitpos = TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field));
  10729.       
  10730.       bc_store_field (elt, bitsize, bitpos, mode, TREE_VALUE (elt), TREE_TYPE (TREE_VALUE (elt)),
  10731.               /* The alignment of TARGET is
  10732.                  at least what its type requires.  */
  10733.               VOIDmode, 0,
  10734.               TYPE_ALIGN (TREE_TYPE (constr)) / BITS_PER_UNIT,
  10735.               int_size_in_bytes (TREE_TYPE (constr)));
  10736.     }
  10737.     }
  10738.   else
  10739.     
  10740.     /* Constructor type is array */
  10741.     if (TREE_CODE (TREE_TYPE (constr)) == ARRAY_TYPE)
  10742.       {
  10743.     register tree elt;
  10744.     register int i;
  10745.     tree domain = TYPE_DOMAIN (TREE_TYPE (constr));
  10746.     int minelt = TREE_INT_CST_LOW (TYPE_MIN_VALUE (domain));
  10747.     int maxelt = TREE_INT_CST_LOW (TYPE_MAX_VALUE (domain));
  10748.     tree elttype = TREE_TYPE (TREE_TYPE (constr));
  10749.     
  10750.     /* If the constructor has fewer fields than the structure,
  10751.        clear the whole structure first.  */
  10752.     
  10753.     if (list_length (CONSTRUCTOR_ELTS (constr)) < maxelt - minelt + 1)
  10754.       {
  10755.         bc_emit_instruction (duplicate);
  10756.         bc_emit_instruction (constSI, (HOST_WIDE_INT) int_size_in_bytes (TREE_TYPE (constr)));
  10757.         bc_emit_instruction (clearBLK);
  10758.       }
  10759.     
  10760.     
  10761.     /* Store each element of the constructor into the corresponding
  10762.        element of TARGET, determined by counting the elements. */
  10763.     
  10764.     for (elt = CONSTRUCTOR_ELTS (constr), i = 0;
  10765.          elt;
  10766.          elt = TREE_CHAIN (elt), i++)
  10767.       {
  10768.         register enum machine_mode mode;
  10769.         int bitsize;
  10770.         int bitpos;
  10771.         int unsignedp;
  10772.         
  10773.         mode = TYPE_MODE (elttype);
  10774.         bitsize = GET_MODE_BITSIZE (mode);
  10775.         unsignedp = TREE_UNSIGNED (elttype);
  10776.         
  10777.         bitpos = (i * TREE_INT_CST_LOW (TYPE_SIZE (elttype))
  10778.               /* * TYPE_SIZE_UNIT (elttype) */ );
  10779.         
  10780.         bc_store_field (elt, bitsize, bitpos, mode,
  10781.                 TREE_VALUE (elt), TREE_TYPE (TREE_VALUE (elt)),
  10782.                 /* The alignment of TARGET is
  10783.                    at least what its type requires.  */
  10784.                 VOIDmode, 0,
  10785.                 TYPE_ALIGN (TREE_TYPE (constr)) / BITS_PER_UNIT,
  10786.                 int_size_in_bytes (TREE_TYPE (constr)));
  10787.       }
  10788.   
  10789.       }
  10790. }
  10791.  
  10792.  
  10793. /* Store the value of EXP (an expression tree) into member FIELD of
  10794.    structure at address on stack, which has type TYPE, mode MODE and
  10795.    occupies BITSIZE bits, starting BITPOS bits from the beginning of the
  10796.    structure.
  10797.  
  10798.    ALIGN is the alignment that TARGET is known to have, measured in bytes.
  10799.    TOTAL_SIZE is its size in bytes, or -1 if variable.  */
  10800.  
  10801. void
  10802. bc_store_field (field, bitsize, bitpos, mode, exp, type,
  10803.         value_mode, unsignedp, align, total_size)
  10804.      int bitsize, bitpos;
  10805.      enum machine_mode mode;
  10806.      tree field, exp, type;
  10807.      enum machine_mode value_mode;
  10808.      int unsignedp;
  10809.      int align;
  10810.      int total_size;
  10811. {
  10812.  
  10813.   /* Expand expression and copy pointer */
  10814.   bc_expand_expr (exp);
  10815.   bc_emit_instruction (over);
  10816.  
  10817.  
  10818.   /* If the component is a bit field, we cannot use addressing to access
  10819.      it.  Use bit-field techniques to store in it.  */
  10820.  
  10821.   if (DECL_BIT_FIELD (field))
  10822.     {
  10823.       bc_store_bit_field (bitpos, bitsize, unsignedp);
  10824.       return;
  10825.     }
  10826.   else
  10827.     /* Not bit field */
  10828.     {
  10829.       HOST_WIDE_INT offset = bitpos / BITS_PER_UNIT;
  10830.  
  10831.       /* Advance pointer to the desired member */
  10832.       if (offset)
  10833.     bc_emit_instruction (addconstPSI, offset);
  10834.  
  10835.       /* Store */
  10836.       bc_store_memory (type, field);
  10837.     }
  10838. }
  10839.  
  10840.  
  10841. /* Store SI/SU in bitfield */
  10842. void
  10843. bc_store_bit_field (offset, size, unsignedp)
  10844.      int offset, size, unsignedp;
  10845. {
  10846.   /* Push bitfield offset and size */
  10847.   bc_push_offset_and_size (offset, size);
  10848.  
  10849.   /* Store */
  10850.   bc_emit_instruction (sstoreBI);
  10851. }
  10852.  
  10853.  
  10854. /* Load SI/SU from bitfield */
  10855. void
  10856. bc_load_bit_field (offset, size, unsignedp)
  10857.      int offset, size, unsignedp;
  10858. {
  10859.   /* Push bitfield offset and size */
  10860.   bc_push_offset_and_size (offset, size);
  10861.  
  10862.   /* Load: sign-extend if signed, else zero-extend */
  10863.   bc_emit_instruction (unsignedp ? zxloadBI : sxloadBI);
  10864. }  
  10865.  
  10866.  
  10867. /* Adjust interpreter stack by NLEVELS.  Positive means drop NLEVELS
  10868.    (adjust stack pointer upwards), negative means add that number of
  10869.    levels (adjust the stack pointer downwards).  Only positive values
  10870.    normally make sense. */
  10871.  
  10872. void
  10873. bc_adjust_stack (nlevels)
  10874.      int nlevels;
  10875. {
  10876.   switch (nlevels)
  10877.     {
  10878.     case 0:
  10879.       break;
  10880.       
  10881.     case 2:
  10882.       bc_emit_instruction (drop);
  10883.       
  10884.     case 1:
  10885.       bc_emit_instruction (drop);
  10886.       break;
  10887.       
  10888.     default:
  10889.       
  10890.       bc_emit_instruction (adjstackSI, (HOST_WIDE_INT) nlevels);
  10891.       stack_depth -= nlevels;
  10892.     }
  10893.  
  10894. #if defined (VALIDATE_STACK_FOR_BC)
  10895.   VALIDATE_STACK_FOR_BC ();
  10896. #endif
  10897. }
  10898.