OSDN Git Service

Move RTL checking code into make_insn_raw
[pf3gnuchains/gcc-fork.git] / gcc / emit-rtl.c
1 /* Emit RTL for the GNU C-Compiler expander.
2    Copyright (C) 1987, 88, 92-99, 2000 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 /* Middle-to-low level generation of rtx code and insns.
23
24    This file contains the functions `gen_rtx', `gen_reg_rtx'
25    and `gen_label_rtx' that are the usual ways of creating rtl
26    expressions for most purposes.
27
28    It also has the functions for creating insns and linking
29    them in the doubly-linked chain.
30
31    The patterns of the insns are created by machine-dependent
32    routines in insn-emit.c, which is generated automatically from
33    the machine description.  These routines use `gen_rtx' to make
34    the individual rtx's of the pattern; what is machine dependent
35    is the kind of rtx's they make and what arguments they use.  */
36
37 #include "config.h"
38 #include "system.h"
39 #include "toplev.h"
40 #include "rtl.h"
41 #include "tree.h"
42 #include "tm_p.h"
43 #include "flags.h"
44 #include "function.h"
45 #include "expr.h"
46 #include "regs.h"
47 #include "hard-reg-set.h"
48 #include "insn-config.h"
49 #include "recog.h"
50 #include "real.h"
51 #include "obstack.h"
52 #include "bitmap.h"
53 #include "basic-block.h"
54 #include "ggc.h"
55
56 /* Commonly used modes.  */
57
58 enum machine_mode byte_mode;    /* Mode whose width is BITS_PER_UNIT.  */
59 enum machine_mode word_mode;    /* Mode whose width is BITS_PER_WORD.  */
60 enum machine_mode double_mode;  /* Mode whose width is DOUBLE_TYPE_SIZE.  */
61 enum machine_mode ptr_mode;     /* Mode whose width is POINTER_SIZE.  */
62
63
64 /* This is *not* reset after each function.  It gives each CODE_LABEL
65    in the entire compilation a unique label number.  */
66
67 static int label_num = 1;
68
69 /* Highest label number in current function.
70    Zero means use the value of label_num instead.
71    This is nonzero only when belatedly compiling an inline function.  */
72
73 static int last_label_num;
74
75 /* Value label_num had when set_new_first_and_last_label_number was called.
76    If label_num has not changed since then, last_label_num is valid.  */
77
78 static int base_label_num;
79
80 /* Nonzero means do not generate NOTEs for source line numbers.  */
81
82 static int no_line_numbers;
83
84 /* Commonly used rtx's, so that we only need space for one copy.
85    These are initialized once for the entire compilation.
86    All of these except perhaps the floating-point CONST_DOUBLEs
87    are unique; no other rtx-object will be equal to any of these.  */
88
89 rtx global_rtl[GR_MAX];
90
91 /* We record floating-point CONST_DOUBLEs in each floating-point mode for
92    the values of 0, 1, and 2.  For the integer entries and VOIDmode, we
93    record a copy of const[012]_rtx.  */
94
95 rtx const_tiny_rtx[3][(int) MAX_MACHINE_MODE];
96
97 rtx const_true_rtx;
98
99 REAL_VALUE_TYPE dconst0;
100 REAL_VALUE_TYPE dconst1;
101 REAL_VALUE_TYPE dconst2;
102 REAL_VALUE_TYPE dconstm1;
103
104 /* All references to the following fixed hard registers go through
105    these unique rtl objects.  On machines where the frame-pointer and
106    arg-pointer are the same register, they use the same unique object.
107
108    After register allocation, other rtl objects which used to be pseudo-regs
109    may be clobbered to refer to the frame-pointer register.
110    But references that were originally to the frame-pointer can be
111    distinguished from the others because they contain frame_pointer_rtx.
112
113    When to use frame_pointer_rtx and hard_frame_pointer_rtx is a little
114    tricky: until register elimination has taken place hard_frame_pointer_rtx
115    should be used if it is being set, and frame_pointer_rtx otherwise.  After 
116    register elimination hard_frame_pointer_rtx should always be used.
117    On machines where the two registers are same (most) then these are the
118    same.
119
120    In an inline procedure, the stack and frame pointer rtxs may not be
121    used for anything else.  */
122 rtx struct_value_rtx;           /* (REG:Pmode STRUCT_VALUE_REGNUM) */
123 rtx struct_value_incoming_rtx;  /* (REG:Pmode STRUCT_VALUE_INCOMING_REGNUM) */
124 rtx static_chain_rtx;           /* (REG:Pmode STATIC_CHAIN_REGNUM) */
125 rtx static_chain_incoming_rtx;  /* (REG:Pmode STATIC_CHAIN_INCOMING_REGNUM) */
126 rtx pic_offset_table_rtx;       /* (REG:Pmode PIC_OFFSET_TABLE_REGNUM) */
127
128 /* This is used to implement __builtin_return_address for some machines.
129    See for instance the MIPS port.  */
130 rtx return_address_pointer_rtx; /* (REG:Pmode RETURN_ADDRESS_POINTER_REGNUM) */
131
132 /* We make one copy of (const_int C) where C is in
133    [- MAX_SAVED_CONST_INT, MAX_SAVED_CONST_INT]
134    to save space during the compilation and simplify comparisons of
135    integers.  */
136
137 rtx const_int_rtx[MAX_SAVED_CONST_INT * 2 + 1];
138
139 /* start_sequence and gen_sequence can make a lot of rtx expressions which are
140    shortly thrown away.  We use two mechanisms to prevent this waste:
141
142    For sizes up to 5 elements, we keep a SEQUENCE and its associated
143    rtvec for use by gen_sequence.  One entry for each size is
144    sufficient because most cases are calls to gen_sequence followed by
145    immediately emitting the SEQUENCE.  Reuse is safe since emitting a
146    sequence is destructive on the insn in it anyway and hence can't be
147    redone.
148
149    We do not bother to save this cached data over nested function calls.
150    Instead, we just reinitialize them.  */
151
152 #define SEQUENCE_RESULT_SIZE 5
153
154 static rtx sequence_result[SEQUENCE_RESULT_SIZE];
155
156 /* During RTL generation, we also keep a list of free INSN rtl codes.  */
157 static rtx free_insn;
158
159 #define first_insn (cfun->emit->x_first_insn)
160 #define last_insn (cfun->emit->x_last_insn)
161 #define cur_insn_uid (cfun->emit->x_cur_insn_uid)
162 #define last_linenum (cfun->emit->x_last_linenum)
163 #define last_filename (cfun->emit->x_last_filename)
164 #define first_label_num (cfun->emit->x_first_label_num)
165
166 /* This is where the pointer to the obstack being used for RTL is stored.  */
167 extern struct obstack *rtl_obstack;
168
169 static rtx make_jump_insn_raw           PARAMS ((rtx));
170 static rtx make_call_insn_raw           PARAMS ((rtx));
171 static rtx find_line_note               PARAMS ((rtx));
172 static void mark_sequence_stack         PARAMS ((struct sequence_stack *));
173 static void unshare_all_rtl_1           PARAMS ((rtx));
174 \f
175 /* There are some RTL codes that require special attention; the generation
176    functions do the raw handling.  If you add to this list, modify
177    special_rtx in gengenrtl.c as well.  */
178
179 rtx
180 gen_rtx_CONST_INT (mode, arg)
181      enum machine_mode mode;
182      HOST_WIDE_INT arg;
183 {
184   if (arg >= - MAX_SAVED_CONST_INT && arg <= MAX_SAVED_CONST_INT)
185     return const_int_rtx[arg + MAX_SAVED_CONST_INT];
186
187 #if STORE_FLAG_VALUE != 1 && STORE_FLAG_VALUE != -1
188   if (const_true_rtx && arg == STORE_FLAG_VALUE)
189     return const_true_rtx;
190 #endif
191
192   return gen_rtx_raw_CONST_INT (mode, arg);
193 }
194
195 /* CONST_DOUBLEs needs special handling because its length is known
196    only at run-time.  */
197 rtx
198 gen_rtx_CONST_DOUBLE (mode, arg0, arg1, arg2)
199      enum machine_mode mode;
200      rtx arg0;
201      HOST_WIDE_INT arg1, arg2;
202 {
203   rtx r = rtx_alloc (CONST_DOUBLE);
204   int i;
205
206   PUT_MODE (r, mode);
207   XEXP (r, 0) = arg0;
208   X0EXP (r, 1) = NULL_RTX;
209   XWINT (r, 2) = arg1;
210   XWINT (r, 3) = arg2;
211
212   for (i = GET_RTX_LENGTH (CONST_DOUBLE) - 1; i > 3; --i)
213     XWINT (r, i) = 0;
214
215   return r;
216 }
217
218 rtx
219 gen_rtx_REG (mode, regno)
220      enum machine_mode mode;
221      int regno;
222 {
223   /* In case the MD file explicitly references the frame pointer, have
224      all such references point to the same frame pointer.  This is
225      used during frame pointer elimination to distinguish the explicit
226      references to these registers from pseudos that happened to be
227      assigned to them.
228
229      If we have eliminated the frame pointer or arg pointer, we will
230      be using it as a normal register, for example as a spill
231      register.  In such cases, we might be accessing it in a mode that
232      is not Pmode and therefore cannot use the pre-allocated rtx.
233
234      Also don't do this when we are making new REGs in reload, since
235      we don't want to get confused with the real pointers.  */
236
237   if (mode == Pmode && !reload_in_progress)
238     {
239       if (regno == FRAME_POINTER_REGNUM)
240         return frame_pointer_rtx;
241 #if FRAME_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
242       if (regno == HARD_FRAME_POINTER_REGNUM)
243         return hard_frame_pointer_rtx;
244 #endif
245 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM && HARD_FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
246       if (regno == ARG_POINTER_REGNUM)
247         return arg_pointer_rtx;
248 #endif
249 #ifdef RETURN_ADDRESS_POINTER_REGNUM
250       if (regno == RETURN_ADDRESS_POINTER_REGNUM)
251         return return_address_pointer_rtx;
252 #endif
253       if (regno == STACK_POINTER_REGNUM)
254         return stack_pointer_rtx;
255     }
256
257   return gen_rtx_raw_REG (mode, regno);
258 }
259
260 rtx
261 gen_rtx_MEM (mode, addr)
262      enum machine_mode mode;
263      rtx addr;
264 {
265   rtx rt = gen_rtx_raw_MEM (mode, addr);
266
267   /* This field is not cleared by the mere allocation of the rtx, so
268      we clear it here.  */
269   MEM_ALIAS_SET (rt) = 0;
270
271   return rt;
272 }
273 \f
274 /* rtx gen_rtx (code, mode, [element1, ..., elementn])
275 **
276 **          This routine generates an RTX of the size specified by
277 **      <code>, which is an RTX code.   The RTX structure is initialized
278 **      from the arguments <element1> through <elementn>, which are
279 **      interpreted according to the specific RTX type's format.   The
280 **      special machine mode associated with the rtx (if any) is specified
281 **      in <mode>.
282 **
283 **          gen_rtx can be invoked in a way which resembles the lisp-like
284 **      rtx it will generate.   For example, the following rtx structure:
285 **
286 **            (plus:QI (mem:QI (reg:SI 1))
287 **                     (mem:QI (plusw:SI (reg:SI 2) (reg:SI 3))))
288 **
289 **              ...would be generated by the following C code:
290 **
291 **              gen_rtx (PLUS, QImode,
292 **                  gen_rtx (MEM, QImode,
293 **                      gen_rtx (REG, SImode, 1)),
294 **                  gen_rtx (MEM, QImode,
295 **                      gen_rtx (PLUS, SImode,
296 **                          gen_rtx (REG, SImode, 2),
297 **                          gen_rtx (REG, SImode, 3)))),
298 */
299
300 /*VARARGS2*/
301 rtx
302 gen_rtx VPARAMS ((enum rtx_code code, enum machine_mode mode, ...))
303 {
304 #ifndef ANSI_PROTOTYPES
305   enum rtx_code code;
306   enum machine_mode mode;
307 #endif
308   va_list p;
309   register int i;               /* Array indices...                     */
310   register const char *fmt;     /* Current rtx's format...              */
311   register rtx rt_val;          /* RTX to return to caller...           */
312
313   VA_START (p, mode);
314
315 #ifndef ANSI_PROTOTYPES
316   code = va_arg (p, enum rtx_code);
317   mode = va_arg (p, enum machine_mode);
318 #endif
319
320   switch (code)
321     {
322     case CONST_INT:
323       rt_val = gen_rtx_CONST_INT (mode, va_arg (p, HOST_WIDE_INT));
324       break;
325
326     case CONST_DOUBLE:
327       {
328         rtx arg0 = va_arg (p, rtx);
329         HOST_WIDE_INT arg1 = va_arg (p, HOST_WIDE_INT);
330         HOST_WIDE_INT arg2 = va_arg (p, HOST_WIDE_INT);
331         rt_val = gen_rtx_CONST_DOUBLE (mode, arg0, arg1, arg2);
332       }
333       break;
334
335     case REG:
336       rt_val = gen_rtx_REG (mode, va_arg (p, int));
337       break;
338
339     case MEM:
340       rt_val = gen_rtx_MEM (mode, va_arg (p, rtx));
341       break;
342
343     default:
344       rt_val = rtx_alloc (code);        /* Allocate the storage space.  */
345       rt_val->mode = mode;              /* Store the machine mode...  */
346
347       fmt = GET_RTX_FORMAT (code);      /* Find the right format...  */
348       for (i = 0; i < GET_RTX_LENGTH (code); i++)
349         {
350           switch (*fmt++)
351             {
352             case '0':           /* Unused field.  */
353               break;
354
355             case 'i':           /* An integer?  */
356               XINT (rt_val, i) = va_arg (p, int);
357               break;
358
359             case 'w':           /* A wide integer? */
360               XWINT (rt_val, i) = va_arg (p, HOST_WIDE_INT);
361               break;
362
363             case 's':           /* A string?  */
364               XSTR (rt_val, i) = va_arg (p, char *);
365               break;
366
367             case 'e':           /* An expression?  */
368             case 'u':           /* An insn?  Same except when printing.  */
369               XEXP (rt_val, i) = va_arg (p, rtx);
370               break;
371
372             case 'E':           /* An RTX vector?  */
373               XVEC (rt_val, i) = va_arg (p, rtvec);
374               break;
375
376             case 'b':           /* A bitmap? */
377               XBITMAP (rt_val, i) = va_arg (p, bitmap);
378               break;
379
380             case 't':           /* A tree? */
381               XTREE (rt_val, i) = va_arg (p, tree);
382               break;
383
384             default:
385               abort ();
386             }
387         }
388       break;
389     }
390
391   va_end (p);
392   return rt_val;
393 }
394
395 /* gen_rtvec (n, [rt1, ..., rtn])
396 **
397 **          This routine creates an rtvec and stores within it the
398 **      pointers to rtx's which are its arguments.
399 */
400
401 /*VARARGS1*/
402 rtvec
403 gen_rtvec VPARAMS ((int n, ...))
404 {
405 #ifndef ANSI_PROTOTYPES
406   int n;
407 #endif
408   int i;
409   va_list p;
410   rtx *vector;
411
412   VA_START (p, n);
413
414 #ifndef ANSI_PROTOTYPES
415   n = va_arg (p, int);
416 #endif
417
418   if (n == 0)
419     return NULL_RTVEC;          /* Don't allocate an empty rtvec...     */
420
421   vector = (rtx *) alloca (n * sizeof (rtx));
422
423   for (i = 0; i < n; i++)
424     vector[i] = va_arg (p, rtx);
425   va_end (p);
426
427   return gen_rtvec_v (n, vector);
428 }
429
430 rtvec
431 gen_rtvec_v (n, argp)
432      int n;
433      rtx *argp;
434 {
435   register int i;
436   register rtvec rt_val;
437
438   if (n == 0)
439     return NULL_RTVEC;          /* Don't allocate an empty rtvec...     */
440
441   rt_val = rtvec_alloc (n);     /* Allocate an rtvec...                 */
442
443   for (i = 0; i < n; i++)
444     rt_val->elem[i] = *argp++;
445
446   return rt_val;
447 }
448
449 \f
450 /* Generate a REG rtx for a new pseudo register of mode MODE.
451    This pseudo is assigned the next sequential register number.  */
452
453 rtx
454 gen_reg_rtx (mode)
455      enum machine_mode mode;
456 {
457   struct function *f = cfun;
458   register rtx val;
459
460   /* Don't let anything called after initial flow analysis create new
461      registers.  */
462   if (no_new_pseudos)
463     abort ();
464
465   if (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT
466       || GET_MODE_CLASS (mode) == MODE_COMPLEX_INT)
467     {
468       /* For complex modes, don't make a single pseudo.
469          Instead, make a CONCAT of two pseudos.
470          This allows noncontiguous allocation of the real and imaginary parts,
471          which makes much better code.  Besides, allocating DCmode
472          pseudos overstrains reload on some machines like the 386.  */
473       rtx realpart, imagpart;
474       int size = GET_MODE_UNIT_SIZE (mode);
475       enum machine_mode partmode
476         = mode_for_size (size * BITS_PER_UNIT,
477                          (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT
478                           ? MODE_FLOAT : MODE_INT),
479                          0);
480
481       realpart = gen_reg_rtx (partmode);
482       imagpart = gen_reg_rtx (partmode);
483       return gen_rtx_CONCAT (mode, realpart, imagpart);
484     }
485
486   /* Make sure regno_pointer_flag and regno_reg_rtx are large
487      enough to have an element for this pseudo reg number.  */
488
489   if (reg_rtx_no == f->emit->regno_pointer_flag_length)
490     {
491       int old_size = f->emit->regno_pointer_flag_length;
492       rtx *new1;
493       char *new;
494       new = xrealloc (f->emit->regno_pointer_flag, old_size * 2);
495       memset (new + old_size, 0, old_size);
496       f->emit->regno_pointer_flag = new;
497
498       new = xrealloc (f->emit->regno_pointer_align, old_size * 2);
499       memset (new + old_size, 0, old_size);
500       f->emit->regno_pointer_align = new;
501
502       new1 = (rtx *) xrealloc (f->emit->x_regno_reg_rtx,
503                                old_size * 2 * sizeof (rtx));
504       memset (new1 + old_size, 0, old_size * sizeof (rtx));
505       regno_reg_rtx = new1;
506
507       f->emit->regno_pointer_flag_length = old_size * 2;
508     }
509
510   val = gen_rtx_raw_REG (mode, reg_rtx_no);
511   regno_reg_rtx[reg_rtx_no++] = val;
512   return val;
513 }
514
515 /* Identify REG (which may be a CONCAT) as a user register.  */
516
517 void
518 mark_user_reg (reg)
519      rtx reg;
520 {
521   if (GET_CODE (reg) == CONCAT)
522     {
523       REG_USERVAR_P (XEXP (reg, 0)) = 1;
524       REG_USERVAR_P (XEXP (reg, 1)) = 1;
525     }
526   else if (GET_CODE (reg) == REG)
527     REG_USERVAR_P (reg) = 1;
528   else
529     abort ();
530 }
531
532 /* Identify REG as a probable pointer register and show its alignment
533    as ALIGN, if nonzero.  */
534
535 void
536 mark_reg_pointer (reg, align)
537      rtx reg;
538      int align;
539 {
540   if (! REGNO_POINTER_FLAG (REGNO (reg)))
541     {
542       REGNO_POINTER_FLAG (REGNO (reg)) = 1;
543
544       if (align)
545         REGNO_POINTER_ALIGN (REGNO (reg)) = align;
546     }
547   else if (align && align < REGNO_POINTER_ALIGN (REGNO (reg)))
548     /* We can no-longer be sure just how aligned this pointer is */
549     REGNO_POINTER_ALIGN (REGNO (reg)) = align;
550 }
551
552 /* Return 1 plus largest pseudo reg number used in the current function.  */
553
554 int
555 max_reg_num ()
556 {
557   return reg_rtx_no;
558 }
559
560 /* Return 1 + the largest label number used so far in the current function.  */
561
562 int
563 max_label_num ()
564 {
565   if (last_label_num && label_num == base_label_num)
566     return last_label_num;
567   return label_num;
568 }
569
570 /* Return first label number used in this function (if any were used).  */
571
572 int
573 get_first_label_num ()
574 {
575   return first_label_num;
576 }
577 \f
578 /* Return a value representing some low-order bits of X, where the number
579    of low-order bits is given by MODE.  Note that no conversion is done
580    between floating-point and fixed-point values, rather, the bit 
581    representation is returned.
582
583    This function handles the cases in common between gen_lowpart, below,
584    and two variants in cse.c and combine.c.  These are the cases that can
585    be safely handled at all points in the compilation.
586
587    If this is not a case we can handle, return 0.  */
588
589 rtx
590 gen_lowpart_common (mode, x)
591      enum machine_mode mode;
592      register rtx x;
593 {
594   int word = 0;
595
596   if (GET_MODE (x) == mode)
597     return x;
598
599   /* MODE must occupy no more words than the mode of X.  */
600   if (GET_MODE (x) != VOIDmode
601       && ((GET_MODE_SIZE (mode) + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD
602           > ((GET_MODE_SIZE (GET_MODE (x)) + (UNITS_PER_WORD - 1))
603              / UNITS_PER_WORD)))
604     return 0;
605
606   if (WORDS_BIG_ENDIAN && GET_MODE_SIZE (GET_MODE (x)) > UNITS_PER_WORD)
607     word = ((GET_MODE_SIZE (GET_MODE (x))
608              - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD))
609             / UNITS_PER_WORD);
610
611   if ((GET_CODE (x) == ZERO_EXTEND || GET_CODE (x) == SIGN_EXTEND)
612       && (GET_MODE_CLASS (mode) == MODE_INT
613           || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT))
614     {
615       /* If we are getting the low-order part of something that has been
616          sign- or zero-extended, we can either just use the object being
617          extended or make a narrower extension.  If we want an even smaller
618          piece than the size of the object being extended, call ourselves
619          recursively.
620
621          This case is used mostly by combine and cse.  */
622
623       if (GET_MODE (XEXP (x, 0)) == mode)
624         return XEXP (x, 0);
625       else if (GET_MODE_SIZE (mode) < GET_MODE_SIZE (GET_MODE (XEXP (x, 0))))
626         return gen_lowpart_common (mode, XEXP (x, 0));
627       else if (GET_MODE_SIZE (mode) < GET_MODE_SIZE (GET_MODE (x)))
628         return gen_rtx_fmt_e (GET_CODE (x), mode, XEXP (x, 0));
629     }
630   else if (GET_CODE (x) == SUBREG
631            && (GET_MODE_SIZE (mode) <= UNITS_PER_WORD
632                || GET_MODE_SIZE (mode) == GET_MODE_UNIT_SIZE (GET_MODE (x))))
633     return (GET_MODE (SUBREG_REG (x)) == mode && SUBREG_WORD (x) == 0
634             ? SUBREG_REG (x)
635             : gen_rtx_SUBREG (mode, SUBREG_REG (x), SUBREG_WORD (x) + word));
636   else if (GET_CODE (x) == REG)
637     {
638       /* Let the backend decide how many registers to skip.  This is needed
639          in particular for Sparc64 where fp regs are smaller than a word.  */
640       /* ??? Note that subregs are now ambiguous, in that those against
641          pseudos are sized by the Word Size, while those against hard
642          regs are sized by the underlying register size.  Better would be
643          to always interpret the subreg offset parameter as bytes or bits.  */
644
645       if (WORDS_BIG_ENDIAN && REGNO (x) < FIRST_PSEUDO_REGISTER)
646         word = (HARD_REGNO_NREGS (REGNO (x), GET_MODE (x))
647                 - HARD_REGNO_NREGS (REGNO (x), mode));
648
649       /* If the register is not valid for MODE, return 0.  If we don't
650          do this, there is no way to fix up the resulting REG later.  
651          But we do do this if the current REG is not valid for its
652          mode.  This latter is a kludge, but is required due to the
653          way that parameters are passed on some machines, most
654          notably Sparc.  */
655       if (REGNO (x) < FIRST_PSEUDO_REGISTER
656           && ! HARD_REGNO_MODE_OK (REGNO (x) + word, mode)
657           && HARD_REGNO_MODE_OK (REGNO (x), GET_MODE (x)))
658         return 0;
659       else if (REGNO (x) < FIRST_PSEUDO_REGISTER
660                /* integrate.c can't handle parts of a return value register. */
661                && (! REG_FUNCTION_VALUE_P (x)
662                    || ! rtx_equal_function_value_matters)
663 #ifdef CLASS_CANNOT_CHANGE_SIZE
664                && ! (GET_MODE_SIZE (mode) != GET_MODE_SIZE (GET_MODE (x))
665                      && GET_MODE_CLASS (GET_MODE (x)) != MODE_COMPLEX_INT
666                      && GET_MODE_CLASS (GET_MODE (x)) != MODE_COMPLEX_FLOAT
667                      && (TEST_HARD_REG_BIT
668                          (reg_class_contents[(int) CLASS_CANNOT_CHANGE_SIZE],
669                           REGNO (x))))
670 #endif
671                /* We want to keep the stack, frame, and arg pointers
672                   special.  */
673                && x != frame_pointer_rtx
674 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
675                && x != arg_pointer_rtx
676 #endif
677                && x != stack_pointer_rtx)
678         return gen_rtx_REG (mode, REGNO (x) + word);
679       else
680         return gen_rtx_SUBREG (mode, x, word);
681     }
682   /* If X is a CONST_INT or a CONST_DOUBLE, extract the appropriate bits
683      from the low-order part of the constant.  */
684   else if ((GET_MODE_CLASS (mode) == MODE_INT
685             || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)
686            && GET_MODE (x) == VOIDmode
687            && (GET_CODE (x) == CONST_INT || GET_CODE (x) == CONST_DOUBLE))
688     {
689       /* If MODE is twice the host word size, X is already the desired
690          representation.  Otherwise, if MODE is wider than a word, we can't
691          do this.  If MODE is exactly a word, return just one CONST_INT.
692          If MODE is smaller than a word, clear the bits that don't belong
693          in our mode, unless they and our sign bit are all one.  So we get
694          either a reasonable negative value or a reasonable unsigned value
695          for this mode.  */
696
697       if (GET_MODE_BITSIZE (mode) >= 2 * HOST_BITS_PER_WIDE_INT)
698         return x;
699       else if (GET_MODE_BITSIZE (mode) > HOST_BITS_PER_WIDE_INT)
700         return 0;
701       else if (GET_MODE_BITSIZE (mode) == HOST_BITS_PER_WIDE_INT)
702         return (GET_CODE (x) == CONST_INT ? x
703                 : GEN_INT (CONST_DOUBLE_LOW (x)));
704       else
705         {
706           /* MODE must be narrower than HOST_BITS_PER_WIDE_INT.  */
707           int width = GET_MODE_BITSIZE (mode);
708           HOST_WIDE_INT val = (GET_CODE (x) == CONST_INT ? INTVAL (x)
709                                : CONST_DOUBLE_LOW (x));
710
711           /* Sign extend to HOST_WIDE_INT.  */
712           val = val << (HOST_BITS_PER_WIDE_INT - width) >> (HOST_BITS_PER_WIDE_INT - width);
713
714           return (GET_CODE (x) == CONST_INT && INTVAL (x) == val ? x
715                   : GEN_INT (val));
716         }
717     }
718
719   /* If X is an integral constant but we want it in floating-point, it
720      must be the case that we have a union of an integer and a floating-point
721      value.  If the machine-parameters allow it, simulate that union here
722      and return the result.  The two-word and single-word cases are 
723      different.  */
724
725   else if (((HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
726              && HOST_BITS_PER_WIDE_INT == BITS_PER_WORD)
727             || flag_pretend_float)
728            && GET_MODE_CLASS (mode) == MODE_FLOAT
729            && GET_MODE_SIZE (mode) == UNITS_PER_WORD
730            && GET_CODE (x) == CONST_INT
731            && sizeof (float) * HOST_BITS_PER_CHAR == HOST_BITS_PER_WIDE_INT)
732 #ifdef REAL_ARITHMETIC
733     {
734       REAL_VALUE_TYPE r;
735       HOST_WIDE_INT i;
736
737       i = INTVAL (x);
738       r = REAL_VALUE_FROM_TARGET_SINGLE (i);
739       return CONST_DOUBLE_FROM_REAL_VALUE (r, mode);
740     }
741 #else
742     {
743       union {HOST_WIDE_INT i; float d; } u;
744
745       u.i = INTVAL (x);
746       return CONST_DOUBLE_FROM_REAL_VALUE (u.d, mode);
747     }
748 #endif
749   else if (((HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
750              && HOST_BITS_PER_WIDE_INT == BITS_PER_WORD)
751             || flag_pretend_float)
752            && GET_MODE_CLASS (mode) == MODE_FLOAT
753            && GET_MODE_SIZE (mode) == 2 * UNITS_PER_WORD
754            && (GET_CODE (x) == CONST_INT || GET_CODE (x) == CONST_DOUBLE)
755            && GET_MODE (x) == VOIDmode
756            && (sizeof (double) * HOST_BITS_PER_CHAR
757                == 2 * HOST_BITS_PER_WIDE_INT))
758 #ifdef REAL_ARITHMETIC
759     {
760       REAL_VALUE_TYPE r;
761       HOST_WIDE_INT i[2];
762       HOST_WIDE_INT low, high;
763
764       if (GET_CODE (x) == CONST_INT)
765         low = INTVAL (x), high = low >> (HOST_BITS_PER_WIDE_INT -1);
766       else
767         low = CONST_DOUBLE_LOW (x), high = CONST_DOUBLE_HIGH (x);
768
769       /* REAL_VALUE_TARGET_DOUBLE takes the addressing order of the
770          target machine.  */
771       if (WORDS_BIG_ENDIAN)
772         i[0] = high, i[1] = low;
773       else
774         i[0] = low, i[1] = high;
775
776       r = REAL_VALUE_FROM_TARGET_DOUBLE (i);
777       return CONST_DOUBLE_FROM_REAL_VALUE (r, mode);
778     }
779 #else
780     {
781       union {HOST_WIDE_INT i[2]; double d; } u;
782       HOST_WIDE_INT low, high;
783
784       if (GET_CODE (x) == CONST_INT)
785         low = INTVAL (x), high = low >> (HOST_BITS_PER_WIDE_INT -1);
786       else
787         low = CONST_DOUBLE_LOW (x), high = CONST_DOUBLE_HIGH (x);
788
789 #ifdef HOST_WORDS_BIG_ENDIAN
790       u.i[0] = high, u.i[1] = low;
791 #else
792       u.i[0] = low, u.i[1] = high;
793 #endif
794
795       return CONST_DOUBLE_FROM_REAL_VALUE (u.d, mode);
796     }
797 #endif
798
799   /* We need an extra case for machines where HOST_BITS_PER_WIDE_INT is the
800      same as sizeof (double) or when sizeof (float) is larger than the
801      size of a word on the target machine.  */
802 #ifdef REAL_ARITHMETIC
803   else if (mode == SFmode && GET_CODE (x) == CONST_INT)
804     {
805       REAL_VALUE_TYPE r;
806       HOST_WIDE_INT i;
807
808       i = INTVAL (x);
809       r = REAL_VALUE_FROM_TARGET_SINGLE (i);
810       return CONST_DOUBLE_FROM_REAL_VALUE (r, mode);
811     }
812   else if (((HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
813              && HOST_BITS_PER_WIDE_INT == BITS_PER_WORD)
814             || flag_pretend_float)
815            && GET_MODE_CLASS (mode) == MODE_FLOAT
816            && GET_MODE_SIZE (mode) == UNITS_PER_WORD
817            && GET_CODE (x) == CONST_INT
818            && (sizeof (double) * HOST_BITS_PER_CHAR
819                == HOST_BITS_PER_WIDE_INT))
820     {
821       REAL_VALUE_TYPE r;
822       HOST_WIDE_INT i;
823
824       i = INTVAL (x);
825       r = REAL_VALUE_FROM_TARGET_DOUBLE (&i);
826       return CONST_DOUBLE_FROM_REAL_VALUE (r, mode);
827     }
828 #endif
829
830   /* Similarly, if this is converting a floating-point value into a
831      single-word integer.  Only do this is the host and target parameters are
832      compatible.  */
833
834   else if (((HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
835              && HOST_BITS_PER_WIDE_INT == BITS_PER_WORD)
836             || flag_pretend_float)
837            && (GET_MODE_CLASS (mode) == MODE_INT
838                || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)
839            && GET_CODE (x) == CONST_DOUBLE
840            && GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT
841            && GET_MODE_BITSIZE (mode) == BITS_PER_WORD)
842     return operand_subword (x, word, 0, GET_MODE (x));
843
844   /* Similarly, if this is converting a floating-point value into a
845      two-word integer, we can do this one word at a time and make an
846      integer.  Only do this is the host and target parameters are
847      compatible.  */
848
849   else if (((HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
850              && HOST_BITS_PER_WIDE_INT == BITS_PER_WORD)
851             || flag_pretend_float)
852            && (GET_MODE_CLASS (mode) == MODE_INT
853                || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)
854            && GET_CODE (x) == CONST_DOUBLE
855            && GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT
856            && GET_MODE_BITSIZE (mode) == 2 * BITS_PER_WORD)
857     {
858       rtx lowpart
859         = operand_subword (x, word + WORDS_BIG_ENDIAN, 0, GET_MODE (x));
860       rtx highpart
861         = operand_subword (x, word + ! WORDS_BIG_ENDIAN, 0, GET_MODE (x));
862
863       if (lowpart && GET_CODE (lowpart) == CONST_INT
864           && highpart && GET_CODE (highpart) == CONST_INT)
865         return immed_double_const (INTVAL (lowpart), INTVAL (highpart), mode);
866     }
867
868   /* Otherwise, we can't do this.  */
869   return 0;
870 }
871 \f
872 /* Return the real part (which has mode MODE) of a complex value X.
873    This always comes at the low address in memory.  */
874
875 rtx
876 gen_realpart (mode, x)
877      enum machine_mode mode;
878      register rtx x;
879 {
880   if (GET_CODE (x) == CONCAT && GET_MODE (XEXP (x, 0)) == mode)
881     return XEXP (x, 0);
882   else if (WORDS_BIG_ENDIAN
883            && GET_MODE_BITSIZE (mode) < BITS_PER_WORD
884            && REG_P (x)
885            && REGNO (x) < FIRST_PSEUDO_REGISTER)
886     fatal ("Unable to access real part of complex value in a hard register on this target");
887   else if (WORDS_BIG_ENDIAN)
888     return gen_highpart (mode, x);
889   else
890     return gen_lowpart (mode, x);
891 }
892
893 /* Return the imaginary part (which has mode MODE) of a complex value X.
894    This always comes at the high address in memory.  */
895
896 rtx
897 gen_imagpart (mode, x)
898      enum machine_mode mode;
899      register rtx x;
900 {
901   if (GET_CODE (x) == CONCAT && GET_MODE (XEXP (x, 0)) == mode)
902     return XEXP (x, 1);
903   else if (WORDS_BIG_ENDIAN)
904     return gen_lowpart (mode, x);
905   else if (!WORDS_BIG_ENDIAN
906            && GET_MODE_BITSIZE (mode) < BITS_PER_WORD
907            && REG_P (x)
908            && REGNO (x) < FIRST_PSEUDO_REGISTER)
909     fatal ("Unable to access imaginary part of complex value in a hard register on this target");
910   else
911     return gen_highpart (mode, x);
912 }
913
914 /* Return 1 iff X, assumed to be a SUBREG,
915    refers to the real part of the complex value in its containing reg.
916    Complex values are always stored with the real part in the first word,
917    regardless of WORDS_BIG_ENDIAN.  */
918
919 int
920 subreg_realpart_p (x)
921      rtx x;
922 {
923   if (GET_CODE (x) != SUBREG)
924     abort ();
925
926   return SUBREG_WORD (x) * UNITS_PER_WORD < GET_MODE_UNIT_SIZE (GET_MODE (SUBREG_REG (x)));
927 }
928 \f
929 /* Assuming that X is an rtx (e.g., MEM, REG or SUBREG) for a value,
930    return an rtx (MEM, SUBREG, or CONST_INT) that refers to the
931    least-significant part of X.
932    MODE specifies how big a part of X to return;
933    it usually should not be larger than a word.
934    If X is a MEM whose address is a QUEUED, the value may be so also.  */
935
936 rtx
937 gen_lowpart (mode, x)
938      enum machine_mode mode;
939      register rtx x;
940 {
941   rtx result = gen_lowpart_common (mode, x);
942
943   if (result)
944     return result;
945   else if (GET_CODE (x) == REG)
946     {
947       /* Must be a hard reg that's not valid in MODE.  */
948       result = gen_lowpart_common (mode, copy_to_reg (x));
949       if (result == 0)
950         abort ();
951       return result;
952     }
953   else if (GET_CODE (x) == MEM)
954     {
955       /* The only additional case we can do is MEM.  */
956       register int offset = 0;
957       if (WORDS_BIG_ENDIAN)
958         offset = (MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD)
959                   - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD));
960
961       if (BYTES_BIG_ENDIAN)
962         /* Adjust the address so that the address-after-the-data
963            is unchanged.  */
964         offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode))
965                    - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x))));
966
967       return change_address (x, mode, plus_constant (XEXP (x, 0), offset));
968     }
969   else if (GET_CODE (x) == ADDRESSOF)
970     return gen_lowpart (mode, force_reg (GET_MODE (x), x));
971   else
972     abort ();
973 }
974
975 /* Like `gen_lowpart', but refer to the most significant part. 
976    This is used to access the imaginary part of a complex number.  */
977
978 rtx
979 gen_highpart (mode, x)
980      enum machine_mode mode;
981      register rtx x;
982 {
983   /* This case loses if X is a subreg.  To catch bugs early,
984      complain if an invalid MODE is used even in other cases.  */
985   if (GET_MODE_SIZE (mode) > UNITS_PER_WORD
986       && GET_MODE_SIZE (mode) != GET_MODE_UNIT_SIZE (GET_MODE (x)))
987     abort ();
988   if (GET_CODE (x) == CONST_DOUBLE
989 #if !(TARGET_FLOAT_FORMAT != HOST_FLOAT_FORMAT || defined (REAL_IS_NOT_DOUBLE))
990       && GET_MODE_CLASS (GET_MODE (x)) != MODE_FLOAT
991 #endif
992       )
993     return GEN_INT (CONST_DOUBLE_HIGH (x) & GET_MODE_MASK (mode));
994   else if (GET_CODE (x) == CONST_INT)
995     {
996       if (HOST_BITS_PER_WIDE_INT <= BITS_PER_WORD)
997         return const0_rtx;
998       return GEN_INT (INTVAL (x) >> (HOST_BITS_PER_WIDE_INT - BITS_PER_WORD));
999     }
1000   else if (GET_CODE (x) == MEM)
1001     {
1002       register int offset = 0;
1003       if (! WORDS_BIG_ENDIAN)
1004         offset = (MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD)
1005                   - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD));
1006
1007       if (! BYTES_BIG_ENDIAN
1008           && GET_MODE_SIZE (mode) < UNITS_PER_WORD)
1009         offset -= (GET_MODE_SIZE (mode)
1010                    - MIN (UNITS_PER_WORD,
1011                           GET_MODE_SIZE (GET_MODE (x))));
1012
1013       return change_address (x, mode, plus_constant (XEXP (x, 0), offset));
1014     }
1015   else if (GET_CODE (x) == SUBREG)
1016     {
1017       /* The only time this should occur is when we are looking at a
1018          multi-word item with a SUBREG whose mode is the same as that of the
1019          item.  It isn't clear what we would do if it wasn't.  */
1020       if (SUBREG_WORD (x) != 0)
1021         abort ();
1022       return gen_highpart (mode, SUBREG_REG (x));
1023     }
1024   else if (GET_CODE (x) == REG)
1025     {
1026       int word;
1027
1028       /* Let the backend decide how many registers to skip.  This is needed
1029          in particular for sparc64 where fp regs are smaller than a word.  */
1030       /* ??? Note that subregs are now ambiguous, in that those against
1031          pseudos are sized by the word size, while those against hard
1032          regs are sized by the underlying register size.  Better would be
1033          to always interpret the subreg offset parameter as bytes or bits.  */
1034
1035       if (WORDS_BIG_ENDIAN)
1036         word = 0;
1037       else if (REGNO (x) < FIRST_PSEUDO_REGISTER)
1038         word = (HARD_REGNO_NREGS (REGNO (x), GET_MODE (x))
1039                 - HARD_REGNO_NREGS (REGNO (x), mode));
1040       else
1041         word = ((GET_MODE_SIZE (GET_MODE (x))
1042                  - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD))
1043                 / UNITS_PER_WORD);
1044
1045       if (REGNO (x) < FIRST_PSEUDO_REGISTER
1046           /* integrate.c can't handle parts of a return value register.  */
1047           && (! REG_FUNCTION_VALUE_P (x)
1048               || ! rtx_equal_function_value_matters)
1049           /* We want to keep the stack, frame, and arg pointers special.  */
1050           && x != frame_pointer_rtx
1051 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
1052           && x != arg_pointer_rtx
1053 #endif
1054           && x != stack_pointer_rtx)
1055         return gen_rtx_REG (mode, REGNO (x) + word);
1056       else
1057         return gen_rtx_SUBREG (mode, x, word);
1058     }
1059   else
1060     abort ();
1061 }
1062
1063 /* Return 1 iff X, assumed to be a SUBREG,
1064    refers to the least significant part of its containing reg.
1065    If X is not a SUBREG, always return 1 (it is its own low part!).  */
1066
1067 int
1068 subreg_lowpart_p (x)
1069      rtx x;
1070 {
1071   if (GET_CODE (x) != SUBREG)
1072     return 1;
1073   else if (GET_MODE (SUBREG_REG (x)) == VOIDmode)
1074     return 0;
1075
1076   if (WORDS_BIG_ENDIAN
1077       && GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))) > UNITS_PER_WORD)
1078     return (SUBREG_WORD (x)
1079             == ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)))
1080                  - MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD))
1081                 / UNITS_PER_WORD));
1082
1083   return SUBREG_WORD (x) == 0;
1084 }
1085 \f
1086 /* Return subword I of operand OP.
1087    The word number, I, is interpreted as the word number starting at the
1088    low-order address.  Word 0 is the low-order word if not WORDS_BIG_ENDIAN,
1089    otherwise it is the high-order word.
1090
1091    If we cannot extract the required word, we return zero.  Otherwise, an
1092    rtx corresponding to the requested word will be returned.
1093
1094    VALIDATE_ADDRESS is nonzero if the address should be validated.  Before
1095    reload has completed, a valid address will always be returned.  After
1096    reload, if a valid address cannot be returned, we return zero.
1097
1098    If VALIDATE_ADDRESS is zero, we simply form the required address; validating
1099    it is the responsibility of the caller.
1100
1101    MODE is the mode of OP in case it is a CONST_INT.  */
1102
1103 rtx
1104 operand_subword (op, i, validate_address, mode)
1105      rtx op;
1106      int i;
1107      int validate_address;
1108      enum machine_mode mode;
1109 {
1110   HOST_WIDE_INT val;
1111   int size_ratio = HOST_BITS_PER_WIDE_INT / BITS_PER_WORD;
1112
1113   if (mode == VOIDmode)
1114     mode = GET_MODE (op);
1115
1116   if (mode == VOIDmode)
1117     abort ();
1118
1119   /* If OP is narrower than a word, fail. */
1120   if (mode != BLKmode
1121       && (GET_MODE_SIZE (mode) < UNITS_PER_WORD))
1122     return 0;
1123
1124   /* If we want a word outside OP, return zero. */
1125   if (mode != BLKmode
1126       && (i + 1) * UNITS_PER_WORD > GET_MODE_SIZE (mode))
1127     return const0_rtx;
1128
1129   /* If OP is already an integer word, return it.  */
1130   if (GET_MODE_CLASS (mode) == MODE_INT
1131       && GET_MODE_SIZE (mode) == UNITS_PER_WORD)
1132     return op;
1133
1134   /* If OP is a REG or SUBREG, we can handle it very simply.  */
1135   if (GET_CODE (op) == REG)
1136     {
1137       /* ??? There is a potential problem with this code.  It does not
1138          properly handle extractions of a subword from a hard register
1139          that is larger than word_mode.  Presumably the check for
1140          HARD_REGNO_MODE_OK catches these most of these cases.  */
1141
1142       /* If OP is a hard register, but OP + I is not a hard register,
1143          then extracting a subword is impossible.
1144
1145          For example, consider if OP is the last hard register and it is
1146          larger than word_mode.  If we wanted word N (for N > 0) because a
1147          part of that hard register was known to contain a useful value,
1148          then OP + I would refer to a pseudo, not the hard register we
1149          actually wanted.  */
1150       if (REGNO (op) < FIRST_PSEUDO_REGISTER
1151           && REGNO (op) + i >= FIRST_PSEUDO_REGISTER)
1152         return 0;
1153
1154       /* If the register is not valid for MODE, return 0.  Note we
1155          have to check both OP and OP + I since they may refer to
1156          different parts of the register file.
1157
1158          Consider if OP refers to the last 96bit FP register and we want
1159          subword 3 because that subword is known to contain a value we
1160          needed.  */
1161       if (REGNO (op) < FIRST_PSEUDO_REGISTER
1162           && (! HARD_REGNO_MODE_OK (REGNO (op), word_mode)
1163               || ! HARD_REGNO_MODE_OK (REGNO (op) + i, word_mode)))
1164         return 0;
1165       else if (REGNO (op) >= FIRST_PSEUDO_REGISTER
1166                || (REG_FUNCTION_VALUE_P (op)
1167                    && rtx_equal_function_value_matters)
1168                /* We want to keep the stack, frame, and arg pointers
1169                   special.  */
1170                || op == frame_pointer_rtx
1171 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
1172                || op == arg_pointer_rtx
1173 #endif
1174                || op == stack_pointer_rtx)
1175         return gen_rtx_SUBREG (word_mode, op, i);
1176       else
1177         return gen_rtx_REG (word_mode, REGNO (op) + i);
1178     }
1179   else if (GET_CODE (op) == SUBREG)
1180     return gen_rtx_SUBREG (word_mode, SUBREG_REG (op), i + SUBREG_WORD (op));
1181   else if (GET_CODE (op) == CONCAT)
1182     {
1183       int partwords = GET_MODE_UNIT_SIZE (GET_MODE (op)) / UNITS_PER_WORD;
1184       if (i < partwords)
1185         return operand_subword (XEXP (op, 0), i, validate_address, mode);
1186       return operand_subword (XEXP (op, 1), i - partwords,
1187                               validate_address, mode);
1188     }
1189
1190   /* Form a new MEM at the requested address.  */
1191   if (GET_CODE (op) == MEM)
1192     {
1193       rtx addr = plus_constant (XEXP (op, 0), i * UNITS_PER_WORD);
1194       rtx new;
1195
1196       if (validate_address)
1197         {
1198           if (reload_completed)
1199             {
1200               if (! strict_memory_address_p (word_mode, addr))
1201                 return 0;
1202             }
1203           else
1204             addr = memory_address (word_mode, addr);
1205         }
1206
1207       new = gen_rtx_MEM (word_mode, addr);
1208
1209       MEM_COPY_ATTRIBUTES (new, op);
1210       RTX_UNCHANGING_P (new) = RTX_UNCHANGING_P (op);
1211       MEM_ALIAS_SET (new) = MEM_ALIAS_SET (op);
1212
1213       return new;
1214     }
1215
1216   /* The only remaining cases are when OP is a constant.  If the host and
1217      target floating formats are the same, handling two-word floating
1218      constants are easy.  Note that REAL_VALUE_TO_TARGET_{SINGLE,DOUBLE}
1219      are defined as returning one or two 32 bit values, respectively,
1220      and not values of BITS_PER_WORD bits.  */
1221 #ifdef REAL_ARITHMETIC
1222   /* The output is some bits, the width of the target machine's word.
1223      A wider-word host can surely hold them in a CONST_INT. A narrower-word
1224      host can't.  */
1225   if (HOST_BITS_PER_WIDE_INT >= BITS_PER_WORD
1226       && GET_MODE_CLASS (mode) == MODE_FLOAT
1227       && GET_MODE_BITSIZE (mode) == 64
1228       && GET_CODE (op) == CONST_DOUBLE)
1229     {
1230       long k[2];
1231       REAL_VALUE_TYPE rv;
1232
1233       REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
1234       REAL_VALUE_TO_TARGET_DOUBLE (rv, k);
1235
1236       /* We handle 32-bit and >= 64-bit words here.  Note that the order in
1237          which the words are written depends on the word endianness.
1238          ??? This is a potential portability problem and should
1239          be fixed at some point.
1240
1241          We must excercise caution with the sign bit.  By definition there
1242          are 32 significant bits in K; there may be more in a HOST_WIDE_INT.
1243          Consider a host with a 32-bit long and a 64-bit HOST_WIDE_INT.
1244          So we explicitly mask and sign-extend as necessary.  */
1245       if (BITS_PER_WORD == 32)
1246         {
1247           val = k[i];
1248           val = ((val & 0xffffffff) ^ 0x80000000) - 0x80000000;
1249           return GEN_INT (val);
1250         }
1251 #if HOST_BITS_PER_WIDE_INT >= 64
1252       else if (BITS_PER_WORD >= 64 && i == 0)
1253         {
1254           val = k[! WORDS_BIG_ENDIAN];
1255           val = (((val & 0xffffffff) ^ 0x80000000) - 0x80000000) << 32;
1256           val |= (HOST_WIDE_INT) k[WORDS_BIG_ENDIAN] & 0xffffffff;
1257           return GEN_INT (val);
1258         }
1259 #endif
1260       else if (BITS_PER_WORD == 16)
1261         {
1262           val = k[i >> 1];
1263           if ((i & 1) == !WORDS_BIG_ENDIAN)
1264             val >>= 16;
1265           val &= 0xffff;
1266           return GEN_INT (val);
1267         }
1268       else
1269         abort ();
1270     }
1271   else if (HOST_BITS_PER_WIDE_INT >= BITS_PER_WORD
1272            && GET_MODE_CLASS (mode) == MODE_FLOAT
1273            && GET_MODE_BITSIZE (mode) > 64
1274            && GET_CODE (op) == CONST_DOUBLE)
1275     {
1276       long k[4];
1277       REAL_VALUE_TYPE rv;
1278
1279       REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
1280       REAL_VALUE_TO_TARGET_LONG_DOUBLE (rv, k);
1281
1282       if (BITS_PER_WORD == 32)
1283         {
1284           val = k[i];
1285           val = ((val & 0xffffffff) ^ 0x80000000) - 0x80000000;
1286           return GEN_INT (val);
1287         }
1288 #if HOST_BITS_PER_WIDE_INT >= 64
1289       else if (BITS_PER_WORD >= 64 && i <= 1)
1290         {
1291           val = k[i*2 + ! WORDS_BIG_ENDIAN];
1292           val = (((val & 0xffffffff) ^ 0x80000000) - 0x80000000) << 32;
1293           val |= (HOST_WIDE_INT) k[i*2 + WORDS_BIG_ENDIAN] & 0xffffffff;
1294           return GEN_INT (val);
1295         }
1296 #endif
1297       else
1298         abort ();
1299     }
1300 #else /* no REAL_ARITHMETIC */
1301   if (((HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
1302         && HOST_BITS_PER_WIDE_INT == BITS_PER_WORD)
1303        || flag_pretend_float)
1304       && GET_MODE_CLASS (mode) == MODE_FLOAT
1305       && GET_MODE_SIZE (mode) == 2 * UNITS_PER_WORD
1306       && GET_CODE (op) == CONST_DOUBLE)
1307     {
1308       /* The constant is stored in the host's word-ordering,
1309          but we want to access it in the target's word-ordering.  Some
1310          compilers don't like a conditional inside macro args, so we have two
1311          copies of the return.  */
1312 #ifdef HOST_WORDS_BIG_ENDIAN
1313       return GEN_INT (i == WORDS_BIG_ENDIAN
1314                       ? CONST_DOUBLE_HIGH (op) : CONST_DOUBLE_LOW (op));
1315 #else
1316       return GEN_INT (i != WORDS_BIG_ENDIAN
1317                       ? CONST_DOUBLE_HIGH (op) : CONST_DOUBLE_LOW (op));
1318 #endif
1319     }
1320 #endif /* no REAL_ARITHMETIC */
1321
1322   /* Single word float is a little harder, since single- and double-word
1323      values often do not have the same high-order bits.  We have already
1324      verified that we want the only defined word of the single-word value.  */
1325 #ifdef REAL_ARITHMETIC
1326   if (GET_MODE_CLASS (mode) == MODE_FLOAT
1327       && GET_MODE_BITSIZE (mode) == 32
1328       && GET_CODE (op) == CONST_DOUBLE)
1329     {
1330       long l;
1331       REAL_VALUE_TYPE rv;
1332
1333       REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
1334       REAL_VALUE_TO_TARGET_SINGLE (rv, l);
1335
1336       /* Sign extend from known 32-bit value to HOST_WIDE_INT.  */
1337       val = l;
1338       val = ((val & 0xffffffff) ^ 0x80000000) - 0x80000000;
1339
1340       if (BITS_PER_WORD == 16)
1341         {
1342           if ((i & 1) == !WORDS_BIG_ENDIAN)
1343             val >>= 16;
1344           val &= 0xffff;
1345         }
1346
1347       return GEN_INT (val);
1348     }
1349 #else
1350   if (((HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
1351         && HOST_BITS_PER_WIDE_INT == BITS_PER_WORD)
1352        || flag_pretend_float)
1353       && sizeof (float) * 8 == HOST_BITS_PER_WIDE_INT
1354       && GET_MODE_CLASS (mode) == MODE_FLOAT
1355       && GET_MODE_SIZE (mode) == UNITS_PER_WORD
1356       && GET_CODE (op) == CONST_DOUBLE)
1357     {
1358       double d;
1359       union {float f; HOST_WIDE_INT i; } u;
1360
1361       REAL_VALUE_FROM_CONST_DOUBLE (d, op);
1362
1363       u.f = d;
1364       return GEN_INT (u.i);
1365     }
1366   if (((HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
1367         && HOST_BITS_PER_WIDE_INT == BITS_PER_WORD)
1368        || flag_pretend_float)
1369       && sizeof (double) * 8 == HOST_BITS_PER_WIDE_INT
1370       && GET_MODE_CLASS (mode) == MODE_FLOAT
1371       && GET_MODE_SIZE (mode) == UNITS_PER_WORD
1372       && GET_CODE (op) == CONST_DOUBLE)
1373     {
1374       double d;
1375       union {double d; HOST_WIDE_INT i; } u;
1376
1377       REAL_VALUE_FROM_CONST_DOUBLE (d, op);
1378
1379       u.d = d;
1380       return GEN_INT (u.i);
1381     }
1382 #endif /* no REAL_ARITHMETIC */
1383       
1384   /* The only remaining cases that we can handle are integers.
1385      Convert to proper endianness now since these cases need it.
1386      At this point, i == 0 means the low-order word.  
1387
1388      We do not want to handle the case when BITS_PER_WORD <= HOST_BITS_PER_INT
1389      in general.  However, if OP is (const_int 0), we can just return
1390      it for any word.  */
1391
1392   if (op == const0_rtx)
1393     return op;
1394
1395   if (GET_MODE_CLASS (mode) != MODE_INT
1396       || (GET_CODE (op) != CONST_INT && GET_CODE (op) != CONST_DOUBLE)
1397       || BITS_PER_WORD > HOST_BITS_PER_WIDE_INT)
1398     return 0;
1399
1400   if (WORDS_BIG_ENDIAN)
1401     i = GET_MODE_SIZE (mode) / UNITS_PER_WORD - 1 - i;
1402
1403   /* Find out which word on the host machine this value is in and get
1404      it from the constant.  */
1405   val = (i / size_ratio == 0
1406          ? (GET_CODE (op) == CONST_INT ? INTVAL (op) : CONST_DOUBLE_LOW (op))
1407          : (GET_CODE (op) == CONST_INT
1408             ? (INTVAL (op) < 0 ? ~0 : 0) : CONST_DOUBLE_HIGH (op)));
1409
1410   /* Get the value we want into the low bits of val.  */
1411   if (BITS_PER_WORD < HOST_BITS_PER_WIDE_INT)
1412     val = ((val >> ((i % size_ratio) * BITS_PER_WORD)));
1413
1414   val = trunc_int_for_mode (val, word_mode);
1415
1416   return GEN_INT (val);
1417 }
1418
1419 /* Similar to `operand_subword', but never return 0.  If we can't extract
1420    the required subword, put OP into a register and try again.  If that fails,
1421    abort.  We always validate the address in this case.  It is not valid
1422    to call this function after reload; it is mostly meant for RTL
1423    generation. 
1424
1425    MODE is the mode of OP, in case it is CONST_INT.  */
1426
1427 rtx
1428 operand_subword_force (op, i, mode)
1429      rtx op;
1430      int i;
1431      enum machine_mode mode;
1432 {
1433   rtx result = operand_subword (op, i, 1, mode);
1434
1435   if (result)
1436     return result;
1437
1438   if (mode != BLKmode && mode != VOIDmode)
1439     {
1440       /* If this is a register which can not be accessed by words, copy it
1441          to a pseudo register.  */
1442       if (GET_CODE (op) == REG)
1443         op = copy_to_reg (op);
1444       else
1445         op = force_reg (mode, op);
1446     }
1447
1448   result = operand_subword (op, i, 1, mode);
1449   if (result == 0)
1450     abort ();
1451
1452   return result;
1453 }
1454 \f
1455 /* Given a compare instruction, swap the operands.
1456    A test instruction is changed into a compare of 0 against the operand.  */
1457
1458 void
1459 reverse_comparison (insn)
1460      rtx insn;
1461 {
1462   rtx body = PATTERN (insn);
1463   rtx comp;
1464
1465   if (GET_CODE (body) == SET)
1466     comp = SET_SRC (body);
1467   else
1468     comp = SET_SRC (XVECEXP (body, 0, 0));
1469
1470   if (GET_CODE (comp) == COMPARE)
1471     {
1472       rtx op0 = XEXP (comp, 0);
1473       rtx op1 = XEXP (comp, 1);
1474       XEXP (comp, 0) = op1;
1475       XEXP (comp, 1) = op0;
1476     }
1477   else
1478     {
1479       rtx new = gen_rtx_COMPARE (VOIDmode,
1480                                  CONST0_RTX (GET_MODE (comp)), comp);
1481       if (GET_CODE (body) == SET)
1482         SET_SRC (body) = new;
1483       else
1484         SET_SRC (XVECEXP (body, 0, 0)) = new;
1485     }
1486 }
1487 \f
1488 /* Return a memory reference like MEMREF, but with its mode changed
1489    to MODE and its address changed to ADDR.
1490    (VOIDmode means don't change the mode.
1491    NULL for ADDR means don't change the address.)  */
1492
1493 rtx
1494 change_address (memref, mode, addr)
1495      rtx memref;
1496      enum machine_mode mode;
1497      rtx addr;
1498 {
1499   rtx new;
1500
1501   if (GET_CODE (memref) != MEM)
1502     abort ();
1503   if (mode == VOIDmode)
1504     mode = GET_MODE (memref);
1505   if (addr == 0)
1506     addr = XEXP (memref, 0);
1507
1508   /* If reload is in progress or has completed, ADDR must be valid.
1509      Otherwise, we can call memory_address to make it valid.  */
1510   if (reload_completed || reload_in_progress)
1511     {
1512       if (! memory_address_p (mode, addr))
1513         abort ();
1514     }
1515   else
1516     addr = memory_address (mode, addr);
1517         
1518   if (rtx_equal_p (addr, XEXP (memref, 0)) && mode == GET_MODE (memref))
1519     return memref;
1520
1521   new = gen_rtx_MEM (mode, addr);
1522   RTX_UNCHANGING_P (new) = RTX_UNCHANGING_P (memref);
1523   MEM_COPY_ATTRIBUTES (new, memref);
1524   MEM_ALIAS_SET (new) = MEM_ALIAS_SET (memref);
1525   return new;
1526 }
1527 \f
1528 /* Return a newly created CODE_LABEL rtx with a unique label number.  */
1529
1530 rtx
1531 gen_label_rtx ()
1532 {
1533   register rtx label;
1534
1535   label = gen_rtx_CODE_LABEL (VOIDmode, 0, NULL_RTX,
1536                               NULL_RTX, label_num++, NULL_PTR, NULL_PTR);
1537
1538   LABEL_NUSES (label) = 0;
1539   LABEL_ALTERNATE_NAME (label) = NULL;
1540   return label;
1541 }
1542 \f
1543 /* For procedure integration.  */
1544
1545 /* Install new pointers to the first and last insns in the chain.
1546    Also, set cur_insn_uid to one higher than the last in use.
1547    Used for an inline-procedure after copying the insn chain.  */
1548
1549 void
1550 set_new_first_and_last_insn (first, last)
1551      rtx first, last;
1552 {
1553   rtx insn;
1554
1555   first_insn = first;
1556   last_insn = last;
1557   cur_insn_uid = 0;
1558
1559   for (insn = first; insn; insn = NEXT_INSN (insn))
1560     cur_insn_uid = MAX (cur_insn_uid, INSN_UID (insn));
1561
1562   cur_insn_uid++;
1563 }
1564
1565 /* Set the range of label numbers found in the current function.
1566    This is used when belatedly compiling an inline function.  */
1567
1568 void
1569 set_new_first_and_last_label_num (first, last)
1570      int first, last;
1571 {
1572   base_label_num = label_num;
1573   first_label_num = first;
1574   last_label_num = last;
1575 }
1576
1577 /* Set the last label number found in the current function.
1578    This is used when belatedly compiling an inline function.  */
1579
1580 void
1581 set_new_last_label_num (last)
1582      int last;
1583 {
1584   base_label_num = label_num;
1585   last_label_num = last;
1586 }
1587 \f
1588 /* Restore all variables describing the current status from the structure *P.
1589    This is used after a nested function.  */
1590
1591 void
1592 restore_emit_status (p)
1593      struct function *p ATTRIBUTE_UNUSED;
1594 {
1595   last_label_num = 0;
1596   clear_emit_caches ();
1597 }
1598
1599 /* Clear out all parts of the state in F that can safely be discarded
1600    after the function has been compiled, to let garbage collection
1601    reclaim the memory.  */
1602
1603 void
1604 free_emit_status (f)
1605      struct function *f;
1606 {
1607   free (f->emit->x_regno_reg_rtx);
1608   free (f->emit->regno_pointer_flag);
1609   free (f->emit->regno_pointer_align);
1610   free (f->emit);
1611   f->emit = NULL;
1612 }
1613 \f
1614 /* Go through all the RTL insn bodies and copy any invalid shared 
1615    structure.  This routine should only be called once.  */
1616
1617 void
1618 unshare_all_rtl (fndecl, insn)
1619      tree fndecl;
1620      rtx insn;
1621 {
1622   tree decl;
1623
1624   /* Make sure that virtual parameters are not shared.  */
1625   for (decl = DECL_ARGUMENTS (fndecl); decl; decl = TREE_CHAIN (decl))
1626     {
1627       copy_rtx_if_shared (DECL_RTL (decl));
1628     }
1629
1630   /* Unshare just about everything else.  */
1631   unshare_all_rtl_1 (insn);
1632   
1633   /* Make sure the addresses of stack slots found outside the insn chain
1634      (such as, in DECL_RTL of a variable) are not shared
1635      with the insn chain.
1636
1637      This special care is necessary when the stack slot MEM does not
1638      actually appear in the insn chain.  If it does appear, its address
1639      is unshared from all else at that point.  */
1640   copy_rtx_if_shared (stack_slot_list);
1641 }
1642
1643 /* Go through all the RTL insn bodies and copy any invalid shared 
1644    structure, again.  This is a fairly expensive thing to do so it
1645    should be done sparingly.  */
1646
1647 void
1648 unshare_all_rtl_again (insn)
1649      rtx insn;
1650 {
1651   rtx p;
1652   for (p = insn; p; p = NEXT_INSN (p))
1653     if (GET_RTX_CLASS (GET_CODE (p)) == 'i')
1654       {
1655         reset_used_flags (PATTERN (p));
1656         reset_used_flags (REG_NOTES (p));
1657         reset_used_flags (LOG_LINKS (p));
1658       }
1659   unshare_all_rtl_1 (insn);
1660 }
1661
1662 /* Go through all the RTL insn bodies and copy any invalid shared structure.
1663    Assumes the mark bits are cleared at entry.  */
1664
1665 static void
1666 unshare_all_rtl_1 (insn)
1667      rtx insn;
1668 {
1669   for (; insn; insn = NEXT_INSN (insn))
1670     if (GET_RTX_CLASS (GET_CODE (insn)) == 'i')
1671       {
1672         PATTERN (insn) = copy_rtx_if_shared (PATTERN (insn));
1673         REG_NOTES (insn) = copy_rtx_if_shared (REG_NOTES (insn));
1674         LOG_LINKS (insn) = copy_rtx_if_shared (LOG_LINKS (insn));
1675       }
1676 }
1677
1678 /* Mark ORIG as in use, and return a copy of it if it was already in use.
1679    Recursively does the same for subexpressions.  */
1680
1681 rtx
1682 copy_rtx_if_shared (orig)
1683      rtx orig;
1684 {
1685   register rtx x = orig;
1686   register int i;
1687   register enum rtx_code code;
1688   register const char *format_ptr;
1689   int copied = 0;
1690
1691   if (x == 0)
1692     return 0;
1693
1694   code = GET_CODE (x);
1695
1696   /* These types may be freely shared.  */
1697
1698   switch (code)
1699     {
1700     case REG:
1701     case QUEUED:
1702     case CONST_INT:
1703     case CONST_DOUBLE:
1704     case SYMBOL_REF:
1705     case CODE_LABEL:
1706     case PC:
1707     case CC0:
1708     case SCRATCH:
1709       /* SCRATCH must be shared because they represent distinct values.  */
1710       return x;
1711
1712     case CONST:
1713       /* CONST can be shared if it contains a SYMBOL_REF.  If it contains
1714          a LABEL_REF, it isn't sharable.  */
1715       if (GET_CODE (XEXP (x, 0)) == PLUS
1716           && GET_CODE (XEXP (XEXP (x, 0), 0)) == SYMBOL_REF
1717           && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT)
1718         return x;
1719       break;
1720
1721     case INSN:
1722     case JUMP_INSN:
1723     case CALL_INSN:
1724     case NOTE:
1725     case BARRIER:
1726       /* The chain of insns is not being copied.  */
1727       return x;
1728
1729     case MEM:
1730       /* A MEM is allowed to be shared if its address is constant.
1731
1732          We used to allow sharing of MEMs which referenced 
1733          virtual_stack_vars_rtx or virtual_incoming_args_rtx, but
1734          that can lose.  instantiate_virtual_regs will not unshare
1735          the MEMs, and combine may change the structure of the address
1736          because it looks safe and profitable in one context, but
1737          in some other context it creates unrecognizable RTL.  */
1738       if (CONSTANT_ADDRESS_P (XEXP (x, 0)))
1739         return x;
1740
1741       break;
1742
1743     default:
1744       break;
1745     }
1746
1747   /* This rtx may not be shared.  If it has already been seen,
1748      replace it with a copy of itself.  */
1749
1750   if (x->used)
1751     {
1752       register rtx copy;
1753
1754       copy = rtx_alloc (code);
1755       bcopy ((char *) x, (char *) copy,
1756              (sizeof (*copy) - sizeof (copy->fld)
1757               + sizeof (copy->fld[0]) * GET_RTX_LENGTH (code)));
1758       x = copy;
1759       copied = 1;
1760     }
1761   x->used = 1;
1762
1763   /* Now scan the subexpressions recursively.
1764      We can store any replaced subexpressions directly into X
1765      since we know X is not shared!  Any vectors in X
1766      must be copied if X was copied.  */
1767
1768   format_ptr = GET_RTX_FORMAT (code);
1769
1770   for (i = 0; i < GET_RTX_LENGTH (code); i++)
1771     {
1772       switch (*format_ptr++)
1773         {
1774         case 'e':
1775           XEXP (x, i) = copy_rtx_if_shared (XEXP (x, i));
1776           break;
1777
1778         case 'E':
1779           if (XVEC (x, i) != NULL)
1780             {
1781               register int j;
1782               int len = XVECLEN (x, i);
1783
1784               if (copied && len > 0)
1785                 XVEC (x, i) = gen_rtvec_v (len, XVEC (x, i)->elem);
1786               for (j = 0; j < len; j++)
1787                 XVECEXP (x, i, j) = copy_rtx_if_shared (XVECEXP (x, i, j));
1788             }
1789           break;
1790         }
1791     }
1792   return x;
1793 }
1794
1795 /* Clear all the USED bits in X to allow copy_rtx_if_shared to be used
1796    to look for shared sub-parts.  */
1797
1798 void
1799 reset_used_flags (x)
1800      rtx x;
1801 {
1802   register int i, j;
1803   register enum rtx_code code;
1804   register const char *format_ptr;
1805
1806   if (x == 0)
1807     return;
1808
1809   code = GET_CODE (x);
1810
1811   /* These types may be freely shared so we needn't do any resetting
1812      for them.  */
1813
1814   switch (code)
1815     {
1816     case REG:
1817     case QUEUED:
1818     case CONST_INT:
1819     case CONST_DOUBLE:
1820     case SYMBOL_REF:
1821     case CODE_LABEL:
1822     case PC:
1823     case CC0:
1824       return;
1825
1826     case INSN:
1827     case JUMP_INSN:
1828     case CALL_INSN:
1829     case NOTE:
1830     case LABEL_REF:
1831     case BARRIER:
1832       /* The chain of insns is not being copied.  */
1833       return;
1834       
1835     default:
1836       break;
1837     }
1838
1839   x->used = 0;
1840
1841   format_ptr = GET_RTX_FORMAT (code);
1842   for (i = 0; i < GET_RTX_LENGTH (code); i++)
1843     {
1844       switch (*format_ptr++)
1845         {
1846         case 'e':
1847           reset_used_flags (XEXP (x, i));
1848           break;
1849
1850         case 'E':
1851           for (j = 0; j < XVECLEN (x, i); j++)
1852             reset_used_flags (XVECEXP (x, i, j));
1853           break;
1854         }
1855     }
1856 }
1857 \f
1858 /* Copy X if necessary so that it won't be altered by changes in OTHER.
1859    Return X or the rtx for the pseudo reg the value of X was copied into.
1860    OTHER must be valid as a SET_DEST.  */
1861
1862 rtx
1863 make_safe_from (x, other)
1864      rtx x, other;
1865 {
1866   while (1)
1867     switch (GET_CODE (other))
1868       {
1869       case SUBREG:
1870         other = SUBREG_REG (other);
1871         break;
1872       case STRICT_LOW_PART:
1873       case SIGN_EXTEND:
1874       case ZERO_EXTEND:
1875         other = XEXP (other, 0);
1876         break;
1877       default:
1878         goto done;
1879       }
1880  done:
1881   if ((GET_CODE (other) == MEM
1882        && ! CONSTANT_P (x)
1883        && GET_CODE (x) != REG
1884        && GET_CODE (x) != SUBREG)
1885       || (GET_CODE (other) == REG
1886           && (REGNO (other) < FIRST_PSEUDO_REGISTER
1887               || reg_mentioned_p (other, x))))
1888     {
1889       rtx temp = gen_reg_rtx (GET_MODE (x));
1890       emit_move_insn (temp, x);
1891       return temp;
1892     }
1893   return x;
1894 }
1895 \f
1896 /* Emission of insns (adding them to the doubly-linked list).  */
1897
1898 /* Return the first insn of the current sequence or current function.  */
1899
1900 rtx
1901 get_insns ()
1902 {
1903   return first_insn;
1904 }
1905
1906 /* Return the last insn emitted in current sequence or current function.  */
1907
1908 rtx
1909 get_last_insn ()
1910 {
1911   return last_insn;
1912 }
1913
1914 /* Specify a new insn as the last in the chain.  */
1915
1916 void
1917 set_last_insn (insn)
1918      rtx insn;
1919 {
1920   if (NEXT_INSN (insn) != 0)
1921     abort ();
1922   last_insn = insn;
1923 }
1924
1925 /* Return the last insn emitted, even if it is in a sequence now pushed.  */
1926
1927 rtx
1928 get_last_insn_anywhere ()
1929 {
1930   struct sequence_stack *stack;
1931   if (last_insn)
1932     return last_insn;
1933   for (stack = seq_stack; stack; stack = stack->next)
1934     if (stack->last != 0)
1935       return stack->last;
1936   return 0;
1937 }
1938
1939 /* Return a number larger than any instruction's uid in this function.  */
1940
1941 int
1942 get_max_uid ()
1943 {
1944   return cur_insn_uid;
1945 }
1946
1947 /* Renumber instructions so that no instruction UIDs are wasted.  */
1948
1949 void
1950 renumber_insns (stream)
1951      FILE *stream;
1952 {
1953   rtx insn;
1954
1955   /* If we're not supposed to renumber instructions, don't.  */
1956   if (!flag_renumber_insns)
1957     return;
1958
1959   /* If there aren't that many instructions, then it's not really
1960      worth renumbering them.  */
1961   if (flag_renumber_insns == 1 && get_max_uid () < 25000)
1962     return;
1963
1964   cur_insn_uid = 1;
1965
1966   for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
1967     {
1968       if (stream)
1969         fprintf (stream, "Renumbering insn %d to %d\n", 
1970                  INSN_UID (insn), cur_insn_uid);
1971       INSN_UID (insn) = cur_insn_uid++;
1972     }
1973 }
1974 \f
1975 /* Return the next insn.  If it is a SEQUENCE, return the first insn
1976    of the sequence.  */
1977
1978 rtx
1979 next_insn (insn)
1980      rtx insn;
1981 {
1982   if (insn)
1983     {
1984       insn = NEXT_INSN (insn);
1985       if (insn && GET_CODE (insn) == INSN
1986           && GET_CODE (PATTERN (insn)) == SEQUENCE)
1987         insn = XVECEXP (PATTERN (insn), 0, 0);
1988     }
1989
1990   return insn;
1991 }
1992
1993 /* Return the previous insn.  If it is a SEQUENCE, return the last insn
1994    of the sequence.  */
1995
1996 rtx
1997 previous_insn (insn)
1998      rtx insn;
1999 {
2000   if (insn)
2001     {
2002       insn = PREV_INSN (insn);
2003       if (insn && GET_CODE (insn) == INSN
2004           && GET_CODE (PATTERN (insn)) == SEQUENCE)
2005         insn = XVECEXP (PATTERN (insn), 0, XVECLEN (PATTERN (insn), 0) - 1);
2006     }
2007
2008   return insn;
2009 }
2010
2011 /* Return the next insn after INSN that is not a NOTE.  This routine does not
2012    look inside SEQUENCEs.  */
2013
2014 rtx
2015 next_nonnote_insn (insn)
2016      rtx insn;
2017 {
2018   while (insn)
2019     {
2020       insn = NEXT_INSN (insn);
2021       if (insn == 0 || GET_CODE (insn) != NOTE)
2022         break;
2023     }
2024
2025   return insn;
2026 }
2027
2028 /* Return the previous insn before INSN that is not a NOTE.  This routine does
2029    not look inside SEQUENCEs.  */
2030
2031 rtx
2032 prev_nonnote_insn (insn)
2033      rtx insn;
2034 {
2035   while (insn)
2036     {
2037       insn = PREV_INSN (insn);
2038       if (insn == 0 || GET_CODE (insn) != NOTE)
2039         break;
2040     }
2041
2042   return insn;
2043 }
2044
2045 /* Return the next INSN, CALL_INSN or JUMP_INSN after INSN;
2046    or 0, if there is none.  This routine does not look inside
2047    SEQUENCEs.  */
2048
2049 rtx
2050 next_real_insn (insn)
2051      rtx insn;
2052 {
2053   while (insn)
2054     {
2055       insn = NEXT_INSN (insn);
2056       if (insn == 0 || GET_CODE (insn) == INSN
2057           || GET_CODE (insn) == CALL_INSN || GET_CODE (insn) == JUMP_INSN)
2058         break;
2059     }
2060
2061   return insn;
2062 }
2063
2064 /* Return the last INSN, CALL_INSN or JUMP_INSN before INSN;
2065    or 0, if there is none.  This routine does not look inside
2066    SEQUENCEs.  */
2067
2068 rtx
2069 prev_real_insn (insn)
2070      rtx insn;
2071 {
2072   while (insn)
2073     {
2074       insn = PREV_INSN (insn);
2075       if (insn == 0 || GET_CODE (insn) == INSN || GET_CODE (insn) == CALL_INSN
2076           || GET_CODE (insn) == JUMP_INSN)
2077         break;
2078     }
2079
2080   return insn;
2081 }
2082
2083 /* Find the next insn after INSN that really does something.  This routine
2084    does not look inside SEQUENCEs.  Until reload has completed, this is the
2085    same as next_real_insn.  */
2086
2087 int
2088 active_insn_p (insn)
2089      rtx insn;
2090 {
2091   return (GET_CODE (insn) == CALL_INSN || GET_CODE (insn) == JUMP_INSN
2092           || (GET_CODE (insn) == INSN
2093               && (! reload_completed
2094                   || (GET_CODE (PATTERN (insn)) != USE
2095                       && GET_CODE (PATTERN (insn)) != CLOBBER))));
2096 }
2097
2098 rtx
2099 next_active_insn (insn)
2100      rtx insn;
2101 {
2102   while (insn)
2103     {
2104       insn = NEXT_INSN (insn);
2105       if (insn == 0 || active_insn_p (insn))
2106         break;
2107     }
2108
2109   return insn;
2110 }
2111
2112 /* Find the last insn before INSN that really does something.  This routine
2113    does not look inside SEQUENCEs.  Until reload has completed, this is the
2114    same as prev_real_insn.  */
2115
2116 rtx
2117 prev_active_insn (insn)
2118      rtx insn;
2119 {
2120   while (insn)
2121     {
2122       insn = PREV_INSN (insn);
2123       if (insn == 0 || active_insn_p (insn))
2124         break;
2125     }
2126
2127   return insn;
2128 }
2129
2130 /* Return the next CODE_LABEL after the insn INSN, or 0 if there is none.  */
2131
2132 rtx
2133 next_label (insn)
2134      rtx insn;
2135 {
2136   while (insn)
2137     {
2138       insn = NEXT_INSN (insn);
2139       if (insn == 0 || GET_CODE (insn) == CODE_LABEL)
2140         break;
2141     }
2142
2143   return insn;
2144 }
2145
2146 /* Return the last CODE_LABEL before the insn INSN, or 0 if there is none.  */
2147
2148 rtx
2149 prev_label (insn)
2150      rtx insn;
2151 {
2152   while (insn)
2153     {
2154       insn = PREV_INSN (insn);
2155       if (insn == 0 || GET_CODE (insn) == CODE_LABEL)
2156         break;
2157     }
2158
2159   return insn;
2160 }
2161 \f
2162 #ifdef HAVE_cc0
2163 /* INSN uses CC0 and is being moved into a delay slot.  Set up REG_CC_SETTER
2164    and REG_CC_USER notes so we can find it.  */
2165
2166 void
2167 link_cc0_insns (insn)
2168      rtx insn;
2169 {
2170   rtx user = next_nonnote_insn (insn);
2171
2172   if (GET_CODE (user) == INSN && GET_CODE (PATTERN (user)) == SEQUENCE)
2173     user = XVECEXP (PATTERN (user), 0, 0);
2174
2175   REG_NOTES (user) = gen_rtx_INSN_LIST (REG_CC_SETTER, insn,
2176                                         REG_NOTES (user));
2177   REG_NOTES (insn) = gen_rtx_INSN_LIST (REG_CC_USER, user, REG_NOTES (insn));
2178 }
2179
2180 /* Return the next insn that uses CC0 after INSN, which is assumed to
2181    set it.  This is the inverse of prev_cc0_setter (i.e., prev_cc0_setter
2182    applied to the result of this function should yield INSN).
2183
2184    Normally, this is simply the next insn.  However, if a REG_CC_USER note
2185    is present, it contains the insn that uses CC0.
2186
2187    Return 0 if we can't find the insn.  */
2188
2189 rtx
2190 next_cc0_user (insn)
2191      rtx insn;
2192 {
2193   rtx note = find_reg_note (insn, REG_CC_USER, NULL_RTX);
2194
2195   if (note)
2196     return XEXP (note, 0);
2197
2198   insn = next_nonnote_insn (insn);
2199   if (insn && GET_CODE (insn) == INSN && GET_CODE (PATTERN (insn)) == SEQUENCE)
2200     insn = XVECEXP (PATTERN (insn), 0, 0);
2201
2202   if (insn && GET_RTX_CLASS (GET_CODE (insn)) == 'i'
2203       && reg_mentioned_p (cc0_rtx, PATTERN (insn)))
2204     return insn;
2205
2206   return 0;
2207 }
2208
2209 /* Find the insn that set CC0 for INSN.  Unless INSN has a REG_CC_SETTER
2210    note, it is the previous insn.  */
2211
2212 rtx
2213 prev_cc0_setter (insn)
2214      rtx insn;
2215 {
2216   rtx note = find_reg_note (insn, REG_CC_SETTER, NULL_RTX);
2217
2218   if (note)
2219     return XEXP (note, 0);
2220
2221   insn = prev_nonnote_insn (insn);
2222   if (! sets_cc0_p (PATTERN (insn)))
2223     abort ();
2224
2225   return insn;
2226 }
2227 #endif
2228 \f
2229 /* Try splitting insns that can be split for better scheduling.
2230    PAT is the pattern which might split.
2231    TRIAL is the insn providing PAT.
2232    LAST is non-zero if we should return the last insn of the sequence produced.
2233
2234    If this routine succeeds in splitting, it returns the first or last
2235    replacement insn depending on the value of LAST.  Otherwise, it
2236    returns TRIAL.  If the insn to be returned can be split, it will be.  */
2237
2238 rtx
2239 try_split (pat, trial, last)
2240      rtx pat, trial;
2241      int last;
2242 {
2243   rtx before = PREV_INSN (trial);
2244   rtx after = NEXT_INSN (trial);
2245   rtx seq = split_insns (pat, trial);
2246   int has_barrier = 0;
2247   rtx tem;
2248
2249   /* If we are splitting a JUMP_INSN, it might be followed by a BARRIER.
2250      We may need to handle this specially.  */
2251   if (after && GET_CODE (after) == BARRIER)
2252     {
2253       has_barrier = 1;
2254       after = NEXT_INSN (after);
2255     }
2256
2257   if (seq)
2258     {
2259       /* SEQ can either be a SEQUENCE or the pattern of a single insn.
2260          The latter case will normally arise only when being done so that
2261          it, in turn, will be split (SFmode on the 29k is an example).  */
2262       if (GET_CODE (seq) == SEQUENCE)
2263         {
2264           /* If we are splitting a JUMP_INSN, look for the JUMP_INSN in
2265              SEQ and copy our JUMP_LABEL to it.  If JUMP_LABEL is non-zero,
2266              increment the usage count so we don't delete the label.  */
2267           int i;
2268
2269           if (GET_CODE (trial) == JUMP_INSN)
2270             for (i = XVECLEN (seq, 0) - 1; i >= 0; i--)
2271               if (GET_CODE (XVECEXP (seq, 0, i)) == JUMP_INSN)
2272                 {
2273                   JUMP_LABEL (XVECEXP (seq, 0, i)) = JUMP_LABEL (trial);
2274
2275                   if (JUMP_LABEL (trial))
2276                     LABEL_NUSES (JUMP_LABEL (trial))++;
2277                 }
2278
2279           tem = emit_insn_after (seq, before);
2280
2281           delete_insn (trial);
2282           if (has_barrier)
2283             emit_barrier_after (tem);
2284
2285           /* Recursively call try_split for each new insn created; by the
2286              time control returns here that insn will be fully split, so
2287              set LAST and continue from the insn after the one returned.
2288              We can't use next_active_insn here since AFTER may be a note.
2289              Ignore deleted insns, which can be occur if not optimizing.  */
2290           for (tem = NEXT_INSN (before); tem != after;
2291                tem = NEXT_INSN (tem))
2292             if (! INSN_DELETED_P (tem)
2293                 && GET_RTX_CLASS (GET_CODE (tem)) == 'i')
2294               tem = try_split (PATTERN (tem), tem, 1);
2295         }
2296       /* Avoid infinite loop if the result matches the original pattern.  */
2297       else if (rtx_equal_p (seq, pat))
2298         return trial;
2299       else
2300         {
2301           PATTERN (trial) = seq;
2302           INSN_CODE (trial) = -1;
2303           try_split (seq, trial, last);
2304         }
2305
2306       /* Return either the first or the last insn, depending on which was
2307          requested.  */
2308       return last 
2309                 ? (after ? prev_active_insn (after) : last_insn) 
2310                 : next_active_insn (before);
2311     }
2312
2313   return trial;
2314 }
2315 \f
2316 /* Make and return an INSN rtx, initializing all its slots.
2317    Store PATTERN in the pattern slots.  */
2318
2319 rtx
2320 make_insn_raw (pattern)
2321      rtx pattern;
2322 {
2323   register rtx insn;
2324
2325   /* If in RTL generation phase, see if FREE_INSN can be used.  */
2326   if (!ggc_p && free_insn != 0 && rtx_equal_function_value_matters)
2327     {
2328       insn = free_insn;
2329       free_insn = NEXT_INSN (free_insn);
2330       PUT_CODE (insn, INSN);
2331     }
2332   else
2333     insn = rtx_alloc (INSN);
2334
2335   INSN_UID (insn) = cur_insn_uid++;
2336   PATTERN (insn) = pattern;
2337   INSN_CODE (insn) = -1;
2338   LOG_LINKS (insn) = NULL;
2339   REG_NOTES (insn) = NULL;
2340
2341 #ifdef ENABLE_RTL_CHECKING
2342   if (insn
2343       && GET_RTX_CLASS (GET_CODE (insn)) == 'i'
2344       && (returnjump_p (insn)
2345           || (GET_CODE (insn) == SET
2346               && SET_DEST (insn) == pc_rtx)))
2347     {
2348       warning ("ICE: emit_insn used where emit_jump_insn needed:\n");
2349       debug_rtx (insn);
2350     }
2351 #endif
2352   
2353   return insn;
2354 }
2355
2356 /* Like `make_insn' but make a JUMP_INSN instead of an insn.  */
2357
2358 static rtx
2359 make_jump_insn_raw (pattern)
2360      rtx pattern;
2361 {
2362   register rtx insn;
2363
2364   insn = rtx_alloc (JUMP_INSN);
2365   INSN_UID (insn) = cur_insn_uid++;
2366
2367   PATTERN (insn) = pattern;
2368   INSN_CODE (insn) = -1;
2369   LOG_LINKS (insn) = NULL;
2370   REG_NOTES (insn) = NULL;
2371   JUMP_LABEL (insn) = NULL;
2372
2373   return insn;
2374 }
2375
2376 /* Like `make_insn' but make a CALL_INSN instead of an insn.  */
2377
2378 static rtx
2379 make_call_insn_raw (pattern)
2380      rtx pattern;
2381 {
2382   register rtx insn;
2383
2384   insn = rtx_alloc (CALL_INSN);
2385   INSN_UID (insn) = cur_insn_uid++;
2386
2387   PATTERN (insn) = pattern;
2388   INSN_CODE (insn) = -1;
2389   LOG_LINKS (insn) = NULL;
2390   REG_NOTES (insn) = NULL;
2391   CALL_INSN_FUNCTION_USAGE (insn) = NULL;
2392
2393   return insn;
2394 }
2395 \f
2396 /* Add INSN to the end of the doubly-linked list.
2397    INSN may be an INSN, JUMP_INSN, CALL_INSN, CODE_LABEL, BARRIER or NOTE.  */
2398
2399 void
2400 add_insn (insn)
2401      register rtx insn;
2402 {
2403   PREV_INSN (insn) = last_insn;
2404   NEXT_INSN (insn) = 0;
2405
2406   if (NULL != last_insn)
2407     NEXT_INSN (last_insn) = insn;
2408
2409   if (NULL == first_insn)
2410     first_insn = insn;
2411
2412   last_insn = insn;
2413 }
2414
2415 /* Add INSN into the doubly-linked list after insn AFTER.  This and
2416    the next should be the only functions called to insert an insn once
2417    delay slots have been filled since only they know how to update a
2418    SEQUENCE.  */
2419
2420 void
2421 add_insn_after (insn, after)
2422      rtx insn, after;
2423 {
2424   rtx next = NEXT_INSN (after);
2425
2426   if (optimize && INSN_DELETED_P (after))
2427     abort ();
2428
2429   NEXT_INSN (insn) = next;
2430   PREV_INSN (insn) = after;
2431
2432   if (next)
2433     {
2434       PREV_INSN (next) = insn;
2435       if (GET_CODE (next) == INSN && GET_CODE (PATTERN (next)) == SEQUENCE)
2436         PREV_INSN (XVECEXP (PATTERN (next), 0, 0)) = insn;
2437     }
2438   else if (last_insn == after)
2439     last_insn = insn;
2440   else
2441     {
2442       struct sequence_stack *stack = seq_stack;
2443       /* Scan all pending sequences too.  */
2444       for (; stack; stack = stack->next)
2445         if (after == stack->last)
2446           {
2447             stack->last = insn;
2448             break;
2449           }
2450
2451       if (stack == 0)
2452         abort ();
2453     }
2454
2455   NEXT_INSN (after) = insn;
2456   if (GET_CODE (after) == INSN && GET_CODE (PATTERN (after)) == SEQUENCE)
2457     {
2458       rtx sequence = PATTERN (after);
2459       NEXT_INSN (XVECEXP (sequence, 0, XVECLEN (sequence, 0) - 1)) = insn;
2460     }
2461 }
2462
2463 /* Add INSN into the doubly-linked list before insn BEFORE.  This and
2464    the previous should be the only functions called to insert an insn once
2465    delay slots have been filled since only they know how to update a
2466    SEQUENCE.  */
2467
2468 void
2469 add_insn_before (insn, before)
2470      rtx insn, before;
2471 {
2472   rtx prev = PREV_INSN (before);
2473
2474   if (optimize && INSN_DELETED_P (before))
2475     abort ();
2476
2477   PREV_INSN (insn) = prev;
2478   NEXT_INSN (insn) = before;
2479
2480   if (prev)
2481     {
2482       NEXT_INSN (prev) = insn;
2483       if (GET_CODE (prev) == INSN && GET_CODE (PATTERN (prev)) == SEQUENCE)
2484         {
2485           rtx sequence = PATTERN (prev);
2486           NEXT_INSN (XVECEXP (sequence, 0, XVECLEN (sequence, 0) - 1)) = insn;
2487         }
2488     }
2489   else if (first_insn == before)
2490     first_insn = insn;
2491   else
2492     {
2493       struct sequence_stack *stack = seq_stack;
2494       /* Scan all pending sequences too.  */
2495       for (; stack; stack = stack->next)
2496         if (before == stack->first)
2497           {
2498             stack->first = insn;
2499             break;
2500           }
2501
2502       if (stack == 0)
2503         abort ();
2504     }
2505
2506   PREV_INSN (before) = insn;
2507   if (GET_CODE (before) == INSN && GET_CODE (PATTERN (before)) == SEQUENCE)
2508     PREV_INSN (XVECEXP (PATTERN (before), 0, 0)) = insn;
2509 }
2510
2511 /* Remove an insn from its doubly-linked list.  This function knows how
2512    to handle sequences.  */
2513 void
2514 remove_insn (insn)
2515      rtx insn;
2516 {
2517   rtx next = NEXT_INSN (insn);
2518   rtx prev = PREV_INSN (insn);
2519   if (prev)
2520     {
2521       NEXT_INSN (prev) = next;
2522       if (GET_CODE (prev) == INSN && GET_CODE (PATTERN (prev)) == SEQUENCE)
2523         {
2524           rtx sequence = PATTERN (prev);
2525           NEXT_INSN (XVECEXP (sequence, 0, XVECLEN (sequence, 0) - 1)) = next;
2526         }
2527     }
2528   else if (first_insn == insn)
2529     first_insn = next;
2530   else
2531     {
2532       struct sequence_stack *stack = seq_stack;
2533       /* Scan all pending sequences too.  */
2534       for (; stack; stack = stack->next)
2535         if (insn == stack->first)
2536           {
2537             stack->first = next;
2538             break;
2539           }
2540
2541       if (stack == 0)
2542         abort ();
2543     }
2544
2545   if (next)
2546     {
2547       PREV_INSN (next) = prev;
2548       if (GET_CODE (next) == INSN && GET_CODE (PATTERN (next)) == SEQUENCE)
2549         PREV_INSN (XVECEXP (PATTERN (next), 0, 0)) = prev;
2550     }
2551   else if (last_insn == insn)
2552     last_insn = prev;
2553   else
2554     {
2555       struct sequence_stack *stack = seq_stack;
2556       /* Scan all pending sequences too.  */
2557       for (; stack; stack = stack->next)
2558         if (insn == stack->last)
2559           {
2560             stack->last = prev;
2561             break;
2562           }
2563
2564       if (stack == 0)
2565         abort ();
2566     }
2567 }
2568
2569 /* Delete all insns made since FROM.
2570    FROM becomes the new last instruction.  */
2571
2572 void
2573 delete_insns_since (from)
2574      rtx from;
2575 {
2576   if (from == 0)
2577     first_insn = 0;
2578   else
2579     NEXT_INSN (from) = 0;
2580   last_insn = from;
2581 }
2582
2583 /* This function is deprecated, please use sequences instead.
2584
2585    Move a consecutive bunch of insns to a different place in the chain.
2586    The insns to be moved are those between FROM and TO.
2587    They are moved to a new position after the insn AFTER.
2588    AFTER must not be FROM or TO or any insn in between.
2589
2590    This function does not know about SEQUENCEs and hence should not be
2591    called after delay-slot filling has been done.  */
2592
2593 void
2594 reorder_insns (from, to, after)
2595      rtx from, to, after;
2596 {
2597   /* Splice this bunch out of where it is now.  */
2598   if (PREV_INSN (from))
2599     NEXT_INSN (PREV_INSN (from)) = NEXT_INSN (to);
2600   if (NEXT_INSN (to))
2601     PREV_INSN (NEXT_INSN (to)) = PREV_INSN (from);
2602   if (last_insn == to)
2603     last_insn = PREV_INSN (from);
2604   if (first_insn == from)
2605     first_insn = NEXT_INSN (to);
2606
2607   /* Make the new neighbors point to it and it to them.  */
2608   if (NEXT_INSN (after))
2609     PREV_INSN (NEXT_INSN (after)) = to;
2610
2611   NEXT_INSN (to) = NEXT_INSN (after);
2612   PREV_INSN (from) = after;
2613   NEXT_INSN (after) = from;
2614   if (after == last_insn)
2615     last_insn = to;
2616 }
2617
2618 /* Return the line note insn preceding INSN.  */
2619
2620 static rtx
2621 find_line_note (insn)
2622      rtx insn;
2623 {
2624   if (no_line_numbers)
2625     return 0;
2626
2627   for (; insn; insn = PREV_INSN (insn))
2628     if (GET_CODE (insn) == NOTE
2629         && NOTE_LINE_NUMBER (insn) >= 0)
2630       break;
2631
2632   return insn;
2633 }
2634
2635 /* Like reorder_insns, but inserts line notes to preserve the line numbers
2636    of the moved insns when debugging.  This may insert a note between AFTER
2637    and FROM, and another one after TO.  */
2638
2639 void
2640 reorder_insns_with_line_notes (from, to, after)
2641      rtx from, to, after;
2642 {
2643   rtx from_line = find_line_note (from);
2644   rtx after_line = find_line_note (after);
2645
2646   reorder_insns (from, to, after);
2647
2648   if (from_line == after_line)
2649     return;
2650
2651   if (from_line)
2652     emit_line_note_after (NOTE_SOURCE_FILE (from_line),
2653                           NOTE_LINE_NUMBER (from_line),
2654                           after);
2655   if (after_line)
2656     emit_line_note_after (NOTE_SOURCE_FILE (after_line),
2657                           NOTE_LINE_NUMBER (after_line),
2658                           to);
2659 }
2660
2661 /* Remove unncessary notes from the instruction stream.  */
2662
2663 void
2664 remove_unncessary_notes ()
2665 {
2666   rtx insn;
2667   rtx next;
2668
2669   /* Remove NOTE_INSN_DELETED notes.  We must not remove the first
2670      instruction in the function because the compiler depends on the
2671      first instruction being a note.  */
2672   for (insn = NEXT_INSN (get_insns ()); insn; insn = next)
2673     {
2674       /* Remember what's next.  */
2675       next = NEXT_INSN (insn);
2676
2677       /* We're only interested in notes.  */
2678       if (GET_CODE (insn) != NOTE)
2679         continue;
2680
2681       if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_DELETED)
2682         remove_insn (insn);
2683     }
2684 }
2685
2686 \f
2687 /* Emit an insn of given code and pattern
2688    at a specified place within the doubly-linked list.  */
2689
2690 /* Make an instruction with body PATTERN
2691    and output it before the instruction BEFORE.  */
2692
2693 rtx
2694 emit_insn_before (pattern, before)
2695      register rtx pattern, before;
2696 {
2697   register rtx insn = before;
2698
2699   if (GET_CODE (pattern) == SEQUENCE)
2700     {
2701       register int i;
2702
2703       for (i = 0; i < XVECLEN (pattern, 0); i++)
2704         {
2705           insn = XVECEXP (pattern, 0, i);
2706           add_insn_before (insn, before);
2707         }
2708       if (!ggc_p && XVECLEN (pattern, 0) < SEQUENCE_RESULT_SIZE)
2709         sequence_result[XVECLEN (pattern, 0)] = pattern;
2710     }
2711   else
2712     {
2713       insn = make_insn_raw (pattern);
2714       add_insn_before (insn, before);
2715     }
2716
2717   return insn;
2718 }
2719
2720 /* Similar to emit_insn_before, but update basic block boundaries as well.  */
2721
2722 rtx
2723 emit_block_insn_before (pattern, before, block)
2724      rtx pattern, before;
2725      basic_block block;
2726 {
2727   rtx prev = PREV_INSN (before);
2728   rtx r = emit_insn_before (pattern, before);
2729   if (block && block->head == before)
2730     block->head = NEXT_INSN (prev);
2731   return r;
2732 }
2733
2734 /* Make an instruction with body PATTERN and code JUMP_INSN
2735    and output it before the instruction BEFORE.  */
2736
2737 rtx
2738 emit_jump_insn_before (pattern, before)
2739      register rtx pattern, before;
2740 {
2741   register rtx insn;
2742
2743   if (GET_CODE (pattern) == SEQUENCE)
2744     insn = emit_insn_before (pattern, before);
2745   else
2746     {
2747       insn = make_jump_insn_raw (pattern);
2748       add_insn_before (insn, before);
2749     }
2750
2751   return insn;
2752 }
2753
2754 /* Make an instruction with body PATTERN and code CALL_INSN
2755    and output it before the instruction BEFORE.  */
2756
2757 rtx
2758 emit_call_insn_before (pattern, before)
2759      register rtx pattern, before;
2760 {
2761   register rtx insn;
2762
2763   if (GET_CODE (pattern) == SEQUENCE)
2764     insn = emit_insn_before (pattern, before);
2765   else
2766     {
2767       insn = make_call_insn_raw (pattern);
2768       add_insn_before (insn, before);
2769       PUT_CODE (insn, CALL_INSN);
2770     }
2771
2772   return insn;
2773 }
2774
2775 /* Make an insn of code BARRIER
2776    and output it before the insn BEFORE.  */
2777
2778 rtx
2779 emit_barrier_before (before)
2780      register rtx before;
2781 {
2782   register rtx insn = rtx_alloc (BARRIER);
2783
2784   INSN_UID (insn) = cur_insn_uid++;
2785
2786   add_insn_before (insn, before);
2787   return insn;
2788 }
2789
2790 /* Emit the label LABEL before the insn BEFORE.  */
2791
2792 rtx
2793 emit_label_before (label, before)
2794      rtx label, before;
2795 {
2796   /* This can be called twice for the same label as a result of the
2797      confusion that follows a syntax error!  So make it harmless.  */
2798   if (INSN_UID (label) == 0)
2799     {
2800       INSN_UID (label) = cur_insn_uid++;
2801       add_insn_before (label, before);
2802     }
2803
2804   return label;
2805 }
2806
2807 /* Emit a note of subtype SUBTYPE before the insn BEFORE.  */
2808
2809 rtx
2810 emit_note_before (subtype, before)
2811      int subtype;
2812      rtx before;
2813 {
2814   register rtx note = rtx_alloc (NOTE);
2815   INSN_UID (note) = cur_insn_uid++;
2816   NOTE_SOURCE_FILE (note) = 0;
2817   NOTE_LINE_NUMBER (note) = subtype;
2818
2819   add_insn_before (note, before);
2820   return note;
2821 }
2822 \f
2823 /* Make an insn of code INSN with body PATTERN
2824    and output it after the insn AFTER.  */
2825
2826 rtx
2827 emit_insn_after (pattern, after)
2828      register rtx pattern, after;
2829 {
2830   register rtx insn = after;
2831
2832   if (GET_CODE (pattern) == SEQUENCE)
2833     {
2834       register int i;
2835
2836       for (i = 0; i < XVECLEN (pattern, 0); i++)
2837         {
2838           insn = XVECEXP (pattern, 0, i);
2839           add_insn_after (insn, after);
2840           after = insn;
2841         }
2842       if (!ggc_p && XVECLEN (pattern, 0) < SEQUENCE_RESULT_SIZE)
2843         sequence_result[XVECLEN (pattern, 0)] = pattern;
2844     }
2845   else
2846     {
2847       insn = make_insn_raw (pattern);
2848       add_insn_after (insn, after);
2849     }
2850
2851   return insn;
2852 }
2853
2854 /* Similar to emit_insn_after, except that line notes are to be inserted so
2855    as to act as if this insn were at FROM.  */
2856
2857 void
2858 emit_insn_after_with_line_notes (pattern, after, from)
2859      rtx pattern, after, from;
2860 {
2861   rtx from_line = find_line_note (from);
2862   rtx after_line = find_line_note (after);
2863   rtx insn = emit_insn_after (pattern, after);
2864
2865   if (from_line)
2866     emit_line_note_after (NOTE_SOURCE_FILE (from_line),
2867                           NOTE_LINE_NUMBER (from_line),
2868                           after);
2869
2870   if (after_line)
2871     emit_line_note_after (NOTE_SOURCE_FILE (after_line),
2872                           NOTE_LINE_NUMBER (after_line),
2873                           insn);
2874 }
2875
2876 /* Similar to emit_insn_after, but update basic block boundaries as well.  */
2877
2878 rtx
2879 emit_block_insn_after (pattern, after, block)
2880      rtx pattern, after;
2881      basic_block block;
2882 {
2883   rtx r = emit_insn_after (pattern, after);
2884   if (block && block->end == after)
2885     block->end = r;
2886   return r;
2887 }
2888
2889 /* Make an insn of code JUMP_INSN with body PATTERN
2890    and output it after the insn AFTER.  */
2891
2892 rtx
2893 emit_jump_insn_after (pattern, after)
2894      register rtx pattern, after;
2895 {
2896   register rtx insn;
2897
2898   if (GET_CODE (pattern) == SEQUENCE)
2899     insn = emit_insn_after (pattern, after);
2900   else
2901     {
2902       insn = make_jump_insn_raw (pattern);
2903       add_insn_after (insn, after);
2904     }
2905
2906   return insn;
2907 }
2908
2909 /* Make an insn of code BARRIER
2910    and output it after the insn AFTER.  */
2911
2912 rtx
2913 emit_barrier_after (after)
2914      register rtx after;
2915 {
2916   register rtx insn = rtx_alloc (BARRIER);
2917
2918   INSN_UID (insn) = cur_insn_uid++;
2919
2920   add_insn_after (insn, after);
2921   return insn;
2922 }
2923
2924 /* Emit the label LABEL after the insn AFTER.  */
2925
2926 rtx
2927 emit_label_after (label, after)
2928      rtx label, after;
2929 {
2930   /* This can be called twice for the same label
2931      as a result of the confusion that follows a syntax error!
2932      So make it harmless.  */
2933   if (INSN_UID (label) == 0)
2934     {
2935       INSN_UID (label) = cur_insn_uid++;
2936       add_insn_after (label, after);
2937     }
2938
2939   return label;
2940 }
2941
2942 /* Emit a note of subtype SUBTYPE after the insn AFTER.  */
2943
2944 rtx
2945 emit_note_after (subtype, after)
2946      int subtype;
2947      rtx after;
2948 {
2949   register rtx note = rtx_alloc (NOTE);
2950   INSN_UID (note) = cur_insn_uid++;
2951   NOTE_SOURCE_FILE (note) = 0;
2952   NOTE_LINE_NUMBER (note) = subtype;
2953   add_insn_after (note, after);
2954   return note;
2955 }
2956
2957 /* Emit a line note for FILE and LINE after the insn AFTER.  */
2958
2959 rtx
2960 emit_line_note_after (file, line, after)
2961      char *file;
2962      int line;
2963      rtx after;
2964 {
2965   register rtx note;
2966
2967   if (no_line_numbers && line > 0)
2968     {
2969       cur_insn_uid++;
2970       return 0;
2971     }
2972
2973   note  = rtx_alloc (NOTE);
2974   INSN_UID (note) = cur_insn_uid++;
2975   NOTE_SOURCE_FILE (note) = file;
2976   NOTE_LINE_NUMBER (note) = line;
2977   add_insn_after (note, after);
2978   return note;
2979 }
2980 \f
2981 /* Make an insn of code INSN with pattern PATTERN
2982    and add it to the end of the doubly-linked list.
2983    If PATTERN is a SEQUENCE, take the elements of it
2984    and emit an insn for each element.
2985
2986    Returns the last insn emitted.  */
2987
2988 rtx
2989 emit_insn (pattern)
2990      rtx pattern;
2991 {
2992   rtx insn = last_insn;
2993
2994   if (GET_CODE (pattern) == SEQUENCE)
2995     {
2996       register int i;
2997
2998       for (i = 0; i < XVECLEN (pattern, 0); i++)
2999         {
3000           insn = XVECEXP (pattern, 0, i);
3001           add_insn (insn);
3002         }
3003       if (!ggc_p && XVECLEN (pattern, 0) < SEQUENCE_RESULT_SIZE)
3004         sequence_result[XVECLEN (pattern, 0)] = pattern;
3005     }
3006   else
3007     {
3008       insn = make_insn_raw (pattern);
3009       add_insn (insn);
3010     }
3011
3012   return insn;
3013 }
3014
3015 /* Emit the insns in a chain starting with INSN.
3016    Return the last insn emitted.  */
3017
3018 rtx
3019 emit_insns (insn)
3020      rtx insn;
3021 {
3022   rtx last = 0;
3023
3024   while (insn)
3025     {
3026       rtx next = NEXT_INSN (insn);
3027       add_insn (insn);
3028       last = insn;
3029       insn = next;
3030     }
3031
3032   return last;
3033 }
3034
3035 /* Emit the insns in a chain starting with INSN and place them in front of
3036    the insn BEFORE.  Return the last insn emitted.  */
3037
3038 rtx
3039 emit_insns_before (insn, before)
3040      rtx insn;
3041      rtx before;
3042 {
3043   rtx last = 0;
3044
3045   while (insn)
3046     {
3047       rtx next = NEXT_INSN (insn);
3048       add_insn_before (insn, before);
3049       last = insn;
3050       insn = next;
3051     }
3052
3053   return last;
3054 }
3055
3056 /* Emit the insns in a chain starting with FIRST and place them in back of
3057    the insn AFTER.  Return the last insn emitted.  */
3058
3059 rtx
3060 emit_insns_after (first, after)
3061      register rtx first;
3062      register rtx after;
3063 {
3064   register rtx last;
3065   register rtx after_after;
3066
3067   if (!after)
3068     abort ();
3069
3070   if (!first)
3071     return first;
3072
3073   for (last = first; NEXT_INSN (last); last = NEXT_INSN (last))
3074     continue;
3075
3076   after_after = NEXT_INSN (after);
3077
3078   NEXT_INSN (after) = first;
3079   PREV_INSN (first) = after;
3080   NEXT_INSN (last) = after_after;
3081   if (after_after)
3082     PREV_INSN (after_after) = last;
3083
3084   if (after == last_insn)
3085     last_insn = last;
3086   return last;
3087 }
3088
3089 /* Make an insn of code JUMP_INSN with pattern PATTERN
3090    and add it to the end of the doubly-linked list.  */
3091
3092 rtx
3093 emit_jump_insn (pattern)
3094      rtx pattern;
3095 {
3096   if (GET_CODE (pattern) == SEQUENCE)
3097     return emit_insn (pattern);
3098   else
3099     {
3100       register rtx insn = make_jump_insn_raw (pattern);
3101       add_insn (insn);
3102       return insn;
3103     }
3104 }
3105
3106 /* Make an insn of code CALL_INSN with pattern PATTERN
3107    and add it to the end of the doubly-linked list.  */
3108
3109 rtx
3110 emit_call_insn (pattern)
3111      rtx pattern;
3112 {
3113   if (GET_CODE (pattern) == SEQUENCE)
3114     return emit_insn (pattern);
3115   else
3116     {
3117       register rtx insn = make_call_insn_raw (pattern);
3118       add_insn (insn);
3119       PUT_CODE (insn, CALL_INSN);
3120       return insn;
3121     }
3122 }
3123
3124 /* Add the label LABEL to the end of the doubly-linked list.  */
3125
3126 rtx
3127 emit_label (label)
3128      rtx label;
3129 {
3130   /* This can be called twice for the same label
3131      as a result of the confusion that follows a syntax error!
3132      So make it harmless.  */
3133   if (INSN_UID (label) == 0)
3134     {
3135       INSN_UID (label) = cur_insn_uid++;
3136       add_insn (label);
3137     }
3138   return label;
3139 }
3140
3141 /* Make an insn of code BARRIER
3142    and add it to the end of the doubly-linked list.  */
3143
3144 rtx
3145 emit_barrier ()
3146 {
3147   register rtx barrier = rtx_alloc (BARRIER);
3148   INSN_UID (barrier) = cur_insn_uid++;
3149   add_insn (barrier);
3150   return barrier;
3151 }
3152
3153 /* Make an insn of code NOTE
3154    with data-fields specified by FILE and LINE
3155    and add it to the end of the doubly-linked list,
3156    but only if line-numbers are desired for debugging info.  */
3157
3158 rtx
3159 emit_line_note (file, line)
3160      char *file;
3161      int line;
3162 {
3163   set_file_and_line_for_stmt (file, line);
3164
3165 #if 0
3166   if (no_line_numbers)
3167     return 0;
3168 #endif
3169
3170   return emit_note (file, line);
3171 }
3172
3173 /* Make an insn of code NOTE
3174    with data-fields specified by FILE and LINE
3175    and add it to the end of the doubly-linked list.
3176    If it is a line-number NOTE, omit it if it matches the previous one.  */
3177
3178 rtx
3179 emit_note (file, line)
3180      char *file;
3181      int line;
3182 {
3183   register rtx note;
3184
3185   if (line > 0)
3186     {
3187       if (file && last_filename && !strcmp (file, last_filename)
3188           && line == last_linenum)
3189         return 0;
3190       last_filename = file;
3191       last_linenum = line;
3192     }
3193
3194   if (no_line_numbers && line > 0)
3195     {
3196       cur_insn_uid++;
3197       return 0;
3198     }
3199
3200   note = rtx_alloc (NOTE);
3201   INSN_UID (note) = cur_insn_uid++;
3202   NOTE_SOURCE_FILE (note) = file;
3203   NOTE_LINE_NUMBER (note) = line;
3204   add_insn (note);
3205   return note;
3206 }
3207
3208 /* Emit a NOTE, and don't omit it even if LINE is the previous note.  */
3209
3210 rtx
3211 emit_line_note_force (file, line)
3212      char *file;
3213      int line;
3214 {
3215   last_linenum = -1;
3216   return emit_line_note (file, line);
3217 }
3218
3219 /* Cause next statement to emit a line note even if the line number
3220    has not changed.  This is used at the beginning of a function.  */
3221
3222 void
3223 force_next_line_note ()
3224 {
3225   last_linenum = -1;
3226 }
3227
3228 /* Place a note of KIND on insn INSN with DATUM as the datum. If a
3229    note of this type already exists, remove it first. */
3230
3231 void 
3232 set_unique_reg_note (insn, kind, datum)
3233      rtx insn;
3234      enum reg_note kind;
3235      rtx datum;
3236 {
3237   rtx note = find_reg_note (insn, kind, NULL_RTX);
3238
3239   /* First remove the note if there already is one.  */
3240   if (note) 
3241     remove_note (insn, note);
3242
3243   REG_NOTES (insn) = gen_rtx_EXPR_LIST (kind, datum, REG_NOTES (insn));
3244 }
3245 \f
3246 /* Return an indication of which type of insn should have X as a body.
3247    The value is CODE_LABEL, INSN, CALL_INSN or JUMP_INSN.  */
3248
3249 enum rtx_code
3250 classify_insn (x)
3251      rtx x;
3252 {
3253   if (GET_CODE (x) == CODE_LABEL)
3254     return CODE_LABEL;
3255   if (GET_CODE (x) == CALL)
3256     return CALL_INSN;
3257   if (GET_CODE (x) == RETURN)
3258     return JUMP_INSN;
3259   if (GET_CODE (x) == SET)
3260     {
3261       if (SET_DEST (x) == pc_rtx)
3262         return JUMP_INSN;
3263       else if (GET_CODE (SET_SRC (x)) == CALL)
3264         return CALL_INSN;
3265       else
3266         return INSN;
3267     }
3268   if (GET_CODE (x) == PARALLEL)
3269     {
3270       register int j;
3271       for (j = XVECLEN (x, 0) - 1; j >= 0; j--)
3272         if (GET_CODE (XVECEXP (x, 0, j)) == CALL)
3273           return CALL_INSN;
3274         else if (GET_CODE (XVECEXP (x, 0, j)) == SET
3275                  && SET_DEST (XVECEXP (x, 0, j)) == pc_rtx)
3276           return JUMP_INSN;
3277         else if (GET_CODE (XVECEXP (x, 0, j)) == SET
3278                  && GET_CODE (SET_SRC (XVECEXP (x, 0, j))) == CALL)
3279           return CALL_INSN;
3280     }
3281   return INSN;
3282 }
3283
3284 /* Emit the rtl pattern X as an appropriate kind of insn.
3285    If X is a label, it is simply added into the insn chain.  */
3286
3287 rtx
3288 emit (x)
3289      rtx x;
3290 {
3291   enum rtx_code code = classify_insn (x);
3292
3293   if (code == CODE_LABEL)
3294     return emit_label (x);
3295   else if (code == INSN)
3296     return emit_insn (x);
3297   else if (code == JUMP_INSN)
3298     {
3299       register rtx insn = emit_jump_insn (x);
3300       if (simplejump_p (insn) || GET_CODE (x) == RETURN)
3301         return emit_barrier ();
3302       return insn;
3303     }
3304   else if (code == CALL_INSN)
3305     return emit_call_insn (x);
3306   else
3307     abort ();
3308 }
3309 \f
3310 /* Begin emitting insns to a sequence which can be packaged in an
3311    RTL_EXPR.  If this sequence will contain something that might cause
3312    the compiler to pop arguments to function calls (because those
3313    pops have previously been deferred; see INHIBIT_DEFER_POP for more
3314    details), use do_pending_stack_adjust before calling this function.
3315    That will ensure that the deferred pops are not accidentally
3316    emitted in the middel of this sequence.  */
3317
3318 void
3319 start_sequence ()
3320 {
3321   struct sequence_stack *tem;
3322
3323   tem = (struct sequence_stack *) xmalloc (sizeof (struct sequence_stack));
3324
3325   tem->next = seq_stack;
3326   tem->first = first_insn;
3327   tem->last = last_insn;
3328   tem->sequence_rtl_expr = seq_rtl_expr;
3329
3330   seq_stack = tem;
3331
3332   first_insn = 0;
3333   last_insn = 0;
3334 }
3335
3336 /* Similarly, but indicate that this sequence will be placed in T, an
3337    RTL_EXPR.  See the documentation for start_sequence for more
3338    information about how to use this function.  */
3339
3340 void
3341 start_sequence_for_rtl_expr (t)
3342      tree t;
3343 {
3344   start_sequence ();
3345
3346   seq_rtl_expr = t;
3347 }
3348
3349 /* Set up the insn chain starting with FIRST as the current sequence,
3350    saving the previously current one.  See the documentation for
3351    start_sequence for more information about how to use this function.  */
3352
3353 void
3354 push_to_sequence (first)
3355      rtx first;
3356 {
3357   rtx last;
3358
3359   start_sequence ();
3360
3361   for (last = first; last && NEXT_INSN (last); last = NEXT_INSN (last));
3362
3363   first_insn = first;
3364   last_insn = last;
3365 }
3366
3367 /* Set up the outer-level insn chain
3368    as the current sequence, saving the previously current one.  */
3369
3370 void
3371 push_topmost_sequence ()
3372 {
3373   struct sequence_stack *stack, *top = NULL;
3374
3375   start_sequence ();
3376
3377   for (stack = seq_stack; stack; stack = stack->next)
3378     top = stack;
3379
3380   first_insn = top->first;
3381   last_insn = top->last;
3382   seq_rtl_expr = top->sequence_rtl_expr;
3383 }
3384
3385 /* After emitting to the outer-level insn chain, update the outer-level
3386    insn chain, and restore the previous saved state.  */
3387
3388 void
3389 pop_topmost_sequence ()
3390 {
3391   struct sequence_stack *stack, *top = NULL;
3392
3393   for (stack = seq_stack; stack; stack = stack->next)
3394     top = stack;
3395
3396   top->first = first_insn;
3397   top->last = last_insn;
3398   /* ??? Why don't we save seq_rtl_expr here?  */
3399
3400   end_sequence ();
3401 }
3402
3403 /* After emitting to a sequence, restore previous saved state.
3404
3405    To get the contents of the sequence just made, you must call
3406    `gen_sequence' *before* calling here.  
3407
3408    If the compiler might have deferred popping arguments while
3409    generating this sequence, and this sequence will not be immediately
3410    inserted into the instruction stream, use do_pending_stack_adjust
3411    before calling gen_sequence.  That will ensure that the deferred
3412    pops are inserted into this sequence, and not into some random
3413    location in the instruction stream.  See INHIBIT_DEFER_POP for more
3414    information about deferred popping of arguments.  */
3415
3416 void
3417 end_sequence ()
3418 {
3419   struct sequence_stack *tem = seq_stack;
3420
3421   first_insn = tem->first;
3422   last_insn = tem->last;
3423   seq_rtl_expr = tem->sequence_rtl_expr;
3424   seq_stack = tem->next;
3425
3426   free (tem);
3427 }
3428
3429 /* Return 1 if currently emitting into a sequence.  */
3430
3431 int
3432 in_sequence_p ()
3433 {
3434   return seq_stack != 0;
3435 }
3436
3437 /* Generate a SEQUENCE rtx containing the insns already emitted
3438    to the current sequence.
3439
3440    This is how the gen_... function from a DEFINE_EXPAND
3441    constructs the SEQUENCE that it returns.  */
3442
3443 rtx
3444 gen_sequence ()
3445 {
3446   rtx result;
3447   rtx tem;
3448   int i;
3449   int len;
3450
3451   /* Count the insns in the chain.  */
3452   len = 0;
3453   for (tem = first_insn; tem; tem = NEXT_INSN (tem))
3454     len++;
3455
3456   /* If only one insn, return it rather than a SEQUENCE.
3457      (Now that we cache SEQUENCE expressions, it isn't worth special-casing
3458      the case of an empty list.)     
3459      We only return the pattern of an insn if its code is INSN and it
3460      has no notes.  This ensures that no information gets lost.  */
3461   if (len == 1
3462       && ! RTX_FRAME_RELATED_P (first_insn)
3463       && GET_CODE (first_insn) == INSN
3464       /* Don't throw away any reg notes. */
3465       && REG_NOTES (first_insn) == 0)
3466     {
3467       if (!ggc_p)
3468         {
3469           NEXT_INSN (first_insn) = free_insn;
3470           free_insn = first_insn;
3471         }
3472       return PATTERN (first_insn);
3473     }
3474
3475   /* Put them in a vector.  See if we already have a SEQUENCE of the
3476      appropriate length around.  */
3477   if (!ggc_p && len < SEQUENCE_RESULT_SIZE 
3478       && (result = sequence_result[len]) != 0)
3479     sequence_result[len] = 0;
3480   else
3481     {
3482       /* Ensure that this rtl goes in saveable_obstack, since we may
3483          cache it.  */
3484       push_obstacks_nochange ();
3485       rtl_in_saveable_obstack ();
3486       result = gen_rtx_SEQUENCE (VOIDmode, rtvec_alloc (len));
3487       pop_obstacks ();
3488     }
3489
3490   for (i = 0, tem = first_insn; tem; tem = NEXT_INSN (tem), i++)
3491     XVECEXP (result, 0, i) = tem;
3492
3493   return result;
3494 }
3495 \f
3496 /* Put the various virtual registers into REGNO_REG_RTX.  */
3497
3498 void
3499 init_virtual_regs (es)
3500      struct emit_status *es;
3501 {
3502   rtx *ptr = es->x_regno_reg_rtx;
3503   ptr[VIRTUAL_INCOMING_ARGS_REGNUM] = virtual_incoming_args_rtx;
3504   ptr[VIRTUAL_STACK_VARS_REGNUM] = virtual_stack_vars_rtx;
3505   ptr[VIRTUAL_STACK_DYNAMIC_REGNUM] = virtual_stack_dynamic_rtx;
3506   ptr[VIRTUAL_OUTGOING_ARGS_REGNUM] = virtual_outgoing_args_rtx;
3507   ptr[VIRTUAL_CFA_REGNUM] = virtual_cfa_rtx;
3508 }
3509
3510 void
3511 clear_emit_caches ()
3512 {
3513   int i;
3514
3515   /* Clear the start_sequence/gen_sequence cache.  */
3516   for (i = 0; i < SEQUENCE_RESULT_SIZE; i++)
3517     sequence_result[i] = 0;
3518   free_insn = 0;
3519 }
3520 \f
3521 /* Used by copy_insn_1 to avoid copying SCRATCHes more than once.  */
3522 static rtx copy_insn_scratch_in[MAX_RECOG_OPERANDS];
3523 static rtx copy_insn_scratch_out[MAX_RECOG_OPERANDS];
3524 static int copy_insn_n_scratches;
3525
3526 /* When an insn is being copied by copy_insn_1, this is nonzero if we have
3527    copied an ASM_OPERANDS.
3528    In that case, it is the original input-operand vector.  */
3529 static rtvec orig_asm_operands_vector;
3530
3531 /* When an insn is being copied by copy_insn_1, this is nonzero if we have
3532    copied an ASM_OPERANDS.
3533    In that case, it is the copied input-operand vector.  */
3534 static rtvec copy_asm_operands_vector;
3535
3536 /* Likewise for the constraints vector.  */
3537 static rtvec orig_asm_constraints_vector;
3538 static rtvec copy_asm_constraints_vector;
3539
3540 /* Recursively create a new copy of an rtx for copy_insn.
3541    This function differs from copy_rtx in that it handles SCRATCHes and
3542    ASM_OPERANDs properly.
3543    Normally, this function is not used directly; use copy_insn as front end.
3544    However, you could first copy an insn pattern with copy_insn and then use
3545    this function afterwards to properly copy any REG_NOTEs containing
3546    SCRATCHes.  */
3547
3548 rtx
3549 copy_insn_1 (orig)
3550      register rtx orig;
3551 {
3552   register rtx copy;
3553   register int i, j;
3554   register RTX_CODE code;
3555   register const char *format_ptr;
3556
3557   code = GET_CODE (orig);
3558
3559   switch (code)
3560     {
3561     case REG:
3562     case QUEUED:
3563     case CONST_INT:
3564     case CONST_DOUBLE:
3565     case SYMBOL_REF:
3566     case CODE_LABEL:
3567     case PC:
3568     case CC0:
3569     case ADDRESSOF:
3570       return orig;
3571
3572     case SCRATCH:
3573       for (i = 0; i < copy_insn_n_scratches; i++)
3574         if (copy_insn_scratch_in[i] == orig)
3575           return copy_insn_scratch_out[i];
3576       break;
3577
3578     case CONST:
3579       /* CONST can be shared if it contains a SYMBOL_REF.  If it contains
3580          a LABEL_REF, it isn't sharable.  */
3581       if (GET_CODE (XEXP (orig, 0)) == PLUS
3582           && GET_CODE (XEXP (XEXP (orig, 0), 0)) == SYMBOL_REF
3583           && GET_CODE (XEXP (XEXP (orig, 0), 1)) == CONST_INT)
3584         return orig;
3585       break;
3586       
3587       /* A MEM with a constant address is not sharable.  The problem is that
3588          the constant address may need to be reloaded.  If the mem is shared,
3589          then reloading one copy of this mem will cause all copies to appear
3590          to have been reloaded.  */
3591
3592     default:
3593       break;
3594     }
3595
3596   copy = rtx_alloc (code);
3597
3598   /* Copy the various flags, and other information.  We assume that
3599      all fields need copying, and then clear the fields that should
3600      not be copied.  That is the sensible default behavior, and forces
3601      us to explicitly document why we are *not* copying a flag.  */
3602   memcpy (copy, orig, sizeof (struct rtx_def) - sizeof (rtunion));
3603
3604   /* We do not copy the USED flag, which is used as a mark bit during
3605      walks over the RTL.  */
3606   copy->used = 0;
3607
3608   /* We do not copy JUMP, CALL, or FRAME_RELATED for INSNs.  */
3609   if (GET_RTX_CLASS (code) == 'i')
3610     {
3611       copy->jump = 0;
3612       copy->call = 0;
3613       copy->frame_related = 0;
3614     }
3615   
3616   format_ptr = GET_RTX_FORMAT (GET_CODE (copy));
3617
3618   for (i = 0; i < GET_RTX_LENGTH (GET_CODE (copy)); i++)
3619     {
3620       copy->fld[i] = orig->fld[i];
3621       switch (*format_ptr++)
3622         {
3623         case 'e':
3624           if (XEXP (orig, i) != NULL)
3625             XEXP (copy, i) = copy_insn_1 (XEXP (orig, i));
3626           break;
3627
3628         case 'E':
3629         case 'V':
3630           if (XVEC (orig, i) == orig_asm_constraints_vector)
3631             XVEC (copy, i) = copy_asm_constraints_vector;
3632           else if (XVEC (orig, i) == orig_asm_operands_vector)
3633             XVEC (copy, i) = copy_asm_operands_vector;
3634           else if (XVEC (orig, i) != NULL)
3635             {
3636               XVEC (copy, i) = rtvec_alloc (XVECLEN (orig, i));
3637               for (j = 0; j < XVECLEN (copy, i); j++)
3638                 XVECEXP (copy, i, j) = copy_insn_1 (XVECEXP (orig, i, j));
3639             }
3640           break;
3641
3642         case 'b':
3643           {
3644             bitmap new_bits = BITMAP_OBSTACK_ALLOC (rtl_obstack);
3645             bitmap_copy (new_bits, XBITMAP (orig, i));
3646             XBITMAP (copy, i) = new_bits;
3647             break;
3648           }
3649
3650         case 't':
3651         case 'w':
3652         case 'i':
3653         case 's':
3654         case 'S':
3655         case 'u':
3656         case '0':
3657           /* These are left unchanged.  */
3658           break;
3659
3660         default:
3661           abort ();
3662         }
3663     }
3664
3665   if (code == SCRATCH)
3666     {
3667       i = copy_insn_n_scratches++;
3668       if (i >= MAX_RECOG_OPERANDS)
3669         abort ();
3670       copy_insn_scratch_in[i] = orig;
3671       copy_insn_scratch_out[i] = copy;
3672     }
3673   else if (code == ASM_OPERANDS)
3674     {
3675       orig_asm_operands_vector = XVEC (orig, 3);
3676       copy_asm_operands_vector = XVEC (copy, 3);
3677       orig_asm_constraints_vector = XVEC (orig, 4);
3678       copy_asm_constraints_vector = XVEC (copy, 4);
3679     }
3680
3681   return copy;
3682 }
3683
3684 /* Create a new copy of an rtx.
3685    This function differs from copy_rtx in that it handles SCRATCHes and
3686    ASM_OPERANDs properly.
3687    INSN doesn't really have to be a full INSN; it could be just the
3688    pattern.  */
3689 rtx
3690 copy_insn (insn)
3691      rtx insn;
3692 {
3693   copy_insn_n_scratches = 0;
3694   orig_asm_operands_vector = 0;
3695   orig_asm_constraints_vector = 0;
3696   copy_asm_operands_vector = 0;
3697   copy_asm_constraints_vector = 0;
3698   return copy_insn_1 (insn);
3699 }
3700
3701 /* Initialize data structures and variables in this file
3702    before generating rtl for each function.  */
3703
3704 void
3705 init_emit ()
3706 {
3707   struct function *f = cfun;
3708
3709   f->emit = (struct emit_status *) xmalloc (sizeof (struct emit_status));
3710   first_insn = NULL;
3711   last_insn = NULL;
3712   seq_rtl_expr = NULL;
3713   cur_insn_uid = 1;
3714   reg_rtx_no = LAST_VIRTUAL_REGISTER + 1;
3715   last_linenum = 0;
3716   last_filename = 0;
3717   first_label_num = label_num;
3718   last_label_num = 0;
3719   seq_stack = NULL;
3720
3721   clear_emit_caches ();
3722
3723   /* Init the tables that describe all the pseudo regs.  */
3724
3725   f->emit->regno_pointer_flag_length = LAST_VIRTUAL_REGISTER + 101;
3726
3727   f->emit->regno_pointer_flag 
3728     = (char *) xcalloc (f->emit->regno_pointer_flag_length, sizeof (char));
3729
3730   f->emit->regno_pointer_align
3731     = (char *) xcalloc (f->emit->regno_pointer_flag_length,
3732                         sizeof (char));
3733
3734   regno_reg_rtx 
3735     = (rtx *) xcalloc (f->emit->regno_pointer_flag_length * sizeof (rtx),
3736                        sizeof (rtx));
3737
3738   /* Put copies of all the virtual register rtx into regno_reg_rtx.  */
3739   init_virtual_regs (f->emit);
3740
3741   /* Indicate that the virtual registers and stack locations are
3742      all pointers.  */
3743   REGNO_POINTER_FLAG (STACK_POINTER_REGNUM) = 1;
3744   REGNO_POINTER_FLAG (FRAME_POINTER_REGNUM) = 1;
3745   REGNO_POINTER_FLAG (HARD_FRAME_POINTER_REGNUM) = 1;
3746   REGNO_POINTER_FLAG (ARG_POINTER_REGNUM) = 1;
3747
3748   REGNO_POINTER_FLAG (VIRTUAL_INCOMING_ARGS_REGNUM) = 1;
3749   REGNO_POINTER_FLAG (VIRTUAL_STACK_VARS_REGNUM) = 1;
3750   REGNO_POINTER_FLAG (VIRTUAL_STACK_DYNAMIC_REGNUM) = 1;
3751   REGNO_POINTER_FLAG (VIRTUAL_OUTGOING_ARGS_REGNUM) = 1;
3752   REGNO_POINTER_FLAG (VIRTUAL_CFA_REGNUM) = 1;
3753
3754 #ifdef STACK_BOUNDARY
3755   REGNO_POINTER_ALIGN (STACK_POINTER_REGNUM) = STACK_BOUNDARY / BITS_PER_UNIT;
3756   REGNO_POINTER_ALIGN (FRAME_POINTER_REGNUM) = STACK_BOUNDARY / BITS_PER_UNIT;
3757   REGNO_POINTER_ALIGN (HARD_FRAME_POINTER_REGNUM)
3758     = STACK_BOUNDARY / BITS_PER_UNIT;
3759   REGNO_POINTER_ALIGN (ARG_POINTER_REGNUM) = STACK_BOUNDARY / BITS_PER_UNIT;
3760
3761   REGNO_POINTER_ALIGN (VIRTUAL_INCOMING_ARGS_REGNUM)
3762     = STACK_BOUNDARY / BITS_PER_UNIT;
3763   REGNO_POINTER_ALIGN (VIRTUAL_STACK_VARS_REGNUM)
3764     = STACK_BOUNDARY / BITS_PER_UNIT;
3765   REGNO_POINTER_ALIGN (VIRTUAL_STACK_DYNAMIC_REGNUM)
3766     = STACK_BOUNDARY / BITS_PER_UNIT;
3767   REGNO_POINTER_ALIGN (VIRTUAL_OUTGOING_ARGS_REGNUM)
3768     = STACK_BOUNDARY / BITS_PER_UNIT;
3769   REGNO_POINTER_ALIGN (VIRTUAL_CFA_REGNUM) = UNITS_PER_WORD;
3770 #endif
3771
3772 #ifdef INIT_EXPANDERS
3773   INIT_EXPANDERS;
3774 #endif
3775 }
3776
3777 /* Mark SS for GC.  */
3778
3779 static void
3780 mark_sequence_stack (ss)
3781      struct sequence_stack *ss;
3782 {
3783   while (ss)
3784     {
3785       ggc_mark_rtx (ss->first);
3786       ggc_mark_tree (ss->sequence_rtl_expr);
3787       ss = ss->next;
3788     }
3789 }
3790
3791 /* Mark ES for GC.  */
3792
3793 void
3794 mark_emit_status (es)
3795      struct emit_status *es;
3796 {
3797   rtx *r;
3798   int i;
3799
3800   if (es == 0)
3801     return;
3802
3803   for (i = es->regno_pointer_flag_length, r = es->x_regno_reg_rtx;
3804        i > 0; --i, ++r)
3805     ggc_mark_rtx (*r);
3806
3807   mark_sequence_stack (es->sequence_stack);
3808   ggc_mark_tree (es->sequence_rtl_expr);
3809   ggc_mark_rtx (es->x_first_insn);
3810 }
3811
3812 /* Create some permanent unique rtl objects shared between all functions.
3813    LINE_NUMBERS is nonzero if line numbers are to be generated.  */
3814
3815 void
3816 init_emit_once (line_numbers)
3817      int line_numbers;
3818 {
3819   int i;
3820   enum machine_mode mode;
3821   enum machine_mode double_mode;
3822
3823   no_line_numbers = ! line_numbers;
3824
3825   /* Compute the word and byte modes.  */
3826
3827   byte_mode = VOIDmode;
3828   word_mode = VOIDmode;
3829   double_mode = VOIDmode;
3830
3831   for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); mode != VOIDmode;
3832        mode = GET_MODE_WIDER_MODE (mode))
3833     {
3834       if (GET_MODE_BITSIZE (mode) == BITS_PER_UNIT
3835           && byte_mode == VOIDmode)
3836         byte_mode = mode;
3837
3838       if (GET_MODE_BITSIZE (mode) == BITS_PER_WORD
3839           && word_mode == VOIDmode)
3840         word_mode = mode;
3841     }
3842
3843 #ifndef DOUBLE_TYPE_SIZE
3844 #define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
3845 #endif
3846
3847   for (mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT); mode != VOIDmode;
3848        mode = GET_MODE_WIDER_MODE (mode))
3849     {
3850       if (GET_MODE_BITSIZE (mode) == DOUBLE_TYPE_SIZE
3851           && double_mode == VOIDmode)
3852         double_mode = mode;
3853     }
3854
3855   ptr_mode = mode_for_size (POINTER_SIZE, GET_MODE_CLASS (Pmode), 0);
3856
3857   /* Assign register numbers to the globally defined register rtx.
3858      This must be done at runtime because the register number field
3859      is in a union and some compilers can't initialize unions.  */
3860
3861   pc_rtx = gen_rtx (PC, VOIDmode);
3862   cc0_rtx = gen_rtx (CC0, VOIDmode);
3863   stack_pointer_rtx = gen_rtx_raw_REG (Pmode, STACK_POINTER_REGNUM);
3864   frame_pointer_rtx = gen_rtx_raw_REG (Pmode, FRAME_POINTER_REGNUM);
3865   if (hard_frame_pointer_rtx == 0)
3866     hard_frame_pointer_rtx = gen_rtx_raw_REG (Pmode, 
3867                                               HARD_FRAME_POINTER_REGNUM);
3868   if (arg_pointer_rtx == 0)
3869     arg_pointer_rtx = gen_rtx_raw_REG (Pmode, ARG_POINTER_REGNUM);
3870   virtual_incoming_args_rtx = 
3871     gen_rtx_raw_REG (Pmode, VIRTUAL_INCOMING_ARGS_REGNUM);
3872   virtual_stack_vars_rtx = 
3873     gen_rtx_raw_REG (Pmode, VIRTUAL_STACK_VARS_REGNUM);
3874   virtual_stack_dynamic_rtx = 
3875     gen_rtx_raw_REG (Pmode, VIRTUAL_STACK_DYNAMIC_REGNUM);
3876   virtual_outgoing_args_rtx = 
3877     gen_rtx_raw_REG (Pmode, VIRTUAL_OUTGOING_ARGS_REGNUM); 
3878   virtual_cfa_rtx = gen_rtx_raw_REG (Pmode, VIRTUAL_CFA_REGNUM);
3879
3880   /* These rtx must be roots if GC is enabled.  */
3881   if (ggc_p)
3882     ggc_add_rtx_root (global_rtl, GR_MAX);
3883
3884 #ifdef INIT_EXPANDERS
3885   /* This is to initialize save_machine_status and restore_machine_status before
3886      the first call to push_function_context_to.  This is needed by the Chill
3887      front end which calls push_function_context_to before the first cal to
3888      init_function_start.  */
3889   INIT_EXPANDERS;
3890 #endif
3891
3892   /* Create the unique rtx's for certain rtx codes and operand values.  */
3893
3894   /* Don't use gen_rtx here since gen_rtx in this case
3895      tries to use these variables.  */
3896   for (i = - MAX_SAVED_CONST_INT; i <= MAX_SAVED_CONST_INT; i++)
3897     const_int_rtx[i + MAX_SAVED_CONST_INT] = 
3898       gen_rtx_raw_CONST_INT (VOIDmode, i);
3899   if (ggc_p)
3900     ggc_add_rtx_root (const_int_rtx, 2 * MAX_SAVED_CONST_INT + 1);
3901
3902   if (STORE_FLAG_VALUE >= - MAX_SAVED_CONST_INT
3903       && STORE_FLAG_VALUE <= MAX_SAVED_CONST_INT)
3904     const_true_rtx = const_int_rtx[STORE_FLAG_VALUE + MAX_SAVED_CONST_INT];
3905   else
3906     const_true_rtx = gen_rtx_CONST_INT (VOIDmode, STORE_FLAG_VALUE);
3907
3908   dconst0 = REAL_VALUE_ATOF ("0", double_mode);
3909   dconst1 = REAL_VALUE_ATOF ("1", double_mode);
3910   dconst2 = REAL_VALUE_ATOF ("2", double_mode);
3911   dconstm1 = REAL_VALUE_ATOF ("-1", double_mode);
3912
3913   for (i = 0; i <= 2; i++)
3914     {
3915       for (mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT); mode != VOIDmode;
3916            mode = GET_MODE_WIDER_MODE (mode))
3917         {
3918           rtx tem = rtx_alloc (CONST_DOUBLE);
3919           union real_extract u;
3920
3921           bzero ((char *) &u, sizeof u);  /* Zero any holes in a structure.  */
3922           u.d = i == 0 ? dconst0 : i == 1 ? dconst1 : dconst2;
3923
3924           bcopy ((char *) &u, (char *) &CONST_DOUBLE_LOW (tem), sizeof u);
3925           CONST_DOUBLE_MEM (tem) = cc0_rtx;
3926           PUT_MODE (tem, mode);
3927
3928           const_tiny_rtx[i][(int) mode] = tem;
3929         }
3930
3931       const_tiny_rtx[i][(int) VOIDmode] = GEN_INT (i);
3932
3933       for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); mode != VOIDmode;
3934            mode = GET_MODE_WIDER_MODE (mode))
3935         const_tiny_rtx[i][(int) mode] = GEN_INT (i);
3936
3937       for (mode = GET_CLASS_NARROWEST_MODE (MODE_PARTIAL_INT);
3938            mode != VOIDmode;
3939            mode = GET_MODE_WIDER_MODE (mode))
3940         const_tiny_rtx[i][(int) mode] = GEN_INT (i);
3941     }
3942
3943   for (mode = CCmode; mode < MAX_MACHINE_MODE; ++mode)
3944     if (GET_MODE_CLASS (mode) == MODE_CC)
3945       const_tiny_rtx[0][(int) mode] = const0_rtx;
3946
3947   ggc_add_rtx_root (&const_tiny_rtx[0][0], sizeof(const_tiny_rtx)/sizeof(rtx));
3948   ggc_add_rtx_root (&const_true_rtx, 1);
3949
3950 #ifdef RETURN_ADDRESS_POINTER_REGNUM
3951   return_address_pointer_rtx
3952     = gen_rtx_raw_REG (Pmode, RETURN_ADDRESS_POINTER_REGNUM);
3953 #endif
3954
3955 #ifdef STRUCT_VALUE
3956   struct_value_rtx = STRUCT_VALUE;
3957 #else
3958   struct_value_rtx = gen_rtx_REG (Pmode, STRUCT_VALUE_REGNUM);
3959 #endif
3960
3961 #ifdef STRUCT_VALUE_INCOMING
3962   struct_value_incoming_rtx = STRUCT_VALUE_INCOMING;
3963 #else
3964 #ifdef STRUCT_VALUE_INCOMING_REGNUM
3965   struct_value_incoming_rtx
3966     = gen_rtx_REG (Pmode, STRUCT_VALUE_INCOMING_REGNUM);
3967 #else
3968   struct_value_incoming_rtx = struct_value_rtx;
3969 #endif
3970 #endif
3971
3972 #ifdef STATIC_CHAIN_REGNUM
3973   static_chain_rtx = gen_rtx_REG (Pmode, STATIC_CHAIN_REGNUM);
3974
3975 #ifdef STATIC_CHAIN_INCOMING_REGNUM
3976   if (STATIC_CHAIN_INCOMING_REGNUM != STATIC_CHAIN_REGNUM)
3977     static_chain_incoming_rtx
3978       = gen_rtx_REG (Pmode, STATIC_CHAIN_INCOMING_REGNUM);
3979   else
3980 #endif
3981     static_chain_incoming_rtx = static_chain_rtx;
3982 #endif
3983
3984 #ifdef STATIC_CHAIN
3985   static_chain_rtx = STATIC_CHAIN;
3986
3987 #ifdef STATIC_CHAIN_INCOMING
3988   static_chain_incoming_rtx = STATIC_CHAIN_INCOMING;
3989 #else
3990   static_chain_incoming_rtx = static_chain_rtx;
3991 #endif
3992 #endif
3993
3994 #ifdef PIC_OFFSET_TABLE_REGNUM
3995   pic_offset_table_rtx = gen_rtx_REG (Pmode, PIC_OFFSET_TABLE_REGNUM);
3996 #endif
3997
3998   ggc_add_rtx_root (&pic_offset_table_rtx, 1);
3999   ggc_add_rtx_root (&struct_value_rtx, 1);
4000   ggc_add_rtx_root (&struct_value_incoming_rtx, 1);
4001   ggc_add_rtx_root (&static_chain_rtx, 1);
4002   ggc_add_rtx_root (&static_chain_incoming_rtx, 1);
4003   ggc_add_rtx_root (&return_address_pointer_rtx, 1);
4004 }
4005 \f
4006 /* Query and clear/ restore no_line_numbers.  This is used by the
4007    switch / case handling in stmt.c to give proper line numbers in
4008    warnings about unreachable code.  */
4009
4010 int
4011 force_line_numbers ()
4012 {
4013   int old = no_line_numbers;
4014
4015   no_line_numbers = 0;
4016   if (old)
4017     force_next_line_note ();
4018   return old;
4019 }
4020
4021 void
4022 restore_line_number_status (old_value)
4023      int old_value;
4024 {
4025   no_line_numbers = old_value;
4026 }