OSDN Git Service

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